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

import com.jeesharp.business.modules.finance.profitsharing.dto.ProfitSharingReturnSaveDTO;
import com.jeesharp.business.modules.finance.profitsharing.entity.ProfitSharingReturn;
import com.jeesharp.business.modules.finance.profitsharing.enums.ProfitSharingReturnStatusEnum;
import com.jeesharp.business.modules.finance.profitsharing.vo.ProfitSharingReturnInfoVO;
import com.jeesharp.business.modules.finance.profitsharing.vo.ProfitSharingReturnListVO;
import com.jeesharp.business.modules.finance.profitsharing.vo.ProfitSharingReturnQueryVO;
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 ProfitSharingReturnConvert extends BasePojoConvert<ProfitSharingReturn, ProfitSharingReturnSaveDTO,
        ProfitSharingReturnInfoVO, ProfitSharingReturnListVO, ProfitSharingReturnQueryVO> {

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

    @Mapping(target = "statusName", source = "status", qualifiedByName = "statusToName")
    @Mapping(target = "orderNo", ignore = true)
    @Override
    ProfitSharingReturnInfoVO toInfoVO(ProfitSharingReturn entity);

    @Mapping(target = "statusName", source = "status", qualifiedByName = "statusToName")
    @Mapping(target = "orderNo", ignore = true)
    @Mapping(target = "sharingNo", ignore = true)
    ProfitSharingReturnListVO toListSingleVO(ProfitSharingReturn entity);

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