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.setIntegral(respVO.getIntegral() / MILLION);
            respVO.setReceivedIntegral(respVO.getReceivedIntegral() / MILLION);
            respVO.setRefundIntegral(respVO.getRefundIntegral() / MILLION);
        }

        return respVOList;
    }
}
