yumeng 2 هفته پیش
والد
کامیت
65eb9a3b3d

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/BytedanceProjectMapper.java

@@ -36,4 +36,6 @@ public interface BytedanceProjectMapper {
     void addLog(@Param("accountId") Long accountId, @Param("projectId") Long projectId, @Param("projectStatus") String projectStatus);
 
     List<JSONObject> getLeaderByAccountId(@Param("accountId") Long accountId);
+
+    JSONObject getAccountInfo(@Param("accountId") Long accountId);
 }

+ 9 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/BytedanceProjectMapper.xml

@@ -200,6 +200,15 @@
                   LIMIT 1))) t
         group by t.wexin_id
     </select>
+    <select id="getAccountInfo" resultType="com.alibaba.fastjson.JSONObject">
+        select t1.user_name as 'userName', t2.project_name as 'projectName'
+        from `jeecg-boot`.ctop_user_allocation t1
+                 left join `jeecg-boot`.ctop_project t2
+                           on t1.project_id = t2.id
+        where t1.account_id = #{accountId}
+          and t1.account_status = 0
+
+    </select>
 
 
 </mapper>

+ 1 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/IBytedanceProjectService.java

@@ -9,8 +9,7 @@ import java.util.Map;
  * 获取项目列表
  */
 public interface IBytedanceProjectService {
-    void updProjectStatus(String token, Long accountId, Long projectId, String disable);
-
+    String updProjectStatus(String token, Long accountId, Long projectId, String disable);
 
     String getTokenByAccountId(Long advertiserId);
 

+ 27 - 13
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/BytedanceProjectServiceImpl.java

@@ -100,12 +100,20 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
             log.info("此账户已进行授权失效通知,此次通知跳过。accountId:{}", accountId);
             return;
         }
+
+        JSONObject accountInfo = projectListMapper.getAccountInfo(accountId);
+        if (Check.isNull(accountInfo)) {
+            log.info("此账户未授权或暂停投放,此次通知跳过。accountId:{}", accountId);
+            return;
+        }
+
+        String userName = accountInfo.getString("userName");
+        String projectName = accountInfo.getString("projectName");
         StringBuilder text = new StringBuilder();
-        text.append("您的账户ID:");
-        text.append(accountId);
-        text.append("<br/>");
-        text.append("当前授权已失效,无法进行预警和拉取投放数据。");
-        text.append("<br/>");
+        text.append("您的账户ID:").append(accountId).append("<br/>");
+        text.append("所属项目:").append(projectName).append("<br/>");
+        text.append("所属运营:").append(userName).append("<br/>");
+        text.append("当前授权已失效,无法进行预警和拉取投放数据。").append("<br/>");
         text.append("请及时前往有腾重新进行授权!");
         List<JSONObject> list = projectListMapper.getLeaderByAccountId(accountId);
         for (JSONObject object : list) {
@@ -263,18 +271,18 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
                 }
             }
 
-
+            String status = null;
             if (!typeFalg || !bidFalg) {
-                this.updProjectStatus(token, accountId, projectId, "DISABLE");
+                status = this.updProjectStatus(token, accountId, projectId, "DISABLE");
             }
 
             if (!typeFalg) { // 出价方式设置非法
-                String text = getProjectBidTypeText(json.getString("projectName"), accountId, projectId, projectName, null, null, msgType.toString());
+                String text = getProjectBidTypeText(json.getString("projectName"), accountId, projectId, projectName, null, null, msgType.toString(), status);
                 sendMsg(accountId, text);
             }
 
             if (!bidFalg) {
-                String text = getProjectOverBidMessage(json.getString("projectName"), accountId, projectId, projectName, null, null, msgBid.toString());
+                String text = getProjectOverBidMessage(json.getString("projectName"), accountId, projectId, projectName, null, null, msgBid.toString(), status);
                 sendMsg(accountId, text);
             }
         }
@@ -344,7 +352,7 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
 
 
     @Override
-    public synchronized void updProjectStatus(String token, Long accountId, Long projectId, String disable) {
+    public synchronized String updProjectStatus(String token, Long accountId, Long projectId, String disable) {
         JSONObject params = new JSONObject();
         params.put("advertiser_id", accountId);
         JSONObject data = new JSONObject();
@@ -361,12 +369,13 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
                 String redisKey = "warning_" + accountId + "_" + projectId;
                 redisUtil.set(redisKey, projectId, 10 * 60);
                 projectListMapper.addLog(accountId, projectId, "stop");
+                return "关停成功";
             } else {
                 log.error("预警关停计划失败,accountId:{},projectId:{}, result:{}", accountId, projectId, object);
             }
         }
 
-        System.err.println(object);
+        return "关停失败";
     }
 
 
@@ -394,7 +403,7 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
 
 
     //转化方式错误消息生成
-    private String getProjectBidTypeText(String projectName, Long advertiserId, Long unitId, String unit_name, Long adId, String adName, String msgType) {
+    private String getProjectBidTypeText(String projectName, Long advertiserId, Long unitId, String unit_name, Long adId, String adName, String msgType, String status) {
         StringBuilder text = new StringBuilder();
         text.append("出价方式错误预警").append("<br/>")
                 .append("您本地的项目:").append(projectName).append("<br/>")
@@ -404,12 +413,13 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
         if (!Check.isNull(adId)) {
             text.append("广告id:").append(adId).append("<br/>").append("广告名称:").append(adName).append("<br/>");
         }
+        text.append("关停项目说明:").append(status).append("<br/>");
         text.append("错误说明:").append("<br/>").append(msgType).append("<br/>").append("请您及时查看并处理!");
         return text.toString();
     }
 
     //出价过高预警消息生成
-    private String getProjectOverBidMessage(String projectName, Long accountId, Long planId, String planName, Long adId, String adName, String msgBid) {
+    private String getProjectOverBidMessage(String projectName, Long accountId, Long planId, String planName, Long adId, String adName, String msgBid, String status) {
         StringBuilder text = new StringBuilder();
         text.append("出价过高预警").append("<br/>")
                 .append("您本地的项目:").append(projectName).append("<br/>")
@@ -422,7 +432,11 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
         if (!msgBid.contains("出价为空")) {
             text.append("出价过高说明:").append("<br/>");
         }
+        text.append("关停项目说明:").append(status).append("<br/>");
         text.append(msgBid).append("<br/>").append("请您及时查看并处理!");
+
         return text.toString();
     }
+
+
 }

+ 5 - 6
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedancePushDataController.java

@@ -91,22 +91,21 @@ public class BytedancePushDataController {
     @ResponseBody
     public void test(HttpServletRequest request, @RequestParam(value = "challenge", defaultValue = "0") int challenge, @RequestParam(value = "event", defaultValue = "") String event, @RequestParam(value = "appId", defaultValue = "") String appId) throws IOException {
 
-        bytedanceProjectService.sendAuthFailure(1847120413784843L);
-       /* String token = bytedanceProjectService.getTokenByAccountId(1832252227629066L);
+     //   bytedanceProjectService.sendAuthFailure(1847120413784843L);
+        String token = bytedanceProjectService.getTokenByAccountId(1842948124549184L);
 
         List<Long> list = new ArrayList<>();
-        list.add(7566848606024794138L);
-        list.add(7566848458911367211L);
+        list.add(7570918730826416178L);
+      //  list.add(7566848458911367211L);
 
 
         Map<Long, JSONObject> projectMap = new HashMap<>();
         List<List<Long>> partitions = Lists.partition(list, 20);
         for (int i = 0; i < partitions.size(); i++) {
             List<Long> ids = partitions.get(i);
-            bytedanceProjectService.getPromotionList(1832252227629066L, token, ids, projectMap, 1);
+            bytedanceProjectService.getPromotionList(1842948124549184L, token, ids, projectMap, 1);
 
         }
-*/
     }