...
|
...
|
@@ -546,7 +546,9 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
@Database(ForceMaster = true)
|
|
|
public boolean transAllEarnest(long orderCode, Integer uid, BigDecimal amount,
|
|
|
AuthorizeResultRespVO aliPayAccount) {
|
|
|
logger.info("退还商家所有保证金,转账开始,orderCode = {}, uid={}, amount={}, alipayAccount={}", orderCode, uid, amount, aliPayAccount);
|
|
|
|
|
|
String logTag = String.format("transfer all earnest {}-{}", orderCode, uid);
|
|
|
logger.info("{}, amount is {} and alipay account is {}", logTag, amount, aliPayAccount);
|
|
|
|
|
|
int now = (int) (System.currentTimeMillis() / 1000);
|
|
|
// 查看是否已经有转账记录
|
...
|
...
|
@@ -563,6 +565,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
TradeBills record = new TradeBills();
|
|
|
record.setUid(uid);
|
|
|
record.setOrderCode(orderCode);
|
|
|
record.setPaidOrderCode(0L);
|
|
|
record.setUserType(2);
|
|
|
record.setPayType(1);
|
|
|
record.setTradeType(1);
|
...
|
...
|
@@ -574,7 +577,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
|
|
|
|
|
|
if (amount == null || amount.compareTo(new BigDecimal("0.1")) < 0) {
|
|
|
logger.warn("transAllEarnestErr transferMon计算费用结果为 {}, 小于0.1或为null", amount);
|
|
|
logger.warn("{}, amount {} less 0.1 or null", logTag, amount);
|
|
|
alarm("转账金额小于0.1或为null", "ufo.order.transAllEarnest", "退还商家入驻所有金额,订单号:" + orderCode + "操作类型(" + 6 + ")计算金额结果为" + amount);
|
|
|
record.setTradeStatus(BillTradeStatus.AMOUNT_IS_ILLEGAL.getCode());
|
|
|
addTradeBills(record);
|
...
|
...
|
@@ -582,20 +585,20 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
}
|
|
|
|
|
|
if (StringUtils.isBlank(aliPayAccount.getAlipayAccount()) && StringUtils.isBlank(aliPayAccount.getAlipayId())) {
|
|
|
logger.warn("transAllEarnestErr uid {} 支付宝账号不合法", account);
|
|
|
logger.warn("{}, alipay account is not exist", logTag);
|
|
|
record.setTradeStatus(BillTradeStatus.NOT_EXIST_ALIPAY_ACCOUNT.getCode());
|
|
|
addTradeBills(record);
|
|
|
throw new ServiceException(400, "uid[" + uid + "]支付宝账号不合法");
|
|
|
}
|
|
|
|
|
|
logger.info("transAllEarnest参数检查成功!");
|
|
|
logger.info("{}, data check ok.", logTag);
|
|
|
tradeBillsMapper.insert(record);
|
|
|
// 转账
|
|
|
JSONObject jsonObject = null;
|
|
|
boolean exceedMillionAndSuccess = false;
|
|
|
transfer.setUpdateTime(now);
|
|
|
try {
|
|
|
logger.info("transAllEarnest开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", orderCode, account, amount);
|
|
|
logger.info("{}, transfer start", logTag);
|
|
|
shoppingRiskWatchDog.checkAlipayBlackUser(aliPayAccount.getUid(), aliPayAccount);
|
|
|
if (alipayTransferChancelSelector.isTransferWithAlipayExceedMillionTransfer()) {
|
|
|
transfer.setInterfaceType(2);
|
...
|
...
|
@@ -615,7 +618,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
ordersPayTransferMapper.updateByPrimaryKeySelective(transfer);
|
|
|
jsonObject = alipayService.transferMoney(Long.toString(orderCode), aliPayAccount.getAlipayId(), aliPayAccount.getAlipayAccount(), amount);
|
|
|
if (jsonObject == null) {
|
|
|
logger.warn("transAllEarnestErr 转账失败 , orderCode is {}", orderCode);
|
|
|
logger.warn("{}, transfer fail.", logTag);
|
|
|
transfer.setStatus(3);
|
|
|
throw new ServiceException(500, "转账失败:阿里接口返回null");
|
|
|
}
|
...
|
...
|
@@ -627,7 +630,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
&& (code = jsonObject.getInteger("code")) == 10000
|
|
|
&& jsonObject.containsKey("order_id")
|
|
|
&& StringUtils.isNotBlank(orderId = jsonObject.getString("order_id"))) {
|
|
|
logger.info("转账成功,targeAccount is {}, amount is {}", account, amount);
|
|
|
logger.info("{}, transfer success, account is {}, amount is {}", logTag, account, amount);
|
|
|
transfer.setAlipayTradeId(orderId);
|
|
|
transfer.setStatus(1);
|
|
|
return true;
|
...
|
...
|
@@ -644,16 +647,15 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
return true;
|
|
|
}
|
|
|
} else {
|
|
|
logger.warn("transAllEarnestErr 返回code或者order_id不是成功状态,code={}, orderId={}", code, orderId);
|
|
|
logger.warn("{}, transfer fail, return_code is {} and return_order_id is {}", logTag, code, orderId);
|
|
|
throw new ServiceException(500, "转账失败:code或者order_id不是成功状态");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.warn("transAllEarnestErr 转账失败 , orderCode is {}, msg is {}", orderCode, e.getMessage());
|
|
|
logger.warn("{}, transfer fail", logTag, e);
|
|
|
String alarmMsg = "订单号:" + orderCode + ",操作类型(商家退出入驻退保证金),msg=" + e.getMessage();
|
|
|
if (jsonObject != null) {
|
|
|
alarmMsg += ",阿里返回DETAIL=" + jsonObject.toJSONString();
|
|
|
}
|
|
|
logger.info("transAllEarnestErr 转账失败 , alarmMsg is {}", alarmMsg);
|
|
|
alarm("转账失败", "ufo.order.transAllEarnest", alarmMsg);
|
|
|
transfer.setStatus(3);
|
|
|
if (e instanceof ServiceException) {
|
...
|
...
|
@@ -663,17 +665,17 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
}
|
|
|
} finally {
|
|
|
if (exceedMillionAndSuccess) {
|
|
|
logger.info("transferMon exceedMillion,转账结束,等待回调 orderCode is {}!", orderCode);
|
|
|
logger.info("{}, transfer exceed million waiting...", logTag);
|
|
|
return true;
|
|
|
}
|
|
|
logger.info("transAllEarnest最后更新状态 status= {}", transfer.getStatus());
|
|
|
logger.info("{}, transfer end update status to {}", logTag, transfer.getStatus());
|
|
|
transfer.setUpdateTime(now);
|
|
|
ordersPayTransferMapper.updateByPrimaryKeySelective(transfer);
|
|
|
// 100:成功;201:没有支付宝账号;202:金额不合法;299:转账失败
|
|
|
BillTradeStatus bts = transfer.getStatus() == 1 ? BillTradeStatus.SUCCESS : BillTradeStatus.TRANSFER_FAIL;
|
|
|
record.setTradeStatus(bts.getCode());
|
|
|
tradeBillsMapper.updateSelectiveByPrimaryKey(record);
|
|
|
logger.info("transAllEarnest最后更新状态完成,转账结束, orderCode is {}!", orderCode);
|
|
|
logger.info("{}, transfer end update status to {} ok", logTag, transfer.getStatus());
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1364,6 +1366,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
TradeBills record = new TradeBills();
|
|
|
record.setUid(targetUid);
|
|
|
record.setOrderCode(buyerOrderCode);
|
|
|
record.setPaidOrderCode(0L);
|
|
|
record.setUserType(targetUserType.getCode());
|
|
|
record.setPayType(1);
|
|
|
// 如果[全部货款->卖家],否则[补偿款->卖家或买家] 2:货款;3:补偿款
|
...
|
...
|
|