Bläddra i källkod

获取罗盘绑定广告主(ps:jeecg-boot.compass_bind_advertisers)

zhaoxian 9 månader sedan
förälder
incheckning
accb3689e3

+ 3 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/constant/KuaishouConstant.java

@@ -57,5 +57,8 @@ public class KuaishouConstant {
     //代理商获取广告主列表接口
     //代理商获取广告主列表接口
     public static final String AGENT_ACCOUNT_LIST = "/rest/openapi/gw/agent/v1/account/list";
     public static final String AGENT_ACCOUNT_LIST = "/rest/openapi/gw/agent/v1/account/list";
 
 
+      //获取罗盘绑定广告主列
+    public static final String GW_UC_V1_ADVERTISERS = "/rest/openapi/gw/uc/v1/advertisers";
+
 
 
 }
 }

+ 4 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/mapper/KuaishouAccountReportDailyMapper.java

@@ -4,6 +4,8 @@ import cn.com.ctop.job.kuaishou.data.entity.KuaishouAccountReportDaily;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouEffectNativeChartreportConversionChart;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouEffectNativeChartreportConversionChart;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouEffectNativeChartreportFunnel;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouEffectNativeChartreportFunnel;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouEffectNativeChartreportSummary;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouEffectNativeChartreportSummary;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
@@ -24,4 +26,6 @@ public interface KuaishouAccountReportDailyMapper extends BaseMapper<KuaishouAcc
     void replaceBatchFunnel(@Param("funList") List<KuaishouEffectNativeChartreportFunnel> funList);
     void replaceBatchFunnel(@Param("funList") List<KuaishouEffectNativeChartreportFunnel> funList);
 
 
     void replaceBatchConversionChart(@Param("chatList") List<KuaishouEffectNativeChartreportConversionChart> chatList);
     void replaceBatchConversionChart(@Param("chatList") List<KuaishouEffectNativeChartreportConversionChart> chatList);
+
+    void replaceBatchAdvertisers(@Param("details") JSONArray lists);
 }
 }

+ 2 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/mapper/OauthTokenMapper.java

@@ -26,4 +26,6 @@ public interface OauthTokenMapper extends BaseMapper<OauthToken> {
     List<JSONObject> getKuaishouOcpxTypeList();
     List<JSONObject> getKuaishouOcpxTypeList();
 
 
     List<JSONObject> getAgentTokens();
     List<JSONObject> getAgentTokens();
+
+    String getOuthTokenAccountId(@Param("accountId") Long accountId);
 }
 }

+ 16 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/mapper/xml/KuaishouAccountReportDailyMapper.xml

@@ -574,4 +574,20 @@
     </insert>
     </insert>
 
 
 
 
+    <insert id="replaceBatchAdvertisers">
+        replace into `jeecg-boot`.compass_bind_advertisers(
+        advertiser_id,
+        advertiser_name,
+        corporation_name
+        )
+        values
+        <foreach collection="details" item="data" separator=",">
+            (
+            #{data.advertiser_id},
+            #{data.advertiser_name},
+            #{data.corporation_name}
+            )
+        </foreach>
+    </insert>
+
 </mapper>
 </mapper>

+ 7 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/mapper/xml/OauthTokenMapper.xml

@@ -16,6 +16,13 @@
         WHERE t1.account_id = #{accountId}
         WHERE t1.account_id = #{accountId}
     </select>
     </select>
 
 
+    <select id="getOuthTokenAccountId" resultType="java.lang.String">
+        SELECT access_token
+        FROM `jeecg-boot`.ctop_oauth_token
+        WHERE account_id = #{accountId}
+        limit 1
+    </select>
+
 
 
     <select id="getByProjectId" resultType="com.alibaba.fastjson.JSONObject">
     <select id="getByProjectId" resultType="com.alibaba.fastjson.JSONObject">
         select t1.access_token as 'accessToken',t1.account_id as 'accountId',t1.access_token_expires_in as 'accessTokenExpiresIn'
         select t1.access_token as 'accessToken',t1.account_id as 'accountId',t1.access_token_expires_in as 'accessTokenExpiresIn'

+ 2 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/IKuaishouAccountReportDailyService.java

@@ -20,4 +20,6 @@ public interface IKuaishouAccountReportDailyService extends IService<KuaishouAcc
     void liveComponentReport(Long accountId, String token, String beginDate, String endDate);
     void liveComponentReport(Long accountId, String token, String beginDate, String endDate);
 
 
     void liveUserReport(Long accountId, String token, String beginDate, String endDate);
     void liveUserReport(Long accountId, String token, String beginDate, String endDate);
+
+    void openapiGwUcV1Advertisers(Long advertiserId, String token);
 }
 }

+ 2 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/IOauthTokenService.java

@@ -23,4 +23,6 @@ public interface IOauthTokenService extends IService<OauthToken> {
   List<JSONObject> selectKuaiShouToken();
   List<JSONObject> selectKuaiShouToken();
 
 
     List<JSONObject> getAgentTokens();
     List<JSONObject> getAgentTokens();
+
+    String getOuthTokenAccountId(Long accountId);
 }
 }

+ 1 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/impl/AdUnitReportServiceImpl.java

@@ -284,7 +284,7 @@ public class AdUnitReportServiceImpl implements IAdUnitReportService {
                         } else if (bidType == 2 && bid > maxBid) {
                         } else if (bidType == 2 && bid > maxBid) {
                             //若优化目标为2点击数,并且广告组出价大于项目设置最大出价,则关停
                             //若优化目标为2点击数,并且广告组出价大于项目设置最大出价,则关停
                             bidFalg = false;
                             bidFalg = false;
-                            msgBid.append("目标优化为点击数,且组出价:").append(bid / 1000).append("大于项目最大出价:").append(maxBid / 1000);
+                            msgBid.append("目标优化为点击数,且组出价:").append(bid).append("大于项目最大出价:").append(maxBid);
                         }
                         }
                     }
                     }
                     //转化目标
                     //转化目标

+ 21 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/impl/KuaishouAccountReportDailyServiceImpl.java

@@ -250,4 +250,25 @@ public class KuaishouAccountReportDailyServiceImpl extends ServiceImpl<KuaishouA
         }
         }
 
 
     }
     }
+
+    @Override
+    public void openapiGwUcV1Advertisers(Long advertiserId, String token) {
+        String url = postUrl + KuaishouConstant.GW_UC_V1_ADVERTISERS;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", token);
+        Map<String, Object> param = new HashMap<>();
+        param.put("advertiser_id", advertiserId);
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        if (null == code || code != 0) {
+            String message = resultJson.getString("message");
+            log.error("获取罗盘绑定广告主列异常:{},advertiserId:{}", message, advertiserId);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (!Check.isNull(details)) {
+            accountReportDailyMapper.replaceBatchAdvertisers(details);
+        }
+    }
 }
 }

+ 5 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/impl/OauthTokenServiceImpl.java

@@ -45,4 +45,9 @@ public class OauthTokenServiceImpl extends ServiceImpl<OauthTokenMapper, OauthTo
     public List<JSONObject> getAgentTokens() {
     public List<JSONObject> getAgentTokens() {
         return tokenMapper.getAgentTokens();
         return tokenMapper.getAgentTokens();
     }
     }
+
+  @Override
+  public String getOuthTokenAccountId(Long accountId) {
+    return tokenMapper.getOuthTokenAccountId(accountId);
+  }
 }
 }

+ 15 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/AccountReportlJob.java

@@ -189,4 +189,19 @@ public class AccountReportlJob {
                     }
                     }
                 });
                 });
     }
     }
+
+    /**
+     * 获取罗盘绑定广告主列
+     * 当前快手ID,账户ID 固定写死
+     */
+
+    @XxlJob("openapiGwUcV1Advertisers")
+    public void openapiGwUcV1Advertisers() throws Exception {
+        //罗盘账户的「快手 id」,只能传递授权时使用的快手 id
+        Long advertiserId = 4361966075L;
+        String token = tokenService.getOuthTokenAccountId(39526067L);
+        kuaishouAccountReportDailyService.openapiGwUcV1Advertisers(advertiserId, token);
+        log.info("------【获取罗盘绑定广告主列】执行完成");
+
+    }
 }
 }