Просмотр исходного кода

发文小程序 需要添加 小程序相关信息

lqc 4 лет назад
Родитель
Сommit
d15bff4257

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

@@ -122,6 +122,12 @@ public class FosterwxCashScheduleTaskList extends Model<FosterwxCashScheduleTask
     @TableField(exist = false)
     private FosterwxCashTaskList fosterwxCashTaskList;
 
+    @TableField(exist = false)
+    private String boxGhid;
+
+    @TableField(exist = false)
+    private Object boxInfo;
+
 
     public Integer getId() {
         return id;
@@ -284,6 +290,22 @@ public class FosterwxCashScheduleTaskList extends Model<FosterwxCashScheduleTask
         this.fosterwxCashTaskList = fosterwxCashTaskList;
     }
 
+    public String getBoxGhid() {
+        return boxGhid;
+    }
+
+    public void setBoxGhid(String boxGhid) {
+        this.boxGhid = boxGhid;
+    }
+
+    public Object getBoxInfo() {
+        return boxInfo;
+    }
+
+    public void setBoxInfo(Object boxInfo) {
+        this.boxInfo = boxInfo;
+    }
+
     @Override
     protected Serializable pkVal() {
         return this.id;

+ 9 - 14
src/main/java/com/mokamrp/privates/service/impl/CoralApiServiceImpl.java

@@ -1,12 +1,7 @@
 package com.mokamrp.privates.service.impl;
 
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.mokamrp.privates.mapper.ChatToolMapper;
-import com.mokamrp.privates.mapper.pojo.ChatTool;
-import com.mokamrp.privates.service.ChatToolService;
 import com.mokamrp.privates.service.CoralApiService;
 import com.mokamrp.privates.utils.http.HttpUtils;
 import org.springframework.stereotype.Service;
@@ -25,13 +20,13 @@ public class CoralApiServiceImpl implements CoralApiService {
      * @param ghId
      * @return
      */
-    public String getBoxToken(String ghId){
+    public String getBoxToken(String ghId) {
         String url = "/boxmanager/box/gettoken";
-        String params = "gh_id="+ghId;
-        String res = HttpUtils.sendGet(coralApi+url,params);
+        String params = "gh_id=" + ghId;
+        String res = HttpUtils.sendGet(coralApi + url, params);
         System.out.println(res);
-        Map<String,Object> tokenInfo = JSON.parseObject(res, HashMap.class);
-        if (Integer.parseInt(tokenInfo.get("code").toString()) != 0){
+        Map<String, Object> tokenInfo = JSON.parseObject(res, HashMap.class);
+        if (Integer.parseInt(tokenInfo.get("code").toString()) != 0) {
             return "";
         }
         return tokenInfo.get("data").toString();
@@ -42,15 +37,15 @@ public class CoralApiServiceImpl implements CoralApiService {
      * @param ghId
      * @return
      */
-    public Object getBoxInfo(String ghId){
+    public Object getBoxInfo(String ghId) {
         String newCoral = "https://moka-coral.mokamrp.com/coral";
         String url = "/box/getBoxInfo";
-        String params = "ghId="+ghId;
-        String res = HttpUtils.sendGet(newCoral+url,params);
+        String params = "ghId=" + ghId;
+        String res = HttpUtils.sendGet(newCoral + url, params);
         System.out.println(res);
         JSONObject info = JSON.parseObject(res);
         JSONObject data = JSON.parseObject(info.get("data").toString());
-        if (Integer.parseInt(info.get("code").toString()) != 200){
+        if (Integer.parseInt(info.get("code").toString()) != 0) {
             return "";
         }
         return data;

+ 17 - 5
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashAccountScheduleServiceImpl.java

@@ -122,11 +122,23 @@ public class FosterwxCashAccountScheduleServiceImpl extends ServiceImpl<Fosterwx
                 fosterwxCashScheduleTaskListMapper.insert(fosterwxCashScheduleTaskList);
 
                 // 小程序和链接的任务不需要发送到typer
-                if (4 != fosterwxCashTaskList.getTaskType() && 3 != fosterwxCashTaskList.getTaskType()) {
-                    newsList.add(fosterwxCashScheduleTaskList);
-                } else if (3 == fosterwxCashTaskList.getTaskType()) {
-                    // 小程序本地生成
-                    fosterwxCashScheduleTaskListService.editBoxUrl(fosterwxCashScheduleTaskList, fosterwxCashTaskList);
+                switch (fosterwxCashTaskList.getTaskType()) {
+                    case 1:
+                        // 发文-小程序
+                        fosterwxCashScheduleTaskListService.editBoxUrl(fosterwxCashScheduleTaskList, fosterwxCashTaskList);
+                    case 2:
+                        newsList.add(fosterwxCashScheduleTaskList);
+                        break;
+                    case 3:
+                        // 小程序本地生成
+                        fosterwxCashScheduleTaskListService.editBoxUrl(fosterwxCashScheduleTaskList, fosterwxCashTaskList);
+                        break;
+                    case 4:
+                        // 任务类型为链接是 不需要操作
+                        break;
+                    default:
+                        break;
+
                 }
             });
 

+ 13 - 1
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashScheduleTaskListServiceImpl.java

@@ -9,6 +9,7 @@ import com.mokamrp.privates.mapper.pangu.FosterwxCashScheduleTaskListMapper;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashOasBox;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashTaskList;
+import com.mokamrp.privates.service.CoralApiService;
 import com.mokamrp.privates.service.pangu.FosterwxCashOasBoxService;
 import com.mokamrp.privates.service.pangu.FosterwxCashScheduleTaskListService;
 import com.mokamrp.privates.service.pangu.FosterwxCashTaskListService;
@@ -43,6 +44,9 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
     @Autowired
     public FosterwxCashOasBoxService fosterwxCashOasBoxService;
 
+    @Autowired
+    public CoralApiService coralApiService;
+
     /**
      * 获取数据列表 支持分页
      * @param handle
@@ -132,6 +136,10 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
             // 发文链接
             fosterwxCashScheduleTaskList.setSendUrl("");
 
+            if (fosterwxCashScheduleTaskList.getTaskType() == 1) {
+                fosterwxCashScheduleTaskList.setBoxInfo(coralApiService.getBoxInfo(ghid));
+            }
+
             fosterwxCashScheduleTaskListMapper.updateById(fosterwxCashScheduleTaskList);
             fosterwxCashScheduleTaskList.setFosterwxCashTaskList(fosterwxCashTaskListService.getById(fosterwxCashScheduleTaskList.getTaskId()));
             tempList.add(fosterwxCashScheduleTaskList);
@@ -172,7 +180,11 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
         // 失败原因
         fosterwxCashScheduleTaskList.setErrInfo("");
         // 分配的公众号
-        fosterwxCashScheduleTaskList.setGhId(fosterwxCashOasBox.getGhId());
+        if (3 == fosterwxCashTaskList.getTaskType()) {
+            fosterwxCashScheduleTaskList.setGhId(fosterwxCashOasBox.getGhId());
+        } else if (1 == fosterwxCashTaskList.getTaskType()) {
+            fosterwxCashScheduleTaskList.setBoxGhid(fosterwxCashOasBox.getGhId());
+        }
 
         // 小程序链接
         if (8 == fosterwxCashTaskList.getBoxType()) {

+ 7 - 2
src/test/java/com/mokamrp/WebTest.java

@@ -5,6 +5,7 @@ import com.mokamrp.privates.PrivateServerStart;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobilePool;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileTaskTimeList;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxTaskSchedule;
+import com.mokamrp.privates.service.CoralApiService;
 import com.mokamrp.privates.service.CorpService;
 import com.mokamrp.privates.service.pangu.FosterwxMobilePoolService;
 import com.mokamrp.privates.service.pangu.FosterwxMobileService;
@@ -50,6 +51,9 @@ public class WebTest {
     @Autowired
     private SyncCreateCashTask syncCreateCashTask;
 
+    @Autowired
+    private CoralApiService coralApiService;
+
     @Test
     public void test1() {
         // 清洗数据
@@ -105,7 +109,8 @@ public class WebTest {
     }
 
     @Test
-    public void test4(){
-        syncCreateCashTask.taskInfoNotify();
+    public void test4() {
+        Object o = coralApiService.getBoxInfo("gh_e529abe24cce");
+        log.info("{}", o);
     }
 }