|
|
@@ -87,10 +87,11 @@ As 平台管理员, I want 在后台通过配置开关控制会员费走虚拟
|
|
|
/**
|
|
|
* 创建会员订单并按后台开关决定支付方式。
|
|
|
* <p>开关 member_pay_virtual_enabled:1/缺省=虚拟支付;0=普通微信支付(JSAPI)。
|
|
|
- * @param openid 普通支付时需要(JSAPI payer.openid);虚拟支付时可为 null
|
|
|
+ * @param sessionKey 当前用户 sessionKey(用于虚拟支付签名;普通支付时忽略)
|
|
|
+ * @param openid 普通支付时需要(JSAPI payer.openid);虚拟支付时可为 null
|
|
|
*/
|
|
|
public Map<String, Object> createOrderWithPayType(Long userId, Long familyId, String levelCode,
|
|
|
- String paymentType, String period, Long userCouponId, String openid) {
|
|
|
+ String paymentType, String period, Long userCouponId, String sessionKey, String openid) {
|
|
|
|
|
|
// 1. 创建订单(现状逻辑不变,trial 直接开通返回)
|
|
|
PaymentOrderDTO order = createOrder(userId, familyId, levelCode, paymentType, period, userCouponId);
|
|
|
@@ -105,19 +106,17 @@ public Map<String, Object> createOrderWithPayType(Long userId, Long familyId, St
|
|
|
resp.put("periodNo", order.getPeriodNo());
|
|
|
resp.put("totalPeriods", order.getTotalPeriods());
|
|
|
|
|
|
- // 2. trial 单已直接开通,无需支付
|
|
|
- if ("trial".equals(paymentType)) {
|
|
|
- resp.put("payType", "none");
|
|
|
- return resp;
|
|
|
- }
|
|
|
+ // 2. trial 单已直接开通,无需支付
|
|
|
+ if ("trial".equals(paymentType)) {
|
|
|
+ resp.put("payType", "none");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
|
|
|
- // 3. 判定支付方式:开关缺省=虚拟支付
|
|
|
- boolean virtualEnabled = !"0".equals(sysConfigService.getValue("member_pay_virtual_enabled"));
|
|
|
+ // 3. 判定支付方式:开关缺省=虚拟支付
|
|
|
+ boolean virtualEnabled = !"0".equals(sysConfigService.getValue("member_pay_virtual_enabled"));
|
|
|
|
|
|
- if (virtualEnabled) {
|
|
|
- VirtualPayParamsDTO dto = virtualPayService.generateMembershipPayParams(order.getOrderNo(), sessionKey);
|
|
|
- // 注:sessionKey 由 controller 传入(Controller 持 user,VirtualPayService 不读库)
|
|
|
- // —— 具体签名:本方法加参 String sessionKey,controller 传 user.getSessionKey()
|
|
|
+ if (virtualEnabled) {
|
|
|
+ VirtualPayParamsDTO dto = virtualPayService.generateMembershipPayParams(order.getOrderNo(), sessionKey);
|
|
|
if (dto == null) {
|
|
|
// 道具未配置 → 沿用现状 46001(由 controller 转 error)
|
|
|
}
|