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

Merge branch 'test' of http://git.mokasz.com/marketing/moka-private into test

leon 4 лет назад
Родитель
Сommit
112fb63bb7

+ 8 - 0
src/main/java/com/mokamrp/privates/service/pangu/FosterwxCashScheduleTaskListService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.mokamrp.privates.entity.ResHandle;
 import com.mokamrp.privates.entity.pangu.FosterwxCashScheduleTaskListHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashTaskList;
 
 import java.util.List;
 
@@ -38,4 +39,11 @@ public interface FosterwxCashScheduleTaskListService extends IService<FosterwxCa
      * @return
      */
     List<FosterwxCashScheduleTaskList> getBannedGhid();
+
+    /**
+     * 任务类型为小程序是 拼接一个json字符串返回 供前端展示
+     * @param fosterwxCashScheduleTaskList
+     * @param fosterwxCashTaskList
+     */
+    void editBoxUrl(FosterwxCashScheduleTaskList fosterwxCashScheduleTaskList, FosterwxCashTaskList fosterwxCashTaskList);
 }

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

@@ -104,7 +104,12 @@ public class FosterwxCashAccountScheduleServiceImpl extends ServiceImpl<Fosterwx
                 fosterwxCashScheduleTaskList.setRemark(fosterwxCashTaskList.getRemark());
                 fosterwxCashScheduleTaskList.setTaskContent("");
                 fosterwxCashScheduleTaskList.setGhId("");
-                fosterwxCashScheduleTaskList.setSendUrl("");
+                // 任务类型为链接是直接赋值
+                if (4 == fosterwxCashTaskList.getTaskType()) {
+                    fosterwxCashScheduleTaskList.setSendUrl(fosterwxCashTaskList.getUrl());
+                } else {
+                    fosterwxCashScheduleTaskList.setSendUrl("");
+                }
                 fosterwxCashScheduleTaskList.setStatus(1);
                 fosterwxCashScheduleTaskList.setErrInfo("");
                 fosterwxCashScheduleTaskList.setSendTime(LocalDateTime.of(fosterwxCashAccountSchedule.getScheduleDate(), fosterwxCashTaskList.getSendAt()));
@@ -116,8 +121,12 @@ public class FosterwxCashAccountScheduleServiceImpl extends ServiceImpl<Fosterwx
 
                 fosterwxCashScheduleTaskListMapper.insert(fosterwxCashScheduleTaskList);
 
-                if (4 != fosterwxCashTaskList.getTaskType()) {
+                // 小程序和链接的任务不需要发送到typer
+                if (4 != fosterwxCashTaskList.getTaskType() && 3 != fosterwxCashTaskList.getTaskType()) {
                     newsList.add(fosterwxCashScheduleTaskList);
+                } else if (3 == fosterwxCashTaskList.getTaskType()) {
+                    // 小程序本地生成
+                    fosterwxCashScheduleTaskListService.editBoxUrl(fosterwxCashScheduleTaskList, fosterwxCashTaskList);
                 }
             });
 

+ 32 - 0
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashScheduleTaskListServiceImpl.java

@@ -8,6 +8,7 @@ import com.mokamrp.privates.entity.pangu.FosterwxCashScheduleTaskListHandle;
 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.pangu.FosterwxCashOasBoxService;
 import com.mokamrp.privates.service.pangu.FosterwxCashScheduleTaskListService;
 import com.mokamrp.privates.service.pangu.FosterwxCashTaskListService;
@@ -154,4 +155,35 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
 
         return fosterwxCashScheduleTaskLists;
     }
+
+    /**
+     * 任务类型为小程序是 拼接一个json字符串返回 供前端展示
+     * @param fosterwxCashScheduleTaskList
+     * @param fosterwxCashTaskList
+     * @return
+     */
+    @Override
+    public void editBoxUrl(FosterwxCashScheduleTaskList fosterwxCashScheduleTaskList, FosterwxCashTaskList fosterwxCashTaskList) {
+        FosterwxCashOasBox fosterwxCashOasBox = fosterwxCashOasBoxService.getRandBox(fosterwxCashScheduleTaskList.getGroupId());
+        fosterwxCashOasBoxService.addSendTextCnt(fosterwxCashScheduleTaskList.getGroupId(), fosterwxCashOasBox.getGhId());
+
+        // 状态
+        fosterwxCashScheduleTaskList.setStatus(1);
+        // 失败原因
+        fosterwxCashScheduleTaskList.setErrInfo("");
+        // 分配的公众号
+        fosterwxCashScheduleTaskList.setGhId(fosterwxCashOasBox.getGhId());
+
+        // 小程序链接
+        if (8 == fosterwxCashTaskList.getBoxType()) {
+            // 投放版视频
+            // 发文链接
+            fosterwxCashScheduleTaskList.setSendUrl("/pages/index/index?type=tuiguang&videoId=" + fosterwxCashTaskList.getVideoId());
+        } else {
+            // 盘古版视频
+            fosterwxCashScheduleTaskList.setSendUrl(String.format("pages/index/index?type=tuiguang&materialId=%d&categoryId=&d", fosterwxCashTaskList.getVideoId(), fosterwxCashTaskList.getTagId()));
+        }
+
+        fosterwxCashScheduleTaskListMapper.updateById(fosterwxCashScheduleTaskList);
+    }
 }

+ 16 - 1
src/main/java/com/mokamrp/privates/task/pangu/SyncFosterwxCash.java

@@ -1,5 +1,6 @@
 package com.mokamrp.privates.task.pangu;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashScheduleTaskList;
 import com.mokamrp.privates.service.pangu.FosterwxCashScheduleTaskListService;
@@ -57,8 +58,22 @@ public class SyncFosterwxCash {
     public void syncCreatedUrlInfo() {
         String urlInfo = taskRedis.getPanguCashTaskInfo();
         while (urlInfo != null) {
+            log.info("typer生成的链接信息{}", urlInfo);
             // 根据获取的信息保存到本地数据库
-            // TODO 需要根据typer返回的redis结构具体生成
+            JSONObject jsonObject = JSONObject.parseObject(urlInfo);
+            if ("success".equals(jsonObject.get("status"))) {
+                fosterwxCashScheduleTaskListService.updateById(new FosterwxCashScheduleTaskList() {{
+                    setId(Integer.valueOf(jsonObject.get("automatic_id").toString()));
+                    setSendUrl(jsonObject.get("article_url").toString());
+                    setStatus(2);
+                }});
+            } else {
+                fosterwxCashScheduleTaskListService.updateById(new FosterwxCashScheduleTaskList() {{
+                    setId(Integer.valueOf(jsonObject.get("automatic_id").toString()));
+                    setErrInfo(jsonObject.get("ret_message").toString());
+                    setStatus(3);
+                }});
+            }
 
             urlInfo = taskRedis.getPanguCashTaskInfo();
         }