Bläddra i källkod

优化人群包编辑逻辑

zhaoxian 4 år sedan
förälder
incheckning
8e9e8be23e

+ 4 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPckageRelMapper.java

@@ -19,11 +19,13 @@ public interface KuaishouDirectionalPckageRelMapper extends BaseMapper<KuaishouD
 
 
     void replace(KuaishouDirectionalaPckageRel rel);
     void replace(KuaishouDirectionalaPckageRel rel);
 
 
-    List<JSONObject> queryPushResults(@Param("id") String id, @Param("accountIds") JSONArray accountIds,@Param("status") String status);
+    List<JSONObject> queryPushResults(@Param("id") String id, @Param("accountIds") JSONArray accountIds, @Param("status") String status);
 
 
     List<JSONObject> getAccountByProjectId(@Param("projectId") Long projectId, @Param("id") String id);
     List<JSONObject> getAccountByProjectId(@Param("projectId") Long projectId, @Param("id") String id);
 
 
     List<JSONObject> queryRelId(@Param("projectId") Long projectId, @Param("id") String id, @Param("type") String type);
     List<JSONObject> queryRelId(@Param("projectId") Long projectId, @Param("id") String id, @Param("type") String type);
 
 
-    List<JSONObject> queryUnitIdByAccountId(@Param("id") String id,@Param("accountId")  Long accountId);
+    List<JSONObject> queryUnitIdByAccountId(@Param("id") String id, @Param("accountId") Long accountId);
+
+    void updateTemName(@Param("id") String id, @Param("templateName") String templateName);
 }
 }

+ 27 - 19
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPckageRelMapper.xml

@@ -53,7 +53,7 @@
         where dir_id = #{id}
         where dir_id = #{id}
         AND rel_type = 'account'
         AND rel_type = 'account'
         <if test=" status!=null">
         <if test=" status!=null">
-        AND  t1.data_status = #{status}
+            AND t1.data_status = #{status}
         </if>
         </if>
         <if test="accountIds!=null">
         <if test="accountIds!=null">
             AND rel_id IN
             AND rel_id IN
@@ -65,34 +65,42 @@
     </select>
     </select>
 
 
     <select id="getAccountByProjectId" resultType="com.alibaba.fastjson.JSONObject">
     <select id="getAccountByProjectId" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            t1.account_id as 'accountId',
-            CONCAT(t1.auth_name,'(',t1.account_id,')') as 'authName',
-            IFNULL(t2.data_status,0) as 'state'
-            FROM ctop_user_allocation t1
-                LEFT JOIN (
-                SELECT rel_id,data_status FROM ctop_kuaishou_directional_package_rel
-                WHERE  project_id = #{projectId}
-                  AND rel_type = 'account'
-                  AND dir_id = #{id}
-            ) t2 ON t1.account_id = t2.rel_id
+        SELECT t1.account_id as 'accountId', CONCAT(t1.auth_name, '(', t1.account_id, ')') as 'authName', IFNULL(t2.data_status, 0) as 'state'
+        FROM ctop_user_allocation t1
+                 LEFT JOIN (
+            SELECT rel_id, data_status
+            FROM ctop_kuaishou_directional_package_rel
+            WHERE project_id = #{projectId}
+              AND rel_type = 'account'
+              AND dir_id = #{id}
+        ) t2 ON t1.account_id = t2.rel_id
         where t1.account_status = 0
         where t1.account_status = 0
           AND t1.project_id = #{projectId}
           AND t1.project_id = #{projectId}
     </select>
     </select>
 
 
     <select id="queryRelId" resultType="com.alibaba.fastjson.JSONObject">
     <select id="queryRelId" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT rel_id,template_id FROM ctop_kuaishou_directional_package_rel
-        WHERE  project_id = #{projectId}
+        SELECT rel_id, template_id
+        FROM ctop_kuaishou_directional_package_rel
+        WHERE project_id = #{projectId}
           AND rel_type = #{type}
           AND rel_type = #{type}
           AND dir_id = #{id}
           AND dir_id = #{id}
     </select>
     </select>
 
 
     <select id="queryUnitIdByAccountId" resultType="com.alibaba.fastjson.JSONObject">
     <select id="queryUnitIdByAccountId" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT rel_id,template_id FROM(
-       SELECT DISTINCT unit_id FROM ctop_kuaishou_group
-       where account_id = #{accountId} ) t1
-       INNER JOIN ctop_kuaishou_directional_package_rel t2 ON t1.unit_id = t2.rel_id
-        WHERE t2.rel_type = 'unit' AND t2.dir_id = #{id}
+        SELECT rel_id, template_id
+        FROM (
+                 SELECT DISTINCT unit_id
+                 FROM ctop_kuaishou_group
+                 where account_id = #{accountId}) t1
+                 INNER JOIN ctop_kuaishou_directional_package_rel t2 ON t1.unit_id = t2.rel_id
+        WHERE t2.rel_type = 'unit'
+          AND t2.dir_id = #{id}
     </select>
     </select>
 
 
+    <update id="updateTemName">
+        update
+            ctop_kuaishou_directional_package_rel
+        set template_name = #{templateName}
+        where dir_id = #{id}
+    </update>
 </mapper>
 </mapper>

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

@@ -133,6 +133,9 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
             };
             };
             thread.start();
             thread.start();
         }
         }
+        if (!entity.getTemplateName().equals(kuaishouDirectionalPackage.getTemplateName())) {
+            relMapper.updateTemName(entity.getId(), kuaishouDirectionalPackage.getTemplateName());
+        }
         return Result.ok("该项目下定向包已做同步修改");
         return Result.ok("该项目下定向包已做同步修改");
     }
     }