Browse Source

小程序投流批量创建/复制多链接的 createTimestamp 改成 baseNow + offset 单调递增,修批量内多 plan 同 timestamp 导致 ORDER BY create_timestamp DESC 列表内部乱序的问题。现在同批次的 N 个 plan 按 insert 顺序倒序排列,每个视频的 N 份链接在列表里连续不打乱。xcxPlanSave 和 xcxPlanMultiLink 两个入口同步修复。

刘立冬 7 hours ago
parent
commit
9d48f82871

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

@@ -2257,7 +2257,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
                 && !Objects.equals(loginUser.getType(), ContentPlatformAccountTypeEnum.AGENT.getVal())) {
                 && !Objects.equals(loginUser.getType(), ContentPlatformAccountTypeEnum.AGENT.getVal())) {
             throw new CommonException(ExceptionEnum.XCX_PLAN_INTERNAL_ONLY);
             throw new CommonException(ExceptionEnum.XCX_PLAN_INTERNAL_ONLY);
         }
         }
-        Long now = System.currentTimeMillis();
+        long baseNow = System.currentTimeMillis();
+        long offset = 0L;
         List<ContentPlatformXcxPlan> list = new ArrayList<>();
         List<ContentPlatformXcxPlan> list = new ArrayList<>();
         for (XcxPlanSaveVideoParam videoParam : param.getVideoList()) {
         for (XcxPlanSaveVideoParam videoParam : param.getVideoList()) {
             int count = (videoParam.getCount() == null || videoParam.getCount() <= 0)
             int count = (videoParam.getCount() == null || videoParam.getCount() <= 0)
@@ -2266,6 +2267,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
                 throw new CommonException(ExceptionEnum.PARAM_ERROR);
                 throw new CommonException(ExceptionEnum.PARAM_ERROR);
             }
             }
             for (int i = 0; i < count; i++) {
             for (int i = 0; i < count; i++) {
+                long ts = baseNow + offset++;
                 ContentPlatformXcxPlan xcxPlan = new ContentPlatformXcxPlan();
                 ContentPlatformXcxPlan xcxPlan = new ContentPlatformXcxPlan();
                 xcxPlan.setAudiencePackage(param.getAudiencePackage());
                 xcxPlan.setAudiencePackage(param.getAudiencePackage());
                 xcxPlan.setRemark(param.getRemark());
                 xcxPlan.setRemark(param.getRemark());
@@ -2280,8 +2282,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
                 xcxPlan.setRootSourceId(rootSourceId);
                 xcxPlan.setRootSourceId(rootSourceId);
                 xcxPlan.setStatus(PlanStatusEnum.NORMAL.getVal());
                 xcxPlan.setStatus(PlanStatusEnum.NORMAL.getVal());
                 xcxPlan.setCreateAccountId(loginUser.getId());
                 xcxPlan.setCreateAccountId(loginUser.getId());
-                xcxPlan.setCreateTimestamp(now);
-                xcxPlan.setUpdateTimestamp(now);
+                xcxPlan.setCreateTimestamp(ts);
+                xcxPlan.setUpdateTimestamp(ts);
                 planMapperExt.insertXcxPlanReturnId(xcxPlan);
                 planMapperExt.insertXcxPlanReturnId(xcxPlan);
                 list.add(xcxPlan);
                 list.add(xcxPlan);
                 // 保存视频内容
                 // 保存视频内容
@@ -2331,10 +2333,11 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         }
         }
         ContentPlatformXcxPlanVideo srcVideo = srcVideoList.get(0);
         ContentPlatformXcxPlanVideo srcVideo = srcVideoList.get(0);
 
 
-        Long now = System.currentTimeMillis();
+        long baseNow = System.currentTimeMillis();
         List<ContentPlatformXcxPlan> created = new ArrayList<>();
         List<ContentPlatformXcxPlan> created = new ArrayList<>();
         try {
         try {
             for (int i = 0; i < param.getCount(); i++) {
             for (int i = 0; i < param.getCount(); i++) {
+                long ts = baseNow + i;
                 ContentPlatformXcxPlan xcxPlan = new ContentPlatformXcxPlan();
                 ContentPlatformXcxPlan xcxPlan = new ContentPlatformXcxPlan();
                 xcxPlan.setAudiencePackage(src.getAudiencePackage());
                 xcxPlan.setAudiencePackage(src.getAudiencePackage());
                 xcxPlan.setRemark(src.getRemark());
                 xcxPlan.setRemark(src.getRemark());
@@ -2348,8 +2351,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
                 xcxPlan.setRootSourceId(rootSourceId);
                 xcxPlan.setRootSourceId(rootSourceId);
                 xcxPlan.setStatus(PlanStatusEnum.NORMAL.getVal());
                 xcxPlan.setStatus(PlanStatusEnum.NORMAL.getVal());
                 xcxPlan.setCreateAccountId(loginUser.getId());
                 xcxPlan.setCreateAccountId(loginUser.getId());
-                xcxPlan.setCreateTimestamp(now);
-                xcxPlan.setUpdateTimestamp(now);
+                xcxPlan.setCreateTimestamp(ts);
+                xcxPlan.setUpdateTimestamp(ts);
                 planMapperExt.insertXcxPlanReturnId(xcxPlan);
                 planMapperExt.insertXcxPlanReturnId(xcxPlan);
                 created.add(xcxPlan);
                 created.add(xcxPlan);