Commit 6eb40aa544d15f4586324f7cf2f408ac99e11d7c
Committed by
芋道源码
1 parent
6a80d7c7
!1041 支付应用,增加 appKey 标识,用于不同接入方的标识
* feat[yudao-module-pay]: 更新新增和更新支付应用时校验逻辑 * fix[yudao-module-trade]: 为支付应用标识提供缺省值 * fix[yudao-module-pay]: appKey注释应用编码更新为应用标识 * feat[yudao-module-pay]: 为支付应用新增支付编码属性
Showing
27 changed files
with
259 additions
and
156 deletions
pom.xml
| @@ -15,15 +15,15 @@ | @@ -15,15 +15,15 @@ | ||
| 15 | <!-- 各种 module 拓展 --> | 15 | <!-- 各种 module 拓展 --> |
| 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>--> | ||
| 19 | -<!-- <module>yudao-module-bpm</module>--> | ||
| 20 | -<!-- <module>yudao-module-report</module>--> | ||
| 21 | -<!-- <module>yudao-module-mp</module>--> | ||
| 22 | -<!-- <module>yudao-module-pay</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>--> | 18 | + <module>yudao-module-member</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> | ||
| 23 | + <module>yudao-module-mall</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 | - .setAppId(orderProperties.getAppId()).setUserIp(order.getUserIp()); | 104 | + .setAppKey(orderProperties.getAppKey()).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
| @@ -5,6 +5,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; | @@ -5,6 +5,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| 5 | import org.springframework.validation.annotation.Validated; | 5 | import org.springframework.validation.annotation.Validated; |
| 6 | 6 | ||
| 7 | import jakarta.validation.constraints.NotNull; | 7 | import jakarta.validation.constraints.NotNull; |
| 8 | + | ||
| 8 | import java.time.Duration; | 9 | import java.time.Duration; |
| 9 | 10 | ||
| 10 | /** | 11 | /** |
| @@ -19,10 +20,16 @@ import java.time.Duration; | @@ -19,10 +20,16 @@ import java.time.Duration; | ||
| 19 | public class TradeOrderProperties { | 20 | public class TradeOrderProperties { |
| 20 | 21 | ||
| 21 | /** | 22 | /** |
| 22 | - * 应用编号 | 23 | + * 默认应用标识 |
| 24 | + */ | ||
| 25 | + private static final String APP_KEY_DEFAULT = "mall"; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 应用标识,用于区分不同的应用程序 | ||
| 29 | + * 通过注解@NotNull确保应用标识不能为空 | ||
| 23 | */ | 30 | */ |
| 24 | - @NotNull(message = "应用编号不能为空") | ||
| 25 | - private Long appId; | 31 | + @NotNull(message = "应用标识不能为空") |
| 32 | + private String appKey = APP_KEY_DEFAULT; | ||
| 26 | 33 | ||
| 27 | /** | 34 | /** |
| 28 | * 支付超时时间 | 35 | * 支付超时时间 |
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.getAppId()).thenReturn(888L); | 102 | + when(tradeOrderProperties.getAppKey()).thenReturn("demo"); |
| 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-api/src/main/java/cn/iocoder/yudao/module/pay/api/order/dto/PayOrderCreateReqDTO.java
| 1 | package cn.iocoder.yudao.module.pay.api.order.dto; | 1 | package cn.iocoder.yudao.module.pay.api.order.dto; |
| 2 | 2 | ||
| 3 | -import lombok.Data; | ||
| 4 | -import org.hibernate.validator.constraints.Length; | ||
| 5 | - | ||
| 6 | import jakarta.validation.constraints.DecimalMin; | 3 | import jakarta.validation.constraints.DecimalMin; |
| 7 | import jakarta.validation.constraints.NotEmpty; | 4 | import jakarta.validation.constraints.NotEmpty; |
| 8 | import jakarta.validation.constraints.NotNull; | 5 | import jakarta.validation.constraints.NotNull; |
| 6 | +import lombok.Data; | ||
| 7 | +import org.hibernate.validator.constraints.Length; | ||
| 8 | + | ||
| 9 | import java.io.Serializable; | 9 | import java.io.Serializable; |
| 10 | import java.time.LocalDateTime; | 10 | import java.time.LocalDateTime; |
| 11 | 11 | ||
| @@ -18,10 +18,10 @@ public class PayOrderCreateReqDTO implements Serializable { | @@ -18,10 +18,10 @@ public class PayOrderCreateReqDTO implements Serializable { | ||
| 18 | public static final int SUBJECT_MAX_LENGTH = 32; | 18 | public static final int SUBJECT_MAX_LENGTH = 32; |
| 19 | 19 | ||
| 20 | /** | 20 | /** |
| 21 | - * 应用编号 | 21 | + * 应用标识 |
| 22 | */ | 22 | */ |
| 23 | - @NotNull(message = "应用编号不能为空") | ||
| 24 | - private Long appId; | 23 | + @NotNull(message = "应用标识不能为空") |
| 24 | + private String appKey; | ||
| 25 | /** | 25 | /** |
| 26 | * 用户 IP | 26 | * 用户 IP |
| 27 | */ | 27 | */ |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/refund/dto/PayRefundCreateReqDTO.java
| 1 | package cn.iocoder.yudao.module.pay.api.refund.dto; | 1 | package cn.iocoder.yudao.module.pay.api.refund.dto; |
| 2 | 2 | ||
| 3 | -import lombok.Data; | ||
| 4 | -import org.hibernate.validator.constraints.Length; | ||
| 5 | - | ||
| 6 | import jakarta.validation.constraints.Min; | 3 | import jakarta.validation.constraints.Min; |
| 7 | import jakarta.validation.constraints.NotEmpty; | 4 | import jakarta.validation.constraints.NotEmpty; |
| 8 | import jakarta.validation.constraints.NotNull; | 5 | import jakarta.validation.constraints.NotNull; |
| 6 | +import lombok.Data; | ||
| 7 | +import org.hibernate.validator.constraints.Length; | ||
| 9 | 8 | ||
| 10 | /** | 9 | /** |
| 11 | * 退款单创建 Request DTO | 10 | * 退款单创建 Request DTO |
| @@ -16,10 +15,10 @@ import jakarta.validation.constraints.NotNull; | @@ -16,10 +15,10 @@ import jakarta.validation.constraints.NotNull; | ||
| 16 | public class PayRefundCreateReqDTO { | 15 | public class PayRefundCreateReqDTO { |
| 17 | 16 | ||
| 18 | /** | 17 | /** |
| 19 | - * 应用编号 | 18 | + * 应用标识 |
| 20 | */ | 19 | */ |
| 21 | - @NotNull(message = "应用编号不能为空") | ||
| 22 | - private Long appId; | 20 | + @NotNull(message = "应用标识不能为空") |
| 21 | + private String appKey; | ||
| 23 | /** | 22 | /** |
| 24 | * 用户 IP | 23 | * 用户 IP |
| 25 | */ | 24 | */ |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/transfer/dto/PayTransferCreateReqDTO.java
| @@ -2,12 +2,12 @@ package cn.iocoder.yudao.module.pay.api.transfer.dto; | @@ -2,12 +2,12 @@ package cn.iocoder.yudao.module.pay.api.transfer.dto; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferTypeEnum; | 4 | import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferTypeEnum; |
| 5 | -import lombok.Data; | ||
| 6 | - | ||
| 7 | import jakarta.validation.constraints.Min; | 5 | import jakarta.validation.constraints.Min; |
| 8 | import jakarta.validation.constraints.NotBlank; | 6 | import jakarta.validation.constraints.NotBlank; |
| 9 | import jakarta.validation.constraints.NotEmpty; | 7 | import jakarta.validation.constraints.NotEmpty; |
| 10 | import jakarta.validation.constraints.NotNull; | 8 | import jakarta.validation.constraints.NotNull; |
| 9 | +import lombok.Data; | ||
| 10 | + | ||
| 11 | import java.util.Map; | 11 | import java.util.Map; |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| @@ -19,10 +19,10 @@ import java.util.Map; | @@ -19,10 +19,10 @@ import java.util.Map; | ||
| 19 | public class PayTransferCreateReqDTO { | 19 | public class PayTransferCreateReqDTO { |
| 20 | 20 | ||
| 21 | /** | 21 | /** |
| 22 | - * 应用编号 | 22 | + * 应用标识 |
| 23 | */ | 23 | */ |
| 24 | - @NotNull(message = "应用编号不能为空") | ||
| 25 | - private Long appId; | 24 | + @NotNull(message = "应用标识不能为空") |
| 25 | + private String appKey; | ||
| 26 | 26 | ||
| 27 | @NotEmpty(message = "转账渠道不能为空") | 27 | @NotEmpty(message = "转账渠道不能为空") |
| 28 | private String channelCode; | 28 | private String channelCode; |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java
| @@ -14,6 +14,7 @@ public interface ErrorCodeConstants { | @@ -14,6 +14,7 @@ public interface ErrorCodeConstants { | ||
| 14 | ErrorCode APP_IS_DISABLE = new ErrorCode(1_007_000_002, "App 已经被禁用"); | 14 | ErrorCode APP_IS_DISABLE = new ErrorCode(1_007_000_002, "App 已经被禁用"); |
| 15 | ErrorCode APP_EXIST_ORDER_CANT_DELETE = new ErrorCode(1_007_000_003, "支付应用存在支付订单,无法删除"); | 15 | ErrorCode APP_EXIST_ORDER_CANT_DELETE = new ErrorCode(1_007_000_003, "支付应用存在支付订单,无法删除"); |
| 16 | ErrorCode APP_EXIST_REFUND_CANT_DELETE = new ErrorCode(1_007_000_004, "支付应用存在退款订单,无法删除"); | 16 | ErrorCode APP_EXIST_REFUND_CANT_DELETE = new ErrorCode(1_007_000_004, "支付应用存在退款订单,无法删除"); |
| 17 | + ErrorCode APP_KEY_EXISTS = new ErrorCode(1_007_000_005, "支付应用标识已经存在"); | ||
| 17 | 18 | ||
| 18 | // ========== CHANNEL 模块 1-007-001-000 ========== | 19 | // ========== CHANNEL 模块 1-007-001-000 ========== |
| 19 | ErrorCode CHANNEL_NOT_FOUND = new ErrorCode(1_007_001_000, "支付渠道的配置不存在"); | 20 | ErrorCode CHANNEL_NOT_FOUND = new ErrorCode(1_007_001_000, "支付渠道的配置不存在"); |
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 | import io.swagger.v3.oas.annotations.media.Schema; | 2 | import io.swagger.v3.oas.annotations.media.Schema; |
| 3 | +import jakarta.validation.constraints.NotNull; | ||
| 3 | import lombok.*; | 4 | import lombok.*; |
| 4 | 5 | ||
| 5 | @Schema(description = "管理后台 - 支付应用信息创建 Request VO") | 6 | @Schema(description = "管理后台 - 支付应用信息创建 Request VO") |
| @@ -8,4 +9,8 @@ import lombok.*; | @@ -8,4 +9,8 @@ import lombok.*; | ||
| 8 | @ToString(callSuper = true) | 9 | @ToString(callSuper = true) |
| 9 | public class PayAppCreateReqVO extends PayAppBaseVO { | 10 | public class PayAppCreateReqVO extends PayAppBaseVO { |
| 10 | 11 | ||
| 12 | + @Schema(description = "应用标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao") | ||
| 13 | + @NotNull(message = "应用标识不能为空") | ||
| 14 | + private String appKey; | ||
| 15 | + | ||
| 11 | } | 16 | } |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageItemRespVO.java
| @@ -17,6 +17,9 @@ public class PayAppPageItemRespVO extends PayAppBaseVO { | @@ -17,6 +17,9 @@ 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 | + | ||
| 20 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 23 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 21 | private LocalDateTime createTime; | 24 | private LocalDateTime createTime; |
| 22 | 25 |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppPageReqVO.java
| @@ -20,6 +20,9 @@ public class PayAppPageReqVO extends PageParam { | @@ -20,6 +20,9 @@ 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") | ||
| 24 | + private String appKey; | ||
| 25 | + | ||
| 23 | @Schema(description = "开启状态", example = "0") | 26 | @Schema(description = "开启状态", example = "0") |
| 24 | private Integer status; | 27 | private Integer status; |
| 25 | 28 |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppRespVO.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 lombok.*; | 4 | +import lombok.Data; |
| 5 | +import lombok.EqualsAndHashCode; | ||
| 6 | +import lombok.ToString; | ||
| 4 | 7 | ||
| 5 | import java.time.LocalDateTime; | 8 | import java.time.LocalDateTime; |
| 6 | 9 | ||
| @@ -13,6 +16,9 @@ public class PayAppRespVO extends PayAppBaseVO { | @@ -13,6 +16,9 @@ public class PayAppRespVO extends PayAppBaseVO { | ||
| 13 | @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 16 | @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 14 | private Long id; | 17 | private Long id; |
| 15 | 18 | ||
| 19 | + @Schema(description = "应用标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao") | ||
| 20 | + private String appKey; | ||
| 21 | + | ||
| 16 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 22 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 17 | private LocalDateTime createTime; | 23 | private LocalDateTime createTime; |
| 18 | 24 |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/app/vo/PayAppUpdateReqVO.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 lombok.*; | 4 | import lombok.*; |
| 4 | import jakarta.validation.constraints.*; | 5 | import jakarta.validation.constraints.*; |
| @@ -13,4 +14,8 @@ public class PayAppUpdateReqVO extends PayAppBaseVO { | @@ -13,4 +14,8 @@ public class PayAppUpdateReqVO extends PayAppBaseVO { | ||
| 13 | @NotNull(message = "应用编号不能为空") | 14 | @NotNull(message = "应用编号不能为空") |
| 14 | private Long id; | 15 | private Long id; |
| 15 | 16 | ||
| 17 | + @Schema(description = "应用标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao") | ||
| 18 | + @NotNull(message = "应用标识不能为空") | ||
| 19 | + private String appKey; | ||
| 20 | + | ||
| 16 | } | 21 | } |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/app/PayAppDO.java
| @@ -32,6 +32,10 @@ public class PayAppDO extends BaseDO { | @@ -32,6 +32,10 @@ public class PayAppDO extends BaseDO { | ||
| 32 | @TableId | 32 | @TableId |
| 33 | private Long id; | 33 | private Long id; |
| 34 | /** | 34 | /** |
| 35 | + * 应用标识 | ||
| 36 | + */ | ||
| 37 | + private String appKey; | ||
| 38 | + /** | ||
| 35 | * 应用名 | 39 | * 应用名 |
| 36 | */ | 40 | */ |
| 37 | private String name; | 41 | private String name; |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/app/PayAppMapper.java
| @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.pay.dal.mysql.app; | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.pay.dal.mysql.app; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | ||
| 7 | import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; | 6 | import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; |
| 8 | import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; | 7 | import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; |
| 9 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| @@ -14,9 +13,14 @@ public interface PayAppMapper extends BaseMapperX<PayAppDO> { | @@ -14,9 +13,14 @@ public interface PayAppMapper extends BaseMapperX<PayAppDO> { | ||
| 14 | default PageResult<PayAppDO> selectPage(PayAppPageReqVO reqVO) { | 13 | default PageResult<PayAppDO> selectPage(PayAppPageReqVO reqVO) { |
| 15 | return selectPage(reqVO, new LambdaQueryWrapperX<PayAppDO>() | 14 | return selectPage(reqVO, new LambdaQueryWrapperX<PayAppDO>() |
| 16 | .likeIfPresent(PayAppDO::getName, reqVO.getName()) | 15 | .likeIfPresent(PayAppDO::getName, reqVO.getName()) |
| 16 | + .likeIfPresent(PayAppDO::getAppKey, reqVO.getAppKey()) | ||
| 17 | .eqIfPresent(PayAppDO::getStatus, reqVO.getStatus()) | 17 | .eqIfPresent(PayAppDO::getStatus, reqVO.getStatus()) |
| 18 | .betweenIfPresent(PayAppDO::getCreateTime, reqVO.getCreateTime()) | 18 | .betweenIfPresent(PayAppDO::getCreateTime, reqVO.getCreateTime()) |
| 19 | .orderByDesc(PayAppDO::getId)); | 19 | .orderByDesc(PayAppDO::getId)); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | + default PayAppDO selectByAppKey(String appKey) { | ||
| 23 | + return selectOne(PayAppDO::getAppKey, appKey); | ||
| 24 | + } | ||
| 25 | + | ||
| 22 | } | 26 | } |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/app/PayAppService.java
| @@ -7,8 +7,8 @@ import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; | @@ -7,8 +7,8 @@ import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; | ||
| 7 | import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; | 7 | import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; |
| 8 | import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; | 8 | import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; |
| 9 | import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; | 9 | import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; |
| 10 | - | ||
| 11 | import jakarta.validation.Valid; | 10 | import jakarta.validation.Valid; |
| 11 | + | ||
| 12 | import java.util.Collection; | 12 | import java.util.Collection; |
| 13 | import java.util.List; | 13 | import java.util.List; |
| 14 | import java.util.Map; | 14 | import java.util.Map; |
| @@ -88,13 +88,13 @@ public interface PayAppService { | @@ -88,13 +88,13 @@ public interface PayAppService { | ||
| 88 | * @return 商户 Map | 88 | * @return 商户 Map |
| 89 | */ | 89 | */ |
| 90 | default Map<Long, PayAppDO> getAppMap(Collection<Long> ids) { | 90 | default Map<Long, PayAppDO> getAppMap(Collection<Long> ids) { |
| 91 | - List<PayAppDO> list = getAppList(ids); | 91 | + List<PayAppDO> list = getAppList(ids); |
| 92 | return CollectionUtils.convertMap(list, PayAppDO::getId); | 92 | return CollectionUtils.convertMap(list, PayAppDO::getId); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | /** | 95 | /** |
| 96 | * 支付应用的合法性 | 96 | * 支付应用的合法性 |
| 97 | - * | 97 | + * <p> |
| 98 | * 如果不合法,抛出 {@link ServiceException} 业务异常 | 98 | * 如果不合法,抛出 {@link ServiceException} 业务异常 |
| 99 | * | 99 | * |
| 100 | * @param id 应用编号 | 100 | * @param id 应用编号 |
| @@ -102,4 +102,14 @@ public interface PayAppService { | @@ -102,4 +102,14 @@ public interface PayAppService { | ||
| 102 | */ | 102 | */ |
| 103 | PayAppDO validPayApp(Long id); | 103 | PayAppDO validPayApp(Long id); |
| 104 | 104 | ||
| 105 | + /** | ||
| 106 | + * 支付应用的合法性 | ||
| 107 | + * <p> | ||
| 108 | + * 如果不合法,抛出 {@link ServiceException} 业务异常 | ||
| 109 | + * | ||
| 110 | + * @param appKey 应用标识 | ||
| 111 | + * @return 应用 | ||
| 112 | + */ | ||
| 113 | + PayAppDO validPayApp(String appKey); | ||
| 114 | + | ||
| 105 | } | 115 | } |
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; | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 5 | import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; | 7 | import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppCreateReqVO; |
| 6 | import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; | 8 | import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppPageReqVO; |
| 7 | import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; | 9 | import cn.iocoder.yudao.module.pay.controller.admin.app.vo.PayAppUpdateReqVO; |
| @@ -11,13 +13,14 @@ import cn.iocoder.yudao.module.pay.dal.mysql.app.PayAppMapper; | @@ -11,13 +13,14 @@ import cn.iocoder.yudao.module.pay.dal.mysql.app.PayAppMapper; | ||
| 11 | import cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants; | 13 | import cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants; |
| 12 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; | 14 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; |
| 13 | import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; | 15 | import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; |
| 16 | +import jakarta.annotation.Resource; | ||
| 14 | import org.springframework.context.annotation.Lazy; | 17 | import org.springframework.context.annotation.Lazy; |
| 15 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
| 16 | import org.springframework.validation.annotation.Validated; | 19 | import org.springframework.validation.annotation.Validated; |
| 17 | 20 | ||
| 18 | -import jakarta.annotation.Resource; | ||
| 19 | import java.util.Collection; | 21 | import java.util.Collection; |
| 20 | import java.util.List; | 22 | import java.util.List; |
| 23 | +import java.util.Objects; | ||
| 21 | 24 | ||
| 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 25 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 23 | import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; | 26 | import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; |
| @@ -43,6 +46,8 @@ public class PayAppServiceImpl implements PayAppService { | @@ -43,6 +46,8 @@ public class PayAppServiceImpl implements PayAppService { | ||
| 43 | 46 | ||
| 44 | @Override | 47 | @Override |
| 45 | public Long createApp(PayAppCreateReqVO createReqVO) { | 48 | public Long createApp(PayAppCreateReqVO createReqVO) { |
| 49 | + // 验证appKey是否重复 | ||
| 50 | + validateAppKeyDuplicate(null, createReqVO.getAppKey()); | ||
| 46 | // 插入 | 51 | // 插入 |
| 47 | PayAppDO app = PayAppConvert.INSTANCE.convert(createReqVO); | 52 | PayAppDO app = PayAppConvert.INSTANCE.convert(createReqVO); |
| 48 | appMapper.insert(app); | 53 | appMapper.insert(app); |
| @@ -54,6 +59,8 @@ public class PayAppServiceImpl implements PayAppService { | @@ -54,6 +59,8 @@ public class PayAppServiceImpl implements PayAppService { | ||
| 54 | public void updateApp(PayAppUpdateReqVO updateReqVO) { | 59 | public void updateApp(PayAppUpdateReqVO updateReqVO) { |
| 55 | // 校验存在 | 60 | // 校验存在 |
| 56 | validateAppExists(updateReqVO.getId()); | 61 | validateAppExists(updateReqVO.getId()); |
| 62 | + // 验证appKey是否重复 | ||
| 63 | + validateAppKeyDuplicate(updateReqVO.getId(), updateReqVO.getAppKey()); | ||
| 57 | // 更新 | 64 | // 更新 |
| 58 | PayAppDO updateObj = PayAppConvert.INSTANCE.convert(updateReqVO); | 65 | PayAppDO updateObj = PayAppConvert.INSTANCE.convert(updateReqVO); |
| 59 | appMapper.updateById(updateObj); | 66 | appMapper.updateById(updateObj); |
| @@ -101,7 +108,7 @@ public class PayAppServiceImpl implements PayAppService { | @@ -101,7 +108,7 @@ public class PayAppServiceImpl implements PayAppService { | ||
| 101 | 108 | ||
| 102 | @Override | 109 | @Override |
| 103 | public List<PayAppDO> getAppList() { | 110 | public List<PayAppDO> getAppList() { |
| 104 | - return appMapper.selectList(); | 111 | + return appMapper.selectList(); |
| 105 | } | 112 | } |
| 106 | 113 | ||
| 107 | @Override | 114 | @Override |
| @@ -110,8 +117,28 @@ public class PayAppServiceImpl implements PayAppService { | @@ -110,8 +117,28 @@ public class PayAppServiceImpl implements PayAppService { | ||
| 110 | } | 117 | } |
| 111 | 118 | ||
| 112 | @Override | 119 | @Override |
| 113 | - public PayAppDO validPayApp(Long id) { | ||
| 114 | - PayAppDO app = appMapper.selectById(id); | 120 | + public PayAppDO validPayApp(Long appId) { |
| 121 | + PayAppDO app = appMapper.selectById(appId); | ||
| 122 | + // 校验支付应用数据是否存在以及可用 | ||
| 123 | + return validatePayAppDO(app); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + @Override | ||
| 127 | + public PayAppDO validPayApp(String appKey) { | ||
| 128 | + PayAppDO app = appMapper.selectByAppKey(appKey); | ||
| 129 | + // 校验支付应用数据是否存在以及可用 | ||
| 130 | + return validatePayAppDO(app); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + /** | ||
| 134 | + * 校验支付应用实体的有效性 | ||
| 135 | + * 主要包括存在性检查和禁用状态检查 | ||
| 136 | + * | ||
| 137 | + * @param app 待校验的支付应用实体 | ||
| 138 | + * @return 校验通过的支付应用实体 | ||
| 139 | + * @throws IllegalArgumentException 如果支付应用实体不存在或已被禁用 | ||
| 140 | + */ | ||
| 141 | + private PayAppDO validatePayAppDO(PayAppDO app) { | ||
| 115 | // 校验是否存在 | 142 | // 校验是否存在 |
| 116 | if (app == null) { | 143 | if (app == null) { |
| 117 | throw exception(ErrorCodeConstants.APP_NOT_FOUND); | 144 | throw exception(ErrorCodeConstants.APP_NOT_FOUND); |
| @@ -123,4 +150,32 @@ public class PayAppServiceImpl implements PayAppService { | @@ -123,4 +150,32 @@ public class PayAppServiceImpl implements PayAppService { | ||
| 123 | return app; | 150 | return app; |
| 124 | } | 151 | } |
| 125 | 152 | ||
| 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 | + | ||
| 126 | } | 181 | } |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/demo/PayDemoOrderServiceImpl.java
| @@ -47,7 +47,7 @@ public class PayDemoOrderServiceImpl implements PayDemoOrderService { | @@ -47,7 +47,7 @@ public class PayDemoOrderServiceImpl implements PayDemoOrderService { | ||
| 47 | * | 47 | * |
| 48 | * 从 [支付管理 -> 应用信息] 里添加 | 48 | * 从 [支付管理 -> 应用信息] 里添加 |
| 49 | */ | 49 | */ |
| 50 | - private static final Long PAY_APP_ID = 7L; | 50 | + private static final String PAY_APP_KEY = "demo"; |
| 51 | 51 | ||
| 52 | /** | 52 | /** |
| 53 | * 商品信息 Map | 53 | * 商品信息 Map |
| @@ -88,7 +88,7 @@ public class PayDemoOrderServiceImpl implements PayDemoOrderService { | @@ -88,7 +88,7 @@ public class PayDemoOrderServiceImpl implements PayDemoOrderService { | ||
| 88 | 88 | ||
| 89 | // 2.1 创建支付单 | 89 | // 2.1 创建支付单 |
| 90 | Long payOrderId = payOrderApi.createOrder(new PayOrderCreateReqDTO() | 90 | Long payOrderId = payOrderApi.createOrder(new PayOrderCreateReqDTO() |
| 91 | - .setAppId(PAY_APP_ID).setUserIp(getClientIP()) // 支付应用 | 91 | + .setAppKey(PAY_APP_KEY).setUserIp(getClientIP()) // 支付应用 |
| 92 | .setMerchantOrderId(demoOrder.getId().toString()) // 业务的订单编号 | 92 | .setMerchantOrderId(demoOrder.getId().toString()) // 业务的订单编号 |
| 93 | .setSubject(spuName).setBody("").setPrice(price) // 价格信息 | 93 | .setSubject(spuName).setBody("").setPrice(price) // 价格信息 |
| 94 | .setExpireTime(addTime(Duration.ofHours(2L)))); // 支付的过期时间 | 94 | .setExpireTime(addTime(Duration.ofHours(2L)))); // 支付的过期时间 |
| @@ -190,7 +190,7 @@ public class PayDemoOrderServiceImpl implements PayDemoOrderService { | @@ -190,7 +190,7 @@ public class PayDemoOrderServiceImpl implements PayDemoOrderService { | ||
| 190 | String refundId = order.getId() + "-refund"; | 190 | String refundId = order.getId() + "-refund"; |
| 191 | // 2.2 创建退款单 | 191 | // 2.2 创建退款单 |
| 192 | Long payRefundId = payRefundApi.createRefund(new PayRefundCreateReqDTO() | 192 | Long payRefundId = payRefundApi.createRefund(new PayRefundCreateReqDTO() |
| 193 | - .setAppId(PAY_APP_ID).setUserIp(getClientIP()) // 支付应用 | 193 | + .setAppKey(PAY_APP_KEY).setUserIp(getClientIP()) // 支付应用 |
| 194 | .setMerchantOrderId(String.valueOf(order.getId())) // 支付单号 | 194 | .setMerchantOrderId(String.valueOf(order.getId())) // 支付单号 |
| 195 | .setMerchantRefundId(refundId) | 195 | .setMerchantRefundId(refundId) |
| 196 | .setReason("想退钱").setPrice(order.getPrice()));// 价格信息 | 196 | .setReason("想退钱").setPrice(order.getPrice()));// 价格信息 |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java
| @@ -111,11 +111,11 @@ public class PayOrderServiceImpl implements PayOrderService { | @@ -111,11 +111,11 @@ public class PayOrderServiceImpl implements PayOrderService { | ||
| 111 | @Override | 111 | @Override |
| 112 | public Long createOrder(PayOrderCreateReqDTO reqDTO) { | 112 | public Long createOrder(PayOrderCreateReqDTO reqDTO) { |
| 113 | // 校验 App | 113 | // 校验 App |
| 114 | - PayAppDO app = appService.validPayApp(reqDTO.getAppId()); | 114 | + PayAppDO app = appService.validPayApp(reqDTO.getAppKey()); |
| 115 | 115 | ||
| 116 | // 查询对应的支付交易单是否已经存在。如果是,则直接返回 | 116 | // 查询对应的支付交易单是否已经存在。如果是,则直接返回 |
| 117 | PayOrderDO order = orderMapper.selectByAppIdAndMerchantOrderId( | 117 | PayOrderDO order = orderMapper.selectByAppIdAndMerchantOrderId( |
| 118 | - reqDTO.getAppId(), reqDTO.getMerchantOrderId()); | 118 | + app.getId(), reqDTO.getMerchantOrderId()); |
| 119 | if (order != null) { | 119 | if (order != null) { |
| 120 | log.warn("[createOrder][appId({}) merchantOrderId({}) 已经存在对应的支付单({})]", order.getAppId(), | 120 | log.warn("[createOrder][appId({}) merchantOrderId({}) 已经存在对应的支付单({})]", order.getAppId(), |
| 121 | order.getMerchantOrderId(), toJsonString(order)); // 理论来说,不会出现这个情况 | 121 | order.getMerchantOrderId(), toJsonString(order)); // 理论来说,不会出现这个情况 |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceImpl.java
| @@ -26,12 +26,12 @@ import cn.iocoder.yudao.module.pay.service.app.PayAppService; | @@ -26,12 +26,12 @@ import cn.iocoder.yudao.module.pay.service.app.PayAppService; | ||
| 26 | import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; | 26 | import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; |
| 27 | import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; | 27 | import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; |
| 28 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; | 28 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; |
| 29 | +import jakarta.annotation.Resource; | ||
| 29 | import lombok.extern.slf4j.Slf4j; | 30 | import lombok.extern.slf4j.Slf4j; |
| 30 | import org.springframework.stereotype.Service; | 31 | import org.springframework.stereotype.Service; |
| 31 | import org.springframework.transaction.annotation.Transactional; | 32 | import org.springframework.transaction.annotation.Transactional; |
| 32 | import org.springframework.validation.annotation.Validated; | 33 | import org.springframework.validation.annotation.Validated; |
| 33 | 34 | ||
| 34 | -import jakarta.annotation.Resource; | ||
| 35 | import java.util.List; | 35 | import java.util.List; |
| 36 | 36 | ||
| 37 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 37 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -93,9 +93,9 @@ public class PayRefundServiceImpl implements PayRefundService { | @@ -93,9 +93,9 @@ public class PayRefundServiceImpl implements PayRefundService { | ||
| 93 | @Override | 93 | @Override |
| 94 | public Long createPayRefund(PayRefundCreateReqDTO reqDTO) { | 94 | public Long createPayRefund(PayRefundCreateReqDTO reqDTO) { |
| 95 | // 1.1 校验 App | 95 | // 1.1 校验 App |
| 96 | - PayAppDO app = appService.validPayApp(reqDTO.getAppId()); | 96 | + PayAppDO app = appService.validPayApp(reqDTO.getAppKey()); |
| 97 | // 1.2 校验支付订单 | 97 | // 1.2 校验支付订单 |
| 98 | - PayOrderDO order = validatePayOrderCanRefund(reqDTO); | 98 | + PayOrderDO order = validatePayOrderCanRefund(reqDTO, app.getId()); |
| 99 | // 1.3 校验支付渠道是否有效 | 99 | // 1.3 校验支付渠道是否有效 |
| 100 | PayChannelDO channel = channelService.validPayChannel(order.getChannelId()); | 100 | PayChannelDO channel = channelService.validPayChannel(order.getChannelId()); |
| 101 | PayClient client = channelService.getPayClient(channel.getId()); | 101 | PayClient client = channelService.getPayClient(channel.getId()); |
| @@ -153,8 +153,8 @@ public class PayRefundServiceImpl implements PayRefundService { | @@ -153,8 +153,8 @@ public class PayRefundServiceImpl implements PayRefundService { | ||
| 153 | * @param reqDTO 退款申请信息 | 153 | * @param reqDTO 退款申请信息 |
| 154 | * @return 支付订单 | 154 | * @return 支付订单 |
| 155 | */ | 155 | */ |
| 156 | - private PayOrderDO validatePayOrderCanRefund(PayRefundCreateReqDTO reqDTO) { | ||
| 157 | - PayOrderDO order = orderService.getOrder(reqDTO.getAppId(), reqDTO.getMerchantOrderId()); | 156 | + private PayOrderDO validatePayOrderCanRefund(PayRefundCreateReqDTO reqDTO, Long appId) { |
| 157 | + PayOrderDO order = orderService.getOrder(appId, reqDTO.getMerchantOrderId()); | ||
| 158 | if (order == null) { | 158 | if (order == null) { |
| 159 | throw exception(PAY_ORDER_NOT_FOUND); | 159 | throw exception(PAY_ORDER_NOT_FOUND); |
| 160 | } | 160 | } |
| @@ -164,11 +164,11 @@ public class PayRefundServiceImpl implements PayRefundService { | @@ -164,11 +164,11 @@ public class PayRefundServiceImpl implements PayRefundService { | ||
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | // 校验金额,退款金额不能大于原定的金额 | 166 | // 校验金额,退款金额不能大于原定的金额 |
| 167 | - if (reqDTO.getPrice() + order.getRefundPrice() > order.getPrice()){ | 167 | + if (reqDTO.getPrice() + order.getRefundPrice() > order.getPrice()) { |
| 168 | throw exception(REFUND_PRICE_EXCEED); | 168 | throw exception(REFUND_PRICE_EXCEED); |
| 169 | } | 169 | } |
| 170 | // 是否有退款中的订单 | 170 | // 是否有退款中的订单 |
| 171 | - if (refundMapper.selectCountByAppIdAndOrderId(reqDTO.getAppId(), order.getId(), | 171 | + if (refundMapper.selectCountByAppIdAndOrderId(appId, order.getId(), |
| 172 | PayRefundStatusEnum.WAITING.getStatus()) > 0) { | 172 | PayRefundStatusEnum.WAITING.getStatus()) > 0) { |
| 173 | throw exception(REFUND_HAS_REFUNDING); | 173 | throw exception(REFUND_HAS_REFUNDING); |
| 174 | } | 174 | } |
| @@ -197,9 +197,10 @@ public class PayRefundServiceImpl implements PayRefundService { | @@ -197,9 +197,10 @@ public class PayRefundServiceImpl implements PayRefundService { | ||
| 197 | * 通知并更新订单的退款结果 | 197 | * 通知并更新订单的退款结果 |
| 198 | * | 198 | * |
| 199 | * @param channel 支付渠道 | 199 | * @param channel 支付渠道 |
| 200 | - * @param notify 通知 | 200 | + * @param notify 通知 |
| 201 | */ | 201 | */ |
| 202 | - @Transactional(rollbackFor = Exception.class) // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyRefund(channel, notify) 调用,否则事务不生效 | 202 | + @Transactional(rollbackFor = Exception.class) |
| 203 | + // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyRefund(channel, notify) 调用,否则事务不生效 | ||
| 203 | public void notifyRefund(PayChannelDO channel, PayRefundRespDTO notify) { | 204 | public void notifyRefund(PayChannelDO channel, PayRefundRespDTO notify) { |
| 204 | // 情况一:退款成功 | 205 | // 情况一:退款成功 |
| 205 | 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/transfer/PayTransferServiceImpl.java
| @@ -24,12 +24,12 @@ import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum; | @@ -24,12 +24,12 @@ import cn.iocoder.yudao.module.pay.enums.transfer.PayTransferStatusEnum; | ||
| 24 | import cn.iocoder.yudao.module.pay.service.app.PayAppService; | 24 | import cn.iocoder.yudao.module.pay.service.app.PayAppService; |
| 25 | import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; | 25 | import cn.iocoder.yudao.module.pay.service.channel.PayChannelService; |
| 26 | import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; | 26 | import cn.iocoder.yudao.module.pay.service.notify.PayNotifyService; |
| 27 | +import jakarta.annotation.Resource; | ||
| 28 | +import jakarta.validation.Validator; | ||
| 27 | import lombok.extern.slf4j.Slf4j; | 29 | import lombok.extern.slf4j.Slf4j; |
| 28 | import org.springframework.stereotype.Service; | 30 | import org.springframework.stereotype.Service; |
| 29 | import org.springframework.transaction.annotation.Transactional; | 31 | import org.springframework.transaction.annotation.Transactional; |
| 30 | 32 | ||
| 31 | -import jakarta.annotation.Resource; | ||
| 32 | -import jakarta.validation.Validator; | ||
| 33 | import java.util.List; | 33 | import java.util.List; |
| 34 | 34 | ||
| 35 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 35 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -79,16 +79,16 @@ public class PayTransferServiceImpl implements PayTransferService { | @@ -79,16 +79,16 @@ public class PayTransferServiceImpl implements PayTransferService { | ||
| 79 | @Override | 79 | @Override |
| 80 | public Long createTransfer(PayTransferCreateReqDTO reqDTO) { | 80 | public Long createTransfer(PayTransferCreateReqDTO reqDTO) { |
| 81 | // 1.1 校验 App | 81 | // 1.1 校验 App |
| 82 | - PayAppDO payApp = appService.validPayApp(reqDTO.getAppId()); | 82 | + PayAppDO payApp = appService.validPayApp(reqDTO.getAppKey()); |
| 83 | // 1.2 校验支付渠道是否有效 | 83 | // 1.2 校验支付渠道是否有效 |
| 84 | - PayChannelDO channel = channelService.validPayChannel(reqDTO.getAppId(), reqDTO.getChannelCode()); | 84 | + PayChannelDO channel = channelService.validPayChannel(payApp.getId(), reqDTO.getChannelCode()); |
| 85 | PayClient client = channelService.getPayClient(channel.getId()); | 85 | PayClient client = channelService.getPayClient(channel.getId()); |
| 86 | if (client == null) { | 86 | if (client == null) { |
| 87 | log.error("[createTransfer][渠道编号({}) 找不到对应的支付客户端]", channel.getId()); | 87 | log.error("[createTransfer][渠道编号({}) 找不到对应的支付客户端]", channel.getId()); |
| 88 | throw exception(CHANNEL_NOT_FOUND); | 88 | throw exception(CHANNEL_NOT_FOUND); |
| 89 | } | 89 | } |
| 90 | // 1.3 校验转账单已经发起过转账。 | 90 | // 1.3 校验转账单已经发起过转账。 |
| 91 | - PayTransferDO transfer = validateTransferCanCreate(reqDTO); | 91 | + PayTransferDO transfer = validateTransferCanCreate(reqDTO, payApp.getId()); |
| 92 | 92 | ||
| 93 | if (transfer == null) { | 93 | if (transfer == null) { |
| 94 | // 2.不存在创建转账单. 否则允许使用相同的 no 再次发起转账 | 94 | // 2.不存在创建转账单. 否则允许使用相同的 no 再次发起转账 |
| @@ -116,8 +116,8 @@ public class PayTransferServiceImpl implements PayTransferService { | @@ -116,8 +116,8 @@ public class PayTransferServiceImpl implements PayTransferService { | ||
| 116 | return transfer.getId(); | 116 | return transfer.getId(); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | - private PayTransferDO validateTransferCanCreate(PayTransferCreateReqDTO dto) { | ||
| 120 | - PayTransferDO transfer = transferMapper.selectByAppIdAndMerchantTransferId(dto.getAppId(), dto.getMerchantTransferId()); | 119 | + private PayTransferDO validateTransferCanCreate(PayTransferCreateReqDTO dto, Long appId) { |
| 120 | + PayTransferDO transfer = transferMapper.selectByAppIdAndMerchantTransferId(appId, dto.getMerchantTransferId()); | ||
| 121 | if (transfer != null) { | 121 | if (transfer != null) { |
| 122 | // 已经存在,并且状态不为等待状态。说明已经调用渠道转账并返回结果. | 122 | // 已经存在,并且状态不为等待状态。说明已经调用渠道转账并返回结果. |
| 123 | if (!PayTransferStatusEnum.isWaiting(transfer.getStatus())) { | 123 | if (!PayTransferStatusEnum.isWaiting(transfer.getStatus())) { |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
| @@ -54,7 +54,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | @@ -54,7 +54,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | ||
| 54 | /** | 54 | /** |
| 55 | * TODO 芋艿:放到 payconfig | 55 | * TODO 芋艿:放到 payconfig |
| 56 | */ | 56 | */ |
| 57 | - private static final Long WALLET_PAY_APP_ID = 8L; | 57 | + private static final String WALLET_PAY_APP_KEY = "wallet"; |
| 58 | 58 | ||
| 59 | private static final String WALLET_RECHARGE_ORDER_SUBJECT = "钱包余额充值"; | 59 | private static final String WALLET_RECHARGE_ORDER_SUBJECT = "钱包余额充值"; |
| 60 | 60 | ||
| @@ -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 | - .setAppId(WALLET_PAY_APP_ID).setUserIp(userIp) | 95 | + .setAppKey(WALLET_PAY_APP_KEY).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 | - .setAppId(WALLET_PAY_APP_ID).setUserIp(userIp) | 177 | + .setAppKey(WALLET_PAY_APP_KEY).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-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceTest.java
| @@ -218,11 +218,11 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest { | @@ -218,11 +218,11 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest { | ||
| 218 | public void testCreateOrder_success() { | 218 | public void testCreateOrder_success() { |
| 219 | // mock 参数 | 219 | // mock 参数 |
| 220 | PayOrderCreateReqDTO reqDTO = randomPojo(PayOrderCreateReqDTO.class, | 220 | PayOrderCreateReqDTO reqDTO = randomPojo(PayOrderCreateReqDTO.class, |
| 221 | - o -> o.setAppId(1L).setMerchantOrderId("10") | 221 | + o -> o.setAppKey("demo").setMerchantOrderId("10") |
| 222 | .setSubject(randomString()).setBody(randomString())); | 222 | .setSubject(randomString()).setBody(randomString())); |
| 223 | // mock 方法 | 223 | // mock 方法 |
| 224 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L).setOrderNotifyUrl("http://127.0.0.1")); | 224 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L).setOrderNotifyUrl("http://127.0.0.1")); |
| 225 | - when(appService.validPayApp(eq(reqDTO.getAppId()))).thenReturn(app); | 225 | + when(appService.validPayApp(eq(reqDTO.getAppKey()))).thenReturn(app); |
| 226 | 226 | ||
| 227 | // 调用 | 227 | // 调用 |
| 228 | Long orderId = orderService.createOrder(reqDTO); | 228 | Long orderId = orderService.createOrder(reqDTO); |
| @@ -239,7 +239,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest { | @@ -239,7 +239,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest { | ||
| 239 | public void testCreateOrder_exists() { | 239 | public void testCreateOrder_exists() { |
| 240 | // mock 参数 | 240 | // mock 参数 |
| 241 | PayOrderCreateReqDTO reqDTO = randomPojo(PayOrderCreateReqDTO.class, | 241 | PayOrderCreateReqDTO reqDTO = randomPojo(PayOrderCreateReqDTO.class, |
| 242 | - o -> o.setAppId(1L).setMerchantOrderId("10")); | 242 | + o -> o.setAppKey("demo").setMerchantOrderId("10")); |
| 243 | // mock 数据 | 243 | // mock 数据 |
| 244 | PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> o.setAppId(1L).setMerchantOrderId("10")); | 244 | PayOrderDO dbOrder = randomPojo(PayOrderDO.class, o -> o.setAppId(1L).setMerchantOrderId("10")); |
| 245 | orderMapper.insert(dbOrder); | 245 | orderMapper.insert(dbOrder); |
yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/refund/PayRefundServiceTest.java
| @@ -209,7 +209,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | @@ -209,7 +209,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | ||
| 209 | @Test | 209 | @Test |
| 210 | public void testCreateRefund_orderNotFound() { | 210 | public void testCreateRefund_orderNotFound() { |
| 211 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, | 211 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, |
| 212 | - o -> o.setAppId(1L)); | 212 | + o -> o.setAppKey("demo")); |
| 213 | // mock 方法(app) | 213 | // mock 方法(app) |
| 214 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); | 214 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); |
| 215 | when(appService.validPayApp(eq(1L))).thenReturn(app); | 215 | when(appService.validPayApp(eq(1L))).thenReturn(app); |
| @@ -232,7 +232,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | @@ -232,7 +232,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | ||
| 232 | private void testCreateRefund_orderWaitingOrClosed(Integer status) { | 232 | private void testCreateRefund_orderWaitingOrClosed(Integer status) { |
| 233 | // 准备参数 | 233 | // 准备参数 |
| 234 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, | 234 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, |
| 235 | - o -> o.setAppId(1L).setMerchantOrderId("100")); | 235 | + o -> o.setAppKey("demo").setMerchantOrderId("100")); |
| 236 | // mock 方法(app) | 236 | // mock 方法(app) |
| 237 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); | 237 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); |
| 238 | when(appService.validPayApp(eq(1L))).thenReturn(app); | 238 | when(appService.validPayApp(eq(1L))).thenReturn(app); |
| @@ -249,7 +249,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | @@ -249,7 +249,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | ||
| 249 | public void testCreateRefund_refundPriceExceed() { | 249 | public void testCreateRefund_refundPriceExceed() { |
| 250 | // 准备参数 | 250 | // 准备参数 |
| 251 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, | 251 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, |
| 252 | - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(10)); | 252 | + o -> o.setAppKey("demo").setMerchantOrderId("100").setPrice(10)); |
| 253 | // mock 方法(app) | 253 | // mock 方法(app) |
| 254 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); | 254 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); |
| 255 | when(appService.validPayApp(eq(1L))).thenReturn(app); | 255 | when(appService.validPayApp(eq(1L))).thenReturn(app); |
| @@ -268,7 +268,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | @@ -268,7 +268,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | ||
| 268 | public void testCreateRefund_orderHasRefunding() { | 268 | public void testCreateRefund_orderHasRefunding() { |
| 269 | // 准备参数 | 269 | // 准备参数 |
| 270 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, | 270 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, |
| 271 | - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(10)); | 271 | + o -> o.setAppKey("demo").setMerchantOrderId("100").setPrice(10)); |
| 272 | // mock 方法(app) | 272 | // mock 方法(app) |
| 273 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); | 273 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); |
| 274 | when(appService.validPayApp(eq(1L))).thenReturn(app); | 274 | when(appService.validPayApp(eq(1L))).thenReturn(app); |
| @@ -291,7 +291,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | @@ -291,7 +291,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | ||
| 291 | public void testCreateRefund_channelNotFound() { | 291 | public void testCreateRefund_channelNotFound() { |
| 292 | // 准备参数 | 292 | // 准备参数 |
| 293 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, | 293 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, |
| 294 | - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9)); | 294 | + o -> o.setAppKey("demo").setMerchantOrderId("100").setPrice(9)); |
| 295 | // mock 方法(app) | 295 | // mock 方法(app) |
| 296 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); | 296 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); |
| 297 | when(appService.validPayApp(eq(1L))).thenReturn(app); | 297 | when(appService.validPayApp(eq(1L))).thenReturn(app); |
| @@ -315,7 +315,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | @@ -315,7 +315,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | ||
| 315 | public void testCreateRefund_refundExists() { | 315 | public void testCreateRefund_refundExists() { |
| 316 | // 准备参数 | 316 | // 准备参数 |
| 317 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, | 317 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, |
| 318 | - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9) | 318 | + o -> o.setAppKey("demo").setMerchantOrderId("100").setPrice(9) |
| 319 | .setMerchantRefundId("200").setReason("测试退款")); | 319 | .setMerchantRefundId("200").setReason("测试退款")); |
| 320 | // mock 方法(app) | 320 | // mock 方法(app) |
| 321 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); | 321 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); |
| @@ -347,7 +347,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | @@ -347,7 +347,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | ||
| 347 | public void testCreateRefund_invokeException() { | 347 | public void testCreateRefund_invokeException() { |
| 348 | // 准备参数 | 348 | // 准备参数 |
| 349 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, | 349 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, |
| 350 | - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9) | 350 | + o -> o.setAppKey("demo").setMerchantOrderId("100").setPrice(9) |
| 351 | .setMerchantRefundId("200").setReason("测试退款")); | 351 | .setMerchantRefundId("200").setReason("测试退款")); |
| 352 | // mock 方法(app) | 352 | // mock 方法(app) |
| 353 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); | 353 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); |
| @@ -391,7 +391,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | @@ -391,7 +391,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest { | ||
| 391 | 391 | ||
| 392 | // 准备参数 | 392 | // 准备参数 |
| 393 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, | 393 | PayRefundCreateReqDTO reqDTO = randomPojo(PayRefundCreateReqDTO.class, |
| 394 | - o -> o.setAppId(1L).setMerchantOrderId("100").setPrice(9) | 394 | + o -> o.setAppKey("demo").setMerchantOrderId("100").setPrice(9) |
| 395 | .setMerchantRefundId("200").setReason("测试退款")); | 395 | .setMerchantRefundId("200").setReason("测试退款")); |
| 396 | // mock 方法(app) | 396 | // mock 方法(app) |
| 397 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); | 397 | PayAppDO app = randomPojo(PayAppDO.class, o -> o.setId(1L)); |
yudao-server/pom.xml
| @@ -33,80 +33,80 @@ | @@ -33,80 +33,80 @@ | ||
| 33 | </dependency> | 33 | </dependency> |
| 34 | 34 | ||
| 35 | <!-- 会员中心。默认注释,保证编译速度 --> | 35 | <!-- 会员中心。默认注释,保证编译速度 --> |
| 36 | -<!-- <dependency>--> | ||
| 37 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 38 | -<!-- <artifactId>yudao-module-member-biz</artifactId>--> | ||
| 39 | -<!-- <version>${revision}</version>--> | ||
| 40 | -<!-- </dependency>--> | 36 | + <dependency> |
| 37 | + <groupId>cn.iocoder.boot</groupId> | ||
| 38 | + <artifactId>yudao-module-member-biz</artifactId> | ||
| 39 | + <version>${revision}</version> | ||
| 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>--> | ||
| 56 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 57 | -<!-- <artifactId>yudao-module-pay-biz</artifactId>--> | ||
| 58 | -<!-- <version>${revision}</version>--> | ||
| 59 | -<!-- </dependency>--> | 55 | + <dependency> |
| 56 | + <groupId>cn.iocoder.boot</groupId> | ||
| 57 | + <artifactId>yudao-module-pay-biz</artifactId> | ||
| 58 | + <version>${revision}</version> | ||
| 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>--> | ||
| 70 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 71 | -<!-- <artifactId>yudao-module-promotion-biz</artifactId>--> | ||
| 72 | -<!-- <version>${revision}</version>--> | ||
| 73 | -<!-- </dependency>--> | ||
| 74 | -<!-- <dependency>--> | ||
| 75 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 76 | -<!-- <artifactId>yudao-module-product-biz</artifactId>--> | ||
| 77 | -<!-- <version>${revision}</version>--> | ||
| 78 | -<!-- </dependency>--> | ||
| 79 | -<!-- <dependency>--> | ||
| 80 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 81 | -<!-- <artifactId>yudao-module-trade-biz</artifactId>--> | ||
| 82 | -<!-- <version>${revision}</version>--> | ||
| 83 | -<!-- </dependency>--> | ||
| 84 | -<!-- <dependency>--> | ||
| 85 | -<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 86 | -<!-- <artifactId>yudao-module-statistics-biz</artifactId>--> | ||
| 87 | -<!-- <version>${revision}</version>--> | ||
| 88 | -<!-- </dependency>--> | 69 | + <dependency> |
| 70 | + <groupId>cn.iocoder.boot</groupId> | ||
| 71 | + <artifactId>yudao-module-promotion-biz</artifactId> | ||
| 72 | + <version>${revision}</version> | ||
| 73 | + </dependency> | ||
| 74 | + <dependency> | ||
| 75 | + <groupId>cn.iocoder.boot</groupId> | ||
| 76 | + <artifactId>yudao-module-product-biz</artifactId> | ||
| 77 | + <version>${revision}</version> | ||
| 78 | + </dependency> | ||
| 79 | + <dependency> | ||
| 80 | + <groupId>cn.iocoder.boot</groupId> | ||
| 81 | + <artifactId>yudao-module-trade-biz</artifactId> | ||
| 82 | + <version>${revision}</version> | ||
| 83 | + </dependency> | ||
| 84 | + <dependency> | ||
| 85 | + <groupId>cn.iocoder.boot</groupId> | ||
| 86 | + <artifactId>yudao-module-statistics-biz</artifactId> | ||
| 87 | + <version>${revision}</version> | ||
| 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://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | 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 连接的示例 |
| 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: 123456 | 57 | + password: 3WLiVUBEwTbvAfsh |
| 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: 127.0.0.1 # 地址 | 73 | + host: 39.105.15.179 # 地址 |
| 74 | port: 6379 # 端口 | 74 | port: 6379 # 端口 |
| 75 | database: 0 # 数据库索引 | 75 | database: 0 # 数据库索引 |
| 76 | -# password: dev # 密码,建议生产环境开启 | 76 | + password: 3WLiVUBEwTbvAfsh # 密码,建议生产环境开启 |
| 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: 127.0.0.1:9876 # RocketMQ Namesrv | 113 | + name-server: 117.72.39.77: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,7 @@ yudao: | @@ -309,7 +309,7 @@ yudao: | ||
| 309 | end-code: 9999 # 这里配置 9999 的原因是,测试方便。 | 309 | end-code: 9999 # 这里配置 9999 的原因是,测试方便。 |
| 310 | trade: | 310 | trade: |
| 311 | order: | 311 | order: |
| 312 | - app-id: 1 # 商户编号 | 312 | + app-key: mall |
| 313 | pay-expire-time: 2h # 支付的过期时间 | 313 | pay-expire-time: 2h # 支付的过期时间 |
| 314 | receive-expire-time: 14d # 收货的过期时间 | 314 | receive-expire-time: 14d # 收货的过期时间 |
| 315 | comment-expire-time: 7d # 评论的过期时间 | 315 | comment-expire-time: 7d # 评论的过期时间 |