@ -0,0 +1,8 @@ | |||||
package org.jeecg.api.wxUtils; | |||||
public class CreateOrderReq { | |||||
/** | |||||
* 微信用户openid(前端不用传参) | |||||
*/ | |||||
private String wxOpenId; | |||||
} |
@ -0,0 +1,47 @@ | |||||
package org.jeecg.api.wxUtils; | |||||
import javax.servlet.ServletInputStream; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import java.io.BufferedReader; | |||||
import java.io.IOException; | |||||
import java.io.InputStreamReader; | |||||
import java.nio.charset.StandardCharsets; | |||||
/** | |||||
* <p> | |||||
* HttpServletRequest 获取请求体 | |||||
* </p> | |||||
* | |||||
* @author songfayuan | |||||
* @date 2024/9/30 19:11 | |||||
*/ | |||||
public class HttpServletUtils { | |||||
/** | |||||
* 获取请求体 | |||||
* | |||||
* @param request | |||||
* @return | |||||
* @throws IOException | |||||
*/ | |||||
public static String getRequestBody(HttpServletRequest request) throws IOException { | |||||
ServletInputStream stream = null; | |||||
BufferedReader reader = null; | |||||
StringBuffer sb = new StringBuffer(); | |||||
try { | |||||
stream = request.getInputStream(); | |||||
// 获取响应 | |||||
reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)); | |||||
String line; | |||||
while ((line = reader.readLine()) != null) { | |||||
sb.append(line); | |||||
} | |||||
} catch (IOException e) { | |||||
throw new IOException("读取返回支付接口数据流出现异常!"); | |||||
} finally { | |||||
reader.close(); | |||||
} | |||||
return sb.toString(); | |||||
} | |||||
} |
@ -0,0 +1,31 @@ | |||||
package org.jeecg.api.wxUtils; | |||||
import lombok.Data; | |||||
import java.math.BigDecimal; | |||||
/** | |||||
* <p> | |||||
* 支付订单信息 | |||||
* </p> | |||||
* | |||||
* @author songfayuan | |||||
* @date 2024/9/30 17:46 | |||||
*/ | |||||
@Data | |||||
public class PayOrderInfo { | |||||
/** | |||||
* 订单标题 | |||||
*/ | |||||
private String description; | |||||
/** | |||||
* 商户订单号 | |||||
* 只能是数字、大小写字母_-*且在同一个商户号下唯一。 | |||||
*/ | |||||
private String outTradeNo; | |||||
/** | |||||
* 支付金额,单位:元 | |||||
*/ | |||||
private BigDecimal amount; | |||||
} | |||||
@ -0,0 +1,23 @@ | |||||
package org.jeecg.api.wxUtils; | |||||
import lombok.Data; | |||||
/** | |||||
* <p> | |||||
* 订单查询请求 | |||||
* </p> | |||||
* | |||||
* @author songfayuan | |||||
* @date 2024/9/30 19:19 | |||||
*/ | |||||
@Data | |||||
public class QueryOrderReq { | |||||
/** | |||||
* 订单号:业务侧的订单号 | |||||
*/ | |||||
private String transactionId; | |||||
/** | |||||
* 商户订单号 | |||||
*/ | |||||
private String outTradeNo; | |||||
} |
@ -0,0 +1,36 @@ | |||||
package org.jeecg.api.wxUtils; | |||||
import lombok.Data; | |||||
import java.math.BigDecimal; | |||||
/** | |||||
* <p> | |||||
* 退款订单请求参数 | |||||
* </p> | |||||
* | |||||
* @author songfayuan | |||||
* @date 2024/9/30 19:19 | |||||
*/ | |||||
@Data | |||||
public class RefundOrderReq { | |||||
/** | |||||
* 订单号:业务侧的订单号 | |||||
*/ | |||||
private String transactionId; | |||||
/** | |||||
* 商户订单号 | |||||
*/ | |||||
private String outTradeNo; | |||||
/** | |||||
* 原订单金额 说明:原支付交易的订单总金额,这里单位为元。 | |||||
*/ | |||||
private BigDecimal totalAmount; | |||||
/** | |||||
* 退款金额 说明:退款金额,这里单位为元,不能超过原订单支付金额。 | |||||
*/ | |||||
private BigDecimal refundAmount; | |||||
} | |||||
@ -0,0 +1,164 @@ | |||||
package org.jeecg.api.wxUtils; | |||||
import lombok.Data; | |||||
/** | |||||
* 返回参数封装类 | |||||
* | |||||
* @param <T> | |||||
* @author songfayuan | |||||
*/ | |||||
@Data | |||||
public class Response<T> { | |||||
/** | |||||
* 状态码 | |||||
*/ | |||||
protected int code; | |||||
/** | |||||
* 提示信息 | |||||
*/ | |||||
protected String msg; | |||||
/** | |||||
* 数据 | |||||
*/ | |||||
protected T data; | |||||
/** | |||||
* 成功时状态码 | |||||
*/ | |||||
private static final int SUCCESS_CODE = 200; | |||||
/** | |||||
* 成功时提示信息 | |||||
*/ | |||||
private static final String SUCCESS_MSG = "success"; | |||||
/** | |||||
* 异常、错误信息状态码 | |||||
*/ | |||||
private static final int ERROR_CODE = 500; | |||||
/** | |||||
* 异常、错误提示信息 | |||||
*/ | |||||
private static final String ERROR_MSG = "服务器内部异常,请联系技术人员!"; | |||||
/** | |||||
* 返回成功消息 | |||||
* | |||||
* @param <T> | |||||
* @return | |||||
*/ | |||||
public static <T> Response<T> success() { | |||||
Response resp = new Response(); | |||||
resp.code = (SUCCESS_CODE); | |||||
resp.msg = (SUCCESS_MSG); | |||||
return resp; | |||||
} | |||||
/** | |||||
* 返回成功消息 | |||||
* | |||||
* @param <T> | |||||
* @param msg | |||||
* @return | |||||
*/ | |||||
public static <T> Response<T> successResponse(String msg) { | |||||
Response resp = new Response(); | |||||
resp.code = SUCCESS_CODE; | |||||
resp.msg = msg; | |||||
return resp; | |||||
} | |||||
/** | |||||
* 返回错误消息 | |||||
* | |||||
* @param <T> | |||||
* @return | |||||
*/ | |||||
public static <T> Response<T> error() { | |||||
Response resp = new Response(); | |||||
resp.code = (ERROR_CODE); | |||||
resp.msg = (ERROR_MSG); | |||||
return resp; | |||||
} | |||||
/** | |||||
* 返回错误消息 | |||||
* | |||||
* @param <T> | |||||
* @param msg | |||||
* @return | |||||
*/ | |||||
public static <T> Response<T> errorResponse(String msg) { | |||||
Response resp = new Response(); | |||||
resp.code = ERROR_CODE; | |||||
resp.msg = msg; | |||||
return resp; | |||||
} | |||||
/** | |||||
* 自定义状态码、提示信息 | |||||
* | |||||
* @param <T> | |||||
* @param code 状态码 | |||||
* @param msg 提示信息 | |||||
* @return | |||||
*/ | |||||
public static <T> Response<T> response(int code, String msg) { | |||||
Response resp = new Response(); | |||||
resp.code = (code); | |||||
resp.msg = (msg); | |||||
return resp; | |||||
} | |||||
/** | |||||
* 自定义状态码、提示信息、业务数据 | |||||
* | |||||
* @param <T> | |||||
* @param code 状态码 | |||||
* @param msg 提示信息 | |||||
* @param data 业务数据 | |||||
* @return | |||||
*/ | |||||
public static <T> Response<T> response(int code, String msg, T data) { | |||||
Response<T> resp = new Response<>(); | |||||
resp.code = (code); | |||||
resp.msg = (msg); | |||||
resp.data = data; | |||||
return resp; | |||||
} | |||||
/** | |||||
* 返回成功数据 | |||||
* | |||||
* @param <T> | |||||
* @param data 业务数据 | |||||
* @return | |||||
*/ | |||||
public static <T> Response<T> success(T data) { | |||||
Response<T> resp = new Response<>(); | |||||
resp.code = (SUCCESS_CODE); | |||||
resp.msg = (SUCCESS_MSG); | |||||
resp.data = data; | |||||
return resp; | |||||
} | |||||
/** | |||||
* 返回错误消息 | |||||
* | |||||
* @param <T> | |||||
* @param data 业务数据 | |||||
* @return | |||||
*/ | |||||
public static <T> Response<T> error(T data) { | |||||
Response<T> resp = new Response<>(); | |||||
resp.code = (ERROR_CODE); | |||||
resp.msg = (ERROR_MSG); | |||||
resp.data = data; | |||||
return resp; | |||||
} | |||||
} |
@ -0,0 +1,86 @@ | |||||
package org.jeecg.api.wxUtils; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.springframework.context.annotation.Configuration; | |||||
@Slf4j | |||||
@Configuration | |||||
public class WxPayAutoCertificateConfig { | |||||
// /** | |||||
// * 微信小程序的 AppID | |||||
// */ | |||||
// @Value("${wx.miniapp.appid}") | |||||
// private String appid; | |||||
// | |||||
// /** | |||||
// * 微信小程序的密钥 | |||||
// */ | |||||
// @Value("${wx.miniapp.secret}") | |||||
// private String secret; | |||||
// | |||||
// /** | |||||
// * 商户号 | |||||
// */ | |||||
// @Value("${wx.miniapp.merchantId}") | |||||
// private String merchantId; | |||||
// | |||||
// /** | |||||
// * 商户API私钥路径 | |||||
// */ | |||||
// @Value("${wx.miniapp.privateKeyPath}") | |||||
// private String privateKeyPath; | |||||
// | |||||
// /** | |||||
// * 商户证书序列号 | |||||
// */ | |||||
// @Value("${wx.miniapp.merchantSerialNumber}") | |||||
// private String merchantSerialNumber; | |||||
// | |||||
// /** | |||||
// * 商户APIV3密钥 | |||||
// */ | |||||
// @Value("${wx.miniapp.apiV3Key}") | |||||
// private String apiV3Key; | |||||
// | |||||
// /** | |||||
// * 支付通知地址 | |||||
// */ | |||||
// @Value("${wx.miniapp.payNotifyUrl}") | |||||
// private String payNotifyUrl; | |||||
// | |||||
// /** | |||||
// * 退款通知地址 | |||||
// */ | |||||
// @Value("${wx.miniapp.refundNotifyUrl}") | |||||
// private String refundNotifyUrl; | |||||
// /** | |||||
// * 初始化商户配置 | |||||
// * @return | |||||
// */ | |||||
// @Bean | |||||
// public Config rsaAutoCertificateConfig() { | |||||
// // 这里把Config作为配置Bean是为了避免多次创建资源,一般项目运行的时候这些东西都确定了 | |||||
// // 具体的参数改为申请的数据,可以通过读配置文件的形式获取 | |||||
//// Config config = new RSAAutoCertificateConfig.Builder() | |||||
//// .merchantId("1659066870") | |||||
//// .privateKeyFromPath("E:\\git_java\\api_java\\popularize-admin\\popularize-admin\\popularize-admin\\module-pay\\src\\main\\resources\\apiclient_key.pem") | |||||
//// .merchantSerialNumber("7BE56DC695B2B612BD1C6C710A7FBFA1AC46B10F") | |||||
//// .apiV3Key("vtribevtribevtribevtribevtribe12") | |||||
//// .build(); | |||||
// | |||||
// | |||||
//// Config config = new RSAAutoCertificateConfig.Builder() | |||||
//// .merchantId(merchantId) | |||||
//// .privateKeyFromPath(privateKeyPath) | |||||
//// .merchantSerialNumber(merchantSerialNumber) | |||||
//// .apiV3Key(apiV3Key) | |||||
//// .build(); | |||||
//// log.info("初始化微信支付商户配置完成..."); | |||||
// return config; | |||||
// } | |||||
} |
@ -0,0 +1,15 @@ | |||||
package org.jeecg.api.wxUtils; | |||||
import lombok.Data; | |||||
import org.springframework.stereotype.Component; | |||||
@Data | |||||
@Component | |||||
public class WxPayConfig { | |||||
} | |||||
@ -0,0 +1,18 @@ | |||||
package org.jeecg.api.wxUtils; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
@Data | |||||
public class WxQrCodeVo { | |||||
/**图片地址*/ | |||||
@ApiModelProperty(value = "图片地址") | |||||
private String url; | |||||
@ApiModelProperty(value = "二维码名称") | |||||
private String name; | |||||
@ApiModelProperty(value = "二维码背景图") | |||||
private String bjImage; | |||||
} |