Răsfoiți Sursa

贸易订单提交加入双方企业合作关系校验

yzc 2 ani în urmă
părinte
comite
2a40bc4f4a

+ 5 - 0
sckw-modules/sckw-order/pom.xml

@@ -91,6 +91,11 @@
             <groupId>com.sckw</groupId>
             <artifactId>sckw-transport-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-manage-api</artifactId>
+            <version>1.0.0</version>
+        </dependency>
 
     </dependencies>
 

+ 9 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/dto/OrderCheckDTO.java

@@ -48,10 +48,19 @@ public class OrderCheckDTO {
      */
     private Long procureTopEntId;
 
+    /**
+     * 采购企业id
+     */
+    private Long procureEntId;
+
     /**
      * 供应一级企业id
      */
     private Long supplyTopEntId;
+    /**
+     * 供应企业id
+     */
+    private Long supplyEntId;
 
     /**
      * 订单来源 1采购下单2代客下单

+ 5 - 5
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/dto/TransportDemandExport.java

@@ -29,15 +29,15 @@ public class TransportDemandExport implements Serializable {
     @ExcelProperty(value = "分类", index = 2)
     private String goodsTypeLabel;
 
-    @ExcelProperty(value = "规格", index = 3)
-    private String spec;
-
-    @ExcelProperty(value = "运需单价", index = 4)
+    @ExcelProperty(value = "运需单价", index = 3)
     private String price;
 
-    @ExcelProperty(value = "总计划量", index = 5)
+    @ExcelProperty(value = "总计划量", index = 4)
     private String amount;
 
+    @ExcelProperty(value = "商品规格", index = 5)
+    private String spec;
+
     @ExcelProperty(value = "装货地址", index = 6)
     private String loadAddress;
 

+ 25 - 9
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java

@@ -10,6 +10,7 @@ import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.exception.CustomPromptException;
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.enums.CooperateTypeEnum;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.OrderGenerateUtils;
@@ -17,6 +18,8 @@ import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.manage.api.RemoteManageService;
+import com.sckw.manage.api.model.dto.res.FindEntCooperateResVo;
 import com.sckw.mongo.model.SckwTradeOrder;
 import com.sckw.order.dao.KwoTradeOrderMapper;
 import com.sckw.order.model.*;
@@ -62,6 +65,9 @@ public class KwoTradeOrderService {
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
 
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private RemoteManageService remoteManageService;
+
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private GoodsInfoService goodsInfoService;
 
@@ -275,15 +281,18 @@ public class KwoTradeOrderService {
         List<Long> entIds = unitInfo.stream().map(UnitInfo::getEntId).toList();
         Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntTreeByIds(entIds);
         unitInfo.forEach(e -> {
-            EntCacheResDto ent = entMap.get(e.getEntId());
+            Long entId = e.getEntId();
+            EntCacheResDto ent = entMap.get(entId);
             if (Objects.isNull(ent)) {
-                log.error("企业:{}找不到对应一级企业信息", e.getEntId());
+                log.error("企业:{}找不到对应一级企业信息", entId);
                 throw new BusinessException("一级企业信息不存在!");
             }
             if (Objects.equals(e.getUnitType(), DictEnum.TORDER_UNIT_TYPE_1.getValue())) {
-                orderCheckDTO.setProcureTopEntId(entMap.get(e.getEntId()).getId());
+                orderCheckDTO.setProcureTopEntId(ent.getId());
+                orderCheckDTO.setProcureEntId(entId);
             } else {
-                orderCheckDTO.setSupplyTopEntId(entMap.get(e.getEntId()).getId());
+                orderCheckDTO.setSupplyTopEntId(ent.getId());
+                orderCheckDTO.setSupplyEntId(entId);
             }
         });
     }
@@ -300,8 +309,15 @@ public class KwoTradeOrderService {
         BigDecimal amount = param.getAmount();
         String trading = param.getTrading();
         BigDecimal price = param.getPrice();
-        if (!isAcceptanceOrder && price.compareTo(amount.multiply(param.getUnitPrice())) != 0) {
-            throw new BusinessException("订单总金额不等于商品单价*订单总量!");
+        if (!isAcceptanceOrder) {
+            if (price.compareTo(amount.multiply(param.getUnitPrice())) != 0) {
+                throw new BusinessException("订单总金额不等于商品单价*订单总量!");
+            }
+            List<FindEntCooperateResVo> entCooperate = remoteManageService.findEntCooperate(param.getProcureEntId()
+                    , param.getSupplyEntId(), CooperateTypeEnum.SUPPLIER.getCode());
+            if (CollectionUtils.isEmpty(entCooperate)) {
+                throw new BusinessException("供采双方企业无合作关系!");
+            }
         }
         KwpGoods goods = goodsInfoService.getGoodsById(param.getGoodsId());
         if (Objects.isNull(goods) || Objects.equals(goods.getDelFlag(), Global.YES) || !Objects.equals(goods.getStatus(), 1)) {
@@ -767,10 +783,10 @@ public class KwoTradeOrderService {
             throw new BusinessException("执行中的订单才能完结订单!");
         }
         if (kwoTradeOrderUnitService.entMatch(param.getId(), LoginUserHolder.getEntId(), DictEnum.TORDER_UNIT_TYPE_2.getValue())) {
-            throw new CustomPromptException("无订单操作权限!");
+            throw new BusinessException("无订单操作权限!");
         }
-        if (transportDubboService.checkLogisticsOrderByTradeOrderId(param.getId())){
-            throw new BusinessException("订单存在未完成的物流托运,不可完结!");
+        if (transportDubboService.checkLogisticsOrderByTradeOrderId(param.getId())) {
+            throw new CustomPromptException("订单存在未完成的物流托运,不可完结!");
         }
         String lockKey = String.format(RedisConstant.TORDER_UPDATE_AMOUNT_KEY, param.getId());
         if (Boolean.FALSE.equals(RedissonUtils.tryLock(lockKey, 5L, 10L))) {