|
|
@@ -2066,7 +2066,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
@Override
|
|
|
public List<XcxPlanItemVO> xcxPlanSave(XcxPlanSaveParam param) {
|
|
|
ContentPlatformAccount loginUser = LoginUserContext.getUser();
|
|
|
- if (!Objects.equals(loginUser.getType(), 2)) {
|
|
|
+ if (!Objects.equals(loginUser.getType(), 2) && !Objects.equals(loginUser.getType(), 3)) {
|
|
|
throw new CommonException(ExceptionEnum.XCX_PLAN_INTERNAL_ONLY);
|
|
|
}
|
|
|
Long now = System.currentTimeMillis();
|
|
|
@@ -2099,7 +2099,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
@Override
|
|
|
public void xcxPlanDelete(Long id) {
|
|
|
ContentPlatformAccount loginUser = LoginUserContext.getUser();
|
|
|
- if (!Objects.equals(loginUser.getType(), 2)) {
|
|
|
+ if (!Objects.equals(loginUser.getType(), 2) && !Objects.equals(loginUser.getType(), 3)) {
|
|
|
throw new CommonException(ExceptionEnum.XCX_PLAN_INTERNAL_ONLY);
|
|
|
}
|
|
|
ContentPlatformXcxPlan plan = xcxPlanMapper.selectByPrimaryKey(id);
|
|
|
@@ -2136,36 +2136,59 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
|
|
|
Long now = System.currentTimeMillis();
|
|
|
List<ContentPlatformXcxPlan> created = new ArrayList<>();
|
|
|
- for (int i = 0; i < param.getCount(); i++) {
|
|
|
- ContentPlatformXcxPlan xcxPlan = new ContentPlatformXcxPlan();
|
|
|
- xcxPlan.setAudiencePackage(src.getAudiencePackage());
|
|
|
- xcxPlan.setRemark(src.getRemark());
|
|
|
- Staff staff = new Staff();
|
|
|
- staff.setCarrierId("wxf7261ed54f2e450e");
|
|
|
- staff.setRemark(src.getRemark());
|
|
|
- String pageUrl = messageAttachmentService.getPageNoCache("touliu", "tencent", staff,
|
|
|
- srcVideo.getVideoId(), "小程序", null, null, srcVideo.getExperimentId());
|
|
|
- String rootSourceId = MessageUtil.getRootSourceId(pageUrl);
|
|
|
- xcxPlan.setPageUrl(pageUrl);
|
|
|
- xcxPlan.setRootSourceId(rootSourceId);
|
|
|
- xcxPlan.setStatus(PlanStatusEnum.NORMAL.getVal());
|
|
|
- xcxPlan.setCreateAccountId(loginUser.getId());
|
|
|
- xcxPlan.setCreateTimestamp(now);
|
|
|
- xcxPlan.setUpdateTimestamp(now);
|
|
|
- planMapperExt.insertXcxPlanReturnId(xcxPlan);
|
|
|
- created.add(xcxPlan);
|
|
|
-
|
|
|
- XcxPlanSaveVideoParam vp = new XcxPlanSaveVideoParam();
|
|
|
- vp.setVideoId(srcVideo.getVideoId());
|
|
|
- vp.setTitle(srcVideo.getTitle());
|
|
|
- vp.setCover(srcVideo.getCover());
|
|
|
- vp.setVideo(srcVideo.getVideo());
|
|
|
- vp.setExperimentId(srcVideo.getExperimentId());
|
|
|
- saveXcxPlanVideo(vp, xcxPlan.getId(), loginUser.getId());
|
|
|
+ try {
|
|
|
+ for (int i = 0; i < param.getCount(); i++) {
|
|
|
+ ContentPlatformXcxPlan xcxPlan = new ContentPlatformXcxPlan();
|
|
|
+ xcxPlan.setAudiencePackage(src.getAudiencePackage());
|
|
|
+ xcxPlan.setRemark(src.getRemark());
|
|
|
+ Staff staff = new Staff();
|
|
|
+ staff.setCarrierId("wxf7261ed54f2e450e");
|
|
|
+ staff.setRemark(src.getRemark());
|
|
|
+ String pageUrl = messageAttachmentService.getPageNoCache("touliu", "tencent", staff,
|
|
|
+ srcVideo.getVideoId(), "小程序", null, null, srcVideo.getExperimentId());
|
|
|
+ String rootSourceId = MessageUtil.getRootSourceId(pageUrl);
|
|
|
+ xcxPlan.setPageUrl(pageUrl);
|
|
|
+ xcxPlan.setRootSourceId(rootSourceId);
|
|
|
+ xcxPlan.setStatus(PlanStatusEnum.NORMAL.getVal());
|
|
|
+ xcxPlan.setCreateAccountId(loginUser.getId());
|
|
|
+ xcxPlan.setCreateTimestamp(now);
|
|
|
+ xcxPlan.setUpdateTimestamp(now);
|
|
|
+ planMapperExt.insertXcxPlanReturnId(xcxPlan);
|
|
|
+ created.add(xcxPlan);
|
|
|
+
|
|
|
+ XcxPlanSaveVideoParam vp = new XcxPlanSaveVideoParam();
|
|
|
+ vp.setVideoId(srcVideo.getVideoId());
|
|
|
+ vp.setTitle(srcVideo.getTitle());
|
|
|
+ vp.setCover(srcVideo.getCover());
|
|
|
+ vp.setVideo(srcVideo.getVideo());
|
|
|
+ vp.setExperimentId(srcVideo.getExperimentId());
|
|
|
+ saveXcxPlanVideo(vp, xcxPlan.getId(), loginUser.getId());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("xcxPlanMultiLink failed at {}/{} for planId={}, rolling back {} created plans",
|
|
|
+ created.size(), param.getCount(), param.getPlanId(), created.size(), e);
|
|
|
+ rollbackXcxPlans(created);
|
|
|
+ throw new CommonException(ExceptionEnum.SYSTEM_ERROR);
|
|
|
}
|
|
|
return buildXcxPlanItemVOList(created);
|
|
|
}
|
|
|
|
|
|
+ private void rollbackXcxPlans(List<ContentPlatformXcxPlan> created) {
|
|
|
+ if (CollectionUtils.isEmpty(created)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Long now = System.currentTimeMillis();
|
|
|
+ for (ContentPlatformXcxPlan plan : created) {
|
|
|
+ try {
|
|
|
+ plan.setStatus(PlanStatusEnum.DELETED.getVal());
|
|
|
+ plan.setUpdateTimestamp(now);
|
|
|
+ xcxPlanMapper.updateByPrimaryKeySelective(plan);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error("xcxPlanMultiLink rollback failed for planId={}", plan.getId(), ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<String> getXcxAudiencePackageList() {
|
|
|
String dt = demandVideoMapperExt.getMaxDt(CHANNEL_NAME_XCX);
|