Переглянути джерело

万超导表+盘古养号变现账号

leon 4 роки тому
батько
коміт
4fc7554c1d

+ 1 - 1
src/main/java/com/mokamrp/privates/controller/OasBoxController.java

@@ -75,7 +75,7 @@ public class OasBoxController extends BaseController<OasBox> {
         feild.put(3, "boxType");
         feild.put(4, "fansType");
         feild.put(5, "scope");
-        feild.put(6, "remark");
+        feild.put(6, "remark|default");
         List<Map<String, String>> row;
         VoltaHandle<ArrayList<Map<String, String>>> voltaRes = Analysis.analysis(file, feild);
         if (voltaRes.getErr() != null) {

+ 73 - 0
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileCashController.java

@@ -0,0 +1,73 @@
+package com.mokamrp.privates.controller.pangu;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.constant.HttpStatus;
+import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.SetIdsHandle;
+import com.mokamrp.privates.help.AjaxResult;
+import com.mokamrp.privates.entity.ResHandle;
+import org.apache.tomcat.jni.Local;
+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.FosterwxMobileCashService;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileCash;
+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.time.LocalDateTime;
+import java.util.Map;
+import java.util.List;
+
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * <p>
+ * 盘古个微养号变现账号库 前端控制器
+ * </p>
+ *
+ * @author leon
+ * @since 2021-10-08
+ */
+@RestController
+@RequestMapping("/pangu/fosterwxMobileCash")
+public class FosterwxMobileCashController extends BaseController<FosterwxMobileCash> {
+
+    @Autowired
+    public FosterwxMobileCashService fosterwxMobileCashService;
+
+    /*
+     * @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<FosterwxMobileCash>> res = fosterwxMobileCashService.getList(postBasePageHandle);
+        return AjaxResult.success(res);
+    }
+
+
+    @PostMapping("/setDomain")
+    public Object setDoamin(@Valid @RequestBody SetIdsHandle setIdsHandle,BindingResult bindingResult){
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        FosterwxMobileCash save = new FosterwxMobileCash();
+        save.setDomainId(setIdsHandle.getId());
+        save.setUpdateAt(LocalDateTime.now());
+        fosterwxMobileCashService.update(save,new QueryWrapper<FosterwxMobileCash>().in("id",setIdsHandle.getIds()));
+        return AjaxResult.success();
+    }
+
+
+
+}
+

+ 14 - 1
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileController.java

@@ -320,7 +320,20 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
         return AjaxResult.success("更新账号成功");
     }
 
-
+    /**
+     * 批量加入变现账号
+     * @param setIdsHandle
+     * @param bindingResult
+     * @return
+     */
+    @PostMapping("/addCashMobileList")
+    public Object addCashMobileList(@Valid @RequestBody SetIdsHandle setIdsHandle,BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        fosterwxMobileService.addCashMobileList(setIdsHandle.getIds());
+        return AjaxResult.success();
+    }
 
     /*
      *@Leon 以下接口为站点负责人后台页面接口,需要独立登陆才可访问

+ 15 - 0
src/main/java/com/mokamrp/privates/entity/SetIdsHandle.java

@@ -0,0 +1,15 @@
+package com.mokamrp.privates.entity;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
+import java.util.List;
+
+@Data
+public class SetIdsHandle {
+    @NotEmpty(message = "ids不可为空")
+    private List<Integer> ids;
+
+    private Integer id;
+}

+ 21 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileCashMapper.java

@@ -0,0 +1,21 @@
+package com.mokamrp.privates.mapper.pangu;
+
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileCash;
+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-10-08
+ */
+@Component
+public interface FosterwxMobileCashMapper extends BaseMapper<FosterwxMobileCash> {
+    public List<FosterwxMobileCash> getList(Page<FosterwxMobileCash> pageObj);
+}

+ 23 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileCashMapper.xml

@@ -0,0 +1,23 @@
+<?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.FosterwxMobileCashMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileCash">
+        <id column="id" property="id" />
+        <result column="group_id" property="groupId" />
+        <result column="station_id" property="stationId" />
+        <result column="mobile_id" property="mobileId" />
+        <result column="h5_url" property="h5Url" />
+        <result column="create_at" property="createAt" />
+        <result column="update_at" property="updateAt" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, group_id, station_id, mobile_id, h5_url, create_at, update_at
+    </sql>
+    <select id="getList" resultType="com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileCash">
+        SELECT * FROM pan_fosterwx_mobile_cash
+    </select>
+</mapper>

+ 1 - 274
src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxMobile.java

@@ -36,6 +36,7 @@ public class FosterwxMobile extends Model<FosterwxMobile> {
      */
     private Integer stationId;
 
+
     /**
      * 手机编号
      */
@@ -198,278 +199,4 @@ public class FosterwxMobile extends Model<FosterwxMobile> {
 
     @TableField(exist = false)
     private Integer incomeFansType;
-
-    public Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public Integer getStationId() {
-        return stationId;
-    }
-
-    public void setStationId(Integer stationId) {
-        this.stationId = stationId;
-    }
-
-    public String getMobileUnioCode() {
-        return mobileUnioCode;
-    }
-
-    public void setMobileUnioCode(String mobileUnioCode) {
-        this.mobileUnioCode = mobileUnioCode;
-    }
-
-    public String getMobileNo() {
-        return mobileNo;
-    }
-
-    public void setMobileNo(String mobileNo) {
-        this.mobileNo = mobileNo;
-    }
-
-    public Integer getMobileOperator() {
-        return mobileOperator;
-    }
-
-    public void setMobileOperator(Integer mobileOperator) {
-        this.mobileOperator = mobileOperator;
-    }
-
-    public LocalDateTime getMobileCreateAt() {
-        return mobileCreateAt;
-    }
-
-    public void setMobileCreateAt(LocalDateTime mobileCreateAt) {
-        this.mobileCreateAt = mobileCreateAt;
-    }
-
-    public Integer getMobileAdvancePayAmt() {
-        return mobileAdvancePayAmt;
-    }
-
-    public void setMobileAdvancePayAmt(Integer mobileAdvancePayAmt) {
-        this.mobileAdvancePayAmt = mobileAdvancePayAmt;
-    }
-
-    public String getMobileCombo() {
-        return mobileCombo;
-    }
-
-    public void setMobileCombo(String mobileCombo) {
-        this.mobileCombo = mobileCombo;
-    }
-
-    public String getMobileComboFlow() {
-        return mobileComboFlow;
-    }
-
-    public void setMobileComboFlow(String mobileComboFlow) {
-        this.mobileComboFlow = mobileComboFlow;
-    }
-
-    public String getMobileRealName() {
-        return mobileRealName;
-    }
-
-    public void setMobileRealName(String mobileRealName) {
-        this.mobileRealName = mobileRealName;
-    }
-
-    public String getMobileIdentityCardNo() {
-        return mobileIdentityCardNo;
-    }
-
-    public void setMobileIdentityCardNo(String mobileIdentityCardNo) {
-        this.mobileIdentityCardNo = mobileIdentityCardNo;
-    }
-
-    public Integer getStatus() {
-        return status;
-    }
-
-    public void setStatus(Integer status) {
-        this.status = status;
-    }
-
-    public Integer getWxStatus() {
-        return wxStatus;
-    }
-
-    public void setWxStatus(Integer wxStatus) {
-        this.wxStatus = wxStatus;
-    }
-
-
-    public Integer getInPool() {
-        return inPool;
-    }
-
-    public void setInPool(Integer inPool) {
-        this.inPool = inPool;
-    }
-
-    public String getWxPassword() {
-        return wxPassword;
-    }
-
-    public void setWxPassword(String wxPassword) {
-        this.wxPassword = wxPassword;
-    }
-
-    public String getWxRealName() {
-        return wxRealName;
-    }
-
-    public void setWxRealName(String wxRealName) {
-        this.wxRealName = wxRealName;
-    }
-
-    public String getWxIdentityCardNo() {
-        return wxIdentityCardNo;
-    }
-
-    public void setWxIdentityCardNo(String wxIdentityCardNo) {
-        this.wxIdentityCardNo = wxIdentityCardNo;
-    }
-
-    public LocalDateTime getWxRegisterAt() {
-        return wxRegisterAt;
-    }
-
-    public void setWxRegisterAt(LocalDateTime wxRegisterAt) {
-        this.wxRegisterAt = wxRegisterAt;
-    }
-
-    public String getWxAppid() {
-        return wxAppid;
-    }
-
-    public void setWxAppid(String wxAppid) {
-        this.wxAppid = wxAppid;
-    }
-
-    public String getBankCardNo() {
-        return bankCardNo;
-    }
-
-    public void setBankCardNo(String bankCardNo) {
-        this.bankCardNo = bankCardNo;
-    }
-
-    public String getBankCardMobileNo() {
-        return bankCardMobileNo;
-    }
-
-    public void setBankCardMobileNo(String bankCardMobileNo) {
-        this.bankCardMobileNo = bankCardMobileNo;
-    }
-
-    public Integer getWorkWxCorpId() {
-        return workWxCorpId;
-    }
-
-    public void setWorkWxCorpId(Integer workWxCorpId) {
-        this.workWxCorpId = workWxCorpId;
-    }
-
-    public String getWorkWxCorp() {
-        return workWxCorp;
-    }
-
-    public void setWorkWxCorp(String workWxCorp) {
-        this.workWxCorp = workWxCorp;
-    }
-
-    public LocalDateTime getWorkWxRegisterAt() {
-        return workWxRegisterAt;
-    }
-
-    public void setWorkWxRegisterAt(LocalDateTime workWxRegisterAt) {
-        this.workWxRegisterAt = workWxRegisterAt;
-    }
-
-    public Integer getWorkWxStatus() {
-        return workWxStatus;
-    }
-
-    public void setWorkWxStatus(Integer workWxStatus) {
-        this.workWxStatus = workWxStatus;
-    }
-
-    public LocalDateTime getTaskStartAt() {
-        return taskStartAt;
-    }
-
-    public void setTaskStartAt(LocalDateTime taskStartAt) {
-        this.taskStartAt = taskStartAt;
-    }
-
-    public String getCodeUrl() {
-        return codeUrl;
-    }
-
-    public void setCodeUrl(String codeUrl) {
-        this.codeUrl = codeUrl;
-    }
-
-    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 "FosterwxMobile{" +
-                "id=" + id +
-                ", stationId=" + stationId +
-                ", mobileCode=" + mobileCode +
-                ", mobileUnioCode=" + mobileUnioCode +
-                ", mobileNo=" + mobileNo +
-                ", mobileOperator=" + mobileOperator +
-                ", mobileCreateAt=" + mobileCreateAt +
-                ", mobileAdvancePayAmt=" + mobileAdvancePayAmt +
-                ", mobileCombo=" + mobileCombo +
-                ", mobileComboFlow=" + mobileComboFlow +
-                ", mobileRealName=" + mobileRealName +
-                ", mobileIdentityCardNo=" + mobileIdentityCardNo +
-                ", status=" + status +
-                ", wxStatus=" + wxStatus +
-                ", wxPassword=" + wxPassword +
-                ", wxRealName=" + wxRealName +
-                ", wxIdentityCardNo=" + wxIdentityCardNo +
-                ", wxRegisterAt=" + wxRegisterAt +
-                ", wxAppid=" + wxAppid +
-                ", bankCardNo=" + bankCardNo +
-                ", bankCardMobileNo=" + bankCardMobileNo +
-                ", workWxCorpId=" + workWxCorpId +
-                ", workWxCorp=" + workWxCorp +
-                ", workWxRegisterAt=" + workWxRegisterAt +
-                ", workWxStatus=" + workWxStatus +
-                ", inPool=" + inPool +
-                ", taskStartAt=" + taskStartAt +
-                ", codeUrl=" + codeUrl +
-                ", createAt=" + createAt +
-                ", updateAt=" + updateAt +
-                "}";
-    }
 }

+ 60 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/pojo/FosterwxMobileCash.java

@@ -0,0 +1,60 @@
+package com.mokamrp.privates.mapper.pangu.pojo;
+
+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-10-08
+ */
+@Data
+@TableName("pan_fosterwx_mobile_cash")
+public class FosterwxMobileCash extends Model<FosterwxMobileCash> {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+      @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 分组
+     */
+    private Integer groupId;
+
+    /**
+     * 站点id(pan_fosterwx_station.id)
+     */
+    private Integer stationId;
+
+    /**
+     * 账号id
+     */
+    private Integer mobileId;
+
+    private Integer domainId;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createAt;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateAt;
+
+
+}

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

@@ -0,0 +1,20 @@
+package com.mokamrp.privates.service.pangu;
+
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileCash;
+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-10-08
+ */
+public interface FosterwxMobileCashService extends IService<FosterwxMobileCash> {
+    //.@leon 获取数据列表
+    public ResHandle<List<FosterwxMobileCash>> getList(PostBasePageHandle handle);
+}

+ 3 - 0
src/main/java/com/mokamrp/privates/service/pangu/FosterwxMobileService.java

@@ -28,4 +28,7 @@ public interface FosterwxMobileService extends IService<FosterwxMobile> {
     public VoltaHandle<Boolean> importData(List<Map<String,String>> row, User authUser) throws Exception;
 
     public List<FosterwxMobileVo> setWxFriend(List<FosterwxMobileVo> list);
+    //.@leon 批量加入变现账号
+    public Boolean addCashMobileList(List<Integer> mobileIds);
+
 }

+ 3 - 7
src/main/java/com/mokamrp/privates/service/pangu/FosterwxTaskScheduleService.java

@@ -55,12 +55,8 @@ public interface FosterwxTaskScheduleService extends IService<FosterwxTaskSchedu
      */
     public String getMobileCodeCombine(List<FosterwxTaskSchedule> fosterwxTaskScheduleList);
 
-    /**
-     * 根据站点 手机号获取账号任务详情
-     * @param stationId
-     * @param mobileCode
-     * @param date
-     * @param type (1:个微任务,2:企微任务)
-     */
+    //. 根据站点 手机号获取账号任务详情
     List<FosterwxTaskSchedule> getTaskListByMobileCode(Integer stationId, Integer mobileCode, String date, Integer type);
+
+    public void syncTaskToRedis(Integer stationId);
 }

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

@@ -0,0 +1,43 @@
+package com.mokamrp.privates.service.pangu.impl;
+
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileCash;
+import com.mokamrp.privates.mapper.pangu.FosterwxMobileCashMapper;
+import com.mokamrp.privates.service.pangu.FosterwxMobileCashService;
+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-10-08
+ */
+@Service
+public class FosterwxMobileCashServiceImpl extends ServiceImpl<FosterwxMobileCashMapper, FosterwxMobileCash> implements FosterwxMobileCashService {
+
+    @Autowired
+    public FosterwxMobileCashMapper fosterwxMobileCashMapper;
+    /**
+     * 获取数据列表 支持分页
+     * @param handle
+     * @return
+     */
+    public ResHandle<List<FosterwxMobileCash>> getList(PostBasePageHandle handle) {
+        Integer pagesize = handle.getPagesize();
+        Integer page = handle.getPage();
+        Page<FosterwxMobileCash> pageObj = new Page<FosterwxMobileCash>(page, pagesize);
+        List<FosterwxMobileCash> list = fosterwxMobileCashMapper.getList(pageObj);
+        ResHandle<List<FosterwxMobileCash>> res = new ResHandle<>();
+        res.setList(list);
+        res.setTotal(pageObj.getTotal());
+        return res;
+    }
+}

+ 25 - 0
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileServiceImpl.java

@@ -59,6 +59,7 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
 
     /**
      * 获取数据列表 支持分页
+     *
      * @param handle
      * @return
      */
@@ -90,6 +91,7 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
 
     /**
      * 获取指定站点下账号列表
+     *
      * @param getForsterwxMobileHandle
      * @param stationId
      * @return
@@ -105,6 +107,7 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
 
     /**
      * 导入数据
+     *
      * @param row
      * @return
      */
@@ -247,6 +250,28 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
         return list;
     }
 
+    /**
+     * 批量加入变现账号
+     * @param mobileIds
+     * @return
+     */
+    public Boolean addCashMobileList(List<Integer> mobileIds) {
+        LocalDateTime now = LocalDateTime.now();
+        for (Integer id : mobileIds) {
+            FosterwxMobile fosterwxMobile = this.getOne(new QueryWrapper<FosterwxMobile>().eq("id", id));
+            if (fosterwxMobile != null) {
+                continue;
+            }
+            FosterwxMobileCash add = new FosterwxMobileCash();
+            add.setMobileId(fosterwxMobile.getId());
+            add.setStationId(fosterwxMobile.getStationId());
+            add.setCreateAt(now);
+            add.setUpdateAt(now);
+            this.save(fosterwxMobile);
+        }
+        return true;
+    }
+
     private Boolean checkWxFriendCnt(List<FosterwxMobileWxfriend> row, String wxName) {
         Integer findCnt = 0;
         for (FosterwxMobileWxfriend fosterwxMobileWxfriend : row) {

+ 106 - 0
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxTaskScheduleServiceImpl.java

@@ -1,9 +1,11 @@
 package com.mokamrp.privates.service.pangu.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.mokamrp.privates.constant.RedisKey;
 import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.pangu.FosterwxTaskScheduleHandle;
 import com.mokamrp.privates.help.AjaxResult;
@@ -12,15 +14,21 @@ import com.mokamrp.privates.mapper.pangu.FosterwxTaskListMapper;
 import com.mokamrp.privates.mapper.pangu.FosterwxTaskScheduleMapper;
 import com.mokamrp.privates.mapper.pangu.pojo.*;
 import com.mokamrp.privates.mapper.pojo.User;
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
+import com.mokamrp.privates.service.pangu.FosterwxTaskListService;
 import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -42,6 +50,15 @@ public class FosterwxTaskScheduleServiceImpl extends ServiceImpl<FosterwxTaskSch
     @Autowired
     private FosterwxTaskListMapper fosterwxTaskListMapper;
 
+    @Autowired
+    private FosterwxTaskListService fosterwxTaskListService;
+
+    @Autowired
+    private FosterwxStationService fosterwxStationService;
+
+    @Autowired
+    private StringRedisTemplate stringRedisTemplate;
+
     /**
      * 获取数据列表 支持分页
      * @param handle
@@ -297,4 +314,93 @@ public class FosterwxTaskScheduleServiceImpl extends ServiceImpl<FosterwxTaskSch
 
         return fosterwxTaskScheduleMapper.selectList(fosterwxTaskScheduleLambdaQueryWrapper);
     }
+
+    public void syncTaskToRedis(Integer stationId) {
+        System.out.println("[cronjob]:同步微信养号任务到REDIS");
+        List<LocalDateTime> dates = new ArrayList<>();
+        LocalDateTime yesterDay = LocalDateTime.now().plusDays(-1);
+        dates.add(LocalDateTime.of(yesterDay.toLocalDate(), LocalTime.MAX)); //.昨天
+        dates.add(LocalDateTime.now()); //.今天
+        List<FosterwxStation> fosterwxStationList = fosterwxStationService.list();
+        Map<String, List<FosterwxTaskSchedule>> saveWxRedis = new HashMap<>();  //.type 1
+        Map<String, List<FosterwxTaskSchedule>> saveWxworkRedis = new HashMap<>(); //. type 2
+        for (Integer i = 0; i < dates.size(); i++) {
+            LocalDateTime nowDate = dates.get(i);
+            LocalDateTime startTime = LocalDateTime.of(nowDate.toLocalDate(), LocalTime.MIN);
+            List<Integer> tasks = new ArrayList<>();
+            FosterwxTaskScheduleHandle fosterwxTaskScheduleHandle = new FosterwxTaskScheduleHandle();
+            fosterwxTaskScheduleHandle.setStationId(stationId);
+            fosterwxTaskScheduleHandle.setSendTime(nowDate);
+            fosterwxTaskScheduleHandle.setPage(1);
+            fosterwxTaskScheduleHandle.setPagesize(99999);
+            ResHandle<List<FosterwxTaskSchedule>> resHandle = this.getList(fosterwxTaskScheduleHandle);
+            System.out.println(resHandle);
+            List<FosterwxTaskSchedule> fosterwxTaskScheduleList = resHandle.getList();
+            for (FosterwxTaskSchedule fosterwxTaskSchedule : fosterwxTaskScheduleList) {
+                String sendDate = fosterwxTaskSchedule.getSendDate().toString();
+                FosterwxTaskScheduleHandle handle = new FosterwxTaskScheduleHandle();
+                handle.setTaskId(fosterwxTaskSchedule.getTaskId());
+                handle.setStationId(fosterwxTaskSchedule.getStationId());
+                handle.setSendDate(fosterwxTaskSchedule.getSendDate());
+                FosterwxTaskSchedule taskInfo = this.getInfo(handle);
+                if (taskInfo == null) {
+                    continue;
+                }
+                tasks.add(fosterwxTaskSchedule.getTaskId());
+                //.视频信息
+                FosterwxTaskList fosterwxTaskInfo = fosterwxTaskListService.getById(fosterwxTaskSchedule.getTaskId());
+                // 临时任务任务列表中无法获取信息
+                if (null != fosterwxTaskInfo) {
+                    fosterwxTaskSchedule.setVideoId(fosterwxTaskInfo.getVideoId());
+                }
+                //.任务详细信息
+                fosterwxTaskSchedule.setMobileCount(taskInfo.getMobileCount());
+                fosterwxTaskSchedule.setComment(taskInfo.getComment());
+                if (fosterwxTaskSchedule.getType() == 1) {
+                    //.个微任务
+                    List<FosterwxTaskSchedule> sendDateDetail = saveWxRedis.get(sendDate);
+                    if (sendDateDetail == null) {
+                        List<FosterwxTaskSchedule> firstAdd = new ArrayList<>();
+                        firstAdd.add(fosterwxTaskSchedule);
+                        saveWxRedis.put(sendDate, firstAdd);
+                    } else {
+                        sendDateDetail.add(fosterwxTaskSchedule);
+                        saveWxRedis.put(sendDate, sendDateDetail);
+                    }
+                } else if (fosterwxTaskSchedule.getType() == 2) {
+                    //.企微任务
+                    List<FosterwxTaskSchedule> sendDateDetail = saveWxworkRedis.get(sendDate);
+                    if (sendDateDetail == null) {
+                        List<FosterwxTaskSchedule> firstAdd = new ArrayList<>();
+                        firstAdd.add(fosterwxTaskSchedule);
+                        saveWxworkRedis.put(sendDate, firstAdd);
+                    } else {
+                        sendDateDetail.add(fosterwxTaskSchedule);
+                        saveWxworkRedis.put(sendDate, sendDateDetail);
+                    }
+                }
+            }
+            //.任务状态改为 已发送
+            if (tasks.size() > 0) {
+                FosterwxTaskSchedule save = new FosterwxTaskSchedule();
+                save.setTaskSendStatus(1);
+                this.update(save, new QueryWrapper<FosterwxTaskSchedule>()
+                        .eq("station_id", stationId)
+                        .in("task_id", tasks)
+                        .apply("UNIX_TIMESTAMP(send_time) >= UNIX_TIMESTAMP('" + startTime + "')")
+                        .apply("UNIX_TIMESTAMP(send_time) <= UNIX_TIMESTAMP('" + nowDate + "')")
+                );
+            }
+            tasks.clear();
+
+            for (Map.Entry<String, List<FosterwxTaskSchedule>> entry : saveWxRedis.entrySet()) {
+                stringRedisTemplate.opsForHash().put(RedisKey.PanWxfosterTask + stationId, entry.getKey(), JSON.toJSONString(entry.getValue()));
+            }
+            for (Map.Entry<String, List<FosterwxTaskSchedule>> entry : saveWxworkRedis.entrySet()) {
+                stringRedisTemplate.opsForHash().put(RedisKey.PanWxworkfosterTask + stationId, entry.getKey(), JSON.toJSONString(entry.getValue()));
+            }
+            saveWxRedis.clear();
+            saveWxworkRedis.clear();
+        }
+    }
 }

BIN
src/main/resources/static/导入私域公众号&小程序.xls


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

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