From 86a7a078c89a671f9ada908e8f82ebd43d463b18 Mon Sep 17 00:00:00 2001 From: fwq <582742538@qq.com> Date: 星期四, 10 十月 2024 18:42:27 +0800 Subject: [PATCH] 其-更新提货单的订单价格 --- phi_platform_user/src/main/java/com/hx/phip/service/init/impl/OrderInitServiceImpl.java | 80 ++++++++++++++++++++++++++++++++++++++++ phi_platform_common/src/main/java/com/hx/phip/tool/user/UserCardTool.java | 19 +++++++++ 2 files changed, 99 insertions(+), 0 deletions(-) diff --git a/phi_platform_common/src/main/java/com/hx/phip/tool/user/UserCardTool.java b/phi_platform_common/src/main/java/com/hx/phip/tool/user/UserCardTool.java index 565427b..a51d21c 100644 --- a/phi_platform_common/src/main/java/com/hx/phip/tool/user/UserCardTool.java +++ b/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(); diff --git a/phi_platform_user/src/main/java/com/hx/phip/service/init/impl/OrderInitServiceImpl.java b/phi_platform_user/src/main/java/com/hx/phip/service/init/impl/OrderInitServiceImpl.java index cf578f9..f0fb0d2 100644 --- a/phi_platform_user/src/main/java/com/hx/phip/service/init/impl/OrderInitServiceImpl.java +++ b/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("澶勭悊鎻愯揣鍗曢噾棰濅俊鎭敊璇�"); + } + } + } + } + } } /**涓�绾ц鍗曢噾棰濆鐞�*/ -- Gitblit v1.8.0