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 e22be721..36dbeb44 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 7d7eb2b6..a45ad4de 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