Commit 8be5f23c by Jony.L

新支付功能测试7.0 完成回调接口的开发,api模块支付待重构

parent 48277ba8
......@@ -45,42 +45,6 @@ public class ComputeWpgjPayController {
@Resource
private WpgjPayProperties wpgjPayProperties;
@PostMapping("/notify")
@PermitAll
@Operation(summary = "WPGJ支付异步回调通知 - 算力资源模块")
public CommonResult<WpgjPayNotifyRespDTO> notifyWpgjPay(@RequestBody WpgjPayNotifyDTO notifyDTO) {
WpgjPayNotifyRespDTO response = new WpgjPayNotifyRespDTO();
try {
log.info("[notifyWpgjPay][Compute] 收到WPGJ支付回调: {}", JsonUtils.toJsonString(notifyDTO));
// 1. 验证签名
if (!verifyWpgjSignature(notifyDTO)) {
log.error("[notifyWpgjPay][Compute] WPGJ回调签名验证失败");
response.setCode("99");
response.setMsg("签名验证失败");
response.setTimestamp(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")));
return CommonResult.success(response);
}
// 2. 处理支付结果通知
handleWpgjPaymentResult(notifyDTO);
log.info("[notifyWpgjPay][Compute] WPGJ支付回调处理完成");
response.setCode("00");
response.setMsg("成功");
response.setTimestamp(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")));
return CommonResult.success(response);
} catch (Exception e) {
log.error("[notifyWpgjPay][Compute] WPGJ支付回调处理失败", e);
response.setCode("99");
response.setMsg("处理失败");
response.setTimestamp(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")));
return CommonResult.success(response);
}
}
@PostMapping("/new-notify")
@PermitAll
@Operation(summary = "WPGJ支付异步回调通知(新) - 按文档通用验签")
......@@ -106,7 +70,7 @@ public class ComputeWpgjPayController {
// 2. 幂等处理:根据订单状态更新(与老接口保持一致逻辑)
if (WpgjOrderStatusEnum.isSuccess(orderStatus)) {
resourceOrderService.updateOrderPaidByWpgj(Long.parseLong(merOrderId), notifyDTO);
resourceOrderService.updateOrderPaidByWpgj(Long.parseLong(merOrderId),notifyDTO);
log.info("[notifyWpgjPayNew] 支付成功处理完成,商户订单号: {}", merOrderId);
} else if (WpgjOrderStatusEnum.isFailedOrClosed(orderStatus)) {
resourceOrderService.updateOrderFailedByWpgj(Long.parseLong(merOrderId), notifyDTO);
......@@ -198,42 +162,4 @@ public class ComputeWpgjPayController {
map.put("sign", dto.getSign());
return map;
}
/**
* 处理WPGJ支付结果
*/
private void handleWpgjPaymentResult(WpgjPayNotifyDTO notifyDTO) {
try {
String merOrderId = notifyDTO.getMerOrderId();
String orderStatus = notifyDTO.getOrderStatus();
log.info("[handleWpgjPaymentResult] 处理WPGJ支付结果,商户订单号: {}, 订单状态: {}", merOrderId, orderStatus);
// 根据WPGJ订单状态更新算力资源订单
if (WpgjOrderStatusEnum.isSuccess(orderStatus)) {
// 支付成功
resourceOrderService.updateOrderPaidByWpgj(Long.parseLong(merOrderId), notifyDTO);
log.info("[handleWpgjPaymentResult] 算力资源订单支付成功处理完成,商户订单号: {}", merOrderId);
} else if (WpgjOrderStatusEnum.isFailedOrClosed(orderStatus)) {
// 支付失败或关闭
resourceOrderService.updateOrderFailedByWpgj(Long.parseLong(merOrderId), notifyDTO);
log.info("[handleWpgjPaymentResult] 算力资源订单支付失败处理完成,商户订单号: {}", merOrderId);
} else {
// 其他状态(处理中等),暂不处理
log.info("[handleWpgjPaymentResult] WPGJ订单状态无需处理,商户订单号: {}, 状态: {}", merOrderId, orderStatus);
}
} catch (Exception e) {
log.error("[handleWpgjPaymentResult] 处理WPGJ支付结果异常", e);
throw e;
}
}
/**
* 验证WPGJ回调签名
*/
private boolean verifyWpgjSignature(WpgjPayNotifyDTO notifyDTO) {
// 复用 Map 验签,确保与文档一致(ASCII 排序 + key)
return verifyWpgjSignature(toPayloadMap(notifyDTO));
}
}
......@@ -24,14 +24,17 @@ import com.luhu.computility.module.compute.service.resourcesku.ResourceSkuServic
import com.luhu.computility.module.compute.service.resourcespu.ResourceSpuService;
import com.luhu.computility.module.pay.api.order.PayOrderApi;
import com.luhu.computility.module.pay.api.order.dto.PayOrderCreateReqDTO;
import com.luhu.computility.module.pay.api.order.dto.PayOrderRespDTO;
import com.luhu.computility.module.pay.api.wpgj.PayOrderWpgjApi;
import com.luhu.computility.module.pay.api.wpgj.dto.PayOrderWpgjCreateReqDTO;
import com.luhu.computility.module.pay.api.order.dto.PayOrderRespDTO;
import com.luhu.computility.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO;
import com.luhu.computility.module.pay.api.wpgj.vo.WpgjPayOrderSubmitReqVO;
import com.luhu.computility.module.pay.controller.admin.notify.vo.WpgjPayNotifyDTO;
import com.luhu.computility.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO;
import com.luhu.computility.module.pay.dal.dataobject.wpgj.PayOrderWpgjDO;
import com.luhu.computility.module.pay.dal.mysql.wpgj.PayOrderWpgjMapper;
import com.luhu.computility.module.pay.enums.WpgjOrderStatusEnum;
import com.luhu.computility.module.pay.enums.order.PayOrderStatusEnum;
import com.luhu.computility.module.pay.framework.pay.core.client.impl.wpgj.WpgjPayProperties;
import com.luhu.computility.module.pay.controller.admin.notify.vo.WpgjPayNotifyDTO;
import com.luhu.computility.module.pay.service.order.PayOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
......@@ -65,6 +68,9 @@ import static com.luhu.computility.module.compute.enums.ResourceOrderRefundStatu
public class ResourceOrderServiceImpl implements ResourceOrderService {
@Resource
private PayOrderWpgjMapper payOrderWpgjMapper;
@Resource
private ResourceOrderMapper resourceOrderMapper;
@Resource
......@@ -83,9 +89,6 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
private PayOrderWpgjApi payOrderWpgjApi;
@Resource
private PayOrderService payOrderService;
@Resource
private ResourceOrderProperties resourceOrderProperties;
@Resource
......@@ -561,13 +564,20 @@ public class ResourceOrderServiceImpl implements ResourceOrderService {
orderId, wpgjOrderAmt, resourceOrderAmt);
// 4. 更新算力资源订单状态为已支付
ResourceOrderDO updateOrder = new ResourceOrderDO();
updateOrder.setId(orderId);
updateOrder.setStatus(ResourceOrderStatus.PAID.getValue());
updateOrder.setPayTime(LocalDateTime.now());
resourceOrderMapper.updateById(updateOrder);
ResourceOrderDO updateResourceOrder = new ResourceOrderDO();
updateResourceOrder.setId(orderId);
updateResourceOrder.setStatus(ResourceOrderStatus.PAID.getValue());
updateResourceOrder.setPayTime(LocalDateTime.now());
//更新支付订单状态为已支付
PayOrderWpgjDO updatePayOrder = new PayOrderWpgjDO();
updatePayOrder.setId(order.getPayOrderId());
updatePayOrder.setOrderId(notifyDTO.getOrderId());
updatePayOrder.setOrderStatus(WpgjOrderStatusEnum.SUCCESS.getStatus());
updatePayOrder.setTradeTime(notifyDTO.getTradeTime());
resourceOrderMapper.updateById(updateResourceOrder);
payOrderWpgjMapper.updateById(updatePayOrder);
log.info("[updateOrderPaidByWpgj] WPGJ支付成功回调处理完成,订单ID: {}, WPGJ订单号: {}",
orderId, notifyDTO.getOrderId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment