|
@@ -8,6 +8,7 @@ import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
@@ -52,11 +53,14 @@ import com.sckw.order.model.vo.res.*;
|
|
|
import com.sckw.order.model.vo.res.GoodsInfoDetailRes;
|
|
import com.sckw.order.model.vo.res.GoodsInfoDetailRes;
|
|
|
import com.sckw.order.model.vo.res.OrderDetailRes;
|
|
import com.sckw.order.model.vo.res.OrderDetailRes;
|
|
|
import com.sckw.order.model.vo.res.UnitInfoDetailRes;
|
|
import com.sckw.order.model.vo.res.UnitInfoDetailRes;
|
|
|
|
|
+import com.sckw.order.repository.KwoTradeOrderUnitRepository;
|
|
|
import com.sckw.payment.api.dubbo.PayCenterDubboService;
|
|
import com.sckw.payment.api.dubbo.PayCenterDubboService;
|
|
|
import com.sckw.payment.api.dubbo.PaymentDubboService;
|
|
import com.sckw.payment.api.dubbo.PaymentDubboService;
|
|
|
|
|
+import com.sckw.payment.api.feign.OfflineWalletFeignService;
|
|
|
import com.sckw.payment.api.model.WalletFreeze;
|
|
import com.sckw.payment.api.model.WalletFreeze;
|
|
|
import com.sckw.payment.api.model.constant.ChannelEnum;
|
|
import com.sckw.payment.api.model.constant.ChannelEnum;
|
|
|
import com.sckw.payment.api.model.dto.WalletDto;
|
|
import com.sckw.payment.api.model.dto.WalletDto;
|
|
|
|
|
+import com.sckw.payment.api.model.dto.WalletFreezeDto;
|
|
|
import com.sckw.payment.api.model.dto.common.R;
|
|
import com.sckw.payment.api.model.dto.common.R;
|
|
|
import com.sckw.product.api.dubbo.GoodsInfoService;
|
|
import com.sckw.product.api.dubbo.GoodsInfoService;
|
|
|
import com.sckw.product.api.model.AddressInfoDetail;
|
|
import com.sckw.product.api.model.AddressInfoDetail;
|
|
@@ -132,6 +136,8 @@ public class KwoTradeOrderService {
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
|
|
@DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
|
|
|
protected RemoteFleetService remoteFleetService;
|
|
protected RemoteFleetService remoteFleetService;
|
|
|
|
|
|
|
|
|
|
+ private final OfflineWalletFeignService offlineWalletFeignService;
|
|
|
|
|
+
|
|
|
private final KwoTradeOrderMapper kwoTradeOrderMapper;
|
|
private final KwoTradeOrderMapper kwoTradeOrderMapper;
|
|
|
private final StreamBridge streamBridge;
|
|
private final StreamBridge streamBridge;
|
|
|
private final KwoTradeOrderAddressService kwoTradeOrderAddressService;
|
|
private final KwoTradeOrderAddressService kwoTradeOrderAddressService;
|
|
@@ -142,6 +148,7 @@ public class KwoTradeOrderService {
|
|
|
private final KwoTradeOrderGoodsUnitService kwoTradeOrderGoodsUnitService;
|
|
private final KwoTradeOrderGoodsUnitService kwoTradeOrderGoodsUnitService;
|
|
|
private final KwoTradeOrderAmountService tradeOrderAmountService;
|
|
private final KwoTradeOrderAmountService tradeOrderAmountService;
|
|
|
private final KwoTradeOrderTransportService kwoTradeOrderTransportService;
|
|
private final KwoTradeOrderTransportService kwoTradeOrderTransportService;
|
|
|
|
|
+ private final KwoTradeOrderUnitRepository kwoTradeOrderUnitRepository;
|
|
|
@Value("${url.order.list.valet.pc}")
|
|
@Value("${url.order.list.valet.pc}")
|
|
|
private String pcValetListUrl;
|
|
private String pcValetListUrl;
|
|
|
|
|
|
|
@@ -1811,6 +1818,66 @@ public class KwoTradeOrderService {
|
|
|
* @Param params:
|
|
* @Param params:
|
|
|
* @return: java.util.List<com.sckw.report.service.param.TradeOrderListExport>
|
|
* @return: java.util.List<com.sckw.report.service.param.TradeOrderListExport>
|
|
|
*/
|
|
*/
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public TradeOrderCountResp countStatistic() {
|
|
|
|
|
+ Long entId = LoginUserHolder.getEntId();
|
|
|
|
|
+ Set<Long> tradeOrderIds = kwoTradeOrderUnitRepository
|
|
|
|
|
+ .queryByEntIdAndUnitType(entId, OrderUnitTypeEnum.PURCHASE.getType())
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .map(KwoTradeOrderUnit::getTOrderId)
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
|
+
|
|
|
|
|
+ Long totalCount = 0L;
|
|
|
|
|
+ Map<Integer, Long> statusCountMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(tradeOrderIds)) {
|
|
|
|
|
+ QueryWrapper<KwoTradeOrder> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapper.select("status", "COUNT(1) AS statusCount")
|
|
|
|
|
+ .eq("del_flag", Global.NO)
|
|
|
|
|
+ .in("id", tradeOrderIds)
|
|
|
|
|
+ .groupBy("status")
|
|
|
|
|
+ .orderByAsc("status");
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, Object>> statisticMaps = kwoTradeOrderMapper.selectMaps(queryWrapper);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(statisticMaps)) {
|
|
|
|
|
+ statusCountMap = statisticMaps.stream()
|
|
|
|
|
+ .filter(item -> Objects.nonNull(item.get("status")))
|
|
|
|
|
+ .collect(Collectors.toMap(item -> Integer.parseInt(String.valueOf(item.get("status"))),
|
|
|
|
|
+ item -> Long.parseLong(String.valueOf(item.get("statusCount"))),
|
|
|
|
|
+ Long::sum));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ totalCount = Optional.ofNullable(kwoTradeOrderMapper.selectCount(
|
|
|
|
|
+ new LambdaQueryWrapper<KwoTradeOrder>()
|
|
|
|
|
+ .eq(KwoTradeOrder::getDelFlag, Global.NO)
|
|
|
|
|
+ .in(KwoTradeOrder::getId, tradeOrderIds))).orElse(0L);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Set<Integer> statuses = new TreeSet<>();
|
|
|
|
|
+ TradeOrderStatusEnum.getSortList().stream().map(TradeOrderStatusEnum::getCode).forEach(statuses::add);
|
|
|
|
|
+ statuses.addAll(statusCountMap.keySet());
|
|
|
|
|
+
|
|
|
|
|
+ List<TradeOrderCountResp.TradeOrderCountItem> items = new ArrayList<>(statuses.size());
|
|
|
|
|
+ for (Integer status : statuses) {
|
|
|
|
|
+ TradeOrderCountResp.TradeOrderCountItem item = new TradeOrderCountResp.TradeOrderCountItem();
|
|
|
|
|
+ item.setStatus(status)
|
|
|
|
|
+ .setStatusDesc(getTradeOrderStatusDesc(status))
|
|
|
|
|
+ .setStatusCount(statusCountMap.getOrDefault(status, 0L));
|
|
|
|
|
+ items.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ return new TradeOrderCountResp().setTotalCount(totalCount).setItems(items);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String getTradeOrderStatusDesc(Integer status) {
|
|
|
|
|
+ String statusDesc = TradeOrderStatusEnum.getMsg(status);
|
|
|
|
|
+ if (StrUtil.isNotBlank(statusDesc)) {
|
|
|
|
|
+ return statusDesc;
|
|
|
|
|
+ }
|
|
|
|
|
+ statusDesc = OrderStatusEnum.getMsg(status);
|
|
|
|
|
+ return StrUtil.isNotBlank(statusDesc) ? statusDesc : "unknown";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public List<TradeOrderListExport> export(TradeOrderListExportParam params) {
|
|
public List<TradeOrderListExport> export(TradeOrderListExportParam params) {
|
|
|
TradeOrderListSelectDTO dto = new TradeOrderListSelectDTO();
|
|
TradeOrderListSelectDTO dto = new TradeOrderListSelectDTO();
|
|
|
List<Long> ids = new ArrayList<>();
|
|
List<Long> ids = new ArrayList<>();
|
|
@@ -1948,6 +2015,34 @@ public class KwoTradeOrderService {
|
|
|
KwpGoods goodsById = goodsInfoService.getGoodsById(tradeOrderParam.getGoodsId());
|
|
KwpGoods goodsById = goodsInfoService.getGoodsById(tradeOrderParam.getGoodsId());
|
|
|
|
|
|
|
|
TradeContractResDto tradeContractResDto = checkPara(tradeOrderParam, order, goodsById);
|
|
TradeContractResDto tradeContractResDto = checkPara(tradeOrderParam, order, goodsById);
|
|
|
|
|
+
|
|
|
|
|
+ // ====== 下单前校验 start ======
|
|
|
|
|
+ // 1. 验证线下钱包预付余额是否足够,不足则提示"线下钱包预付余额不足"
|
|
|
|
|
+ checkWallet(order);
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 验证商品是否开启库存(amount不为null代表已开启库存,null代表无限库存无需验证)
|
|
|
|
|
+ if (goodsById.getAmount() != null && goodsById.getAmount().compareTo(tradeOrderParam.getAmount()) < 0) {
|
|
|
|
|
+ if (!Boolean.TRUE.equals(tradeOrderParam.getConfirmInsufficientStock())) {
|
|
|
|
|
+ throw new CustomPromptException(HttpStatus.STOCK_INSUFFICIENT_CONFIRM_CODE, "当前库存可能不足,是否依旧下单?");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 记录钱包金额账数据,类型为冻结,备注为"贸易订单号:xxx 下单冻结"
|
|
|
|
|
+ // TODO: 后续对接外部系统,记录钱包流水
|
|
|
|
|
+ // recordWalletTransaction(buyEntId, order.getPrice(), "冻结", "贸易订单号:" + order.getTOrderNo() + " 下单冻结");
|
|
|
|
|
+
|
|
|
|
|
+ // 5. 验证贸易合同限量采购,若为限量采购则校验剩余可采购数量并扣减本次下单量
|
|
|
|
|
+ GoodsInfoDto contractGoodsInfo = tradeContractResDto.getGoodsInfoDto();
|
|
|
|
|
+ if (contractGoodsInfo.getAmount() != null && contractGoodsInfo.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ BigDecimal performed = contractGoodsInfo.getPerformedAmount() != null ? contractGoodsInfo.getPerformedAmount() : BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal remaining = contractGoodsInfo.getAmount().subtract(performed);
|
|
|
|
|
+ if (tradeOrderParam.getAmount().compareTo(remaining) > 0) {
|
|
|
|
|
+ throw new BusinessException("当前贸易合同该商品为限量采购,剩余可采购数量为" + remaining.stripTrailingZeros().toPlainString() + ",本次下单数量超出限额");
|
|
|
|
|
+ }
|
|
|
|
|
+ remoteContractService.updateTradeContractGoodsPerformed(tradeOrderParam.getTradeContractId(), tradeOrderParam.getGoodsId(), tradeOrderParam.getAmount());
|
|
|
|
|
+ }
|
|
|
|
|
+ // ====== 下单前校验 end ======
|
|
|
|
|
+
|
|
|
WalletFreeze walletFreeze = new WalletFreeze();
|
|
WalletFreeze walletFreeze = new WalletFreeze();
|
|
|
walletFreeze.setOrderNo(order.getTOrderNo());
|
|
walletFreeze.setOrderNo(order.getTOrderNo());
|
|
|
walletFreeze.setMoney(order.getPrice());
|
|
walletFreeze.setMoney(order.getPrice());
|
|
@@ -2062,7 +2157,7 @@ public class KwoTradeOrderService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
List<TradeContractUnitDto> unitList = tradeContractResDto.getUnitList();
|
|
List<TradeContractUnitDto> unitList = tradeContractResDto.getUnitList();
|
|
|
-
|
|
|
|
|
|
|
+ WalletFreezeDto freezeDto = new WalletFreezeDto();
|
|
|
List<KwoTradeOrderUnit> list = new ArrayList<>();
|
|
List<KwoTradeOrderUnit> list = new ArrayList<>();
|
|
|
unitList.forEach(e -> {
|
|
unitList.forEach(e -> {
|
|
|
KwoTradeOrderUnit unit = BeanUtil.copyProperties(e, KwoTradeOrderUnit.class);
|
|
KwoTradeOrderUnit unit = BeanUtil.copyProperties(e, KwoTradeOrderUnit.class);
|
|
@@ -2071,9 +2166,11 @@ public class KwoTradeOrderService {
|
|
|
unit.setUnitType(StrUtil.equals(e.getUnitType(), "1") ? "2" : "1");//贸易合同和订单的单位类型相反
|
|
unit.setUnitType(StrUtil.equals(e.getUnitType(), "1") ? "2" : "1");//贸易合同和订单的单位类型相反
|
|
|
if (StrUtil.equals(unit.getUnitType(), "1")) {
|
|
if (StrUtil.equals(unit.getUnitType(), "1")) {
|
|
|
walletFreeze.setBuyEntId(unit.getEntId());
|
|
walletFreeze.setBuyEntId(unit.getEntId());
|
|
|
|
|
+ freezeDto.setProEntId(unit.getEntId());
|
|
|
}
|
|
}
|
|
|
if (StrUtil.equals(unit.getUnitType(), "2")) {
|
|
if (StrUtil.equals(unit.getUnitType(), "2")) {
|
|
|
walletFreeze.setSaleEntId(unit.getEntId());
|
|
walletFreeze.setSaleEntId(unit.getEntId());
|
|
|
|
|
+ freezeDto.setSupEntId(unit.getEntId());
|
|
|
}
|
|
}
|
|
|
list.add(unit);
|
|
list.add(unit);
|
|
|
});
|
|
});
|
|
@@ -2083,7 +2180,128 @@ public class KwoTradeOrderService {
|
|
|
if (booleanBaseResult.getCode() != 60200) {
|
|
if (booleanBaseResult.getCode() != 60200) {
|
|
|
throw new BusinessException(booleanBaseResult.getMessage());
|
|
throw new BusinessException(booleanBaseResult.getMessage());
|
|
|
}
|
|
}
|
|
|
|
|
+ // 3. 线下钱包扣减预付余额、增加冻结金额
|
|
|
|
|
+ walletFreeze(tradeOrderParam, order,freezeDto);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void walletFreeze(TradeOrderParam tradeOrderParam, KwoTradeOrder order,WalletFreezeDto freezeDto) {
|
|
|
|
|
+
|
|
|
|
|
+ freezeDto.setFreezeAmount(tradeOrderParam.getAmount());
|
|
|
|
|
+ freezeDto.setOrderNo(order.getTOrderNo());
|
|
|
|
|
+
|
|
|
|
|
+ BaseResult<Boolean> balanceResult;
|
|
|
|
|
+ try {
|
|
|
|
|
+ balanceResult = offlineWalletFeignService.freezeBalance(freezeDto);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("线下钱包扣减预付余额、增加冻结金额异常", e);
|
|
|
|
|
+ throw new BusinessException("线下钱包扣减预付余额、增加冻结金额异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (balanceResult == null || balanceResult.getCode() != HttpStatus.SUCCESS_CODE) {
|
|
|
|
|
+ throw new BusinessException("线下钱包扣减预付余额、增加冻结金额失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ Boolean aBoolean = balanceResult.getData();
|
|
|
|
|
+ if (!Boolean.TRUE.equals(aBoolean)) {
|
|
|
|
|
+ throw new BusinessException("线下钱包扣减预付余额、增加冻结金额失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void checkWallet(KwoTradeOrder order) {
|
|
|
|
|
+ BaseResult<BigDecimal> balanceResult;
|
|
|
|
|
+ try {
|
|
|
|
|
+ balanceResult = offlineWalletFeignService.queryPrepaidBalance(LoginUserHolder.getEntId());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("查询线下钱包服务异常", e);
|
|
|
|
|
+ throw new BusinessException("查询线下钱包服务异常,请稍后再试");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (balanceResult == null || balanceResult.getCode() != HttpStatus.SUCCESS_CODE) {
|
|
|
|
|
+ throw new BusinessException("查询线下钱包预付余额失败,请稍后再试");
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal prepaidBalance = balanceResult.getData();
|
|
|
|
|
+ if (prepaidBalance == null || prepaidBalance.compareTo(order.getPrice()) < 0) {
|
|
|
|
|
+ throw new BusinessException("线下钱包预付余额不足");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 买家撤销贸易订单
|
|
|
|
|
+ */
|
|
|
|
|
+ public void cancelTradeOrder(CancelTradeOrderParam param) {
|
|
|
|
|
+ KwoTradeOrder order = kwoTradeOrderMapper.selectOne(
|
|
|
|
|
+ new LambdaQueryWrapper<KwoTradeOrder>()
|
|
|
|
|
+ .eq(KwoTradeOrder::getId, param.getTradeContractId())
|
|
|
|
|
+ .eq(KwoTradeOrder::getDelFlag, 0)
|
|
|
|
|
+ );
|
|
|
|
|
+ if (Objects.isNull(order)) {
|
|
|
|
|
+ throw new BusinessException("贸易订单不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!Objects.equals(order.getStatus(), TradeOrderStatusEnum.AUDIT.getCode())) {
|
|
|
|
|
+ throw new BusinessException("当前订单状态不允许撤销");
|
|
|
|
|
+ }
|
|
|
|
|
+ TradeContractResDto tradeContractResDto = remoteContractService.queryTradeContract(param.getTradeContractId(), param.getGoodsId());
|
|
|
|
|
+ // 1. 线下钱包加回预付余额、减冻结金额
|
|
|
|
|
+ List<TradeContractUnitDto> unitList = tradeContractResDto.getUnitList();
|
|
|
|
|
+ WalletFreezeDto freezeDto = new WalletFreezeDto();
|
|
|
|
|
+ unitList.forEach(e -> {
|
|
|
|
|
+ KwoTradeOrderUnit unit = BeanUtil.copyProperties(e, KwoTradeOrderUnit.class);
|
|
|
|
|
+ unit.setId(new IdWorker(1).nextId());
|
|
|
|
|
+ unit.setTOrderId(order.getId()).setTOrderNo(order.getTOrderNo()).setTopEntId(e.getEntId());
|
|
|
|
|
+ unit.setUnitType(StrUtil.equals(e.getUnitType(), "1") ? "2" : "1");//贸易合同和订单的单位类型相反
|
|
|
|
|
+ if (StrUtil.equals(unit.getUnitType(), "1")) {
|
|
|
|
|
+ freezeDto.setProEntId(unit.getEntId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equals(unit.getUnitType(), "2")) {
|
|
|
|
|
+ freezeDto.setSupEntId(unit.getEntId());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ freezeDto.setFreezeAmount(param.getFreezeAmount());
|
|
|
|
|
+ freezeDto.setOrderNo(order.getTOrderNo());
|
|
|
|
|
+
|
|
|
|
|
+ BaseResult<Boolean> balanceResult;
|
|
|
|
|
+ try {
|
|
|
|
|
+ balanceResult = offlineWalletFeignService.unfreezeBalance(freezeDto);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("线下钱包扣减预付余额、增加冻结金额异常", e);
|
|
|
|
|
+ throw new BusinessException("线下钱包扣减预付余额、增加冻结金额异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (balanceResult == null || balanceResult.getCode() != HttpStatus.SUCCESS_CODE) {
|
|
|
|
|
+ throw new BusinessException("线下钱包扣减预付余额、增加冻结金额失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ Boolean aBoolean = balanceResult.getData();
|
|
|
|
|
+ if (!Boolean.TRUE.equals(aBoolean)) {
|
|
|
|
|
+ throw new BusinessException("线下钱包扣减预付余额、增加冻结金额失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 记录钱包金额账数据,类型为解冻,备注为"贸易订单号:xxx 撤销订单"
|
|
|
|
|
+ // TODO: 后续对接外部系统,记录钱包流水
|
|
|
|
|
+ // recordWalletTransaction(buyEntId, order.getPrice(), "解冻", "贸易订单号:" + order.getTOrderNo() + " 撤销订单");
|
|
|
|
|
+
|
|
|
|
|
+ // 线上钱包解冻
|
|
|
|
|
+ WalletFreeze walletFreeze = new WalletFreeze();
|
|
|
|
|
+ walletFreeze.setTTradeOrderId(order.getId());
|
|
|
|
|
+ walletFreeze.setOrderNo(order.getTOrderNo());
|
|
|
|
|
+ BaseResult<Boolean> unfreezeResult = paymentDubboService.unfreezeMoney(walletFreeze);
|
|
|
|
|
+ if (unfreezeResult.getCode() != 60200) {
|
|
|
|
|
+ throw new BusinessException(unfreezeResult.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 贸易合同该商品有采购数量,则更新采购数量(加回本单总量)
|
|
|
|
|
+ KwoTradeOrderGoods orderGoods = kwoTradeOrderGoodsService.getByOrderId(order.getId());
|
|
|
|
|
+ KwoTradeOrderContract orderContract = kwoTradeOrderContractService.getByOrderId(order.getId());
|
|
|
|
|
+ if (Objects.nonNull(orderGoods) && Objects.nonNull(orderContract)) {
|
|
|
|
|
+ TradeContractResDto contractRes = remoteContractService.queryTradeContract(orderContract.getContractId(), orderGoods.getGoodsId());
|
|
|
|
|
+ if (Objects.nonNull(contractRes) && Objects.nonNull(contractRes.getGoodsInfoDto())) {
|
|
|
|
|
+ GoodsInfoDto goodsInfo = contractRes.getGoodsInfoDto();
|
|
|
|
|
+ if (goodsInfo.getAmount() != null && goodsInfo.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ remoteContractService.updateTradeContractGoodsPerformed(
|
|
|
|
|
+ orderContract.getContractId(), orderGoods.getGoodsId(), order.getAmount().negate()
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 更新贸易订单状态为"取消"
|
|
|
|
|
+ order.setStatus(TradeOrderStatusEnum.CANCEL.getCode());
|
|
|
|
|
+ kwoTradeOrderMapper.updateById(order);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private TradeContractResDto checkPara(TradeOrderParam tradeOrderParam, KwoTradeOrder order, KwpGoods goodsById) {
|
|
private TradeContractResDto checkPara(TradeOrderParam tradeOrderParam, KwoTradeOrder order, KwpGoods goodsById) {
|