|
@@ -3,16 +3,16 @@ 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.ContentPlatformGzhPlanTypeEnum;
|
|
|
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.*;
|
|
@@ -21,17 +21,16 @@ import com.tzld.piaoquan.api.model.vo.contentplatform.GzhPlanItemVO;
|
|
|
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.CgiReplyService;
|
|
|
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;
|
|
|
import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
|
|
|
-import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
|
|
|
import com.tzld.piaoquan.growth.common.dao.mapper.ext.CgiReplyBucketDataMapperExt;
|
|
|
import com.tzld.piaoquan.growth.common.model.bo.VideoDetail;
|
|
|
import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
|
|
|
-import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
|
|
|
import com.tzld.piaoquan.growth.common.model.po.GhDetail;
|
|
|
import com.tzld.piaoquan.growth.common.service.MessageAttachmentService;
|
|
|
import com.tzld.piaoquan.growth.common.utils.MessageUtil;
|
|
@@ -63,8 +62,6 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
@Autowired
|
|
|
private ContentPlatformQwPlanVideoMapper qwPlanVideoMapper;
|
|
|
@Autowired
|
|
|
- private CgiReplyBucketDataMapper cgiReplyBucketDataMapper;
|
|
|
- @Autowired
|
|
|
private CgiReplyBucketDataMapperExt cgiReplyBucketDataMapperExt;
|
|
|
@Autowired
|
|
|
private ContentPlatformVideoMapper contentPlatformVideoMapper;
|
|
@@ -84,6 +81,11 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
private ContentPlatformAccountService accountService;
|
|
|
@Autowired
|
|
|
private AdApiService adApiService;
|
|
|
+ @Autowired
|
|
|
+ private CgiReplyService cgiReplyService;
|
|
|
+ @Autowired
|
|
|
+ private TouLiuHttpClient touLiuHttpClient;
|
|
|
+
|
|
|
|
|
|
@Value("${vlog.share.appType:11}")
|
|
|
private String shareAppType;
|
|
@@ -91,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();
|
|
@@ -114,20 +119,30 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
}
|
|
|
List<Long> accountIds = planList.stream().map(ContentPlatformGzhPlan::getAccountId).collect(Collectors.toList());
|
|
|
List<ContentPlatformGzhAccount> accountList = cooperateAccountService.getAccountListByIds(accountIds);
|
|
|
- Map<Long, String> accountMap = accountList.stream().collect(Collectors.toMap(ContentPlatformGzhAccount::getId,
|
|
|
- ContentPlatformGzhAccount::getName));
|
|
|
+ Map<Long, ContentPlatformGzhAccount> accountMap = accountList.stream().collect(Collectors.toMap(ContentPlatformGzhAccount::getId,
|
|
|
+ Function.identity()));
|
|
|
List<Long> planIds = planList.stream().map(ContentPlatformGzhPlan::getId).collect(Collectors.toList());
|
|
|
List<ContentPlatformGzhPlanVideo> videoList = getGzhPlanVideoList(planIds);
|
|
|
Map<Long, List<ContentPlatformGzhPlanVideo>> videoMap = videoList.stream()
|
|
|
.collect(Collectors.groupingBy(ContentPlatformGzhPlanVideo::getPlanId));
|
|
|
+ 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())));
|
|
|
List<GzhPlanItemVO> result = new ArrayList<>();
|
|
|
for (ContentPlatformGzhPlan gzhPlan : planList) {
|
|
|
GzhPlanItemVO planItemVO = new GzhPlanItemVO();
|
|
|
planItemVO.setId(gzhPlan.getId());
|
|
|
planItemVO.setAccountId(gzhPlan.getAccountId());
|
|
|
- planItemVO.setAccountName(accountMap.get(gzhPlan.getAccountId()));
|
|
|
+ ContentPlatformGzhAccount gzhAccount = accountMap.get(gzhPlan.getAccountId());
|
|
|
+ if (Objects.nonNull(gzhAccount)) {
|
|
|
+ planItemVO.setAccountName(gzhAccount.getName());
|
|
|
+ }
|
|
|
+ planItemVO.setType(gzhPlan.getType());
|
|
|
planItemVO.setScene(gzhPlan.getScene());
|
|
|
planItemVO.setPublishStage(gzhPlan.getPublishStage());
|
|
|
+ planItemVO.setSelectVideoType(gzhPlan.getSelectVideoType());
|
|
|
List<ContentPlatformGzhPlanVideo> videoListByPlanId = videoMap.get(gzhPlan.getId());
|
|
|
if (CollectionUtils.isNotEmpty(videoListByPlanId)) {
|
|
|
planItemVO.setVideoCount(videoListByPlanId.size());
|
|
@@ -135,6 +150,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
.collect(Collectors.toList());
|
|
|
planItemVO.setTitle(titleList);
|
|
|
List<GzhPlanVideoContentItemVO> videoVOList = new ArrayList<>();
|
|
|
+ Map<Long, CgiReplyBucketData> bucketDataMapByGhId = bucketDataMap.get(gzhAccount.getGhId());
|
|
|
for (ContentPlatformGzhPlanVideo video : videoListByPlanId) {
|
|
|
GzhPlanVideoContentItemVO videoItemVO = new GzhPlanVideoContentItemVO();
|
|
|
videoItemVO.setVideoId(video.getVideoId());
|
|
@@ -144,6 +160,13 @@ 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)) {
|
|
|
+ videoItemVO.setPageUrl(bucketData.getMiniPagePath());
|
|
|
+ }
|
|
|
+ }
|
|
|
videoVOList.add(videoItemVO);
|
|
|
}
|
|
|
planItemVO.setVideoList(videoVOList);
|
|
@@ -176,6 +199,25 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void gzhUpdateStagePublishStatus(Long id, Integer stagePublishStatus) {
|
|
|
+ ContentPlatformGzhPlan plan = gzhPlanMapper.selectByPrimaryKey(id);
|
|
|
+ if (Objects.isNull(plan)) {
|
|
|
+ throw new CommonException(ExceptionEnum.GZH_PLAN_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ if (!Objects.equals(LoginUserContext.getUser().getId(), plan.getCreateAccountId())) {
|
|
|
+ throw new CommonException(ExceptionEnum.PARAM_ERROR);
|
|
|
+ }
|
|
|
+ plan.setStagePublishStatus(stagePublishStatus);
|
|
|
+ plan.setUpdateTimestamp(System.currentTimeMillis());
|
|
|
+ gzhPlanMapper.updateByPrimaryKeySelective(plan);
|
|
|
+ ContentPlatformGzhAccount gzhAccount = cooperateAccountService.getById(plan.getAccountId());
|
|
|
+ if (StringUtils.hasText(plan.getExternalId()) && StringUtils.hasText(gzhAccount.getExternalId())) {
|
|
|
+ aigcApiService.changePublishPlanAccountStatus(plan.getExternalId(), gzhAccount.getExternalId(), stagePublishStatus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void qwPlanDelete(Long id) {
|
|
|
ContentPlatformQwPlan plan = qwPlanMapper.selectByPrimaryKey(id);
|
|
@@ -190,8 +232,9 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
@Override
|
|
|
public void gzhPlanSave(GzhPlanSaveParam param) {
|
|
|
ContentPlatformAccount loginAccount = LoginUserContext.getUser();
|
|
|
- List<ContentPlatformGzhPlan> planExistList = planMapperExt.getGzhPlanExists(param.getAccountId(), param.getScene(), param.getId());
|
|
|
- if (CollectionUtils.isNotEmpty(planExistList)) {
|
|
|
+ List<ContentPlatformGzhPlan> planExistList = planMapperExt.getGzhPlanExists(param.getAccountId(),
|
|
|
+ param.getType(), param.getScene(), param.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(planExistList) && param.getType() != ContentPlatformGzhPlanTypeEnum.FWH_PUSH.getVal()) {
|
|
|
throw new CommonException(ExceptionEnum.GZH_SCENE_PLAN_EXISTS);
|
|
|
}
|
|
|
if (param.getVideoList().size() > 3) {
|
|
@@ -207,18 +250,23 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
Long now = System.currentTimeMillis();
|
|
|
ContentPlatformGzhPlan gzhPlan = new ContentPlatformGzhPlan();
|
|
|
gzhPlan.setAccountId(param.getAccountId());
|
|
|
+ gzhPlan.setType(param.getType());
|
|
|
gzhPlan.setScene(param.getScene());
|
|
|
gzhPlan.setPublishStage(param.getPublishStage());
|
|
|
+ gzhPlan.setSelectVideoType(param.getSelectVideoType());
|
|
|
gzhPlan.setUpdateTimestamp(now);
|
|
|
- // 更新gh_detail
|
|
|
- List<Long> videoIds = param.getVideoList().stream().map(GzhPlanVideoContentItemVO::getVideoId).collect(Collectors.toList());
|
|
|
- updateGhDetail(account, videoIds);
|
|
|
- // 更新cgi_reply_bucket_data
|
|
|
- updateCgiReplyBucketData(account.getGhId(), param.getVideoList());
|
|
|
+ List<Long> videoIds = param.getVideoList().stream().map(GzhPlanVideoContentItemParam::getVideoId).collect(Collectors.toList());
|
|
|
+ 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()) {
|
|
|
String externalId = aigcApiService.createPublishPlan(account.getExternalId(), account.getName(), loginAccount.getChannel());
|
|
|
+ gzhPlan.setStagePublishStatus(1);
|
|
|
gzhPlan.setExternalId(externalId);
|
|
|
}
|
|
|
gzhPlan.setCreateAccountId(loginAccount.getId());
|
|
@@ -228,13 +276,16 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
ContentPlatformGzhPlan oldPlan = gzhPlanMapper.selectByPrimaryKey(param.getId());
|
|
|
if (PublishStageEnum.USER.getVal() == param.getPublishStage()) {
|
|
|
if (StringUtils.hasText(oldPlan.getExternalId())) {
|
|
|
+ gzhPlan.setStagePublishStatus(0);
|
|
|
aigcApiService.changePublishPlanStatus(oldPlan.getExternalId(), 0);
|
|
|
}
|
|
|
} else {
|
|
|
if (StringUtils.hasText(oldPlan.getExternalId())) {
|
|
|
+ gzhPlan.setStagePublishStatus(1);
|
|
|
aigcApiService.changePublishPlanStatus(oldPlan.getExternalId(), 1);
|
|
|
} else {
|
|
|
String externalId = aigcApiService.createPublishPlan(account.getExternalId(), account.getName(), loginAccount.getChannel());
|
|
|
+ gzhPlan.setStagePublishStatus(1);
|
|
|
gzhPlan.setExternalId(externalId);
|
|
|
}
|
|
|
}
|
|
@@ -242,20 +293,25 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
gzhPlanMapper.updateByPrimaryKeySelective(gzhPlan);
|
|
|
}
|
|
|
// 保存视频内容
|
|
|
- saveGzhPlanVideo(param, videoIds, gzhPlan.getId(), loginAccount.getId());
|
|
|
+ saveGzhPlanVideo(param, videoIds, gzhPlan.getId(), account, loginAccount);
|
|
|
// 调用aigc重新拉取视频
|
|
|
- aigcApiService.refreshGzhAutoReplyMsgData(account.getGhId());
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private void updateCgiReplyBucketData(String ghId, List<GzhPlanVideoContentItemVO> videoList) {
|
|
|
- for (GzhPlanVideoContentItemVO video : videoList) {
|
|
|
+ private void updateCgiReplyBucketData(String ghId, List<GzhPlanVideoContentItemParam> videoList) {
|
|
|
+ for (GzhPlanVideoContentItemParam video : videoList) {
|
|
|
if (!StringUtils.hasText(video.getCustomCover()) && !StringUtils.hasText(video.getCustomTitle())) {
|
|
|
continue;
|
|
|
}
|
|
|
- CgiReplyBucketDataExample example = new CgiReplyBucketDataExample();
|
|
|
- example.createCriteria().andGhIdEqualTo(ghId).andMiniVideoIdEqualTo(video.getVideoId())
|
|
|
- .andIsDeleteEqualTo(0);
|
|
|
- List<CgiReplyBucketData> dataList = cgiReplyBucketDataMapper.selectByExample(example);
|
|
|
+ List<CgiReplyBucketData> dataList = cgiReplyService.getCgiReplyBucketDataListByVideoId(video.getVideoId());
|
|
|
if (CollectionUtils.isEmpty(dataList)) {
|
|
|
continue;
|
|
|
}
|
|
@@ -266,7 +322,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void saveGzhPlanVideo(GzhPlanSaveParam param, List<Long> videoIds, Long id, Long loginAccountId) {
|
|
|
+ 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()
|
|
@@ -276,7 +333,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
gzhPlanVideoMapper.deleteByPrimaryKey(item.getId());
|
|
|
}
|
|
|
}
|
|
|
- for (GzhPlanVideoContentItemVO vo : param.getVideoList()) {
|
|
|
+ for (GzhPlanVideoContentItemParam vo : param.getVideoList()) {
|
|
|
if (existsVideoIds.contains(vo.getVideoId())) {
|
|
|
ContentPlatformGzhPlanVideo item = existsVideoMap.get(vo.getVideoId());
|
|
|
item.setTitle(vo.getTitle());
|
|
@@ -295,7 +352,14 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
item.setCustomCover(vo.getCustomCover());
|
|
|
item.setCustomCoverType(vo.getCustomCoverType());
|
|
|
item.setVideo(vo.getVideo());
|
|
|
- item.setCreateAccountId(loginAccountId);
|
|
|
+ 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);
|
|
|
}
|
|
@@ -308,13 +372,14 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
return gzhPlanVideoMapper.selectByExample(example);
|
|
|
}
|
|
|
|
|
|
- private void updateGhDetail(ContentPlatformGzhAccount account, List<Long> videoIds) {
|
|
|
+ private void updateGhDetail(ContentPlatformGzhAccount account, Integer selectVideoType, List<Long> videoIds) {
|
|
|
GhDetail ghDetail = ghDetailService.getGhDetailByGhIdType(account.getGhId(), GhTypeEnum.THIRD_PARTY_GH.type);
|
|
|
GhDetailVo detailVo = new GhDetailVo();
|
|
|
+ Integer strategyStatus = selectVideoType == 0 ? StrategyStatusEnum.DEFAULT.status : StrategyStatusEnum.STRATEGY.status;
|
|
|
if (Objects.nonNull(ghDetail)) {
|
|
|
BeanUtils.copyProperties(ghDetail, detailVo);
|
|
|
detailVo.setVideoIds(videoIds);
|
|
|
- detailVo.setStrategyStatus(StrategyStatusEnum.DEFAULT.status);
|
|
|
+ detailVo.setStrategyStatus(strategyStatus);
|
|
|
detailVo.setAutoreplySendMinigramNum(videoIds.size());
|
|
|
detailVo.setCategory1(account.getContentType());
|
|
|
ghDetailService.updateDetail(detailVo);
|
|
@@ -325,7 +390,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
detailVo.setType(GhTypeEnum.THIRD_PARTY_GH.type);
|
|
|
detailVo.setChannel(loginUser.getChannel());
|
|
|
detailVo.setCategory1(account.getContentType());
|
|
|
- detailVo.setStrategyStatus(StrategyStatusEnum.DEFAULT.status);
|
|
|
+ detailVo.setStrategyStatus(strategyStatus);
|
|
|
detailVo.setVideoIds(videoIds);
|
|
|
detailVo.setAutoreplySendMinigramNum(videoIds.size());
|
|
|
ghDetailService.addGhDetail(detailVo);
|
|
@@ -529,6 +594,22 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
return qwPlanVideoMapper.selectByExample(example);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String getGzhChannel(String ghId) {
|
|
|
+ ContentPlatformGzhAccount gzhAccount = cooperateAccountService.getGzhAccount(ghId);
|
|
|
+ if (Objects.nonNull(gzhAccount)) {
|
|
|
+ ContentPlatformAccount account = accountService.getAccountById(gzhAccount.getCreateAccountId());
|
|
|
+ ContentPlatformGzhPlanExample example = new ContentPlatformGzhPlanExample();
|
|
|
+ example.createCriteria().andCreateAccountIdEqualTo(account.getId()).andAccountIdEqualTo(gzhAccount.getId())
|
|
|
+ .andStatusEqualTo(1).andTypeEqualTo(ContentPlatformGzhPlanTypeEnum.FWH_PUSH.getVal());
|
|
|
+ List<ContentPlatformGzhPlan> list = gzhPlanMapper.selectByExample(example);
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ return account.getChannel();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void gzhPlanImport(List<String> channels) {
|
|
|
List<ContentPlatformAccount> accountList = accountService.getAccountListByChannels(channels);
|
|
@@ -536,7 +617,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
Long now = System.currentTimeMillis();
|
|
|
List<GhDetail> ghDetailList = ghDetailService.getByChannel(account.getChannel());
|
|
|
ghDetailList = ghDetailList.stream()
|
|
|
- .filter(o -> Objects.equals(o.getStrategyStatus(), StrategyStatusEnum.DEFAULT.status))
|
|
|
+ .filter(o -> Objects.equals(o.getStrategyStatus(), StrategyStatusEnum.STRATEGY.status))
|
|
|
.collect(Collectors.toList());
|
|
|
if (CollectionUtils.isEmpty(ghDetailList)) {
|
|
|
continue;
|
|
@@ -544,7 +625,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) {
|
|
@@ -554,18 +635,26 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
continue;
|
|
|
}
|
|
|
gzhPlan.setAccountId(gzhAccount.getId());
|
|
|
+ gzhPlan.setType(ContentPlatformGzhPlanTypeEnum.AUTO_REPLY.getVal());
|
|
|
gzhPlan.setScene(0);
|
|
|
+ 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);
|
|
|
+ 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);
|
|
|
gzhPlan.setUpdateTimestamp(now);
|
|
|
planMapperExt.insertGzhPlanReturnId(gzhPlan);
|
|
|
+ if (!StringUtils.hasText(ghDetail.getVideoIds())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
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()) {
|