From fe07e223e4403f1797ea5c5f08f73c18d80d0d49 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 18 Aug 2023 19:28:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=EF=BC=9A=201=E3=80=81?= =?UTF-8?q?=E7=AE=80=E5=8C=96=E4=BA=A4=E6=98=93=E8=AE=A2=E5=8D=95=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/order/TradeOrderController.java | 18 +---- .../app/order/AppTradeOrderController.java | 5 +- .../convert/order/TradeOrderConvert.java | 81 ++----------------- 3 files changed, 13 insertions(+), 91 deletions(-) diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java index 786be10d7..62ef72597 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java @@ -5,8 +5,6 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; -import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi; -import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDetailRespVO; import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO; @@ -44,8 +42,6 @@ public class TradeOrderController { @Resource private TradeOrderQueryService tradeOrderQueryService; - @Resource - private ProductPropertyValueApi productPropertyValueApi; @Resource private MemberUserApi memberUserApi; @@ -64,11 +60,8 @@ public class TradeOrderController { // 查询订单项 List orderItems = tradeOrderQueryService.getOrderItemListByOrderId( convertSet(pageResult.getList(), TradeOrderDO::getId)); - // 查询商品属性 - List propertyValueDetails = productPropertyValueApi - .getPropertyValueDetailList(TradeOrderConvert.INSTANCE.convertPropertyValueIds(orderItems)); // 最终组合 - return success(TradeOrderConvert.INSTANCE.convertPage(pageResult, orderItems, propertyValueDetails, userMap)); + return success(TradeOrderConvert.INSTANCE.convertPage(pageResult, orderItems, userMap)); } @GetMapping("/get-detail") @@ -80,13 +73,10 @@ public class TradeOrderController { TradeOrderDO order = tradeOrderQueryService.getOrder(id); // 查询订单项 List orderItems = tradeOrderQueryService.getOrderItemListByOrderId(id); - // 查询商品属性 - List propertyValueDetails = productPropertyValueApi - .getPropertyValueDetailList(TradeOrderConvert.INSTANCE.convertPropertyValueIds(orderItems)); - // 查询会员 + + // 拼接数据 MemberUserRespDTO user = memberUserApi.getUser(order.getUserId()); - // 最终组合 - return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, propertyValueDetails, user)); + return success(TradeOrderConvert.INSTANCE.convert(order, orderItems, user)); } @PostMapping("/delivery") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java index 6456db122..8a34f1180 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java @@ -118,11 +118,8 @@ public class AppTradeOrderController { // 查询订单项 List orderItems = tradeOrderQueryService.getOrderItemListByOrderId( convertSet(pageResult.getList(), TradeOrderDO::getId)); - // 查询商品属性 - List propertyValueDetails = productPropertyValueApi - .getPropertyValueDetailList(TradeOrderConvert.INSTANCE.convertPropertyValueIds(orderItems)); // 最终组合 - return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems, propertyValueDetails)); + return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems)); } @GetMapping("/get-count") diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java index 04749e7c8..3728ea58b 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java @@ -14,7 +14,6 @@ import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDT import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; -import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; @@ -84,9 +83,6 @@ public interface TradeOrderConvert { TradeOrderItemDO convert(TradePriceCalculateRespBO.OrderItem item); - @Mapping(source = "userId", target = "userId") - PriceCalculateReqDTO convert(AppTradeOrderCreateReqVO createReqVO, Long userId); - @Mappings({ @Mapping(source = "skuId", target = "id"), @Mapping(source = "count", target = "incrCount"), @@ -123,38 +119,18 @@ public interface TradeOrderConvert { } // TODO 芋艿:可简化 - default PageResult convertPage(PageResult pageResult, List orderItems, - List propertyValueDetails, - Map memberUserRespDTOMap) { + default PageResult convertPage(PageResult pageResult, + List orderItems, + Map memberUserMap) { Map> orderItemMap = convertMultiMap(orderItems, TradeOrderItemDO::getOrderId); - Map propertyValueDetailMap = convertMap(propertyValueDetails, ProductPropertyValueDetailRespDTO::getValueId); // 转化 List List orderVOs = CollectionUtils.convertList(pageResult.getList(), order -> { List xOrderItems = orderItemMap.get(order.getId()); TradeOrderPageItemRespVO orderVO = convert(order, xOrderItems); - if (CollUtil.isNotEmpty(xOrderItems)) { - // 处理商品属性 - for (int i = 0; i < xOrderItems.size(); i++) { - List properties = xOrderItems.get(i).getProperties(); - if (CollUtil.isEmpty(properties)) { - continue; - } - TradeOrderPageItemRespVO.Item item = orderVO.getItems().get(i); - item.setProperties(new ArrayList<>(properties.size())); - // 遍历每个 properties,设置到 TradeOrderPageItemRespVO.Item 中 - properties.forEach(property -> { - ProductPropertyValueDetailRespDTO propertyValueDetail = propertyValueDetailMap.get(property.getValueId()); - if (propertyValueDetail == null) { - return; - } - item.getProperties().add(convert(propertyValueDetail)); - }); - } - } // 处理收货地址 orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); // 增加用户昵称 - orderVO.setUser(memberUserRespDTOMap.get(orderVO.getUserId())); + orderVO.setUser(memberUserMap.get(orderVO.getUserId())); return orderVO; }); return new PageResult<>(orderVOs, pageResult.getTotal()); @@ -164,28 +140,9 @@ public interface TradeOrderConvert { ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean); - // TODO 芋艿:可简化 default TradeOrderDetailRespVO convert(TradeOrderDO order, List orderItems, - List propertyValueDetails, MemberUserRespDTO user) { + MemberUserRespDTO user) { TradeOrderDetailRespVO orderVO = convert2(order, orderItems); - // 处理商品属性 - Map propertyValueDetailMap = convertMap(propertyValueDetails, ProductPropertyValueDetailRespDTO::getValueId); - for (int i = 0; i < orderItems.size(); i++) { - List properties = orderItems.get(i).getProperties(); - if (CollUtil.isEmpty(properties)) { - continue; - } - TradeOrderDetailRespVO.Item item = orderVO.getItems().get(i); - item.setProperties(new ArrayList<>(properties.size())); - // 遍历每个 properties,设置到 TradeOrderPageItemRespVO.Item 中 - properties.forEach(property -> { - ProductPropertyValueDetailRespDTO propertyValueDetail = propertyValueDetailMap.get(property.getValueId()); - if (propertyValueDetail == null) { - return; - } - item.getProperties().add(convert(propertyValueDetail)); - }); - } // 处理收货地址 orderVO.setReceiverAreaName(AreaUtils.format(order.getReceiverAreaId())); // 处理用户信息 @@ -197,35 +154,13 @@ public interface TradeOrderConvert { MemberUserRespVO convert(MemberUserRespDTO bean); - // TODO 芋艿:可简化 - default PageResult convertPage02(PageResult pageResult, List orderItems, - List propertyValueDetails) { + default PageResult convertPage02(PageResult pageResult, + List orderItems) { Map> orderItemMap = convertMultiMap(orderItems, TradeOrderItemDO::getOrderId); - Map propertyValueDetailMap = convertMap(propertyValueDetails, ProductPropertyValueDetailRespDTO::getValueId); // 转化 List List orderVOs = CollectionUtils.convertList(pageResult.getList(), order -> { List xOrderItems = orderItemMap.get(order.getId()); - AppTradeOrderPageItemRespVO orderVO = convert02(order, xOrderItems); - if (CollUtil.isNotEmpty(xOrderItems)) { - // 处理商品属性 - for (int i = 0; i < xOrderItems.size(); i++) { - List properties = xOrderItems.get(i).getProperties(); - if (CollUtil.isEmpty(properties)) { - continue; - } - AppTradeOrderItemRespVO item = orderVO.getItems().get(i); - item.setProperties(new ArrayList<>(properties.size())); - // 遍历每个 properties,设置到 TradeOrderPageItemRespVO.Item 中 - properties.forEach(property -> { - ProductPropertyValueDetailRespDTO propertyValueDetail = propertyValueDetailMap.get(property.getValueId()); - if (propertyValueDetail == null) { - return; - } - item.getProperties().add(convert02(propertyValueDetail)); - }); - } - } - return orderVO; + return convert02(order, xOrderItems); }); return new PageResult<>(orderVOs, pageResult.getTotal()); }