Ver Fonte

代理商获取广告主列表接口
event_draw_credit_line kuaishou_account_report_hourly kuaishou_account_report_daily

zhaoxian há 1 ano atrás
pai
commit
f603247be0

+ 13 - 4
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/controller/KuaishouController.java

@@ -165,7 +165,10 @@ public class KuaishouController {
 //        String date = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -4);
 //        for (String s : list) {
 //            unitReportDailyService2.getUnitReportDaily(accountId, token, s, s, 1);
-        adUnitReportService.getAgentReport();
+//        adUnitReportService.getAgentReport();
+        kuaishouAccountReportHourlyService
+                .getAdvertiserReportHour(accountId, token, "2024-07-11", "2024-07-11", 1);
+//        videoListService.getVideoList(accountId, token, null, null, 1);
 //            campaignReportDailyService.getCampaignReportDaily(accountId, token, s, s, 1);
 //        }
 
@@ -209,7 +212,7 @@ public class KuaishouController {
 
         List<Long> accountIds = tokenService.getAllAccountIds();
 
-        for (String date : dates) {
+//        for (String date : dates) {
             for (Long accountId : accountIds) {
                 String token = tokenService.getByAccountId(accountId);
                 hourlyExecutorService.submit(
@@ -219,10 +222,10 @@ public class KuaishouController {
                             public void run() {
                                 Thread.sleep(500);
                                 kuaishouAccountReportHourlyService
-                                        .getAdvertiserReportHour(accountId, token, date, date, 1);
+                                        .getAdvertiserReportHour(accountId, token, "2024-07-11", "2024-07-11", 1);
                             }
                         });
-            }
+//            }
         }
     }
 
@@ -264,4 +267,10 @@ public class KuaishouController {
         tokens.forEach(token -> accountWarningService.kuaiShouAccountWarning(token.getLong("accountId"), todayInt, yesterdayInt));
     }
 
+    @GetMapping(value = "testE")
+    public void testE(Long accountId) throws Exception {
+        adUnitReportService.getAgentAccountList();
+    }
+
+
 }

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

@@ -54,5 +54,8 @@ public class KuaishouConstant {
     //直播间报表
     public static final String LIVE_USER_REPORT = "/rest/openapi/gw/dsp/v1/report/live_user_report";
 
+    //代理商获取广告主列表接口
+    public static final String AGENT_ACCOUNT_LIST = "/rest/openapi/gw/agent/v1/account/list";
+
 
 }

+ 2 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/entity/KuaishouAccountReportDaily.java

@@ -447,6 +447,7 @@ public class KuaishouAccountReportDaily {
   private BigDecimal conversionComponentRate;
   private Long adLandingPageImpression;
   private Long adAppDownloadHalfImpression;
+  private Long eventDrawCreditLine;
 
 
 
@@ -698,6 +699,7 @@ public class KuaishouAccountReportDaily {
     reportDaily.setConversionComponentRate(returnJson.getBigDecimal("conversion_component_rate"));
     reportDaily.setAdLandingPageImpression(returnJson.getLong("ad_landing_page_impression"));
     reportDaily.setAdAppDownloadHalfImpression(returnJson.getLong("ad_app_download_half_impression"));
+    reportDaily.setEventDrawCreditLine(returnJson.getLong("event_draw_credit_line"));
 
     return reportDaily;
 

+ 2 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/entity/KuaishouAccountReportHourly.java

@@ -553,6 +553,7 @@ public class KuaishouAccountReportHourly {
 
 
 
+  private Long eventDrawCreditLine;
   private Long adPhotoPlayed10s;
   private Long adPhotoPlayed2s;
   private Long adPhotoPlayed75percent;
@@ -912,6 +913,7 @@ public class KuaishouAccountReportHourly {
     reportHourly.setConversionComponentRate(returnJson.getBigDecimal("conversion_component_rate"));
     reportHourly.setAdLandingPageImpression(returnJson.getLong("ad_landing_page_impression"));
     reportHourly.setAdAppDownloadHalfImpression(returnJson.getLong("ad_app_download_half_impression"));
+    reportHourly.setEventDrawCreditLine(returnJson.getLong("event_draw_credit_line"));
 
     return reportHourly;
 

+ 292 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/entity/KuaishouAgentAccountList.java

@@ -0,0 +1,292 @@
+package cn.com.ctop.job.kuaishou.data.entity;
+
+import cn.com.ctop.job.kuaishou.data.utils.Check;
+import cn.com.ctop.job.kuaishou.data.utils.DateUtils;
+import com.alibaba.fastjson.JSONObject;
+import lombok.Data;
+
+/**
+ * 代理商-广告主列对象 kuaishou_agent_account_list
+ *
+ * @author ruoyi
+ * @date 2024-07-25
+ */
+@Data
+public class KuaishouAgentAccountList {
+
+    /**
+     * 主键ID
+     */
+    private Long id;
+
+    /**
+     * 代理商ID
+     */
+    private Long agentId;
+    /**
+     * 快手ID
+     */
+    private Long userId;
+
+    /**
+     * 广告主ID
+     */
+    private Long accountId;
+
+    /**
+     * 快手昵称
+     */
+    private String accountName;
+
+    /**
+     * 账户类型
+     */
+    private String ucType;
+
+    /**
+     * 付款类型
+     */
+    private String paymentType;
+
+    /**
+     * 创建时间
+     */
+    private String createTime;
+
+    private String statDate;
+
+    /**
+     * 现金余额
+     */
+    private Long balance;
+
+    /**
+     * 信用账户余额
+     */
+    private Long creditBalance;
+
+    /**
+     * 预留账户余额
+     */
+    private Long extendedBalance;
+
+    /**
+     * 后返余额
+     */
+    private Long rebate;
+
+    /**
+     * 前返余额
+     */
+    private Long preRebate;
+
+    /**
+     * 框返余额
+     */
+    private Long contractRebate;
+
+    /**
+     * 激励余额
+     */
+    private Long directRebate;
+
+    /**
+     * 总余额
+     */
+    private Long totalBalance;
+
+    /**
+     * 账户最低余额
+     */
+    private Long loLimit;
+
+    /**
+     * 单次转账金额
+     */
+    private Long singleOut;
+
+    /**
+     * 自动转账状态 1-ture,0-false
+     */
+    private String autoOut;
+
+    /**
+     * 余额不足提醒 1-ture,0-false
+     */
+    private String balanceOut;
+
+    /**
+     * 产品名称
+     */
+    private String productName;
+
+    /**
+     * 首日消耗日期
+     */
+    private String firstCostDay;
+
+    /**
+     * 一级行业
+     */
+    private String industry;
+
+    /**
+     * 二级行业
+     */
+    private String secondIndustry;
+
+    /**
+     * $column.columnComment
+     */
+    private Long kuaibiBalance;
+
+    /**
+     * $column.columnComment
+     */
+    private Long pushBalance;
+
+    /**
+     * 1-ture,0-false
+     */
+    private String recharged;
+
+    /**
+     * 企业名称
+     */
+    private String corporationName;
+
+    /**
+     * 审核状态	1-审核中,2-审核通过,3-审核拒绝,0-待提交
+     */
+    private Integer reviewStatus;
+    /**
+     * 审核详情
+     */
+    private String reviewDetail;
+
+    /**
+     * 冻结状态
+     */
+    private Integer forzenStatus;
+
+    /**
+     * 转账状态  1-ture,0-false
+     */
+    private String transferAccountStatus;
+
+    private Long appId;
+
+    /**
+     * 创建来源
+     */
+    private Integer createSource;
+
+    /**
+     * 账号认证状态	0-无状态,1-待认证,2-认证中,3-认证通过,4-认证失败,5-认证失效
+     */
+    private Integer authenticationStatus;
+
+    /**
+     * 账号认证状态详情
+     */
+    private String authenticationDetail;
+
+    /**
+     * 合同签约状态	0-无效,1-签约中,2-已签约,3-已终止,4-已过期,5-已撤销,6-已拒签,7-已删除,8-提前终止
+     */
+    private Integer contractReviewStatus;
+
+    /**
+     * 合同签约状态详情
+     */
+    private String contractReviewDetail;
+
+    /**
+     * 用户审核状态	0-未送审,1-待审核,2-审核通过,3-审核拒绝,4-封禁
+     */
+    private Integer userReviewStatus;
+
+    /**
+     * 用户审核状态详情
+     */
+    private String userReviewDetail;
+
+    /**
+     * 是否为复制账户 1-ture,0-false
+     */
+    private String copyAccount;
+
+    public KuaishouAgentAccountList() {
+    }
+
+    public KuaishouAgentAccountList(JSONObject json, Long agentId) {
+        this.appId = json.getLong("app_id");
+        this.agentId = agentId;
+        this.userId = json.getLong("user_id");
+        this.accountId = json.getLong("account_id");
+        this.accountName = json.getString("account_name");
+        this.ucType = json.getString("uc_type");
+        this.paymentType = json.getString("payment_type");
+        this.balance = json.getLong("balance");
+        this.createTime = DateUtils.tempToDate(json.getLong("create_time"), "yyyy-MM-dd HH:mm:ss");
+        this.statDate = DateUtils.tempToDate(json.getLong("create_time"), "yyyy-MM-dd");
+        this.creditBalance = json.getLong("credit_balance");
+        this.extendedBalance = json.getLong("extended_balance");
+        this.rebate = json.getLong("rebate");
+        this.preRebate = json.getLong("pre_rebate");
+        this.contractRebate = json.getLong("contract_rebate");
+        this.directRebate = json.getLong("direct_rebate");
+        this.totalBalance = json.getLong("total_balance");
+        this.loLimit = json.getLong("lo_limit");
+        this.singleOut = json.getLong("single_out");
+        Boolean auto_out = json.getBoolean("auto_out");
+        if (!Check.isNull(auto_out)) {
+            this.autoOut = auto_out ? "1" : "0";
+        }
+        Boolean balance_out = json.getBoolean("balance_out");
+        if (!Check.isNull(balance_out)) {
+            this.balanceOut = balance_out ? "1" : "0";
+        }
+        this.productName = json.getString("product_name");
+        this.firstCostDay = json.getString("first_cost_day");
+        this.industry = json.getString("industry");
+        this.secondIndustry = json.getString("second_industry");
+        this.kuaibiBalance = json.getLong("kuaibi_balance");
+        this.pushBalance = json.getLong("push_balance");
+        Boolean recharged = json.getBoolean("recharged");
+        if (!Check.isNull(recharged)) {
+            this.recharged = recharged ? "1" : "0";
+        }
+        this.corporationName = json.getString("corporation_name");
+        this.reviewStatus = json.getInteger("review_status");
+        this.reviewDetail = json.getString("review_detail");
+        this.forzenStatus = json.getInteger("forzen_status");
+        Boolean transfer_account_status = json.getBoolean("transfer_account_status");
+        if (!Check.isNull(transfer_account_status)) {
+            this.transferAccountStatus = transfer_account_status ? "1" : "0";
+        }
+        this.createSource = json.getInteger("create_source");
+        JSONObject info = json.getJSONObject("child_review_status_info");
+        if (!Check.isNull(info)) {
+            JSONObject contractReviewInfo = info.getJSONObject("contract_review_info");
+            if (!Check.isNull(contractReviewInfo)) {
+                this.contractReviewStatus = contractReviewInfo.getInteger("contract_review_status");
+                this.contractReviewDetail = contractReviewInfo.getString("contract_review_detail");
+            }
+            JSONObject authenticationReviewInfo = info.getJSONObject("authentication_review_info");
+            if (!Check.isNull(authenticationReviewInfo)) {
+                this.authenticationStatus = authenticationReviewInfo.getInteger("authentication_status");
+                this.authenticationDetail = authenticationReviewInfo.getString("authentication_detail");
+            }
+            JSONObject userReviewInfo = info.getJSONObject("user_review_info");
+            if (!Check.isNull(userReviewInfo)) {
+                this.userReviewStatus = userReviewInfo.getInteger("review_status");
+                this.userReviewDetail = userReviewInfo.getString("review_detail");
+            }
+        }
+        Boolean copy_account = json.getBoolean("copy_account");
+        if (!Check.isNull(copy_account)) {
+            this.copyAccount = copy_account ? "1" : "0";
+        }
+    }
+}

+ 3 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/mapper/AdUnitReportMapper.java

@@ -2,6 +2,7 @@ package cn.com.ctop.job.kuaishou.data.mapper;
 
 import cn.com.ctop.job.kuaishou.data.entity.KuaiShouDailyAgent;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouAdUnitList;
+import cn.com.ctop.job.kuaishou.data.entity.KuaishouAgentAccountList;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouCampaignList;
 import cn.com.ctop.job.kuaishou.data.entity.MediaSendAlarmRecord;
 import com.alibaba.fastjson.JSONObject;
@@ -32,4 +33,6 @@ public interface AdUnitReportMapper {
     void insertSendRecord(MediaSendAlarmRecord record);
 
     void deleteByMap(Map<String, Object> deleteMap);
+
+    void replaceBatchKuaishouAgentAccountList(@Param("addList") List<KuaishouAgentAccountList> agentList);
 }

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

@@ -308,4 +308,101 @@
         where account_id = #{accountId}
           AND unit_id#{unitId}
     </delete>
+
+
+
+    <!-- 插入 代理商-广告主列表-->
+    <insert id="replaceBatchKuaishouAgentAccountList">
+        replace into `jeecg-boot`.kuaishou_agent_account_list(
+        agent_id,
+        user_id,
+        account_id,
+        account_name,
+        create_time,
+        stat_date,
+        uc_type,
+        payment_type,
+        balance,
+        credit_balance,
+        extended_balance,
+        rebate,
+        pre_rebate,
+        contract_rebate,
+        direct_rebate,
+        total_balance,
+        lo_limit,
+        single_out,
+        auto_out,
+        balance_out,
+        product_name,
+        first_cost_day,
+        industry,
+        second_industry,
+        kuaibi_balance,
+        push_balance,
+        recharged,
+        app_id,
+        corporation_name,
+        review_detail,
+        review_status,
+        forzen_status,
+        transfer_account_status,
+        create_source,
+        authentication_status,
+        authentication_detail,
+        contract_review_status,
+        contract_review_detail,
+        user_review_status,
+        user_review_detail,
+        copy_account
+
+        )
+        values
+        <foreach collection="addList" item="add" separator=",">
+            (
+            #{add.agentId},
+            #{add.userId},
+            #{add.accountId},
+            #{add.accountName},
+            #{add.createTime},
+            #{add.statDate},
+            #{add.ucType},
+            #{add.paymentType},
+            #{add.balance},
+            #{add.creditBalance},
+            #{add.extendedBalance},
+            #{add.rebate},
+            #{add.preRebate},
+            #{add.contractRebate},
+            #{add.directRebate},
+            #{add.totalBalance},
+            #{add.loLimit},
+            #{add.singleOut},
+            #{add.autoOut},
+            #{add.balanceOut},
+            #{add.productName},
+            #{add.firstCostDay},
+            #{add.industry},
+            #{add.secondIndustry},
+            #{add.kuaibiBalance},
+            #{add.pushBalance},
+            #{add.recharged},
+            #{add.appId},
+            #{add.corporationName},
+            #{add.reviewDetail},
+            #{add.reviewStatus},
+            #{add.forzenStatus},
+            #{add.transferAccountStatus},
+            #{add.createSource},
+            #{add.authenticationStatus},
+            #{add.authenticationDetail},
+            #{add.contractReviewStatus},
+            #{add.contractReviewDetail},
+            #{add.userReviewStatus},
+            #{add.userReviewDetail},
+            #{add.copyAccount}
+
+            )
+        </foreach>
+    </insert>
 </mapper>

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

@@ -243,6 +243,7 @@
         ,`conversion_component_rate`
         ,`ad_landing_page_impression`
         ,`ad_app_download_half_impression`
+        ,`event_draw_credit_line`
         )
         values
         <foreach collection="addList" item="add" separator=",">
@@ -486,7 +487,8 @@
             #{add.conversionComponentClick},
             #{add.conversionComponentRate},
             #{add.adLandingPageImpression},
-            #{add.adAppDownloadHalfImpression}
+            #{add.adAppDownloadHalfImpression},
+            #{add.eventDrawCreditLine}
 
 
             )

+ 3 - 2
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/mapper/xml/KuaishouAccountReportHourlyMapper.xml

@@ -245,6 +245,7 @@
         ,`conversion_component_rate`
         ,`ad_landing_page_impression`
         ,`ad_app_download_half_impression`
+        ,`event_draw_credit_line`
 
         )
         values
@@ -490,8 +491,8 @@
             #{add.conversionComponentClick},
             #{add.conversionComponentRate},
             #{add.adLandingPageImpression},
-            #{add.adAppDownloadHalfImpression}
-
+            #{add.adAppDownloadHalfImpression},
+            #{add.eventDrawCreditLine}
 
 
 

+ 1 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/IAdUnitReportService.java

@@ -29,4 +29,5 @@ public interface IAdUnitReportService {
 
     void getKuaishouDailyFundGet(Long advertiserId, String accessToken);
 
+    void getAgentAccountList();
 }

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

@@ -6,6 +6,7 @@ import cn.com.ctop.job.kuaishou.data.entity.KuaishouAccountAdSceneReportDaily;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouAdUnitList;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouAdvertiserFundDailyFlows;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouAdvertiserFundGet;
+import cn.com.ctop.job.kuaishou.data.entity.KuaishouAgentAccountList;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.job.kuaishou.data.entity.KuaishouCampaignList;
 import cn.com.ctop.job.kuaishou.data.entity.OauthAgentToken;
@@ -28,7 +29,6 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -835,5 +835,85 @@ public class AdUnitReportServiceImpl implements IAdUnitReportService {
 
     }
 
+    /**
+     * 快手-代理商数据
+     */
+    @Override
+    public void getAgentAccountList() {
+        List<Long> appList = new ArrayList<>();
+        appList.add(27L);
+        appList.add(165893351L);
+        for (int i = 0; i < appList.size(); i++) {
+            Long appId = appList.get(i);
+            OauthAgentToken agentToken = agentTokenMapper.getTokenByAppId(appId);
+            getAgentAccountList(agentToken.getAccessToken(), agentToken.getAgentId(), 1);
+        }
+
+    }
+
 
+    /**
+     * 代理商获取广告主列表
+     */
+    private void getAgentAccountList(String token, Long agentId, int page) {
+        try {
+            log.info("=====代理商获取广告主列表====page--{}===《《《《《", page);
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Content-Type", " application/json");
+            headers.put("Access-Token", token);
+            JSONObject param = new JSONObject();
+            param.put("select_type", 0);
+            param.put("select_value", null);
+            param.put("agent_id", agentId);
+            param.put("page_size", 1000);
+            param.put("page", page);
+
+            String result = HttpUtils.httpPostRequest(postUrl + KuaishouConstant.AGENT_ACCOUNT_LIST, param, headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (Check.isNull(resultJson)) {
+                log.info("代理商获取广告主列表返回为空");
+                return;
+            }
+            Integer code = resultJson.getInteger("code");
+            if (code != 0) {
+                log.error("代理商获取广告主列表code错误,返回:{}", resultJson);
+                return;
+            }
+            JSONObject data = resultJson.getJSONObject("data");
+            if (Check.isNull(data)) {
+                log.error("代理商获取广告主列表data节点为空");
+                return;
+            }
+            JSONArray details = data.getJSONArray("details");
+            if (Check.isNull(details)) {
+                log.error("代理商获取广告主列表details节点为空");
+                return;
+            }
+
+            List<KuaishouAgentAccountList> agentList = new ArrayList<>();
+            for (int i = 0; i < details.size(); i++) {
+                JSONObject detailJson = details.getJSONObject(i);
+                if (!Check.isNull(detailJson)) {
+                    KuaishouAgentAccountList agent = new KuaishouAgentAccountList(detailJson, agentId);
+                    agentList.add(agent);
+                }
+            }
+            if (!Check.isNull(agentList)) {
+                adUnitReportMapper.replaceBatchKuaishouAgentAccountList(agentList);
+            }
+            //是否有下一页
+            Boolean toGet = true;
+            if (details.size() < 1000) {
+                toGet = false;
+            }
+            if (toGet) {
+                getAgentAccountList(token, agentId, page + 1);
+            } else {
+                log.info("代理商获取广告主列表完成========");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
 }

+ 1 - 1
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/utils/DateUtils.java

@@ -115,6 +115,6 @@ public class DateUtils {
 
     public static void main(String[] args) {
 
-        System.out.println(tempToDate(1704858060000L,"yyyy-MMdd"));
+        System.out.println(tempToDate(1721873285120L,"yyyy-MM-dd HH:mm:ss"));
     }
 }

+ 10 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/AdUnitReportJob.java

@@ -144,6 +144,16 @@ public class AdUnitReportJob {
         adUnitReportService.getAgentReport();
     }
 
+    /**
+     * 代理商t-1数据获取
+     *
+     * @throws
+     */
+    @XxlJob("kuaiShouAgentAccountListJob")
+    public void kuaiShouAgentAccountListJob() throws Exception {
+        adUnitReportService.getAgentAccountList();
+    }
+
 
     /**
      * 快手-账户日报-adScene(按广告场景)