|
|
@@ -38,7 +38,8 @@ public class PayScoreController {
|
|
|
private final PayScoreService payScoreService;
|
|
|
private final OrderService orderService;
|
|
|
private final UserService userService;
|
|
|
- private final WxPayConfig wxPayConfig;
|
|
|
+ // todo 微信支付开通好后放开
|
|
|
+// private final WxPayConfig wxPayConfig;
|
|
|
|
|
|
/**
|
|
|
* 检查用户是否已开通微信支付分
|
|
|
@@ -61,7 +62,7 @@ public class PayScoreController {
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
data.put("enabled", isEnabled);
|
|
|
data.put("userId", userId);
|
|
|
-
|
|
|
+
|
|
|
log.info("用户 {} 支付分开通状态:{}", userId, isEnabled ? "已开通" : "未开通");
|
|
|
return Result.success("查询成功", data);
|
|
|
|
|
|
@@ -101,10 +102,10 @@ public class PayScoreController {
|
|
|
|
|
|
// 生成微信商户订单号
|
|
|
String outOrderNo = generatePayscoreOrderNo(userId);
|
|
|
-
|
|
|
+
|
|
|
// 构建返回数据,供前端调起微信支付分开通页面
|
|
|
Map<String, Object> data = buildEnableData(userId, outOrderNo);
|
|
|
-
|
|
|
+
|
|
|
log.info("用户 {} 准备开通支付分,outOrderNo: {}", userId, outOrderNo);
|
|
|
return Result.success("请完成支付分授权", data);
|
|
|
|
|
|
@@ -140,15 +141,15 @@ public class PayScoreController {
|
|
|
|
|
|
// 查询支付分订单状态
|
|
|
PayScoreResult result = payScoreService.queryPayScoreOrder(outOrderNo);
|
|
|
-
|
|
|
+
|
|
|
if (result.isSuccess() && "ACCEPTED".equals(result.getState())) {
|
|
|
// 用户已授权,更新状态
|
|
|
updateUserPayscoreStatus(user);
|
|
|
-
|
|
|
+
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
data.put("enabled", true);
|
|
|
data.put("userId", userId);
|
|
|
-
|
|
|
+
|
|
|
log.info("用户 {} 确认开通支付分成功", userId);
|
|
|
return Result.success("开通成功", data);
|
|
|
} else {
|
|
|
@@ -184,8 +185,9 @@ public class PayScoreController {
|
|
|
data.put("enabled", false);
|
|
|
data.put("userId", userId);
|
|
|
data.put("outOrderNo", outOrderNo);
|
|
|
- data.put("serviceId", wxPayConfig != null ? wxPayConfig.getServiceId() : "");
|
|
|
- data.put("appId", wxPayConfig != null ? wxPayConfig.getAppId() : "");
|
|
|
+ // todo 微信支付开通好后放开
|
|
|
+// data.put("serviceId", wxPayConfig != null ? wxPayConfig.getServiceId() : "");
|
|
|
+// data.put("appId", wxPayConfig != null ? wxPayConfig.getAppId() : "");
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
@@ -205,7 +207,7 @@ public class PayScoreController {
|
|
|
user.setPayscoreEnabled(PAYSCORE_ENABLED);
|
|
|
user.setUpdateTime(java.time.LocalDateTime.now());
|
|
|
boolean updated = userService.updateById(user);
|
|
|
-
|
|
|
+
|
|
|
if (!updated) {
|
|
|
throw new RuntimeException("更新用户状态失败");
|
|
|
}
|
|
|
@@ -271,7 +273,7 @@ public class PayScoreController {
|
|
|
log.info("创建支付分服务订单成功 - orderId: {}, outOrderNo: {}", orderId, result.getOutOrderNo());
|
|
|
return Result.success("创建成功", data);
|
|
|
} else {
|
|
|
- log.warn("创建支付分服务订单失败 - orderId: {}, errorCode: {}, errorMsg: {}",
|
|
|
+ log.warn("创建支付分服务订单失败 - orderId: {}, errorCode: {}, errorMsg: {}",
|
|
|
orderId, result.getErrorCode(), result.getErrorMsg());
|
|
|
return Result.error(500, result.getErrorMsg());
|
|
|
}
|
|
|
@@ -339,7 +341,7 @@ public class PayScoreController {
|
|
|
log.info("完结支付分服务订单成功 - orderId: {}, state: {}", orderId, result.getState());
|
|
|
return Result.success("完结成功", data);
|
|
|
} else {
|
|
|
- log.warn("完结支付分服务订单失败 - orderId: {}, errorCode: {}, errorMsg: {}",
|
|
|
+ log.warn("完结支付分服务订单失败 - orderId: {}, errorCode: {}, errorMsg: {}",
|
|
|
orderId, result.getErrorCode(), result.getErrorMsg());
|
|
|
return Result.error(500, result.getErrorMsg());
|
|
|
}
|
|
|
@@ -392,7 +394,7 @@ public class PayScoreController {
|
|
|
log.info("取消支付分服务订单成功 - orderId: {}", orderId);
|
|
|
return Result.success("取消成功", data);
|
|
|
} else {
|
|
|
- log.warn("取消支付分服务订单失败 - orderId: {}, errorCode: {}, errorMsg: {}",
|
|
|
+ log.warn("取消支付分服务订单失败 - orderId: {}, errorCode: {}, errorMsg: {}",
|
|
|
orderId, result.getErrorCode(), result.getErrorMsg());
|
|
|
return Result.error(500, result.getErrorMsg());
|
|
|
}
|
|
|
@@ -441,7 +443,7 @@ public class PayScoreController {
|
|
|
log.info("查询支付分服务订单成功 - orderId: {}, state: {}", orderId, result.getState());
|
|
|
return Result.success("查询成功", data);
|
|
|
} else {
|
|
|
- log.warn("查询支付分服务订单失败 - orderId: {}, errorCode: {}, errorMsg: {}",
|
|
|
+ log.warn("查询支付分服务订单失败 - orderId: {}, errorCode: {}, errorMsg: {}",
|
|
|
orderId, result.getErrorCode(), result.getErrorMsg());
|
|
|
return Result.error(500, result.getErrorMsg());
|
|
|
}
|
|
|
@@ -520,15 +522,15 @@ public class PayScoreController {
|
|
|
params.put("Wechatpay-Serial", request.getHeader("Wechatpay-Serial"));
|
|
|
params.put("Wechatpay-Signature-Type", request.getHeader("Wechatpay-Signature-Type"));
|
|
|
|
|
|
- log.info("支付分回调请求头: Timestamp={}, Nonce={}, Serial={}",
|
|
|
- params.get("Wechatpay-Timestamp"),
|
|
|
- params.get("Wechatpay-Nonce"),
|
|
|
+ log.info("支付分回调请求头: Timestamp={}, Nonce={}, Serial={}",
|
|
|
+ params.get("Wechatpay-Timestamp"),
|
|
|
+ params.get("Wechatpay-Nonce"),
|
|
|
params.get("Wechatpay-Serial"));
|
|
|
|
|
|
PayScoreCallbackResult result = payScoreService.handlePayScoreCallback(params);
|
|
|
|
|
|
if (result.isSuccess()) {
|
|
|
- log.info("支付分回调处理成功 - outOrderNo: {}, eventType: {}, state: {}",
|
|
|
+ log.info("支付分回调处理成功 - outOrderNo: {}, eventType: {}, state: {}",
|
|
|
result.getOutOrderNo(), result.getEventType(), result.getState());
|
|
|
return "{\"code\": \"SUCCESS\", \"message\": \"成功\"}";
|
|
|
} else {
|