From a6cf27e733515a20fc14840f5c63b6c6139b1e33 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期日, 26 一月 2025 11:16:27 +0800
Subject: [PATCH] 12.18
---
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopPointServiceImpl.java | 186 +++++++++++++++++++++++++++++++++-------------
1 files changed, 132 insertions(+), 54 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 883a4c3..77b4e55 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,13 +1,17 @@
package com.ruoyi.other.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.service.TokenService;
+import com.ruoyi.other.api.domain.Shop;
import com.ruoyi.other.api.domain.ShopPoint;
import com.ruoyi.other.api.enums.PointChangeType;
import com.ruoyi.other.mapper.ShopPointMapper;
import com.ruoyi.other.service.ShopPointService;
+import com.ruoyi.other.service.ShopService;
import com.ruoyi.other.vo.ShopPointStatistics;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
@@ -37,6 +41,8 @@
private TokenService tokenService;
@Resource
private SysUserClient sysUserClient;
+ @Resource
+ private ShopService shopService;
@@ -45,62 +51,134 @@
public ShopPointStatistics statistics(IPage<ShopPoint> page, ShopPoint shopPoint) {
Long userid = tokenService.getLoginUser().getUserid();
SysUser sysUser = sysUserClient.getSysUser(userid).getData();
- List<ShopPoint> shopPoints = this.baseMapper.selectShopPointList(shopPoint);
- Map<Integer, Integer> shopPointMap = shopPoints.stream()
- .collect(Collectors.groupingBy(
- ShopPoint::getType,
- Collectors.summingInt(ShopPoint::getVariablePoint)
- ));
+ Integer sPoint = 0;
+ Integer shopCommissionPoint = 0;
+ Integer subShopCommissionPoint = 0;
+ Integer serverCommissionPoint = 0;
+ if (sysUser.getRoleType()==1){
+ if (StringUtils.isNotEmpty(shopPoint.getShopName())){
- ShopPointStatistics shopPointStatistics = new ShopPointStatistics();
- int sPoint = shopPointMap.getOrDefault(PointChangeType.SHOP_ACHIEVEMENT.getCode(), 0);
- int shopCommissionPoint = shopPointMap.getOrDefault(PointChangeType.SHOP_REBATE.getCode(), 0);
- int subShopCommissionPoint = shopPointMap.getOrDefault(PointChangeType.JUNIOR_SHOP_REBATE.getCode(), 0);
- shopPointStatistics.setTotalPoint(sPoint + shopCommissionPoint + subShopCommissionPoint);
- shopPointStatistics.setShopPoint(sPoint);
- shopPointStatistics.setShopCommissionPoint(shopCommissionPoint);
- shopPointStatistics.setSubShopCommissionPoint(subShopCommissionPoint);
-
- IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint);
- shopPointStatistics.setShopPointIPage(shopPointIPage);
-
- LocalDateTime startTime = shopPoint.getStartTime();
- LocalDateTime endTime = shopPoint.getEndTime();
- if(null != startTime){
- List<ShopPoint> list = this.list(new LambdaUpdateWrapper<ShopPoint>()
- .eq(ShopPoint::getShopId, sysUser.getObjectId())
- .last(" and create_time between '" + startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "' and '" + endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "'"));
- List<String> date = new ArrayList<>();
- List<Map<String, Integer>> data = new ArrayList<>();
- String format = "MM.dd";
- while (true){
- if(startTime.isAfter(endTime)){
- break;
- }
- date.add(startTime.format(DateTimeFormatter.ofPattern(format)));
- Map<String, Integer> map = new HashMap<>();
- //返佣积分
- LocalDateTime finalStartTime = startTime;
- List<ShopPoint> collect = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
- .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 2).collect(Collectors.toList());
- map.put("fyjf", collect.stream().mapToInt(ShopPoint::getVariablePoint).sum());
-
- //服务积分
- List<ShopPoint> collect1 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
- .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 4).collect(Collectors.toList());
- map.put("fwjf", collect1.stream().mapToInt(ShopPoint::getVariablePoint).sum());
- //绑定下级门店返佣积分
- List<ShopPoint> collect2 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
- .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 3).collect(Collectors.toList());
- map.put("xjmdfyjf", collect2.stream().mapToInt(ShopPoint::getVariablePoint).sum());
- data.add(map);
- startTime = startTime.plusDays(1);
}
- Map<String, Object> brokenLine = new HashMap<>();
- brokenLine.put("date", date);
- brokenLine.put("data", data);
- shopPointStatistics.setBrokenLine(brokenLine);
+ if (StringUtils.isNotEmpty(shopPoint.getShopLeaderName())){
+
+ }
+ ShopPointStatistics shopPointStatistics = new ShopPointStatistics();
+ IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint);
+ shopPointStatistics.setShopPointIPage(shopPointIPage);
+
+ for (ShopPoint record : shopPointIPage.getRecords()) {
+ switch (record.getType()){
+ case 1:
+ sPoint += record.getVariablePoint();
+
+ break;
+ case 2:
+ shopCommissionPoint += record.getVariablePoint();
+
+ break;
+ case 3:
+ subShopCommissionPoint += record.getVariablePoint();
+
+ break;
+ case 4:
+ serverCommissionPoint+= record.getVariablePoint();
+ break;
+ }
+ }
+ shopPointStatistics.setTotalPoint(sPoint + shopCommissionPoint + subShopCommissionPoint+serverCommissionPoint);
+ shopPointStatistics.setShopPoint(sPoint);
+ shopPointStatistics.setShopCommissionPoint(shopCommissionPoint);
+ shopPointStatistics.setSubShopCommissionPoint(subShopCommissionPoint);
+ LocalDateTime startTime = shopPoint.getStartTime();
+ LocalDateTime endTime = shopPoint.getEndTime();
+ if(null != startTime){
+ List<ShopPoint> list = this.list(new LambdaUpdateWrapper<ShopPoint>()
+ .eq(ShopPoint::getShopId, sysUser.getObjectId())
+ .last(" and create_time between '" + startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "' and '" + endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "'"));
+ List<String> date = new ArrayList<>();
+ List<Map<String, Integer>> data = new ArrayList<>();
+ String format = "MM.dd";
+ while (true){
+ if(startTime.isAfter(endTime)){
+ break;
+ }
+ date.add(startTime.format(DateTimeFormatter.ofPattern(format)));
+ Map<String, Integer> map = new HashMap<>();
+ //返佣积分
+ LocalDateTime finalStartTime = startTime;
+ List<ShopPoint> collect = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
+ .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 2).collect(Collectors.toList());
+ map.put("fyjf", collect.stream().mapToInt(ShopPoint::getVariablePoint).sum());
+
+ //服务积分
+ List<ShopPoint> collect1 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
+ .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 1).collect(Collectors.toList());
+ map.put("fwjf", collect1.stream().mapToInt(ShopPoint::getVariablePoint).sum());
+ //绑定下级门店返佣积分
+ List<ShopPoint> collect2 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
+ .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 3).collect(Collectors.toList());
+ map.put("xjmdfyjf", collect2.stream().mapToInt(ShopPoint::getVariablePoint).sum());
+ data.add(map);
+ startTime = startTime.plusDays(1);
+ }
+ Map<String, Object> brokenLine = new HashMap<>();
+ brokenLine.put("date", date);
+ brokenLine.put("data", data);
+ shopPointStatistics.setBrokenLine(brokenLine);
+ }
+ return shopPointStatistics;
+ }else{
+ Shop shop = shopService.getById(sysUser.getObjectId());
+ sPoint += shop.getServerPoint();
+ shopCommissionPoint += shop.getSharePoint();
+ subShopCommissionPoint += shop.getLowerLevelSharePoint();
+ ShopPointStatistics shopPointStatistics = new ShopPointStatistics();
+ shopPointStatistics.setTotalPoint(sPoint + shopCommissionPoint + subShopCommissionPoint);
+ shopPointStatistics.setShopPoint(sPoint);
+ shopPointStatistics.setShopCommissionPoint(shopCommissionPoint);
+ shopPointStatistics.setSubShopCommissionPoint(subShopCommissionPoint);
+
+ IPage<ShopPoint> shopPointIPage = this.baseMapper.queryShpointPage(page, shopPoint);
+ shopPointStatistics.setShopPointIPage(shopPointIPage);
+
+ LocalDateTime startTime = shopPoint.getStartTime();
+ LocalDateTime endTime = shopPoint.getEndTime();
+ if(null != startTime){
+ List<ShopPoint> list = this.list(new LambdaUpdateWrapper<ShopPoint>()
+ .eq(ShopPoint::getShopId, sysUser.getObjectId())
+ .last(" and create_time between '" + startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "' and '" + endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + "'"));
+ List<String> date = new ArrayList<>();
+ List<Map<String, Integer>> data = new ArrayList<>();
+ String format = "MM.dd";
+ while (true){
+ if(startTime.isAfter(endTime)){
+ break;
+ }
+ date.add(startTime.format(DateTimeFormatter.ofPattern(format)));
+ Map<String, Integer> map = new HashMap<>();
+ //返佣积分
+ LocalDateTime finalStartTime = startTime;
+ List<ShopPoint> collect = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
+ .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 2).collect(Collectors.toList());
+ map.put("fyjf", collect.stream().mapToInt(ShopPoint::getVariablePoint).sum());
+
+ //服务积分
+ List<ShopPoint> collect1 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
+ .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 1).collect(Collectors.toList());
+ map.put("fwjf", collect1.stream().mapToInt(ShopPoint::getVariablePoint).sum());
+ //绑定下级门店返佣积分
+ List<ShopPoint> collect2 = list.stream().filter(s -> s.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
+ .equals(finalStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) && s.getType() == 3).collect(Collectors.toList());
+ map.put("xjmdfyjf", collect2.stream().mapToInt(ShopPoint::getVariablePoint).sum());
+ data.add(map);
+ startTime = startTime.plusDays(1);
+ }
+ Map<String, Object> brokenLine = new HashMap<>();
+ brokenLine.put("date", date);
+ brokenLine.put("data", data);
+ shopPointStatistics.setBrokenLine(brokenLine);
+ }
+ return shopPointStatistics;
}
- return shopPointStatistics;
}
}
--
Gitblit v1.7.1