后端:pingxx 回调接口,增加错误日志
This commit is contained in:
parent
e0713cda1f
commit
3e156b18ee
@ -49,6 +49,7 @@ public class PayTransactionController {
|
|||||||
@PostMapping(value = "pingxx_pay_success", consumes = MediaType.APPLICATION_JSON_VALUE)
|
@PostMapping(value = "pingxx_pay_success", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
// @GetMapping(value = "pingxx_pay_success")
|
// @GetMapping(value = "pingxx_pay_success")
|
||||||
public String pingxxSuccess(HttpServletRequest request) throws IOException {
|
public String pingxxSuccess(HttpServletRequest request) throws IOException {
|
||||||
|
logger.info("[pingxxSuccess][被回调]");
|
||||||
// 读取 webhook
|
// 读取 webhook
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
try (BufferedReader reader = request.getReader()) {
|
try (BufferedReader reader = request.getReader()) {
|
||||||
|
@ -154,7 +154,8 @@ public class PayServiceImpl implements PayTransactionService {
|
|||||||
if (updateCounts == 0) { // 校验状态,必须是待支付
|
if (updateCounts == 0) { // 校验状态,必须是待支付
|
||||||
throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_TRANSACTION_EXTENSION_STATUS_IS_NOT_WAITING.getCode());
|
throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_TRANSACTION_EXTENSION_STATUS_IS_NOT_WAITING.getCode());
|
||||||
}
|
}
|
||||||
// 2.1
|
logger.info("[updateTransactionPaySuccess][PayTransactionExtensionDO({}) 更新为已支付]", payTransactionExtension.getId());
|
||||||
|
// 2.1 判断 PayTransactionDO 是否处于待支付
|
||||||
PayTransactionDO payTransactionDO = payTransactionMapper.selectById(payTransactionExtension.getTransactionId());
|
PayTransactionDO payTransactionDO = payTransactionMapper.selectById(payTransactionExtension.getTransactionId());
|
||||||
if (payTransactionDO == null) {
|
if (payTransactionDO == null) {
|
||||||
return ServiceExceptionUtil.error(PayErrorCodeEnum.PAY_TRANSACTION_NOT_FOUND.getCode());
|
return ServiceExceptionUtil.error(PayErrorCodeEnum.PAY_TRANSACTION_NOT_FOUND.getCode());
|
||||||
@ -175,6 +176,7 @@ public class PayServiceImpl implements PayTransactionService {
|
|||||||
if (updateCounts == 0) { // 校验状态,必须是待支付 TODO 这种类型,需要思考下。需要返回错误,但是又要保证事务回滚
|
if (updateCounts == 0) { // 校验状态,必须是待支付 TODO 这种类型,需要思考下。需要返回错误,但是又要保证事务回滚
|
||||||
throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_TRANSACTION_STATUS_IS_NOT_WAITING.getCode());
|
throw ServiceExceptionUtil.exception(PayErrorCodeEnum.PAY_TRANSACTION_STATUS_IS_NOT_WAITING.getCode());
|
||||||
}
|
}
|
||||||
|
logger.info("[updateTransactionPaySuccess][PayTransactionDO({}) 更新为已支付]", payTransactionDO.getId());
|
||||||
// 3.1 插入
|
// 3.1 插入
|
||||||
PayTransactionNotifyTaskDO payTransactionNotifyTask = new PayTransactionNotifyTaskDO()
|
PayTransactionNotifyTaskDO payTransactionNotifyTask = new PayTransactionNotifyTaskDO()
|
||||||
.setTransactionId(payTransactionExtension.getTransactionId()).setTransactionExtensionId(payTransactionExtension.getId())
|
.setTransactionId(payTransactionExtension.getTransactionId()).setTransactionExtensionId(payTransactionExtension.getId())
|
||||||
@ -184,9 +186,11 @@ public class PayServiceImpl implements PayTransactionService {
|
|||||||
.setNextNotifyTime(DateUtil.addDate(Calendar.SECOND, PayTransactionNotifyTaskDO.NOTIFY_FREQUENCY[0]))
|
.setNextNotifyTime(DateUtil.addDate(Calendar.SECOND, PayTransactionNotifyTaskDO.NOTIFY_FREQUENCY[0]))
|
||||||
.setNotifyUrl(payTransactionDO.getNotifyUrl());
|
.setNotifyUrl(payTransactionDO.getNotifyUrl());
|
||||||
payTransactionNotifyTaskMapper.insert(payTransactionNotifyTask);
|
payTransactionNotifyTaskMapper.insert(payTransactionNotifyTask);
|
||||||
|
logger.info("[updateTransactionPaySuccess][PayTransactionNotifyTaskDO({}) 新增一个任务]", payTransactionNotifyTask.getId());
|
||||||
// 3.2 发送 MQ
|
// 3.2 发送 MQ
|
||||||
rocketMQTemplate.convertAndSend(MQConstant.TOPIC_PAY_TRANSACTION_PAY_SUCCESS,
|
rocketMQTemplate.convertAndSend(MQConstant.TOPIC_PAY_TRANSACTION_PAY_SUCCESS,
|
||||||
PayTransactionConvert.INSTANCE.convert(payTransactionNotifyTask));
|
PayTransactionConvert.INSTANCE.convert(payTransactionNotifyTask));
|
||||||
|
logger.info("[updateTransactionPaySuccess][PayTransactionNotifyTaskDO({}) 发送 MQ 任务]", payTransactionNotifyTask.getId());
|
||||||
// 返回结果
|
// 返回结果
|
||||||
return CommonResult.success(true);
|
return CommonResult.success(true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user