瀏覽代碼

公众号计划修改

wangyunpeng 2 月之前
父節點
當前提交
9726cb374e

+ 40 - 0
api-module/src/main/java/com/tzld/piaoquan/api/component/AigcApiService.java

@@ -245,4 +245,44 @@ public class AigcApiService {
             log.error("closeAccountMessagePublishPlan error", e);
         }
     }
+
+    public boolean checkContainMessagePlan(String publishAccountId) {
+        String url = aigcApiHost + "/publish/plan/list";
+        JSONObject params = JSONObject.parseObject("{\n" +
+                "    \"filterItems\": [\n" +
+                "        {\n" +
+                "            \"itemName\": \"planType\",\n" +
+                "            \"selectValues\": [\n" +
+                "                1\n" +
+                "            ]\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"itemName\": \"publishAccounts\",\n" +
+                "            \"selectValues\": [\n" +
+                "                \"" + publishAccountId + "\"\n" +
+                "            ]\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"itemName\": \"planStatus\",\n" +
+                "            \"selectValues\": [\n" +
+                "                1\n" +
+                "            ]\n" +
+                "        }\n" +
+                "    ],\n" +
+                "    \"listFieldFormula\": [],\n" +
+                "    \"pageNum\": 1,\n" +
+                "    \"pageSize\": 50,\n" +
+                "    \"channel\": 5,\n" +
+                "    \"contentModal\": 7\n" +
+                "}");
+        try {
+            String post = httpPoolClient.post(url, getAigcPostParam(params));
+            JSONObject res = JSONObject.parseObject(post);
+            Integer totalCount = res.getJSONObject("data").getInteger("totalCount");
+            return totalCount > 0;
+        } catch (Exception e) {
+            log.error("closeAccountMessagePublishPlan error", e);
+        }
+        return false;
+    }
 }

+ 10 - 8
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java

@@ -125,8 +125,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         List<String> ghIds = accountList.stream().map(ContentPlatformGzhAccount::getGhId).collect(Collectors.toList());
         List<CgiReplyBucketData> bucketDataList = cgiReplyService.getCgiReplyBucketDataListByGhIds(ghIds, "manual");
         Map<String, Map<Long, CgiReplyBucketData>> bucketDataMap = bucketDataList.stream()
-               .collect(Collectors.groupingBy(CgiReplyBucketData::getGhId,
-                       Collectors.toMap(CgiReplyBucketData::getMiniVideoId, Function.identity())));
+                .collect(Collectors.groupingBy(CgiReplyBucketData::getGhId,
+                        Collectors.toMap(CgiReplyBucketData::getMiniVideoId, Function.identity())));
         List<GzhPlanItemVO> result = new ArrayList<>();
         for (ContentPlatformGzhPlan gzhPlan : planList) {
             GzhPlanItemVO planItemVO = new GzhPlanItemVO();
@@ -609,7 +609,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
             List<String> ghIds = ghDetailList.stream().map(GhDetail::getGhId).collect(Collectors.toList());
             List<ContentPlatformGzhAccount> gzhAccountList = cooperateAccountService.getCooperateAccountListByGhIds(account.getId(), ghIds);
             List<ContentPlatformGzhPlan> existsPlanList = getGzhPlanListByCreateAccountId(account.getId());
-            List<Long> existsAccountIds = existsPlanList.stream().map(ContentPlatformGzhPlan::getAccountId).collect(Collectors.toList());
+            List<Long> existsAccountIds = existsPlanList.stream().map(ContentPlatformGzhPlan::getAccountId).distinct().collect(Collectors.toList());
             Map<String, ContentPlatformGzhAccount> gzhAccountMap = gzhAccountList.stream()
                     .collect(Collectors.toMap(ContentPlatformGzhAccount::getGhId, Function.identity()));
             for (GhDetail ghDetail : ghDetailList) {
@@ -624,11 +624,13 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
                 gzhPlan.setSelectVideoType(ghDetail.getStrategyStatus());
                 gzhPlan.setPublishStage(PublishStageEnum.USER.getVal());
                 if (StringUtils.hasText(gzhAccount.getExternalId())) {
-                    aigcApiService.closeAccountMessagePublishPlan(gzhAccount.getExternalId());
-                    gzhPlan.setPublishStage(PublishStageEnum.PLATFORM.getVal());
-                    String externalId = aigcApiService.createPublishPlan(gzhAccount.getExternalId(), gzhAccount.getName(), account.getChannel());
-                    gzhPlan.setExternalId(externalId);
-                    gzhPlan.setStagePublishStatus(1);
+                    if (aigcApiService.checkContainMessagePlan(gzhAccount.getExternalId())) {
+                        aigcApiService.closeAccountMessagePublishPlan(gzhAccount.getExternalId());
+                        gzhPlan.setPublishStage(PublishStageEnum.PLATFORM.getVal());
+                        String externalId = aigcApiService.createPublishPlan(gzhAccount.getExternalId(), gzhAccount.getName(), account.getChannel());
+                        gzhPlan.setExternalId(externalId);
+                        gzhPlan.setStagePublishStatus(1);
+                    }
                 }
                 gzhPlan.setCreateAccountId(account.getId());
                 gzhPlan.setCreateTimestamp(now);