fwq
2024-10-10 86a7a078c89a671f9ada908e8f82ebd43d463b18
其-更新提货单的订单价格
2个文件已修改
99 ■■■■■ 已修改文件
phi_platform_common/src/main/java/com/hx/phip/tool/user/UserCardTool.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/init/impl/OrderInitServiceImpl.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/java/com/hx/phip/tool/user/UserCardTool.java
@@ -590,6 +590,25 @@
        return cardBuyMoneyMap;
    }
    /**
     * 卡包订单子项分配到的金额
     */
    public static BigDecimal orderItemSonMoney(String orderItemSonId, CommonService commonService) {
        SqlSentence sqlSentence = new SqlSentence();
        Map<String, Object> values = new HashMap<>();
        values.put("isDel", BaseEntity.NO);
        values.put("orderItemSonId", orderItemSonId);
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT SUM(actualTotal) AS actualTotal 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.orderItemSonId = #{m.orderItemSonId} ");
        //卡包要么全退,要么不退,这里查未退款的
        sql.append(" AND ot.isDel = #{m.isDel} AND ot.payStatus = 3 AND ot.refundStatus = -1 ");
        sqlSentence.sqlSentence(sql.toString(), values);
        UserCardPay userCardPay = commonService.selectOne(UserCardPayMapper.class, sqlSentence);
        return userCardPay == null?BigDecimal.ZERO:userCardPay.getActualTotal();
    }
    /**获取卡项权益的条目数量*/
    public static List<CardItemInfo> getCardInfoList(String cardEquityId,CommonService commonService){
        SqlSentence sqlSentence = new SqlSentence();
phi_platform_user/src/main/java/com/hx/phip/service/init/impl/OrderInitServiceImpl.java
@@ -25,6 +25,7 @@
import com.hx.phiappt.model.user.UserCard;
import com.hx.phiappt.model.user.UserCardPay;
import com.hx.phiappt.model.user.UserProjectItem;
import com.hx.phiappt.model.warehouse.PickUpGoodItem;
import com.hx.phiappt.tool.project.ProjectIntegralCashTool;
import com.hx.phiappt.vo.payMethod.PayMethodVo;
import com.hx.phip.config.CustomParameter;
@@ -382,6 +383,85 @@
                orderItemSonHandle(ordersTotal,orderItem,updateUserProject);
            }
        }
        //提货单金额处理
        pickUpOrderHandle(ordersTotal,orderItemList);
    }
    /**关联提货单数据处理*/
    private void pickUpOrderHandle(OrdersTotal ordersTotal, List<OrderItem> orderItemList) {
        if (orderItemList == null || orderItemList.size() == 0) {
            return;
        }
        SqlSentence sqlSentence = new SqlSentence();
        Map<String, Object> sqlMap = new HashMap<>();
        sqlMap.put("orderId", ordersTotal.getId());
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT * FROM pick_up_good_item AS i ");
        sql.append(" JOIN pick_up_good AS p ON p.id = i.pickUpGoodId ");
        sql.append(" WHERE p.isDel = 0 AND i.isDel = 0 AND p.commonId = #{m.orderId} ");
        sqlSentence.sqlSentence(sql.toString(), sqlMap);
        List<PickUpGoodItem> pickUpGoodItemList = commonService.selectList(PickUpGoodItemMapper.class, sqlSentence);
        if (pickUpGoodItemList == null || pickUpGoodItemList.size() < 1) {
            return;
        }
        //耗材标识,数据
        Map<String, PickUpGoodItem> pickUpGoodItemMap = new HashMap<>();
        for (PickUpGoodItem pickUpGoodItem : pickUpGoodItemList) {
            pickUpGoodItemMap.put(pickUpGoodItem.getConsumablesId(), pickUpGoodItem);
        }
        for (OrderItem orderItem : orderItemList) {
            //商品直接来
            if (OrderItemConstants.TYPE_RETAIL.equals(orderItem.getType())) {
                PickUpGoodItem pickUpGoodItem = pickUpGoodItemMap.get(orderItem.getCommonId());
                if (pickUpGoodItem == null) {
                    continue;
                }
                //查询这个子单分到的钱
                sqlMap.put("typeId", orderItem.getId());
                sqlSentence.sqlSentence("SELECT SUM(actualTotal) AS actualTotal FROM consume_pay_item WHERE isDel = 0 AND typeId = #{m.typeId} ", sqlMap);
                ConsumePayItem consumePayItem = commonService.selectOne(ConsumePayItemMapper.class, sqlSentence);
                sqlMap.put("orderPrice", consumePayItem == null ? BigDecimal.ZERO : consumePayItem.getActualTotal());
                sqlMap.put("id", pickUpGoodItem.getId());
                sqlSentence.sqlSentence("orderPrice = #{m.orderPrice} WHERE id = #{m.id}", sqlMap);
                if (commonService.updateWhere(PickUpGoodItemMapper.class, sqlSentence) != 1) {
                    throw new TipsException("处理提货单金额信息错误");
                }
            } else {
                if (OrderItemConstants.TYPE_PROMOTION.equals(orderItem.getType()) || OrderItemConstants.CARD_BAG.equals(orderItem.getType())) {
                    //促销和卡包查询二级子单
                    sqlMap.put("orderItemId", orderItem.getId());
                    sqlSentence.sqlSentence("SELECT * FROM order_item_source WHERE isDel = 0 AND orderItemId = #{m.orderItemId}", sqlMap);
                    List<OrderItemSon> orderItemSonList = orderItemSonMapper.selectList(sqlSentence);
                    if (orderItemSonList == null || orderItemSonList.size() < 1) {
                        continue;
                    }
                    for (OrderItemSon orderItemSon : orderItemSonList) {
                        PickUpGoodItem pickUpGoodItem = pickUpGoodItemMap.get(orderItemSon.getGoodsId());
                        if (pickUpGoodItem == null) {
                            continue;
                        }
                        //促销
                        if (OrderItemConstants.TYPE_PROMOTION.equals(orderItem.getType())) {
                            //查询这个子单分到的钱
                            sqlMap.put("typeId", orderItemSon.getId());
                            sqlSentence.sqlSentence("SELECT SUM(actualTotal) AS actualTotal FROM consume_pay_item_son WHERE isDel = 0 AND typeId = #{m.typeId} ", sqlMap);
                            ConsumePayItemSon consumePayItemSon = commonService.selectOne(ConsumePayItemSonMapper.class, sqlSentence);
                            sqlMap.put("orderPrice", consumePayItemSon == null ? BigDecimal.ZERO : consumePayItemSon.getActualTotal());
                        } else if (OrderItemConstants.CARD_BAG.equals(orderItem.getType())) {
                            //查询这个卡包单分到的钱
                            sqlMap.put("orderPrice", UserCardTool.orderItemSonMoney(orderItemSon.getId(), commonService));
                        }
                        sqlMap.put("id", pickUpGoodItem.getId());
                        sqlSentence.sqlSentence("orderPrice = #{m.orderPrice} WHERE id = #{m.id}", sqlMap);
                        if (commonService.updateWhere(PickUpGoodItemMapper.class, sqlSentence) != 1) {
                            throw new TipsException("处理提货单金额信息错误");
                        }
                    }
                }
            }
        }
    }
    /**一级订单金额处理*/