|
@@ -1,5 +1,8 @@
|
|
|
package org.dromara.order.controller.pc;
|
|
package org.dromara.order.controller.pc;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import jakarta.validation.constraints.NotNull;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.common.core.domain.R;
|
|
import org.dromara.common.core.domain.R;
|
|
@@ -13,13 +16,14 @@ import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
import org.dromara.common.web.core.BaseController;
|
|
import org.dromara.common.web.core.BaseController;
|
|
|
import org.dromara.customer.api.RemoteCustomerService;
|
|
import org.dromara.customer.api.RemoteCustomerService;
|
|
|
import org.dromara.customer.api.domain.CustomerApiVo;
|
|
import org.dromara.customer.api.domain.CustomerApiVo;
|
|
|
-import org.dromara.order.domain.bo.OrderMainBo;
|
|
|
|
|
-import org.dromara.order.domain.bo.OrderProductBo;
|
|
|
|
|
-import org.dromara.order.domain.bo.PcSubmitOrderBo;
|
|
|
|
|
|
|
+import org.dromara.order.domain.OrderCustomerFlowLink;
|
|
|
|
|
+import org.dromara.order.domain.bo.*;
|
|
|
import org.dromara.order.domain.dto.OrderPayDto;
|
|
import org.dromara.order.domain.dto.OrderPayDto;
|
|
|
import org.dromara.order.domain.vo.OrderMainVo;
|
|
import org.dromara.order.domain.vo.OrderMainVo;
|
|
|
import org.dromara.order.domain.vo.OrderProductVo;
|
|
import org.dromara.order.domain.vo.OrderProductVo;
|
|
|
import org.dromara.order.domain.vo.OrderStatusStats;
|
|
import org.dromara.order.domain.vo.OrderStatusStats;
|
|
|
|
|
+import org.dromara.order.service.IOrderCustomerFlowLinkService;
|
|
|
|
|
+import org.dromara.order.service.IOrderCustomerFlowService;
|
|
|
import org.dromara.order.service.IOrderMainService;
|
|
import org.dromara.order.service.IOrderMainService;
|
|
|
import org.dromara.product.api.RemoteProductService;
|
|
import org.dromara.product.api.RemoteProductService;
|
|
|
import org.dromara.product.api.RemoteProductShoppingCartService;
|
|
import org.dromara.product.api.RemoteProductShoppingCartService;
|
|
@@ -28,8 +32,6 @@ import org.dromara.product.api.domain.RemoteProductShoppingCartVo;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
-import jakarta.validation.constraints.NotNull;
|
|
|
|
|
-
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.time.ZoneOffset;
|
|
import java.time.ZoneOffset;
|
|
@@ -61,6 +63,11 @@ public class PcOrderController extends BaseController {
|
|
|
@DubboReference
|
|
@DubboReference
|
|
|
private RemoteProductShoppingCartService remoteProductShoppingCartService;
|
|
private RemoteProductShoppingCartService remoteProductShoppingCartService;
|
|
|
|
|
|
|
|
|
|
+ //客户订单流程
|
|
|
|
|
+ private final IOrderCustomerFlowService orderCustomerFlowService;
|
|
|
|
|
+
|
|
|
|
|
+ private final IOrderCustomerFlowLinkService orderCustomerFlowLinkService;
|
|
|
|
|
+
|
|
|
private final IOrderMainService orderMainService;
|
|
private final IOrderMainService orderMainService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -142,6 +149,32 @@ public class PcOrderController extends BaseController {
|
|
|
return orderMainService.getCustomerOrderProductList(uniqueOrderIds);
|
|
return orderMainService.getCustomerOrderProductList(uniqueOrderIds);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @GetMapping("/productsWithAvailableQty")
|
|
|
|
|
+ public TableDataInfo<OrderProductVo> getOrderProductsWithAvailableQty(@RequestParam("orderIds") List<Long> orderIds) {
|
|
|
|
|
+ if (orderIds == null || orderIds.isEmpty()) {
|
|
|
|
|
+ throw new IllegalArgumentException("订单ID列表不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (orderIds.size() > 1000) {
|
|
|
|
|
+ throw new IllegalArgumentException("订单ID数量不能超过1000个");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取当前登录用户的企业ID
|
|
|
|
|
+ Long customerId = LoginHelper.getLoginUser().getCustomerId();
|
|
|
|
|
+
|
|
|
|
|
+ // 验证所有订单是否都属于当前用户的企业
|
|
|
|
|
+ for (Long orderId : orderIds) {
|
|
|
|
|
+ OrderMainVo order = orderMainService.queryById(orderId);
|
|
|
|
|
+ if (order == null) {
|
|
|
|
|
+ throw new IllegalArgumentException("订单ID " + orderId + " 不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!customerId.equals(order.getCustomerId())) {
|
|
|
|
|
+ throw new IllegalArgumentException("无权访问订单ID " + orderId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return orderMainService.getOrderProductsWithAvailableQty(orderIds.get(0));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 取消订单
|
|
* 取消订单
|
|
|
* PC端用户只能取消自己企业的订单
|
|
* PC端用户只能取消自己企业的订单
|
|
@@ -237,10 +270,10 @@ public class PcOrderController extends BaseController {
|
|
|
mainBo.setWarehouseId(1L); // TODO: 后续可配置或根据客户动态获取
|
|
mainBo.setWarehouseId(1L); // TODO: 后续可配置或根据客户动态获取
|
|
|
|
|
|
|
|
|
|
|
|
|
- // 设置订单状态为待审核
|
|
|
|
|
|
|
+ // 设置订单状态为待支付
|
|
|
mainBo.setOrderStatus(OrderStatus.PENDING_PAYMENT.getCode());
|
|
mainBo.setOrderStatus(OrderStatus.PENDING_PAYMENT.getCode());
|
|
|
|
|
|
|
|
- // 设置检查状态为待审核
|
|
|
|
|
|
|
+ // 设置审核状态为待审核
|
|
|
mainBo.setCheckStatus("0");
|
|
mainBo.setCheckStatus("0");
|
|
|
|
|
|
|
|
mainBo.setOrderSource(OrderSourceEnum.BEFORE_ADD.getCode());
|
|
mainBo.setOrderSource(OrderSourceEnum.BEFORE_ADD.getCode());
|
|
@@ -306,9 +339,9 @@ public class PcOrderController extends BaseController {
|
|
|
orderProductBo.setProductUnitId(Long.valueOf(productVo.getUnitId()));
|
|
orderProductBo.setProductUnitId(Long.valueOf(productVo.getUnitId()));
|
|
|
orderProductBo.setProductUnit(productVo.getUnitName());
|
|
orderProductBo.setProductUnit(productVo.getUnitName());
|
|
|
orderProductBo.setProductImage(productVo.getProductImageUrl());
|
|
orderProductBo.setProductImage(productVo.getProductImageUrl());
|
|
|
- orderProductBo.setOrderPrice(productVo.getMarketPrice());
|
|
|
|
|
|
|
+ orderProductBo.setOrderPrice(productVo.getMemberPrice());
|
|
|
orderProductBo.setOrderQuantity(quantity);
|
|
orderProductBo.setOrderQuantity(quantity);
|
|
|
- orderProductBo.setSubtotal(productVo.getMarketPrice().multiply(BigDecimal.valueOf(quantity)));
|
|
|
|
|
|
|
+ orderProductBo.setSubtotal(productVo.getMemberPrice().multiply(BigDecimal.valueOf(quantity)));
|
|
|
return orderProductBo;
|
|
return orderProductBo;
|
|
|
})
|
|
})
|
|
|
.filter(Objects::nonNull)
|
|
.filter(Objects::nonNull)
|
|
@@ -322,9 +355,13 @@ public class PcOrderController extends BaseController {
|
|
|
|
|
|
|
|
// 5. 保存订单(关键:成功后再删除购物车)
|
|
// 5. 保存订单(关键:成功后再删除购物车)
|
|
|
Long orderId = orderMainService.insertByBo(mainBo);
|
|
Long orderId = orderMainService.insertByBo(mainBo);
|
|
|
- if (orderId != null && orderId > 0 && bo.getPlaceOrderType() == 1) {
|
|
|
|
|
- // 成功下单后,删除对应的购物车项
|
|
|
|
|
- remoteProductShoppingCartService.deleteWithValidByIds(bo.getProductShoppingCartId());
|
|
|
|
|
|
|
+ if (orderId != null && orderId > 0) {
|
|
|
|
|
+ //初始化审批流程
|
|
|
|
|
+ orderCustomerFlowService.initOrderFlow(orderId);
|
|
|
|
|
+ if(bo.getPlaceOrderType() == 1){
|
|
|
|
|
+ // 成功下单后,删除对应的购物车项
|
|
|
|
|
+ remoteProductShoppingCartService.deleteWithValidByIds(productShoppingCartIds);
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
throw new RuntimeException("订单创建失败");
|
|
throw new RuntimeException("订单创建失败");
|
|
|
}
|
|
}
|
|
@@ -353,4 +390,55 @@ public class PcOrderController extends BaseController {
|
|
|
|
|
|
|
|
return R.ok(orderPayResult);
|
|
return R.ok(orderPayResult);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/batchConfirmation")
|
|
|
|
|
+ public R<Void> batchConfirmation(@RequestParam("orderIds") List<Long> orderIds) {
|
|
|
|
|
+ if (orderIds == null || orderIds.isEmpty()) {
|
|
|
|
|
+ throw new IllegalArgumentException("订单ID列表不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (orderIds.size() > 1000) {
|
|
|
|
|
+ throw new IllegalArgumentException("订单ID数量不能超过1000个");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取当前登录用户的企业ID
|
|
|
|
|
+ Long customerId = LoginHelper.getLoginUser().getCustomerId();
|
|
|
|
|
+
|
|
|
|
|
+ // 验证所有订单是否都属于当前用户的企业
|
|
|
|
|
+ for (Long orderId : orderIds) {
|
|
|
|
|
+ OrderMainVo order = orderMainService.queryById(orderId);
|
|
|
|
|
+ if (order == null) {
|
|
|
|
|
+ throw new IllegalArgumentException("订单ID " + orderId + " 不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!customerId.equals(order.getCustomerId())) {
|
|
|
|
|
+ throw new IllegalArgumentException("无权访问订单ID " + orderId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Set<Long> uniqueOrderIds = new HashSet<>(orderIds);
|
|
|
|
|
+ return toAjax(orderMainService.batchConfirmation(uniqueOrderIds));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 订单审核(PC端审核)
|
|
|
|
|
+ */
|
|
|
|
|
+ @Log(title = "PC端-订单审核", businessType = BusinessType.UPDATE)
|
|
|
|
|
+ @PostMapping("/checkOrder")
|
|
|
|
|
+ public R<?> checkOrder(@RequestBody @Validated PcCheckOrderBo checkOrderBo) {
|
|
|
|
|
+// Long customerId = LoginHelper.getLoginUser().getCustomerId();
|
|
|
|
|
+//
|
|
|
|
|
+// Long userId = LoginHelper.getLoginUser().getUserId();
|
|
|
|
|
+
|
|
|
|
|
+ OrderCustomerFlowLinkBo bo = new OrderCustomerFlowLinkBo();
|
|
|
|
|
+ List<OrderCustomerFlowLink> flowLinks = orderCustomerFlowLinkService.list(new LambdaQueryWrapper<OrderCustomerFlowLink>().eq(OrderCustomerFlowLink::getOrderId, checkOrderBo.getOrderId()));
|
|
|
|
|
+ if (CollUtil.isNotEmpty(flowLinks)) {
|
|
|
|
|
+ bo.setNodeId(flowLinks.get(0).getNodeId());
|
|
|
|
|
+ }
|
|
|
|
|
+ bo.setOrderId(checkOrderBo.getOrderId());
|
|
|
|
|
+ bo.setReviewStatus(Long.valueOf(checkOrderBo.getCheckStatus()));
|
|
|
|
|
+ bo.setReason(checkOrderBo.getCheckRemark());
|
|
|
|
|
+ bo.setReason(checkOrderBo.getCheckRemark());
|
|
|
|
|
+ orderCustomerFlowService.auditOrderFlow(bo);
|
|
|
|
|
+
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|