|
@@ -119,11 +119,11 @@ public class PayCallService extends SuperService {
|
|
|
unionFrictionlessPay(entity);
|
|
unionFrictionlessPay(entity);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- boolean isPaying = isPaying(entity.getPaymentNo(), paymentType);
|
|
|
|
|
|
|
+ boolean isPaying = orderIsPaying(entity.getPaymentNo(), paymentType);
|
|
|
if (isPaying) {
|
|
if (isPaying) {
|
|
|
AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
while (atomicInteger.get() <= maxTime) {
|
|
while (atomicInteger.get() <= maxTime) {
|
|
|
- isPaying = isPaying(entity.getPaymentNo(), paymentType);
|
|
|
|
|
|
|
+ isPaying = orderIsPaying(entity.getPaymentNo(), paymentType);
|
|
|
if (!isPaying) {
|
|
if (!isPaying) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -135,6 +135,7 @@ public class PayCallService extends SuperService {
|
|
|
atomicInteger.addAndGet(300);
|
|
atomicInteger.addAndGet(300);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (entity.getIsPaySuccess() != null && entity.getIsPaySuccess()) {
|
|
if (entity.getIsPaySuccess() != null && entity.getIsPaySuccess()) {
|
|
|
b = true;
|
|
b = true;
|
|
|
break;
|
|
break;
|
|
@@ -195,6 +196,7 @@ public class PayCallService extends SuperService {
|
|
|
paymentProcess.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
paymentProcess.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
paymentProcessDao.save(paymentProcess);
|
|
paymentProcessDao.save(paymentProcess);
|
|
|
|
|
|
|
|
|
|
+ // 记录订单的现在支付类型
|
|
|
orderNoInfoService.saveInfo(entity.getPaymentNo(), OrderNoType.Pay, entity.getPaymentType());
|
|
orderNoInfoService.saveInfo(entity.getPaymentNo(), OrderNoType.Pay, entity.getPaymentType());
|
|
|
} else {
|
|
} else {
|
|
|
String msg = resultContent.getMsg();
|
|
String msg = resultContent.getMsg();
|
|
@@ -251,6 +253,8 @@ public class PayCallService extends SuperService {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
public ResultContent unionFrictionlessPay(ExpenseFlow entity) {
|
|
public ResultContent unionFrictionlessPay(ExpenseFlow entity) {
|
|
|
|
|
+ orderNoInfoService.saveInfo(entity.getPaymentNo(), OrderNoType.Pay, entity.getPaymentType());
|
|
|
|
|
+
|
|
|
String desc = "消费";
|
|
String desc = "消费";
|
|
|
OperationLogsAddParam logsAddParam = initLog(entity.getUserId());
|
|
OperationLogsAddParam logsAddParam = initLog(entity.getUserId());
|
|
|
logsAddParam.setTitle(desc);
|
|
logsAddParam.setTitle(desc);
|
|
@@ -278,7 +282,6 @@ public class PayCallService extends SuperService {
|
|
|
logsAddParam.setMessageType(MessageType.Info);
|
|
logsAddParam.setMessageType(MessageType.Info);
|
|
|
logsAddParam.setLevel(LogsLevel.Low);
|
|
logsAddParam.setLevel(LogsLevel.Low);
|
|
|
logsAddParam.setContent(msg);
|
|
logsAddParam.setContent(msg);
|
|
|
- orderNoInfoService.saveInfo(entity.getPaymentNo(), OrderNoType.Pay, entity.getPaymentType());
|
|
|
|
|
} else {
|
|
} else {
|
|
|
String msg = resultContent.getMsg();
|
|
String msg = resultContent.getMsg();
|
|
|
if (StringUtils.isNotEmpty(msg) && msg.contains("Connection reset")) {
|
|
if (StringUtils.isNotEmpty(msg) && msg.contains("Connection reset")) {
|
|
@@ -315,6 +318,7 @@ public class PayCallService extends SuperService {
|
|
|
entity.setPayMillis(entity.getPayEndTime() - entity.getPayStartTime());
|
|
entity.setPayMillis(entity.getPayEndTime() - entity.getPayStartTime());
|
|
|
expenseFlowDao.save(entity);
|
|
expenseFlowDao.save(entity);
|
|
|
|
|
|
|
|
|
|
+ // 支付产品日志
|
|
|
paymentProcess.setPayEndTime(System.currentTimeMillis());
|
|
paymentProcess.setPayEndTime(System.currentTimeMillis());
|
|
|
paymentProcess.setPayMillis(paymentProcess.getPayEndTime() - paymentProcess.getPayStartTime());
|
|
paymentProcess.setPayMillis(paymentProcess.getPayEndTime() - paymentProcess.getPayStartTime());
|
|
|
paymentProcess.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
paymentProcess.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
@@ -328,13 +332,38 @@ public class PayCallService extends SuperService {
|
|
|
* @param paymentNo
|
|
* @param paymentNo
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public ResultContent unionFrictionlessPayFinish(String paymentNo, com.github.microservice.pay.client.ret.ResultContent<List<TransactionLogModel>> resultContent, String state) {
|
|
|
|
|
|
|
+ public ResultContent unionFrictionlessPayFinish(String paymentNo,
|
|
|
|
|
+ com.github.microservice.pay.client.ret.ResultContent<List<TransactionLogModel>> resultContent, String state) {
|
|
|
if (StringUtils.isEmpty(paymentNo)) {
|
|
if (StringUtils.isEmpty(paymentNo)) {
|
|
|
return ResultContent.buildFail("paymentNo为空");
|
|
return ResultContent.buildFail("paymentNo为空");
|
|
|
}
|
|
}
|
|
|
|
|
+ log.info("云闪付支付回调: {}", paymentNo);
|
|
|
ExpenseFlow entity = expenseFlowDao.findTopByPaymentNo(paymentNo);
|
|
ExpenseFlow entity = expenseFlowDao.findTopByPaymentNo(paymentNo);
|
|
|
|
|
+ PaymentProcess paymentProcess = paymentProcessDao.findTopByPaymentNoAndPaymentTypeOrderByCreateTimeDesc(paymentNo, PaymentType.UnionFrictionlessPay);
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
|
|
+ if (state.equals("TRADE_SUCCESS")) {
|
|
|
|
|
+ entity.setOrderType(OrderState.HAVE_PAID);
|
|
|
|
|
+ entity.setIsPaySuccess(Boolean.TRUE);
|
|
|
|
|
+
|
|
|
|
|
+ paymentProcess.setIsPaySuccess(Boolean.TRUE);
|
|
|
|
|
+ paymentProcess.setPayRemark("支付成功");
|
|
|
|
|
+ paymentProcess.setIsPaying(Boolean.FALSE);
|
|
|
|
|
+ if (resultContent.getState() == ResultState.Success) {
|
|
|
|
|
+ List<TransactionLogModel> list = resultContent.getContent();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
|
|
+ entity.setTransactionIds(list.stream().map(it -> it.getId()).collect(Collectors.toUnmodifiableList()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ entity.setOrderType(OrderState.PAID_ERROR);
|
|
|
|
|
+ entity.setIsPaySuccess(Boolean.FALSE);
|
|
|
|
|
|
|
|
|
|
+ paymentProcess.setIsPaySuccess(Boolean.FALSE);
|
|
|
|
|
+ paymentProcess.setPayRemark("支付失败");
|
|
|
|
|
+ paymentProcess.setIsPaying(Boolean.FALSE);
|
|
|
|
|
+ }
|
|
|
|
|
+ expenseFlowDao.save(entity);
|
|
|
|
|
+ paymentProcessDao.save(paymentProcess);
|
|
|
}
|
|
}
|
|
|
return ResultContent.buildSuccess();
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
}
|
|
@@ -346,7 +375,7 @@ public class PayCallService extends SuperService {
|
|
|
* @param paymentType
|
|
* @param paymentType
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public boolean isPaying(String paymentNo, PaymentType paymentType) {
|
|
|
|
|
|
|
+ public boolean orderIsPaying(String paymentNo, PaymentType paymentType) {
|
|
|
PaymentProcess paymentProcess = paymentProcessDao.findTopByPaymentNoAndPaymentTypeOrderByCreateTimeDesc(paymentNo, paymentType);
|
|
PaymentProcess paymentProcess = paymentProcessDao.findTopByPaymentNoAndPaymentTypeOrderByCreateTimeDesc(paymentNo, paymentType);
|
|
|
if (ObjectUtils.isNotEmpty(paymentProcess) && paymentProcess.getIsPaying() != null && paymentProcess.getIsPaying()) {
|
|
if (ObjectUtils.isNotEmpty(paymentProcess) && paymentProcess.getIsPaying() != null && paymentProcess.getIsPaying()) {
|
|
|
return true;
|
|
return true;
|