|
@@ -13,6 +13,7 @@ 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.bo.BucketDataParam;
|
|
|
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 +22,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 +63,6 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
@Autowired
|
|
|
private ContentPlatformQwPlanVideoMapper qwPlanVideoMapper;
|
|
|
@Autowired
|
|
|
- private CgiReplyBucketDataMapper cgiReplyBucketDataMapper;
|
|
|
- @Autowired
|
|
|
private CgiReplyBucketDataMapperExt cgiReplyBucketDataMapperExt;
|
|
|
@Autowired
|
|
|
private ContentPlatformVideoMapper contentPlatformVideoMapper;
|
|
@@ -84,6 +82,9 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
private ContentPlatformAccountService accountService;
|
|
|
@Autowired
|
|
|
private AdApiService adApiService;
|
|
|
+ @Autowired
|
|
|
+ private CgiReplyService cgiReplyService;
|
|
|
+
|
|
|
|
|
|
@Value("${vlog.share.appType:11}")
|
|
|
private String shareAppType;
|
|
@@ -114,20 +115,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 +146,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 +156,10 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
videoItemVO.setCustomCover(video.getCustomCover());
|
|
|
videoItemVO.setCustomCoverType(video.getCustomCoverType());
|
|
|
videoItemVO.setVideo(video.getVideo());
|
|
|
+ CgiReplyBucketData bucketData = bucketDataMapByGhId.get(video.getVideoId());
|
|
|
+ if (Objects.nonNull(bucketData)) {
|
|
|
+ videoItemVO.setPageUrl(bucketData.getMiniPagePath());
|
|
|
+ }
|
|
|
videoVOList.add(videoItemVO);
|
|
|
}
|
|
|
planItemVO.setVideoList(videoVOList);
|
|
@@ -176,6 +192,12 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void gzhUpdateStagePublishStatus(Long id) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void qwPlanDelete(Long id) {
|
|
|
ContentPlatformQwPlan plan = qwPlanMapper.selectByPrimaryKey(id);
|
|
@@ -207,18 +229,21 @@ 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);
|
|
|
+ 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 (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 +253,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 +270,23 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
gzhPlanMapper.updateByPrimaryKeySelective(gzhPlan);
|
|
|
}
|
|
|
// 保存视频内容
|
|
|
- saveGzhPlanVideo(param, videoIds, gzhPlan.getId(), loginAccount.getId());
|
|
|
+ saveGzhPlanVideo(param, videoIds, gzhPlan.getId(), loginAccount);
|
|
|
// 调用aigc重新拉取视频
|
|
|
- aigcApiService.refreshGzhAutoReplyMsgData(account.getGhId());
|
|
|
+ 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 +297,7 @@ 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, 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 +307,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 +326,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
item.setCustomCover(vo.getCustomCover());
|
|
|
item.setCustomCoverType(vo.getCustomCoverType());
|
|
|
item.setVideo(vo.getVideo());
|
|
|
- item.setCreateAccountId(loginAccountId);
|
|
|
+ item.setCreateAccountId(loginAccount.getId());
|
|
|
item.setCreateTimestamp(System.currentTimeMillis());
|
|
|
gzhPlanVideoMapper.insertSelective(item);
|
|
|
}
|
|
@@ -308,13 +339,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 +357,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);
|