Commit 73f1636daa82b633ea1dc75a6d92b51f731bbed4

Authored by chenchen
1 parent 3e4b1c05

售后日志添加售前售后状态

sql/mysql/optional/mall_trade_log.sql 0 → 100644
  1 +ALTER TABLE `ruoyi-vue-pro`.`trade_after_sale_log`
  2 + ADD COLUMN `before_status` int NOT NULL COMMENT '售前状态' AFTER `id`,
  3 + ADD COLUMN `after_status` int NOT NULL COMMENT '售后状态' AFTER `before_status`;
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/JobLogController.java
@@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; 5 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
6 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; 6 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
  7 +import cn.iocoder.yudao.framework.operatelog.core.util.OperateLogUtils;
7 import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExcelVO; 8 import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExcelVO;
8 import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO; 9 import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO;
9 import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; 10 import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO;
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/aftersale/AppTradeAfterSaleController.java
@@ -8,8 +8,10 @@ import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSa @@ -8,8 +8,10 @@ import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSa
8 import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleRespVO; 8 import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleRespVO;
9 import cn.iocoder.yudao.module.trade.convert.aftersale.TradeAfterSaleConvert; 9 import cn.iocoder.yudao.module.trade.convert.aftersale.TradeAfterSaleConvert;
10 import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; 10 import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum;
  11 +import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleStatusEnum;
11 import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; 12 import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum;
12 import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog; 13 import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog;
  14 +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.util.AfterSaleLogUtils;
13 import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService; 15 import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService;
14 import io.swagger.v3.oas.annotations.Operation; 16 import io.swagger.v3.oas.annotations.Operation;
15 import io.swagger.v3.oas.annotations.Parameter; 17 import io.swagger.v3.oas.annotations.Parameter;
@@ -71,6 +73,8 @@ public class AppTradeAfterSaleController { @@ -71,6 +73,8 @@ public class AppTradeAfterSaleController {
71 @Operation(summary = "申请售后") 73 @Operation(summary = "申请售后")
72 @AfterSaleLog(id = "#info.data", content = "'申请售后:售后编号['+#info.data+'],订单编号['+#createReqVO.orderItemId+'], '", operateType = AfterSaleOperateTypeEnum.APPLY) 74 @AfterSaleLog(id = "#info.data", content = "'申请售后:售后编号['+#info.data+'],订单编号['+#createReqVO.orderItemId+'], '", operateType = AfterSaleOperateTypeEnum.APPLY)
73 public CommonResult<Long> createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) { 75 public CommonResult<Long> createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) {
  76 + AfterSaleLogUtils.setBeforeStatus(0);
  77 + AfterSaleLogUtils.setAfterStatus(TradeAfterSaleStatusEnum.APPLY.getStatus());
74 return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO)); 78 return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO));
75 } 79 }
76 80
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/aop/AfterSaleLogAspect.java
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop; @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop;
3 import cn.hutool.core.map.MapUtil; 3 import cn.hutool.core.map.MapUtil;
4 import cn.hutool.core.util.ObjectUtil; 4 import cn.hutool.core.util.ObjectUtil;
5 import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils; 5 import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils;
  6 +import cn.iocoder.yudao.framework.operatelog.core.service.OperateLog;
6 import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; 7 import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
7 import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog; 8 import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog;
8 import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO; 9 import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.dto.TradeAfterSaleLogCreateReqDTO;
@@ -33,9 +34,26 @@ public class AfterSaleLogAspect { @@ -33,9 +34,26 @@ public class AfterSaleLogAspect {
33 34
34 @Resource 35 @Resource
35 private AfterSaleLogService afterSaleLogService; 36 private AfterSaleLogService afterSaleLogService;
36 -  
37 - // TODO chenchen: 这个分 3 行把;  
38 - private final static String OPERATE_TYPE = "operateType", ID = "id", CONTENT = "content"; 37 + /**
  38 + * 售前状态
  39 + */
  40 + private static final ThreadLocal<Integer> BEFORE_STATUS = new ThreadLocal<>();
  41 + /**
  42 + * 售后状态
  43 + */
  44 + private static final ThreadLocal<Integer> AFTER_STATUS = new ThreadLocal<>();
  45 + /**
  46 + * 操作类型
  47 + */
  48 + private final static String OPERATE_TYPE = "operateType";
  49 + /**
  50 + * ID
  51 + */
  52 + private final static String ID = "id";
  53 + /**
  54 + * 操作明细
  55 + */
  56 + private final static String CONTENT = "content";
39 57
40 /** 58 /**
41 * 切面存入日志 59 * 切面存入日志
@@ -52,11 +70,15 @@ public class AfterSaleLogAspect { @@ -52,11 +70,15 @@ public class AfterSaleLogAspect {
52 .setUserType(userType) 70 .setUserType(userType)
53 .setAfterSaleId(MapUtil.getLong(formatObj, ID)) 71 .setAfterSaleId(MapUtil.getLong(formatObj, ID))
54 .setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE)) 72 .setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE))
  73 + .setBeforeStatus(BEFORE_STATUS.get())
  74 + .setAfterStatus(AFTER_STATUS.get())
55 .setContent(MapUtil.getStr(formatObj, CONTENT)); 75 .setContent(MapUtil.getStr(formatObj, CONTENT));
56 // 异步存入数据库 76 // 异步存入数据库
57 afterSaleLogService.createLog(dto); 77 afterSaleLogService.createLog(dto);
58 } catch (Exception exception) { 78 } catch (Exception exception) {
59 log.error("[doAfterReturning][afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception); 79 log.error("[doAfterReturning][afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception);
  80 + }finally {
  81 + clearThreadLocal();
60 } 82 }
61 } 83 }
62 84
@@ -85,4 +107,17 @@ public class AfterSaleLogAspect { @@ -85,4 +107,17 @@ public class AfterSaleLogAspect {
85 return result; 107 return result;
86 } 108 }
87 109
  110 + public static void setBeforeStatus(Integer beforestatus) {
  111 + BEFORE_STATUS.set(beforestatus);
  112 + }
  113 +
  114 + public static void setAfterStatus(Integer afterStatus) {
  115 + AFTER_STATUS.set(afterStatus);
  116 + }
  117 +
  118 + private static void clearThreadLocal() {
  119 + AFTER_STATUS.remove();
  120 + BEFORE_STATUS.remove();
  121 + }
  122 +
88 } 123 }
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/dto/TradeAfterSaleLogCreateReqDTO.java
@@ -42,5 +42,13 @@ public class TradeAfterSaleLogCreateReqDTO { @@ -42,5 +42,13 @@ public class TradeAfterSaleLogCreateReqDTO {
42 * 操作明细 42 * 操作明细
43 */ 43 */
44 private String content; 44 private String content;
  45 + /**
  46 + * 售前状态
  47 + */
  48 + private Integer beforeStatus;
  49 + /**
  50 + * 售后状态
  51 + */
  52 + private Integer afterStatus;
45 53
46 } 54 }
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/aftersalelog/core/util/AfterSaleLogUtils.java 0 → 100644
  1 +package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.util;
  2 +
  3 +
  4 +import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop.AfterSaleLogAspect;
  5 +
  6 +/**
  7 + * 操作日志工具类
  8 + * 目前主要的作用,是提供给业务代码,记录操作明细和拓展字段
  9 + *
  10 + * @author 芋道源码
  11 + */
  12 +public class AfterSaleLogUtils {
  13 +
  14 + public static void setBeforeStatus(Integer status) {
  15 + AfterSaleLogAspect.setBeforeStatus(status);
  16 + }
  17 +
  18 + public static void setAfterStatus(Integer status) {
  19 + AfterSaleLogAspect.setAfterStatus(status);
  20 + }
  21 +
  22 +}