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

import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
import cn.newfeifan.mall.module.distri.controller.admin.shopsettlement.excelvo.ShopSettlementExcelRespVO;
import cn.newfeifan.mall.module.distri.controller.admin.shopsettlement.vo.ShopSettlementRespVO;
import org.mapstruct.Mapper;

import java.util.List;

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

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

    default List<ShopSettlementExcelRespVO> convertList(List<ShopSettlementRespVO> list){
        List<ShopSettlementExcelRespVO> respVOList = BeanUtils.toBean(list, ShopSettlementExcelRespVO.class);
        for (ShopSettlementExcelRespVO respVO : respVOList) {
            respVO.setPlatformCollectionAmount(respVO.getPlatformCollectionAmount() / ONE_HUNDRED);
            respVO.setShopAmount(respVO.getShopAmount() / MILLION);
            respVO.setShopConsumptionPoints(respVO.getShopConsumptionPoints() / MILLION);
            respVO.setShopTotalHighAmount(Math.floor(respVO.getShopTotalHighAmount() / ONE_HUNDRED * ONE_HUNDRED) / ONE_HUNDRED);       // 将小数点后的位数截断，保留两位但不进行四舍五入
        }
        return respVOList;
    }
}
