yumeng hace 3 años
padre
commit
9d27f2f802

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 240 - 204
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java


+ 4 - 8
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -42,6 +42,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
 import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
@@ -104,18 +105,13 @@ public class SampleTest {
     private ISendMessageService sendMessageService;
     @Autowired
     private IKuaishouProgramCreativeService kuaishouProgramCreativeService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
 
 
     @Test
     public void loadKuaishouCookie() throws ParseException {
-      /*  CtopOauthToken oauthToken = tokenService.getTokenByAccountId(10571378L);
-        ruleKuaiShouPlanService.cleanRuleDataTarget(10571378L, oauthToken.getAccessToken(), 1);*/
-
-     //   sendMessageService.sendMessage("eb003a809ff44ee6bd1d9be5384ef4b8","测试发送消息");
-        CtopOauthToken oauthToken = tokenService.getTokenByAccountId(10838846L);
-        kuaishouProgramCreativeService.getProgramCreative(oauthToken.getAccountId(),  536025521L, oauthToken.getAccessToken(), null, null, 1);
-
-        //   iKuaishouInterfaceService.getVideoList(oauthToken,null,null);
+        sendMessageService.sendMessage("d2331a00e1be42ec8542167e321eeb01","测试消息");
     }
 
 

+ 3 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCreativeMapper.java

@@ -40,4 +40,7 @@ public interface KuaiShouCreativeMapper extends BaseMapper<KuaiShouCreative> {
     List<JSONObject> queryCreativeByPhotoId(@Param("photoId") String photoId);
 
     List<JSONObject> queryCreativeByPhotoIds(@Param("photoIds") List<String> photoIds, @Param("accountId") Long accountId);
+
+
+    List<Long> getCreativeList(@Param("accountId") Long accountId,@Param("unitId") Long unitId);
 }

+ 14 - 10
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml

@@ -172,7 +172,7 @@
 
     <select id="queryCreativeByPhotoIdTotal" resultType="java.lang.Long">
         SELECT
-            IFNULL(COUNT(1),0)
+        IFNULL(COUNT(1),0)
         FROM ctop_kuaishou_creative t1
         WHERE t1.photo_id in
         <foreach collection="photoIds" item="item" separator=","
@@ -180,7 +180,7 @@
             #{item}
         </foreach>
         <if test="accountId!=null">
-            and  t1.account_id = #{accountId}
+            and t1.account_id = #{accountId}
         </if>
         and t1.status = 42
     </select>
@@ -202,13 +202,13 @@
 
     <select id="queryCreativeByPhotoIds" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-            IFNULL(t2.auth_name,'') 'authName',
-            IFNULL(t1.account_id,'') 'accountId',
-            IFNULL(t1.creative_id,'') 'creativeId',
-            IFNULL(t1.creative_name,'') 'creativeName',
-            IFNULL(t1.cover_url,'') 'coverUrl',
-            IFNULL(t1.description,'') 'description',
-            IFNULL(t1.review_detail,'') 'reviewDetail'
+        IFNULL(t2.auth_name,'') 'authName',
+        IFNULL(t1.account_id,'') 'accountId',
+        IFNULL(t1.creative_id,'') 'creativeId',
+        IFNULL(t1.creative_name,'') 'creativeName',
+        IFNULL(t1.cover_url,'') 'coverUrl',
+        IFNULL(t1.description,'') 'description',
+        IFNULL(t1.review_detail,'') 'reviewDetail'
         FROM ctop_kuaishou_creative t1
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         WHERE t1.photo_id in
@@ -217,8 +217,12 @@
             #{item}
         </foreach>
         <if test="accountId!=null">
-            and  t1.account_id = #{accountId}
+            and t1.account_id = #{accountId}
         </if>
         and t1.status = 42
     </select>
+    <select id="getCreativeList" resultType="java.lang.Long">
+        select  creative_id  from  ctop_kuaishou_creative where  account_id = #{accountId}
+        and unit_id = #{unitId}
+    </select>
 </mapper>

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCreativeService.java

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -74,4 +75,8 @@ public interface IKuaiShouCreativeService extends IService<KuaiShouCreative> {
 
 
     void getProgramCreative(CtopOauthToken oauthToken, int page);
+
+    List<Long> getCreativeList(Long accountId, Long unitId);
+
+    JSONObject batchUpdateCreative(JSONObject json, CtopOauthToken oauthToken);
 }

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

@@ -2045,6 +2045,8 @@ public class BatchServiceImpl implements IBatchService {
     }
 
 
+
+
     /**
      * 获取联盟白名单
      *

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

@@ -379,5 +379,42 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
 
     }
 
+    @Override
+    public List<Long> getCreativeList(Long accountId, Long unitId) {
+        return kuaiShouCreativeMapper.getCreativeList(accountId, unitId);
+    }
+
+    @Override
+    public JSONObject batchUpdateCreative(JSONObject json, CtopOauthToken token) {
+        String url = "https://ad.e.kuaishou.com/rest/openapi/v2/creative/batch/update";
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", token.getAccessToken());
+        headers.put("Content-Type", "application/json");
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, json.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        System.err.println("返回信息:" + resultJson);
+        if (!Check.isNull(resultJson)) {
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                JSONObject data = resultJson.getJSONObject("data");
+                if (!Check.isNull(data)) {
+                    Map<String, Object> deleteMap = new HashMap<>();
+                    deleteMap.put("account_id", json.getLong("advertiser_id"));
+                    deleteMap.put("unit_id", json.getLong("unit_id"));
+                    kuaiShouCreativeMapper.deleteByMap(deleteMap);
+                    log.info("修改成功,accountId:{},unitId:{}", json.getLong("advertiser_id"), json.getLong("unit_id"));
+
+                } else {
+                    log.error("返回数据为空,accountId:{},unitId:{}", json.getLong("advertiser_id"), json.getLong("unit_id"));
+
+                }
+
+            } else {
+                log.error("修改失败,accountId:{},unitId:{},message:{}", json.getLong("advertiser_id"), json.getLong("unit_id"), resultJson.getString("message"));
+            }
+        }
+        return null;
+    }
+
 
 }

+ 4 - 8
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java

@@ -695,14 +695,10 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                 if (code == 0) {
                     JSONObject data = resultJson.getJSONObject("data");
                     if (!Check.isNull(data)) {
-
-                        try {
-                            Thread.sleep(200);
-                            interfaceService.getCreativeByCreativeId(accessToken, creativeJson.getLong("advertiser_id"), data.getLong("creative_id"));
-                            createLandPageAndUnit(creativeJson, resultJson.getJSONObject("data"));
-                        } catch (InterruptedException e) {
-                            e.printStackTrace();
-                        }
+                        Map<String, Object> deleteMap = new HashMap<>();
+                        deleteMap.put("account_id", creativeJson.getLong("advertiser_id"));
+                        deleteMap.put("creative_id", creativeJson.getLong("creative_id"));
+                        creativeMapper.deleteByMap(deleteMap);
 
 
                         returnJson.put("code", 0);

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -848,7 +848,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
-
     /**
      * 创建广告计划
      *
@@ -1234,6 +1233,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         if (Check.isNull(details)) {
             return;
         }
+    //    System.err.println(details);
         addGroup(token.getAccountId(), details);
         //   ruleKuaiShouPlanService.insertTarget(token.getAccountId(), details);
         getGroupListByPage(token, startDate, endDate, page + 1);
@@ -1412,7 +1412,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         try {
 
 
-            Thread.sleep(1500);
+            Thread.sleep(1000);
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
             Map<String, String> headers = new HashMap<>();
             headers.put("Content-Type", " application/json");

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

@@ -78,7 +78,6 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
 
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
-        System.err.println(resultJson);
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");
         if (null == code || code != 0) {