Browse Source

Merge branch 'master' into dev-xym-add-corp

xueyiming 1 day ago
parent
commit
dcf23d58bb
19 changed files with 457 additions and 21 deletions
  1. 2 0
      api-module/src/main/java/com/tzld/piaoquan/api/common/enums/ExceptionEnum.java
  2. 9 1
      api-module/src/main/java/com/tzld/piaoquan/api/common/enums/contentplatform/QwPlanTypeEnum.java
  3. 55 0
      api-module/src/main/java/com/tzld/piaoquan/api/component/AdApiService.java
  4. 23 9
      api-module/src/main/java/com/tzld/piaoquan/api/component/AigcApiService.java
  5. 50 0
      api-module/src/main/java/com/tzld/piaoquan/api/model/bo/AdPutFlowRecordTencent.java
  6. 11 0
      api-module/src/main/java/com/tzld/piaoquan/api/model/param/contentplatform/CooperateAccountImportParam.java
  7. 4 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/GhDetailService.java
  8. 5 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformAccountService.java
  9. 4 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformCooperateAccountService.java
  10. 6 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformPlanService.java
  11. 19 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformAccountServiceImpl.java
  12. 65 4
      api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformCooperateAccountServiceImpl.java
  13. 140 2
      api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java
  14. 7 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/impl/GhDetailServiceImpl.java
  15. 3 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/BuckStrategyV1.java
  16. 42 0
      api-module/src/test/java/com/tzld/piaoquan/api/ContentPlatformTest.java
  17. 5 5
      common-module/src/main/java/com/tzld/piaoquan/growth/common/config/HttpClientConfig.java
  18. 2 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/bo/VideoDetail.java
  19. 5 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageAttachmentServiceImpl.java

+ 2 - 0
api-module/src/main/java/com/tzld/piaoquan/api/common/enums/ExceptionEnum.java

@@ -36,6 +36,8 @@ public enum ExceptionEnum {
     GZH_PLAN_NOT_EXISTS(3001, "公众号计划不存在"),
     GZH_PLAN_VIDEO_SIZE_EXCEED(3002, "计划视频数量超过限制"),
     QW_PLAN_NOT_EXISTS(3003, "企微计划不存在"),
+    GZH_ACCOUNT_NOT_EXISTS(3004, "公众号不存在"),
+    GZH_ACCOUNT_NOT_AUTH(3005, "公众号未授权,无法使用平台发布"),
     ;
     private int code;
     private String msg;

+ 9 - 1
api-module/src/main/java/com/tzld/piaoquan/api/common/enums/contentplatform/QwPlanTypeEnum.java

@@ -5,7 +5,7 @@ import lombok.Getter;
 @Getter
 public enum QwPlanTypeEnum {
     GROUP(0, "社群"),
-    DAILY(1, "每日推送"),
+    REPLY(1, "自动回复"),
 
     other(999, "其他");
 
@@ -23,7 +23,15 @@ public enum QwPlanTypeEnum {
                 return typeEnum;
             }
         }
+        return other;
+    }
 
+    public static QwPlanTypeEnum from(String description) {
+        for (QwPlanTypeEnum typeEnum : QwPlanTypeEnum.values()) {
+            if (typeEnum.getDescription().equals(description)) {
+                return typeEnum;
+            }
+        }
         return other;
     }
 

+ 55 - 0
api-module/src/main/java/com/tzld/piaoquan/api/component/AdApiService.java

@@ -0,0 +1,55 @@
+package com.tzld.piaoquan.api.component;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.api.model.bo.AdPutFlowRecordTencent;
+import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+@Component
+@Slf4j
+public class AdApiService {
+
+    @Autowired
+    private HttpPoolClient httpPoolClient;
+
+    @Value("${ad.api.host:https://testapi.piaoquantv.com/ad}")
+    private String adApiHost;
+
+
+    public Integer getPutFlowListTencentCount(String channel, Integer pageNum, Integer pageSize) {
+        String url = adApiHost + "/put/flow/list/tencent?videoId=&putScene=&channel="
+                + channel + "&currentPage=" + pageNum + "&pageSize=" + pageSize;
+        try {
+            String post = httpPoolClient.get(url);
+            JSONObject res = JSONObject.parseObject(post);
+            return res.getJSONObject("data").getInteger("totalSize");
+        } catch (Exception e) {
+            log.error("getPutFlowListTencentCount error", e);
+        }
+        return 0;
+    }
+
+    public List<AdPutFlowRecordTencent> getPutFlowListTencent(String channel, Integer pageNum, Integer pageSize) {
+        String url = adApiHost + "/put/flow/list/tencent?videoId=&putScene=&channel="
+                + channel + "&currentPage=" + pageNum + "&pageSize=" + pageSize;
+        try {
+            String post = httpPoolClient.get(url);
+            JSONObject res = JSONObject.parseObject(post);
+            JSONArray data = res.getJSONObject("data").getJSONArray("objs");
+            if (Objects.nonNull(data) && !data.isEmpty()) {
+                return data.toJavaList(AdPutFlowRecordTencent.class);
+            }
+        } catch (Exception e) {
+            log.error("getPutFlowListTencent error", e);
+        }
+        return new ArrayList<>();
+    }
+}

+ 23 - 9
api-module/src/main/java/com/tzld/piaoquan/api/component/AigcApiService.java

@@ -101,16 +101,18 @@ public class AigcApiService {
             String post = httpPoolClient.post(url, getAigcPostParam(params));
             JSONObject res = JSONObject.parseObject(post);
             JSONObject data = res.getJSONObject("data");
-            return data.getString("id");
+            if (Objects.nonNull(data)) {
+                return data.getString("id");
+            }
         } catch (Exception e) {
-            log.error("getAccountDetail error", e);
+            log.error("getDetailByGhId error", e);
         }
         return null;
     }
 
-    public String createPublishPlan(String publishAccountId, String name) {
+    public String createPublishPlan(String publishAccountId, String name, String channel) {
         String url = aigcApiHost + "/publish/plan/save";
-        JSONObject params = getPublishPlanAddParam(publishAccountId, name);
+        JSONObject params = getPublishPlanAddParam(publishAccountId, name, channel);
         JSONObject res = null;
         try {
             String post = httpPoolClient.post(url, getAigcPostParam(params));
@@ -129,7 +131,7 @@ public class AigcApiService {
         return data.getString("id");
     }
 
-    private JSONObject getPublishPlanAddParam(String publishAccountId, String name) {
+    private JSONObject getPublishPlanAddParam(String publishAccountId, String name, String channel) {
         String dateStr = DateUtil.getCurrentDateStr("yyyyMMdd");
         JSONObject params = JSONObject.parseObject("{\n" +
                 "    \"accountIds\": [\n" +
@@ -141,7 +143,7 @@ public class AigcApiService {
                 "    \"contentModal\": 7,\n" +
                 "    \"douyinPublishAccoutSetting\": [],\n" +
                 "    \"filterMatchMode\": 1,\n" +
-                "    \"name\": \"自动回复-" + dateStr + "-" + name + "\",\n" +
+                "    \"name\": \"自动回复-" + dateStr + "-" + name + "-" + channel + "\",\n" +
                 "    \"publishAccoutJson\": \"\",\n" +
                 "    \"publishBgmType\": 0,\n" +
                 "    \"publishDate\": \"\",\n" +
@@ -175,7 +177,7 @@ public class AigcApiService {
                 "    \"gzhTriggerSyncFrequency\": 1,\n" +
                 "    \"gzhTriggerSendContentType\": 1,\n" +
                 "    \"gzhAutoReplyDelayFlag\": 1,\n" +
-                "    \"gzhAutoReplyDelayMillisecond\": 500,\n" +
+                "    \"gzhAutoReplyDelayMillisecond\": 1000,\n" +
                 "    \"pushContentSortingRules\": 1\n" +
                 "}");
         return params;
@@ -190,7 +192,7 @@ public class AigcApiService {
             String post = httpPoolClient.post(url, getAigcPostParam(params));
             JSONObject res = JSONObject.parseObject(post);
         } catch (Exception e) {
-            log.error("closePublishPlan error", e);
+            log.error("changePublishPlanStatus error", e);
         }
     }
 
@@ -213,8 +215,20 @@ public class AigcApiService {
             JSONObject res = JSONObject.parseObject(post);
             return res.getJSONArray("data").toJavaList(WxAccountDatastatVO.class);
         } catch (Exception e) {
-            log.error("closePublishPlan error", e);
+            log.error("getWxAccountDatastat error", e);
         }
         return null;
     }
+
+    public void closeAccountMessagePublishPlan(String publishAccountId) {
+        String url = aigcApiHost + "/publish/plan/closeAccountMessagePublishPlan";
+        JSONObject params = new JSONObject();
+        params.put("id", publishAccountId);
+        try {
+            String post = httpPoolClient.post(url, getAigcPostParam(params));
+            JSONObject res = JSONObject.parseObject(post);
+        } catch (Exception e) {
+            log.error("closeAccountMessagePublishPlan error", e);
+        }
+    }
 }

+ 50 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/bo/AdPutFlowRecordTencent.java

@@ -0,0 +1,50 @@
+package com.tzld.piaoquan.api.model.bo;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class AdPutFlowRecordTencent {
+
+    private Long id;
+
+    private Long videoId;
+
+    private String videoTitle;
+
+    private String putScene;
+
+    private String channel;
+
+    private String remark;
+
+    private String url;
+
+    private String sharePic;
+
+    private String rootSourceId;
+
+    private String putTypeOne;
+
+    private String putTypeTwo;
+
+    private String putTypeThree;
+
+    private String testId;
+
+    private String putCarrierId;
+
+    private String putStartDate;
+
+    private Integer isDelete;
+
+    private String createUser;
+
+    private String updateUser;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+}

+ 11 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/param/contentplatform/CooperateAccountImportParam.java

@@ -0,0 +1,11 @@
+package com.tzld.piaoquan.api.model.param.contentplatform;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CooperateAccountImportParam {
+    private String channel;
+    private List<String> ghIds;
+}

+ 4 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/GhDetailService.java

@@ -6,6 +6,8 @@ import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
 import com.tzld.piaoquan.growth.common.model.po.GhDetail;
 import com.tzld.piaoquan.growth.common.utils.page.Page;
 
+import java.util.List;
+
 public interface GhDetailService {
 
     CommonResponse<Page<GhDetailVo>> getGhDetailList(Integer pageNum, Integer pageSize, String accountId, String accountName);
@@ -17,4 +19,6 @@ public interface GhDetailService {
     CommonResponse<Void> deleteDetail(Long id);
 
     GhDetail getGhDetailByGhIdType(String ghId, Integer type);
+
+    List<GhDetail> getByChannel(String channel);
 }

+ 5 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformAccountService.java

@@ -1,6 +1,7 @@
 package com.tzld.piaoquan.api.service.contentplatform;
 
 import com.tzld.piaoquan.api.model.param.contentplatform.*;
+import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformAccount;
 import com.tzld.piaoquan.api.model.vo.contentplatform.AccountLoginVO;
 import com.tzld.piaoquan.api.model.vo.contentplatform.AccountVO;
 import com.tzld.piaoquan.growth.common.utils.page.Page;
@@ -17,4 +18,8 @@ public interface ContentPlatformAccountService {
     void accountForbidden(AccountForbiddenParam param);
 
     void saveAccount(AccountSaveParam param);
+
+    List<ContentPlatformAccount> getAccountListByChannels(List<String> channels);
+
+    ContentPlatformAccount getAccountByChannel(String channel);
 }

+ 4 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformCooperateAccountService.java

@@ -30,4 +30,8 @@ public interface ContentPlatformCooperateAccountService {
     List<ContentPlatformGzhAccount> getAccountListByIds(List<Long> ids);
 
     ContentPlatformGzhAccount getById(Long id);
+
+    List<ContentPlatformGzhAccount> getCooperateAccountListByGhIds(Long loginAccountId, List<String> ghIds);
+
+    void gzhImport(List<String> channels);
 }

+ 6 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformPlanService.java

@@ -44,6 +44,8 @@ public interface ContentPlatformPlanService {
 
     List<ContentPlatformGzhPlan> getGzhPlanListByCooperateAccountId(Long accountId);
 
+    List<ContentPlatformGzhPlan> getGzhPlanListByCreateAccountId(Long createAccountId);
+
     List<ContentPlatformGzhPlan> getGzhPlanListByCooperateAccountIds(List<Long> accountIds);
 
     List<ContentPlatformGzhPlanVideo> getGzhPlanVideoListByCooperateAccountId(String ghId);
@@ -61,4 +63,8 @@ public interface ContentPlatformPlanService {
     void gzhPlanDelete(Long id);
 
     void qwPlanDelete(Long id);
+
+    void gzhPlanImport(List<String> channels);
+
+    void qwPlanImport(List<String> channels);
 }

+ 19 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformAccountServiceImpl.java

@@ -217,4 +217,23 @@ public class ContentPlatformAccountServiceImpl implements ContentPlatformAccount
         BeanUtils.copyProperties(account, loginVO);
         saveTokenToRedis(loginVO, account.getToken(), account.getToken());
     }
+
+
+    @Override
+    public List<ContentPlatformAccount> getAccountListByChannels(List<String> channels) {
+        ContentPlatformAccountExample example = new ContentPlatformAccountExample();
+        example.createCriteria().andChannelIn(channels);
+        return accountMapper.selectByExample(example);
+    }
+
+    @Override
+    public ContentPlatformAccount getAccountByChannel(String channel) {
+        ContentPlatformAccountExample example = new ContentPlatformAccountExample();
+        example.createCriteria().andChannelEqualTo(channel);
+        List<ContentPlatformAccount> list = accountMapper.selectByExample(example);
+        if (CollectionUtils.isNotEmpty(list)) {
+            return list.get(0);
+        }
+        return null;
+    }
 }

+ 65 - 4
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformCooperateAccountServiceImpl.java

@@ -18,20 +18,24 @@ import com.tzld.piaoquan.api.model.vo.contentplatform.CooperateAccountItemVO;
 import com.tzld.piaoquan.api.model.vo.contentplatform.GenerateQrcodeVO;
 import com.tzld.piaoquan.api.model.vo.contentplatform.GzhAccountItem;
 import com.tzld.piaoquan.api.model.vo.contentplatform.GzhAuthResultVO;
+import com.tzld.piaoquan.api.service.GhDetailService;
+import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformAccountService;
 import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformCooperateAccountService;
 import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
+import com.tzld.piaoquan.growth.common.model.po.GhDetail;
 import com.tzld.piaoquan.growth.common.utils.page.Page;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 @Service
+@Slf4j
 public class ContentPlatformCooperateAccountServiceImpl implements ContentPlatformCooperateAccountService {
 
     @Autowired
@@ -41,7 +45,11 @@ public class ContentPlatformCooperateAccountServiceImpl implements ContentPlatfo
     @Autowired
     private ContentPlatformGzhAccountMapperExt gzhAccountMapperExt;
     @Autowired
+    private GhDetailService ghDetailService;
+    @Autowired
     private ContentPlatformPlanService planService;
+    @Autowired
+    private ContentPlatformAccountService accountService;
 
     @Override
     public Page<CooperateAccountItemVO> gzhList(CooperateAccountListParam param) {
@@ -174,4 +182,57 @@ public class ContentPlatformCooperateAccountServiceImpl implements ContentPlatfo
     public ContentPlatformGzhAccount getById(Long id) {
         return gzhAccountMapper.selectByPrimaryKey(id);
     }
+
+    @Override
+    public List<ContentPlatformGzhAccount> getCooperateAccountListByGhIds(Long loginAccountId, List<String> ghIds) {
+        ContentPlatformGzhAccountExample gzhAccountExample = new ContentPlatformGzhAccountExample();
+        gzhAccountExample.createCriteria().andCreateAccountIdEqualTo(loginAccountId).andGhIdIn(ghIds).andStatusEqualTo(1);
+        return gzhAccountMapper.selectByExample(gzhAccountExample);
+    }
+
+
+    @Override
+    public void gzhImport(List<String> channels) {
+        List<ContentPlatformAccount> accountList = accountService.getAccountListByChannels(channels);
+        if (CollectionUtils.isEmpty(accountList)) {
+            throw new CommonException(ExceptionEnum.ACCOUNT_NOT_EXISTS_WRONG);
+        }
+        for (ContentPlatformAccount account : accountList) {
+            List<GhDetail> ghDetailList = ghDetailService.getByChannel(account.getChannel());
+            Map<String, GhDetail> ghDetailMap = ghDetailList.stream().collect(Collectors.toMap(GhDetail::getGhId, Function.identity()));
+            List<String> ghIds = ghDetailList.stream().map(GhDetail::getGhId).collect(Collectors.toList());
+            List<ContentPlatformGzhAccount> gzhAccountList = getCooperateAccountListByGhIds(account.getId(), ghIds);
+            List<String> existGhIdList = new ArrayList<>();
+            for (ContentPlatformGzhAccount gzhAccount : gzhAccountList) {
+                existGhIdList.add(gzhAccount.getGhId());
+            }
+            Long now = System.currentTimeMillis();
+            List<String> addFailGhIds = new ArrayList<>();
+            for (String ghId : ghIds) {
+                if (existGhIdList.contains(ghId)) {
+                    continue;
+                }
+                List<ContentPlatformAccount> ghIdExistList = gzhAccountMapperExt.getGhIdExists(account.getId(), ghId);
+                if (CollectionUtils.isNotEmpty(ghIdExistList)) {
+                    addFailGhIds.add(ghId);
+                }
+                GhDetail ghDetail = ghDetailMap.get(ghId);
+                ContentPlatformGzhAccount gzhAccount = new ContentPlatformGzhAccount();
+                gzhAccount.setName(ghDetail.getGhName());
+                gzhAccount.setGhId(ghDetail.getGhId());
+                gzhAccount.setContentType(ghDetail.getCategory1());
+                gzhAccount.setUpdateTimestamp(now);
+                String externalId = aigcApiService.getDetailByGhId(ghDetail.getGhId());
+                if (StringUtils.hasText(externalId)) {
+                    gzhAccount.setExternalId(externalId);
+                }
+                gzhAccount.setCreateAccountId(account.getId());
+                gzhAccount.setCreateTimestamp(now);
+                gzhAccountMapper.insertSelective(gzhAccount);
+            }
+            if (CollectionUtils.isNotEmpty(addFailGhIds)) {
+                log.error("导入失败账号 channel:{} ghIds:{}", account.getChannel(), addFailGhIds);
+            }
+        }
+    }
 }

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

@@ -1,15 +1,18 @@
 package com.tzld.piaoquan.api.service.contentplatform.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
 import com.tzld.piaoquan.api.common.enums.ExceptionEnum;
 import com.tzld.piaoquan.api.common.enums.contentplatform.PublishStageEnum;
 import com.tzld.piaoquan.api.common.enums.contentplatform.QwPlanTypeEnum;
 import com.tzld.piaoquan.api.common.exception.CommonException;
+import com.tzld.piaoquan.api.component.AdApiService;
 import com.tzld.piaoquan.api.component.AigcApiService;
 import com.tzld.piaoquan.api.component.ManagerApiService;
 import com.tzld.piaoquan.api.component.VlogApiService;
 import com.tzld.piaoquan.api.dao.mapper.contentplatform.*;
 import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformPlanMapperExt;
+import com.tzld.piaoquan.api.model.bo.AdPutFlowRecordTencent;
 import com.tzld.piaoquan.api.model.config.LoginUserContext;
 import com.tzld.piaoquan.api.model.param.contentplatform.*;
 import com.tzld.piaoquan.api.model.po.contentplatform.*;
@@ -19,6 +22,7 @@ import com.tzld.piaoquan.api.model.vo.contentplatform.GzhPlanVideoContentItemVO;
 import com.tzld.piaoquan.api.model.vo.contentplatform.QwPlanItemVO;
 import com.tzld.piaoquan.api.model.vo.contentplatform.VideoContentItemVO;
 import com.tzld.piaoquan.api.service.GhDetailService;
+import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformAccountService;
 import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformCooperateAccountService;
 import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
 import com.tzld.piaoquan.growth.common.common.enums.GhTypeEnum;
@@ -76,6 +80,10 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
     private MessageAttachmentService messageAttachmentService;
     @Autowired
     private VlogApiService vlogApiService;
+    @Autowired
+    private ContentPlatformAccountService accountService;
+    @Autowired
+    private AdApiService adApiService;
 
     @Value("${vlog.share.appType:11}")
     private String shareAppType;
@@ -187,6 +195,12 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
             throw new CommonException(ExceptionEnum.GZH_PLAN_VIDEO_SIZE_EXCEED);
         }
         ContentPlatformGzhAccount account = cooperateAccountService.getById(param.getAccountId());
+        if (Objects.isNull(account)) {
+            throw new CommonException(ExceptionEnum.GZH_ACCOUNT_NOT_EXISTS);
+        }
+        if (!StringUtils.hasText(account.getExternalId()) && param.getPublishStage().equals(PublishStageEnum.PLATFORM.getVal())) {
+            throw new CommonException(ExceptionEnum.GZH_ACCOUNT_NOT_AUTH);
+        }
         Long now = System.currentTimeMillis();
         ContentPlatformGzhPlan gzhPlan = new ContentPlatformGzhPlan();
         gzhPlan.setAccountId(param.getAccountId());
@@ -201,7 +215,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         if (Objects.isNull(param.getId())) {
             // 调用aigc创建发布计划
             if (PublishStageEnum.PLATFORM.getVal() == param.getPublishStage()) {
-                String externalId = aigcApiService.createPublishPlan(account.getExternalId(), account.getName());
+                String externalId = aigcApiService.createPublishPlan(account.getExternalId(), account.getName(), loginAccount.getChannel());
                 gzhPlan.setExternalId(externalId);
             }
             gzhPlan.setCreateAccountId(loginAccount.getId());
@@ -217,7 +231,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
                 if (StringUtils.hasText(oldPlan.getExternalId())) {
                     aigcApiService.changePublishPlanStatus(oldPlan.getExternalId(), 1);
                 } else {
-                    String externalId = aigcApiService.createPublishPlan(account.getExternalId(), account.getName());
+                    String externalId = aigcApiService.createPublishPlan(account.getExternalId(), account.getName(), loginAccount.getChannel());
                     gzhPlan.setExternalId(externalId);
                 }
             }
@@ -322,6 +336,13 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         return gzhPlanMapper.selectByExample(example);
     }
 
+    @Override
+    public List<ContentPlatformGzhPlan> getGzhPlanListByCreateAccountId(Long createAccountId) {
+        ContentPlatformGzhPlanExample example = new ContentPlatformGzhPlanExample();
+        example.createCriteria().andCreateAccountIdEqualTo(createAccountId).andStatusEqualTo(1);
+        return gzhPlanMapper.selectByExample(example);
+    }
+
     @Override
     public List<ContentPlatformGzhPlan> getGzhPlanListByCooperateAccountIds(List<Long> accountIds) {
         ContentPlatformGzhPlanExample example = new ContentPlatformGzhPlanExample();
@@ -502,4 +523,121 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         return qwPlanVideoMapper.selectByExample(example);
     }
 
+    @Override
+    public void gzhPlanImport(List<String> channels) {
+        List<ContentPlatformAccount> accountList = accountService.getAccountListByChannels(channels);
+        for (ContentPlatformAccount account : accountList) {
+            Long now = System.currentTimeMillis();
+            List<GhDetail> ghDetailList = ghDetailService.getByChannel(account.getChannel());
+            ghDetailList = ghDetailList.stream()
+                    .filter(o -> Objects.equals(o.getStrategyStatus(), StrategyStatusEnum.DEFAULT.status))
+                    .collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(ghDetailList)) {
+                continue;
+            }
+            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());
+            Map<String, ContentPlatformGzhAccount> gzhAccountMap = gzhAccountList.stream()
+                    .collect(Collectors.toMap(ContentPlatformGzhAccount::getGhId, Function.identity()));
+            for (GhDetail ghDetail : ghDetailList) {
+                ContentPlatformGzhAccount gzhAccount = gzhAccountMap.get(ghDetail.getGhId());
+                ContentPlatformGzhPlan gzhPlan = new ContentPlatformGzhPlan();
+                if (existsAccountIds.contains(gzhAccount.getId())) {
+                    continue;
+                }
+                gzhPlan.setAccountId(gzhAccount.getId());
+                gzhPlan.setScene(0);
+                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.setCreateAccountId(account.getId());
+                gzhPlan.setCreateTimestamp(now);
+                gzhPlan.setUpdateTimestamp(now);
+                planMapperExt.insertGzhPlanReturnId(gzhPlan);
+                List<Long> videoIds = JSONObject.parseArray(ghDetail.getVideoIds(), Long.class);
+                Map<Long, VideoDetail> videoMap = messageAttachmentService.getVideoDetail(new HashSet<>(videoIds));
+                for (Map.Entry<Long, VideoDetail> entry : videoMap.entrySet()) {
+                    Long videoId = entry.getKey();
+                    VideoDetail videoDetail = entry.getValue();
+                    ContentPlatformGzhPlanVideo item = new ContentPlatformGzhPlanVideo();
+                    item.setPlanId(gzhPlan.getId());
+                    item.setVideoId(videoId);
+                    item.setTitle(videoDetail.getTitle());
+                    item.setCover(videoDetail.getCover());
+                    item.setVideo(videoDetail.getVideoPath());
+                    item.setCreateAccountId(account.getId());
+                    item.setCreateTimestamp(System.currentTimeMillis());
+                    gzhPlanVideoMapper.insertSelective(item);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void qwPlanImport(List<String> channels) {
+        List<AdPutFlowRecordTencent> list = new ArrayList<>();
+        for (String channel : channels) {
+            Integer count = adApiService.getPutFlowListTencentCount(channel, 1, 1);
+            if (count == 0) {
+                continue;
+            }
+            int pageNum = 1000;
+            int totalPage = (count / pageNum) + 1;
+            for (int i = 1; i <= totalPage; i++) {
+                list.addAll(adApiService.getPutFlowListTencent(channel, i, pageNum));
+            }
+        }
+        List<String> filterChannels = Arrays.asList("ml2025", "mj", "nh", "qc", "tczy", "wb", "xj", "wxm", "wxmx1", "wxmx", "xycsd", "xycsd1", "xycsd2", "xycsd3", "xycsd4", "xycsd5", "xycsd6", "xycsd7", "xycsd8", "xycsd9", "xycsd10", "xycsd11", "xycsd12", "xycsd13", "xycsd14", "xycsd15", "xycsd16", "xycsd17", "xycsd18", "shy");
+        Map<String, List<AdPutFlowRecordTencent>> channelMap = list.stream()
+                .filter(o -> filterChannels.contains(o.getChannel()))
+                .collect(Collectors.groupingBy(AdPutFlowRecordTencent::getChannel));
+        for (Map.Entry<String, List<AdPutFlowRecordTencent>> entry : channelMap.entrySet()) {
+            String channel = entry.getKey();
+            List<AdPutFlowRecordTencent> recordList = entry.getValue();
+            ContentPlatformAccount account = accountService.getAccountByChannel(channel);
+            List<String> rootSourceIds = recordList.stream().map(AdPutFlowRecordTencent::getRootSourceId).distinct().collect(Collectors.toList());
+            List<ContentPlatformQwPlan> existsPlanList = getQwPlanListByRootSourceIds(rootSourceIds);
+            List<String> existsRootSourceIds = existsPlanList.stream().map(ContentPlatformQwPlan::getRootSourceId).collect(Collectors.toList());
+            List<Long> videoIds = recordList.stream().filter(o -> !existsRootSourceIds.contains(o.getRootSourceId()))
+                    .map(AdPutFlowRecordTencent::getVideoId).distinct().collect(Collectors.toList());
+            Map<Long, VideoDetail> videoMap = new HashMap<>();
+            for (List<Long> partition : Lists.partition(videoIds, 20)) {
+                Set<Long> ids = new HashSet<>(partition);
+                videoMap.putAll(messageAttachmentService.getVideoDetail(ids));
+            }
+            Long now = System.currentTimeMillis();
+            for (AdPutFlowRecordTencent record : recordList) {
+                if (existsRootSourceIds.contains(record.getRootSourceId())) {
+                    continue;
+                }
+                ContentPlatformQwPlan qwPlan = new ContentPlatformQwPlan();
+                QwPlanTypeEnum typeEnum = QwPlanTypeEnum.from(record.getPutTypeTwo());
+                qwPlan.setType(typeEnum.getVal());
+                qwPlan.setScene(0);
+                qwPlan.setPageUrl(record.getUrl());
+                qwPlan.setRootSourceId(record.getRootSourceId());
+                qwPlan.setCreateAccountId(account.getId());
+                qwPlan.setCreateTimestamp(now);
+                // 保存视频内容
+                VideoDetail videoDetail = videoMap.get(record.getVideoId());
+                if (Objects.isNull(videoDetail)) {
+                    continue;
+                }
+                QwPlanSaveVideoParam videoParam = new QwPlanSaveVideoParam();
+                videoParam.setVideoId(record.getVideoId());
+                videoParam.setTitle(record.getVideoTitle());
+                videoParam.setCover(videoDetail.getCover());
+                videoParam.setVideo(videoDetail.getVideoPath());
+                planMapperExt.insertQwPlanReturnId(qwPlan);
+                saveQwPlanVideo(videoParam, qwPlan.getId(), account.getId());
+            }
+        }
+    }
+
 }

+ 7 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/GhDetailServiceImpl.java

@@ -233,5 +233,12 @@ public class GhDetailServiceImpl implements GhDetailService {
         return null;
     }
 
+    @Override
+    public List<GhDetail> getByChannel(String channel) {
+        GhDetailExample ghDetailExample = new GhDetailExample();
+        ghDetailExample.createCriteria().andChannelEqualTo(channel).andIsDeleteEqualTo(0);
+        return ghDetailMapper.selectByExample(ghDetailExample);
+    }
+
 
 }

+ 3 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/BuckStrategyV1.java

@@ -320,6 +320,9 @@ public class BuckStrategyV1 implements ReplyStrategyService {
             }
         } else if (Objects.equals(StrategyStatusEnum.STRATEGY.status, bucketDataParam.getStrategyStatus())) {
             for (String key : keyedSet) {
+                if ("base".equals(key)) {
+                    continue;
+                }
                 List<CgiReplyBucketData> strategyData = getStrategyData(key);
                 if (!CollectionUtils.isEmpty(strategyData)) {
                     result.addAll(strategyData);

+ 42 - 0
api-module/src/test/java/com/tzld/piaoquan/api/ContentPlatformTest.java

@@ -0,0 +1,42 @@
+package com.tzld.piaoquan.api;
+
+import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformCooperateAccountService;
+import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.Arrays;
+import java.util.List;
+
+@SpringBootTest(classes = GrowthServerApplication.class)
+@Slf4j
+public class ContentPlatformTest {
+
+    @Autowired
+    ContentPlatformCooperateAccountService cooperateAccountService;
+
+    @Autowired
+    ContentPlatformPlanService planService;
+
+    @Test
+    public void testImportGzhAccount() {
+        List<String> channels = Arrays.asList("ml","yy","zh","llf","wxm","hc","xs","wx","yqst","lq","bh","qd","bz","sw","pj","cy","xsy","ls","zqh");
+        cooperateAccountService.gzhImport(channels);
+    }
+
+    @Test
+    public void testImportGzhPlan() {
+        List<String> channels = Arrays.asList("ml","yy","zh","llf","wxm","hc","xs","wx","yqst","lq","bh","qd","bz","sw","pj","cy","xsy","ls","zqh");
+        planService.gzhPlanImport(channels);
+    }
+
+    @Test
+    public void testImportQwPlan() {
+        List<String> channels = Arrays.asList("ml2025", "mj", "nh", "qc", "tczy", "wb", "xj", "wxm", "xycsd", "shy");
+        planService.qwPlanImport(channels);
+    }
+
+
+}

+ 5 - 5
common-module/src/main/java/com/tzld/piaoquan/growth/common/config/HttpClientConfig.java

@@ -15,21 +15,21 @@ public class HttpClientConfig {
     /**
      * 链接建立的超时时间 ms
      */
-    private static final int CONNECTION_TIMEOUT = 3000;
+    private static final int CONNECTION_TIMEOUT = 5000;
     /**
      * 响应超时时间 ms
      */
-    private static final int SOCKET_TIMEOUT = 10000;
+    private static final int SOCKET_TIMEOUT = 30000;
 
     /**
      * 每个路由的最大连接数
      */
-    private static final int MAX_PER_ROUTE = 20;
+    private static final int MAX_PER_ROUTE = 100;
 
     /**
      * 最大连接数
      */
-    private static final int MAX_TOTAL = 100;
+    private static final int MAX_TOTAL = 500;
 
     /**
      * 重试次数,默认0
@@ -39,7 +39,7 @@ public class HttpClientConfig {
     /**
      * 从connection pool中获得一个connection的超时时间 ms
      */
-    private static final int CONNECTION_WAIT_TIMEOUT = 2000;
+    private static final int CONNECTION_WAIT_TIMEOUT = 5000;
 
 
     @Bean

+ 2 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/bo/VideoDetail.java

@@ -8,4 +8,6 @@ public class VideoDetail {
     private String cover;
 
     private String title;
+
+    private String videoPath;
 }

+ 5 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageAttachmentServiceImpl.java

@@ -296,11 +296,16 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             for (int i = 0; i < data.size(); i++) {
                 VideoDetail videoDetail = new VideoDetail();
                 JSONObject jsonObject = data.getJSONObject(i);
+                if (Objects.isNull(jsonObject)) {
+                    continue;
+                }
                 Long videoId = jsonObject.getLong("id");
                 String shareImgPath = jsonObject.getString("shareImgPath");
                 String title = jsonObject.getString("title");
+                String videoPath = jsonObject.getString("videoPath");
                 videoDetail.setCover(shareImgPath);
                 videoDetail.setTitle(title);
+                videoDetail.setVideoPath(videoPath);
                 map.put(videoId, videoDetail);
             }
             return map;