|
|
@@ -128,8 +128,12 @@ public class KwoTradeOrderService {
|
|
|
List<Long> entIds = unitInfos.stream().map(UnitInfo::getEntId).distinct().toList();
|
|
|
Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntTreeByIds(entIds);
|
|
|
unitInfos.forEach(e -> {
|
|
|
+ EntCacheResDto ent = entMap.get(e.getEntId());
|
|
|
+ if (Objects.isNull(ent)) {
|
|
|
+ throw new BusinessException("企业:" + e.getFirmName() + "的一级企业信息不存在!");
|
|
|
+ }
|
|
|
KwoTradeOrderUnit unit = BeanUtils.copyProperties(e, KwoTradeOrderUnit.class);
|
|
|
- unit.setTOrderId(id).setTOrderNo(tOrderNo).setTopEntId(entMap.get(e.getEntId()).getId());
|
|
|
+ unit.setTOrderId(id).setTOrderNo(tOrderNo).setTopEntId(ent.getId());
|
|
|
list.add(unit);
|
|
|
if (Objects.equals(e.getUnitType(), DictEnum.TORDER_UNIT_TYPE_1.getValue())) {
|
|
|
order.setProcureEntId(e.getEntId()).setProcureTopEntId(unit.getTopEntId()).setProcureFirmName(e.getFirmName())
|
|
|
@@ -223,9 +227,14 @@ public class KwoTradeOrderService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void addPurchaseOrderSubmit(PurchaseOrderParam param) {
|
|
|
+ GoodsInfo goodsInfo = param.getGoodsInfo();
|
|
|
+ if (Objects.isNull(goodsInfo.getPriceRangeId())) {
|
|
|
+ throw new BusinessException("采购下单价格梯度信息不能为空!");
|
|
|
+ }
|
|
|
OrderCheckDTO orderCheckDTO = BeanUtils.copyProperties(param, OrderCheckDTO.class);
|
|
|
getTopEnt(orderCheckDTO, param.getUnitInfo());
|
|
|
- orderCheckDTO.setGoodsId(param.getGoodsInfo().getGoodsId()).setUnitPrice(param.getGoodsInfo().getUnitPrice());
|
|
|
+ orderCheckDTO.setGoodsId(goodsInfo.getGoodsId()).setUnitPrice(goodsInfo.getUnitPrice())
|
|
|
+ .setOrderSource(DictEnum.TORDER_SOURCE_1.getValue());
|
|
|
orderCheck(orderCheckDTO, false);
|
|
|
KwoTradeOrder order = BeanUtils.copyProperties(param, KwoTradeOrder.class);
|
|
|
order.setEntId(LoginUserHolder.getEntId()).setTOrderNo(OrderGenerateUtils.generateOrderNo(ORDER_NO_PREFIX))
|
|
|
@@ -252,6 +261,11 @@ 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());
|
|
|
+ if (Objects.isNull(ent)) {
|
|
|
+ log.error("企业:{}找不到对应一级企业信息", e.getEntId());
|
|
|
+ throw new BusinessException("一级企业信息不存在!");
|
|
|
+ }
|
|
|
if (Objects.equals(e.getUnitType(), DictEnum.TORDER_UNIT_TYPE_1.getValue())) {
|
|
|
orderCheckDTO.setProcureTopEntId(entMap.get(e.getEntId()).getId());
|
|
|
} else {
|
|
|
@@ -283,11 +297,11 @@ public class KwoTradeOrderService {
|
|
|
throw new BusinessException("商品库存不足,请联系供应方!");
|
|
|
}
|
|
|
BigDecimal advancePrice = goods.getAdvancePrice().multiply(new BigDecimal("10000"));
|
|
|
- //受理订单不校验预付款限额
|
|
|
- if (!isAcceptanceOrder && trading.startsWith("0") && price.compareTo(advancePrice) < 0) {
|
|
|
+ //直接采购下单才校验预付款限额
|
|
|
+ if (Objects.equals(param.getOrderSource(), DictEnum.TORDER_SOURCE_1.getValue()) && trading.startsWith("1") && price.compareTo(advancePrice) < 0) {
|
|
|
throw new BusinessException("您的订单总额未达到预付限额,请确认");
|
|
|
}
|
|
|
- if (trading.startsWith("0")) {
|
|
|
+ if (trading.startsWith("1")) {
|
|
|
R<List<WalletDto>> wallet = payCenterDubboService.wallet(param.getProcureTopEntId(), ChannelEnum.getByCode(trading), param.getSupplyTopEntId());
|
|
|
if (Objects.isNull(wallet) || Objects.equals(wallet.getCode(), 0)) {
|
|
|
throw new BusinessException("校验预付钱包异常,请联系管理员!");
|
|
|
@@ -297,7 +311,7 @@ public class KwoTradeOrderService {
|
|
|
throw new BusinessException("检测尚未创建对应预付款清单,请先创建!");
|
|
|
}
|
|
|
long money = data.get(0).getMoney();
|
|
|
- if (money < advancePrice.multiply(new BigDecimal("10000")).longValueExact()) {
|
|
|
+ if (money < advancePrice.multiply(new BigDecimal("100")).longValueExact()) {
|
|
|
throw new BusinessException("您的预付清单可用余额不足,请先充值!");
|
|
|
}
|
|
|
}
|
|
|
@@ -314,7 +328,8 @@ public class KwoTradeOrderService {
|
|
|
public void addValetOrderSubmit(ValetOrderParam param) {
|
|
|
OrderCheckDTO orderCheck = BeanUtils.copyProperties(param, OrderCheckDTO.class);
|
|
|
getTopEnt(orderCheck, param.getUnitInfo());
|
|
|
- orderCheck.setGoodsId(param.getGoodsInfo().getGoodsId()).setUnitPrice(param.getGoodsInfo().getUnitPrice());
|
|
|
+ orderCheck.setGoodsId(param.getGoodsInfo().getGoodsId()).setUnitPrice(param.getGoodsInfo().getUnitPrice())
|
|
|
+ .setOrderSource(DictEnum.TORDER_SOURCE_2.getValue());
|
|
|
orderCheck(orderCheck, false);
|
|
|
KwoTradeOrder order = BeanUtils.copyProperties(param, KwoTradeOrder.class);
|
|
|
order.setEntId(LoginUserHolder.getEntId()).setTOrderNo(OrderGenerateUtils.generateOrderNo(ORDER_NO_PREFIX))
|
|
|
@@ -450,7 +465,8 @@ public class KwoTradeOrderService {
|
|
|
}
|
|
|
OrderCheckDTO orderCheck = BeanUtils.copyProperties(param, OrderCheckDTO.class);
|
|
|
getTopEnt(orderCheck, param.getUnitInfo());
|
|
|
- orderCheck.setGoodsId(param.getGoodsInfo().getGoodsId()).setUnitPrice(param.getGoodsInfo().getUnitPrice());
|
|
|
+ orderCheck.setGoodsId(param.getGoodsInfo().getGoodsId()).setUnitPrice(param.getGoodsInfo().getUnitPrice())
|
|
|
+ .setOrderSource(source);
|
|
|
orderCheck(orderCheck, false);
|
|
|
//扣减库存
|
|
|
HttpResult updateResult = goodsInfoService.updateGoodsAmount(param.getGoodsInfo().getGoodsId(), param.getAmount());
|