Browse Source
- 新增 WechatPayType 类,定义微信支付的具体实现方式 - 在 PaymentType 枚举中添加获取微信支付类型的方法 - 在 ShopOrder 实体中增加微信支付子类型字段 - 优化 ShopOrderServiceImpl 中的微信支付逻辑,支持自动选择支付类型pan
4 changed files with 108 additions and 2 deletions
@ -0,0 +1,81 @@ |
|||
package com.gxwebsoft.payment.constants; |
|||
|
|||
/** |
|||
* 微信支付类型常量 |
|||
* 定义微信支付的具体实现方式 |
|||
* |
|||
* @author 科技小王子 |
|||
* @since 2025-08-30 |
|||
*/ |
|||
public class WechatPayType { |
|||
|
|||
/** |
|||
* JSAPI支付 - 小程序/公众号内支付 |
|||
* 需要用户的openid |
|||
*/ |
|||
public static final String JSAPI = "JSAPI"; |
|||
|
|||
/** |
|||
* Native支付 - 扫码支付 |
|||
* 生成二维码供用户扫描支付 |
|||
*/ |
|||
public static final String NATIVE = "NATIVE"; |
|||
|
|||
/** |
|||
* H5支付 - 手机网页支付 |
|||
* 在手机浏览器中调起微信支付 |
|||
*/ |
|||
public static final String H5 = "H5"; |
|||
|
|||
/** |
|||
* APP支付 - 移动应用支付 |
|||
* 在APP中调起微信支付 |
|||
*/ |
|||
public static final String APP = "APP"; |
|||
|
|||
/** |
|||
* 根据openid自动选择微信支付类型 |
|||
* |
|||
* @param openid 用户openid |
|||
* @return JSAPI 或 NATIVE |
|||
*/ |
|||
public static String getAutoType(String openid) { |
|||
return (openid != null && !openid.trim().isEmpty()) ? JSAPI : NATIVE; |
|||
} |
|||
|
|||
/** |
|||
* 检查是否为有效的微信支付类型 |
|||
* |
|||
* @param payType 支付类型 |
|||
* @return true表示有效 |
|||
*/ |
|||
public static boolean isValidType(String payType) { |
|||
return JSAPI.equals(payType) || NATIVE.equals(payType) || |
|||
H5.equals(payType) || APP.equals(payType); |
|||
} |
|||
|
|||
/** |
|||
* 获取支付类型描述 |
|||
* |
|||
* @param payType 支付类型 |
|||
* @return 描述文本 |
|||
*/ |
|||
public static String getDescription(String payType) { |
|||
if (payType == null) { |
|||
return "未知支付类型"; |
|||
} |
|||
|
|||
switch (payType) { |
|||
case JSAPI: |
|||
return "小程序/公众号支付"; |
|||
case NATIVE: |
|||
return "扫码支付"; |
|||
case H5: |
|||
return "手机网页支付"; |
|||
case APP: |
|||
return "移动应用支付"; |
|||
default: |
|||
return "未知支付类型: " + payType; |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue