feat 支付/同步/修复流程联调, 支付宝支付同步逻辑优化

This commit is contained in:
nws
2024-01-03 22:41:33 +08:00
parent a9777203d0
commit d405eafb90
281 changed files with 1818 additions and 1265 deletions

View File

@@ -266,7 +266,7 @@ INSERT INTO `iam_perm_menu` VALUES (1584380679478779904, 'dax-pay', 158437960218
INSERT INTO `iam_perm_menu` VALUES (1584380824308097024, 'dax-pay', 1584379602188574720, '素材管理', 'WechatMediaList', NULL, b'0', '', b'0', b'0', '/modules/third/wechat/media/WechatMediaList.vue', NULL, '/third/wechat/media', '', 0, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2022-10-24 11:06:40', 1414143554414059520, '2022-10-27 16:38:47', 1, 0);
INSERT INTO `iam_perm_menu` VALUES (1584381134950834176, 'dax-pay', 1584379704122744832, '企微机器人', 'WeComRobotConfigList', NULL, b'0', '', b'0', b'0', '/modules/third/wecom/robot/WecomRobotConfigList.vue', NULL, '/third/wecom/robot', '', 0, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2022-10-24 11:07:54', 1414143554414059520, '2022-11-12 20:58:25', 3, 0);
INSERT INTO `iam_perm_menu` VALUES (1584381322184564736, 'dax-pay', 1584380087805091840, '钉钉机器人', 'DingRobotConfigList', NULL, b'0', '', b'0', b'0', '/modules/third/dingtalk/robot/DingRobotConfigList.vue', NULL, '/third/dingTalk/robot', '', 0, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2022-10-24 11:08:38', 1414143554414059520, '2022-11-12 20:58:37', 6, 0);
INSERT INTO `iam_perm_menu` VALUES (1584382569381830656, 'dax-pay', 1582276184120709120, '支付道菜单', 'PayChannel', NULL, b'0', '', b'1', b'1', 'Layout', NULL, '/payment/channel', '', 0, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2022-10-24 11:13:36', 1414143554414059520, '2023-06-15 20:09:59', 1, 0);
INSERT INTO `iam_perm_menu` VALUES (1584382569381830656, 'dax-pay', 1582276184120709120, '支付道菜单', 'PayChannel', NULL, b'0', '', b'1', b'1', 'Layout', NULL, '/payment/channel', '', 0, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2022-10-24 11:13:36', 1414143554414059520, '2023-06-15 20:09:59', 1, 0);
INSERT INTO `iam_perm_menu` VALUES (1584382723186958336, 'dax-pay', NULL, '支付订单', 'PayOrder', NULL, b'0', 'ant-design:copy-filled', b'0', b'0', 'Layout', NULL, '/payment/order', '', 0, 0, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2022-10-24 11:14:12', 1414143554414059520, '2023-07-11 09:07:48', 1, 0);
INSERT INTO `iam_perm_menu` VALUES (1584382815407120384, 'dax-pay', NULL, '通知记录', 'PayNotify', NULL, b'0', 'ant-design:delete-row-outlined', b'0', b'0', 'Layout', NULL, '/payment/notify', '', 0, 0, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2022-10-24 11:14:34', 1414143554414059520, '2023-07-17 09:35:16', 4, 0);
INSERT INTO `iam_perm_menu` VALUES (1584383492338425856, 'dax-pay', 1582276184120709120, '钱包管理', 'Wallet', NULL, b'0', '', b'0', b'0', 'Layout', NULL, '/payment/wallet', '', 0, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2022-10-24 11:17:16', 1414143554414059520, '2022-10-24 11:17:16', 0, 0);
@@ -287,7 +287,7 @@ INSERT INTO `iam_perm_menu` VALUES (1623494586215579648, 'dax-pay', 155220798251
INSERT INTO `iam_perm_menu` VALUES (1635274568758435840, 'dax-pay', 1582276341792985088, 'SQL查询语句', 'QuerySqlList', NULL, b'0', '', b'0', b'0', '/modules/develop/query/QuerySqlList', NULL, '/develop/querySql', '', 0, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2023-03-13 21:40:14', 1414143554414059520, '2023-03-13 21:43:05', 2, 0);
INSERT INTO `iam_perm_menu` VALUES (1660185276763594752, 'dax-pay', 1582276184120709120, '商户管理', 'Merchant', NULL, b'0', '', b'0', b'0', '/modules/payment/merchant/MerchantInfoList', NULL, '/payment/merchant', '', -99, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2023-05-21 15:26:29', 1414143554414059520, '2023-05-21 15:27:58', 3, 0);
INSERT INTO `iam_perm_menu` VALUES (1660247003681181696, 'dax-pay', 1582276184120709120, '商户应用', 'MchApplicationList', NULL, b'0', '', b'0', b'0', '/modules/payment/app/MchApplicationList', NULL, '/payment/mch/app', '', -99, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2023-05-21 19:31:46', 1414143554414059520, '2023-05-23 10:28:42', 2, 0);
INSERT INTO `iam_perm_menu` VALUES (1661556612357128192, 'dax-pay', 1582276184120709120, '支付', 'ChannelConfig', NULL, b'0', '', b'0', b'0', '/modules/payment/channel/config/PayChannelConfigList', NULL, '/payment/channel/config', '', -99, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2023-05-25 10:15:41', 1414143554414059520, '2023-06-15 20:10:14', 3, 0);
INSERT INTO `iam_perm_menu` VALUES (1661556612357128192, 'dax-pay', 1582276184120709120, '支付', 'ChannelConfig', NULL, b'0', '', b'0', b'0', '/modules/payment/channel/config/PayChannelConfigList', NULL, '/payment/channel/config', '', -99, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2023-05-25 10:15:41', 1414143554414059520, '2023-06-15 20:10:14', 3, 0);
INSERT INTO `iam_perm_menu` VALUES (1670605512011345920, 'dax-pay', NULL, '演示实例', 'PayDemo', NULL, b'0', 'ant-design:gateway-outlined', b'0', b'0', 'Layout', NULL, '/payment/demo', '', 0, 0, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2023-06-19 09:32:47', 1414143554414059520, '2023-07-11 09:10:21', 2, 0);
INSERT INTO `iam_perm_menu` VALUES (1670605893923696640, 'dax-pay', 1670605512011345920, '结算台支付演示', 'cashierDemo', NULL, b'0', '', b'0', b'0', '', NULL, 'outside:///cashier', '', 0, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2023-06-19 09:34:18', 1414143554414059520, '2023-06-19 09:34:18', 0, 0);
INSERT INTO `iam_perm_menu` VALUES (1670987342170497024, 'dax-pay', 1670605512011345920, '简单支付', 'SimpleCashier', NULL, b'0', '', b'0', b'0', '/demo/payment/cashier/SimpleCashier', NULL, '/payment/demo/SimpleCashier', '', 0, 1, NULL, b'1', b'0', b'0', b'0', NULL, 1414143554414059520, '2023-06-20 10:50:02', 1414143554414059520, '2023-06-20 10:59:01', 1, 0);
@@ -329,10 +329,10 @@ INSERT INTO `base_dict` VALUES (1439961232651034624, 'MessageTemplateCode', '消
INSERT INTO `base_dict` VALUES (1452836604783845376, 'SocialType', '三方系统类型', b'1', '系统属性', '三方系统类型', 1399985191002447872, '2021-10-26 11:16:54', 1399985191002447872, '2022-05-11 19:48:28', 0, 3);
INSERT INTO `base_dict` VALUES (1452843488735621120, 'ParamType', '参数类型', b'1', '系统属性', '参数类型', 1399985191002447872, '2021-10-26 11:44:15', 1399985191002447872, '2022-05-11 19:48:21', 0, 2);
INSERT INTO `base_dict` VALUES (1496024933900169216, 'Political', '政治面貌', b'1', '基础数据', '政治面貌', 1399985191002447872, '2022-02-22 15:31:54', 1399985191002447872, '2022-05-11 19:48:04', 0, 1);
INSERT INTO `base_dict` VALUES (1496722894707728384, 'PayChannel', '支付', b'1', '支付服务', '支付宝, 微信, 云闪付等', 1399985191002447872, '2022-02-24 13:45:21', 1399985191002447872, '2022-05-11 19:47:51', 0, 1);
INSERT INTO `base_dict` VALUES (1496722894707728384, 'PayChannel', '支付', b'1', '支付服务', '支付宝, 微信, 云闪付等', 1399985191002447872, '2022-02-24 13:45:21', 1399985191002447872, '2022-05-11 19:47:51', 0, 1);
INSERT INTO `base_dict` VALUES (1496723207565058048, 'PayWay', '支付方式', b'1', '支付服务', '扫码支付、Wap、App支付等', 1399985191002447872, '2022-02-24 13:46:35', 1399985191002447872, '2022-05-11 19:47:46', 0, 1);
INSERT INTO `base_dict` VALUES (1497140849954185216, 'PayStatus', '支付状态', b'1', '支付服务', '支付中,成功,失败等', 1399985191002447872, '2022-02-25 17:26:09', 1399985191002447872, '2022-05-11 19:47:40', 0, 2);
INSERT INTO `base_dict` VALUES (1501031423232937984, 'AsyncPayChannel', '异步支付', b'1', '支付服务', '如微信支付宝云闪付等第三方支付', 1399985191002447872, '2022-03-08 11:05:54', 1399985191002447872, '2022-05-11 19:47:37', 0, 1);
INSERT INTO `base_dict` VALUES (1501031423232937984, 'AsyncPayChannel', '异步支付', b'1', '支付服务', '如微信支付宝云闪付等第三方支付', 1399985191002447872, '2022-03-08 11:05:54', 1399985191002447872, '2022-05-11 19:47:37', 0, 1);
INSERT INTO `base_dict` VALUES (1502276739978473472, 'WalletStatus', '钱包状态', b'1', '支付服务', '钱包状态', 1399985191002447872, '2022-03-11 21:34:20', 1399985191002447872, '2022-05-11 19:47:33', 0, 2);
INSERT INTO `base_dict` VALUES (1502624515799085056, 'WalletLogType', '钱包日志类型', b'1', '支付服务', '钱包日志类型', 1399985191002447872, '2022-03-12 20:36:17', 1399985191002447872, '2022-05-11 19:47:29', 0, 1);
INSERT INTO `base_dict` VALUES (1502624632392347648, 'WalletLogOperation', '钱包日志操作类型', b'1', '支付服务', '钱包日志操作类型', 1399985191002447872, '2022-03-12 20:36:44', 1399985191002447872, '2022-05-11 19:47:21', 0, 1);
@@ -434,7 +434,7 @@ CREATE TABLE `pay_channel_config` (
`version` int(11) NOT NULL COMMENT '乐观锁',
`deleted` bit(1) NOT NULL COMMENT '删除标志',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支付道配置' ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '支付道配置' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of pay_channel_config
@@ -1507,7 +1507,7 @@ CREATE TABLE `pay_sync_record` (
`payment_id` bigint(20) NULL DEFAULT NULL COMMENT '支付记录id',
`mch_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户编码',
`mch_app_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户应用编码',
`pay_channel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付',
`pay_channel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付',
`sync_info` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '通知消息',
`status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '同步状态',
`sync_time` datetime(0) NULL DEFAULT NULL COMMENT '同步时间',
@@ -1565,12 +1565,12 @@ CREATE TABLE `pay_payment` (
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标题',
`description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述',
`async_pay_mode` bit(1) NULL DEFAULT NULL COMMENT '是否是异步支付',
`async_pay_channel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '异步支付',
`async_pay_channel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '异步支付',
`amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '金额',
`refundable_balance` decimal(10, 2) NULL DEFAULT NULL COMMENT '可退款余额',
`error_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '错误码',
`error_msg` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '错误信息',
`pay_channel_info` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '支付道信息列表',
`pay_channel_info` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '支付道信息列表',
`refundable_info` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '退款信息列表',
`pay_status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付状态',
`pay_time` datetime(0) NULL DEFAULT NULL COMMENT '支付时间',
@@ -1622,7 +1622,7 @@ CREATE TABLE `pay_pay_notify_record` (
`id` bigint(20) NOT NULL COMMENT '主键',
`payment_id` bigint(20) NULL DEFAULT NULL COMMENT '支付记录id',
`notify_info` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '通知消息',
`pay_channel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付',
`pay_channel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付',
`status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '处理状态',
`msg` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '提示信息',
`notify_time` datetime(0) NULL DEFAULT NULL COMMENT '回调时间',
@@ -1676,7 +1676,7 @@ DROP TABLE IF EXISTS `pay_mch_app_config`;
CREATE TABLE `pay_mch_app_config` (
`id` bigint(20) NOT NULL COMMENT '主键',
`config_id` bigint(20) NULL DEFAULT NULL COMMENT '关联配置ID',
`channel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付道编码',
`channel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '支付道编码',
`state` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '状态',
`creator` bigint(20) NULL DEFAULT NULL COMMENT '创建者ID',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',

View File

@@ -1,20 +1,29 @@
2.0.0
- x 参数签名机制
- x 开放接口供第三方调用
- 增加回调机制
- 增加消息通知机制
- 支付超时取消支付单
- 新增支付单预警功能, 处理支付单与网关状态不一致且无法自动修复的情况
- 记录支付修复单的情况, 主要分为自动修复, 人工介入
- 已经完成的
- 参数签名和验签机制
- 开放接口供第三方调用
- 将零散的上下文对象进行抽取为统一的上下文对象
- 拆分原有的策略类,实现粒度更细
- 去除用户概念,作为独立的支付网关使用, 不与其他系统产生耦合性
- 2023-12-31:
- 支付关闭相关逻辑
- 各支付通道补充相关未实现的逻辑
- 支付订单修复逻辑, 用于回调和支付同步后不一致的情况处理
- 2024-01-01:
- 支付订单修复逻辑, 用于回调和支付同步后不一致的情况处理
- 2024-01-02:
- 2024-01-02:
- 添加管理端的各类`Controller`
- x 支持定时同步支付中订单状态, 借助订单超时任务
- 订单取消/修复/取消/同步添加分布式锁, 防止操作订单时出现重复操作
- **任务池**
- 支付配置支持数据库配置和配置文件配置
- 支付订单的各类操作接入订单超时任务处理
- 超时任务处理支持轮训表+Redis过期事件
- 支持定时同步支付中订单状态, 借助订单超时任务
- 订单取消/修复/取消/同步添加分布式锁, 防止操作订单时出现重复操作
- 增加回调机制
- 增加消息通知机制
- 新增支付单预警功能, 处理支付单与网关状态不一致且无法自动修复的情况
- 记录支付修复单的情况, 主要分为自动修复, 人工介入
- 支付平台全局性配置
- 微信消息通知相关配置
- 钉钉消息通知配置
-

View File

@@ -3,9 +3,9 @@ package cn.bootx.platform.daxpay.admin.controller.channel;
import cn.bootx.platform.common.core.rest.Res;
import cn.bootx.platform.common.core.rest.ResResult;
import cn.bootx.platform.common.core.rest.dto.LabelValue;
import cn.bootx.platform.daxpay.core.channel.alipay.service.AliPayConfigService;
import cn.bootx.platform.daxpay.dto.channel.alipay.AliPayConfigDto;
import cn.bootx.platform.daxpay.param.channel.alipay.AliPayConfigParam;
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayConfigService;
import cn.bootx.platform.daxpay.service.dto.channel.alipay.AliPayConfigDto;
import cn.bootx.platform.daxpay.service.param.channel.alipay.AliPayConfigParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
@@ -28,6 +28,12 @@ public class AlipayConfigController {
private final AliPayConfigService alipayConfigService;
@Operation(summary = "获取配置")
@GetMapping("/getConfig")
public ResResult<AliPayConfigDto> getConfig() {
return Res.ok(alipayConfigService.getConfig().toDto());
}
@Operation(summary = "更新")
@PostMapping("/update")
public ResResult<Void> update(@RequestBody AliPayConfigParam param) {
@@ -35,12 +41,6 @@ public class AlipayConfigController {
return Res.ok();
}
@Operation(summary = "获取配置")
@GetMapping("/getConfig")
public ResResult<AliPayConfigDto> getConfig() {
return Res.ok(alipayConfigService.getConfig().toDto());
}
@Operation(summary = "支付宝支持支付方式")
@GetMapping("/findPayWays")
public ResResult<List<LabelValue>> findPayWays() {

View File

@@ -3,9 +3,9 @@ package cn.bootx.platform.daxpay.admin.controller.channel;
import cn.bootx.platform.common.core.rest.Res;
import cn.bootx.platform.common.core.rest.ResResult;
import cn.bootx.platform.common.core.rest.dto.LabelValue;
import cn.bootx.platform.daxpay.core.channel.wechat.service.WeChatPayConfigService;
import cn.bootx.platform.daxpay.dto.channel.wechat.WeChatPayConfigDto;
import cn.bootx.platform.daxpay.param.channel.wechat.WeChatPayConfigParam;
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayConfigService;
import cn.bootx.platform.daxpay.service.dto.channel.wechat.WeChatPayConfigDto;
import cn.bootx.platform.daxpay.service.param.channel.wechat.WeChatPayConfigParam;
import cn.hutool.core.codec.Base64;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -28,19 +28,18 @@ public class WeChatPayConfigController {
private final WeChatPayConfigService weChatPayConfigService;
@Operation(summary = "更新")
@PostMapping("/update")
public ResResult<Void> update(@RequestBody WeChatPayConfigParam param) {
weChatPayConfigService.update(param);
return Res.ok();
}
@Operation(summary = "获取配置")
@GetMapping("/getConfig")
public ResResult<WeChatPayConfigDto> getConfig() {
return Res.ok(weChatPayConfigService.getConfig().toDto());
}
@Operation(summary = "更新")
@PostMapping("/update")
public ResResult<Void> update(@RequestBody WeChatPayConfigParam param) {
weChatPayConfigService.update(param);
return Res.ok();
}
@Operation(summary = "微信支持支付方式")
@GetMapping("/findPayWays")
public ResResult<List<LabelValue>> findPayWays() {

View File

@@ -0,0 +1,43 @@
package cn.bootx.platform.daxpay.admin.controller.system;
import cn.bootx.platform.common.core.rest.Res;
import cn.bootx.platform.common.core.rest.ResResult;
import cn.bootx.platform.daxpay.service.core.system.service.PayApiConfigService;
import cn.bootx.platform.daxpay.service.dto.system.PayApiConfigDto;
import cn.bootx.platform.daxpay.service.param.system.PayApiConfigParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 支付接口配置
* @author xxm
* @since 2024/1/2
*/
@Tag(name = "支付接口配置")
@RestController
@RequestMapping("/pay/api/config")
@RequiredArgsConstructor
public class PayApiConfigController {
private final PayApiConfigService payApiConfigService;
@Operation(summary = "根据ID获取")
@GetMapping("/findById")
public ResResult<PayApiConfigDto> findById(Long id){
return Res.ok(payApiConfigService.findById(id));
}
@Operation(summary = "获取全部")
@GetMapping("/findAll")
public ResResult<List<PayApiConfigDto>> findAll(){
return Res.ok(payApiConfigService.findAll());
}
@Operation(summary = "更新")
@PostMapping("/update")
public ResResult<Void> update(@RequestBody PayApiConfigParam param){
payApiConfigService.update(param);
return Res.ok();
}
}

View File

@@ -0,0 +1,37 @@
package cn.bootx.platform.daxpay.admin.controller.system;
import cn.bootx.platform.common.core.rest.Res;
import cn.bootx.platform.common.core.rest.ResResult;
import cn.bootx.platform.daxpay.service.core.system.service.PlatformConfigService;
import cn.bootx.platform.daxpay.service.dto.system.PlatformConfigDto;
import cn.bootx.platform.daxpay.service.param.system.PlatformConfigParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
/**
* 平台配置项
* @author xxm
* @since 2024/1/2
*/
@Tag(name = "平台配置项")
@RestController
@RequestMapping("/platform/config")
@RequiredArgsConstructor
public class PlatformConfigController {
private final PlatformConfigService platformConfigService;
@Operation(summary = "平台配置项")
@GetMapping("/getConfig")
public ResResult<PlatformConfigDto> getConfig(){
return Res.ok(platformConfigService.getConfig().toDto());
}
@Operation(summary = "更新平台配置项")
@PostMapping("/update")
public ResResult<Void> update(@RequestBody PlatformConfigParam param){
platformConfigService.update(param);
return Res.ok();
}
}

View File

@@ -0,0 +1,37 @@
package cn.bootx.platform.daxpay.admin.controller.system;
import cn.bootx.platform.common.core.rest.Res;
import cn.bootx.platform.common.core.rest.ResResult;
import cn.bootx.platform.daxpay.service.core.system.service.WechatNoticeConfigService;
import cn.bootx.platform.daxpay.service.dto.system.WechatNoticeConfigDto;
import cn.bootx.platform.daxpay.service.param.system.WechatNoticeConfigParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
/**
* 微信消息通知配置
* @author xxm
* @since 2024/1/2
*/
@Tag(name = "微信消息通知配置")
@RestController
@RequestMapping("/wx/notice")
@RequiredArgsConstructor
public class WechatNoticeConfigController {
private final WechatNoticeConfigService configService;
@Operation(summary = "获取微信消息通知配置")
@GetMapping("/getConfig")
public ResResult<WechatNoticeConfigDto> getConfig() {
return Res.ok(configService.getConfig().toDto());
}
@Operation(summary = "更新微信消息通知配置")
@PostMapping("/update")
public ResResult<Void> update(@RequestBody WechatNoticeConfigParam param) {
configService.update(param);
return Res.ok();
}
}

View File

@@ -1 +1 @@
cn.bootx.platform.daxpay.DaxPaySingleAdminApp
cn.bootx.platform.daxpay.admin.DaxPaySingleAdminApp

View File

@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.bootx.platform</groupId>
<artifactId>dax-pay</artifactId>
<artifactId>daxpay-single</artifactId>
<version>2.0.0</version>
</parent>

View File

@@ -39,7 +39,7 @@ public enum PayChannelEnum {
return Arrays.stream(values())
.filter(e -> Objects.equals(code, e.getCode()))
.findFirst()
.orElseThrow(() -> new PayFailureException("不存在的支付"));
.orElseThrow(() -> new PayFailureException("不存在的支付"));
}
/** 支付宝 UA */

View File

@@ -17,7 +17,6 @@ public enum PayStatusEnum {
FAIL("fail","失败"),
CANCEL("cancel","支付取消"),
CLOSE("close","支付关闭"),
/** 超时取消 */
TIMEOUT("timeout","超时取消"),
PARTIAL_REFUND("partial_refund","部分退款"),
REFUNDED("refunded","全部退款");

View File

@@ -23,6 +23,10 @@ public enum PaySyncStatusEnum {
CLOSED("closed", "已关闭"),
REFUND("refund", "已退款"),
NOT_FOUND("not_found", "未查询到订单"),
/** 例如支付宝支付后, 客户未进行操作, 将不会创建出订单, 所以同步会返回未查询到订单 */
IGNORE("ignore", "忽略"),
/** 本地订单到了超时时间, 但是网关和本地都未关闭, 需要触发关闭相关处理 */
TIMEOUT("timeout", "超时未关闭"),
FAIL("fail", "查询失败");
/** 编码 */

View File

@@ -1,7 +1,7 @@
package cn.bootx.platform.daxpay.param.pay;
import cn.bootx.platform.daxpay.serializer.TimestampToLocalDateTimeDeserializer;
import cn.bootx.platform.daxpay.util.PayUtil;
import cn.bootx.platform.daxpay.service.util.PayUtil;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@@ -25,8 +25,8 @@ public class PayWayParam {
/**
* @see PayChannelEnum#getCode()
*/
@Schema(description = "支付道编码")
@NotBlank(message = "支付道编码不可为空")
@Schema(description = "支付道编码")
@NotBlank(message = "支付道编码不可为空")
private String channel;
/**

View File

@@ -12,6 +12,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
@@ -47,8 +48,8 @@ public class SimplePayParam extends PayCommonParam{
/**
* @see PayChannelEnum#getCode()
*/
@Schema(description = "支付道编码")
@NotBlank(message = "支付道编码不可为空")
@Schema(description = "支付道编码")
@NotBlank(message = "支付道编码不可为空")
private String payChannel;
/**
@@ -60,6 +61,7 @@ public class SimplePayParam extends PayCommonParam{
@Schema(description = "支付金额")
@NotNull(message = "支付金额不可为空")
@Min(1)
private Integer amount;
/**

View File

@@ -1,7 +1,9 @@
package cn.bootx.platform.daxpay.result.pay;
import cn.bootx.platform.common.core.code.CommonCode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.slf4j.MDC;
/**
* 支付通用返回参数
@@ -9,11 +11,11 @@ import lombok.Data;
* @since 2023/12/25
*/
@Data
@Schema(title = "")
@Schema(title = "支付通用返回参数")
public class PayCommonResult {
@Schema(description = "请求ID")
private String reqId;
private String reqId = MDC.get(CommonCode.TRACE_ID);
@Schema(description = "商户扩展参数,回调时会原样返回")
private String extraParam;

View File

@@ -18,12 +18,12 @@ public class PayResult {
private Long paymentId;
@Schema(description = "是否是异步支付")
private boolean asyncPayMode;
private boolean asyncPay;
/**
* @see PayChannelEnum#ASYNC_TYPE_CODE
*/
@Schema(description = "异步支付")
@Schema(description = "异步支付")
private String asyncPayChannel;

View File

@@ -1,7 +1,7 @@
package cn.bootx.platform.daxpay.serializer;
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
import com.fasterxml.jackson.core.JacksonException;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
@@ -17,8 +17,12 @@ import java.time.LocalDateTime;
public class TimestampToLocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {
@Override
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException {
long timestamp = p.getLongValue();
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
String value = p.getValueAsString();
if (StrUtil.isBlank(value)){
return null;
}
long timestamp = Long.parseLong(value);
return LocalDateTimeUtil.of(timestamp);
}
}

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.util;
package cn.bootx.platform.daxpay.service.util;
import cn.bootx.platform.daxpay.result.DaxResult;
import lombok.experimental.UtilityClass;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.util;
package cn.bootx.platform.daxpay.service.util;
import cn.bootx.platform.common.core.util.LocalDateTimeUtil;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
@@ -92,16 +92,16 @@ public class PayUtil {
/**
* 检查异步支付方式
*/
public void validationAsyncPayMode(PayParam payParam) {
public void validationAsyncPay(PayParam payParam) {
// 组合支付时只允许有一个异步支付方式
List<PayWayParam> payModeList = payParam.getPayWays();
long asyncPayModeCount = payModeList.stream()
long asyncPayCount = payModeList.stream()
.map(PayWayParam::getChannel)
.map(PayChannelEnum::findByCode)
.filter(PayChannelEnum.ASYNC_TYPE::contains)
.count();
if (asyncPayModeCount > 1) {
if (asyncPayCount > 1) {
throw new PayFailureException("组合支付时只允许有一个异步支付方式");
}
}

View File

@@ -1,8 +1,8 @@
package cn.bootx.platform.daxpay.gateway.controller;
import cn.bootx.platform.common.core.annotation.IgnoreAuth;
import cn.bootx.platform.daxpay.core.channel.alipay.service.AliPayCallbackService;
import cn.bootx.platform.daxpay.core.channel.wechat.service.WeChatPayCallbackService;
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayCallbackService;
import cn.bootx.platform.daxpay.service.core.channel.wechat.service.WeChatPayCallbackService;
import com.ijpay.alipay.AliPayApi;
import com.ijpay.core.kit.HttpKit;
import com.ijpay.core.kit.WxPayKit;

View File

@@ -1,17 +1,18 @@
package cn.bootx.platform.daxpay.gateway.controller;
import cn.bootx.platform.common.core.annotation.CountTime;
import cn.bootx.platform.common.core.annotation.IgnoreAuth;
import cn.bootx.platform.daxpay.annotation.PaymentApi;
import cn.bootx.platform.daxpay.core.payment.close.service.PayCloseService;
import cn.bootx.platform.daxpay.core.payment.pay.service.PayService;
import cn.bootx.platform.daxpay.core.payment.refund.service.PayRefundService;
import cn.bootx.platform.daxpay.core.payment.sync.service.PaySyncService;
import cn.bootx.platform.daxpay.service.annotation.PaymentApi;
import cn.bootx.platform.daxpay.service.core.payment.close.service.PayCloseService;
import cn.bootx.platform.daxpay.service.core.payment.pay.service.PayService;
import cn.bootx.platform.daxpay.service.core.payment.refund.service.PayRefundService;
import cn.bootx.platform.daxpay.service.core.payment.sync.service.PaySyncService;
import cn.bootx.platform.daxpay.param.pay.*;
import cn.bootx.platform.daxpay.result.DaxResult;
import cn.bootx.platform.daxpay.result.pay.PayResult;
import cn.bootx.platform.daxpay.result.pay.PaySyncResult;
import cn.bootx.platform.daxpay.result.pay.RefundResult;
import cn.bootx.platform.daxpay.util.DaxRes;
import cn.bootx.platform.daxpay.service.util.DaxRes;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
@@ -36,6 +37,8 @@ public class UniPayController {
private final PaySyncService paySyncService;
private final PayCloseService payCloseService;
@CountTime
@PaymentApi("pay")
@Operation(summary = "统一下单")
@PostMapping("/pay")
@@ -43,6 +46,7 @@ public class UniPayController {
return DaxRes.ok(payService.pay(payParam));
}
@CountTime
@PaymentApi("simplePay")
@Operation(summary = "简单下单")
@PostMapping("/simplePay")
@@ -50,6 +54,7 @@ public class UniPayController {
return DaxRes.ok(payService.simplePay(payParam));
}
@CountTime
@PaymentApi("close")
@Operation(summary = "订单关闭")
@PostMapping("/close")
@@ -58,6 +63,7 @@ public class UniPayController {
return DaxRes.ok();
}
@CountTime
@PaymentApi("refund")
@Operation(summary = "统一退款")
@PostMapping("/refund")
@@ -65,6 +71,7 @@ public class UniPayController {
return DaxRes.ok(payRefundService.refund(param));
}
@CountTime
@PaymentApi("simpleRefund")
@Operation(summary = "简单退款")
@PostMapping("/simpleRefund")
@@ -72,13 +79,15 @@ public class UniPayController {
return DaxRes.ok(payRefundService.simpleRefund(param));
}
@CountTime
@PaymentApi("syncPay")
@Operation(summary = "支付状态同步")
@PostMapping("/syncPay")
public DaxResult<PaySyncResult> syncPay(PaySyncParam param){
public DaxResult<PaySyncResult> syncPay(@RequestBody PaySyncParam param){
return DaxRes.ok(paySyncService.sync(param));
}
@CountTime
@PaymentApi("syncRefund")
@Operation(summary = "退款状态同步")
@PostMapping("/syncRefund")

View File

@@ -1 +1 @@
cn.bootx.platform.daxpay.DaxpaySingleGatewayApp
cn.bootx.platform.daxpay.gateway.DaxpaySingleGatewayApp

View File

@@ -36,7 +36,7 @@
<!-- 自动建表 -->
<dependency>
<groupId>cn.bootx</groupId>
<artifactId>table-modify-mysql</artifactId>
<artifactId>table-modify-mysql-boot-starter</artifactId>
<version>${table-modify.version}</version>
</dependency>
<!-- redis客户端封装 -->

View File

@@ -1,26 +0,0 @@
package cn.bootx.platform.daxpay.core.channel.alipay.convert;
import cn.bootx.platform.daxpay.core.channel.alipay.entity.AliPayConfig;
import cn.bootx.platform.daxpay.dto.channel.alipay.AliPayConfigDto;
import cn.bootx.platform.daxpay.param.channel.alipay.AliPayConfigParam;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 支付宝转换
*
* @author xxm
* @since 2021/7/5
*/
@Mapper
public interface AlipayConvert {
AlipayConvert CONVERT = Mappers.getMapper(AlipayConvert.class);
AliPayConfig convert(AliPayConfigDto in);
AliPayConfig convert(AliPayConfigParam in);
AliPayConfigDto convert(AliPayConfig in);
}

View File

@@ -1,27 +0,0 @@
package cn.bootx.platform.daxpay.core.channel.voucher.convert;
import cn.bootx.platform.daxpay.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.core.channel.voucher.entity.VoucherLog;
import cn.bootx.platform.daxpay.core.channel.voucher.entity.VoucherPayOrder;
import cn.bootx.platform.daxpay.dto.channel.voucher.VoucherDto;
import cn.bootx.platform.daxpay.dto.channel.voucher.VoucherLogDto;
import cn.bootx.platform.daxpay.dto.channel.voucher.VoucherPayOrderDto;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* @author xxm
* @since 2022/3/14
*/
@Mapper
public interface VoucherConvert {
VoucherConvert CONVERT = Mappers.getMapper(VoucherConvert.class);
VoucherDto convert(Voucher in);
VoucherLogDto convert(VoucherLog in);
VoucherPayOrderDto convert(VoucherPayOrder in);
}

View File

@@ -1,36 +0,0 @@
package cn.bootx.platform.daxpay.core.channel.wallet.convert;
import cn.bootx.platform.daxpay.core.channel.wallet.entity.Wallet;
import cn.bootx.platform.daxpay.core.channel.wallet.entity.WalletConfig;
import cn.bootx.platform.daxpay.core.channel.wallet.entity.WalletLog;
import cn.bootx.platform.daxpay.core.channel.wallet.entity.WalletPayOrder;
import cn.bootx.platform.daxpay.dto.channel.wallet.WalletConfigDto;
import cn.bootx.platform.daxpay.dto.channel.wallet.WalletDto;
import cn.bootx.platform.daxpay.dto.channel.wallet.WalletLogDto;
import cn.bootx.platform.daxpay.dto.channel.wallet.WalletPayOrderDto;
import cn.bootx.platform.daxpay.param.channel.wechat.WalletConfigParam;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 转换
*
* @author xxm
* @since 2021/8/20
*/
@Mapper
public interface WalletConvert {
WalletConvert CONVERT = Mappers.getMapper(WalletConvert.class);
WalletDto convert(Wallet in);
WalletPayOrderDto convert(WalletPayOrder in);
WalletLogDto convert(WalletLog in);
WalletConfigDto convert(WalletConfig in);
WalletConfig convert(WalletConfigParam in);
}

View File

@@ -1,30 +0,0 @@
package cn.bootx.platform.daxpay.core.channel.wechat.convert;
import cn.bootx.platform.daxpay.core.channel.wechat.entity.WeChatPayConfig;
import cn.bootx.platform.daxpay.core.channel.wechat.entity.WeChatPayOrder;
import cn.bootx.platform.daxpay.dto.channel.wechat.WeChatPayConfigDto;
import cn.bootx.platform.daxpay.dto.channel.wechat.WeChatPayOrderDto;
import cn.bootx.platform.daxpay.param.channel.wechat.WeChatPayConfigParam;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 微信转换类
*
* @author xxm
* @since 2021/6/21
*/
@Mapper
public interface WeChatConvert {
WeChatConvert CONVERT = Mappers.getMapper(WeChatConvert.class);
WeChatPayConfig convert(WeChatPayConfigParam in);
WeChatPayConfigDto convert(WeChatPayConfig in);
WeChatPayOrderDto convert(WeChatPayOrder in);
WeChatPayOrder convert(WeChatPayOrderDto in);
}

View File

@@ -1,18 +0,0 @@
package cn.bootx.platform.daxpay.core.openapi.convert;
import cn.bootx.platform.daxpay.core.openapi.entity.PayOpenApi;
import cn.bootx.platform.daxpay.param.openapi.PayOpenApiInfoParam;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 开放接口信息转换
* @author xxm
* @since 2023/12/22
*/
@Mapper
public interface PayOpenApiInfoConvert {
PayOpenApiInfoConvert CONVERT = Mappers.getMapper(PayOpenApiInfoConvert.class);
PayOpenApi convert(PayOpenApiInfoParam in);
}

View File

@@ -1,35 +0,0 @@
package cn.bootx.platform.daxpay.core.openapi.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.daxpay.core.openapi.entity.PayOpenApi;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import java.util.Optional;
/**
* 支付开放接口管理
* @author xxm
* @since 2023/12/22
*/
@Slf4j
@Repository
@RequiredArgsConstructor
public class PayOpenApiManager extends BaseManager<PayOpenApiMapper, PayOpenApi> {
/**
* 根据code查询
*/
public Optional<PayOpenApi> findByCode(String code){
return findByField(PayOpenApi::getCode,code);
}
/**
* 根据api查询
*/
public Optional<PayOpenApi> findByApi(String api){
return findByField(PayOpenApi::getApi,api);
}
}

View File

@@ -1,14 +0,0 @@
package cn.bootx.platform.daxpay.core.openapi.dao;
import cn.bootx.platform.daxpay.core.openapi.entity.PayOpenApi;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 开放接口信息
* @author xxm
* @since 2023/12/22
*/
@Mapper
public interface PayOpenApiMapper extends BaseMapper<PayOpenApi> {
}

View File

@@ -1,60 +0,0 @@
package cn.bootx.platform.daxpay.core.openapi.service;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.daxpay.common.context.ApiInfoLocal;
import cn.bootx.platform.daxpay.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.core.openapi.dao.PayOpenApiManager;
import cn.bootx.platform.daxpay.core.openapi.entity.PayOpenApi;
import cn.bootx.platform.daxpay.param.openapi.PayOpenApiInfoParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* 开放接口信息
* @author xxm
* @since 2023/12/22
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class PayOpenApiService {
private final PayOpenApiManager openApiInfoManager;
/**
* 编辑
*/
public void update(PayOpenApiInfoParam param){
}
/**
* 分页
*/
public void page(PageParam pageParam){
}
/**
* 根据ID获取
*/
public void findById(Long id){
}
/**
* 初始化接口上下文信息
*/
public void initApiInfo(PayOpenApi api){
// 记录支付接口信息
ApiInfoLocal apiInfoLocal = PaymentContextLocal.get().getApiInfo();
apiInfoLocal.setApiCode(api.getCode())
.setReqSign(api.isReqSign())
.setResSign(api.isResSign())
.setNotice(api.isNotice())
.setNoticeSign(api.isNoticeSign())
.setRecord(api.isRecord());
}
}

View File

@@ -1,67 +0,0 @@
package cn.bootx.platform.daxpay.core.payment.repair.strategy;
import cn.bootx.platform.daxpay.code.PayRepairSourceEnum;
import cn.bootx.platform.daxpay.core.channel.wechat.entity.WeChatPayConfig;
import cn.bootx.platform.daxpay.core.channel.wechat.service.WeChatPayCloseService;
import cn.bootx.platform.daxpay.core.channel.wechat.service.WeChatPayConfigService;
import cn.bootx.platform.daxpay.core.channel.wechat.service.WeChatPayOrderService;
import cn.bootx.platform.daxpay.func.AbsPayRepairStrategy;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
/**
*
* @author xxm
* @since 2023/12/29
*/
@Slf4j
@Scope(SCOPE_PROTOTYPE)
@Service
@RequiredArgsConstructor
public class WeChatPayRepairStrategy extends AbsPayRepairStrategy {
private final WeChatPayCloseService weChatPayCloseService;
private final WeChatPayOrderService weChatPayOrderService;
private final WeChatPayConfigService weChatPayConfigService;
private WeChatPayConfig weChatPayConfig;
/**
* 修复前处理
*/
@Override
public void doBeforeHandler() {
this.weChatPayConfig = weChatPayConfigService.getConfig();
}
/**
* 支付成功处理
*/
@Override
public void doSuccessHandler() {
weChatPayOrderService.updateAsyncSuccess();
}
/**
* 退款处理 todo 需要结合退款同步功能进行协同实现
*/
@Override
public void doRefundHandler() {
}
/**
* 取消支付
*/
@Override
public void doCloseHandler() {
// 如果非同步出的订单取消状态, 则调用支付网关关闭订单
if (this.getRepairSource() != PayRepairSourceEnum.SYNC){
weChatPayCloseService.close(this.getOrder(),this.weChatPayConfig);
}
weChatPayOrderService.updateClose(this.getOrder().getId());
}
}

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay;
package cn.bootx.platform.daxpay.service;
import org.apache.ibatis.annotations.Mapper;
import org.mybatis.spring.annotation.MapperScan;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.annotation;
package cn.bootx.platform.daxpay.service.annotation;
import java.lang.annotation.*;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.code;
package cn.bootx.platform.daxpay.service.code;
/**
* 支付宝支付参数

View File

@@ -1,5 +1,6 @@
package cn.bootx.platform.daxpay.code;
package cn.bootx.platform.daxpay.service.code;
import cn.bootx.platform.daxpay.code.PayWayEnum;
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
import lombok.experimental.UtilityClass;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.code;
package cn.bootx.platform.daxpay.service.code;
import lombok.AllArgsConstructor;
import lombok.Getter;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.code;
package cn.bootx.platform.daxpay.service.code;
import lombok.AllArgsConstructor;
import lombok.Getter;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.code;
package cn.bootx.platform.daxpay.service.code;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -14,6 +14,7 @@ public enum PayRepairTypeEnum {
SUCCESS("success","成功"),
CLOSE("close","关闭"),
TIMEOUT("timeout","超时关闭"),
REFUND("refund","退款");
private final String code;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.code;
package cn.bootx.platform.daxpay.service.code;
/**
* 支付方式扩展字段

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.code;
package cn.bootx.platform.daxpay.service.code;
/**
* 储值卡常量

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.code;
package cn.bootx.platform.daxpay.service.code;
/**
* 钱包涉及到的常量

View File

@@ -1,5 +1,6 @@
package cn.bootx.platform.daxpay.code;
package cn.bootx.platform.daxpay.service.code;
import cn.bootx.platform.daxpay.code.PayWayEnum;
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
import lombok.experimental.UtilityClass;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.common.context;
package cn.bootx.platform.daxpay.service.common.context;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.common.context;
package cn.bootx.platform.daxpay.service.common.context;
import cn.bootx.platform.daxpay.code.PayWayEnum;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.common.context;
package cn.bootx.platform.daxpay.service.common.context;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.common.context;
package cn.bootx.platform.daxpay.service.common.context;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.common.context;
package cn.bootx.platform.daxpay.service.common.context;
import lombok.Getter;
import lombok.experimental.Accessors;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.common.context;
package cn.bootx.platform.daxpay.service.common.context;
import cn.bootx.platform.daxpay.code.PaySignTypeEnum;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.common.context;
package cn.bootx.platform.daxpay.service.common.context;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.common.context;
package cn.bootx.platform.daxpay.service.common.context;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.common.entity;
package cn.bootx.platform.daxpay.service.common.entity;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.table.modify.annotation.DbColumn;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.common.entity;
package cn.bootx.platform.daxpay.service.common.entity;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.common.exception;
package cn.bootx.platform.daxpay.service.common.exception;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@@ -1,6 +1,6 @@
package cn.bootx.platform.daxpay.common.filter;
package cn.bootx.platform.daxpay.service.common.filter;
import cn.bootx.platform.daxpay.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.core.annotation.Order;

View File

@@ -1,6 +1,6 @@
package cn.bootx.platform.daxpay.common.local;
package cn.bootx.platform.daxpay.service.common.local;
import cn.bootx.platform.daxpay.common.context.PaymentContext;
import cn.bootx.platform.daxpay.service.common.context.PaymentContext;
import com.alibaba.ttl.TransmittableThreadLocal;
import lombok.experimental.UtilityClass;

View File

@@ -0,0 +1,23 @@
package cn.bootx.platform.daxpay.service.common.typehandler;
import cn.bootx.platform.common.mybatisplus.handler.JacksonTypeReferenceHandler;
import cn.bootx.platform.daxpay.service.common.entity.OrderRefundableInfo;
import com.fasterxml.jackson.core.type.TypeReference;
import java.util.List;
/**
* 支付订单可退款信息对应的MP字段处理器
* @author xxm
* @since 2024/1/3
*/
public class RefundableInfoTypeHandler extends JacksonTypeReferenceHandler<List<OrderRefundableInfo>> {
/**
* 返回要反序列化的类型对象
*/
@Override
public TypeReference<List<OrderRefundableInfo>> getTypeReference() {
return new TypeReference<List<OrderRefundableInfo>>() {};
}
}

View File

@@ -0,0 +1,29 @@
package cn.bootx.platform.daxpay.service.core.channel.alipay.convert;
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayConfig;
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayOrder;
import cn.bootx.platform.daxpay.service.dto.channel.alipay.AliPayConfigDto;
import cn.bootx.platform.daxpay.service.dto.channel.alipay.AliPaymentDto;
import cn.bootx.platform.daxpay.service.param.channel.alipay.AliPayConfigParam;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 支付宝转换
*
* @author xxm
* @since 2021/7/5
*/
@Mapper
public interface AlipayConvert {
AlipayConvert CONVERT = Mappers.getMapper(AlipayConvert.class);
AliPayConfig convert(AliPayConfigDto in);
AliPayConfig convert(AliPayConfigParam in);
AliPayConfigDto convert(AliPayConfig in);
AliPaymentDto convert(AliPayOrder aliPayOrder);
}

View File

@@ -1,7 +1,7 @@
package cn.bootx.platform.daxpay.core.channel.alipay.dao;
package cn.bootx.platform.daxpay.service.core.channel.alipay.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.daxpay.core.channel.alipay.entity.AliPayConfig;
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayConfig;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

View File

@@ -1,6 +1,6 @@
package cn.bootx.platform.daxpay.core.channel.alipay.dao;
package cn.bootx.platform.daxpay.service.core.channel.alipay.dao;
import cn.bootx.platform.daxpay.core.channel.alipay.entity.AliPayConfig;
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

View File

@@ -1,8 +1,8 @@
package cn.bootx.platform.daxpay.core.channel.alipay.dao;
package cn.bootx.platform.daxpay.service.core.channel.alipay.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.daxpay.common.entity.BasePayOrder;
import cn.bootx.platform.daxpay.core.channel.alipay.entity.AliPayOrder;
import cn.bootx.platform.daxpay.service.common.entity.BasePayOrder;
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayOrder;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

View File

@@ -1,6 +1,6 @@
package cn.bootx.platform.daxpay.core.channel.alipay.dao;
package cn.bootx.platform.daxpay.service.core.channel.alipay.dao;
import cn.bootx.platform.daxpay.core.channel.alipay.entity.AliPayOrder;
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

View File

@@ -1,14 +1,13 @@
package cn.bootx.platform.daxpay.core.channel.alipay.entity;
package cn.bootx.platform.daxpay.service.core.channel.alipay.entity;
import cn.bootx.platform.common.core.annotation.BigField;
import cn.bootx.platform.common.core.annotation.EncryptionField;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.bootx.platform.common.mybatisplus.handler.StringListTypeHandler;
import cn.bootx.platform.daxpay.code.AliPayCode;
import cn.bootx.platform.daxpay.core.channel.alipay.convert.AlipayConvert;
import cn.bootx.platform.daxpay.dto.channel.alipay.AliPayConfigDto;
import cn.bootx.platform.daxpay.param.channel.alipay.AliPayConfigParam;
import cn.bootx.platform.daxpay.service.code.AliPayCode;
import cn.bootx.platform.daxpay.service.core.channel.alipay.convert.AlipayConvert;
import cn.bootx.platform.daxpay.service.dto.channel.alipay.AliPayConfigDto;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import cn.bootx.table.modify.mysql.annotation.DbMySqlFieldType;
@@ -31,7 +30,7 @@ import java.util.List;
@Data
@Accessors(chain = true)
@DbTable(comment = "支付宝支付配置")
@TableName("pay_alipay_config")
@TableName(value = "pay_alipay_config",autoResultMap = true)
public class AliPayConfig extends MpBaseEntity implements EntityBaseFunction<AliPayConfigDto> {
/** 支付宝商户appId */
@@ -43,7 +42,7 @@ public class AliPayConfig extends MpBaseEntity implements EntityBaseFunction<Ali
private String notifyUrl;
/** 请求网关地址 */
@DbColumn(comment = "")
@DbColumn(comment = "请求网关地址")
private String serverUrl;
/**
@@ -98,6 +97,7 @@ public class AliPayConfig extends MpBaseEntity implements EntityBaseFunction<Ali
/** 可用支付方式 */
@DbColumn(comment = "可用支付方式")
@DbMySqlFieldType(MySqlFieldTypeEnum.VARCHAR)
@TableField(typeHandler = StringListTypeHandler.class)
private List<String> payWays;
@@ -113,8 +113,4 @@ public class AliPayConfig extends MpBaseEntity implements EntityBaseFunction<Ali
return AlipayConvert.CONVERT.convert(this);
}
public static AliPayConfig init(AliPayConfigParam in) {
return AlipayConvert.CONVERT.convert(in);
}
}

View File

@@ -1,9 +1,10 @@
package cn.bootx.platform.daxpay.core.channel.alipay.entity;
package cn.bootx.platform.daxpay.service.core.channel.alipay.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.daxpay.common.entity.BasePayOrder;
import cn.bootx.platform.daxpay.dto.channel.alipay.AliPaymentDto;
import cn.hutool.core.bean.BeanUtil;
import cn.bootx.platform.daxpay.service.common.entity.BasePayOrder;
import cn.bootx.platform.daxpay.service.core.channel.alipay.convert.AlipayConvert;
import cn.bootx.platform.daxpay.service.dto.channel.alipay.AliPaymentDto;
import cn.bootx.table.modify.annotation.DbTable;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -18,6 +19,7 @@ import lombok.experimental.Accessors;
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@DbTable(comment = "支付宝支付记录")
@TableName("pay_ali_payment")
public class AliPayOrder extends BasePayOrder implements EntityBaseFunction<AliPaymentDto> {
@@ -29,9 +31,7 @@ public class AliPayOrder extends BasePayOrder implements EntityBaseFunction<AliP
@Override
public AliPaymentDto toDto() {
AliPaymentDto dto = new AliPaymentDto();
BeanUtil.copyProperties(this, dto);
return dto;
return AlipayConvert.CONVERT.convert(this);
}
}

View File

@@ -1,15 +1,15 @@
package cn.bootx.platform.daxpay.core.channel.alipay.service;
package cn.bootx.platform.daxpay.service.core.channel.alipay.service;
import cn.bootx.platform.common.core.util.CertUtil;
import cn.bootx.platform.common.redis.RedisClient;
import cn.bootx.platform.daxpay.code.AliPayCode;
import cn.bootx.platform.daxpay.service.code.AliPayCode;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.core.record.callback.dao.CallbackRecordManager;
import cn.bootx.platform.daxpay.core.channel.alipay.entity.AliPayConfig;
import cn.bootx.platform.daxpay.core.payment.callback.service.PayCallbackService;
import cn.bootx.platform.daxpay.func.AbsPayCallbackStrategy;
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.service.core.record.callback.dao.CallbackRecordManager;
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayConfig;
import cn.bootx.platform.daxpay.service.core.payment.callback.service.PayCallbackService;
import cn.bootx.platform.daxpay.service.func.AbsPayCallbackStrategy;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;

View File

@@ -1,8 +1,8 @@
package cn.bootx.platform.daxpay.core.channel.alipay.service;
package cn.bootx.platform.daxpay.service.core.channel.alipay.service;
import cn.bootx.platform.common.spring.exception.RetryableException;
import cn.bootx.platform.daxpay.code.AliPayCode;
import cn.bootx.platform.daxpay.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.service.code.AliPayCode;
import cn.bootx.platform.daxpay.service.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
import com.alipay.api.AlipayApiException;
import com.alipay.api.domain.AlipayTradeCloseModel;

View File

@@ -1,13 +1,13 @@
package cn.bootx.platform.daxpay.core.channel.alipay.service;
package cn.bootx.platform.daxpay.service.core.channel.alipay.service;
import cn.bootx.platform.common.core.exception.BizException;
import cn.bootx.platform.common.core.exception.DataNotExistException;
import cn.bootx.platform.common.core.rest.dto.LabelValue;
import cn.bootx.platform.daxpay.code.AliPayCode;
import cn.bootx.platform.daxpay.code.AliPayWay;
import cn.bootx.platform.daxpay.core.channel.alipay.dao.AliPayConfigManager;
import cn.bootx.platform.daxpay.core.channel.alipay.entity.AliPayConfig;
import cn.bootx.platform.daxpay.param.channel.alipay.AliPayConfigParam;
import cn.bootx.platform.daxpay.service.code.AliPayCode;
import cn.bootx.platform.daxpay.service.code.AliPayWay;
import cn.bootx.platform.daxpay.service.core.channel.alipay.dao.AliPayConfigManager;
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayConfig;
import cn.bootx.platform.daxpay.service.param.channel.alipay.AliPayConfigParam;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.CharsetUtil;

View File

@@ -1,13 +1,13 @@
package cn.bootx.platform.daxpay.core.channel.alipay.service;
package cn.bootx.platform.daxpay.service.core.channel.alipay.service;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.common.entity.OrderRefundableInfo;
import cn.bootx.platform.daxpay.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.core.channel.alipay.dao.AliPayOrderManager;
import cn.bootx.platform.daxpay.core.channel.alipay.entity.AliPayOrder;
import cn.bootx.platform.daxpay.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.core.record.pay.service.PayOrderChannelService;
import cn.bootx.platform.daxpay.service.common.entity.OrderRefundableInfo;
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.service.core.channel.alipay.dao.AliPayOrderManager;
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayOrder;
import cn.bootx.platform.daxpay.service.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.service.core.record.pay.service.PayOrderChannelService;
import cn.bootx.platform.daxpay.param.pay.PayWayParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -41,7 +41,7 @@ public class AliPayOrderService {
*/
public void updatePaySuccess(PayOrder payOrder, PayWayParam payWayParam) {
// 更新支付宝异步支付类型信息
payOrder.setAsyncPay(true).setAsyncPayChannel(PayChannelEnum.ALI.getCode());
payOrder.setAsyncPay(true).setAsyncChannel(PayChannelEnum.ALI.getCode());
payOrderChannelService.updateChannel(payWayParam,payOrder);
// 更新支付宝可退款类型信息

View File

@@ -1,9 +1,9 @@
package cn.bootx.platform.daxpay.core.channel.alipay.service;
package cn.bootx.platform.daxpay.service.core.channel.alipay.service;
import cn.bootx.platform.daxpay.code.AliPayCode;
import cn.bootx.platform.daxpay.common.context.AsyncRefundLocal;
import cn.bootx.platform.daxpay.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.service.code.AliPayCode;
import cn.bootx.platform.daxpay.service.common.context.AsyncRefundLocal;
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.service.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
import cn.hutool.core.util.IdUtil;
import com.alipay.api.AlipayApiException;

View File

@@ -1,18 +1,18 @@
package cn.bootx.platform.daxpay.core.channel.alipay.service;
package cn.bootx.platform.daxpay.service.core.channel.alipay.service;
import cn.bootx.platform.daxpay.code.AliPayCode;
import cn.bootx.platform.daxpay.code.AliPayWay;
import cn.bootx.platform.daxpay.service.code.AliPayCode;
import cn.bootx.platform.daxpay.service.code.AliPayWay;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.code.PayWayEnum;
import cn.bootx.platform.daxpay.common.context.AsyncPayLocal;
import cn.bootx.platform.daxpay.common.context.NoticeLocal;
import cn.bootx.platform.daxpay.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.core.channel.alipay.entity.AliPayConfig;
import cn.bootx.platform.daxpay.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.service.common.context.AsyncPayLocal;
import cn.bootx.platform.daxpay.service.common.context.NoticeLocal;
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.service.core.channel.alipay.entity.AliPayConfig;
import cn.bootx.platform.daxpay.service.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.exception.pay.PayFailureException;
import cn.bootx.platform.daxpay.param.channel.AliPayParam;
import cn.bootx.platform.daxpay.param.pay.PayWayParam;
import cn.bootx.platform.daxpay.util.PayUtil;
import cn.bootx.platform.daxpay.service.util.PayUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.Method;
@@ -31,7 +31,7 @@ import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;
import static cn.bootx.platform.daxpay.code.AliPayCode.QUICK_MSECURITY_PAY;
import static cn.bootx.platform.daxpay.service.code.AliPayCode.QUICK_MSECURITY_PAY;
/**
@@ -50,7 +50,7 @@ public class AliPayService {
*/
public void validation(PayWayParam payWayParam, AliPayConfig alipayConfig) {
if (CollUtil.isNotEmpty(alipayConfig.getPayWays())){
if (CollUtil.isEmpty(alipayConfig.getPayWays())){
throw new PayFailureException("支付宝未配置可用的支付方式");
}
// 发起的支付类型是否在支持的范围内

View File

@@ -1,12 +1,12 @@
package cn.bootx.platform.daxpay.core.channel.alipay.service;
package cn.bootx.platform.daxpay.service.core.channel.alipay.service;
import cn.bootx.platform.daxpay.code.AliPayCode;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.code.PaySyncStatusEnum;
import cn.bootx.platform.daxpay.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.core.channel.alipay.dao.AliPayOrderManager;
import cn.bootx.platform.daxpay.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.core.payment.sync.result.GatewaySyncResult;
import cn.bootx.platform.daxpay.service.code.AliPayCode;
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.service.core.channel.alipay.dao.AliPayOrderManager;
import cn.bootx.platform.daxpay.service.core.payment.sync.result.GatewaySyncResult;
import cn.bootx.platform.daxpay.service.core.record.pay.entity.PayOrder;
import cn.hutool.json.JSONUtil;
import com.alipay.api.AlipayApiException;
import com.alipay.api.domain.AlipayTradeQueryModel;
@@ -31,7 +31,7 @@ public class AliPaySyncService {
private final AliPayOrderManager payOrderManager;
/**
* 与支付宝网关同步状态, 退款状态会参加
* 与支付宝网关同步状态, 退款状态会
* 1 远程支付成功
* 2 交易创建等待买家付款
* 3 超时关闭
@@ -39,7 +39,7 @@ public class AliPaySyncService {
* 5 查询失败
*/
public GatewaySyncResult syncPayStatus(PayOrder payOrder) {
GatewaySyncResult syncResult = new GatewaySyncResult().setSyncStatus(PaySyncStatusEnum.FAIL.getCode());
GatewaySyncResult syncResult = new GatewaySyncResult().setSyncStatus(PaySyncStatusEnum.FAIL);
// 查询
try {
AlipayTradeQueryModel queryModel = new AlipayTradeQueryModel();
@@ -51,24 +51,24 @@ public class AliPaySyncService {
// 支付完成
if (Objects.equals(tradeStatus, AliPayCode.PAYMENT_TRADE_SUCCESS) || Objects.equals(tradeStatus, AliPayCode.PAYMENT_TRADE_FINISHED)) {
PaymentContextLocal.get().getAsyncPayInfo().setTradeNo(response.getTradeNo());
return syncResult.setSyncStatus(PaySyncStatusEnum.PAY_SUCCESS.getCode());
return syncResult.setSyncStatus(PaySyncStatusEnum.PAY_SUCCESS);
}
// 待支付
if (Objects.equals(tradeStatus, AliPayCode.PAYMENT_WAIT_BUYER_PAY)) {
return syncResult.setSyncStatus(PaySyncStatusEnum.PAY_WAIT.getCode());
return syncResult.setSyncStatus(PaySyncStatusEnum.PAY_WAIT);
}
// 已关闭或支付完成后全额退款
if (Objects.equals(tradeStatus, AliPayCode.PAYMENT_TRADE_CLOSED)) {
// 根据支付订单区分退款的情况, TODO 后期添加查询退款信息的逻辑
if (Objects.equals(payOrder.getStatus(), PayStatusEnum.REFUNDED.getCode())){
return syncResult.setSyncStatus(PaySyncStatusEnum.REFUND.getCode());
return syncResult.setSyncStatus(PaySyncStatusEnum.REFUND);
} else {
return syncResult.setSyncStatus(PaySyncStatusEnum.CLOSED.getCode());
return syncResult.setSyncStatus(PaySyncStatusEnum.CLOSED);
}
}
// 未找到
// 支付宝支付后, 客户未进行操作将不会创建出订单, 所以交易不存在等于未查询订单
if (Objects.equals(response.getSubCode(), AliPayCode.ACQ_TRADE_NOT_EXIST)) {
return syncResult.setSyncStatus(PaySyncStatusEnum.NOT_FOUND.getCode());
return syncResult.setSyncStatus(PaySyncStatusEnum.IGNORE);
}
}
catch (AlipayApiException e) {

View File

@@ -1,7 +1,7 @@
package cn.bootx.platform.daxpay.core.channel.cash.dao;
package cn.bootx.platform.daxpay.service.core.channel.cash.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.daxpay.core.channel.cash.entity.CashPayOrder;
import cn.bootx.platform.daxpay.service.core.channel.cash.entity.CashPayOrder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

View File

@@ -1,6 +1,6 @@
package cn.bootx.platform.daxpay.core.channel.cash.dao;
package cn.bootx.platform.daxpay.service.core.channel.cash.dao;
import cn.bootx.platform.daxpay.core.channel.cash.entity.CashPayOrder;
import cn.bootx.platform.daxpay.service.core.channel.cash.entity.CashPayOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

View File

@@ -1,6 +1,7 @@
package cn.bootx.platform.daxpay.core.channel.cash.entity;
package cn.bootx.platform.daxpay.service.core.channel.cash.entity;
import cn.bootx.platform.daxpay.common.entity.BasePayOrder;
import cn.bootx.platform.daxpay.service.common.entity.BasePayOrder;
import cn.bootx.table.modify.annotation.DbTable;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -14,6 +15,7 @@ import lombok.experimental.Accessors;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@DbTable(comment = "现金支付记录")
@TableName("pay_cash_payment")
@Accessors(chain = true)
public class CashPayOrder extends BasePayOrder {

View File

@@ -1,9 +1,9 @@
package cn.bootx.platform.daxpay.core.channel.cash.service;
package cn.bootx.platform.daxpay.service.core.channel.cash.service;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.core.channel.cash.dao.CashPayOrderManager;
import cn.bootx.platform.daxpay.core.channel.cash.entity.CashPayOrder;
import cn.bootx.platform.daxpay.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.service.core.channel.cash.dao.CashPayOrderManager;
import cn.bootx.platform.daxpay.service.core.channel.cash.entity.CashPayOrder;
import cn.bootx.platform.daxpay.service.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.param.pay.PayParam;
import cn.bootx.platform.daxpay.param.pay.PayWayParam;
import lombok.RequiredArgsConstructor;

View File

@@ -1,7 +1,7 @@
package cn.bootx.platform.daxpay.core.channel.union.convert;
package cn.bootx.platform.daxpay.service.core.channel.union.convert;
import cn.bootx.platform.daxpay.core.channel.union.entity.UnionPayConfig;
import cn.bootx.platform.daxpay.dto.channel.union.UnionPayConfigDto;
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionPayConfig;
import cn.bootx.platform.daxpay.service.dto.channel.union.UnionPayConfigDto;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

View File

@@ -1,7 +1,7 @@
package cn.bootx.platform.daxpay.core.channel.union.dao;
package cn.bootx.platform.daxpay.service.core.channel.union.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.daxpay.core.channel.union.entity.UnionPayConfig;
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionPayConfig;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

View File

@@ -1,6 +1,6 @@
package cn.bootx.platform.daxpay.core.channel.union.dao;
package cn.bootx.platform.daxpay.service.core.channel.union.dao;
import cn.bootx.platform.daxpay.core.channel.union.entity.UnionPayConfig;
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionPayConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

View File

@@ -1,7 +1,7 @@
package cn.bootx.platform.daxpay.core.channel.union.dao;
package cn.bootx.platform.daxpay.service.core.channel.union.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.daxpay.core.channel.union.entity.UnionPayOrder;
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionPayOrder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

View File

@@ -1,6 +1,6 @@
package cn.bootx.platform.daxpay.core.channel.union.dao;
package cn.bootx.platform.daxpay.service.core.channel.union.dao;
import cn.bootx.platform.daxpay.core.channel.union.entity.UnionPayOrder;
import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionPayOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

View File

@@ -1,9 +1,10 @@
package cn.bootx.platform.daxpay.core.channel.union.entity;
package cn.bootx.platform.daxpay.service.core.channel.union.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.bootx.platform.daxpay.core.channel.union.convert.UnionPayConvert;
import cn.bootx.platform.daxpay.dto.channel.union.UnionPayConfigDto;
import cn.bootx.platform.daxpay.service.core.channel.union.convert.UnionPayConvert;
import cn.bootx.platform.daxpay.service.dto.channel.union.UnionPayConfigDto;
import cn.bootx.table.modify.annotation.DbTable;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -17,6 +18,7 @@ import lombok.experimental.Accessors;
*/
@EqualsAndHashCode(callSuper = true)
@Data
@DbTable(comment = "云闪付支付配置")
@Accessors(chain = true)
@TableName("pay_union_pay_config")
public class UnionPayConfig extends MpBaseEntity implements EntityBaseFunction<UnionPayConfigDto> {

View File

@@ -1,6 +1,7 @@
package cn.bootx.platform.daxpay.core.channel.union.entity;
package cn.bootx.platform.daxpay.service.core.channel.union.entity;
import cn.bootx.platform.daxpay.common.entity.BasePayOrder;
import cn.bootx.platform.daxpay.service.common.entity.BasePayOrder;
import cn.bootx.table.modify.annotation.DbTable;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -13,6 +14,7 @@ import lombok.experimental.Accessors;
*/
@EqualsAndHashCode(callSuper = true)
@Data
@DbTable(comment = "云闪付支付订单")
@Accessors(chain = true)
@TableName("pay_union_payment")
public class UnionPayOrder extends BasePayOrder {

View File

@@ -1,6 +1,6 @@
package cn.bootx.platform.daxpay.core.channel.union.service;
package cn.bootx.platform.daxpay.service.core.channel.union.service;
import cn.bootx.platform.daxpay.core.channel.union.dao.UnionPayConfigManager;
import cn.bootx.platform.daxpay.service.core.channel.union.dao.UnionPayConfigManager;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.core.channel.union.service;
package cn.bootx.platform.daxpay.service.core.channel.union.service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.core.channel.union.service;
package cn.bootx.platform.daxpay.service.core.channel.union.service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

View File

@@ -0,0 +1,27 @@
package cn.bootx.platform.daxpay.service.core.channel.voucher.convert;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherLog;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherPayOrder;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherDto;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherLogDto;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherPayOrderDto;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* @author xxm
* @since 2022/3/14
*/
@Mapper
public interface VoucherConvert {
VoucherConvert CONVERT = Mappers.getMapper(VoucherConvert.class);
VoucherDto convert(Voucher in);
VoucherLogDto convert(VoucherLog in);
VoucherPayOrderDto convert(VoucherPayOrder in);
}

View File

@@ -1,10 +1,10 @@
package cn.bootx.platform.daxpay.core.channel.voucher.dao;
package cn.bootx.platform.daxpay.service.core.channel.voucher.dao;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.mybatisplus.base.MpIdEntity;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.daxpay.core.channel.voucher.entity.VoucherLog;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherLog;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

View File

@@ -1,6 +1,6 @@
package cn.bootx.platform.daxpay.core.channel.voucher.dao;
package cn.bootx.platform.daxpay.service.core.channel.voucher.dao;
import cn.bootx.platform.daxpay.core.channel.voucher.entity.VoucherLog;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

View File

@@ -1,12 +1,12 @@
package cn.bootx.platform.daxpay.core.channel.voucher.dao;
package cn.bootx.platform.daxpay.service.core.channel.voucher.dao;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.mybatisplus.base.MpDelEntity;
import cn.bootx.platform.common.mybatisplus.base.MpIdEntity;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.daxpay.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.param.channel.voucher.VoucherParam;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.param.channel.voucher.VoucherParam;
import cn.bootx.platform.starter.auth.util.SecurityUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

View File

@@ -1,6 +1,6 @@
package cn.bootx.platform.daxpay.core.channel.voucher.dao;
package cn.bootx.platform.daxpay.service.core.channel.voucher.dao;
import cn.bootx.platform.daxpay.core.channel.voucher.entity.Voucher;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.Voucher;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

View File

@@ -1,6 +1,6 @@
package cn.bootx.platform.daxpay.core.channel.voucher.dao;
package cn.bootx.platform.daxpay.service.core.channel.voucher.dao;
import cn.bootx.platform.daxpay.core.channel.voucher.entity.VoucherPayOrder;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherPayOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

View File

@@ -1,7 +1,7 @@
package cn.bootx.platform.daxpay.core.channel.voucher.dao;
package cn.bootx.platform.daxpay.service.core.channel.voucher.dao;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.daxpay.core.channel.voucher.entity.VoucherPayOrder;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherPayOrder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

View File

@@ -1,10 +1,10 @@
package cn.bootx.platform.daxpay.core.channel.voucher.entity;
package cn.bootx.platform.daxpay.service.core.channel.voucher.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.bootx.platform.daxpay.code.VoucherCode;
import cn.bootx.platform.daxpay.core.channel.voucher.convert.VoucherConvert;
import cn.bootx.platform.daxpay.dto.channel.voucher.VoucherDto;
import cn.bootx.platform.daxpay.service.code.VoucherCode;
import cn.bootx.platform.daxpay.service.core.channel.voucher.convert.VoucherConvert;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherDto;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbComment;
import cn.bootx.table.modify.annotation.DbTable;

View File

@@ -1,10 +1,10 @@
package cn.bootx.platform.daxpay.core.channel.voucher.entity;
package cn.bootx.platform.daxpay.service.core.channel.voucher.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.bootx.platform.daxpay.code.VoucherCode;
import cn.bootx.platform.daxpay.core.channel.voucher.convert.VoucherConvert;
import cn.bootx.platform.daxpay.dto.channel.voucher.VoucherLogDto;
import cn.bootx.platform.daxpay.service.code.VoucherCode;
import cn.bootx.platform.daxpay.service.core.channel.voucher.convert.VoucherConvert;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherLogDto;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import cn.bootx.table.modify.mysql.annotation.DbMySqlIndex;

View File

@@ -1,14 +1,16 @@
package cn.bootx.platform.daxpay.core.channel.voucher.entity;
package cn.bootx.platform.daxpay.service.core.channel.voucher.entity;
import cn.bootx.platform.common.core.function.EntityBaseFunction;
import cn.bootx.platform.daxpay.common.entity.BasePayOrder;
import cn.bootx.platform.daxpay.core.channel.voucher.convert.VoucherConvert;
import cn.bootx.platform.daxpay.dto.channel.voucher.VoucherPayOrderDto;
import cn.bootx.platform.daxpay.service.common.entity.BasePayOrder;
import cn.bootx.platform.daxpay.service.core.channel.voucher.convert.VoucherConvert;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherPayOrderDto;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.table.modify.annotation.DbTable;
import cn.bootx.table.modify.mysql.annotation.DbMySqlFieldType;
import cn.bootx.table.modify.mysql.constants.MySqlFieldTypeEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@@ -28,7 +30,8 @@ public class VoucherPayOrder extends BasePayOrder implements EntityBaseFunction<
/** 扣款储值卡 */
@DbColumn(comment = "扣款储值卡")
@DbMySqlFieldType(MySqlFieldTypeEnum.LONGTEXT)
@DbMySqlFieldType(MySqlFieldTypeEnum.JSON)
@TableField(typeHandler = JacksonTypeHandler.class)
private VoucherRecord voucherRecord;

View File

@@ -1,4 +1,4 @@
package cn.bootx.platform.daxpay.core.channel.voucher.entity;
package cn.bootx.platform.daxpay.service.core.channel.voucher.entity;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@@ -1,10 +1,10 @@
package cn.bootx.platform.daxpay.core.channel.voucher.service;
package cn.bootx.platform.daxpay.service.core.channel.voucher.service;
import cn.bootx.platform.common.core.rest.PageResult;
import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.daxpay.core.channel.voucher.dao.VoucherLogManager;
import cn.bootx.platform.daxpay.dto.channel.voucher.VoucherLogDto;
import cn.bootx.platform.daxpay.service.core.channel.voucher.dao.VoucherLogManager;
import cn.bootx.platform.daxpay.service.dto.channel.voucher.VoucherLogDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

View File

@@ -1,11 +1,11 @@
package cn.bootx.platform.daxpay.core.channel.voucher.service;
package cn.bootx.platform.daxpay.service.core.channel.voucher.service;
import cn.bootx.platform.common.core.exception.BizException;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.core.channel.voucher.dao.VoucherPaymentManager;
import cn.bootx.platform.daxpay.core.channel.voucher.entity.VoucherPayOrder;
import cn.bootx.platform.daxpay.core.channel.voucher.entity.VoucherRecord;
import cn.bootx.platform.daxpay.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.service.core.channel.voucher.dao.VoucherPaymentManager;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherPayOrder;
import cn.bootx.platform.daxpay.service.core.channel.voucher.entity.VoucherRecord;
import cn.bootx.platform.daxpay.service.core.record.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.param.pay.PayParam;
import cn.bootx.platform.daxpay.param.pay.PayWayParam;
import lombok.RequiredArgsConstructor;

Some files were not shown because too many files have changed in this diff Show More