...
|
...
|
@@ -568,19 +568,27 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
throw new ServiceException(400, "不合法的金额:" + transferAmount);
|
|
|
}
|
|
|
|
|
|
String alipayAccount = getAlipayAccount(targetUid);
|
|
|
transfer.setAlipayAccount(alipayAccount);
|
|
|
if (StringUtils.isBlank(alipayAccount)) {
|
|
|
AuthorizeResultRespVO account = getAlipayAccount(targetUid);
|
|
|
if (account == null ||
|
|
|
(StringUtils.isBlank(account.getAlipayAccount()) && StringUtils.isBlank(account.getAlipayId()))) {
|
|
|
logger.warn("transferMonErr uid {} 没有获取到有效的支付宝账号", targetUid);
|
|
|
record.setTradeStatus(201);
|
|
|
addTradeBills(record);
|
|
|
throw new ServiceException(400, "uid[" + targetUid + "]没有获取到有效的支付宝账号");
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(account.getAlipayId())) {
|
|
|
logger.info("transferMon uid {} 支付宝账号uid有值优先使用{}", targetUid, account.getAlipayId());
|
|
|
transfer.setAlipayAccount(account.getAlipayId());
|
|
|
} else if(StringUtils.isNotBlank(account.getAlipayAccount())) {
|
|
|
logger.info("transferMon uid {} 支付宝账号uid无值使用账号{}", targetUid, account.getAlipayAccount());
|
|
|
transfer.setAlipayAccount(account.getAlipayAccount());
|
|
|
}
|
|
|
String alipayAccount = transfer.getAlipayAccount();
|
|
|
|
|
|
// 转账
|
|
|
try {
|
|
|
logger.info("transferMon开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", buyerOrderCode, alipayAccount, transferAmount);
|
|
|
JSONObject jsonObject = alipayService.transferMoney(Long.toString(buyerOrderCode), null, alipayAccount, transferAmount);
|
|
|
JSONObject jsonObject = alipayService.transferMoney(Long.toString(buyerOrderCode), account.getAlipayId(), account.getAlipayAccount(), transferAmount);
|
|
|
if (jsonObject == null) {
|
|
|
logger.warn("transferMonErr 转账失败 , orderCode is {}", buyerOrderCode);
|
|
|
transfer.setStatus(3);
|
...
|
...
|
@@ -801,10 +809,6 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
if (StringUtils.isBlank(req.getOperateUname())) {
|
|
|
throw new ServiceException(400, "manualDeal:客服名称不合法");
|
|
|
}
|
|
|
String alipayAccount = req.getAlipayAccount();
|
|
|
if (StringUtils.isBlank(alipayAccount)) {
|
|
|
throw new ServiceException(400, "manualDeal:支付宝账号不合法");
|
|
|
}
|
|
|
TradeBills tradeBills = tradeBillsMapper.selectByPrimaryKey(tradeBillsId);
|
|
|
if (tradeBills == null) {
|
|
|
throw new ServiceException(400, "manualDeal:流水不存在");
|
...
|
...
|
@@ -819,10 +823,19 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
if (tradeBillsMapper.selectByDealRelateId(tradeBillsId) != null) {
|
|
|
throw new ServiceException(400, "manualDeal:该流水已经处理过");
|
|
|
}
|
|
|
String alipayAccountDb = getAlipayAccount(tradeBills.getUid());
|
|
|
if (!StringUtils.equals(alipayAccount, alipayAccountDb)) {
|
|
|
logger.warn("manualDeal:传入支付宝账号和系统不一致{},{}", alipayAccount, alipayAccountDb);
|
|
|
throw new ServiceException(400, "manualDeal:传入支付宝账号(" + alipayAccount + ")和系统不一致(" + alipayAccountDb + ")");
|
|
|
AuthorizeResultRespVO account = getAlipayAccount(tradeBills.getUid());
|
|
|
if (account == null ||
|
|
|
(StringUtils.isBlank(account.getAlipayAccount()) && StringUtils.isBlank(account.getAlipayId()))) {
|
|
|
logger.warn("manualDealErr uid {} 没有获取到有效的支付宝账号", tradeBills.getUid());
|
|
|
throw new ServiceException(400, "uid[" + tradeBills.getUid() + "]没有获取到有效的支付宝账号");
|
|
|
}
|
|
|
String alipayAccount = null;
|
|
|
if(StringUtils.isNotBlank(account.getAlipayId())) {
|
|
|
logger.info("manualDeal uid {} 支付宝账号uid有值优先使用{}", tradeBills.getUid(), account.getAlipayId());
|
|
|
alipayAccount = account.getAlipayId();
|
|
|
} else if(StringUtils.isNotBlank(account.getAlipayAccount())) {
|
|
|
logger.info("manualDeal uid {} 支付宝账号uid无值使用账号{}", tradeBills.getUid(), account.getAlipayAccount());
|
|
|
alipayAccount = account.getAlipayAccount();
|
|
|
}
|
|
|
long orderCode = tradeBills.getOrderCode();
|
|
|
|
...
|
...
|
@@ -894,7 +907,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
throw new ServiceException(400, "转账记录已成功转账,流水id=" + tradeBillsId);
|
|
|
}
|
|
|
|
|
|
JSONObject jsonObject = alipayService.transferMoney(Long.toString(orderCode), null, alipayAccount, amount);
|
|
|
JSONObject jsonObject = alipayService.transferMoney(Long.toString(orderCode), account.getAlipayId(), account.getAlipayAccount(), amount);
|
|
|
if (jsonObject == null) {
|
|
|
logger.warn("manualDeal 转账失败 , req is {}", req);
|
|
|
throw new ServiceException(500, "转账失败:阿里接口返回null");
|
...
|
...
|
@@ -1109,12 +1122,12 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
private String getAlipayAccount(int targetUid) {
|
|
|
private AuthorizeResultRespVO getAlipayAccount(int targetUid) {
|
|
|
ApiResponse<AuthorizeResultRespVO> resp = ufoServiceCaller.call("ufo.user.aliPayAccountQuery", ApiResponse.class, targetUid);
|
|
|
if (resp != null) {
|
|
|
AuthorizeResultRespVO data = (AuthorizeResultRespVO) resp.getData();
|
|
|
if (data != null && data.getAlipayAccount() != null) {
|
|
|
return data.getAlipayAccount();
|
|
|
if (data != null) {
|
|
|
return data;
|
|
|
}
|
|
|
}
|
|
|
return null;
|
...
|
...
|
|