package com.jeesharp.business.modules.pay.payfundwithdraw.convert;

import com.jeesharp.business.modules.pay.payfundbalance.enums.PayFundAccountTypeEnum;
import com.jeesharp.business.modules.pay.payfundwithdraw.entity.PayFundWithdraw;
import com.jeesharp.business.modules.pay.payfundwithdraw.enums.PayFundWithdrawScopeEnum;
import com.jeesharp.business.modules.pay.payfundwithdraw.enums.PayFundWithdrawStatusEnum;
import com.jeesharp.business.modules.pay.payfundwithdraw.vo.PayFundWithdrawInfoVO;
import com.jeesharp.business.modules.pay.payfundwithdraw.vo.PayFundWithdrawListVO;
import com.jeesharp.business.modules.pay.payfundwithdraw.vo.PayFundWithdrawSubmitVO;
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-12
 */
@Mapper
public interface PayFundWithdrawConvert {

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

    @Mapping(target = "scopeTypeName", source = "scopeType", qualifiedByName = "scopeToName")
    @Mapping(target = "accountTypeName", source = "accountType", qualifiedByName = "accountTypeToName")
    @Mapping(target = "withdrawStatusName", source = "withdrawStatus", qualifiedByName = "statusToName")
    PayFundWithdrawListVO toListVO(PayFundWithdraw entity);

    List<PayFundWithdrawListVO> toListVOList(List<PayFundWithdraw> list);

    @Mapping(target = "scopeTypeName", source = "scopeType", qualifiedByName = "scopeToName")
    @Mapping(target = "accountTypeName", source = "accountType", qualifiedByName = "accountTypeToName")
    @Mapping(target = "withdrawStatusName", source = "withdrawStatus", qualifiedByName = "statusToName")
    PayFundWithdrawInfoVO toInfoVO(PayFundWithdraw entity);

    @Mapping(target = "withdrawStatusName", source = "withdrawStatus", qualifiedByName = "statusToName")
    PayFundWithdrawSubmitVO toSubmitVO(PayFundWithdraw entity);

    @Named("scopeToName")
    default String scopeToName(String scopeType) {
        return PayFundWithdrawScopeEnum.getDescByValue(scopeType);
    }

    @Named("accountTypeToName")
    default String accountTypeToName(String accountType) {
        return PayFundAccountTypeEnum.getDescByValue(accountType);
    }

    @Named("statusToName")
    default String statusToName(String withdrawStatus) {
        return PayFundWithdrawStatusEnum.getDescByValue(withdrawStatus);
    }
}
