|
@@ -7,14 +7,12 @@ import com.tzld.piaoquan.api.common.enums.contentplatform.ContentPlatformGzhPlan
|
|
|
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.component.*;
|
|
|
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.bo.BucketDataParam;
|
|
|
+import com.tzld.piaoquan.api.model.bo.SmallPageUrlDetail;
|
|
|
import com.tzld.piaoquan.api.model.config.LoginUserContext;
|
|
|
import com.tzld.piaoquan.api.model.param.contentplatform.*;
|
|
|
import com.tzld.piaoquan.api.model.po.contentplatform.*;
|
|
@@ -85,6 +83,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
private AdApiService adApiService;
|
|
|
@Autowired
|
|
|
private CgiReplyService cgiReplyService;
|
|
|
+ @Autowired
|
|
|
+ private TouLiuHttpClient touLiuHttpClient;
|
|
|
|
|
|
|
|
|
@Value("${vlog.share.appType:11}")
|
|
@@ -93,6 +93,9 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
@Value("${video.min.score:0.6}")
|
|
|
private Double videoMinScore;
|
|
|
|
|
|
+ @Value("${small_page_url}")
|
|
|
+ private String GET_SMALL_PAGE_URL;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<GzhPlanItemVO> gzhPlanList(GzhPlanListParam param) {
|
|
|
ContentPlatformAccount loginAccount = LoginUserContext.getUser();
|
|
@@ -125,8 +128,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();
|
|
@@ -157,6 +160,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
videoItemVO.setCustomCover(video.getCustomCover());
|
|
|
videoItemVO.setCustomCoverType(video.getCustomCoverType());
|
|
|
videoItemVO.setVideo(video.getVideo());
|
|
|
+ videoItemVO.setPageUrl(video.getPageUrl());
|
|
|
if (Objects.nonNull(bucketDataMapByGhId)) {
|
|
|
CgiReplyBucketData bucketData = bucketDataMapByGhId.get(video.getVideoId());
|
|
|
if (Objects.nonNull(bucketData)) {
|
|
@@ -251,11 +255,13 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
gzhPlan.setPublishStage(param.getPublishStage());
|
|
|
gzhPlan.setSelectVideoType(param.getSelectVideoType());
|
|
|
gzhPlan.setUpdateTimestamp(now);
|
|
|
- // 更新gh_detail
|
|
|
List<Long> videoIds = param.getVideoList().stream().map(GzhPlanVideoContentItemParam::getVideoId).collect(Collectors.toList());
|
|
|
- updateGhDetail(account, param.getSelectVideoType(), videoIds);
|
|
|
- // 更新cgi_reply_bucket_data
|
|
|
- updateCgiReplyBucketData(account.getGhId(), param.getVideoList());
|
|
|
+ if (param.getType() == ContentPlatformGzhPlanTypeEnum.AUTO_REPLY.getVal()) {
|
|
|
+ // 更新gh_detail
|
|
|
+ updateGhDetail(account, param.getSelectVideoType(), videoIds);
|
|
|
+ // 更新cgi_reply_bucket_data
|
|
|
+ updateCgiReplyBucketData(account.getGhId(), param.getVideoList());
|
|
|
+ }
|
|
|
if (Objects.isNull(param.getId())) {
|
|
|
// 调用aigc创建发布计划
|
|
|
if (PublishStageEnum.PLATFORM.getVal() == param.getPublishStage()) {
|
|
@@ -287,14 +293,16 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
gzhPlanMapper.updateByPrimaryKeySelective(gzhPlan);
|
|
|
}
|
|
|
// 保存视频内容
|
|
|
- saveGzhPlanVideo(param, videoIds, gzhPlan.getId(), loginAccount);
|
|
|
+ saveGzhPlanVideo(param, videoIds, gzhPlan.getId(), account, loginAccount);
|
|
|
// 调用aigc重新拉取视频
|
|
|
- if (PublishStageEnum.PLATFORM.getVal() == param.getPublishStage()) {
|
|
|
- aigcApiService.refreshGzhAutoReplyMsgData(account.getGhId());
|
|
|
- } else {
|
|
|
- BucketDataParam bucketDataParam = new BucketDataParam();
|
|
|
- bucketDataParam.setGhId(account.getGhId());
|
|
|
- cgiReplyService.getRgiReplyData(bucketDataParam);
|
|
|
+ if (param.getType() == ContentPlatformGzhPlanTypeEnum.AUTO_REPLY.getVal()) {
|
|
|
+ if (PublishStageEnum.PLATFORM.getVal() == param.getPublishStage()) {
|
|
|
+ aigcApiService.refreshGzhAutoReplyMsgData(account.getGhId());
|
|
|
+ } else {
|
|
|
+ BucketDataParam bucketDataParam = new BucketDataParam();
|
|
|
+ bucketDataParam.setGhId(account.getGhId());
|
|
|
+ cgiReplyService.getRgiReplyData(bucketDataParam);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -314,7 +322,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void saveGzhPlanVideo(GzhPlanSaveParam param, List<Long> videoIds, Long id, ContentPlatformAccount loginAccount) {
|
|
|
+ private void saveGzhPlanVideo(GzhPlanSaveParam param, List<Long> videoIds, Long id,
|
|
|
+ ContentPlatformGzhAccount account, ContentPlatformAccount loginAccount) {
|
|
|
List<ContentPlatformGzhPlanVideo> existsVideo = getGzhVideoByPlanId(id);
|
|
|
List<Long> existsVideoIds = existsVideo.stream().map(ContentPlatformGzhPlanVideo::getVideoId).collect(Collectors.toList());
|
|
|
Map<Long, ContentPlatformGzhPlanVideo> existsVideoMap = existsVideo.stream()
|
|
@@ -343,6 +352,13 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
item.setCustomCover(vo.getCustomCover());
|
|
|
item.setCustomCoverType(vo.getCustomCoverType());
|
|
|
item.setVideo(vo.getVideo());
|
|
|
+ if (param.getType() == ContentPlatformGzhPlanTypeEnum.FWH_PUSH.getVal()) {
|
|
|
+ String response = touLiuHttpClient.sendAdFlowAddRequest(GET_SMALL_PAGE_URL, String.valueOf(vo.getVideoId()), "fwhdyy",
|
|
|
+ loginAccount.getChannel(), "自动", "公众号", "文章插小程序", "文字和小程序", account.getGhId());
|
|
|
+ JSONObject json = JSONObject.parseObject(response);
|
|
|
+ SmallPageUrlDetail smallPageUrlDetail = json.getJSONObject("data").toJavaObject(SmallPageUrlDetail.class);
|
|
|
+ item.setPageUrl(smallPageUrlDetail.getUrl());
|
|
|
+ }
|
|
|
item.setCreateAccountId(loginAccount.getId());
|
|
|
item.setCreateTimestamp(System.currentTimeMillis());
|
|
|
gzhPlanVideoMapper.insertSelective(item);
|
|
@@ -610,7 +626,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) {
|
|
@@ -625,11 +641,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);
|