From 912d2e62391b1459952375a60ba87cfa842f1c41 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期二, 17 十二月 2024 10:26:54 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java |   69 +++++++++++++++++++++++++++++++++-
 1 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java
index accf87f..9e2354a 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java
@@ -1,15 +1,27 @@
 package com.ruoyi.other.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.account.api.feignClient.AppUserClient;
+import com.ruoyi.account.api.model.AppUser;
+import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.other.api.domain.Shop;
 import com.ruoyi.other.mapper.ShopPointMapper;
 import com.ruoyi.other.api.domain.ShopPoint;
 import com.ruoyi.other.service.ShopPointService;
+import com.ruoyi.other.service.ShopService;
 import com.ruoyi.other.vo.ShopPointStatistics;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author luodangjia
@@ -17,10 +29,61 @@
  */
 @Service
 public class ShopPointServiceImpl extends ServiceImpl<ShopPointMapper, ShopPoint> implements ShopPointService {
+    @Resource
+    private ShopPointMapper shopPointMapper;
+    @Resource
+    private ShopService shopService;
 
     @Override
-    public ShopPointStatistics statistics() {
+    public ShopPointStatistics statistics(IPage<ShopPoint> page, ShopPoint shopPoint) {
+
+        String shopName = shopPoint.getShopName();
+        String phone = shopPoint.getPhone();
+        String shopLeaderName = shopPoint.getShopLeaderName();
+        if (StringUtils.isNotEmpty(shopName) || StringUtils.isNotEmpty(phone) || StringUtils.isNotEmpty(shopLeaderName)) {
+            List<Integer> shopIds = shopService.listObjs(new LambdaQueryWrapper<Shop>()
+                            .select(Shop::getId)
+                            .like(StringUtils.isNotEmpty(shopName), Shop::getName, shopName)
+                            .like(StringUtils.isNotEmpty(phone), Shop::getPhone, phone)
+                            .like(StringUtils.isNotEmpty(shopLeaderName), Shop::getShopManager, shopLeaderName))
+                    .stream().map(o -> (Integer) o).collect(Collectors.toList());
+
+            shopPoint.setShopIds(shopIds);
+        }
+
+
         ShopPointStatistics shopPointStatistics = new ShopPointStatistics();
-        return null;
+        List<ShopPoint> latestChangeByType = shopPointMapper.findLatestChangeByType(shopPoint);
+        for (ShopPoint sp : latestChangeByType) {
+            switch (sp.getType()) {
+                case 1:
+                    shopPointStatistics.setShopPoint(sp.getVariablePoint());
+                    break;
+                case 2:
+                    shopPointStatistics.setShopCommissionPoint(sp.getVariablePoint());
+                    break;
+                case 3:
+                    shopPointStatistics.setSubShopCommissionPoint(sp.getVariablePoint());
+                    break;
+            }
+        }
+        shopPointStatistics.setTotalPoint(shopPointStatistics.getShopPoint() + shopPointStatistics.getShopCommissionPoint() + shopPointStatistics.getSubShopCommissionPoint());
+
+
+        boolean condition = shopPoint.getStartTime() != null && shopPoint.getEndTime() != null;
+        IPage<ShopPoint> shopPointIPage = page(page, new LambdaQueryWrapper<ShopPoint>()
+                .in(!CollectionUtils.isEmpty(shopPoint.getShopIds()), ShopPoint::getShopId, shopPoint.getShopIds())
+                .eq(shopPoint.getType() != null, ShopPoint::getType, shopPoint.getType())
+                .between(condition, ShopPoint::getCreateTime, shopPoint.getStartTime(), shopPoint.getEndTime())
+                .orderByDesc(ShopPoint::getCreateTime));
+        List<ShopPoint> shopPoints = shopPointIPage.getRecords();
+        for (ShopPoint sp : shopPoints) {
+            Shop shop = shopService.getById(sp.getShopId());
+            sp.setShopName(shop.getName());
+            sp.setShopLeaderName(shop.getShopManager());
+            sp.setPhone(shop.getPhone());
+        }
+        shopPointStatistics.setShopPointIPage(shopPointIPage);
+        return shopPointStatistics;
     }
 }

--
Gitblit v1.7.1