Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/ruoyi-vue-pro
# Conflicts: # yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/config/YudaoWebAutoConfiguration.java # yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/client/impl/weixin/WxPayClientConfig.java # yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java
This commit is contained in:
commit
f3b680cfd3
@ -1 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 针对 infra 模块的 api 包
|
||||||
|
*/
|
||||||
package cn.iocoder.yudao.framework.common.biz.infra;
|
package cn.iocoder.yudao.framework.common.biz.infra;
|
@ -1,14 +1,14 @@
|
|||||||
package cn.iocoder.yudao.framework.web.config;
|
package cn.iocoder.yudao.framework.web.config;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.biz.infra.logger.ApiErrorLogCommonApi;
|
||||||
import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
|
import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
|
||||||
import cn.iocoder.yudao.framework.web.core.filter.CacheRequestBodyFilter;
|
import cn.iocoder.yudao.framework.web.core.filter.CacheRequestBodyFilter;
|
||||||
import cn.iocoder.yudao.framework.web.core.filter.DemoFilter;
|
import cn.iocoder.yudao.framework.web.core.filter.DemoFilter;
|
||||||
import cn.iocoder.yudao.framework.web.core.handler.GlobalExceptionHandler;
|
import cn.iocoder.yudao.framework.web.core.handler.GlobalExceptionHandler;
|
||||||
import cn.iocoder.yudao.framework.web.core.handler.GlobalResponseBodyHandler;
|
import cn.iocoder.yudao.framework.web.core.handler.GlobalResponseBodyHandler;
|
||||||
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||||
import cn.iocoder.yudao.framework.common.biz.infra.logger.ApiErrorLogCommonApi;
|
import jakarta.annotation.Resource;
|
||||||
import javax.annotation.Resource;
|
import jakarta.servlet.Filter;
|
||||||
import javax.servlet.Filter;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
@ -7,6 +7,8 @@ package cn.iocoder.yudao.module.infra.enums;
|
|||||||
*/
|
*/
|
||||||
public interface DictTypeConstants {
|
public interface DictTypeConstants {
|
||||||
|
|
||||||
|
String USER_TYPE = "user_type"; // 用户类型
|
||||||
|
|
||||||
String JOB_STATUS = "infra_job_status"; // 定时任务状态的枚举
|
String JOB_STATUS = "infra_job_status"; // 定时任务状态的枚举
|
||||||
String JOB_LOG_STATUS = "infra_job_log_status"; // 定时任务日志状态的枚举
|
String JOB_LOG_STATUS = "infra_job_log_status"; // 定时任务日志状态的枚举
|
||||||
|
|
||||||
|
@ -19,11 +19,6 @@
|
|||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-module-system-api</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
<artifactId>yudao-module-infra-api</artifactId>
|
<artifactId>yudao-module-infra-api</artifactId>
|
||||||
|
@ -34,7 +34,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserNickname;
|
||||||
import static cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
|
import static cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 代码生成器")
|
@Tag(name = "管理后台 - 代码生成器")
|
||||||
@ -93,7 +93,7 @@ public class CodegenController {
|
|||||||
@PostMapping("/create-list")
|
@PostMapping("/create-list")
|
||||||
@PreAuthorize("@ss.hasPermission('infra:codegen:create')")
|
@PreAuthorize("@ss.hasPermission('infra:codegen:create')")
|
||||||
public CommonResult<List<Long>> createCodegenList(@Valid @RequestBody CodegenCreateListReqVO reqVO) {
|
public CommonResult<List<Long>> createCodegenList(@Valid @RequestBody CodegenCreateListReqVO reqVO) {
|
||||||
return success(codegenService.createCodegenList(getLoginUserId(), reqVO));
|
return success(codegenService.createCodegenList(getLoginUserNickname(), reqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "更新数据库的表和字段定义")
|
@Operation(summary = "更新数据库的表和字段定义")
|
||||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
@ -29,7 +29,7 @@ public class ApiErrorLogRespVO {
|
|||||||
|
|
||||||
@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||||
@DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_TYPE)
|
@DictFormat(DictTypeConstants.USER_TYPE)
|
||||||
private Integer userType;
|
private Integer userType;
|
||||||
|
|
||||||
@Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
|
@Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
|
||||||
|
@ -21,11 +21,11 @@ public interface CodegenService {
|
|||||||
/**
|
/**
|
||||||
* 基于数据库的表结构,创建代码生成器的表定义
|
* 基于数据库的表结构,创建代码生成器的表定义
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param author 作者
|
||||||
* @param reqVO 表信息
|
* @param reqVO 表信息
|
||||||
* @return 创建的表定义的编号数组
|
* @return 创建的表定义的编号数组
|
||||||
*/
|
*/
|
||||||
List<Long> createCodegenList(Long userId, CodegenCreateListReqVO reqVO);
|
List<Long> createCodegenList(String author, CodegenCreateListReqVO reqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新数据库的表和字段定义
|
* 更新数据库的表和字段定义
|
||||||
|
@ -18,7 +18,6 @@ import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties;
|
|||||||
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder;
|
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder;
|
||||||
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine;
|
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine;
|
||||||
import cn.iocoder.yudao.module.infra.service.db.DatabaseTableService;
|
import cn.iocoder.yudao.module.infra.service.db.DatabaseTableService;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
||||||
import com.baomidou.mybatisplus.generator.config.po.TableField;
|
import com.baomidou.mybatisplus.generator.config.po.TableField;
|
||||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -52,9 +51,6 @@ public class CodegenServiceImpl implements CodegenService {
|
|||||||
@Resource
|
@Resource
|
||||||
private CodegenColumnMapper codegenColumnMapper;
|
private CodegenColumnMapper codegenColumnMapper;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AdminUserApi userApi;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CodegenBuilder codegenBuilder;
|
private CodegenBuilder codegenBuilder;
|
||||||
@Resource
|
@Resource
|
||||||
@ -65,21 +61,21 @@ public class CodegenServiceImpl implements CodegenService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public List<Long> createCodegenList(Long userId, CodegenCreateListReqVO reqVO) {
|
public List<Long> createCodegenList(String author, CodegenCreateListReqVO reqVO) {
|
||||||
List<Long> ids = new ArrayList<>(reqVO.getTableNames().size());
|
List<Long> ids = new ArrayList<>(reqVO.getTableNames().size());
|
||||||
// 遍历添加。虽然效率会低一点,但是没必要做成完全批量,因为不会这么大量
|
// 遍历添加。虽然效率会低一点,但是没必要做成完全批量,因为不会这么大量
|
||||||
reqVO.getTableNames().forEach(tableName -> ids.add(createCodegen(userId, reqVO.getDataSourceConfigId(), tableName)));
|
reqVO.getTableNames().forEach(tableName -> ids.add(createCodegen(author, reqVO.getDataSourceConfigId(), tableName)));
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long createCodegen(Long userId, Long dataSourceConfigId, String tableName) {
|
private Long createCodegen(String author, Long dataSourceConfigId, String tableName) {
|
||||||
// 从数据库中,获得数据库表结构
|
// 从数据库中,获得数据库表结构
|
||||||
TableInfo tableInfo = databaseTableService.getTable(dataSourceConfigId, tableName);
|
TableInfo tableInfo = databaseTableService.getTable(dataSourceConfigId, tableName);
|
||||||
// 导入
|
// 导入
|
||||||
return createCodegen0(userId, dataSourceConfigId, tableInfo);
|
return createCodegen0(author, dataSourceConfigId, tableInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long createCodegen0(Long userId, Long dataSourceConfigId, TableInfo tableInfo) {
|
private Long createCodegen0(String author, Long dataSourceConfigId, TableInfo tableInfo) {
|
||||||
// 校验导入的表和字段非空
|
// 校验导入的表和字段非空
|
||||||
validateTableInfo(tableInfo);
|
validateTableInfo(tableInfo);
|
||||||
// 校验是否已经存在
|
// 校验是否已经存在
|
||||||
@ -93,7 +89,7 @@ public class CodegenServiceImpl implements CodegenService {
|
|||||||
table.setDataSourceConfigId(dataSourceConfigId);
|
table.setDataSourceConfigId(dataSourceConfigId);
|
||||||
table.setScene(CodegenSceneEnum.ADMIN.getScene()); // 默认配置下,使用管理后台的模板
|
table.setScene(CodegenSceneEnum.ADMIN.getScene()); // 默认配置下,使用管理后台的模板
|
||||||
table.setFrontType(codegenProperties.getFrontType());
|
table.setFrontType(codegenProperties.getFrontType());
|
||||||
table.setAuthor(userApi.getUser(userId).getNickname());
|
table.setAuthor(author);
|
||||||
codegenTableMapper.insert(table);
|
codegenTableMapper.insert(table);
|
||||||
|
|
||||||
// 构建 CodegenColumnDO 数组,插入到 DB 中
|
// 构建 CodegenColumnDO 数组,插入到 DB 中
|
||||||
|
@ -20,8 +20,6 @@ import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties;
|
|||||||
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder;
|
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder;
|
||||||
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine;
|
import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine;
|
||||||
import cn.iocoder.yudao.module.infra.service.db.DatabaseTableService;
|
import cn.iocoder.yudao.module.infra.service.db.DatabaseTableService;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
||||||
import com.baomidou.mybatisplus.generator.config.po.TableField;
|
import com.baomidou.mybatisplus.generator.config.po.TableField;
|
||||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -65,9 +63,6 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
|||||||
@MockBean
|
@MockBean
|
||||||
private DatabaseTableService databaseTableService;
|
private DatabaseTableService databaseTableService;
|
||||||
|
|
||||||
@MockBean
|
|
||||||
private AdminUserApi userApi;
|
|
||||||
|
|
||||||
@MockBean
|
@MockBean
|
||||||
private CodegenBuilder codegenBuilder;
|
private CodegenBuilder codegenBuilder;
|
||||||
@MockBean
|
@MockBean
|
||||||
@ -79,7 +74,7 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCreateCodegenList() {
|
public void testCreateCodegenList() {
|
||||||
// 准备参数
|
// 准备参数
|
||||||
Long userId = randomLongId();
|
String author = randomString();
|
||||||
CodegenCreateListReqVO reqVO = randomPojo(CodegenCreateListReqVO.class,
|
CodegenCreateListReqVO reqVO = randomPojo(CodegenCreateListReqVO.class,
|
||||||
o -> o.setDataSourceConfigId(1L).setTableNames(Collections.singletonList("t_yunai")));
|
o -> o.setDataSourceConfigId(1L).setTableNames(Collections.singletonList("t_yunai")));
|
||||||
// mock 方法(TableInfo)
|
// mock 方法(TableInfo)
|
||||||
@ -97,9 +92,6 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
|||||||
// mock 方法(CodegenTableDO)
|
// mock 方法(CodegenTableDO)
|
||||||
CodegenTableDO table = randomPojo(CodegenTableDO.class);
|
CodegenTableDO table = randomPojo(CodegenTableDO.class);
|
||||||
when(codegenBuilder.buildTable(same(tableInfo))).thenReturn(table);
|
when(codegenBuilder.buildTable(same(tableInfo))).thenReturn(table);
|
||||||
// mock 方法(AdminUserRespDTO)
|
|
||||||
AdminUserRespDTO user = randomPojo(AdminUserRespDTO.class, o -> o.setNickname("芋头"));
|
|
||||||
when(userApi.getUser(eq(userId))).thenReturn(user);
|
|
||||||
// mock 方法(CodegenColumnDO)
|
// mock 方法(CodegenColumnDO)
|
||||||
List<CodegenColumnDO> columns = randomPojoList(CodegenColumnDO.class);
|
List<CodegenColumnDO> columns = randomPojoList(CodegenColumnDO.class);
|
||||||
when(codegenBuilder.buildColumns(eq(table.getId()), same(fields)))
|
when(codegenBuilder.buildColumns(eq(table.getId()), same(fields)))
|
||||||
@ -108,7 +100,7 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
|||||||
when(codegenProperties.getFrontType()).thenReturn(CodegenFrontTypeEnum.VUE3_ELEMENT_PLUS.getType());
|
when(codegenProperties.getFrontType()).thenReturn(CodegenFrontTypeEnum.VUE3_ELEMENT_PLUS.getType());
|
||||||
|
|
||||||
// 调用
|
// 调用
|
||||||
List<Long> result = codegenService.createCodegenList(userId, reqVO);
|
List<Long> result = codegenService.createCodegenList(author, reqVO);
|
||||||
// 断言
|
// 断言
|
||||||
assertEquals(1, result.size());
|
assertEquals(1, result.size());
|
||||||
// 断言(CodegenTableDO)
|
// 断言(CodegenTableDO)
|
||||||
@ -117,7 +109,7 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
|||||||
assertEquals(1L, dbTable.getDataSourceConfigId());
|
assertEquals(1L, dbTable.getDataSourceConfigId());
|
||||||
assertEquals(CodegenSceneEnum.ADMIN.getScene(), dbTable.getScene());
|
assertEquals(CodegenSceneEnum.ADMIN.getScene(), dbTable.getScene());
|
||||||
assertEquals(CodegenFrontTypeEnum.VUE3_ELEMENT_PLUS.getType(), dbTable.getFrontType());
|
assertEquals(CodegenFrontTypeEnum.VUE3_ELEMENT_PLUS.getType(), dbTable.getFrontType());
|
||||||
assertEquals("芋头", dbTable.getAuthor());
|
assertEquals(author, dbTable.getAuthor());
|
||||||
// 断言(CodegenColumnDO)
|
// 断言(CodegenColumnDO)
|
||||||
List<CodegenColumnDO> dbColumns = codegenColumnMapper.selectList();
|
List<CodegenColumnDO> dbColumns = codegenColumnMapper.selectList();
|
||||||
assertEquals(columns.size(), dbColumns.size());
|
assertEquals(columns.size(), dbColumns.size());
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>yudao-module-pay-api</module>
|
<module>yudao-module-pay-api</module>
|
||||||
<module>yudao-module-pay-biz</module>
|
<module>yudao-module-pay-biz</module>
|
||||||
<module>yudao-spring-boot-starter-biz-pay</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.pay.enums;
|
package cn.iocoder.yudao.module.pay.enums;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -27,6 +29,7 @@ public enum PayChannelEnum implements ArrayValuable<String> {
|
|||||||
ALIPAY_APP("alipay_app", "支付宝App 支付"),
|
ALIPAY_APP("alipay_app", "支付宝App 支付"),
|
||||||
ALIPAY_QR("alipay_qr", "支付宝扫码支付"),
|
ALIPAY_QR("alipay_qr", "支付宝扫码支付"),
|
||||||
ALIPAY_BAR("alipay_bar", "支付宝条码支付"),
|
ALIPAY_BAR("alipay_bar", "支付宝条码支付"),
|
||||||
|
|
||||||
MOCK("mock", "模拟支付"),
|
MOCK("mock", "模拟支付"),
|
||||||
|
|
||||||
WALLET("wallet", "钱包支付");
|
WALLET("wallet", "钱包支付");
|
||||||
@ -49,4 +52,16 @@ public enum PayChannelEnum implements ArrayValuable<String> {
|
|||||||
return ARRAYS;
|
return ARRAYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PayChannelEnum getByCode(String code) {
|
||||||
|
return ArrayUtil.firstMatch(o -> o.getCode().equals(code), values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAlipay(String channelCode) {
|
||||||
|
return StrUtil.startWith(channelCode, "alipay_");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWeixin(String channelCode) {
|
||||||
|
return StrUtil.startWith(channelCode, "wx_");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,16 @@ public enum PayOrderStatusEnum implements ArrayValuable<Integer> {
|
|||||||
return Objects.equals(status, SUCCESS.getStatus());
|
return Objects.equals(status, SUCCESS.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否已退款
|
||||||
|
*
|
||||||
|
* @param status 状态
|
||||||
|
* @return 是否已退款
|
||||||
|
*/
|
||||||
|
public static boolean isRefund(Integer status) {
|
||||||
|
return Objects.equals(status, REFUND.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否支付成功或者已退款
|
* 判断是否支付成功或者已退款
|
||||||
*
|
*
|
||||||
|
@ -40,7 +40,7 @@ public enum PayTransferStatusEnum {
|
|||||||
return Objects.equals(status, WAITING.getStatus());
|
return Objects.equals(status, WAITING.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isProgressing(Integer status) {
|
public static boolean isProcessing(Integer status) {
|
||||||
return Objects.equals(status, PROCESSING.getStatus());
|
return Objects.equals(status, PROCESSING.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ public enum PayTransferStatusEnum {
|
|||||||
* @return 是否
|
* @return 是否
|
||||||
*/
|
*/
|
||||||
public static boolean isWaitingOrProcessing(Integer status) {
|
public static boolean isWaitingOrProcessing(Integer status) {
|
||||||
return isWaiting(status) || isProgressing(status);
|
return isWaiting(status) || isProcessing(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,11 +30,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 业务组件 -->
|
<!-- 业务组件 -->
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-spring-boot-starter-biz-pay</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
|
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
|
||||||
@ -75,6 +70,24 @@
|
|||||||
<groupId>cn.iocoder.boot</groupId>
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 三方云服务相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alipay.sdk</groupId>
|
||||||
|
<artifactId>alipay-sdk-java</artifactId>
|
||||||
|
<version>4.35.79.ALL</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.binarywang</groupId>
|
||||||
|
<artifactId>weixin-java-pay</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.pay.api.transfer;
|
package cn.iocoder.yudao.module.pay.api.transfer;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin.WxPayClientConfig;
|
||||||
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO;
|
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferRespDTO;
|
||||||
|
@ -4,10 +4,10 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskDetailRespVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskDetailRespVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO;
|
||||||
@ -156,7 +156,7 @@ public class PayNotifyController {
|
|||||||
}
|
}
|
||||||
// 拼接返回
|
// 拼接返回
|
||||||
Map<Long, PayAppDO> apps = appService.getAppMap(convertList(pageResult.getList(), PayNotifyTaskDO::getAppId));
|
Map<Long, PayAppDO> apps = appService.getAppMap(convertList(pageResult.getList(), PayNotifyTaskDO::getAppId));
|
||||||
|
|
||||||
// 转换对象
|
// 转换对象
|
||||||
return success(BeanUtils.toBean(pageResult, PayNotifyTaskRespVO.class, order -> {
|
return success(BeanUtils.toBean(pageResult, PayNotifyTaskRespVO.class, order -> {
|
||||||
PayAppDO app = apps.get(order.getAppId());
|
PayAppDO app = apps.get(order.getAppId());
|
||||||
|
@ -6,15 +6,15 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.*;
|
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.*;
|
||||||
import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert;
|
import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||||
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
||||||
import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.wallet.WalletPayClient;
|
||||||
import cn.iocoder.yudao.module.pay.service.app.PayAppService;
|
import cn.iocoder.yudao.module.pay.service.app.PayAppService;
|
||||||
import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
|
import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
|
||||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
|
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
|
||||||
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.pay.controller.app.order;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderRespVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderRespVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitReqVO;
|
import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitReqVO;
|
||||||
@ -10,8 +9,9 @@ import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitResp
|
|||||||
import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert;
|
import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||||
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
||||||
import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.wallet.WalletPayClient;
|
||||||
import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
|
import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
|
||||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
|
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.pay.convert.order;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.*;
|
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.*;
|
||||||
@ -67,7 +67,7 @@ public interface PayOrderConvert {
|
|||||||
PayOrderUnifiedReqDTO convert2(PayOrderSubmitReqVO reqVO, String userIp);
|
PayOrderUnifiedReqDTO convert2(PayOrderSubmitReqVO reqVO, String userIp);
|
||||||
|
|
||||||
@Mapping(source = "order.status", target = "status")
|
@Mapping(source = "order.status", target = "status")
|
||||||
PayOrderSubmitRespVO convert(PayOrderDO order, cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO respDTO);
|
PayOrderSubmitRespVO convert(PayOrderDO order, cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO respDTO);
|
||||||
|
|
||||||
AppPayOrderSubmitRespVO convert3(PayOrderSubmitRespVO bean);
|
AppPayOrderSubmitRespVO convert3(PayOrderSubmitRespVO bean);
|
||||||
|
|
||||||
|
@ -1,16 +1,26 @@
|
|||||||
package cn.iocoder.yudao.module.pay.dal.dataobject.channel;
|
package cn.iocoder.yudao.module.pay.dal.dataobject.channel;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClientConfig;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.NonePayClientConfig;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.AlipayAppPayClient;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.AlipayPayClientConfig;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin.WxPayClientConfig;
|
||||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
|
||||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付渠道 DO
|
* 支付渠道 DO
|
||||||
* 一个应用下,会有多种支付渠道,例如说微信支付、支付宝支付等等
|
* 一个应用下,会有多种支付渠道,例如说微信支付、支付宝支付等等
|
||||||
@ -63,7 +73,46 @@ public class PayChannelDO extends TenantBaseDO {
|
|||||||
/**
|
/**
|
||||||
* 支付渠道配置
|
* 支付渠道配置
|
||||||
*/
|
*/
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
@TableField(typeHandler = PayClientConfigTypeHandler.class)
|
||||||
private PayClientConfig config;
|
private PayClientConfig config;
|
||||||
|
|
||||||
|
public static class PayClientConfigTypeHandler extends AbstractJsonTypeHandler<Object> {
|
||||||
|
|
||||||
|
public PayClientConfigTypeHandler(Class<?> type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PayClientConfigTypeHandler(Class<?> type, Field field) {
|
||||||
|
super(type, field);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object parse(String json) {
|
||||||
|
PayClientConfig config = JsonUtils.parseObjectQuietly(json, new TypeReference<>() {});
|
||||||
|
if (config != null) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 兼容老版本的包路径
|
||||||
|
String className = JsonUtils.parseObject(json, "@class", String.class);
|
||||||
|
className = StrUtil.subAfter(className, ".", true);
|
||||||
|
switch (className) {
|
||||||
|
case "AlipayPayClientConfig":
|
||||||
|
return JsonUtils.parseObject2(json, AlipayPayClientConfig.class);
|
||||||
|
case "WxPayClientConfig":
|
||||||
|
return JsonUtils.parseObject2(json, WxPayClientConfig.class);
|
||||||
|
case "NonePayClientConfig":
|
||||||
|
return JsonUtils.parseObject2(json, NonePayClientConfig.class);
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("未知的 PayClientConfig 类型:" + json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toJson(Object obj) {
|
||||||
|
return JsonUtils.toJsonString(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.pay.dal.dataobject.order;
|
package cn.iocoder.yudao.module.pay.dal.dataobject.order;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
||||||
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
||||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.pay.dal.dataobject.order;
|
package cn.iocoder.yudao.module.pay.dal.dataobject.order;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
||||||
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package cn.iocoder.yudao.module.pay.dal.dataobject.refund;
|
package cn.iocoder.yudao.module.pay.dal.dataobject.refund;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.pay.dal.dataobject.transfer;
|
package cn.iocoder.yudao.module.pay.dal.dataobject.transfer;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum;
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
||||||
|
import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum;
|
||||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
@ -89,7 +89,7 @@ public class PayTransferDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 转账状态
|
* 转账状态
|
||||||
*
|
*
|
||||||
* 枚举 {@link PayTransferStatusRespEnum}
|
* 枚举 {@link PayTransferStatusEnum}
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@ -1,9 +1,18 @@
|
|||||||
package cn.iocoder.yudao.module.pay.framework.pay.config;
|
package cn.iocoder.yudao.module.pay.framework.pay.config;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClientFactory;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.PayClientFactoryImpl;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
@EnableConfigurationProperties(PayProperties.class)
|
@EnableConfigurationProperties(PayProperties.class)
|
||||||
public class PayConfiguration {
|
public class PayConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PayClientFactory payClientFactory() {
|
||||||
|
return new PayClientFactoryImpl();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
@ -1,6 +1,4 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付客户端的工厂接口
|
* 支付客户端的工厂接口
|
||||||
@ -27,13 +25,4 @@ public interface PayClientFactory {
|
|||||||
*/
|
*/
|
||||||
<Config extends PayClientConfig> PayClient createOrUpdatePayClient(Long channelId, String channelCode,
|
<Config extends PayClientConfig> PayClient createOrUpdatePayClient(Long channelId, String channelCode,
|
||||||
Config config);
|
Config config);
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册支付客户端 Class,用于模块中实现的 PayClient
|
|
||||||
*
|
|
||||||
* @param channel 支付渠道的编码的枚举
|
|
||||||
* @param payClientClass 支付客户端 class
|
|
||||||
*/
|
|
||||||
void registerPayClientClass(PayChannelEnum channel, Class<?> payClientClass);
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.dto.order;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.exception.PayException;
|
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.exception.PayClientException;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -18,7 +18,7 @@ public class PayOrderRespDTO {
|
|||||||
/**
|
/**
|
||||||
* 支付状态
|
* 支付状态
|
||||||
*
|
*
|
||||||
* 枚举:{@link PayOrderStatusRespEnum}
|
* 枚举:{@link PayOrderStatusEnum}
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ public class PayOrderRespDTO {
|
|||||||
* 调用渠道的错误码
|
* 调用渠道的错误码
|
||||||
*
|
*
|
||||||
* 注意:这里返回的是业务异常,而是不系统异常。
|
* 注意:这里返回的是业务异常,而是不系统异常。
|
||||||
* 如果是系统异常,则会抛出 {@link PayException}
|
* 如果是系统异常,则会抛出 {@link PayClientException}
|
||||||
*/
|
*/
|
||||||
private String channelErrorCode;
|
private String channelErrorCode;
|
||||||
/**
|
/**
|
||||||
@ -82,7 +82,7 @@ public class PayOrderRespDTO {
|
|||||||
public static PayOrderRespDTO waitingOf(String displayMode, String displayContent,
|
public static PayOrderRespDTO waitingOf(String displayMode, String displayContent,
|
||||||
String outTradeNo, Object rawData) {
|
String outTradeNo, Object rawData) {
|
||||||
PayOrderRespDTO respDTO = new PayOrderRespDTO();
|
PayOrderRespDTO respDTO = new PayOrderRespDTO();
|
||||||
respDTO.status = PayOrderStatusRespEnum.WAITING.getStatus();
|
respDTO.status = PayOrderStatusEnum.WAITING.getStatus();
|
||||||
respDTO.displayMode = displayMode;
|
respDTO.displayMode = displayMode;
|
||||||
respDTO.displayContent = displayContent;
|
respDTO.displayContent = displayContent;
|
||||||
// 相对通用的字段
|
// 相对通用的字段
|
||||||
@ -97,7 +97,7 @@ public class PayOrderRespDTO {
|
|||||||
public static PayOrderRespDTO successOf(String channelOrderNo, String channelUserId, LocalDateTime successTime,
|
public static PayOrderRespDTO successOf(String channelOrderNo, String channelUserId, LocalDateTime successTime,
|
||||||
String outTradeNo, Object rawData) {
|
String outTradeNo, Object rawData) {
|
||||||
PayOrderRespDTO respDTO = new PayOrderRespDTO();
|
PayOrderRespDTO respDTO = new PayOrderRespDTO();
|
||||||
respDTO.status = PayOrderStatusRespEnum.SUCCESS.getStatus();
|
respDTO.status = PayOrderStatusEnum.SUCCESS.getStatus();
|
||||||
respDTO.channelOrderNo = channelOrderNo;
|
respDTO.channelOrderNo = channelOrderNo;
|
||||||
respDTO.channelUserId = channelUserId;
|
respDTO.channelUserId = channelUserId;
|
||||||
respDTO.successTime = successTime;
|
respDTO.successTime = successTime;
|
||||||
@ -129,7 +129,7 @@ public class PayOrderRespDTO {
|
|||||||
public static PayOrderRespDTO closedOf(String channelErrorCode, String channelErrorMsg,
|
public static PayOrderRespDTO closedOf(String channelErrorCode, String channelErrorMsg,
|
||||||
String outTradeNo, Object rawData) {
|
String outTradeNo, Object rawData) {
|
||||||
PayOrderRespDTO respDTO = new PayOrderRespDTO();
|
PayOrderRespDTO respDTO = new PayOrderRespDTO();
|
||||||
respDTO.status = PayOrderStatusRespEnum.CLOSED.getStatus();
|
respDTO.status = PayOrderStatusEnum.CLOSED.getStatus();
|
||||||
respDTO.channelErrorCode = channelErrorCode;
|
respDTO.channelErrorCode = channelErrorCode;
|
||||||
respDTO.channelErrorMsg = channelErrorMsg;
|
respDTO.channelErrorMsg = channelErrorMsg;
|
||||||
// 相对通用的字段
|
// 相对通用的字段
|
@ -1,6 +1,6 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.dto.order;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
import org.hibernate.validator.constraints.URL;
|
import org.hibernate.validator.constraints.URL;
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.dto.refund;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.exception.PayException;
|
import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.exception.PayClientException;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -17,7 +17,7 @@ public class PayRefundRespDTO {
|
|||||||
/**
|
/**
|
||||||
* 退款状态
|
* 退款状态
|
||||||
*
|
*
|
||||||
* 枚举 {@link PayRefundStatusRespEnum}
|
* 枚举 {@link PayRefundStatusEnum}
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class PayRefundRespDTO {
|
|||||||
* 调用渠道的错误码
|
* 调用渠道的错误码
|
||||||
*
|
*
|
||||||
* 注意:这里返回的是业务异常,而是不系统异常。
|
* 注意:这里返回的是业务异常,而是不系统异常。
|
||||||
* 如果是系统异常,则会抛出 {@link PayException}
|
* 如果是系统异常,则会抛出 {@link PayClientException}
|
||||||
*/
|
*/
|
||||||
private String channelErrorCode;
|
private String channelErrorCode;
|
||||||
/**
|
/**
|
||||||
@ -66,7 +66,7 @@ public class PayRefundRespDTO {
|
|||||||
public static PayRefundRespDTO waitingOf(String channelRefundNo,
|
public static PayRefundRespDTO waitingOf(String channelRefundNo,
|
||||||
String outRefundNo, Object rawData) {
|
String outRefundNo, Object rawData) {
|
||||||
PayRefundRespDTO respDTO = new PayRefundRespDTO();
|
PayRefundRespDTO respDTO = new PayRefundRespDTO();
|
||||||
respDTO.status = PayRefundStatusRespEnum.WAITING.getStatus();
|
respDTO.status = PayRefundStatusEnum.WAITING.getStatus();
|
||||||
respDTO.channelRefundNo = channelRefundNo;
|
respDTO.channelRefundNo = channelRefundNo;
|
||||||
// 相对通用的字段
|
// 相对通用的字段
|
||||||
respDTO.outRefundNo = outRefundNo;
|
respDTO.outRefundNo = outRefundNo;
|
||||||
@ -80,7 +80,7 @@ public class PayRefundRespDTO {
|
|||||||
public static PayRefundRespDTO successOf(String channelRefundNo, LocalDateTime successTime,
|
public static PayRefundRespDTO successOf(String channelRefundNo, LocalDateTime successTime,
|
||||||
String outRefundNo, Object rawData) {
|
String outRefundNo, Object rawData) {
|
||||||
PayRefundRespDTO respDTO = new PayRefundRespDTO();
|
PayRefundRespDTO respDTO = new PayRefundRespDTO();
|
||||||
respDTO.status = PayRefundStatusRespEnum.SUCCESS.getStatus();
|
respDTO.status = PayRefundStatusEnum.SUCCESS.getStatus();
|
||||||
respDTO.channelRefundNo = channelRefundNo;
|
respDTO.channelRefundNo = channelRefundNo;
|
||||||
respDTO.successTime = successTime;
|
respDTO.successTime = successTime;
|
||||||
// 相对通用的字段
|
// 相对通用的字段
|
||||||
@ -103,7 +103,7 @@ public class PayRefundRespDTO {
|
|||||||
public static PayRefundRespDTO failureOf(String channelErrorCode, String channelErrorMsg,
|
public static PayRefundRespDTO failureOf(String channelErrorCode, String channelErrorMsg,
|
||||||
String outRefundNo, Object rawData) {
|
String outRefundNo, Object rawData) {
|
||||||
PayRefundRespDTO respDTO = new PayRefundRespDTO();
|
PayRefundRespDTO respDTO = new PayRefundRespDTO();
|
||||||
respDTO.status = PayRefundStatusRespEnum.FAILURE.getStatus();
|
respDTO.status = PayRefundStatusEnum.FAILURE.getStatus();
|
||||||
respDTO.channelErrorCode = channelErrorCode;
|
respDTO.channelErrorCode = channelErrorCode;
|
||||||
respDTO.channelErrorMsg = channelErrorMsg;
|
respDTO.channelErrorMsg = channelErrorMsg;
|
||||||
// 相对通用的字段
|
// 相对通用的字段
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.dto.refund;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
@ -1,6 +1,6 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.dto.transfer;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum;
|
import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -16,7 +16,7 @@ public class PayTransferRespDTO {
|
|||||||
/**
|
/**
|
||||||
* 转账状态
|
* 转账状态
|
||||||
*
|
*
|
||||||
* 关联 {@link PayTransferStatusRespEnum#getStatus()}
|
* 关联 {@link PayTransferStatusEnum}
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ public class PayTransferRespDTO {
|
|||||||
public static PayTransferRespDTO waitingOf(String channelTransferNo,
|
public static PayTransferRespDTO waitingOf(String channelTransferNo,
|
||||||
String outTransferNo, Object rawData) {
|
String outTransferNo, Object rawData) {
|
||||||
PayTransferRespDTO respDTO = new PayTransferRespDTO();
|
PayTransferRespDTO respDTO = new PayTransferRespDTO();
|
||||||
respDTO.status = PayTransferStatusRespEnum.WAITING.getStatus();
|
respDTO.status = PayTransferStatusEnum.WAITING.getStatus();
|
||||||
respDTO.channelTransferNo = channelTransferNo;
|
respDTO.channelTransferNo = channelTransferNo;
|
||||||
respDTO.outTransferNo = outTransferNo;
|
respDTO.outTransferNo = outTransferNo;
|
||||||
respDTO.rawData = rawData;
|
respDTO.rawData = rawData;
|
||||||
@ -76,7 +76,7 @@ public class PayTransferRespDTO {
|
|||||||
public static PayTransferRespDTO processingOf(String channelTransferNo,
|
public static PayTransferRespDTO processingOf(String channelTransferNo,
|
||||||
String outTransferNo, Object rawData) {
|
String outTransferNo, Object rawData) {
|
||||||
PayTransferRespDTO respDTO = new PayTransferRespDTO();
|
PayTransferRespDTO respDTO = new PayTransferRespDTO();
|
||||||
respDTO.status = PayTransferStatusRespEnum.PROCESSING.getStatus();
|
respDTO.status = PayTransferStatusEnum.PROCESSING.getStatus();
|
||||||
respDTO.channelTransferNo = channelTransferNo;
|
respDTO.channelTransferNo = channelTransferNo;
|
||||||
respDTO.outTransferNo = outTransferNo;
|
respDTO.outTransferNo = outTransferNo;
|
||||||
respDTO.rawData = rawData;
|
respDTO.rawData = rawData;
|
||||||
@ -89,7 +89,7 @@ public class PayTransferRespDTO {
|
|||||||
public static PayTransferRespDTO closedOf(String channelErrorCode, String channelErrorMsg,
|
public static PayTransferRespDTO closedOf(String channelErrorCode, String channelErrorMsg,
|
||||||
String outTransferNo, Object rawData) {
|
String outTransferNo, Object rawData) {
|
||||||
PayTransferRespDTO respDTO = new PayTransferRespDTO();
|
PayTransferRespDTO respDTO = new PayTransferRespDTO();
|
||||||
respDTO.status = PayTransferStatusRespEnum.CLOSED.getStatus();
|
respDTO.status = PayTransferStatusEnum.CLOSED.getStatus();
|
||||||
respDTO.channelErrorCode = channelErrorCode;
|
respDTO.channelErrorCode = channelErrorCode;
|
||||||
respDTO.channelErrorMsg = channelErrorMsg;
|
respDTO.channelErrorMsg = channelErrorMsg;
|
||||||
// 相对通用的字段
|
// 相对通用的字段
|
||||||
@ -104,7 +104,7 @@ public class PayTransferRespDTO {
|
|||||||
public static PayTransferRespDTO successOf(String channelTransferNo, LocalDateTime successTime,
|
public static PayTransferRespDTO successOf(String channelTransferNo, LocalDateTime successTime,
|
||||||
String outTransferNo, Object rawData) {
|
String outTransferNo, Object rawData) {
|
||||||
PayTransferRespDTO respDTO = new PayTransferRespDTO();
|
PayTransferRespDTO respDTO = new PayTransferRespDTO();
|
||||||
respDTO.status = PayTransferStatusRespEnum.SUCCESS.getStatus();
|
respDTO.status = PayTransferStatusEnum.SUCCESS.getStatus();
|
||||||
respDTO.channelTransferNo = channelTransferNo;
|
respDTO.channelTransferNo = channelTransferNo;
|
||||||
respDTO.successTime = successTime;
|
respDTO.successTime = successTime;
|
||||||
// 相对通用的字段
|
// 相对通用的字段
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.dto.transfer;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
@ -0,0 +1,17 @@
|
|||||||
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.exception;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付系统异常 Exception
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class PayClientException extends RuntimeException {
|
||||||
|
|
||||||
|
public PayClientException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,16 +1,16 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClientConfig;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.exception.PayException;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.exception.PayClientException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -241,11 +241,11 @@ public abstract class AbstractPayClient<Config extends PayClientConfig> implemen
|
|||||||
|
|
||||||
// ========== 各种工具方法 ==========
|
// ========== 各种工具方法 ==========
|
||||||
|
|
||||||
private PayException buildPayException(Throwable ex) {
|
private PayClientException buildPayException(Throwable ex) {
|
||||||
if (ex instanceof PayException) {
|
if (ex instanceof PayClientException) {
|
||||||
return (PayException) ex;
|
return (PayClientException) ex;
|
||||||
}
|
}
|
||||||
throw new PayException(ex);
|
throw new PayClientException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClientConfig;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.Validator;
|
import javax.validation.Validator;
|
@ -1,21 +1,24 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.hutool.core.util.TypeUtil;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.*;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClientConfig;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.mock.MockPayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClientFactory;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.*;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.*;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.wallet.WalletPayClient;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin.*;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.mock.MockPayClient;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum.*;
|
import static cn.iocoder.yudao.module.pay.enums.PayChannelEnum.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付客户端的工厂实现类
|
* 支付客户端的工厂实现类
|
||||||
@ -35,7 +38,7 @@ public class PayClientFactoryImpl implements PayClientFactory {
|
|||||||
/**
|
/**
|
||||||
* 支付客户端 Class Map
|
* 支付客户端 Class Map
|
||||||
*/
|
*/
|
||||||
private final Map<PayChannelEnum, Class<?>> clientClass = new ConcurrentHashMap<>();
|
private final Map<PayChannelEnum, Class<? extends PayClient<?>>> clientClass = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public PayClientFactoryImpl() {
|
public PayClientFactoryImpl() {
|
||||||
// 微信支付客户端
|
// 微信支付客户端
|
||||||
@ -51,15 +54,12 @@ public class PayClientFactoryImpl implements PayClientFactory {
|
|||||||
clientClass.put(ALIPAY_APP, AlipayAppPayClient.class);
|
clientClass.put(ALIPAY_APP, AlipayAppPayClient.class);
|
||||||
clientClass.put(ALIPAY_PC, AlipayPcPayClient.class);
|
clientClass.put(ALIPAY_PC, AlipayPcPayClient.class);
|
||||||
clientClass.put(ALIPAY_BAR, AlipayBarPayClient.class);
|
clientClass.put(ALIPAY_BAR, AlipayBarPayClient.class);
|
||||||
|
// 钱包支付客户端
|
||||||
|
clientClass.put(WALLET, WalletPayClient.class);
|
||||||
// Mock 支付客户端
|
// Mock 支付客户端
|
||||||
clientClass.put(MOCK, MockPayClient.class);
|
clientClass.put(MOCK, MockPayClient.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerPayClientClass(PayChannelEnum channel, Class<?> payClientClass) {
|
|
||||||
clientClass.put(channel, payClientClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PayClient getPayClient(Long channelId) {
|
public PayClient getPayClient(Long channelId) {
|
||||||
AbstractPayClient<?> client = clients.get(channelId);
|
AbstractPayClient<?> client = clients.get(channelId);
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
@ -8,14 +8,14 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.AbstractPayClient;
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.AlipayConfig;
|
import com.alipay.api.AlipayConfig;
|
||||||
import com.alipay.api.AlipayResponse;
|
import com.alipay.api.AlipayResponse;
|
||||||
@ -39,8 +39,8 @@ import java.util.Objects;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER;
|
import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER;
|
||||||
import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE;
|
import static cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE;
|
||||||
import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_PUBLIC_KEY;
|
import static cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_PUBLIC_KEY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝抽象类,实现支付宝统一的接口、以及部分实现(退款)
|
* 支付宝抽象类,实现支付宝统一的接口、以及部分实现(退款)
|
||||||
@ -89,7 +89,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa
|
|||||||
Integer status = parseStatus(bodyObj.get("trade_status"));
|
Integer status = parseStatus(bodyObj.get("trade_status"));
|
||||||
// 特殊逻辑: 支付宝没有退款成功的状态,所以,如果有退款金额,我们认为是退款成功
|
// 特殊逻辑: 支付宝没有退款成功的状态,所以,如果有退款金额,我们认为是退款成功
|
||||||
if (MapUtil.getDouble(bodyObj, "refund_fee", 0D) > 0) {
|
if (MapUtil.getDouble(bodyObj, "refund_fee", 0D) > 0) {
|
||||||
status = PayOrderStatusRespEnum.REFUND.getStatus();
|
status = PayOrderStatusEnum.REFUND.getStatus();
|
||||||
}
|
}
|
||||||
Assert.notNull(status, (Supplier<Throwable>) () -> {
|
Assert.notNull(status, (Supplier<Throwable>) () -> {
|
||||||
throw new IllegalArgumentException(StrUtil.format("body({}) 的 trade_status 不正确", body));
|
throw new IllegalArgumentException(StrUtil.format("body({}) 的 trade_status 不正确", body));
|
||||||
@ -127,9 +127,9 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Integer parseStatus(String tradeStatus) {
|
private static Integer parseStatus(String tradeStatus) {
|
||||||
return Objects.equals("WAIT_BUYER_PAY", tradeStatus) ? PayOrderStatusRespEnum.WAITING.getStatus()
|
return Objects.equals("WAIT_BUYER_PAY", tradeStatus) ? PayOrderStatusEnum.WAITING.getStatus()
|
||||||
: ObjectUtils.equalsAny(tradeStatus, "TRADE_FINISHED", "TRADE_SUCCESS") ? PayOrderStatusRespEnum.SUCCESS.getStatus()
|
: ObjectUtils.equalsAny(tradeStatus, "TRADE_FINISHED", "TRADE_SUCCESS") ? PayOrderStatusEnum.SUCCESS.getStatus()
|
||||||
: Objects.equals("TRADE_CLOSED", tradeStatus) ? PayOrderStatusRespEnum.CLOSED.getStatus() : null;
|
: Objects.equals("TRADE_CLOSED", tradeStatus) ? PayOrderStatusEnum.CLOSED.getStatus() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ 退款相关 ==========
|
// ============ 退款相关 ==========
|
@ -1,10 +1,9 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.domain.AlipayTradeAppPayModel;
|
import com.alipay.api.domain.AlipayTradeAppPayModel;
|
||||||
import com.alipay.api.request.AlipayTradeAppPayRequest;
|
import com.alipay.api.request.AlipayTradeAppPayRequest;
|
@ -1,13 +1,12 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.domain.AlipayTradePayModel;
|
import com.alipay.api.domain.AlipayTradePayModel;
|
||||||
import com.alipay.api.request.AlipayTradePayRequest;
|
import com.alipay.api.request.AlipayTradePayRequest;
|
||||||
@ -19,7 +18,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST;
|
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST;
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||||
import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE;
|
import static cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝【条码支付】的 PayClient 实现类
|
* 支付宝【条码支付】的 PayClient 实现类
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClientConfig;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.ConstraintViolation;
|
import javax.validation.ConstraintViolation;
|
@ -1,12 +1,11 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.http.Method;
|
import cn.hutool.http.Method;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.domain.AlipayTradePagePayModel;
|
import com.alipay.api.domain.AlipayTradePagePayModel;
|
||||||
import com.alipay.api.request.AlipayTradePagePayRequest;
|
import com.alipay.api.request.AlipayTradePagePayRequest;
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.domain.AlipayTradePrecreateModel;
|
import com.alipay.api.domain.AlipayTradePrecreateModel;
|
||||||
import com.alipay.api.request.AlipayTradePrecreateRequest;
|
import com.alipay.api.request.AlipayTradePrecreateRequest;
|
||||||
@ -12,7 +12,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE;
|
import static cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_CERTIFICATE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝【扫码支付】的 PayClient 实现类
|
* 支付宝【扫码支付】的 PayClient 实现类
|
@ -1,10 +1,10 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
import cn.hutool.http.Method;
|
import cn.hutool.http.Method;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.domain.AlipayTradeWapPayModel;
|
import com.alipay.api.domain.AlipayTradeWapPayModel;
|
||||||
import com.alipay.api.request.AlipayTradeWapPayRequest;
|
import com.alipay.api.request.AlipayTradeWapPayRequest;
|
@ -1,14 +1,14 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.mock;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.mock;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.AbstractPayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.NonePayClientConfig;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
@ -1,20 +1,20 @@
|
|||||||
package cn.iocoder.yudao.module.pay.framework.pay.core;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.wallet;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.AbstractPayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.NonePayClientConfig;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.transfer.PayTransferDO;
|
||||||
@ -51,7 +51,7 @@ public class WalletPayClient extends AbstractPayClient<NonePayClientConfig> {
|
|||||||
private PayRefundService refundService;
|
private PayRefundService refundService;
|
||||||
private PayTransferService transferService;
|
private PayTransferService transferService;
|
||||||
|
|
||||||
public WalletPayClient(Long channelId, NonePayClientConfig config) {
|
public WalletPayClient(Long channelId, NonePayClientConfig config) {
|
||||||
super(channelId, PayChannelEnum.WALLET.getCode(), config);
|
super(channelId, PayChannelEnum.WALLET.getCode(), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,12 +163,12 @@ public class WalletPayClient extends AbstractPayClient<NonePayClientConfig> {
|
|||||||
outRefundNo, "");
|
outRefundNo, "");
|
||||||
}
|
}
|
||||||
// 退款失败
|
// 退款失败
|
||||||
if (PayRefundStatusRespEnum.isFailure(payRefund.getStatus())) {
|
if (PayRefundStatusEnum.isFailure(payRefund.getStatus())) {
|
||||||
return PayRefundRespDTO.failureOf(payRefund.getChannelErrorCode(), payRefund.getChannelErrorMsg(),
|
return PayRefundRespDTO.failureOf(payRefund.getChannelErrorCode(), payRefund.getChannelErrorMsg(),
|
||||||
outRefundNo, "");
|
outRefundNo, "");
|
||||||
}
|
}
|
||||||
// 退款成功
|
// 退款成功
|
||||||
if (PayRefundStatusRespEnum.isSuccess(payRefund.getStatus())) {
|
if (PayRefundStatusEnum.isSuccess(payRefund.getStatus())) {
|
||||||
PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransaction(
|
PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransaction(
|
||||||
String.valueOf(payRefund.getId()), PayWalletBizTypeEnum.PAYMENT_REFUND);
|
String.valueOf(payRefund.getId()), PayWalletBizTypeEnum.PAYMENT_REFUND);
|
||||||
Assert.notNull(walletTransaction, "支付退款单 {} 钱包流水不能为空", outRefundNo);
|
Assert.notNull(walletTransaction, "支付退款单 {} 钱包流水不能为空", outRefundNo);
|
||||||
@ -221,12 +221,12 @@ public class WalletPayClient extends AbstractPayClient<NonePayClientConfig> {
|
|||||||
PAY_ORDER_EXTENSION_NOT_FOUND.getMsg(), outTradeNo, "");
|
PAY_ORDER_EXTENSION_NOT_FOUND.getMsg(), outTradeNo, "");
|
||||||
}
|
}
|
||||||
// 关闭状态
|
// 关闭状态
|
||||||
if (PayTransferStatusRespEnum.isClosed(transfer.getStatus())) {
|
if (PayTransferStatusEnum.isClosed(transfer.getStatus())) {
|
||||||
return PayTransferRespDTO.closedOf(transfer.getChannelErrorCode(),
|
return PayTransferRespDTO.closedOf(transfer.getChannelErrorCode(),
|
||||||
transfer.getChannelErrorMsg(), outTradeNo, "");
|
transfer.getChannelErrorMsg(), outTradeNo, "");
|
||||||
}
|
}
|
||||||
// 成功状态
|
// 成功状态
|
||||||
if (PayTransferStatusRespEnum.isSuccess(transfer.getStatus())) {
|
if (PayTransferStatusEnum.isSuccess(transfer.getStatus())) {
|
||||||
PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransaction(
|
PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransaction(
|
||||||
String.valueOf(transfer.getId()), PayWalletBizTypeEnum.TRANSFER);
|
String.valueOf(transfer.getId()), PayWalletBizTypeEnum.TRANSFER);
|
||||||
Assert.notNull(walletTransaction, "转账单 {} 钱包流水不能为空", outTradeNo);
|
Assert.notNull(walletTransaction, "转账单 {} 钱包流水不能为空", outTradeNo);
|
||||||
@ -234,12 +234,12 @@ public class WalletPayClient extends AbstractPayClient<NonePayClientConfig> {
|
|||||||
outTradeNo, walletTransaction);
|
outTradeNo, walletTransaction);
|
||||||
}
|
}
|
||||||
// 处理中状态
|
// 处理中状态
|
||||||
if (PayTransferStatusRespEnum.isProcessing(transfer.getStatus())) {
|
if (PayTransferStatusEnum.isProcessing(transfer.getStatus())) {
|
||||||
return PayTransferRespDTO.processingOf(transfer.getChannelTransferNo(),
|
return PayTransferRespDTO.processingOf(transfer.getChannelTransferNo(),
|
||||||
outTradeNo, transfer);
|
outTradeNo, transfer);
|
||||||
}
|
}
|
||||||
// 等待状态
|
// 等待状态
|
||||||
if (transfer.getStatus().equals(PayTransferStatusRespEnum.WAITING.getStatus())) {
|
if (PayTransferStatusEnum.isWaiting(transfer.getStatus())) {
|
||||||
return PayTransferRespDTO.waitingOf(transfer.getChannelTransferNo(),
|
return PayTransferRespDTO.waitingOf(transfer.getChannelTransferNo(),
|
||||||
outTradeNo, transfer);
|
outTradeNo, transfer);
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
@ -9,14 +9,14 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import cn.iocoder.yudao.framework.common.util.io.FileUtils;
|
import cn.iocoder.yudao.framework.common.util.io.FileUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.AbstractPayClient;
|
||||||
import com.github.binarywang.wxpay.bean.notify.*;
|
import com.github.binarywang.wxpay.bean.notify.*;
|
||||||
import com.github.binarywang.wxpay.bean.request.*;
|
import com.github.binarywang.wxpay.bean.request.*;
|
||||||
import com.github.binarywang.wxpay.bean.result.*;
|
import com.github.binarywang.wxpay.bean.result.*;
|
||||||
@ -36,8 +36,8 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static cn.hutool.core.date.DatePattern.*;
|
import static cn.hutool.core.date.DatePattern.*;
|
||||||
import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig.API_VERSION_V2;
|
import static cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin.WxPayClientConfig.API_VERSION_V2;
|
||||||
import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig.API_VERSION_V3;
|
import static cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin.WxPayClientConfig.API_VERSION_V3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付抽象类,实现微信统一的接口、以及部分实现(退款)
|
* 微信支付抽象类,实现微信统一的接口、以及部分实现(退款)
|
||||||
@ -173,7 +173,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
|||||||
// 2. 构建结果
|
// 2. 构建结果
|
||||||
// V2 微信支付的回调,只有 SUCCESS 支付成功、CLOSED 支付失败两种情况,无需像支付宝一样解析的比较复杂
|
// V2 微信支付的回调,只有 SUCCESS 支付成功、CLOSED 支付失败两种情况,无需像支付宝一样解析的比较复杂
|
||||||
Integer status = Objects.equals(response.getResultCode(), "SUCCESS") ?
|
Integer status = Objects.equals(response.getResultCode(), "SUCCESS") ?
|
||||||
PayOrderStatusRespEnum.SUCCESS.getStatus() : PayOrderStatusRespEnum.CLOSED.getStatus();
|
PayOrderStatusEnum.SUCCESS.getStatus() : PayOrderStatusEnum.CLOSED.getStatus();
|
||||||
return PayOrderRespDTO.of(status, response.getTransactionId(), response.getOpenid(), parseDateV2(response.getTimeEnd()),
|
return PayOrderRespDTO.of(status, response.getTransactionId(), response.getOpenid(), parseDateV2(response.getTimeEnd()),
|
||||||
response.getOutTradeNo(), body);
|
response.getOutTradeNo(), body);
|
||||||
}
|
}
|
||||||
@ -244,15 +244,15 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
|||||||
switch (tradeState) {
|
switch (tradeState) {
|
||||||
case "NOTPAY":
|
case "NOTPAY":
|
||||||
case "USERPAYING": // 支付中,等待用户输入密码(条码支付独有)
|
case "USERPAYING": // 支付中,等待用户输入密码(条码支付独有)
|
||||||
return PayOrderStatusRespEnum.WAITING.getStatus();
|
return PayOrderStatusEnum.WAITING.getStatus();
|
||||||
case "SUCCESS":
|
case "SUCCESS":
|
||||||
return PayOrderStatusRespEnum.SUCCESS.getStatus();
|
return PayOrderStatusEnum.SUCCESS.getStatus();
|
||||||
case "REFUND":
|
case "REFUND":
|
||||||
return PayOrderStatusRespEnum.REFUND.getStatus();
|
return PayOrderStatusEnum.REFUND.getStatus();
|
||||||
case "CLOSED":
|
case "CLOSED":
|
||||||
case "REVOKED": // 已撤销(刷卡支付独有)
|
case "REVOKED": // 已撤销(刷卡支付独有)
|
||||||
case "PAYERROR": // 支付失败(其它原因,如银行返回失败)
|
case "PAYERROR": // 支付失败(其它原因,如银行返回失败)
|
||||||
return PayOrderStatusRespEnum.CLOSED.getStatus();
|
return PayOrderStatusEnum.CLOSED.getStatus();
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException(StrUtil.format("未知的支付状态({})", tradeState));
|
throw new IllegalArgumentException(StrUtil.format("未知的支付状态({})", tradeState));
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult;
|
import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
@ -1,13 +1,13 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin;
|
||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest;
|
||||||
import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult;
|
import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult;
|
||||||
import com.github.binarywang.wxpay.constant.WxPayConstants;
|
import com.github.binarywang.wxpay.constant.WxPayConstants;
|
@ -1,6 +1,6 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult;
|
import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
@ -1,12 +1,11 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClientConfig;
|
||||||
|
import jakarta.validation.Validator;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.Validator;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付的 PayClientConfig 实现类
|
* 微信支付的 PayClientConfig 实现类
|
||||||
* 属性主要来自 {@link com.github.binarywang.wxpay.config.WxPayConfig} 的必要属性
|
* 属性主要来自 {@link com.github.binarywang.wxpay.config.WxPayConfig} 的必要属性
|
@ -1,10 +1,11 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin;
|
||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
||||||
@ -27,6 +28,11 @@ import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class WxPubPayClient extends AbstractWxPayClient {
|
public class WxPubPayClient extends AbstractWxPayClient {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused") // 反射会调用到,所以不能删除
|
||||||
|
public WxPubPayClient(Long channelId, WxPayClientConfig config) {
|
||||||
|
super(channelId, PayChannelEnum.WX_PUB.getCode(), config);
|
||||||
|
}
|
||||||
|
|
||||||
protected WxPubPayClient(Long channelId, String channelCode, WxPayClientConfig config) {
|
protected WxPubPayClient(Long channelId, String channelCode, WxPayClientConfig config) {
|
||||||
super(channelId, channelCode, config);
|
super(channelId, channelCode, config);
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.enums.order;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.enums;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* 支付客户端,接入国内多个支付渠道:
|
||||||
|
* 1. 支付宝,基于官方 SDK 接入
|
||||||
|
* 2. 微信支付,基于 weixin-java-pay 接入
|
||||||
|
*/
|
||||||
|
package cn.iocoder.yudao.module.pay.framework.pay;
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.pay.service.channel;
|
package cn.iocoder.yudao.module.pay.service.channel;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
||||||
|
@ -4,31 +4,30 @@ import cn.hutool.core.lang.Assert;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClientConfig;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClientFactory;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.convert.channel.PayChannelConvert;
|
import cn.iocoder.yudao.module.pay.convert.channel.PayChannelConvert;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.mysql.channel.PayChannelMapper;
|
import cn.iocoder.yudao.module.pay.dal.mysql.channel.PayChannelMapper;
|
||||||
import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.NonePayClientConfig;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.AlipayPayClientConfig;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin.WxPayClientConfig;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Validator;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.validation.Validator;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付渠道 Service 实现类
|
* 支付渠道 Service 实现类
|
||||||
*
|
*
|
||||||
@ -48,14 +47,6 @@ public class PayChannelServiceImpl implements PayChannelService {
|
|||||||
@Resource
|
@Resource
|
||||||
private Validator validator;
|
private Validator validator;
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化,为了注册钱包
|
|
||||||
*/
|
|
||||||
@PostConstruct
|
|
||||||
public void init() {
|
|
||||||
payClientFactory.registerPayClientClass(PayChannelEnum.WALLET, WalletPayClient.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createChannel(PayChannelCreateReqVO reqVO) {
|
public Long createChannel(PayChannelCreateReqVO reqVO) {
|
||||||
// 断言是否有重复的
|
// 断言是否有重复的
|
||||||
@ -91,7 +82,9 @@ public class PayChannelServiceImpl implements PayChannelService {
|
|||||||
*/
|
*/
|
||||||
private PayClientConfig parseConfig(String code, String configStr) {
|
private PayClientConfig parseConfig(String code, String configStr) {
|
||||||
// 解析配置
|
// 解析配置
|
||||||
Class<? extends PayClientConfig> payClass = PayChannelEnum.getByCode(code).getConfigClass();
|
Class<? extends PayClientConfig> payClass = PayChannelEnum.isAlipay(configStr) ? AlipayPayClientConfig.class
|
||||||
|
: PayChannelEnum.isWeixin(configStr) ? WxPayClientConfig.class
|
||||||
|
: NonePayClientConfig.class;
|
||||||
if (ObjectUtil.isNull(payClass)) {
|
if (ObjectUtil.isNull(payClass)) {
|
||||||
throw exception(CHANNEL_NOT_FOUND);
|
throw exception(CHANNEL_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.pay.service.order;
|
package cn.iocoder.yudao.module.pay.service.order;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO;
|
||||||
|
@ -7,10 +7,9 @@ import cn.hutool.extra.spring.SpringUtil;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum;
|
|
||||||
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO;
|
||||||
@ -218,13 +217,13 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|||||||
throw exception(PAY_ORDER_EXTENSION_IS_PAID);
|
throw exception(PAY_ORDER_EXTENSION_IS_PAID);
|
||||||
}
|
}
|
||||||
// 情况二:调用三方接口,查询支付单状态,是不是已支付
|
// 情况二:调用三方接口,查询支付单状态,是不是已支付
|
||||||
PayClient payClient = channelService.getPayClient(orderExtension.getChannelId());
|
PayClient<?> payClient = channelService.getPayClient(orderExtension.getChannelId());
|
||||||
if (payClient == null) {
|
if (payClient == null) {
|
||||||
log.error("[validateOrderCanSubmit][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId());
|
log.error("[validateOrderCanSubmit][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo());
|
PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo());
|
||||||
if (respDTO != null && PayOrderStatusRespEnum.isSuccess(respDTO.getStatus())) {
|
if (respDTO != null && PayOrderStatusEnum.isSuccess(respDTO.getStatus())) {
|
||||||
log.warn("[validateOrderCanSubmit][order({}) 的 PayOrderRespDTO({}) 已支付,可能是回调延迟]",
|
log.warn("[validateOrderCanSubmit][order({}) 的 PayOrderRespDTO({}) 已支付,可能是回调延迟]",
|
||||||
id, toJsonString(respDTO));
|
id, toJsonString(respDTO));
|
||||||
throw exception(PAY_ORDER_EXTENSION_IS_PAID);
|
throw exception(PAY_ORDER_EXTENSION_IS_PAID);
|
||||||
@ -273,12 +272,12 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|||||||
// 注意,如果是方法内调用该方法,需要通过 getSelf().notifyPayOrder(channel, notify) 调用,否则事务不生效
|
// 注意,如果是方法内调用该方法,需要通过 getSelf().notifyPayOrder(channel, notify) 调用,否则事务不生效
|
||||||
public void notifyOrder(PayChannelDO channel, PayOrderRespDTO notify) {
|
public void notifyOrder(PayChannelDO channel, PayOrderRespDTO notify) {
|
||||||
// 情况一:支付成功的回调
|
// 情况一:支付成功的回调
|
||||||
if (PayOrderStatusRespEnum.isSuccess(notify.getStatus())) {
|
if (PayOrderStatusEnum.isSuccess(notify.getStatus())) {
|
||||||
notifyOrderSuccess(channel, notify);
|
notifyOrderSuccess(channel, notify);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 情况二:支付失败的回调
|
// 情况二:支付失败的回调
|
||||||
if (PayOrderStatusRespEnum.isClosed(notify.getStatus())) {
|
if (PayOrderStatusEnum.isClosed(notify.getStatus())) {
|
||||||
notifyOrderClosed(channel, notify);
|
notifyOrderClosed(channel, notify);
|
||||||
}
|
}
|
||||||
// 情况三:WAITING:无需处理
|
// 情况三:WAITING:无需处理
|
||||||
@ -373,6 +372,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|||||||
updateOrderExtensionClosed(channel, notify);
|
updateOrderExtensionClosed(channel, notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private void updateOrderExtensionClosed(PayChannelDO channel, PayOrderRespDTO notify) {
|
private void updateOrderExtensionClosed(PayChannelDO channel, PayOrderRespDTO notify) {
|
||||||
// 1. 查询 PayOrderExtensionDO
|
// 1. 查询 PayOrderExtensionDO
|
||||||
PayOrderExtensionDO orderExtension = orderExtensionMapper.selectByNo(notify.getOutTradeNo());
|
PayOrderExtensionDO orderExtension = orderExtensionMapper.selectByNo(notify.getOutTradeNo());
|
||||||
@ -488,7 +488,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|||||||
private boolean syncOrder(PayOrderExtensionDO orderExtension) {
|
private boolean syncOrder(PayOrderExtensionDO orderExtension) {
|
||||||
try {
|
try {
|
||||||
// 1.1 查询支付订单信息
|
// 1.1 查询支付订单信息
|
||||||
PayClient payClient = channelService.getPayClient(orderExtension.getChannelId());
|
PayClient<?> payClient = channelService.getPayClient(orderExtension.getChannelId());
|
||||||
if (payClient == null) {
|
if (payClient == null) {
|
||||||
log.error("[syncOrder][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId());
|
log.error("[syncOrder][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId());
|
||||||
return false;
|
return false;
|
||||||
@ -499,14 +499,14 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|||||||
// 当用户支付成功之后,该订单状态在渠道的回调中无法从已关闭改为已支付,造成重大影响。
|
// 当用户支付成功之后,该订单状态在渠道的回调中无法从已关闭改为已支付,造成重大影响。
|
||||||
// 考虑此定时任务是异常场景的兜底操作,因此这里不做变更,优先以回调为准。
|
// 考虑此定时任务是异常场景的兜底操作,因此这里不做变更,优先以回调为准。
|
||||||
// 让订单自动随着支付渠道那边一起等到过期,确保渠道先过期关闭支付入口,而后通过订单过期定时任务关闭自己的订单。
|
// 让订单自动随着支付渠道那边一起等到过期,确保渠道先过期关闭支付入口,而后通过订单过期定时任务关闭自己的订单。
|
||||||
if (PayOrderStatusRespEnum.isClosed(respDTO.getStatus())) {
|
if (PayOrderStatusEnum.isClosed(respDTO.getStatus())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 1.2 回调支付结果
|
// 1.2 回调支付结果
|
||||||
notifyOrder(orderExtension.getChannelId(), respDTO);
|
notifyOrder(orderExtension.getChannelId(), respDTO);
|
||||||
|
|
||||||
// 2. 如果是已支付,则返回 true
|
// 2. 如果是已支付,则返回 true
|
||||||
return PayOrderStatusRespEnum.isSuccess(respDTO.getStatus());
|
return PayOrderStatusEnum.isSuccess(respDTO.getStatus());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("[syncOrder][orderExtension({}) 同步支付状态异常]", orderExtension.getId(), e);
|
log.error("[syncOrder][orderExtension({}) 同步支付状态异常]", orderExtension.getId(), e);
|
||||||
return false;
|
return false;
|
||||||
@ -551,20 +551,20 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 情况二:调用三方接口,查询支付单状态,是不是已支付/已退款
|
// 情况二:调用三方接口,查询支付单状态,是不是已支付/已退款
|
||||||
PayClient payClient = channelService.getPayClient(orderExtension.getChannelId());
|
PayClient<?> payClient = channelService.getPayClient(orderExtension.getChannelId());
|
||||||
if (payClient == null) {
|
if (payClient == null) {
|
||||||
log.error("[expireOrder][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId());
|
log.error("[expireOrder][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo());
|
PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo());
|
||||||
if (PayOrderStatusRespEnum.isRefund(respDTO.getStatus())) {
|
if (PayOrderStatusEnum.isRefund(respDTO.getStatus())) {
|
||||||
// 补充说明:按道理,应该是 WAITING => SUCCESS => REFUND 状态,如果直接 WAITING => REFUND 状态,说明中间丢了过程
|
// 补充说明:按道理,应该是 WAITING => SUCCESS => REFUND 状态,如果直接 WAITING => REFUND 状态,说明中间丢了过程
|
||||||
// 此时,需要人工介入,手工补齐数据,保持 WAITING => SUCCESS => REFUND 的过程
|
// 此时,需要人工介入,手工补齐数据,保持 WAITING => SUCCESS => REFUND 的过程
|
||||||
log.error("[expireOrder][extension({}) 的 PayOrderRespDTO({}) 已退款,可能是回调延迟]",
|
log.error("[expireOrder][extension({}) 的 PayOrderRespDTO({}) 已退款,可能是回调延迟]",
|
||||||
orderExtension.getId(), toJsonString(respDTO));
|
orderExtension.getId(), toJsonString(respDTO));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (PayOrderStatusRespEnum.isSuccess(respDTO.getStatus())) {
|
if (PayOrderStatusEnum.isSuccess(respDTO.getStatus())) {
|
||||||
notifyOrder(orderExtension.getChannelId(), respDTO);
|
notifyOrder(orderExtension.getChannelId(), respDTO);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.pay.service.refund;
|
package cn.iocoder.yudao.module.pay.service.refund;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO;
|
||||||
|
@ -3,10 +3,9 @@ package cn.iocoder.yudao.module.pay.service.refund;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
|
|
||||||
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||||
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO;
|
||||||
@ -203,12 +202,12 @@ public class PayRefundServiceImpl implements PayRefundService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void notifyRefund(PayChannelDO channel, PayRefundRespDTO notify) {
|
public void notifyRefund(PayChannelDO channel, PayRefundRespDTO notify) {
|
||||||
// 情况一:退款成功
|
// 情况一:退款成功
|
||||||
if (PayRefundStatusRespEnum.isSuccess(notify.getStatus())) {
|
if (PayRefundStatusEnum.isSuccess(notify.getStatus())) {
|
||||||
notifyRefundSuccess(channel, notify);
|
notifyRefundSuccess(channel, notify);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 情况二:退款失败
|
// 情况二:退款失败
|
||||||
if (PayRefundStatusRespEnum.isFailure(notify.getStatus())) {
|
if (PayRefundStatusEnum.isFailure(notify.getStatus())) {
|
||||||
notifyRefundFailure(channel, notify);
|
notifyRefundFailure(channel, notify);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,7 +301,7 @@ public class PayRefundServiceImpl implements PayRefundService {
|
|||||||
private boolean syncRefund(PayRefundDO refund) {
|
private boolean syncRefund(PayRefundDO refund) {
|
||||||
try {
|
try {
|
||||||
// 1.1 查询退款订单信息
|
// 1.1 查询退款订单信息
|
||||||
PayClient payClient = channelService.getPayClient(refund.getChannelId());
|
PayClient<?> payClient = channelService.getPayClient(refund.getChannelId());
|
||||||
if (payClient == null) {
|
if (payClient == null) {
|
||||||
log.error("[syncRefund][渠道编号({}) 找不到对应的支付客户端]", refund.getChannelId());
|
log.error("[syncRefund][渠道编号({}) 找不到对应的支付客户端]", refund.getChannelId());
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.pay.service.transfer;
|
package cn.iocoder.yudao.module.pay.service.transfer;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO;
|
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.transfer.vo.PayTransferPageReqVO;
|
||||||
|
@ -6,10 +6,9 @@ import cn.hutool.extra.spring.SpringUtil;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.transfer.PayTransferUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.transfer.PayTransferStatusRespEnum;
|
|
||||||
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||||
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO;
|
import cn.iocoder.yudao.module.pay.api.transfer.dto.PayTransferCreateRespDTO;
|
||||||
@ -142,15 +141,15 @@ public class PayTransferServiceImpl implements PayTransferService {
|
|||||||
// 注意,如果是方法内调用该方法,需要通过 getSelf().notifyTransfer(channel, notify) 调用,否则事务不生效
|
// 注意,如果是方法内调用该方法,需要通过 getSelf().notifyTransfer(channel, notify) 调用,否则事务不生效
|
||||||
public void notifyTransfer(PayChannelDO channel, PayTransferRespDTO notify) {
|
public void notifyTransfer(PayChannelDO channel, PayTransferRespDTO notify) {
|
||||||
// 转账成功的回调
|
// 转账成功的回调
|
||||||
if (PayTransferStatusRespEnum.isSuccess(notify.getStatus())) {
|
if (PayTransferStatusEnum.isSuccess(notify.getStatus())) {
|
||||||
notifyTransferSuccess(channel, notify);
|
notifyTransferSuccess(channel, notify);
|
||||||
}
|
}
|
||||||
// 转账关闭的回调
|
// 转账关闭的回调
|
||||||
if (PayTransferStatusRespEnum.isClosed(notify.getStatus())) {
|
if (PayTransferStatusEnum.isClosed(notify.getStatus())) {
|
||||||
notifyTransferClosed(channel, notify);
|
notifyTransferClosed(channel, notify);
|
||||||
}
|
}
|
||||||
// 转账处理中的回调
|
// 转账处理中的回调
|
||||||
if (PayTransferStatusRespEnum.isProcessing(notify.getStatus())) {
|
if (PayTransferStatusEnum.isProcessing(notify.getStatus())) {
|
||||||
notifyTransferProgressing(channel, notify);
|
notifyTransferProgressing(channel, notify);
|
||||||
}
|
}
|
||||||
// WAITING 状态无需处理
|
// WAITING 状态无需处理
|
||||||
@ -162,7 +161,7 @@ public class PayTransferServiceImpl implements PayTransferService {
|
|||||||
if (transfer == null) {
|
if (transfer == null) {
|
||||||
throw exception(PAY_TRANSFER_NOT_FOUND);
|
throw exception(PAY_TRANSFER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
if (PayTransferStatusEnum.isProgressing(transfer.getStatus())) { // 如果已经是转账中,直接返回,不用重复更新
|
if (PayTransferStatusEnum.isProcessing(transfer.getStatus())) { // 如果已经是转账中,直接返回,不用重复更新
|
||||||
log.info("[notifyTransferProgressing][transfer({}) 已经是转账中状态,无需更新]", transfer.getId());
|
log.info("[notifyTransferProgressing][transfer({}) 已经是转账中状态,无需更新]", transfer.getId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
|
|
||||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi;
|
import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi;
|
||||||
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
||||||
@ -224,7 +223,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
|||||||
.setRefundTotalPrice(walletRecharge.getTotalPrice()).setRefundPayPrice(walletRecharge.getPayPrice())
|
.setRefundTotalPrice(walletRecharge.getTotalPrice()).setRefundPayPrice(walletRecharge.getPayPrice())
|
||||||
.setRefundBonusPrice(walletRecharge.getBonusPrice());
|
.setRefundBonusPrice(walletRecharge.getBonusPrice());
|
||||||
// 情况二:退款失败
|
// 情况二:退款失败
|
||||||
} else if (PayRefundStatusRespEnum.isFailure(payRefund.getStatus())) {
|
} else if (PayRefundStatusEnum.isFailure(payRefund.getStatus())) {
|
||||||
// 2.2 解冻余额
|
// 2.2 解冻余额
|
||||||
payWalletService.unfreezePrice(walletRecharge.getWalletId(), walletRecharge.getTotalPrice());
|
payWalletService.unfreezePrice(walletRecharge.getWalletId(), walletRecharge.getTotalPrice());
|
||||||
|
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl;
|
||||||
|
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayQrPayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.PayClientFactoryImpl;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.AlipayPayClientConfig;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.AlipayQrPayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPubPayClient;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.AlipayWapPayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin.WxPayClientConfig;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin.WxPubPayClient;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
@ -1,16 +1,16 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.exception.PayException;
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
|
|
||||||
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
|
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
|
||||||
|
import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.exception.PayClientException;
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.DefaultAlipayClient;
|
import com.alipay.api.DefaultAlipayClient;
|
||||||
import com.alipay.api.DefaultSigner;
|
import com.alipay.api.DefaultSigner;
|
||||||
@ -27,8 +27,8 @@ import org.mockito.Mock;
|
|||||||
import javax.validation.ConstraintViolationException;
|
import javax.validation.ConstraintViolationException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_PUBLIC_KEY;
|
|
||||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.AlipayPayClientConfig.MODE_PUBLIC_KEY;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.mockito.ArgumentMatchers.argThat;
|
import static org.mockito.ArgumentMatchers.argThat;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@ -106,7 +106,7 @@ public abstract class AbstractAlipayClientTest extends BaseMockitoUnitTest {
|
|||||||
// 调用
|
// 调用
|
||||||
PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO);
|
PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO);
|
||||||
// 断言
|
// 断言
|
||||||
assertEquals(PayRefundStatusRespEnum.SUCCESS.getStatus(), resp.getStatus());
|
assertEquals(PayRefundStatusEnum.SUCCESS.getStatus(), resp.getStatus());
|
||||||
assertEquals(outRefundNo, resp.getOutRefundNo());
|
assertEquals(outRefundNo, resp.getOutRefundNo());
|
||||||
assertNull(resp.getChannelRefundNo());
|
assertNull(resp.getChannelRefundNo());
|
||||||
assertEquals(LocalDateTimeUtil.of(refundTime), resp.getSuccessTime());
|
assertEquals(LocalDateTimeUtil.of(refundTime), resp.getSuccessTime());
|
||||||
@ -142,7 +142,7 @@ public abstract class AbstractAlipayClientTest extends BaseMockitoUnitTest {
|
|||||||
// 调用
|
// 调用
|
||||||
PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO);
|
PayRefundRespDTO resp = client.unifiedRefund(refundReqDTO);
|
||||||
// 断言
|
// 断言
|
||||||
assertEquals(PayRefundStatusRespEnum.FAILURE.getStatus(), resp.getStatus());
|
assertEquals(PayRefundStatusEnum.FAILURE.getStatus(), resp.getStatus());
|
||||||
assertEquals(outRefundNo, resp.getOutRefundNo());
|
assertEquals(outRefundNo, resp.getOutRefundNo());
|
||||||
assertNull(resp.getChannelRefundNo());
|
assertNull(resp.getChannelRefundNo());
|
||||||
assertNull(resp.getSuccessTime());
|
assertNull(resp.getSuccessTime());
|
||||||
@ -190,7 +190,7 @@ public abstract class AbstractAlipayClientTest extends BaseMockitoUnitTest {
|
|||||||
PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> o.setNotifyUrl(notifyUrl));
|
PayRefundUnifiedReqDTO refundReqDTO = randomPojo(PayRefundUnifiedReqDTO.class, o -> o.setNotifyUrl(notifyUrl));
|
||||||
|
|
||||||
// 调用,并断言
|
// 调用,并断言
|
||||||
assertThrows(PayException.class, () -> client.unifiedRefund(refundReqDTO));
|
assertThrows(PayClientException.class, () -> client.unifiedRefund(refundReqDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
@ -1,11 +1,11 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.domain.AlipayTradePayModel;
|
import com.alipay.api.domain.AlipayTradePayModel;
|
||||||
import com.alipay.api.request.AlipayTradePayRequest;
|
import com.alipay.api.request.AlipayTradePayRequest;
|
||||||
@ -20,8 +20,8 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED;
|
import static cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum.CLOSED;
|
||||||
import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING;
|
import static cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum.WAITING;
|
||||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.mockito.ArgumentMatchers.argThat;
|
import static org.mockito.ArgumentMatchers.argThat;
|
||||||
@ -110,7 +110,7 @@ public class AlipayBarPayClientTest extends AbstractAlipayClientTest {
|
|||||||
// 下单请求
|
// 下单请求
|
||||||
PayOrderRespDTO resp = client.unifiedOrder(reqDTO);
|
PayOrderRespDTO resp = client.unifiedOrder(reqDTO);
|
||||||
// 断言
|
// 断言
|
||||||
assertEquals(PayOrderStatusRespEnum.SUCCESS.getStatus(), resp.getStatus());
|
assertEquals(PayOrderStatusEnum.SUCCESS.getStatus(), resp.getStatus());
|
||||||
assertEquals(outTradeNo, resp.getOutTradeNo());
|
assertEquals(outTradeNo, resp.getOutTradeNo());
|
||||||
assertEquals(channelNo, resp.getChannelOrderNo());
|
assertEquals(channelNo, resp.getChannelOrderNo());
|
||||||
assertEquals(channelUserId, resp.getChannelUserId());
|
assertEquals(channelUserId, resp.getChannelUserId());
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
import cn.hutool.http.Method;
|
import cn.hutool.http.Method;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.request.AlipayTradePagePayRequest;
|
import com.alipay.api.request.AlipayTradePagePayRequest;
|
||||||
import com.alipay.api.response.AlipayTradePagePayResponse;
|
import com.alipay.api.response.AlipayTradePagePayResponse;
|
||||||
@ -13,8 +13,8 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.mockito.ArgumentMatcher;
|
import org.mockito.ArgumentMatcher;
|
||||||
import org.mockito.InjectMocks;
|
import org.mockito.InjectMocks;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED;
|
import static cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum.CLOSED;
|
||||||
import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING;
|
import static cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum.WAITING;
|
||||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
@ -1,12 +1,12 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.exception.PayException;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.exception.PayClientException;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.request.AlipayTradePrecreateRequest;
|
import com.alipay.api.request.AlipayTradePrecreateRequest;
|
||||||
import com.alipay.api.response.AlipayTradePrecreateResponse;
|
import com.alipay.api.response.AlipayTradePrecreateResponse;
|
||||||
@ -16,9 +16,9 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.mockito.ArgumentMatcher;
|
import org.mockito.ArgumentMatcher;
|
||||||
import org.mockito.InjectMocks;
|
import org.mockito.InjectMocks;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED;
|
|
||||||
import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING;
|
|
||||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum.CLOSED;
|
||||||
|
import static cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum.WAITING;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.mockito.ArgumentMatchers.argThat;
|
import static org.mockito.ArgumentMatchers.argThat;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@ -123,7 +123,7 @@ public class AlipayQrPayClientTest extends AbstractAlipayClientTest {
|
|||||||
PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo,price);
|
PayOrderUnifiedReqDTO reqDTO = buildOrderUnifiedReqDTO(notifyUrl, outTradeNo,price);
|
||||||
|
|
||||||
// 调用,并断言
|
// 调用,并断言
|
||||||
assertThrows(PayException.class, () -> client.unifiedOrder(reqDTO));
|
assertThrows(PayClientException.class, () -> client.unifiedOrder(reqDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.alipay;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay;
|
||||||
|
|
||||||
import cn.hutool.http.Method;
|
import cn.hutool.http.Method;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.domain.AlipayTradeWapPayModel;
|
import com.alipay.api.domain.AlipayTradeWapPayModel;
|
||||||
import com.alipay.api.request.AlipayTradeWapPayRequest;
|
import com.alipay.api.request.AlipayTradeWapPayRequest;
|
||||||
@ -14,9 +14,9 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.mockito.ArgumentMatcher;
|
import org.mockito.ArgumentMatcher;
|
||||||
import org.mockito.InjectMocks;
|
import org.mockito.InjectMocks;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.CLOSED;
|
|
||||||
import static cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum.WAITING;
|
|
||||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum.CLOSED;
|
||||||
|
import static cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum.WAITING;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.mockito.ArgumentMatchers.argThat;
|
import static org.mockito.ArgumentMatchers.argThat;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.AbstractWxPayClient.formatDateV2;
|
import static cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin.AbstractWxPayClient.formatDateV2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link WxBarPayClient} 的集成测试,用于快速调试微信条码支付
|
* {@link WxBarPayClient} 的集成测试,用于快速调试微信条码支付
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.impl.weixin;
|
package cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
@ -15,7 +15,8 @@ import org.junit.jupiter.api.Test;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.pay.core.client.impl.weixin.AbstractWxPayClient.formatDateV3;
|
import static cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin.AbstractWxPayClient.formatDateV3;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link WxNativePayClient} 的集成测试,用于快速调试微信扫码支付
|
* {@link WxNativePayClient} 的集成测试,用于快速调试微信扫码支付
|
@ -2,11 +2,11 @@ package cn.iocoder.yudao.module.pay.service.channel;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClientFactory;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.alipay.AlipayPayClientConfig;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.impl.weixin.WxPayClientConfig;
|
||||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO;
|
||||||
|
@ -2,11 +2,10 @@ package cn.iocoder.yudao.module.pay.service.order;
|
|||||||
|
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.enums.PayOrderDisplayModeEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum;
|
|
||||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest;
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest;
|
||||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO;
|
||||||
@ -515,7 +514,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
||||||
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
||||||
o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus()));
|
o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus()));
|
||||||
|
|
||||||
// 调用,并断言异常
|
// 调用,并断言异常
|
||||||
assertServiceException(() -> orderService.notifyOrder(channel, notify),
|
assertServiceException(() -> orderService.notifyOrder(channel, notify),
|
||||||
@ -532,7 +531,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
||||||
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
||||||
o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus())
|
o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())
|
||||||
.setOutTradeNo("P110"));
|
.setOutTradeNo("P110"));
|
||||||
|
|
||||||
// 调用,并断言异常
|
// 调用,并断言异常
|
||||||
@ -550,7 +549,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
||||||
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
||||||
o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus())
|
o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())
|
||||||
.setOutTradeNo("P110"));
|
.setOutTradeNo("P110"));
|
||||||
|
|
||||||
// 调用,并断言异常
|
// 调用,并断言异常
|
||||||
@ -583,7 +582,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
||||||
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
||||||
o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus())
|
o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())
|
||||||
.setOutTradeNo("P110"));
|
.setOutTradeNo("P110"));
|
||||||
|
|
||||||
// 调用,并断言异常
|
// 调用,并断言异常
|
||||||
@ -611,7 +610,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
||||||
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
||||||
o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus())
|
o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())
|
||||||
.setOutTradeNo("P110"));
|
.setOutTradeNo("P110"));
|
||||||
|
|
||||||
// 调用,并断言异常
|
// 调用,并断言异常
|
||||||
@ -641,7 +640,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L)
|
||||||
.setFeeRate(10D));
|
.setFeeRate(10D));
|
||||||
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
||||||
o -> o.setStatus(PayOrderStatusRespEnum.SUCCESS.getStatus())
|
o -> o.setStatus(PayOrderStatusEnum.SUCCESS.getStatus())
|
||||||
.setOutTradeNo("P110"));
|
.setOutTradeNo("P110"));
|
||||||
|
|
||||||
// 调用,并断言异常
|
// 调用,并断言异常
|
||||||
@ -669,7 +668,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
||||||
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
||||||
o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus()));
|
o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus()));
|
||||||
|
|
||||||
// 调用,并断言异常
|
// 调用,并断言异常
|
||||||
assertServiceException(() -> orderService.notifyOrder(channel, notify),
|
assertServiceException(() -> orderService.notifyOrder(channel, notify),
|
||||||
@ -686,7 +685,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
||||||
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
||||||
o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus())
|
o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus())
|
||||||
.setOutTradeNo("P110"));
|
.setOutTradeNo("P110"));
|
||||||
|
|
||||||
// 调用,并断言
|
// 调用,并断言
|
||||||
@ -705,7 +704,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
||||||
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
||||||
o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus())
|
o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus())
|
||||||
.setOutTradeNo("P110"));
|
.setOutTradeNo("P110"));
|
||||||
|
|
||||||
// 调用,并断言
|
// 调用,并断言
|
||||||
@ -724,7 +723,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
||||||
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
||||||
o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus())
|
o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus())
|
||||||
.setOutTradeNo("P110"));
|
.setOutTradeNo("P110"));
|
||||||
|
|
||||||
// 调用,并断言异常
|
// 调用,并断言异常
|
||||||
@ -742,7 +741,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L));
|
||||||
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
PayOrderRespDTO notify = randomPojo(PayOrderRespDTO.class,
|
||||||
o -> o.setStatus(PayOrderStatusRespEnum.CLOSED.getStatus())
|
o -> o.setStatus(PayOrderStatusEnum.CLOSED.getStatus())
|
||||||
.setOutTradeNo("P110"));
|
.setOutTradeNo("P110"));
|
||||||
|
|
||||||
// 调用
|
// 调用
|
||||||
|
@ -2,11 +2,10 @@ package cn.iocoder.yudao.module.pay.service.refund;
|
|||||||
|
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.module.pay.enums.PayChannelEnum;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum;
|
import cn.iocoder.yudao.module.pay.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
|
|
||||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest;
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbAndRedisUnitTest;
|
||||||
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO;
|
||||||
@ -464,7 +463,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
||||||
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
||||||
o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100"));
|
o -> o.setStatus(PayRefundStatusEnum.SUCCESS.getStatus()).setOutRefundNo("R100"));
|
||||||
|
|
||||||
// 调用,并断言异常
|
// 调用,并断言异常
|
||||||
assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO),
|
assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO),
|
||||||
@ -476,7 +475,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
||||||
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
||||||
o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100"));
|
o -> o.setStatus(PayRefundStatusEnum.SUCCESS.getStatus()).setOutRefundNo("R100"));
|
||||||
// mock 数据(refund + 已支付)
|
// mock 数据(refund + 已支付)
|
||||||
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
||||||
.setStatus(PayRefundStatusEnum.SUCCESS.getStatus()));
|
.setStatus(PayRefundStatusEnum.SUCCESS.getStatus()));
|
||||||
@ -493,7 +492,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
||||||
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
||||||
o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100"));
|
o -> o.setStatus(PayRefundStatusEnum.SUCCESS.getStatus()).setOutRefundNo("R100"));
|
||||||
// mock 数据(refund + 已支付)
|
// mock 数据(refund + 已支付)
|
||||||
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
||||||
.setStatus(PayRefundStatusEnum.FAILURE.getStatus()));
|
.setStatus(PayRefundStatusEnum.FAILURE.getStatus()));
|
||||||
@ -509,7 +508,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
||||||
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
||||||
o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100"));
|
o -> o.setStatus(PayRefundStatusEnum.SUCCESS.getStatus()).setOutRefundNo("R100"));
|
||||||
// mock 数据(refund + 已支付)
|
// mock 数据(refund + 已支付)
|
||||||
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
||||||
.setStatus(PayRefundStatusEnum.WAITING.getStatus())
|
.setStatus(PayRefundStatusEnum.WAITING.getStatus())
|
||||||
@ -530,7 +529,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
||||||
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
||||||
o -> o.setStatus(PayRefundStatusRespEnum.SUCCESS.getStatus()).setOutRefundNo("R100"));
|
o -> o.setStatus(PayRefundStatusEnum.SUCCESS.getStatus()).setOutRefundNo("R100"));
|
||||||
// mock 数据(refund + 已支付)
|
// mock 数据(refund + 已支付)
|
||||||
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
||||||
.setStatus(PayRefundStatusEnum.WAITING.getStatus())
|
.setStatus(PayRefundStatusEnum.WAITING.getStatus())
|
||||||
@ -557,7 +556,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
||||||
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
||||||
o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100"));
|
o -> o.setStatus(PayRefundStatusEnum.FAILURE.getStatus()).setOutRefundNo("R100"));
|
||||||
|
|
||||||
// 调用,并断言异常
|
// 调用,并断言异常
|
||||||
assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO),
|
assertServiceException(() -> refundService.notifyRefund(channel, refundRespDTO),
|
||||||
@ -569,7 +568,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
||||||
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
||||||
o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100"));
|
o -> o.setStatus(PayRefundStatusEnum.FAILURE.getStatus()).setOutRefundNo("R100"));
|
||||||
// mock 数据(refund + 退款失败)
|
// mock 数据(refund + 退款失败)
|
||||||
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
||||||
.setStatus(PayRefundStatusEnum.FAILURE.getStatus()));
|
.setStatus(PayRefundStatusEnum.FAILURE.getStatus()));
|
||||||
@ -586,7 +585,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
||||||
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
||||||
o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100"));
|
o -> o.setStatus(PayRefundStatusEnum.FAILURE.getStatus()).setOutRefundNo("R100"));
|
||||||
// mock 数据(refund + 已支付)
|
// mock 数据(refund + 已支付)
|
||||||
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
||||||
.setStatus(PayRefundStatusEnum.SUCCESS.getStatus()));
|
.setStatus(PayRefundStatusEnum.SUCCESS.getStatus()));
|
||||||
@ -602,7 +601,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
PayChannelDO channel = randomPojo(PayChannelDO.class, o -> o.setId(10L).setAppId(1L));
|
||||||
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
PayRefundRespDTO refundRespDTO = randomPojo(PayRefundRespDTO.class,
|
||||||
o -> o.setStatus(PayRefundStatusRespEnum.FAILURE.getStatus()).setOutRefundNo("R100"));
|
o -> o.setStatus(PayRefundStatusEnum.FAILURE.getStatus()).setOutRefundNo("R100"));
|
||||||
// mock 数据(refund + 已支付)
|
// mock 数据(refund + 已支付)
|
||||||
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
PayRefundDO refund = randomPojo(PayRefundDO.class, o -> o.setAppId(1L).setNo("R100")
|
||||||
.setStatus(PayRefundStatusEnum.WAITING.getStatus())
|
.setStatus(PayRefundStatusEnum.WAITING.getStatus())
|
||||||
@ -639,17 +638,17 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSyncRefund_waiting() {
|
public void testSyncRefund_waiting() {
|
||||||
assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusRespEnum.WAITING.getStatus()), 0);
|
assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusEnum.WAITING.getStatus()), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSyncRefund_success() {
|
public void testSyncRefund_success() {
|
||||||
assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusRespEnum.SUCCESS.getStatus()), 1);
|
assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusEnum.SUCCESS.getStatus()), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSyncRefund_failure() {
|
public void testSyncRefund_failure() {
|
||||||
assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusRespEnum.FAILURE.getStatus()), 1);
|
assertEquals(testSyncRefund_waitingOrSuccessOrFailure(PayRefundStatusEnum.FAILURE.getStatus()), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int testSyncRefund_waitingOrSuccessOrFailure(Integer status) {
|
private int testSyncRefund_waitingOrSuccessOrFailure(Integer status) {
|
||||||
|
@ -1,77 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-module-pay</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>yudao-spring-boot-starter-biz-pay</artifactId>
|
|
||||||
<name>${project.artifactId}</name>
|
|
||||||
<description>支付拓展,接入国内多个支付渠道
|
|
||||||
1. 支付宝,基于官方 SDK 接入
|
|
||||||
2. 微信支付,基于 weixin-java-pay 接入
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring 核心 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 工具类相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 三方云服务相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alipay.sdk</groupId>
|
|
||||||
<artifactId>alipay-sdk-java</artifactId>
|
|
||||||
<version>4.35.79.ALL</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.bouncycastle</groupId>
|
|
||||||
<artifactId>bcprov-jdk15on</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.binarywang</groupId>
|
|
||||||
<artifactId>weixin-java-pay</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Test 测试相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
|
||||||
<artifactId>yudao-spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
@ -1,22 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.config;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory;
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.PayClientFactoryImpl;
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付配置类
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@AutoConfiguration
|
|
||||||
public class YudaoPayAutoConfiguration {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public PayClientFactory payClientFactory() {
|
|
||||||
return new PayClientFactoryImpl();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.client.exception;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付系统异常 Exception
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class PayException extends RuntimeException {
|
|
||||||
|
|
||||||
public PayException(Throwable cause) {
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.enums.channel;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.NonePayClientConfig;
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig;
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig;
|
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付渠道的编码的枚举
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum PayChannelEnum {
|
|
||||||
|
|
||||||
WX_PUB("wx_pub", "微信 JSAPI 支付", WxPayClientConfig.class), // 公众号网页
|
|
||||||
WX_LITE("wx_lite", "微信小程序支付", WxPayClientConfig.class),
|
|
||||||
WX_APP("wx_app", "微信 App 支付", WxPayClientConfig.class),
|
|
||||||
WX_NATIVE("wx_native", "微信 Native 支付", WxPayClientConfig.class),
|
|
||||||
WX_WAP("wx_wap", "微信 Wap 网站支付", WxPayClientConfig.class), // H5 网页
|
|
||||||
WX_BAR("wx_bar", "微信付款码支付", WxPayClientConfig.class),
|
|
||||||
|
|
||||||
ALIPAY_PC("alipay_pc", "支付宝 PC 网站支付", AlipayPayClientConfig.class),
|
|
||||||
ALIPAY_WAP("alipay_wap", "支付宝 Wap 网站支付", AlipayPayClientConfig.class),
|
|
||||||
ALIPAY_APP("alipay_app", "支付宝App 支付", AlipayPayClientConfig.class),
|
|
||||||
ALIPAY_QR("alipay_qr", "支付宝扫码支付", AlipayPayClientConfig.class),
|
|
||||||
ALIPAY_BAR("alipay_bar", "支付宝条码支付", AlipayPayClientConfig.class),
|
|
||||||
MOCK("mock", "模拟支付", NonePayClientConfig.class),
|
|
||||||
|
|
||||||
WALLET("wallet", "钱包支付", NonePayClientConfig.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编码
|
|
||||||
*
|
|
||||||
* 参考 <a href="https://www.pingxx.com/api/支付渠道属性值.html">支付渠道属性值</a>
|
|
||||||
*/
|
|
||||||
private final String code;
|
|
||||||
/**
|
|
||||||
* 名字
|
|
||||||
*/
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置类
|
|
||||||
*/
|
|
||||||
private final Class<? extends PayClientConfig> configClass;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 微信支付
|
|
||||||
*/
|
|
||||||
public static final String WECHAT = "WECHAT";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付宝支付
|
|
||||||
*/
|
|
||||||
public static final String ALIPAY = "ALIPAY";
|
|
||||||
|
|
||||||
public static PayChannelEnum getByCode(String code) {
|
|
||||||
return ArrayUtil.firstMatch(o -> o.getCode().equals(code), values());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isAlipay(String channelCode) {
|
|
||||||
return channelCode != null && channelCode.startsWith("alipay");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.enums.order;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 渠道的支付状态枚举
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum PayOrderStatusRespEnum {
|
|
||||||
|
|
||||||
WAITING(0, "未支付"),
|
|
||||||
SUCCESS(10, "支付成功"),
|
|
||||||
REFUND(20, "已退款"),
|
|
||||||
CLOSED(30, "支付关闭"),
|
|
||||||
;
|
|
||||||
|
|
||||||
private final Integer status;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否支付成功
|
|
||||||
*
|
|
||||||
* @param status 状态
|
|
||||||
* @return 是否支付成功
|
|
||||||
*/
|
|
||||||
public static boolean isSuccess(Integer status) {
|
|
||||||
return Objects.equals(status, SUCCESS.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否已退款
|
|
||||||
*
|
|
||||||
* @param status 状态
|
|
||||||
* @return 是否支付成功
|
|
||||||
*/
|
|
||||||
public static boolean isRefund(Integer status) {
|
|
||||||
return Objects.equals(status, REFUND.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否支付关闭
|
|
||||||
*
|
|
||||||
* @param status 状态
|
|
||||||
* @return 是否支付关闭
|
|
||||||
*/
|
|
||||||
public static boolean isClosed(Integer status) {
|
|
||||||
return Objects.equals(status, CLOSED.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.enums.refund;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 渠道的退款状态枚举
|
|
||||||
*
|
|
||||||
* @author jason
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum PayRefundStatusRespEnum {
|
|
||||||
|
|
||||||
WAITING(0, "等待退款"),
|
|
||||||
SUCCESS(10, "退款成功"),
|
|
||||||
FAILURE(20, "退款失败");
|
|
||||||
|
|
||||||
private final Integer status;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public static boolean isSuccess(Integer status) {
|
|
||||||
return Objects.equals(status, SUCCESS.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isFailure(Integer status) {
|
|
||||||
return Objects.equals(status, FAILURE.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.pay.core.enums.transfer;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 渠道的转账状态枚举
|
|
||||||
*
|
|
||||||
* @author jason
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum PayTransferStatusRespEnum {
|
|
||||||
|
|
||||||
WAITING(0, "等待转账"),
|
|
||||||
PROCESSING(5, "转账进行中"),
|
|
||||||
SUCCESS(10, "转账成功"),
|
|
||||||
CLOSED(20, "转账关闭");
|
|
||||||
|
|
||||||
private final Integer status;
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public static boolean isSuccess(Integer status) {
|
|
||||||
return Objects.equals(status, SUCCESS.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isClosed(Integer status) {
|
|
||||||
return Objects.equals(status, CLOSED.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isProcessing(Integer status) {
|
|
||||||
return Objects.equals(status, PROCESSING.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
cn.iocoder.yudao.framework.pay.config.YudaoPayAutoConfiguration
|
|
Loading…
x
Reference in New Issue
Block a user