diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/OrderItemService.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/OrderItemService.java index 2f9f9c63..a1fc9a97 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/OrderItemService.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/OrderItemService.java @@ -3,15 +3,19 @@ package com.skyeye.order.service; import com.skyeye.base.business.service.SkyeyeBusinessService; import com.skyeye.common.enumeration.WhetherEnum; import com.skyeye.order.entity.OrderItem; +import org.aspectj.weaver.ast.Or; import java.util.List; +import java.util.Map; public interface OrderItemService extends SkyeyeBusinessService { void deleteByPerentIds(List ids); - List selectByParentId(String id); +// List selectByParentId(String id); List queryListByStateAndOrderId(String orderId, Integer state); + + Map> queryListByParentId(String... idList); } diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderItemServiceImpl.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderItemServiceImpl.java index 53e82d9c..198fc051 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderItemServiceImpl.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderItemServiceImpl.java @@ -4,31 +4,32 @@ import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.skyeye.annotation.service.SkyeyeService; import com.skyeye.base.business.service.impl.SkyeyeBusinessServiceImpl; -import com.skyeye.common.constans.CommonNumConstants; -import com.skyeye.common.util.CalculationUtil; import com.skyeye.common.util.mybatisplus.MybatisPlusUtil; -import com.skyeye.coupon.enums.CouponUseState; -import com.skyeye.coupon.enums.PromotionDiscountType; -import com.skyeye.coupon.service.CouponUseService; -import com.skyeye.erp.service.IMaterialNormsService; -import com.skyeye.erp.service.IMaterialService; -import com.skyeye.exception.CustomException; import com.skyeye.order.dao.OrderItemDao; -import com.skyeye.order.entity.Order; import com.skyeye.order.entity.OrderItem; -import com.skyeye.order.enums.ShopOrderCommentState; import com.skyeye.order.service.OrderItemService; +import com.skyeye.rest.shopmaterialnorms.sevice.IShopMaterialNormsService; +import com.skyeye.store.service.ShopStoreService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -import java.util.Objects; +import java.util.Map; +import java.util.stream.Collectors; @Service @SkyeyeService(name = "商品订单子单项管理", groupName = "商品订单子单项管理") public class OrderItemServiceImpl extends SkyeyeBusinessServiceImpl implements OrderItemService { + + @Autowired + private IShopMaterialNormsService iShopMaterialNormsService; + + @Autowired + private ShopStoreService shopStoreService; + @Override public void deleteByPerentIds(List ids) { QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -36,12 +37,19 @@ public class OrderItemServiceImpl extends SkyeyeBusinessServiceImpl selectByParentId(String parentId) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq(MybatisPlusUtil.toColumns(OrderItem::getParentId), parentId); - return list(queryWrapper); - } +// @Override +// public List selectByParentId(String parentId) { +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.eq(MybatisPlusUtil.toColumns(OrderItem::getParentId), parentId); +// List> mapList = listMaps(queryWrapper); +// Map> collect = mapList.stream().collect(Collectors.toMap(map -> map.get("id").toString(), map -> map)); +// List materialStoreIds = mapList.stream().map(map -> map.get("materialStoreId").toString()).collect(Collectors.toList()); +// List> materialByIds = iShopMaterialNormsService.queryShopMaterialByIds(materialStoreIds); +// for (Map map : materialByIds) { +// collect.get(map.get("id").toString()).put("materialMation", map); +// } +// return BeanUtil.copyToList(mapList, OrderItem.class); +// } @Override public List queryListByStateAndOrderId(String orderId, Integer state) { @@ -51,4 +59,20 @@ public class OrderItemServiceImpl extends SkyeyeBusinessServiceImpl list = list(queryWrapper); return CollectionUtil.isEmpty(list) ? new ArrayList<>() : list; } + + @Override + public Map> queryListByParentId(String... idList) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in(MybatisPlusUtil.toColumns(OrderItem::getId), Arrays.asList(idList)); + List mapList = list(queryWrapper); + shopStoreService.setDataMation(mapList, OrderItem::getStoreId); + List materialStoreIds = mapList.stream().map(OrderItem::getMaterialStoreId).distinct().collect(Collectors.toList()); + List> materialByIds = iShopMaterialNormsService.queryShopMaterialByIds(materialStoreIds); + Map> materialMap = materialByIds.stream().collect(Collectors.toMap(map -> map.get("id").toString(), map -> map)); + mapList.forEach(map -> { + map.setMaterialMation(materialMap.get(map.getMaterialStoreId())); + }); + Map> result = mapList.stream().collect(Collectors.groupingBy(OrderItem::getParentId)); + return result; + } } \ No newline at end of file diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java index 596f4017..4503b6e0 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/order/service/impl/OrderServiceImpl.java @@ -30,6 +30,8 @@ import com.skyeye.order.enums.ShopOrderCommentState; import com.skyeye.order.enums.ShopOrderState; import com.skyeye.order.service.OrderItemService; import com.skyeye.order.service.OrderService; +import com.skyeye.rest.shopmaterialnorms.sevice.IShopMaterialNormsService; +import com.skyeye.store.service.ShopStoreService; import com.xxl.job.core.util.IpUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -258,9 +260,10 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl return CollectionUtil.newArrayList(); } List idList = list.stream().map(map -> map.get("id").toString()).collect(Collectors.toList()); - Map> mapByIds = orderItemService.selectValIsMapByIds(idList); + Map> mapByIds = orderItemService.queryListByParentId(String.valueOf(idList)); for (Map map : list) { - map.put(map.get("id").toString(), mapByIds.get("id")); + String id = map.get("id").toString(); + map.put("orderItem", mapByIds.containsKey(id) ? mapByIds.get("id") : new ArrayList<>()); } iAreaService.setMationForMap(list, "provinceId", "provinceMation"); iAreaService.setMationForMap(list, "cityId", "cityMation"); @@ -278,8 +281,8 @@ public class OrderServiceImpl extends SkyeyeBusinessServiceImpl @Override public Order selectById(String id) { Order order = super.selectById(id); - List orderItemList = orderItemService.selectByParentId(id); - order.setOrderItemList(orderItemList); + Map> orderItemList = orderItemService.queryListByParentId(id); + order.setOrderItemList(orderItemList.get(order.getId())); iAreaService.setDataMation(order, Order::getProvinceId); iAreaService.setDataMation(order, Order::getCityId); iAreaService.setDataMation(order, Order::getAreaId);