From 2f6628b63f062825dc6e3f2b9ebb04c136f35d71 Mon Sep 17 00:00:00 2001 From: luluyuyu <3305167204@qq.com> Date: Thu, 5 Dec 2024 16:59:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat=EF=BC=9A=E4=BF=AE=E6=94=B9=E6=80=BB?= =?UTF-8?q?=E5=8D=95=E5=92=8C=E5=AD=90=E5=8D=95=E7=AD=BE=E6=94=B6=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/conroller/OrderController.java | 15 +++ .../java/com/skyeye/order/entity/Order.java | 4 + .../com/skyeye/order/entity/OrderItem.java | 4 + .../order/service/OrderItemService.java | 4 + .../skyeye/order/service/OrderService.java | 2 + .../service/impl/OrderItemServiceImpl.java | 21 ++++ .../order/service/impl/OrderServiceImpl.java | 96 ++++++++++++------- 7 files changed, 110 insertions(+), 36 deletions(-) diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/conroller/OrderController.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/conroller/OrderController.java index 4702a5e5..de1ef996 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/conroller/OrderController.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/conroller/OrderController.java @@ -199,4 +199,19 @@ public class OrderController { public void updateOrderToPayState(InputObject inputObject, OutputObject outputObject) { orderService.updateOrderToPayState(inputObject, outputObject); } + + /** + * 修改订单签收状态 + * + * @param inputObject 入参以及用户信息等获取对象 + * @param outputObject 出参以及提示信息的返回值对象 + */ + @ApiOperation(id = "updateOrderItemState", value = "修改订单签收状态", method = "POST", allUse = "2") + @ApiImplicitParams({ + @ApiImplicitParam(id = "id", name = "id", value = "主键id", required = "required"), + @ApiImplicitParam(id = "orderItemId", name = "orderItemId", value = "子单Id", required = "required")}) + @RequestMapping("/post/OrderController/updateOrderItemState") + public void updateOrderItemState(InputObject inputObject, OutputObject outputObject) { + orderService.updateOrderItemState(inputObject, outputObject); + } } \ No newline at end of file diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/entity/Order.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/entity/Order.java index 1d9be8b1..5cc425f5 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/entity/Order.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/entity/Order.java @@ -219,4 +219,8 @@ public class Order extends AreaInfo { @TableField("extension_no") @Property(value = "支付成功的外部订单号") private String extensionNo; + + @TableField("order_state") + @ApiModelProperty(value = "订单状态") + private Integer orderState; } \ No newline at end of file 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 36755874..b1c31246 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 @@ -124,4 +124,8 @@ public class OrderItem extends OperatorUserInfo { @TableField("vip_price") @ApiModelProperty(value = "VIP 减免金额,单位:分") private String vipPrice; + + @TableField("order_item_state") + @ApiModelProperty(value = "订单子单状态") + private Integer orderItemState; } \ No newline at end of file diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/OrderItemService.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/OrderItemService.java index 53c54d54..2f078a27 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/OrderItemService.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/OrderItemService.java @@ -30,4 +30,8 @@ public interface OrderItemService extends SkyeyeBusinessService { void setValueAndCreateEntity(Order order, String userId); void updateCommentStateById(String id); + + List queryOrderItemByParentId(String orderId); + + void UpdateOrderItemState(String orderItemId); } diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/OrderService.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/OrderService.java index 8a43b0d5..8be9e4fe 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/OrderService.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/OrderService.java @@ -37,4 +37,6 @@ public interface OrderService extends SkyeyeBusinessService { void updateOrderToPayState(InputObject inputObject, OutputObject outputObject); void setOrderCancle(String orderId); + + void updateOrderItemState(InputObject inputObject, OutputObject outputObject); } 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 22eafe25..85eaccdf 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 @@ -11,10 +11,12 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.skyeye.annotation.service.SkyeyeService; import com.skyeye.base.business.service.impl.SkyeyeBusinessServiceImpl; import com.skyeye.common.constans.CommonConstants; +import com.skyeye.common.constans.CommonNumConstants; import com.skyeye.common.enumeration.WhetherEnum; import com.skyeye.common.util.mybatisplus.MybatisPlusUtil; import com.skyeye.erp.service.IMaterialNormsService; import com.skyeye.erp.service.IMaterialService; +import com.skyeye.exception.CustomException; import com.skyeye.order.dao.OrderItemDao; import com.skyeye.order.entity.Order; import com.skyeye.order.entity.OrderItem; @@ -122,4 +124,23 @@ public class OrderItemServiceImpl extends SkyeyeBusinessServiceImpl queryOrderItemByParentId(String orderId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(MybatisPlusUtil.toColumns(OrderItem::getParentId), orderId); + return list(queryWrapper); + } + + @Override + public void UpdateOrderItemState(String orderItemId) { + OrderItem orderItem = selectById(orderItemId); + if (orderItem.getOrderItemState().equals(CommonNumConstants.NUM_TWO)){ + throw new CustomException("该订单已收货"); + } + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq(CommonConstants.ID, orderItemId); + updateWrapper.set(MybatisPlusUtil.toColumns(OrderItem::getOrderItemState), CommonNumConstants.NUM_TWO); + update(updateWrapper); + } } \ No newline at end of file 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 b4f4ea6a..f13b6e1c 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 @@ -226,9 +226,8 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl if (Objects.equals(couponUse.getDiscountType(), PromotionDiscountType.PERCENT.getKey())) {// 百分比折扣 orderItem = orderItemList.stream().max(Comparator.comparing(OrderItem::getPrice)).orElse(null);// 获取优惠券使用商品列表中,价格最高的商品 } else {// 满减 将优惠券使用到第一个商品 - //卢雨佳 double usePrice = Integer.parseInt(couponUse.getUsePrice());//优惠券使用金额 - if (totalPrice>= usePrice) {//商品价格大于等于优惠券使用金额 + if (totalPrice >= usePrice) {//商品价格大于等于优惠券使用金额 Optional maxPriceItem = orderItemList.stream() .max(Comparator.comparing(OrderItem::getPrice));//获取优惠券使用商品列表中,价格最高的商品 int index = maxPriceItem @@ -237,13 +236,13 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl orderItemList.get(index).setCouponUseId(couponUseId); orderItemList.get(index).setCouponUseMation(JSONUtil.toBean(JSONUtil.toJsonStr(couponUse), null));// 设置mation方便后续计算价格 return; - }else { + } else { throw new CustomException("商品价格不足以使用优惠券"); } } } else if (Objects.equals(couponUse.getProductScope(), PromotionMaterialScope.SPU.getKey())) {// 指定商品 List couponUseMaterialIds = couponUseMaterialService.queryListByCouponIds(Collections.singletonList(couponUseId)) - .stream().map(CouponUseMaterial::getMaterialId).collect(Collectors.toList());// 收集子单商品id + .stream().map(CouponUseMaterial::getMaterialId).collect(Collectors.toList());// 收集子单商品id List newOrderItemList = new ArrayList<>(); for (OrderItem item : orderItemList) { if (couponUseMaterialIds.contains(item.getMaterialId())) { @@ -295,33 +294,33 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl break; case "2": // 待收货 stateList = Arrays.asList(new Integer[]{ - ShopOrderState.UNDELIVERED.getKey(),// 待发货 - ShopOrderState.DELIVERED.getKey(), // 已发货 - ShopOrderState.TRANSPORTING.getKey()});//运输中 + ShopOrderState.UNDELIVERED.getKey(),// 待发货 + ShopOrderState.DELIVERED.getKey(), // 已发货 + ShopOrderState.TRANSPORTING.getKey()});//运输中 break; case "3":// 已完成 stateList = Arrays.asList(new Integer[]{ - ShopOrderState.SIGN.getKey(), // 已签收 - ShopOrderState.COMPLETED.getKey(), // 已完成 - ShopOrderState.UNEVALUATE.getKey(), // 待评价 - ShopOrderState.EVALUATED.getKey()});// 已评价 + ShopOrderState.SIGN.getKey(), // 已签收 + ShopOrderState.COMPLETED.getKey(), // 已完成 + ShopOrderState.UNEVALUATE.getKey(), // 待评价 + ShopOrderState.EVALUATED.getKey()});// 已评价 break; case "4":// 已取消 stateList = Arrays.asList(new Integer[]{ShopOrderState.CANCELED.getKey()}); break; case "5":// 处理中 stateList = Arrays.asList(new Integer[]{ - ShopOrderState.REFUNDING.getKey(), // 退款中 + ShopOrderState.REFUNDING.getKey(), // 退款中 - ShopOrderState.SALESRETURNING.getKey(),//退货中 + ShopOrderState.SALESRETURNING.getKey(),//退货中 - ShopOrderState.EXCHANGEING.getKey()});//换货中 + ShopOrderState.EXCHANGEING.getKey()});//换货中 break; case "6": // 申请记录 stateList = Arrays.asList(new Integer[]{ - ShopOrderState.REFUND.getKey(), // 已退款 - ShopOrderState.SALESRETURNED.getKey(),//已退货 - ShopOrderState.EXCHANGED.getKey()});//已换货 + ShopOrderState.REFUND.getKey(), // 已退款 + ShopOrderState.SALESRETURNED.getKey(),//已退货 + ShopOrderState.EXCHANGED.getKey()});//已换货 } QueryWrapper wrapper = super.getQueryWrapper(commonPageInfo); if (CollectionUtil.isNotEmpty(stateList)) { // 状态列表为空时,则查询全部订单 @@ -358,31 +357,31 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl break; case "2": // 待收货 stateList = Arrays.asList(new Integer[]{ - ShopOrderState.UNDELIVERED.getKey(),// 待发货 - ShopOrderState.DELIVERED.getKey(), // 已发货 - ShopOrderState.TRANSPORTING.getKey()});//运输中 + ShopOrderState.UNDELIVERED.getKey(),// 待发货 + ShopOrderState.DELIVERED.getKey(), // 已发货 + ShopOrderState.TRANSPORTING.getKey()});//运输中 break; case "3":// 已完成 stateList = Arrays.asList(new Integer[]{ - ShopOrderState.SIGN.getKey(), // 已签收 - ShopOrderState.COMPLETED.getKey(), // 已完成 - ShopOrderState.UNEVALUATE.getKey(), // 待评价 - ShopOrderState.EVALUATED.getKey()});// 已评价 + ShopOrderState.SIGN.getKey(), // 已签收 + ShopOrderState.COMPLETED.getKey(), // 已完成 + ShopOrderState.UNEVALUATE.getKey(), // 待评价 + ShopOrderState.EVALUATED.getKey()});// 已评价 break; case "4":// 已取消 stateList = Arrays.asList(new Integer[]{ShopOrderState.CANCELED.getKey()}); break; case "5":// 处理中 stateList = Arrays.asList(new Integer[]{ - ShopOrderState.REFUNDING.getKey(), // 退款中 - ShopOrderState.SALESRETURNING.getKey(),//退货中 - ShopOrderState.EXCHANGEING.getKey()});//换货中 + ShopOrderState.REFUNDING.getKey(), // 退款中 + ShopOrderState.SALESRETURNING.getKey(),//退货中 + ShopOrderState.EXCHANGEING.getKey()});//换货中 break; case "6": // 申请记录 stateList = Arrays.asList(new Integer[]{ - ShopOrderState.REFUND.getKey(), // 已退款 - ShopOrderState.SALESRETURNED.getKey(),//已退货 - ShopOrderState.EXCHANGED.getKey()});//已换货 + ShopOrderState.REFUND.getKey(), // 已退款 + ShopOrderState.SALESRETURNED.getKey(),//已退货 + ShopOrderState.EXCHANGED.getKey()});//已换货 } QueryWrapper wrapper = new QueryWrapper<>(); if (CollectionUtil.isNotEmpty(stateList)) { // 状态列表为空时,则查询全部订单 @@ -490,9 +489,9 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl } // 可取消的订单状态:未提交(0)、已提交(1)、待支付(2)、待发货(5) if (Objects.equals(one.getState(), ShopOrderState.UNSUBMIT.getKey()) || - Objects.equals(one.getState(), ShopOrderState.SUBMIT.getKey()) || - Objects.equals(one.getState(), ShopOrderState.UNPAID.getKey()) || - Objects.equals(one.getState(), ShopOrderState.UNDELIVERED.getKey())) { + Objects.equals(one.getState(), ShopOrderState.SUBMIT.getKey()) || + Objects.equals(one.getState(), ShopOrderState.UNPAID.getKey()) || + Objects.equals(one.getState(), ShopOrderState.UNDELIVERED.getKey())) { updateWrapper.set(MybatisPlusUtil.toColumns(Order::getState), ShopOrderState.CANCELED.getKey()); updateWrapper.set(MybatisPlusUtil.toColumns(Order::getCancelType), params.get("cancelType")); updateWrapper.set(MybatisPlusUtil.toColumns(Order::getCancelTime), DateUtil.getTimeAndToString()); @@ -547,7 +546,7 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl updateWrapper.set(MybatisPlusUtil.toColumns(Order::getPayTime), payOrderRespDTO.get("successTime").toString()); updateWrapper.set(MybatisPlusUtil.toColumns(Order::getChannelFeeRate), payChannel.get("feeRate").toString()); updateWrapper.set(MybatisPlusUtil.toColumns(Order::getChannelFeePrice), CalculationUtil.multiply( - one.getPayPrice(), payChannel.get("feeRate").toString())); + one.getPayPrice(), payChannel.get("feeRate").toString())); updateWrapper.set(MybatisPlusUtil.toColumns(Order::getExtensionId), payOrderRespDTO.get("id").toString()); updateWrapper.set(MybatisPlusUtil.toColumns(Order::getExtensionNo), payOrderRespDTO.get("no").toString()); update(updateWrapper); @@ -604,9 +603,34 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl UpdateWrapper updateWrapper = new UpdateWrapper<>(); updateWrapper.eq(CommonConstants.ID, orderId); updateWrapper.set(MybatisPlusUtil.toColumns(Order::getState), ShopOrderState.CANCELED.getKey()) - .set(MybatisPlusUtil.toColumns(Order::getCancelType), ShopOrderCancelType.PAY_TIMEOUT.getKey()) - .set(MybatisPlusUtil.toColumns(Order::getCancelTime), DateUtil.getTimeAndToString()); + .set(MybatisPlusUtil.toColumns(Order::getCancelType), ShopOrderCancelType.PAY_TIMEOUT.getKey()) + .set(MybatisPlusUtil.toColumns(Order::getCancelTime), DateUtil.getTimeAndToString()); update(updateWrapper); refreshCache(orderId); } + + @Override + public void updateOrderItemState(InputObject inputObject, OutputObject outputObject) { + Map map = inputObject.getParams(); + String orderId = map.get("id").toString(); + String orderItemId = map.get("orderItemId").toString(); + orderItemService.UpdateOrderItemState(orderItemId); + List orderItemList = orderItemService.queryOrderItemByParentId(orderId); + boolean allTwo = orderItemList.stream().map(OrderItem::getOrderItemState) + .allMatch(orderItemState -> orderItemState == CommonNumConstants.NUM_TWO); + if (allTwo) { + Integer numThree = CommonNumConstants.NUM_THREE; + updateOrderState(orderId, numThree); + } else { + Integer numTwo = CommonNumConstants.NUM_TWO; + updateOrderState(orderId, numTwo); + } + } + + private void updateOrderState(String orderId, Integer orderState) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq(CommonConstants.ID, orderId); + updateWrapper.set(MybatisPlusUtil.toColumns(Order::getOrderState), orderState); + update(updateWrapper); + } } \ No newline at end of file From b021d9f90e8bda7caa7c9a58de5e11ebc1b2795d Mon Sep 17 00:00:00 2001 From: luluyuyu <3305167204@qq.com> Date: Thu, 5 Dec 2024 17:07:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat=EF=BC=9A=E4=BF=AE=E6=94=B9=E6=80=BB?= =?UTF-8?q?=E5=8D=95=E5=92=8C=E5=AD=90=E5=8D=95=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/service/impl/OrderServiceImpl.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) 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 b62bda85..a03b65c9 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 @@ -590,4 +590,29 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl update(updateWrapper); refreshCache(orderId); } + + @Override + public void updateOrderItemState(InputObject inputObject, OutputObject outputObject) { + Map map = inputObject.getParams(); + String orderId = map.get("id").toString(); + String orderItemId = map.get("orderItemId").toString(); + orderItemService.UpdateOrderItemState(orderItemId); + List orderItemList = orderItemService.queryOrderItemByParentId(orderId); + boolean allTwo = orderItemList.stream().map(OrderItem::getOrderItemState) + .allMatch(orderItemState -> orderItemState == CommonNumConstants.NUM_TWO); + if (allTwo) { + Integer numThree = CommonNumConstants.NUM_THREE; + updateOrderState(orderId, numThree); + } else { + Integer numTwo = CommonNumConstants.NUM_TWO; + updateOrderState(orderId, numTwo); + } + } + + private void updateOrderState(String orderId, Integer orderState) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq(CommonConstants.ID, orderId); + updateWrapper.set(MybatisPlusUtil.toColumns(Order::getOrderState), orderState); + update(updateWrapper); + } } \ No newline at end of file