Commit 1dadfb8fba1eecdd27f43787d44ddd7c5912ff0f

Authored by YunaiV
1 parent 6eb40aa5

【功能优化】支付:支付应用,增加 appKey 标识,用于不同接入方的标识

Showing 18 changed files with 122 additions and 137 deletions
@@ -16,14 +16,14 @@ @@ -16,14 +16,14 @@
16 <module>yudao-module-system</module> 16 <module>yudao-module-system</module>
17 <module>yudao-module-infra</module> 17 <module>yudao-module-infra</module>
18 <module>yudao-module-member</module> 18 <module>yudao-module-member</module>
19 - <module>yudao-module-bpm</module>  
20 - <module>yudao-module-report</module>  
21 - <module>yudao-module-mp</module> 19 +<!-- <module>yudao-module-bpm</module>-->
  20 +<!-- <module>yudao-module-report</module>-->
  21 +<!-- <module>yudao-module-mp</module>-->
22 <module>yudao-module-pay</module> 22 <module>yudao-module-pay</module>
23 <module>yudao-module-mall</module> 23 <module>yudao-module-mall</module>
24 - <module>yudao-module-crm</module>  
25 - <module>yudao-module-erp</module>  
26 - <module>yudao-module-ai</module> 24 +<!-- <module>yudao-module-crm</module>-->
  25 +<!-- <module>yudao-module-erp</module>-->
  26 +<!-- <module>yudao-module-ai</module>-->
27 </modules> 27 </modules>
28 28
29 <name>${project.artifactId}</name> 29 <name>${project.artifactId}</name>
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java
@@ -101,7 +101,7 @@ public interface TradeOrderConvert { @@ -101,7 +101,7 @@ public interface TradeOrderConvert {
101 default PayOrderCreateReqDTO convert(TradeOrderDO order, List<TradeOrderItemDO> orderItems, 101 default PayOrderCreateReqDTO convert(TradeOrderDO order, List<TradeOrderItemDO> orderItems,
102 TradeOrderProperties orderProperties) { 102 TradeOrderProperties orderProperties) {
103 PayOrderCreateReqDTO createReqDTO = new PayOrderCreateReqDTO() 103 PayOrderCreateReqDTO createReqDTO = new PayOrderCreateReqDTO()
104 - .setAppKey(orderProperties.getAppKey()).setUserIp(order.getUserIp()); 104 + .setAppKey(orderProperties.getPayAppKey()).setUserIp(order.getUserIp());
105 // 商户相关字段 105 // 商户相关字段
106 createReqDTO.setMerchantOrderId(String.valueOf(order.getId())); 106 createReqDTO.setMerchantOrderId(String.valueOf(order.getId()));
107 String subject = orderItems.get(0).getSpuName(); 107 String subject = orderItems.get(0).getSpuName();
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/config/TradeOrderProperties.java
1 package cn.iocoder.yudao.module.trade.framework.order.config; 1 package cn.iocoder.yudao.module.trade.framework.order.config;
2 2
  3 +import jakarta.validation.constraints.NotEmpty;
3 import lombok.Data; 4 import lombok.Data;
4 import org.springframework.boot.context.properties.ConfigurationProperties; 5 import org.springframework.boot.context.properties.ConfigurationProperties;
5 import org.springframework.validation.annotation.Validated; 6 import org.springframework.validation.annotation.Validated;
@@ -19,17 +20,15 @@ import java.time.Duration; @@ -19,17 +20,15 @@ import java.time.Duration;
19 @Validated 20 @Validated
20 public class TradeOrderProperties { 21 public class TradeOrderProperties {
21 22
22 - /**  
23 - * 默认应用标识  
24 - */  
25 - private static final String APP_KEY_DEFAULT = "mall"; 23 + private static final String PAY_APP_KEY_DEFAULT = "mall";
26 24
27 /** 25 /**
28 - * 应用标识,用于区分不同的应用程序  
29 - * 通过注解@NotNull确保应用标识不能为空 26 + * 支付应用标识
  27 + *
  28 + * 在 pay 模块的 [支付管理 -> 应用信息] 里添加
30 */ 29 */
31 - @NotNull(message = "应用标识不能为空")  
32 - private String appKey = APP_KEY_DEFAULT; 30 + @NotEmpty(message = "Pay 应用标识不能为空")
  31 + private String payAppKey = PAY_APP_KEY_DEFAULT;
33 32
34 /** 33 /**
35 * 支付超时时间 34 * 支付超时时间
yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java
@@ -99,7 +99,7 @@ public class TradeOrderUpdateServiceTest extends BaseDbUnitTest { @@ -99,7 +99,7 @@ public class TradeOrderUpdateServiceTest extends BaseDbUnitTest {
99 99
100 @BeforeEach 100 @BeforeEach
101 public void setUp() { 101 public void setUp() {
102 - when(tradeOrderProperties.getAppKey()).thenReturn("demo"); 102 + when(tradeOrderProperties.getPayAppKey()).thenReturn("mall");
103 when(tradeOrderProperties.getPayExpireTime()).thenReturn(Duration.ofDays(1)); 103 when(tradeOrderProperties.getPayExpireTime()).thenReturn(Duration.ofDays(1));
104 when(tradeNoRedisDAO.generate(anyString())).thenReturn(IdUtil.randomUUID()); 104 when(tradeNoRedisDAO.generate(anyString())).thenReturn(IdUtil.randomUUID());
105 } 105 }
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppBaseVO.java
@@ -14,6 +14,10 @@ import jakarta.validation.constraints.*; @@ -14,6 +14,10 @@ import jakarta.validation.constraints.*;
14 @Data 14 @Data
15 public class PayAppBaseVO { 15 public class PayAppBaseVO {
16 16
  17 + @Schema(description = "应用标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
  18 + @NotEmpty(message = "应用标识不能为空")
  19 + private String appKey;
  20 +
17 @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "小豆") 21 @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "小豆")
18 @NotNull(message = "应用名不能为空") 22 @NotNull(message = "应用名不能为空")
19 private String name; 23 private String name;
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppCreateReqVO.java
1 package cn.iocoder.yudao.module.pay.controller.admin.app.vo; 1 package cn.iocoder.yudao.module.pay.controller.admin.app.vo;
  2 +
2 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
3 -import jakarta.validation.constraints.NotNull;  
4 -import lombok.*; 4 +import lombok.Data;
  5 +import lombok.EqualsAndHashCode;
  6 +import lombok.ToString;
5 7
6 @Schema(description = "管理后台 - 支付应用信息创建 Request VO") 8 @Schema(description = "管理后台 - 支付应用信息创建 Request VO")
7 @Data 9 @Data
@@ -9,8 +11,4 @@ import lombok.*; @@ -9,8 +11,4 @@ import lombok.*;
9 @ToString(callSuper = true) 11 @ToString(callSuper = true)
10 public class PayAppCreateReqVO extends PayAppBaseVO { 12 public class PayAppCreateReqVO extends PayAppBaseVO {
11 13
12 - @Schema(description = "应用标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")  
13 - @NotNull(message = "应用标识不能为空")  
14 - private String appKey;  
15 -  
16 } 14 }
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java
@@ -17,9 +17,6 @@ public class PayAppPageItemRespVO extends PayAppBaseVO { @@ -17,9 +17,6 @@ public class PayAppPageItemRespVO extends PayAppBaseVO {
17 @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") 17 @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
18 private Long id; 18 private Long id;
19 19
20 - @Schema(description = "应用标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")  
21 - private String appKey;  
22 -  
23 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) 20 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
24 private LocalDateTime createTime; 21 private LocalDateTime createTime;
25 22
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java
@@ -20,7 +20,7 @@ public class PayAppPageReqVO extends PageParam { @@ -20,7 +20,7 @@ public class PayAppPageReqVO extends PageParam {
20 @Schema(description = "应用名", example = "小豆") 20 @Schema(description = "应用名", example = "小豆")
21 private String name; 21 private String name;
22 22
23 - @Schema(description = "应用标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao") 23 + @Schema(description = "应用标识", example = "yudao")
24 private String appKey; 24 private String appKey;
25 25
26 @Schema(description = "开启状态", example = "0") 26 @Schema(description = "开启状态", example = "0")
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.java
@@ -14,8 +14,4 @@ public class PayAppUpdateReqVO extends PayAppBaseVO { @@ -14,8 +14,4 @@ public class PayAppUpdateReqVO extends PayAppBaseVO {
14 @NotNull(message = "应用编号不能为空") 14 @NotNull(message = "应用编号不能为空")
15 private Long id; 15 private Long id;
16 16
17 - @Schema(description = "应用标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")  
18 - @NotNull(message = "应用标识不能为空")  
19 - private String appKey;  
20 -  
21 } 17 }
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/config/PayProperties.java
@@ -15,6 +15,8 @@ public class PayProperties { @@ -15,6 +15,8 @@ public class PayProperties {
15 private static final String ORDER_NO_PREFIX = "P"; 15 private static final String ORDER_NO_PREFIX = "P";
16 private static final String REFUND_NO_PREFIX = "R"; 16 private static final String REFUND_NO_PREFIX = "R";
17 17
  18 + private static final String WALLET_PAY_APP_KEY_DEFAULT = "wallet";
  19 +
18 /** 20 /**
19 * 支付回调地址 21 * 支付回调地址
20 * 22 *
@@ -49,4 +51,10 @@ public class PayProperties { @@ -49,4 +51,10 @@ public class PayProperties {
49 @NotEmpty(message = "退款订单 no 的前缀不能为空") 51 @NotEmpty(message = "退款订单 no 的前缀不能为空")
50 private String refundNoPrefix = REFUND_NO_PREFIX; 52 private String refundNoPrefix = REFUND_NO_PREFIX;
51 53
  54 + /**
  55 + * 钱包支付应用 AppKey
  56 + */
  57 + @NotEmpty(message = "钱包支付应用 AppKey 不能为空")
  58 + private String walletPayAppKey = WALLET_PAY_APP_KEY_DEFAULT;
  59 +
52 } 60 }
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppServiceImpl.java
1 package cn.iocoder.yudao.module.pay.service.app; 1 package cn.iocoder.yudao.module.pay.service.app;
2 2
3 -import cn.hutool.core.util.StrUtil;  
4 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; 3 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;  
7 import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; 5 import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO;
8 import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; 6 import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO;
9 import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; 7 import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO;
@@ -20,7 +18,6 @@ import org.springframework.validation.annotation.Validated; @@ -20,7 +18,6 @@ import org.springframework.validation.annotation.Validated;
20 18
21 import java.util.Collection; 19 import java.util.Collection;
22 import java.util.List; 20 import java.util.List;
23 -import java.util.Objects;  
24 21
25 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 22 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
26 import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; 23 import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
@@ -46,8 +43,9 @@ public class PayAppServiceImpl implements PayAppService { @@ -46,8 +43,9 @@ public class PayAppServiceImpl implements PayAppService {
46 43
47 @Override 44 @Override
48 public Long createApp(PayAppCreateReqVO createReqVO) { 45 public Long createApp(PayAppCreateReqVO createReqVO) {
49 - // 验证appKey是否重复  
50 - validateAppKeyDuplicate(null, createReqVO.getAppKey()); 46 + // 验证 appKey 是否重复
  47 + validateEmailUnique(null, createReqVO.getAppKey());
  48 +
51 // 插入 49 // 插入
52 PayAppDO app = PayAppConvert.INSTANCE.convert(createReqVO); 50 PayAppDO app = PayAppConvert.INSTANCE.convert(createReqVO);
53 appMapper.insert(app); 51 appMapper.insert(app);
@@ -59,13 +57,28 @@ public class PayAppServiceImpl implements PayAppService { @@ -59,13 +57,28 @@ public class PayAppServiceImpl implements PayAppService {
59 public void updateApp(PayAppUpdateReqVO updateReqVO) { 57 public void updateApp(PayAppUpdateReqVO updateReqVO) {
60 // 校验存在 58 // 校验存在
61 validateAppExists(updateReqVO.getId()); 59 validateAppExists(updateReqVO.getId());
62 - // 验证appKey是否重复  
63 - validateAppKeyDuplicate(updateReqVO.getId(), updateReqVO.getAppKey()); 60 + // 验证 appKey 是否重复
  61 + validateEmailUnique(updateReqVO.getId(), updateReqVO.getAppKey());
  62 +
64 // 更新 63 // 更新
65 PayAppDO updateObj = PayAppConvert.INSTANCE.convert(updateReqVO); 64 PayAppDO updateObj = PayAppConvert.INSTANCE.convert(updateReqVO);
66 appMapper.updateById(updateObj); 65 appMapper.updateById(updateObj);
67 } 66 }
68 67
  68 + void validateEmailUnique(Long id, String appKey) {
  69 + PayAppDO app = appMapper.selectByAppKey(appKey);
  70 + if (app == null) {
  71 + return;
  72 + }
  73 + // 如果 id 为空,说明不用比较是否为相同 appKey 的应用
  74 + if (id == null) {
  75 + throw exception(APP_KEY_EXISTS);
  76 + }
  77 + if (!app.getId().equals(id)) {
  78 + throw exception(APP_KEY_EXISTS);
  79 + }
  80 + }
  81 +
69 @Override 82 @Override
70 public void updateAppStatus(Long id, Integer status) { 83 public void updateAppStatus(Long id, Integer status) {
71 // 校验商户存在 84 // 校验商户存在
@@ -119,63 +132,31 @@ public class PayAppServiceImpl implements PayAppService { @@ -119,63 +132,31 @@ public class PayAppServiceImpl implements PayAppService {
119 @Override 132 @Override
120 public PayAppDO validPayApp(Long appId) { 133 public PayAppDO validPayApp(Long appId) {
121 PayAppDO app = appMapper.selectById(appId); 134 PayAppDO app = appMapper.selectById(appId);
122 - // 校验支付应用数据是否存在以及可用  
123 - return validatePayAppDO(app); 135 + return validatePayApp(app);
124 } 136 }
125 137
126 @Override 138 @Override
127 public PayAppDO validPayApp(String appKey) { 139 public PayAppDO validPayApp(String appKey) {
128 PayAppDO app = appMapper.selectByAppKey(appKey); 140 PayAppDO app = appMapper.selectByAppKey(appKey);
129 - // 校验支付应用数据是否存在以及可用  
130 - return validatePayAppDO(app); 141 + return validatePayApp(app);
131 } 142 }
132 143
133 /** 144 /**
134 - * 校验支付应用实体的有效性  
135 - * 主要包括存在性检查和禁用状态检查 145 + * 校验支付应用实体的有效性:存在 + 开启
136 * 146 *
137 * @param app 待校验的支付应用实体 147 * @param app 待校验的支付应用实体
138 * @return 校验通过的支付应用实体 148 * @return 校验通过的支付应用实体
139 - * @throws IllegalArgumentException 如果支付应用实体不存在或已被禁用  
140 */ 149 */
141 - private PayAppDO validatePayAppDO(PayAppDO app) { 150 + private PayAppDO validatePayApp(PayAppDO app) {
142 // 校验是否存在 151 // 校验是否存在
143 if (app == null) { 152 if (app == null) {
144 throw exception(ErrorCodeConstants.APP_NOT_FOUND); 153 throw exception(ErrorCodeConstants.APP_NOT_FOUND);
145 } 154 }
146 // 校验是否禁用 155 // 校验是否禁用
147 - if (CommonStatusEnum.DISABLE.getStatus().equals(app.getStatus())) { 156 + if (CommonStatusEnum.isDisable(app.getStatus())) {
148 throw exception(ErrorCodeConstants.APP_IS_DISABLE); 157 throw exception(ErrorCodeConstants.APP_IS_DISABLE);
149 } 158 }
150 return app; 159 return app;
151 } 160 }
152 161
153 -  
154 - /**  
155 - * 校验应用密钥是否重复  
156 - * 在新增或更新支付应用时,确保应用密钥(appKey)的唯一性  
157 - * 如果是在新增情况下,检查数据库中是否已存在相同的appKey  
158 - * 如果是在更新情况下,检查数据库中是否存在除当前应用外的其他应用使用了相同的appKey  
159 - *  
160 - * @param payAppId 支付应用的ID,更新时使用,新增时可能为null  
161 - * @param payAppKey 支付应用的密钥,用于校验是否重复  
162 - * @throws RuntimeException 如果发现appKey重复,抛出运行时异常  
163 - */  
164 - private void validateAppKeyDuplicate(Long payAppId, String payAppKey) {  
165 - // 新增时,校验appKey是否重复  
166 - if (Objects.isNull(payAppId) && StrUtil.isNotBlank(payAppKey)) {  
167 - if (appMapper.selectCount(PayAppDO::getAppKey, payAppKey) > 0) {  
168 - throw exception(APP_KEY_EXISTS);  
169 - }  
170 - // 更新时,校验appKey是否重复  
171 - } else if (Objects.nonNull(payAppId) && StrUtil.isNotBlank(payAppKey)) {  
172 - LambdaQueryWrapperX<PayAppDO> queryWrapper = new LambdaQueryWrapperX<>();  
173 - queryWrapper.eq(PayAppDO::getAppKey, payAppKey)  
174 - .ne(PayAppDO::getId, payAppId);  
175 - if (appMapper.selectCount(queryWrapper) > 0) {  
176 - throw exception(APP_KEY_EXISTS);  
177 - }  
178 - }  
179 - }  
180 -  
181 } 162 }
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderServiceImpl.java
@@ -43,7 +43,7 @@ import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; @@ -43,7 +43,7 @@ import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
43 public class PayDemoOrderServiceImpl implements PayDemoOrderService { 43 public class PayDemoOrderServiceImpl implements PayDemoOrderService {
44 44
45 /** 45 /**
46 - * 接入的实力应用编号 46 + * 接入的支付应用标识
47 * 47 *
48 * 从 [支付管理 -> 应用信息] 里添加 48 * 从 [支付管理 -> 应用信息] 里添加
49 */ 49 */
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java
@@ -199,8 +199,8 @@ public class PayRefundServiceImpl implements PayRefundService { @@ -199,8 +199,8 @@ public class PayRefundServiceImpl implements PayRefundService {
199 * @param channel 支付渠道 199 * @param channel 支付渠道
200 * @param notify 通知 200 * @param notify 通知
201 */ 201 */
202 - @Transactional(rollbackFor = Exception.class)  
203 // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyRefund(channel, notify) 调用,否则事务不生效 202 // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyRefund(channel, notify) 调用,否则事务不生效
  203 + @Transactional(rollbackFor = Exception.class)
204 public void notifyRefund(PayChannelDO channel, PayRefundRespDTO notify) { 204 public void notifyRefund(PayChannelDO channel, PayRefundRespDTO notify) {
205 // 情况一:退款成功 205 // 情况一:退款成功
206 if (PayRefundStatusRespEnum.isSuccess(notify.getStatus())) { 206 if (PayRefundStatusRespEnum.isSuccess(notify.getStatus())) {
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
@@ -18,6 +18,7 @@ import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletRechargeMapper; @@ -18,6 +18,7 @@ import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletRechargeMapper;
18 import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; 18 import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
19 import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; 19 import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
20 import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; 20 import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;
  21 +import cn.iocoder.yudao.module.pay.framework.pay.config.PayProperties;
21 import cn.iocoder.yudao.module.pay.service.order.PayOrderService; 22 import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
22 import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; 23 import cn.iocoder.yudao.module.pay.service.refund.PayRefundService;
23 import cn.iocoder.yudao.module.system.api.social.SocialClientApi; 24 import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
@@ -51,11 +52,6 @@ import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*; @@ -51,11 +52,6 @@ import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*;
51 @Slf4j 52 @Slf4j
52 public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { 53 public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
53 54
54 - /**  
55 - * TODO 芋艿:放到 payconfig  
56 - */  
57 - private static final String WALLET_PAY_APP_KEY = "wallet";  
58 -  
59 private static final String WALLET_RECHARGE_ORDER_SUBJECT = "钱包余额充值"; 55 private static final String WALLET_RECHARGE_ORDER_SUBJECT = "钱包余额充值";
60 56
61 @Resource 57 @Resource
@@ -68,9 +64,13 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { @@ -68,9 +64,13 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
68 private PayRefundService payRefundService; 64 private PayRefundService payRefundService;
69 @Resource 65 @Resource
70 private PayWalletRechargePackageService payWalletRechargePackageService; 66 private PayWalletRechargePackageService payWalletRechargePackageService;
  67 +
71 @Resource 68 @Resource
72 public SocialClientApi socialClientApi; 69 public SocialClientApi socialClientApi;
73 70
  71 + @Resource
  72 + private PayProperties payProperties;
  73 +
74 @Override 74 @Override
75 @Transactional(rollbackFor = Exception.class) 75 @Transactional(rollbackFor = Exception.class)
76 public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp, 76 public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp,
@@ -92,7 +92,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { @@ -92,7 +92,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
92 92
93 // 2.1 创建支付单 93 // 2.1 创建支付单
94 Long payOrderId = payOrderService.createOrder(new PayOrderCreateReqDTO() 94 Long payOrderId = payOrderService.createOrder(new PayOrderCreateReqDTO()
95 - .setAppKey(WALLET_PAY_APP_KEY).setUserIp(userIp) 95 + .setAppKey(payProperties.getWalletPayAppKey()).setUserIp(userIp)
96 .setMerchantOrderId(recharge.getId().toString()) // 业务的订单编号 96 .setMerchantOrderId(recharge.getId().toString()) // 业务的订单编号
97 .setSubject(WALLET_RECHARGE_ORDER_SUBJECT).setBody("") 97 .setSubject(WALLET_RECHARGE_ORDER_SUBJECT).setBody("")
98 .setPrice(recharge.getPayPrice()) 98 .setPrice(recharge.getPayPrice())
@@ -174,7 +174,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { @@ -174,7 +174,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
174 String walletRechargeId = String.valueOf(id); 174 String walletRechargeId = String.valueOf(id);
175 String refundId = walletRechargeId + "-refund"; 175 String refundId = walletRechargeId + "-refund";
176 Long payRefundId = payRefundService.createPayRefund(new PayRefundCreateReqDTO() 176 Long payRefundId = payRefundService.createPayRefund(new PayRefundCreateReqDTO()
177 - .setAppKey(WALLET_PAY_APP_KEY).setUserIp(userIp) 177 + .setAppKey(payProperties.getWalletPayAppKey()).setUserIp(userIp)
178 .setMerchantOrderId(walletRechargeId) 178 .setMerchantOrderId(walletRechargeId)
179 .setMerchantRefundId(refundId) 179 .setMerchantRefundId(refundId)
180 .setReason("想退钱").setPrice(walletRecharge.getPayPrice())); 180 .setReason("想退钱").setPrice(walletRecharge.getPayPrice()));
yudao-module-pay/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayClientConfig.java
@@ -98,9 +98,12 @@ public class AlipayPayClientConfig implements PayClientConfig { @@ -98,9 +98,12 @@ public class AlipayPayClientConfig implements PayClientConfig {
98 private String rootCertContent; 98 private String rootCertContent;
99 99
100 /** 100 /**
101 - * 接口内容加密方式,如果为空,将使用无加密方式  
102 - * 如果要加密,目前支付宝只有 AES 一种加密方式  
103 - * <a href="https://opendocs.alipay.com/common/02mse3">支付宝开放平台</a> 101 + * 接口内容加密方式
  102 + *
  103 + * 1. 如果为空,将使用无加密方式
  104 + * 2. 如果要加密,目前支付宝只有 AES 一种加密方式
  105 + *
  106 + * @see <a href="https://opendocs.alipay.com/common/02mse3">支付宝开放平台</a>
104 * @see AlipayPayClientConfig#ENC_TYPE_AES 107 * @see AlipayPayClientConfig#ENC_TYPE_AES
105 */ 108 */
106 private String encryptType; 109 private String encryptType;
yudao-server/pom.xml
@@ -40,17 +40,17 @@ @@ -40,17 +40,17 @@
40 </dependency> 40 </dependency>
41 41
42 <!-- 数据报表。默认注释,保证编译速度 --> 42 <!-- 数据报表。默认注释,保证编译速度 -->
43 - <dependency>  
44 - <groupId>cn.iocoder.boot</groupId>  
45 - <artifactId>yudao-module-report-biz</artifactId>  
46 - <version>${revision}</version>  
47 - </dependency> 43 +<!-- <dependency>-->
  44 +<!-- <groupId>cn.iocoder.boot</groupId>-->
  45 +<!-- <artifactId>yudao-module-report-biz</artifactId>-->
  46 +<!-- <version>${revision}</version>-->
  47 +<!-- </dependency>-->
48 <!-- 工作流。默认注释,保证编译速度 --> 48 <!-- 工作流。默认注释,保证编译速度 -->
49 - <dependency>  
50 - <groupId>cn.iocoder.boot</groupId>  
51 - <artifactId>yudao-module-bpm-biz</artifactId>  
52 - <version>${revision}</version>  
53 - </dependency> 49 +<!-- <dependency>-->
  50 +<!-- <groupId>cn.iocoder.boot</groupId>-->
  51 +<!-- <artifactId>yudao-module-bpm-biz</artifactId>-->
  52 +<!-- <version>${revision}</version>-->
  53 +<!-- </dependency>-->
54 <!-- 支付服务。默认注释,保证编译速度 --> 54 <!-- 支付服务。默认注释,保证编译速度 -->
55 <dependency> 55 <dependency>
56 <groupId>cn.iocoder.boot</groupId> 56 <groupId>cn.iocoder.boot</groupId>
@@ -59,11 +59,11 @@ @@ -59,11 +59,11 @@
59 </dependency> 59 </dependency>
60 60
61 <!-- 微信公众号模块。默认注释,保证编译速度 --> 61 <!-- 微信公众号模块。默认注释,保证编译速度 -->
62 - <dependency>  
63 - <groupId>cn.iocoder.boot</groupId>  
64 - <artifactId>yudao-module-mp-biz</artifactId>  
65 - <version>${revision}</version>  
66 - </dependency> 62 +<!-- <dependency>-->
  63 +<!-- <groupId>cn.iocoder.boot</groupId>-->
  64 +<!-- <artifactId>yudao-module-mp-biz</artifactId>-->
  65 +<!-- <version>${revision}</version>-->
  66 +<!-- </dependency>-->
67 67
68 <!-- 商城相关模块。默认注释,保证编译速度--> 68 <!-- 商城相关模块。默认注释,保证编译速度-->
69 <dependency> 69 <dependency>
@@ -88,25 +88,25 @@ @@ -88,25 +88,25 @@
88 </dependency> 88 </dependency>
89 89
90 <!-- CRM 相关模块。默认注释,保证编译速度 --> 90 <!-- CRM 相关模块。默认注释,保证编译速度 -->
91 - <dependency>  
92 - <groupId>cn.iocoder.boot</groupId>  
93 - <artifactId>yudao-module-crm-biz</artifactId>  
94 - <version>${revision}</version>  
95 - </dependency> 91 +<!-- <dependency>-->
  92 +<!-- <groupId>cn.iocoder.boot</groupId>-->
  93 +<!-- <artifactId>yudao-module-crm-biz</artifactId>-->
  94 +<!-- <version>${revision}</version>-->
  95 +<!-- </dependency>-->
96 96
97 <!-- ERP 相关模块。默认注释,保证编译速度 --> 97 <!-- ERP 相关模块。默认注释,保证编译速度 -->
98 - <dependency>  
99 - <groupId>cn.iocoder.boot</groupId>  
100 - <artifactId>yudao-module-erp-biz</artifactId>  
101 - <version>${revision}</version>  
102 - </dependency> 98 +<!-- <dependency>-->
  99 +<!-- <groupId>cn.iocoder.boot</groupId>-->
  100 +<!-- <artifactId>yudao-module-erp-biz</artifactId>-->
  101 +<!-- <version>${revision}</version>-->
  102 +<!-- </dependency>-->
103 103
104 <!-- AI 大模型相关模块。默认注释,保证编译速度 --> 104 <!-- AI 大模型相关模块。默认注释,保证编译速度 -->
105 - <dependency>  
106 - <groupId>cn.iocoder.boot</groupId>  
107 - <artifactId>yudao-module-ai-biz</artifactId>  
108 - <version>${revision}</version>  
109 - </dependency> 105 +<!-- <dependency>-->
  106 +<!-- <groupId>cn.iocoder.boot</groupId>-->
  107 +<!-- <artifactId>yudao-module-ai-biz</artifactId>-->
  108 +<!-- <version>${revision}</version>-->
  109 +<!-- </dependency>-->
110 110
111 <!-- spring boot 配置所需依赖 --> 111 <!-- spring boot 配置所需依赖 -->
112 <dependency> 112 <dependency>
yudao-server/src/main/resources/application-local.yaml
@@ -45,7 +45,7 @@ spring: @@ -45,7 +45,7 @@ spring:
45 primary: master 45 primary: master
46 datasource: 46 datasource:
47 master: 47 master:
48 - url: jdbc:mysql://39.105.15.179:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 48 + url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
49 # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 49 # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
50 # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 50 # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
51 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 51 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
@@ -54,26 +54,26 @@ spring: @@ -54,26 +54,26 @@ spring:
54 # url: jdbc:kingbase8://127.0.0.1:54321/test # 人大金仓 KingbaseES 连接的示例 54 # url: jdbc:kingbase8://127.0.0.1:54321/test # 人大金仓 KingbaseES 连接的示例
55 # url: jdbc:postgresql://127.0.0.1:5432/postgres # OpenGauss 连接的示例 55 # url: jdbc:postgresql://127.0.0.1:5432/postgres # OpenGauss 连接的示例
56 username: root 56 username: root
57 - password: 3WLiVUBEwTbvAfsh 57 + password: 123456
58 # username: sa # SQL Server 连接的示例 58 # username: sa # SQL Server 连接的示例
59 # password: Yudao@2024 # SQL Server 连接的示例 59 # password: Yudao@2024 # SQL Server 连接的示例
60 # username: SYSDBA # DM 连接的示例 60 # username: SYSDBA # DM 连接的示例
61 # password: SYSDBA001 # DM 连接的示例 61 # password: SYSDBA001 # DM 连接的示例
62 # username: root # OpenGauss 连接的示例 62 # username: root # OpenGauss 连接的示例
63 # password: Yudao@2024 # OpenGauss 连接的示例 63 # password: Yudao@2024 # OpenGauss 连接的示例
64 -# slave: # 模拟从库,可根据自己需要修改  
65 -# lazy: true # 开启懒加载,保证启动速度  
66 -# url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true  
67 -# username: root  
68 -# password: 123456 64 + slave: # 模拟从库,可根据自己需要修改
  65 + lazy: true # 开启懒加载,保证启动速度
  66 + url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
  67 + username: root
  68 + password: 123456
69 69
70 # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 70 # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
71 data: 71 data:
72 redis: 72 redis:
73 - host: 39.105.15.179 # 地址 73 + host: 127.0.0.1 # 地址
74 port: 6379 # 端口 74 port: 6379 # 端口
75 database: 0 # 数据库索引 75 database: 0 # 数据库索引
76 - password: 3WLiVUBEwTbvAfsh # 密码,建议生产环境开启 76 +# password: dev # 密码,建议生产环境开启
77 77
78 --- #################### 定时任务相关配置 #################### 78 --- #################### 定时任务相关配置 ####################
79 79
@@ -110,18 +110,18 @@ spring: @@ -110,18 +110,18 @@ spring:
110 110
111 # rocketmq 配置项,对应 RocketMQProperties 配置类 111 # rocketmq 配置项,对应 RocketMQProperties 配置类
112 rocketmq: 112 rocketmq:
113 - name-server: 117.72.39.77:9876 # RocketMQ Namesrv 113 + name-server: 127.0.0.1:9876 # RocketMQ Namesrv
114 114
115 -#spring:  
116 -# # RabbitMQ 配置项,对应 RabbitProperties 配置类  
117 -# rabbitmq:  
118 -# host: 127.0.0.1 # RabbitMQ 服务的地址  
119 -# port: 5672 # RabbitMQ 服务的端口  
120 -# username: rabbit # RabbitMQ 服务的账号  
121 -# password: rabbit # RabbitMQ 服务的密码  
122 -# # Kafka 配置项,对应 KafkaProperties 配置类  
123 -# kafka:  
124 -# bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔 115 +spring:
  116 + # RabbitMQ 配置项,对应 RabbitProperties 配置类
  117 + rabbitmq:
  118 + host: 127.0.0.1 # RabbitMQ 服务的地址
  119 + port: 5672 # RabbitMQ 服务的端口
  120 + username: rabbit # RabbitMQ 服务的账号
  121 + password: rabbit # RabbitMQ 服务的密码
  122 + # Kafka 配置项,对应 KafkaProperties 配置类
  123 + kafka:
  124 + bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔
125 125
126 --- #################### 服务保障相关配置 #################### 126 --- #################### 服务保障相关配置 ####################
127 127
yudao-server/src/main/resources/application.yaml
@@ -309,7 +309,6 @@ yudao: @@ -309,7 +309,6 @@ yudao:
309 end-code: 9999 # 这里配置 9999 的原因是,测试方便。 309 end-code: 9999 # 这里配置 9999 的原因是,测试方便。
310 trade: 310 trade:
311 order: 311 order:
312 - app-key: mall  
313 pay-expire-time: 2h # 支付的过期时间 312 pay-expire-time: 2h # 支付的过期时间
314 receive-expire-time: 14d # 收货的过期时间 313 receive-expire-time: 14d # 收货的过期时间
315 comment-expire-time: 7d # 评论的过期时间 314 comment-expire-time: 7d # 评论的过期时间