From 780578502875aa0c339cb73f11b1e635df458c77 Mon Sep 17 00:00:00 2001
From: 李林 <z1292839451@163.com>
Date: 星期三, 28 二月 2024 14:55:05 +0800
Subject: [PATCH] 系统调整

---
 data-server/src/main/java/com/yuanchu/mom/service/impl/FansSubmitServiceImpl.java |   87 +++++++++++++++++++++++++++++++------------
 1 files changed, 63 insertions(+), 24 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 5177530..193955e 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,29 +1,26 @@
 package com.yuanchu.mom.service.impl;
 
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.json.JSONUtil;
+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.exception.ErrorException;
 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.Jwt;
 import com.yuanchu.mom.utils.QueryWrappers;
-import com.yuanchu.mom.utils.ServletUtils;
 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;
 
 /**
@@ -55,39 +52,81 @@
     @Transactional(rollbackFor = Exception.class)
     @Override
     public int delFansSubmit(Integer id) {
-        FansSubmit fansSubmit = fansSubmitMapper.selectOne(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getId, id).select(FansSubmit::getFansAdd, FansSubmit::getDataId));
-        DataReporting dataReporting = dataReportingMapper.selectById(fansSubmit.getDataId());
-        dataReporting.setFansAdd(dataReporting.getFansAdd() - fansSubmit.getFansAdd());
-        dataReportingMapper.updateById(dataReporting);
-        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 fansSubmit) {
-        DataReporting dataReporting = dataReportingMapper.selectById(fansSubmit.getDataId());
-        dataReporting.setFansAdd(dataReporting.getFansAdd() + fansSubmit.getFansAdd() - fansSubmitMapper.selectOne(Wrappers.<FansSubmit>lambdaQuery().eq(FansSubmit::getId, fansSubmit.getId()).select(FansSubmit::getFansAdd)).getFansAdd());
-        dataReportingMapper.updateById(dataReporting);
-        return fansSubmitMapper.updateById(fansSubmit);
+    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) {
-        if(date == null) date = getYesterday();
-        DataReporting dataReporting = dataReportingMapper.selectOne(Wrappers.<DataReporting>lambdaQuery().eq(DataReporting::getName, fansSubmit.getCustom()).eq(DataReporting::getProduct, fansSubmit.getProduct()).eq(DataReporting::getCreateUser, getLook.selectPowerByMethodAndUserId("selectRegistrantCountDtoPageList").get("userId")).like(DataReporting::getCreateTime, date));
-        if(ObjectUtil.isEmpty(dataReporting)){
-            throw new ErrorException(date+" 瀹㈡埛锛�"+fansSubmit.getCustom()+" 骞舵湭涓婃姤杩� "+fansSubmit.getProduct()+" 椤圭洰");
+        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"));
         }
-        dataReporting.setFansAdd((dataReporting.getFansAdd()==null?0:dataReporting.getFansAdd()) + fansSubmit.getFansAdd());
-        dataReportingMapper.updateById(dataReporting);
-        fansSubmit.setDataId(dataReporting.getId());
-        return fansSubmitMapper.insert(fansSubmit);
+        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 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 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);
+    }
 }
 
 

--
Gitblit v1.9.3