Commit 1dfbe4591350b25a3fe8b1a1248e1e2251bb4f10

Authored by YunaiV
1 parent 07884ef4

mall + order:review 售后日志

yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/spring/SpringExpressionUtils.java
@@ -97,6 +97,7 @@ public class SpringExpressionUtils { @@ -97,6 +97,7 @@ public class SpringExpressionUtils {
97 * @author 陈賝 97 * @author 陈賝
98 * @since 2023/6/18 11:20 98 * @since 2023/6/18 11:20
99 */ 99 */
  100 + // TODO @chenchen: 这个方法,和 parseExpressions 比较接近,是不是可以合并下;
100 public static Map<String, Object> parseExpression(JoinPoint joinPoint, Object info, List<String> expressionStrings) { 101 public static Map<String, Object> parseExpression(JoinPoint joinPoint, Object info, List<String> expressionStrings) {
101 // 如果为空,则不进行解析 102 // 如果为空,则不进行解析
102 if (CollUtil.isEmpty(expressionStrings)) { 103 if (CollUtil.isEmpty(expressionStrings)) {
@@ -115,7 +116,7 @@ public class SpringExpressionUtils { @@ -115,7 +116,7 @@ public class SpringExpressionUtils {
115 //获取方法参数值 116 //获取方法参数值
116 Object[] args = joinPoint.getArgs(); 117 Object[] args = joinPoint.getArgs();
117 for (int i = 0; i < args.length; i++) { 118 for (int i = 0; i < args.length; i++) {
118 - //替换spel里的变量值为实际值, 比如 #user --> user对象 119 + // 替换 SP EL 里的变量值为实际值, 比如 #user --> user对象
119 context.setVariable(parameterNames[i], args[i]); 120 context.setVariable(parameterNames[i], args[i]);
120 } 121 }
121 context.setVariable("info", info); 122 context.setVariable("info", info);
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java
@@ -6,6 +6,7 @@ package cn.iocoder.yudao.module.trade.enums.aftersale; @@ -6,6 +6,7 @@ package cn.iocoder.yudao.module.trade.enums.aftersale;
6 * @author 陈賝 6 * @author 陈賝
7 * @since 2023/6/13 13:53 7 * @since 2023/6/13 13:53
8 */ 8 */
  9 +// TODO @chenchen:可以 lombok 简化构造方法,和 get 方法
9 public enum AfterSaleOperateTypeEnum { 10 public enum AfterSaleOperateTypeEnum {
10 11
11 /** 12 /**
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/TradeAfterSaleLogDO.java
@@ -2,9 +2,7 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.aftersale; @@ -2,9 +2,7 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.aftersale;
2 2
3 import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; 3 import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
4 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 4 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
5 -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;  
6 -import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;  
7 -import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleStatusEnum; 5 +import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum;
8 import com.baomidou.mybatisplus.annotation.KeySequence; 6 import com.baomidou.mybatisplus.annotation.KeySequence;
9 import com.baomidou.mybatisplus.annotation.TableId; 7 import com.baomidou.mybatisplus.annotation.TableId;
10 import com.baomidou.mybatisplus.annotation.TableName; 8 import com.baomidou.mybatisplus.annotation.TableName;
@@ -51,8 +49,11 @@ public class TradeAfterSaleLogDO extends BaseDO { @@ -51,8 +49,11 @@ public class TradeAfterSaleLogDO extends BaseDO {
51 * 关联 {@link TradeAfterSaleDO#getId()} 49 * 关联 {@link TradeAfterSaleDO#getId()}
52 */ 50 */
53 private Long afterSaleId; 51 private Long afterSaleId;
  52 + // todo @CHENCHEN: 改成 Integer 哈;主要未来改文案,不好洗 log 存的字段;
54 /** 53 /**
55 - * 操作类型 {@link TradeAfterSaleStatusEnum} 54 + * 操作类型
  55 + *
  56 + * 枚举 {@link AfterSaleOperateTypeEnum}
56 */ 57 */
57 private String operateType; 58 private String operateType;
58 /** 59 /**
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/config/AfterSaleLogConfiguration.java
@@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop.AfterSaleLo @@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop.AfterSaleLo
4 import org.springframework.context.annotation.Bean; 4 import org.springframework.context.annotation.Bean;
5 import org.springframework.context.annotation.Configuration; 5 import org.springframework.context.annotation.Configuration;
6 6
  7 +// TODO @chenchen:改成 aftersale 好点哈;
7 /** 8 /**
8 * trade 模块的 afterSaleLog 组件的 Configuration 9 * trade 模块的 afterSaleLog 组件的 Configuration
9 * 10 *
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/annotations/AfterSaleLog.java
@@ -5,10 +5,13 @@ import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; @@ -5,10 +5,13 @@ import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum;
5 import java.lang.annotation.*; 5 import java.lang.annotation.*;
6 6
7 /** 7 /**
8 - * 售后日志 8 + * 售后日志的注解
  9 + *
  10 + * 写在方法上时,会自动记录售后日志
9 * 11 *
10 * @author 陈賝 12 * @author 陈賝
11 * @since 2023/6/8 17:04 13 * @since 2023/6/8 17:04
  14 + * @see cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop.AfterSaleLogAspect
12 */ 15 */
13 @Target({ElementType.METHOD, ElementType.TYPE}) 16 @Target({ElementType.METHOD, ElementType.TYPE})
14 @Retention(RetentionPolicy.RUNTIME) 17 @Retention(RetentionPolicy.RUNTIME)
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/aop/AfterSaleLogAspect.java
@@ -30,9 +30,11 @@ import static java.util.Arrays.asList; @@ -30,9 +30,11 @@ import static java.util.Arrays.asList;
30 @Slf4j 30 @Slf4j
31 @Aspect 31 @Aspect
32 public class AfterSaleLogAspect { 32 public class AfterSaleLogAspect {
  33 +
33 @Resource 34 @Resource
34 - private AfterSaleLogService saleLogService; 35 + private AfterSaleLogService afterSaleLogService;
35 36
  37 + // TODO chenchen: 这个分 3 行把;
36 private final static String OPERATE_TYPE = "operateType", ID = "id", CONTENT = "content"; 38 private final static String OPERATE_TYPE = "operateType", ID = "id", CONTENT = "content";
37 39
38 /** 40 /**
@@ -52,9 +54,9 @@ public class AfterSaleLogAspect { @@ -52,9 +54,9 @@ public class AfterSaleLogAspect {
52 .setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE)) 54 .setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE))
53 .setContent(MapUtil.getStr(formatObj, CONTENT)); 55 .setContent(MapUtil.getStr(formatObj, CONTENT));
54 // 异步存入数据库 56 // 异步存入数据库
55 - saleLogService.createLog(dto); 57 + afterSaleLogService.createLog(dto);
56 } catch (Exception exception) { 58 } catch (Exception exception) {
57 - log.error("[afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception); 59 + log.error("[doAfterReturning][afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception);
58 } 60 }
59 } 61 }
60 62
@@ -67,6 +69,7 @@ public class AfterSaleLogAspect { @@ -67,6 +69,7 @@ public class AfterSaleLogAspect {
67 HashMap<String, String> result = Maps.newHashMapWithExpectedSize(2); 69 HashMap<String, String> result = Maps.newHashMapWithExpectedSize(2);
68 Map<String, Object> spelMap = SpringExpressionUtils.parseExpression(joinPoint, info, 70 Map<String, Object> spelMap = SpringExpressionUtils.parseExpression(joinPoint, info,
69 asList(afterSaleLogPoint.id(), afterSaleLogPoint.content())); 71 asList(afterSaleLogPoint.id(), afterSaleLogPoint.content()));
  72 + // TODO @chenchen:是不是抽成 3 个方法好点;毕竟 map 太抽象了;;
70 // 售后ID 73 // 售后ID
71 String id = MapUtil.getStr(spelMap, afterSaleLogPoint.id()); 74 String id = MapUtil.getStr(spelMap, afterSaleLogPoint.id());
72 result.put(ID, id); 75 result.put(ID, id);
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/dto/TradeAfterSaleLogCreateReqDTO.java
@@ -21,7 +21,7 @@ public class TradeAfterSaleLogCreateReqDTO { @@ -21,7 +21,7 @@ public class TradeAfterSaleLogCreateReqDTO {
21 private Long id; 21 private Long id;
22 /** 22 /**
23 * 用户编号 23 * 用户编号
24 - * <p> 24 + *
25 * 关联 1:AdminUserDO 的 id 字段 25 * 关联 1:AdminUserDO 的 id 字段
26 * 关联 2:MemberUserDO 的 id 字段 26 * 关联 2:MemberUserDO 的 id 字段
27 */ 27 */
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java
@@ -398,6 +398,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa @@ -398,6 +398,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
398 this.createLog(logDTO); 398 this.createLog(logDTO);
399 } 399 }
400 400
  401 + // TODO @CHENCHEN:这个注释,写在接口就好了,补充重复写哈;@date 应该是 @since
401 /** 402 /**
402 * 日志记录 403 * 日志记录
403 * 404 *
@@ -416,8 +417,9 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa @@ -416,8 +417,9 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
416 .setOperateType(logDTO.getOperateType()) 417 .setOperateType(logDTO.getOperateType())
417 .setContent(logDTO.getContent()); 418 .setContent(logDTO.getContent());
418 tradeAfterSaleLogMapper.insert(afterSaleLog); 419 tradeAfterSaleLogMapper.insert(afterSaleLog);
  420 + // TODO @CHENCHEN:代码排版哈;空格要正确
419 }catch (Exception exception){ 421 }catch (Exception exception){
420 - log.error("[request({}) 日志记录错误]", toJsonString(logDTO), exception); 422 + log.error("[createLog][request({}) 日志记录错误]", toJsonString(logDTO), exception);
421 } 423 }
422 } 424 }
423 } 425 }