yumeng hai 1 semana
pai
achega
39d8612307

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

@@ -31,7 +31,7 @@ public interface BytedanceProjectMapper {
 
     List<JSONObject> getBytedanceOcpxTypeList();
 
-    String getTokenByAccountId(@Param("advertiserId") Long advertiserId);
+    JSONObject getTokenByAccountId(@Param("advertiserId") Long advertiserId);
 
     void addLog(@Param("accountId") Long accountId, @Param("projectId") Long projectId, @Param("projectStatus") String projectStatus);
 

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

@@ -176,10 +176,11 @@
         select ocpx_action_type as 'ocpxActionType', ocpx_action_name as 'ocpxActionName'
         from `jeecg-boot`.ctop_bytedance_ocpx_action_type_config
     </select>
-    <select id="getTokenByAccountId" resultType="java.lang.String">
-        select access_token
-        from `jeecg-boot`.ctop_oauth_token
-        where account_id = #{advertiserId} limit 1
+    <select id="getTokenByAccountId" resultType="com.alibaba.fastjson.JSONObject">
+        select t1.access_token as 'accessToken', t2.account_status as 'accountStatus'
+        from `jeecg-boot`.ctop_oauth_token t1
+                 left join `jeecg-boot`.ctop_user_allocation t2 on t1.account_id = t2.account_id
+        where t1.account_id = #{advertiserId} limit 1
 
     </select>
     <select id="getLeaderByAccountId" resultType="com.alibaba.fastjson.JSONObject">

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

@@ -11,7 +11,7 @@ import java.util.Map;
 public interface IBytedanceProjectService {
     String updProjectStatus(String token, Long accountId, Long projectId, String disable);
 
-    String getTokenByAccountId(Long advertiserId);
+    JSONObject getTokenByAccountId(Long advertiserId);
 
     void getPromotionList(Long accountId, String token, List<Long> ids, Map<Long, JSONObject> projectMap, int page);
 

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

@@ -169,7 +169,6 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
 
 
         for (JSONObject promotionJson : promotionList) {
-
             //广告项目ID
             Long projectId = promotionJson.getLong("projectId");
             String redisKey = "warning_" + accountId + "_" + projectId;
@@ -178,9 +177,21 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
                 log.info("该账户:{},下的项目ID:{},在10分钟内已经执行过预警,此次预警跳过", accountId, projectId);
                 continue;
             }
+
+
             BigDecimal cpaBid = promotionJson.getBigDecimal("cpaBid");
             BigDecimal deepCpabid = promotionJson.getBigDecimal("deepCpabid");
             JSONObject projectJson = projectInfo.get(projectId);
+            String optStatus = projectJson.getString("optStatus");
+            if (!Check.isNull(optStatus)) {
+                if ("DISABLE".equals(optStatus)) {
+                    log.info("项目状态为暂停中,此次预警跳过,accountId:{},projectId:{}", accountId, projectId);
+                    continue;
+                }
+
+            }
+
+
             if (Check.isNull(cpaBid)) {
                 if (!Check.isNull(projectJson.getBigDecimal("cpaBid"))) {
                     cpaBid = projectJson.getBigDecimal("cpaBid");
@@ -341,6 +352,8 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
                 String cpaBid = dataObject.getJSONObject("delivery_setting").getString("cpa_bid");
                 mapJson.put("cpaBid", cpaBid);
                 mapJson.put("bidType", bidType);
+                String optStatus = dataObject.getString("opt_status");
+                mapJson.put("optStatus", optStatus);
                 returnMap.put(projectId, mapJson);
             }
 
@@ -380,7 +393,7 @@ public class BytedanceProjectServiceImpl implements IBytedanceProjectService {
 
 
     @Override
-    public String getTokenByAccountId(Long advertiserId) {
+    public JSONObject getTokenByAccountId(Long advertiserId) {
         return projectListMapper.getTokenByAccountId(advertiserId);
     }
 

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

@@ -70,10 +70,19 @@ public class BytedancePushDataController {
                         projectExecutorService.submit(new Runnable() {
                             @Override
                             public void run() {
-                                String token = bytedanceProjectService.getTokenByAccountId(advertiserId);
-                                if (!Check.isNull(token)) {
+                                JSONObject tokenJson = bytedanceProjectService.getTokenByAccountId(advertiserId);
+                                if (!Check.isNull(tokenJson)) {
                                     Map<Long, JSONObject> projectMap = new HashMap<>();
-                                    bytedanceProjectService.getPromotionList(advertiserId, token, ids, projectMap, 1);
+                                    String accessToken = tokenJson.getString("accessToken");
+                                    Integer accountStatus = tokenJson.getInteger("accountStatus");
+                                    if (!Check.isNull(accountStatus)) {
+                                        if (accountStatus == 0) {
+                                            bytedanceProjectService.getPromotionList(advertiserId, accessToken, ids, projectMap, 1);
+                                        }
+
+                                    }
+
+
                                 }
                             }
                         });
@@ -91,19 +100,19 @@ 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(1842948124549184L);
+        //   bytedanceProjectService.sendAuthFailure(1847120413784843L);
+        JSONObject token = bytedanceProjectService.getTokenByAccountId(1842948124549184L);
 
         List<Long> list = new ArrayList<>();
         list.add(7570918730826416178L);
-      //  list.add(7566848458911367211L);
+        //  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(1842948124549184L, token, ids, projectMap, 1);
+            bytedanceProjectService.getPromotionList(1842948124549184L, token.getString("accessToken"), ids, projectMap, 1);
 
         }
     }