fwq
2024-10-10 33b85f849916efd0d726fdfb76db937ef9679ad5
其-卡包支付,分配OCC金额,分配当前金额
2个文件已修改
721 ■■■■■ 已修改文件
phi_platform_common/src/main/java/com/hx/phip/tool/user/UserCardTool.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/init/impl/OrderInitServiceImpl.java 645 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/java/com/hx/phip/tool/user/UserCardTool.java
@@ -11,6 +11,7 @@
import com.hx.phiappt.model.cardItem.CardEquity;
import com.hx.phiappt.model.cardItem.CardItem;
import com.hx.phiappt.model.cardItem.CardItemInfo;
import com.hx.phiappt.model.consume.ConsumePayCard;
import com.hx.phiappt.model.order.OrderItem;
import com.hx.phiappt.model.refund.RefundRecordItem;
import com.hx.phiappt.model.user.UserCard;
@@ -556,9 +557,9 @@
    /**
     * 卡包权益支付过的数据-剔除退款的数据
     * 卡包支付过的数据-剔除退款的数据
     */
    public static List<UserCardPay> getCardBagEquityMoney(String cardEquityId, CardEquity cardEquity, CommonService commonService) {
    public static Map<String,Map<String,UserCardPay>> getCardBagUseList(String cardEquityId, CardEquity cardEquity, CommonService commonService) {
        SqlSentence sqlSentence = new SqlSentence();
        Map<String, Object> values = new HashMap<>();
        values.put("isDel", BaseEntity.NO);
@@ -567,15 +568,26 @@
        }
        values.put("cardEquityId", cardEquityId);
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT SUM(u.actualTotal) AS actualTotal,SUM(u.deductionMoney) AS deductionMoney,u.numberNo  ");
        sql.append(" FROM user_card_pay AS u  ");
        sql.append(" SELECT * FROM  user_card_pay AS u ");
        sql.append(" JOIN orders_total AS ot ON ot.id = u.orderId");
        sql.append(" WHERE u.isDel = #{m.isDel} AND u.cardEquityId = #{m.cardEquityId} ");
        //卡包要么全退,要么不退,这里查未退款的
        sql.append(" AND ot.isDel = #{m.isDel} AND ot.payStatus = 3 AND ot.refundStatus = -1 ");
        sql.append(" GROUP BY u.numberNo  ");
        sqlSentence.sqlSentence(sql.toString(), values);
        return commonService.selectList(UserCardPayMapper.class, sqlSentence);
        List<UserCardPay> cardBagUseList = commonService.selectList(UserCardPayMapper.class, sqlSentence);
        Map<String,Map<String,UserCardPay>> cardBuyMoneyMap = new HashMap<>();
        Map<String, UserCardPay> itemMap = null;
        if (cardBagUseList != null && cardBagUseList.size() > 0){
            for (UserCardPay userCardPay : cardBagUseList) {
                itemMap = cardBuyMoneyMap.get(userCardPay.getCardItemInfoId());
                if (itemMap == null){
                    itemMap = new HashMap<>();
                }
                itemMap.put(userCardPay.getConsumePayItemId(),userCardPay);
                cardBuyMoneyMap.put(userCardPay.getCardItemInfoId(),itemMap);
            }
        }
        return cardBuyMoneyMap;
    }
    /**获取卡项权益的条目数量*/
@@ -587,4 +599,56 @@
        return commonService.selectList(CardItemInfoMapper.class,sqlSentence);
    }
    /**
     * 获取买卡单数据-已分配的OCC
     * @return <卡项,支付方式,数据>
     * */
    public static Map<String,Map<String,ConsumePayCard>> getCardBuyMoneyByItemId(String orderItemId,CommonService commonService) {
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
        values.put("orderItemId",orderItemId);
        values.put("commonType", ConsumePayCard.TYPE_CARD);
        sqlSentence.sqlSentence("SELECT * FROM consume_pay_card WHERE isDel = 0 AND orderItemId = #{m.orderItemId} AND commonType = #{m.commonType}",values);
        List<ConsumePayCard> consumePayCardList = commonService.selectOne(ConsumePayCardMapper.class,sqlSentence);
        Map<String,Map<String,ConsumePayCard>> totalMap = new HashMap<>();
        Map<String,ConsumePayCard> itemMap = null;
        if (consumePayCardList != null && consumePayCardList.size() > 0){
            for (ConsumePayCard consumePayCard : consumePayCardList) {
                itemMap = totalMap.get(consumePayCard.getUserCardId());
                if (itemMap == null){
                    itemMap = new HashMap<>();
                }
                itemMap.put(consumePayCard.getConsumePayItemId(),consumePayCard);
                totalMap.put(consumePayCard.getUserCardId(),itemMap);
            }
        }
        return totalMap;
    }
    /**
     * 获取买卡单数据-已分配的OCC
     * @return <权益或者条目,支付方式,数据>
     * */
    public static Map<String, Map<String, ConsumePayCard>> getCardDetailBuyMoneyByItemId(String commonId,String commonType, CommonService commonService) {
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
        values.put("commonId",commonId);
        values.put("commonType", ConsumePayCard.TYPE_EQU);
        sqlSentence.sqlSentence("SELECT * FROM consume_pay_card WHERE isDel = 0 AND commonId = #{m.commonId} AND commonType = #{m.commonType}",values);
        List<ConsumePayCard> consumePayCardList = commonService.selectOne(ConsumePayCardMapper.class,sqlSentence);
        Map<String,Map<String,ConsumePayCard>> totalMap = new HashMap<>();
        Map<String,ConsumePayCard> itemMap = null;
        if (consumePayCardList != null && consumePayCardList.size() > 0){
            for (ConsumePayCard consumePayCard : consumePayCardList) {
                itemMap = totalMap.get(consumePayCard.getCommonId());
                if (itemMap == null){
                    itemMap = new HashMap<>();
                }
                itemMap.put(consumePayCard.getConsumePayItemId(),consumePayCard);
                totalMap.put(consumePayCard.getCommonId(),itemMap);
            }
        }
        return totalMap;
    }
}
phi_platform_user/src/main/java/com/hx/phip/service/init/impl/OrderInitServiceImpl.java
@@ -15,6 +15,7 @@
import com.hx.phiappt.model.cardItem.CardItem;
import com.hx.phiappt.model.cardItem.CardItemInfo;
import com.hx.phiappt.model.consume.ConsumePay;
import com.hx.phiappt.model.consume.ConsumePayCard;
import com.hx.phiappt.model.consume.ConsumePayItem;
import com.hx.phiappt.model.consume.ConsumePayItemSon;
import com.hx.phiappt.model.coupon.CouponOrderDiscountLog;
@@ -1558,225 +1559,88 @@
        if (cardItem == null) {
            throw new TipsException("获取购买卡项订单数据失败[03],请联系管理员");
        }
        //买卡子单支付总数据
        List<PayMethodVo> groupByNumberNoList = refundMapper.getConsumePayOneGroupByNumberNo(orderItemBuy.getId());
        Map<String, PayMethodVo> groupByNumberNoMap = new HashMap<>();
        for (PayMethodVo payMethodVo : groupByNumberNoList) {
            //要注意可能买多张
            payMethodVo.setPayTotal(payMethodVo.getPayTotal().divide(new BigDecimal(orderItemBuy.getBuyNum()),2,RoundingMode.HALF_UP));
            payMethodVo.setDeductionMoney(payMethodVo.getDeductionMoney().divide(new BigDecimal(orderItemBuy.getBuyNum()),2,RoundingMode.HALF_UP));
            groupByNumberNoMap.put(payMethodVo.getNumberNo(), payMethodVo);
        }
        logger.info("买卡子单,支付数据总和:"+JSON.toJSONString(groupByNumberNoMap));
        //子单支付方式数据
        values.put("typeId", orderItemBuy.getId());
        sqlSentence.sqlSentence("SELECT * FROM consume_pay_item WHERE isDel = 0 AND typeId = #{m.typeId} ",values);
        List<ConsumePayItem> consumePayItemList = commonService.selectList(ConsumePayItemMapper.class,sqlSentence);
        for (ConsumePayItem consumePayItemVo : consumePayItemList) {
            //要注意可能买多张
            consumePayItemVo.setActualTotal(consumePayItemVo.getActualTotal().divide(new BigDecimal(orderItemBuy.getBuyNum()),2,RoundingMode.HALF_UP));
            consumePayItemVo.setDeductionMoney(consumePayItemVo.getDeductionMoney().divide(new BigDecimal(orderItemBuy.getBuyNum()),2,RoundingMode.HALF_UP));
        }
        logger.info("买卡子单,单卡的支付方式:"+JSON.toJSONString(consumePayItemList));
        Map<String,ConsumePayItem> consumePayItemMap = new HashMap<>();
        consumePayItemList.forEach(consumePayItem -> consumePayItemMap.put(consumePayItem.getId(),consumePayItem));
        logger.info("买卡子单,单卡的支付方式:"+JSON.toJSONString(consumePayItemMap));
        //卡项权益,支付方式编号,支付方式数据
        Map<String, Map<String, ConsumePayItem>> cardEquityMethodMap = new HashMap<>();
        Map<String, ConsumePayItem> methodMap = null;
        ConsumePayItem consumePayItem = null;
        //每个权益的总金额数据
        Map<String,CardEquity> cardEquityMapTotal = new HashMap<>();
        CardEquity cardEquity = null;
        //权益标识,是否是全部使用完,通过判断条目的最终剩余次数来看是不是最后一个
        Map<String, Boolean> cardEquityNumMap = new HashMap<>();
        //每个权益的金额数据(方法内部已排序,金额字段在shareMoney)
        List<CardEquity> cardEquityMoneyList = UserCardTool.getCardEquityMoneyList(null, cardItem, commonService);
        for (int i = 0; i < cardEquityMoneyList.size(); i++) {
            cardEquity = cardEquityMoneyList.get(i);
            cardEquityMapTotal.put(cardEquity.getId(), cardEquity);
            //每个权益的占比,如果是最后一个则占剩余的
            BigDecimal rate = null;
            if (i != cardEquityMoneyList.size() - 1) {
                rate = cardEquity.getShareMoney().divide(cardItem.getTotal(), 20, RoundingMode.HALF_UP);
            }
            logger.info("权益:{},权益占比卡项金额比例:{}",cardEquity.getId(),rate);
            //权益Map
            methodMap = cardEquityMethodMap.get(cardEquity.getId());
            if (methodMap == null) {
                methodMap = new HashMap<>();
            }
            //循环买卡的支付方式,封装每个权益的分配支付方式金额
            for (ConsumePayItem consumePayItemVo : consumePayItemList) {
                //获取该支付方式的总额
                PayMethodVo payMethodVo = groupByNumberNoMap.get(consumePayItemVo.getNumberNo());
                logger.info("循环:{},支付方式:{}",cardEquity.getId(),consumePayItemVo.getNumberNo());
                logger.info("支付金额:{},抵扣金额:{}",consumePayItemVo.getActualTotal(),consumePayItemVo.getDeductionMoney());
                logger.info("总额:{},总抵扣金额:{}",payMethodVo.getPayTotal(),payMethodVo.getDeductionMoney());
        //1.获取分摊的卡项数据<卡项,支付项标识,数据>
        Map<String, Map<String,ConsumePayCard>> buyTotalMap = UserCardTool.getCardBuyMoneyByItemId(orderItemBuy.getId(), commonService);
        logger.info("获取分摊的卡项数据:"+JSON.toJSONString(buyTotalMap));
        //1.获取当前卡分配的金额数据<支付项标识,卡项数据>
        Map<String,ConsumePayCard> cardBuyMoneyMap = getUserCardMoneyMap(buyTotalMap,userCard,orderItemBuy,consumePayItemList);
                //计算当前要分摊的金额
                BigDecimal actualTotal = BigDecimal.ZERO;
                BigDecimal deductionMoney = BigDecimal.ZERO;
                if (rate != null) {
                    actualTotal = consumePayItemVo.getActualTotal().multiply(rate).setScale(2, RoundingMode.DOWN);
                    deductionMoney = consumePayItemVo.getDeductionMoney().multiply(rate).setScale(2, RoundingMode.DOWN);
                } else {
                    //最后一个拿剩余的
                    actualTotal = payMethodVo.getPayTotal();
                    deductionMoney = payMethodVo.getDeductionMoney();
                }
                logger.info("比例:{},分配金额:{},抵扣金额:{}",rate,actualTotal,deductionMoney);
        //2.获取分摊的权益数据<权益标识,支付项标识,数据>
        Map<String, Map<String,ConsumePayCard>> buyEquMap = UserCardTool.getCardDetailBuyMoneyByItemId(userCard.getId(),ConsumePayCard.TYPE_EQU, commonService);
        logger.info("获取分摊的权益数据:"+JSON.toJSONString(buyEquMap));
        //2.获取当前权益分配的金额数据<权益标识,支付项标识,权益数据>
        Map<String,Map<String, ConsumePayCard>> cardEquBuyMoneyMap = getUserCardEquMoneyMap(buyEquMap,cardBuyMoneyMap,cardItem,orderItemSonList);
                //减去分配的金额
                payMethodVo.setPayTotal(payMethodVo.getPayTotal().subtract(actualTotal));
                payMethodVo.setDeductionMoney(payMethodVo.getDeductionMoney().subtract(deductionMoney));
                if (payMethodVo.getPayTotal().compareTo(BigDecimal.ZERO) < 0) {
                    throw new RuntimeException("卡包金额分配错误[0223]");
                }
                if (payMethodVo.getDeductionMoney().compareTo(BigDecimal.ZERO) < 0) {
                    throw new RuntimeException("卡包抵扣金额分配错误[0223]");
                }
                //更新map总剩余金额
                groupByNumberNoMap.put(payMethodVo.getNumberNo(), payMethodVo);
        //3.获取分摊的条目数据<条目标识,支付项标识,数据>
        Map<String, Map<String,ConsumePayCard>> buyInfoMap = UserCardTool.getCardDetailBuyMoneyByItemId(userCard.getId(),ConsumePayCard.TYPE_INFO, commonService);
        logger.info("获取分摊的条目数据:"+JSON.toJSONString(buyInfoMap));
        //3.获取当前条目分配的金额数据<表目标识,支付项标识,条目数据>
        Map<String,Map<String, ConsumePayCard>> cardInfoBuyMoneyMap = getUserCardInfoMoneyMap(buyInfoMap,cardEquBuyMoneyMap,orderItemSonList);
                //封装每个权益的支付方式
                consumePayItem = methodMap.get(consumePayItemVo.getNumberNo());
                if (consumePayItem == null) {
                    consumePayItem = new ConsumePayItem();
                    BeanUtils.copyProperties(consumePayItemVo,consumePayItem);
                    consumePayItem.setActualTotal(BigDecimal.ZERO);
                    consumePayItem.setDeductionMoney(BigDecimal.ZERO);
                }
                consumePayItem.actualTotalAdd(actualTotal);
                consumePayItem.deductionMoneyAdd(deductionMoney);
                methodMap.put(consumePayItemVo.getNumberNo(), consumePayItem);
            }
            cardEquityMethodMap.put(cardEquity.getId(), methodMap);
            //查询用户的卡项对应的这个权益,是否使用完
            cardEquityNumMap.put(cardEquity.getId(),true);
            List<CardItemInfo> cardInfoList = UserCardTool.getCardInfoList(cardEquity.getId(), commonService);
            if (cardInfoList != null && cardInfoList.size() > 0){
                for (CardItemInfo cardItemInfo : cardInfoList) {
                    //获取这个条目剩余的次数
                    UserCardItemInfoVo userCardItemInfoVo = UserCardTool.getSurplusNumber(userCard, cardItemInfo, null, commonService);
                    logger.info("权益{},条目:{},剩余:{}",cardEquity.getId(),cardItemInfo.getId(),userCardItemInfoVo.getSurplusNum());
                    if (userCardItemInfoVo.getSurplusNum() != null && userCardItemInfoVo.getSurplusNum() > 0){
                        cardEquityNumMap.put(cardEquity.getId(),false);
                        break;
                    }
                }
                logger.info("权益:{},是否是最后一个:{}",cardEquity.getId(),cardEquityNumMap.get(cardEquity.getId()));
            }
        }
        logger.info("-----计算条目金额------");
        //这一步算出当前卡包购买的权益下,每个条目应分摊的金额(算出占比权益)
        //权益标识,开卡选择的条目标识,条目数据
        Map<String, Map<String,CardItemInfo>> cardEquityMap = new HashMap<>();
        Map<String,CardItemInfo> cardItemInfoMap = null;
        CardItemInfo cardItemInfo = null;
        for (OrderItemSon itemSon : orderItemSonList) {
            //获取卡项的条目
            cardItemInfo = cardItemInfoMapper.selectOneByKey(itemSon.getCardItemInfoId());
            if (cardItemInfo == null){
                continue;
            }
            //条目数量
            int deductionNun;
            if (cardItemInfo.getEveryDrawNum() != null && cardItemInfo.getEveryDrawNum() > 0) {
                deductionNun = itemSon.getBuyNum() * cardItemInfo.getEveryDrawNum();
            } else {
                deductionNun = itemSon.getBuyNum();
            }
            //这次购买的金额(规则:单次x数量)
            BigDecimal infoShareMoney = UserCardTool.countOneMoney(cardItemInfo).multiply(new BigDecimal(deductionNun)).setScale(2, RoundingMode.DOWN);
            cardItemInfo.setInfoShareMoney(infoShareMoney);
            itemSon.setInfoShareMoney(infoShareMoney);
            logger.info("权益{},条目:{},条目总次数金额:{}",itemSon.getCardEquityId(),cardItemInfo.getId(),infoShareMoney);
            //按照权益进行分组
            cardItemInfoMap = cardEquityMap.get(itemSon.getCardEquityId());
            if (cardItemInfoMap == null) {
                cardItemInfoMap = new HashMap<>();
            }
            cardItemInfoMap.put(itemSon.getCardItemInfoId(), cardItemInfo);
            cardEquityMap.put(itemSon.getCardEquityId(), cardItemInfoMap);
        }
        logger.info("-----计算已使用金额------");
        //到这一步的时候,用户卡项使用记录会有记录,拿到每个权益已经使用了的金额
        //权益标识,支付方式编号,已购买数据
        Map<String, Map<String, ConsumePayItem>> cardEquityMapUsedTotal = new HashMap<>();
        Map<String, ConsumePayItem> usedCardEqu = null;
        List<UserCardPay> cardBagEquityMoney = null;
        for (Map.Entry<String, CardEquity> stringCardEquityEntry : cardEquityMapTotal.entrySet()) {
            cardEquity = stringCardEquityEntry.getValue();
            cardBagEquityMoney = UserCardTool.getCardBagEquityMoney(null, cardEquity, commonService);
            methodMap = cardEquityMapUsedTotal.get(cardEquity.getId());
            if (methodMap == null){
                methodMap = new HashMap<>();
            }
            if (cardBagEquityMoney != null && cardBagEquityMoney.size() > 0){
                for (UserCardPay userCardPay : cardBagEquityMoney) {
                    consumePayItem = methodMap.get(userCardPay.getNumberNo());
                    if (consumePayItem == null){
                        consumePayItem = new ConsumePayItem();
                        consumePayItem.setNumberNo(userCardPay.getNumberNo());
                        consumePayItem.setActualTotal(BigDecimal.ZERO);
                        consumePayItem.setDeductionMoney(BigDecimal.ZERO);
                    }
                    consumePayItem.actualTotalAdd(userCardPay.getActualTotal());
                    consumePayItem.deductionMoneyAdd(userCardPay.getDeductionMoney());
                    methodMap.put(userCardPay.getNumberNo(),consumePayItem);
                    logger.info("权益:{},已用支付:{},已用金额:{},已用抵扣金额:{}",cardEquity.getId(),userCardPay.getNumberNo()
                            ,userCardPay.getActualTotal(),userCardPay.getDeductionMoney());
                }
            }
            cardEquityMapUsedTotal.put(cardEquity.getId(),methodMap);
        }
        //到这里才是真正算这次卡包开单分配的钱
        //按权益分组
        Map<String,List<OrderItemSon>> cardItemInfoListMap = orderItemSonList.stream().collect(Collectors.groupingBy(OrderItemSon::getCardEquityId));
        for (Map.Entry<String, List<OrderItemSon>> entry : cardItemInfoListMap.entrySet()) {
            //这个权益的数据
            cardEquity = cardEquityMapTotal.get(entry.getKey());
            //这个权益的总支付金额数据
            methodMap = cardEquityMethodMap.get(entry.getKey());
            //这个权益已使用了的支付金额数据
            usedCardEqu = cardEquityMapUsedTotal.get(entry.getKey());
            //这个权益下的购买的条目数据
            cardItemInfoMap = cardEquityMap.get(entry.getKey());
            //当前结账权益已分配的金额(单前的卡包单可能会有同一个权益不同条目)
            Map<String,ConsumePayItem> usedMap = new HashMap<>();
            //这个权益信息
            CardEquity cardEquity = commonService.selectOneByKey(CardEquityMapper.class,entry.getKey());
            //这个权益下购买的条目,按金额排序
            List<OrderItemSon> infoList = entry.getValue().stream().sorted(Comparator.comparing(OrderItemSon::getInfoShareMoney)).collect(Collectors.toList());
            //这个权益下使用过的数据<条目,支付项,数据>
            Map<String,Map<String,UserCardPay>> usedMoneyMap = UserCardTool.getCardBagUseList(entry.getKey(), null, commonService);
            Map<String,UserCardPay> usedNumMap = new HashMap<>();
            for (Map.Entry<String, Map<String, UserCardPay>> mapEntry : usedMoneyMap.entrySet()) {
                CardItemInfo cardItemInfo = commonService.selectOneByKey(CardItemInfoMapper.class,mapEntry.getKey());
                for (Map.Entry<String, UserCardPay> itemEntry : mapEntry.getValue().entrySet()) {
                    UserCardPay userCardPay = usedNumMap.get(mapEntry.getKey());
                    if (userCardPay == null){
                        userCardPay = new UserCardPay();
                    }
                    OrderItem usedItem = commonService.selectOneByKey(OrderItemMapper.class,itemEntry.getValue().getOrderItemId());
                    if (cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_TIME_CARD)){
                        userCardPay.pNumAdd(usedItem.getBuyNum() * cardItemInfo.getEveryDrawNum());
                        userCardPay.setNowByNum(orderItem.getBuyNum() * cardItemInfo.getEveryDrawNum());
                        userCardPay.setTotalNum(cardEquity.getValue());
                    }else {
                        userCardPay.pNumAdd(usedItem.getBuyNum());
                        userCardPay.setNowByNum(orderItem.getBuyNum());
                        userCardPay.setTotalNum(cardItemInfo.getMaxNum());
                    }
                    usedNumMap.put(mapEntry.getKey(),userCardPay);
                }
            }
            for (int i = 0; i < infoList.size(); i++) {
                OrderItemSon orderItemSon = infoList.get(i);
                //条目的数据
                cardItemInfo = cardItemInfoMap.get(orderItemSon.getCardItemInfoId());
                //条目要更新的未执行金额
                BigDecimal totalNoDeductionMoney = BigDecimal.ZERO;
                //条目占比权益
                BigDecimal proportion = null;
                //这次购买,权益次数已用完,需要直接扣完
                if (cardEquityNumMap.get(entry.getKey())){
                    //不是最后一个则按比例
                    if (i != infoList.size()-1){
                        proportion = cardItemInfo.getInfoShareMoney().divide(cardEquity.getShareMoney(), 20, RoundingMode.HALF_UP);
                    }
                }else {
                    //不是最后一个则按比例
                    proportion = cardItemInfo.getInfoShareMoney().divide(cardEquity.getShareMoney(), 20, RoundingMode.HALF_UP);
                }
                logger.info("权益:{},条目:{},占比权益:{}",cardEquity.getId(),cardItemInfo.getId(),proportion);
                CardItemInfo cardItemInfo = commonService.selectOneByKey(CardItemInfoMapper.class,orderItemSon.getCardItemInfoId());
                //条目OCC数据
                Map<String, ConsumePayCard> infoMap = cardInfoBuyMoneyMap.get(orderItemSon.getCardItemInfoId());
                //权益占比卡项支付方式的数据
                for (Map.Entry<String, ConsumePayItem> payItemEntry : methodMap.entrySet()) {
                //是否最后的数量
                UserCardPay usedUserCardPay = usedNumMap.get(orderItemSon.getCardItemInfoId());
                usedUserCardPay.handlerLast();
                logger.info("条目:{},是否最后:{}",orderItemSon.getCardItemInfoId(),usedUserCardPay.getIsLast());
                //使用过的金额
                Map<String, UserCardPay> usedInfoMoneyMap = usedMoneyMap.get(orderItemSon.getCardItemInfoId());
                logger.info("条目:{},使用过的金额:{}",orderItemSon.getCardItemInfoId(),JSON.toJSONString(usedInfoMoneyMap));
                //总的可执行金额
                BigDecimal totalNoDeductionMoney = BigDecimal.ZERO;
                for (Map.Entry<String, ConsumePayItem> payItemEntry : consumePayItemMap.entrySet()) {
                    UserCardPay userCardPay = new UserCardPay();
                    //当前订单数据
                    userCardPay.setOrderId(orderItemSon.getOrderId());
                    userCardPay.setOrderItemId(orderItemSon.getOrderItemId());
                    userCardPay.setOrderItemSonId(orderItemSon.getId());
                    userCardPay.setUserCardId(orderItem.getUserCardId());
                    userCardPay.setCardEquityId(orderItemSon.getCardEquityId());
                    userCardPay.setCardItemInfoId(orderItemSon.getCardItemInfoId());
                    userCardPay.setGoodsId(orderItemSon.getGoodsId());
@@ -1788,7 +1652,6 @@
                    //权益的支付方式
                    ConsumePayItem value = payItemEntry.getValue();
                    logger.info("{},--------循环支付方式-----",payItemEntry.getKey());
                    logger.info("权益分配金额:{},抵扣:{}",value.getActualTotal(),value.getDeductionMoney());
                    //存储买卡的支付数据
                    userCardPay.setConsumePayItemId(value.getId());
                    userCardPay.setPaymentMethodId(value.getPaymentMethodId());
@@ -1798,53 +1661,34 @@
                    userCardPay.setIsExecute(value.getIsExecute());
                    userCardPay.setIsPay(value.getIsPay());
                    userCardPay.setDeductionType(value.getDeductionType());
                    //当前卡包单下权益已经分配了的数据
                    ConsumePayItem usedItem = usedMap.get(value.getNumberNo());
                    if (usedItem == null){
                        usedItem = new ConsumePayItem();
                        usedItem.setActualTotal(BigDecimal.ZERO);
                        usedItem.setDeductionMoney(BigDecimal.ZERO);
                    }
                    logger.info("当前其它权益已分金额:{},抵扣:{}",usedItem.getActualTotal(),usedItem.getDeductionMoney());
                    //分摊买卡的支付数据
                    BigDecimal actualTotal = BigDecimal.ZERO;
                    BigDecimal deductionMoney = BigDecimal.ZERO;
                    if (proportion != null){
                        //按比例分配
                        actualTotal = value.getActualTotal().multiply(proportion).setScale(2,RoundingMode.DOWN);
                        deductionMoney = value.getDeductionMoney().multiply(proportion).setScale(2,RoundingMode.DOWN);
                    //OCC数据
                    ConsumePayCard occPayCard = infoMap.get(value.getId());
                    logger.info("支付方式OCC分配金额:{},抵扣金额:{}",occPayCard.getActualTotal(),occPayCard.getDeductionMoney());
                    //当前卡包单分配的金额
                    if (usedUserCardPay.getIsLast()){
                        UserCardPay usedMoney = usedInfoMoneyMap.get(value.getId());
                        userCardPay.setActualTotal(occPayCard.getActualTotal().subtract(usedMoney.getActualTotal()));
                        userCardPay.setDeductionMoney(occPayCard.getDeductionMoney().subtract(usedMoney.getDeductionMoney()));
                    }else {
                        //分配剩余的钱
                        //减去当前结账的钱
                        actualTotal = value.getActualTotal().subtract(usedItem.getActualTotal());
                        deductionMoney = value.getDeductionMoney().subtract(usedItem.getDeductionMoney());
                        logger.info("减去当前其它权益金额:{},抵扣:{}",actualTotal,deductionMoney);
                        //减去以前使用的
                        if (usedCardEqu != null){
                            ConsumePayItem usedPayItem = usedCardEqu.get(value.getNumberNo());
                            if (usedPayItem != null){
                                logger.info("以前权益已分金额:{},抵扣:{}",usedPayItem.getActualTotal(),usedPayItem.getDeductionMoney());
                                actualTotal = actualTotal.subtract(usedPayItem.getActualTotal());
                                deductionMoney = deductionMoney.subtract(usedPayItem.getDeductionMoney());
                                logger.info("减去以前权益金额:{},抵扣:{}",actualTotal,deductionMoney);
                            }
                        if (cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_TIME_CARD)){
                            //次卡 每次抵扣的OCCx抵扣次数
                            int num = orderItemSon.getBuyNum() * cardItemInfo.getEveryDrawNum();
                            userCardPay.setActualTotal(occPayCard.getActualTotal().multiply(new BigDecimal(num)).setScale(2, RoundingMode.DOWN));
                            userCardPay.setDeductionMoney(occPayCard.getDeductionMoney().multiply(new BigDecimal(num)).setScale(2, RoundingMode.DOWN));
                        }else{
                            //N选M和固定项目 按数量比例
                            BigDecimal rate = new BigDecimal(orderItemSon.getBuyNum()).divide(new BigDecimal(cardItemInfo.getMaxNum()),2, RoundingMode.HALF_UP);
                            userCardPay.setActualTotal(occPayCard.getActualTotal().multiply(rate).setScale(2, RoundingMode.DOWN));
                            userCardPay.setDeductionMoney(occPayCard.getDeductionMoney().multiply(rate).setScale(2, RoundingMode.DOWN));
                        }
                    }
                    logger.info("最终分配给条目的金额:{},抵扣:{}",actualTotal,deductionMoney);
                    if (actualTotal.compareTo(BigDecimal.ZERO) < 0){
                        throw new TipsException("卡项金额分配错误[011]");
                    if (userCardPay.getActualTotal().compareTo(BigDecimal.ZERO) <= 0){
                        throw new RuntimeException("卡包金额分配错误[0223]");
                    }
                    if (deductionMoney.compareTo(BigDecimal.ZERO) < 0){
                        throw new TipsException("卡项金额分配错误[012]");
                    if (userCardPay.getDeductionMoney().compareTo(BigDecimal.ZERO) <= 0){
                        throw new RuntimeException("卡包抵扣金额分配错误[0223]");
                    }
                    //叠加已分配的钱
                    usedItem.actualTotalAdd(actualTotal);
                    usedItem.deductionMoneyAdd(deductionMoney);
                    usedMap.put(value.getNumberNo(),usedItem);
                    //设置分配的钱
                    userCardPay.setActualTotal(actualTotal);
                    userCardPay.setDeductionMoney(deductionMoney);
                    //可划扣金额
                    if (userCardPay.getIsExecute() != null && userCardPay.getIsExecute() == 1){
                        userCardPay.setNoDeductionAmount(userCardPay.getActualTotal());
@@ -1880,6 +1724,329 @@
        }
    }
    /**
     * 处理条目分配OCC金额数据
     *
     * @param buyInfoMap         已经分配的条目数据
     * @param cardEquBuyMoneyMap 分配的卡项金额数据
     * @param orderItemSonList  购买子单数据
     */
    private Map<String, Map<String, ConsumePayCard>> getUserCardInfoMoneyMap(Map<String, Map<String, ConsumePayCard>> buyInfoMap
            , Map<String, Map<String, ConsumePayCard>> cardEquBuyMoneyMap, List<OrderItemSon> orderItemSonList) {
        //返回数据
        Map<String, Map<String, ConsumePayCard>> returnDataMap = new HashMap<>();
        Map<String, ConsumePayCard> returnItemMap = null;
        //条目标识,条目数据
        Map<String, CardItemInfo> infoDataMap = null;
        //权益分组后的购买条目
        List<OrderItemSon> groupSonList = null;
        //算出已经分配的条目的总额
        Map<String, ConsumePayCard> payTotalMap = null;
        //按权益分组
        Map<String, List<OrderItemSon>> groupMap = orderItemSonList.stream().collect(Collectors.groupingBy(OrderItemSon::getCardEquityId));
        for (Map.Entry<String, List<OrderItemSon>> equEntry : groupMap.entrySet()) {
            //权益
            CardEquity cardEquity = commonService.selectOneByKey(CardEquityMapper.class, equEntry.getKey());
            //查询权益下所有的条目数据
            infoDataMap = new HashMap<>();
            List<CardItemInfo> cardInfoList = UserCardTool.getCardInfoList(equEntry.getKey(), commonService);
            for (CardItemInfo cardItemInfo : cardInfoList) {
                infoDataMap.put(cardItemInfo.getId(),cardItemInfo);
                //固定项目叠加金额
                if (cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_PROJECT)){
                    cardEquity.setShareMoney(cardEquity.getShareMoney().add(cardItemInfo.getShareMoney()));
                }
            }
            //权益分摊好的金额数据
            Map<String, ConsumePayCard> equBuyMap = cardEquBuyMoneyMap.get(cardEquity.getId());
            //排序要购买的条目数据
            groupSonList = equEntry.getValue();
            for (OrderItemSon orderItemSon : groupSonList) {
                CardItemInfo cardItemInfo = infoDataMap.get(orderItemSon.getCardItemInfoId());
                orderItemSon.setInfoShareMoney(cardItemInfo.getShareMoney() == null ? cardItemInfo.getEveryShareMoney() : cardItemInfo.getShareMoney());
                if (orderItemSon.getInfoShareMoney() == null){
                    orderItemSon.setInfoShareMoney(BigDecimal.ZERO);
                }
            }
            groupSonList =  groupSonList.stream().sorted(Comparator.comparing(OrderItemSon::getInfoShareMoney)).collect(Collectors.toList());
            //算出已经分配的条目的总额
            payTotalMap = new HashMap<>();
            ConsumePayCard useValue = null;
            for (Map.Entry<String, Map<String, ConsumePayCard>> entry : buyInfoMap.entrySet()) {
                for (Map.Entry<String, ConsumePayCard> itemEntry : entry.getValue().entrySet()) {
                    useValue = payTotalMap.get(itemEntry.getKey());
                    if (useValue == null) {
                        useValue = new ConsumePayCard();
                    }
                    useValue.actualTotalAdd(itemEntry.getValue().getActualTotal());
                    useValue.deductionMoneyAdd(itemEntry.getValue().getDeductionMoney());
                    payTotalMap.put(itemEntry.getKey(), useValue);
                }
            }
            //此次是否买完了最后的条目种类
            boolean isLast = false;
            if (cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_PROJECT) || cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_N_M)){
                //条目数据,未购买过的
                Map<String, CardItemInfo> noBuyMap = new HashMap<>();
                for (CardItemInfo cardItemInfo : cardInfoList) {
                    if (buyInfoMap.get(cardItemInfo.getId()) == null) {
                        noBuyMap.put(cardItemInfo.getId(), cardItemInfo);
                    }
                }
                List<String> infoIdList = orderItemSonList.stream().map(OrderItemSon::getCardItemInfoId).collect(Collectors.toList());
                for (String infoId : infoIdList) {
                    noBuyMap.remove(infoId);
                }
                isLast = noBuyMap.size() == 0;
            }
            for (int i = 0; i < groupSonList.size(); i++) {
                OrderItemSon orderItemSon = groupSonList.get(i);
                //子单条目数据
                CardItemInfo cardItemInfo = infoDataMap.get(orderItemSon.getId());
                //返回数据
                returnItemMap = returnDataMap.get(orderItemSon.getCardItemInfoId());
                if (returnItemMap == null){
                    returnItemMap = new HashMap<>();
                }
                //未分配过,获取权益下的条目数据
                if (buyInfoMap.get(orderItemSon.getCardItemInfoId()) == null){
                    for (Map.Entry<String, ConsumePayCard> cardEntry : equBuyMap.entrySet()) {
                        ConsumePayCard consumePayCard = cardEntry.getValue();
                        //新增
                        ConsumePayCard addValue = new ConsumePayCard();
                        addValue.setConsumePayItemId(consumePayCard.getConsumePayItemId());
                        addValue.setPaymentMethodId(consumePayCard.getPaymentMethodId());
                        addValue.setNumberNo(consumePayCard.getNumberNo());
                        addValue.setName(consumePayCard.getName());
                        addValue.setCommonType(ConsumePayCard.TYPE_INFO);
                        addValue.setCommonId(cardItemInfo.getId());
                        addValue.setUserCardId(consumePayCard.getUserCardId());
                        addValue.setOrderItemId(consumePayCard.getOrderItemId());
                        addValue.setOrderId(consumePayCard.getOrderId());
                        addValue.setDeductionType(consumePayCard.getDeductionType());
                        //获取使用了的总额,权益金额减去使用的总额
                        useValue = payTotalMap.get(consumePayCard.getConsumePayItemId());
                        //条目分摊的钱看权益的类型
                        if (cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_PROJECT)){
                            //权益是固定项目,那么直接按金额占比分配,注意最后一个条目
                            if (isLast && i == groupSonList.size() - 1) {
                                addValue.setActualTotal(consumePayCard.getActualTotal().subtract(useValue.getActualTotal()));
                                addValue.setDeductionMoney(consumePayCard.getDeductionMoney().subtract(useValue.getDeductionMoney()));
                            } else {
                                //条目占比权益的
                                BigDecimal rate = cardItemInfo.getShareMoney().divide(cardEquity.getShareMoney(), 30, RoundingMode.HALF_UP);
                                addValue.setActualTotal(consumePayCard.getActualTotal().multiply(rate).setScale(2, RoundingMode.HALF_UP));
                                addValue.setDeductionMoney(consumePayCard.getDeductionMoney().multiply(rate).setScale(2, RoundingMode.HALF_UP));
                            }
                        }else if (cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_N_M)){
                            //权益是N选M,那么每次选的那个按金额占比分配,注意最后一个M
                            if (isLast && i == groupSonList.size() - 1) {
                                addValue.setActualTotal(consumePayCard.getActualTotal().subtract(useValue.getActualTotal()));
                                addValue.setDeductionMoney(consumePayCard.getDeductionMoney().subtract(useValue.getDeductionMoney()));
                            } else {
                                //分成N份,每份都相同
                                addValue.setActualTotal(consumePayCard.getActualTotal().divide(new BigDecimal(cardEquity.getValue()), 2, RoundingMode.DOWN));
                                addValue.setDeductionMoney(consumePayCard.getDeductionMoney().divide(new BigDecimal(cardEquity.getValue()), 2, RoundingMode.DOWN));
                            }
                        }else if (cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_TIME_CARD)){
                            //权益是次卡,默认就是平均分配(只是计算的时候,需要看是否次数用完)
                            addValue.setActualTotal(consumePayCard.getActualTotal().divide(new BigDecimal(cardEquity.getValue()), 2, RoundingMode.DOWN));
                            addValue.setDeductionMoney(consumePayCard.getDeductionMoney().divide(new BigDecimal(cardEquity.getValue()), 2, RoundingMode.DOWN));
                        }
                        commonService.insert(ConsumePayCardMapper.class, addValue);
                        returnItemMap.put(consumePayCard.getConsumePayItemId(), addValue);
                    }
                }else {
                    //分配过了
                    returnItemMap.putAll(buyInfoMap.get(orderItemSon.getCardItemInfoId()));
                }
                returnDataMap.put(cardItemInfo.getId(), returnItemMap);
            }
        }
        return returnDataMap;
    }
    /**
     * 处理权益分配OCC金额数据
     *
     * @param buyEquMap         已经分配的权益数据
     * @param consumePayCardMap 分配的卡项金额数据
     * @param cardItem          卡项数据
     * @param orderItemSonList  购买子单数据
     */
    private Map<String, Map<String, ConsumePayCard>> getUserCardEquMoneyMap(Map<String, Map<String, ConsumePayCard>> buyEquMap
            , Map<String, ConsumePayCard> consumePayCardMap, CardItem cardItem, List<OrderItemSon> orderItemSonList) {
        //每个权益的金额数据(方法内部已排序,金额字段在shareMoney)
        List<CardEquity> cardEquityMoneyList = UserCardTool.getCardEquityMoneyList(null, cardItem, commonService);
        //权益数据,未购买过的
        Map<String, CardEquity> noBuyMap = new HashMap<>();
        for (CardEquity cardEquity : cardEquityMoneyList) {
            if (buyEquMap.get(cardEquity.getId()) == null) {
                noBuyMap.put(cardEquity.getId(), cardEquity);
            }
        }
        //算出已经分配的权益的总额
        Map<String, ConsumePayCard> payTotalMap = new HashMap<>();
        ConsumePayCard useValue = null;
        for (Map.Entry<String, Map<String, ConsumePayCard>> entry : buyEquMap.entrySet()) {
            for (Map.Entry<String, ConsumePayCard> itemEntry : entry.getValue().entrySet()) {
                useValue = payTotalMap.get(itemEntry.getKey());
                if (useValue == null) {
                    useValue = new ConsumePayCard();
                }
                useValue.actualTotalAdd(itemEntry.getValue().getActualTotal());
                useValue.deductionMoneyAdd(itemEntry.getValue().getDeductionMoney());
                payTotalMap.put(itemEntry.getKey(), useValue);
            }
        }
        //购买的权益标识
        List<String> buyEquList = orderItemSonList.stream().map(OrderItemSon::getCardEquityId).collect(Collectors.toList());
        //剔除不是这次购买的
        cardEquityMoneyList.removeIf(cardEquity -> !buyEquList.contains(cardEquity.getId()));
        cardEquityMoneyList = cardEquityMoneyList.stream().sorted(Comparator.comparing(CardEquity::getShareMoney)).collect(Collectors.toList());
        for (String equId : buyEquList) {
            noBuyMap.remove(equId);
        }
        //此次是否买完了最后的权益
        boolean isLast = noBuyMap.size() == 0;
        //返回数据
        Map<String, Map<String, ConsumePayCard>> returnDataMap = new HashMap<>();
        Map<String, ConsumePayCard> returnItemMap = null;
        for (Map.Entry<String, ConsumePayCard> cardEntry : consumePayCardMap.entrySet()) {
            //卡项分摊的金额
            ConsumePayCard consumePayCard = cardEntry.getValue();
            //权益
            CardEquity cardEquity = null;
            //新增分配数据
            ConsumePayCard addValue = null;
            for (int i = 0; i < cardEquityMoneyList.size(); i++) {
                cardEquity = cardEquityMoneyList.get(i);
                returnItemMap = returnDataMap.get(cardEquity.getId());
                if (returnItemMap == null) {
                    returnItemMap = new HashMap<>();
                }
                if (buyEquMap.get(cardEquity.getId()) == null) {
                    //没有这个权益的OCC数据
                    addValue = new ConsumePayCard();
                    addValue.setConsumePayItemId(consumePayCard.getConsumePayItemId());
                    addValue.setPaymentMethodId(consumePayCard.getPaymentMethodId());
                    addValue.setNumberNo(consumePayCard.getNumberNo());
                    addValue.setName(consumePayCard.getName());
                    addValue.setCommonType(ConsumePayCard.TYPE_EQU);
                    addValue.setCommonId(cardEquity.getId());
                    addValue.setUserCardId(consumePayCard.getUserCardId());
                    addValue.setOrderItemId(consumePayCard.getOrderItemId());
                    addValue.setOrderId(consumePayCard.getOrderId());
                    addValue.setDeductionType(consumePayCard.getDeductionType());
                    //获取使用了的总额
                    useValue = payTotalMap.get(consumePayCard.getConsumePayItemId());
                    if (isLast && i == cardEquityMoneyList.size() - 1) {
                        addValue.setActualTotal(consumePayCard.getActualTotal().subtract(useValue.getActualTotal()));
                        addValue.setDeductionMoney(consumePayCard.getDeductionMoney().subtract(useValue.getDeductionMoney()));
                    } else {
                        //权益占比卡项的
                        BigDecimal rate = cardEquity.getShareMoney().divide(cardItem.getTotal(), 30, RoundingMode.HALF_UP);
                        addValue.setActualTotal(consumePayCard.getActualTotal().multiply(rate).setScale(2, RoundingMode.HALF_UP));
                        addValue.setDeductionMoney(consumePayCard.getDeductionMoney().multiply(rate).setScale(2, RoundingMode.HALF_UP));
                    }
                    commonService.insert(ConsumePayCardMapper.class, addValue);
                    returnItemMap.put(consumePayCard.getConsumePayItemId(), addValue);
                } else {
                    returnItemMap.putAll(buyEquMap.get(cardEquity.getId()));
                }
                returnDataMap.put(cardEquity.getId(), returnItemMap);
            }
        }
        return returnDataMap;
    }
    /**
     * 处理卡项分配OCC金额数据
     *
     * @param buyTotalMap        分配的卡项金额数据
     * @param userCard           客户卡项
     * @param orderItemBuy       客户卡项来源子单
     * @param consumePayItemList 子项支付数据
     */
    private Map<String, ConsumePayCard> getUserCardMoneyMap(Map<String, Map<String, ConsumePayCard>> buyTotalMap
            , UserCard userCard, OrderItem orderItemBuy, List<ConsumePayItem> consumePayItemList) {
        //是否用剩余全部:未分配过这个卡+判断是不是最后的(已分配的数量+当前 = 购买数量)
        boolean useRemain = false;
        if (buyTotalMap.get(userCard.getId()) == null && orderItemBuy.getBuyNum() == (buyTotalMap.keySet().size() + 1)) {
            useRemain = true;
        }
        //这张卡分配的金额数据,优先拿之前分配好的
        Map<String, ConsumePayCard> cardBuyMoneyMap = buyTotalMap.get(userCard.getId());
        if (cardBuyMoneyMap == null) {
            //未分配过,进行金额分配
            cardBuyMoneyMap = new HashMap<>();
            //算出已经分配的总的
            Map<String, ConsumePayCard> payTotalMap = new HashMap<>();
            ConsumePayCard useValue = null;
            for (Map.Entry<String, Map<String, ConsumePayCard>> entry : buyTotalMap.entrySet()) {
                for (Map.Entry<String, ConsumePayCard> itemEntry : entry.getValue().entrySet()) {
                    useValue = payTotalMap.get(itemEntry.getKey());
                    if (useValue == null) {
                        useValue = new ConsumePayCard();
                    }
                    useValue.actualTotalAdd(itemEntry.getValue().getActualTotal());
                    useValue.deductionMoneyAdd(itemEntry.getValue().getDeductionMoney());
                    payTotalMap.put(itemEntry.getKey(), useValue);
                }
            }
            //新增分配数据
            ConsumePayCard addValue = null;
            for (ConsumePayItem consumePayItem : consumePayItemList) {
                addValue = new ConsumePayCard();
                addValue.setConsumePayItemId(consumePayItem.getId());
                addValue.setPaymentMethodId(consumePayItem.getPaymentMethodId());
                addValue.setNumberNo(consumePayItem.getNumberNo());
                addValue.setName(consumePayItem.getName());
                addValue.setCommonType(ConsumePayCard.TYPE_CARD);
                addValue.setCommonId(userCard.getId());
                addValue.setUserCardId(userCard.getId());
                addValue.setOrderItemId(orderItemBuy.getId());
                addValue.setOrderId(orderItemBuy.getOrderId());
                addValue.setDeductionType(consumePayItem.getDeductionType());
                //获取使用了的总额
                useValue = payTotalMap.get(consumePayItem.getId());
                if (useRemain) {
                    addValue.setActualTotal(consumePayItem.getActualTotal().subtract(useValue.getActualTotal()));
                    addValue.setDeductionMoney(consumePayItem.getDeductionMoney().subtract(useValue.getDeductionMoney()));
                } else {
                    if (consumePayItem.getActualTotal().compareTo(BigDecimal.ZERO) == 0) {
                        addValue.setActualTotal(BigDecimal.ZERO);
                    } else {
                        addValue.setActualTotal(consumePayItem.getActualTotal().divide(new BigDecimal(orderItemBuy.getBuyNum()), 2, RoundingMode.DOWN));
                    }
                    if (consumePayItem.getDeductionMoney().compareTo(BigDecimal.ZERO) == 0) {
                        addValue.setDeductionMoney(BigDecimal.ZERO);
                    } else {
                        addValue.setDeductionMoney(consumePayItem.getDeductionMoney().divide(new BigDecimal(orderItemBuy.getBuyNum()), 2, RoundingMode.DOWN));
                    }
                }
                commonService.insert(ConsumePayCardMapper.class, addValue);
                cardBuyMoneyMap.put(consumePayItem.getId(), addValue);
            }
        }
        return cardBuyMoneyMap;
    }
    /**更新用户项目数据*/
    private void updateUserProject(UserProjectItem userProjectItem,BigDecimal total,BigDecimal actualTotal,BigDecimal oriPrice