Browse Source

修复个微养号部分BUG

leon 5 years ago
parent
commit
805e1636ea

+ 3 - 0
src/main/java/com/mokamrp/privates/entity/pangu/PromoteCodeListHandle.java

@@ -3,6 +3,7 @@ package com.mokamrp.privates.entity.pangu;
 import lombok.Data;
 import lombok.Data;
 
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotBlank;
+import java.time.LocalDateTime;
 
 
 /**
 /**
  * @param <T>
  * @param <T>
@@ -12,6 +13,8 @@ import javax.validation.constraints.NotBlank;
 public class PromoteCodeListHandle<T> {
 public class PromoteCodeListHandle<T> {
     private Integer id;
     private Integer id;
     private String name;
     private String name;
+    private LocalDateTime startDate;
+    private LocalDateTime endDate;
     @NotBlank(message = "page 不可为空")
     @NotBlank(message = "page 不可为空")
     private Integer page;
     private Integer page;
     @NotBlank(message = "pagesize 不可为空")
     @NotBlank(message = "pagesize 不可为空")

+ 1 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/PromoteCodeMapper.xml

@@ -38,6 +38,7 @@
         LEFT JOIN pan_playbill as D ON A.custservice_playbill_id = D.id
         LEFT JOIN pan_playbill as D ON A.custservice_playbill_id = D.id
         <where>
         <where>
             <if test="promoteCodeListHandle.name != null">and A.name like CONCAT('%',#{promoteCodeListHandle.name},'%')</if>
             <if test="promoteCodeListHandle.name != null">and A.name like CONCAT('%',#{promoteCodeListHandle.name},'%')</if>
+            <if test="promoteCodeListHandle.startDate != null">and A.create_at between #{promoteCodeListHandle.startDate} and #{promoteCodeListHandle.endDate}</if>
         </where>
         </where>
     </select>
     </select>
     <select id="getInfo" resultType="com.mokamrp.privates.mapper.pangu.pojo.PromoteCodeVo">
     <select id="getInfo" resultType="com.mokamrp.privates.mapper.pangu.pojo.PromoteCodeVo">

+ 34 - 1
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileServiceImpl.java

@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.mokamrp.privates.constant.HttpMsg;
 import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
+import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.mapper.pangu.FosterwxMobileMapper;
 import com.mokamrp.privates.mapper.pangu.FosterwxMobileMapper;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobilePool;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobilePool;
@@ -29,6 +31,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -103,7 +106,7 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
      * @return
      * @return
      */
      */
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
-    public VoltaHandle<Boolean> importData(List<Map<String, String>> row, User authUser) throws Exception {
+    public VoltaHandle<Boolean>  importData(List<Map<String, String>> row, User authUser) throws Exception {
         VoltaHandle<Boolean> res = new VoltaHandle<>();
         VoltaHandle<Boolean> res = new VoltaHandle<>();
         if (row.size() <= 0) {
         if (row.size() <= 0) {
             throw new Exception("表格读取完成后,没有获取到任何数据");
             throw new Exception("表格读取完成后,没有获取到任何数据");
@@ -160,8 +163,15 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
 
 
             fosterwxMobile.setMobileUnioCode(stationInfo.getStationName() + fosterwxMobile.getMobileCode());
             fosterwxMobile.setMobileUnioCode(stationInfo.getStationName() + fosterwxMobile.getMobileCode());
             this.save(fosterwxMobile);
             this.save(fosterwxMobile);
+            //.查询当前站点下所有账号的微信好友
+            List<FosterwxMobile> mobileList = fosterwxMobileService.list(new QueryWrapper<FosterwxMobile>().eq("station_id",fosterwxMobile.getStationId()));
+            List<Integer> mobileIds = mobileList.stream().map(FosterwxMobile::getId).collect(Collectors.toList());
+            List<FosterwxMobileWxfriend> friends = fosterwxMobileWxfriendService.list(new QueryWrapper<FosterwxMobileWxfriend>()
+                    .in("mobile_id",mobileIds)
+            );
             //.批量录入微信好友
             //.批量录入微信好友
             List<FosterwxMobileWxfriend> addFriend = new ArrayList<>();
             List<FosterwxMobileWxfriend> addFriend = new ArrayList<>();
+            Map<String,Boolean> friendsNames = new HashMap<>();
             for (Integer s = 1; s <= 3; s++) {
             for (Integer s = 1; s <= 3; s++) {
                 String sStr = s.toString();
                 String sStr = s.toString();
                 String wxFriendName = row.get(i).get("wxFriendName" + sStr);
                 String wxFriendName = row.get(i).get("wxFriendName" + sStr);
@@ -169,6 +179,14 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
                 if (wxFriendName == null || wxFriendName.isEmpty()) {
                 if (wxFriendName == null || wxFriendName.isEmpty()) {
                     continue;
                     continue;
                 }
                 }
+                if(friendsNames.get(wxFriendName) == null){
+                    throw new Exception("第" + (i + 1) + "行," +wxFriendName+ "微信好友名称录入重复");
+                }
+                friendsNames.put(wxFriendName,true);
+                Boolean findRes = this.checkWxFriendCnt(friends,wxFriendName);
+                if (!findRes){
+                    throw new Exception("第" + (i + 1) + "行," +wxFriendName+ "微信好友名称在当前站点内已经使用超过三次,无法再次录入");
+                }
                 FosterwxMobileWxfriend fosterwxMobileWxfriend = new FosterwxMobileWxfriend();
                 FosterwxMobileWxfriend fosterwxMobileWxfriend = new FosterwxMobileWxfriend();
                 fosterwxMobileWxfriend.setMobileId(fosterwxMobile.getId());
                 fosterwxMobileWxfriend.setMobileId(fosterwxMobile.getId());
                 fosterwxMobileWxfriend.setCreateAt(nowDate);
                 fosterwxMobileWxfriend.setCreateAt(nowDate);
@@ -180,6 +198,7 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
                 }
                 }
                 addFriend.add(fosterwxMobileWxfriend);
                 addFriend.add(fosterwxMobileWxfriend);
             }
             }
+
             if (addFriend.size() > 0) {
             if (addFriend.size() > 0) {
                 fosterwxMobileWxfriendService.remove(new QueryWrapper<FosterwxMobileWxfriend>().eq("mobile_id", fosterwxMobile.getId()));
                 fosterwxMobileWxfriendService.remove(new QueryWrapper<FosterwxMobileWxfriend>().eq("mobile_id", fosterwxMobile.getId()));
                 fosterwxMobileWxfriendService.saveBatch(addFriend);
                 fosterwxMobileWxfriendService.saveBatch(addFriend);
@@ -191,9 +210,23 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
                     setWxAppid(corp.getWxCorpid());
                     setWxAppid(corp.getWxCorpid());
                 }}, new LambdaQueryWrapper<FosterwxMobilePool>().eq(FosterwxMobilePool::getPoolIndex, fosterwxMobile.getMobileUnioCode()));
                 }}, new LambdaQueryWrapper<FosterwxMobilePool>().eq(FosterwxMobilePool::getPoolIndex, fosterwxMobile.getMobileUnioCode()));
             }
             }
+
         }
         }
 //        this.saveBatch(add);
 //        this.saveBatch(add);
         return res;
         return res;
     }
     }
 
 
+    private Boolean checkWxFriendCnt(List<FosterwxMobileWxfriend> row,String wxName){
+        Integer findCnt = 0;
+        for (FosterwxMobileWxfriend fosterwxMobileWxfriend : row){
+            if (fosterwxMobileWxfriend.getWxName().equals(wxName)){
+                findCnt++;
+            }
+            if (findCnt >= 3){
+                return false;
+            }
+        }
+        return true;
+    }
+
 }
 }

+ 66 - 0
src/main/java/com/mokamrp/privates/task/pangu/CheckFosterwxTaskExpire.java

@@ -0,0 +1,66 @@
+package com.mokamrp.privates.task.pangu;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.entity.pangu.FosterwxTaskScheduleHandle;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxTaskSchedule;
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
+import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService;
+import net.javacrumbs.shedlock.core.SchedulerLock;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class CheckFosterwxTaskExpire {
+
+    @Autowired
+    public FosterwxTaskScheduleService fosterwxTaskScheduleService;
+
+    @Autowired
+    public FosterwxStationService fosterwxStationService;
+
+    @Autowired
+    public StringRedisTemplate stringRedisTemplate;
+
+    @Scheduled(cron = "0 1 0 * * ?")
+    @SchedulerLock(name = "pangu:CheckFosterwxTaskExpire", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void execute() {
+        System.out.println("[cronjob]:检测微信养号任务过期");
+        LocalDate lastDay = LocalDate.now().plusDays(-1);
+        List<FosterwxStation> fosterwxStationList = fosterwxStationService.list();
+        for (FosterwxStation fosterwxStation : fosterwxStationList) {
+            List<Integer> tasks = new ArrayList<>();
+            Integer stationId = fosterwxStation.getId();
+            FosterwxTaskScheduleHandle fosterwxTaskScheduleHandle = new FosterwxTaskScheduleHandle();
+            fosterwxTaskScheduleHandle.setStationId(stationId);
+            fosterwxTaskScheduleHandle.setSendDate(lastDay);
+            fosterwxTaskScheduleHandle.setPage(1);
+            fosterwxTaskScheduleHandle.setPagesize(99999);
+            ResHandle<List<FosterwxTaskSchedule>> resHandle = fosterwxTaskScheduleService.getList(fosterwxTaskScheduleHandle);
+            List<FosterwxTaskSchedule> fosterwxTaskScheduleList = resHandle.getList();
+            Map<String, List<FosterwxTaskSchedule>> saveRedis = new HashMap<>();
+            for (FosterwxTaskSchedule fosterwxTaskSchedule : fosterwxTaskScheduleList) {
+                tasks.add(fosterwxTaskSchedule.getTaskId());
+                //.昨日数据直接设置为过期任务
+                FosterwxTaskSchedule save = new FosterwxTaskSchedule();
+                save.setTaskStatus(2);
+                fosterwxTaskScheduleService.update(save, new QueryWrapper<FosterwxTaskSchedule>()
+                        .eq("station_id", fosterwxStation.getId())
+                        .in("task_id", tasks)
+                        .eq("send_date", lastDay)
+                );
+
+            }
+        }
+    }
+}

+ 4 - 3
src/main/java/com/mokamrp/privates/task/pangu/SyncNewFosterwxTask.java

@@ -67,9 +67,9 @@ public class SyncNewFosterwxTask {
                     fosterwxTaskSchedule.setMobileCount(taskInfo.getMobileCount());
                     fosterwxTaskSchedule.setMobileCount(taskInfo.getMobileCount());
                     fosterwxTaskSchedule.setComment(taskInfo.getComment());
                     fosterwxTaskSchedule.setComment(taskInfo.getComment());
                     //.昨日数据直接设置为过期任务
                     //.昨日数据直接设置为过期任务
-                    if (i.equals(0)){
-                        fosterwxTaskSchedule.setTaskStatus(2);
-                    }
+//                    if (i.equals(0)){
+//                        fosterwxTaskSchedule.setTaskStatus(2);
+//                    }
                     List<FosterwxTaskSchedule> sendDateDetail = saveRedis.get(sendDate);
                     List<FosterwxTaskSchedule> sendDateDetail = saveRedis.get(sendDate);
                     if (sendDateDetail == null){
                     if (sendDateDetail == null){
                         List<FosterwxTaskSchedule> firstAdd = new ArrayList<>();
                         List<FosterwxTaskSchedule> firstAdd = new ArrayList<>();
@@ -99,4 +99,5 @@ public class SyncNewFosterwxTask {
             }
             }
         }
         }
     }
     }
+
 }
 }

BIN
src/main/resources/static/站点账号导入.xls