微信支付整体框架已经完成,直接使用JavaSDK-v3实现,包括服务的封装、数据库的交互;还需要完善付款、退款回调的实现,状态轮训的逻辑优化

This commit is contained in:
jkcdev 2025-04-27 17:51:54 +08:00
parent 862279391f
commit 54f2d49dea
2 changed files with 99 additions and 1 deletions

View File

@ -67,7 +67,7 @@ public class WsPayTask {
// 2. 遍历退款单查询退款状态
for (EbikeRefund ebikeRefund : ebikeRefundList) {
log.warn("超时未退款的退款单号 ===> {}", ebikeRefund.getRefundId());
// TODO: 2025/4/25 调用微信退款查询接口查询退款状态
// 调用微信退款查询接口查询退款状态
Refund refund = wxPayService.queryRefundByOutNo(ebikeRefund.getRefundId());
if (refund!= null&& Status.SUCCESS.equals(refund.getStatus())){
// 3. 更新退款单状态

View File

@ -0,0 +1,98 @@
package com.cdzy.payment;
import com.mybatisflex.codegen.Generator;
import com.mybatisflex.codegen.config.GlobalConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.junit.jupiter.api.Test;
/**
* 功能描述
*
* @author dingchao
* @date 2025/4/24
* @modified by:
*/
public class EbikePaymentApplicationTest {
private static final String model_path ="D:/Projects/eBIKE/mybatis-flex/ebike-pay";
private static final String mapperPath="D:/Projects/eBIKE/mybatis-flex/ebike-pay/resources/mapper";
private static final String packageName ="com.cdzy.payment";
private static final String[] tables= new String[]{
"ebike_payment",
"ebike_refund",
"ebike_order_details"
};
@Test
public void pay_mybatis_code() {
//配置数据源
HikariDataSource dataSource = new HikariDataSource();
dataSource.setJdbcUrl("jdbc:mysql://192.168.2.226:3306/ebike_orders?characterEncoding=utf-8");
dataSource.setUsername("root");
dataSource.setPassword("970529");
//生成全库的
GlobalConfig globalConfig = createGlobalConfigUseStyle2();
//单表的
//GlobalConfig globalConfig = createGlobalConfigUseStyle2();
Generator generator = new Generator(dataSource, globalConfig);
//生成代码
generator.generate();
}
private GlobalConfig createGlobalConfigUseStyle1() {
// 创建配置内容
GlobalConfig globalConfig = new GlobalConfig();
// 设置项目源目录和基础包
globalConfig.getPackageConfig()
.setSourceDir(model_path)
.setBasePackage(packageName);
// 启用生成 entity并启用 Lombok
globalConfig.setEntityGenerateEnable(true);
globalConfig.setEntityWithLombok(true);
// 设置项目的JDK版本
globalConfig.setEntityJdkVersion(17);
// 启用生成 mapperservicecontroller
globalConfig.enableEntity();
globalConfig.enableMapper();
globalConfig.enableService();
globalConfig.enableServiceImpl();
globalConfig.enableController();
globalConfig.enableMapperXml();
globalConfig.setMapperXmlPath(mapperPath);
// 配置 Mapper XML 生成路径和文件名
globalConfig.getMapperXmlConfig()
.setFilePrefix("") // 设置合适的前缀
.setFileSuffix("Mapper"); // 确保设置正确的后缀名
return globalConfig;
}
private GlobalConfig createGlobalConfigUseStyle2() {
// 创建配置内容
GlobalConfig globalConfig = new GlobalConfig();
// 设置项目源目录和基础包
globalConfig.getPackageConfig()
.setSourceDir(model_path)
.setBasePackage(packageName);
// 启用生成 entity并启用 Lombok
globalConfig.setEntityGenerateEnable(true);
globalConfig.setEntityWithLombok(true);
// 设置项目的JDK版本
globalConfig.setEntityJdkVersion(17);
// 启用生成 mapperservicecontroller
globalConfig.enableEntity();
globalConfig.enableMapper();
globalConfig.enableService();
globalConfig.enableServiceImpl();
globalConfig.enableController();
globalConfig.enableMapperXml();
globalConfig.setMapperXmlPath(mapperPath);
// 配置 Mapper XML 生成路径和文件名
globalConfig.getMapperXmlConfig()
.setFilePrefix("") // 设置合适的前缀
.setFileSuffix("Mapper"); // 确保设置正确的后缀名
//设置表前缀和只生成哪些表
// globalConfig.setTablePrefix("tb_");
globalConfig.setGenerateTable(tables);
// 返回配置
return globalConfig;
}
}