소스 검색

头条预警 发送人添加领导

zhaoxian 2 년 전
부모
커밋
dd2699028a

+ 1 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/MonitorBytedanceActionTrackUrlMapper.java

@@ -57,4 +57,5 @@ public interface MonitorBytedanceActionTrackUrlMapper {
      */
     void updAccountActionTrackUrl(MonitorBytedanceAdVo monitorBytedanceAdVo);
 
+    List<JSONObject> getWChatIdsByAccountId(Long accountId);
 }

+ 67 - 52
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/MonitorBytedanceActionTrackUrlMapper.xml

@@ -3,75 +3,90 @@
 <mapper namespace="org.jeecg.modules.bytedance.advertise.mapper.MonitorBytedanceActionTrackUrlMapper">
 
 
-<!-- 获取头条自动配置中的账户 以及 点击监测链接-->
-    <select id="getBytedancStrategyAcctionId" resultType="org.jeecg.modules.bytedance.advertise.vo.MonitorBytedanceAdVo">
+    <!-- 获取头条自动配置中的账户 以及 点击监测链接-->
+    <select id="getBytedancStrategyAcctionId"
+            resultType="org.jeecg.modules.bytedance.advertise.vo.MonitorBytedanceAdVo">
         SELECT
-            stra.account_id accountId,
-            stra.ad_convert_id convertId,
-            stra.creative_action_track_url actionTrackUrl,
-            ua.auth_name accountName,
-            ua.user_id operateUserid,
-            ua.user_name operateUserName
+        stra.account_id accountId,
+        stra.ad_convert_id convertId,
+        stra.creative_action_track_url actionTrackUrl,
+        ua.auth_name accountName,
+        ua.user_id operateUserid,
+        ua.user_name operateUserName
         FROM
-            ctop_ai_bytedance_advertiser_strategy stra
-                LEFT JOIN ctop_user_allocation ua on stra.account_id = ua.account_id
+        ctop_ai_bytedance_advertiser_strategy stra
+        LEFT JOIN ctop_user_allocation ua on stra.account_id = ua.account_id
         WHERE
-            stra.status = 0
+        stra.status = 0
         <if test="accountId !=null and accountId != ''">
             AND stra.account_id = #{accountId}
         </if>
         GROUP BY stra.account_id
         ORDER BY
-            stra.create_time DESC
+        stra.create_time DESC
     </select>
 
 
     <!-- 根据账户id 查询该账户下的计划中的 点击监测链接 -->
-    <select id="getBytedancPlanActionTrackUrl" resultType="org.jeecg.modules.bytedance.advertise.vo.MonitorBytedanceAdVo">
-        SELECT
-            DISTINCT
-            action_track_url actionTrackUrl,
-            id as planId,
-            account_id
-        FROM
-            ctop_bytedance_advertise_plan
+    <select id="getBytedancPlanActionTrackUrl"
+            resultType="org.jeecg.modules.bytedance.advertise.vo.MonitorBytedanceAdVo">
+        SELECT DISTINCT action_track_url actionTrackUrl,
+                        id as            planId,
+                        account_id
+        FROM ctop_bytedance_advertise_plan
         WHERE action_track_url is NOT NULL
-            and opt_status = 'AD_STATUS_ENABLE'
-            and account_id = #{accountId}
-          and DATE_FORMAT(start_time,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d')
+          and opt_status = 'AD_STATUS_ENABLE'
+          and account_id = #{accountId}
+          and DATE_FORMAT(start_time, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
     </select>
 
 
     <!-- 获取用户微信id -->
     <select id="getWChatIdByUserId" resultType="com.alibaba.fastjson.JSONObject">
-        select t1.wexin_id,corp_id
+        select t1.wexin_id, corp_id
         from ctop_corp_wexin_user t1
-                 left join  sys_user t2
-                            on  t1.user_id = t2.id
-        where  t1.user_id = #{userId}
+                 left join sys_user t2
+                           on t1.user_id = t2.id
+        where t1.user_id = #{userId}
           and t2.`status` = 1
 
     </select>
 
 
+    <!-- 获取用户微信id -->
+    <select id="getWChatIdsByAccountId" resultType="com.alibaba.fastjson.JSONObject">
+        select wexin_id, corp_id, wexin_name
+        from ctop_corp_wexin_user
+        where user_id = (select ctop_user_allocation.user_id
+                         from ctop_user_allocation
+                         where account_id = #{accountId} limit 1)
+        union all
+        select wexin_id, corp_id, wexin_name
+        from ctop_corp_wexin_user
+        where user_id = (select leader_id
+                         from sys_user
+                         where id = (SELECT ctop_user_allocation.user_id
+                                     FROM ctop_user_allocation
+                                     WHERE account_id = #{accountId}
+            LIMIT 1))
+        union all
+        select wexin_id, corp_id, wexin_name
+        from ctop_corp_wexin_user
+        where user_id = '461857c245f54ba5813bcb5900a23092';
+    </select>
+
 
     <!-- 新增第三方监测连接 -->
     <insert id="insertAccountTrackUrl">
-        INSERT INTO ctop_ai_bytedance_advertiser_strategy_action_track_url (
-            `account_id`,
-            `action_track_url`,
-            `warning_flag`,
-            `create_user_id`,
-            `create_time`
-        )
-        VALUES
-        ( #{accountId}, #{actionTrackUrl}, 1, #{createUserId}, NOW());
+        INSERT INTO ctop_ai_bytedance_advertiser_strategy_action_track_url (`account_id`,
+                                                                            `action_track_url`,
+                                                                            `warning_flag`,
+                                                                            `create_user_id`,
+                                                                            `create_time`)
+        VALUES (#{accountId}, #{actionTrackUrl}, 1, #{createUserId}, NOW());
     </insert>
 
 
-
-
-
     <!-- 查询 监测链接 -->
     <select id="getAccountActionTrackUrl" resultType="org.jeecg.modules.bytedance.advertise.vo.MonitorBytedanceAdVo">
         SELECT
@@ -89,18 +104,18 @@
         ctop_ai_bytedance_advertiser_strategy_action_track_url u
         LEFT JOIN ctop_user_allocation a on u.account_id = a.account_id
         <where>
-              <if test="accountId !=null and accountId != ''">
-                  AND  u.account_id = #{accountId}
-              </if>
-              <if test="warningFlag !=null and warningFlag != ''">
-                  AND  u.warning_flag = #{warningFlag}
-              </if>
-              <if test="operateUserIds != null and operateUserIds.size > 0">
-                  AND  a.user_id in
-                  <foreach item="userId" index="index" collection="operateUserIds" open="(" separator="," close=")">
-                      #{userId}
-                  </foreach>
-              </if>
+            <if test="accountId !=null and accountId != ''">
+                AND u.account_id = #{accountId}
+            </if>
+            <if test="warningFlag !=null and warningFlag != ''">
+                AND u.warning_flag = #{warningFlag}
+            </if>
+            <if test="operateUserIds != null and operateUserIds.size > 0">
+                AND a.user_id in
+                <foreach item="userId" index="index" collection="operateUserIds" open="(" separator="," close=")">
+                    #{userId}
+                </foreach>
+            </if>
         </where>
     </select>
 
@@ -118,7 +133,7 @@
         <if test="createUserId != null and createUserId !=''">
             create_user_id =#{createUserId},
         </if>
-            update_time = NOW()
+        update_time = NOW()
         WHERE account_id = #{accountId};
     </update>
 

+ 10 - 7
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -446,14 +446,17 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         }
         log.info(">预警<,账户:{}=>计划:{}现已【关停】---> {}", accountId, planId, text);
         try {
-            UserAllocation account = userAllocationService.getByAccountId(accountId);
-            String userId = "";
-            if (!Check.isNull(account)) {
-                userId = account.getUserId();
-                record.setUserId(userId);
+//            UserAllocation account = userAllocationService.getByAccountId(accountId);
+//            String userId = "";
+//            if (!Check.isNull(account)) {
+//                userId = account.getUserId();
+//                record.setUserId(userId);
+//            }
+//            JSONObject jsonObject = monitorBytedanceActionTrackUrlMapper.getWChatIdByUserId(userId);
+            List<JSONObject> list = monitorBytedanceActionTrackUrlMapper.getWChatIdsByAccountId(accountId);
+            for (JSONObject object : list) {
+                corpWexinUtils.sendMessageByWeChatId(object, text);
             }
-            JSONObject jsonObject = monitorBytedanceActionTrackUrlMapper.getWChatIdByUserId(userId);
-            corpWexinUtils.sendMessageByWeChatId(jsonObject, text);
             insertSendRecord(record);
         } catch (Exception e) {
             e.printStackTrace();