|
|
@@ -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))) {
|