mall + order:review 售后日志

This commit is contained in:
YunaiV 2023-06-23 21:50:57 +08:00
parent 07884ef423
commit 1dfbe45913
8 changed files with 24 additions and 12 deletions

View File

@ -97,6 +97,7 @@ public class SpringExpressionUtils {
* @author 陈賝 * @author 陈賝
* @since 2023/6/18 11:20 * @since 2023/6/18 11:20
*/ */
// TODO @chenchen: 这个方法 parseExpressions 比较接近是不是可以合并下
public static Map<String, Object> parseExpression(JoinPoint joinPoint, Object info, List<String> expressionStrings) { public static Map<String, Object> parseExpression(JoinPoint joinPoint, Object info, List<String> expressionStrings) {
// 如果为空则不进行解析 // 如果为空则不进行解析
if (CollUtil.isEmpty(expressionStrings)) { if (CollUtil.isEmpty(expressionStrings)) {
@ -115,7 +116,7 @@ public class SpringExpressionUtils {
//获取方法参数值 //获取方法参数值
Object[] args = joinPoint.getArgs(); Object[] args = joinPoint.getArgs();
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
//替换spel里的变量值为实际值 比如 #user --> user对象 // 替换 SP EL 里的变量值为实际值 比如 #user --> user对象
context.setVariable(parameterNames[i], args[i]); context.setVariable(parameterNames[i], args[i]);
} }
context.setVariable("info", info); context.setVariable("info", info);

View File

@ -6,6 +6,7 @@ package cn.iocoder.yudao.module.trade.enums.aftersale;
* @author 陈賝 * @author 陈賝
* @since 2023/6/13 13:53 * @since 2023/6/13 13:53
*/ */
// TODO @chenchen可以 lombok 简化构造方法 get 方法
public enum AfterSaleOperateTypeEnum { public enum AfterSaleOperateTypeEnum {
/** /**

View File

@ -2,9 +2,7 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.aftersale;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleStatusEnum;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -51,8 +49,11 @@ public class TradeAfterSaleLogDO extends BaseDO {
* 关联 {@link TradeAfterSaleDO#getId()} * 关联 {@link TradeAfterSaleDO#getId()}
*/ */
private Long afterSaleId; private Long afterSaleId;
// todo @CHENCHEN: 改成 Integer 主要未来改文案不好洗 log 存的字段
/** /**
* 操作类型 {@link TradeAfterSaleStatusEnum} * 操作类型
*
* 枚举 {@link AfterSaleOperateTypeEnum}
*/ */
private String operateType; private String operateType;
/** /**

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop.AfterSaleLo
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
// TODO @chenchen改成 aftersale 好点哈
/** /**
* trade 模块的 afterSaleLog 组件的 Configuration * trade 模块的 afterSaleLog 组件的 Configuration
* *

View File

@ -5,10 +5,13 @@ import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum;
import java.lang.annotation.*; import java.lang.annotation.*;
/** /**
* 售后日志 * 售后日志的注解
*
* 写在方法上时会自动记录售后日志
* *
* @author 陈賝 * @author 陈賝
* @since 2023/6/8 17:04 * @since 2023/6/8 17:04
* @see cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop.AfterSaleLogAspect
*/ */
@Target({ElementType.METHOD, ElementType.TYPE}) @Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)

View File

@ -30,9 +30,11 @@ import static java.util.Arrays.asList;
@Slf4j @Slf4j
@Aspect @Aspect
public class AfterSaleLogAspect { public class AfterSaleLogAspect {
@Resource
private AfterSaleLogService saleLogService;
@Resource
private AfterSaleLogService afterSaleLogService;
// TODO chenchen: 这个分 3 行把
private final static String OPERATE_TYPE = "operateType", ID = "id", CONTENT = "content"; private final static String OPERATE_TYPE = "operateType", ID = "id", CONTENT = "content";
/** /**
@ -52,9 +54,9 @@ public class AfterSaleLogAspect {
.setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE)) .setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE))
.setContent(MapUtil.getStr(formatObj, CONTENT)); .setContent(MapUtil.getStr(formatObj, CONTENT));
// 异步存入数据库 // 异步存入数据库
saleLogService.createLog(dto); afterSaleLogService.createLog(dto);
} catch (Exception exception) { } catch (Exception exception) {
log.error("[afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception); log.error("[doAfterReturning][afterSaleLog({}) 日志记录错误]", toJsonString(afterSaleLog), exception);
} }
} }
@ -67,6 +69,7 @@ public class AfterSaleLogAspect {
HashMap<String, String> result = Maps.newHashMapWithExpectedSize(2); HashMap<String, String> result = Maps.newHashMapWithExpectedSize(2);
Map<String, Object> spelMap = SpringExpressionUtils.parseExpression(joinPoint, info, Map<String, Object> spelMap = SpringExpressionUtils.parseExpression(joinPoint, info,
asList(afterSaleLogPoint.id(), afterSaleLogPoint.content())); asList(afterSaleLogPoint.id(), afterSaleLogPoint.content()));
// TODO @chenchen是不是抽成 3 个方法好点毕竟 map 太抽象了
// 售后ID // 售后ID
String id = MapUtil.getStr(spelMap, afterSaleLogPoint.id()); String id = MapUtil.getStr(spelMap, afterSaleLogPoint.id());
result.put(ID, id); result.put(ID, id);

View File

@ -21,7 +21,7 @@ public class TradeAfterSaleLogCreateReqDTO {
private Long id; private Long id;
/** /**
* 用户编号 * 用户编号
* <p> *
* 关联 1AdminUserDO id 字段 * 关联 1AdminUserDO id 字段
* 关联 2MemberUserDO id 字段 * 关联 2MemberUserDO id 字段
*/ */

View File

@ -398,6 +398,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
this.createLog(logDTO); this.createLog(logDTO);
} }
// TODO @CHENCHEN这个注释写在接口就好了补充重复写哈@date 应该是 @since
/** /**
* 日志记录 * 日志记录
* *
@ -416,8 +417,9 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
.setOperateType(logDTO.getOperateType()) .setOperateType(logDTO.getOperateType())
.setContent(logDTO.getContent()); .setContent(logDTO.getContent());
tradeAfterSaleLogMapper.insert(afterSaleLog); tradeAfterSaleLogMapper.insert(afterSaleLog);
// TODO @CHENCHEN代码排版哈空格要正确
}catch (Exception exception){ }catch (Exception exception){
log.error("[request({}) 日志记录错误]", toJsonString(logDTO), exception); log.error("[createLog][request({}) 日志记录错误]", toJsonString(logDTO), exception);
} }
} }
} }