trade:完善订单详情
This commit is contained in:
parent
f8b4a08fae
commit
0c1f5c9582
@ -9,6 +9,8 @@ import cn.iocoder.yudao.module.trade.controller.admin.order.vo.*;
|
||||
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
|
||||
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.dal.dataobject.order.TradeOrderLogDO;
|
||||
import cn.iocoder.yudao.module.trade.service.order.TradeOrderLogService;
|
||||
import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService;
|
||||
import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -37,6 +39,8 @@ public class TradeOrderController {
|
||||
private TradeOrderUpdateService tradeOrderUpdateService;
|
||||
@Resource
|
||||
private TradeOrderQueryService tradeOrderQueryService;
|
||||
@Resource
|
||||
private TradeOrderLogService tradeOrderLogService;
|
||||
|
||||
@Resource
|
||||
private MemberUserApi memberUserApi;
|
||||
@ -70,13 +74,15 @@ public class TradeOrderController {
|
||||
if (order == null) {
|
||||
return success(null);
|
||||
}
|
||||
|
||||
// 查询订单项
|
||||
List<TradeOrderItemDO> orderItems = tradeOrderQueryService.getOrderItemListByOrderId(id);
|
||||
// TODO @puhui999:orderLog
|
||||
|
||||
// 拼接数据
|
||||
MemberUserRespDTO user = memberUserApi.getUser(order.getUserId());
|
||||
return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, user));
|
||||
MemberUserRespDTO brokerageUser = order.getBrokerageUserId() != null ?
|
||||
memberUserApi.getUser(order.getBrokerageUserId()) : null;
|
||||
List<TradeOrderLogDO> orderLogs = tradeOrderLogService.getOrderLogListByOrderId(id);
|
||||
return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, orderLogs, user, brokerageUser));
|
||||
}
|
||||
|
||||
@GetMapping("/get-express-track-list")
|
||||
|
@ -141,4 +141,8 @@ public class TradeOrderBaseVO {
|
||||
|
||||
@Schema(description = "积分抵扣的金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Integer pointPrice;
|
||||
|
||||
@Schema(description = "VIP 减免金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "888")
|
||||
private Integer vipPrice;
|
||||
|
||||
}
|
||||
|
@ -12,24 +12,28 @@ import java.util.List;
|
||||
@Data
|
||||
public class TradeOrderDetailRespVO extends TradeOrderBaseVO {
|
||||
|
||||
@Schema(description = "收件人地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海 上海市 普陀区")
|
||||
private String receiverAreaName;
|
||||
|
||||
/**
|
||||
* 订单项列表
|
||||
*/
|
||||
private List<Item> items;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
* 下单用户信息
|
||||
*/
|
||||
private MemberUserRespVO user;
|
||||
/**
|
||||
* 推广用户信息
|
||||
*/
|
||||
private MemberUserRespVO brokerageUser;
|
||||
|
||||
/**
|
||||
* TODO 订单操作日志, 先模拟一波
|
||||
* 操作日志列表
|
||||
*/
|
||||
private List<OrderLog> logs;
|
||||
|
||||
@Schema(description = "收件人地区名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海 上海市 普陀区")
|
||||
private String receiverAreaName;
|
||||
|
||||
@Schema(description = "管理后台 - 交易订单的操作日志")
|
||||
@Data
|
||||
public static class OrderLog {
|
||||
|
@ -74,8 +74,6 @@ public class AppTradeOrderController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// TODO @芋艿:如果拼团活动、秒杀活动、砍价活动时,是不是要额外在返回活动之类的信息;
|
||||
// TODO @puhui999:需要的
|
||||
@GetMapping("/get-detail")
|
||||
@Operation(summary = "获得交易订单")
|
||||
@Parameter(name = "id", description = "交易订单编号")
|
||||
@ -91,7 +89,6 @@ public class AppTradeOrderController {
|
||||
// 查询物流公司
|
||||
DeliveryExpressDO express = order.getLogisticsId() != null && order.getLogisticsId() > 0 ?
|
||||
deliveryExpressService.getDeliveryExpress(order.getLogisticsId()) : null;
|
||||
// TODO @puhui999:如果门店自提,信息的拼接;
|
||||
// 最终组合
|
||||
return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems, tradeOrderProperties, express));
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
|
||||
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.dal.dataobject.order.TradeOrderLogDO;
|
||||
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties;
|
||||
@ -42,7 +43,6 @@ import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -115,7 +115,6 @@ public interface TradeOrderConvert {
|
||||
return createReqDTO;
|
||||
}
|
||||
|
||||
// TODO 芋艿:可简化
|
||||
default PageResult<TradeOrderPageItemRespVO> convertPage(PageResult<TradeOrderDO> pageResult,
|
||||
List<TradeOrderItemDO> orderItems,
|
||||
Map<Long, MemberUserRespDTO> memberUserMap) {
|
||||
@ -138,24 +137,19 @@ public interface TradeOrderConvert {
|
||||
ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean);
|
||||
|
||||
default TradeOrderDetailRespVO convert(TradeOrderDO order, List<TradeOrderItemDO> orderItems,
|
||||
MemberUserRespDTO user) {
|
||||
List<TradeOrderLogDO> orderLogs,
|
||||
MemberUserRespDTO user, MemberUserRespDTO brokerageUser) {
|
||||
TradeOrderDetailRespVO orderVO = convert2(order, orderItems);
|
||||
// 处理收货地址
|
||||
orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId()));
|
||||
// 处理用户信息
|
||||
orderVO.setUser(convert(user));
|
||||
// TODO puhui999:模拟订单操作日志
|
||||
ArrayList<TradeOrderDetailRespVO.OrderLog> orderLogs = new ArrayList<>();
|
||||
for (int i = 0; i < 6; i++) {
|
||||
TradeOrderDetailRespVO.OrderLog orderLog = new TradeOrderDetailRespVO.OrderLog();
|
||||
orderLog.setContent("订单操作" + i);
|
||||
orderLog.setCreateTime(LocalDateTime.now());
|
||||
orderLog.setUserType(i % 2 == 0 ? 2 : 1);
|
||||
orderLogs.add(orderLog);
|
||||
}
|
||||
orderVO.setLogs(orderLogs);
|
||||
orderVO.setBrokerageUser(convert(brokerageUser));
|
||||
// 处理日志
|
||||
orderVO.setLogs(convertList03(orderLogs));
|
||||
return orderVO;
|
||||
}
|
||||
List<TradeOrderDetailRespVO.OrderLog> convertList03(List<TradeOrderLogDO> orderLogs);
|
||||
|
||||
TradeOrderDetailRespVO convert2(TradeOrderDO order, List<TradeOrderItemDO> items);
|
||||
|
||||
@ -176,7 +170,6 @@ public interface TradeOrderConvert {
|
||||
|
||||
AppProductPropertyValueDetailRespVO convert02(ProductPropertyValueDetailRespDTO bean);
|
||||
|
||||
// TODO 芋艿:可简化
|
||||
default AppTradeOrderDetailRespVO convert02(TradeOrderDO order, List<TradeOrderItemDO> orderItems,
|
||||
TradeOrderProperties tradeOrderProperties,
|
||||
DeliveryExpressDO express) {
|
||||
@ -244,9 +237,6 @@ public interface TradeOrderConvert {
|
||||
if (address != null) {
|
||||
respVO.getAddress().setAreaName(AreaUtils.format(address.getAreaId()));
|
||||
}
|
||||
// TODO 芋艿:积分的接入;
|
||||
respVO.setUsedPoint(1);
|
||||
respVO.setTotalPoint(100);
|
||||
return respVO;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.trade.convert.order;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO;
|
||||
import cn.iocoder.yudao.module.trade.service.order.bo.logger.TradeOrderLogCreateReqBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface TradeOrderLogConvert {
|
||||
|
||||
TradeOrderLogConvert INSTANCE = Mappers.getMapper(TradeOrderLogConvert.class);
|
||||
|
||||
TradeOrderLogDO convert(TradeOrderLogCreateReqBO createReqBO);
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.module.trade.dal.mysql.order;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface TradeOrderLogMapper extends BaseMapperX<TradeOrderLogDO> {
|
||||
|
||||
default List<TradeOrderLogDO> selectListByOrderId(Long orderId) {
|
||||
return selectList(TradeOrderLogDO::getOrderId, orderId);
|
||||
}
|
||||
|
||||
}
|
@ -88,8 +88,9 @@ public class TradeOrderLogAspect {
|
||||
.setOperateType(orderLog.operateType().getType()).setContent(content);
|
||||
orderLogService.createOrderLog(createBO);
|
||||
} catch (Exception ex) {
|
||||
// todo 芋艿:清理上下文
|
||||
log.error("[doAfterReturning][orderLog({}) 订单日志错误]", toJsonString(orderLog), ex);
|
||||
} finally {
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,4 +128,13 @@ public class TradeOrderLogAspect {
|
||||
USER_TYPE.set(userType);
|
||||
}
|
||||
|
||||
private static void clear() {
|
||||
USER_ID.remove();
|
||||
USER_TYPE.remove();
|
||||
ORDER_ID.remove();
|
||||
BEFORE_STATUS.remove();
|
||||
AFTER_STATUS.remove();
|
||||
EXTS.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,9 @@ public class TradeMessageServiceImpl implements TradeMessageService {
|
||||
|
||||
@Override
|
||||
public void sendMessageWhenDeliveryOrder(TradeOrderMessageWhenDeliveryOrderReqBO reqBO) {
|
||||
if (true) {
|
||||
return;
|
||||
}
|
||||
// 1、构造消息
|
||||
Map<String, Object> msgMap = new HashMap<>(2);
|
||||
msgMap.put("orderId", reqBO.getOrderId());
|
||||
|
@ -1,8 +1,11 @@
|
||||
package cn.iocoder.yudao.module.trade.service.order;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO;
|
||||
import cn.iocoder.yudao.module.trade.service.order.bo.logger.TradeOrderLogCreateReqBO;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交易下单日志 Service 接口
|
||||
*
|
||||
@ -21,4 +24,12 @@ public interface TradeOrderLogService {
|
||||
@Async
|
||||
void createOrderLog(TradeOrderLogCreateReqBO logDTO);
|
||||
|
||||
/**
|
||||
* 获得交易订单日志列表
|
||||
*
|
||||
* @param orderId 订单编号
|
||||
* @return 交易订单日志列表
|
||||
*/
|
||||
List<TradeOrderLogDO> getOrderLogListByOrderId(Long orderId);
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,14 @@
|
||||
package cn.iocoder.yudao.module.trade.service.order;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderLogConvert;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderLogMapper;
|
||||
import cn.iocoder.yudao.module.trade.service.order.bo.logger.TradeOrderLogCreateReqBO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交易下单日志 Service 实现类
|
||||
*
|
||||
@ -12,10 +18,17 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class TradeOrderLogServiceImpl implements TradeOrderLogService {
|
||||
|
||||
@Resource
|
||||
private TradeOrderLogMapper tradeOrderLogMapper;
|
||||
|
||||
@Override
|
||||
public void createOrderLog(TradeOrderLogCreateReqBO createReqBO) {
|
||||
// TODO 芋艿:存储还没搞
|
||||
System.out.println();
|
||||
tradeOrderLogMapper.insert(TradeOrderLogConvert.INSTANCE.convert(createReqBO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TradeOrderLogDO> getOrderLogListByOrderId(Long orderId) {
|
||||
return tradeOrderLogMapper.selectListByOrderId(orderId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -211,8 +211,6 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
return order;
|
||||
}
|
||||
|
||||
// TODO @puhui999:订单超时,自动取消;
|
||||
|
||||
private TradeOrderDO createTradeOrder(Long userId, String clientIp, AppTradeOrderCreateReqVO createReqVO,
|
||||
TradePriceCalculateRespBO calculateRespBO) {
|
||||
TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(userId, clientIp, createReqVO, calculateRespBO);
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.service.order.bo.logger;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
@ -42,10 +43,12 @@ public class TradeOrderLogCreateReqBO {
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
@NotNull(message = "操作类型不能为空")
|
||||
private Integer operateType;
|
||||
/**
|
||||
* 操作明细
|
||||
*/
|
||||
@NotEmpty(message = "操作明细不能为空")
|
||||
private String content;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user