|
@@ -1,34 +1,48 @@
|
|
|
package com.sckw.payment.service.impl;
|
|
package com.sckw.payment.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
|
|
+import com.sckw.core.model.vo.FileInfoVO;
|
|
|
import com.sckw.core.utils.PageUtils;
|
|
import com.sckw.core.utils.PageUtils;
|
|
|
|
|
+import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.core.web.response.BaseResult;
|
|
import com.sckw.core.web.response.BaseResult;
|
|
|
|
|
+import com.sckw.file.api.dubbo.RemoteFileService;
|
|
|
|
|
+import com.sckw.payment.api.model.dto.common.R;
|
|
|
|
|
+import com.sckw.payment.config.ApplicationProperties;
|
|
|
import com.sckw.payment.entity.*;
|
|
import com.sckw.payment.entity.*;
|
|
|
import com.sckw.payment.enums.ExecutionStatusEnum;
|
|
import com.sckw.payment.enums.ExecutionStatusEnum;
|
|
|
import com.sckw.payment.enums.OrderTypeEnum;
|
|
import com.sckw.payment.enums.OrderTypeEnum;
|
|
|
import com.sckw.payment.enums.PayStatusEnum;
|
|
import com.sckw.payment.enums.PayStatusEnum;
|
|
|
import com.sckw.payment.enums.TransactionTypeEnum;
|
|
import com.sckw.payment.enums.TransactionTypeEnum;
|
|
|
import com.sckw.payment.mapper.*;
|
|
import com.sckw.payment.mapper.*;
|
|
|
|
|
+import com.sckw.payment.pojo.dto.CustomSettleDto;
|
|
|
|
|
+import com.sckw.payment.pojo.dto.CustomSettleRes;
|
|
|
|
|
+import com.sckw.payment.pojo.dto.DivideDto;
|
|
|
import com.sckw.payment.pojo.vo.PayRes;
|
|
import com.sckw.payment.pojo.vo.PayRes;
|
|
|
import com.sckw.payment.pojo.vo.req.*;
|
|
import com.sckw.payment.pojo.vo.req.*;
|
|
|
import com.sckw.payment.pojo.vo.res.*;
|
|
import com.sckw.payment.pojo.vo.res.*;
|
|
|
import com.sckw.payment.service.IWalletPayableService;
|
|
import com.sckw.payment.service.IWalletPayableService;
|
|
|
|
|
+import com.sckw.payment.service.PayXwService;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
|
|
+import jakarta.annotation.Resource;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
-import org.slf4j.Logger;
|
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -39,9 +53,9 @@ import java.util.stream.Collectors;
|
|
|
* @author tangys
|
|
* @author tangys
|
|
|
* @since 2026-01-06 11:03:35
|
|
* @since 2026-01-06 11:03:35
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
- private static final Logger logger = LoggerFactory.getLogger(WalletPayableServiceImpl.class);
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WalletPayableMapper walletPayableMapper;
|
|
private WalletPayableMapper walletPayableMapper;
|
|
@@ -49,20 +63,27 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
private WalletPayableBalanceMapper walletPayableBalanceMapper;
|
|
private WalletPayableBalanceMapper walletPayableBalanceMapper;
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false, timeout = 8000)
|
|
@DubboReference(version = "1.0.0", group = "design", check = false, timeout = 8000)
|
|
|
private RemoteSystemService remoteSystemService;
|
|
private RemoteSystemService remoteSystemService;
|
|
|
-
|
|
|
|
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
|
|
+ private RemoteFileService remoteFileService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WalletBusinessFileMapper businessFileMapper;
|
|
private WalletBusinessFileMapper businessFileMapper;
|
|
|
-
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private ApplicationProperties applicationProperties;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private KwpWalletSplitMapper kwpWalletSplitMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WalletPayableApplyMapper walletPayableApplyMapper;
|
|
private WalletPayableApplyMapper walletPayableApplyMapper;
|
|
|
-
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private PayXwService payXwService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WalletPayablePayMapper walletPayablePayMapper;
|
|
private WalletPayablePayMapper walletPayablePayMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private KwpWalletMapper kwpWalletMapper;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public PageInfo<WalletPayableRes> selectWalletPayableList(WalletPayableQuery query) {
|
|
public PageInfo<WalletPayableRes> selectWalletPayableList(WalletPayableQuery query) {
|
|
|
PageInfo<WalletPayableRes> pageInfo = new PageInfo<>(new ArrayList<>());
|
|
PageInfo<WalletPayableRes> pageInfo = new PageInfo<>(new ArrayList<>());
|
|
|
- query.setCurEntId(LoginUserHolder.getUserId());
|
|
|
|
|
|
|
+ query.setCurEntId(LoginUserHolder.getEntId());
|
|
|
PageUtils.startPage(query);
|
|
PageUtils.startPage(query);
|
|
|
List<WalletPayable> walletPayables = walletPayableMapper.selectWalletPayableList(query);
|
|
List<WalletPayable> walletPayables = walletPayableMapper.selectWalletPayableList(query);
|
|
|
if (!CollectionUtils.isEmpty(walletPayables)) {
|
|
if (!CollectionUtils.isEmpty(walletPayables)) {
|
|
@@ -75,7 +96,7 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
}).toList();
|
|
}).toList();
|
|
|
List<EntCacheResDto> entInfos = remoteSystemService.queryEntCacheByIds(tradeEntIdList);
|
|
List<EntCacheResDto> entInfos = remoteSystemService.queryEntCacheByIds(tradeEntIdList);
|
|
|
Map<Long, String> entNameMap;
|
|
Map<Long, String> entNameMap;
|
|
|
- if(!CollectionUtils.isEmpty(entInfos)){
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(entInfos)) {
|
|
|
entNameMap = entInfos.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName));
|
|
entNameMap = entInfos.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName));
|
|
|
} else {
|
|
} else {
|
|
|
entNameMap = new HashMap<>();
|
|
entNameMap = new HashMap<>();
|
|
@@ -113,6 +134,8 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
WalletBusinessFile file = new WalletBusinessFile();
|
|
WalletBusinessFile file = new WalletBusinessFile();
|
|
|
file.setBusinessId(payableBalance.getId());
|
|
file.setBusinessId(payableBalance.getId());
|
|
|
file.setFilePath(e);
|
|
file.setFilePath(e);
|
|
|
|
|
+ file.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ file.setCreateTime(new Date());
|
|
|
list.add(file);
|
|
list.add(file);
|
|
|
});
|
|
});
|
|
|
businessFileMapper.insertBatch(list);
|
|
businessFileMapper.insertBatch(list);
|
|
@@ -122,7 +145,7 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
|
|
|
|
|
private int manualEntryFreight(WalletPayable payable, WalletPayableManualDto payableManualDto) {
|
|
private int manualEntryFreight(WalletPayable payable, WalletPayableManualDto payableManualDto) {
|
|
|
// 查询是否存在待待付/代收运费
|
|
// 查询是否存在待待付/代收运费
|
|
|
- WalletPayable existedPayable = walletPayableMapper.selectByConsignAndCarrier(payableManualDto.getTradeEntId(), LoginUserHolder.get().getEntId());
|
|
|
|
|
|
|
+ WalletPayable existedPayable = walletPayableMapper.selectByConsignAndCarrier(payableManualDto.getTradeEntId(), LoginUserHolder.getEntId());
|
|
|
int result = 0;
|
|
int result = 0;
|
|
|
if (existedPayable != null) {
|
|
if (existedPayable != null) {
|
|
|
// 如果存在,则更新待待付/代收运费
|
|
// 如果存在,则更新待待付/代收运费
|
|
@@ -140,9 +163,11 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
if (Objects.equals(payableManualDto.getFreightType(), 1)) {
|
|
if (Objects.equals(payableManualDto.getFreightType(), 1)) {
|
|
|
//待付/代收运费
|
|
//待付/代收运费
|
|
|
payable.setConsignEntId(payableManualDto.getTradeEntId());
|
|
payable.setConsignEntId(payableManualDto.getTradeEntId());
|
|
|
- payable.setCarrierEntId(LoginUserHolder.get().getEntId());
|
|
|
|
|
|
|
+ payable.setCarrierEntId(LoginUserHolder.getEntId());
|
|
|
payable.setFreight(payableManualDto.getTradeAmount());
|
|
payable.setFreight(payableManualDto.getTradeAmount());
|
|
|
payable.setTradingFreight(BigDecimal.ZERO);
|
|
payable.setTradingFreight(BigDecimal.ZERO);
|
|
|
|
|
+ payable.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ payable.setCreateTime(new Date());
|
|
|
payable.setPayingFreight(BigDecimal.ZERO);
|
|
payable.setPayingFreight(BigDecimal.ZERO);
|
|
|
result = walletPayableMapper.insertWalletPayable(payable);
|
|
result = walletPayableMapper.insertWalletPayable(payable);
|
|
|
}
|
|
}
|
|
@@ -152,10 +177,10 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
|
|
|
|
|
private WalletPayableBalance buildWalletManualPayableBalance(WalletPayable payable, WalletPayableManualDto payableManualDto) {
|
|
private WalletPayableBalance buildWalletManualPayableBalance(WalletPayable payable, WalletPayableManualDto payableManualDto) {
|
|
|
WalletPayableBalance payableBalance = new WalletPayableBalance();
|
|
WalletPayableBalance payableBalance = new WalletPayableBalance();
|
|
|
- payableBalance.setOrderNo("f" + System.currentTimeMillis());
|
|
|
|
|
|
|
+ payableBalance.setOrderNo(IdUtil.getSnowflakeNextIdStr());
|
|
|
payableBalance.setOrderType(OrderTypeEnum.PAYMENT_ORDER.getCode());
|
|
payableBalance.setOrderType(OrderTypeEnum.PAYMENT_ORDER.getCode());
|
|
|
payableBalance.setConsignEntId(payableManualDto.getTradeEntId());
|
|
payableBalance.setConsignEntId(payableManualDto.getTradeEntId());
|
|
|
- payableBalance.setCarrierEntId(LoginUserHolder.get().getEntId());
|
|
|
|
|
|
|
+ payableBalance.setCarrierEntId(LoginUserHolder.getEntId());
|
|
|
payableBalance.setTradeType(TransactionTypeEnum.MANUAL_ENTRY.getCode());
|
|
payableBalance.setTradeType(TransactionTypeEnum.MANUAL_ENTRY.getCode());
|
|
|
payableBalance.setTradeAmount(payableManualDto.getTradeAmount());
|
|
payableBalance.setTradeAmount(payableManualDto.getTradeAmount());
|
|
|
payableBalance.setFreight(payable.getFreight());
|
|
payableBalance.setFreight(payable.getFreight());
|
|
@@ -164,6 +189,8 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
payableBalance.setStatus(ExecutionStatusEnum.SUCCESS.getCode());
|
|
payableBalance.setStatus(ExecutionStatusEnum.SUCCESS.getCode());
|
|
|
payableBalance.setRemark(payableManualDto.getRemark());
|
|
payableBalance.setRemark(payableManualDto.getRemark());
|
|
|
payableBalance.setVoucherFlag(CollectionUtils.isEmpty(payableManualDto.getVoucherFiles()) ? 0 : 1);
|
|
payableBalance.setVoucherFlag(CollectionUtils.isEmpty(payableManualDto.getVoucherFiles()) ? 0 : 1);
|
|
|
|
|
+ payableBalance.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ payableBalance.setCreateTime(new Date());
|
|
|
return payableBalance;
|
|
return payableBalance;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -179,6 +206,8 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
payable.setCarrierEntId(payableAddDto.getCarriageEntId());
|
|
payable.setCarrierEntId(payableAddDto.getCarriageEntId());
|
|
|
payable.setFreight(payableAddDto.getTradeAmount());
|
|
payable.setFreight(payableAddDto.getTradeAmount());
|
|
|
payable.setTradingFreight(payableAddDto.getTradeAmount());
|
|
payable.setTradingFreight(payableAddDto.getTradeAmount());
|
|
|
|
|
+ payable.setCreateTime(new Date());
|
|
|
|
|
+ payable.setCreateBy(LoginUserHolder.getUserId());
|
|
|
payable.setPayingFreight(payableAddDto.getTradeAmount());
|
|
payable.setPayingFreight(payableAddDto.getTradeAmount());
|
|
|
result = walletPayableMapper.insertWalletPayable(payable);
|
|
result = walletPayableMapper.insertWalletPayable(payable);
|
|
|
}
|
|
}
|
|
@@ -198,7 +227,7 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
//待付运费清单处理
|
|
//待付运费清单处理
|
|
|
if (Objects.equals(payableUpdateDto.getTradeType(), TransactionTypeEnum.FREEZE.getCode())) {
|
|
if (Objects.equals(payableUpdateDto.getTradeType(), TransactionTypeEnum.FREEZE.getCode())) {
|
|
|
//冻结
|
|
//冻结
|
|
|
- if(payableUpdateDto.getTradeAmount() == null){
|
|
|
|
|
|
|
+ if (payableUpdateDto.getTradeAmount() == null) {
|
|
|
throw new BusinessException("交易金额不能为空");
|
|
throw new BusinessException("交易金额不能为空");
|
|
|
}
|
|
}
|
|
|
existedPayable.setTradingFreight(existedPayable.getTradingFreight().add(payableUpdateDto.getTradeAmount()));
|
|
existedPayable.setTradingFreight(existedPayable.getTradingFreight().add(payableUpdateDto.getTradeAmount()));
|
|
@@ -214,7 +243,7 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
payableUpdateDto.setTradeAmount(payableBalance.getTradeAmount());
|
|
payableUpdateDto.setTradeAmount(payableBalance.getTradeAmount());
|
|
|
} else if (Objects.equals(payableUpdateDto.getTradeType(), TransactionTypeEnum.CONSUME.getCode())) {
|
|
} else if (Objects.equals(payableUpdateDto.getTradeType(), TransactionTypeEnum.CONSUME.getCode())) {
|
|
|
//消费
|
|
//消费
|
|
|
- if(payableUpdateDto.getTradeAmount() == null){
|
|
|
|
|
|
|
+ if (payableUpdateDto.getTradeAmount() == null) {
|
|
|
throw new BusinessException("交易金额不能为空");
|
|
throw new BusinessException("交易金额不能为空");
|
|
|
}
|
|
}
|
|
|
existedPayable.setFreight(existedPayable.getFreight().add(payableUpdateDto.getTradeAmount()));
|
|
existedPayable.setFreight(existedPayable.getFreight().add(payableUpdateDto.getTradeAmount()));
|
|
@@ -241,6 +270,8 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
payableBalance.setPayingFreight(payable.getPayingFreight());
|
|
payableBalance.setPayingFreight(payable.getPayingFreight());
|
|
|
payableBalance.setStatus(ExecutionStatusEnum.SUCCESS.getCode());
|
|
payableBalance.setStatus(ExecutionStatusEnum.SUCCESS.getCode());
|
|
|
payableBalance.setRemark(payableAddDto.getRemark());
|
|
payableBalance.setRemark(payableAddDto.getRemark());
|
|
|
|
|
+ payableBalance.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ payableBalance.setCreateTime(new Date());
|
|
|
return payableBalance;
|
|
return payableBalance;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -281,6 +312,8 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
payableBalance.setFreight(payable.getFreight());
|
|
payableBalance.setFreight(payable.getFreight());
|
|
|
payableBalance.setPayingFreight(payable.getPayingFreight());
|
|
payableBalance.setPayingFreight(payable.getPayingFreight());
|
|
|
payableBalance.setStatus(ExecutionStatusEnum.SUCCESS.getCode());
|
|
payableBalance.setStatus(ExecutionStatusEnum.SUCCESS.getCode());
|
|
|
|
|
+ payableBalance.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ payableBalance.setCreateTime(new Date());
|
|
|
payableBalance.setRemark(freightApply.getRemark());
|
|
payableBalance.setRemark(freightApply.getRemark());
|
|
|
return payableBalance;
|
|
return payableBalance;
|
|
|
}
|
|
}
|
|
@@ -288,9 +321,11 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
private WalletPayableApply buildWalletPayableApply(WalletPayable payable, WalletPayableApplyPayDto applyPayDto) {
|
|
private WalletPayableApply buildWalletPayableApply(WalletPayable payable, WalletPayableApplyPayDto applyPayDto) {
|
|
|
WalletPayableApply apply = new WalletPayableApply();
|
|
WalletPayableApply apply = new WalletPayableApply();
|
|
|
apply.setPayableId(payable.getId());
|
|
apply.setPayableId(payable.getId());
|
|
|
- apply.setOrderNo("f" + System.currentTimeMillis());
|
|
|
|
|
|
|
+ apply.setOrderNo(IdUtil.getSnowflakeNextIdStr());
|
|
|
apply.setApplyAmount(applyPayDto.getApplyAmount());
|
|
apply.setApplyAmount(applyPayDto.getApplyAmount());
|
|
|
apply.setRemark(applyPayDto.getRemark());
|
|
apply.setRemark(applyPayDto.getRemark());
|
|
|
|
|
+ apply.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ apply.setCreateTime(new Date());
|
|
|
return apply;
|
|
return apply;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -343,7 +378,7 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
pageInfo = ((Page<WalletPayablePay>) payablePays).toPageInfo(e -> {
|
|
pageInfo = ((Page<WalletPayablePay>) payablePays).toPageInfo(e -> {
|
|
|
WalletPayablePayRes freightRecordRes = new WalletPayablePayRes();
|
|
WalletPayablePayRes freightRecordRes = new WalletPayablePayRes();
|
|
|
BeanUtils.copyProperties(e, freightRecordRes);
|
|
BeanUtils.copyProperties(e, freightRecordRes);
|
|
|
- freightRecordRes.setStatusDesc(PayStatusEnum.getByCode(e.getStatus()).getName());
|
|
|
|
|
|
|
+ freightRecordRes.setStatusDesc(PayStatusEnum.getByCode(e.getStatus()));
|
|
|
return freightRecordRes;
|
|
return freightRecordRes;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -363,22 +398,18 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
walletPayAddRes.setSettleAcctNo(data.getSettleAcct());
|
|
walletPayAddRes.setSettleAcctNo(data.getSettleAcct());
|
|
|
walletPayAddRes.setAmount(new BigDecimal(data.getAmt()));
|
|
walletPayAddRes.setAmount(new BigDecimal(data.getAmt()));
|
|
|
walletPayAddRes.setBankName("新网银行");
|
|
walletPayAddRes.setBankName("新网银行");
|
|
|
- return BaseResult.success(generateWalletPayAddRes(payablePay));
|
|
|
|
|
|
|
+ return BaseResult.success(walletPayAddRes);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- private WalletPayAddRes generateWalletPayAddRes(WalletPayablePay walletPayablePay) {
|
|
|
|
|
- //todo 获取打款账户信息
|
|
|
|
|
- //根据供应商企业id查询银行账户信息
|
|
|
|
|
-// Long supEntId = prepaid.getSupEntId();
|
|
|
|
|
-
|
|
|
|
|
- WalletPayAddRes res = new WalletPayAddRes();
|
|
|
|
|
- res.setOrderNo(walletPayablePay.getOrderNo());
|
|
|
|
|
- res.setSettleAcctName("xxx");
|
|
|
|
|
- res.setSettleAcctNo("xxx");
|
|
|
|
|
- res.setAmount(walletPayablePay.getApplyAmount());
|
|
|
|
|
- res.setBankName("xxx");
|
|
|
|
|
- return res;
|
|
|
|
|
|
|
+ private String getUid(Long id) {
|
|
|
|
|
+ if (Objects.isNull(id)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ KwpWallet kwpWallet = kwpWalletMapper.selectOne(Wrappers.lambdaQuery(KwpWallet.class).eq(KwpWallet::getEntId, id).eq(KwpWallet::getStatus, 2).eq(KwpWallet::getDelFlag, 0));
|
|
|
|
|
+ if (Objects.isNull(kwpWallet)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return kwpWallet.getUid();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//构建支付记录
|
|
//构建支付记录
|
|
@@ -386,25 +417,91 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
WalletPayablePay payablePay = new WalletPayablePay();
|
|
WalletPayablePay payablePay = new WalletPayablePay();
|
|
|
payablePay.setPayableId(payableApply.getPayableId());
|
|
payablePay.setPayableId(payableApply.getPayableId());
|
|
|
payablePay.setApplyOrderNo(payableApply.getOrderNo());
|
|
payablePay.setApplyOrderNo(payableApply.getOrderNo());
|
|
|
- payablePay.setOrderNo("f" + System.currentTimeMillis());
|
|
|
|
|
|
|
+ payablePay.setOrderNo(IdUtil.getSnowflakeNextIdStr());
|
|
|
payablePay.setApplyAmount(payableApply.getApplyAmount().subtract(payableApply.getPayingAmount().add(payableApply.getReceivedAmount())));
|
|
payablePay.setApplyAmount(payableApply.getApplyAmount().subtract(payableApply.getPayingAmount().add(payableApply.getReceivedAmount())));
|
|
|
payablePay.setReceivedAmount(BigDecimal.ZERO);
|
|
payablePay.setReceivedAmount(BigDecimal.ZERO);
|
|
|
|
|
+ payablePay.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ payablePay.setCreateTime(new Date());
|
|
|
return payablePay;
|
|
return payablePay;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void receivedCallback(ReceivedCallbackDto receivedCallbackDto) {
|
|
public void receivedCallback(ReceivedCallbackDto receivedCallbackDto) {
|
|
|
- //1.todo 修改在线钱包金额
|
|
|
|
|
- //2.todo 插入在线钱包明细
|
|
|
|
|
- //3.修改支付记录到账金额和状态
|
|
|
|
|
|
|
+ log.info("运费到账回调接口 {}", JSONObject.toJSONString(receivedCallbackDto));
|
|
|
WalletPayablePay walletPayablePay = walletPayablePayMapper.selectWalletPayablePayByOrderNo(receivedCallbackDto.getPayOrderNo());
|
|
WalletPayablePay walletPayablePay = walletPayablePayMapper.selectWalletPayablePayByOrderNo(receivedCallbackDto.getPayOrderNo());
|
|
|
if (walletPayablePay == null) {
|
|
if (walletPayablePay == null) {
|
|
|
- throw new BusinessException("支付记录不存在");
|
|
|
|
|
|
|
+ throw new BusinessException("运费支付记录不存在");
|
|
|
}
|
|
}
|
|
|
walletPayablePay.setReceivedAmount(receivedCallbackDto.getTranAmt());
|
|
walletPayablePay.setReceivedAmount(receivedCallbackDto.getTranAmt());
|
|
|
walletPayablePay.setStatus(1);
|
|
walletPayablePay.setStatus(1);
|
|
|
walletPayablePayMapper.updateWalletPayablePay(walletPayablePay);
|
|
walletPayablePayMapper.updateWalletPayablePay(walletPayablePay);
|
|
|
- //4.修改申请记录支付中=0,到账金额,判断申请金额是否等于到账金额,等于则修改状态为已完成
|
|
|
|
|
|
|
+
|
|
|
|
|
+ WalletPayable walletPayable = walletPayableMapper.selectById(walletPayablePay.getPayableId());
|
|
|
|
|
+
|
|
|
|
|
+ CustomSettleDto customSettleDto = new CustomSettleDto();
|
|
|
|
|
+
|
|
|
|
|
+ KwpWalletSplit kwpWalletSplit = new KwpWalletSplit();
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 新增清分订单,清分成功后,增加可提现余额
|
|
|
|
|
+ customSettleDto.setUid(getUid(walletPayable.getConsignEntId()));
|
|
|
|
|
+ customSettleDto.setAmt(String.valueOf(receivedCallbackDto.getTranAmt()));
|
|
|
|
|
+ customSettleDto.setMchtFee("0.00");
|
|
|
|
|
+ customSettleDto.setNoticeUrl(applicationProperties.getSplit());
|
|
|
|
|
+ customSettleDto.setSummery("");
|
|
|
|
|
+ customSettleDto.setRemark("清分");
|
|
|
|
|
+ DivideDto divideDto = new DivideDto();
|
|
|
|
|
+ divideDto.setAmt(String.valueOf(receivedCallbackDto.getTranAmt()));
|
|
|
|
|
+ divideDto.setFilter(getUid(walletPayable.getCarrierEntId()));
|
|
|
|
|
+ customSettleDto.setDivide(Lists.newArrayList(divideDto));
|
|
|
|
|
+
|
|
|
|
|
+ R<CustomSettleRes> split = payXwService.split(customSettleDto);
|
|
|
|
|
+ kwpWalletSplit.setStatus(1);
|
|
|
|
|
+ if (split.getCode() != 200) {
|
|
|
|
|
+ log.error("清分失败 {}", JSONObject.toJSONString(split));
|
|
|
|
|
+ kwpWalletSplit.setStatus(3);
|
|
|
|
|
+ }
|
|
|
|
|
+ CustomSettleRes data = split.getData();
|
|
|
|
|
+ kwpWalletSplit.setFromEnt(walletPayable.getConsignEntId());
|
|
|
|
|
+ kwpWalletSplit.setToEnt(walletPayable.getCarrierEntId());
|
|
|
|
|
+ kwpWalletSplit.setPayOrderNo(receivedCallbackDto.getPayOrderNo());
|
|
|
|
|
+ kwpWalletSplit.setOrderNo(Objects.nonNull(data) ? data.getTxnNo() : "-");
|
|
|
|
|
+ kwpWalletSplit.setAction(1);
|
|
|
|
|
+ kwpWalletSplit.setMoney(receivedCallbackDto.getTranAmt());
|
|
|
|
|
+ kwpWalletSplit.setRemark("");
|
|
|
|
|
+ kwpWalletSplit.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ kwpWalletSplit.setCreateTime(LocalDateTime.now());
|
|
|
|
|
+ kwpWalletSplit.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ kwpWalletSplit.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
+ kwpWalletSplit.setDelFlag(0);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("清分异常 {} 异常信息 {}", JSONObject.toJSONString(customSettleDto), e.getMessage());
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ kwpWalletSplitMapper.insert(kwpWalletSplit);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ WalletBusinessFile walletBusinessFile = new WalletBusinessFile();
|
|
|
|
|
+ try {
|
|
|
|
|
+ walletBusinessFile.setBusinessId(walletPayablePay.getId());
|
|
|
|
|
+ walletBusinessFile.setRemark("");
|
|
|
|
|
+ walletBusinessFile.setStatus(0);
|
|
|
|
|
+ walletBusinessFile.setDelFlag(0);
|
|
|
|
|
+ walletBusinessFile.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ walletBusinessFile.setCreateTime(new Date());
|
|
|
|
|
+ walletBusinessFile.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ walletBusinessFile.setUpdateTime(new Date());
|
|
|
|
|
+ MultipartFile file = receivedCallbackDto.getFile();
|
|
|
|
|
+ BaseResult<FileInfoVO> httpResult = remoteFileService.fileUpload(file);
|
|
|
|
|
+ if (HttpStatus.SUCCESS_CODE == httpResult.getCode()) {
|
|
|
|
|
+ FileInfoVO data = httpResult.getData();
|
|
|
|
|
+ walletBusinessFile.setFilePath(Objects.nonNull(data) ? data.getFileAbsolutePath() : "");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("支付凭证文件写入异常 {}", e.getMessage());
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ businessFileMapper.insert(walletBusinessFile);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
WalletPayableApply payableApply = walletPayableApplyMapper.selectWalletPayableApplyByOrderNo(walletPayablePay.getApplyOrderNo());
|
|
WalletPayableApply payableApply = walletPayableApplyMapper.selectWalletPayableApplyByOrderNo(walletPayablePay.getApplyOrderNo());
|
|
|
payableApply.setPayingAmount(BigDecimal.ZERO);
|
|
payableApply.setPayingAmount(BigDecimal.ZERO);
|
|
|
payableApply.setReceivedAmount(payableApply.getReceivedAmount().add(receivedCallbackDto.getTranAmt()));
|
|
payableApply.setReceivedAmount(payableApply.getReceivedAmount().add(receivedCallbackDto.getTranAmt()));
|
|
@@ -413,7 +510,6 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
}
|
|
}
|
|
|
walletPayableApplyMapper.updateWalletPayableApply(payableApply);
|
|
walletPayableApplyMapper.updateWalletPayableApply(payableApply);
|
|
|
//5.运费清单付款中金额扣减
|
|
//5.运费清单付款中金额扣减
|
|
|
- WalletPayable walletPayable = walletPayableMapper.selectWalletPayableById(walletPayablePay.getPayableId());
|
|
|
|
|
walletPayable.setPayingFreight(walletPayable.getPayingFreight().subtract(receivedCallbackDto.getTranAmt()));
|
|
walletPayable.setPayingFreight(walletPayable.getPayingFreight().subtract(receivedCallbackDto.getTranAmt()));
|
|
|
walletPayableMapper.updateWalletPayable(walletPayable);
|
|
walletPayableMapper.updateWalletPayable(walletPayable);
|
|
|
//6.运费明细插入记录
|
|
//6.运费明细插入记录
|
|
@@ -432,6 +528,8 @@ public class WalletPayableServiceImpl implements IWalletPayableService {
|
|
|
payableBalance.setFreight(payable.getFreight());
|
|
payableBalance.setFreight(payable.getFreight());
|
|
|
payableBalance.setTradingFreight(payable.getTradingFreight());
|
|
payableBalance.setTradingFreight(payable.getTradingFreight());
|
|
|
payableBalance.setPayingFreight(payable.getPayingFreight());
|
|
payableBalance.setPayingFreight(payable.getPayingFreight());
|
|
|
|
|
+ payableBalance.setCreateTime(new Date());
|
|
|
|
|
+ payableBalance.setCreateBy(LoginUserHolder.getUserId());
|
|
|
payableBalance.setStatus(ExecutionStatusEnum.SUCCESS.getCode());
|
|
payableBalance.setStatus(ExecutionStatusEnum.SUCCESS.getCode());
|
|
|
return payableBalance;
|
|
return payableBalance;
|
|
|
}
|
|
}
|