package com.jeesharp.business.modules.finance.merchantreceivable.convert;

import com.jeesharp.business.modules.finance.merchantreceivable.dto.MerchantReceivableSaveDTO;
import com.jeesharp.business.modules.finance.merchantreceivable.entity.MerchantReceivable;
import com.jeesharp.business.modules.finance.merchantreceivable.enums.MerchantReceivableEntryTypeEnum;
import com.jeesharp.business.modules.finance.merchantreceivable.vo.MerchantReceivableExportVO;
import com.jeesharp.business.modules.finance.merchantreceivable.vo.MerchantReceivableInfoVO;
import com.jeesharp.business.modules.finance.merchantreceivable.vo.MerchantReceivableListVO;
import com.jeesharp.business.modules.finance.merchantreceivable.vo.MerchantReceivableQueryVO;
import com.jeesharp.framework.common.pojo.convert.BasePojoConvert;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 商户应收账 MapStruct 转换器。
 *
 * @author jeesharp
 * @since 2026-06-11
 */
@Mapper
public interface MerchantReceivableConvert extends BasePojoConvert<MerchantReceivable, MerchantReceivableSaveDTO,
        MerchantReceivableInfoVO, MerchantReceivableListVO, MerchantReceivableQueryVO> {

    MerchantReceivableConvert INSTANCE = Mappers.getMapper(MerchantReceivableConvert.class);

    @Mapping(target = "entryTypeName", source = "entryType", qualifiedByName = "entryTypeToName")
    @Mapping(target = "orderNo", ignore = true)
    @Mapping(target = "batchNo", ignore = true)
    @Override
    MerchantReceivableInfoVO toInfoVO(MerchantReceivable entity);

    @Mapping(target = "entryTypeName", source = "entryType", qualifiedByName = "entryTypeToName")
    @Mapping(target = "orderNo", ignore = true)
    @Mapping(target = "batchNo", ignore = true)
    MerchantReceivableListVO toListSingleVO(MerchantReceivable entity);

    @Mapping(target = "entryTypeName", source = "entryType", qualifiedByName = "entryTypeToName")
    @Mapping(target = "orderNo", ignore = true)
    @Mapping(target = "batchNo", ignore = true)
    MerchantReceivableExportVO toExportVO(MerchantReceivable entity);

    List<MerchantReceivableExportVO> toExportVOList(List<MerchantReceivable> list);

    @Named("entryTypeToName")
    default String entryTypeToName(String entryType) {
        return MerchantReceivableEntryTypeEnum.getDescByValue(entryType);
    }
}
