|
@@ -546,7 +546,9 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -546,7 +546,9 @@ public class PaymentServiceImpl implements IPaymentService { |
546
|
@Database(ForceMaster = true)
|
546
|
@Database(ForceMaster = true)
|
547
|
public boolean transAllEarnest(long orderCode, Integer uid, BigDecimal amount,
|
547
|
public boolean transAllEarnest(long orderCode, Integer uid, BigDecimal amount,
|
548
|
AuthorizeResultRespVO aliPayAccount) {
|
548
|
AuthorizeResultRespVO aliPayAccount) {
|
549
|
- logger.info("退还商家所有保证金,转账开始,orderCode = {}, uid={}, amount={}, alipayAccount={}", orderCode, uid, amount, aliPayAccount);
|
549
|
+
|
|
|
550
|
+ String logTag = String.format("transfer all earnest {}-{}", orderCode, uid);
|
|
|
551
|
+ logger.info("{}, amount is {} and alipay account is {}", logTag, amount, aliPayAccount);
|
550
|
|
552
|
|
551
|
int now = (int) (System.currentTimeMillis() / 1000);
|
553
|
int now = (int) (System.currentTimeMillis() / 1000);
|
552
|
// 查看是否已经有转账记录
|
554
|
// 查看是否已经有转账记录
|
|
@@ -575,7 +577,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -575,7 +577,7 @@ public class PaymentServiceImpl implements IPaymentService { |
575
|
|
577
|
|
576
|
|
578
|
|
577
|
if (amount == null || amount.compareTo(new BigDecimal("0.1")) < 0) {
|
579
|
if (amount == null || amount.compareTo(new BigDecimal("0.1")) < 0) {
|
578
|
- logger.warn("transAllEarnestErr transferMon计算费用结果为 {}, 小于0.1或为null", amount);
|
580
|
+ logger.warn("{}, amount {} less 0.1 or null", logTag, amount);
|
579
|
alarm("转账金额小于0.1或为null", "ufo.order.transAllEarnest", "退还商家入驻所有金额,订单号:" + orderCode + "操作类型(" + 6 + ")计算金额结果为" + amount);
|
581
|
alarm("转账金额小于0.1或为null", "ufo.order.transAllEarnest", "退还商家入驻所有金额,订单号:" + orderCode + "操作类型(" + 6 + ")计算金额结果为" + amount);
|
580
|
record.setTradeStatus(BillTradeStatus.AMOUNT_IS_ILLEGAL.getCode());
|
582
|
record.setTradeStatus(BillTradeStatus.AMOUNT_IS_ILLEGAL.getCode());
|
581
|
addTradeBills(record);
|
583
|
addTradeBills(record);
|
|
@@ -583,20 +585,20 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -583,20 +585,20 @@ public class PaymentServiceImpl implements IPaymentService { |
583
|
}
|
585
|
}
|
584
|
|
586
|
|
585
|
if (StringUtils.isBlank(aliPayAccount.getAlipayAccount()) && StringUtils.isBlank(aliPayAccount.getAlipayId())) {
|
587
|
if (StringUtils.isBlank(aliPayAccount.getAlipayAccount()) && StringUtils.isBlank(aliPayAccount.getAlipayId())) {
|
586
|
- logger.warn("transAllEarnestErr uid {} 支付宝账号不合法", account);
|
588
|
+ logger.warn("{}, alipay account is not exist", logTag);
|
587
|
record.setTradeStatus(BillTradeStatus.NOT_EXIST_ALIPAY_ACCOUNT.getCode());
|
589
|
record.setTradeStatus(BillTradeStatus.NOT_EXIST_ALIPAY_ACCOUNT.getCode());
|
588
|
addTradeBills(record);
|
590
|
addTradeBills(record);
|
589
|
throw new ServiceException(400, "uid[" + uid + "]支付宝账号不合法");
|
591
|
throw new ServiceException(400, "uid[" + uid + "]支付宝账号不合法");
|
590
|
}
|
592
|
}
|
591
|
|
593
|
|
592
|
- logger.info("transAllEarnest参数检查成功!");
|
594
|
+ logger.info("{}, data check ok.", logTag);
|
593
|
tradeBillsMapper.insert(record);
|
595
|
tradeBillsMapper.insert(record);
|
594
|
// 转账
|
596
|
// 转账
|
595
|
JSONObject jsonObject = null;
|
597
|
JSONObject jsonObject = null;
|
596
|
boolean exceedMillionAndSuccess = false;
|
598
|
boolean exceedMillionAndSuccess = false;
|
597
|
transfer.setUpdateTime(now);
|
599
|
transfer.setUpdateTime(now);
|
598
|
try {
|
600
|
try {
|
599
|
- logger.info("transAllEarnest开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", orderCode, account, amount);
|
601
|
+ logger.info("{}, transfer start", logTag);
|
600
|
shoppingRiskWatchDog.checkAlipayBlackUser(aliPayAccount.getUid(), aliPayAccount);
|
602
|
shoppingRiskWatchDog.checkAlipayBlackUser(aliPayAccount.getUid(), aliPayAccount);
|
601
|
if (alipayTransferChancelSelector.isTransferWithAlipayExceedMillionTransfer()) {
|
603
|
if (alipayTransferChancelSelector.isTransferWithAlipayExceedMillionTransfer()) {
|
602
|
transfer.setInterfaceType(2);
|
604
|
transfer.setInterfaceType(2);
|
|
@@ -616,7 +618,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -616,7 +618,7 @@ public class PaymentServiceImpl implements IPaymentService { |
616
|
ordersPayTransferMapper.updateByPrimaryKeySelective(transfer);
|
618
|
ordersPayTransferMapper.updateByPrimaryKeySelective(transfer);
|
617
|
jsonObject = alipayService.transferMoney(Long.toString(orderCode), aliPayAccount.getAlipayId(), aliPayAccount.getAlipayAccount(), amount);
|
619
|
jsonObject = alipayService.transferMoney(Long.toString(orderCode), aliPayAccount.getAlipayId(), aliPayAccount.getAlipayAccount(), amount);
|
618
|
if (jsonObject == null) {
|
620
|
if (jsonObject == null) {
|
619
|
- logger.warn("transAllEarnestErr 转账失败 , orderCode is {}", orderCode);
|
621
|
+ logger.warn("{}, transfer fail.", logTag);
|
620
|
transfer.setStatus(3);
|
622
|
transfer.setStatus(3);
|
621
|
throw new ServiceException(500, "转账失败:阿里接口返回null");
|
623
|
throw new ServiceException(500, "转账失败:阿里接口返回null");
|
622
|
}
|
624
|
}
|
|
@@ -628,7 +630,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -628,7 +630,7 @@ public class PaymentServiceImpl implements IPaymentService { |
628
|
&& (code = jsonObject.getInteger("code")) == 10000
|
630
|
&& (code = jsonObject.getInteger("code")) == 10000
|
629
|
&& jsonObject.containsKey("order_id")
|
631
|
&& jsonObject.containsKey("order_id")
|
630
|
&& StringUtils.isNotBlank(orderId = jsonObject.getString("order_id"))) {
|
632
|
&& StringUtils.isNotBlank(orderId = jsonObject.getString("order_id"))) {
|
631
|
- logger.info("转账成功,targeAccount is {}, amount is {}", account, amount);
|
633
|
+ logger.info("{}, transfer success, account is {}, amount is {}", logTag, account, amount);
|
632
|
transfer.setAlipayTradeId(orderId);
|
634
|
transfer.setAlipayTradeId(orderId);
|
633
|
transfer.setStatus(1);
|
635
|
transfer.setStatus(1);
|
634
|
return true;
|
636
|
return true;
|
|
@@ -645,16 +647,15 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -645,16 +647,15 @@ public class PaymentServiceImpl implements IPaymentService { |
645
|
return true;
|
647
|
return true;
|
646
|
}
|
648
|
}
|
647
|
} else {
|
649
|
} else {
|
648
|
- logger.warn("transAllEarnestErr 返回code或者order_id不是成功状态,code={}, orderId={}", code, orderId);
|
650
|
+ logger.warn("{}, transfer fail, return_code is {} and return_order_id is {}", logTag, code, orderId);
|
649
|
throw new ServiceException(500, "转账失败:code或者order_id不是成功状态");
|
651
|
throw new ServiceException(500, "转账失败:code或者order_id不是成功状态");
|
650
|
}
|
652
|
}
|
651
|
} catch (Exception e) {
|
653
|
} catch (Exception e) {
|
652
|
- logger.warn("transAllEarnestErr 转账失败 , orderCode is {}, msg is {}", orderCode, e.getMessage());
|
654
|
+ logger.warn("{}, transfer fail", logTag, e);
|
653
|
String alarmMsg = "订单号:" + orderCode + ",操作类型(商家退出入驻退保证金),msg=" + e.getMessage();
|
655
|
String alarmMsg = "订单号:" + orderCode + ",操作类型(商家退出入驻退保证金),msg=" + e.getMessage();
|
654
|
if (jsonObject != null) {
|
656
|
if (jsonObject != null) {
|
655
|
alarmMsg += ",阿里返回DETAIL=" + jsonObject.toJSONString();
|
657
|
alarmMsg += ",阿里返回DETAIL=" + jsonObject.toJSONString();
|
656
|
}
|
658
|
}
|
657
|
- logger.info("transAllEarnestErr 转账失败 , alarmMsg is {}", alarmMsg);
|
|
|
658
|
alarm("转账失败", "ufo.order.transAllEarnest", alarmMsg);
|
659
|
alarm("转账失败", "ufo.order.transAllEarnest", alarmMsg);
|
659
|
transfer.setStatus(3);
|
660
|
transfer.setStatus(3);
|
660
|
if (e instanceof ServiceException) {
|
661
|
if (e instanceof ServiceException) {
|
|
@@ -664,17 +665,17 @@ public class PaymentServiceImpl implements IPaymentService { |
|
@@ -664,17 +665,17 @@ public class PaymentServiceImpl implements IPaymentService { |
664
|
}
|
665
|
}
|
665
|
} finally {
|
666
|
} finally {
|
666
|
if (exceedMillionAndSuccess) {
|
667
|
if (exceedMillionAndSuccess) {
|
667
|
- logger.info("transferMon exceedMillion,转账结束,等待回调 orderCode is {}!", orderCode);
|
668
|
+ logger.info("{}, transfer exceed million waiting...", logTag);
|
668
|
return true;
|
669
|
return true;
|
669
|
}
|
670
|
}
|
670
|
- logger.info("transAllEarnest最后更新状态 status= {}", transfer.getStatus());
|
671
|
+ logger.info("{}, transfer end update status to {}", logTag, transfer.getStatus());
|
671
|
transfer.setUpdateTime(now);
|
672
|
transfer.setUpdateTime(now);
|
672
|
ordersPayTransferMapper.updateByPrimaryKeySelective(transfer);
|
673
|
ordersPayTransferMapper.updateByPrimaryKeySelective(transfer);
|
673
|
// 100:成功;201:没有支付宝账号;202:金额不合法;299:转账失败
|
674
|
// 100:成功;201:没有支付宝账号;202:金额不合法;299:转账失败
|
674
|
BillTradeStatus bts = transfer.getStatus() == 1 ? BillTradeStatus.SUCCESS : BillTradeStatus.TRANSFER_FAIL;
|
675
|
BillTradeStatus bts = transfer.getStatus() == 1 ? BillTradeStatus.SUCCESS : BillTradeStatus.TRANSFER_FAIL;
|
675
|
record.setTradeStatus(bts.getCode());
|
676
|
record.setTradeStatus(bts.getCode());
|
676
|
tradeBillsMapper.updateSelectiveByPrimaryKey(record);
|
677
|
tradeBillsMapper.updateSelectiveByPrimaryKey(record);
|
677
|
- logger.info("transAllEarnest最后更新状态完成,转账结束, orderCode is {}!", orderCode);
|
678
|
+ logger.info("{}, transfer end update status to {} ok", logTag, transfer.getStatus());
|
678
|
}
|
679
|
}
|
679
|
}
|
680
|
}
|
680
|
|
681
|
|