mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-26 00:45:08 +08:00
售后日志优化,map->抽方法
This commit is contained in:
@ -54,7 +54,7 @@ public class TradeAfterSaleLogDO extends BaseDO {
|
|||||||
*
|
*
|
||||||
* 枚举 {@link AfterSaleOperateTypeEnum}
|
* 枚举 {@link AfterSaleOperateTypeEnum}
|
||||||
*/
|
*/
|
||||||
private String operateType;
|
private Integer operateType;
|
||||||
/**
|
/**
|
||||||
* 操作明细
|
* 操作明细
|
||||||
*/
|
*/
|
||||||
|
@ -4,6 +4,7 @@ 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.web.core.util.WebFrameworkUtils;
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||||
|
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.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;
|
||||||
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service.AfterSaleLogService;
|
import cn.iocoder.yudao.module.trade.framework.aftersalelog.core.service.AfterSaleLogService;
|
||||||
@ -47,13 +48,12 @@ public class AfterSaleLogAspect {
|
|||||||
// 日志对象拼接
|
// 日志对象拼接
|
||||||
Integer userType = WebFrameworkUtils.getLoginUserType();
|
Integer userType = WebFrameworkUtils.getLoginUserType();
|
||||||
Long id = WebFrameworkUtils.getLoginUserId();
|
Long id = WebFrameworkUtils.getLoginUserId();
|
||||||
Map<String, String> formatObj = spelFormat(joinPoint, info);
|
|
||||||
TradeAfterSaleLogCreateReqDTO dto = new TradeAfterSaleLogCreateReqDTO()
|
TradeAfterSaleLogCreateReqDTO dto = new TradeAfterSaleLogCreateReqDTO()
|
||||||
.setUserId(id)
|
.setUserId(id)
|
||||||
.setUserType(userType)
|
.setUserType(userType)
|
||||||
.setAfterSaleId(MapUtil.getLong(formatObj, ID))
|
.setAfterSaleId(getAfterSaleId(joinPoint, info, afterSaleLog.id()))
|
||||||
.setOperateType(MapUtil.getStr(formatObj, OPERATE_TYPE))
|
.setOperateType(afterSaleLog.operateType().getType())
|
||||||
.setContent(MapUtil.getStr(formatObj, CONTENT));
|
.setContent(getContent(joinPoint, info, afterSaleLog));
|
||||||
// 异步存入数据库
|
// 异步存入数据库
|
||||||
afterSaleLogService.createLog(dto);
|
afterSaleLogService.createLog(dto);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
@ -64,26 +64,49 @@ public class AfterSaleLogAspect {
|
|||||||
/**
|
/**
|
||||||
* 获取描述信息
|
* 获取描述信息
|
||||||
*/
|
*/
|
||||||
public static Map<String, String> spelFormat(JoinPoint joinPoint, Object info) {
|
private static Map<String, Object> spelFormat(JoinPoint joinPoint, Object info) {
|
||||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||||
AfterSaleLog afterSaleLogPoint = signature.getMethod().getAnnotation(AfterSaleLog.class);
|
AfterSaleLog afterSaleLogPoint = signature.getMethod().getAnnotation(AfterSaleLog.class);
|
||||||
HashMap<String, String> result = Maps.newHashMapWithExpectedSize(2);
|
return 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
|
|
||||||
String id = MapUtil.getStr(spelMap, afterSaleLogPoint.id());
|
|
||||||
result.put(ID, id);
|
|
||||||
// 操作类型
|
|
||||||
String operateType = afterSaleLogPoint.operateType().description();
|
|
||||||
result.put(OPERATE_TYPE, operateType);
|
|
||||||
// 日志内容
|
|
||||||
String content = MapUtil.getStr(spelMap, afterSaleLogPoint.content());
|
|
||||||
if (ObjectUtil.isNotNull(afterSaleLogPoint.operateType())) {
|
|
||||||
content += operateType;
|
|
||||||
}
|
|
||||||
result.put(CONTENT, content);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取售后ID
|
||||||
|
*/
|
||||||
|
private static Long getAfterSaleId(JoinPoint joinPoint, Object info, String spel) {
|
||||||
|
Map<String, Object> spelMap = spelFormat(joinPoint, info);
|
||||||
|
return MapUtil.getLong(spelMap, spel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取解析后的日志内容
|
||||||
|
*/
|
||||||
|
private static String getContent(JoinPoint joinPoint, Object info, AfterSaleLog afterSaleLog) {
|
||||||
|
Map<String, Object> spelMap = spelFormat(joinPoint, info);
|
||||||
|
StringBuilder content = new StringBuilder().append(MapUtil.getStr(spelMap, afterSaleLog.content()));
|
||||||
|
AfterSaleOperateTypeEnum afterSaleOperateTypeEnum = afterSaleLog.operateType();
|
||||||
|
return ObjectUtil.isNotNull(afterSaleOperateTypeEnum) ?
|
||||||
|
content.append(afterSaleOperateTypeEnum.getDescription()).toString() : content.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static Map<String, Object> spelFormat(JoinPoint joinPoint, Object info) {
|
||||||
|
// MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||||
|
// AfterSaleLog afterSaleLogPoint = signature.getMethod().getAnnotation(AfterSaleLog.class);
|
||||||
|
// HashMap<String, Object> result = Maps.newHashMapWithExpectedSize(2);
|
||||||
|
// Map<String, Object> spelMap = SpringExpressionUtils.parseExpression(joinPoint, info,
|
||||||
|
// asList(afterSaleLogPoint.id(), afterSaleLogPoint.content()));
|
||||||
|
//
|
||||||
|
// // 售后ID
|
||||||
|
// result.put(ID, MapUtil.getLong(spelMap, afterSaleLogPoint.id()));
|
||||||
|
// // 操作类型
|
||||||
|
// result.put(OPERATE_TYPE, afterSaleLogPoint.operateType().getType());
|
||||||
|
// // 日志内容
|
||||||
|
// StringBuilder content = new StringBuilder().append(MapUtil.getStr(spelMap, afterSaleLogPoint.content()));
|
||||||
|
//
|
||||||
|
// result.put(CONTENT, ObjectUtil.isNotNull(afterSaleLogPoint.operateType()) ?
|
||||||
|
// content.append(afterSaleLogPoint.operateType().getDescription()).toString() : content.toString());
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class TradeAfterSaleLogCreateReqDTO {
|
|||||||
/**
|
/**
|
||||||
* 操作类型
|
* 操作类型
|
||||||
*/
|
*/
|
||||||
private String operateType;
|
private Integer operateType;
|
||||||
/**
|
/**
|
||||||
* 操作明细
|
* 操作明细
|
||||||
*/
|
*/
|
||||||
|
@ -393,7 +393,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
|
|||||||
.setUserId(userId)
|
.setUserId(userId)
|
||||||
.setUserType(userType)
|
.setUserType(userType)
|
||||||
.setAfterSaleId(afterSale.getId())
|
.setAfterSaleId(afterSale.getId())
|
||||||
.setOperateType(afterStatus.toString());
|
.setOperateType(afterStatus);
|
||||||
// TODO 废弃,待删除
|
// TODO 废弃,待删除
|
||||||
this.createLog(logDTO);
|
this.createLog(logDTO);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user