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

import com.jeesharp.business.modules.finance.merchantsettle.dto.MerchantSettleConfigSaveDTO;
import com.jeesharp.business.modules.finance.merchantsettle.entity.MerchantSettleConfig;
import com.jeesharp.business.modules.finance.merchantsettle.enums.MerchantSettleConfigStatusEnum;
import com.jeesharp.business.modules.finance.merchantsettle.enums.SettleModeEnum;
import com.jeesharp.business.modules.finance.merchantsettle.vo.MerchantSettleConfigInfoVO;
import com.jeesharp.business.modules.finance.merchantsettle.vo.MerchantSettleConfigListVO;
import com.jeesharp.business.modules.finance.merchantsettle.vo.MerchantSettleConfigQueryVO;
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;

/**
 * 商户结算配置 MapStruct 转换器，继承 {@code BasePojoConvert} 并补充枚举展示字段映射。
 *
 * @author jeesharp
 * @since 2026-06-11
 */
@Mapper
public interface MerchantSettleConfigConvert extends BasePojoConvert<MerchantSettleConfig, MerchantSettleConfigSaveDTO,
        MerchantSettleConfigInfoVO, MerchantSettleConfigListVO, MerchantSettleConfigQueryVO> {

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

    @Mapping(target = "settleModeName", source = "settleMode", qualifiedByName = "settleModeToName")
    @Mapping(target = "statusName", source = "status", qualifiedByName = "statusToName")
    @Override
    MerchantSettleConfigInfoVO toInfoVO(MerchantSettleConfig entity);

    @Mapping(target = "settleModeName", source = "settleMode", qualifiedByName = "settleModeToName")
    @Mapping(target = "statusName", source = "status", qualifiedByName = "statusToName")
    MerchantSettleConfigListVO toListSingleVO(MerchantSettleConfig entity);

    @Named("settleModeToName")
    default String settleModeToName(String settleMode) {
        return SettleModeEnum.getDescByValue(settleMode);
    }

    @Named("statusToName")
    default String statusToName(Integer status) {
        return MerchantSettleConfigStatusEnum.getDescByValue(status);
    }
}
