package cn.newfeifan.mall.module.distri.convert.dailybill;

import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
import cn.newfeifan.mall.module.distri.controller.admin.dailybill.excelvo.DailyBillExcelRespVO;
import cn.newfeifan.mall.module.distri.controller.admin.dailybill.vo.DailyBillRespVO;
import org.mapstruct.Mapper;

import java.util.List;

import static cn.newfeifan.mall.module.distri.constant.DistriConstants.*;

@Mapper
public interface DailyBillConvert {
    DailyBillConvert INSTANCE = org.mapstruct.factory.Mappers.getMapper(DailyBillConvert.class);

    default List<DailyBillExcelRespVO> convertList(List<DailyBillRespVO> list) {
        List<DailyBillExcelRespVO> respVOList = BeanUtils.toBean(list, DailyBillExcelRespVO.class);
        for (DailyBillExcelRespVO respVO : respVOList) {
            respVO.setPrice(respVO.getPrice() / ONE_HUNDRED);
            respVO.setReceivedPrice(respVO.getReceivedPrice() / ONE_HUNDRED);
            respVO.setRefundPrice(respVO.getRefundPrice() / ONE_HUNDRED);
            respVO.setIntegral(respVO.getIntegral() / MILLION);
            respVO.setReceivedIntegral(respVO.getReceivedIntegral() / MILLION);
            respVO.setRefundIntegral(respVO.getRefundIntegral() / MILLION);
            respVO.setConsumptionPoints(respVO.getConsumptionPoints() / MILLION);
            respVO.setReceivedConsumptionPoints(respVO.getReceivedConsumptionPoints() / MILLION);
            respVO.setRefundConsumptionPoints(respVO.getRefundConsumptionPoints() / MILLION);
        }

        return respVOList;
    }
}
