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

This commit is contained in:
chenchen 2023-08-29 18:23:23 +08:00
parent 3e4b1c0552
commit 73f1636daa
6 changed files with 76 additions and 3 deletions

View File

@ -0,0 +1,3 @@
ALTER TABLE `ruoyi-vue-pro`.`trade_after_sale_log`
ADD COLUMN `before_status` int NOT NULL COMMENT '售前状态' AFTER `id`,
ADD COLUMN `after_status` int NOT NULL COMMENT '售后状态' AFTER `before_status`;

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.framework.operatelog.core.util.OperateLogUtils;
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExcelVO; import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExcelVO;
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO; import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO;

View File

@ -8,8 +8,10 @@ import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSa
import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleRespVO; import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleRespVO;
import cn.iocoder.yudao.module.trade.convert.aftersale.TradeAfterSaleConvert; import cn.iocoder.yudao.module.trade.convert.aftersale.TradeAfterSaleConvert;
import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum; import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum;
import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleStatusEnum;
import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum; import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleWayEnum;
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog; import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog;
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.util.AfterSaleLogUtils;
import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService; import cn.iocoder.yudao.module.trade.service.aftersale.TradeAfterSaleService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
@ -71,6 +73,8 @@ public class AppTradeAfterSaleController {
@Operation(summary = "申请售后") @Operation(summary = "申请售后")
@AfterSaleLog(id = "#info.data", content = "'申请售后:售后编号['+#info.data+'],订单编号['+#createReqVO.orderItemId+'], '", operateType = AfterSaleOperateTypeEnum.APPLY) @AfterSaleLog(id = "#info.data", content = "'申请售后:售后编号['+#info.data+'],订单编号['+#createReqVO.orderItemId+'], '", operateType = AfterSaleOperateTypeEnum.APPLY)
public CommonResult<Long> createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) { public CommonResult<Long> createAfterSale(@RequestBody AppTradeAfterSaleCreateReqVO createReqVO) {
AfterSaleLogUtils.setBeforeStatus(0);
AfterSaleLogUtils.setAfterStatus(TradeAfterSaleStatusEnum.APPLY.getStatus());
return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO)); return success(afterSaleService.createAfterSale(getLoginUserId(), createReqVO));
} }

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils; import cn.iocoder.yudao.framework.common.util.spring.SpringExpressionUtils;
import cn.iocoder.yudao.framework.operatelog.core.service.OperateLog;
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.annotations.AfterSaleLog; 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.dto.TradeAfterSaleLogCreateReqDTO;
@ -33,9 +34,26 @@ public class AfterSaleLogAspect {
@Resource @Resource
private AfterSaleLogService afterSaleLogService; private AfterSaleLogService afterSaleLogService;
/**
// TODO chenchen: 这个分 3 行把 * 售前状态
private final static String OPERATE_TYPE = "operateType", ID = "id", CONTENT = "content"; */
private static final ThreadLocal<Integer> BEFORE_STATUS = new ThreadLocal<>();
/**
* 售后状态
*/
private static final ThreadLocal<Integer> AFTER_STATUS = new ThreadLocal<>();
/**
* 操作类型
*/
private final static String OPERATE_TYPE = "operateType";
/**
* ID
*/
private final static String ID = "id";
/**
* 操作明细
*/
private final static String CONTENT = "content";
/** /**
* 切面存入日志 * 切面存入日志
@ -52,11 +70,15 @@ public class AfterSaleLogAspect {
.setUserType(userType) .setUserType(userType)
.setAfterSaleId(MapUtil.getLong(formatObj, ID)) .setAfterSaleId(MapUtil.getLong(formatObj, ID))
.setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE)) .setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE))
.setBeforeStatus(BEFORE_STATUS.get())
.setAfterStatus(AFTER_STATUS.get())
.setContent(MapUtil.getStr(formatObj, CONTENT)); .setContent(MapUtil.getStr(formatObj, CONTENT));
// 异步存入数据库 // 异步存入数据库
afterSaleLogService.createLog(dto); afterSaleLogService.createLog(dto);
} catch (Exception exception) { } catch (Exception exception) {
log.error("[doAfterReturning][afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception); log.error("[doAfterReturning][afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception);
}finally {
clearThreadLocal();
} }
} }
@ -85,4 +107,17 @@ public class AfterSaleLogAspect {
return result; return result;
} }
public static void setBeforeStatus(Integer beforestatus) {
BEFORE_STATUS.set(beforestatus);
}
public static void setAfterStatus(Integer afterStatus) {
AFTER_STATUS.set(afterStatus);
}
private static void clearThreadLocal() {
AFTER_STATUS.remove();
BEFORE_STATUS.remove();
}
} }

View File

@ -42,5 +42,13 @@ public class TradeAfterSaleLogCreateReqDTO {
* 操作明细 * 操作明细
*/ */
private String content; private String content;
/**
* 售前状态
*/
private Integer beforeStatus;
/**
* 售后状态
*/
private Integer afterStatus;
} }

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.trade.framework.aftersalelog.core.util;
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop.AfterSaleLogAspect;
/**
* 操作日志工具类
* 目前主要的作用是提供给业务代码记录操作明细和拓展字段
*
* @author 芋道源码
*/
public class AfterSaleLogUtils {
public static void setBeforeStatus(Integer status) {
AfterSaleLogAspect.setBeforeStatus(status);
}
public static void setAfterStatus(Integer status) {
AfterSaleLogAspect.setAfterStatus(status);
}
}