Przeglądaj źródła

用户更多服务——下单(添加判断避免重复提交订单)

wangyu 6 lat temu
rodzic
commit
578a2869a9

+ 3 - 1
diagbotman-service/src/main/java/com/diagbot/facade/LantoneProductFacade.java

@@ -43,6 +43,8 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
     private OpenedProductsFacade openedProductsFacade;
     @Autowired
     private UserServiceClient userServiceClient;
+    @Autowired
+    private OrderDetailsFacade orderDetailsFacade;
 
     /**
      * 产品线管理添加产品
@@ -157,7 +159,7 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
         List<ProductLineDTO> productLineDTOList = this.productLines();//所有产品
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
         List<Long> opendId = openedProductsFacade.getOpendCountByUserId(userId);
-        List<Long> orderDetailsId = openedProductsFacade.getOpendCountByUserId(userId);
+        List<Long> orderDetailsId = orderDetailsFacade.getOrderDetailsByUser(userId);
         for (ProductLineDTO productLineDTO:productLineDTOList) {
             productLineDTO.setProductAudit(ProductAuditEnum.NotOpend.getKey());
             for (int i =0; i<opendId.size();i++){

+ 16 - 2
diagbotman-service/src/main/java/com/diagbot/facade/ProductOrderFacade.java

@@ -107,6 +107,20 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
     @Transactional
     public Boolean addOrders(AddOrderVO addOrderVO) {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
+        List<Long> opendId = openedProductsFacade.getOpendCountByUserId(userId);
+        List<Long> orderDetailsId = orderDetailsFacade.getOrderDetailsByUser(userId);
+        for (int i =0; i<addOrderVO.getProductId().size();i++){
+            for (int j =0; j<opendId.size();j++){
+                if(addOrderVO.getProductId().get(i)==opendId.get(j)){
+                    throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请勿重复提交已开通产品:");
+                }
+            }
+            for (int k =0; k<orderDetailsId.size();k++){
+                if(addOrderVO.getProductId().get(i)==orderDetailsId.get(k)){
+                    throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "产品正在审核中请勿重复提交:");
+                }
+            }
+        }
         ProductOrder productOrder = new ProductOrder();
         productOrder.setCreator(UserUtils.getCurrentPrincipleID());
         productOrder.setGmtCreate(DateUtil.now());
@@ -133,9 +147,9 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
         if (0 == lantoneProductFacade.listByIds(lantoneProductId).size()) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "获取产品信息失败:");
         }
-        if(orderDetailsFacade.saveOrderDetails(list)){
+        /*if(orderDetailsFacade.saveOrderDetails(list)){
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "添加订单失败");
-        }
+        }*/
         return true;
     }