Browse Source

好友相关改动

leon 4 years ago
parent
commit
941bc9160e
23 changed files with 332 additions and 72 deletions
  1. 1 1
      src/main/java/com/mokamrp/privates/constant/HttpMsg.java
  2. 6 0
      src/main/java/com/mokamrp/privates/constant/RedisKey.java
  3. 3 6
      src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileController.java
  4. 4 3
      src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileWxfriendController.java
  5. 4 3
      src/main/java/com/mokamrp/privates/controller/pangu/FosterwxWxfriendController.java
  6. 1 0
      src/main/java/com/mokamrp/privates/entity/PostBasePageHandle.java
  7. 1 1
      src/main/java/com/mokamrp/privates/entity/pangu/AddFosterwxMobileHandle.java
  8. 2 0
      src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileWxfriendMapper.java
  9. 14 3
      src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileWxfriendMapper.xml
  10. 3 2
      src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxWxfriendMapper.java
  11. 10 2
      src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxWxfriendMapper.xml
  12. 17 0
      src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxMobile.java
  13. 9 2
      src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxMobileWxfriend.java
  14. 29 1
      src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxWxfriend.java
  15. 7 1
      src/main/java/com/mokamrp/privates/service/pangu/FosterwxMobileWxfriendService.java
  16. 1 1
      src/main/java/com/mokamrp/privates/service/pangu/FosterwxWxfriendService.java
  17. 24 28
      src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileServiceImpl.java
  18. 30 15
      src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileWxfriendServiceImpl.java
  19. 2 2
      src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxWxfriendServiceImpl.java
  20. 61 0
      src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxCanSwitchFriendToRedis.java
  21. 3 1
      src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxEdit.java
  22. 35 0
      src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxFriendToRedis.java
  23. 65 0
      src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxMobileFriendToRedis.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 = "本次选择的微信好友昵称存在重复:";
 }

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

@@ -51,6 +51,12 @@ 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:";
+    //.盘古 账号绑定的微信好友
+    public static final String PanWxFosterMobileFriendInfo = "pan_wxfoster_mobile_friend_info:";
+    //.盘古 站点内可被替换的解封微信好友ID
+    public static final String PanWxFosterCanSwitchFriendId = "pan_wxfoster_can_switch_friend_id:";
 
 }
 

+ 3 - 6
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileController.java

@@ -557,12 +557,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<>();

+ 4 - 3
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileWxfriendController.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 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;
@@ -60,7 +61,7 @@ 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);
     }
 
@@ -75,7 +76,7 @@ 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);
         }
         //.判断好友微信名称是否同样的超过3个
@@ -103,7 +104,7 @@ 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);
         }
         //.好友验证

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

@@ -4,6 +4,7 @@ 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 io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -26,10 +27,11 @@ 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
@@ -49,6 +51,5 @@ public class FosterwxWxfriendController extends BaseController<FosterwxWxfriend>
         ResHandle<List<FosterwxWxfriend>> res = fosterwxWxfriendService.getList(postBasePageHandle);
         return AjaxResult.success(res);
     }
-
 }
 

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

@@ -20,6 +20,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;
 }

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

@@ -3,6 +3,7 @@ package com.mokamrp.privates.mapper.pangu;
 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;
@@ -18,4 +19,5 @@ import java.util.List;
 @Component
 public interface FosterwxMobileWxfriendMapper extends BaseMapper<FosterwxMobileWxfriend> {
     public List<FosterwxMobileWxfriend> getList(Page<FosterwxMobileWxfriend> pageObj);
+    public List<FosterwxWxfriend> getCanSwtichFriendList();
 }

+ 14 - 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,19 @@
         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.*,
+               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
+    </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
     </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);
 }

+ 10 - 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,16 @@
 
     <!-- 通用查询结果列 -->
     <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 FROM pan_fosterwx_wxfriend as A
+        left join pan_fosterwx_wxfriend as B on A.switch_friend_id = B.id
+        <where>
+            <if test="params.name != null">and wx_name like CONCAT('%',#{params.name},'%')</if>
+            <if test="params.status != null">and status = #{params.status}</if>
+            <if test="params.stationId != null">and station_id = #{params.stationId}</if>
+            <if test="params.mobileId != null">and mobile_id = #{params.mobileId}</if>
+        </where>
     </select>
 </mapper>

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

@@ -184,6 +184,23 @@ public class FosterwxMobile extends Model<FosterwxMobile> {
     private String codeUrl;
 
     /**
+     * 本次解封好友
+     */
+    private Integer unsealFriendId;
+    /**
+     * 新解封好友
+     */
+    private Integer switchUnsealFriendId;
+    /**
+     * 封禁时间
+     */
+    private LocalDateTime forbiddenAt;
+    /**
+     * 解封时间
+     */
+    private LocalDateTime unsealAt;
+
+    /**
      * 创建时间
      */
     private LocalDateTime createAt;

+ 9 - 2
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;
@@ -45,10 +46,16 @@ public class FosterwxMobileWxfriend extends Model<FosterwxMobileWxfriend> {
      */
     @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;
     /**
      * 创建时间
      */

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

@@ -1,11 +1,16 @@
 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 java.time.LocalDateTime;
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * <p>
@@ -13,7 +18,7 @@ import java.io.Serializable;
  * </p>
  *
  * @author leon
- * @since 2021-11-03
+ * @since 2021-11-10
  */
 @TableName("pan_fosterwx_wxfriend")
 public class FosterwxWxfriend extends Model<FosterwxWxfriend> {
@@ -47,6 +52,20 @@ public class FosterwxWxfriend extends Model<FosterwxWxfriend> {
     private String wxUsername;
 
     /**
+     * 替换解封好友
+     */
+    private Integer switchFriendId;
+
+    /**
+     * 绑定的解封手机账号
+     */
+    @TableField(exist = false)
+    private List<FosterwxMobile> bindUnsealMobile;
+
+    @TableField(exist = false)
+    private String switchFriendWxName;
+
+    /**
      * 下次启用时间
      */
     private LocalDateTime nextStartAt;
@@ -96,6 +115,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 +160,7 @@ public class FosterwxWxfriend extends Model<FosterwxWxfriend> {
         ", status=" + status +
         ", wxName=" + wxName +
         ", wxUsername=" + wxUsername +
+        ", switchFriendId=" + switchFriendId +
         ", nextStartAt=" + nextStartAt +
         ", createAt=" + createAt +
         ", updateAt=" + updateAt +

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

@@ -1,10 +1,14 @@
 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 java.util.List;
 import java.util.Map;
 /**
  * <p>
@@ -16,7 +20,9 @@ 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);
+    //.@volta 获取可被替换的解封好友
+    public List<FosterwxWxfriend> getCanSwtichFriendList();
     //.@leon 删除数据同时新增数据
     public Boolean removeAndAdd(AddFosterwxMobileHandle addFosterwxMobileHandle);
     //.@leon 检查好友限制

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

@@ -12,7 +12,7 @@ import java.util.Map;
  * </p>
  *
  * @author leon
- * @since 2021-11-03
+ * @since 2021-11-10
  */
 public interface FosterwxWxfriendService extends IService<FosterwxWxfriend> {
     //.@leon 获取数据列表

+ 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) {

+ 30 - 15
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileWxfriendServiceImpl.java

@@ -2,12 +2,14 @@ package com.mokamrp.privates.service.pangu.impl;
 
 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.FosterwxWxfriend;
 import com.mokamrp.privates.service.pangu.FosterwxMobileService;
 import com.mokamrp.privates.service.pangu.FosterwxMobileWxfriendService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -42,15 +44,24 @@ public class FosterwxMobileWxfriendServiceImpl extends ServiceImpl<FosterwxMobil
      * @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;
+        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;
     }
 
     /**
@@ -62,8 +73,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 +101,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){

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

@@ -18,7 +18,7 @@ import java.util.*;
  * </p>
  *
  * @author leon
- * @since 2021-11-03
+ * @since 2021-11-10
  */
 @Service
 public class FosterwxWxfriendServiceImpl extends ServiceImpl<FosterwxWxfriendMapper, FosterwxWxfriend> implements FosterwxWxfriendService {
@@ -34,7 +34,7 @@ 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());

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

@@ -0,0 +1,61 @@
+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.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 SyncFosterwxCanSwitchFriendToRedis {
+    @Autowired
+    public FosterwxWxfriendService fosterwxWxfriendService;
+
+    @Autowired
+    public FosterwxMobileWxfriendService fosterwxMobileWxfriendService;
+
+    @Autowired
+    public StringRedisTemplate stringRedisTemplate;
+
+    @Scheduled(cron = "*/1 * * * * ?")
+    @SchedulerLock(name = "pangu:SyncFosterwxCanSwitchFriendToRedis", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
+    public void execute() {
+        System.out.println("[cronjob]:同步微信养号可被替换的解封好友到REDIS");
+        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 (Integer stationId : sync.keySet()){
+            //.置空
+            stringRedisTemplate.delete(RedisKey.PanWxFosterCanSwitchFriendId+stationId.toString());
+            for (FosterwxWxfriend fosterwxWxfriend: sync.get(stationId)){
+                //.更新可用好友
+                stringRedisTemplate.opsForSet().add(
+                        RedisKey.PanWxFosterCanSwitchFriendId+stationId.toString(),
+                        fosterwxWxfriend.getId().toString());
+            }
+        }
+    }
+}

+ 3 - 1
src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxEdit.java

@@ -21,6 +21,7 @@ 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 {
@@ -95,7 +96,8 @@ 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::getId).collect(Collectors.toList());
+                    addFosterwxMobileHandle.setFriendIds(friendIds);
                     fosterwxMobileWxfriendService.removeAndAdd(addFosterwxMobileHandle);
                 }
                 //.立刻更新账号REDIS

+ 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));
+        }
+    }
+}

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

@@ -0,0 +1,65 @@
+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.PanWxFosterMobileFriendInfo + mobileId);
+            for (FosterwxMobileWxfriend fosterwxMobileWxfriend : sync.get(mobileId)) {
+                //.更新可用好友
+                stringRedisTemplate.opsForSet().add(
+                        RedisKey.PanWxFosterMobileFriendInfo + mobileId.toString(),
+                        JSONObject.toJSONString(fosterwxMobileWxfriend));
+            }
+        }
+    }
+}