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

import com.jeesharp.business.modules.finance.payrefund.dto.PayRefundOrderSaveDTO;
import com.jeesharp.business.modules.finance.payrefund.entity.PayRefundOrder;
import com.jeesharp.business.modules.finance.payrefund.enums.PayRefundOrderStatusEnum;
import com.jeesharp.business.modules.finance.payrefund.vo.PayRefundOrderInfoVO;
import com.jeesharp.business.modules.finance.payrefund.vo.PayRefundOrderListVO;
import com.jeesharp.business.modules.finance.payrefund.vo.PayRefundOrderQueryVO;
import com.jeesharp.business.modules.finance.paymentrecord.enums.PayRecordBizSceneEnum;
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 转换器。
 *
 * @author jeesharp
 * @since 2026-06-11
 */
@Mapper
public interface PayRefundOrderConvert extends BasePojoConvert<PayRefundOrder, PayRefundOrderSaveDTO,
        PayRefundOrderInfoVO, PayRefundOrderListVO, PayRefundOrderQueryVO> {

    // SaveDTO 占位，管理端暂不开放手工编辑退款单

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

    @Mapping(target = "statusName", source = "status", qualifiedByName = "statusToName")
    @Mapping(target = "bizSceneName", source = "bizScene", qualifiedByName = "bizSceneToName")
    @Override
    PayRefundOrderInfoVO toInfoVO(PayRefundOrder entity);

    @Mapping(target = "statusName", source = "status", qualifiedByName = "statusToName")
    @Mapping(target = "bizSceneName", source = "bizScene", qualifiedByName = "bizSceneToName")
    PayRefundOrderListVO toListSingleVO(PayRefundOrder entity);

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

    @Named("bizSceneToName")
    default String bizSceneToName(String bizScene) {
        return PayRecordBizSceneEnum.getDescByCode(bizScene);
    }
}
