From 0ddc86f819e167ef658c7248c6973d5e1b9fe993 Mon Sep 17 00:00:00 2001 From: wst <2450473462@qq.com> Date: Fri, 6 Dec 2024 16:13:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A2=E5=8D=95=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E4=BF=A1=E6=81=AF=E6=94=B9=E4=B8=BA=E4=BB=8E?= =?UTF-8?q?=E5=95=86=E5=9F=8E=E6=8B=BF=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/skyeye/order/entity/OrderItem.java | 2 +- .../service/impl/OrderItemServiceImpl.java | 4 +-- .../order/service/impl/OrderServiceImpl.java | 26 ++++++++++--------- .../skyeye/store/entity/ShopTradeCart.java | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/entity/OrderItem.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/entity/OrderItem.java index b1c31246..3971b49e 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/entity/OrderItem.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/entity/OrderItem.java @@ -74,7 +74,7 @@ public class OrderItem extends OperatorUserInfo { private Integer count; @TableField("comment_state") - @Property(value = "是否评价",enumClass = WhetherEnum.class) + @Property(value = "是否评价", enumClass = WhetherEnum.class) private Integer commentState; @TableField("price") diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderItemServiceImpl.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderItemServiceImpl.java index 85eaccdf..a0b39bd8 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderItemServiceImpl.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderItemServiceImpl.java @@ -118,7 +118,7 @@ public class OrderItemServiceImpl extends SkyeyeBusinessServiceImpl updateWrapper = new UpdateWrapper<>(); updateWrapper.eq(CommonConstants.ID, id) .set(MybatisPlusUtil.toColumns(OrderItem::getCommentState), WhetherEnum.ENABLE_USING.getKey()); @@ -135,7 +135,7 @@ public class OrderItemServiceImpl extends SkyeyeBusinessServiceImpl updateWrapper = new UpdateWrapper<>(); diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java index ee9e0cec..a7632259 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java @@ -13,8 +13,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; +import com.google.common.base.Joiner; import com.skyeye.annotation.service.SkyeyeService; import com.skyeye.base.business.service.impl.SkyeyeBusinessServiceImpl; +import com.skyeye.common.constans.CommonCharConstants; import com.skyeye.common.constans.CommonConstants; import com.skyeye.common.constans.CommonNumConstants; import com.skyeye.common.constans.QuartzConstants; @@ -31,8 +33,6 @@ import com.skyeye.coupon.enums.PromotionDiscountType; import com.skyeye.coupon.enums.PromotionMaterialScope; import com.skyeye.coupon.service.CouponUseMaterialService; import com.skyeye.coupon.service.CouponUseService; -import com.skyeye.erp.service.IMaterialNormsService; -import com.skyeye.erp.service.IMaterialService; import com.skyeye.eve.rest.quartz.SysQuartzMation; import com.skyeye.eve.service.IAreaService; import com.skyeye.eve.service.IQuartzService; @@ -47,6 +47,7 @@ import com.skyeye.order.enums.ShopOrderState; import com.skyeye.order.service.OrderItemService; import com.skyeye.order.service.OrderService; import com.skyeye.rest.pay.service.IPayService; +import com.skyeye.rest.shopmaterialnorms.sevice.IShopMaterialNormsService; import com.skyeye.store.entity.ShopAddress; import com.skyeye.store.service.ShopAddressService; import com.skyeye.store.service.ShopTradeCartService; @@ -79,10 +80,7 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl private IAreaService iAreaService; @Autowired - private IMaterialService iMaterialService; - - @Autowired - private IMaterialNormsService iMaterialNormsService; + private IShopMaterialNormsService iShopMaterialNormsService; @Autowired private CouponUseService couponUseService; @@ -134,17 +132,21 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl checkAndSetVariable(order); // 活动信息及积分操作方法 checkAndSetActive(order); - refreshCache(order.getId()); } private void checkAndSetItemCouponUse(Order order) {// 子单的优惠券操作 List orderItemList = order.getOrderItemList(); // 设置商品信息、商品规格信息和优惠券信息 - iMaterialNormsService.setDataMation(orderItemList, OrderItem::getNormsId); - iMaterialService.setDataMation(orderItemList, OrderItem::getMaterialId); + List normsIdList = orderItemList.stream().map(OrderItem::getNormsId).collect(Collectors.toList()); + List> normsListMap = iShopMaterialNormsService.queryShopMaterialByNormsIdList(Joiner.on(CommonCharConstants.COMMA_MARK).join(normsIdList)); + Map normsPriceMap = normsListMap.stream() + .collect(Collectors.toMap(map -> map.get("normsId").toString(), map -> map.get("salePrice").toString())); for (OrderItem orderItem : orderItemList) {// 计算每一个子单的总价 + if (!normsPriceMap.containsKey(orderItem.getNormsId())) { + throw new CustomException("商城不存在normsId: " + orderItem.getNormsId()); + } // 获取子单单价 元 -> 分 - String salePrice = CalculationUtil.multiply(orderItem.getNormsMation().get("salePrice").toString(), "100"); + String salePrice = CalculationUtil.multiply(normsPriceMap.get(orderItem.getNormsId()), "100"); // 设置子单总价 String price = CalculationUtil.multiply(String.valueOf(orderItem.getCount()), salePrice, CommonNumConstants.NUM_SIX); orderItem.setPrice(price); @@ -354,7 +356,7 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl ShopOrderState.COMPLETED.getKey(), // 已完成 ShopOrderState.UNEVALUATE.getKey(), // 待评价 ShopOrderState.EVALUATED.getKey()});// 已评价 - ShopOrderState.PARTIALLYDONE.getKey();//部分完成 + ShopOrderState.PARTIALLYDONE.getKey();//部分完成 break; case "4":// 已取消 stateList = Arrays.asList(new Integer[]{ShopOrderState.CANCELED.getKey()}); @@ -605,7 +607,7 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl orderItemService.UpdateOrderItemState(orderItemId); List orderItemList = orderItemService.queryOrderItemByParentId(orderId); boolean allTwo = orderItemList.stream().map(OrderItem::getOrderItemState) - .allMatch(orderItemState -> orderItemState == CommonNumConstants.NUM_TWO); + .allMatch(orderItemState -> orderItemState == CommonNumConstants.NUM_TWO); if (allTwo) { Integer partiallydoneKey = ShopOrderState.COMPLETED.getKey(); updateOrderState(orderId, partiallydoneKey); diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/store/entity/ShopTradeCart.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/store/entity/ShopTradeCart.java index 3f05f0f3..a2e04a3c 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/store/entity/ShopTradeCart.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/store/entity/ShopTradeCart.java @@ -65,6 +65,6 @@ public class ShopTradeCart extends OperatorUserInfo { private Integer count; @TableField("selected") - @ApiModelProperty(value = "是否选中", required = "required,num",enumClass = WhetherEnum.class) + @ApiModelProperty(value = "是否选中", required = "required,num", enumClass = WhetherEnum.class) private Integer selected; }