Procházet zdrojové kódy

兼容原有功能,添加行为兴趣定向参数2

zhaoxian před 4 roky
rodič
revize
a5eaf0deab

+ 41 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java

@@ -3,12 +3,21 @@ package cn.com.ctop.kuaishou.modules.ai.service.impl;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
-import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.HttpUtils2;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouCreateService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -614,9 +623,36 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 target.put("intelli_extend", intelli_extend); // 智能扩量
             }
         }
-        if (Check.isNull(unitJson.getJSONObject("behavior_interest"))) {
-            // TODO 只是单独结构体 后续需要优化
-            target.put("behavior_interest", unitJson.getJSONObject("behavior_interest")); // 智能扩量
+        //-------------兴趣行为定向
+        JSONObject behaviorInterest = new JSONObject();
+        JSONObject behavior = new JSONObject();
+        JSONObject interest = new JSONObject();
+        if (!Check.isNull(unitJson.getJSONArray("keyword"))) {
+            behavior.put("keyword", unitJson.getJSONArray("keyword"));
+        }
+        if (!Check.isNull(unitJson.getJSONArray("label"))) {
+            behavior.put("label", unitJson.getJSONArray("label"));
+        }
+        if (!Check.isNull(unitJson.getInteger("strengthType"))) {
+            behavior.put("strength_type", unitJson.getInteger("strengthType"));
+        }
+        if (!Check.isNull(unitJson.getInteger("timeType"))) {
+            behavior.put("time_type", unitJson.getInteger("timeType"));
+        }
+        if (!Check.isNull(unitJson.getJSONArray("sceneType"))) {
+            behavior.put("scene_type", unitJson.getJSONArray("sceneType"));
+        }
+        if (!Check.isNull(unitJson.getJSONArray("interestLabel"))) {
+            interest.put("label", unitJson.getJSONArray("interestLabel"));
+        }
+        if (!Check.isNull(behavior)) {
+            behaviorInterest.put("behavior", behavior);
+        }
+        if (!Check.isNull(interest)) {
+            behaviorInterest.put("interest", interest);
+        }
+        if (!Check.isNull(behaviorInterest)) {
+            target.put("behavior_interest", behaviorInterest);
         }
         return target;
     }

+ 12 - 10
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouDirectionalPackageServiceImpl.java

@@ -159,9 +159,9 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
                 if (Check.isNullMap(unionJson)) {
                     throw new Exception("根据定向模板未获取到相关信息");
                 }
-                unitJson.put("target", unionJson);
+                unitJson.put("target", unionJson.getJSONObject("target"));
             }
-            JSONObject jsonObject = updateService.updateUnit(token.getAccessToken(), unitJson);
+            updateService.updateUnit(token.getAccessToken(), unitJson);
         } catch (Exception e) {
             log.error("修改广告组定向异常", e);
             e.printStackTrace();
@@ -275,9 +275,6 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
                     targetJson.put("intelli_extend", intelliExtendJson);
                 }
             }
-            if (!Check.isNull(targetJson)) {
-                param.put("target", targetJson);
-            }
             JSONObject behaviorInterest = new JSONObject();
             JSONObject behavior = new JSONObject();
             JSONObject interest = new JSONObject();
@@ -306,7 +303,10 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
                 behaviorInterest.put("interest", interest);
             }
             if (!Check.isNull(behaviorInterest)) {
-                param.put("behavior_interest", behaviorInterest);
+                targetJson.put("behavior_interest", behaviorInterest);
+            }
+            if (!Check.isNull(targetJson)) {
+                param.put("target", targetJson);
             }
             Map<String, String> headers = new HashMap<String, String>();
             headers.put("Access-Token", oauthToken.getAccessToken());
@@ -318,6 +318,8 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
                     kuaishouTemplateService.getTemplateByAccountId(accountId, oauthToken.getAccessToken(), 1);
+                }else{
+                    log.error("修改账户定向失败,"+resultJson.getString("message"));
                 }
             }
         } catch (Exception e) {
@@ -470,9 +472,6 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
                     targetJson.put("intelli_extend", intelliExtendJson);
                 }
             }
-            if (!Check.isNull(targetJson)) {
-                param.put("target", targetJson);
-            }
             //-------------兴趣行为定向
             JSONObject behaviorInterest = new JSONObject();
             JSONObject behavior = new JSONObject();
@@ -502,7 +501,10 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
                 behaviorInterest.put("interest", interest);
             }
             if (!Check.isNull(behaviorInterest)) {
-                param.put("behavior_interest", behaviorInterest);
+                targetJson.put("behavior_interest", behaviorInterest);
+            }
+            if (!Check.isNull(targetJson)) {
+                param.put("target", targetJson);
             }
             Map<String, String> headers = new HashMap<String, String>();
             headers.put("Access-Token", oauthToken.getAccessToken());

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/DingPanController.java

@@ -157,7 +157,7 @@ public class DingPanController {
                 if (Check.isNullMap(unionJson)) {
                     throw new Exception("根据定向模板未获取到相关信息");
                 }
-                unitJson.put("target", unionJson);
+                unitJson.put("target", unionJson.getJSONObject("target"));
             }
             JSONObject jsonObject = updateService.updateUnit(token.getAccessToken(), unitJson);
             Integer code = jsonObject.getInteger("code");

+ 16 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupTargetMapper.xml

@@ -31,7 +31,13 @@
         is_open,
         no_age_break,
         no_gender_break,
-        no_area_break
+        no_area_break,
+        keyword,
+        label,
+        interest_label,
+        time_type,
+        strength_type,
+        scene_type
         )
         values
         <foreach collection="targets" item="targets" separator=",">
@@ -62,7 +68,13 @@
             #{targets.isOpen},
             #{targets.noAgeBreak},
             #{targets.noGenderBreak},
-            #{targets.noAreaBreak}
+            #{targets.noAreaBreak},
+            #{targets.keyword},
+            #{targets.label},
+            #{targets.interestLabel},
+            #{targets.timeType},
+            #{targets.strengthType},
+            #{targets.sceneType}
             )
         </foreach>
     </insert>
@@ -77,10 +89,9 @@
 
 
     <select id="queryTargetInfoByunitId" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTarget">
-        SELECT
-        *
+        SELECT *
         FROM ctop_kuaishou_group_target
         WHERE account_id = #{accountId}
-         AND unit_id = #{unitId}
+          AND unit_id = #{unitId}
     </select>
 </mapper>

+ 12 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouTemplateTargetMapper.xml

@@ -33,6 +33,12 @@
         no_age_break,
         no_gender_break,
         no_area_break,
+        keyword,
+        label,
+        interest_label,
+        time_type,
+        strength_type,
+        scene_type,
         create_time,
         update_time)
         values
@@ -67,6 +73,12 @@
             #{templateTarget.noAgeBreak},
             #{templateTarget.noGenderBreak},
             #{templateTarget.noAreaBreak},
+            #{templateTarget.keyword},
+            #{templateTarget.label},
+            #{templateTarget.interestLabel},
+            #{templateTarget.timeType},
+            #{templateTarget.strengthType},
+            #{templateTarget.sceneType},
             #{templateTarget.createTime},
             #{templateTarget.updateTime}
             )

+ 28 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java

@@ -548,6 +548,34 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
                             groupTarget.setNoAreaBreak(intelliExtend.getInteger("no_area_break"));
 
                         }
+                        //行为兴趣定向
+                        JSONObject behaviorInterest = targetJson.getJSONObject("behavior_interest");
+                        if (!Check.isNull(behaviorInterest)) {
+                            JSONObject behavior = behaviorInterest.getJSONObject("behavior");
+                            if (!Check.isNull(behavior)) {
+                                if (!Check.isNull(behavior.getJSONArray("keyword"))) {
+                                    groupTarget.setKeyword(JSONObject.toJSONString(behavior.getJSONArray("keyword")));
+                                }
+                                if (!Check.isNull(behavior.getString("label"))) {
+                                    groupTarget.setLabel(behavior.getString("label"));
+                                }
+                                if (!Check.isNull(behavior.getInteger("time_type"))) {
+                                    groupTarget.setTimeType(behavior.getInteger("time_type"));
+                                }
+                                if (!Check.isNull(behavior.getInteger("strength_type"))) {
+                                    groupTarget.setStrengthType(behavior.getInteger("strength_type"));
+                                }
+                                if (!Check.isNull(behavior.getString("scene_type"))) {
+                                    groupTarget.setSceneType(behavior.getString("scene_type"));
+                                }
+                            }
+                            JSONObject interest = behaviorInterest.getJSONObject("interest");
+                            if (!Check.isNull(interest)) {
+                                if (!Check.isNull(interest.getString("label"))) {
+                                    groupTarget.setInterestLabel(interest.getString("label"));
+                                }
+                            }
+                        }
                         targets.add(groupTarget);
                     }
                 }

+ 28 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateServiceImpl.java

@@ -177,7 +177,34 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
                                 templateTarget.setNoAreaBreak(intelliExtendJson.getInteger("no_area_break"));
                             }
                         }
-
+                        //行为兴趣定向
+                        JSONObject behaviorInterest = targetJson.getJSONObject("behavior_interest");
+                        if (!Check.isNull(behaviorInterest)) {
+                            JSONObject behavior = behaviorInterest.getJSONObject("behavior");
+                            if (!Check.isNull(behavior)) {
+                                if (!Check.isNull(behavior.getJSONArray("keyword"))) {
+                                    templateTarget.setKeyword(JSONObject.toJSONString(behavior.getJSONArray("keyword")));
+                                }
+                                if (!Check.isNull(behavior.getString("label"))) {
+                                    templateTarget.setLabel(behavior.getString("label"));
+                                }
+                                if (!Check.isNull(behavior.getInteger("time_type"))) {
+                                    templateTarget.setTimeType(behavior.getInteger("time_type"));
+                                }
+                                if (!Check.isNull(behavior.getInteger("strength_type"))) {
+                                    templateTarget.setStrengthType(behavior.getInteger("strength_type"));
+                                }
+                                if (!Check.isNull(behavior.getString("scene_type"))) {
+                                    templateTarget.setSceneType(behavior.getString("scene_type"));
+                                }
+                            }
+                            JSONObject interest = behaviorInterest.getJSONObject("interest");
+                            if (!Check.isNull(interest)) {
+                                if (!Check.isNull(interest.getString("label"))) {
+                                    templateTarget.setInterestLabel(interest.getString("label"));
+                                }
+                            }
+                        }
 
                         templateTarget.setCreateTime(jsonObject.getDate("create_time"));
                         templateTarget.setUpdateTime(jsonObject.getDate("updateTime"));