diff --git a/sql/mysql/menu.sql b/sql/mysql/menu.sql deleted file mode 100644 index 704979b78..000000000 --- a/sql/mysql/menu.sql +++ /dev/null @@ -1,230 +0,0 @@ --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '积分设置管理', '', 2, 0, 2162, - 'config', '', 'point/config/index', 0, 'PointConfig' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '积分设置查询', 'point:config:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '积分设置创建', 'point:config:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '积分设置更新', 'point:config:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '积分设置删除', 'point:config:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '积分设置导出', 'point:config:export', 3, 5, @parentId, - '', '', '', 0 -); - - - --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '积分签到规则管理', '', 2, 0, 2162, - 'sign-in-config', '', 'point/signInConfig/index', 0, 'SignInConfig' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '积分签到规则查询', 'point:sign-in-config:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '积分签到规则创建', 'point:sign-in-config:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '积分签到规则更新', 'point:sign-in-config:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '积分签到规则删除', 'point:sign-in-config:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '积分签到规则导出', 'point:sign-in-config:export', 3, 5, @parentId, - '', '', '', 0 -); - - --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '用户积分记录管理', '', 2, 0, 2162, - 'record', '', 'point/record/index', 0, 'PointRecord' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '用户积分记录查询', 'point:record:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '用户积分记录创建', 'point:record:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '用户积分记录更新', 'point:record:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '用户积分记录删除', 'point:record:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '用户积分记录导出', 'point:record:export', 3, 5, @parentId, - '', '', '', 0 -); - - - --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '用户签到积分管理', '', 2, 0, 2162, - 'sign-in-record', '', 'point/signInRecord/index', 0, 'SignInRecord' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '用户签到积分查询', 'point:sign-in-record:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '用户签到积分创建', 'point:sign-in-record:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '用户签到积分更新', 'point:sign-in-record:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '用户签到积分删除', 'point:sign-in-record:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '用户签到积分导出', 'point:sign-in-record:export', 3, 5, @parentId, - '', '', '', 0 -); - - diff --git a/sql/mysql/optional/mall.sql b/sql/mysql/optional/mall.sql deleted file mode 100644 index 655c03073..000000000 --- a/sql/mysql/optional/mall.sql +++ /dev/null @@ -1,555 +0,0 @@ -/* - Navicat Premium Data Transfer - - Source Server : 127.0.0.1 MySQL - Source Server Type : MySQL - Source Server Version : 80026 - Source Host : localhost:3306 - Source Schema : ruoyi-vue-pro - - Target Server Type : MySQL - Target Server Version : 80026 - File Encoding : 65001 - - Date: 01/08/2022 23:01:36 -*/ - -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; - --- ---------------------------- --- Table structure for market_activity --- ---------------------------- -DROP TABLE IF EXISTS `market_activity`; -CREATE TABLE `market_activity` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '活动编号', - `title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '活动标题', - `activity_type` tinyint NOT NULL COMMENT '活动类型', - `status` tinyint NOT NULL DEFAULT -1 COMMENT '活动状态', - `start_time` datetime NOT NULL COMMENT '开始时间', - `end_time` datetime NOT NULL COMMENT '结束时间', - `invalid_time` datetime NULL DEFAULT NULL COMMENT '失效时间', - `delete_time` datetime NULL DEFAULT NULL COMMENT '删除时间', - `time_limited_discount` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '限制折扣字符串,使用 JSON 序列化成字符串存储', - `full_privilege` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '限制折扣字符串,使用 JSON 序列化成字符串存储', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '促销活动'; - --- ---------------------------- --- Records of market_activity --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for market_banner --- ---------------------------- -DROP TABLE IF EXISTS `market_banner`; -CREATE TABLE `market_banner` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'Banner编号', - `title` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'Banner标题', - `pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '图片URL', - `status` tinyint NOT NULL DEFAULT -1 COMMENT '活动状态', - `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '跳转地址', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - `sort` tinyint NULL DEFAULT NULL COMMENT '排序', - `memo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'Banner管理'; - --- ---------------------------- --- Records of market_banner --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for member_address --- ---------------------------- -DROP TABLE IF EXISTS `member_address`; -CREATE TABLE `member_address` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '收件地址编号', - `user_id` bigint NOT NULL COMMENT '用户编号', - `name` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '收件人名称', - `mobile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '手机号', - `area_id` bigint NOT NULL COMMENT '地区编码', - `post_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '邮编', - `detail_address` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '收件详细地址', - `defaulted` bit(1) NOT NULL COMMENT '是否默认', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE, - INDEX `idx_userId`(`user_id` ASC) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '用户收件地址'; - --- ---------------------------- --- Records of member_address --- ---------------------------- -BEGIN; -INSERT INTO `ruoyi-vue-pro`.`member_address` (`id`, `user_id`, `name`, `mobile`, `area_id`, `post_code`, `detail_address`, `defaulted`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (21, 1, 'yunai', '15601691300', 610632, '200000', '芋道源码 233 号 666 室', b'1', '1', '2022-08-01 22:46:35', '1', '2022-08-01 22:46:35', b'0', 1); -COMMIT; - --- ---------------------------- --- Table structure for product_brand --- ---------------------------- -DROP TABLE IF EXISTS `product_brand`; -CREATE TABLE `product_brand` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '品牌编号', - `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '品牌名称', - `pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '品牌图片', - `sort` int NULL DEFAULT 0 COMMENT '品牌排序', - `description` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '品牌描述', - `status` tinyint NOT NULL COMMENT '状态', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '商品品牌'; - --- ---------------------------- --- Records of product_brand --- ---------------------------- -BEGIN; -INSERT INTO `ruoyi-vue-pro`.`product_brand` (`id`, `name`, `pic_url`, `sort`, `description`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, '苹果', 'http://test.yudao.iocoder.cn/e3726713fa56db5717c78c011762fcc7a251db12735c3581470638b8e1fa17e2.jpeg', 0, '是上市', 0, '1', '2022-07-30 22:12:18', '1', '2022-07-30 22:13:55', b'0', 1); -COMMIT; - --- ---------------------------- --- Table structure for product_category --- ---------------------------- -DROP TABLE IF EXISTS `product_category`; -CREATE TABLE `product_category` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类编号', - `parent_id` bigint NOT NULL COMMENT '父分类编号', - `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '分类名称', - `pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '移动端分类图', - `big_pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'PC 端分类图', - `sort` int DEFAULT '0' COMMENT '分类排序', - `status` tinyint NOT NULL COMMENT '开启状态', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商品分类'; - --- ---------------------------- --- Records of product_category --- ---------------------------- -BEGIN; -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 0, '电脑办公', 'http://test.yudao.iocoder.cn/122d548e1b3cd5dec72fe8075c6977a70f9cc13541a684ab3685f1b5df42f6bd.jpeg', '', 300, 0, '1', '2022-07-30 16:36:35', '1', '2022-07-30 20:27:16', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2, 1, '笔记本', 'http://test.yudao.iocoder.cn/72713ac7b947600a019a18786ed0e6562e8692e253dbd35110a0a85c2469bbec.jpg', '', 310, 0, '1', '2022-07-30 16:38:09', '1', '2022-07-30 16:38:09', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (3, 1, '游戏本', 'http://test.yudao.iocoder.cn/287c50dd9f5f575f57329a0c57b2095be6d1aeba83867b905fe549f54a296feb.jpg', '', 312, 0, '1', '2022-07-30 16:39:09', '1', '2022-07-30 20:26:59', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (4, 0, '手机', 'http://test.yudao.iocoder.cn/e1b63900c78dbb661b3e383960cee5cfea7e1dd2fb22cff2e317ff025faaf8b2.jpeg', '', 313, 0, '1', '2022-07-30 16:40:00', '1', '2022-07-30 16:40:09', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (5, 4, '5G手机', 'http://test.yudao.iocoder.cn/3af6557ac7def6423f046f5b2e920b644793420b466959aaa996a2e19068bbde.jpeg', '', 314, 0, '1', '2022-07-30 16:43:00', '1', '2022-07-30 16:43:00', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (6, 4, '游戏手机', 'http://test.yudao.iocoder.cn/964fe9ccd1710d64ede261dc36d231918a017641986c15293c367f9f66d94d05.jpeg', '', 315, 0, '1', '2022-07-30 16:43:44', '1', '2022-07-30 16:43:44', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (7, 5, '厉害的 5G 手机', 'http://test.yudao.iocoder.cn/b287122f277838e8de368769b96217918605743bc45f3a29bda3cc7359dc66e1.png', '', '123', 0, '1', '2022-07-30 20:38:09', '1', '2022-07-30 20:38:09', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (15, 0, '服装鞋包', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/a23f732db55e6adbc608f4b6cf2b0ab50db6d9147af0ee267a315805a596e175.jpg', '', 100, 0, '1', '2023-04-25 16:57:05', '1', '2023-04-25 17:08:26', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (16, 15, '时尚女装', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/aa8d5c44ac0390ab398bae0dc8883575e3cb57594f9ed00248febe8e3d7484d1.png', '', 200, 0, '1', '2023-04-25 17:09:00', '1', '2023-04-25 17:09:00', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (17, 15, '精品男装', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/b0c166c0846fa2280b4a02431e2ac2e2363f2d2a6b608598f34b067a5ccf1245.png', '', 100, 0, '1', '2023-04-25 17:09:33', '1', '2023-04-25 17:09:33', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (18, 15, '箱包', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/8682928caa2a5a49b380ac93059adc435099873cdf646084f31cea79d5c27f40.png', '', 80, 0, '1', '2023-04-25 17:09:51', '1', '2023-04-25 17:09:51', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (19, 15, '西服', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/c202fa79f2fbe188cfdf40b107c7eca89c548a5c4b0047e26b7a6445c470615a.jpg', '', 0, 0, '1', '2023-04-25 17:10:15', '1', '2023-04-25 17:10:15', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (20, 15, '配饰', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/51bf43fcad0b947f5fa377356fb7034b47223fdbcec241d50e6e60a9be498730.jpg', '', 0, 0, '1', '2023-04-25 17:10:56', '1', '2023-04-25 17:10:56', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (21, 15, '美妆工具', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/c3cd6735cf157c218bc32ece312fd90cb2130c437dc9ec61d4030681d6ba4efb.png', '', 0, 0, '1', '2023-04-25 17:11:15', '1', '2023-04-25 17:11:24', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (22, 0, '网络盒子', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/74656bb8bc988c0419e0dbc613eda24a03956b950452b3565527301a5782db3a.png', '', 50, 0, '1', '2023-04-25 17:12:13', '1', '2023-04-25 17:12:13', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (23, 22, '尿裤湿巾', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/20162f22d8f6b427f0d6f1678c9fbb7bf0c1b70768bdc86101bee8b5e13bec5a.jpeg', '', 0, 0, '1', '2023-04-25 17:12:42', '1', '2023-04-25 17:12:42', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (24, 15, '宠物主粮', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/383729ba05711c400f9e44db11a63603af0fdbc99e58cd7b40e9296ca4e0510e.jpg', '', 0, 0, '1', '2023-04-25 17:13:09', '1', '2023-04-25 17:13:09', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (25, 0, '家电电器', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/c8a34dc2688fd4d2c95b5f49888865db1c88fd3bde153e3f7f0bcd4ff9971c96.png', '', 50, 0, '1', '2023-04-25 17:13:43', '1', '2023-04-25 17:13:43', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (26, 25, '封口/封杯机', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/1c0c208cfcf871c146006d97f95ae4fcd14d8a2deb3eabe3696367af61cb5e69.png', '', 60, 0, '1', '2023-04-25 17:14:39', '1', '2023-04-25 17:14:39', b'0', 1); -INSERT INTO `ruoyi-vue-pro`.`product_category` (`id`, `parent_id`, `name`, `pic_url`, `big_pic_url`, `sort`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (27, 25, '空调', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/d578e1e60b2dc3efe70643d25a8b2150dabfecd658fdb2fafcdb786d525f66d1.png', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/34ed55f822ad25ab445e6b396dcd61a7d119882ef19f85f0e24742911d896959.jpeg', 60, 0, '1', '2023-04-25 17:15:12', '1', '2023-04-25 17:17:04', b'0', 1); -COMMIT; - --- ---------------------------- --- Table structure for product_property --- ---------------------------- -DROP TABLE IF EXISTS `product_property`; -CREATE TABLE `product_property` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '规格名称', - `status` tinyint DEFAULT NULL COMMENT '状态: 0 开启 ,1 禁用', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人', - `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注', - PRIMARY KEY (`id`) USING BTREE, - KEY `idx_name` (`name`(32)) USING BTREE COMMENT '规格名称索引' -) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='规格名称'; - --- ---------------------------- --- Records of product_property --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for product_property_value --- ---------------------------- -DROP TABLE IF EXISTS `product_property_value`; -CREATE TABLE `product_property_value` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `property_id` bigint DEFAULT NULL COMMENT '规格键id', - `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '规格值名字', - `status` tinyint DEFAULT NULL COMMENT '状态: 1 开启 ,2 禁用', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人', - `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `remark` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='规格值'; - --- ---------------------------- --- Records of product_property_value --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for product_sku --- ---------------------------- -DROP TABLE IF EXISTS `product_sku`; -CREATE TABLE `product_sku` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `spu_id` bigint NOT NULL COMMENT 'spu编号', - `properties` varchar(512) DEFAULT NULL COMMENT '属性数组,JSON 格式 [{propertId: , valueId: }, {propertId: , valueId: }]', - `price` int NOT NULL DEFAULT '-1' COMMENT '商品价格,单位:分', - `market_price` int DEFAULT NULL COMMENT '市场价,单位:分', - `cost_price` int NOT NULL DEFAULT '-1' COMMENT '成本价,单位: 分', - `bar_code` varchar(64) DEFAULT NULL COMMENT 'SKU 的条形码', - `pic_url` varchar(256) NOT NULL COMMENT '图片地址', - `stock` int DEFAULT NULL COMMENT '库存', - `weight` double DEFAULT NULL COMMENT '商品重量,单位:kg 千克', - `volume` double DEFAULT NULL COMMENT '商品体积,单位:m^3 平米', - `sub_commission_first_price` int DEFAULT NULL COMMENT '一级分销的佣金,单位:分', - `sub_commission_second_price` int DEFAULT NULL COMMENT '二级分销的佣金,单位:分', - `sales_count` int DEFAULT NULL COMMENT '商品销量', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar(64) DEFAULT NULL COMMENT '创建人', - `updater` double(64,0) DEFAULT NULL COMMENT '更新人', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', -PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB COMMENT='商品sku'; - --- ---------------------------- --- Records of product_sku --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for product_spu --- ---------------------------- -DROP TABLE IF EXISTS `product_spu`; -CREATE TABLE `product_spu` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '商品 SPU 编号,自增', - `name` varchar(128) NOT NULL COMMENT '商品名称', - `keyword` varchar(256) DEFAULT NULL COMMENT '关键字', - `introduction` varchar(256) COMMENT '商品简介', - `description` text COMMENT '商品详情', - `bar_code` varchar(64) DEFAULT NULL COMMENT '条形码', - `category_id` bigint NOT NULL COMMENT '商品分类编号', - `brand_id` int DEFAULT NULL COMMENT '商品品牌编号', - `pic_url` varchar(256) NOT NULL COMMENT '商品封面图', - `slider_pic_urls` varchar(2000) DEFAULT '' COMMENT '商品轮播图地址\n 数组,以逗号分隔\n 最多上传15张', - `video_url` varchar(256) DEFAULT NULL COMMENT '商品视频', - `unit` tinyint NOT NULL COMMENT '单位', - `sort` int NOT NULL DEFAULT '0' COMMENT '排序字段', - `status` tinyint NOT NULL COMMENT '商品状态: 0 上架(开启) 1 下架(禁用)-1 回收', - `spec_type` bit(1) DEFAULT NULL COMMENT '规格类型:0 单规格 1 多规格', - `price` int NOT NULL DEFAULT '-1' COMMENT '商品价格,单位使用:分', - `market_price` int DEFAULT NULL COMMENT '市场价,单位使用:分', - `cost_price` int NOT NULL DEFAULT '-1' COMMENT '成本价,单位: 分', - `stock` int NOT NULL DEFAULT '0' COMMENT '库存', - `delivery_template_id` bigint NOT NULL COMMENT '物流配置模板编号', - `recommend_hot` bit(1) DEFAULT NULL COMMENT '是否热卖推荐: 0 默认 1 热卖', - `recommend_benefit` bit(1) DEFAULT NULL COMMENT '是否优惠推荐: 0 默认 1 优选', - `recommend_best` bit(1) DEFAULT NULL COMMENT '是否精品推荐: 0 默认 1 精品', - `recommend_new` bit(1) DEFAULT NULL COMMENT '是否新品推荐: 0 默认 1 新品', - `recommend_good` bit(1) DEFAULT NULL COMMENT '是否优品推荐', - `give_integral` int NOT NULL COMMENT '赠送积分', - `give_coupon_template_ids` varchar(512) DEFAULT '' COMMENT '赠送的优惠劵编号的数组', - `sub_commission_type` bit(1) DEFAULT NULL COMMENT '分销类型', - `activity_orders` varchar(16) NOT NULL DEFAULT '' COMMENT '活动显示排序0=默认, 1=秒杀,2=砍价,3=拼团', - `sales_count` int DEFAULT '0' COMMENT '商品销量', - `virtual_sales_count` int DEFAULT '0' COMMENT '虚拟销量', - `browse_count` int DEFAULT '0' COMMENT '商品点击量', - `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `creator` varchar(64) DEFAULT NULL COMMENT '创建人', - `updater` varchar(64) DEFAULT NULL COMMENT '更新人', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB COMMENT='商品spu'; - --- ---------------------------- --- Table structure for product_favorite --- ---------------------------- -DROP TABLE IF EXISTS `product_favorite`; -CREATE TABLE `product_favorite` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,自增', - `spu_id` bigint NOT NULL COMMENT '商品 SPU 编号', - `user_id` bigint NOT NULL COMMENT '用户id', - `type` int(10) NOT NULL DEFAULT 1 COMMENT '类型1:收藏 2:点赞', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB COMMENT='商品收藏表'; - --- Table structure for trade_delivery_express_template --- ---------------------------- -DROP TABLE IF EXISTS `trade_delivery_express_template`; -CREATE TABLE `trade_delivery_express_template` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', - `name` varchar(64) NOT NULL COMMENT '模板名称', - `charge_mode` tinyint NOT NULL COMMENT '配送计费方式', - `sort` int NOT NULL DEFAULT 0 COMMENT '排序', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB COMMENT='快递运费模板'; - --- ---------------------------- --- Table structure for trade_delivery_express_template_free --- ---------------------------- -DROP TABLE IF EXISTS `trade_delivery_express_template_free`; -CREATE TABLE `trade_delivery_express_template_free` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', - `template_id` bigint NOT NULL COMMENT '快递运费模板编号', - `area_ids` varchar(100) NOT NULL COMMENT '包邮区域 ids', - `free_price` int NOT NULL COMMENT '包邮金额,单位:分', - `free_count` int NOT NULL DEFAULT 0 COMMENT '包邮件数,', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB COMMENT='快递运费模板包邮配置'; - --- ---------------------------- --- Table structure for trade_delivery_express_template_charge --- ---------------------------- -DROP TABLE IF EXISTS `trade_delivery_express_template_charge`; -CREATE TABLE `trade_delivery_express_template_charge` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,自增', - `template_id` bigint NOT NULL COMMENT '快递运费模板编号', - `area_ids` varchar(100) NOT NULL COMMENT '配送区域 ids', - `charge_mode` tinyint NOT NULL COMMENT '配送计费方式', - `start_count` double NOT NULL COMMENT '首件数量', - `start_price` int NOT NULL COMMENT '起步价,单位:分', - `extra_count` double NOT NULL COMMENT '续件数量', - `extra_price` int NOT NULL COMMENT '额外价,单位:分', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB COMMENT='快递运费模板计费配置'; - --- ---------------------------- --- Table structure for trade_delivery_pick_up_store --- ---------------------------- -DROP TABLE IF EXISTS `trade_delivery_pick_up_store`; -CREATE TABLE `trade_delivery_pick_up_store` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', - `name` varchar(64) NOT NULL COMMENT '门店名称', - `introduction` varchar(256) COMMENT '门店简介', - `phone` varchar(16) NOT NULL COMMENT '门店手机', - `area_id` int NOT NULL COMMENT '区域编号', - `detail_address` varchar(256) NOT NULL COMMENT '门店详细地址', - `logo` varchar(256) NOT NULL COMMENT '门店 logo', - `opening_time` time NOT NULL COMMENT '营业开始时间', - `closing_time` time NOT NULL COMMENT '营业结束时间', - `latitude` double NOT NULL COMMENT '纬度', - `longitude` double NOT NULL COMMENT '经度', - `status` tinyint NOT NULL DEFAULT 0 COMMENT '门店状态', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB COMMENT='自提门店'; - --- ---------------------------- --- Table structure for trade_delivery_pick_up_store_staff --- ---------------------------- -DROP TABLE IF EXISTS `trade_delivery_pick_up_store_staff`; -CREATE TABLE `trade_delivery_pick_up_store_staff` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,自增', - store_id bigint NOT NULL COMMENT '自提门店编号', - `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB COMMENT='自提门店店员'; - --- ---------------------------- --- Table structure for trade_delivery_express --- ---------------------------- -DROP TABLE IF EXISTS `trade_delivery_express`; -CREATE TABLE `trade_delivery_express` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', - `code` varchar(64) NOT NULL COMMENT '快递公司编码', - `name` varchar(64) NOT NULL COMMENT '快递公司名称', - `logo` varchar(256) COMMENT '快递公司 logo', - `sort` int NOT NULL DEFAULT 0 COMMENT '排序', - `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB COMMENT='快递公司'; - --- ---------------------------- --- 页面装修表 --- ---------------------------- -DROP TABLE IF EXISTS `promotion_decorate_component`; -CREATE TABLE `promotion_decorate_component` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', - `page_id` int NOT NULL COMMENT '所属页面id', - `code` varchar(64) NOT NULL COMMENT '组件编码', - `value` json NOT NULL COMMENT '组件值:json 格式。包含配置和数据', - `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB COMMENT='页面装修表'; - -SET FOREIGN_KEY_CHECKS = 1; - -BEGIN; -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2000, '商品中心', '', 1, 60, 0, '/product', 'merchant', NULL, 0, b'1', b'1', '', '2022-07-29 15:53:53', '1', '2022-07-30 22:26:19', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2002, '商品分类', '', 2, 2, 2000, 'category', 'dict', 'mall/product/category/index', 0, b'1', b'1', '', '2022-07-29 15:53:53', '1', '2022-07-30 22:23:37', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2003, '分类查询', 'product:category:query', 3, 1, 2002, '', '', '', 0, b'1', b'1', '', '2022-07-29 15:53:53', '', '2022-07-29 15:53:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2004, '分类创建', 'product:category:create', 3, 2, 2002, '', '', '', 0, b'1', b'1', '', '2022-07-29 15:53:53', '', '2022-07-29 15:53:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2005, '分类更新', 'product:category:update', 3, 3, 2002, '', '', '', 0, b'1', b'1', '', '2022-07-29 15:53:53', '', '2022-07-29 15:53:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2006, '分类删除', 'product:category:delete', 3, 4, 2002, '', '', '', 0, b'1', b'1', '', '2022-07-29 15:53:53', '', '2022-07-29 15:53:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2007, '分类导出', 'product:category:export', 3, 5, 2002, '', '', '', 0, b'1', b'1', '', '2022-07-29 15:53:53', '', '2022-07-30 13:52:13', b'1'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2008, '商品品牌', '', 2, 1, 2000, 'brand', 'dashboard', 'mall/product/brand/index', 0, b'1', b'1', '', '2022-07-30 13:52:44', '1', '2022-07-30 22:23:43', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2009, '品牌查询', 'product:brand:query', 3, 1, 2008, '', '', '', 0, b'1', b'1', '', '2022-07-30 13:52:44', '', '2022-07-30 13:52:44', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2010, '品牌创建', 'product:brand:create', 3, 2, 2008, '', '', '', 0, b'1', b'1', '', '2022-07-30 13:52:44', '', '2022-07-30 13:52:44', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2011, '品牌更新', 'product:brand:update', 3, 3, 2008, '', '', '', 0, b'1', b'1', '', '2022-07-30 13:52:44', '', '2022-07-30 13:52:44', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2012, '品牌删除', 'product:brand:delete', 3, 4, 2008, '', '', '', 0, b'1', b'1', '', '2022-07-30 13:52:44', '', '2022-07-30 13:52:44', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2013, '品牌导出', 'product:brand:export', 3, 5, 2008, '', '', '', 0, b'1', b'1', '', '2022-07-30 13:52:44', '', '2022-07-30 14:15:00', b'1'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2014, '商品管理', '', 2, 0, 2000, 'spu', 'link', 'mall/product/spu/index', 0, b'1', b'1', '', '2022-07-30 14:22:58', '1', '2022-07-30 22:26:35', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2015, '商品查询', 'product:spu:query', 3, 1, 2014, '', '', '', 0, b'1', b'1', '', '2022-07-30 14:22:58', '', '2022-07-30 14:22:58', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2016, '商品创建', 'product:spu:create', 3, 2, 2014, '', '', '', 0, b'1', b'1', '', '2022-07-30 14:22:58', '', '2022-07-30 14:22:58', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2017, '商品更新', 'product:spu:update', 3, 3, 2014, '', '', '', 0, b'1', b'1', '', '2022-07-30 14:22:58', '', '2022-07-30 14:22:58', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2018, '商品删除', 'product:spu:delete', 3, 4, 2014, '', '', '', 0, b'1', b'1', '', '2022-07-30 14:22:58', '', '2022-07-30 14:22:58', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2018, '商品导出', 'product:spu:export', 3, 5, 2014, '', '', '', 0, b'1', b'1', '', '2022-07-30 14:22:58', '', '2022-07-30 14:22:58', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2019, '规格管理', '', 2, 3, 2000, 'property', '', 'mall/product/property/index', 0, b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-08-01 14:55:35', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2020, '规格查询', 'product:property:query', 3, 1, 2019, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-08-01 14:55:35', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2021, '规格创建', 'product:property:create', 3, 2, 2019, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-08-01 14:55:35', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2022, '规格更新', 'product:property:update', 3, 3, 2019, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-08-01 14:55:35', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2023, '规格删除', 'product:property:delete', 3, 4, 2019, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-08-01 14:55:35', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2024, '规格导出', 'product:property:export', 3, 5, 2019, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-08-01 14:55:35', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2025, 'Banner管理', '', 2, 1, 2000, 'brand', '', 'mall/market/banner/index', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2026, 'Banner查询', 'market:banner:query', 3, 1, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2027, 'Banner创建', 'market:banner:create', 3, 2, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2028, 'Banner更新', 'market:banner:update', 3, 3, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2029, 'Banner删除', 'market:banner:delete', 3, 4, 2025, '', '', '', 0, b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2164, '配送管理', '', 1, 0, 2072, 'delivery', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:18:02', '1', '2023-05-18 09:48:48', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2165, '快递发货', '', 1, 0, 2164, 'express', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:22:06', '1', '2023-05-18 09:22:06', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2166, '门店自提', '', 1, 1, 2164, 'pick-up', '', '', '', 0, b'1', b'1', b'1', '1', '2023-05-18 09:23:14', '1', '2023-05-18 09:23:14', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2167, '快递公司', '', 2, 0, 2165, 'express', '', 'mall/trade/delivery/express/index', 'Express', 0, b'1', b'1', b'1', '1', '2023-05-18 09:27:21', '1', '2023-05-18 22:11:14', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2168, '快递公司查询', 'trade:delivery:express:query', 3, 1, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2169, '快递公司创建', 'trade:delivery:express:create', 3, 2, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2170, '快递公司更新', 'trade:delivery:express:update', 3, 3, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2171, '快递公司删除', 'trade:delivery:express:delete', 3, 4, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2172, '快递公司导出', 'trade:delivery:express:export', 3, 5, 2167, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-18 09:37:53', '', '2023-05-18 09:37:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2178, '快递运费模板导出', 'trade:delivery:express-template:export', 3, 5, 2173, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-20 06:49:53', '', '2023-05-20 06:49:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2177, '快递运费模板删除', 'trade:delivery:express-template:delete', 3, 4, 2173, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-20 06:49:53', '', '2023-05-20 06:49:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2176, '快递运费模板更新', 'trade:delivery:express-template:update', 3, 3, 2173, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-20 06:49:53', '', '2023-05-20 06:49:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2175, '快递运费模板创建', 'trade:delivery:express-template:create', 3, 2, 2173, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-20 06:49:53', '', '2023-05-20 06:49:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2174, '快递运费模板查询', 'trade:delivery:express-template:query', 3, 1, 2173, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-20 06:49:53', '', '2023-05-20 06:49:53', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2173, '运费模版', 'trade:delivery:express-template:query', 2, 1, 2165, 'express-template', '', 'mall/trade/delivery/expressTemplate/index', 'ExpressTemplate', 0, b'1', b'1', b'1', '1', '2023-05-20 06:48:10', '1', '2023-05-20 06:48:29', b'0'); -BEGIN; - --- ---------------------------- --- 字典管理,添加商品单位字典 product_unit --- ---------------------------- -BEGIN; -INSERT INTO `ruoyi-vue-pro`.`system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (169, '商品单位', 'product_unit', 0, '', '1', '2023-05-21 22:45:03', '1', '2023-05-21 22:45:03', b'0', '1970-01-01 00:00:00'); -INSERT INTO `ruoyi-vue-pro`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '个', 1, 'product_unit', 0, '', '', '', 1, NOW(), 1, NOW(), b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '件', 2, 'product_unit', 0, '', '', '', 1, NOW(), 1, NOW(), b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '盒', 3, 'product_unit', 0, '', '', '', 1, NOW(), 1, NOW(), b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '袋', 4, 'product_unit', 0, '', '', '', 1, NOW(), 1, NOW(), b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '箱', 5, 'product_unit', 0, '', '', '', 1, NOW(), 1, NOW(), b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '套', 6, 'product_unit', 0, '', '', '', 1, NOW(), 1, NOW(), b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '包', 7, 'product_unit', 0, '', '', '', 1, NOW(), 1, NOW(), b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '双', 8, 'product_unit', 0, '', '', '', 1, NOW(), 1, NOW(), b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '卷', 9, 'product_unit', 0, '', '', '', 1, NOW(), 1, NOW(), b'0'); -COMMIT; - --- ---------------------------- --- 数字字典,快递计费方式 --- ---------------------------- -BEGIN; -INSERT INTO `ruoyi-vue-pro`.`system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (169, '快递计费方式', 'trade_delivery_express_charge_mode', 0, '用于商城交易模块配送管理', '1', '2023-05-21 22:45:03', '1', '2023-05-21 22:45:03', b'0', '1970-01-01 00:00:00'); -INSERT INTO `ruoyi-vue-pro`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1237, 2, '按体积', '3', 'trade_delivery_express_charge_mode', 0, '', '', '', '1', '2023-05-21 22:47:18', '1', '2023-05-21 22:47:18', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1236, 1, '按重量', '2', 'trade_delivery_express_charge_mode', 0, '', '', '', '1', '2023-05-21 22:46:58', '1', '2023-05-21 22:46:58', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1235, 0, '按件', '1', 'trade_delivery_express_charge_mode', 0, '', '', '', '1', '2023-05-21 22:46:40', '1', '2023-05-21 22:46:40', b'0'); -COMMIT; - --- ---------------------------- --- 门店管理 菜单 --- ---------------------------- -BEGIN; -INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2179, '门店管理', '', 2, 1, 2166, 'pick-up-store', '', 'mall/trade/delivery/pickUpStore/index', 'PickUpStore', 0, b'1', b'1', b'1', '1', '2023-05-25 10:50:00', '1', '2023-05-25 10:50:00', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2180, '自提门店查询', 'trade:delivery:pick-up-store:query', 3, 1, 2179, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-25 10:53:29', '', '2023-05-25 10:53:29', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2181, '自提门店创建', 'trade:delivery:pick-up-store:create', 3, 2, 2179, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-25 10:53:29', '', '2023-05-25 10:53:29', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2182, '自提门店更新', 'trade:delivery:pick-up-store:update', 3, 3, 2179, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-25 10:53:29', '', '2023-05-25 10:53:29', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2183, '自提门店删除', 'trade:delivery:pick-up-store:delete', 3, 4, 2179, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-25 10:53:29', '', '2023-05-25 10:53:29', b'0'); -INSERT INTO `ruoyi-vue-pro`.`system_menu`(`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2184, '自提门店导出', 'trade:delivery:pick-up-store:export', 3, 5, 2179, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-05-25 10:53:29', '', '2023-05-25 10:53:29', b'0'); -COMMIT; diff --git a/sql/mysql/ruoyi-vue-pro.sql b/sql/mysql/ruoyi-vue-pro.sql index a5d6982fd..b05c14de6 100644 --- a/sql/mysql/ruoyi-vue-pro.sql +++ b/sql/mysql/ruoyi-vue-pro.sql @@ -875,294 +875,6 @@ CREATE TABLE `member_user` ( BEGIN; COMMIT; --- ---------------------------- --- Table structure for pay_app --- ---------------------------- -DROP TABLE IF EXISTS `pay_app`; -CREATE TABLE `pay_app` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '应用编号', - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '应用名', - `status` tinyint NOT NULL COMMENT '开启状态', - `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', - `pay_notify_url` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '支付结果的回调地址', - `refund_notify_url` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '退款结果的回调地址', - `merchant_id` bigint NOT NULL COMMENT '商户编号', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '支付应用信息'; - --- ---------------------------- --- Records of pay_app --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for pay_channel --- ---------------------------- -DROP TABLE IF EXISTS `pay_channel`; -CREATE TABLE `pay_channel` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '商户编号', - `code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '渠道编码', - `status` tinyint NOT NULL COMMENT '开启状态', - `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', - `fee_rate` double NOT NULL DEFAULT 0 COMMENT '渠道费率,单位:百分比', - `merchant_id` bigint NOT NULL COMMENT '商户编号', - `app_id` bigint NOT NULL COMMENT '应用编号', - `config` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '支付渠道配置', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '支付渠道\n'; - --- ---------------------------- --- Records of pay_channel --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for pay_demo_order --- ---------------------------- -DROP TABLE IF EXISTS `pay_demo_order`; -CREATE TABLE `pay_demo_order` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '订单编号', - `user_id` bigint UNSIGNED NOT NULL COMMENT '用户编号', - `spu_id` bigint NOT NULL COMMENT '商品编号', - `spu_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '商品名字', - `price` int NOT NULL COMMENT '价格,单位:分', - `payed` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已支付:[0:未支付 1:已经支付过]', - `pay_order_id` bigint NULL DEFAULT NULL COMMENT '支付订单编号', - `pay_channel_code` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '支付成功的支付渠道', - `pay_time` datetime NULL DEFAULT NULL COMMENT '订单支付时间', - `pay_refund_id` bigint NULL DEFAULT NULL COMMENT '退款订单编号', - `refund_price` int NOT NULL DEFAULT 0 COMMENT '退款金额,单位:分', - `refund_time` datetime NULL DEFAULT NULL COMMENT '退款时间', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 72 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '示例订单\n'; - --- ---------------------------- --- Records of pay_demo_order --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for pay_merchant --- ---------------------------- -DROP TABLE IF EXISTS `pay_merchant`; -CREATE TABLE `pay_merchant` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '商户编号', - `no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户号', - `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户全称', - `short_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户简称', - `status` tinyint NOT NULL COMMENT '开启状态', - `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '支付商户信息'; - --- ---------------------------- --- Records of pay_merchant --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for pay_notify_log --- ---------------------------- -DROP TABLE IF EXISTS `pay_notify_log`; -CREATE TABLE `pay_notify_log` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '日志编号', - `task_id` bigint NOT NULL COMMENT '通知任务编号', - `notify_times` tinyint NOT NULL COMMENT '第几次被通知', - `response` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '请求参数', - `status` tinyint NOT NULL COMMENT '通知状态', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 371964 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '支付通知 App 的日志'; - --- ---------------------------- --- Records of pay_notify_log --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for pay_notify_task --- ---------------------------- -DROP TABLE IF EXISTS `pay_notify_task`; -CREATE TABLE `pay_notify_task` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '任务编号', - `merchant_id` bigint NOT NULL COMMENT '商户编号', - `app_id` bigint NOT NULL COMMENT '应用编号', - `type` tinyint NOT NULL COMMENT '通知类型', - `data_id` bigint NOT NULL COMMENT '数据编号', - `status` tinyint NOT NULL COMMENT '通知状态', - `merchant_order_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户订单编号', - `next_notify_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '下一次通知时间', - `last_execute_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后一次执行时间', - `notify_times` tinyint NOT NULL COMMENT '当前通知次数', - `max_notify_times` tinyint NOT NULL COMMENT '最大可通知次数', - `notify_url` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '异步通知地址', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 151 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '商户支付、退款等的通知\n'; - --- ---------------------------- --- Records of pay_notify_task --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for pay_order --- ---------------------------- -DROP TABLE IF EXISTS `pay_order`; -CREATE TABLE `pay_order` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '支付订单编号', - `merchant_id` bigint NOT NULL COMMENT '商户编号', - `app_id` bigint NOT NULL COMMENT '应用编号', - `channel_id` bigint NULL DEFAULT NULL COMMENT '渠道编号', - `channel_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '渠道编码', - `merchant_order_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户订单编号', - `subject` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品标题', - `body` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品描述', - `notify_url` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '异步通知地址', - `notify_status` tinyint NOT NULL COMMENT '通知商户支付结果的回调状态', - `amount` bigint NOT NULL COMMENT '支付金额,单位:分', - `channel_fee_rate` double NULL DEFAULT 0 COMMENT '渠道手续费,单位:百分比', - `channel_fee_amount` bigint NULL DEFAULT 0 COMMENT '渠道手续金额,单位:分', - `status` tinyint NOT NULL COMMENT '支付状态', - `user_ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '用户 IP', - `expire_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '订单失效时间', - `success_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '订单支付成功时间', - `notify_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '订单支付通知时间', - `success_extension_id` bigint NULL DEFAULT NULL COMMENT '支付成功的订单拓展单编号', - `refund_status` tinyint NOT NULL COMMENT '退款状态', - `refund_times` tinyint NOT NULL COMMENT '退款次数', - `refund_amount` bigint NOT NULL COMMENT '退款总金额,单位:分', - `channel_user_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '渠道用户编号', - `channel_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '渠道订单号', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 171 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '支付订单\n'; - --- ---------------------------- --- Records of pay_order --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for pay_order_extension --- ---------------------------- -DROP TABLE IF EXISTS `pay_order_extension`; -CREATE TABLE `pay_order_extension` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '支付订单编号', - `no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '支付订单号', - `order_id` bigint NOT NULL COMMENT '支付订单编号', - `channel_id` bigint NOT NULL COMMENT '渠道编号', - `channel_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '渠道编码', - `user_ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '用户 IP', - `status` tinyint NOT NULL COMMENT '支付状态', - `channel_extras` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '支付渠道的额外参数', - `channel_notify_data` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '支付渠道异步通知的内容', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 383 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '支付订单\n'; - --- ---------------------------- --- Records of pay_order_extension --- ---------------------------- -BEGIN; -COMMIT; - --- ---------------------------- --- Table structure for pay_refund --- ---------------------------- -DROP TABLE IF EXISTS `pay_refund`; -CREATE TABLE `pay_refund` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '支付退款编号', - `merchant_id` bigint NOT NULL COMMENT '商户编号', - `app_id` bigint NOT NULL COMMENT '应用编号', - `channel_id` bigint NOT NULL COMMENT '渠道编号', - `channel_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '渠道编码', - `order_id` bigint NOT NULL COMMENT '支付订单编号 pay_order 表id', - `trade_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '交易订单号 pay_extension 表no 字段', - `merchant_order_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户订单编号(商户系统生成)', - `merchant_refund_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户退款订单号(商户系统生成)', - `notify_url` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '异步通知商户地址', - `notify_status` tinyint NOT NULL COMMENT '通知商户退款结果的回调状态', - `status` tinyint NOT NULL COMMENT '退款状态', - `type` tinyint NOT NULL COMMENT '退款类型(部分退款,全部退款)', - `pay_amount` bigint NOT NULL COMMENT '支付金额,单位分', - `refund_amount` bigint NOT NULL COMMENT '退款金额,单位分', - `reason` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '退款原因', - `user_ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '用户 IP', - `channel_order_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '渠道订单号,pay_order 中的channel_order_no 对应', - `channel_refund_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '渠道退款单号,渠道返回', - `channel_error_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '渠道调用报错时,错误码', - `channel_error_msg` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '渠道调用报错时,错误信息', - `channel_extras` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '支付渠道的额外参数', - `expire_time` datetime NULL DEFAULT NULL COMMENT '退款失效时间', - `success_time` datetime NULL DEFAULT NULL COMMENT '退款成功时间', - `notify_time` datetime NULL DEFAULT NULL COMMENT '退款通知时间', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 26 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '退款订单'; - --- ---------------------------- --- Records of pay_refund --- ---------------------------- -BEGIN; -COMMIT; - -- ---------------------------- -- Table structure for system_dept -- ---------------------------- diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/util/ServiceExceptionUtil.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/util/ServiceExceptionUtil.java index 7a9d62dd1..966109fbf 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/util/ServiceExceptionUtil.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/util/ServiceExceptionUtil.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.common.exception.util; import cn.iocoder.yudao.framework.common.exception.ErrorCode; import cn.iocoder.yudao.framework.common.exception.ServiceException; +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; import com.google.common.annotations.VisibleForTesting; import lombok.extern.slf4j.Slf4j; @@ -80,6 +81,10 @@ public class ServiceExceptionUtil { return new ServiceException(code, message); } + public static ServiceException invalidParamException(String messagePattern, Object... params) { + return exception0(GlobalErrorCodeConstants.BAD_REQUEST.getCode(), messagePattern, params); + } + // ========== 格式化方法 ========== /** diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/notify/PayOrderNotifyRespDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/notify/PayOrderNotifyRespDTO.java index 97e967253..239ddda23 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/notify/PayOrderNotifyRespDTO.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/notify/PayOrderNotifyRespDTO.java @@ -35,14 +35,4 @@ public class PayOrderNotifyRespDTO { */ private LocalDateTime successTime; - /** - * TODO @jason 结合其他的渠道定义成枚举, - * - * alipay - * TRADE_CLOSED,未付款交易超时关闭,或支付完成后全额退款。 - * TRADE_SUCCESS, 交易支付成功 - * TRADE_FINISHED 交易结束,不可退款。 - */ - private String tradeStatus; - } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/notify/PayRefundNotifyRespDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/notify/PayRefundNotifyRespDTO.java index de2e47ba0..9c05b3ac0 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/notify/PayRefundNotifyRespDTO.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/notify/PayRefundNotifyRespDTO.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.framework.pay.core.client.dto.notify; -import cn.iocoder.yudao.framework.pay.core.enums.PayNotifyRefundStatusEnum; +import cn.iocoder.yudao.framework.pay.core.enums.refund.PayNotifyRefundStatusEnum; import lombok.Builder; import lombok.Data; import lombok.ToString; diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java index e1f54f7bb..ba31b08ad 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedReqDTO.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.framework.pay.core.client.dto.order; -import cn.iocoder.yudao.framework.pay.core.enums.PayDisplayModeEnum; +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; import lombok.Data; import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.URL; @@ -8,7 +8,6 @@ import org.hibernate.validator.constraints.URL; import javax.validation.constraints.DecimalMin; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; -import java.awt.*; import java.time.LocalDateTime; import java.util.Map; @@ -85,7 +84,7 @@ public class PayOrderUnifiedReqDTO { * * 如果不传递,则每个支付渠道使用默认的方式 * - * 枚举 {@link PayDisplayModeEnum} + * 枚举 {@link PayOrderDisplayModeEnum} */ private String displayMode; diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedRespDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedRespDTO.java index ae6bed40f..815f63ec3 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedRespDTO.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/order/PayOrderUnifiedRespDTO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.framework.pay.core.client.dto.order; -import lombok.AllArgsConstructor; +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; import lombok.Data; /** @@ -13,6 +14,8 @@ public class PayOrderUnifiedRespDTO { /** * 展示模式 + * + * 枚举 {@link PayOrderDisplayModeEnum} 类 */ private String displayMode; /** @@ -20,4 +23,20 @@ public class PayOrderUnifiedRespDTO { */ private String displayContent; + /** + * 支付状态 + * + * 枚举 {@link PayOrderStatusRespEnum} 类 + */ + private Integer status; + + public PayOrderUnifiedRespDTO(String displayMode, String displayContent) { + this(displayMode, displayContent, PayOrderStatusRespEnum.WAITING.getStatus()); + } + + public PayOrderUnifiedRespDTO(String displayMode, String displayContent, Integer status) { + this.displayMode = displayMode; + this.displayContent = displayContent; + this.status = status; + } } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedRespDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedRespDTO.java index 8a120f7d7..104dc2bbe 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedRespDTO.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/refund/PayRefundUnifiedRespDTO.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.framework.pay.core.client.dto.refund; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelRefundRespEnum; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/exception/PayException.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/exception/PayException.java new file mode 100644 index 000000000..75f4c3975 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/exception/PayException.java @@ -0,0 +1,17 @@ +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); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java index 88fa4b100..0225739ca 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java @@ -1,23 +1,18 @@ package cn.iocoder.yudao.framework.pay.core.client.impl; -import cn.hutool.core.date.LocalDateTimeUtil; +import cn.iocoder.yudao.framework.common.exception.ServiceException; import cn.iocoder.yudao.framework.pay.core.client.PayClient; import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedRespDTO; -import com.alipay.api.AlipayResponse;import lombok.extern.slf4j.Slf4j; +import cn.iocoder.yudao.framework.pay.core.client.exception.PayException; +import lombok.extern.slf4j.Slf4j; import javax.validation.Validation; -import java.time.LocalDateTime; -import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER; -import static cn.hutool.core.date.DatePattern.NORM_DATETIME_MS_FORMATTER; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.framework.pay.core.enums.PayFrameworkErrorCodeConstants.PAY_EXCEPTION; /** * 支付客户端的抽象类,提供模板方法,减少子类的冗余代码 @@ -78,16 +73,19 @@ public abstract class AbstractPayClient implemen @Override public final PayOrderUnifiedRespDTO unifiedOrder(PayOrderUnifiedReqDTO reqDTO) { Validation.buildDefaultValidatorFactory().getValidator().validate(reqDTO); - // 执行短信发送 - PayOrderUnifiedRespDTO result; + // 执行统一下单 + PayOrderUnifiedRespDTO resp; try { - result = doUnifiedOrder(reqDTO); + resp = doUnifiedOrder(reqDTO); + } catch (ServiceException ex) { + // 业务异常,都是实现类已经翻译,所以直接抛出即可 + throw ex; } catch (Throwable ex) { - // 打印异常日志 - log.error("[unifiedOrder][request({}) 发起支付失败]", toJsonString(reqDTO), ex); + // 系统异常,则包装成 PayException 异常抛出 + log.error("[unifiedRefund][request({}) 发起支付异常]", toJsonString(reqDTO), ex); throw buildException(ex); } - return result; + return resp; } protected abstract PayOrderUnifiedRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) @@ -95,12 +93,17 @@ public abstract class AbstractPayClient implemen @Override public PayRefundUnifiedRespDTO unifiedRefund(PayRefundUnifiedReqDTO reqDTO) { + Validation.buildDefaultValidatorFactory().getValidator().validate(reqDTO); + // 执行统一退款 PayRefundUnifiedRespDTO resp; try { resp = doUnifiedRefund(reqDTO); - } catch (Throwable ex) { - // 记录异常日志 - log.error("[unifiedRefund][request({}) 发起退款失败]", toJsonString(reqDTO), ex); + } catch (ServiceException ex) { + // 业务异常,都是实现类已经翻译,所以直接抛出即可 + throw ex; + } catch (Throwable ex) { + // 系统异常,则包装成 PayException 异常抛出 + log.error("[unifiedRefund][request({}) 发起退款异常]", toJsonString(reqDTO), ex); throw buildException(ex); } return resp; @@ -110,32 +113,11 @@ public abstract class AbstractPayClient implemen // ========== 各种工具方法 ========== - private RuntimeException buildException(Throwable ex) { - if (ex instanceof RuntimeException) { - return (RuntimeException) ex; + private PayException buildException(Throwable ex) { + if (ex instanceof PayException) { + return (PayException) ex; } - throw new RuntimeException(ex); - } - - protected void validateSuccess(AlipayResponse response) { - if (response.isSuccess()) { - return; - } - throw exception0(PAY_EXCEPTION.getCode(), response.getSubMsg()); - } - - protected String formatAmount(Integer amount) { - return String.valueOf(amount / 100.0); - } - - protected String formatTime(LocalDateTime time) { - // "yyyy-MM-dd HH:mm:ss" - return LocalDateTimeUtil.format(time, NORM_DATETIME_FORMATTER); - } - - protected LocalDateTime parseTime(String str) { - // "yyyy-MM-dd HH:mm:ss" - return LocalDateTimeUtil.parse(str, NORM_DATETIME_FORMATTER); + throw new PayException(ex); } } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java index aee06ee18..cafc3585b 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImpl.java @@ -5,11 +5,8 @@ import cn.iocoder.yudao.framework.pay.core.client.PayClient; import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.*; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXLitePayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXNativePayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPubPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.*; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import lombok.extern.slf4j.Slf4j; import java.util.concurrent.ConcurrentHashMap; @@ -58,12 +55,15 @@ public class PayClientFactoryImpl implements PayClientFactory { PayChannelEnum channelEnum = PayChannelEnum.getByCode(channelCode); Assert.notNull(channelEnum, String.format("支付渠道(%s) 为空", channelEnum)); // 创建客户端 - // TODO @芋艿 WX_LITE WX_APP 如果不添加在 项目启动的时候去初始化会报错无法启动。所以我手动加了两个,具体需要你来配 switch (channelEnum) { - case WX_PUB: return (AbstractPayClient) new WXPubPayClient(channelId, (WXPayClientConfig) config); - case WX_LITE: return (AbstractPayClient) new WXLitePayClient(channelId, (WXPayClientConfig) config); //微信小程序请求支付 - case WX_APP: return (AbstractPayClient) new WXPubPayClient(channelId, (WXPayClientConfig) config); - case WX_NATIVE: return (AbstractPayClient) new WXNativePayClient(channelId, (WXPayClientConfig) config); + // 微信支付 + case WX_PUB: return (AbstractPayClient) new WxPubPayClient(channelId, (WxPayClientConfig) config); + case WX_LITE: return (AbstractPayClient) new WxLitePayClient(channelId, (WxPayClientConfig) config); + case WX_APP: return (AbstractPayClient) new WxAppPayClient(channelId, (WxPayClientConfig) config); + case WX_BAR: return (AbstractPayClient) new WxBarPayClient(channelId, (WxPayClientConfig) config); + case WX_NATIVE: return (AbstractPayClient) new WxNativePayClient(channelId, (WxPayClientConfig) config); + case WX_H5: return (AbstractPayClient) new WxH5PayClient(channelId, (WxPayClientConfig) config); + // 支付宝支付 case ALIPAY_WAP: return (AbstractPayClient) new AlipayWapPayClient(channelId, (AlipayPayClientConfig) config); case ALIPAY_QR: return (AbstractPayClient) new AlipayQrPayClient(channelId, (AlipayPayClientConfig) config); case ALIPAY_APP: return (AbstractPayClient) new AlipayAppPayClient(channelId, (AlipayPayClientConfig) config); diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java similarity index 65% rename from yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClient.java rename to yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java index 3e73cdc06..60472fefb 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AbstractAlipayPayClient.java @@ -1,17 +1,17 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.http.HttpUtil; +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayNotifyReqDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayOrderNotifyRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayRefundNotifyRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedRespDTO; import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.PayNotifyRefundStatusEnum; -import com.alipay.api.AlipayApiException; -import com.alipay.api.AlipayConfig; -import com.alipay.api.DefaultAlipayClient; +import cn.iocoder.yudao.framework.pay.core.enums.refund.PayNotifyRefundStatusEnum; +import com.alipay.api.*; import com.alipay.api.domain.AlipayTradeRefundModel; import com.alipay.api.internal.util.AlipaySignature; import com.alipay.api.request.AlipayTradeRefundRequest; @@ -20,21 +20,25 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import java.nio.charset.StandardCharsets; +import java.time.LocalDateTime; import java.util.Map; +import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; +import static cn.iocoder.yudao.framework.pay.core.enums.PayFrameworkErrorCodeConstants.ORDER_UNIFIED_ERROR; /** - * 支付宝抽象类, 实现支付宝统一的接口。如退款 + * 支付宝抽象类,实现支付宝统一的接口、以及部分实现(退款) * - * @author jason + * @author jason */ @Slf4j -public abstract class AbstractAlipayClient extends AbstractPayClient { +public abstract class AbstractAlipayPayClient extends AbstractPayClient { protected DefaultAlipayClient client; - public AbstractAlipayClient(Long channelId, String channelCode, AlipayPayClientConfig config) { + public AbstractAlipayPayClient(Long channelId, String channelCode, AlipayPayClientConfig config) { super(channelId, channelCode, config); } @@ -58,7 +62,7 @@ public abstract class AbstractAlipayClient extends AbstractPayClient> verifyParam(Validator validator) { + // TODO 芋艿:参数校验 return validator.validate(this, MODE_PUBLIC_KEY.equals(this.getMode()) ? ModePublicKey.class : ModeCertificate.class); } + } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java index 591b02dbc..d1a7eef14 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPcPayClient.java @@ -4,8 +4,8 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.http.Method; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.PayDisplayModeEnum; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; import com.alipay.api.AlipayApiException; import com.alipay.api.domain.AlipayTradePagePayModel; import com.alipay.api.request.AlipayTradePagePayRequest; @@ -22,7 +22,7 @@ import java.util.Objects; * @author XGD */ @Slf4j -public class AlipayPcPayClient extends AbstractAlipayClient { +public class AlipayPcPayClient extends AbstractAlipayPayClient { public AlipayPcPayClient(Long channelId, AlipayPayClientConfig config) { super(channelId, PayChannelEnum.ALIPAY_PC.getCode(), config); @@ -44,7 +44,7 @@ public class AlipayPcPayClient extends AbstractAlipayClient { model.setQrPayMode("2"); // 跳转模式 - 订单码,效果参见:https://help.pingxx.com/article/1137360/ // ③ 支付宝 PC 支付有两种展示模式:FORM、URL String displayMode = ObjectUtil.defaultIfNull(reqDTO.getDisplayMode(), - PayDisplayModeEnum.URL.getMode()); + PayOrderDisplayModeEnum.URL.getMode()); // 1.2 构建 AlipayTradePagePayRequest 请求 AlipayTradePagePayRequest request = new AlipayTradePagePayRequest(); @@ -54,16 +54,14 @@ public class AlipayPcPayClient extends AbstractAlipayClient { // 2.1 执行请求 AlipayTradePagePayResponse response; - if (Objects.equals(displayMode, PayDisplayModeEnum.FORM.getMode())) { + if (Objects.equals(displayMode, PayOrderDisplayModeEnum.FORM.getMode())) { response = client.pageExecute(request, Method.POST.name()); // 需要特殊使用 POST 请求 } else { response = client.pageExecute(request, Method.GET.name()); } - // 2.2 处理结果 - validateSuccess(response); - return new PayOrderUnifiedRespDTO().setDisplayMode(displayMode) - .setDisplayContent(response.getBody()); + validateUnifiedOrderResponse(request, response); + return new PayOrderUnifiedRespDTO(displayMode, response.getBody()); } } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java index 4080824d1..27b2ba5c4 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayQrPayClient.java @@ -2,8 +2,8 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.PayDisplayModeEnum; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; import com.alipay.api.AlipayApiException; import com.alipay.api.domain.AlipayTradePrecreateModel; import com.alipay.api.request.AlipayTradePrecreateRequest; @@ -18,7 +18,7 @@ import lombok.extern.slf4j.Slf4j; * @author 芋道源码 */ @Slf4j -public class AlipayQrPayClient extends AbstractAlipayClient { +public class AlipayQrPayClient extends AbstractAlipayPayClient { public AlipayQrPayClient(Long channelId, AlipayPayClientConfig config) { super(channelId, PayChannelEnum.ALIPAY_QR.getCode(), config); @@ -36,7 +36,7 @@ public class AlipayQrPayClient extends AbstractAlipayClient { model.setProductCode("FACE_TO_FACE_PAYMENT"); // 销售产品码. 目前扫码支付场景下仅支持 FACE_TO_FACE_PAYMENT // ② 个性化的参数【无】 // ③ 支付宝扫码支付只有一种展示,考虑到前端可能希望二维码扫描后,手机打开 - String displayMode = PayDisplayModeEnum.QR_CODE.getMode(); + String displayMode = PayOrderDisplayModeEnum.QR_CODE.getMode(); // 1.2 构建 AlipayTradePrecreateRequest 请求 AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); @@ -47,8 +47,8 @@ public class AlipayQrPayClient extends AbstractAlipayClient { // 2.1 执行请求 AlipayTradePrecreateResponse response = client.execute(request); // 2.2 处理结果 - validateSuccess(response); - return new PayOrderUnifiedRespDTO() - .setDisplayMode(displayMode).setDisplayContent(response.getQrCode()); + validateUnifiedOrderResponse(request, response); + return new PayOrderUnifiedRespDTO(displayMode, response.getQrCode()); } + } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java index 23291a7f3..1db837b69 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java @@ -3,8 +3,8 @@ package cn.iocoder.yudao.framework.pay.core.client.impl.alipay; import cn.hutool.http.Method; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import cn.iocoder.yudao.framework.pay.core.enums.PayDisplayModeEnum; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; import com.alipay.api.AlipayApiException; import com.alipay.api.domain.AlipayTradeWapPayModel; import com.alipay.api.request.AlipayTradeWapPayRequest; @@ -19,7 +19,7 @@ import lombok.extern.slf4j.Slf4j; * @author 芋道源码 */ @Slf4j -public class AlipayWapPayClient extends AbstractAlipayClient { +public class AlipayWapPayClient extends AbstractAlipayPayClient { public AlipayWapPayClient(Long channelId, AlipayPayClientConfig config) { super(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), config); @@ -37,7 +37,7 @@ public class AlipayWapPayClient extends AbstractAlipayClient { model.setProductCode("QUICK_WAP_PAY"); // 销售产品码. 目前 Wap 支付场景下仅支持 QUICK_WAP_PAY // ② 个性化的参数【无】 // ③ 支付宝 Wap 支付只有一种展示:URL - String displayMode = PayDisplayModeEnum.URL.getMode(); + String displayMode = PayOrderDisplayModeEnum.URL.getMode(); // 1.2 构建 AlipayTradeWapPayRequest 请求 AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest(); @@ -50,9 +50,8 @@ public class AlipayWapPayClient extends AbstractAlipayClient { AlipayTradeWapPayResponse response = client.pageExecute(request, Method.GET.name()); // 2.2 处理结果 - validateSuccess(response); - return new PayOrderUnifiedRespDTO() - .setDisplayMode(displayMode).setDisplayContent(response.getBody()); + validateUnifiedOrderResponse(request, response); + return new PayOrderUnifiedRespDTO(displayMode, response.getBody()); } } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java new file mode 100644 index 000000000..fa5a793d5 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/AbstractWxPayClient.java @@ -0,0 +1,198 @@ +package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.date.TemporalAccessorUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.framework.common.util.io.FileUtils; +import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayNotifyReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayOrderNotifyRespDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; +import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; +import cn.iocoder.yudao.framework.pay.core.enums.PayFrameworkErrorCodeConstants; +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result; +import com.github.binarywang.wxpay.config.WxPayConfig; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; +import lombok.extern.slf4j.Slf4j; + +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Objects; + +import static cn.hutool.core.date.DatePattern.PURE_DATETIME_PATTERN; +import static cn.hutool.core.date.DatePattern.UTC_WITH_XXX_OFFSET_PATTERN; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.*; +import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; + +/** + * 微信支付抽象类,实现微信统一的接口、以及部分实现(退款) + * + * @author 遇到源码 + */ +@Slf4j +public abstract class AbstractWxPayClient extends AbstractPayClient { + + protected WxPayService client; + + public AbstractWxPayClient(Long channelId, String channelCode, WxPayClientConfig config) { + super(channelId, channelCode, config); + } + + /** + * 初始化 client 客户端 + * + * @param tradeType 交易类型 + */ + protected void doInit(String tradeType) { + // 创建 config 配置 + WxPayConfig payConfig = new WxPayConfig(); + BeanUtil.copyProperties(config, payConfig, "keyContent"); + payConfig.setTradeType(tradeType); + if (StrUtil.isNotEmpty(config.getPrivateKeyContent())) { + // weixin-pay-java 存在 BUG,无法直接设置内容,所以创建临时文件来解决 + payConfig.setPrivateKeyPath(FileUtils.createTempFile(config.getPrivateKeyContent()).getPath()); + } + if (StrUtil.isNotEmpty(config.getPrivateCertContent())) { + // weixin-pay-java 存在 BUG,无法直接设置内容,所以创建临时文件来解决 + payConfig.setPrivateCertPath(FileUtils.createTempFile(config.getPrivateCertContent()).getPath()); + } + + // 创建 client 客户端 + client = new WxPayServiceImpl(); + client.setConfig(payConfig); + } + + @Override + protected PayOrderUnifiedRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws Exception { + try { + switch (config.getApiVersion()) { + case WxPayClientConfig.API_VERSION_V2: + return doUnifiedOrderV2(reqDTO); + case WxPayClientConfig.API_VERSION_V3: + return doUnifiedOrderV3(reqDTO); + default: + throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); + } + } catch (WxPayException e) { + throw buildUnifiedOrderException(reqDTO, e); + } + } + + /** + * 【V2】调用支付渠道,统一下单 + * + * @param reqDTO 下单信息 + * @return 各支付渠道的返回结果 + */ + protected abstract PayOrderUnifiedRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) + throws WxPayException; + + /** + * 【V3】调用支付渠道,统一下单 + * + * @param reqDTO 下单信息 + * @return 各支付渠道的返回结果 + */ + protected abstract PayOrderUnifiedRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) + throws WxPayException; + + + @Override + public Object parseNotify(PayNotifyReqDTO rawNotify) { + log.info("[parseNotify][微信支付回调 data 数据: {}]", rawNotify.getBody()); + try { + // 微信支付 v2 回调结果处理 + switch (config.getApiVersion()) { + case WxPayClientConfig.API_VERSION_V2: + return parseOrderNotifyV2(rawNotify); + case WxPayClientConfig.API_VERSION_V3: + return parseOrderNotifyV3(rawNotify); + default: + throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); + } + } catch (WxPayException e) { + log.error("[parseNotify][rawNotify({}) 解析失败]", toJsonString(rawNotify), e); +// throw buildPayException(e); + throw new RuntimeException(e); + // TODO 芋艿:缺一个异常翻译 + } + } + + private PayOrderNotifyRespDTO parseOrderNotifyV2(PayNotifyReqDTO data) throws WxPayException { + WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody()); + Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS"); + // 转换结果 + return PayOrderNotifyRespDTO + .builder() + .orderExtensionNo(notifyResult.getOutTradeNo()) + .channelOrderNo(notifyResult.getTransactionId()) + .channelUserId(notifyResult.getOpenid()) + .successTime(parseDateV2(notifyResult.getTimeEnd())) + .build(); + } + + private PayOrderNotifyRespDTO parseOrderNotifyV3(PayNotifyReqDTO data) throws WxPayException { + WxPayOrderNotifyV3Result notifyResult = client.parseOrderNotifyV3Result(data.getBody(), null); + WxPayOrderNotifyV3Result.DecryptNotifyResult result = notifyResult.getResult(); + // 转换结果 + Assert.isTrue(Objects.equals(notifyResult.getResult().getTradeState(), "SUCCESS"), + "支付结果非 SUCCESS"); + return PayOrderNotifyRespDTO.builder() + .orderExtensionNo(result.getOutTradeNo()) + .channelOrderNo(result.getTradeState()) + .channelUserId(result.getPayer() != null ? result.getPayer().getOpenid() : null) + .successTime(parseDateV3(result.getSuccessTime())) + .build(); + } + + // ========== 各种工具方法 ========== + + /** + * 构建统一下单的异常 + * + * 目的:将参数不正确等异常,转换成 {@link cn.iocoder.yudao.framework.common.exception.ServiceException} 业务异常 + * + * @param reqDTO 请求 + * @param e 微信的支付异常 + * @return 转换后的异常 + * + */ + static Exception buildUnifiedOrderException(PayOrderUnifiedReqDTO reqDTO, WxPayException e) { + // 情况一:业务结果为 FAIL + if (Objects.equals(e.getResultCode(), "FAIL")) { + log.error("[buildUnifiedOrderException][request({}) 发起支付失败]", toJsonString(reqDTO), e); + if (Objects.equals(e.getErrCode(), "PARAM_ERROR")) { + throw invalidParamException(e.getErrCodeDes()); + } + throw exception(PayFrameworkErrorCodeConstants.ORDER_UNIFIED_ERROR, e.getErrCodeDes()); + } + // 情况二:状态码结果为 FAIL + if (Objects.equals(e.getReturnCode(), "FAIL")) { + throw exception(PayFrameworkErrorCodeConstants.ORDER_UNIFIED_ERROR, e.getReturnMsg()); + } + // 情况三:系统异常,这里暂时不打,交给上层的 AbstractPayClient 统一打 + return e; + } + + static String formatDateV2(LocalDateTime time) { + return TemporalAccessorUtil.format(time.atZone(ZoneId.systemDefault()), PURE_DATETIME_PATTERN); + } + + static LocalDateTime parseDateV2(String time) { + return LocalDateTimeUtil.parse(time, PURE_DATETIME_PATTERN); + } + + static String formatDateV3(LocalDateTime time) { + return TemporalAccessorUtil.format(time.atZone(ZoneId.systemDefault()), UTC_WITH_XXX_OFFSET_PATTERN); + } + + static LocalDateTime parseDateV3(String time) { + return LocalDateTimeUtil.parse(time, UTC_WITH_XXX_OFFSET_PATTERN); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxAppPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxAppPayClient.java new file mode 100644 index 000000000..2b1e8459b --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxAppPayClient.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; + +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedRespDTO; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; +import com.github.binarywang.wxpay.constant.WxPayConstants; +import com.github.binarywang.wxpay.exception.WxPayException; + +// TODO 芋艿:未实现 +public class WxAppPayClient extends AbstractWxPayClient { + + public WxAppPayClient(Long channelId, WxPayClientConfig config) { + super(channelId, PayChannelEnum.WX_APP.getCode(), config); + } + + @Override + protected void doInit() { + super.doInit(WxPayConstants.TradeType.APP); + } + + @Override + protected PayRefundUnifiedRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable { + return null; + } + + @Override + protected PayOrderUnifiedRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { + return null; + } + + @Override + protected PayOrderUnifiedRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { + return null; + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClient.java new file mode 100644 index 000000000..47df5625c --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxBarPayClient.java @@ -0,0 +1,113 @@ +package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; + +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedRespDTO; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; +import com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest; +import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult; +import com.github.binarywang.wxpay.constant.WxPayConstants; +import com.github.binarywang.wxpay.exception.WxPayException; +import lombok.extern.slf4j.Slf4j; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.concurrent.TimeUnit; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; + +/** + * 微信支付【付款码支付】的 PayClient 实现类 + * + * 文档:付款码支付 + * + * @author 芋道源码 + */ +@Slf4j +public class WxBarPayClient extends AbstractWxPayClient { + + /** + * 微信付款码的过期时间 + */ + private static final Duration AUTH_CODE_EXPIRE = Duration.ofMinutes(3); + + public WxBarPayClient(Long channelId, WxPayClientConfig config) { + super(channelId, PayChannelEnum.WX_BAR.getCode(), config); + } + + @Override + protected void doInit() { + super.doInit(WxPayConstants.TradeType.MICROPAY); + } + + @Override + protected PayOrderUnifiedRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { + // 由于付款码需要不断轮询,所以需要在较短的时间完成支付 + LocalDateTime expireTime = LocalDateTimeUtils.addTime(AUTH_CODE_EXPIRE); + if (expireTime.isAfter(reqDTO.getExpireTime())) { + expireTime = reqDTO.getExpireTime(); + } + // 构建 WxPayMicropayRequest 对象 + WxPayMicropayRequest request = WxPayMicropayRequest.newBuilder() + .outTradeNo(reqDTO.getMerchantOrderId()) + .body(reqDTO.getSubject()) + .detail(reqDTO.getBody()) + .totalFee(reqDTO.getAmount()) // 单位分 + .timeExpire(formatDateV2(expireTime)) + .spbillCreateIp(reqDTO.getUserIp()) + .authCode(getAuthCode(reqDTO)) + .build(); + // 执行请求,重试直到失败(过期),或者成功 + for (int i = 1; i < Byte.MAX_VALUE; i++) { + try { + WxPayMicropayResult response = client.micropay(request); + // 支付成功(例如说,用户输入了密码) + return new PayOrderUnifiedRespDTO(PayOrderDisplayModeEnum.BAR_CODE.getMode(), + JsonUtils.toJsonString(response), + PayOrderStatusRespEnum.SUCCESS.getStatus()); + } catch (WxPayException ex) { + // 如果不满足这 3 种任一的,则直接抛出 WxPayException 异常,不仅需处理 + // 1. SYSTEMERROR:接口返回错误:请立即调用被扫订单结果查询API,查询当前订单状态,并根据订单的状态决定下一步的操作。 + // 2. USERPAYING:用户支付中,需要输入密码:等待 5 秒,然后调用被扫订单结果查询 API,查询当前订单的不同状态,决定下一步的操作。 + // 3. BANKERROR:银行系统异常:请立即调用被扫订单结果查询 API,查询当前订单的不同状态,决定下一步的操作。 + if (!StrUtil.equalsAny(ex.getErrCode(), "SYSTEMERROR", "USERPAYING", "BANKERROR")) { + throw ex; + } + // 等待 5 秒,继续下一轮重新发起支付 + log.info("[doUnifiedOrderV2][发起微信 Bar 支付第({})失败,等待下一轮重试,请求({}),响应({})]", i, + JsonUtils.toJsonString(request), ex.getMessage()); + ThreadUtil.sleep(5, TimeUnit.SECONDS); + } + } + throw new IllegalStateException("微信 Bar 支付,重试多次失败"); + } + + @Override + protected PayOrderUnifiedRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { + return doUnifiedOrderV2(reqDTO); + } + + @Override + protected PayRefundUnifiedRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { + return null; + } + + // ========== 各种工具方法 ========== + + static String getAuthCode(PayOrderUnifiedReqDTO reqDTO) { + String authCode = MapUtil.getStr(reqDTO.getChannelExtras(), "authCode"); + if (StrUtil.isEmpty(authCode)) { + throw invalidParamException("支付请求的 authCode 不能为空!"); + } + return authCode; + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxH5PayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxH5PayClient.java new file mode 100644 index 000000000..8d0a68034 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxH5PayClient.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; + +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedRespDTO; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; +import com.github.binarywang.wxpay.constant.WxPayConstants; +import com.github.binarywang.wxpay.exception.WxPayException; + +// TODO 芋艿:未实现 +public class WxH5PayClient extends AbstractWxPayClient { + + public WxH5PayClient(Long channelId, WxPayClientConfig config) { + super(channelId, PayChannelEnum.WX_H5.getCode(), config); + } + + @Override + protected void doInit() { + super.doInit(WxPayConstants.TradeType.MWEB); + } + + @Override + protected PayRefundUnifiedRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable { + return null; + } + + @Override + protected PayOrderUnifiedRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { + return null; + } + + @Override + protected PayOrderUnifiedRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { + return null; + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxLitePayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxLitePayClient.java new file mode 100644 index 000000000..9929955ae --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxLitePayClient.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; + +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; +import lombok.extern.slf4j.Slf4j; + +/** + * 微信支付【小程序】的 PayClient 实现类 + * + * 由于公众号和小程序的微信支付逻辑一致,所以直接进行继承 + * + * 文档:JSAPI 下单 + * + * @author zwy + */ +@Slf4j +public class WxLitePayClient extends WxPubPayClient { + + public WxLitePayClient(Long channelId, WxPayClientConfig config) { + super(channelId, PayChannelEnum.WX_LITE.getCode(), config); + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java new file mode 100644 index 000000000..bec86060f --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxNativePayClient.java @@ -0,0 +1,80 @@ +package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; + +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedRespDTO; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; +import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; +import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; +import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; +import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; +import com.github.binarywang.wxpay.constant.WxPayConstants; +import com.github.binarywang.wxpay.exception.WxPayException; +import lombok.extern.slf4j.Slf4j; + +/** + * 微信支付【Native 二维码】的 PayClient 实现类 + * + * 文档:Native 下单 + * + * @author zwy + */ +@Slf4j +public class WxNativePayClient extends AbstractWxPayClient { + + public WxNativePayClient(Long channelId, WxPayClientConfig config) { + super(channelId, PayChannelEnum.WX_NATIVE.getCode(), config); + } + + @Override + protected void doInit() { + super.doInit(WxPayConstants.TradeType.NATIVE); + } + + @Override + protected PayOrderUnifiedRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { + // 构建 WxPayUnifiedOrderRequest 对象 + WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest.newBuilder() + .outTradeNo(reqDTO.getMerchantOrderId()) + .body(reqDTO.getSubject()) + .detail(reqDTO.getBody()) + .totalFee(reqDTO.getAmount()) // 单位分 + .productId(reqDTO.getMerchantOrderId()) + .timeExpire(formatDateV2(reqDTO.getExpireTime())) + .spbillCreateIp(reqDTO.getUserIp()) + .notifyUrl(reqDTO.getNotifyUrl()) + .build(); + // 执行请求 + WxPayNativeOrderResult response = client.createOrder(request); + + // 转换结果 + return new PayOrderUnifiedRespDTO(PayOrderDisplayModeEnum.QR_CODE_URL.getMode(), + response.getCodeUrl()); + } + + @Override + protected PayOrderUnifiedRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { + // 构建 WxPayUnifiedOrderRequest 对象 + WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request(); + request.setOutTradeNo(reqDTO.getMerchantOrderId()); + request.setDescription(reqDTO.getBody()); + request.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(reqDTO.getAmount())); // 单位分 + request.setTimeExpire(formatDateV3(reqDTO.getExpireTime())); + request.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(reqDTO.getUserIp())); + request.setNotifyUrl(reqDTO.getNotifyUrl()); + // 执行请求 + WxPayNativeOrderResult response = client.createOrderV3(TradeTypeEnum.NATIVE, request); + + // 转换结果 + return new PayOrderUnifiedRespDTO(PayOrderDisplayModeEnum.QR_CODE_URL.getMode(), + response.getCodeUrl()); + } + + @Override + protected PayRefundUnifiedRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable { + return null; + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPayClientConfig.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPayClientConfig.java similarity index 88% rename from yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPayClientConfig.java rename to yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPayClientConfig.java index 294f8e4ff..e109a6cf7 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPayClientConfig.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPayClientConfig.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.wx; +package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; import cn.hutool.core.io.IoUtil; import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; @@ -18,23 +18,26 @@ import java.util.Set; * @author 芋道源码 */ @Data -public class WXPayClientConfig implements PayClientConfig { +public class WxPayClientConfig implements PayClientConfig { /** * API 版本 - V2 - * https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4_1 + * + * V2 协议说明 */ public static final String API_VERSION_V2 = "v2"; /** * API 版本 - V3 - * https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay-1.shtml + * + * V3 协议说明 */ public static final String API_VERSION_V3 = "v3"; /** * 公众号或者小程序的 appid + * + * 只有公众号或小程序需要该字段 */ - @NotBlank(message = "APPID 不能为空", groups = {V2.class, V3.class}) private String appId; /** * 商户号 diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java new file mode 100644 index 000000000..f23942bc7 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/weixin/WxPubPayClient.java @@ -0,0 +1,102 @@ +package cn.iocoder.yudao.framework.pay.core.client.impl.weixin; + +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; +import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedRespDTO; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderDisplayModeEnum; +import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; +import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; +import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; +import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result; +import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; +import com.github.binarywang.wxpay.constant.WxPayConstants; +import com.github.binarywang.wxpay.exception.WxPayException; +import lombok.extern.slf4j.Slf4j; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; + +/** + * 微信支付(公众号)的 PayClient 实现类 + * + * 文档:JSAPI 下单 + * + * @author 芋道源码 + */ +@Slf4j +public class WxPubPayClient extends AbstractWxPayClient { + + public WxPubPayClient(Long channelId, WxPayClientConfig config) { + super(channelId, PayChannelEnum.WX_PUB.getCode(), config); + } + + protected WxPubPayClient(Long channelId, String channelCode, WxPayClientConfig config) { + super(channelId, channelCode, config); + } + + @Override + protected void doInit() { + super.doInit(WxPayConstants.TradeType.JSAPI); + } + + @Override + protected PayOrderUnifiedRespDTO doUnifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { + // 构建 WxPayUnifiedOrderRequest 对象 + WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest.newBuilder() + .outTradeNo(reqDTO.getMerchantOrderId()) + .body(reqDTO.getSubject()) + .detail(reqDTO.getBody()) + .totalFee(reqDTO.getAmount()) // 单位分 + .timeExpire(formatDateV2(reqDTO.getExpireTime())) + .spbillCreateIp(reqDTO.getUserIp()) + .openid(getOpenid(reqDTO)) + .notifyUrl(reqDTO.getNotifyUrl()) + .build(); + // 执行请求 + WxPayMpOrderResult response = client.createOrder(request); + + // 转换结果 + return new PayOrderUnifiedRespDTO(PayOrderDisplayModeEnum.CUSTOM.getMode(), + JsonUtils.toJsonString(response)); + } + + @Override + protected PayOrderUnifiedRespDTO doUnifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { + // 构建 WxPayUnifiedOrderRequest 对象 + WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request(); + request.setOutTradeNo(reqDTO.getMerchantOrderId()); + request.setDescription(reqDTO.getSubject()); + request.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(reqDTO.getAmount())); // 单位分 + request.setTimeExpire(formatDateV3(reqDTO.getExpireTime())); + request.setPayer(new WxPayUnifiedOrderV3Request.Payer().setOpenid(getOpenid(reqDTO))); + request.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(reqDTO.getUserIp())); + request.setNotifyUrl(reqDTO.getNotifyUrl()); + // 执行请求 + WxPayUnifiedOrderV3Result.JsapiResult response = client.createOrderV3(TradeTypeEnum.JSAPI, request); + + // 转换结果 + return new PayOrderUnifiedRespDTO(PayOrderDisplayModeEnum.CUSTOM.getMode(), + JsonUtils.toJsonString(response)); + } + + @Override + protected PayRefundUnifiedRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { + // TODO 需要实现 + throw new UnsupportedOperationException(); + } + + // ========== 各种工具方法 ========== + + static String getOpenid(PayOrderUnifiedReqDTO reqDTO) { + String openid = MapUtil.getStr(reqDTO.getChannelExtras(), "openid"); + if (StrUtil.isEmpty(openid)) { + throw invalidParamException("支付请求的 openid 不能为空!"); + } + return openid; + } + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXLitePayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXLitePayClient.java deleted file mode 100644 index 46ac3139e..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXLitePayClient.java +++ /dev/null @@ -1,198 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.wx; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.io.FileUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayNotifyReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayOrderNotifyRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayRefundNotifyRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; -import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result; -import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; -import lombok.extern.slf4j.Slf4j; - -import java.time.ZoneId; -import java.util.Date; -import java.util.Objects; - -/** - * 微信小程序下支付 - * - * @author zwy - */ -@Slf4j -public class WXLitePayClient extends AbstractPayClient { - - private WxPayService client; - - public WXLitePayClient(Long channelId, WXPayClientConfig config) { - super(channelId, PayChannelEnum.WX_LITE.getCode(), config); - } - - @Override - protected void doInit() { - WxPayConfig payConfig = new WxPayConfig(); - BeanUtil.copyProperties(config, payConfig, "privateKeyContent","privateCertContent"); - payConfig.setTradeType(WxPayConstants.TradeType.JSAPI); // 设置使用 JS API 支付方式 -// if (StrUtil.isNotEmpty(config.getKeyContent())) { -// payConfig.setKeyContent(config.getKeyContent().getBytes(StandardCharsets.UTF_8)); -// } - if (StrUtil.isNotEmpty(config.getPrivateKeyContent())) { - // weixin-pay-java 存在 BUG,无法直接设置内容,所以创建临时文件来解决 - payConfig.setPrivateKeyPath(FileUtils.createTempFile(config.getPrivateKeyContent()).getPath()); - } - if (StrUtil.isNotEmpty(config.getPrivateCertContent())) { - // weixin-pay-java 存在 BUG,无法直接设置内容,所以创建临时文件来解决 - payConfig.setPrivateCertPath(FileUtils.createTempFile(config.getPrivateCertContent()).getPath()); - } - // 真实客户端 - this.client = new WxPayServiceImpl(); - client.setConfig(payConfig); - } - - @Override - public PayOrderUnifiedRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - throw new UnsupportedOperationException(); -// WxPayMpOrderResult response; -// try { -// switch (config.getApiVersion()) { -// case WXPayClientConfig.API_VERSION_V2: -// response = this.unifiedOrderV2(reqDTO); -// break; -// case WXPayClientConfig.API_VERSION_V3: -// WxPayUnifiedOrderV3Result.JsapiResult responseV3 = this.unifiedOrderV3(reqDTO); -// // 将 V3 的结果,统一转换成 V2。返回的字段是一致的 -// response = new WxPayMpOrderResult(); -// BeanUtil.copyProperties(responseV3, response, true); -// break; -// default: -// throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); -// } -// } catch (WxPayException e) { -// log.error("[unifiedOrder][request({}) 发起支付失败,原因({})]", toJsonString(reqDTO), e); -// return PayCommonResult.build(ObjectUtils.defaultIfNull(e.getErrCode(), e.getReturnCode(), "CustomErrorCode"), -// ObjectUtils.defaultIfNull(e.getErrCodeDes(), e.getCustomErrorMsg()), null, codeMapping); -// } -// return PayCommonResult.build(CODE_SUCCESS, MESSAGE_SUCCESS, response, codeMapping); - } - - private WxPayMpOrderResult unifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest.newBuilder() - .outTradeNo(reqDTO.getMerchantOrderId()) - .body(reqDTO.getBody()) - .totalFee(reqDTO.getAmount().intValue()) // 单位分 - .timeExpire(DateUtil.format(reqDTO.getExpireTime(), "yyyyMMddHHmmss")) // v2的时间格式 - .spbillCreateIp(reqDTO.getUserIp()) - .openid(getOpenid(reqDTO)) - .notifyUrl(reqDTO.getNotifyUrl()) - .build(); - // 执行请求 - return client.createOrder(request); - } - - private WxPayUnifiedOrderV3Result.JsapiResult unifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request(); - request.setOutTradeNo(reqDTO.getMerchantOrderId()); - - request.setDescription(reqDTO.getBody()); - request.setAmount(new WxPayUnifiedOrderV3Request - .Amount() - .setTotal(reqDTO - .getAmount() - .intValue())); // 单位分 - request.setTimeExpire(DateUtil.format(Date.from(reqDTO.getExpireTime().atZone(ZoneId.systemDefault()).toInstant()), "yyyy-MM-dd'T'HH:mm:ssXXX")); // v3的时间格式 - request.setPayer(new WxPayUnifiedOrderV3Request.Payer().setOpenid(getOpenid(reqDTO))); - request.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(reqDTO.getUserIp())); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - // 执行请求 - return client.createOrderV3(TradeTypeEnum.JSAPI, request); - } - - private static String getOpenid(PayOrderUnifiedReqDTO reqDTO) { - String openid = MapUtil.getStr(reqDTO.getChannelExtras(), "openid"); - if (StrUtil.isEmpty(openid)) { - throw new IllegalArgumentException("支付请求的 openid 不能为空!"); - } - return openid; - } - - /** - * - * 微信支付回调 分 v2 和v3 的处理方式 - * - * @param data 通知结果 - * @return 支付回调对象 - * @throws WxPayException 微信异常类 - */ -// @Override - public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyReqDTO data) throws WxPayException { - log.info("[parseOrderNotify][微信支付回调data数据:{}]", data.getBody()); - // 微信支付 v2 回调结果处理 - switch (config.getApiVersion()) { - case WXPayClientConfig.API_VERSION_V2: - return parseOrderNotifyV2(data); - case WXPayClientConfig.API_VERSION_V3: - return parseOrderNotifyV3(data); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } - - private PayOrderNotifyRespDTO parseOrderNotifyV3(PayNotifyReqDTO data) throws WxPayException { - WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null); - WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult(); - // 转换结果 - Assert.isTrue(Objects.equals(wxPayOrderNotifyV3Result.getResult().getTradeState(), "SUCCESS"), - "支付结果非 SUCCESS"); - - return PayOrderNotifyRespDTO - .builder() - .orderExtensionNo(result.getOutTradeNo()) - .channelOrderNo(result.getTransactionId()) - .channelUserId(result.getPayer().getOpenid()) - .successTime(LocalDateTimeUtil.parse(result.getSuccessTime(), "yyyy-MM-dd'T'HH:mm:ssXXX")) - .build(); - } - - private PayOrderNotifyRespDTO parseOrderNotifyV2(PayNotifyReqDTO data) throws WxPayException { - WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody()); - Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS"); - // 转换结果 - return PayOrderNotifyRespDTO - .builder() - .orderExtensionNo(notifyResult.getOutTradeNo()) - .channelOrderNo(notifyResult.getTransactionId()) - .channelUserId(notifyResult.getOpenid()) - .successTime(LocalDateTimeUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss")) - .build(); - - } - - @Override - protected PayRefundUnifiedRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - //TODO 需要实现 - throw new UnsupportedOperationException(); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXNativePayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXNativePayClient.java deleted file mode 100644 index d31cdcd30..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXNativePayClient.java +++ /dev/null @@ -1,181 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.wx; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.io.FileUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayNotifyReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayOrderNotifyRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayRefundNotifyRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; -import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result; -import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; -import lombok.extern.slf4j.Slf4j; - -import java.time.ZoneId; -import java.util.Date; -import java.util.Objects; - -/** - * 微信 App 支付 - * - * @author zwy - */ -@Slf4j -public class WXNativePayClient extends AbstractPayClient { - - private WxPayService client; - - public WXNativePayClient(Long channelId, WXPayClientConfig config) { - super(channelId, PayChannelEnum.WX_NATIVE.getCode(), config); - } - - @Override - protected void doInit() { - WxPayConfig payConfig = new WxPayConfig(); - BeanUtil.copyProperties(config, payConfig, "keyContent"); - payConfig.setTradeType(WxPayConstants.TradeType.NATIVE); // 设置使用 native 支付方式 -// if (StrUtil.isNotEmpty(config.getKeyContent())) { -// payConfig.setKeyContent(config.getKeyContent().getBytes(StandardCharsets.UTF_8)); -// } - if (StrUtil.isNotEmpty(config.getPrivateKeyContent())) { - // weixin-pay-java 存在 BUG,无法直接设置内容,所以创建临时文件来解决 - payConfig.setPrivateKeyPath(FileUtils.createTempFile(config.getPrivateKeyContent()).getPath()); - } - if (StrUtil.isNotEmpty(config.getPrivateCertContent())) { - // weixin-pay-java 存在 BUG,无法直接设置内容,所以创建临时文件来解决 - payConfig.setPrivateCertPath(FileUtils.createTempFile(config.getPrivateCertContent()).getPath()); - } - // 真实客户端 - this.client = new WxPayServiceImpl(); - client.setConfig(payConfig); - } - - @Override - public PayOrderUnifiedRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - throw new UnsupportedOperationException(); -// // 这里原生的返回的是支付的 url 所以直接使用string接收 -// // "invokeResponse": "weixin://wxpay/bizpayurl?pr=EGYAem7zz" -// String responseV3; -// try { -// switch (config.getApiVersion()) { -// case WXPayClientConfig.API_VERSION_V2: -// responseV3 = unifiedOrderV2(reqDTO).getCodeUrl(); -// break; -// case WXPayClientConfig.API_VERSION_V3: -// responseV3 = this.unifiedOrderV3(reqDTO); -// break; -// default: -// throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); -// } -// } catch (WxPayException e) { -// log.error("[unifiedOrder][request({}) 发起支付失败,原因({})]", toJsonString(reqDTO), e); -// return PayCommonResult.build(ObjectUtils.defaultIfNull(e.getErrCode(), e.getReturnCode(), "CustomErrorCode"), -// ObjectUtils.defaultIfNull(e.getErrCodeDes(), e.getCustomErrorMsg()), null, codeMapping); -// } -// return PayCommonResult.build(CODE_SUCCESS, MESSAGE_SUCCESS, responseV3, codeMapping); - } - - private WxPayNativeOrderResult unifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - //前端 - String tradeType = reqDTO.getChannelExtras().get("trade_type"); - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest - .newBuilder() - .outTradeNo(reqDTO.getMerchantOrderId()) - .body(reqDTO.getBody()) - .totalFee(reqDTO.getAmount().intValue()) // 单位分 - .timeExpire(DateUtil.format(Date.from(reqDTO.getExpireTime().atZone(ZoneId.systemDefault()).toInstant()), "yyyy-MM-dd'T'HH:mm:ssXXX")) - .spbillCreateIp(reqDTO.getUserIp()) - .notifyUrl(reqDTO.getNotifyUrl()) - .productId(tradeType) - .build(); - // 执行请求 - return client.createOrder(request); - } - - private String unifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request(); - request.setOutTradeNo(reqDTO.getMerchantOrderId()); - request.setDescription(reqDTO.getBody()); - request.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(reqDTO.getAmount().intValue())); // 单位分 - request.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(reqDTO.getUserIp())); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - // 执行请求 - return client.createOrderV3(TradeTypeEnum.NATIVE, request); - } - - /** - * - * 微信支付回调 分v2 和v3 的处理方式 - * - * @param data 通知结果 - * @return 支付回调对象 - * @throws WxPayException 微信异常类 - */ -// @Override - public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyReqDTO data) throws WxPayException { - log.info("微信支付回调data数据:{}", data.getBody()); - // 微信支付 v2 回调结果处理 - switch (config.getApiVersion()) { - case WXPayClientConfig.API_VERSION_V2: - return parseOrderNotifyV2(data); - case WXPayClientConfig.API_VERSION_V3: - return parseOrderNotifyV3(data); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } - - private PayOrderNotifyRespDTO parseOrderNotifyV3(PayNotifyReqDTO data) throws WxPayException { - WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null); - WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult(); - // 转换结果 - Assert.isTrue(Objects.equals(wxPayOrderNotifyV3Result.getResult().getTradeState(), "SUCCESS"), - "支付结果非 SUCCESS"); - return PayOrderNotifyRespDTO - .builder() - .orderExtensionNo(result.getOutTradeNo()) - .channelOrderNo(result.getTradeState()) - .successTime(LocalDateTimeUtil.parse(result.getSuccessTime(), "yyyy-MM-dd'T'HH:mm:ssXXX")) - .build(); - } - - private PayOrderNotifyRespDTO parseOrderNotifyV2(PayNotifyReqDTO data) throws WxPayException { - WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody()); - Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS"); - // 转换结果 - return PayOrderNotifyRespDTO - .builder() - .orderExtensionNo(notifyResult.getOutTradeNo()) - .channelOrderNo(notifyResult.getTransactionId()) - .channelUserId(notifyResult.getOpenid()) - .successTime(LocalDateTimeUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss")) - .build(); - - } - - @Override - protected PayRefundUnifiedRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - // TODO 需要实现 - throw new UnsupportedOperationException(); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPubPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPubPayClient.java deleted file mode 100644 index f4645829d..000000000 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPubPayClient.java +++ /dev/null @@ -1,196 +0,0 @@ -package cn.iocoder.yudao.framework.pay.core.client.impl.wx; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.date.TemporalAccessorUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.io.FileUtils; -import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayNotifyReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayOrderNotifyRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedRespDTO; -import cn.iocoder.yudao.framework.pay.core.client.impl.AbstractPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; -import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result; -import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; -import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request; -import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result; -import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum; -import com.github.binarywang.wxpay.config.WxPayConfig; -import com.github.binarywang.wxpay.constant.WxPayConstants; -import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.service.WxPayService; -import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; -import lombok.extern.slf4j.Slf4j; - -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.Objects; - -/** - * 微信支付(公众号)的 PayClient 实现类 - * - * @author 芋道源码 - */ -@Slf4j -public class WXPubPayClient extends AbstractPayClient { - - private WxPayService client; - - public WXPubPayClient(Long channelId, WXPayClientConfig config) { - super(channelId, PayChannelEnum.WX_PUB.getCode(), config); - } - - @Override - protected void doInit() { - WxPayConfig payConfig = new WxPayConfig(); - BeanUtil.copyProperties(config, payConfig, "keyContent"); - payConfig.setTradeType(WxPayConstants.TradeType.JSAPI); // 设置使用 JS API 支付方式 -// if (StrUtil.isNotEmpty(config.getKeyContent())) { -// payConfig.setKeyContent(config.getKeyContent().getBytes(StandardCharsets.UTF_8)); -// } - if (StrUtil.isNotEmpty(config.getPrivateKeyContent())) { - // weixin-pay-java 存在 BUG,无法直接设置内容,所以创建临时文件来解决 - payConfig.setPrivateKeyPath(FileUtils.createTempFile(config.getPrivateKeyContent()).getPath()); - } - if (StrUtil.isNotEmpty(config.getPrivateCertContent())) { - // weixin-pay-java 存在 BUG,无法直接设置内容,所以创建临时文件来解决 - payConfig.setPrivateCertPath(FileUtils.createTempFile(config.getPrivateCertContent()).getPath()); - } - // 真实客户端 - this.client = new WxPayServiceImpl(); - client.setConfig(payConfig); - } - - @Override - public PayOrderUnifiedRespDTO doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) { - throw new UnsupportedOperationException(); -// -// WxPayMpOrderResult response; -// try { -// switch (config.getApiVersion()) { -// case WXPayClientConfig.API_VERSION_V2: -// response = this.unifiedOrderV2(reqDTO); -// break; -// case WXPayClientConfig.API_VERSION_V3: -// WxPayUnifiedOrderV3Result.JsapiResult responseV3 = this.unifiedOrderV3(reqDTO); -// // 将 V3 的结果,统一转换成 V2。返回的字段是一致的 -// response = new WxPayMpOrderResult(); -// BeanUtil.copyProperties(responseV3, response, true); -// break; -// default: -// throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); -// } -// } catch (WxPayException e) { -// log.error("[unifiedOrder][request({}) 发起支付失败,原因({})]", toJsonString(reqDTO), e); -// return PayCommonResult.build(ObjectUtils.defaultIfNull(e.getErrCode(), e.getReturnCode(), "CustomErrorCode"), -// ObjectUtils.defaultIfNull(e.getErrCodeDes(), e.getCustomErrorMsg()),null, codeMapping); -// } -// return PayCommonResult.build(CODE_SUCCESS, MESSAGE_SUCCESS, response, codeMapping); - } - - - private WxPayMpOrderResult unifiedOrderV2(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest.newBuilder() - .outTradeNo(reqDTO.getMerchantOrderId()) - .body(reqDTO.getBody()) - .totalFee(reqDTO.getAmount()) // 单位分 - .timeExpire(formatDate(reqDTO.getExpireTime())) - .spbillCreateIp(reqDTO.getUserIp()) - .openid(getOpenid(reqDTO)) - .notifyUrl(reqDTO.getNotifyUrl()) - .build(); - // 执行请求 - return client.createOrder(request); - } - - private WxPayUnifiedOrderV3Result.JsapiResult unifiedOrderV3(PayOrderUnifiedReqDTO reqDTO) throws WxPayException { - // 构建 WxPayUnifiedOrderRequest 对象 - WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request(); - request.setOutTradeNo(reqDTO.getMerchantOrderId()); - request.setDescription(reqDTO.getBody()); - request.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(reqDTO.getAmount())); // 单位分 - request.setTimeExpire(formatDate(reqDTO.getExpireTime())); - request.setPayer(new WxPayUnifiedOrderV3Request.Payer().setOpenid(getOpenid(reqDTO))); - request.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(reqDTO.getUserIp())); - request.setNotifyUrl(reqDTO.getNotifyUrl()); - // 执行请求 - return client.createOrderV3(TradeTypeEnum.JSAPI, request); - } - - private static String getOpenid(PayOrderUnifiedReqDTO reqDTO) { - String openid = MapUtil.getStr(reqDTO.getChannelExtras(), "openid"); - if (StrUtil.isEmpty(openid)) { - throw new IllegalArgumentException("支付请求的 openid 不能为空!"); - } - return openid; - } - - /** - * - * 微信支付回调 分v2 和v3 的处理方式 - * - * @param data 通知结果 - * @return 支付回调对象 - * @throws WxPayException 微信异常类 - */ -// @Override - public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyReqDTO data) throws WxPayException { - log.info("[parseOrderNotify][微信支付回调data数据: {}]", data.getBody()); - // 微信支付 v2 回调结果处理 - switch (config.getApiVersion()) { - case WXPayClientConfig.API_VERSION_V2: - return parseOrderNotifyV2(data); - case WXPayClientConfig.API_VERSION_V3: - return parseOrderNotifyV3(data); - default: - throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion())); - } - } - - private PayOrderNotifyRespDTO parseOrderNotifyV3(PayNotifyReqDTO data) throws WxPayException { - WxPayOrderNotifyV3Result wxPayOrderNotifyV3Result = client.parseOrderNotifyV3Result(data.getBody(), null); - WxPayOrderNotifyV3Result.DecryptNotifyResult result = wxPayOrderNotifyV3Result.getResult(); - // 转换结果 - Assert.isTrue(Objects.equals(wxPayOrderNotifyV3Result.getResult().getTradeState(), "SUCCESS"), - "支付结果非 SUCCESS"); - return PayOrderNotifyRespDTO - .builder() - .orderExtensionNo(result.getOutTradeNo()) - .channelOrderNo(result.getTradeState()) - .successTime(LocalDateTimeUtil.parse(result.getSuccessTime(), "yyyy-MM-dd'T'HH:mm:ssXXX")) - .build(); - } - - private PayOrderNotifyRespDTO parseOrderNotifyV2(PayNotifyReqDTO data) throws WxPayException { - WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data.getBody()); - Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS"); - // 转换结果 - return PayOrderNotifyRespDTO - .builder() - .orderExtensionNo(notifyResult.getOutTradeNo()) - .channelOrderNo(notifyResult.getTransactionId()) - .channelUserId(notifyResult.getOpenid()) - .successTime(LocalDateTimeUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss")) - .build(); - - } - - @Override - protected PayRefundUnifiedRespDTO doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable { - // TODO 需要实现 - throw new UnsupportedOperationException(); - } - - private static String formatDate(LocalDateTime time) { - return TemporalAccessorUtil.format(time.atZone(ZoneId.systemDefault()), "yyyy-MM-dd'T'HH:mm:ssXXX"); - } - -} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayFrameworkErrorCodeConstants.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayFrameworkErrorCodeConstants.java index ca76059ef..d9abcc18d 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayFrameworkErrorCodeConstants.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayFrameworkErrorCodeConstants.java @@ -11,19 +11,6 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; */ public interface PayFrameworkErrorCodeConstants { - ErrorCode PAY_UNKNOWN = new ErrorCode(2002000000, "未知错误,需要解析"); - - // ========== 配置相关相关 2002000100 ========== - // todo 芋艿:如下的错误码,怎么处理掉 - ErrorCode PAY_CONFIG_APP_ID_ERROR = new ErrorCode(2002000100, "支付渠道 AppId 不正确"); - ErrorCode PAY_CONFIG_SIGN_ERROR = new ErrorCode(2002000100, "签名错误"); // 例如说,微信支付,配置错了 mchId 或者 mchKey - - - // ========== 其它相关 2002000900 开头 ========== - // todo 芋艿:如下的错误码,怎么处理掉 - ErrorCode PAY_OPENID_ERROR = new ErrorCode(2002000900, "无效的 openid"); // 例如说,微信 openid 未授权过 - ErrorCode PAY_PARAM_MISSING = new ErrorCode(2002000901, "请求参数缺失"); // 例如说,支付少传了金额 - - ErrorCode PAY_EXCEPTION = new ErrorCode(2002000999, "调用异常"); + ErrorCode ORDER_UNIFIED_ERROR = new ErrorCode(2002000000, "发起支付失败,原因:{}"); } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java similarity index 68% rename from yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java rename to yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java index c6528ae87..44055e16d 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelEnum.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/channel/PayChannelEnum.java @@ -1,15 +1,14 @@ -package cn.iocoder.yudao.framework.pay.core.enums; +package cn.iocoder.yudao.framework.pay.core.enums.channel; import cn.hutool.core.util.ArrayUtil; 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.wx.WXPayClientConfig; +import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; import lombok.AllArgsConstructor; import lombok.Getter; /** * 支付渠道的编码的枚举 - * 枚举值 * * @author 芋道源码 */ @@ -17,10 +16,12 @@ import lombok.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_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_BAR("wx_bar", "微信付款码支付", WxPayClientConfig.class), + WX_H5("wx_h5", "微信 H5 支付", WxPayClientConfig.class), ALIPAY_PC("alipay_pc", "支付宝 PC 网站支付", AlipayPayClientConfig.class), ALIPAY_WAP("alipay_wap", "支付宝 Wap 网站支付", AlipayPayClientConfig.class), @@ -30,8 +31,8 @@ public enum PayChannelEnum { /** * 编码 - *

- * 参考 https://www.pingxx.com/api/支付渠道属性值.html + * + * 参考 支付渠道属性值 */ private final String code; /** diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayDisplayModeEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderDisplayModeEnum.java similarity index 55% rename from yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayDisplayModeEnum.java rename to yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderDisplayModeEnum.java index d19bfde33..1e81d74c5 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayDisplayModeEnum.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderDisplayModeEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.framework.pay.core.enums; +package cn.iocoder.yudao.framework.pay.core.enums.order; import lombok.AllArgsConstructor; import lombok.Getter; @@ -10,15 +10,16 @@ import lombok.Getter; */ @Getter @AllArgsConstructor -public enum PayDisplayModeEnum { +public enum PayOrderDisplayModeEnum { URL("url"), // Redirect 跳转链接的方式 - IFRAME("iframe"), // IFrame 内嵌链接的方式 + IFRAME("iframe"), // IFrame 内嵌链接的方式【目前暂时用不到】 FORM("form"), // HTML 表单提交 QR_CODE("qr_code"), // 二维码的文字内容 QR_CODE_URL("qr_code_url"), // 二维码的图片链接 BAR_CODE("bar_code"), // 条形码 - APP("app"), // 应用 + APP("app"), // 应用【目前暂时用不到】 + CUSTOM("custom"), // 自定义:每种支付方式,做个性化处理;例如说,微信公众号支付时,调用 JSAPI 接口 ; /** diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderStatusRespEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderStatusRespEnum.java new file mode 100644 index 000000000..059010896 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/order/PayOrderStatusRespEnum.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.framework.pay.core.enums.order; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 渠道的支付状态枚举 + * + * @author 遇到源码 + */ +@Getter +@AllArgsConstructor +public enum PayOrderStatusRespEnum { + + WAITING(0, "未支付"), + SUCCESS(10, "支付成功"), + CLOSED(20, "支付关闭"), // 未付款交易超时关闭,或支付完成后全额退款 + ; + + private final Integer status; + private final String name; + +} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayNotifyRefundStatusEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayNotifyRefundStatusEnum.java similarity index 79% rename from yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayNotifyRefundStatusEnum.java rename to yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayNotifyRefundStatusEnum.java index 7a2b2ef65..5b5387cea 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayNotifyRefundStatusEnum.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayNotifyRefundStatusEnum.java @@ -1,5 +1,6 @@ -package cn.iocoder.yudao.framework.pay.core.enums; +package cn.iocoder.yudao.framework.pay.core.enums.refund; +// TODO 芋艿:看看能不能去掉 /** * 退款通知, 统一的渠道退款状态 * diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelRefundRespEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayRefundRespEnum.java similarity index 67% rename from yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelRefundRespEnum.java rename to yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayRefundRespEnum.java index 53aa16bc2..693c91a27 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelRefundRespEnum.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/refund/PayRefundRespEnum.java @@ -1,16 +1,16 @@ -package cn.iocoder.yudao.framework.pay.core.enums; +package cn.iocoder.yudao.framework.pay.core.enums.refund; import lombok.AllArgsConstructor; import lombok.Getter; /** - * 渠道统一的退款返回结果 + * 渠道的退款状态枚举 * - * @author jason + * @author jason */ @Getter @AllArgsConstructor -public enum PayChannelRefundRespEnum { +public enum PayRefundRespEnum { SUCCESS(1, "退款成功"), FAILURE(2, "退款失败"), diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java index 071f53d12..fee70b4c4 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn/iocoder/yudao/framework/pay/core/client/impl/PayClientFactoryImplIntegrationTest.java @@ -2,17 +2,14 @@ package cn.iocoder.yudao.framework.pay.core.client.impl; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.pay.core.client.PayClient; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayQrPayClient; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayWapPayClient; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPubPayClient; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import com.alipay.api.response.AlipayTradePrecreateResponse; +import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; +import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPubPayClient; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -30,15 +27,15 @@ public class PayClientFactoryImplIntegrationTest { private final PayClientFactoryImpl payClientFactory = new PayClientFactoryImpl(); /** - * {@link WXPubPayClient} 的 V2 版本 + * {@link WxPubPayClient} 的 V2 版本 */ @Test public void testCreatePayClient_WX_PUB_V2() { // 创建配置 - WXPayClientConfig config = new WXPayClientConfig(); + WxPayClientConfig config = new WxPayClientConfig(); config.setAppId("wx041349c6f39b268b"); config.setMchId("1545083881"); - config.setApiVersion(WXPayClientConfig.API_VERSION_V2); + config.setApiVersion(WxPayClientConfig.API_VERSION_V2); config.setMchKey("0alL64UDQdlCwiKZ73ib7ypaIjMns06p"); // 创建客户端 Long channelId = RandomUtil.randomLong(); @@ -51,15 +48,15 @@ public class PayClientFactoryImplIntegrationTest { } /** - * {@link WXPubPayClient} 的 V3 版本 + * {@link WxPubPayClient} 的 V3 版本 */ @Test public void testCreatePayClient_WX_PUB_V3() throws FileNotFoundException { // 创建配置 - WXPayClientConfig config = new WXPayClientConfig(); + WxPayClientConfig config = new WxPayClientConfig(); config.setAppId("wx041349c6f39b268b"); config.setMchId("1545083881"); - config.setApiVersion(WXPayClientConfig.API_VERSION_V3); + config.setApiVersion(WxPayClientConfig.API_VERSION_V3); config.setPrivateKeyContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_key.pem"))); config.setPrivateCertContent(IoUtil.readUtf8(new FileInputStream("/Users/yunai/Downloads/wx_pay/apiclient_cert.pem"))); config.setApiV3Key("joerVi8y5DJ3o4ttA0o1uH47Xz1u2Ase"); diff --git a/yudao-module-member/yudao-module-member-biz/pom.xml b/yudao-module-member/yudao-module-member-biz/pom.xml index 5b135dd7d..a5eda05b0 100644 --- a/yudao-module-member/yudao-module-member-biz/pom.xml +++ b/yudao-module-member/yudao-module-member-biz/pom.xml @@ -41,11 +41,11 @@ cn.iocoder.boot - yudao-spring-boot-starter-biz-weixin + yudao-spring-boot-starter-biz-tenant cn.iocoder.boot - yudao-spring-boot-starter-biz-tenant + yudao-spring-boot-starter-biz-weixin diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/weixin/AppWxMpController.http b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/weixin/AppWxMpController.http deleted file mode 100644 index 60f28c64d..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/weixin/AppWxMpController.http +++ /dev/null @@ -1,2 +0,0 @@ -### 请求 /login 接口 => 成功 -GET {{userServerUrl}}/wx/mp/get-jsapi-ticket diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java index d8c59ad37..e0d23e03a 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java @@ -125,6 +125,7 @@ public class MemberAuthServiceImpl implements MemberAuthService { @Override public AppAuthLoginRespVO weixinMiniAppLogin(AppAuthWeixinMiniAppLoginReqVO reqVO) { // 获得对应的手机号信息 + // TODO @芋艿:需要弱化微信小程序的依赖,通过 system 获取手机号 WxMaPhoneNumberInfo phoneNumberInfo; try { phoneNumberInfo = wxMaService.getUserService().getNewPhoneNoInfo(reqVO.getPhoneCode()); diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java index 4d74cdf02..a53b82a8e 100644 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.pay.enums; -import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.exception.ErrorCode; /** @@ -21,21 +20,15 @@ public interface ErrorCodeConstants { ErrorCode PAY_CHANNEL_CLIENT_NOT_FOUND = new ErrorCode(1007001002, "支付渠道的客户端不存在"); ErrorCode CHANNEL_NOT_EXISTS = new ErrorCode(1007001003, "支付渠道不存在"); ErrorCode CHANNEL_EXIST_SAME_CHANNEL_ERROR = new ErrorCode(1007001005, "已存在相同的渠道"); - ErrorCode CHANNEL_WECHAT_VERSION_2_MCH_KEY_IS_NULL = new ErrorCode(1007001006,"微信渠道v2版本中商户密钥不可为空"); - ErrorCode CHANNEL_WECHAT_VERSION_3_PRIVATE_KEY_IS_NULL = new ErrorCode(1007001007,"微信渠道v3版本apiclient_key.pem不可为空"); - ErrorCode CHANNEL_WECHAT_VERSION_3_CERT_KEY_IS_NULL = new ErrorCode(1007001008,"微信渠道v3版本中apiclient_cert.pem不可为空"); - ErrorCode PAY_CHANNEL_NOTIFY_VERIFY_FAILED = new ErrorCode(1007001009, "渠道通知校验失败"); // ========== ORDER 模块 1007002000 ========== ErrorCode PAY_ORDER_NOT_FOUND = new ErrorCode(1007002000, "支付订单不存在"); ErrorCode PAY_ORDER_STATUS_IS_NOT_WAITING = new ErrorCode(1007002001, "支付订单不处于待支付"); ErrorCode PAY_ORDER_STATUS_IS_NOT_SUCCESS = new ErrorCode(1007002002, "支付订单不处于已支付"); - ErrorCode PAY_ORDER_ERROR_USER = new ErrorCode(1007002003, "支付订单用户不正确"); // ========== ORDER 模块(拓展单) 1007003000 ========== ErrorCode PAY_ORDER_EXTENSION_NOT_FOUND = new ErrorCode(1007003000, "支付交易拓展单不存在"); ErrorCode PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING = new ErrorCode(1007003001, "支付交易拓展单不处于待支付"); - ErrorCode PAY_ORDER_EXTENSION_STATUS_IS_NOT_SUCCESS = new ErrorCode(1007003002, "支付订单不处于已支付"); // ========== 支付模块(退款) 1007006000 ========== ErrorCode PAY_REFUND_AMOUNT_EXCEED = new ErrorCode(1007006000, "退款金额超过订单可退款金额"); diff --git a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java index b4a5b2b98..684f42bc6 100644 --- a/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java +++ b/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/order/PayOrderStatusEnum.java @@ -17,7 +17,7 @@ public enum PayOrderStatusEnum implements IntArrayValuable { WAITING(0, "未支付"), SUCCESS(10, "支付成功"), - CLOSED(20, "支付关闭"), // 未付款交易超时关闭,或支付完成后全额退款 TODO 芋艿:需要优化下 + CLOSED(20, "支付关闭"), // 未付款交易超时关闭,或支付完成后全额退款 ; private final Integer status; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/PayAppController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/PayAppController.java similarity index 67% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/PayAppController.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/PayAppController.java index 4d746cf89..dda11bc96 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/PayAppController.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/PayAppController.java @@ -1,36 +1,29 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant; +package cn.iocoder.yudao.module.pay.controller.admin.app; import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.*; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.*; import cn.iocoder.yudao.module.pay.convert.app.PayAppConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; -import cn.iocoder.yudao.module.pay.service.merchant.PayAppService; -import cn.iocoder.yudao.module.pay.service.merchant.PayChannelService; -import cn.iocoder.yudao.module.pay.service.merchant.PayMerchantService; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; +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.service.app.PayAppService; +import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; -import java.io.IOException; import java.util.*; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @Slf4j @Tag(name = "管理后台 - 支付应用信息") @@ -43,8 +36,6 @@ public class PayAppController { private PayAppService appService; @Resource private PayChannelService channelService; - @Resource - private PayMerchantService merchantService; @PostMapping("/create") @Operation(summary = "创建支付应用信息") @@ -112,17 +103,11 @@ public class PayAppController { // TODO @aquan:可以基于 appId 简历一个 multiMap。这样下面,直接 get 到之后,CollUtil buildSet 即可 Iterator iterator = channels.iterator(); - // 得到所有的商户信息 - Collection merchantIds = CollectionUtils.convertList(pageResult.getList(), PayAppDO::getMerchantId); - Map deptMap = merchantService.getMerchantMap(merchantIds); - // 利用反射将渠道数据复制到返回的数据结构中去 List appList = new ArrayList<>(pageResult.getList().size()); pageResult.getList().forEach(app -> { // 写入应用信息的数据 PayAppPageItemRespVO respVO = PayAppConvert.INSTANCE.pageConvert(app); - // 写入商户的数据 - respVO.setPayMerchant(PayAppConvert.INSTANCE.convert(deptMap.get(app.getMerchantId()))); // 写入支付渠道信息的数据 Set channelCodes = new HashSet<>(PayChannelEnum.values().length); while (iterator.hasNext()) { @@ -139,25 +124,4 @@ public class PayAppController { return success(new PageResult<>(appList, pageResult.getTotal())); } - @GetMapping("/export-excel") - @Operation(summary = "导出支付应用信息 Excel") - @PreAuthorize("@ss.hasPermission('pay:app:export')") - @OperateLog(type = EXPORT) - public void exportAppExcel(@Valid PayAppExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = appService.getAppList(exportReqVO); - // 导出 Excel - List datas = PayAppConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "支付应用信息.xls", "数据", PayAppExcelVO.class, datas); - } - - @GetMapping("/list-merchant-id") - @Operation(summary = "根据商户 ID 查询支付应用信息") - @Parameter(name = "merchantId", description = "商户ID", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('pay:merchant:query')") - public CommonResult> getMerchantListByName(@RequestParam Long merchantId) { - List appListDO = appService.getListByMerchantId(merchantId); - return success(PayAppConvert.INSTANCE.convertList(appListDO)); - } - } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java similarity index 82% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppBaseVO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java index 86ea5dce7..c6a4570b3 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppBaseVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app; +package cn.iocoder.yudao.module.pay.controller.admin.app.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import javax.validation.constraints.*; @@ -29,8 +29,4 @@ public class PayAppBaseVO { @NotNull(message = "退款结果的回调地址不能为空") private String refundNotifyUrl; - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "商户编号不能为空") - private Long merchantId; - } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java similarity index 79% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppCreateReqVO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java index 36816cc24..03cab7d3e 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppCreateReqVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app; +package cn.iocoder.yudao.module.pay.controller.admin.app.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java similarity index 58% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppPageItemRespVO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java index 99c095a32..0610d63fb 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppPageItemRespVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app; +package cn.iocoder.yudao.module.pay.controller.admin.app.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -20,25 +20,7 @@ public class PayAppPageItemRespVO extends PayAppBaseVO { @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) private LocalDateTime createTime; - /** - * 所属商户 - */ - private PayMerchant payMerchant; - - @Schema(description = "商户") - @Data - public static class PayMerchant { - - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long id; - - @Schema(description = "商户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "研发部") - private String name; - - } - - @Schema(description = "渠道编码集合", requiredMode = Schema.RequiredMode.REQUIRED, example = "alipay_pc,alipay_wap...") + @Schema(description = "渠道编码集合", requiredMode = Schema.RequiredMode.REQUIRED, example = "[alipay_pc, alipay_wap]") private Set channelCodes; - } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java similarity index 86% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppPageReqVO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java index 1aaadc78a..5a4cd1ce8 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppPageReqVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java @@ -1,10 +1,13 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app; +package cn.iocoder.yudao.module.pay.controller.admin.app.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -29,9 +32,6 @@ public class PayAppPageReqVO extends PageParam { @Schema(description = "退款结果的回调地址") private String refundNotifyUrl; - @Schema(description = "商户名称") - private String merchantName; - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @Schema(description = "创建时间") private LocalDateTime[] createTime; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.java similarity index 88% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppRespVO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.java index 78e6b20b0..87dadcbc7 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppRespVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app; +package cn.iocoder.yudao.module.pay.controller.admin.app.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppUpdateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java similarity index 87% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppUpdateReqVO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java index 66f865acb..2cc363b6e 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppUpdateReqVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app; +package cn.iocoder.yudao.module.pay.controller.admin.app.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import javax.validation.constraints.*; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppUpdateStatusReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateStatusReqVO.java similarity index 89% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppUpdateStatusReqVO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateStatusReqVO.java index 5ab4a53e3..64b7ea444 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppUpdateStatusReqVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateStatusReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app; +package cn.iocoder.yudao.module.pay.controller.admin.app.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/PayChannelController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java similarity index 61% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/PayChannelController.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java index 6ef6f5712..cec33bf1a 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/PayChannelController.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/PayChannelController.java @@ -1,30 +1,29 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant; +package cn.iocoder.yudao.module.pay.controller.admin.channel; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.*; -import cn.iocoder.yudao.module.pay.convert.channel.PayChannelConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; -import cn.iocoder.yudao.module.pay.service.merchant.PayChannelService; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import io.swagger.v3.oas.annotations.tags.Tag; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelPageReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelRespVO; +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.dal.dataobject.channel.PayChannelDO; +import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; +import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; -import java.io.IOException; -import java.util.Collection; import java.util.List; +import java.util.Set; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; @Tag(name = "管理后台 - 支付渠道") @RestController @@ -68,16 +67,6 @@ public class PayChannelController { return success(PayChannelConvert.INSTANCE.convert(channel)); } - @GetMapping("/list") - @Operation(summary = "获得支付渠道列表") - @Parameter(name = "ids", description = "编号列表", - required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('pay:channel:query')") - public CommonResult> getChannelList(@RequestParam("ids") Collection ids) { - List list = channelService.getChannelList(ids); - return success(PayChannelConvert.INSTANCE.convertList(list)); - } - @GetMapping("/page") @Operation(summary = "获得支付渠道分页") @PreAuthorize("@ss.hasPermission('pay:channel:query')") @@ -86,33 +75,17 @@ public class PayChannelController { return success(PayChannelConvert.INSTANCE.convertPage(pageResult)); } - @GetMapping("/export-excel") - @Operation(summary = "导出支付渠道Excel") - @PreAuthorize("@ss.hasPermission('pay:channel:export')") - @OperateLog(type = EXPORT) - public void exportChannelExcel(@Valid PayChannelExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = channelService.getChannelList(exportReqVO); - // 导出 Excel - List datas = PayChannelConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "支付渠道.xls", "数据", PayChannelExcelVO.class, datas); - } - + // TODO 芋艿:需要 review 下实现 @GetMapping("/get-channel") @Operation(summary = "根据条件查询微信支付渠道") @Parameters({ - @Parameter(name = "merchantId", description = "商户编号", - required = true, example = "1"), - @Parameter(name = "appId", description = "应用编号", - required = true, example = "1"), - @Parameter(name = "code", description = "支付渠道编码", - required = true, example = "wx_pub") + @Parameter(name = "appId", description = "应用编号", required = true, example = "1"), + @Parameter(name = "code", description = "支付渠道编码", required = true, example = "wx_pub") }) @PreAuthorize("@ss.hasPermission('pay:channel:query')") - public CommonResult getChannel( - @RequestParam Long merchantId, @RequestParam Long appId, @RequestParam String code) { + public CommonResult getChannel(@RequestParam Long appId, @RequestParam String code) { // 獲取渠道 - PayChannelDO channel = channelService.getChannelByConditions(merchantId, appId, code); + PayChannelDO channel = channelService.getChannelByConditions(appId, code); if (channel == null) { return success(new PayChannelRespVO()); } @@ -121,4 +94,12 @@ public class PayChannelController { return success(respVo); } + @GetMapping("/get-enable-code-list") + @Operation(summary = "获得指定应用的开启的支付渠道编码列表") + @Parameter(name = "appId", description = "应用编号", required = true, example = "1") + public CommonResult> getEnableChannelCodeList(@RequestParam("appId") Long appId) { + List channels = channelService.getEnableChannelList(appId); + return success(convertSet(channels, PayChannelDO::getCode)); + } + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelBaseVO.java similarity index 81% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelBaseVO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelBaseVO.java index 155066f01..48e98a3be 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelBaseVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelBaseVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel; +package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import javax.validation.constraints.*; @@ -25,10 +25,6 @@ public class PayChannelBaseVO { @NotNull(message = "渠道费率,单位:百分比不能为空") private Double feeRate; - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "商户编号不能为空") - private Long merchantId; - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "应用编号不能为空") private Long appId; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelCreateReqVO.java similarity index 87% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelCreateReqVO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelCreateReqVO.java index 89547bc1e..d43ebbd3c 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelCreateReqVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelCreateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel; +package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelPageReqVO.java similarity index 87% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelPageReqVO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelPageReqVO.java index 00c724893..675730128 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelPageReqVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelPageReqVO.java @@ -1,10 +1,13 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel; +package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -26,9 +29,6 @@ public class PayChannelPageReqVO extends PageParam { @Schema(description = "渠道费率,单位:百分比") private Double feeRate; - @Schema(description = "商户编号") - private Long merchantId; - @Schema(description = "应用编号") private Long appId; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelRespVO.java similarity index 89% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelRespVO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelRespVO.java index 3defb466c..0d63aa25f 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelRespVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel; +package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelUpdateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelUpdateReqVO.java similarity index 89% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelUpdateReqVO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelUpdateReqVO.java index fc078dc70..357151ea2 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelUpdateReqVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/channel/vo/PayChannelUpdateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel; +package cn.iocoder.yudao.module.pay.controller.admin.channel.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import javax.validation.constraints.*; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/PayMerchantController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/PayMerchantController.java deleted file mode 100644 index 2af7fa528..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/PayMerchantController.java +++ /dev/null @@ -1,116 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant; - -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.*; -import cn.iocoder.yudao.module.pay.convert.merchant.PayMerchantConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; -import cn.iocoder.yudao.module.pay.service.merchant.PayMerchantService; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; - -@Tag(name = "支付商户信息") -@RestController -@RequestMapping("/pay/merchant") -@Validated -public class PayMerchantController { - - @Resource - private PayMerchantService merchantService; - - @PostMapping("/create") - @Operation(summary = "创建支付商户信息") - @PreAuthorize("@ss.hasPermission('pay:merchant:create')") - public CommonResult createMerchant(@Valid @RequestBody PayMerchantCreateReqVO createReqVO) { - return success(merchantService.createMerchant(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新支付商户信息") - @PreAuthorize("@ss.hasPermission('pay:merchant:update')") - public CommonResult updateMerchant(@Valid @RequestBody PayMerchantUpdateReqVO updateReqVO) { - merchantService.updateMerchant(updateReqVO); - return success(true); - } - - @PutMapping("/update-status") - @Operation(summary = "修改支付商户状态") - @PreAuthorize("@ss.hasPermission('pay:merchant:update')") - public CommonResult updateMerchantStatus(@Valid @RequestBody PayMerchantUpdateStatusReqVO reqVO) { - merchantService.updateMerchantStatus(reqVO.getId(), reqVO.getStatus()); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除支付商户信息") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('pay:merchant:delete')") - public CommonResult deleteMerchant(@RequestParam("id") Long id) { - merchantService.deleteMerchant(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得支付商户信息") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('pay:merchant:query')") - public CommonResult getMerchant(@RequestParam("id") Long id) { - PayMerchantDO merchant = merchantService.getMerchant(id); - return success(PayMerchantConvert.INSTANCE.convert(merchant)); - } - - @GetMapping("/list-by-name") - @Operation(summary = "根据商户名称获得支付商户信息列表") - @Parameter(name = "name", description = "商户名称", example = "芋道") - @PreAuthorize("@ss.hasPermission('pay:merchant:query')") - public CommonResult> getMerchantListByName(@RequestParam(required = false) String name) { - List merchantListDO = merchantService.getMerchantListByName(name); - return success(PayMerchantConvert.INSTANCE.convertList(merchantListDO)); - } - - @GetMapping("/list") - @Operation(summary = "获得支付商户信息列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('pay:merchant:query')") - public CommonResult> getMerchantList(@RequestParam("ids") Collection ids) { - List list = merchantService.getMerchantList(ids); - return success(PayMerchantConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @Operation(summary = "获得支付商户信息分页") - @PreAuthorize("@ss.hasPermission('pay:merchant:query')") - public CommonResult> getMerchantPage(@Valid PayMerchantPageReqVO pageVO) { - PageResult pageResult = merchantService.getMerchantPage(pageVO); - return success(PayMerchantConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出支付商户信息 Excel") - @PreAuthorize("@ss.hasPermission('pay:merchant:export')") - @OperateLog(type = EXPORT) - public void exportMerchantExcel(@Valid PayMerchantExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = merchantService.getMerchantList(exportReqVO); - // 导出 Excel - List datas = PayMerchantConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "支付商户信息.xls", "数据", PayMerchantExcelVO.class, datas); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppExcelVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppExcelVO.java deleted file mode 100644 index 20556e573..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppExcelVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app; - -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 支付应用信息 Excel VO - * - * @author 芋艿 - */ -@Data -public class PayAppExcelVO { - - @ExcelProperty("应用编号") - private Long id; - - @ExcelProperty("应用名") - private String name; - - @ExcelProperty("开启状态") - private Integer status; - - @ExcelProperty("备注") - private String remark; - - @ExcelProperty("支付结果的回调地址") - private String payNotifyUrl; - - @ExcelProperty("退款结果的回调地址") - private String refundNotifyUrl; - - @ExcelProperty("商户编号") - private Long merchantId; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppExportReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppExportReqVO.java deleted file mode 100644 index b13a6e65b..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/app/PayAppExportReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付应用信息 Excel 导出 Request VO,参数和 PayAppPageReqVO 是一致的") -@Data -public class PayAppExportReqVO { - - @Schema(description = "应用名") - private String name; - - @Schema(description = "开启状态") - private Integer status; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "支付结果的回调地址") - private String payNotifyUrl; - - @Schema(description = "退款结果的回调地址") - private String refundNotifyUrl; - - @Schema(description = "商户名称") - private String merchantName; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelExcelVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelExcelVO.java deleted file mode 100644 index a37088955..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelExcelVO.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel; - -import lombok.*; - -import java.time.LocalDateTime; - -import com.alibaba.excel.annotation.ExcelProperty; - -/** - * 支付渠道 Excel VO - * - * @author 芋艿 - */ -@Data -public class PayChannelExcelVO { - - @ExcelProperty("商户编号") - private Long id; - - @ExcelProperty("渠道编码") - private String code; - - @ExcelProperty("开启状态") - private Integer status; - - @ExcelProperty("备注") - private String remark; - - @ExcelProperty("渠道费率,单位:百分比") - private Double feeRate; - - @ExcelProperty("商户编号") - private Long merchantId; - - @ExcelProperty("应用编号") - private Long appId; - - /** - * todo @芋艿 mapStruct 存在转换问题 - * java: Can't map property "PayClientConfig payChannelDO.config" to "String payChannelExcelVO.config". - * Consider to declare/implement a mapping method: "String map(PayClientConfig value)". - */ - /// @ExcelProperty("支付渠道配置") - /// private String config; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelExportReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelExportReqVO.java deleted file mode 100644 index 3a7e16fb5..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/channel/PayChannelExportReqVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付渠道 Excel 导出 Request VO,参数和 PayChannelPageReqVO 是一致的") -@Data -public class PayChannelExportReqVO { - - @Schema(description = "渠道编码") - private String code; - - @Schema(description = "开启状态") - private Integer status; - - @Schema(description = "备注") - private String remark; - - @Schema(description = "渠道费率,单位:百分比") - private Double feeRate; - - @Schema(description = "商户编号") - private Long merchantId; - - @Schema(description = "应用编号") - private Long appId; - - @Schema(description = "支付渠道配置") - private String config; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantBaseVO.java deleted file mode 100644 index e2692ec85..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantBaseVO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** -* 支付商户信息 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ -@Data -public class PayMerchantBaseVO { - - @Schema(description = "商户全称", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "商户全称不能为空") - private String name; - - @Schema(description = "商户简称", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "商户简称不能为空") - private String shortName; - - @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "开启状态不能为空") - private Integer status; - - @Schema(description = "备注") - private String remark; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantCreateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantCreateReqVO.java deleted file mode 100644 index f63aa123f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantCreateReqVO.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -@Schema(description = "管理后台 - 支付商户信息创建 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayMerchantCreateReqVO extends PayMerchantBaseVO { - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantExcelVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantExcelVO.java deleted file mode 100644 index 821d55fe5..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantExcelVO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * 支付商户信息 Excel VO - * - * @author 芋艿 - */ -@Data -public class PayMerchantExcelVO { - - @ExcelProperty("商户编号") - private Long id; - - @ExcelProperty("商户号") - private String no; - - @ExcelProperty("商户全称") - private String name; - - @ExcelProperty("商户简称") - private String shortName; - - @ExcelProperty(value = "开启状态",converter = DictConvert.class) - @DictFormat("sys_common_status") - private Integer status; - - @ExcelProperty("备注") - private String remark; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantExportReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantExportReqVO.java deleted file mode 100644 index 4903531c9..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantExportReqVO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付商户信息 Excel 导出 Request VO,参数和 PayMerchantPageReqVO 是一致的") -@Data -public class PayMerchantExportReqVO { - - @Schema(description = "商户号") - private String no; - - @Schema(description = "商户全称") - private String name; - - @Schema(description = "商户简称") - private String shortName; - - @Schema(description = "开启状态") - private Integer status; - - @Schema(description = "备注") - private String remark; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantPageReqVO.java deleted file mode 100644 index 0dccc4dab..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantPageReqVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; - -import java.time.LocalDateTime; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - 支付商户信息分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayMerchantPageReqVO extends PageParam { - - @Schema(description = "商户号") - private String no; - - @Schema(description = "商户全称") - private String name; - - @Schema(description = "商户简称") - private String shortName; - - @Schema(description = "开启状态") - private Integer status; - - @Schema(description = "备注") - private String remark; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Schema(description = "创建时间") - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantRespVO.java deleted file mode 100644 index ca8d51884..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 支付商户信息 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayMerchantRespVO extends PayMerchantBaseVO { - - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED) - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - - @Schema(description = "商户号", requiredMode = Schema.RequiredMode.REQUIRED, example = "M233666999") - private String no; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantUpdateReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantUpdateReqVO.java deleted file mode 100644 index 103c3d5a9..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantUpdateReqVO.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import javax.validation.constraints.*; - -@Schema(description = "管理后台 - 支付商户信息更新 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PayMerchantUpdateReqVO extends PayMerchantBaseVO { - - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "商户编号不能为空") - private Long id; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantUpdateStatusReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantUpdateStatusReqVO.java deleted file mode 100644 index eb3e8f1cf..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/merchant/vo/merchant/PayMerchantUpdateStatusReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商户更新状态 Request VO") -@Data -public class PayMerchantUpdateStatusReqVO { - - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @NotNull(message = "商户编号不能为空") - private Long id; - - @Schema(description = "状态,见 SysCommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java index 09c24c4a8..fc753812a 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java @@ -7,15 +7,13 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; +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.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; +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.PayOrderExtensionDO; -import cn.iocoder.yudao.module.pay.service.merchant.PayAppService; -import cn.iocoder.yudao.module.pay.service.merchant.PayMerchantService; +import cn.iocoder.yudao.module.pay.service.app.PayAppService; import cn.iocoder.yudao.module.pay.service.order.PayOrderExtensionService; import cn.iocoder.yudao.module.pay.service.order.PayOrderService; import io.swagger.v3.oas.annotations.Operation; @@ -48,8 +46,6 @@ public class PayOrderController { @Resource private PayOrderExtensionService orderExtensionService; @Resource - private PayMerchantService merchantService; - @Resource private PayAppService appService; @GetMapping("/get") @@ -71,13 +67,11 @@ public class PayOrderController { return success(new PayOrderDetailsRespVO()); } - PayMerchantDO merchantDO = merchantService.getMerchant(order.getMerchantId()); PayAppDO appDO = appService.getApp(order.getAppId()); PayChannelEnum channelEnum = PayChannelEnum.getByCode(order.getChannelCode()); // TODO @aquan:文案,都是前端 format; PayOrderDetailsRespVO respVO = PayOrderConvert.INSTANCE.orderDetailConvert(order); - respVO.setMerchantName(ObjectUtil.isNotNull(merchantDO) ? merchantDO.getName() : "未知商户"); respVO.setAppName(ObjectUtil.isNotNull(appDO) ? appDO.getName() : "未知应用"); respVO.setChannelCodeName(ObjectUtil.isNotNull(channelEnum) ? channelEnum.getName() : "未知渠道"); @@ -105,21 +99,16 @@ public class PayOrderController { return success(new PageResult<>(pageResult.getTotal())); } - // 处理商户ID数据 - Map merchantMap = merchantService.getMerchantMap( - CollectionUtils.convertList(pageResult.getList(), PayOrderDO::getMerchantId)); // 处理应用ID数据 Map appMap = appService.getAppMap( CollectionUtils.convertList(pageResult.getList(), PayOrderDO::getAppId)); List pageList = new ArrayList<>(pageResult.getList().size()); pageResult.getList().forEach(c -> { - PayMerchantDO merchantDO = merchantMap.get(c.getMerchantId()); PayAppDO appDO = appMap.get(c.getAppId()); PayChannelEnum channelEnum = PayChannelEnum.getByCode(c.getChannelCode()); PayOrderPageItemRespVO orderItem = PayOrderConvert.INSTANCE.pageConvertItemPage(c); - orderItem.setMerchantName(ObjectUtil.isNotNull(merchantDO) ? merchantDO.getName() : "未知商户"); orderItem.setAppName(ObjectUtil.isNotNull(appDO) ? appDO.getName() : "未知应用"); orderItem.setChannelCodeName(ObjectUtil.isNotNull(channelEnum) ? channelEnum.getName() : "未知渠道"); pageList.add(orderItem); @@ -133,16 +122,12 @@ public class PayOrderController { @OperateLog(type = EXPORT) public void exportOrderExcel(@Valid PayOrderExportReqVO exportReqVO, HttpServletResponse response) throws IOException { - List list = payOrderService.getOrderList(exportReqVO); if (CollectionUtil.isEmpty(list)) { ExcelUtils.write(response, "支付订单.xls", "数据", PayOrderExcelVO.class, new ArrayList<>()); } - // 处理商户ID数据 - Map merchantMap = merchantService.getMerchantMap( - CollectionUtils.convertList(list, PayOrderDO::getMerchantId)); // 处理应用ID数据 Map appMap = appService.getAppMap( CollectionUtils.convertList(list, PayOrderDO::getAppId)); @@ -152,13 +137,11 @@ public class PayOrderController { List excelDatum = new ArrayList<>(list.size()); list.forEach(c -> { - PayMerchantDO merchantDO = merchantMap.get(c.getMerchantId()); PayAppDO appDO = appMap.get(c.getAppId()); PayChannelEnum channelEnum = PayChannelEnum.getByCode(c.getChannelCode()); PayOrderExtensionDO orderExtensionDO = orderExtensionMap.get(c.getSuccessExtensionId()); PayOrderExcelVO excelItem = PayOrderConvert.INSTANCE.excelConvert(c); - excelItem.setMerchantName(ObjectUtil.isNotNull(merchantDO) ? merchantDO.getName() : "未知商户"); excelItem.setAppName(ObjectUtil.isNotNull(appDO) ? appDO.getName() : "未知应用"); excelItem.setChannelCodeName(ObjectUtil.isNotNull(channelEnum) ? channelEnum.getName() : "未知渠道"); excelItem.setNo(ObjectUtil.isNotNull(orderExtensionDO) ? orderExtensionDO.getNo() : ""); diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java index e2c22aeed..97db64a17 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderBaseVO.java @@ -17,10 +17,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class PayOrderBaseVO { - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "商户编号不能为空") - private Long merchantId; - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "应用编号不能为空") private Long appId; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java index 6a1d2c8f6..759450c93 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderDetailsRespVO.java @@ -16,9 +16,6 @@ public class PayOrderDetailsRespVO extends PayOrderBaseVO { @Schema(description = "支付订单编号") private Long id; - @Schema(description = "商户名称") - private String merchantName; - @Schema(description = "应用名称") private String appName; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java index 71b4879d7..540e6beec 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExcelVO.java @@ -19,9 +19,6 @@ public class PayOrderExcelVO { @ExcelProperty("支付订单编号") private Long id; - @ExcelProperty(value = "商户名称") - private String merchantName; - @ExcelProperty(value = "应用名称") private String appName; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java index a5783806c..b96f455ad 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderExportReqVO.java @@ -12,9 +12,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class PayOrderExportReqVO { - @Schema(description = "商户编号") - private Long merchantId; - @Schema(description = "应用编号") private Long appId; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java index 53ceb13d2..ada7c179b 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageItemRespVO.java @@ -19,9 +19,6 @@ public class PayOrderPageItemRespVO extends PayOrderBaseVO { @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) private LocalDateTime createTime; - @Schema(description = "商户名称") - private String merchantName; - @Schema(description = "应用名称") private String appName; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java index 2ca72f9fc..4705feaf9 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/vo/PayOrderPageReqVO.java @@ -17,9 +17,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class PayOrderPageReqVO extends PageParam { - @Schema(description = "商户编号") - private Long merchantId; - @Schema(description = "应用编号") private Long appId; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java index e16e51115..5f8446192 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/PayRefundController.java @@ -4,12 +4,10 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.*; import cn.iocoder.yudao.module.pay.convert.refund.PayRefundConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; +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.refund.PayRefundDO; -import cn.iocoder.yudao.module.pay.service.merchant.PayAppService; -import cn.iocoder.yudao.module.pay.service.merchant.PayMerchantService; +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.refund.PayRefundService; import cn.iocoder.yudao.framework.common.pojo.CommonResult; @@ -17,7 +15,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Operation; @@ -48,8 +46,6 @@ public class PayRefundController { @Resource private PayRefundService refundService; @Resource - private PayMerchantService merchantService; - @Resource private PayAppService appService; @Resource private PayOrderService orderService; @@ -64,13 +60,11 @@ public class PayRefundController { return success(new PayRefundDetailsRespVO()); } - PayMerchantDO merchantDO = merchantService.getMerchant(refund.getMerchantId()); PayAppDO appDO = appService.getApp(refund.getAppId()); PayChannelEnum channelEnum = PayChannelEnum.getByCode(refund.getChannelCode()); PayOrderDO orderDO = orderService.getOrder(refund.getOrderId()); PayRefundDetailsRespVO refundDetail = PayRefundConvert.INSTANCE.refundDetailConvert(refund); - refundDetail.setMerchantName(ObjectUtil.isNotNull(merchantDO) ? merchantDO.getName() : "未知商户"); refundDetail.setAppName(ObjectUtil.isNotNull(appDO) ? appDO.getName() : "未知应用"); refundDetail.setChannelCodeName(ObjectUtil.isNotNull(channelEnum) ? channelEnum.getName() : "未知渠道"); refundDetail.setSubject(orderDO.getSubject()); @@ -87,21 +81,16 @@ public class PayRefundController { return success(new PageResult<>(pageResult.getTotal())); } - // 处理商户ID数据 - Map merchantMap = merchantService.getMerchantMap( - CollectionUtils.convertList(pageResult.getList(), PayRefundDO::getMerchantId)); // 处理应用ID数据 Map appMap = appService.getAppMap( CollectionUtils.convertList(pageResult.getList(), PayRefundDO::getAppId)); List list = new ArrayList<>(pageResult.getList().size()); pageResult.getList().forEach(c -> { - PayMerchantDO merchantDO = merchantMap.get(c.getMerchantId()); PayAppDO appDO = appMap.get(c.getAppId()); PayChannelEnum channelEnum = PayChannelEnum.getByCode(c.getChannelCode()); PayRefundPageItemRespVO item = PayRefundConvert.INSTANCE.pageItemConvert(c); - item.setMerchantName(ObjectUtil.isNotNull(merchantDO) ? merchantDO.getName() : "未知商户"); item.setAppName(ObjectUtil.isNotNull(appDO) ? appDO.getName() : "未知应用"); item.setChannelCodeName(ObjectUtil.isNotNull(channelEnum) ? channelEnum.getName() : "未知渠道"); list.add(item); @@ -123,9 +112,6 @@ public class PayRefundController { PayRefundExcelVO.class, new ArrayList<>()); } - // 处理商户ID数据 - Map merchantMap = merchantService.getMerchantMap( - CollectionUtils.convertList(list, PayRefundDO::getMerchantId)); // 处理应用ID数据 Map appMap = appService.getAppMap( CollectionUtils.convertList(list, PayRefundDO::getAppId)); @@ -136,12 +122,10 @@ public class PayRefundController { CollectionUtils.convertList(list, PayRefundDO::getOrderId)); list.forEach(c -> { - PayMerchantDO merchantDO = merchantMap.get(c.getMerchantId()); PayAppDO appDO = appMap.get(c.getAppId()); PayChannelEnum channelEnum = PayChannelEnum.getByCode(c.getChannelCode()); PayRefundExcelVO excelItem = PayRefundConvert.INSTANCE.excelConvert(c); - excelItem.setMerchantName(ObjectUtil.isNotNull(merchantDO) ? merchantDO.getName() : "未知商户"); excelItem.setAppName(ObjectUtil.isNotNull(appDO) ? appDO.getName() : "未知应用"); excelItem.setChannelCodeName(ObjectUtil.isNotNull(channelEnum) ? channelEnum.getName() : "未知渠道"); excelItem.setSubject(orderMap.get(c.getOrderId()).getSubject()); diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java index 222c10bc6..35b791e10 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundBaseVO.java @@ -15,10 +15,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class PayRefundBaseVO { - @Schema(description = "商户编号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "商户编号不能为空") - private Long merchantId; - @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "应用编号不能为空") private Long appId; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java index 4f21dc1ef..f622dda79 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundDetailsRespVO.java @@ -17,9 +17,6 @@ public class PayRefundDetailsRespVO extends PayRefundBaseVO { @Schema(description = "支付退款编号", requiredMode = Schema.RequiredMode.REQUIRED) private Long id; - @Schema(description = "商户名称") - private String merchantName; - @Schema(description = "应用名称") private String appName; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java index c4ec3e733..5e412147b 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExcelVO.java @@ -22,9 +22,6 @@ public class PayRefundExcelVO { @ExcelProperty("商品名称") private String subject; - @ExcelProperty(value = "商户名称") - private String merchantName; - @ExcelProperty(value = "应用名称") private String appName; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java index bc7d7946b..02ef801b2 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundExportReqVO.java @@ -12,9 +12,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class PayRefundExportReqVO { - @Schema(description = "商户编号") - private Long merchantId; - @Schema(description = "应用编号") private Long appId; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java index be719565a..8c547c6e4 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageItemRespVO.java @@ -16,9 +16,6 @@ public class PayRefundPageItemRespVO extends PayRefundBaseVO { @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED) private Long id; - @Schema(description = "商户名称") - private String merchantName; - @Schema(description = "应用名称") private String appName; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java index 49d87f645..a7acc4db7 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/refund/vo/PayRefundPageReqVO.java @@ -17,9 +17,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class PayRefundPageReqVO extends PageParam { - @Schema(description = "商户编号") - private Long merchantId; - @Schema(description = "应用编号") private Long appId; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/channel/AppPayChannelController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/channel/AppPayChannelController.java new file mode 100644 index 000000000..12323a7d5 --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/channel/AppPayChannelController.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.pay.controller.app.channel; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; +import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Set; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; + +@Tag(name = "用户 App - 支付渠道") +@RestController +@RequestMapping("/pay/channel") +@Validated +public class AppPayChannelController { + + @Resource + private PayChannelService channelService; + + @GetMapping("/get-enable-code-list") + @Operation(summary = "获得指定应用的开启的支付渠道编码列表") + @Parameter(name = "appId", description = "应用编号", required = true, example = "1") + public CommonResult> getEnableChannelCodeList(@RequestParam("appId") Long appId) { + List channels = channelService.getEnableChannelList(appId); + return success(convertSet(channels, PayChannelDO::getCode)); + } + +} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http index b2da78127..8b4008455 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.http @@ -1,4 +1,4 @@ -### /pay/create 提交支付订单 +### /pay/create 提交支付订单【alipay_pc】 POST {{appApi}}/pay/order/submit Content-Type: application/json Authorization: Bearer {{appToken}} @@ -8,3 +8,56 @@ tenant-id: {{appTenentId}} "id": 174, "channelCode": "alipay_pc" } + +### /pay/create 提交支付订单【wx_bar】 +POST {{appApi}}/pay/order/submit +Content-Type: application/json +Authorization: Bearer {{appToken}} +tenant-id: {{appTenentId}} + +{ + "id": 202, + "channelCode": "wx_bar", + "channelExtras": { + "authCode": "132990241553789274" + } +} + +### /pay/create 提交支付订单【wx_pub】 +POST {{appApi}}/pay/order/submit +Content-Type: application/json +Authorization: Bearer {{appToken}} +tenant-id: {{appTenentId}} + +{ + "id": 202, + "channelCode": "wx_pub", + "channelExtras": { + "openid": "ockUAwIZ-0OeMZl9ogcZ4ILrGba0" + } +} + +### /pay/create 提交支付订单【wx_lite】 +POST {{appApi}}/pay/order/submit +Content-Type: application/json +Authorization: Bearer {{appToken}} +tenant-id: {{appTenentId}} + +{ + "id": 202, + "channelCode": "wx_lite", + "channelExtras": { + "openid": "oLefc4g5GjKWHJjLjMSXB3wX0fD0" + } +} + +### /pay/create 提交支付订单【wx_native】 +POST {{appApi}}/pay/order/submit +Content-Type: application/json +Authorization: Bearer {{appToken}} +tenant-id: {{appTenentId}} + +{ + "id": 202, + "channelCode": "wx_native" +} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java index 432699bc2..ef0be7e3d 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/app/PayAppConvert.java @@ -1,15 +1,16 @@ package cn.iocoder.yudao.module.pay.convert.app; -import java.util.*; - import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.*; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageItemRespVO; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppRespVO; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; +import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; +import java.util.List; + /** * 支付应用信息 Convert * @@ -22,8 +23,6 @@ public interface PayAppConvert { PayAppPageItemRespVO pageConvert (PayAppDO bean); - PayAppPageItemRespVO.PayMerchant convert(PayMerchantDO bean); - PayAppDO convert(PayAppCreateReqVO bean); PayAppDO convert(PayAppUpdateReqVO bean); @@ -34,6 +33,4 @@ public interface PayAppConvert { PageResult convertPage(PageResult page); - List convertList02(List list); - } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java index 2535008ea..5baf598fd 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/channel/PayChannelConvert.java @@ -1,14 +1,10 @@ package cn.iocoder.yudao.module.pay.convert.channel; -import java.util.*; - import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelExcelVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelRespVO; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; +import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @@ -27,12 +23,6 @@ public interface PayChannelConvert { @Mapping(target = "config",expression = "java(cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString(bean.getConfig()))") PayChannelRespVO convert(PayChannelDO bean); - List convertList(List list); - PageResult convertPage(PageResult page); - List convertList02(List list); - - - } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/merchant/PayMerchantConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/merchant/PayMerchantConvert.java deleted file mode 100644 index 1cb51a2bb..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/merchant/PayMerchantConvert.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.pay.convert.merchant; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantExcelVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantRespVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface PayMerchantConvert { - - PayMerchantConvert INSTANCE = Mappers.getMapper(PayMerchantConvert.class); - - PayMerchantDO convert(PayMerchantCreateReqVO bean); - - PayMerchantDO convert(PayMerchantUpdateReqVO bean); - - PayMerchantRespVO convert(PayMerchantDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java index a73d528ba..29d050c19 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/order/PayOrderConvert.java @@ -94,7 +94,7 @@ public interface PayOrderConvert { @Mapping(target = "id", ignore = true) PayOrderExtensionDO convert(PayOrderSubmitReqVO bean, String userIp); - PayOrderUnifiedReqDTO convert2(PayOrderSubmitReqVO reqVO); + PayOrderUnifiedReqDTO convert2(PayOrderSubmitReqVO reqVO, String userIp); PayOrderSubmitRespVO convert(PayOrderUnifiedRespDTO bean); diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayAppDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java similarity index 88% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayAppDO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java index 3fd02502c..9b073cc46 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayAppDO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.merchant; +package cn.iocoder.yudao.module.pay.dal.dataobject.app; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; @@ -54,11 +54,4 @@ public class PayAppDO extends BaseDO { */ private String refundNotifyUrl; - /** - * 商户编号 - * - * 关联 {@link PayMerchantDO#getId()} - */ - private Long merchantId; - } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/channel/PayChannelDO.java similarity index 87% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDO.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/channel/PayChannelDO.java index 656cea01c..72387eb1c 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/channel/PayChannelDO.java @@ -1,9 +1,10 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.merchant; +package cn.iocoder.yudao.module.pay.dal.dataobject.channel; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -53,12 +54,6 @@ public class PayChannelDO extends TenantBaseDO { */ private String remark; - /** - * 商户编号 - * - * 关联 {@link PayMerchantDO#getId()} - */ - private Long merchantId; /** * 应用编号 * diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayMerchantDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayMerchantDO.java deleted file mode 100644 index 035bce726..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayMerchantDO.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.dataobject.merchant; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.*; -import lombok.*; - -/** - * 支付商户信息 DO - * 目前暂时没有特别的用途,主要为未来多商户提供基础。 - * - * @author 芋道源码 - */ -@TableName("pay_merchant") -@KeySequence("pay_merchant_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class PayMerchantDO extends BaseDO { - - /** - * 商户编号,数据库自增 - */ - @TableId - private Long id; - /** - * 商户号 - * 例如说,M233666999 - * 只有新增时插入,不允许修改 - */ - private String no; - /** - * 商户全称 - */ - private String name; - /** - * 商户简称 - */ - private String shortName; - /** - * 状态 - * - * 枚举 {@link CommonStatusEnum} - */ - private Integer status; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java index e4d858089..d3d79c5f5 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/notify/PayNotifyTaskDO.java @@ -1,12 +1,11 @@ package cn.iocoder.yudao.module.pay.dal.dataobject.notify; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +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.refund.PayRefundDO; import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyStatusEnum; import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -42,12 +41,6 @@ public class PayNotifyTaskDO extends BaseDO { * 编号,自增 */ private Long id; - /** - * 商户编号 - * - * 关联 {@link PayMerchantDO#getId()} - */ - private Long merchantId; /** * 应用编号 * diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java index 4f568ba5e..e44062f99 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderDO.java @@ -1,13 +1,12 @@ package cn.iocoder.yudao.module.pay.dal.dataobject.order; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderNotifyStatusEnum; -import cn.iocoder.yudao.module.pay.enums.refund.PayRefundTypeEnum; -import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; +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.channel.PayChannelDO; +import cn.iocoder.yudao.module.pay.enums.order.PayOrderNotifyStatusEnum; +import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; +import cn.iocoder.yudao.module.pay.enums.refund.PayRefundTypeEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; @@ -33,12 +32,6 @@ public class PayOrderDO extends BaseDO { * 订单编号,数据库自增 */ private Long id; - /** - * 商户编号 - * - * 关联 {@link PayMerchantDO#getId()} - */ - private Long merchantId; /** * 应用编号 * diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java index ad377b2b5..a486e0562 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/order/PayOrderExtensionDO.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.pay.dal.dataobject.order; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; +import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java index e8ac0ea8f..098778cd8 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/refund/PayRefundDO.java @@ -1,13 +1,12 @@ package cn.iocoder.yudao.module.pay.dal.dataobject.refund; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; +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.channel.PayChannelDO; import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; import cn.iocoder.yudao.module.pay.enums.refund.PayRefundTypeEnum; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -39,12 +38,6 @@ public class PayRefundDO extends BaseDO { @TableId private Long id; - /** - * 商户编号 - * - * 关联 {@link PayMerchantDO#getId()} - */ - private Long merchantId; /** * 应用编号 * diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java new file mode 100644 index 000000000..6ac163a9e --- /dev/null +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.pay.dal.mysql.app; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; +import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface PayAppMapper extends BaseMapperX { + + default PageResult selectPage(PayAppPageReqVO reqVO) { + return selectPage(reqVO, new QueryWrapperX() + .likeIfPresent("name", reqVO.getName()) + .eqIfPresent("status", reqVO.getStatus()) + .eqIfPresent("remark", reqVO.getRemark()) + .eqIfPresent("pay_notify_url", reqVO.getPayNotifyUrl()) + .eqIfPresent("refund_notify_url", reqVO.getRefundNotifyUrl()) + .betweenIfPresent("create_time", reqVO.getCreateTime()) + .orderByDesc("id")); + } + +} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java similarity index 50% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapper.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java index bea47f8ba..2f7fd86fd 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapper.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/channel/PayChannelMapper.java @@ -1,11 +1,11 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.merchant; +package cn.iocoder.yudao.module.pay.dal.mysql.channel; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelPageReqVO; +import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.ibatis.annotations.Mapper; @@ -25,51 +25,21 @@ public interface PayChannelMapper extends BaseMapperX { .eqIfPresent("status", reqVO.getStatus()) .eqIfPresent("remark", reqVO.getRemark()) .eqIfPresent("fee_rate", reqVO.getFeeRate()) - .eqIfPresent("merchant_id", reqVO.getMerchantId()) .eqIfPresent("app_id", reqVO.getAppId()) .betweenIfPresent("create_time", reqVO.getCreateTime()) .orderByDesc("id")); } - default List selectList(PayChannelExportReqVO reqVO) { - return selectList(new QueryWrapperX() - .eqIfPresent("code", reqVO.getCode()) - .eqIfPresent("status", reqVO.getStatus()) - .eqIfPresent("remark", reqVO.getRemark()) - .eqIfPresent("fee_rate", reqVO.getFeeRate()) - .eqIfPresent("merchant_id", reqVO.getMerchantId()) - .eqIfPresent("app_id", reqVO.getAppId()) - .betweenIfPresent("create_time", reqVO.getCreateTime()) - .orderByDesc("id")); - } - - /** - * 根据条件获取渠道数量 - * - * @param merchantId 商户编号 - * @param appid 应用编号 - * @param code 渠道编码 - * @return 数量 - */ - default Integer selectCount(Long merchantId, Long appid, String code) { - return this.selectCount(new QueryWrapper().lambda() - .eq(PayChannelDO::getMerchantId, merchantId) - .eq(PayChannelDO::getAppId, appid) - .eq(PayChannelDO::getCode, code)).intValue(); - } - /** * 根据条件获取渠道 * - * @param merchantId 商户编号 - * @param appI 应用编号 + * @param appId 应用编号 * @param code 渠道编码 * @return 数量 */ - default PayChannelDO selectOne(Long merchantId, Long appI, String code) { + default PayChannelDO selectOne(Long appId, String code) { return this.selectOne((new QueryWrapper().lambda() - .eq(PayChannelDO::getMerchantId, merchantId) - .eq(PayChannelDO::getAppId, appI) + .eq(PayChannelDO::getAppId, appId) .eq(PayChannelDO::getCode, code) )); } @@ -86,4 +56,10 @@ public interface PayChannelMapper extends BaseMapperX { .in(PayChannelDO::getAppId, appIds)); } + default List selectListByAppId(Long appId, Integer status) { + return selectList(new LambdaQueryWrapperX() + .eq(PayChannelDO::getAppId, appId) + .eq(PayChannelDO::getStatus, status)); + } + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayAppMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayAppMapper.java deleted file mode 100644 index ef1ce0427..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayAppMapper.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.merchant; - -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppPageReqVO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface PayAppMapper extends BaseMapperX { - - default PageResult selectPage(PayAppPageReqVO reqVO, Collection merchantIds) { - return selectPage(reqVO, new QueryWrapperX() - .likeIfPresent("name", reqVO.getName()) - .eqIfPresent("status", reqVO.getStatus()) - .eqIfPresent("remark", reqVO.getRemark()) - .eqIfPresent("pay_notify_url", reqVO.getPayNotifyUrl()) - .eqIfPresent("refund_notify_url", reqVO.getRefundNotifyUrl()) - .inIfPresent("merchant_id", merchantIds) - .betweenIfPresent("create_time", reqVO.getCreateTime()) - .orderByDesc("id")); - } - - default List selectList(PayAppExportReqVO reqVO, Collection merchantIds) { - return selectList(new QueryWrapperX() - .likeIfPresent("name", reqVO.getName()) - .eqIfPresent("status", reqVO.getStatus()) - .eqIfPresent("remark", reqVO.getRemark()) - .eqIfPresent("pay_notify_url", reqVO.getPayNotifyUrl()) - .eqIfPresent("refund_notify_url", reqVO.getRefundNotifyUrl()) - .inIfPresent("merchant_id", merchantIds) - .betweenIfPresent("create_time", reqVO.getCreateTime()) - .orderByDesc("id")); - } - - default List getListByMerchantId(Long merchantId) { - return selectList(new LambdaQueryWrapper() - .select(PayAppDO::getId, PayAppDO::getName) - .eq(PayAppDO::getMerchantId, merchantId)); - } - - // TODO @aquan:方法名补充 ByMerchantId - default Long selectCount(Long merchantId) { - return selectCount(new LambdaQueryWrapper().eq(PayAppDO::getMerchantId, merchantId)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayMerchantMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayMerchantMapper.java deleted file mode 100644 index c418aa958..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayMerchantMapper.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.yudao.module.pay.dal.mysql.merchant; - -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantPageReqVO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface PayMerchantMapper extends BaseMapperX { - - default PageResult selectPage(PayMerchantPageReqVO reqVO) { - return selectPage(reqVO, new QueryWrapperX() - .likeIfPresent("no", reqVO.getNo()) - .likeIfPresent("name", reqVO.getName()) - .likeIfPresent("short_name", reqVO.getShortName()) - .eqIfPresent("status", reqVO.getStatus()) - .eqIfPresent("remark", reqVO.getRemark()) - .betweenIfPresent("create_time", reqVO.getCreateTime()) - .orderByDesc("id")); - } - - default List selectList(PayMerchantExportReqVO reqVO) { - return selectList(new QueryWrapperX() - .likeIfPresent("no", reqVO.getNo()) - .likeIfPresent("name", reqVO.getName()) - .likeIfPresent("short_name", reqVO.getShortName()) - .eqIfPresent("status", reqVO.getStatus()) - .eqIfPresent("remark", reqVO.getRemark()) - .betweenIfPresent("create_time", reqVO.getCreateTime()) - .orderByDesc("id")); - } - - /** - * 根据商户名称模糊查询商户集合 - * - * @param merchantName 商户名称 - * @return 商户集合 - */ - default List getMerchantListByName(String merchantName) { - return this.selectList(new QueryWrapperX() - .likeIfPresent("name", merchantName)); - } -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java index 8d7daa4fb..5d90f41f9 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java @@ -18,7 +18,6 @@ public interface PayOrderMapper extends BaseMapperX { default PageResult selectPage(PayOrderPageReqVO reqVO) { return selectPage(reqVO, new QueryWrapperX() - .eqIfPresent("merchant_id", reqVO.getMerchantId()) .eqIfPresent("app_id", reqVO.getAppId()) .eqIfPresent("channel_id", reqVO.getChannelId()) .eqIfPresent("channel_code", reqVO.getChannelCode()) @@ -33,7 +32,6 @@ public interface PayOrderMapper extends BaseMapperX { default List selectList(PayOrderExportReqVO reqVO) { return selectList(new QueryWrapperX() - .eqIfPresent("merchant_id", reqVO.getMerchantId()) .eqIfPresent("app_id", reqVO.getAppId()) .eqIfPresent("channel_id", reqVO.getChannelId()) .eqIfPresent("channel_code", reqVO.getChannelCode()) diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java index 38fa4bc66..7614c8f8e 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/refund/PayRefundMapper.java @@ -16,7 +16,6 @@ public interface PayRefundMapper extends BaseMapperX { default PageResult selectPage(PayRefundPageReqVO reqVO) { return selectPage(reqVO, new QueryWrapperX() - .eqIfPresent("merchant_id", reqVO.getMerchantId()) .eqIfPresent("app_id", reqVO.getAppId()) .eqIfPresent("channel_code", reqVO.getChannelCode()) .likeIfPresent("merchant_refund_no", reqVO.getMerchantRefundNo()) @@ -29,7 +28,6 @@ public interface PayRefundMapper extends BaseMapperX { default List selectList(PayRefundExportReqVO reqVO) { return selectList(new QueryWrapperX() - .eqIfPresent("merchant_id", reqVO.getMerchantId()) .eqIfPresent("app_id", reqVO.getAppId()) .eqIfPresent("channel_code", reqVO.getChannelCode()) .likeIfPresent("merchant_refund_no", reqVO.getMerchantRefundNo()) diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java similarity index 64% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppService.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java index feb03e0a9..14dce0a18 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppService.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java @@ -1,13 +1,12 @@ -package cn.iocoder.yudao.module.pay.service.merchant; +package cn.iocoder.yudao.module.pay.service.app; import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppUpdateReqVO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; +import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; import javax.validation.Valid; import java.util.Collection; @@ -67,14 +66,6 @@ public interface PayAppService { */ PageResult getAppPage(PayAppPageReqVO pageReqVO); - /** - * 获得支付应用信息列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 支付应用信息列表 - */ - List getAppList(PayAppExportReqVO exportReqVO); - /** * 修改应用信息状态 * @@ -83,22 +74,14 @@ public interface PayAppService { */ void updateAppStatus(Long id, Integer status); - /** - * 根据商户 ID 获得支付应用信息列表, - * - * @param merchantId 商户 ID - * @return 支付应用信息列表 - */ - List getListByMerchantId(Long merchantId); - /** * 获得指定编号的商户 Map * - * @param appIdList 应用编号集合 + * @param ids 应用编号集合 * @return 商户 Map */ - default Map getAppMap(Collection appIdList) { - List list = this.getAppList(appIdList); + default Map getAppMap(Collection ids) { + List list = getAppList(ids); return CollectionUtils.convertMap(list, PayAppDO::getId); } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java similarity index 64% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppServiceImpl.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java index 1a7e2bebf..5f70fb5fe 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java @@ -1,21 +1,16 @@ -package cn.iocoder.yudao.module.pay.service.merchant; +package cn.iocoder.yudao.module.pay.service.app; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppUpdateReqVO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; import cn.iocoder.yudao.module.pay.convert.app.PayAppConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; -import cn.iocoder.yudao.module.pay.dal.mysql.merchant.PayAppMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.merchant.PayMerchantMapper; +import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; +import cn.iocoder.yudao.module.pay.dal.mysql.app.PayAppMapper; import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderMapper; import cn.iocoder.yudao.module.pay.dal.mysql.refund.PayRefundMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; @@ -24,11 +19,12 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import java.util.*; +import java.util.Collection; +import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_APP_EXIST_TRANSACTION_ORDER_CANT_DELETE; +import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_APP_NOT_FOUND; /** * 支付应用信息 Service 实现类 @@ -41,9 +37,7 @@ public class PayAppServiceImpl implements PayAppService { @Resource private PayAppMapper appMapper; - // TODO @aquan:使用对方的 Service。模块与模块之间,避免直接调用对方的 mapper - @Resource - private PayMerchantMapper merchantMapper; + // TODO 芋艿:不能调用对方的 mapper @Resource private PayOrderMapper orderMapper; @Resource @@ -95,33 +89,7 @@ public class PayAppServiceImpl implements PayAppService { @Override public PageResult getAppPage(PayAppPageReqVO pageReqVO) { - Set merchantIdList = this.getMerchantCondition(pageReqVO.getMerchantName()); - if (StrUtil.isNotBlank(pageReqVO.getMerchantName()) && CollectionUtil.isEmpty(merchantIdList)) { - return new PageResult<>(); - } - return appMapper.selectPage(pageReqVO, merchantIdList); - } - - @Override - public List getAppList(PayAppExportReqVO exportReqVO) { - Set merchantIdList = this.getMerchantCondition(exportReqVO.getMerchantName()); - if (StrUtil.isNotBlank(exportReqVO.getMerchantName()) && CollectionUtil.isEmpty(merchantIdList)) { - return new ArrayList<>(); - } - return appMapper.selectList(exportReqVO, merchantIdList); - } - - /** - * 获取商户编号集合,根据商户名称模糊查询得到所有的商户编号集合 - * - * @param merchantName 商户名称 - * @return 商户编号集合 - */ - private Set getMerchantCondition(String merchantName) { - if (StrUtil.isBlank(merchantName)) { - return Collections.emptySet(); - } - return convertSet(merchantMapper.getMerchantListByName(merchantName), PayMerchantDO::getId); + return appMapper.selectPage(pageReqVO); } @Override @@ -135,11 +103,6 @@ public class PayAppServiceImpl implements PayAppService { appMapper.updateById(app); } - @Override - public List getListByMerchantId(Long merchantId) { - return appMapper.getListByMerchantId(merchantId); - } - /** * 检查商户是否存在 * diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java similarity index 60% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelService.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java index 166c50598..3c634b8a9 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelService.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelService.java @@ -1,12 +1,11 @@ -package cn.iocoder.yudao.module.pay.service.merchant; +package cn.iocoder.yudao.module.pay.service.channel; import cn.iocoder.yudao.framework.common.exception.ServiceException; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelUpdateReqVO; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelPageReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateReqVO; +import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; import javax.validation.Valid; import java.util.Collection; @@ -54,33 +53,14 @@ public interface PayChannelService { */ PayChannelDO getChannel(Long id); - /** - * 获得支付渠道列表 - * - * @param ids 编号 - * @return 支付渠道 - * 列表 - */ - List getChannelList(Collection ids); - /** * 获得支付渠道分页 * * @param pageReqVO 分页查询 - * @return 支付渠道 - * 分页 + * @return 支付渠道分页 */ PageResult getChannelPage(PayChannelPageReqVO pageReqVO); - /** - * 获得支付渠道 - * 列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 支付渠道列表 - */ - List getChannelList(PayChannelExportReqVO exportReqVO); - /** * 根据支付应用ID集合获得支付渠道列表 * @@ -89,25 +69,14 @@ public interface PayChannelService { */ List getChannelListByAppIds(Collection appIds); - /** - * 根据条件获取渠道数量 - * - * @param merchantId 商户编号 - * @param appid 应用编号 - * @param code 渠道编码 - * @return 数量 - */ - Integer getChannelCountByConditions(Long merchantId, Long appid, String code); - /** * 根据条件获取渠道 * - * @param merchantId 商户编号 * @param appid 应用编号 * @param code 渠道编码 * @return 数量 */ - PayChannelDO getChannelByConditions(Long merchantId, Long appid, String code); + PayChannelDO getChannelByConditions(Long appid, String code); /** * 支付渠道的合法性 @@ -130,4 +99,12 @@ public interface PayChannelService { */ PayChannelDO validPayChannel(Long appId, String code); + /** + * 获得指定应用的开启的渠道列表 + * + * @param appId 应用编号 + * @return 渠道列表 + */ + List getEnableChannelList(Long appId); + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java similarity index 73% rename from yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelServiceImpl.java rename to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java index d4869a414..de3d51ba7 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.pay.service.merchant; +package cn.iocoder.yudao.module.pay.service.channel; import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONUtil; @@ -7,15 +7,14 @@ import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.pay.core.client.PayClientConfig; import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelUpdateReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelPageReqVO; +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.dal.dataobject.merchant.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.mysql.merchant.PayChannelMapper; +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.enums.ErrorCodeConstants; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -24,7 +23,6 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.validation.Validator; -import java.time.LocalDateTime; import java.util.Collection; import java.util.List; @@ -42,11 +40,6 @@ import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.CHANNEL_NOT_E @Validated public class PayChannelServiceImpl implements PayChannelService { - /** - * 缓存菜单的最大更新时间,用于后续的增量轮询,判断是否有更新 - */ - private volatile LocalDateTime maxUpdateTime; - @Resource private PayClientFactory payClientFactory; @@ -77,7 +70,7 @@ public class PayChannelServiceImpl implements PayChannelService { @Override public Long createChannel(PayChannelCreateReqVO reqVO) { // 断言是否有重复的 - PayChannelDO channelDO = this.getChannelByConditions(reqVO.getMerchantId(), reqVO.getAppId(), reqVO.getCode()); + PayChannelDO channelDO = this.getChannelByConditions(reqVO.getAppId(), reqVO.getCode()); if (ObjectUtil.isNotNull(channelDO)) { throw exception(CHANNEL_EXIST_SAME_CHANNEL_ERROR); } @@ -121,57 +114,19 @@ public class PayChannelServiceImpl implements PayChannelService { return channelMapper.selectById(id); } - @Override - public List getChannelList(Collection ids) { - return channelMapper.selectBatchIds(ids); - } - @Override public PageResult getChannelPage(PayChannelPageReqVO pageReqVO) { return channelMapper.selectPage(pageReqVO); } - @Override - public List getChannelList(PayChannelExportReqVO exportReqVO) { - return channelMapper.selectList(exportReqVO); - } - - /** - * 根据支付应用ID集合获得支付渠道列表 - * - * @param appIds 应用编号集合 - * @return 支付渠道列表 - */ @Override public List getChannelListByAppIds(Collection appIds) { return channelMapper.getChannelListByAppIds(appIds); } - - /** - * 根据条件获取渠道数量 - * - * @param merchantId 商户编号 - * @param appid 应用编号 - * @param code 渠道编码 - * @return 数量 - */ @Override - public Integer getChannelCountByConditions(Long merchantId, Long appid, String code) { - return this.channelMapper.selectCount(merchantId, appid, code); - } - - /** - * 根据条件获取渠道 - * - * @param merchantId 商户编号 - * @param appid 应用编号 - * @param code 渠道编码 - * @return 数量 - */ - @Override - public PayChannelDO getChannelByConditions(Long merchantId, Long appid, String code) { - return this.channelMapper.selectOne(merchantId, appid, code); + public PayChannelDO getChannelByConditions(Long appid, String code) { + return this.channelMapper.selectOne(appid, code); } /** @@ -204,10 +159,15 @@ public class PayChannelServiceImpl implements PayChannelService { @Override public PayChannelDO validPayChannel(Long appId, String code) { PayChannelDO channel = channelMapper.selectByAppIdAndCode(appId, code); - this.validPayChannel(channel); + validPayChannel(channel); return channel; } + @Override + public List getEnableChannelList(Long appId) { + return channelMapper.selectListByAppId(appId, CommonStatusEnum.ENABLE.getStatus()); + } + private void validPayChannel(PayChannelDO channel) { if (channel == null) { throw ServiceExceptionUtil.exception(ErrorCodeConstants.PAY_CHANNEL_NOT_FOUND); @@ -216,4 +176,5 @@ public class PayChannelServiceImpl implements PayChannelService { throw ServiceExceptionUtil.exception(ErrorCodeConstants.PAY_CHANNEL_IS_DISABLE); } } + } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayMerchantService.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayMerchantService.java deleted file mode 100644 index 40f02b99c..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayMerchantService.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.merchant; - -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantUpdateReqVO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 支付商户信息 Service 接口 - * - * @author aquan - */ -public interface PayMerchantService { - - /** - * 创建支付商户信息 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createMerchant(@Valid PayMerchantCreateReqVO createReqVO); - - /** - * 更新支付商户信息 - * - * @param updateReqVO 更新信息 - */ - void updateMerchant(@Valid PayMerchantUpdateReqVO updateReqVO); - - /** - * 删除支付商户信息 - * - * @param id 编号 - */ - void deleteMerchant(Long id); - - /** - * 获得支付商户信息 - * - * @param id 编号 - * @return 支付商户信息 - */ - PayMerchantDO getMerchant(Long id); - - /** - * 获得支付商户信息列表 - * - * @param ids 编号 - * @return 支付商户信息列表 - */ - List getMerchantList(Collection ids); - - /** - * 获得支付商户信息分页 - * - * @param pageReqVO 分页查询 - * @return 支付商户信息分页 - */ - PageResult getMerchantPage(PayMerchantPageReqVO pageReqVO); - - /** - * 获得支付商户信息列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 支付商户信息列表 - */ - List getMerchantList(PayMerchantExportReqVO exportReqVO); - - /** - * 修改商户状态 - * - * @param id 商户编号 - * @param status 状态 - */ - void updateMerchantStatus(Long id, Integer status); - - /** - * 根据商户名称模糊查询商户集合 - * - * @param merchantName 商户名称 - * @return 商户集合 - */ - List getMerchantListByName(String merchantName); - - /** - * 获得指定编号的商户 Map - * - * @param merchantIds 商户编号数组 - * @return 商户 Map - */ - default Map getMerchantMap(Collection merchantIds) { - List list = this.getMerchantList(merchantIds); - return CollectionUtils.convertMap(list, PayMerchantDO::getId); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayMerchantServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayMerchantServiceImpl.java deleted file mode 100644 index c14a87d7d..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/merchant/PayMerchantServiceImpl.java +++ /dev/null @@ -1,148 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.merchant; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantUpdateReqVO; -import cn.iocoder.yudao.module.pay.convert.merchant.PayMerchantConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; -import cn.iocoder.yudao.module.pay.dal.mysql.merchant.PayAppMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.merchant.PayMerchantMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import com.google.common.annotations.VisibleForTesting; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; - -/** - * 支付商户信息 Service 实现类 - * - * @author aquan - */ -@Service -@Validated -public class PayMerchantServiceImpl implements PayMerchantService { - - @Resource - private PayMerchantMapper merchantMapper; - - @Resource - private PayAppMapper appMapper; - - @Override - public Long createMerchant(PayMerchantCreateReqVO createReqVO) { - // 插入 - PayMerchantDO merchant = PayMerchantConvert.INSTANCE.convert(createReqVO); - merchant.setNo(this.generateMerchantNo()); - merchantMapper.insert(merchant); - // 返回 - return merchant.getId(); - } - - @Override - public void updateMerchant(PayMerchantUpdateReqVO updateReqVO) { - // 校验存在 - this.validateMerchantExists(updateReqVO.getId()); - // 更新 - PayMerchantDO updateObj = PayMerchantConvert.INSTANCE.convert(updateReqVO); - merchantMapper.updateById(updateObj); - } - - @Override - public void deleteMerchant(Long id) { - // 校验 - this.validateMerchantExists(id); - this.validateAppExists(id); - // 删除 - merchantMapper.deleteById(id); - } - - @Override - public PayMerchantDO getMerchant(Long id) { - return merchantMapper.selectById(id); - } - - @Override - public List getMerchantList(Collection ids) { - return merchantMapper.selectBatchIds(ids); - } - - @Override - public PageResult getMerchantPage(PayMerchantPageReqVO pageReqVO) { - return merchantMapper.selectPage(pageReqVO); - } - - @Override - public List getMerchantList(PayMerchantExportReqVO exportReqVO) { - return merchantMapper.selectList(exportReqVO); - } - - @Override - public void updateMerchantStatus(Long id, Integer status) { - // 校验商户存在 - this.checkMerchantExists(id); - // 更新状态 - PayMerchantDO merchant = new PayMerchantDO(); - merchant.setId(id); - merchant.setStatus(status); - merchantMapper.updateById(merchant); - } - - @Override - public List getMerchantListByName(String merchantName) { - return this.merchantMapper.getMerchantListByName(merchantName); - } - - @VisibleForTesting - public void checkMerchantExists(Long id) { - if (id == null) { - return; - } - PayMerchantDO merchant = merchantMapper.selectById(id); - if (merchant == null) { - throw exception(PAY_MERCHANT_NOT_EXISTS); - } - } - - /** - * 校验商户是否存在 - * - * @param id 商户 ID - */ - private void validateMerchantExists(Long id) { - if (ObjectUtil.isNull(merchantMapper.selectById(id))) { - throw exception(PAY_MERCHANT_NOT_EXISTS); - } - } - - /** - * 校验商户是否还存在支付应用 - * - * @param id 商户ID - */ - private void validateAppExists(Long id) { - if (appMapper.selectCount(id) > 0) { - throw exception(PAY_MERCHANT_EXIST_APP_CANT_DELETE); - } - } - - // TODO @芋艿:后续增加下合适的算法 - /** - * 根据年月日时分秒毫秒生成商户号 - * - * @return 商户号 - */ - private String generateMerchantNo() { - return "M" + DateUtil.format(LocalDateTime.now(), "yyyyMMddHHmmssSSS"); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java index 73cfe7e68..43179b716 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/notify/PayNotifyServiceImpl.java @@ -91,14 +91,14 @@ public class PayNotifyServiceImpl implements PayNotifyService { task.setType(reqDTO.getType()).setDataId(reqDTO.getDataId()); task.setStatus(PayNotifyStatusEnum.WAITING.getStatus()).setNextNotifyTime(LocalDateTime.now()) .setNotifyTimes(0).setMaxNotifyTimes(PayNotifyTaskDO.NOTIFY_FREQUENCY.length + 1); - // 补充 merchantId + appId + notifyUrl 字段 + // 补充 appId + notifyUrl 字段 if (Objects.equals(task.getType(), PayNotifyTypeEnum.ORDER.getType())) { PayOrderDO order = orderService.getOrder(task.getDataId()); // 不进行非空判断,有问题直接异常 - task.setMerchantId(order.getMerchantId()).setAppId(order.getAppId()). + task.setAppId(order.getAppId()). setMerchantOrderId(order.getMerchantOrderId()).setNotifyUrl(order.getNotifyUrl()); } else if (Objects.equals(task.getType(), PayNotifyTypeEnum.REFUND.getType())) { PayRefundDO refundDO = refundService.getRefund(task.getDataId()); - task.setMerchantId(refundDO.getMerchantId()).setAppId(refundDO.getAppId()) + task.setAppId(refundDO.getAppId()) .setMerchantOrderId(refundDO.getMerchantOrderId()).setNotifyUrl(refundDO.getNotifyUrl()); } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java index a653887a9..ff3313ff0 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java @@ -18,8 +18,8 @@ import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitReqVO; import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; +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.order.PayOrderDO; import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderExtensionMapper; @@ -28,8 +28,8 @@ import cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.pay.enums.notify.PayNotifyTypeEnum; import cn.iocoder.yudao.module.pay.enums.order.PayOrderNotifyStatusEnum; import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; -import cn.iocoder.yudao.module.pay.service.merchant.PayAppService; -import cn.iocoder.yudao.module.pay.service.merchant.PayChannelService; +import cn.iocoder.yudao.module.pay.service.app.PayAppService; +import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; import cn.iocoder.yudao.module.pay.service.notify.dto.PayNotifyTaskCreateReqDTO; import lombok.extern.slf4j.Slf4j; @@ -109,8 +109,7 @@ public class PayOrderServiceImpl implements PayOrderService { } // 创建支付交易单 - order = PayOrderConvert.INSTANCE.convert(reqDTO) - .setMerchantId(app.getMerchantId()).setAppId(app.getId()); + order = PayOrderConvert.INSTANCE.convert(reqDTO).setAppId(app.getId()); // 商户相关字段 order.setNotifyUrl(app.getPayNotifyUrl()) .setNotifyStatus(PayOrderNotifyStatusEnum.NO.getStatus()); @@ -141,7 +140,7 @@ public class PayOrderServiceImpl implements PayOrderService { orderExtensionMapper.insert(orderExtension); // 3. 调用三方接口 - PayOrderUnifiedReqDTO unifiedOrderReqDTO = PayOrderConvert.INSTANCE.convert2(reqVO) + PayOrderUnifiedReqDTO unifiedOrderReqDTO = PayOrderConvert.INSTANCE.convert2(reqVO, userIp) // 商户相关的字段 .setMerchantOrderId(orderExtension.getNo()) // 注意,此处使用的是 PayOrderExtensionDO.no 属性! .setSubject(order.getSubject()).setBody(order.getBody()) diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java index 55a1487a1..9d113b84d 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java @@ -10,12 +10,12 @@ import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayNotifyReqDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.notify.PayRefundNotifyRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO; -import cn.iocoder.yudao.framework.pay.core.enums.PayNotifyRefundStatusEnum; +import cn.iocoder.yudao.framework.pay.core.enums.refund.PayNotifyRefundStatusEnum; 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.PayRefundPageReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; +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.order.PayOrderDO; import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; @@ -27,8 +27,8 @@ import cn.iocoder.yudao.module.pay.enums.order.PayOrderNotifyStatusEnum; import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; import cn.iocoder.yudao.module.pay.enums.refund.PayRefundTypeEnum; -import cn.iocoder.yudao.module.pay.service.merchant.PayAppService; -import cn.iocoder.yudao.module.pay.service.merchant.PayChannelService; +import cn.iocoder.yudao.module.pay.service.app.PayAppService; +import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; import cn.iocoder.yudao.module.pay.service.notify.dto.PayNotifyTaskCreateReqDTO; import cn.iocoder.yudao.module.pay.service.order.PayOrderExtensionService; @@ -141,7 +141,6 @@ public class PayRefundServiceImpl implements PayRefundService { .channelOrderNo(order.getChannelOrderNo()) .channelCode(order.getChannelCode()) .channelId(order.getChannelId()) - .merchantId(order.getMerchantId()) .orderId(order.getId()) .merchantRefundNo(merchantRefundId) // TODO 芋艿:需要优化 .notifyUrl(app.getRefundNotifyUrl()) diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java index 2818cb12d..73b4f6f82 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/dataobject/merchant/PayChannelDOTest.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.pay.dal.dataobject.merchant; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; +import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WXPayClientConfig; import org.junit.jupiter.api.Test; public class PayChannelDOTest { diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java index b869163a2..2150a8a15 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/dal/mysql/merchant/PayChannelMapperIntegrationTest.java @@ -4,7 +4,7 @@ import cn.hutool.core.io.IoUtil; import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; +import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WXPayClientConfig; import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; import cn.iocoder.yudao.module.pay.test.BaseDbIntegrationTest; import org.junit.jupiter.api.Test; @@ -29,7 +29,6 @@ public class PayChannelMapperIntegrationTest extends BaseDbIntegrationTest { payChannelDO.setCode(PayChannelEnum.WX_PUB.getCode()); payChannelDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); payChannelDO.setFeeRate(1D); - payChannelDO.setMerchantId(1L); payChannelDO.setAppId(6L); // 配置 WXPayClientConfig config = new WXPayClientConfig(); @@ -55,7 +54,6 @@ public class PayChannelMapperIntegrationTest extends BaseDbIntegrationTest { payChannelDO.setCode(PayChannelEnum.ALIPAY_QR.getCode()); payChannelDO.setStatus(CommonStatusEnum.ENABLE.getStatus()); payChannelDO.setFeeRate(1D); - payChannelDO.setMerchantId(1L); payChannelDO.setAppId(6L); // 配置 AlipayPayClientConfig config = new AlipayPayClientConfig(); diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java index f6f953635..983bd16b5 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/test-integration/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceIntegrationTest.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.pay.service.order; -import cn.iocoder.yudao.module.pay.service.merchant.PayAppServiceImpl; -import cn.iocoder.yudao.module.pay.service.merchant.PayChannelServiceImpl; +import cn.iocoder.yudao.module.pay.service.channel.PayAppServiceImpl; +import cn.iocoder.yudao.module.pay.service.channel.PayChannelServiceImpl; import cn.iocoder.yudao.module.pay.service.order.dto.PayOrderCreateReqDTO; import cn.iocoder.yudao.module.pay.service.order.dto.PayOrderSubmitReqDTO; import cn.iocoder.yudao.module.pay.test.BaseDbIntegrationTest; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceTest.java similarity index 54% rename from yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppServiceTest.java rename to yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceTest.java index 95851a551..3fad0745b 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayAppServiceTest.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceTest.java @@ -1,26 +1,19 @@ -package cn.iocoder.yudao.module.pay.service.merchant; +package cn.iocoder.yudao.module.pay.service.app; import cn.hutool.core.util.RandomUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.app.PayAppUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayAppDO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; -import cn.iocoder.yudao.module.pay.dal.mysql.merchant.PayAppMapper; -import cn.iocoder.yudao.module.pay.dal.mysql.merchant.PayMerchantMapper; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; +import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; +import cn.iocoder.yudao.module.pay.dal.mysql.app.PayAppMapper; import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import javax.annotation.Resource; import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; @@ -40,9 +33,6 @@ public class PayAppServiceTest extends BaseDbUnitTest { @Resource private PayAppMapper appMapper; - @MockBean(name = "payMerchantMapper") - private PayMerchantMapper payMerchantMapper; - @Test public void testCreateApp_success() { // 准备参数 @@ -112,9 +102,6 @@ public class PayAppServiceTest extends BaseDbUnitTest { @Test public void testGetAppPage() { - Long merchantId = 1L; - Long mismatchMerchantId = 2L; - // mock 数据 PayAppDO dbApp = randomPojo(PayAppDO.class, o -> { // 等会查询到 o.setName("灿灿姐的杂货铺"); @@ -122,24 +109,9 @@ public class PayAppServiceTest extends BaseDbUnitTest { o.setRemark("敏敏姐的小卖铺"); o.setPayNotifyUrl("https://www.hc.com"); o.setRefundNotifyUrl("https://www.xm.com"); - o.setMerchantId(merchantId); o.setCreateTime(buildTime(2021,11,20)); }); - // mock 数据 - PayMerchantDO dbMerchant = randomPojo(PayMerchantDO.class, o -> { // 等会查询到 - o.setId(merchantId); - o.setNo("M1008611"); - o.setName("灿哥的杂货铺"); - o.setShortName("灿灿子"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setRemark("灿哥的杂货铺"); - o.setCreateTime(buildTime(2021,11,3)); - }); - - Mockito.when(payMerchantMapper.getMerchantListByName(dbMerchant.getName())) - .thenReturn(Collections.singletonList(dbMerchant)); - appMapper.insert(dbApp); // 测试 name 不匹配 appMapper.insert(cloneIgnoreId(dbApp, o -> o.setName("敏敏姐的杂货铺"))); @@ -151,8 +123,6 @@ public class PayAppServiceTest extends BaseDbUnitTest { appMapper.insert(cloneIgnoreId(dbApp, o -> o.setPayNotifyUrl("xm.com"))); // 测试 refundNotifyUrl 不匹配 appMapper.insert(cloneIgnoreId(dbApp, o -> o.setRefundNotifyUrl("hc.com"))); - // 测试 merchantId 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setMerchantId(mismatchMerchantId))); // 测试 createTime 不匹配 appMapper.insert(cloneIgnoreId(dbApp, o -> o.setCreateTime(buildTime(2021,12,21)))); // 准备参数 @@ -162,7 +132,6 @@ public class PayAppServiceTest extends BaseDbUnitTest { reqVO.setRemark("敏敏姐的小卖铺"); reqVO.setPayNotifyUrl("https://www.hc.com"); reqVO.setRefundNotifyUrl("https://www.xm.com"); - reqVO.setMerchantName(dbMerchant.getName()); reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021,11,19),buildTime(2021,11,21)})); // 调用 @@ -173,66 +142,4 @@ public class PayAppServiceTest extends BaseDbUnitTest { assertPojoEquals(dbApp, pageResult.getList().get(0)); } - @Test // TODO 请修改 null 为需要的值 - public void testGetAppList() { - Long merchantId = 1L; - Long mismatchMerchantId = 2L; - - // mock 数据 - PayAppDO dbApp = randomPojo(PayAppDO.class, o -> { // 等会查询到 - o.setName("灿灿姐的杂货铺"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setRemark("敏敏姐的小卖铺"); - o.setPayNotifyUrl("https://www.hc.com"); - o.setRefundNotifyUrl("https://www.xm.com"); - o.setMerchantId(merchantId); - o.setCreateTime(buildTime(2021,11,20)); - }); - - // mock 数据 - PayMerchantDO dbMerchant = randomPojo(PayMerchantDO.class, o -> { // 等会查询到 - o.setId(merchantId); - o.setNo("M1008611"); - o.setName("灿哥的杂货铺"); - o.setShortName("灿灿子"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setRemark("灿哥的杂货铺"); - o.setCreateTime(buildTime(2021,11,3)); - }); - - Mockito.when(payMerchantMapper.getMerchantListByName(dbMerchant.getName())) - .thenReturn(Collections.singletonList(dbMerchant)); - - appMapper.insert(dbApp); - // 测试 name 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setName("敏敏姐的杂货铺"))); - // 测试 status 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 remark 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setRemark("灿灿姐的小卖部"))); - // 测试 payNotifyUrl 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setPayNotifyUrl("xm.com"))); - // 测试 refundNotifyUrl 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setRefundNotifyUrl("hc.com"))); - // 测试 merchantId 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setMerchantId(mismatchMerchantId))); - // 测试 createTime 不匹配 - appMapper.insert(cloneIgnoreId(dbApp, o -> o.setCreateTime(buildTime(2021,12,21)))); - // 准备参数 - PayAppExportReqVO reqVO = new PayAppExportReqVO(); - reqVO.setName("灿灿姐的杂货铺"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setRemark("敏敏姐的小卖铺"); - reqVO.setPayNotifyUrl("https://www.hc.com"); - reqVO.setRefundNotifyUrl("https://www.xm.com"); - reqVO.setMerchantName(dbMerchant.getName()); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021,11,19),buildTime(2021,11,21)})); - - // 调用 - List list = appService.getAppList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbApp, list.get(0)); - } - } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java similarity index 73% rename from yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelServiceTest.java rename to yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java index 44ea6c0b9..614af37f5 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayChannelServiceTest.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java @@ -1,18 +1,17 @@ -package cn.iocoder.yudao.module.pay.service.merchant; +package cn.iocoder.yudao.module.pay.service.channel; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; import cn.iocoder.yudao.framework.pay.core.client.impl.alipay.AlipayPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.client.impl.wx.WXPayClientConfig; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.client.impl.weixin.WxPayClientConfig; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.channel.PayChannelUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayChannelDO; -import cn.iocoder.yudao.module.pay.dal.mysql.merchant.PayChannelMapper; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelCreateReqVO; +import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelPageReqVO; +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.mysql.channel.PayChannelMapper; import com.alibaba.fastjson.JSON; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; @@ -21,7 +20,6 @@ import org.springframework.context.annotation.Import; import javax.annotation.Resource; import javax.validation.Validator; import java.time.LocalDateTime; -import java.util.List; import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; @@ -49,7 +47,7 @@ public class PayChannelServiceTest extends BaseDbUnitTest { @Test public void testCreateWechatVersion2Channel_success() { // 准备参数 - WXPayClientConfig v2Config = getV2Config(); + WxPayClientConfig v2Config = getV2Config(); PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> { o.setCode(PayChannelEnum.WX_PUB.getCode()); o.setStatus(CommonStatusEnum.ENABLE.getStatus()); @@ -70,7 +68,7 @@ public class PayChannelServiceTest extends BaseDbUnitTest { @Test public void testCreateWechatVersion3Channel_success() { // 准备参数 - WXPayClientConfig v3Config = getV3Config(); + WxPayClientConfig v3Config = getV3Config(); PayChannelCreateReqVO reqVO = randomPojo(PayChannelCreateReqVO.class, o -> { o.setCode(PayChannelEnum.WX_PUB.getCode()); o.setStatus(CommonStatusEnum.ENABLE.getStatus()); @@ -211,7 +209,6 @@ public class PayChannelServiceTest extends BaseDbUnitTest { o.setStatus(CommonStatusEnum.ENABLE.getStatus()); o.setRemark("灿灿子的支付渠道"); o.setFeeRate(0.03); - o.setMerchantId(1L); o.setAppId(1L); o.setConfig(payClientConfig); o.setCreateTime(buildTime(2021,11,20)); @@ -239,11 +236,6 @@ public class PayChannelServiceTest extends BaseDbUnitTest { o.setConfig(payClientConfig); o.setFeeRate(1.23); })); - // 测试 merchantId 不匹配 - channelMapper.insert(cloneIgnoreId(dbChannel, o -> { - o.setConfig(payClientConfig); - o.setMerchantId(2L); - })); // 测试 appId 不匹配 channelMapper.insert(cloneIgnoreId(dbChannel, o -> { o.setConfig(payClientConfig); @@ -260,7 +252,6 @@ public class PayChannelServiceTest extends BaseDbUnitTest { reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); reqVO.setRemark("灿灿子的支付渠道"); reqVO.setFeeRate(0.03); - reqVO.setMerchantId(1L); reqVO.setAppId(1L); reqVO.setConfig(JSON.toJSONString(payClientConfig)); reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021,11,19),buildTime(2021,11,21)})); @@ -275,93 +266,22 @@ public class PayChannelServiceTest extends BaseDbUnitTest { } - @Test - public void testGetChannelList() { - // mock 数据 - AlipayPayClientConfig payClientConfig = getCertificateConfig(); - PayChannelDO dbChannel = randomPojo(PayChannelDO.class, o -> { // 等会查询到 - o.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setRemark("灿灿子的支付渠道"); - o.setFeeRate(0.03); - o.setMerchantId(1L); - o.setAppId(1L); - o.setConfig(payClientConfig); - o.setCreateTime(buildTime(2021,11,20)); - }); - channelMapper.insert(dbChannel); - // 执行拷贝的时候会出现异常,所以在插入后要重置为null 后续在写入新的 - dbChannel.setConfig(null); - // 测试 code 不匹配 - channelMapper.insert(cloneIgnoreId(dbChannel, o -> { - o.setConfig(payClientConfig); - o.setCode(PayChannelEnum.WX_PUB.getCode()); - })); - // 测试 status 不匹配 - channelMapper.insert(cloneIgnoreId(dbChannel, o -> { - o.setConfig(payClientConfig); - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - })); - // 测试 remark 不匹配 - channelMapper.insert(cloneIgnoreId(dbChannel, o ->{ - o.setConfig(payClientConfig); - o.setRemark("敏敏子的渠道"); - })); - // 测试 feeRate 不匹配 - channelMapper.insert(cloneIgnoreId(dbChannel, o -> { - o.setConfig(payClientConfig); - o.setFeeRate(1.23); - })); - // 测试 merchantId 不匹配 - channelMapper.insert(cloneIgnoreId(dbChannel, o -> { - o.setConfig(payClientConfig); - o.setMerchantId(2L); - })); - // 测试 appId 不匹配 - channelMapper.insert(cloneIgnoreId(dbChannel, o -> { - o.setConfig(payClientConfig); - o.setAppId(2L); - })); - // 测试 createTime 不匹配 - channelMapper.insert(cloneIgnoreId(dbChannel, o -> { - o.setConfig(payClientConfig); - o.setCreateTime(buildTime(2021, 10, 20)); - })); - // 准备参数 - PayChannelExportReqVO reqVO = new PayChannelExportReqVO(); - reqVO.setCode(PayChannelEnum.ALIPAY_APP.getCode()); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setRemark("灿灿子的支付渠道"); - reqVO.setFeeRate(0.03); - reqVO.setMerchantId(1L); - reqVO.setAppId(1L); - reqVO.setConfig(JSON.toJSONString(payClientConfig)); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021,11,19),buildTime(2021,11,21)})); - - // 调用 - List list = channelService.getChannelList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbChannel, list.get(0), "config"); - assertPojoEquals(payClientConfig, list.get(0).getConfig()); - } - - public WXPayClientConfig getV2Config() { - return new WXPayClientConfig() + public WxPayClientConfig getV2Config() { + return new WxPayClientConfig() .setAppId("APP00001") .setMchId("MCH00001") - .setApiVersion(WXPayClientConfig.API_VERSION_V2) + .setApiVersion(WxPayClientConfig.API_VERSION_V2) .setMchKey("dsa1d5s6a1d6sa16d1sa56d15a61das6") .setApiV3Key("") .setPrivateCertContent("") .setPrivateKeyContent(""); } - public WXPayClientConfig getV3Config() { - return new WXPayClientConfig() + public WxPayClientConfig getV3Config() { + return new WxPayClientConfig() .setAppId("APP00001") .setMchId("MCH00001") - .setApiVersion(WXPayClientConfig.API_VERSION_V3) + .setApiVersion(WxPayClientConfig.API_VERSION_V3) .setMchKey("") .setApiV3Key("sdadasdsadadsa") .setPrivateKeyContent("dsa445das415d15asd16ad156as") diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayMerchantServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayMerchantServiceTest.java deleted file mode 100644 index de3f6904f..000000000 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/merchant/PayMerchantServiceTest.java +++ /dev/null @@ -1,191 +0,0 @@ -package cn.iocoder.yudao.module.pay.service.merchant; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantCreateReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantExportReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantPageReqVO; -import cn.iocoder.yudao.module.pay.controller.admin.merchant.vo.merchant.PayMerchantUpdateReqVO; -import cn.iocoder.yudao.module.pay.dal.dataobject.merchant.PayMerchantDO; -import cn.iocoder.yudao.module.pay.dal.mysql.merchant.PayMerchantMapper; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_MERCHANT_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** -* {@link PayMerchantServiceImpl} 的单元测试类 -* -* @author aquan -*/ -@Import(PayMerchantServiceImpl.class) -public class PayMerchantServiceTest extends BaseDbUnitTest { - - @Resource - private PayMerchantServiceImpl merchantService; - - @Resource - private PayMerchantMapper merchantMapper; - - @Test - public void testCreateMerchant_success() { - // 准备参数 - PayMerchantCreateReqVO reqVO = randomPojo(PayMerchantCreateReqVO.class,o -> - o.setStatus(RandomUtil.randomEle(CommonStatusEnum.values()).getStatus())); - - // 调用 - Long merchantId = merchantService.createMerchant(reqVO); - // 断言 - assertNotNull(merchantId); - // 校验记录的属性是否正确 - PayMerchantDO merchant = merchantMapper.selectById(merchantId); - assertPojoEquals(reqVO, merchant); - } - - @Test - public void testUpdateMerchant_success() { - // mock 数据 - PayMerchantDO dbMerchant = randomPojo(PayMerchantDO.class, o -> - o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - merchantMapper.insert(dbMerchant);// @Sql: 先插入出一条存在的数据 - // 准备参数 - PayMerchantUpdateReqVO reqVO = randomPojo(PayMerchantUpdateReqVO.class, o -> { - o.setId(dbMerchant.getId()); // 设置更新的 ID - o.setStatus(CommonStatusEnum.DISABLE.getStatus()); - }); - - // 调用 - merchantService.updateMerchant(reqVO); - // 校验是否更新正确 - PayMerchantDO merchant = merchantMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, merchant); - } - - @Test - public void testUpdateMerchant_notExists() { - // 准备参数 - PayMerchantUpdateReqVO reqVO = randomPojo(PayMerchantUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> merchantService.updateMerchant(reqVO), PAY_MERCHANT_NOT_EXISTS); - } - - @Test - public void testDeleteMerchant_success() { - // mock 数据 - PayMerchantDO dbMerchant = randomPojo(PayMerchantDO.class, - o-> o.setStatus(CommonStatusEnum.ENABLE.getStatus())); - merchantMapper.insert(dbMerchant);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbMerchant.getId(); - - // 调用 - merchantService.deleteMerchant(id); - // 校验数据不存在了 - assertNull(merchantMapper.selectById(id)); - } - - @Test - public void testDeleteMerchant_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> merchantService.deleteMerchant(id), PAY_MERCHANT_NOT_EXISTS); - } - - @Test - public void testGetMerchantPage() { - // mock 数据 - PayMerchantDO dbMerchant = randomPojo(PayMerchantDO.class, o -> { // 等会查询到 - o.setNo("M1008611"); - o.setName("灿哥的杂货铺"); - o.setShortName("灿灿子"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setRemark("灿哥的杂货铺"); - o.setCreateTime(buildTime(2021,11,3)); - }); - merchantMapper.insert(dbMerchant); - // 测试 no 不匹配 - merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setNo("M200000"))); - // 测试 name 不匹配 - merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setName("斌哥的杂货铺"))); - // 测试 shortName 不匹配 - merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setShortName("斌斌子"))); - // 测试 status 不匹配 - merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 remark 不匹配 - merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setRemark("斌哥的杂货铺"))); - // 测试 createTime 不匹配 - merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setCreateTime(buildTime(2022,12,4)))); - // 准备参数 - PayMerchantPageReqVO reqVO = new PayMerchantPageReqVO(); - reqVO.setNo("M1008611"); - reqVO.setName("灿哥的杂货铺"); - reqVO.setShortName("灿灿子"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setRemark("灿哥的杂货铺"); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021,11,2),buildTime(2021,11,4)})); - - // 调用 - PageResult pageResult = merchantService.getMerchantPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbMerchant, pageResult.getList().get(0)); - } - - @Test - public void testGetMerchantList() { - // mock 数据 - PayMerchantDO dbMerchant = randomPojo(PayMerchantDO.class, o -> { // 等会查询到 - o.setNo("M1008611"); - o.setName("灿哥的杂货铺"); - o.setShortName("灿灿子"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setRemark("灿哥的杂货铺"); - o.setCreateTime(buildTime(2021,11,3)); - }); - merchantMapper.insert(dbMerchant); - // 测试 no 不匹配 - merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setNo("M200000"))); - // 测试 name 不匹配 - merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setName("斌哥的杂货铺"))); - // 测试 shortName 不匹配 - merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setShortName("斌斌子"))); - // 测试 status 不匹配 - merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 remark 不匹配 - merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setRemark("斌哥的杂货铺"))); - // 测试 createTime 不匹配 - merchantMapper.insert(cloneIgnoreId(dbMerchant, o -> o.setCreateTime(buildTime(2022,12,4)))); - // 准备参数 - PayMerchantExportReqVO reqVO = new PayMerchantExportReqVO(); - reqVO.setNo("M1008611"); - reqVO.setName("灿哥的杂货铺"); - reqVO.setShortName("灿灿子"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setRemark("灿哥的杂货铺"); - reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021,11,2),buildTime(2021,11,4)})); - - // 调用 - List list = merchantService.getMerchantList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbMerchant, list.get(0)); - } - -} diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java index 774ec3ade..eaad15c03 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java @@ -5,7 +5,7 @@ import cn.hutool.core.util.RandomUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.pay.config.PayProperties; import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; @@ -14,8 +14,8 @@ import cn.iocoder.yudao.module.pay.dal.mysql.order.PayOrderMapper; import cn.iocoder.yudao.module.pay.enums.order.PayOrderNotifyStatusEnum; import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; import cn.iocoder.yudao.module.pay.enums.refund.PayRefundTypeEnum; -import cn.iocoder.yudao.module.pay.service.merchant.PayAppService; -import cn.iocoder.yudao.module.pay.service.merchant.PayChannelService; +import cn.iocoder.yudao.module.pay.service.app.PayAppService; +import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; @@ -67,7 +67,6 @@ public class PayOrderServiceTest extends BaseDbUnitTest { // mock 数据 PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> { // 等会查询到 - o.setMerchantId(1L); o.setAppId(1L); o.setChannelId(1L); o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); @@ -94,8 +93,6 @@ public class PayOrderServiceTest extends BaseDbUnitTest { o.setUpdateTime(LocalDateTime.of(2018, 1, 1, 10, 10, 15)); }); orderMapper.insert(dbOrder); - // 测试 merchantId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setMerchantId(2L))); // 测试 appId 不匹配 orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setAppId(2L))); // 测试 channelId 不匹配 @@ -115,7 +112,6 @@ public class PayOrderServiceTest extends BaseDbUnitTest { 1)))); // 准备参数 PayOrderPageReqVO reqVO = new PayOrderPageReqVO(); - reqVO.setMerchantId(1L); reqVO.setAppId(1L); reqVO.setChannelId(1L); reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); @@ -139,7 +135,6 @@ public class PayOrderServiceTest extends BaseDbUnitTest { String merchantOrderId = generateNo(); String channelOrderId = generateNo(); PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> { // 等会查询到 - o.setMerchantId(1L); o.setAppId(1L); o.setChannelId(1L); o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); @@ -167,8 +162,6 @@ public class PayOrderServiceTest extends BaseDbUnitTest { }); orderMapper.insert(dbOrder); - // 测试 merchantId 不匹配 - orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setMerchantId(2L))); // 测试 appId 不匹配 orderMapper.insert(cloneIgnoreId(dbOrder, o -> o.setAppId(2L))); // 测试 channelId 不匹配 @@ -188,7 +181,6 @@ public class PayOrderServiceTest extends BaseDbUnitTest { 1)))); // 准备参数 PayOrderExportReqVO reqVO = new PayOrderExportReqVO(); - reqVO.setMerchantId(1L); reqVO.setAppId(1L); reqVO.setChannelId(1L); reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java index 1f2e67d55..74c965e4b 100755 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.pay.service.refund; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.pay.config.PayProperties; import cn.iocoder.yudao.framework.pay.core.client.PayClientFactory; -import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum; +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundExportReqVO; import cn.iocoder.yudao.module.pay.controller.admin.refund.vo.PayRefundPageReqVO; @@ -12,8 +12,8 @@ import cn.iocoder.yudao.module.pay.dal.mysql.refund.PayRefundMapper; import cn.iocoder.yudao.module.pay.enums.order.PayOrderNotifyStatusEnum; import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; import cn.iocoder.yudao.module.pay.enums.refund.PayRefundTypeEnum; -import cn.iocoder.yudao.module.pay.service.merchant.PayAppService; -import cn.iocoder.yudao.module.pay.service.merchant.PayChannelService; +import cn.iocoder.yudao.module.pay.service.app.PayAppService; +import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; import cn.iocoder.yudao.module.pay.service.order.PayOrderExtensionService; import cn.iocoder.yudao.module.pay.service.order.PayOrderService; @@ -58,7 +58,6 @@ public class PayRefundServiceTest extends BaseDbUnitTest { public void testGetRefundPage() { // mock 数据 PayRefundDO dbRefund = randomPojo(PayRefundDO.class, o -> { // 等会查询到 - o.setMerchantId(1L); o.setAppId(1L); o.setChannelId(1L); o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); @@ -86,8 +85,6 @@ public class PayRefundServiceTest extends BaseDbUnitTest { o.setUpdateTime(LocalDateTime.of(2021, 1, 1, 10, 10, 35)); }); refundMapper.insert(dbRefund); - // 测试 merchantId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantId(2L))); // 测试 appId 不匹配 refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L))); // 测试 channelCode 不匹配 @@ -106,7 +103,6 @@ public class PayRefundServiceTest extends BaseDbUnitTest { o.setCreateTime(LocalDateTime.of(2022, 1, 1, 10, 10, 10)))); // 准备参数 PayRefundPageReqVO reqVO = new PayRefundPageReqVO(); - reqVO.setMerchantId(1L); reqVO.setAppId(1L); reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); reqVO.setMerchantRefundNo("MRF0000001"); @@ -127,7 +123,6 @@ public class PayRefundServiceTest extends BaseDbUnitTest { public void testGetRefundList() { // mock 数据 PayRefundDO dbRefund = randomPojo(PayRefundDO.class, o -> { // 等会查询到 - o.setMerchantId(1L); o.setAppId(1L); o.setChannelId(1L); o.setChannelCode(PayChannelEnum.WX_PUB.getCode()); @@ -155,8 +150,6 @@ public class PayRefundServiceTest extends BaseDbUnitTest { o.setUpdateTime(LocalDateTime.of(2021, 1, 1, 10, 10, 35)); }); refundMapper.insert(dbRefund); - // 测试 merchantId 不匹配 - refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setMerchantId(2L))); // 测试 appId 不匹配 refundMapper.insert(cloneIgnoreId(dbRefund, o -> o.setAppId(2L))); // 测试 channelCode 不匹配 @@ -176,7 +169,6 @@ public class PayRefundServiceTest extends BaseDbUnitTest { // 准备参数 PayRefundExportReqVO reqVO = new PayRefundExportReqVO(); - reqVO.setMerchantId(1L); reqVO.setAppId(1L); reqVO.setChannelCode(PayChannelEnum.WX_PUB.getCode()); reqVO.setMerchantRefundNo("MRF0000001"); diff --git a/yudao-module-system/yudao-module-system-biz/pom.xml b/yudao-module-system/yudao-module-system-biz/pom.xml index 898029163..5abeb06ca 100644 --- a/yudao-module-system/yudao-module-system-biz/pom.xml +++ b/yudao-module-system/yudao-module-system-biz/pom.xml @@ -58,6 +58,10 @@ cn.iocoder.boot yudao-spring-boot-starter-biz-ip + + cn.iocoder.boot + yudao-spring-boot-starter-biz-weixin + diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/weixin/AppWxMpController.http b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/weixin/AppWxMpController.http new file mode 100644 index 000000000..6af305aef --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/weixin/AppWxMpController.http @@ -0,0 +1,4 @@ +### 请求 /login 接口 => 成功 +POST {{appApi}}/system/wx-mp/create-jsapi-signature?url=http://www.iocoder.cn +Authorization: Bearer {{appToken}} +tenant-id: {{appTenentId}} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/weixin/AppWxMpController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/weixin/AppWxMpController.java similarity index 85% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/weixin/AppWxMpController.java rename to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/weixin/AppWxMpController.java index 7a2413ee3..e6e91b669 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/weixin/AppWxMpController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/weixin/AppWxMpController.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.member.controller.app.weixin; +package cn.iocoder.yudao.module.system.controller.app.weixin; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import io.swagger.v3.oas.annotations.tags.Tag; @@ -19,7 +19,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "微信公众号") @RestController -@RequestMapping("/member/wx-mp") +@RequestMapping("/system/wx-mp") @Validated @Slf4j public class AppWxMpController { @@ -27,6 +27,7 @@ public class AppWxMpController { @Resource private WxMpService mpService; + // TODO @芋艿:需要额外考虑个问题;多租户下,如果每个小程序一个微信公众号,则会存在多个 appid; @PostMapping("/create-jsapi-signature") @Operation(summary = "创建微信 JS SDK 初始化所需的签名", description = "参考 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html 文档") diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 2059b107d..250a29d29 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -173,8 +173,8 @@ wx: key-prefix: wx # Redis Key 的前缀 TODO 芋艿:解决下 Redis key 管理的配置 http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台 miniapp: # 小程序配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-miniapp-spring-boot-starter/README.md 文档 - appid: wx63c280fe3248a3e7 - secret: 6f270509224a7ae1296bbf1c8cb97aed + appid: wx62056c0d5e8db250 + secret: 333ae72f41552af1e998fe1f54e1584a config-storage: type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 key-prefix: wa # Redis Key 的前缀 TODO 芋艿:解决下 Redis key 管理的配置 diff --git a/yudao-server/src/main/resources/static/pay_wx_pub.html b/yudao-server/src/main/resources/static/pay_wx_pub.html index aa3471c83..b41bb4b60 100644 --- a/yudao-server/src/main/resources/static/pay_wx_pub.html +++ b/yudao-server/src/main/resources/static/pay_wx_pub.html @@ -16,8 +16,8 @@ diff --git a/yudao-ui-admin/src/views/pay/order/index.vue b/yudao-ui-admin/src/views/pay/order/index.vue index ecf70bb7a..1a0aeb486 100755 --- a/yudao-ui-admin/src/views/pay/order/index.vue +++ b/yudao-ui-admin/src/views/pay/order/index.vue @@ -3,13 +3,6 @@ - - - - - @@ -70,12 +63,9 @@ - -