Преглед на файлове

Merge branch 'test' into LeoN

# Conflicts:
#	src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashScheduleTaskListServiceImpl.java
leon преди 4 години
родител
ревизия
482554a5aa

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

@@ -137,13 +137,14 @@ public class FosterwxCashAccountScheduleController extends BaseController<Foster
     @PostMapping("/immediateCreate")
     @Transactional(rollbackFor = Exception.class)
     @ApiOperation(value = "生成")
-    public Object immediateCreate(@RequestBody FosterwxCashAccountScheduleHandle handle) {
-        Arrays.asList(handle.getIds().split(REGEX)).forEach(id -> {
+    public Object immediateCreate(@RequestBody FosterwxCashAccountScheduleHandle handle) throws Exception {
+        for (int i = 0; i < Arrays.asList(handle.getIds().split(REGEX)).size(); i++) {
+            String id = Arrays.asList(handle.getIds().split(REGEX)).get(i);
             List<FosterwxCashScheduleTaskList> newsList = fosterwxCashAccountScheduleService.createTask(Integer.valueOf(id));
             // 由于不能浪费公众号发文为 需要整合起来一起发送
             // 调用typer生成链接
             fosterwxCashScheduleTaskListService.create(newsList);
-        });
+        }
 
         return AjaxResult.success("生成成功");
     }

+ 1 - 0
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxCashScheduleTaskListController.java

@@ -94,6 +94,7 @@ public class FosterwxCashScheduleTaskListController extends BaseController<Foste
         FosterwxCashScheduleTaskList fosterwxCashScheduleTaskList = fosterwxCashScheduleTaskListService.getById(id);
 
         List<FosterwxCashScheduleTaskList> fosterwxCashScheduleTaskLists = fosterwxCashScheduleTaskListService.list(new LambdaQueryWrapper<FosterwxCashScheduleTaskList>().
+                eq(FosterwxCashScheduleTaskList::getScheduleId, fosterwxCashScheduleTaskList.getScheduleId()).
                 eq(FosterwxCashScheduleTaskList::getTemplateId, fosterwxCashScheduleTaskList.getTemplateId()).
                 eq(FosterwxCashScheduleTaskList::getTaskId, fosterwxCashScheduleTaskList.getTaskId()));
 

+ 30 - 12
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxCashWorkClientController.java

@@ -52,6 +52,9 @@ public class FosterwxCashWorkClientController {
     @Autowired
     private FosterwxCashWorkwxTaskListService fosterwxCashWorkwxTaskListService;
 
+    @Autowired
+    private FosterwxCashOasBoxService fosterwxCashOasBoxService;
+
 
     @PostMapping(value = "/getTaskInfo", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
     @ApiOperation(value = "返回凌晨到当前时间的未发送的数据,主体 昵称/团队id 昵称 两两一组必须有数据")
@@ -105,15 +108,30 @@ public class FosterwxCashWorkClientController {
                     last("LIMIT 1"));
             FosterwxCashBoxClientInfo fosterwxCashBoxClientInfo = new FosterwxCashBoxClientInfo();
             fosterwxCashBoxClientInfo.setTaskType(fosterwxCashScheduleTaskList.getTaskType());
-            if (1 == fosterwxCashScheduleTaskList.getTaskType() || 3 == fosterwxCashScheduleTaskList.getTaskType()) {
-                FosterwxCashWorkBoxClientInfo fosterwxCashWorkBoxClientInfo = fosterwxCashWorkBoxClientInfoService.getOne(new LambdaQueryWrapper<FosterwxCashWorkBoxClientInfo>().like(FosterwxCashWorkBoxClientInfo::getGhid, fosterwxCashScheduleTaskList.getBoxGhid()));
+            if (3 == fosterwxCashScheduleTaskList.getTaskType()) {
+                LambdaQueryWrapper<FosterwxCashWorkBoxClientInfo> fosterwxCashWorkBoxClientInfoLambdaQueryWrapper = new LambdaQueryWrapper<FosterwxCashWorkBoxClientInfo>();
+                fosterwxCashWorkBoxClientInfoLambdaQueryWrapper.like(FosterwxCashWorkBoxClientInfo::getWxid, fosterwxCashScheduleTaskList.getBoxGhid());
+                switch (fosterwxCashWorkwxTaskList.getBoxType()) {
+                    case 8:
+                        // 投放版小程序
+                        fosterwxCashWorkBoxClientInfoLambdaQueryWrapper.like(FosterwxCashWorkBoxClientInfo::getEnterpoint, "videoId=" + fosterwxCashWorkwxTaskList.getVideoId() + "&");
+                        break;
+                    case 26:
+                        fosterwxCashWorkBoxClientInfoLambdaQueryWrapper.like(FosterwxCashWorkBoxClientInfo::getEnterpoint, "materialId=" + fosterwxCashWorkwxTaskList.getVideoId() + "&");
+                        fosterwxCashWorkBoxClientInfoLambdaQueryWrapper.like(FosterwxCashWorkBoxClientInfo::getEnterpoint, "categoryId=" + fosterwxCashWorkwxTaskList.getTagId() + "&");
+                        break;
+                    default:
+                        break;
+                }
+                FosterwxCashWorkBoxClientInfo fosterwxCashWorkBoxClientInfo = fosterwxCashWorkBoxClientInfoService.getOne(fosterwxCashWorkBoxClientInfoLambdaQueryWrapper);
+
                 if (null != fosterwxCashWorkBoxClientInfo) {
                     FosterwxCashBoxClientInfo.BoxInfo boxInfo = fosterwxCashBoxClientInfo.new BoxInfo();
                     boxInfo.setGhid(fosterwxCashWorkBoxClientInfo.getGhid());
                     boxInfo.setWxid(fosterwxCashWorkBoxClientInfo.getWxid());
                     boxInfo.setName(fosterwxCashWorkBoxClientInfo.getName());
                     boxInfo.setTitle(fosterwxCashWorkwxTaskList.getTitle());
-                    boxInfo.setEnterpoint(fosterwxCashScheduleTaskList.getBoxUrl());
+                    boxInfo.setEnterpoint(fosterwxCashWorkBoxClientInfo.getEnterpoint());
                     boxInfo.setHeadimg(fosterwxCashWorkBoxClientInfo.getHeadimg());
                     boxInfo.setImage_key1(fosterwxCashWorkBoxClientInfo.getImageKey1());
                     boxInfo.setImage_key2(fosterwxCashWorkBoxClientInfo.getImageKey2());
@@ -122,8 +140,9 @@ public class FosterwxCashWorkClientController {
                     boxInfo.setApp_type(fosterwxCashWorkBoxClientInfo.getAppType());
                     boxInfo.setDesc(fosterwxCashWorkBoxClientInfo.getDesc());
                     fosterwxCashBoxClientInfo.setBoxInfo(boxInfo);
+                } else {
+                    log.info("小程序{}无法根据{}{}获取缓存", fosterwxCashScheduleTaskList.getBoxGhid(), fosterwxCashWorkwxTaskList.getVideoId(), fosterwxCashWorkwxTaskList.getTagId());
                 }
-
             } else {
                 FosterwxCashBoxClientInfo.UrlInfo urlInfo = fosterwxCashBoxClientInfo.new UrlInfo();
                 urlInfo.setTitle(fosterwxCashWorkwxTaskList.getUrlTitle());
@@ -160,7 +179,8 @@ public class FosterwxCashWorkClientController {
 
                 fosterwxMobile = fosterwxMobileService.getOne(new LambdaQueryWrapper<FosterwxMobile>().eq(FosterwxMobile::getMobileNo, handle.getMobileNo()).eq(FosterwxMobile::getWorkWxCorpId, corp.getId()).last("LIMIT 1"));
 
-                return fosterwxMobile;
+                if (null != fosterwxMobile)
+                    return fosterwxMobile;
             }
 
             // 主体 昵称 组
@@ -169,7 +189,8 @@ public class FosterwxCashWorkClientController {
 
                 fosterwxMobile = fosterwxMobileService.getOne(new LambdaQueryWrapper<FosterwxMobile>().eq(FosterwxMobile::getCustserviceName, handle.getNickName()).eq(FosterwxMobile::getWorkWxCorpId, corp.getId()).last("LIMIT 1"));
 
-                return fosterwxMobile;
+                if (null != fosterwxMobile)
+                    return fosterwxMobile;
             }
         }
 
@@ -177,7 +198,8 @@ public class FosterwxCashWorkClientController {
         if (null != handle.getNickName() && !handle.getNickName().isEmpty() && null != handle.getTeamId() && !handle.getTeamId().isEmpty()) {
             fosterwxMobile = fosterwxMobileService.getOne(new LambdaQueryWrapper<FosterwxMobile>().eq(FosterwxMobile::getTeamId, handle.getTeamId()).eq(FosterwxMobile::getCustserviceName, handle.getNickName()).last("LIMIT 1"));
 
-            return fosterwxMobile;
+            if (null != fosterwxMobile)
+                return fosterwxMobile;
         }
 
         return null;
@@ -213,11 +235,7 @@ public class FosterwxCashWorkClientController {
     @PostMapping(value = "/saveBoxInfo", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
     @ApiOperation(value = "保存小程序信息,已经保存过的小程序更新处理")
     public Object saveBoxInfo(FosterwxCashWorkBoxClientInfo fosterwxCashWorkBoxClientInfo) {
-        if (fosterwxCashWorkBoxClientInfoService.count(new LambdaQueryWrapper<FosterwxCashWorkBoxClientInfo>().eq(FosterwxCashWorkBoxClientInfo::getGhid, fosterwxCashWorkBoxClientInfo.getGhid())) == 0) {
-            fosterwxCashWorkBoxClientInfoService.save(fosterwxCashWorkBoxClientInfo);
-        } else {
-            fosterwxCashWorkBoxClientInfoService.update(fosterwxCashWorkBoxClientInfo, new LambdaQueryWrapper<FosterwxCashWorkBoxClientInfo>().eq(FosterwxCashWorkBoxClientInfo::getGhid, fosterwxCashWorkBoxClientInfo.getGhid()));
-        }
+        fosterwxCashWorkBoxClientInfoService.save(fosterwxCashWorkBoxClientInfo);
 
         return "新增修改成功!";
     }

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

@@ -22,7 +22,7 @@ public class FosterCashTaskJobController {
     private SyncCreateCashTask syncCreateCashTask;
 
     @GetMapping("syncCreateCashTask")
-    public Object syncCreateCashTask() {
+    public Object syncCreateCashTask() throws Exception {
         syncCreateCashTask.syncCreateCashTask();
         return AjaxResult.success("触发成功");
     }

+ 5 - 4
src/main/java/com/mokamrp/privates/service/impl/CoralApiServiceImpl.java

@@ -38,16 +38,17 @@ public class CoralApiServiceImpl implements CoralApiService {
      * @return
      */
     public Object getBoxInfo(String ghId) {
-        String newCoral = "https://moka-coral.mokamrp.com/coral";
+        String newCoral = "https://moka-coral.mokamrp.com/coral/api";
         String url = "/box/getBoxInfo";
         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()) != 0) {
-            return "";
+        if (info.get("code") == null || Integer.parseInt(info.get("code").toString()) != 0) {
+            return null;
         }
+        JSONObject data = JSON.parseObject(info.get("data").toString());
+
         return data;
     }
 }

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

@@ -33,7 +33,7 @@ public interface FosterwxCashScheduleTaskListService extends IService<FosterwxCa
      * 生成任务 正常生成 | 生成失败|检测到公众号封禁重新生成链接
      * @param newsList
      */
-    void create(List<FosterwxCashScheduleTaskList> newsList);
+    void create(List<FosterwxCashScheduleTaskList> newsList) throws Exception;
 
     /**
      * 获取被封禁的任务

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

@@ -113,7 +113,7 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
      * @param newsList
      */
     @Override
-    public void create(List<FosterwxCashScheduleTaskList> newsList) {
+    public void create(List<FosterwxCashScheduleTaskList> newsList) throws Exception {
         if (newsList.isEmpty()) return;
         List<FosterwxCashScheduleTaskList> editList = new ArrayList<>();
         newsList.forEach(fosterwxCashScheduleTaskList -> editList.add(fosterwxCashScheduleTaskList));
@@ -150,7 +150,13 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
             fosterwxCashScheduleTaskList.setSendUrl("");
 
             if (fosterwxCashScheduleTaskList.getTaskType() == 1) {
-                fosterwxCashScheduleTaskList.setBoxInfo(coralApiService.getBoxInfo(fosterwxCashScheduleTaskList.getBoxGhid()));
+                Object obj = null;
+                if (null != fosterwxCashScheduleTaskList.getBoxGhid() && !fosterwxCashScheduleTaskList.getBoxGhid().isEmpty()) {
+                    obj = coralApiService.getBoxInfo(fosterwxCashScheduleTaskList.getBoxGhid());
+                }
+                if (obj == null)
+                    throw new Exception("小程序:" + fosterwxCashScheduleTaskList.getBoxGhid() + "无法从珊瑚云获取信息,请录入");
+                fosterwxCashScheduleTaskList.setBoxInfo(obj);
             }
 
             fosterwxCashScheduleTaskListMapper.updateById(fosterwxCashScheduleTaskList);
@@ -239,7 +245,18 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
 
     @Override
     public void editWorkBoxUrl(FosterwxCashScheduleTaskList fosterwxCashScheduleTaskList, FosterwxCashWorkwxTaskList fosterwxCashWorkwxTaskList) {
+        // 直发小程序
+        if (fosterwxCashScheduleTaskList.getTaskType() == 3) {
+            fosterwxCashScheduleTaskList.setGhId(fosterwxCashWorkwxTaskList.getBoxAppid());
+            fosterwxCashScheduleTaskList.setBoxGhid(fosterwxCashWorkwxTaskList.getBoxAppid());
+            fosterwxCashScheduleTaskList.setSendUrl(fosterwxCashWorkwxTaskList.getBoxPath());
+            fosterwxCashScheduleTaskList.setBoxUrl(fosterwxCashWorkwxTaskList.getBoxPath());
+
+            fosterwxCashScheduleTaskListMapper.updateById(fosterwxCashScheduleTaskList);
+            return;
+        }
         FosterwxCashOasBox fosterwxCashOasBox = fosterwxCashOasBoxService.getRandBox(fosterwxCashScheduleTaskList.getGroupId(),fosterwxCashScheduleTaskList.getType());
+
         if (null == fosterwxCashOasBox) {
             // 状态
             fosterwxCashScheduleTaskList.setStatus(3);
@@ -247,6 +264,8 @@ public class FosterwxCashScheduleTaskListServiceImpl extends ServiceImpl<Fosterw
             fosterwxCashScheduleTaskList.setErrInfo("该分组下没有可用的公众号");
 
             fosterwxCashScheduleTaskListMapper.updateById(fosterwxCashScheduleTaskList);
+
+            return;
         }
 
         fosterwxCashOasBoxService.addSendTextCnt(fosterwxCashScheduleTaskList.getGroupId(), fosterwxCashOasBox.getGhId());

+ 2 - 2
src/main/java/com/mokamrp/privates/task/pangu/SyncCreateCashTask.java

@@ -51,7 +51,7 @@ public class SyncCreateCashTask {
      */
     @Scheduled(cron = "0 0 17 * * ?")
     @SchedulerLock(name = "pangu:SyncCreateCashTask", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
-    public void syncCreateCashTask() {
+    public void syncCreateCashTask() throws Exception {
         // 优先清空公众号 小程序使用次数
         fosterwxCashOasBoxService.update(new FosterwxCashOasBox() {{
             setUpdateAt(LocalDateTime.now());
@@ -123,7 +123,7 @@ public class SyncCreateCashTask {
      */
     @Scheduled(cron = "0 */1 * * * ?")
     @SchedulerLock(name = "pangu:TaskInfoNotify", lockAtLeastForString = "PT5S", lockAtMostForString = "PT15M")
-    public void checkGhidStatus() {
+    public void checkGhidStatus() throws Exception {
         // 获取待发送状态的封禁的任务
         List<FosterwxCashScheduleTaskList> fosterwxCashScheduleTaskLists = fosterwxCashScheduleTaskListService.getBannedGhid();
 

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

@@ -109,7 +109,7 @@ public class WebTest {
     }
 
     @Test
-    public void test4() {
+    public void test4() throws Exception {
         syncCreateCashTask.syncCreateCashTask();
     }
 }