mirror of
https://github.com/weizhiqiang1995/erp-pro.git
synced 2024-12-29 11:29:58 +08:00
feat: 订单子单返回商品信息和门店信息
This commit is contained in:
parent
aa93a8301a
commit
4503ab6a8d
3 changed files with 53 additions and 22 deletions
|
@ -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<OrderItem> {
|
||||
|
||||
|
||||
void deleteByPerentIds(List<String> ids);
|
||||
|
||||
List<OrderItem> selectByParentId(String id);
|
||||
// List<OrderItem> selectByParentId(String id);
|
||||
|
||||
List<OrderItem> queryListByStateAndOrderId(String orderId, Integer state);
|
||||
|
||||
Map<String, List<OrderItem>> queryListByParentId(String... idList);
|
||||
}
|
||||
|
|
|
@ -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<OrderItemDao, OrderItem> implements OrderItemService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private IShopMaterialNormsService iShopMaterialNormsService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreService shopStoreService;
|
||||
|
||||
@Override
|
||||
public void deleteByPerentIds(List<String> ids) {
|
||||
QueryWrapper<OrderItem> queryWrapper = new QueryWrapper<>();
|
||||
|
@ -36,12 +37,19 @@ public class OrderItemServiceImpl extends SkyeyeBusinessServiceImpl<OrderItemDao
|
|||
remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderItem> selectByParentId(String parentId) {
|
||||
QueryWrapper<OrderItem> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(MybatisPlusUtil.toColumns(OrderItem::getParentId), parentId);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
// @Override
|
||||
// public List<OrderItem> selectByParentId(String parentId) {
|
||||
// QueryWrapper<OrderItem> queryWrapper = new QueryWrapper<>();
|
||||
// queryWrapper.eq(MybatisPlusUtil.toColumns(OrderItem::getParentId), parentId);
|
||||
// List<Map<String, Object>> mapList = listMaps(queryWrapper);
|
||||
// Map<String, Map<String, Object>> collect = mapList.stream().collect(Collectors.toMap(map -> map.get("id").toString(), map -> map));
|
||||
// List<String> materialStoreIds = mapList.stream().map(map -> map.get("materialStoreId").toString()).collect(Collectors.toList());
|
||||
// List<Map<String, Object>> materialByIds = iShopMaterialNormsService.queryShopMaterialByIds(materialStoreIds);
|
||||
// for (Map<String, Object> map : materialByIds) {
|
||||
// collect.get(map.get("id").toString()).put("materialMation", map);
|
||||
// }
|
||||
// return BeanUtil.copyToList(mapList, OrderItem.class);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<OrderItem> queryListByStateAndOrderId(String orderId, Integer state) {
|
||||
|
@ -51,4 +59,20 @@ public class OrderItemServiceImpl extends SkyeyeBusinessServiceImpl<OrderItemDao
|
|||
List<OrderItem> list = list(queryWrapper);
|
||||
return CollectionUtil.isEmpty(list) ? new ArrayList<>() : list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<OrderItem>> queryListByParentId(String... idList) {
|
||||
QueryWrapper<OrderItem> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in(MybatisPlusUtil.toColumns(OrderItem::getId), Arrays.asList(idList));
|
||||
List<OrderItem> mapList = list(queryWrapper);
|
||||
shopStoreService.setDataMation(mapList, OrderItem::getStoreId);
|
||||
List<String> materialStoreIds = mapList.stream().map(OrderItem::getMaterialStoreId).distinct().collect(Collectors.toList());
|
||||
List<Map<String, Object>> materialByIds = iShopMaterialNormsService.queryShopMaterialByIds(materialStoreIds);
|
||||
Map<String, Map<String, Object>> materialMap = materialByIds.stream().collect(Collectors.toMap(map -> map.get("id").toString(), map -> map));
|
||||
mapList.forEach(map -> {
|
||||
map.setMaterialMation(materialMap.get(map.getMaterialStoreId()));
|
||||
});
|
||||
Map<String, List<OrderItem>> result = mapList.stream().collect(Collectors.groupingBy(OrderItem::getParentId));
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -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<OrderDao, Order>
|
|||
return CollectionUtil.newArrayList();
|
||||
}
|
||||
List<String> idList = list.stream().map(map -> map.get("id").toString()).collect(Collectors.toList());
|
||||
Map<String, Map<String, Object>> mapByIds = orderItemService.selectValIsMapByIds(idList);
|
||||
Map<String, List<OrderItem>> mapByIds = orderItemService.queryListByParentId(String.valueOf(idList));
|
||||
for (Map<String, Object> 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<OrderDao, Order>
|
|||
@Override
|
||||
public Order selectById(String id) {
|
||||
Order order = super.selectById(id);
|
||||
List<OrderItem> orderItemList = orderItemService.selectByParentId(id);
|
||||
order.setOrderItemList(orderItemList);
|
||||
Map<String, List<OrderItem>> 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);
|
||||
|
|
Loading…
Reference in a new issue