瀏覽代碼

Merge branch '盘古养号好友整改' into LeoN

leon 4 年之前
父節點
當前提交
5cf2acc469
共有 39 個文件被更改,包括 1376 次插入103 次删除
  1. 1 1
      src/main/java/com/mokamrp/privates/constant/HttpMsg.java
  2. 8 0
      src/main/java/com/mokamrp/privates/constant/RedisKey.java
  3. 5 1
      src/main/java/com/mokamrp/privates/controller/pangu/FosterwxCashOasBoxController.java
  4. 60 12
      src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileController.java
  5. 55 0
      src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileForbiddenRecordController.java
  6. 88 7
      src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileWxfriendController.java
  7. 78 4
      src/main/java/com/mokamrp/privates/controller/pangu/FosterwxWxfriendController.java
  8. 2 0
      src/main/java/com/mokamrp/privates/entity/PostBasePageHandle.java
  9. 1 1
      src/main/java/com/mokamrp/privates/entity/pangu/AddFosterwxMobileHandle.java
  10. 22 0
      src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileForbiddenRecordMapper.java
  11. 37 0
      src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileForbiddenRecordMapper.xml
  12. 7 1
      src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileWxfriendMapper.java
  13. 67 3
      src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileWxfriendMapper.xml
  14. 3 2
      src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxWxfriendMapper.java
  15. 14 2
      src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxWxfriendMapper.xml
  16. 2 0
      src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxMobile.java
  17. 174 0
      src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxMobileForbiddenRecord.java
  18. 18 3
      src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxMobileWxfriend.java
  19. 39 1
      src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxWxfriend.java
  20. 20 0
      src/main/java/com/mokamrp/privates/service/pangu/FosterwxMobileForbiddenRecordService.java
  21. 16 1
      src/main/java/com/mokamrp/privates/service/pangu/FosterwxMobileWxfriendService.java
  22. 6 1
      src/main/java/com/mokamrp/privates/service/pangu/FosterwxWxfriendService.java
  23. 4 10
      src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashOasBoxServiceImpl.java
  24. 43 0
      src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileForbiddenRecordServiceImpl.java
  25. 24 28
      src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileServiceImpl.java
  26. 161 16
      src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileWxfriendServiceImpl.java
  27. 41 2
      src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxWxfriendServiceImpl.java
  28. 65 0
      src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxCanBindFriendToRedis.java
  29. 69 0
      src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxCanSwitchFriendToRedis.java
  30. 35 0
      src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxFriendToRedis.java
  31. 7 1
      src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxMobile.java
  32. 7 3
      src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxMobileEdit.java
  33. 63 0
      src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxMobileFriendToRedis.java
  34. 50 0
      src/main/java/com/mokamrp/privates/task/pangu/UpdateFosterwxFriendStatus.java
  35. 81 0
      src/main/java/com/mokamrp/privates/task/pangu/UpdateFosterwxMobileStatus.java
  36. 1 1
      src/main/resources/application-local.properties
  37. 1 1
      src/main/resources/application-test.properties
  38. 二進制
      src/main/resources/static/导入账号绑定解封好友.xls
  39. 1 1
      src/test/java/com/mokamrp/AutoMPPangu.java

+ 1 - 1
src/main/java/com/mokamrp/privates/constant/HttpMsg.java

@@ -12,5 +12,5 @@ public class HttpMsg {
     public static final String importSuccess = "导入数据成功";
 
     public static final String wxFriendCntMax3 = "当前站点下,微信好友名称存在超过三个:";
-    public static final String wxFriendResume = "本次录入的微信好友昵称存在重复:";
+    public static final String wxFriendResume = "本次选择的微信好友昵称存在重复:";
 }

+ 8 - 0
src/main/java/com/mokamrp/privates/constant/RedisKey.java

@@ -51,6 +51,14 @@ public class RedisKey {
     public static final String PanPromoteNoticeRecode = "pan_promote_notice_recode:";
     //.盘古 微信养号视频库
     public static final String PanWxFosterTeachingVideo = "pan_wxfoster_teaching_video_info";
+    //.盘古 站点微信好友库
+    public static final String PanWxFosterFriendInfo = "pan_wxfoster_friend_info:";
+    //.盘古 账号绑定的微信好友ID
+    public static final String PanWxFosterMobileFriendId = "pan_wxfoster_mobile_friend_id:";
+    //.盘古 站点内可被替换的解封微信好友ID
+    public static final String PanWxFosterCanSwitchFriendId = "pan_wxfoster_can_switch_friend_id:";
+    //.盘古 站点内可被绑定的解封微信好友ID
+    public static final String PanWxFosterCanBindFriendId = "pan_wxfoster_can_bind_friend_id:";
 
 }
 

+ 5 - 1
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxCashOasBoxController.java

@@ -225,7 +225,11 @@ public class FosterwxCashOasBoxController extends BaseController<FosterwxCashOas
         }
         return AjaxResult.success(HttpMsg.importSuccess);
     }
-
+    @GetMapping("/test")
+    public Object test(){
+        FosterwxCashOasBox fosterwxCashOasBox = fosterwxCashOasBoxService.getRandBox(10, 1);
+        return AjaxResult.success(fosterwxCashOasBox);
+    }
 
 
 }

+ 60 - 12
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileController.java

@@ -1,7 +1,9 @@
 package com.mokamrp.privates.controller.pangu;
 
+import com.aliyun.oss.model.PutObjectRequest;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.config.OSSConfiguration;
 import com.mokamrp.privates.constant.Constants;
 import com.mokamrp.privates.constant.HttpMsg;
 import com.mokamrp.privates.constant.HttpStatus;
@@ -17,6 +19,7 @@ import com.mokamrp.privates.mapper.pojo.Corp;
 import com.mokamrp.privates.mapper.pojo.User;
 import com.mokamrp.privates.service.CorpService;
 import com.mokamrp.privates.service.pangu.*;
+import com.mokamrp.privates.utils.OssFile;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -25,6 +28,8 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.Valid;
+import java.io.ByteArrayInputStream;
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
@@ -124,8 +129,12 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
         if (null != corp) {
             res.setWxAppid(corp.getWxCorpid());
         }
-        List<FosterwxMobileWxfriend> friendList = fosterwxMobileWxfriendService.list(new QueryWrapper<FosterwxMobileWxfriend>().eq("mobile_id", res.getId()).orderByAsc("seq"));
-        res.setFriend(friendList);
+        PostBasePageHandle handle = new PostBasePageHandle();
+        handle.setMobileId(res.getId());
+        handle.setPage(1);
+        handle.setPagesize(9999);
+        ResHandle<List<FosterwxMobileWxfriend>> friendList = fosterwxMobileWxfriendService.getList(handle);
+        res.setFriend(friendList.getList());
 
         // 获取个微账号任务时间list
         List<FosterwxMobileTaskTimeList> fosterwxMobileTaskTimeLists = fosterwxMobileTaskTimeListService.list(new LambdaQueryWrapper<FosterwxMobileTaskTimeList>().eq(FosterwxMobileTaskTimeList::getMobileUnioCode, res.getMobileUnioCode()).eq(FosterwxMobileTaskTimeList::getType, 1).orderByAsc(FosterwxMobileTaskTimeList::getId));
@@ -294,7 +303,10 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
                     } else if (null != fosterwxMobileTaskTimeList.getTaskEndAt() && gwOldTimeList.get(gwOldTimeList.size() - 1).getTaskEndAt() == null) {
                         fosterwxMobileTaskTimeListService.update(new FosterwxMobileTaskTimeList() {{
                             setTaskEndAt(fosterwxMobileTaskTimeList.getTaskEndAt());
-                        }}, new LambdaQueryWrapper<FosterwxMobileTaskTimeList>().eq(FosterwxMobileTaskTimeList::getMobileUnioCode, fosterwxMobile.getMobileUnioCode()).eq(FosterwxMobileTaskTimeList::getType, 1));
+                        }}, new LambdaQueryWrapper<FosterwxMobileTaskTimeList>().
+                                eq(FosterwxMobileTaskTimeList::getMobileUnioCode, fosterwxMobile.getMobileUnioCode()).
+                                eq(FosterwxMobileTaskTimeList::getType, 1).
+                                eq(FosterwxMobileTaskTimeList::getId, gwOldTimeList.get(gwOldTimeList.size() - 1).getId()));
                         // 删除后面的任务
                         fosterwxTaskScheduleService.remove(new LambdaQueryWrapper<FosterwxTaskSchedule>().eq(FosterwxTaskSchedule::getStationId, oldVO.getStationId()).eq(FosterwxTaskSchedule::getMobileCode, oldVO.getMobileCode()).eq(FosterwxTaskSchedule::getType, 1).gt(FosterwxTaskSchedule::getSendDate, fosterwxMobileTaskTimeList.getTaskEndAt()));
                     }
@@ -342,7 +354,10 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
                     } else if (null != fosterwxMobileTaskTimeList.getTaskEndAt() && qwOldTimeList.get(qwOldTimeList.size() - 1).getTaskEndAt() == null) {
                         fosterwxMobileTaskTimeListService.update(new FosterwxMobileTaskTimeList() {{
                             setTaskEndAt(fosterwxMobileTaskTimeList.getTaskEndAt());
-                        }}, new LambdaQueryWrapper<FosterwxMobileTaskTimeList>().eq(FosterwxMobileTaskTimeList::getMobileUnioCode, fosterwxMobile.getMobileUnioCode()).eq(FosterwxMobileTaskTimeList::getType, 2));
+                        }}, new LambdaQueryWrapper<FosterwxMobileTaskTimeList>().
+                                eq(FosterwxMobileTaskTimeList::getMobileUnioCode, fosterwxMobile.getMobileUnioCode()).
+                                eq(FosterwxMobileTaskTimeList::getType, 2).
+                                eq(FosterwxMobileTaskTimeList::getId, qwOldTimeList.get(qwOldTimeList.size() - 1).getId()));
                         // 删除后面的任务
                         fosterwxTaskScheduleService.remove(new LambdaQueryWrapper<FosterwxTaskSchedule>().eq(FosterwxTaskSchedule::getStationId, oldVO.getStationId()).eq(FosterwxTaskSchedule::getMobileCode, oldVO.getMobileCode()).eq(FosterwxTaskSchedule::getType, 2).gt(FosterwxTaskSchedule::getSendDate, fosterwxMobileTaskTimeList.getTaskEndAt()));
                     }
@@ -557,12 +572,9 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
         feild.put(13, "wxIdentityCardNo|default");
         feild.put(14, "bankCardNo|default");
         feild.put(15, "bankCardMobileNo");
-        feild.put(16, "wxFriendName1");
-        feild.put(17, "wxFriendUserName1");
-        feild.put(18, "wxFriendName2");
-        feild.put(19, "wxFriendUserName2");
-        feild.put(20, "wxFriendName3");
-        feild.put(21, "wxFriendUserName3");
+        feild.put(16, "wxFriendId1|default");
+        feild.put(17, "wxFriendId2|default");
+        feild.put(18, "wxFriendId3|default");
         feild.put(22, "workWxCorp|default");
         feild.put(23, "workWxRegisterAt|default");
         List<Map<String, String>> row = new ArrayList<>();
@@ -696,7 +708,6 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
             return AjaxResult.error(voltaRes.getErr());
         }
         row = voltaRes.getData();
-
         StringBuffer sb = new StringBuffer();
         row.forEach(map -> {
             LambdaQueryWrapper<FosterwxMobile> fosterwxMobileLambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -705,7 +716,6 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
             if (fosterwxMobileService.count(fosterwxMobileLambdaQueryWrapper) == 0)
                 sb.append("手机唯一编码:" + map.get("mobileUnioCode") + "不存在<br>");
         });
-
         if (sb.length() > 0) return AjaxResult.error(sb.toString().substring(0, sb.length() - 4));
 
         row.forEach(map -> {
@@ -1015,5 +1025,43 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
 
         return AjaxResult.success(baseVO);
     }
+//    @PostMapping("/export")
+//    public Object export(@Valid @RequestBody GetForsterwxMobileHandle getForsterwxMobileHandle, BindingResult bindingResult){
+//        if (bindingResult.hasErrors()) {
+//            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+//        }
+//
+//        List<Object> tempObj;
+//        List<List<Object>> resList = new ArrayList<List<Object>>();
+//        Object[] head = {"","",""};
+//        List<Object> headList = Arrays.asList(head);
+//        Date currentTime = new Date();
+//        String fileName = "活码数据.csv";
+//        resList.add(headList);
+//        for (){
+//            tempObj = new ArrayList<Object>() {
+//                {
+//                    this.add(promoteDataGroup.getDs());
+//                    this.add(promoteDataGroup.getPromoteId());
+//                    this.add(promoteDataGroup.getPromoteName());
+//                    this.add(promoteDataGroup.getCustserviceId());
+//                    this.add(promoteDataGroup.getCustserviceName());
+//                    this.add(promoteDataGroup.getTakeQrcodePv());
+//                    this.add(promoteDataGroup.getTakeQrcodeUv());
+//                    this.add(promoteDataGroup.getLongTouchPv());
+//                    this.add(promoteDataGroup.getLongTouchUv());
+//                }
+//            };
+//            resList.add(tempObj);
+//        }
+//        StringBuffer content = OssFile.createCSV(resList);
+//        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+//        String dateString = formatter.format(currentTime);
+//        String randNum = Integer.toString((int)(10000+Math.random()*(99999-10000+1)));
+//        String filePath = OSSConfiguration.PAN_DIR + dateString + "/" + randNum + "_" + fileName;
+//        PutObjectRequest putObjectRequest = new PutObjectRequest(ossConfiguration.getBucketName(), filePath,
+//                new ByteArrayInputStream(content.toString().getBytes()));
+//        ossClient.putObject(putObjectRequest);
+//    }
 }
 

+ 55 - 0
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileForbiddenRecordController.java

@@ -0,0 +1,55 @@
+package com.mokamrp.privates.controller.pangu;
+
+import com.mokamrp.privates.constant.HttpStatus;
+import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.help.AjaxResult;
+import com.mokamrp.privates.entity.ResHandle;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.RequestMapping;
+import com.mokamrp.privates.service.pangu.FosterwxMobileForbiddenRecordService;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileForbiddenRecord;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import com.mokamrp.privates.controller.BaseController;
+import javax.validation.Valid;
+import java.util.Map;
+import java.util.List;
+
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * <p>
+ * 盘古养号账号封禁记录 前端控制器
+ * </p>
+ *
+ * @author leon
+ * @since 2021-11-13
+ */
+@RestController
+@RequestMapping("/fosterwxMobileForbiddenRecord")
+public class FosterwxMobileForbiddenRecordController extends BaseController<FosterwxMobileForbiddenRecord> {
+
+    @Autowired
+    public FosterwxMobileForbiddenRecordService fosterwxMobileForbiddenRecordService;
+
+    /*
+     * @fast
+     * 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
+     * 如果需要定制化,需要将BaseController中对应的方法复制到当前控制器,然后进行修改
+     */
+
+    @PostMapping("/list")
+    public Object list(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult){
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        ResHandle<List<FosterwxMobileForbiddenRecord>> res = fosterwxMobileForbiddenRecordService.getList(postBasePageHandle);
+        return AjaxResult.success(res);
+    }
+
+
+}
+

+ 88 - 7
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileWxfriendController.java

@@ -1,16 +1,24 @@
 package com.mokamrp.privates.controller.pangu;
 
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.model.PutObjectRequest;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.config.OSSConfiguration;
 import com.mokamrp.privates.constant.HttpMsg;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.entity.pangu.AddFosterwxMobileHandle;
 import com.mokamrp.privates.help.AjaxResult;
+import com.mokamrp.privates.help.Analysis;
+import com.mokamrp.privates.interceptor.AuthUser;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
+import com.mokamrp.privates.mapper.pojo.User;
 import com.mokamrp.privates.service.pangu.FosterwxMobileService;
 import com.mokamrp.privates.service.pangu.FosterwxStationService;
+import com.mokamrp.privates.utils.OssFile;
 import org.aspectj.weaver.loadtime.Aj;
 import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,12 +28,13 @@ import com.mokamrp.privates.service.pangu.FosterwxMobileWxfriendService;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
 import org.springframework.web.bind.annotation.RequestMapping;
 import com.mokamrp.privates.controller.BaseController;
+import org.springframework.web.multipart.MultipartFile;
+
 import javax.validation.Valid;
+import java.io.ByteArrayInputStream;
+import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 
@@ -49,6 +58,11 @@ public class FosterwxMobileWxfriendController extends BaseController<FosterwxMob
 
     @Autowired
     public FosterwxMobileService fosterwxMobileService;
+    @Autowired
+    private OSSConfiguration ossConfiguration;
+
+    @Autowired
+    private OSS ossClient;
     /*
      * @fast
      * 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
@@ -60,10 +74,20 @@ public class FosterwxMobileWxfriendController extends BaseController<FosterwxMob
         if (bindingResult.hasErrors()) {
             return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
         }
-        Map<String,Object> res = fosterwxMobileWxfriendService.getList(postBasePageHandle);
+        ResHandle<List<FosterwxMobileWxfriend>> res = fosterwxMobileWxfriendService.getList(postBasePageHandle);
         return AjaxResult.success(res);
     }
 
+    @PostMapping("/listPro")
+    public Object listPro(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult){
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        ResHandle<List<FosterwxMobileWxfriend>> res = fosterwxMobileWxfriendService.getListPro(postBasePageHandle);
+        return AjaxResult.success(res);
+    }
+
+
     /**
      * 新增好友,会加入seq
      * @param addFosterwxMobileHandle
@@ -75,9 +99,10 @@ public class FosterwxMobileWxfriendController extends BaseController<FosterwxMob
         if (bindingResult.hasErrors()) {
             return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
         }
-        if (addFosterwxMobileHandle.getFriends() == null || addFosterwxMobileHandle.getFriends().size() <= 0){
+        if (addFosterwxMobileHandle.getFriendIds() == null || addFosterwxMobileHandle.getFriendIds().size() <= 0){
             return AjaxResult.error(HttpMsg.error);
         }
+        addFosterwxMobileHandle.getFriendIds().removeIf(i -> i == 0);
         //.判断好友微信名称是否同样的超过3个
         VoltaHandle<String> res = fosterwxMobileWxfriendService.checkFriend(addFosterwxMobileHandle);
         if(res.getErr() != null){
@@ -103,9 +128,10 @@ public class FosterwxMobileWxfriendController extends BaseController<FosterwxMob
         if (bindingResult.hasErrors()) {
             return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
         }
-        if (addFosterwxMobileHandle.getFriends() == null || addFosterwxMobileHandle.getFriends().size() <= 0){
+        if (addFosterwxMobileHandle.getFriendIds() == null || addFosterwxMobileHandle.getFriendIds().size() <= 0){
             return AjaxResult.error(HttpMsg.error);
         }
+        addFosterwxMobileHandle.getFriendIds().removeIf(i -> i == 0);
         //.好友验证
         VoltaHandle<String> res = fosterwxMobileWxfriendService.checkFriend(addFosterwxMobileHandle);
         if(res.getErr() != null){
@@ -119,5 +145,60 @@ public class FosterwxMobileWxfriendController extends BaseController<FosterwxMob
         fosterwxMobileWxfriendService.removeAndAdd(addFosterwxMobileHandle);
         return AjaxResult.success();
     }
+
+    @PostMapping("/import")
+    public Object uploadFile(@RequestBody MultipartFile file, @AuthUser User authUser) {
+        Map<String, Object> map = new HashMap<>(16);
+        Map<Integer, String> feild = new HashMap<>(5);
+        feild.put(0, "stationName");
+        feild.put(1, "mobileCode");
+        feild.put(2, "friendId");
+        List<Map<String, String>> row = new ArrayList<>();
+        VoltaHandle<ArrayList<Map<String, String>>> voltaRes = Analysis.analysis(file, feild);
+        if (voltaRes.getErr() != null) {
+            return AjaxResult.error(voltaRes.getErr());
+        }
+        row = voltaRes.getData();
+        try {
+            VoltaHandle<Boolean> res = fosterwxMobileWxfriendService.importData(row, authUser);
+        } catch (Exception e) {
+            return AjaxResult.error(e.getMessage());
+        }
+        return AjaxResult.success(HttpMsg.importSuccess);
+    }
+
+    @PostMapping("/export")
+    public Object export(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult){
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        ResHandle<List<FosterwxMobileWxfriend>> res = fosterwxMobileWxfriendService.export(postBasePageHandle);
+        List<Object> tempObj;
+        List<List<Object>> resList = new ArrayList<List<Object>>();
+        Object[] head = {"站点编号","账号编号","好友ID"};
+        List<Object> headList = Arrays.asList(head);
+        Date currentTime = new Date();
+        String fileName = "账号绑定好友数据.csv";
+        resList.add(headList);
+        for (FosterwxMobileWxfriend fosterwxMobileWxfriend : res.getList()){
+            tempObj = new ArrayList<Object>() {
+                {
+                    this.add(fosterwxMobileWxfriend.getStationName());
+                    this.add(fosterwxMobileWxfriend.getMobileCode());
+                    this.add(fosterwxMobileWxfriend.getFriendId());
+                }
+            };
+            resList.add(tempObj);
+        }
+        StringBuffer content = OssFile.createCSV(resList);
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        String dateString = formatter.format(currentTime);
+        String randNum = Integer.toString((int)(10000+Math.random()*(99999-10000+1)));
+        String filePath = OSSConfiguration.PAN_DIR + dateString + "/" + randNum + "_" + fileName;
+        PutObjectRequest putObjectRequest = new PutObjectRequest(ossConfiguration.getBucketName(), filePath,
+                new ByteArrayInputStream(content.toString().getBytes()));
+        ossClient.putObject(putObjectRequest);
+        return AjaxResult.success(ossConfiguration.getHost() + filePath);
+    }
 }
 

+ 78 - 4
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxWxfriendController.java

@@ -1,9 +1,20 @@
 package com.mokamrp.privates.controller.pangu;
 
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.model.PutObjectRequest;
+import com.mokamrp.privates.config.OSSConfiguration;
+import com.mokamrp.privates.constant.HttpMsg;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.help.Analysis;
+import com.mokamrp.privates.interceptor.AuthUser;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
+import com.mokamrp.privates.mapper.pojo.User;
+import com.mokamrp.privates.utils.OssFile;
+import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -14,10 +25,12 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import com.mokamrp.privates.controller.BaseController;
 import javax.validation.Valid;
-import java.util.Map;
-import java.util.List;
+import java.io.ByteArrayInputStream;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -26,15 +39,20 @@ import org.springframework.web.bind.annotation.RestController;
  * </p>
  *
  * @author leon
- * @since 2021-11-03
+ * @since 2021-11-10
  */
 @RestController
-@RequestMapping("/fosterwxWxfriend")
+@RequestMapping("/pangu/fosterwxWxfriend")
+@Api(tags = "个微养号站点好友管理")
 public class FosterwxWxfriendController extends BaseController<FosterwxWxfriend> {
 
     @Autowired
     public FosterwxWxfriendService fosterwxWxfriendService;
+    @Autowired
+    private OSSConfiguration ossConfiguration;
 
+    @Autowired
+    private OSS ossClient;
     /*
      * @fast
      * 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
@@ -50,5 +68,61 @@ public class FosterwxWxfriendController extends BaseController<FosterwxWxfriend>
         return AjaxResult.success(res);
     }
 
+    @PostMapping("/export")
+    public Object export(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult){
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        ResHandle<List<FosterwxWxfriend>> res = fosterwxWxfriendService.getList(postBasePageHandle);
+        List<Object> tempObj;
+        List<List<Object>> resList = new ArrayList<List<Object>>();
+        Object[] head = {"ID","好友昵称","微信号","站点编号","状态"};
+        List<Object> headList = Arrays.asList(head);
+        Date currentTime = new Date();
+        String fileName = "站点微信好友数据.csv";
+        resList.add(headList);
+        for (FosterwxWxfriend fosterwxWxfriend : res.getList()){
+            tempObj = new ArrayList<Object>() {
+                {
+                    this.add(fosterwxWxfriend.getId());
+                    this.add(fosterwxWxfriend.getWxName());
+                    this.add(fosterwxWxfriend.getWxUsername());
+                    this.add(fosterwxWxfriend.getStationName());
+                    this.add(fosterwxWxfriend.getStatus());
+                }
+            };
+            resList.add(tempObj);
+        }
+        StringBuffer content = OssFile.createCSV(resList);
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        String dateString = formatter.format(currentTime);
+        String randNum = Integer.toString((int)(10000+Math.random()*(99999-10000+1)));
+        String filePath = OSSConfiguration.PAN_DIR + dateString + "/" + randNum + "_" + fileName;
+        PutObjectRequest putObjectRequest = new PutObjectRequest(ossConfiguration.getBucketName(), filePath,
+                new ByteArrayInputStream(content.toString().getBytes()));
+        ossClient.putObject(putObjectRequest);
+        return AjaxResult.success(ossConfiguration.getHost() + filePath);
+    }
+
+    @PostMapping("/import")
+    public Object uploadFile(@RequestBody MultipartFile file, @AuthUser User authUser) {
+        Map<String, Object> map = new HashMap<>(16);
+        Map<Integer, String> feild = new HashMap<>(5);
+        feild.put(0, "stationName");
+        feild.put(1, "wxName");
+        feild.put(2, "wxUsername");
+        List<Map<String, String>> row = new ArrayList<>();
+        VoltaHandle<ArrayList<Map<String, String>>> voltaRes = Analysis.analysis(file, feild);
+        if (voltaRes.getErr() != null) {
+            return AjaxResult.error(voltaRes.getErr());
+        }
+        row = voltaRes.getData();
+        try {
+            VoltaHandle<Boolean> res = fosterwxWxfriendService.importData(row, authUser);
+        } catch (Exception e) {
+            return AjaxResult.error(e.getMessage());
+        }
+        return AjaxResult.success(HttpMsg.importSuccess);
+    }
 }
 

+ 2 - 0
src/main/java/com/mokamrp/privates/entity/PostBasePageHandle.java

@@ -10,6 +10,7 @@ public class PostBasePageHandle {
     private Integer groupId;
     private Integer stationId;
     private Integer mobileId;
+    private String mobileCode;
     private Integer createUid;
     private String title;
     private String name;
@@ -20,6 +21,7 @@ public class PostBasePageHandle {
     private String ghId;
     private Integer uploadUid;
     private Integer wxType;
+    private Integer status;
     public Integer getPage() {
         return page;
     }

+ 1 - 1
src/main/java/com/mokamrp/privates/entity/pangu/AddFosterwxMobileHandle.java

@@ -8,5 +8,5 @@ import java.util.List;
 @Data
 public class AddFosterwxMobileHandle {
     private Integer mobileId;
-    private List<FosterwxMobileWxfriend> friends;
+    private List<Integer> friendIds;
 }

+ 22 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileForbiddenRecordMapper.java

@@ -0,0 +1,22 @@
+package com.mokamrp.privates.mapper.pangu;
+
+import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileForbiddenRecord;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.springframework.stereotype.Component;
+import org.apache.ibatis.annotations.Param;
+import java.util.List;
+
+/**
+ * <p>
+ * 盘古养号账号封禁记录 Mapper 接口
+ * </p>
+ *
+ * @author leon
+ * @since 2021-11-13
+ */
+@Component
+public interface FosterwxMobileForbiddenRecordMapper extends BaseMapper<FosterwxMobileForbiddenRecord> {
+    public List<FosterwxMobileForbiddenRecord> getList(Page<FosterwxMobileForbiddenRecord> pageObj, @Param("params")PostBasePageHandle handle);
+}

+ 37 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileForbiddenRecordMapper.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.mokamrp.privates.mapper.pangu.FosterwxMobileForbiddenRecordMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileForbiddenRecord">
+        <id column="id" property="id"/>
+        <result column="type" property="type"/>
+        <result column="unseal_friend_id" property="unsealFriendId"/>
+        <result column="switch_unseal_friend_id" property="switchUnsealFriendId"/>
+        <result column="forbidden_image" property="forbiddenImage"/>
+        <result column="forbidden_at" property="forbiddenAt"/>
+        <result column="unseal_at" property="unsealAt"/>
+        <result column="create_at" property="createAt"/>
+        <result column="update_at" property="updateAt"/>
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id
+        , type, unseal_friend_id, switch_unseal_friend_id, forbidden_image, forbidden_at, unseal_at, create_at, update_at
+    </sql>
+    <select id="getList" resultType="com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileForbiddenRecord">
+        SELECT A.*,
+        B.wx_name as unseal_wx_name,
+        B.wx_username as unseal_wx_username,
+        C.wx_name as switch_unseal_wx_name,
+        C.wx_username as switch_unseal_wx_username
+        FROM pan_fosterwx_mobile_forbidden_record as A
+        left join pan_fosterwx_wxfriend as B on A.unseal_friend_id = B.id
+        left join pan_fosterwx_wxfriend as C on A.switch_unseal_friend_id = C.id
+        <where>
+            <if test="params.id != null">and A.mobile_id = #{params.id}</if>
+            <if test="params.type != null">and A.type = #{params.type}</if>
+        </where>
+    </select>
+</mapper>

+ 7 - 1
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileWxfriendMapper.java

@@ -1,8 +1,10 @@
 package com.mokamrp.privates.mapper.pangu;
 
+import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend;
 import org.springframework.stereotype.Component;
 import org.apache.ibatis.annotations.Param;
 import java.util.List;
@@ -17,5 +19,9 @@ import java.util.List;
  */
 @Component
 public interface FosterwxMobileWxfriendMapper extends BaseMapper<FosterwxMobileWxfriend> {
-    public List<FosterwxMobileWxfriend> getList(Page<FosterwxMobileWxfriend> pageObj);
+    public List<FosterwxMobileWxfriend> getList(Page<FosterwxMobileWxfriend> pageObj,@Param("params")PostBasePageHandle handle);
+    public List<FosterwxMobileWxfriend> getListPro(Page<FosterwxMobileWxfriend> pageObj, @Param("params")PostBasePageHandle handle);
+    public List<FosterwxMobileWxfriend> export(Page<FosterwxMobileWxfriend> pageObj, @Param("params")PostBasePageHandle handle);
+    public List<FosterwxWxfriend> getCanSwtichFriendList();
+    public List<FosterwxWxfriend> getCanBindFriendList();
 }

+ 67 - 3
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileWxfriendMapper.xml

@@ -7,8 +7,6 @@
         <id column="id" property="id" />
         <result column="mobile_id" property="mobileId" />
         <result column="seq" property="seq" />
-        <result column="wx_name" property="wxName" />
-        <result column="wx_username" property="wxUsername" />
         <result column="create_at" property="createAt" />
         <result column="update_at" property="updateAt" />
     </resultMap>
@@ -18,6 +16,72 @@
         id, mobile_id, seq, wx_name, wx_username, create_at, update_at
     </sql>
     <select id="getList" resultType="com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend">
-        SELECT * FROM pan_fosterwx_mobile_wxfriend
+        SELECT A.id,
+               A.seq,
+               A.mobile_id,
+               A.friend_id,
+               B.wx_name,
+               B.wx_username,
+               B.status,
+               B.switch_friend_id,
+               B.next_start_at
+               FROM pan_fosterwx_mobile_wxfriend as A
+        left join pan_fosterwx_wxfriend as B on A.friend_id = B.id
+        <where>
+            <if test="params.mobileId">and A.mobile_id = #{params.mobileId}</if>
+        </where>
+        order by A.seq asc
+    </select>
+
+    <select id="getCanSwtichFriendList" resultType="com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend">
+        SELECT A.* FROM pan_fosterwx_wxfriend AS A
+        LEFT JOIN (SELECT friend_id FROM pan_fosterwx_mobile_wxfriend GROUP BY friend_id) AS B ON A.id = B.friend_id
+        WHERE B.friend_id IS null
+        and A.status = 1
+    </select>
+
+    <select id="getCanBindFriendList" resultType="com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend">
+        SELECT t.* from (SELECT A.*,ifnull(B.bind_mobile_cnt,0) as bind_mobile_cnt FROM pan_fosterwx_wxfriend AS A
+        LEFT JOIN (SELECT count(friend_id) as bind_mobile_cnt,friend_id FROM pan_fosterwx_mobile_wxfriend GROUP BY friend_id) AS B ON A.id = B.friend_id
+        WHERE A.status = 1) AS t
+        WHERE t.bind_mobile_cnt &lt; 3
+    </select>
+    <select id="getListPro" resultType="com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend">
+        SELECT GROUP_CONCAT(B.wx_name,'#',B.wx_username,'#',B.id) as wx_str,
+               A.mobile_id,
+               C.mobile_code,
+               D.id as station_id,
+               D.station_name
+        FROM pan_fosterwx_mobile_wxfriend as A
+                 left join pan_fosterwx_wxfriend as B on A.friend_id = B.id
+                 left join pan_fosterwx_mobile as C on A.mobile_id = C.id
+                 left join pan_fosterwx_station as D on C.station_id = D.id
+        <where>
+            <if test="params.stationId">and D.id = #{params.stationId}</if>
+            <if test="params.mobileCode">and C.mobile_code = #{params.mobileCode}</if>
+            <if test="params.name">and B.wx_name like CONCAT('%',#{params.name},'%') or B.wx_username like CONCAT('%',#{params.name},'%')</if>
+        </where>
+        GROUP BY A.mobile_id,C.mobile_code,D.id,D.station_name
+    </select>
+
+    <select id="export" resultType="com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend">
+        SELECT T.* FROM  (SELECT
+        A.friend_id,
+        A.mobile_id,
+        B.wx_name,
+        B.wx_username,
+        C.mobile_code,
+        D.id as station_id,
+        D.station_name
+        FROM pan_fosterwx_mobile_wxfriend as A
+        left join pan_fosterwx_wxfriend as B on A.friend_id = B.id
+        left join pan_fosterwx_mobile as C on A.mobile_id = C.id
+        left join pan_fosterwx_station as D on C.station_id = D.id
+        GROUP BY A.mobile_id,B.wx_name,B.wx_username,C.mobile_code,D.id,D.station_name,A.friend_id) as T
+        <where>
+            <if test="params.stationId">and T.station_id = #{params.stationId}</if>
+            <if test="params.mobileCode">and T.mobile_code = #{params.mobileCode}</if>
+            <if test="params.name">and T.wx_name like CONCAT('%',#{params.name},'%') or T.wx_username like CONCAT('%',#{params.name},'%')</if>
+        </where>
     </select>
 </mapper>

+ 3 - 2
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxWxfriendMapper.java

@@ -1,5 +1,6 @@
 package com.mokamrp.privates.mapper.pangu;
 
+import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -13,9 +14,9 @@ import java.util.List;
  * </p>
  *
  * @author leon
- * @since 2021-11-03
+ * @since 2021-11-10
  */
 @Component
 public interface FosterwxWxfriendMapper extends BaseMapper<FosterwxWxfriend> {
-    public List<FosterwxWxfriend> getList(Page<FosterwxWxfriend> pageObj);
+    public List<FosterwxWxfriend> getList(Page<FosterwxWxfriend> pageObj, @Param("params") PostBasePageHandle handle);
 }

+ 14 - 2
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxWxfriendMapper.xml

@@ -9,6 +9,7 @@
         <result column="status" property="status" />
         <result column="wx_name" property="wxName" />
         <result column="wx_username" property="wxUsername" />
+        <result column="switch_friend_id" property="switchFriendId" />
         <result column="next_start_at" property="nextStartAt" />
         <result column="create_at" property="createAt" />
         <result column="update_at" property="updateAt" />
@@ -16,9 +17,20 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, station_id, status, wx_name, wx_username, next_start_at, create_at, update_at
+        id, station_id, status, wx_name, wx_username, switch_friend_id, next_start_at, create_at, update_at
     </sql>
     <select id="getList" resultType="com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend">
-        SELECT * FROM pan_fosterwx_wxfriend
+        SELECT A.*,
+               B.wx_name as switch_friend_wx_name,
+               C.station_name
+        FROM pan_fosterwx_wxfriend as A
+        left join pan_fosterwx_wxfriend as B on A.switch_friend_id = B.id
+        left join pan_fosterwx_station as C on A.station_id = C.id
+        <where>
+            <if test="params.name != null">and A.wx_name like CONCAT('%',#{params.name},'%')</if>
+            <if test="params.status != null">and A.status = #{params.status}</if>
+            <if test="params.stationId != null">and A.station_id = #{params.stationId}</if>
+        </where>
+        order by A.create_at desc
     </select>
 </mapper>

+ 2 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxMobile.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import io.swagger.models.auth.In;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -183,6 +184,7 @@ public class FosterwxMobile extends Model<FosterwxMobile> {
      */
     private String codeUrl;
 
+
     /**
      * 创建时间
      */

+ 174 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxMobileForbiddenRecord.java

@@ -0,0 +1,174 @@
+package com.mokamrp.privates.mapper.pangu.pojo;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 盘古养号账号封禁记录
+ * </p>
+ *
+ * @author leon
+ * @since 2021-11-13
+ */
+@Data
+@TableName("pan_fosterwx_mobile_forbidden_record")
+public class FosterwxMobileForbiddenRecord extends Model<FosterwxMobileForbiddenRecord> {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+      @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 封禁类型(1.个微2.企微)
+     */
+    private Integer type;
+
+    /**
+     * 解封好友
+     */
+    private Integer unsealFriendId;
+
+    /**
+     * 新解封好友
+     */
+    private Integer switchUnsealFriendId;
+
+    @TableField(exist = false)
+    private String unsealWxName;
+    @TableField(exist = false)
+    private String unsealWxUsername;
+    @TableField(exist = false)
+    private String switchUnsealWxName;
+    @TableField(exist = false)
+    private String switchUnsealWxUsername;
+
+    /**
+     * 账号封禁截图
+     */
+    private String forbiddenImage;
+
+    /**
+     * 封禁时间
+     */
+    private LocalDateTime forbiddenAt;
+
+    /**
+     * 解封时间
+     */
+    private LocalDateTime unsealAt;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createAt;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateAt;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public Integer getUnsealFriendId() {
+        return unsealFriendId;
+    }
+
+    public void setUnsealFriendId(Integer unsealFriendId) {
+        this.unsealFriendId = unsealFriendId;
+    }
+
+    public Integer getSwitchUnsealFriendId() {
+        return switchUnsealFriendId;
+    }
+
+    public void setSwitchUnsealFriendId(Integer switchUnsealFriendId) {
+        this.switchUnsealFriendId = switchUnsealFriendId;
+    }
+
+    public String getForbiddenImage() {
+        return forbiddenImage;
+    }
+
+    public void setForbiddenImage(String forbiddenImage) {
+        this.forbiddenImage = forbiddenImage;
+    }
+
+    public LocalDateTime getForbiddenAt() {
+        return forbiddenAt;
+    }
+
+    public void setForbiddenAt(LocalDateTime forbiddenAt) {
+        this.forbiddenAt = forbiddenAt;
+    }
+
+    public LocalDateTime getUnsealAt() {
+        return unsealAt;
+    }
+
+    public void setUnsealAt(LocalDateTime unsealAt) {
+        this.unsealAt = unsealAt;
+    }
+
+    public LocalDateTime getCreateAt() {
+        return createAt;
+    }
+
+    public void setCreateAt(LocalDateTime createAt) {
+        this.createAt = createAt;
+    }
+
+    public LocalDateTime getUpdateAt() {
+        return updateAt;
+    }
+
+    public void setUpdateAt(LocalDateTime updateAt) {
+        this.updateAt = updateAt;
+    }
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+    @Override
+    public String toString() {
+        return "FosterwxMobileForbiddenRecord{" +
+        "id=" + id +
+        ", type=" + type +
+        ", unsealFriendId=" + unsealFriendId +
+        ", switchUnsealFriendId=" + switchUnsealFriendId +
+        ", forbiddenImage=" + forbiddenImage +
+        ", forbiddenAt=" + forbiddenAt +
+        ", unsealAt=" + unsealAt +
+        ", createAt=" + createAt +
+        ", updateAt=" + updateAt +
+        "}";
+    }
+}

+ 18 - 3
src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxMobileWxfriend.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import lombok.Data;
+import org.springframework.cglib.core.Local;
 
 import java.time.LocalDateTime;
 import java.io.Serializable;
@@ -43,12 +44,26 @@ public class FosterwxMobileWxfriend extends Model<FosterwxMobileWxfriend> {
     /**
      * 好友ID
      */
-    @TableField(exist = false)
     private Integer friendId;
-
+    @TableField(exist = false)
     private String wxName;
-
+    @TableField(exist = false)
     private String wxUsername;
+    @TableField(exist = false)
+    private Integer status;
+    @TableField(exist = false)
+    private Integer switchFriendId;
+    @TableField(exist = false)
+    private LocalDateTime nextStartAt;
+    @TableField(exist = false)
+    private String wxStr;
+    @TableField(exist = false)
+    private String mobileCode;
+    @TableField(exist = false)
+    private String stationName;
+    @TableField(exist = false)
+    private Integer stationId;
+
     /**
      * 创建时间
      */

+ 39 - 1
src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxWxfriend.java

@@ -1,11 +1,17 @@
 package com.mokamrp.privates.mapper.pangu.pojo;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.Data;
+
 import java.time.LocalDateTime;
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * <p>
@@ -13,8 +19,9 @@ import java.io.Serializable;
  * </p>
  *
  * @author leon
- * @since 2021-11-03
+ * @since 2021-11-10
  */
+@Data
 @TableName("pan_fosterwx_wxfriend")
 public class FosterwxWxfriend extends Model<FosterwxWxfriend> {
 
@@ -47,6 +54,28 @@ public class FosterwxWxfriend extends Model<FosterwxWxfriend> {
     private String wxUsername;
 
     /**
+     * 替换解封好友
+     */
+    private Integer switchFriendId;
+    @TableField(exist = false)
+    private String stationName;
+
+    /**
+     * 已经绑定的账号
+     */
+    @TableField(exist = false)
+    private Integer bindMobileCnt;
+
+    /**
+     * 绑定的解封手机账号
+     */
+    @TableField(exist = false)
+    private List<FosterwxMobile> bindUnsealMobile;
+
+    @TableField(exist = false)
+    private String switchFriendWxName;
+
+    /**
      * 下次启用时间
      */
     private LocalDateTime nextStartAt;
@@ -96,6 +125,14 @@ public class FosterwxWxfriend extends Model<FosterwxWxfriend> {
         this.wxUsername = wxUsername;
     }
 
+    public Integer getSwitchFriendId() {
+        return switchFriendId;
+    }
+
+    public void setSwitchFriendId(Integer switchFriendId) {
+        this.switchFriendId = switchFriendId;
+    }
+
     public LocalDateTime getNextStartAt() {
         return nextStartAt;
     }
@@ -133,6 +170,7 @@ public class FosterwxWxfriend extends Model<FosterwxWxfriend> {
         ", status=" + status +
         ", wxName=" + wxName +
         ", wxUsername=" + wxUsername +
+        ", switchFriendId=" + switchFriendId +
         ", nextStartAt=" + nextStartAt +
         ", createAt=" + createAt +
         ", updateAt=" + updateAt +

+ 20 - 0
src/main/java/com/mokamrp/privates/service/pangu/FosterwxMobileForbiddenRecordService.java

@@ -0,0 +1,20 @@
+package com.mokamrp.privates.service.pangu;
+
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileForbiddenRecord;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.ResHandle;
+import java.util.List;
+import java.util.Map;
+/**
+ * <p>
+ * 盘古养号账号封禁记录 服务类
+ * </p>
+ *
+ * @author leon
+ * @since 2021-11-13
+ */
+public interface FosterwxMobileForbiddenRecordService extends IService<FosterwxMobileForbiddenRecord> {
+    //.@leon 获取数据列表
+    public ResHandle<List<FosterwxMobileForbiddenRecord>> getList(PostBasePageHandle handle);
+}

+ 16 - 1
src/main/java/com/mokamrp/privates/service/pangu/FosterwxMobileWxfriendService.java

@@ -1,10 +1,15 @@
 package com.mokamrp.privates.service.pangu;
 
+import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.entity.pangu.AddFosterwxMobileHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend;
+import com.mokamrp.privates.mapper.pojo.User;
+
+import java.util.List;
 import java.util.Map;
 /**
  * <p>
@@ -16,7 +21,17 @@ import java.util.Map;
  */
 public interface FosterwxMobileWxfriendService extends IService<FosterwxMobileWxfriend> {
     //.@leon 获取数据列表
-    public Map<String, Object> getList(PostBasePageHandle handle);
+    public ResHandle<List<FosterwxMobileWxfriend>> getList(PostBasePageHandle handle);
+    //.@leon 导入数据
+    public VoltaHandle<Boolean> importData(List<Map<String,String>> row, User authUser) throws Exception;
+    //.@leon 获取数据列表 加强版
+    public ResHandle<List<FosterwxMobileWxfriend>> getListPro(PostBasePageHandle handle);
+
+    public ResHandle<List<FosterwxMobileWxfriend>> export(PostBasePageHandle handle);
+    //.@volta 获取可被替换的解封好友
+    public List<FosterwxWxfriend> getCanSwtichFriendList();
+    //.@volta 获取可被绑定的解封好友
+    public List<FosterwxWxfriend> getCanBindFriendList();
     //.@leon 删除数据同时新增数据
     public Boolean removeAndAdd(AddFosterwxMobileHandle addFosterwxMobileHandle);
     //.@leon 检查好友限制

+ 6 - 1
src/main/java/com/mokamrp/privates/service/pangu/FosterwxWxfriendService.java

@@ -1,9 +1,12 @@
 package com.mokamrp.privates.service.pangu;
 
+import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.mapper.pojo.User;
+
 import java.util.List;
 import java.util.Map;
 /**
@@ -12,9 +15,11 @@ import java.util.Map;
  * </p>
  *
  * @author leon
- * @since 2021-11-03
+ * @since 2021-11-10
  */
 public interface FosterwxWxfriendService extends IService<FosterwxWxfriend> {
     //.@leon 获取数据列表
     public ResHandle<List<FosterwxWxfriend>> getList(PostBasePageHandle handle);
+    //.@leon 导入
+    public VoltaHandle<Boolean> importData(List<Map<String,String>> row, User authUser) throws Exception;
 }

+ 4 - 10
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashOasBoxServiceImpl.java

@@ -102,14 +102,11 @@ public class FosterwxCashOasBoxServiceImpl extends ServiceImpl<FosterwxCashOasBo
         if (list == null || list.size() <= 0) {
             return null;
         }
+        Random rand =  new Random();
         if (list.size() == 1){
             return list.get(0);
         }
-        int max = list.size() - 1;
-        int min = 0;
-        Random random = new Random();
-        int i = random.nextInt(max) % (max - min + 1) + min;
-        return list.get(i);
+        return list.get(rand.nextInt(list.size()));
     }
 
     /**
@@ -132,11 +129,8 @@ public class FosterwxCashOasBoxServiceImpl extends ServiceImpl<FosterwxCashOasBo
         if (list.size() == 1){
             return list.get(0);
         }
-        int max = list.size() - 1;
-        int min = 0;
-        Random random = new Random();
-        int i = random.nextInt(max) % (max - min + 1) + min;
-        return list.get(i);
+        Random rand =  new Random();
+        return list.get(rand.nextInt(list.size()));
     }
 
     /**

+ 43 - 0
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileForbiddenRecordServiceImpl.java

@@ -0,0 +1,43 @@
+package com.mokamrp.privates.service.pangu.impl;
+
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileForbiddenRecord;
+import com.mokamrp.privates.mapper.pangu.FosterwxMobileForbiddenRecordMapper;
+import com.mokamrp.privates.service.pangu.FosterwxMobileForbiddenRecordService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import com.mokamrp.privates.entity.ResHandle;
+import java.util.*;
+
+/**
+ * <p>
+ * 盘古养号账号封禁记录 服务实现类
+ * </p>
+ *
+ * @author leon
+ * @since 2021-11-13
+ */
+@Service
+public class FosterwxMobileForbiddenRecordServiceImpl extends ServiceImpl<FosterwxMobileForbiddenRecordMapper, FosterwxMobileForbiddenRecord> implements FosterwxMobileForbiddenRecordService {
+
+    @Autowired
+    public FosterwxMobileForbiddenRecordMapper fosterwxMobileForbiddenRecordMapper;
+    /**
+     * 获取数据列表 支持分页
+     * @param handle
+     * @return
+     */
+    public ResHandle<List<FosterwxMobileForbiddenRecord>> getList(PostBasePageHandle handle) {
+        Integer pagesize = handle.getPagesize();
+        Integer page = handle.getPage();
+        Page<FosterwxMobileForbiddenRecord> pageObj = new Page<FosterwxMobileForbiddenRecord>(page, pagesize);
+        List<FosterwxMobileForbiddenRecord> list = fosterwxMobileForbiddenRecordMapper.getList(pageObj,handle);
+        ResHandle<List<FosterwxMobileForbiddenRecord>> res = new ResHandle<>();
+        res.setList(list);
+        res.setTotal(pageObj.getTotal());
+        return res;
+    }
+}

+ 24 - 28
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileServiceImpl.java

@@ -186,32 +186,28 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
             );
             //.批量录入微信好友
             List<FosterwxMobileWxfriend> addFriend = new ArrayList<>();
-            Map<String, Boolean> friendsNames = new HashMap<>();
+            Map<Integer, Boolean> friendsIds = new HashMap<>();
             for (Integer s = 1; s <= 3; s++) {
                 String sStr = s.toString();
-                String wxFriendName = row.get(i).get("wxFriendName" + sStr);
-                String wxFriendUserName = row.get(i).get("wxFriendUserName" + sStr);
-                if (wxFriendName == null || wxFriendName.isEmpty()) {
+                String wxFriendIdStr = row.get(i).get("wxFriendId" + sStr);
+                Integer wxFriendId = Integer.parseInt(wxFriendIdStr);
+                if (wxFriendId == null || wxFriendId == 0) {
                     continue;
                 }
-                if (friendsNames.get(wxFriendName) != null) {
-                    throw new Exception("第" + (i + 1) + "行," + wxFriendName + "微信好友名称录入重复");
+                if (friendsIds.get(wxFriendId) != null) {
+                    throw new Exception("第" + (i + 1) + "行," + wxFriendId + "微信好友ID录入重复");
                 }
-                friendsNames.put(wxFriendName, true);
-                Boolean findRes = this.checkWxFriendCnt(friends, wxFriendName);
+                friendsIds.put(wxFriendId, true);
+                Boolean findRes = this.checkWxFriendCnt(friends, wxFriendId);
                 if (!findRes) {
-                    throw new Exception("第" + (i + 1) + "行," + wxFriendName + "微信好友名称在当前站点内已经使用超过三次,无法再次录入");
+                    throw new Exception("第" + (i + 1) + "行," + wxFriendId + "微信好友ID在当前站点内已经使用超过三次,无法再次录入");
                 }
                 FosterwxMobileWxfriend fosterwxMobileWxfriend = new FosterwxMobileWxfriend();
                 fosterwxMobileWxfriend.setMobileId(fosterwxMobile.getId());
                 fosterwxMobileWxfriend.setCreateAt(nowDate);
                 fosterwxMobileWxfriend.setUpdateAt(nowDate);
                 fosterwxMobileWxfriend.setSeq(s);
-                fosterwxMobileWxfriend.setWxName(wxFriendName);
-                if (wxFriendUserName != null && !wxFriendUserName.isEmpty()) {
-                    fosterwxMobileWxfriend.setWxUsername(wxFriendUserName);
-                }
-
+                fosterwxMobileWxfriend.setFriendId(wxFriendId);
                 addFriend.add(fosterwxMobileWxfriend);
             }
 
@@ -245,18 +241,18 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
             if (wxfriendList == null || wxfriendList.size() <= 0) {
                 continue;
             }
-            for (FosterwxMobileWxfriend fosterwxMobileWxfriend : wxfriendList) {
-                if (fosterwxMobileWxfriend.getSeq().equals(1)) {
-                    fosterwxMobileVo.setWxName1(fosterwxMobileWxfriend.getWxName());
-                    fosterwxMobileVo.setWxUsername1(fosterwxMobileWxfriend.getWxUsername());
-                } else if (fosterwxMobileWxfriend.getSeq().equals(2)) {
-                    fosterwxMobileVo.setWxName2(fosterwxMobileWxfriend.getWxName());
-                    fosterwxMobileVo.setWxUsername2(fosterwxMobileWxfriend.getWxUsername());
-                } else if (fosterwxMobileWxfriend.getSeq().equals(3)) {
-                    fosterwxMobileVo.setWxName3(fosterwxMobileWxfriend.getWxName());
-                    fosterwxMobileVo.setWxUsername3(fosterwxMobileWxfriend.getWxUsername());
-                }
-            }
+//            for (FosterwxMobileWxfriend fosterwxMobileWxfriend : wxfriendList) {
+//                if (fosterwxMobileWxfriend.getSeq().equals(1)) {
+//                    fosterwxMobileVo.setWxName1(fosterwxMobileWxfriend.getWxName());
+//                    fosterwxMobileVo.setWxUsername1(fosterwxMobileWxfriend.getWxUsername());
+//                } else if (fosterwxMobileWxfriend.getSeq().equals(2)) {
+//                    fosterwxMobileVo.setWxName2(fosterwxMobileWxfriend.getWxName());
+//                    fosterwxMobileVo.setWxUsername2(fosterwxMobileWxfriend.getWxUsername());
+//                } else if (fosterwxMobileWxfriend.getSeq().equals(3)) {
+//                    fosterwxMobileVo.setWxName3(fosterwxMobileWxfriend.getWxName());
+//                    fosterwxMobileVo.setWxUsername3(fosterwxMobileWxfriend.getWxUsername());
+//                }
+//            }
         }
         return list;
     }
@@ -333,10 +329,10 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
         return true;
     }
 
-    private Boolean checkWxFriendCnt(List<FosterwxMobileWxfriend> row, String wxName) {
+    private Boolean checkWxFriendCnt(List<FosterwxMobileWxfriend> row, Integer friendId) {
         Integer findCnt = 0;
         for (FosterwxMobileWxfriend fosterwxMobileWxfriend : row) {
-            if (fosterwxMobileWxfriend.getWxName().equals(wxName)) {
+            if (fosterwxMobileWxfriend.getFriendId().equals(friendId)) {
                 findCnt++;
             }
             if (findCnt >= 3) {

+ 161 - 16
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileWxfriendServiceImpl.java

@@ -1,23 +1,33 @@
 package com.mokamrp.privates.service.pangu.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.mokamrp.privates.constant.HttpMsg;
+import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.entity.pangu.AddFosterwxMobileHandle;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
 import com.mokamrp.privates.mapper.pangu.FosterwxMobileWxfriendMapper;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend;
+import com.mokamrp.privates.mapper.pojo.Corp;
+import com.mokamrp.privates.mapper.pojo.User;
 import com.mokamrp.privates.service.pangu.FosterwxMobileService;
 import com.mokamrp.privates.service.pangu.FosterwxMobileWxfriendService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
+import com.mokamrp.privates.service.pangu.FosterwxWxfriendService;
 import org.springframework.stereotype.Service;
 import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -37,20 +47,71 @@ public class FosterwxMobileWxfriendServiceImpl extends ServiceImpl<FosterwxMobil
 
     @Autowired
     public FosterwxMobileService fosterwxMobileService;
+
+    @Autowired
+    public FosterwxStationService fosterwxStationService;
+
+    @Autowired
+    public FosterwxWxfriendService fosterwxWxfriendService;
     /**
      * 获取数据列表 支持分页
      * @param handle
      * @return
      */
-    public Map<String, Object> getList(PostBasePageHandle handle) {
+    public ResHandle<List<FosterwxMobileWxfriend>> getList(PostBasePageHandle handle) {
         Integer pagesize = handle.getPagesize();
         Integer page = handle.getPage();
         Page<FosterwxMobileWxfriend> pageObj = new Page<FosterwxMobileWxfriend>(page, pagesize);
-        List<FosterwxMobileWxfriend> list = fosterwxMobileWxfriendMapper.getList(pageObj);
-        Map<String, Object> resMap = new HashMap<String, Object>();
-        resMap.put("list", list);
-        resMap.put("total", pageObj.getTotal());
-        return resMap;
+        List<FosterwxMobileWxfriend> list = fosterwxMobileWxfriendMapper.getList(pageObj,handle);
+        ResHandle<List<FosterwxMobileWxfriend>> res = new ResHandle<>();
+        res.setList(list);
+        res.setTotal(pageObj.getTotal());
+        return res;
+    }
+
+    /**
+     * 获取数据列表 支持分页 加强版
+     * @param handle
+     * @return
+     */
+    public ResHandle<List<FosterwxMobileWxfriend>> getListPro(PostBasePageHandle handle) {
+        Integer pagesize = handle.getPagesize();
+        Integer page = handle.getPage();
+        Page<FosterwxMobileWxfriend> pageObj = new Page<FosterwxMobileWxfriend>(page, pagesize);
+        List<FosterwxMobileWxfriend> list = fosterwxMobileWxfriendMapper.getListPro(pageObj,handle);
+        ResHandle<List<FosterwxMobileWxfriend>> res = new ResHandle<>();
+        res.setList(list);
+        res.setTotal(pageObj.getTotal());
+        return res;
+    }
+
+    public ResHandle<List<FosterwxMobileWxfriend>> export(PostBasePageHandle handle) {
+        Integer pagesize = handle.getPagesize();
+        Integer page = handle.getPage();
+        Page<FosterwxMobileWxfriend> pageObj = new Page<FosterwxMobileWxfriend>(page, pagesize);
+        List<FosterwxMobileWxfriend> list = fosterwxMobileWxfriendMapper.export(pageObj,handle);
+        ResHandle<List<FosterwxMobileWxfriend>> res = new ResHandle<>();
+        res.setList(list);
+        res.setTotal(pageObj.getTotal());
+        return res;
+    }
+
+    /**
+     * 获取可被替换的解封好友
+     * @return
+     */
+    public List<FosterwxWxfriend> getCanSwtichFriendList() {
+        List<FosterwxWxfriend> list = fosterwxMobileWxfriendMapper.getCanSwtichFriendList();
+        return list;
+    }
+
+    /**
+     * 获取可被绑定的解封好友
+     * @return
+     */
+    public List<FosterwxWxfriend> getCanBindFriendList() {
+        List<FosterwxWxfriend> list = fosterwxMobileWxfriendMapper.getCanBindFriendList();
+        return list;
     }
 
     /**
@@ -62,8 +123,10 @@ public class FosterwxMobileWxfriendServiceImpl extends ServiceImpl<FosterwxMobil
         Integer i = 1;
         this.remove(new QueryWrapper<FosterwxMobileWxfriend>().eq("mobile_id",addFosterwxMobileHandle.getMobileId()));
         List<FosterwxMobileWxfriend> add = new ArrayList<>();
-        for (FosterwxMobileWxfriend fosterwxMobileWxfriend : addFosterwxMobileHandle.getFriends()){
+        for (Integer friendId : addFosterwxMobileHandle.getFriendIds()){
+            FosterwxMobileWxfriend fosterwxMobileWxfriend = new FosterwxMobileWxfriend();
             fosterwxMobileWxfriend.setSeq(i);
+            fosterwxMobileWxfriend.setFriendId(friendId);
             fosterwxMobileWxfriend.setMobileId(addFosterwxMobileHandle.getMobileId());
             fosterwxMobileWxfriend.setCreateAt(LocalDateTime.now());
             fosterwxMobileWxfriend.setUpdateAt(LocalDateTime.now());
@@ -88,26 +151,28 @@ public class FosterwxMobileWxfriendServiceImpl extends ServiceImpl<FosterwxMobil
         List<FosterwxMobileWxfriend> friends = this.list(new QueryWrapper<FosterwxMobileWxfriend>()
                 .in("mobile_id",mobileIds)
         );
-        Map<String,Boolean> friendsNames = new HashMap<>();
-        for (FosterwxMobileWxfriend add :addFosterwxMobileHandle.getFriends()){
-            if(friendsNames.get(add.getWxName()) != null){
-                res.setErr(HttpMsg.wxFriendResume+add.getWxName());
+
+        Map<Integer,Boolean> friendsNames = new HashMap<>();
+        for (Integer friendId :addFosterwxMobileHandle.getFriendIds()){
+            if(friendsNames.get(friendId) != null){
+                res.setErr(HttpMsg.wxFriendResume+friendId.toString());
                 return res;
             }
-            friendsNames.put(add.getWxName(),true);
-            Boolean findRes = this.checkWxFriendCnt(friends,add.getWxName());
+            friendsNames.put(friendId,true);
+            Boolean findRes = this.checkWxFriendCnt(friends,friendId);
             if (!findRes){
-                res.setErr(HttpMsg.wxFriendCntMax3+add.getWxName());
+                res.setErr(HttpMsg.wxFriendCntMax3+friendId.toString());
+
                 return res;
             }
         }
         return res;
     }
 
-    public Boolean checkWxFriendCnt(List<FosterwxMobileWxfriend> row,String wxName){
+    public Boolean checkWxFriendCnt(List<FosterwxMobileWxfriend> row,Integer friendId){
         Integer findCnt = 0;
         for (FosterwxMobileWxfriend fosterwxMobileWxfriend : row){
-            if (fosterwxMobileWxfriend.getWxName().equals(wxName)){
+            if (fosterwxMobileWxfriend.getFriendId().equals(friendId)){
                 findCnt++;
             }
             if (findCnt >= 3){
@@ -116,4 +181,84 @@ public class FosterwxMobileWxfriendServiceImpl extends ServiceImpl<FosterwxMobil
         }
         return true;
     }
+    @Transactional(rollbackFor = Exception.class)
+    public VoltaHandle<Boolean> importData(List<Map<String,String>> row, User authUser) throws Exception{
+        VoltaHandle<Boolean> res = new VoltaHandle<>();
+        if (row.size() <= 0) {
+            throw new Exception("表格读取完成后,没有获取到任何数据");
+        }
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        for (int i = 0; i < row.size(); i++) {
+            FosterwxStation stationInfo = fosterwxStationService.getOne(new QueryWrapper<FosterwxStation>()
+                    .eq("station_name", row.get(i).get("stationName")));
+            if (stationInfo == null) {
+                throw new Exception("站点编号不存在");
+            }
+            String mobileCode = String.format("%03d", Integer.parseInt(row.get(i).get("mobileCode")));
+            FosterwxMobile mobileInfo = fosterwxMobileService.getOne(new QueryWrapper<FosterwxMobile>()
+                    .eq("station_id", stationInfo.getId())
+                    .eq("mobile_code", mobileCode)
+            );
+            if (mobileInfo == null) {
+                throw new Exception("第" + (i + 1) + "行,手机编号:" + mobileCode + ",不存在");
+            }
+            FosterwxWxfriend friendInfo = fosterwxWxfriendService.getOne(new QueryWrapper<FosterwxWxfriend>()
+                    .eq("station_id",stationInfo.getId())
+                    .eq("id",row.get(i).get("friendId"))
+            );
+            if (friendInfo == null){
+                throw new Exception("第" + (i + 1) + "行,好友编号:"+row.get(i).get("friendId") + "不是"+stationInfo.getStationName()+"站点下的微信好友,请检查后录入");
+            }
+            //.判断是否同账号下重复绑定好友
+            Integer hasRecord = this.count(new QueryWrapper<FosterwxMobileWxfriend>()
+                    .eq("mobile_id",mobileInfo.getId())
+                    .eq("friend_id",row.get(i).get("friendId")));
+            if(hasRecord > 0){
+                throw new Exception("第" + (i + 1) + "行,好友编号:"+row.get(i).get("friendId") + "已经和账号绑定不可重复绑定");
+            }
+            //.判断账号下是否已经绑满3个好友
+            VoltaHandle<String> checkBindRes = this.checkOneFriendInMobile(mobileInfo.getId());
+            if (checkBindRes.getErr() != null){
+                throw new Exception("第" + (i + 1) + "行,站点编号:"+row.get(i).get("mobileCode") + "已经绑定3个好友,无法再次绑定了");
+            }
+            //.判断好友ID是否在站点下已经被绑定了3次
+            VoltaHandle<String> checkRes = this.checkOneFriend(stationInfo.getId(),Integer.parseInt(row.get(i).get("friendId")));
+            if (checkRes.getErr() != null){
+                throw new Exception("第" + (i + 1) + "行,好友编号:"+row.get(i).get("friendId") + "已经绑定3次,无法再次绑定了");
+            }
+            FosterwxMobileWxfriend add = new FosterwxMobileWxfriend();
+            add.setMobileId(mobileInfo.getId());
+            add.setFriendId(Integer.parseInt(row.get(i).get("friendId")));
+            add.setCreateAt(LocalDateTime.now());
+            add.setUpdateAt(LocalDateTime.now());
+            this.save(add);
+        }
+        return res;
+    }
+
+    public VoltaHandle<String> checkOneFriendInMobile(Integer mobileId){
+        VoltaHandle<String> res = new VoltaHandle<>();
+        Integer mobileBindCnt = this.count(new QueryWrapper<FosterwxMobileWxfriend>().eq("mobile_id",mobileId));
+        if (mobileBindCnt >= 3){
+            res.setErr("账号id:"+mobileId + "已经绑定了3个好友");
+        }
+        return res;
+    }
+
+    //.判断某个好友是否已经在站点下呗绑定了3次
+    public VoltaHandle<String> checkOneFriend(Integer stationId,Integer friendId){
+        VoltaHandle<String> res = new VoltaHandle<>();
+        List<FosterwxMobile> mobileList = fosterwxMobileService.list(new QueryWrapper<FosterwxMobile>()
+                .eq("station_id", stationId)
+        );
+        List<Integer> mobileIds = mobileList.stream().map(FosterwxMobile::getId).collect(Collectors.toList());
+        List<FosterwxMobileWxfriend> friends = this.list(new QueryWrapper<FosterwxMobileWxfriend>()
+                .in("mobile_id",mobileIds)
+                .eq("friend_id",friendId)
+        );
+        if (friends.size() >= 3){
+            res.setErr("好友id:"+friendId + "已经被绑定3个无法再绑定");
+        }
+        return res;
+    }
 }

+ 41 - 2
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxWxfriendServiceImpl.java

@@ -1,7 +1,14 @@
 package com.mokamrp.privates.service.pangu.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.entity.VoltaHandle;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend;
 import com.mokamrp.privates.mapper.pangu.FosterwxWxfriendMapper;
+import com.mokamrp.privates.mapper.pojo.User;
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
 import com.mokamrp.privates.service.pangu.FosterwxWxfriendService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
@@ -10,6 +17,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import com.mokamrp.privates.entity.ResHandle;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 
 /**
@@ -18,13 +29,16 @@ import java.util.*;
  * </p>
  *
  * @author leon
- * @since 2021-11-03
+ * @since 2021-11-10
  */
 @Service
 public class FosterwxWxfriendServiceImpl extends ServiceImpl<FosterwxWxfriendMapper, FosterwxWxfriend> implements FosterwxWxfriendService {
 
     @Autowired
     public FosterwxWxfriendMapper fosterwxWxfriendMapper;
+
+    @Autowired
+    public FosterwxStationService fosterwxStationService;
     /**
      * 获取数据列表 支持分页
      * @param handle
@@ -34,10 +48,35 @@ public class FosterwxWxfriendServiceImpl extends ServiceImpl<FosterwxWxfriendMap
         Integer pagesize = handle.getPagesize();
         Integer page = handle.getPage();
         Page<FosterwxWxfriend> pageObj = new Page<FosterwxWxfriend>(page, pagesize);
-        List<FosterwxWxfriend> list = fosterwxWxfriendMapper.getList(pageObj);
+        List<FosterwxWxfriend> list = fosterwxWxfriendMapper.getList(pageObj,handle);
         ResHandle<List<FosterwxWxfriend>> res = new ResHandle<>();
         res.setList(list);
         res.setTotal(pageObj.getTotal());
         return res;
     }
+
+    @Transactional(rollbackFor = Exception.class)
+    public VoltaHandle<Boolean> importData(List<Map<String,String>> row, User authUser) throws Exception{
+        VoltaHandle<Boolean> res = new VoltaHandle<>();
+        if (row.size() <= 0) {
+            throw new Exception("表格读取完成后,没有获取到任何数据");
+        }
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        for (int i = 0; i < row.size(); i++) {
+            FosterwxStation stationInfo = fosterwxStationService.getOne(new QueryWrapper<FosterwxStation>()
+                    .eq("station_name", row.get(i).get("stationName")));
+            if (stationInfo == null) {
+                throw new Exception("站点编号不存在");
+            }
+
+            FosterwxWxfriend add = new FosterwxWxfriend();
+            add.setStationId(stationInfo.getId());
+            add.setWxName(row.get(i).get("wxName"));
+            add.setWxUsername(row.get(i).get("wxUsername"));
+            add.setCreateAt(LocalDateTime.now());
+            add.setUpdateAt(LocalDateTime.now());
+            this.save(add);
+        }
+        return res;
+    }
 }

+ 65 - 0
src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxCanBindFriendToRedis.java

@@ -0,0 +1,65 @@
+package com.mokamrp.privates.task.pangu;
+
+import com.mokamrp.privates.constant.RedisKey;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend;
+import com.mokamrp.privates.service.pangu.FosterwxMobileWxfriendService;
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
+import com.mokamrp.privates.service.pangu.FosterwxWxfriendService;
+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.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class SyncFosterwxCanBindFriendToRedis {
+    @Autowired
+    public FosterwxWxfriendService fosterwxWxfriendService;
+
+    @Autowired
+    public FosterwxMobileWxfriendService fosterwxMobileWxfriendService;
+
+    @Autowired
+    public StringRedisTemplate stringRedisTemplate;
+
+    @Autowired
+    public FosterwxStationService fosterwxStationService;
+
+    @Scheduled(cron = "*/5 * * * * ?")
+    @SchedulerLock(name = "pangu:SyncFosterwxCanBindFriendToRedis", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void execute() {
+        System.out.println("[cronjob]:同步微信养号可被绑定的解封好友到REDIS");
+        List<FosterwxStation> stations = fosterwxStationService.list();
+        List<FosterwxWxfriend> list = fosterwxMobileWxfriendService.getCanBindFriendList();
+        Map<Integer,List<FosterwxWxfriend>> sync = new HashMap<>();
+        for (FosterwxWxfriend fosterwxWxfriend : list) {
+            if (sync.get(fosterwxWxfriend.getStationId()) == null){
+                List<FosterwxWxfriend> stationFriends = new ArrayList<>();
+                stationFriends.add(fosterwxWxfriend);
+                sync.put(fosterwxWxfriend.getStationId(),stationFriends);
+            }else{
+                List<FosterwxWxfriend> stationFriends = sync.get(fosterwxWxfriend.getStationId());
+                stationFriends.add(fosterwxWxfriend);
+                sync.put(fosterwxWxfriend.getStationId(),stationFriends);
+            }
+        }
+        for (FosterwxStation fosterwxStation : stations){
+            Integer stationId = fosterwxStation.getId();
+            //.置空
+            stringRedisTemplate.delete(RedisKey.PanWxFosterCanBindFriendId+stationId.toString());
+            if (sync.get(stationId) == null) continue;
+            for (FosterwxWxfriend fosterwxWxfriend: sync.get(stationId)){
+                //.更新可用好友
+                stringRedisTemplate.opsForSet().add(
+                        RedisKey.PanWxFosterCanBindFriendId+stationId.toString(),
+                        fosterwxWxfriend.getId().toString());
+            }
+        }
+    }
+}

+ 69 - 0
src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxCanSwitchFriendToRedis.java

@@ -0,0 +1,69 @@
+package com.mokamrp.privates.task.pangu;
+
+import com.alibaba.fastjson.JSONObject;
+import com.mokamrp.privates.constant.RedisKey;
+import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend;
+import com.mokamrp.privates.service.pangu.FosterwxMobileWxfriendService;
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
+import com.mokamrp.privates.service.pangu.FosterwxWxfriendService;
+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.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class SyncFosterwxCanSwitchFriendToRedis {
+    @Autowired
+    public FosterwxWxfriendService fosterwxWxfriendService;
+
+    @Autowired
+    public FosterwxMobileWxfriendService fosterwxMobileWxfriendService;
+
+    @Autowired
+    public StringRedisTemplate stringRedisTemplate;
+
+    @Autowired
+    public FosterwxStationService fosterwxStationService;
+
+    @Scheduled(cron = "*/5 * * * * ?")
+    @SchedulerLock(name = "pangu:SyncFosterwxCanSwitchFriendToRedis", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void execute() {
+        System.out.println("[cronjob]:同步微信养号可被替换的解封好友到REDIS");
+        List<FosterwxStation> stations = fosterwxStationService.list();
+        List<FosterwxWxfriend> list = fosterwxMobileWxfriendService.getCanSwtichFriendList();
+        Map<Integer,List<FosterwxWxfriend>> sync = new HashMap<>();
+        for (FosterwxWxfriend fosterwxWxfriend : list) {
+            if (sync.get(fosterwxWxfriend.getStationId()) == null){
+                List<FosterwxWxfriend> stationFriends = new ArrayList<>();
+                stationFriends.add(fosterwxWxfriend);
+                sync.put(fosterwxWxfriend.getStationId(),stationFriends);
+            }else{
+                List<FosterwxWxfriend> stationFriends = sync.get(fosterwxWxfriend.getStationId());
+                stationFriends.add(fosterwxWxfriend);
+                sync.put(fosterwxWxfriend.getStationId(),stationFriends);
+            }
+        }
+        for (FosterwxStation fosterwxStation : stations){
+            Integer stationId = fosterwxStation.getId();
+            //.置空
+            stringRedisTemplate.delete(RedisKey.PanWxFosterCanSwitchFriendId+stationId.toString());
+            if (sync.get(stationId) == null) continue;
+            for (FosterwxWxfriend fosterwxWxfriend: sync.get(stationId)){
+                //.更新可用好友
+                stringRedisTemplate.opsForSet().add(
+                        RedisKey.PanWxFosterCanSwitchFriendId+stationId.toString(),
+                        fosterwxWxfriend.getId().toString());
+            }
+        }
+    }
+}

+ 35 - 0
src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxFriendToRedis.java

@@ -0,0 +1,35 @@
+package com.mokamrp.privates.task.pangu;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.constant.RedisKey;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxTeachingVideo;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend;
+import com.mokamrp.privates.service.pangu.*;
+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.util.List;
+
+@Component
+public class SyncFosterwxFriendToRedis {
+    @Autowired
+    public FosterwxWxfriendService fosterwxWxfriendService;
+
+    @Autowired
+    public StringRedisTemplate stringRedisTemplate;
+
+    @Scheduled(cron = "*/1 * * * * ?")
+    @SchedulerLock(name = "pangu:SyncFosterwxFriendToRedis", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void execute() {
+        System.out.println("[cronjob]:同步微信养号站点好友到REDIS");
+        List<FosterwxWxfriend> fosterwxWxfriendList = fosterwxWxfriendService.list();
+        for (FosterwxWxfriend fosterwxWxfriend : fosterwxWxfriendList) {
+            stringRedisTemplate.opsForHash().put(RedisKey.PanWxFosterFriendInfo+fosterwxWxfriend.getStationId(),fosterwxWxfriend.getId().toString(),JSONObject.toJSONString(fosterwxWxfriend));
+        }
+    }
+}

+ 7 - 1
src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxMobile.java

@@ -2,6 +2,8 @@ package com.mokamrp.privates.task.pangu;
 
 import com.alibaba.fastjson.JSONArray;
 import com.mokamrp.privates.constant.RedisKey;
+import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
 import com.mokamrp.privates.service.pangu.FosterwxMobileService;
@@ -45,7 +47,11 @@ public class SyncFosterwxMobile {
         List<Integer> mobileIds = new ArrayList<>();
         this.fosterwxMobileList = fosterwxMobileService.list();
         //.查询所有账号下微信好友
-        this.fosterwxMobileWxfriendList = fosterwxMobileWxfriendService.list();
+        PostBasePageHandle handle = new PostBasePageHandle();
+        handle.setPage(1);
+        handle.setPagesize(999999);
+        ResHandle<List<FosterwxMobileWxfriend>> resHandle = fosterwxMobileWxfriendService.getList(handle);
+        this.fosterwxMobileWxfriendList = resHandle.getList();
         Map<String, List<FosterwxMobile>> add = new HashMap<>();
         for (FosterwxMobile fosterwxMobile : this.fosterwxMobileList) {
             Integer stationId = fosterwxMobile.getStationId();

+ 7 - 3
src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxEdit.java → src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxMobileEdit.java

@@ -21,9 +21,10 @@ import org.springframework.stereotype.Component;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Component
-public class SyncFosterwxEdit {
+public class SyncFosterwxMobileEdit {
 
     @Autowired
     public FosterwxTaskScheduleService fosterwxTaskScheduleService;
@@ -52,7 +53,7 @@ public class SyncFosterwxEdit {
      *     它的目的不在于隐藏任务,更重要的是,释放锁,并且查找解决问题。
      *     至于是否带有string后缀,只是2种表达方式,数字类型的就是毫秒数,字符串类型的就有自己固定的格式 ,例如:PT30S  30s时间设置,单位可以是S,M,H
      */
-    @SchedulerLock(name = "pangu:SyncFosterwxEdit", lockAtLeastForString = "PT2S", lockAtMostForString = "PT15M")
+    @SchedulerLock(name = "pangu:SyncFosterwxMobileEdit", lockAtLeastForString = "PT2S", lockAtMostForString = "PT15M")
     public void execute() {
         System.out.println("[cronjob]:异步执行微信养号账号信息修改/新增操作");
         Integer cnt = 1;
@@ -95,8 +96,11 @@ public class SyncFosterwxEdit {
                 if (fosterwxMobile.getFriend() != null) {
                     AddFosterwxMobileHandle addFosterwxMobileHandle = new AddFosterwxMobileHandle();
                     addFosterwxMobileHandle.setMobileId(fosterwxMobile.getId());
-                    addFosterwxMobileHandle.setFriends(fosterwxMobile.getFriend());
+                    List<Integer> friendIds = fosterwxMobile.getFriend().stream().map(FosterwxMobileWxfriend::getFriendId).collect(Collectors.toList());
+                    addFosterwxMobileHandle.setFriendIds(friendIds);
                     fosterwxMobileWxfriendService.removeAndAdd(addFosterwxMobileHandle);
+                }else{
+                    fosterwxMobileWxfriendService.remove(new QueryWrapper<FosterwxMobileWxfriend>().eq("mobile_id",fosterwxMobile.getId()));
                 }
                 //.立刻更新账号REDIS
                 List<FosterwxMobile> fosterwxMobileList = fosterwxMobileService.list(new QueryWrapper<FosterwxMobile>().eq("station_id", fosterwxMobile.getStationId()));

+ 63 - 0
src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxMobileFriendToRedis.java

@@ -0,0 +1,63 @@
+package com.mokamrp.privates.task.pangu;
+
+import com.alibaba.fastjson.JSONObject;
+import com.mokamrp.privates.constant.RedisKey;
+import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend;
+import com.mokamrp.privates.service.pangu.FosterwxMobileWxfriendService;
+import com.mokamrp.privates.service.pangu.FosterwxWxfriendService;
+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.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class SyncFosterwxMobileFriendToRedis {
+    @Autowired
+    public FosterwxWxfriendService fosterwxWxfriendService;
+
+    @Autowired
+    public FosterwxMobileWxfriendService fosterwxMobileWxfriendService;
+
+    @Autowired
+    public StringRedisTemplate stringRedisTemplate;
+
+    @Scheduled(cron = "*/20 * * * * ?")
+    @SchedulerLock(name = "pangu:SyncFosterwxMobileFriendToRedis", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void execute() {
+        System.out.println("[cronjob]:同步微信养号账号绑定的好友到REDIS");
+        PostBasePageHandle handle = new PostBasePageHandle();
+        handle.setPage(1);
+        handle.setPagesize(999999);
+        ResHandle<List<FosterwxMobileWxfriend>> res = fosterwxMobileWxfriendService.getList(handle);
+        Map<Integer, List<FosterwxMobileWxfriend>> sync = new HashMap<>();
+        for (FosterwxMobileWxfriend fosterwxMobileWxfriend : res.getList()) {
+            if (sync.get(fosterwxMobileWxfriend.getMobileId()) == null) {
+                List<FosterwxMobileWxfriend> mobileFriends = new ArrayList<>();
+                mobileFriends.add(fosterwxMobileWxfriend);
+                sync.put(fosterwxMobileWxfriend.getMobileId(), mobileFriends);
+            } else {
+                List<FosterwxMobileWxfriend> mobileFriends = sync.get(fosterwxMobileWxfriend.getMobileId());
+                mobileFriends.add(fosterwxMobileWxfriend);
+                sync.put(fosterwxMobileWxfriend.getMobileId(), mobileFriends);
+            }
+        }
+        for (Integer mobileId : sync.keySet()) {
+            //.置空
+            stringRedisTemplate.delete(RedisKey.PanWxFosterMobileFriendId + mobileId);
+            for (FosterwxMobileWxfriend fosterwxMobileWxfriend : sync.get(mobileId)) {
+                //.更新可用好友
+                stringRedisTemplate.opsForSet().add(RedisKey.PanWxFosterMobileFriendId + mobileId.toString(),fosterwxMobileWxfriend.getFriendId().toString());
+            }
+        }
+    }
+}

+ 50 - 0
src/main/java/com/mokamrp/privates/task/pangu/UpdateFosterwxFriendStatus.java

@@ -0,0 +1,50 @@
+package com.mokamrp.privates.task.pangu;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileForbiddenRecord;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend;
+import com.mokamrp.privates.service.pangu.FosterwxMobileForbiddenRecordService;
+import com.mokamrp.privates.service.pangu.FosterwxMobileService;
+import com.mokamrp.privates.service.pangu.FosterwxMobileWxfriendService;
+import com.mokamrp.privates.service.pangu.FosterwxWxfriendService;
+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.LocalDateTime;
+import java.util.List;
+
+@Component
+public class UpdateFosterwxFriendStatus {
+    @Autowired
+    public FosterwxWxfriendService fosterwxWxfriendService;
+
+    @Autowired
+    public FosterwxMobileService fosterwxMobileService;
+
+    @Autowired
+    public FosterwxMobileWxfriendService fosterwxMobileWxfriendService;
+
+    @Autowired
+    public FosterwxMobileForbiddenRecordService fosterwxMobileForbiddenRecordService;
+
+    @Autowired
+    public StringRedisTemplate stringRedisTemplate;
+
+    @Scheduled(cron = "0 */1 * * * ?")
+    @SchedulerLock(name = "pangu:UpdateFosterwxFriendStatus", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void execute() {
+        System.out.println("[cronjob]:更新养号微信好友的停用状态");
+        List<FosterwxWxfriend> list = fosterwxWxfriendService.list(new QueryWrapper<FosterwxWxfriend>().eq("status", 2));
+        for (FosterwxWxfriend fosterwxWxfriend:list) {
+            if (fosterwxWxfriend.getNextStartAt().isBefore(LocalDateTime.now())){
+                fosterwxWxfriend.setStatus(1);
+                fosterwxWxfriend.setUpdateAt(LocalDateTime.now());
+                fosterwxWxfriendService.updateById(fosterwxWxfriend);
+            }
+        }
+    }
+}

+ 81 - 0
src/main/java/com/mokamrp/privates/task/pangu/UpdateFosterwxMobileStatus.java

@@ -0,0 +1,81 @@
+package com.mokamrp.privates.task.pangu;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.constant.RedisKey;
+import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileForbiddenRecord;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
+import com.mokamrp.privates.service.pangu.FosterwxMobileForbiddenRecordService;
+import com.mokamrp.privates.service.pangu.FosterwxMobileService;
+import com.mokamrp.privates.service.pangu.FosterwxMobileWxfriendService;
+import com.mokamrp.privates.service.pangu.FosterwxWxfriendService;
+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.LocalDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class UpdateFosterwxMobileStatus {
+    @Autowired
+    public FosterwxWxfriendService fosterwxWxfriendService;
+
+    @Autowired
+    public FosterwxMobileService fosterwxMobileService;
+
+    @Autowired
+    public FosterwxMobileWxfriendService fosterwxMobileWxfriendService;
+
+    @Autowired
+    public FosterwxMobileForbiddenRecordService fosterwxMobileForbiddenRecordService;
+
+    @Autowired
+    public StringRedisTemplate stringRedisTemplate;
+
+    @Scheduled(cron = "0 */1 * * * ?")
+    @SchedulerLock(name = "pangu:UpdateFosterwxMobileStatus", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void execute() {
+        System.out.println("[cronjob]:更新养号账号的封禁状态");
+        List<FosterwxMobile> wxFobiddenMobile = fosterwxMobileService.list(new QueryWrapper<FosterwxMobile>().eq("wx_status", 2));
+        for (FosterwxMobile fosterwxMobile : wxFobiddenMobile) {
+            FosterwxMobileForbiddenRecord record = getLastFobiddenRecord(fosterwxMobile.getId(),1); //.个微封禁记录
+            if(record == null){
+                continue;
+            }
+            if (record.getUnsealAt().isBefore(LocalDateTime.now())){
+                fosterwxMobile.setWxStatus(1); //.解封
+                fosterwxMobile.setUpdateAt(LocalDateTime.now());
+                fosterwxMobileService.updateById(fosterwxMobile);
+            }
+        }
+        List<FosterwxMobile> workwxFobiddenMobile = fosterwxMobileService.list(new QueryWrapper<FosterwxMobile>().eq("work_wx_status", 2));
+        for (FosterwxMobile fosterwxMobile : workwxFobiddenMobile) {
+            FosterwxMobileForbiddenRecord record = getLastFobiddenRecord(fosterwxMobile.getId(),2); //.企微封禁记录
+            if(record == null){
+                continue;
+            }
+            if (record.getUnsealAt().isBefore(LocalDateTime.now())){
+                fosterwxMobile.setWorkWxStatus(1); //.解封
+                fosterwxMobile.setUpdateAt(LocalDateTime.now());
+                fosterwxMobileService.updateById(fosterwxMobile);
+            }
+        }
+    }
+
+    public FosterwxMobileForbiddenRecord getLastFobiddenRecord(Integer mobileId,Integer type){
+        return fosterwxMobileForbiddenRecordService.getOne(new QueryWrapper<FosterwxMobileForbiddenRecord>()
+                .eq("mobile_id",mobileId)
+                .eq("type",type)
+                .orderByDesc("unseal_at")
+                .last("limit 1")
+        );
+    }
+}

+ 1 - 1
src/main/resources/application-local.properties

@@ -48,7 +48,7 @@ spring.redis.jedis.pool.max-idle=8
 spring.redis.jedis.pool.max-active=20
 spring.redis.jedis.pool.max-wait=-1ms
 #阿里云oss配置(增加一个cdn地址配置)
-aliyun.host=http://mini-short-video-oss.lushenjin.cn/
+aliyun.host=https://mini-short-video-oss.lushenjin.cn/
 aliyun.endpoint=https://oss-cn-hangzhou.aliyuncs.com
 aliyun.accessKeyId=LTAI4FnmkS1SNFkaKb4YZ1ga
 aliyun.accessKeySecret=irLfHOni7ffLU3yAf3LsKEXwQLfrNc

+ 1 - 1
src/main/resources/application-test.properties

@@ -41,7 +41,7 @@ spring.redis.jedis.pool.max-idle=8
 spring.redis.jedis.pool.max-active=20
 spring.redis.jedis.pool.max-wait=-1ms
 #阿里云oss配置(增加一个cdn地址配置)
-aliyun.host=http://mini-short-video-oss.lushenjin.cn/
+aliyun.host=https://mini-short-video-oss.lushenjin.cn/
 aliyun.endpoint=https://oss-cn-hangzhou.aliyuncs.com
 aliyun.accessKeyId=LTAI4FnmkS1SNFkaKb4YZ1ga
 aliyun.accessKeySecret=irLfHOni7ffLU3yAf3LsKEXwQLfrNc

二進制
src/main/resources/static/导入账号绑定解封好友.xls


+ 1 - 1
src/test/java/com/mokamrp/AutoMPPangu.java

@@ -46,7 +46,7 @@ public class AutoMPPangu {
                 .setColumnNaming(NamingStrategy.underline_to_camel)
                 .setNaming(NamingStrategy.underline_to_camel) // 数据库表映射到实体的命名策略,下划线转驼峰命名
                 .setTablePrefix("pan_") //表名前缀
-                .setInclude("pan_fosterwx_cash_workwx_mobile_group");
+                .setInclude("pan_fosterwx_mobile_forbidden_record");
         //4. 包名策略配置
         PackageConfig pkConfig = new PackageConfig();
         pkConfig.setParent("com.mokamrp.privates")