mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
mall + order:review 售后日志
This commit is contained in:
parent
07884ef423
commit
1dfbe45913
@ -97,6 +97,7 @@ public class SpringExpressionUtils {
|
||||
* @author 陈賝
|
||||
* @since 2023/6/18 11:20
|
||||
*/
|
||||
// TODO @chenchen: 这个方法,和 parseExpressions 比较接近,是不是可以合并下;
|
||||
public static Map<String, Object> parseExpression(JoinPoint joinPoint, Object info, List<String> expressionStrings) {
|
||||
// 如果为空,则不进行解析
|
||||
if (CollUtil.isEmpty(expressionStrings)) {
|
||||
@ -115,7 +116,7 @@ public class SpringExpressionUtils {
|
||||
//获取方法参数值
|
||||
Object[] args = joinPoint.getArgs();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
//替换spel里的变量值为实际值, 比如 #user --> user对象
|
||||
// 替换 SP EL 里的变量值为实际值, 比如 #user --> user对象
|
||||
context.setVariable(parameterNames[i], args[i]);
|
||||
}
|
||||
context.setVariable("info", info);
|
||||
|
@ -6,6 +6,7 @@ package cn.iocoder.yudao.module.trade.enums.aftersale;
|
||||
* @author 陈賝
|
||||
* @since 2023/6/13 13:53
|
||||
*/
|
||||
// TODO @chenchen:可以 lombok 简化构造方法,和 get 方法
|
||||
public enum AfterSaleOperateTypeEnum {
|
||||
|
||||
/**
|
||||
|
@ -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.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
|
||||
import cn.iocoder.yudao.module.trade.enums.aftersale.TradeAfterSaleStatusEnum;
|
||||
import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@ -51,8 +49,11 @@ public class TradeAfterSaleLogDO extends BaseDO {
|
||||
* 关联 {@link TradeAfterSaleDO#getId()}
|
||||
*/
|
||||
private Long afterSaleId;
|
||||
// todo @CHENCHEN: 改成 Integer 哈;主要未来改文案,不好洗 log 存的字段;
|
||||
/**
|
||||
* 操作类型 {@link TradeAfterSaleStatusEnum}
|
||||
* 操作类型
|
||||
*
|
||||
* 枚举 {@link AfterSaleOperateTypeEnum}
|
||||
*/
|
||||
private String operateType;
|
||||
/**
|
||||
|
@ -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.Configuration;
|
||||
|
||||
// TODO @chenchen:改成 aftersale 好点哈;
|
||||
/**
|
||||
* trade 模块的 afterSaleLog 组件的 Configuration
|
||||
*
|
||||
|
@ -5,10 +5,13 @@ import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleOperateTypeEnum;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 售后日志
|
||||
* 售后日志的注解
|
||||
*
|
||||
* 写在方法上时,会自动记录售后日志
|
||||
*
|
||||
* @author 陈賝
|
||||
* @since 2023/6/8 17:04
|
||||
* @see cn.iocoder.yudao.module.trade.framework.aftersalelog.core.aop.AfterSaleLogAspect
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -30,9 +30,11 @@ import static java.util.Arrays.asList;
|
||||
@Slf4j
|
||||
@Aspect
|
||||
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";
|
||||
|
||||
/**
|
||||
@ -52,9 +54,9 @@ public class AfterSaleLogAspect {
|
||||
.setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE))
|
||||
.setContent(MapUtil.getStr(formatObj, CONTENT));
|
||||
// 异步存入数据库
|
||||
saleLogService.createLog(dto);
|
||||
afterSaleLogService.createLog(dto);
|
||||
} 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);
|
||||
Map<String, Object> spelMap = SpringExpressionUtils.parseExpression(joinPoint, info,
|
||||
asList(afterSaleLogPoint.id(), afterSaleLogPoint.content()));
|
||||
// TODO @chenchen:是不是抽成 3 个方法好点;毕竟 map 太抽象了;;
|
||||
// 售后ID
|
||||
String id = MapUtil.getStr(spelMap, afterSaleLogPoint.id());
|
||||
result.put(ID, id);
|
||||
|
@ -21,7 +21,7 @@ public class TradeAfterSaleLogCreateReqDTO {
|
||||
private Long id;
|
||||
/**
|
||||
* 用户编号
|
||||
* <p>
|
||||
*
|
||||
* 关联 1:AdminUserDO 的 id 字段
|
||||
* 关联 2:MemberUserDO 的 id 字段
|
||||
*/
|
||||
|
@ -398,6 +398,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
|
||||
this.createLog(logDTO);
|
||||
}
|
||||
|
||||
// TODO @CHENCHEN:这个注释,写在接口就好了,补充重复写哈;@date 应该是 @since
|
||||
/**
|
||||
* 日志记录
|
||||
*
|
||||
@ -416,8 +417,9 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
|
||||
.setOperateType(logDTO.getOperateType())
|
||||
.setContent(logDTO.getContent());
|
||||
tradeAfterSaleLogMapper.insert(afterSaleLog);
|
||||
// TODO @CHENCHEN:代码排版哈;空格要正确
|
||||
}catch (Exception exception){
|
||||
log.error("[request({}) 日志记录错误]", toJsonString(logDTO), exception);
|
||||
log.error("[createLog][request({}) 日志记录错误]", toJsonString(logDTO), exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user