Commit 4acada62d35253bcda4bf23e65a8e7c0fd206e3f

Authored by YunaiV
1 parent 75633aa8

完成支付回调的逻辑

Showing 33 changed files with 427 additions and 75 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/logger/InfApiAccessLogConvert.java
... ... @@ -2,7 +2,6 @@ package cn.iocoder.yudao.adminserver.modules.infra.convert.logger;
2 2  
3 3 import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
4 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO;
6 5 import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExcelVO;
7 6 import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogRespVO;
8 7 import org.mapstruct.Mapper;
... ...
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/social/impl/SysSocialServiceImpl.java
... ... @@ -19,9 +19,9 @@ import me.zhyd.oauth.request.AuthRequest;
19 19 import me.zhyd.oauth.utils.AuthStateUtils;
20 20 import org.springframework.stereotype.Service;
21 21 import org.springframework.transaction.annotation.Transactional;
  22 +import org.springframework.validation.annotation.Validated;
22 23  
23 24 import javax.annotation.Resource;
24   -import javax.validation.Valid;
25 25 import java.util.List;
26 26 import java.util.Objects;
27 27  
... ... @@ -36,7 +36,7 @@ import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString
36 36 * @author 芋道源码
37 37 */
38 38 @Service
39   -@Valid
  39 +@Validated
40 40 @Slf4j
41 41 public class SysSocialServiceImpl implements SysSocialService {
42 42  
... ...
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiAccessLogServiceImplTest.java
1 1 package cn.iocoder.yudao.adminserver.modules.infra.service.logger;
2 2  
3   -import cn.hutool.core.util.RandomUtil;
4 3 import cn.iocoder.yudao.adminserver.BaseDbUnitTest;
5 4 import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
6 5 import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
7 6 import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
8 7 import cn.iocoder.yudao.framework.common.pojo.PageResult;
9   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO;
10 8 import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO;
11 9 import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO;
12 10 import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger.InfApiAccessLogMapper;
... ... @@ -19,7 +17,6 @@ import org.springframework.context.annotation.Import;
19 17 import javax.annotation.Resource;
20 18 import java.util.Date;
21 19 import java.util.List;
22   -import java.util.concurrent.Future;
23 20  
24 21 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
25 22 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime;
... ...
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiErrorLogServiceImplTest.java
1 1 package cn.iocoder.yudao.adminserver.modules.infra.service.logger;
2 2  
3   -import cn.hutool.core.util.RandomUtil;
4 3 import cn.iocoder.yudao.adminserver.BaseDbUnitTest;
5 4 import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO;
6 5 import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
7 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
8   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO;
9 7 import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogExportReqVO;
10 8 import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogPageReqVO;
11 9 import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger.InfApiErrorLogMapper;
... ... @@ -19,7 +17,6 @@ import org.springframework.context.annotation.Import;
19 17 import javax.annotation.Resource;
20 18 import java.util.Date;
21 19 import java.util.List;
22   -import java.util.concurrent.Future;
23 20  
24 21 import static cn.iocoder.yudao.adminserver.modules.infra.enums.InfErrorCodeConstants.API_ERROR_LOG_NOT_FOUND;
25 22 import static cn.iocoder.yudao.adminserver.modules.infra.enums.InfErrorCodeConstants.API_ERROR_LOG_PROCESSED;
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/logger/InfApiAccessLogCoreConvert.java
1 1 package cn.iocoder.yudao.coreservice.modules.infra.convert.logger;
2 2  
3   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO;
  3 +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO;
4 4 import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
5 5 import org.mapstruct.Mapper;
6 6 import org.mapstruct.factory.Mappers;
... ... @@ -10,6 +10,6 @@ public interface InfApiAccessLogCoreConvert {
10 10  
11 11 InfApiAccessLogCoreConvert INSTANCE = Mappers.getMapper(InfApiAccessLogCoreConvert.class);
12 12  
13   - InfApiAccessLogDO convert(ApiAccessLogCreateDTO bean);
  13 + InfApiAccessLogDO convert(ApiAccessLogCreateReqDTO bean);
14 14  
15 15 }
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/logger/InfApiErrorLogCoreConvert.java
1 1 package cn.iocoder.yudao.coreservice.modules.infra.convert.logger;
2 2  
3   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO;
  3 +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO;
4 4 import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO;
5 5 import org.mapstruct.Mapper;
6 6 import org.mapstruct.factory.Mappers;
... ... @@ -10,6 +10,6 @@ public interface InfApiErrorLogCoreConvert {
10 10  
11 11 InfApiErrorLogCoreConvert INSTANCE = Mappers.getMapper(InfApiErrorLogCoreConvert.class);
12 12  
13   - InfApiErrorLogDO convert(ApiErrorLogCreateDTO bean);
  13 + InfApiErrorLogDO convert(ApiErrorLogCreateReqDTO bean);
14 14  
15 15 }
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/impl/InfApiAccessLogCoreServiceImpl.java
1 1 package cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl;
2 2  
3 3 import cn.iocoder.yudao.coreservice.modules.infra.convert.logger.InfApiAccessLogCoreConvert;
4   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO;
  4 +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO;
5 5 import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
6 6 import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiAccessLogCoreMapper;
7 7 import cn.iocoder.yudao.coreservice.modules.infra.service.logger.InfApiAccessLogCoreService;
8 8 import lombok.extern.slf4j.Slf4j;
9 9 import org.springframework.scheduling.annotation.Async;
10   -import org.springframework.scheduling.annotation.AsyncResult;
11 10 import org.springframework.stereotype.Service;
12 11 import org.springframework.validation.annotation.Validated;
13 12  
14 13 import javax.annotation.Resource;
15   -import java.util.concurrent.Future;
16 14  
17 15 /**
18 16 * API 访问日志 Service 实现类
... ... @@ -29,7 +27,7 @@ public class InfApiAccessLogCoreServiceImpl implements InfApiAccessLogCoreServic
29 27  
30 28 @Override
31 29 @Async
32   - public void createApiAccessLogAsync(ApiAccessLogCreateDTO createDTO) {
  30 + public void createApiAccessLogAsync(ApiAccessLogCreateReqDTO createDTO) {
33 31 InfApiAccessLogDO apiAccessLog = InfApiAccessLogCoreConvert.INSTANCE.convert(createDTO);
34 32 apiAccessLogMapper.insert(apiAccessLog);
35 33 }
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/impl/InfApiErrorLogCoreServiceImpl.java
... ... @@ -5,15 +5,13 @@ import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiEr
5 5 import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiErrorLogCoreMapper;
6 6 import cn.iocoder.yudao.coreservice.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum;
7 7 import cn.iocoder.yudao.coreservice.modules.infra.service.logger.InfApiErrorLogCoreService;
8   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO;
  8 +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO;
9 9 import lombok.extern.slf4j.Slf4j;
10 10 import org.springframework.scheduling.annotation.Async;
11   -import org.springframework.scheduling.annotation.AsyncResult;
12 11 import org.springframework.stereotype.Service;
13 12 import org.springframework.validation.annotation.Validated;
14 13  
15 14 import javax.annotation.Resource;
16   -import java.util.concurrent.Future;
17 15  
18 16 /**
19 17 * API 错误日志 Service 实现类
... ... @@ -30,7 +28,7 @@ public class InfApiErrorLogCoreServiceImpl implements InfApiErrorLogCoreService
30 28  
31 29 @Override
32 30 @Async
33   - public void createApiErrorLogAsync(ApiErrorLogCreateDTO createDTO) {
  31 + public void createApiErrorLogAsync(ApiErrorLogCreateReqDTO createDTO) {
34 32 InfApiErrorLogDO apiErrorLog = InfApiErrorLogCoreConvert.INSTANCE.convert(createDTO);
35 33 apiErrorLog.setProcessStatus(InfApiErrorLogProcessStatusEnum.INIT.getStatus());
36 34 apiErrorLogMapper.insert(apiErrorLog);
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/notify/PayNotifyLogDO.java 0 → 100644
  1 +package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.notify;
  2 +
  3 +import cn.iocoder.yudao.coreservice.modules.pay.enums.notify.PayNotifyStatusEnum;
  4 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  5 +import com.baomidou.mybatisplus.annotation.TableName;
  6 +import lombok.Data;
  7 +import lombok.EqualsAndHashCode;
  8 +import lombok.experimental.Accessors;
  9 +
  10 +/**
  11 + * 商户支付、退款等的通知 Log
  12 + * 每次通知时,都会在该表中,记录一次 Log,方便排查问题
  13 + *
  14 + * @author 芋道源码
  15 + */
  16 +@TableName("pay_notify_log")
  17 +@Data
  18 +@EqualsAndHashCode(callSuper = true)
  19 +@Accessors(chain = true)
  20 +public class PayNotifyLogDO extends BaseDO {
  21 +
  22 + /**
  23 + * 日志编号,自增
  24 + */
  25 + private Long id;
  26 + /**
  27 + * 通知编号
  28 + *
  29 + * 关联 {@link PayNotifyTaskDO#getId()}
  30 + */
  31 + private Long notifyId;
  32 + /**
  33 + * 当前通知次数
  34 + */
  35 + private Integer notifyTimes;
  36 + /**
  37 + * 请求参数
  38 + */
  39 + private String request;
  40 + /**
  41 + * 响应结果
  42 + */
  43 + private String response;
  44 + /**
  45 + * 状态
  46 + *
  47 + * 外键 {@link PayNotifyStatusEnum}
  48 + */
  49 + private Integer status;
  50 +
  51 +}
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/notify/PayNotifyTaskDO.java 0 → 100644
  1 +package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.notify;
  2 +
  3 +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO;
  4 +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayMerchantDO;
  5 +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO;
  6 +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayRefundDO;
  7 +import cn.iocoder.yudao.coreservice.modules.pay.enums.notify.PayNotifyStatusEnum;
  8 +import cn.iocoder.yudao.coreservice.modules.pay.enums.notify.PayNotifyTypeEnum;
  9 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  10 +import com.baomidou.mybatisplus.annotation.TableName;
  11 +import lombok.Data;
  12 +import lombok.EqualsAndHashCode;
  13 +import lombok.experimental.Accessors;
  14 +
  15 +import java.util.Date;
  16 +
  17 +/**
  18 + * 商户支付、退款等的通知
  19 + * 在支付系统收到支付渠道的支付、退款的结果后,需要不断的通知到业务系统,直到成功。
  20 + *
  21 + * @author 芋道源码
  22 + */
  23 +@TableName("pay_notify_task")
  24 +@Data
  25 +@EqualsAndHashCode(callSuper = true)
  26 +@Accessors(chain = true)
  27 +public class PayNotifyTaskDO extends BaseDO {
  28 +
  29 + /**
  30 + * 通知频率,单位为秒。
  31 + *
  32 + * 算上首次的通知,实际是一共 1 + 8 = 9 次。
  33 + */
  34 + public static final Integer[] NOTIFY_FREQUENCY = new Integer[]{
  35 + 15, 15, 30, 180,
  36 + 1800, 1800, 1800, 3600
  37 + };
  38 +
  39 + /**
  40 + * 编号,自增
  41 + */
  42 + private Long id;
  43 + /**
  44 + * 商户编号
  45 + *
  46 + * 关联 {@link PayMerchantDO#getId()}
  47 + */
  48 + private Long merchantId;
  49 + /**
  50 + * 应用编号
  51 + *
  52 + * 关联 {@link PayAppDO#getId()}
  53 + */
  54 + private Long appId;
  55 + /**
  56 + * 通知类型
  57 + *
  58 + * 外键 {@link PayNotifyTypeEnum}
  59 + */
  60 + private Integer type;
  61 + /**
  62 + * 数据编号,根据不同 type 进行关联:
  63 + *
  64 + * 1. {@link PayNotifyTypeEnum#ORDER} 时,关联 {@link PayOrderDO#getId()}
  65 + * 2. {@link PayNotifyTypeEnum#REFUND} 时,关联 {@link PayRefundDO#getId()}
  66 + */
  67 + private Long dataId;
  68 + /**
  69 + * 商户订单编号
  70 + */
  71 + private String merchantOrderId;
  72 + /**
  73 + * 通知状态
  74 + *
  75 + * 外键 {@link PayNotifyStatusEnum}
  76 + */
  77 + private Integer status;
  78 + /**
  79 + * 下一次通知时间
  80 + */
  81 + private Date nextNotifyTime;
  82 + /**
  83 + * 最后一次执行时间
  84 + */
  85 + private Date lastExecuteTime;
  86 + /**
  87 + * 当前通知次数
  88 + */
  89 + private Integer notifyTimes;
  90 + /**
  91 + * 最大可通知次数
  92 + */
  93 + private Integer maxNotifyTimes;
  94 + /**
  95 + * 通知地址
  96 + */
  97 + private String notifyUrl;
  98 +
  99 +}
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/order/PayNotifyDO.java deleted
1   -package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order;
2   -
3   -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
4   -import lombok.Data;
5   -
6   -/**
7   - * 商户支付、退款等的通知
8   - * 在支付系统收到支付渠道的支付、退款的结果后,需要不断的通知到业务系统,直到成功。
9   - * TODO 芋艿:待完善
10   - *
11   - * @author 芋道源码
12   - */
13   -@Data
14   -public class PayNotifyDO extends BaseDO {
15   -}
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/dataobject/package-info.java deleted
1   -package cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject;
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/notify/PayNotifyTaskCoreMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.coreservice.modules.pay.dal.mysql.notify;
  2 +
  3 +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.merchant.PayAppDO;
  4 +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.notify.PayNotifyTaskDO;
  5 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  6 +import org.apache.ibatis.annotations.Mapper;
  7 +
  8 +@Mapper
  9 +public interface PayNotifyTaskCoreMapper extends BaseMapperX<PayNotifyTaskDO> {
  10 +}
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/dal/mysql/order/PayOrderExtensionCoreMapper.java
... ... @@ -8,8 +8,8 @@ import org.apache.ibatis.annotations.Mapper;
8 8 @Mapper
9 9 public interface PayOrderExtensionCoreMapper extends BaseMapperX<PayOrderExtensionDO> {
10 10  
11   - default PayOrderExtensionDO selectByOrderExtensionNo(String orderExtensionNo) {
12   - return selectOne("order_extension_no", orderExtensionNo);
  11 + default PayOrderExtensionDO selectByNo(String no) {
  12 + return selectOne("no", no);
13 13 }
14 14  
15 15 default int updateByIdAndStatus(Long id, Integer status, PayOrderExtensionDO update) {
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/notify/PayNotifyStatusEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.coreservice.modules.pay.enums.notify;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Getter;
  5 +
  6 +/**
  7 + * 支付通知状态枚举
  8 + *
  9 + * @author 芋道源码
  10 + */
  11 +@Getter
  12 +@AllArgsConstructor
  13 +public enum PayNotifyStatusEnum {
  14 +
  15 + WAITING(1, "等待通知"),
  16 + SUCCESS(2, "通知成功"),
  17 + FAILURE(3, "通知失败"), // 多次尝试,彻底失败
  18 + REQUEST_SUCCESS(4, "请求成功,但是结果失败"),
  19 + REQUEST_FAILURE(5, "请求失败"),
  20 +
  21 + ;
  22 +
  23 + /**
  24 + * 状态
  25 + */
  26 + private final Integer status;
  27 + /**
  28 + * 名字
  29 + */
  30 + private final String name;
  31 +
  32 +}
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/enums/notify/PayNotifyTypeEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.coreservice.modules.pay.enums.notify;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Getter;
  5 +
  6 +/**
  7 + * 支付通知类型
  8 + *
  9 + * @author 芋道源码
  10 + */
  11 +@Getter
  12 +@AllArgsConstructor
  13 +public enum PayNotifyTypeEnum {
  14 +
  15 + ORDER(1, "支付单"),
  16 + REFUND(2, "退款单"),
  17 + ;
  18 +
  19 + /**
  20 + * 类型
  21 + */
  22 + private final Integer type;
  23 + /**
  24 + * 名字
  25 + */
  26 + private final String name;
  27 +
  28 +}
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/merchant/PayChannelCoreService.java
... ... @@ -20,6 +20,16 @@ public interface PayChannelCoreService {
20 20 *
21 21 * 如果不合法,抛出 {@link ServiceException} 业务异常
22 22 *
  23 + * @param id 渠道编号
  24 + * @return 渠道信息
  25 + */
  26 + PayChannelDO validPayChannel(Long id);
  27 +
  28 + /**
  29 + * 支付渠道的合法性
  30 + *
  31 + * 如果不合法,抛出 {@link ServiceException} 业务异常
  32 + *
23 33 * @param appId 应用编号
24 34 * @param code 支付渠道
25 35 * @return 渠道信息
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/merchant/impl/PayChannelCoreServiceImpl.java
... ... @@ -96,15 +96,26 @@ public class PayChannelCoreServiceImpl implements PayChannelCoreService {
96 96 }
97 97  
98 98 @Override
  99 + public PayChannelDO validPayChannel(Long id) {
  100 + PayChannelDO channel = payChannelCoreMapper.selectById(id);
  101 + this.validPayChannel(channel);
  102 + return channel;
  103 + }
  104 +
  105 + @Override
99 106 public PayChannelDO validPayChannel(Long appId, String code) {
100 107 PayChannelDO channel = payChannelCoreMapper.selectByAppIdAndCode(appId, code);
  108 + this.validPayChannel(channel);
  109 + return channel;
  110 + }
  111 +
  112 + private void validPayChannel(PayChannelDO channel) {
101 113 if (channel == null) {
102 114 throw exception(PAY_CHANNEL_NOT_FOUND);
103 115 }
104 116 if (CommonStatusEnum.DISABLE.getStatus().equals(channel.getStatus())) {
105 117 throw exception(PayErrorCodeCoreConstants.PAY_CHANNEL_IS_DISABLE);
106 118 }
107   - return channel;
108 119 }
109 120  
110 121 }
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/notify/PayNotifyCoreService.java 0 → 100644
  1 +package cn.iocoder.yudao.coreservice.modules.pay.service.notify;
  2 +
  3 +import cn.iocoder.yudao.coreservice.modules.pay.service.notify.dto.PayNotifyTaskCreateReqDTO;
  4 +
  5 +import javax.validation.Valid;
  6 +
  7 +/**
  8 + * 支付通知 Core Service 接口
  9 + *
  10 + * @author 芋道源码
  11 + */
  12 +public interface PayNotifyCoreService {
  13 +
  14 + /**
  15 + * 创建支付通知任务
  16 + *
  17 + * @param reqDTO 任务信息
  18 + */
  19 + void createPayNotifyTask(@Valid PayNotifyTaskCreateReqDTO reqDTO);
  20 +
  21 + /**
  22 + * 执行支付通知
  23 + *
  24 + * 注意,该方法提供给定时任务调用。目前是 yudao-admin-server 进行调用
  25 + */
  26 + void executeNotify();
  27 +
  28 +}
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/notify/dto/PayNotifyTaskCreateReqDTO.java 0 → 100644
  1 +package cn.iocoder.yudao.coreservice.modules.pay.service.notify.dto;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Builder;
  5 +import lombok.Data;
  6 +import lombok.NoArgsConstructor;
  7 +
  8 +import javax.validation.constraints.NotNull;
  9 +
  10 +/**
  11 + * 支付通知创建 DTO
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@Data
  16 +@Builder
  17 +@NoArgsConstructor
  18 +@AllArgsConstructor
  19 +public class PayNotifyTaskCreateReqDTO {
  20 +
  21 + /**
  22 + * 类型
  23 + */
  24 + @NotNull(message = "类型不能为空")
  25 + private Integer type;
  26 + /**
  27 + * 数据编号
  28 + */
  29 + @NotNull(message = "数据编号不能为空")
  30 + private Long dataId;
  31 +
  32 +}
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/notify/impl/PayNotifyCoreServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.coreservice.modules.pay.service.notify.impl;
  2 +
  3 +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.notify.PayNotifyTaskDO;
  4 +import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO;
  5 +import cn.iocoder.yudao.coreservice.modules.pay.dal.mysql.notify.PayNotifyTaskCoreMapper;
  6 +import cn.iocoder.yudao.coreservice.modules.pay.enums.notify.PayNotifyStatusEnum;
  7 +import cn.iocoder.yudao.coreservice.modules.pay.enums.notify.PayNotifyTypeEnum;
  8 +import cn.iocoder.yudao.coreservice.modules.pay.service.notify.PayNotifyCoreService;
  9 +import cn.iocoder.yudao.coreservice.modules.pay.service.notify.dto.PayNotifyTaskCreateReqDTO;
  10 +import cn.iocoder.yudao.coreservice.modules.pay.service.order.PayOrderCoreService;
  11 +import lombok.extern.slf4j.Slf4j;
  12 +import org.springframework.context.annotation.Lazy;
  13 +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
  14 +import org.springframework.stereotype.Service;
  15 +
  16 +import javax.annotation.Resource;
  17 +import javax.validation.Valid;
  18 +import java.util.Date;
  19 +import java.util.Objects;
  20 +
  21 +/**
  22 + * 支付通知 Core Service 实现类
  23 + *
  24 + * @author 芋道源码
  25 + */
  26 +@Service
  27 +@Valid
  28 +@Slf4j
  29 +public class PayNotifyCoreServiceImpl implements PayNotifyCoreService {
  30 +
  31 + @Resource
  32 + @Lazy // 循环依赖,避免报错
  33 + private PayOrderCoreService payOrderCoreService;
  34 +
  35 + @Resource
  36 + private PayNotifyTaskCoreMapper payNotifyTaskCoreMapper;
  37 +
  38 + @Resource
  39 + private ThreadPoolTaskExecutor threadPoolTaskExecutor; // TODO 芋艿:未来提供独立的线程池
  40 +
  41 + @Override
  42 + public void createPayNotifyTask(PayNotifyTaskCreateReqDTO reqDTO) {
  43 + PayNotifyTaskDO task = new PayNotifyTaskDO();
  44 + task.setType(reqDTO.getType()).setDataId(reqDTO.getDataId());
  45 + task.setStatus(PayNotifyStatusEnum.WAITING.getStatus()).setNextNotifyTime(new Date())
  46 + .setNotifyTimes(0).setMaxNotifyTimes(PayNotifyTaskDO.NOTIFY_FREQUENCY.length + 1);
  47 + // 补充 merchantId + appId + notifyUrl 字段
  48 + if (Objects.equals(task.getType(), PayNotifyTypeEnum.ORDER.getType())) {
  49 + PayOrderDO order = payOrderCoreService.getPayOrder(task.getDataId()); // 不进行非空判断,有问题直接异常
  50 + task.setMerchantId(order.getMerchantId()).setAppId(order.getAppId()).
  51 + setMerchantOrderId(order.getMerchantOrderId()).setNotifyUrl(order.getNotifyUrl());
  52 + } else if (Objects.equals(task.getType(), PayNotifyTypeEnum.REFUND.getType())) {
  53 + // TODO 芋艿,需要实现下哈
  54 + throw new UnsupportedOperationException("需要实现");
  55 + }
  56 +
  57 + // 执行插入
  58 + payNotifyTaskCoreMapper.insert(task);
  59 + }
  60 +
  61 + @Override
  62 + public void executeNotify() {
  63 +
  64 + }
  65 +
  66 +}
... ...
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/impl/PayOrderCoreServiceImpl.java
... ... @@ -10,10 +10,13 @@ import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderDO;
10 10 import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderExtensionDO;
11 11 import cn.iocoder.yudao.coreservice.modules.pay.dal.mysql.order.PayOrderCoreMapper;
12 12 import cn.iocoder.yudao.coreservice.modules.pay.dal.mysql.order.PayOrderExtensionCoreMapper;
  13 +import cn.iocoder.yudao.coreservice.modules.pay.enums.notify.PayNotifyTypeEnum;
13 14 import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayOrderNotifyStatusEnum;
14 15 import cn.iocoder.yudao.coreservice.modules.pay.enums.order.PayOrderStatusEnum;
15 16 import cn.iocoder.yudao.coreservice.modules.pay.service.merchant.PayAppCoreService;
16 17 import cn.iocoder.yudao.coreservice.modules.pay.service.merchant.PayChannelCoreService;
  18 +import cn.iocoder.yudao.coreservice.modules.pay.service.notify.PayNotifyCoreService;
  19 +import cn.iocoder.yudao.coreservice.modules.pay.service.notify.dto.PayNotifyTaskCreateReqDTO;
17 20 import cn.iocoder.yudao.coreservice.modules.pay.service.order.PayOrderCoreService;
18 21 import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderCreateReqDTO;
19 22 import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderSubmitReqDTO;
... ... @@ -27,6 +30,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.PayOrderNotifyRespDTO;
27 30 import cn.iocoder.yudao.framework.pay.core.client.dto.PayOrderUnifiedReqDTO;
28 31 import lombok.extern.slf4j.Slf4j;
29 32 import org.springframework.stereotype.Service;
  33 +import org.springframework.transaction.annotation.Transactional;
30 34 import org.springframework.validation.annotation.Validated;
31 35  
32 36 import javax.annotation.Resource;
... ... @@ -53,6 +57,8 @@ public class PayOrderCoreServiceImpl implements PayOrderCoreService {
53 57 private PayAppCoreService payAppCoreService;
54 58 @Resource
55 59 private PayChannelCoreService payChannelCoreService;
  60 + @Resource
  61 + private PayNotifyCoreService payNotifyCoreService;
56 62  
57 63 @Resource
58 64 private PayClientFactory payClientFactory;
... ... @@ -129,7 +135,7 @@ public class PayOrderCoreServiceImpl implements PayOrderCoreService {
129 135 // 调用三方接口
130 136 PayOrderUnifiedReqDTO unifiedOrderReqDTO = PayOrderCoreConvert.INSTANCE.convert2(reqDTO);
131 137 // 商户相关字段
132   - unifiedOrderReqDTO.setMerchantOrderId(order.getMerchantOrderId())
  138 + unifiedOrderReqDTO.setMerchantOrderId(orderExtension.getNo()) // 注意,此处使用的是 PayOrderExtensionDO.no 属性!
133 139 .setSubject(order.getSubject()).setBody(order.getBody())
134 140 .setNotifyUrl(genChannelPayNotifyUrl(channel));
135 141 // 订单相关字段
... ... @@ -174,12 +180,13 @@ public class PayOrderCoreServiceImpl implements PayOrderCoreService {
174 180 }
175 181  
176 182 @Override
  183 + @Transactional
177 184 public void notifyPayOrder(Long channelId, String channelCode, String notifyData) throws Exception {
178 185 // TODO 芋艿,记录回调日志
179 186 log.info("[notifyPayOrder][channelId({}) 回调数据({})]", channelId, notifyData);
180 187  
181 188 // 校验支付渠道是否有效
182   - PayChannelDO channel = payChannelCoreService.validPayChannel(channelId, channelCode);
  189 + PayChannelDO channel = payChannelCoreService.validPayChannel(channelId);
183 190 // 校验支付客户端是否正确初始化
184 191 PayClient client = payClientFactory.getPayClient(channel.getId());
185 192 if (client == null) {
... ... @@ -191,7 +198,7 @@ public class PayOrderCoreServiceImpl implements PayOrderCoreService {
191 198  
192 199 // TODO 芋艿,先最严格的校验。即使调用方重复调用,实际哪个订单已经被重复回调的支付,也返回 false 。也没问题,因为实际已经回调成功了。
193 200 // 1.1 查询 PayOrderExtensionDO
194   - PayOrderExtensionDO orderExtension = payOrderExtensionCoreMapper.selectByOrderExtensionNo(
  201 + PayOrderExtensionDO orderExtension = payOrderExtensionCoreMapper.selectByNo(
195 202 notifyRespDTO.getOrderExtensionNo());
196 203 if (orderExtension == null) {
197 204 throw exception(PAY_ORDER_EXTENSION_NOT_FOUND);
... ... @@ -200,7 +207,7 @@ public class PayOrderCoreServiceImpl implements PayOrderCoreService {
200 207 throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
201 208 }
202 209 // 1.2 更新 PayOrderExtensionDO
203   - int updateCounts = payOrderExtensionCoreMapper.updateByIdAndStatus(orderExtension.getOrderId(),
  210 + int updateCounts = payOrderExtensionCoreMapper.updateByIdAndStatus(orderExtension.getId(),
204 211 PayOrderStatusEnum.WAITING.getStatus(), PayOrderExtensionDO.builder().id(orderExtension.getId())
205 212 .status(PayOrderStatusEnum.SUCCESS.getStatus()).channelNotifyData(notifyData).build());
206 213 if (updateCounts == 0) { // 校验状态,必须是待支付
... ... @@ -219,15 +226,17 @@ public class PayOrderCoreServiceImpl implements PayOrderCoreService {
219 226 // 2.2 更新 PayOrderDO
220 227 updateCounts = payOrderCoreMapper.updateByIdAndStatus(order.getId(), PayOrderStatusEnum.WAITING.getStatus(),
221 228 PayOrderDO.builder().status(PayOrderStatusEnum.SUCCESS.getStatus()).channelId(channelId).channelCode(channelCode)
222   - .successTime(notifyRespDTO.getSuccessTime()).notifyTime(new Date())
223   - .successExtensionId(orderExtension.getId()).build());
  229 + .successTime(notifyRespDTO.getSuccessTime()).successExtensionId(orderExtension.getId())
  230 + .channelOrderNo(notifyRespDTO.getChannelOrderNo()).channelUserId(notifyRespDTO.getChannelUserId())
  231 + .notifyTime(new Date()).build());
224 232 if (updateCounts == 0) { // 校验状态,必须是待支付
225 233 throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING);
226 234 }
227 235 log.info("[notifyPayOrder][支付订单({}) 更新为已支付]", order.getId());
228 236  
229 237 // 3. 插入支付通知记录
230   -// payNotifyService.addPayTransactionNotifyTask(order, orderExtension);
  238 + payNotifyCoreService.createPayNotifyTask(PayNotifyTaskCreateReqDTO.builder()
  239 + .type(PayNotifyTypeEnum.ORDER.getType()).dataId(order.getId()).build());
231 240 }
232 241  
233 242 }
... ...
yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiAccessLogCoreServiceTest.java
... ... @@ -5,14 +5,13 @@ import cn.iocoder.yudao.coreservice.BaseDbUnitTest;
5 5 import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
6 6 import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiAccessLogCoreMapper;
7 7 import cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl.InfApiAccessLogCoreServiceImpl;
8   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO;
  8 +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO;
9 9 import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
10 10 import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
11 11 import org.junit.jupiter.api.Test;
12 12 import org.springframework.context.annotation.Import;
13 13  
14 14 import javax.annotation.Resource;
15   -import java.util.concurrent.Future;
16 15  
17 16 import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
18 17 import static org.junit.jupiter.api.Assertions.assertNotNull;
... ... @@ -32,7 +31,7 @@ public class InfApiAccessLogCoreServiceTest extends BaseDbUnitTest {
32 31 @Test
33 32 public void testCreateApiAccessLogAsync() {
34 33 // 准备参数
35   - ApiAccessLogCreateDTO createDTO = RandomUtils.randomPojo(ApiAccessLogCreateDTO.class,
  34 + ApiAccessLogCreateReqDTO createDTO = RandomUtils.randomPojo(ApiAccessLogCreateReqDTO.class,
36 35 dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()));
37 36  
38 37 // 调用
... ...
yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiErrorLogCoreServiceTest.java
... ... @@ -5,7 +5,7 @@ import cn.iocoder.yudao.coreservice.BaseDbUnitTest;
5 5 import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO;
6 6 import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiErrorLogCoreMapper;
7 7 import cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl.InfApiErrorLogCoreServiceImpl;
8   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO;
  8 +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO;
9 9 import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
10 10 import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
11 11 import org.junit.jupiter.api.Test;
... ... @@ -31,7 +31,7 @@ public class InfApiErrorLogCoreServiceTest extends BaseDbUnitTest {
31 31 @Test
32 32 public void testCreateApiErrorLogAsync() {
33 33 // 准备参数
34   - ApiErrorLogCreateDTO createDTO = RandomUtils.randomPojo(ApiErrorLogCreateDTO.class,
  34 + ApiErrorLogCreateReqDTO createDTO = RandomUtils.randomPojo(ApiErrorLogCreateReqDTO.class,
35 35 dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()));
36 36  
37 37 // 调用
... ...
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/PayOrderNotifyRespDTO.java
1 1 package cn.iocoder.yudao.framework.pay.core.client.dto;
2 2  
3 3 import lombok.AllArgsConstructor;
  4 +import lombok.Builder;
4 5 import lombok.Data;
5 6 import lombok.NoArgsConstructor;
6 7  
... ... @@ -12,6 +13,7 @@ import java.util.Date;
12 13 * @author 芋道源码
13 14 */
14 15 @Data
  16 +@Builder
15 17 @NoArgsConstructor
16 18 @AllArgsConstructor
17 19 public class PayOrderNotifyRespDTO {
... ... @@ -21,11 +23,15 @@ public class PayOrderNotifyRespDTO {
21 23 */
22 24 private String orderExtensionNo;
23 25 /**
24   - * 支付渠道
  26 + * 支付渠道编号
25 27 */
26 28 private String channelOrderNo;
27 29 /**
28   - * 支付渠道
  30 + * 支付渠道用户编号
  31 + */
  32 + private String channelUserId;
  33 + /**
  34 + * 支付成功时间
29 35 */
30 36 private Date successTime;
31 37  
... ...
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/wx/WXPubPayClient.java
... ... @@ -122,7 +122,6 @@ public class WXPubPayClient extends AbstractPayClient&lt;WXPayClientConfig&gt; {
122 122 return client.createOrderV3(TradeTypeEnum.JSAPI, request);
123 123 }
124 124  
125   -
126 125 private static String getOpenid(PayOrderUnifiedReqDTO reqDTO) {
127 126 String openid = MapUtil.getStr(reqDTO.getChannelExtras(), "openid");
128 127 if (StrUtil.isEmpty(openid)) {
... ... @@ -136,8 +135,10 @@ public class WXPubPayClient extends AbstractPayClient&lt;WXPayClientConfig&gt; {
136 135 WxPayOrderNotifyResult notifyResult = client.parseOrderNotifyResult(data);
137 136 Assert.isTrue(Objects.equals(notifyResult.getResultCode(), "SUCCESS"), "支付结果非 SUCCESS");
138 137 // 转换结果
139   - return new PayOrderNotifyRespDTO(notifyResult.getOutTradeNo(), notifyResult.getTransactionId(),
140   - DateUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss"), data);
  138 + return PayOrderNotifyRespDTO.builder().orderExtensionNo(notifyResult.getOutTradeNo())
  139 + .channelOrderNo(notifyResult.getTransactionId()).channelUserId(notifyResult.getOpenid())
  140 + .successTime(DateUtil.parse(notifyResult.getTimeEnd(), "yyyyMMddHHmmss"))
  141 + .data(data).build();
141 142 }
142 143  
143 144 }
... ...
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java
... ... @@ -6,7 +6,7 @@ import cn.hutool.extra.servlet.ServletUtil;
6 6 import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
7 7 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
8 8 import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
9   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO;
  9 +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO;
10 10 import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
11 11 import cn.iocoder.yudao.framework.web.config.WebProperties;
12 12 import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
... ... @@ -68,7 +68,7 @@ public class ApiAccessLogFilter extends OncePerRequestFilter {
68 68  
69 69 private void createApiAccessLog(HttpServletRequest request, Date beginTime,
70 70 Map<String, String> queryString, String requestBody, Exception ex) {
71   - ApiAccessLogCreateDTO accessLog = new ApiAccessLogCreateDTO();
  71 + ApiAccessLogCreateReqDTO accessLog = new ApiAccessLogCreateReqDTO();
72 72 try {
73 73 this.buildApiAccessLogDTO(accessLog, request, beginTime, queryString, requestBody, ex);
74 74 apiAccessLogFrameworkService.createApiAccessLogAsync(accessLog);
... ... @@ -77,7 +77,7 @@ public class ApiAccessLogFilter extends OncePerRequestFilter {
77 77 }
78 78 }
79 79  
80   - private void buildApiAccessLogDTO(ApiAccessLogCreateDTO accessLog, HttpServletRequest request, Date beginTime,
  80 + private void buildApiAccessLogDTO(ApiAccessLogCreateReqDTO accessLog, HttpServletRequest request, Date beginTime,
81 81 Map<String, String> queryString, String requestBody, Exception ex) {
82 82 // 处理用户信息
83 83 accessLog.setUserId(WebFrameworkUtils.getLoginUserId(request));
... ...
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java
1 1 package cn.iocoder.yudao.framework.apilog.core.service;
2 2  
3   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO;
  3 +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO;
4 4  
5 5 import javax.validation.Valid;
6   -import java.util.concurrent.Future;
7 6  
8 7 /**
9 8 * API 访问日志 Framework Service 接口
... ... @@ -17,6 +16,6 @@ public interface ApiAccessLogFrameworkService {
17 16 *
18 17 * @param createDTO 创建信息
19 18 */
20   - void createApiAccessLogAsync(@Valid ApiAccessLogCreateDTO createDTO);
  19 + void createApiAccessLogAsync(@Valid ApiAccessLogCreateReqDTO createDTO);
21 20  
22 21 }
... ...
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java
1 1 package cn.iocoder.yudao.framework.apilog.core.service;
2 2  
3   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO;
  3 +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO;
4 4  
5 5 import javax.validation.Valid;
6   -import java.util.concurrent.Future;
7 6  
8 7 /**
9 8 * API 错误日志 Framework Service 接口
... ... @@ -17,6 +16,6 @@ public interface ApiErrorLogFrameworkService {
17 16 *
18 17 * @param createDTO 创建信息
19 18 */
20   - void createApiErrorLogAsync(@Valid ApiErrorLogCreateDTO createDTO);
  19 + void createApiErrorLogAsync(@Valid ApiErrorLogCreateReqDTO createDTO);
21 20  
22 21 }
... ...
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiAccessLogCreateDTO.java renamed to yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiAccessLogCreateReqDTO.java
... ... @@ -11,7 +11,7 @@ import java.util.Date;
11 11 * @author 芋道源码
12 12 */
13 13 @Data
14   -public class ApiAccessLogCreateDTO {
  14 +public class ApiAccessLogCreateReqDTO {
15 15  
16 16 /**
17 17 * 链路追踪编号
... ...
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiErrorLogCreateDTO.java renamed to yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/dto/ApiErrorLogCreateReqDTO.java
... ... @@ -13,7 +13,7 @@ import java.util.Date;
13 13 */
14 14 @Data
15 15 @Accessors(chain = true)
16   -public class ApiErrorLogCreateDTO {
  16 +public class ApiErrorLogCreateReqDTO {
17 17  
18 18 /**
19 19 * 链路编号
... ...
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
... ... @@ -6,7 +6,7 @@ import cn.hutool.extra.servlet.ServletUtil;
6 6 import cn.iocoder.yudao.framework.common.exception.ServiceException;
7 7 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
8 8 import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService;
9   -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO;
  9 +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO;
10 10 import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
11 11 import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
12 12 import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
... ... @@ -15,7 +15,6 @@ import io.github.resilience4j.ratelimiter.RequestNotPermitted;
15 15 import lombok.AllArgsConstructor;
16 16 import lombok.extern.slf4j.Slf4j;
17 17 import org.apache.commons.lang3.exception.ExceptionUtils;
18   -import org.springframework.beans.factory.annotation.Value;
19 18 import org.springframework.security.access.AccessDeniedException;
20 19 import org.springframework.util.Assert;
21 20 import org.springframework.validation.BindException;
... ... @@ -28,7 +27,6 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
28 27 import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
29 28 import org.springframework.web.servlet.NoHandlerFoundException;
30 29  
31   -import javax.annotation.Resource;
32 30 import javax.servlet.http.HttpServletRequest;
33 31 import javax.validation.ConstraintViolation;
34 32 import javax.validation.ConstraintViolationException;
... ... @@ -231,7 +229,7 @@ public class GlobalExceptionHandler {
231 229  
232 230 private void createExceptionLog(HttpServletRequest req, Throwable e) {
233 231 // 插入错误日志
234   - ApiErrorLogCreateDTO errorLog = new ApiErrorLogCreateDTO();
  232 + ApiErrorLogCreateReqDTO errorLog = new ApiErrorLogCreateReqDTO();
235 233 try {
236 234 // 初始化 errorLog
237 235 initExceptionLog(errorLog, req, e);
... ... @@ -242,7 +240,7 @@ public class GlobalExceptionHandler {
242 240 }
243 241 }
244 242  
245   - private void initExceptionLog(ApiErrorLogCreateDTO errorLog, HttpServletRequest request, Throwable e) {
  243 + private void initExceptionLog(ApiErrorLogCreateReqDTO errorLog, HttpServletRequest request, Throwable e) {
246 244 // 处理用户信息
247 245 errorLog.setUserId(WebFrameworkUtils.getLoginUserId(request));
248 246 errorLog.setUserType(WebFrameworkUtils.getLoginUserType(request));
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java
... ... @@ -6,6 +6,7 @@ import cn.iocoder.yudao.coreservice.modules.pay.service.order.PayOrderCoreServic
6 6 import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderSubmitReqDTO;
7 7 import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderSubmitRespDTO;
8 8 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  9 +import cn.iocoder.yudao.framework.pay.core.enums.PayChannelEnum;
9 10 import cn.iocoder.yudao.userserver.modules.pay.controller.order.vo.PayOrderSubmitReqVO;
10 11 import cn.iocoder.yudao.userserver.modules.pay.controller.order.vo.PayOrderSubmitRespVO;
11 12 import io.swagger.annotations.Api;
... ... @@ -52,8 +53,8 @@ public class PayOrderController {
52 53 @PostMapping("/notify/wx-pub/{channelId}")
53 54 @ApiOperation("通知微信公众号的结果")
54 55 public String notifyWxPayOrder(@PathVariable("channelId") Long channelId,
55   - @RequestBody String xmlData) {
56   - System.out.println(xmlData);
  56 + @RequestBody String xmlData) throws Exception {
  57 + payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.WX_PUB.getCode(), xmlData);
57 58 return "success";
58 59 }
59 60  
... ...