Commit a93b9a616f089e5707a881eb63ed380f363e3be0
1 parent
7d0e9ea7
售后日志优化
Showing
17 changed files
with
124 additions
and
201 deletions
yudao-dependencies/pom.xml
| @@ -98,11 +98,6 @@ | @@ -98,11 +98,6 @@ | ||
| 98 | </dependency> | 98 | </dependency> |
| 99 | <dependency> | 99 | <dependency> |
| 100 | <groupId>cn.iocoder.boot</groupId> | 100 | <groupId>cn.iocoder.boot</groupId> |
| 101 | - <artifactId>yudao-spring-boot-starter-biz-trade</artifactId> | ||
| 102 | - <version>${revision}</version> | ||
| 103 | - </dependency> | ||
| 104 | - <dependency> | ||
| 105 | - <groupId>cn.iocoder.boot</groupId> | ||
| 106 | <artifactId>yudao-spring-boot-starter-biz-dict</artifactId> | 101 | <artifactId>yudao-spring-boot-starter-biz-dict</artifactId> |
| 107 | <version>${revision}</version> | 102 | <version>${revision}</version> |
| 108 | </dependency> | 103 | </dependency> |
yudao-framework/pom.xml
| @@ -31,7 +31,6 @@ | @@ -31,7 +31,6 @@ | ||
| 31 | <module>yudao-spring-boot-starter-biz-sms</module> | 31 | <module>yudao-spring-boot-starter-biz-sms</module> |
| 32 | 32 | ||
| 33 | <module>yudao-spring-boot-starter-biz-pay</module> | 33 | <module>yudao-spring-boot-starter-biz-pay</module> |
| 34 | - <module>yudao-spring-boot-starter-biz-trade</module> | ||
| 35 | <module>yudao-spring-boot-starter-biz-weixin</module> | 34 | <module>yudao-spring-boot-starter-biz-weixin</module> |
| 36 | <module>yudao-spring-boot-starter-biz-social</module> | 35 | <module>yudao-spring-boot-starter-biz-social</module> |
| 37 | <module>yudao-spring-boot-starter-biz-tenant</module> | 36 | <module>yudao-spring-boot-starter-biz-tenant</module> |
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/spel/SpelUtil.java deleted
| 1 | -package cn.iocoder.yudao.framework.common.util.spel; | ||
| 2 | - | ||
| 3 | -import org.aspectj.lang.JoinPoint; | ||
| 4 | -import org.aspectj.lang.reflect.MethodSignature; | ||
| 5 | -import org.springframework.core.DefaultParameterNameDiscoverer; | ||
| 6 | -import org.springframework.expression.EvaluationContext; | ||
| 7 | -import org.springframework.expression.spel.standard.SpelExpressionParser; | ||
| 8 | -import org.springframework.expression.spel.support.StandardEvaluationContext; | ||
| 9 | - | ||
| 10 | -// TODO @Chopper:和 SpringExpressionUtils 合并下 | ||
| 11 | -/** | ||
| 12 | - * SpelUtil | ||
| 13 | - * | ||
| 14 | - * @author Chopper | ||
| 15 | - * @version v1.0 | ||
| 16 | - * @since 2021-01-11 10:45 | ||
| 17 | - */ | ||
| 18 | -public class SpelUtil { | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - /** | ||
| 22 | - * spel表达式解析器 | ||
| 23 | - */ | ||
| 24 | - private static SpelExpressionParser spelExpressionParser = new SpelExpressionParser(); | ||
| 25 | - /** | ||
| 26 | - * 参数名发现器 | ||
| 27 | - */ | ||
| 28 | - private static DefaultParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer(); | ||
| 29 | - | ||
| 30 | - /** | ||
| 31 | - * 转换 jspl参数 | ||
| 32 | - * | ||
| 33 | - * @param joinPoint | ||
| 34 | - * @param spel | ||
| 35 | - * @return | ||
| 36 | - */ | ||
| 37 | - public static String compileParams(JoinPoint joinPoint, String spel) { //Spel表达式解析日志信息 | ||
| 38 | - //获得方法参数名数组 | ||
| 39 | - MethodSignature signature = (MethodSignature) joinPoint.getSignature(); | ||
| 40 | - | ||
| 41 | - String[] parameterNames = parameterNameDiscoverer.getParameterNames(signature.getMethod()); | ||
| 42 | - if (parameterNames != null && parameterNames.length > 0) { | ||
| 43 | - EvaluationContext context = new StandardEvaluationContext(); | ||
| 44 | - | ||
| 45 | - //获取方法参数值 | ||
| 46 | - Object[] args = joinPoint.getArgs(); | ||
| 47 | - for (int i = 0; i < args.length; i++) { | ||
| 48 | - //替换spel里的变量值为实际值, 比如 #user --> user对象 | ||
| 49 | - context.setVariable(parameterNames[i], args[i]); | ||
| 50 | - } | ||
| 51 | - return spelExpressionParser.parseExpression(spel).getValue(context).toString(); | ||
| 52 | - } | ||
| 53 | - return ""; | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - /** | ||
| 57 | - * 转换 jspl参数 | ||
| 58 | - * | ||
| 59 | - * @param joinPoint | ||
| 60 | - * @param spel | ||
| 61 | - * @return | ||
| 62 | - */ | ||
| 63 | - public static String compileParams(JoinPoint joinPoint, Object rvt, String spel) { //Spel表达式解析日志信息 | ||
| 64 | - //获得方法参数名数组 | ||
| 65 | - MethodSignature signature = (MethodSignature) joinPoint.getSignature(); | ||
| 66 | - | ||
| 67 | - String[] parameterNames = parameterNameDiscoverer.getParameterNames(signature.getMethod()); | ||
| 68 | - if (parameterNames != null && parameterNames.length > 0) { | ||
| 69 | - EvaluationContext context = new StandardEvaluationContext(); | ||
| 70 | - | ||
| 71 | - //获取方法参数值 | ||
| 72 | - Object[] args = joinPoint.getArgs(); | ||
| 73 | - for (int i = 0; i < args.length; i++) { | ||
| 74 | - //替换spel里的变量值为实际值, 比如 #user --> user对象 | ||
| 75 | - context.setVariable(parameterNames[i], args[i]); | ||
| 76 | - } | ||
| 77 | - context.setVariable("rvt", rvt); | ||
| 78 | - return spelExpressionParser.parseExpression(spel).getValue(context).toString(); | ||
| 79 | - } | ||
| 80 | - return ""; | ||
| 81 | - } | ||
| 82 | -} |
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/spring/SpringExpressionUtils.java
| @@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.common.util.spring; | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.common.util.spring; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.map.MapUtil; | 4 | import cn.hutool.core.map.MapUtil; |
| 5 | import cn.hutool.core.util.ArrayUtil; | 5 | import cn.hutool.core.util.ArrayUtil; |
| 6 | +import org.aspectj.lang.JoinPoint; | ||
| 6 | import org.aspectj.lang.ProceedingJoinPoint; | 7 | import org.aspectj.lang.ProceedingJoinPoint; |
| 7 | import org.aspectj.lang.reflect.MethodSignature; | 8 | import org.aspectj.lang.reflect.MethodSignature; |
| 8 | import org.springframework.core.DefaultParameterNameDiscoverer; | 9 | import org.springframework.core.DefaultParameterNameDiscoverer; |
| @@ -24,7 +25,15 @@ import java.util.Map; | @@ -24,7 +25,15 @@ import java.util.Map; | ||
| 24 | */ | 25 | */ |
| 25 | public class SpringExpressionUtils { | 26 | public class SpringExpressionUtils { |
| 26 | 27 | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * spel表达式解析器 | ||
| 32 | + */ | ||
| 27 | private static final ExpressionParser EXPRESSION_PARSER = new SpelExpressionParser(); | 33 | private static final ExpressionParser EXPRESSION_PARSER = new SpelExpressionParser(); |
| 34 | + /** | ||
| 35 | + * 参数名发现器 | ||
| 36 | + */ | ||
| 28 | private static final ParameterNameDiscoverer PARAMETER_NAME_DISCOVERER = new DefaultParameterNameDiscoverer(); | 37 | private static final ParameterNameDiscoverer PARAMETER_NAME_DISCOVERER = new DefaultParameterNameDiscoverer(); |
| 29 | 38 | ||
| 30 | private SpringExpressionUtils() { | 39 | private SpringExpressionUtils() { |
| @@ -33,7 +42,7 @@ public class SpringExpressionUtils { | @@ -33,7 +42,7 @@ public class SpringExpressionUtils { | ||
| 33 | /** | 42 | /** |
| 34 | * 从切面中,单个解析 EL 表达式的结果 | 43 | * 从切面中,单个解析 EL 表达式的结果 |
| 35 | * | 44 | * |
| 36 | - * @param joinPoint 切面点 | 45 | + * @param joinPoint 切面点 |
| 37 | * @param expressionString EL 表达式数组 | 46 | * @param expressionString EL 表达式数组 |
| 38 | * @return 执行界面 | 47 | * @return 执行界面 |
| 39 | */ | 48 | */ |
| @@ -45,7 +54,7 @@ public class SpringExpressionUtils { | @@ -45,7 +54,7 @@ public class SpringExpressionUtils { | ||
| 45 | /** | 54 | /** |
| 46 | * 从切面中,批量解析 EL 表达式的结果 | 55 | * 从切面中,批量解析 EL 表达式的结果 |
| 47 | * | 56 | * |
| 48 | - * @param joinPoint 切面点 | 57 | + * @param joinPoint 切面点 |
| 49 | * @param expressionStrings EL 表达式数组 | 58 | * @param expressionStrings EL 表达式数组 |
| 50 | * @return 结果,key 为表达式,value 为对应值 | 59 | * @return 结果,key 为表达式,value 为对应值 |
| 51 | */ | 60 | */ |
| @@ -79,4 +88,47 @@ public class SpringExpressionUtils { | @@ -79,4 +88,47 @@ public class SpringExpressionUtils { | ||
| 79 | }); | 88 | }); |
| 80 | return result; | 89 | return result; |
| 81 | } | 90 | } |
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * JoinPoint 切面 批量解析 EL 表达式,转换 jspl参数 | ||
| 94 | + * | ||
| 95 | + * @param joinPoint 切面点 | ||
| 96 | + * @param rvt 返回值 | ||
| 97 | + * @param expressionStrings EL 表达式数组 | ||
| 98 | + * @return java.lang.String 结果 | ||
| 99 | + * @author 陈賝 | ||
| 100 | + * @since 2023/6/18 11:20 | ||
| 101 | + */ | ||
| 102 | + public static Map<String, Object> parseExpression(JoinPoint joinPoint, Object rvt, List<String> expressionStrings) { | ||
| 103 | + // 如果为空,则不进行解析 | ||
| 104 | + if (CollUtil.isEmpty(expressionStrings)) { | ||
| 105 | + return MapUtil.newHashMap(); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + // 第一步,构建解析的上下文 EvaluationContext | ||
| 109 | + // 通过 joinPoint 获取被注解方法 | ||
| 110 | + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); | ||
| 111 | + Method method = signature.getMethod(); | ||
| 112 | + // 使用 spring 的 ParameterNameDiscoverer 获取方法形参名数组 | ||
| 113 | + String[] parameterNames = PARAMETER_NAME_DISCOVERER.getParameterNames(method); | ||
| 114 | + // Spring 的表达式上下文对象 | ||
| 115 | + EvaluationContext context = new StandardEvaluationContext(); | ||
| 116 | + if (ArrayUtil.isNotEmpty(parameterNames)) { | ||
| 117 | + //获取方法参数值 | ||
| 118 | + Object[] args = joinPoint.getArgs(); | ||
| 119 | + for (int i = 0; i < args.length; i++) { | ||
| 120 | + //替换spel里的变量值为实际值, 比如 #user --> user对象 | ||
| 121 | + context.setVariable(parameterNames[i], args[i]); | ||
| 122 | + } | ||
| 123 | + context.setVariable("rvt", rvt); | ||
| 124 | + } | ||
| 125 | + // 第二步,逐个参数解析 | ||
| 126 | + Map<String, Object> result = MapUtil.newHashMap(expressionStrings.size(), true); | ||
| 127 | + expressionStrings.forEach(key -> { | ||
| 128 | + Object value = EXPRESSION_PARSER.parseExpression(key).getValue(context); | ||
| 129 | + result.put(key, value); | ||
| 130 | + }); | ||
| 131 | + return result; | ||
| 132 | + } | ||
| 133 | + | ||
| 82 | } | 134 | } |
yudao-framework/yudao-spring-boot-starter-biz-trade/pom.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 4 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 5 | - <parent> | ||
| 6 | - <groupId>cn.iocoder.boot</groupId> | ||
| 7 | - <artifactId>yudao-framework</artifactId> | ||
| 8 | - <version>${revision}</version> | ||
| 9 | - </parent> | ||
| 10 | - <modelVersion>4.0.0</modelVersion> | ||
| 11 | - <artifactId>yudao-spring-boot-starter-biz-trade</artifactId> | ||
| 12 | - <packaging>jar</packaging> | ||
| 13 | - | ||
| 14 | - <name>${project.artifactId}</name> | ||
| 15 | - <description>交易模块</description> | ||
| 16 | - <url>https://github.com/YunaiV/ruoyi-vue-pro</url> | ||
| 17 | - | ||
| 18 | - <dependencies> | ||
| 19 | - <dependency> | ||
| 20 | - <groupId>cn.iocoder.boot</groupId> | ||
| 21 | - <artifactId>yudao-common</artifactId> | ||
| 22 | - </dependency> | ||
| 23 | - | ||
| 24 | - <!-- Spring 核心 --> | ||
| 25 | - <dependency> | ||
| 26 | - <groupId>org.springframework.boot</groupId> | ||
| 27 | - <artifactId>spring-boot-starter-aop</artifactId> | ||
| 28 | - </dependency> | ||
| 29 | - | ||
| 30 | - <!-- Web 相关 --> | ||
| 31 | - <dependency> | ||
| 32 | - <groupId>cn.iocoder.boot</groupId> | ||
| 33 | - <artifactId>yudao-spring-boot-starter-web</artifactId> | ||
| 34 | - <scope>provided</scope> | ||
| 35 | - </dependency> | ||
| 36 | - | ||
| 37 | - <!-- 业务组件 --> | ||
| 38 | - <dependency> | ||
| 39 | - <groupId>cn.iocoder.boot</groupId> | ||
| 40 | - <artifactId>yudao-module-system-api</artifactId> <!-- 需要使用它,进行操作日志的记录 --> | ||
| 41 | - <version>${revision}</version> | ||
| 42 | - </dependency> | ||
| 43 | - | ||
| 44 | - <!-- 工具类相关 --> | ||
| 45 | - <dependency> | ||
| 46 | - <groupId>com.google.guava</groupId> | ||
| 47 | - <artifactId>guava</artifactId> | ||
| 48 | - </dependency> | ||
| 49 | - </dependencies> | ||
| 50 | -</project> |
yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted
| 1 | -cn.iocoder.yudao.framework.trade.config.YudaoAfterSaleLogAutoConfiguration |
yudao-module-mall/yudao-module-trade-biz/pom.xml
| @@ -58,10 +58,6 @@ | @@ -58,10 +58,6 @@ | ||
| 58 | <groupId>cn.iocoder.boot</groupId> | 58 | <groupId>cn.iocoder.boot</groupId> |
| 59 | <artifactId>yudao-spring-boot-starter-biz-ip</artifactId> | 59 | <artifactId>yudao-spring-boot-starter-biz-ip</artifactId> |
| 60 | </dependency> | 60 | </dependency> |
| 61 | - <dependency> | ||
| 62 | - <groupId>cn.iocoder.boot</groupId> | ||
| 63 | - <artifactId>yudao-spring-boot-starter-biz-trade</artifactId> | ||
| 64 | - </dependency> | ||
| 65 | 61 | ||
| 66 | <!-- Web 相关 --> | 62 | <!-- Web 相关 --> |
| 67 | <dependency> | 63 | <dependency> |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java
| @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.trade.controller.admin.aftersale; | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.trade.controller.admin.aftersale; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.framework.trade.core.annotations.AfterSaleLog; | ||
| 7 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; | 6 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; |
| 8 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | 7 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 9 | import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi; | 8 | import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi; |
| @@ -15,6 +14,8 @@ import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSal | @@ -15,6 +14,8 @@ import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSal | ||
| 15 | import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; | 14 | import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; |
| 16 | import cn.iocoder.yudao.module.trade.convert.aftersale.TradeAfterSaleConvert; | 15 | import cn.iocoder.yudao.module.trade.convert.aftersale.TradeAfterSaleConvert; |
| 17 | import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; | 16 | import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; |
| 17 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog; | ||
| 18 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.enums.AfterSaleStatusEnum; | ||
| 18 | import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService; | 19 | import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService; |
| 19 | import io.swagger.v3.oas.annotations.Operation; | 20 | import io.swagger.v3.oas.annotations.Operation; |
| 20 | import io.swagger.v3.oas.annotations.Parameter; | 21 | import io.swagger.v3.oas.annotations.Parameter; |
| @@ -122,7 +123,7 @@ public class TradeAfterSaleController { | @@ -122,7 +123,7 @@ public class TradeAfterSaleController { | ||
| 122 | * @date 2023/6/14 21:39 | 123 | * @date 2023/6/14 21:39 |
| 123 | */ | 124 | */ |
| 124 | @PostMapping(value = "/create") | 125 | @PostMapping(value = "/create") |
| 125 | - @AfterSaleLog(id = "#createReqVO.orderItemId", content = "'申请售后:售后编号['+#createReqVO.orderItemId+'] , '", operateType = "#createReqVO.operateType") | 126 | + @AfterSaleLog(id = "#createReqVO.orderItemId", content = "'申请售后:售后编号['+#createReqVO.orderItemId+'] , '", operateType = AfterSaleStatusEnum.APPLY) |
| 126 | public CommonResult<Long> createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) { | 127 | public CommonResult<Long> createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) { |
| 127 | return success(1L); | 128 | return success(1L); |
| 128 | // return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO)); | 129 | // return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO)); |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/vo/AppTradeAfterSaleCreateReqVO.java
| 1 | package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; | 1 | package cn.iocoder.yudao.module.trade.controller.app.aftersale.vo; |
| 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.framework.trade.core.enums.AfterSaleStatusEnum; | ||
| 5 | import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; | 4 | import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; |
| 6 | import io.swagger.v3.oas.annotations.media.Schema; | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 7 | import lombok.Data; | 6 | import lombok.Data; |
| @@ -32,14 +31,6 @@ public class AppTradeAfterSaleCreateReqVO { | @@ -32,14 +31,6 @@ public class AppTradeAfterSaleCreateReqVO { | ||
| 32 | @NotNull(message = "申请原因不能为空") | 31 | @NotNull(message = "申请原因不能为空") |
| 33 | private String applyReason; | 32 | private String applyReason; |
| 34 | 33 | ||
| 35 | - // TODO @陈賝:这个参数不应该有呀。 | ||
| 36 | - /** | ||
| 37 | - * @see AfterSaleStatusEnum | ||
| 38 | - */ | ||
| 39 | - @Schema(description = "操作类型", required = true, example = "1") | ||
| 40 | - @NotNull(message = "操作类型不能为空") | ||
| 41 | - private String operateType; | ||
| 42 | - | ||
| 43 | @Schema(description = "补充描述", example = "商品质量不好") | 34 | @Schema(description = "补充描述", example = "商品质量不好") |
| 44 | private String applyDescription; | 35 | private String applyDescription; |
| 45 | 36 |
yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/java/cn/iocoder/yudao/framework/trade/config/YudaoAfterSaleLogAutoConfiguration.java renamed to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/config/AfterSaleLogConfiguration.java
| 1 | -package cn.iocoder.yudao.framework.trade.config; | 1 | +package cn.iocoder.yudao.module.trade.framework.aftersalelog.config; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.trade.core.aop.AfterSaleLogAspect; | 3 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop.AfterSaleLogAspect; |
| 4 | import org.springframework.boot.autoconfigure.AutoConfiguration; | 4 | import org.springframework.boot.autoconfigure.AutoConfiguration; |
| 5 | import org.springframework.context.annotation.Bean; | 5 | import org.springframework.context.annotation.Bean; |
| 6 | 6 | ||
| 7 | -// TODO @Chopper:和 yudao-module-trade-biz 的 framework 里 | 7 | +/** |
| 8 | + * trade 模块的 afterSaleLog 组件的 Configuration | ||
| 9 | + * | ||
| 10 | + * @author 陈賝 | ||
| 11 | + * @since 2023/6/18 11:09 | ||
| 12 | + */ | ||
| 8 | @AutoConfiguration | 13 | @AutoConfiguration |
| 9 | -public class YudaoAfterSaleLogAutoConfiguration { | 14 | +public class AfterSaleLogConfiguration { |
| 10 | 15 | ||
| 11 | @Bean | 16 | @Bean |
| 12 | public AfterSaleLogAspect afterSaleLogAspect() { | 17 | public AfterSaleLogAspect afterSaleLogAspect() { |
yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/java/cn/iocoder/yudao/framework/trade/core/annotations/AfterSaleLog.java renamed to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/annotations/AfterSaleLog.java
| 1 | -package cn.iocoder.yudao.framework.trade.core.annotations; | 1 | +package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations; |
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.enums.AfterSaleStatusEnum; | ||
| 2 | 4 | ||
| 3 | import java.lang.annotation.*; | 5 | import java.lang.annotation.*; |
| 4 | 6 | ||
| @@ -18,11 +20,10 @@ public @interface AfterSaleLog { | @@ -18,11 +20,10 @@ public @interface AfterSaleLog { | ||
| 18 | */ | 20 | */ |
| 19 | String id(); | 21 | String id(); |
| 20 | 22 | ||
| 21 | - // TODO @陈賝:是不是改成一个操作的枚举? | ||
| 22 | /** | 23 | /** |
| 23 | * 操作类型 | 24 | * 操作类型 |
| 24 | */ | 25 | */ |
| 25 | - String operateType() default ""; | 26 | + AfterSaleStatusEnum operateType() default AfterSaleStatusEnum.APPLY; |
| 26 | 27 | ||
| 27 | /** | 28 | /** |
| 28 | * 日志内容 | 29 | * 日志内容 |
yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/java/cn/iocoder/yudao/framework/trade/core/aop/AfterSaleLogAspect.java renamed to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/aop/AfterSaleLogAspect.java
| 1 | -package cn.iocoder.yudao.framework.trade.core.aop; | 1 | +package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.util.StrUtil; | ||
| 4 | -import cn.hutool.extra.spring.SpringUtil; | ||
| 5 | -import cn.iocoder.yudao.framework.common.util.spel.SpelUtil; | ||
| 6 | -import cn.iocoder.yudao.framework.trade.core.annotations.AfterSaleLog; | ||
| 7 | -import cn.iocoder.yudao.framework.trade.core.dto.TradeAfterSaleLogCreateReqDTO; | ||
| 8 | -import cn.iocoder.yudao.framework.trade.core.enums.AfterSaleStatusEnum; | ||
| 9 | -import cn.iocoder.yudao.framework.trade.core.service.AfterSaleLogService; | 3 | +import cn.hutool.core.map.MapUtil; |
| 4 | +import cn.hutool.core.util.ObjectUtil; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils; | ||
| 10 | import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; | 6 | import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; |
| 7 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO; | ||
| 8 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog; | ||
| 9 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service.AfterSaleLogService; | ||
| 10 | +import com.google.common.collect.Maps; | ||
| 11 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| 12 | import org.aspectj.lang.JoinPoint; | 12 | import org.aspectj.lang.JoinPoint; |
| 13 | +import org.aspectj.lang.ProceedingJoinPoint; | ||
| 13 | import org.aspectj.lang.annotation.AfterReturning; | 14 | import org.aspectj.lang.annotation.AfterReturning; |
| 14 | import org.aspectj.lang.annotation.Aspect; | 15 | import org.aspectj.lang.annotation.Aspect; |
| 15 | import org.aspectj.lang.reflect.MethodSignature; | 16 | import org.aspectj.lang.reflect.MethodSignature; |
| 16 | 17 | ||
| 18 | +import javax.annotation.Resource; | ||
| 17 | import java.util.HashMap; | 19 | import java.util.HashMap; |
| 18 | import java.util.Map; | 20 | import java.util.Map; |
| 19 | 21 | ||
| 22 | +import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; | ||
| 23 | +import static java.util.Arrays.asList; | ||
| 24 | + | ||
| 20 | /** | 25 | /** |
| 21 | * 记录售后日志的 AOP 切面 | 26 | * 记录售后日志的 AOP 切面 |
| 22 | * | 27 | * |
| @@ -26,6 +31,8 @@ import java.util.Map; | @@ -26,6 +31,8 @@ import java.util.Map; | ||
| 26 | @Slf4j | 31 | @Slf4j |
| 27 | @Aspect | 32 | @Aspect |
| 28 | public class AfterSaleLogAspect { | 33 | public class AfterSaleLogAspect { |
| 34 | + @Resource | ||
| 35 | + private AfterSaleLogService saleLogService; | ||
| 29 | 36 | ||
| 30 | @AfterReturning(pointcut = "@annotation(afterSaleLog)", returning = "info") | 37 | @AfterReturning(pointcut = "@annotation(afterSaleLog)", returning = "info") |
| 31 | public void doAfterReturning(JoinPoint joinPoint, AfterSaleLog afterSaleLog, Object info) { | 38 | public void doAfterReturning(JoinPoint joinPoint, AfterSaleLog afterSaleLog, Object info) { |
| @@ -36,15 +43,13 @@ public class AfterSaleLogAspect { | @@ -36,15 +43,13 @@ public class AfterSaleLogAspect { | ||
| 36 | Map<String, String> formatObj = spelFormat(joinPoint, info); | 43 | Map<String, String> formatObj = spelFormat(joinPoint, info); |
| 37 | TradeAfterSaleLogCreateReqDTO dto = new TradeAfterSaleLogCreateReqDTO() | 44 | TradeAfterSaleLogCreateReqDTO dto = new TradeAfterSaleLogCreateReqDTO() |
| 38 | .setUserId(id).setUserType(userType) | 45 | .setUserId(id).setUserType(userType) |
| 39 | -// MapUtil.getLong() TODO @陈賝:试试这个方法 | ||
| 40 | - .setAfterSaleId(Long.valueOf(formatObj.get("id"))) | 46 | + .setAfterSaleId(MapUtil.getLong(formatObj, "id")) |
| 41 | .setContent(formatObj.get("content")) | 47 | .setContent(formatObj.get("content")) |
| 42 | .setOperateType(formatObj.get("operateType")); | 48 | .setOperateType(formatObj.get("operateType")); |
| 43 | - // 异步存入数据库 TODO 可以注入哈; | ||
| 44 | - SpringUtil.getBean(AfterSaleLogService.class).insert(dto); | 49 | + // 异步存入数据库 |
| 50 | + saleLogService.createLog(dto); | ||
| 45 | } catch (Exception exception) { | 51 | } catch (Exception exception) { |
| 46 | - // TODO @陈賝:日志要记录下参数哈,不然排查问题不好搞; | ||
| 47 | - log.error("日志记录错误", exception); | 52 | + log.error("[afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception); |
| 48 | } | 53 | } |
| 49 | } | 54 | } |
| 50 | 55 | ||
| @@ -54,17 +59,19 @@ public class AfterSaleLogAspect { | @@ -54,17 +59,19 @@ public class AfterSaleLogAspect { | ||
| 54 | public static Map<String, String> spelFormat(JoinPoint joinPoint, Object info) { | 59 | public static Map<String, String> spelFormat(JoinPoint joinPoint, Object info) { |
| 55 | MethodSignature signature = (MethodSignature) joinPoint.getSignature(); | 60 | MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
| 56 | AfterSaleLog afterSaleLogPoint = signature.getMethod().getAnnotation(AfterSaleLog.class); | 61 | AfterSaleLog afterSaleLogPoint = signature.getMethod().getAnnotation(AfterSaleLog.class); |
| 57 | - Map<String, String> result = new HashMap<>(2); // TODO @陈賝:Maps.newExpectedXXX(3) | 62 | + HashMap<String, String> result = Maps.newHashMapWithExpectedSize(3); |
| 63 | + Map<String, Object> spelMap = SpringExpressionUtils.parseExpression(joinPoint, info, | ||
| 64 | + asList(afterSaleLogPoint.id(), afterSaleLogPoint.operateType().description(), afterSaleLogPoint.content())); | ||
| 58 | // 售后ID | 65 | // 售后ID |
| 59 | - String id = SpelUtil.compileParams(joinPoint, info, afterSaleLogPoint.id()); | 66 | + String id = MapUtil.getStr(spelMap, afterSaleLogPoint.id()); |
| 60 | result.put("id", id); | 67 | result.put("id", id); |
| 61 | // 操作类型 | 68 | // 操作类型 |
| 62 | - String operateType = SpelUtil.compileParams(joinPoint, info, afterSaleLogPoint.operateType()); | 69 | + String operateType = MapUtil.getStr(spelMap, afterSaleLogPoint.operateType().description()); |
| 63 | result.put("operateType", operateType); | 70 | result.put("operateType", operateType); |
| 64 | // 日志内容 | 71 | // 日志内容 |
| 65 | - String content = SpelUtil.compileParams(joinPoint, info, afterSaleLogPoint.content()); | ||
| 66 | - if (StrUtil.isNotEmpty(afterSaleLogPoint.operateType())) { | ||
| 67 | - content += AfterSaleStatusEnum.valueOf(SpelUtil.compileParams(joinPoint, info, afterSaleLogPoint.operateType())).description(); | 72 | + String content = MapUtil.getStr(spelMap, afterSaleLogPoint.content()); |
| 73 | + if (ObjectUtil.isNotNull(afterSaleLogPoint.operateType())) { | ||
| 74 | + content += MapUtil.getStr(spelMap, afterSaleLogPoint.operateType().description()); | ||
| 68 | } | 75 | } |
| 69 | result.put("content", content); | 76 | result.put("content", content); |
| 70 | return result; | 77 | return result; |
yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/java/cn/iocoder/yudao/framework/trade/core/dto/TradeAfterSaleLogCreateReqDTO.java renamed to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/dto/TradeAfterSaleLogCreateReqDTO.java
| 1 | -package cn.iocoder.yudao.framework.trade.core.dto; | 1 | +package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto; |
| 2 | 2 | ||
| 3 | import lombok.AllArgsConstructor; | 3 | import lombok.AllArgsConstructor; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| @@ -6,6 +6,9 @@ import lombok.NoArgsConstructor; | @@ -6,6 +6,9 @@ import lombok.NoArgsConstructor; | ||
| 6 | 6 | ||
| 7 | /** | 7 | /** |
| 8 | * 售后日志的创建 Request DTO | 8 | * 售后日志的创建 Request DTO |
| 9 | + * | ||
| 10 | + * @author 陈賝 | ||
| 11 | + * @since 2023/6/19 09:54 | ||
| 9 | */ | 12 | */ |
| 10 | @Data | 13 | @Data |
| 11 | @NoArgsConstructor | 14 | @NoArgsConstructor |
| @@ -18,7 +21,7 @@ public class TradeAfterSaleLogCreateReqDTO { | @@ -18,7 +21,7 @@ public class TradeAfterSaleLogCreateReqDTO { | ||
| 18 | private Long id; | 21 | private Long id; |
| 19 | /** | 22 | /** |
| 20 | * 用户编号 | 23 | * 用户编号 |
| 21 | - * | 24 | + * <p> |
| 22 | * 关联 1:AdminUserDO 的 id 字段 | 25 | * 关联 1:AdminUserDO 的 id 字段 |
| 23 | * 关联 2:MemberUserDO 的 id 字段 | 26 | * 关联 2:MemberUserDO 的 id 字段 |
| 24 | */ | 27 | */ |
yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/java/cn/iocoder/yudao/framework/trade/core/enums/AfterSaleStatusEnum.java renamed to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/enums/AfterSaleStatusEnum.java
yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/java/cn/iocoder/yudao/framework/trade/core/service/AfterSaleLogService.java renamed to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/service/AfterSaleLogService.java
| 1 | -package cn.iocoder.yudao.framework.trade.core.service; | 1 | +package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.trade.core.dto.TradeAfterSaleLogCreateReqDTO; | ||
| 4 | 3 | ||
| 5 | -// TODO @陈賝:类注释 | 4 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO; |
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 交易售后日志 Service 接口 | ||
| 8 | + * | ||
| 9 | + * @author 陈賝 | ||
| 10 | + * @since 2023/6/12 14:18 | ||
| 11 | + */ | ||
| 6 | public interface AfterSaleLogService { | 12 | public interface AfterSaleLogService { |
| 7 | 13 | ||
| 8 | /** | 14 | /** |
| @@ -12,7 +18,6 @@ public interface AfterSaleLogService { | @@ -12,7 +18,6 @@ public interface AfterSaleLogService { | ||
| 12 | * @author 陈賝 | 18 | * @author 陈賝 |
| 13 | * @since 2023/6/12 14:18 | 19 | * @since 2023/6/12 14:18 |
| 14 | */ | 20 | */ |
| 15 | - // TODO @陈賝:createLog 方法名 | ||
| 16 | - void insert(TradeAfterSaleLogCreateReqDTO logDTO); | 21 | + void createLog(TradeAfterSaleLogCreateReqDTO logDTO); |
| 17 | 22 | ||
| 18 | } | 23 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java
| @@ -5,8 +5,6 @@ import cn.hutool.core.util.RandomUtil; | @@ -5,8 +5,6 @@ import cn.hutool.core.util.RandomUtil; | ||
| 5 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 5 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 8 | -import cn.iocoder.yudao.framework.trade.core.dto.TradeAfterSaleLogCreateReqDTO; | ||
| 9 | -import cn.iocoder.yudao.framework.trade.core.service.AfterSaleLogService; | ||
| 10 | import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; | 8 | import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi; |
| 11 | import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; | 9 | import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; |
| 12 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleDisagreeReqVO; | 10 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleDisagreeReqVO; |
| @@ -26,6 +24,8 @@ import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleTypeEnum; | @@ -26,6 +24,8 @@ import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleTypeEnum; | ||
| 26 | import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; | 24 | import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; |
| 27 | import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; | 25 | import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; |
| 28 | import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; | 26 | import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; |
| 27 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO; | ||
| 28 | +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service.AfterSaleLogService; | ||
| 29 | import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; | 29 | import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; |
| 30 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderService; | 30 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderService; |
| 31 | import lombok.extern.slf4j.Slf4j; | 31 | import lombok.extern.slf4j.Slf4j; |
| @@ -40,6 +40,7 @@ import javax.annotation.Resource; | @@ -40,6 +40,7 @@ import javax.annotation.Resource; | ||
| 40 | import java.time.LocalDateTime; | 40 | import java.time.LocalDateTime; |
| 41 | 41 | ||
| 42 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 42 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 43 | +import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; | ||
| 43 | import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; | 44 | import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; |
| 44 | 45 | ||
| 45 | /** | 46 | /** |
| @@ -394,7 +395,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa | @@ -394,7 +395,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa | ||
| 394 | .setAfterSaleId(afterSale.getId()) | 395 | .setAfterSaleId(afterSale.getId()) |
| 395 | .setOperateType(afterStatus.toString()); | 396 | .setOperateType(afterStatus.toString()); |
| 396 | // TODO 废弃,待删除 | 397 | // TODO 废弃,待删除 |
| 397 | - this.insert(logDTO); | 398 | + this.createLog(logDTO); |
| 398 | } | 399 | } |
| 399 | 400 | ||
| 400 | /** | 401 | /** |
| @@ -406,7 +407,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa | @@ -406,7 +407,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa | ||
| 406 | */ | 407 | */ |
| 407 | @Override | 408 | @Override |
| 408 | @Async | 409 | @Async |
| 409 | - public void insert(TradeAfterSaleLogCreateReqDTO logDTO) { | 410 | + public void createLog(TradeAfterSaleLogCreateReqDTO logDTO) { |
| 410 | try { | 411 | try { |
| 411 | TradeAfterSaleLogDO afterSaleLog = new TradeAfterSaleLogDO() | 412 | TradeAfterSaleLogDO afterSaleLog = new TradeAfterSaleLogDO() |
| 412 | .setUserId(logDTO.getUserId()) | 413 | .setUserId(logDTO.getUserId()) |
| @@ -416,7 +417,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa | @@ -416,7 +417,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa | ||
| 416 | .setContent(logDTO.getContent()); | 417 | .setContent(logDTO.getContent()); |
| 417 | tradeAfterSaleLogMapper.insert(afterSaleLog); | 418 | tradeAfterSaleLogMapper.insert(afterSaleLog); |
| 418 | }catch (Exception exception){ | 419 | }catch (Exception exception){ |
| 419 | - log.error("日志记录错误", exception); | 420 | + log.error("[request({}) 日志记录错误]", toJsonString(logDTO), exception); |
| 420 | } | 421 | } |
| 421 | } | 422 | } |
| 422 | } | 423 | } |
yudao-server/pom.xml
| @@ -84,11 +84,11 @@ | @@ -84,11 +84,11 @@ | ||
| 84 | <!-- <version>${revision}</version>--> | 84 | <!-- <version>${revision}</version>--> |
| 85 | <!-- </dependency>--> | 85 | <!-- </dependency>--> |
| 86 | 86 | ||
| 87 | - <dependency> | ||
| 88 | - <groupId>cn.iocoder.boot</groupId> | ||
| 89 | - <artifactId>yudao-module-point-biz</artifactId> | ||
| 90 | - <version>${revision}</version> | ||
| 91 | - </dependency> | 87 | +<!-- <dependency>--> |
| 88 | +<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 89 | +<!-- <artifactId>yudao-module-point-biz</artifactId>--> | ||
| 90 | +<!-- <version>${revision}</version>--> | ||
| 91 | +<!-- </dependency>--> | ||
| 92 | 92 | ||
| 93 | <!-- spring boot 配置所需依赖 --> | 93 | <!-- spring boot 配置所需依赖 --> |
| 94 | <dependency> | 94 | <dependency> |