From 39a54c860830baa9fb42d0e3e90843f455f7d05e Mon Sep 17 00:00:00 2001
From: rentaiming <806181062@qq.com>
Date: 星期一, 03 六月 2024 10:03:58 +0800
Subject: [PATCH] 修改循环注入

---
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java |   65 ++++++++++++++++++++++++++++++--
 1 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
index 07cb825..334950d 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -1,13 +1,24 @@
 package com.ruoyi.order.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.core.enums.OrderStatusEnum;
-import com.ruoyi.order.domain.pojo.Order;
+import com.ruoyi.order.domain.OrderMall;
 import com.ruoyi.order.mapper.OrderMapper;
+import com.ruoyi.order.service.IOrderMallService;
 import com.ruoyi.order.service.IOrderService;
 import com.ruoyi.order.util.OrderUtil;
+import com.ruoyi.system.api.domain.Order;
+import com.ruoyi.system.api.domain.OrderAuctionBond;
+import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO;
 import com.ruoyi.system.api.domain.dto.OrderDTO;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
 import javax.annotation.Resource;
+
+import com.ruoyi.system.api.domain.vo.OrderVO;
 import org.springframework.stereotype.Service;
 
 /**
@@ -22,8 +33,9 @@
 public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {
 
 
+
     @Resource
-    private  IOrderService orderService;
+    private IOrderMallService orderMallService;
     @Override
     public void saveOrderOne(OrderDTO OrderDTO) {
         Order order=new Order();
@@ -41,11 +53,56 @@
         order.setReceiverCity(OrderDTO.getReceiverCity());
         order.setReceiverDetailAddress(OrderDTO.getReceiverDetailAddress());
         order.setBound(OrderDTO.getBound());
-        orderService.save(order);
+        this.save(order);
     }
+
+    /**
+     * 获取某个商品的已购会员数
+     *
+     * @param id 秒杀商品id
+     * @return 已购会员数
+     */
     @Override
     public Integer getSeckillMembers(Long id) {
         return baseMapper.getSeckillMembers(id);
     }
-    
+
+    /**
+     * 获取团购商品已购数量
+     *
+     * @param id 团购商品id
+     * @return 团购商品已购数量
+     */
+    @Override
+    public Integer getGroupPurchasesGoodsNum(Long id) {
+        Set<Long> orderIdSet = orderMallService.lambdaQuery().eq(OrderMall::getActivityId, id)
+                .list()
+                .stream().map(OrderMall::getOrderId).collect(
+                        Collectors.toSet());
+        List<Order> list = this.lambdaQuery().in(Order::getId, orderIdSet)
+                .in(Order::getOrderStatus, OrderStatusEnum.TO_BE_SHIPPED,
+                        OrderStatusEnum.GOODS_TO_BE_RECEIVED, OrderStatusEnum.FINISHED).list();
+        return list.stream().map(Order::getGoodsQuantity).reduce(0, Integer::sum);
+    }
+
+    /**
+     * 根据团购商品id获取团购商品订单
+     *
+     * @param id 团购商品id
+     * @return 订单列表
+     */
+    @Override
+    public List<Order> getOrderByGroupPurchaseId(Long id) {
+        return baseMapper.getOrderByGroupPurchaseId(id);
+    }
+
+    @Override
+    public Order getOrderByGroupPurchaseMemberId(HomeGoodsSkuDTO homeGoodsSkuDTO) {
+        return baseMapper.getOrderByGroupPurchaseMemberId(homeGoodsSkuDTO);
+    }
+
+    @Override
+    public List<OrderVO> getOrderByGroupPurchaseMemberList(HomeGoodsSkuDTO homeGoodsSkuDTO) {
+        return baseMapper.getOrderByGroupPurchaseMemberList(homeGoodsSkuDTO);
+    }
 }

--
Gitblit v1.7.1