| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.STATIC_BONUS.getType(), DataDictionaryEnum.STATIC_BONUS.getCode()); |
| | | BigDecimal perProfit = totalIncome.multiply(new BigDecimal(dic.getValue()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP)); |
| | | |
| | | Map<Long, List<Map<String, Object>>> map = new HashMap<>(); |
| | | Map<Long, BigDecimal> goodsProp = new HashMap<>(); |
| | | for (MallMember member : members) { |
| | | List<MallGoods> goodsList = mallGoodsMapper.selectOrderGoodsList(member.getId(), profitDate); |
| | | |
| | |
| | | continue; |
| | | } |
| | | |
| | | BigDecimal goodsProfit = goods.getStaticProp().multiply(perProfit); |
| | | |
| | | int reduce = walletService.reduce(goodsProfit, member.getId(), "score"); |
| | | if (reduce == 2) { |
| | | break; |
| | | List<Map<String, Object>> list = map.get(goods.getId()); |
| | | if (CollUtil.isEmpty(list)) { |
| | | list = new ArrayList<>(); |
| | | } |
| | | |
| | | walletService.add(goodsProfit, member.getId(), "commission"); |
| | | moneyFlowService.addMoneyFlow(member.getId(), goodsProfit, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), goods.getOrderNo(), FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(member.getId(), goodsProfit.negate(), MoneyFlowTypeEnum.STATIC_BONUS.getValue(), goods.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | Map<String, Object> listItem = new HashMap<>(); |
| | | listItem.put("memberId", member.getId()); |
| | | listItem.put("orderNo", goods.getOrderNo()); |
| | | list.add(listItem); |
| | | |
| | | map.put(goods.getId(), list); |
| | | goodsProp.put(goods.getId(), goods.getStaticProp()); |
| | | } |
| | | } |
| | | |
| | | if (!map.isEmpty()) { |
| | | for (Map.Entry<Long, List<Map<String, Object>>> entry : map.entrySet()) { |
| | | List<Map<String, Object>> list = entry.getValue(); |
| | | BigDecimal staticProfit = goodsProp.get(entry.getKey()).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).multiply(perProfit); |
| | | BigDecimal preStaticProfit = staticProfit.divide(new BigDecimal(list.size()), 2, RoundingMode.HALF_UP); |
| | | |
| | | for (Map<String, Object> item : list) { |
| | | Long memberId = (Long) item.get("memberId"); |
| | | String orderNo = (String) item.get("orderNo"); |
| | | |
| | | int reduce = walletService.reduce(preStaticProfit, memberId, "score"); |
| | | if (reduce == 2) { |
| | | break; |
| | | } |
| | | |
| | | walletService.add(preStaticProfit, memberId, "commission"); |
| | | moneyFlowService.addMoneyFlow(memberId, preStaticProfit, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderNo, FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(memberId, preStaticProfit.negate(), MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderNo, FlowTypeEnum.SCORE.getValue()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.RANK_BONUS.getType(), DataDictionaryEnum.RANK_BONUS.getCode()); |
| | | |
| | | |
| | | BigDecimal rankBonusTotal = new BigDecimal(dic.getValue()).divide(totalIncome, 2, RoundingMode.HALF_UP); |
| | | BigDecimal rankBonusTotal = totalIncome.multiply(new BigDecimal(dic.getValue()).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP)); |
| | | BigDecimal preBonus = rankBonusTotal.divide(BigDecimal.valueOf(100),2 , RoundingMode.HALF_UP); |
| | | |
| | | int i = 0; |