spelMap = SpringExpressionUtils.parseExpression(joinPoint, info,
+ asList(afterSaleLogPoint.id(), afterSaleLogPoint.operateType().description(), afterSaleLogPoint.content()));
+ // 售后ID
+ String id = MapUtil.getStr(spelMap, afterSaleLogPoint.id());
+ result.put("id", id);
+ // 操作类型
+ String operateType = MapUtil.getStr(spelMap, afterSaleLogPoint.operateType().description());
+ result.put("operateType", operateType);
+ // 日志内容
+ String content = MapUtil.getStr(spelMap, afterSaleLogPoint.content());
+ if (ObjectUtil.isNotNull(afterSaleLogPoint.operateType())) {
+ content += MapUtil.getStr(spelMap, afterSaleLogPoint.operateType().description());
+ }
+ result.put("content", content);
+ return result;
+ }
+
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/java/cn/iocoder/yudao/framework/trade/core/dto/TradeAfterSaleLogCreateReqDTO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/dto/TradeAfterSaleLogCreateReqDTO.java
similarity index 84%
rename from yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/java/cn/iocoder/yudao/framework/trade/core/dto/TradeAfterSaleLogCreateReqDTO.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/dto/TradeAfterSaleLogCreateReqDTO.java
index 8c4a0fcc3..a6f29e4ce 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/java/cn/iocoder/yudao/framework/trade/core/dto/TradeAfterSaleLogCreateReqDTO.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/dto/TradeAfterSaleLogCreateReqDTO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.framework.trade.core.dto;
+package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -6,6 +6,9 @@ import lombok.NoArgsConstructor;
/**
* 售后日志的创建 Request DTO
+ *
+ * @author 陈賝
+ * @since 2023/6/19 09:54
*/
@Data
@NoArgsConstructor
@@ -18,7 +21,7 @@ public class TradeAfterSaleLogCreateReqDTO {
private Long id;
/**
* 用户编号
- *
+ *
* 关联 1:AdminUserDO 的 id 字段
* 关联 2:MemberUserDO 的 id 字段
*/
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/java/cn/iocoder/yudao/framework/trade/core/enums/AfterSaleStatusEnum.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/enums/AfterSaleStatusEnum.java
similarity index 83%
rename from yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/java/cn/iocoder/yudao/framework/trade/core/enums/AfterSaleStatusEnum.java
rename to yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/enums/AfterSaleStatusEnum.java
index e5f66dbf6..8897216e3 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-trade/src/main/java/cn/iocoder/yudao/framework/trade/core/enums/AfterSaleStatusEnum.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/enums/AfterSaleStatusEnum.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.framework.trade.core.enums;
+package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.enums;
/**
* 售后状态的枚举
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/service/AfterSaleLogService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/service/AfterSaleLogService.java
new file mode 100644
index 000000000..ccea309f4
--- /dev/null
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/service/AfterSaleLogService.java
@@ -0,0 +1,23 @@
+package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service;
+
+
+import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO;
+
+/**
+ * 交易售后日志 Service 接口
+ *
+ * @author 陈賝
+ * @since 2023/6/12 14:18
+ */
+public interface AfterSaleLogService {
+
+ /**
+ * 创建售后日志
+ *
+ * @param logDTO 日志记录
+ * @author 陈賝
+ * @since 2023/6/12 14:18
+ */
+ void createLog(TradeAfterSaleLogCreateReqDTO logDTO);
+
+}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java
index 94cd15876..73e8f085e 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceImpl.java
+++ b/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;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
-import cn.iocoder.yudao.framework.trade.core.dto.TradeAfterSaleLogCreateReqDTO;
-import cn.iocoder.yudao.framework.trade.core.service.AfterSaleLogService;
import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi;
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleDisagreeReqVO;
@@ -26,6 +24,8 @@ import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleTypeEnum;
import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
+import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO;
+import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service.AfterSaleLogService;
import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties;
import cn.iocoder.yudao.module.trade.service.order.TradeOrderService;
import lombok.extern.slf4j.Slf4j;
@@ -40,6 +40,7 @@ import javax.annotation.Resource;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
/**
@@ -394,7 +395,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
.setAfterSaleId(afterSale.getId())
.setOperateType(afterStatus.toString());
// TODO 废弃,待删除
- this.insert(logDTO);
+ this.createLog(logDTO);
}
/**
@@ -406,7 +407,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
*/
@Override
@Async
- public void insert(TradeAfterSaleLogCreateReqDTO logDTO) {
+ public void createLog(TradeAfterSaleLogCreateReqDTO logDTO) {
try {
TradeAfterSaleLogDO afterSaleLog = new TradeAfterSaleLogDO()
.setUserId(logDTO.getUserId())
@@ -416,7 +417,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
.setContent(logDTO.getContent());
tradeAfterSaleLogMapper.insert(afterSaleLog);
}catch (Exception exception){
- log.error("日志记录错误", exception);
+ log.error("[request({}) 日志记录错误]", toJsonString(logDTO), exception);
}
}
}
diff --git a/yudao-server/pom.xml b/yudao-server/pom.xml
index f38a73ce9..6811a34f3 100644
--- a/yudao-server/pom.xml
+++ b/yudao-server/pom.xml
@@ -84,11 +84,11 @@
-
- cn.iocoder.boot
- yudao-module-point-biz
- ${revision}
-
+
+
+
+
+
From 2672b3e2fa0ea9afc4ffe8724b550557283ea630 Mon Sep 17 00:00:00 2001
From: chenchen <934298133@qq.com>
Date: Sat, 17 Jun 2023 23:47:38 +0800
Subject: [PATCH 3/4] =?UTF-8?q?fix=20=E4=BE=9D=E8=B5=96=E5=90=AF=E5=8A=A8?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
yudao-dependencies/pom.xml | 5 +++++
yudao-framework/yudao-spring-boot-starter-biz-trade/pom.xml | 4 ----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml
index b34b01f63..92b914c97 100644
--- a/yudao-dependencies/pom.xml
+++ b/yudao-dependencies/pom.xml
@@ -96,6 +96,11 @@
yudao-spring-boot-starter-biz-operatelog
${revision}
+
+ cn.iocoder.boot
+ yudao-spring-boot-starter-biz-trade
+ ${revision}
+
cn.iocoder.boot
yudao-spring-boot-starter-biz-dict
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-trade/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-trade/pom.xml
index ab9c820bf..0008793e5 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-trade/pom.xml
+++ b/yudao-framework/yudao-spring-boot-starter-biz-trade/pom.xml
@@ -46,9 +46,5 @@
com.google.guava
guava
-
- cn.iocoder.boot
- yudao-spring-boot-starter-security
-
From 2f0aaee82334657a9341874734dcda01854f7861 Mon Sep 17 00:00:00 2001
From: chenchen <934298133@qq.com>
Date: Mon, 19 Jun 2023 17:04:07 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E5=94=AE=E5=90=8E=E6=97=A5=E5=BF=97?=
=?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../util/spring/SpringExpressionUtils.java | 14 ++++-----
.../aftersale/AfterSaleOperateTypeEnum.java} | 13 ++++----
.../aftersale/TradeAfterSaleController.java | 19 ------------
.../AppTradeAfterSaleController.java | 3 ++
.../config/AfterSaleLogConfiguration.java | 4 +--
.../core/annotations/AfterSaleLog.java | 6 ++--
.../core/aop/AfterSaleLogAspect.java | 31 +++++++++++--------
.../aftersale/TradeAfterSaleServiceTest.java | 3 --
8 files changed, 39 insertions(+), 54 deletions(-)
rename yudao-module-mall/{yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/enums/AfterSaleStatusEnum.java => yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java} (50%)
diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/spring/SpringExpressionUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/spring/SpringExpressionUtils.java
index a2b97206e..d706767b9 100644
--- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/spring/SpringExpressionUtils.java
+++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/spring/SpringExpressionUtils.java
@@ -25,8 +25,6 @@ import java.util.Map;
*/
public class SpringExpressionUtils {
-
-
/**
* spel表达式解析器
*/
@@ -92,14 +90,14 @@ public class SpringExpressionUtils {
/**
* JoinPoint 切面 批量解析 EL 表达式,转换 jspl参数
*
- * @param joinPoint 切面点
- * @param rvt 返回值
- * @param expressionStrings EL 表达式数组
- * @return java.lang.String 结果
+ * @param joinPoint 切面点
+ * @param info 返回值
+ * @param expressionStrings EL 表达式数组
+ * @return Map 结果
* @author 陈賝
* @since 2023/6/18 11:20
*/
- public static Map parseExpression(JoinPoint joinPoint, Object rvt, List expressionStrings) {
+ public static Map parseExpression(JoinPoint joinPoint, Object info, List expressionStrings) {
// 如果为空,则不进行解析
if (CollUtil.isEmpty(expressionStrings)) {
return MapUtil.newHashMap();
@@ -120,7 +118,7 @@ public class SpringExpressionUtils {
//替换spel里的变量值为实际值, 比如 #user --> user对象
context.setVariable(parameterNames[i], args[i]);
}
- context.setVariable("rvt", rvt);
+ context.setVariable("info", info);
}
// 第二步,逐个参数解析
Map result = MapUtil.newHashMap(expressionStrings.size(), true);
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/enums/AfterSaleStatusEnum.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java
similarity index 50%
rename from yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/enums/AfterSaleStatusEnum.java
rename to yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java
index 8897216e3..93cc0b5cd 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/enums/AfterSaleStatusEnum.java
+++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/aftersale/AfterSaleOperateTypeEnum.java
@@ -1,21 +1,22 @@
-package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.enums;
+package cn.iocoder.yudao.module.trade.enums.aftersale;
/**
- * 售后状态的枚举
+ * 售后操作类型的枚举
*
* @author 陈賝
* @since 2023/6/13 13:53
*/
-public enum AfterSaleStatusEnum {
+public enum AfterSaleOperateTypeEnum {
/**
- * 申请中
+ * 用户申请
*/
- APPLY("申请中");
+ APPLY("用户申请"),
+ ;
private final String description;
- AfterSaleStatusEnum(String description) {
+ AfterSaleOperateTypeEnum(String description) {
this.description = description;
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java
index 868b0a056..a1bf5d544 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java
@@ -11,11 +11,8 @@ import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSal
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSalePageReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRefuseReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRespPageItemVO;
-import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO;
import cn.iocoder.yudao.module.trade.convert.aftersale.TradeAfterSaleConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO;
-import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog;
-import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.enums.AfterSaleStatusEnum;
import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -113,20 +110,4 @@ public class TradeAfterSaleController {
return success(true);
}
- // TODO @陈賝:后续要删除下
- /**
- * 售后日志测试
- *
- * @param createReqVO
- * @return cn.iocoder.yudao.framework.common.pojo.CommonResult
- * @author 陈賝
- * @date 2023/6/14 21:39
- */
- @PostMapping(value = "/create")
- @AfterSaleLog(id = "#createReqVO.orderItemId", content = "'申请售后:售后编号['+#createReqVO.orderItemId+'] , '", operateType = AfterSaleStatusEnum.APPLY)
- public CommonResult createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) {
- return success(1L);
-// return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO));
- }
-
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java
index 1982a9bdd..004f6e68a 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java
@@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSa
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleDeliveryReqVO;
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSalePageItemRespVO;
import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO;
+import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum;
+import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog;
import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -78,6 +80,7 @@ public class AppTradeAfterSaleController {
@PostMapping(value = "/create")
@Operation(summary = "申请售后")
+ @AfterSaleLog(id = "#info.data", content = "'申请售后:售后编号['+#info.data+'],订单编号['+#createReqVO.orderItemId+'], '", operateType = AfterSaleOperateTypeEnum.APPLY)
public CommonResult createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) {
return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO));
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/config/AfterSaleLogConfiguration.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/config/AfterSaleLogConfiguration.java
index b62f384ff..901621d79 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/config/AfterSaleLogConfiguration.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/config/AfterSaleLogConfiguration.java
@@ -1,8 +1,8 @@
package cn.iocoder.yudao.module.trade.framework.aftersalelog.config;
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop.AfterSaleLogAspect;
-import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
/**
* trade 模块的 afterSaleLog 组件的 Configuration
@@ -10,7 +10,7 @@ import org.springframework.context.annotation.Bean;
* @author 陈賝
* @since 2023/6/18 11:09
*/
-@AutoConfiguration
+@Configuration(proxyBeanMethods = false)
public class AfterSaleLogConfiguration {
@Bean
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/annotations/AfterSaleLog.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/annotations/AfterSaleLog.java
index d86b42515..d1f26d7a5 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/annotations/AfterSaleLog.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/annotations/AfterSaleLog.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations;
-import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.enums.AfterSaleStatusEnum;
+import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum;
import java.lang.annotation.*;
@@ -10,7 +10,7 @@ import java.lang.annotation.*;
* @author 陈賝
* @since 2023/6/8 17:04
*/
-@Target({ElementType.METHOD,ElementType.TYPE})
+@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface AfterSaleLog {
@@ -23,7 +23,7 @@ public @interface AfterSaleLog {
/**
* 操作类型
*/
- AfterSaleStatusEnum operateType() default AfterSaleStatusEnum.APPLY;
+ AfterSaleOperateTypeEnum operateType();
/**
* 日志内容
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/aop/AfterSaleLogAspect.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/aop/AfterSaleLogAspect.java
index 5e76e084e..16a98a574 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/aop/AfterSaleLogAspect.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/aop/AfterSaleLogAspect.java
@@ -4,13 +4,12 @@ import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils;
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
-import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO;
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog;
+import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO;
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service.AfterSaleLogService;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
@@ -34,6 +33,11 @@ public class AfterSaleLogAspect {
@Resource
private AfterSaleLogService saleLogService;
+ private final static String OPERATE_TYPE = "operateType", ID = "id", CONTENT = "content";
+
+ /**
+ * 切面存入日志
+ */
@AfterReturning(pointcut = "@annotation(afterSaleLog)", returning = "info")
public void doAfterReturning(JoinPoint joinPoint, AfterSaleLog afterSaleLog, Object info) {
try {
@@ -42,10 +46,11 @@ public class AfterSaleLogAspect {
Long id = WebFrameworkUtils.getLoginUserId();
Map formatObj = spelFormat(joinPoint, info);
TradeAfterSaleLogCreateReqDTO dto = new TradeAfterSaleLogCreateReqDTO()
- .setUserId(id).setUserType(userType)
- .setAfterSaleId(MapUtil.getLong(formatObj, "id"))
- .setContent(formatObj.get("content"))
- .setOperateType(formatObj.get("operateType"));
+ .setUserId(id)
+ .setUserType(userType)
+ .setAfterSaleId(MapUtil.getLong(formatObj, ID))
+ .setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE))
+ .setContent(MapUtil.getStr(formatObj, CONTENT));
// 异步存入数据库
saleLogService.createLog(dto);
} catch (Exception exception) {
@@ -59,21 +64,21 @@ public class AfterSaleLogAspect {
public static Map spelFormat(JoinPoint joinPoint, Object info) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
AfterSaleLog afterSaleLogPoint = signature.getMethod().getAnnotation(AfterSaleLog.class);
- HashMap result = Maps.newHashMapWithExpectedSize(3);
+ HashMap result = Maps.newHashMapWithExpectedSize(2);
Map spelMap = SpringExpressionUtils.parseExpression(joinPoint, info,
- asList(afterSaleLogPoint.id(), afterSaleLogPoint.operateType().description(), afterSaleLogPoint.content()));
+ asList(afterSaleLogPoint.id(), afterSaleLogPoint.content()));
// 售后ID
String id = MapUtil.getStr(spelMap, afterSaleLogPoint.id());
- result.put("id", id);
+ result.put(ID, id);
// 操作类型
- String operateType = MapUtil.getStr(spelMap, afterSaleLogPoint.operateType().description());
- result.put("operateType", operateType);
+ String operateType = afterSaleLogPoint.operateType().description();
+ result.put(OPERATE_TYPE, operateType);
// 日志内容
String content = MapUtil.getStr(spelMap, afterSaleLogPoint.content());
if (ObjectUtil.isNotNull(afterSaleLogPoint.operateType())) {
- content += MapUtil.getStr(spelMap, afterSaleLogPoint.operateType().description());
+ content += operateType;
}
- result.put("content", content);
+ result.put(CONTENT, content);
return result;
}
diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java
index 7f94b6d19..68efd67a7 100644
--- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java
+++ b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/aftersale/TradeAfterSaleServiceTest.java
@@ -66,7 +66,6 @@ public class TradeAfterSaleServiceTest extends BaseDbUnitTest {
AppTradeAfterSaleCreateReqVO createReqVO = new AppTradeAfterSaleCreateReqVO()
.setOrderItemId(1L).setRefundPrice(100).setWay(TradeAfterSaleWayEnum.RETURN_AND_REFUND.getWay())
.setApplyReason("退钱").setApplyDescription("快退")
- .setOperateType("APPLY")
.setApplyPicUrls(asList("https://www.baidu.com/1.png", "https://www.baidu.com/2.png"));
// mock 方法(交易订单项)
TradeOrderItemDO orderItem = randomPojo(TradeOrderItemDO.class, o -> {
@@ -103,8 +102,6 @@ public class TradeAfterSaleServiceTest extends BaseDbUnitTest {
assertEquals(afterSaleLog.getUserType(), UserTypeEnum.MEMBER.getValue());
assertEquals(afterSaleLog.getAfterSaleId(), afterSaleId);
assertPojoEquals(afterSale, orderItem, "id", "creator", "createTime", "updater", "updateTime");
-// assertNull(afterSaleLog.getBeforeStatus());
-// assertEquals(afterSaleLog.getAfterStatus(), TradeAfterSaleStatusEnum.APPLY.getStatus());
assertEquals(afterSaleLog.getContent(), TradeAfterSaleStatusEnum.APPLY.getContent());
}