|
|
@@ -568,6 +568,8 @@ public class KwpSettlementWalletService {
|
|
|
|
|
|
/**
|
|
|
* 销售-预付款
|
|
|
+ * 贸易订单下单时,冻结资金
|
|
|
+ * 预付款结算时,解冻资金。在进行清分。
|
|
|
*
|
|
|
* @param id 结算单id
|
|
|
* @return
|
|
|
@@ -576,20 +578,19 @@ public class KwpSettlementWalletService {
|
|
|
public String confirmTradeCollection(Long id) {
|
|
|
log.info("销售预付款确认,结算单id:{}", id);
|
|
|
String key = String.format(RedisConstant.SETTLEMENT_KEY, id);
|
|
|
-
|
|
|
+ SettlementTradeDto byId = kwpSettlementTradeService.getById(id, TradeUnitType.PURCHASE);
|
|
|
+ if (Objects.isNull(byId)) {
|
|
|
+ throw new BusinessException("结算单不存在");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(byId.getTrading()) && !byId.getTrading().startsWith(TradingEnum.PRE_PAY.getValue())) {
|
|
|
+ throw new BusinessException("只支持预付款交易方式进行预付款确认操作");
|
|
|
+ }
|
|
|
+ List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(byId.getLedgerId());
|
|
|
+ if (CollectionUtils.isEmpty(kwpLedgerTradeOrders)) {
|
|
|
+ throw new BusinessException("未找到关联的贸易订单");
|
|
|
+ }
|
|
|
if (redisLockUtil.tryLock(key)) {
|
|
|
try {
|
|
|
- SettlementTradeDto byId = kwpSettlementTradeService.getById(id, TradeUnitType.PURCHASE);
|
|
|
- if (Objects.isNull(byId)) {
|
|
|
- throw new BusinessException("结算单不存在");
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(byId.getTrading()) && !byId.getTrading().startsWith(TradingEnum.PRE_PAY.getValue())) {
|
|
|
- throw new BusinessException("只支持预付款交易方式进行预付款确认操作");
|
|
|
- }
|
|
|
- List<KwpLedgerTradeOrder> kwpLedgerTradeOrders = tradeOrderService.queryList(byId.getLedgerId());
|
|
|
- if (CollectionUtils.isEmpty(kwpLedgerTradeOrders)) {
|
|
|
- throw new BusinessException("未找到关联的贸易订单");
|
|
|
- }
|
|
|
//更新交易结算单状态和金额
|
|
|
KwpSettlementTrade kwpSettlementTrade = new KwpSettlementTrade();
|
|
|
kwpSettlementTrade.setId(byId.getId());
|
|
|
@@ -601,9 +602,12 @@ public class KwpSettlementWalletService {
|
|
|
//预付款-更新对账单已付金额
|
|
|
kwpLedgerTradeService.updateActualPrice(byId.gettLedgerId(), byId.getTotalPrice());
|
|
|
//新增电子钱包结算记录
|
|
|
+ //清分单号
|
|
|
+ String orderNo = OrderUtils.generateOrderNo("ST");
|
|
|
KwpSettlementWallet kwpSettlementWallet = new KwpSettlementWallet();
|
|
|
kwpSettlementWallet.setId(new IdWorker(1).nextId());
|
|
|
kwpSettlementWallet.setEntId(LoginUserHolder.getEntId());
|
|
|
+ kwpSettlementWallet.setOrderNo(orderNo);
|
|
|
kwpSettlementWallet.setSettlementId(byId.getId());
|
|
|
kwpSettlementWallet.setOrderType(SettlementOrderTypeEnum.TRADE.getStatus());
|
|
|
kwpSettlementWallet.setChannel(WalletChannelEnum.getValue(byId.getTrading()));
|
|
|
@@ -644,6 +648,7 @@ public class KwpSettlementWalletService {
|
|
|
|
|
|
//todo-xcq 调用中台接口
|
|
|
|
|
|
+
|
|
|
return "确认回款成功";
|
|
|
} finally {
|
|
|
redisLockUtil.unlock(key);
|