From 02a11da1ca0523e4f8e3d7273904da816f951ffc Mon Sep 17 00:00:00 2001
From: 李林 <z1292839451@163.com>
Date: 星期五, 22 三月 2024 01:54:36 +0800
Subject: [PATCH] 系统调整

---
 data-server/src/main/java/com/yuanchu/mom/service/impl/FansSubmitServiceImpl.java |  100 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 94 insertions(+), 6 deletions(-)

diff --git a/data-server/src/main/java/com/yuanchu/mom/service/impl/FansSubmitServiceImpl.java b/data-server/src/main/java/com/yuanchu/mom/service/impl/FansSubmitServiceImpl.java
index e1b3b37..70134e2 100644
--- a/data-server/src/main/java/com/yuanchu/mom/service/impl/FansSubmitServiceImpl.java
+++ b/data-server/src/main/java/com/yuanchu/mom/service/impl/FansSubmitServiceImpl.java
@@ -1,17 +1,26 @@
 package com.yuanchu.mom.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yuanchu.mom.common.GetLook;
 import com.yuanchu.mom.common.PrintChina;
-import com.yuanchu.mom.dto.DataReportingPageDto;
+import com.yuanchu.mom.mapper.DataReportingMapper;
+import com.yuanchu.mom.pojo.DataReporting;
 import com.yuanchu.mom.pojo.FansSubmit;
 import com.yuanchu.mom.service.FansSubmitService;
 import com.yuanchu.mom.mapper.FansSubmitMapper;
 import com.yuanchu.mom.utils.QueryWrappers;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -26,28 +35,107 @@
 
     private FansSubmitMapper fansSubmitMapper;
 
+    private GetLook getLook;
+
+    private DataReportingMapper dataReportingMapper;
+
     @Override
     public Map<String, Object> selectFansSubmitList(IPage<FansSubmit> page, FansSubmit fansSubmit) {
         Map<String, Object> map = new HashMap<>();
         map.put("head", PrintChina.printChina(FansSubmit.class));
+        Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectFansSubmitList");
+        if(map1.get("look")==1) fansSubmit.setCreateUser(map1.get("userId"));
         map.put("body", fansSubmitMapper.selectFansSubmitPageList(page, QueryWrappers.queryWrappers(fansSubmit)));
         return map;
     }
 
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public int delFansSubmit(Integer id) {
-        return fansSubmitMapper.deleteById(id);
+        FansSubmit fansSubmit = fansSubmitMapper.selectOne(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getId, id).select(FansSubmit::getFansAdd,FansSubmit::getProduct,FansSubmit::getVx,FansSubmit::getCreateTime));
+        fansSubmitMapper.deleteById(id);
+        List<FansSubmit> fansSubmits = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getProduct, fansSubmit.getProduct()).eq(FansSubmit::getVx, fansSubmit.getVx()).select(FansSubmit::getFansAdd).like(FansSubmit::getCreateTime, fansSubmit.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
+        Integer sum = 0;
+        for (FansSubmit fansSubmit2 : fansSubmits) {
+            sum += fansSubmit2.getFansAdd();
+        }
+        List<DataReporting> dataReportings = dataReportingMapper.selectList(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getProduct, fansSubmit.getProduct()).eq(DataReporting::getVxCard, fansSubmit.getVx()).like(DataReporting::getCreateTime, fansSubmit.getCreateTime().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
+        for (DataReporting dataReporting : dataReportings) {
+            dataReporting.setFansAdd(sum);
+            dataReportingMapper.updateById(dataReporting);
+        }
+        return 1;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public int updateFansSubmit(FansSubmit fansSubmit3) {
+        fansSubmitMapper.updateById(fansSubmit3);
+        FansSubmit fansSubmit = fansSubmitMapper.selectOne(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getId, fansSubmit3.getId()).select(FansSubmit::getFansAdd,FansSubmit::getProduct,FansSubmit::getVx,FansSubmit::getCreateTime));
+        List<FansSubmit> fansSubmits = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getProduct, fansSubmit.getProduct()).eq(FansSubmit::getVx, fansSubmit.getVx()).select(FansSubmit::getFansAdd).like(FansSubmit::getCreateTime, fansSubmit.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
+        Integer sum = 0;
+        for (FansSubmit fansSubmit2 : fansSubmits) {
+            sum += fansSubmit2.getFansAdd();
+        }
+        List<DataReporting> dataReportings = dataReportingMapper.selectList(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getProduct, fansSubmit.getProduct()).eq(DataReporting::getVxCard, fansSubmit.getVx()).like(DataReporting::getCreateTime, fansSubmit.getCreateTime().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
+        for (DataReporting dataReporting : dataReportings) {
+            dataReporting.setFansAdd(sum);
+            dataReportingMapper.updateById(dataReporting);
+        }
+        return 1;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public int addFansSubmit(FansSubmit fansSubmit, String date) {
+        String date2 = null;
+        if(date == null) {
+            date = getToday();
+            date2 = getYesterday();
+        }else{
+            date = LocalDateTime.parse(date + "T00:00:00").plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+            date2 = LocalDateTime.parse(date + "T00:00:00").minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+            fansSubmit.setCreateTime(LocalDateTime.parse(date + "T00:00:00"));
+        }
+        fansSubmitMapper.insert(fansSubmit);
+        List<FansSubmit> fansSubmits = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getProduct, fansSubmit.getProduct()).eq(FansSubmit::getVx, fansSubmit.getVx()).select(FansSubmit::getFansAdd).like(FansSubmit::getCreateTime, date));
+        Integer sum = 0;
+        for (FansSubmit fansSubmit2 : fansSubmits) {
+            sum += fansSubmit2.getFansAdd();
+        }
+        List<DataReporting> dataReportings = dataReportingMapper.selectList(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getProduct, fansSubmit.getProduct()).eq(DataReporting::getVxCard, fansSubmit.getVx()).like(DataReporting::getCreateTime, date2).orderByDesc(DataReporting::getAccountConsumption));
+        for (DataReporting dataReporting : dataReportings) {
+            dataReporting.setFansAdd(sum);
+            dataReportingMapper.updateById(dataReporting);
+        }
+        return 1;
     }
 
     @Override
-    public int updateFansSubmit(FansSubmit fansSubmit) {
-        return fansSubmitMapper.updateById(fansSubmit);
+    public String getYesterday(){
+        return LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+    }
+
+    public String getToday(){
+        return LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
     }
 
     @Override
-    public int addFansSubmit(FansSubmit fansSubmit) {
-        return fansSubmitMapper.insert(fansSubmit);
+    public List<FansSubmit> vxs(String date) {
+        String format = LocalDateTime.parse(date.replace(" ", "T")).plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        QueryWrapper<FansSubmit> queryWrapper = new QueryWrapper<FansSubmit>();
+        queryWrapper.select("DISTINCT vx").like("create_time", format);
+        return fansSubmitMapper.selectList(queryWrapper);
     }
+
+    @Override
+    public void deleteAllFans(String date) {
+        List<FansSubmit> list = fansSubmitMapper.selectList(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getCreateUser, getLook.selectPowerByMethodAndUserId("selectDataReportingList").get("userId")).like(FansSubmit::getCreateTime, date).select(FansSubmit::getId));
+        for (FansSubmit fansSubmit : list) {
+            delFansSubmit(fansSubmit.getId());
+        }
+    }
+
 }
 
 

--
Gitblit v1.9.3