wjx 1 tydzień temu
rodzic
commit
68a7780369

+ 20 - 4
src/pages/launchSystemV3/components/PageModal/index.tsx

@@ -98,9 +98,20 @@ const PageModal: React.FC<Props> = (props) => {
     }
 
     const handleOk = () => {
-        if (deliveryMode === "DELIVERY_MODE_COMPONENT" && !data?.every(item => item.pageList?.length === mainJumpInfo?.length)) {
-            message.error(`当前落地页数量不足,跳转类型选择了${mainJumpInfo.length}组,落地页应当选择${mainJumpInfo.length}组`)
-            return
+        if (deliveryMode === "DELIVERY_MODE_COMPONENT") {
+            if (creativeTemplateId === 910) {
+                if (!data?.every(item => {
+                    return item.pageList?.length >= mainJumpInfo?.length && item.pageList?.length % mainJumpInfo?.length === 0
+                })) {
+                    message.error(`当前落地页数量不足,跳转类型选择了${mainJumpInfo.length}组,落地页应当选择大于等于${mainJumpInfo.length},并且是${mainJumpInfo?.length}倍数`)
+                    return
+                }
+            } else {
+                if (!data?.every(item => item.pageList?.length === mainJumpInfo?.length)) {
+                    message.error(`当前落地页数量不足,跳转类型选择了${mainJumpInfo.length}组,落地页应当选择${mainJumpInfo.length}组`)
+                    return
+                }
+            }
         }
         if (data?.every(item => item.pageList)) {
             onChange && onChange({ data, landingPageType: pageAllocationType })
@@ -309,6 +320,11 @@ const PageModal: React.FC<Props> = (props) => {
                             }
                             // 组件化创意
                             if (deliveryMode === "DELIVERY_MODE_COMPONENT") {
+                                if ([910].includes(creativeTemplateId)) {
+                                    return {
+                                        disabled: false
+                                    }
+                                }
                                 if (data[selectAdz - 1]?.pageList?.length >= mainJumpInfo?.length) {
                                     return {
                                         disabled: data[selectAdz - 1]?.pageList?.some((item: any) => item?.pageId === record?.pageId) ? false : true
@@ -364,7 +380,7 @@ const PageModal: React.FC<Props> = (props) => {
                             }
                         },
                         selectedRowKeys: data[selectAdz - 1]?.pageList?.map((item: any) => item?.pageId),
-                        hideSelectAll: deliveryMode === "DELIVERY_MODE_COMPONENT",
+                        hideSelectAll: deliveryMode === "DELIVERY_MODE_COMPONENT" ? creativeTemplateId === 910 ? false : true : false,
                         onSelect: (record: any, selected: boolean) => {
                             let newData = JSON.parse(JSON.stringify(data))
                             if (([910].includes(creativeTemplateId) || deliveryMode === "DELIVERY_MODE_COMPONENT")) {

+ 20 - 4
src/pages/launchSystemV3/components/PageModal/indexOfficial.tsx

@@ -98,9 +98,20 @@ const PageOfficialModal: React.FC<Props> = (props) => {
     }
 
     const handleOk = () => {
-        if (deliveryMode === "DELIVERY_MODE_COMPONENT" && !data?.every(item => item.pageList?.length === mainJumpInfo?.length)) {
-            message.error(`当前落地页数量不足,跳转类型选择了${mainJumpInfo.length}组,落地页应当选择${mainJumpInfo.length}组`)
-            return
+        if (deliveryMode === "DELIVERY_MODE_COMPONENT") {
+            if (creativeTemplateId === 910) {
+                if (!data?.every(item => {
+                    return item.pageList?.length >= mainJumpInfo?.length && item.pageList?.length % mainJumpInfo?.length === 0
+                })) {
+                    message.error(`当前落地页数量不足,跳转类型选择了${mainJumpInfo.length}组,落地页应当选择大于等于${mainJumpInfo.length},并且是${mainJumpInfo?.length}倍数`)
+                    return
+                }
+            } else {
+                if (!data?.every(item => item.pageList?.length === mainJumpInfo?.length)) {
+                    message.error(`当前落地页数量不足,跳转类型选择了${mainJumpInfo.length}组,落地页应当选择${mainJumpInfo.length}组`)
+                    return
+                }
+            }
         }
         if (data?.every(item => item.pageList)) {
             onChange && onChange({ data, landingPageType: pageAllocationType })
@@ -316,6 +327,11 @@ const PageOfficialModal: React.FC<Props> = (props) => {
                             }
                             // 组件化创意
                             if (deliveryMode === "DELIVERY_MODE_COMPONENT") {
+                                if ([910].includes(creativeTemplateId)) {
+                                    return {
+                                        disabled: false
+                                    }
+                                }
                                 if (data[selectAdz - 1]?.pageList?.length >= mainJumpInfo?.length) {
                                     return {
                                         disabled: data[selectAdz - 1]?.pageList?.some((item: any) => item?.pageId === record?.pageId) ? false : true
@@ -331,7 +347,7 @@ const PageOfficialModal: React.FC<Props> = (props) => {
                             }
                         },
                         selectedRowKeys: data[selectAdz - 1]?.pageList?.map((item: any) => item?.pageId),
-                        hideSelectAll: deliveryMode === "DELIVERY_MODE_COMPONENT",
+                        hideSelectAll: deliveryMode === "DELIVERY_MODE_COMPONENT" ? creativeTemplateId === 910 ? false : true : false,
                         onSelect: (record: any, selected: boolean) => {
                             let newData = JSON.parse(JSON.stringify(data))
                             if (([910].includes(creativeTemplateId) || deliveryMode === "DELIVERY_MODE_COMPONENT")) {

+ 2 - 2
src/pages/launchSystemV3/tencentAdPutIn/create/Ad/adgroupsSitSet.tsx

@@ -52,8 +52,8 @@ const AdgroupsSitSet: React.FC = () => {
                 SET_OFFICIAL_ACCOUNT_MEDIA_CATEGORY(NEW_OFFICIAL_ACCOUNT_MEDIA_CATEGORY || [])
                 SET_MINI_PROGRAM_AND_MINI_GAME(NEW_MINI_PROGRAM_AND_MINI_GAME || [])
                 SET_PAY_SCENE(NEW_PAY_SCENE || [])
-                setNoLimitOAMC(NEW_OFFICIAL_ACCOUNT_MEDIA_CATEGORY?.filter((i: { description: string; }) => i.description === '不限')?.[0].id)
-                setNoLimitMPAMG(NEW_MINI_PROGRAM_AND_MINI_GAME?.filter((i: { description: string; }) => i.description === '不限')?.[0].id)
+                setNoLimitOAMC(NEW_OFFICIAL_ACCOUNT_MEDIA_CATEGORY?.filter((i: { description: string; }) => i.description === '不限')?.[0]?.id)
+                setNoLimitMPAMG(NEW_MINI_PROGRAM_AND_MINI_GAME?.filter((i: { description: string; }) => i.description === '不限')?.[0]?.id)
                 setNoLimitPS(NEW_PAY_SCENE?.filter((i: { description: string; }) => i.description === '不限')?.[0].id)
             })
         }

+ 12 - 4
src/pages/launchSystemV3/tencentAdPutIn/create/PageList/index.tsx

@@ -49,13 +49,21 @@ const PageList: React.FC<{ adDataGroup?: { [x: number]: any[] } }> = ({ adDataGr
                 }
             } else {
                 let targetingLength = targeting.length
+                const mainJumpInfoLength = dynamic?.creativeComponents?.mainJumpInfo?.length || 1
                 if (data.some(item => {
                     let productListLength = item?.productList?.length || 1
                     let total = targetingLength * productListLength
                     let pageLength = item.pageList.length
-                    if (total > pageLength) {
-                        message.error(`当前${item.accountId}下的广告总数(${total})大于落地页总数(${pageLength}),平均分配需要落地页总数大于广告总数`)
-                        return true
+                    if (mainJumpInfoLength > 1) {
+                        if (!(total * mainJumpInfoLength <= pageLength && pageLength % mainJumpInfoLength === 0)) {
+                            message.error(`当前${item.accountId}下的广告总数是:${total},落地页组数是:${mainJumpInfoLength},平均分配需要落地页总数(${pageLength})要大于${total * mainJumpInfoLength}并且要是${mainJumpInfoLength}倍数`)
+                            return true
+                        }
+                    } else {
+                        if (total > pageLength) {
+                            message.error(`当前${item.accountId}下的广告总数(${total})大于落地页总数(${pageLength}),平均分配需要落地页总数大于广告总数`)
+                            return true
+                        }
                     }
                     return false
                 })) {
@@ -65,7 +73,7 @@ const PageList: React.FC<{ adDataGroup?: { [x: number]: any[] } }> = ({ adDataGr
         }
         setAccountCreateLogs(data);
         setAddelivery({ ...addelivery, dynamic: { ...dynamic, landingPageType } })
-        switch(type) {
+        switch (type) {
             case 1:
                 setAddVisible(false);
                 break

+ 17 - 9
src/pages/launchSystemV3/tencentAdPutIn/create/addDynamic.tsx

@@ -9,7 +9,7 @@ import PageList from "./PageList";
 import { DispatchAddelivery } from ".";
 import { CheckOutlined, SearchOutlined } from "@ant-design/icons";
 import WechatAccount from "../../components/WechatAccount";
-import { cartesianProduct, distributeArray, processData, splitArrayIntoRandomChunks } from "@/utils/utils";
+import { cartesianProduct, distributeArray, processData, splitArrayIntoRandomChunks, groupArr } from "@/utils/utils";
 import { columnsAddDynamic } from "./tableConfig";
 import { useAjax } from "@/Hook/useAjax";
 import { createDynamicTaskApi } from "@/services/adqV3";
@@ -258,14 +258,22 @@ const AddDynamic: React.FC<PULLIN.NewAddDynamic> = ({ visible, onChange, onClose
                 }
             }
         }
+        const mainJumpInfoLength = dynamic?.creativeComponents?.mainJumpInfo?.length || 1
         // 落地页平均分配判断数量
         if ([910].includes(dynamic.creativeTemplateId) && dynamic?.landingPageType === 1) {
             if (accountCreateLogs.some(item => {
                 const total = adDataGroup[item.accountId].length
                 const pageLength = item.pageList.length
-                if (total > pageLength) {
-                    message.error(`当前${item.accountId}下的广告总数(${total})大于落地页总数(${pageLength}),平均分配需要落地页总数大于广告总数`)
-                    return true
+                if (mainJumpInfoLength > 1) {
+                    if (!(total * mainJumpInfoLength <= pageLength && pageLength % mainJumpInfoLength === 0)) {
+                        message.error(`当前${item.accountId}下的广告总数是:${total},落地页组数是:${mainJumpInfoLength},平均分配需要落地页总数(${pageLength})要大于${total * mainJumpInfoLength}并且要是${mainJumpInfoLength}倍数`)
+                        return true
+                    }
+                } else {
+                    if (total > pageLength) {
+                        message.error(`当前${item.accountId}下的广告总数(${total})大于落地页总数(${pageLength}),平均分配需要落地页总数大于广告总数`)
+                        return true
+                    }
                 }
                 return false
             })) {
@@ -293,7 +301,7 @@ const AddDynamic: React.FC<PULLIN.NewAddDynamic> = ({ visible, onChange, onClose
         if (dynamic?.landingPageType === 1 && [910].includes(dynamic.creativeTemplateId)) {
             accountCreateLogs.forEach(item => {
                 const adData = adDataGroup[item.accountId]
-                const averageAdPageList: any[] = distributeArray(item.pageList, adData.length)
+                const averageAdPageList: any[] =  groupArr(item.pageList, adData.length, mainJumpInfoLength)
                 let newData: any[] = []
                 adData.forEach((ad, index) => {
                     const data = [{
@@ -306,7 +314,7 @@ const AddDynamic: React.FC<PULLIN.NewAddDynamic> = ({ visible, onChange, onClose
                         return {
                             ...d1,
                             id: d1.id + '_' + index,
-                            pageListDto: [pageList],
+                            pageListDto: pageList,
                             dynamicDto: {
                                 ...d1.dynamicDto,
                                 dynamicCreativeName: d1.dynamicDto.dynamicCreativeName + num
@@ -330,17 +338,17 @@ const AddDynamic: React.FC<PULLIN.NewAddDynamic> = ({ visible, onChange, onClose
                         adgroupsDto: ad,
                         dynamicDto: dynamic,                          // 创意信息
                         averageAdDynamic,
-                        rowSpan: ((mediaType === 1 || mediaType === 3) && textType !== 4) ? averageAdDynamic.length : ([910].includes(dynamic.creativeTemplateId) ? item.pageList?.length : (textType === 3 ? textDtoLenth * dynamicGroupLength : dynamicGroupLength)) || 1
+                        rowSpan: ((mediaType === 1 || mediaType === 3) && textType !== 4) ? averageAdDynamic.length : ([910].includes(dynamic.creativeTemplateId) ? item.pageList?.length / mainJumpInfoLength : (textType === 3 ? textDtoLenth * dynamicGroupLength : dynamicGroupLength)) || 1
                     }]
 
                     let newData: any[] = []
                     if ([910].includes(dynamic.creativeTemplateId)) {
-                        newData = cartesianProduct(data, item.pageList).map((item, index) => {
+                        newData = cartesianProduct(data, distributeArray(item.pageList, item.pageList.length / mainJumpInfoLength)).map((item, index) => {
                             const [d1, pageList, num] = item
                             return {
                                 ...d1,
                                 id: d1.id + '_' + index,
-                                pageListDto: [pageList],
+                                pageListDto: pageList,
                                 dynamicDto: {
                                     ...d1.dynamicDto,
                                     dynamicCreativeName: d1.dynamicDto.dynamicCreativeName + num

+ 18 - 11
src/pages/launchSystemV3/tencentAdPutIn/create/index.tsx

@@ -14,7 +14,7 @@ import Dynamic from "./Dynamic"
 import Material from "./Material"
 import MaterialText from "./MaterialText"
 import PageList from "./PageList"
-import { cartesianProduct, distributeArray, processData, randomString, splitArrayIntoRandomChunks } from "@/utils/utils"
+import { cartesianProduct, distributeArray, processData, randomString, splitArrayIntoRandomChunks, groupArr } from "@/utils/utils"
 import columns from "./tableConfig"
 import SubmitModal from "./submitModal"
 import { createAdgroupTaskApi, createAdgroupTaskV2Api, getSelectTaskDetailApi } from "@/services/adqV3"
@@ -523,6 +523,7 @@ const Create: React.FC = () => {
                 return
             }
         }
+        const mainJumpInfoLength = dynamic?.creativeComponents?.mainJumpInfo?.length || 1
         // 落地页平均分配判断数量
         if ([910].includes(dynamic.creativeTemplateId) && dynamic?.landingPageType === 1) {
             const targetingLength = targeting.length
@@ -530,9 +531,16 @@ const Create: React.FC = () => {
                 const productListLength = item?.productList?.length || 1
                 const total = targetingLength * productListLength
                 const pageLength = item.pageList.length
-                if (total > pageLength) {
-                    message.error(`当前${item.accountId}下的广告总数(${total})大于落地页总数(${pageLength}),平均分配需要落地页总数大于广告总数`)
-                    return true
+                if (mainJumpInfoLength > 1) {
+                    if (!(total * mainJumpInfoLength <= pageLength && pageLength % mainJumpInfoLength === 0)) {
+                        message.error(`当前${item.accountId}下的广告总数是:${total},落地页组数是:${mainJumpInfoLength},平均分配需要落地页总数(${pageLength})要大于${total * mainJumpInfoLength}并且要是${mainJumpInfoLength}倍数`)
+                        return true
+                    }
+                } else {
+                    if (total > pageLength) {
+                        message.error(`当前${item.accountId}下的广告总数(${total})大于落地页总数(${pageLength}),平均分配需要落地页总数大于广告总数`)
+                        return true
+                    }
                 }
                 return false
             })) {
@@ -577,7 +585,7 @@ const Create: React.FC = () => {
                     },
                     dynamicDto: dynamic,                          // 创意信息
                     averageAdDynamic,
-                    rowSpan: ((mediaType === 1 || mediaType === 3) && textType !== 4) ? averageAdDynamic.length : ([910].includes(dynamic.creativeTemplateId) ? item.pageList?.length : (textType === 3 ? textDtoLenth * dynamicGroupLength : dynamicGroupLength)) || 1
+                    rowSpan: ((mediaType === 1 || mediaType === 3) && textType !== 4) ? averageAdDynamic.length : ([910].includes(dynamic.creativeTemplateId) ? item.pageList?.length / mainJumpInfoLength : (textType === 3 ? textDtoLenth * dynamicGroupLength : dynamicGroupLength)) || 1
                 }
                 if (marketingCarrierType === 'MARKETING_CARRIER_TYPE_WECHAT_OFFICIAL_ACCOUNT') { // 营销载体
                     dat.marketingCarrierDto = item?.wechatChannelList
@@ -591,14 +599,14 @@ const Create: React.FC = () => {
             // 激励
             if ([910].includes(dynamic.creativeTemplateId)) {
                 if (dynamic?.landingPageType === 1) {
-                    const averageAdPageList: any[] = distributeArray(item.pageList, productList.length * targeting.length)
+                    const averageAdPageList: any[] = groupArr(item.pageList, productList.length * targeting.length, mainJumpInfoLength)
                     data.forEach((item, aIndex) => {
                         const aPageList: any[] = averageAdPageList[aIndex]
                         aPageList.forEach((page, index) => {
                             newData.push({
                                 ...item,
                                 id: item.id + '_' + index,
-                                pageListDto: [page],
+                                pageListDto: page,
                                 dynamicDto: {
                                     ...item.dynamicDto,
                                     dynamicCreativeName: item.dynamicDto.dynamicCreativeName + index
@@ -611,12 +619,12 @@ const Create: React.FC = () => {
 
                     })
                 } else {
-                    newData = cartesianProduct(data, item.pageList).map((item, index) => {
+                    newData = cartesianProduct(data, distributeArray(item.pageList, item.pageList.length / mainJumpInfoLength)).map((item, index) => {
                         const [d1, pageList, num] = item
                         return {
                             ...d1,
                             id: d1.id + '_' + index,
-                            pageListDto: [pageList],
+                            pageListDto: pageList,
                             dynamicDto: {
                                 ...d1.dynamicDto,
                                 dynamicCreativeName: d1.dynamicDto.dynamicCreativeName + num
@@ -712,7 +720,6 @@ const Create: React.FC = () => {
                     })
                 }
             }
-
             newdynamicCount = newdynamicCount + newData.length
             newTableData[item.accountId] = newData
         })
@@ -1039,7 +1046,7 @@ const Create: React.FC = () => {
                                 adLength,
                                 isDqSubmit,
                                 setIsDqSubmit,
-                                targetRules, 
+                                targetRules,
                                 setTargetRules
                             }}>
                             <div className={style.settingsBody_content_right}>

+ 34 - 1
src/utils/utils.ts

@@ -427,7 +427,7 @@ export const arraysHaveSameValues = (arr1: any[], arr2: any[]): boolean => {
 export const distributeArray = (originalArray: any[], numGroups: number): any[][] => {
     // 初始化结果数组,每个子数组为空
     const result: any[][] = Array.from({ length: numGroups }, () => []);
-
+    console.log('result==============>', result)
     // 分配原始数组中的元素到结果数组
     originalArray.forEach((element, index) => {
         result[index % numGroups].push(element);
@@ -436,6 +436,39 @@ export const distributeArray = (originalArray: any[], numGroups: number): any[][
     return result;
 };
 
+/**
+ * 数组分组
+ * @param arr 
+ * @param adLength 
+ * @param infoLength 
+ * @returns 
+ * arr = [1,2,3,4,5,6]
+ * groupArr(arr, 2, 2) [[[1,2],[3,4]],[[5,6]]]
+ * groupArr(arr, 2, 3) [[[1,2,3],[4,5,6]]]
+ * groupArr(arr, 3, 2) [[[1,2],[3,4],[5,6]]]
+ */
+export function groupArr<T>(arr: T[], adLength: number, infoLength: number): T[][][] {
+  // 1. 先按 infoLength 切分
+  const infoGroups: T[][] = []
+  for (let i = 0; i < arr.length; i += infoLength) {
+    infoGroups.push(arr.slice(i, i + infoLength))
+  }
+
+  // 2. 如果数量小于等于 adLength,每个单独一组
+  if (infoGroups.length <= adLength) {
+    return infoGroups.map(g => [g])
+  }
+
+  // 3. 轮询分配
+  const result: T[][][] = Array.from({ length: adLength }, () => [])
+
+  infoGroups.forEach((group, index) => {
+    const target = index % adLength
+    result[target].push(group)
+  })
+
+  return result
+}
 
 /**
  * 随机取几个值