Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

yumeng 1 год назад
Родитель
Сommit
a99c835167
34 измененных файлов с 1870 добавлено и 154 удалено
  1. 13 1
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/ChangDuController.java
  2. 233 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/AdvertiserApplet.java
  3. 120 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/AdvertiserAvatar.java
  4. 65 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/AdvertiserNameInfo.java
  5. 35 2
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/AdvertiserToolsSite.java
  6. 31 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/ChangDuAppDistributor.java
  7. 0 2
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/BytedancePromoterReportMapper.java
  8. 2 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/BytedanceRefreshTokenMapper.java
  9. 22 2
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/ChannelMapper.java
  10. 5 1
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/ReportsAdPushMapper.java
  11. 28 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/ToolsSiteMapper.java
  12. 0 7
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/BytedancePromoterReportMapper.xml
  13. 6 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/BytedanceRefreshTokenMapper.xml
  14. 71 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/ChannelMapper.xml
  15. 59 7
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/ReportsAdPushMapper.xml
  16. 276 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/ToolsSiteMapper.xml
  17. 6 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IBindAppErrorWarnService.java
  18. 0 1
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IBytedancePromoterReportService.java
  19. 6 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IChannelService.java
  20. 19 1
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IToolsSiteService.java
  21. 5 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/ITotalRankPushService.java
  22. 191 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BindAppErrorWarnServiceImpl.java
  23. 1 4
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedancePromoterReportServiceImpl.java
  24. 141 4
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/ChannelServiceImpl.java
  25. 35 38
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/OptimizerRankPushServiceImpl.java
  26. 1 1
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/ReportsAdPushServiceImpl.java
  27. 188 17
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/ToolsSiteServiceImpl.java
  28. 156 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/TotalRankPushServiceImpl.java
  29. 12 10
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/UnbindWarnPushServiceImpl.java
  30. 7 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/utils/HttpUtils.java
  31. 0 33
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedancePromoterReportJob.java
  32. 65 0
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ChangDuJob.java
  33. 15 3
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/FeishuPushJob.java
  34. 56 20
      job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ToolsSiteJob.java

+ 13 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/ChangDuController.java

@@ -29,7 +29,7 @@ public class ChangDuController {
     public void changDuOrder(@RequestParam(required = false) String distributorId,
                              @RequestParam(required = false) String startDate,
                              @RequestParam(required = false) String endDate) {
-        List<JSONObject> channelList = promoterReportService.getChannelInfoList();
+        List<JSONObject> channelList = channelService.getChannelInfoList();
         for (JSONObject jsonObject : channelList) {
             String channelAccountId = jsonObject.getString("channelAccountId");
             if (distributorId != null && !distributorId.equals(channelAccountId)) {
@@ -68,5 +68,17 @@ public class ChangDuController {
         }
     }
 
+    @GetMapping("/distributorConfig")
+    public void distributorConfig() {
+        channelService.getDistributorConfig();
+    }
+
+    @GetMapping("/syncMovieId")
+    public void syncMovieId(@RequestParam(required = false) String startDate,
+                            @RequestParam(required = false) String endDate) {
+        startDate = startDate == null ? DateUtils.getNowAddDate("yyyy-MM-dd", -1) : startDate;
+        endDate = endDate == null ? DateUtils.getNowDate("yyyy-MM-dd") : endDate;
+        channelService.syncMovieId(startDate, endDate);
+    }
 
 }

+ 233 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/AdvertiserApplet.java

@@ -0,0 +1,233 @@
+package cn.com.ctop.job.bytedance.data.entity;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 小程序对象 AdvertiserApplet
+ *
+ * @author ruoyi
+ * @date 2025-03-07
+ */
+@Data
+public class AdvertiserApplet {
+
+    /**
+     * 广告主ID
+     */
+    private Long advertiserId;
+
+    /**
+     * 小程序资产ID
+     */
+    private Long instanceId;
+
+    /**
+     * 小程序名称
+     */
+    private String appName;
+
+    /**
+     * 字节小程序备注名称
+     */
+    private String remark;
+
+    /**
+     * 小程序appid
+     */
+    private String appId;
+
+    /**
+     * 小程序原始ID,获取方式:小程序后台>设置>基本设置>账号信息>原始ID,例如“gh_”,最大长度不超过20
+     */
+    private String originalAppId;
+
+    /**
+     * 小程序类型:1-字节,2-微信
+     */
+    private String platType;
+
+    /**
+     * 审核状态: AUDIT_ACCEPTED 审核成功,AUDITING 审核中,AUDIT_REJECTED审核失败
+     */
+    private String auditStatus;
+
+    /**
+     * 小程序类型:1-字节,2-微信
+     */
+    private String reason;
+
+    /**
+     * (bytedance)小程序链接,以 sslocal://microapp 开头 。生效优先级大于 启动页面 和 启动参数  ,详细内容见接口说明
+     */
+    private String link;
+
+    /**
+     * (bytedance)链接备注
+     */
+    private String linkRemark;
+
+    /**
+     * (wx)小程序路径参数,如有跳转指定页面或自定义参数监测广告效果数据诉求,需填写。获取方式:登录关联的公众号后台>素材管理>新建图文素材>小程序>选择小程序>获取更多路径
+     */
+    private String path;
+
+    /**
+     * (wx)资产备注信息,最大长度不超过15
+     */
+    private String remarkMessage;
+
+    /**
+     * (wx)小程序icon图片的url,尺寸60*60px,大小不超2MB,图片格式要求jpeg、png或gif
+     */
+    private String iconImageUrl;
+
+    /**
+     * (wx)顶部头图的url,大小不超过5MB的图片,推荐尺寸2:1,图片格式要求jpeg、png或gif
+     */
+    private String headerImageUrl;
+
+    /**
+     * (wx)小程序标签,每个标签长度不超过6,最多支持6个标签
+     */
+    private String labels;
+
+    /**
+     * (wx)引导文案,最大长度不超过14
+     */
+    private String guideText;
+
+    /**
+     * (wx)竖图的url地址,要求尺寸必须为3:5,否则报错;最少3张,最多8张,大小不超过5MB;图片格式要求jpeg、png或gif,竖图和横图不能同时传
+     */
+    private String imagesVerticalUrl;
+
+    /**
+     * (wx)横图的url地址,要求尺寸必须为3:5,否则报错;最少3张,最多8张,大小不超过5MB;图片格式要求jpeg、png或gif,竖图和横图不能同时传
+     */
+    private String imagesHorizontalUrl;
+
+    /**
+     * (wx)小程序简介,最大长度不超过50
+     */
+    private String introduction;
+
+    /**
+     * 细分类型,填写细分类型的末级分类ID category_id
+     */
+    private String tagInfo;
+
+    /**
+     * (bytedance)启动页面,形如:page/home/xxx。不得以反斜线开头,不得以反斜线结尾,请避免参数中出现特殊字符
+     */
+    private String startPage;
+
+    /**
+     * (bytedance)启动参数,形如:name=zhangsan&age=25。不得以问号、连接符等特殊字符开头,请确保各参数间仅使用一个连接符
+     */
+    private String startParam;
+    /**
+     * 是否共享1是,0否
+     */
+    private String appShare;
+    /**
+     * 共享源广告主ID
+     */
+    private Long shareAdvertiserId;
+    /**
+     * 小程序创建时间
+     */
+    private String appCreateTime;
+    /**
+     * 小程序更新时间
+     */
+    private String appUpdateTime;
+    /**
+     * 任务ID
+     */
+    private String taskId;
+
+    /**
+     * 入参,排查问题
+     */
+    private String parameters;
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    public AdvertiserApplet() {
+    }
+
+    public AdvertiserApplet(Long advertiserId, JSONObject entity, String platType) {
+        this.advertiserId = advertiserId;
+        this.appName = entity.getString("name");
+        this.appId = entity.getString("app_id");
+        this.originalAppId = entity.getString("user_name");
+        this.path = entity.getString("path");
+        this.instanceId = entity.getLong("instance_id");
+        this.auditStatus = entity.getString("audit_status");
+        this.reason = entity.getString("reason");
+        this.appCreateTime = entity.getString("create_time");
+        this.appUpdateTime = entity.getString("modify_time");
+        this.headerImageUrl = entity.getString("header_image_url");
+        this.imagesVerticalUrl = entity.getString("images_vertical_url");
+        this.iconImageUrl = entity.getString("icon_image_url");
+        this.introduction = entity.getString("introduction");
+        this.labels = entity.getString("labels");
+        this.remarkMessage = entity.getString("remark_message");
+        this.tagInfo = entity.getString("tag_info");
+        this.guideText = entity.getString("guide_text");
+        this.remark = entity.getString("remark");
+        this.platType = platType;
+    }
+
+    public AdvertiserApplet(String taskId, Long advertiserId, String appName, String appId, String tagInfo, String startPage, String startParam) {
+        this.taskId = taskId;
+        this.advertiserId = advertiserId;
+        this.appName = appName;
+        this.appId = appId;
+        this.tagInfo = tagInfo;
+        this.startPage = startPage;
+        this.startParam = startParam;
+    }
+
+    public AdvertiserApplet(AdvertiserApplet one) {
+        this.advertiserId = one.getAdvertiserId();
+        this.instanceId = one.getInstanceId();
+        this.platType = one.getPlatType();
+        this.appName = one.getAppName();
+        this.appId = one.getAppId();
+        this.remark = one.getRemark();
+        this.auditStatus = one.getAuditStatus();
+        this.originalAppId = one.getOriginalAppId();
+        this.reason = one.getReason();
+        this.link = one.getLink();
+        this.linkRemark = one.getLinkRemark();
+        this.path = one.getPath();
+        this.remarkMessage = one.getRemarkMessage();
+        this.iconImageUrl = one.getIconImageUrl();
+        this.headerImageUrl = one.getHeaderImageUrl();
+        this.labels = one.getLabels();
+        this.guideText = one.getGuideText();
+        this.imagesVerticalUrl = one.getImagesVerticalUrl();
+        this.imagesHorizontalUrl = one.getImagesHorizontalUrl();
+        this.introduction = one.getIntroduction();
+        this.tagInfo = one.getTagInfo();
+        this.startPage = one.getStartPage();
+        this.startParam = one.getStartParam();
+        this.appCreateTime = one.getAppCreateTime();
+        this.appUpdateTime = one.getAppUpdateTime();
+        this.taskId = one.getTaskId();
+    }
+}

+ 120 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/AdvertiserAvatar.java

@@ -0,0 +1,120 @@
+package cn.com.ctop.job.bytedance.data.entity;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 【广告主账户头像】对象 advertiser_avatar
+ *
+ * @author ruoyi
+ * @date 2025-03-03
+ */
+@Data
+public class AdvertiserAvatar {
+    /**
+     * 广告主id
+     */
+    private Long advertiserId;
+
+    /**
+     * 头像审核状态 0-未设置,1-审核中,2-审核被拒,3-审核通过
+     */
+    private String avatarStatus;
+
+    /**
+     * 头像被拒原因
+     */
+    private String avatarReason;
+
+    /**
+     * 品牌审核状态 0-未设置,1-审核中,2-审核被拒,3-审核通过
+     */
+    private String sourceStatus;
+
+    /**
+     * 品牌信息
+     */
+    private String sourceInfo;
+
+    /**
+     * 品牌信息被拒原因
+     */
+    private String sourceReason;
+
+    /**
+     * 当前头像的uri
+     */
+    private String webUri;
+
+    /**
+     * 审核中头像的uri
+     */
+    private String auditWebUri;
+
+    /**
+     * 审核中头像的高度
+     */
+    private Long height;
+
+    /**
+     * 审核中头像的宽度
+     */
+    private Long width;
+
+    /**
+     * 当前头像的预览链接,有效期1h
+     */
+    private String webUrl;
+
+    /**
+     * oss路径
+     */
+    private String ossUrl;
+    /**
+     * 原因
+     */
+    private String reason;
+    /**
+     * 入参,排查问题
+     */
+    private String parameters;
+
+    /**
+     * 审核中头像的预览链接,有效期1h
+     */
+    private String auditWebUrl;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    public AdvertiserAvatar() {
+    }
+
+    public AdvertiserAvatar(JSONObject data) {
+        this.advertiserId = data.getLong("advertiser_id");
+        this.avatarStatus = data.getString("avatar_status");
+        this.avatarReason = data.getString("avatar_reason");
+        this.sourceStatus = data.getString("source_status");
+        this.sourceInfo = data.getString("source_info");
+        this.sourceReason = data.getString("source_reason");
+        JSONObject avatarInfo = data.getJSONObject("avatar_info");
+        this.webUri = avatarInfo.getString("web_uri");
+        this.auditWebUri = avatarInfo.getString("audit_web_uri");
+        this.height = avatarInfo.getLong("height");
+        this.width = avatarInfo.getLong("width");
+        this.webUrl = avatarInfo.getString("web_url");
+        this.auditWebUrl = avatarInfo.getString("audit_web_url");
+    }
+}

+ 65 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/AdvertiserNameInfo.java

@@ -0,0 +1,65 @@
+package cn.com.ctop.job.bytedance.data.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 【广告主账户名称】对象 advertiser_name_info
+ */
+@Data
+public class AdvertiserNameInfo {
+    /**
+     * 广告主id
+     */
+    private Long advertiserId;
+
+    /**
+     * 广告主名称
+     */
+    private String advertiserName;
+
+    /**
+     * 头像审核状态:STATUS_PENDING_CONFIRM:审核中;STATUS_PENDING_CONFIRM:审核失败;STATUS_ENABLE:审核通过;STATUS_CONFIRM_FAIL_END:审核失败;FAIL:创建失败
+     */
+    private String advertiserStatus;
+
+    /**
+     * 原因
+     */
+    private String reason;
+    /**
+     * 入参,排查问题
+     */
+    private String parameters;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    public AdvertiserNameInfo() {
+    }
+
+    public AdvertiserNameInfo(Long advertiserId, String advertiserName, String advertiserStatus) {
+        this.advertiserId = advertiserId;
+        this.advertiserName = advertiserName;
+        this.advertiserStatus = advertiserStatus;
+    }
+
+    public AdvertiserNameInfo(Long advertiserId, String reason, String advertiserStatus, String parameters) {
+        this.advertiserId = advertiserId;
+        this.reason = reason;
+        this.advertiserStatus = advertiserStatus;
+        this.parameters = parameters;
+    }
+
+}

+ 35 - 2
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/AdvertiserToolsSite.java

@@ -53,8 +53,20 @@ public class AdvertiserToolsSite {
      * 创建类型 1-橙子建站
      */
     private String createType;
+    /**
+     * 原因
+     */
+    private String reason;
+    /**
+     * 任务批次ID
+     */
+    private String taskId;
 
     /**
+     * 入参
+     */
+    private String parameters;
+    /**
      * 创建时间
      */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@@ -69,10 +81,20 @@ public class AdvertiserToolsSite {
     public AdvertiserToolsSite() {
     }
 
-    public AdvertiserToolsSite(Long advertiserId, String siteId, String thumbnail) {
+    public AdvertiserToolsSite(Long advertiserId, String siteId, String status, String taskId) {
+        this.advertiserId = advertiserId;
+        this.siteId = siteId;
+        this.status = status;
+        this.taskId = taskId;
+    }
+
+    public AdvertiserToolsSite(Long advertiserId, String siteId, String reason, String name, String parameters, String taskId) {
         this.advertiserId = advertiserId;
         this.siteId = siteId;
-        this.thumbnail = thumbnail;
+        this.reason = reason;
+        this.name = name;
+        this.parameters = parameters;
+        this.taskId = taskId;
     }
 
     public AdvertiserToolsSite(JSONObject data, Long advertiserId, String createType) {
@@ -84,4 +106,15 @@ public class AdvertiserToolsSite {
         this.siteType = data.getString("siteType");
         this.createType = createType;
     }
+
+    public AdvertiserToolsSite(JSONObject data, Long advertiserId, String name, String createType, String taskId) {
+        this.advertiserId = advertiserId;
+        this.siteId = data.getString("id");
+        this.name = name;
+        this.thumbnail = data.getString("thumbnail");
+        this.status = data.getString("status");
+        this.siteType = data.getString("site_type");
+        this.createType = createType;
+        this.taskId = taskId;
+    }
 }

+ 31 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/ChangDuAppDistributor.java

@@ -0,0 +1,31 @@
+package cn.com.ctop.job.bytedance.data.entity;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+
+import java.util.Objects;
+
+@Data
+public class ChangDuAppDistributor {
+    private String appId;
+    private String appName;
+    private String distributorId;
+    private String nickName;
+    private String distributorName;
+    private String changduAccountId;
+    private Integer channelType;
+    private String remark;
+    private String apiKey;
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == null || getClass() != o.getClass()) return false;
+        ChangDuAppDistributor that = (ChangDuAppDistributor) o;
+        return Objects.equals(appId, that.appId) && Objects.equals(distributorId, that.distributorId);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(appId, distributorId);
+    }
+}

+ 0 - 2
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/BytedancePromoterReportMapper.java

@@ -18,8 +18,6 @@ public interface BytedancePromoterReportMapper {
 
     void replacePromoterReportDailies(@Param("list") List<BytedancePromoterReportDaily> promoterReportDailies);
 
-    List<JSONObject> getChannelInfoList();
-
     void replaceErrorInfo(BytedanceErrorLog errorInfo);
 
     List<JSONObject> getListBydate(@Param("date") Integer date);

+ 2 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/BytedanceRefreshTokenMapper.java

@@ -13,4 +13,6 @@ public interface BytedanceRefreshTokenMapper {
     List<JSONObject> getBaiduYunTokenList();
 
     void updateBaiduYunToken(@Param("obj") JSONObject obj);
+
+    String onlyGetToken(@Param("advertiserId") Long advertiserId);
 }

+ 22 - 2
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/ChannelMapper.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.job.bytedance.data.mapper;
 
+import cn.com.ctop.job.bytedance.data.entity.ChangDuAppDistributor;
 import cn.com.ctop.job.bytedance.data.entity.ChangDuOrder;
 import cn.com.ctop.job.bytedance.data.entity.ChannelChangdunovelInfo;
 import com.alibaba.fastjson.JSONObject;
@@ -7,18 +8,37 @@ import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 public interface ChannelMapper {
+    List<String> getSyncMovieList(@Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> getChannelInfoList();
+
     void repalceChannels(@Param("adds") List<ChannelChangdunovelInfo> adds);
+
     Integer getAppType(@Param("appId") String appId);
-    List<String> getOrderIds(@Param("startDate")Integer startDate,
-                             @Param("startPayTime")String startPayTime,
+
+    List<String> getOrderIds(@Param("startDate") Integer startDate,
+                             @Param("startPayTime") String startPayTime,
                              @Param("endDate") Integer endDate,
                              @Param("endPayTime") String endPayTime);
+
     Map<String, Object> getUserInfo(@Param("distributorId") String distributorId, @Param("eventTime") String eventTime, @Param("uid") String uid);
+
     Map<String, Object> getLinkInfo(@Param("linkId") String linkId);
+
     String getMovieName(@Param("movieId") String movieId);
+
     void insertOrder(List<ChangDuOrder> changDuOrders);
+
     List<JSONObject> getChangDuRetryJob();
 
+    List<JSONObject> getDistributorKey();
+
+    void insertChangduDistributorApp(Set<ChangDuAppDistributor> adds);
+
+    void insertChangduDistributorConfig(Set<ChangDuAppDistributor> adds);
+
+    void insertChannelAccountInfo(Set<ChangDuAppDistributor> adds);
 }

+ 5 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/ReportsAdPushMapper.java

@@ -19,6 +19,10 @@ public interface ReportsAdPushMapper {
     List<Map<String, String>> optimizerDateData(@Param("date") Long date);
     List<Map<String, String>> optimizerHourData(@Param("date") Long date, @Param("hour") String hour);
 
+    List<Map<String, String>> deptCostRank(@Param("date") Long date, @Param("hour") String hour);
+
     //漏绑账户预警
-    List<Map<String, String>> unbindData(@Param("date") Long date, @Param("last30Day") Long last30Day);
+    List<Map<String, String>> unbindData(@Param("date") Long date, @Param("last90Day") Long last90Day);
+
+    List<Map<String, String>> bindAppErrorData(@Param("last30Day") Long last30Day);
 }

+ 28 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/ToolsSiteMapper.java

@@ -1,5 +1,8 @@
 package cn.com.ctop.job.bytedance.data.mapper;
 
+import cn.com.ctop.job.bytedance.data.entity.AdvertiserApplet;
+import cn.com.ctop.job.bytedance.data.entity.AdvertiserAvatar;
+import cn.com.ctop.job.bytedance.data.entity.AdvertiserNameInfo;
 import cn.com.ctop.job.bytedance.data.entity.AdvertiserToolsSite;
 import org.apache.ibatis.annotations.Param;
 
@@ -9,4 +12,29 @@ public interface ToolsSiteMapper {
 
     void replaceAdvertiserToolsSite(@Param("siteList") List<AdvertiserToolsSite> siteList);
 
+    List<Long> getAvatarAdvertiserIds();
+
+    public boolean updateAdvertiserAvatar(AdvertiserAvatar advertiserAvatar);
+
+    public boolean insertAdvertiserAvatar(AdvertiserAvatar advertiserAvatar);
+
+    List<Long> getNameAdvertiserIds();
+
+    boolean updateAdvertiserNameInfo(AdvertiserNameInfo nameInfo);
+
+    boolean insertAdvertiserNameInfo(AdvertiserNameInfo nameInfo);
+
+    List<Long> getAppAdvertiserIds(String platType);
+
+    boolean updateAdvertiserAppList(AdvertiserApplet advertiserApplet);
+
+    boolean insertAdvertiserAppList(AdvertiserApplet advertiserApplet);
+
+    List<Long> getsiteAdvertiserIds();
+
+    boolean updateAdvertiserToolsSite(AdvertiserToolsSite advertiserToolsSite);
+
+    void insertAdvertiserToolsSite(AdvertiserToolsSite advertiserToolsSite);
+
+
 }

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

@@ -14,13 +14,6 @@
                  LEFT JOIN deepthink.bytedance_auth_list t3 ON t2.admin_advertiser_id = t3.admin_advertiser_id
     </select>
 
-    <select id="getChannelInfoList" resultType="com.alibaba.fastjson.JSONObject">
-        select channel_account_id as 'channelAccountId',
-                secret_key         as 'secretKey',
-                channel_app_id as 'channelAppId',
-                channel_app_name as 'channelAppName'
-        from deepthink.channel_account_info
-    </select>
     <select id="getListBydate" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.lang.Integer">
         SELECT t1.advertiser_id AS 'advertiserId', t3.access_token AS 'accessToken'
         FROM (SELECT advertiser_id

+ 6 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/BytedanceRefreshTokenMapper.xml

@@ -31,4 +31,10 @@
         WHERE app_id = #{obj.app_id}
     </update>
 
+
+    <select id="onlyGetToken" resultType="java.lang.String">
+        select 'eb0cea58911b7a7fd30f3458f1d421a57d2b0078'
+    </select>
+
+
 </mapper>

+ 71 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/ChannelMapper.xml

@@ -1,6 +1,20 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="cn.com.ctop.job.bytedance.data.mapper.ChannelMapper">
+    <select id="getSyncMovieList" resultType="java.lang.String">
+        select distinct i.movie_id
+        from deepthink.channel_changdunovel_info i
+        left join deepthink.changdu_movie_config c
+        on i.movie_id = c.movie_id
+        where c.movie_id is null
+        <if test="startDate != null">
+            and i.create_time >= "${startDate} 00:00:00"
+        </if>
+        <if test="endDate != null">
+            and i.create_time &lt;= "${endDate} 23:59:59"
+        </if>
+    </select>
+
     <select id="getChangDuRetryJob" resultType="com.alibaba.fastjson.JSONObject">
         SELECT t1.is_send AS 'isSend', t1.id AS 'id', t1.start_date AS 'startDate', t1.end_date AS 'endDate', t1.data_dimension AS 'dataDimension', t1.data_type AS 'dataType',
                 t2.channel_account_id as 'channelAccountId',t2.secret_key as 'secretKey',
@@ -9,6 +23,14 @@
         JOIN deepthink.channel_account_info t2 ON t1.advertiser_id = t2.channel_account_id
     </select>
 
+    <select id="getChannelInfoList" resultType="com.alibaba.fastjson.JSONObject">
+        select channel_account_id as 'channelAccountId',
+                secret_key         as 'secretKey',
+                channel_app_id as 'channelAppId',
+                channel_app_name as 'channelAppName'
+        from deepthink.channel_account_info
+    </select>
+
     <insert id="repalceChannels">
         replace into deepthink.channel_changdunovel_info (
         distributor_id,
@@ -107,4 +129,53 @@
             </trim>
         </foreach>
     </insert>
+
+    <select id="getDistributorKey" resultType="com.alibaba.fastjson.JSONObject">
+        select changdu_account_id as 'changduAccountId',max(account_name) as 'accountName',
+                max(distributor_id) as 'distributorId', max(api_key) as 'apiKey'
+        from deepthink.changdu_distributor_config c
+                 join deepthink.changdu_account_config a
+                      on c.changdu_account_id = a.account_id
+        group by changdu_account_id
+    </select>
+
+    <insert id="insertChangduDistributorApp">
+        replace into deepthink.changdu_distributor_app (distributor_id,app_id)
+        values
+        <foreach collection="collection" item="item" separator=",">
+            (
+            #{item.distributorId},
+            #{item.appId}
+            )
+        </foreach>
+    </insert>
+    <insert id="insertChangduDistributorConfig">
+        replace into deepthink.changdu_distributor_config
+        (distributor_id,distributor_name,changdu_account_id,channel_type,remark)
+        values
+        <foreach collection="collection" item="item" separator=",">
+            (
+            #{item.distributorId},
+            #{item.distributorName},
+            #{item.changduAccountId},
+            #{item.channelType},
+            #{item.remark}
+            )
+        </foreach>
+    </insert>
+    <insert id="insertChannelAccountInfo">
+        replace into deepthink.channel_account_info
+        (channel_account_id,channel_account_name,channel_app_id,channel_app_name,business_type,secret_key)
+        values
+        <foreach collection="collection" item="item" separator=",">
+            (
+            #{item.distributorId},
+            #{item.distributorName},
+            #{item.appId},
+            #{item.appName},
+            #{item.channelType},
+            #{item.apiKey}
+            )
+        </foreach>
+    </insert>
 </mapper>

+ 59 - 7
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/ReportsAdPushMapper.xml

@@ -62,7 +62,7 @@
 
 
     <select id="optimizerCostRank" resultType="java.util.Map">
-        select tb1.user_id, tb4.phonenumber,
+        select tb1.user_id, tb4.phonenumber, tb4.nick_name, tb4.dept_id, tb5.dept_name,
         rank() over (order by sum(cost_amount) desc) as rk,
         sum(cost_amount) as cost_amount,
         concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (ifnull(sum(share_iaa_amount),0)+ifnull(sum(share_pay_amount),0))/sum(real_cost_amount)*100), 2), '%') AS real_roi
@@ -74,15 +74,16 @@
         left join (select advertiser_id, sum(share_iaa_amount) as share_iaa_amount, sum(share_pay_amount) as share_pay_amount
         from application.user_data_report_daily where stat_date=#{date} group by advertiser_id) tb3
         on tb1.advertiser_id = tb3.advertiser_id
-        left join (select user_id, nick_name, phonenumber from deepthink.sys_user) tb4
+        left join (select user_id, nick_name, phonenumber, dept_id from deepthink.sys_user) tb4
         on tb1.user_id=tb4.user_id
+        left join (select dept_id, dept_name from deepthink.sys_dept) tb5
+        on tb4.dept_id = tb5.dept_id
         group by tb1.user_id
         having sum(cost_amount)>1
         order by rk asc
-        limit 10
     </select>
     <select id="optimizerDateData" resultType="java.util.Map">
-        select tb1.user_id,tb4.phonenumber,tb4.nick_name,
+        select tb1.user_id,tb4.phonenumber,tb4.nick_name, tb4.dept_id,
         concat(round(if(ifnull(sum(cost_amount),0)=0, 0, (ifnull(sum(iaa_amount),0)+ifnull(sum(pay_amount), 0))/sum(cost_amount)*100 ), 2), '%') AS water_roi,
         concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (ifnull(sum(share_iaa_amount),0)+ifnull(sum(share_pay_amount),0))/sum(real_cost_amount)*100), 2), '%') AS real_roi,
         ifnull(sum(cost_amount),0) AS cost_amount,
@@ -102,7 +103,7 @@
         from application.user_data_report_daily
         where stat_date = #{date}
         group by advertiser_id) tb3 on tb1.advertiser_id = tb3.advertiser_id
-        left join (select user_id, nick_name, phonenumber from deepthink.sys_user) tb4
+        left join (select user_id, nick_name, phonenumber, dept_id from deepthink.sys_user) tb4
         on tb1.user_id=tb4.user_id
         group by tb1.user_id
         having sum(cost_amount)>0
@@ -134,6 +135,30 @@
 
 
 
+    <select id="deptCostRank" resultType="java.util.Map">
+        select tb4.dept_id, tb5.dept_name,
+        rank() over (order by sum(cost_amount) desc) as rk,
+        ifnull(sum(cost_amount), 0) as cost_amount,
+        ifnull(sum(cost_amount_hour), 0) as cost_amount_hour
+        from
+        (select cast(advertiser_id as char) advertiser_id, user_id from deepthink.advertiser_bind_info) tb1
+        left join (select advertiser_id, sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount
+        from application.media_ad_report_daily where stat_date=#{date} group by advertiser_id) tb2
+        on tb1.advertiser_id = tb2.advertiser_id
+        left join (select advertiser_id, sum(cost_amount) as cost_amount_hour
+        from application.media_ad_report_hourly where stat_date=#{date} and `hour`= ${hour} group by advertiser_id) tb3
+        on tb1.advertiser_id = tb3.advertiser_id
+        left join (select user_id, nick_name, phonenumber, dept_id from deepthink.sys_user) tb4
+        on tb1.user_id=tb4.user_id
+        left join (select dept_id, dept_name from deepthink.sys_dept) tb5
+        on tb4.dept_id = tb5.dept_id
+        group by tb4.dept_id
+        having sum(cost_amount)>1
+        order by rk asc
+        limit 10
+    </select>
+
+
     <select id="unbindData" resultType="java.util.Map">
         select tb1.advertiser_id, tb1.advertiser_name, ifnull(tb2.ca,0) as today_cost, tb3.ca as last_30_cost from
         (select cast(advertiser_id as char) advertiser_id, advertiser_name from deepthink.advertiser_unbind_info) tb1
@@ -142,16 +167,43 @@
         on tb1.advertiser_id = tb2.advertiser_id
         left join
         (select advertiser_id, ifnull(sum(cost_amount),0) as ca from application.media_ad_report_daily
-        where stat_date &gt;= #{last30Day} and stat_date &lt;= #{date} group by advertiser_id) tb3
+        where stat_date &gt;= #{last90Day} and stat_date &lt;= #{date} group by advertiser_id) tb3
         on tb1.advertiser_id = tb3.advertiser_id
         where tb3.ca > 10
         order by tb3.ca desc
     </select>
     <select id="selectUserList" resultType="com.alibaba.fastjson.JSONObject">
-        select user_id, nick_name, phonenumber, remark
+        select user_id, nick_name, phonenumber, remark, u.dept_id
         from deepthink.sys_user u
         left join deepthink.sys_dept d on u.dept_id = d.dept_id
         where u.del_flag = '0'
         AND (u.dept_id = 300 OR u.dept_id IN ( SELECT t.dept_id FROM deepthink.sys_dept t WHERE find_in_set(300, ancestors) ))
     </select>
+    <select id="bindAppErrorData" resultType="java.util.Map">
+        select tb1.advertiser_id, tb2.advertiser_name, tb1.ma_appid as right_app, tb2.ma_appid as error_app,
+        tb3.app_name as right_app_name, tb4.app_name as error_app_name,
+        tb2.user_id, tb5.nick_name, tb5.phonenumber
+        from (select advertiser_id, ma_appid
+        from (select advertiser_id, ma_appid,row_number() over (partition by advertiser_id order by pay_amount desc) as rn
+        from (select advertiser_id, ma_appid, sum(ifnull(pay_amount,0) + ifnull(iaa_amount,0)+ ifnull(new_users,0)) as pay_amount
+        from application.user_data_report_daily
+        where stat_date &gt;= #{last30Day}
+        and advertiser_id != '-9999'
+        and ma_appid != '-9999'
+        group by advertiser_id, ma_appid
+        )t1
+        )t2 where t2.rn = 1
+        )tb1
+        inner join
+        (select advertiser_id, advertiser_name, ma_appid, user_id from deepthink.advertiser_bind_info) tb2
+        on tb1.advertiser_id = tb2.advertiser_id
+        left join (select distinct app_id, app_name from hr_playlet.m_mini_app_info) tb3
+        on tb1.ma_appid = tb3.app_id
+        left join (select distinct app_id, app_name from hr_playlet.m_mini_app_info) tb4
+        on tb2.ma_appid = tb4.app_id
+        left join (select user_id, phonenumber, nick_name from deepthink.sys_user) tb5
+        on tb2.user_id=tb5.user_id
+        where tb1.ma_appid != tb2.ma_appid
+        order by tb2.user_id
+    </select>
 </mapper>

+ 276 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/ToolsSiteMapper.xml

@@ -26,4 +26,280 @@
             #{item.createType} )
         </foreach>
     </insert>
+
+    <select id="getAvatarAdvertiserIds">
+        select advertiser_id
+        from deepthink.advertiser_avatar
+        where avatar_status = 'IN_AUDIT'
+    </select>
+
+    <update id="updateAdvertiserAvatar" parameterType="cn.com.ctop.job.bytedance.data.entity.AdvertiserAvatar">
+        update deepthink.advertiser_avatar
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="avatarStatus != null">avatar_status = #{avatarStatus},</if>
+            <if test="avatarReason != null">avatar_reason = #{avatarReason},</if>
+            <if test="sourceStatus != null">source_status = #{sourceStatus},</if>
+            <if test="sourceInfo != null">source_info = #{sourceInfo},</if>
+            <if test="sourceReason != null">source_reason = #{sourceReason},</if>
+            <if test="webUri != null">web_uri = #{webUri},</if>
+            <if test="auditWebUri != null">audit_web_uri = #{auditWebUri},</if>
+            <if test="height != null">height = #{height},</if>
+            <if test="width != null">width = #{width},</if>
+            <if test="webUrl != null">web_url = #{webUrl},</if>
+            <if test="auditWebUrl != null">audit_web_url = #{auditWebUrl},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where advertiser_id = #{advertiserId}
+    </update>
+
+    <insert id="insertAdvertiserAvatar" parameterType="cn.com.ctop.job.bytedance.data.entity.AdvertiserAvatar">
+        insert into deepthink.advertiser_avatar
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="advertiserId != null">advertiser_id,</if>
+            <if test="avatarStatus != null">avatar_status,</if>
+            <if test="avatarReason != null">avatar_reason,</if>
+            <if test="sourceStatus != null">source_status,</if>
+            <if test="sourceInfo != null">source_info,</if>
+            <if test="sourceReason != null">source_reason,</if>
+            <if test="webUri != null">web_uri,</if>
+            <if test="auditWebUri != null">audit_web_uri,</if>
+            <if test="height != null">height,</if>
+            <if test="width != null">width,</if>
+            <if test="webUrl != null">web_url,</if>
+            <if test="auditWebUrl != null">audit_web_url,</if>
+            <if test="ossUrl != null">oss_url,</if>
+            <if test="reason != null">reason,</if>
+            <if test="parameters != null">parameters,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="advertiserId != null">#{advertiserId},</if>
+            <if test="avatarStatus != null">#{avatarStatus},</if>
+            <if test="avatarReason != null">#{avatarReason},</if>
+            <if test="sourceStatus != null">#{sourceStatus},</if>
+            <if test="sourceInfo != null">#{sourceInfo},</if>
+            <if test="sourceReason != null">#{sourceReason},</if>
+            <if test="webUri != null">#{webUri},</if>
+            <if test="auditWebUri != null">#{auditWebUri},</if>
+            <if test="height != null">#{height},</if>
+            <if test="width != null">#{width},</if>
+            <if test="webUrl != null">#{webUrl},</if>
+            <if test="auditWebUrl != null">#{auditWebUrl},</if>
+            <if test="ossUrl != null">#{ossUrl},</if>
+            <if test="reason != null">#{reason},</if>
+            <if test="parameters != null">#{parameters},</if>
+        </trim>
+    </insert>
+
+    <select id="getNameAdvertiserIds">
+        select advertiser_id
+        from deepthink.advertiser_name_info
+        where advertiser_status = 'STATUS_PENDING_CONFIRM'
+    </select>
+
+    <insert id="insertAdvertiserNameInfo" parameterType="cn.com.ctop.job.bytedance.data.entity.AdvertiserNameInfo">
+        insert into deepthink.advertiser_name_info
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="advertiserId != null">advertiser_id,</if>
+            <if test="advertiserName != null">advertiser_name,</if>
+            <if test="advertiserStatus != null">advertiser_status,</if>
+            <if test="reason != null">reason,</if>
+            <if test="parameters != null">parameters,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="advertiserId != null">#{advertiserId},</if>
+            <if test="advertiserName != null">#{advertiserName},</if>
+            <if test="advertiserStatus != null">#{advertiserStatus},</if>
+            <if test="reason != null">#{reason},</if>
+            <if test="parameters != null">#{parameters},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+        </trim>
+    </insert>
+
+    <update id="updateAdvertiserNameInfo" parameterType="cn.com.ctop.job.bytedance.data.entity.AdvertiserNameInfo">
+        update deepthink.advertiser_name_info
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="advertiserName != null">advertiser_name = #{advertiserName},</if>
+            <if test="advertiserStatus != null">advertiser_status = #{advertiserStatus},</if>
+            <if test="reason != null">reason = #{reason},</if>
+            <if test="parameters != null">parameters = #{parameters},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where advertiser_id = #{advertiserId}
+    </update>
+
+
+    <select id="getAppAdvertiserIds">
+        select advertiser_id
+        from deepthink.advertiser_app_list
+        where advertiser_status = 'AUDITING'
+          AND plat_type = #{platType}
+    </select>
+
+
+    <insert id="insertAdvertiserAppList" parameterType="cn.com.ctop.job.bytedance.data.entity.AdvertiserApplet"
+            useGeneratedKeys="true"
+            keyProperty="id">
+        replace into deepthink.advertiser_app_list
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="advertiserId != null">advertiser_id,</if>
+            <if test="appName != null">app_name,</if>
+            <if test="remark != null">remark,</if>
+            <if test="instanceId != null">instance_id,</if>
+            <if test="appId != null">app_id,</if>
+            <if test="originalAppId != null">original_app_id,</if>
+            <if test="platType != null">plat_type,</if>
+            <if test="auditStatus != null">audit_status,</if>
+            <if test="reason != null">reason,</if>
+            <if test="link != null">link,</if>
+            <if test="linkRemark != null">link_remark,</if>
+            <if test="path != null">path,</if>
+            <if test="remarkMessage != null">remark_message,</if>
+            <if test="iconImageUrl != null">icon_image_url,</if>
+            <if test="headerImageUrl != null">header_image_url,</if>
+            <if test="labels != null">labels,</if>
+            <if test="guideText != null">guide_text,</if>
+            <if test="imagesVerticalUrl != null">images_vertical_url,</if>
+            <if test="imagesHorizontalUrl != null">images_horizontal_url,</if>
+            <if test="introduction != null">introduction,</if>
+            <if test="tagInfo != null">tag_info,</if>
+            <if test="startPage != null">start_page,</if>
+            <if test="startParam != null">start_param,</if>
+            <if test="appCreateTime != null">app_create_time,</if>
+            <if test="appUpdateTime != null">app_update_time,</if>
+            <if test="parameters != null">parameters,</if>
+            <if test="taskId != null">task_id,</if>
+            <if test="appShare != null">app_share,</if>
+            <if test="shareAdvertiserId != null">share_advertiser_id,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="advertiserId != null">#{advertiserId},</if>
+            <if test="appName != null">#{appName},</if>
+            <if test="remark != null">#{remark},</if>
+            <if test="instanceId != null">#{instanceId},</if>
+            <if test="appId != null">#{appId},</if>
+            <if test="originalAppId != null">#{originalAppId},</if>
+            <if test="platType != null">#{platType},</if>
+            <if test="auditStatus != null">#{auditStatus},</if>
+            <if test="reason != null">#{reason},</if>
+            <if test="link != null">#{link},</if>
+            <if test="linkRemark != null">#{linkRemark},</if>
+            <if test="path != null">#{path},</if>
+            <if test="remarkMessage != null">#{remarkMessage},</if>
+            <if test="iconImageUrl != null">#{iconImageUrl},</if>
+            <if test="headerImageUrl != null">#{headerImageUrl},</if>
+            <if test="labels != null">#{labels},</if>
+            <if test="guideText != null">#{guideText},</if>
+            <if test="imagesVerticalUrl != null">#{imagesVerticalUrl},</if>
+            <if test="imagesHorizontalUrl != null">#{imagesHorizontalUrl},</if>
+            <if test="introduction != null">#{introduction},</if>
+            <if test="tagInfo != null">#{tagInfo},</if>
+            <if test="startPage != null">#{startPage},</if>
+            <if test="startParam != null">#{startParam},</if>
+            <if test="appCreateTime != null">#{appCreateTime},</if>
+            <if test="appUpdateTime != null">#{appUpdateTime},</if>
+            <if test="parameters != null">#{parameters},</if>
+            <if test="taskId != null">#{taskId},</if>
+            <if test="appShare != null">#{appShare},</if>
+            <if test="shareAdvertiserId != null">#{shareAdvertiserId},</if>
+        </trim>
+    </insert>
+
+    <update id="updateAdvertiserAppList" parameterType="cn.com.ctop.job.bytedance.data.entity.AdvertiserApplet">
+        update deepthink.advertiser_app_list
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="advertiserId != null">advertiser_id = #{advertiserId},</if>
+            <if test="appName != null">app_name = #{appName},</if>
+            <if test="remark != null">remark = #{remark},</if>
+            <if test="instanceId != null">instance_id = #{instanceId},</if>
+            <if test="appId != null">app_id = #{appId},</if>
+            <if test="originalAppId != null">original_app_id = #{originalAppId},</if>
+            <if test="platType != null">plat_type = #{platType},</if>
+            <if test="auditStatus != null">audit_status = #{auditStatus},</if>
+            <if test="reason != null">reason = #{reason},</if>
+            <if test="link != null">link = #{link},</if>
+            <if test="linkRemark != null">link_remark = #{linkRemark},</if>
+            <if test="path != null">path = #{path},</if>
+            <if test="remarkMessage != null">remark_message = #{remarkMessage},</if>
+            <if test="iconImageUrl != null">icon_image_url = #{iconImageUrl},</if>
+            <if test="headerImageUrl != null">header_image_url = #{headerImageUrl},</if>
+            <if test="labels != null">labels = #{labels},</if>
+            <if test="guideText != null">guide_text = #{guideText},</if>
+            <if test="imagesVerticalUrl != null">images_vertical_url = #{imagesVerticalUrl},</if>
+            <if test="imagesHorizontalUrl != null">images_horizontal_url = #{imagesHorizontalUrl},</if>
+            <if test="introduction != null">introduction = #{introduction},</if>
+            <if test="tagInfo != null">tag_info = #{tagInfo},</if>
+            <if test="startPage != null">start_page = #{startPage},</if>
+            <if test="startParam != null">start_param = #{startParam},</if>
+            <if test="appCreateTime != null">app_create_time = #{appCreateTime},</if>
+            <if test="appUpdateTime != null">app_update_time = #{appUpdateTime},</if>
+            <if test="taskId != null">task_id = #{taskId},</if>
+            <if test="appShare != null">app_share = #{appShare},</if>
+            <if test="shareAdvertiserId != null">share_advertiser_id = #{shareAdvertiserId},</if>
+        </trim>
+        WHERE advertiser_id = #{advertiserId}
+        AND instance_id = #{instanceId}
+        AND plat_type = #{platType}
+    </update>
+
+    <select id="getsiteAdvertiserIds">
+        select advertiser_id
+        from deepthink.advertiser_tools_site
+        where advertiser_status = 'EDIT'
+    </select>
+
+    <update id="updateAdvertiserToolsSite" parameterType="cn.com.ctop.job.bytedance.data.entity.AdvertiserToolsSite">
+        update deepthink.advertiser_tools_site
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="name != null">name = #{name},</if>
+            <if test="thumbnail != null">thumbnail = #{thumbnail},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="siteType != null">site_type = #{siteType},</if>
+            <if test="functionType != null">function_type = #{functionType},</if>
+            <if test="createType != null">create_type = #{createType},</if>
+            <if test="parameters != null">parameters = #{parameters},</if>
+            <if test="taskId != null">task_id = #{taskId},</if>
+        </trim>
+        where site_id = #{siteId}
+        AND advertiser_id = #{advertiserId}
+    </update>
+
+
+    <insert id="insertAdvertiserToolsSite" parameterType="cn.com.ctop.job.bytedance.data.entity.AdvertiserToolsSite">
+        replace into deepthink.advertiser_tools_site
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="siteId != null">site_id,</if>
+            <if test="advertiserId != null">advertiser_id,</if>
+            <if test="name != null">name,</if>
+            <if test="thumbnail != null">thumbnail,</if>
+            <if test="status != null">status,</if>
+            <if test="reason != null">reason,</if>
+            <if test="siteType != null">site_type,</if>
+            <if test="functionType != null">function_type,</if>
+            <if test="createType != null">create_type,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="parameters != null">parameters,</if>
+            <if test="taskId != null">task_id,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="siteId != null">#{siteId},</if>
+            <if test="advertiserId != null">#{advertiserId},</if>
+            <if test="name != null">#{name},</if>
+            <if test="thumbnail != null">#{thumbnail},</if>
+            <if test="status != null">#{status},</if>
+            <if test="reason != null">#{reason},</if>
+            <if test="siteType != null">#{siteType},</if>
+            <if test="functionType != null">#{functionType},</if>
+            <if test="createType != null">#{createType},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="parameters != null">#{parameters},</if>
+            <if test="taskId != null">#{taskId},</if>
+        </trim>
+    </insert>
 </mapper>

+ 6 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IBindAppErrorWarnService.java

@@ -0,0 +1,6 @@
+package cn.com.ctop.job.bytedance.data.service;
+
+public interface IBindAppErrorWarnService {
+
+    void send();
+}

+ 0 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IBytedancePromoterReportService.java

@@ -12,7 +12,6 @@ public interface IBytedancePromoterReportService {
 
     void getBytedancePromoterRetryDailyReport(Long errorId, Long advertiserId, String accessToken, String startDate, String endDate, Integer page,Integer isSend);
 
-    List<JSONObject> getChannelInfoList();
 
     void getBytedancePromoterHour(Long advertiserId, String accessToken, String startDate, String endDate, Integer page, Integer isLog);
 

+ 6 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IChannelService.java

@@ -10,4 +10,10 @@ public interface IChannelService {
     void getOrderList(String startDt, String endDt, String appId, String appName, String distributorId, String secretKey, Integer isLog, Long errId, Integer isSend);
 
     List<JSONObject> getChangDuRetry();
+
+    void getDistributorConfig();
+
+    List<JSONObject> getChannelInfoList();
+
+    void syncMovieId(String startDate,String endDate);
 }

+ 19 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IToolsSiteService.java

@@ -1,6 +1,24 @@
 package cn.com.ctop.job.bytedance.data.service;
 
+import java.util.List;
+
 public interface IToolsSiteService {
 
-    void getToolsSiteStatusList(String accessToken, Long advertiserId, int page);
+    List<Long> getAvatarAdvertiserIds();
+
+    void updateAvatarStatus(Long id);
+
+    List<Long> getNameAdvertiserIds();
+
+    void updateNameStatus(Long id);
+
+    List<Long> getAppAdvertiserIds(String platType);
+
+    void updateWxAppStatus(Long advertiserId, String searchType, Integer page);
+
+    void updateTTAppStatus(Long id, String createOnly, Integer page);
+
+    List<Long> getSiteAdvertiserIds();
+
+    void updateSiteStatus(Long id, Integer page);
 }

+ 5 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/ITotalRankPushService.java

@@ -0,0 +1,5 @@
+package cn.com.ctop.job.bytedance.data.service;
+
+public interface ITotalRankPushService {
+    void send();
+}

+ 191 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BindAppErrorWarnServiceImpl.java

@@ -0,0 +1,191 @@
+package cn.com.ctop.job.bytedance.data.service.impl;
+
+import cn.com.ctop.job.bytedance.data.mapper.ReportsAdPushMapper;
+import cn.com.ctop.job.bytedance.data.service.IBindAppErrorWarnService;
+import cn.com.ctop.job.bytedance.data.utils.Check;
+import cn.com.ctop.job.bytedance.data.utils.DateUtils;
+import cn.com.ctop.job.bytedance.utils.FeishuRobotUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class BindAppErrorWarnServiceImpl implements IBindAppErrorWarnService {
+
+    private static final String TEMPLATE_VERSION = "1.0.1";
+    private static final String TEMPLATE_ID = "AAqRUxu6bzaaa";
+    @Autowired
+    ReportsAdPushMapper reportsPushMapper;
+
+
+    @Override
+    public void send() {
+        List<JSONObject> users = reportsPushMapper.selectUserList();
+        List<String> mobiles = users.stream().map(user -> user.getString("phonenumber"))
+                .filter(s -> s != null && s.length() == 11)
+                .collect(Collectors.toList());
+        String last30Day = DateUtils.getNowAddDate("yyyy-MM-dd", -30);
+        Long last30DayLong = Long.parseLong(last30Day.substring(0, 10).replaceAll("-", ""));
+
+        List<Map<String, String>> bindAppErrorWarnList = reportsPushMapper.bindAppErrorData(last30DayLong);
+        if (Check.isNull(bindAppErrorWarnList)){
+            log.info(">>>> 没有绑定错误的广告账号,任务结束");
+            return;
+        }
+
+        long lastUserId = 0L;
+        ErrorBind lastBind = null;
+        List<ErrorBind> errorBinds = new ArrayList<>();
+        for (Map<String, String> map : bindAppErrorWarnList) {
+            long userId = Long.parseLong(String.valueOf(map.get("user_id")));
+            if (lastUserId != userId) {
+                if (lastBind != null) {
+                    errorBinds.add(lastBind);
+                }
+                lastBind = new ErrorBind();
+                lastBind.setPhoneNumber(map.get("phonenumber"));
+                lastBind.setNickName(map.get("nick_name"));
+                lastBind.setErrorNum(1);
+                lastBind.setList(new ArrayList<>());
+                lastUserId = userId;
+            } else {
+                lastBind.setErrorNum(lastBind.getErrorNum() + 1);
+            }
+            lastBind.getList().add(map);
+        }
+        if (lastBind != null) {
+            errorBinds.add(lastBind);
+        }
+
+        System.out.println(JSON.toJSONString(errorBinds));
+        String alarm_time = DateUtils.getNowDate("yyyy-MM-dd HH:mm:ss");
+
+        String token = null;
+        Map<String, String> mobileMap = null;
+        try {
+            token = FeishuRobotUtil.getFsAdlbTenantToken();
+            mobileMap = FeishuRobotUtil.getFsUserIds(token, mobiles); //mobile -> userId
+        }catch (IOException e){
+            log.error("获取飞书token失败", e);
+            return;
+        }
+
+        for (ErrorBind errorBind : errorBinds) {
+            String userId = mobileMap.get(errorBind.getPhoneNumber());
+            if (!Check.isNull(userId) && errorBind.getErrorNum() > 0) {
+                JSONObject template_variable = new JSONObject();
+                template_variable.put("unbindNum", errorBind.getErrorNum());
+                template_variable.put("alarm_time", alarm_time);
+                JSONArray object_list_1 = new JSONArray();
+                int index = 0;
+                for (Map<String, String> map : errorBind.getList()){
+                    if (++index > 20){
+                        break;
+                    }
+                    JSONObject object = new JSONObject();
+                    object.put("advertiserName", map.get("advertiser_name"));
+                    object.put("advertiserId", String.valueOf(map.get("advertiser_id")));
+                    object.put("errorApp", String.valueOf(map.get("error_app_name")));
+                    object.put("rightApp", String.valueOf(map.get("right_app_name")));
+                    object_list_1.add(object);
+                }
+                template_variable.put("object_list_1", object_list_1);
+
+                JSONObject content = new JSONObject();
+                JSONObject contentData = new JSONObject();
+                contentData.put("template_id",TEMPLATE_ID);
+                contentData.put("template_version_name", TEMPLATE_VERSION);
+                contentData.put("template_variable", template_variable);
+                content.put("type", "template");
+                content.put("data", contentData);
+
+                JSONObject request = new JSONObject();
+                request.put("receive_id", userId);
+//                request.put("receive_id", "44fbaed6");
+                request.put("msg_type", "interactive");
+                request.put("content", content.toJSONString());
+                System.out.println("发送给: "+errorBind.getNickName());
+                sendToFeishu(token, request);
+            }
+        }
+
+        JSONObject template_variable = new JSONObject();
+        template_variable.put("unbindNum", bindAppErrorWarnList.size());
+        template_variable.put("alarm_time", alarm_time);
+        JSONArray object_list_1 = new JSONArray();
+        int index = 0;
+        for (Map<String, String> map : bindAppErrorWarnList){
+            if (++index > 20){
+                break;
+            }
+            JSONObject object = new JSONObject();
+            object.put("advertiserName", map.get("advertiser_name"));
+            object.put("advertiserId", String.valueOf(map.get("advertiser_id")));
+            object.put("errorApp", String.valueOf(map.get("error_app_name")));
+            object.put("rightApp", String.valueOf(map.get("right_app_name")));
+            object_list_1.add(object);
+        }
+        template_variable.put("object_list_1", object_list_1);
+
+        JSONObject content = new JSONObject();
+        JSONObject contentData = new JSONObject();
+        contentData.put("template_id",TEMPLATE_ID);
+        contentData.put("template_version_name", TEMPLATE_VERSION);
+        contentData.put("template_variable", template_variable);
+        content.put("type", "template");
+        content.put("data", contentData);
+
+        JSONObject request = new JSONObject();
+        request.put("receive_id", "44fbaed6");
+        request.put("msg_type", "interactive");
+        request.put("content", content.toJSONString());
+        sendToFeishu(token, request);
+        request.put("receive_id", "58e7a98a");
+        sendToFeishu(token, request);
+
+    }
+
+    private void sendToFeishu(String token, JSONObject requestBody){
+        //发送
+        try (CloseableHttpClient client = HttpClients.createDefault()){
+            HttpPost httpPost = new HttpPost("https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=user_id");
+            httpPost.setHeader("Authorization", "Bearer "+token);
+            HttpEntity entity = new StringEntity(requestBody.toJSONString(), "UTF-8");
+            httpPost.setEntity(entity);
+            httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
+            CloseableHttpResponse respon = client.execute(httpPost);
+            System.out.println("发送结果: "+ EntityUtils.toString(respon.getEntity(), "UTF-8"));
+        } catch (IOException e) {
+            log.error("发送飞书消息失败", e);
+        }
+    }
+
+
+
+    @Data
+     public static class ErrorBind{
+        String phoneNumber;
+        String nickName;
+        int errorNum;
+        List<Map<String, String>> list;
+    }
+
+}

+ 1 - 4
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/BytedancePromoterReportServiceImpl.java

@@ -192,10 +192,7 @@ public class BytedancePromoterReportServiceImpl implements IBytedancePromoterRep
         }
     }
 
-    @Override
-    public List<JSONObject> getChannelInfoList() {
-        return promoterReportMapper.getChannelInfoList();
-    }
+
 
     @Override
     public void getBytedancePromoterHour(Long advertiserId, String accessToken, String startDate, String endDate, Integer page, Integer isLog) {

+ 141 - 4
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/ChannelServiceImpl.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.job.bytedance.data.service.impl;
 
 import cn.com.ctop.job.bytedance.data.entity.BytedanceErrorLog;
+import cn.com.ctop.job.bytedance.data.entity.ChangDuAppDistributor;
 import cn.com.ctop.job.bytedance.data.entity.ChangDuOrder;
 import cn.com.ctop.job.bytedance.data.entity.ChannelChangdunovelInfo;
 import cn.com.ctop.job.bytedance.data.mapper.BytedancePromoterReportMapper;
@@ -17,9 +18,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Service
 @Slf4j
@@ -88,7 +87,115 @@ public class ChannelServiceImpl implements IChannelService {
             e.printStackTrace();
 
         }
+    }
 
+    @Override
+    public void getDistributorConfig() {
+        try {
+            List<JSONObject> distributorApp = getDistributorApp();
+            Set<ChangDuAppDistributor> adds = new HashSet<>();
+            for (JSONObject appDistributor : distributorApp) {
+                String appId = appDistributor.getString("app_id");
+                String appName = appDistributor.getString("app_name");
+                String apiKey = appDistributor.getString("api_key");
+                String distributorId = appDistributor.getString("distributor_id");
+                String changduAccountId = appDistributor.getString("changdu_account_id");
+                String accountName = appDistributor.getString("account_name");
+                int thisPageIndex = 0;
+                int pageSize = 50;
+                int totalPageIndex = 0;
+                while (thisPageIndex <= totalPageIndex) {
+                    String url = "https://www.changdunovel.com/novelsale/openapi/wx/get_bound_package_list/v1/";
+                    String ts = String.valueOf(System.currentTimeMillis()).substring(0, 10);
+                    String sign = getSign(distributorId, apiKey, ts);
+                    Map<String, Object> params = new JSONObject();
+                    params.put("distributor_id", distributorId);
+                    params.put("ts", ts);
+                    params.put("sign", sign);
+                    params.put("app_id", appId);
+                    params.put("page_index", thisPageIndex);
+                    params.put("page_size", pageSize);
+                    String s = HttpUtils.httpGet(url, params, null);
+                    JSONObject jsonObject = JSONObject.parseObject(s);
+                    if (!Check.isNull(jsonObject)) {
+                        Integer code = jsonObject.getInteger("code");
+                        if (code == 200) {
+                            int total = jsonObject.getIntValue("total");
+                            totalPageIndex = (int) Math.ceil(total * 1.0 / pageSize) - 1;
+                            JSONArray result = jsonObject.getJSONArray("wx_package_info_open_list");
+                            if (!Check.isNull(result)) {
+                                for (int i = 0; i < result.size(); i++) {
+                                    JSONObject resultJson = result.getJSONObject(i);
+                                    ChangDuAppDistributor distributorConfig = JSONObject.parseObject(resultJson.toJSONString(), ChangDuAppDistributor.class);
+                                    distributorConfig.setChangduAccountId(changduAccountId);
+                                    distributorConfig.setChannelType(3);
+                                    distributorConfig.setApiKey(apiKey);
+                                    distributorConfig.setDistributorName(accountName + "-" + appName + "-" + distributorConfig.getNickName());
+                                    log.info("番茄获取小程序绑定的渠道信息 {}", distributorConfig);
+                                    adds.add(distributorConfig);
+                                }
+                            }
+                        } else {
+                            log.error("番茄获取小程序绑定的渠道信息失败,返回信息:{}", jsonObject);
+                        }
+                    } else {
+                        log.error("番茄获取小程序绑定的渠道信息失败,返回信息为空。");
+                    }
+                    thisPageIndex = thisPageIndex + 1;
+                }
+            }
+            if (!Check.isNull(adds)) {
+                channelMapper.insertChangduDistributorApp(adds);
+                channelMapper.insertChangduDistributorConfig(adds);
+                channelMapper.insertChannelAccountInfo(adds);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private List<JSONObject> getDistributorApp() {
+        List<JSONObject> appDistributors = new ArrayList<>();
+        try {
+            List<JSONObject> list = channelMapper.getDistributorKey();
+            for (JSONObject didKey : list) {
+                String changduAccountId = didKey.getString("changduAccountId");
+                String distributorId = didKey.getString("distributorId");
+                String apiKey = didKey.getString("apiKey");
+                String accountName = didKey.getString("accountName");
+                String url = "https://www.changdunovel.com/novelsale/openapi/package_info/v1/";
+                String ts = String.valueOf(System.currentTimeMillis()).substring(0, 10);
+                String sign = getSign(distributorId, apiKey, ts);
+                Map<String, Object> params = new JSONObject();
+                params.put("distributor_id", distributorId);
+                params.put("ts", ts);
+                params.put("sign", sign);
+                String s = HttpUtils.httpGet(url, params, null);
+                JSONObject jsonObject = JSONObject.parseObject(s);
+                if (!Check.isNull(jsonObject)) {
+                    Integer code = jsonObject.getInteger("code");
+                    if (code == 200) {
+                        JSONArray result = jsonObject.getJSONArray("result");
+                        if (!Check.isNull(result)) {
+                            for (int i = 0; i < result.size(); i++) {
+                                JSONObject resultJson = result.getJSONObject(i);
+                                resultJson.put("changdu_account_id", changduAccountId);
+                                resultJson.put("api_key", apiKey);
+                                resultJson.put("account_name", accountName);
+                                log.info("番茄获取账户内快应用/公众号列表 {}", resultJson);
+                                appDistributors.add(resultJson);
+                            }
+                        }
+                    } else {
+                        log.error("番茄获取账户内快应用/公众号列表失败,返回信息:{}", jsonObject);
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return appDistributors;
     }
 
     @Override
@@ -196,7 +303,7 @@ public class ChannelServiceImpl implements IChannelService {
                                     order.setMovieName(channelMapper.getMovieName(order.getMovieId()));
                                     order.setDyingMovieId(dyingMovieId);
                                     order.setDyingMovieName(dyingMovieName);
-                                    log.info("常读order:[{}]",order);
+                                    log.info("常读order:[{}]", order);
                                     adds.add(order);
                                 }
                             }
@@ -235,6 +342,36 @@ public class ChannelServiceImpl implements IChannelService {
         return channelMapper.getChangDuRetryJob();
     }
 
+    @Override
+    public List<JSONObject> getChannelInfoList() {
+        return channelMapper.getChannelInfoList();
+    }
+
+    @Override
+    public void syncMovieId(String startDate, String endDate) {
+        String url = "https://api.deepthink.artlinkworld.cn/changdu/movieConfig/taskAdd";
+        try {
+            List<String> syncMovieIds = channelMapper.getSyncMovieList(startDate, endDate);
+            log.info("录入常读剧列表size:{}", syncMovieIds.size());
+            for (String movieId : syncMovieIds) {
+                HashMap<String, Object> postParam = new HashMap<>();
+                postParam.put("movieId", movieId);
+                postParam.put("movieSource", 2);
+                String s = HttpUtils.httpPostRequest(url, postParam, null);
+                JSONObject jsonObject = JSONObject.parseObject(s);
+                if (!Check.isNull(jsonObject) && jsonObject.getInteger("code") == 0) {
+                    log.info("movieId: {} 录入成功", movieId);
+                } else {
+                    log.error("movieId: {} 录入失败,返回:{}", movieId, s);
+                }
+                Thread.sleep(500);
+            }
+        } catch (Exception e) {
+            log.error("录入常读剧列表失败", e);
+            e.printStackTrace();
+        }
+    }
+
     private static String getSign(String distributorId, String secretKey, String ts) {
         return SecureUtil.md5(distributorId + secretKey + ts).toLowerCase();
     }

+ 35 - 38
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/OptimizerRankPushServiceImpl.java

@@ -2,6 +2,7 @@ package cn.com.ctop.job.bytedance.data.service.impl;
 
 import cn.com.ctop.job.bytedance.data.mapper.ReportsAdPushMapper;
 import cn.com.ctop.job.bytedance.data.service.IOptimizerRankPushService;
+import cn.com.ctop.job.bytedance.data.utils.Check;
 import cn.com.ctop.job.bytedance.data.utils.DateUtils;
 import cn.com.ctop.job.bytedance.utils.FeishuRobotUtil;
 import com.alibaba.fastjson.JSONArray;
@@ -19,7 +20,6 @@ import org.springframework.stereotype.Service;
 
 import java.io.IOException;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -30,8 +30,8 @@ public class OptimizerRankPushServiceImpl implements IOptimizerRankPushService {
     @Autowired
     ReportsAdPushMapper reportsPushMapper;
 
-    private static final String TEMPLATE_VERSION = "1.0.8";
-    private static final String TEMPLATE_ID = "AAqBGPmrbiJtk";
+    private static final String TEMPLATE_VERSION = "1.0.5";
+    private static final String TEMPLATE_ID = "AAqRUxrkkWuZf";
 
     public void send() {
         List<JSONObject> users = reportsPushMapper.selectUserList();
@@ -48,33 +48,15 @@ public class OptimizerRankPushServiceImpl implements IOptimizerRankPushService {
             return;
         }
 
-        JSONObject template_variable = new JSONObject();
+
         String today = DateUtils.getNowDate("yyyy-MM-dd");
         Long todayLong = Long.parseLong(today.replaceAll("-", ""));
         int hour = Integer.parseInt(DateUtils.getNowDate("H"));
         int lastHour = hour -1;
         int lastLastHour = hour -2;
-        template_variable.put("todaydate", today.substring(5, 10));
-        template_variable.put("thisHour", String.valueOf(hour));
-        template_variable.put("lastHour", String.valueOf(lastHour));
-        template_variable.put("lastLastHour", String.valueOf(lastLastHour));
-        JSONArray object_list_4 = new JSONArray();//优化师排名
+
         List<Map<String, String>> optimizerCostRank = reportsPushMapper.optimizerCostRank(todayLong, String.valueOf(lastHour));
-        for (int i = 0; i < optimizerCostRank.size(); i++) {
-            Map<String, String> map = optimizerCostRank.get(i);
-            JSONObject object = new JSONObject();
-            object.put("rankRank", String.valueOf(map.getOrDefault("rk", "-")));
-            if (mobileMap.containsKey(map.get("phonenumber"))){
-                object.put("user_id", Arrays.asList(mobileMap.get(map.get("phonenumber"))));
-            }else {
-                object.put("user_id", Collections.emptyList());
-            }
-            object.put("rankTodayData", String.valueOf(map.getOrDefault("cost_amount", "0")));
-//            object.put("rankThisHourData", String.valueOf(map.getOrDefault("hour_cost_amount", "0")));
-            object.put("rankRealROI", String.valueOf(map.getOrDefault("real_roi", "0")));
-            object_list_4.add(object);
-        }
-        template_variable.put("object_list_4", object_list_4);
+        Map<String, List<Map<String, String>>> deptMap = optimizerCostRank.stream().collect(Collectors.groupingBy(m -> String.valueOf(m.get("dept_id"))));
 
         List<Map<String, String>> todayData = reportsPushMapper.optimizerDateData(todayLong);
         List<Map<String, String>> hourData = reportsPushMapper.optimizerHourData(todayLong, String.valueOf(lastHour));
@@ -89,12 +71,35 @@ public class OptimizerRankPushServiceImpl implements IOptimizerRankPushService {
                 new Pair<>("real_roi", "真实ROI")
         );
 
-//        int index = 0;
+
         for (Map<String, String> optToday : todayData){
-//            if (index++ >= 1){
-//                break;
-//            }
-            JSONArray object_list_5 = new JSONArray();//本人数据
+            String deptId = String.valueOf(optToday.get("dept_id"));
+            if (deptId.equals("30201")){
+                continue;
+            }
+
+            JSONObject template_variable = new JSONObject();
+            template_variable.put("todaydate", today.substring(5, 10));
+            template_variable.put("thisHour", String.valueOf(hour));
+            template_variable.put("lastHour", String.valueOf(lastHour));
+            template_variable.put("lastLastHour", String.valueOf(lastLastHour));
+            List<Map<String, String>> deptUserData = deptMap.get(deptId);
+            if (!Check.isNull(deptUserData)){
+                JSONArray object_list_4 = new JSONArray();
+                for (Map<String, String> deptUser: deptUserData){
+                    //rankTodayData, rankRank, rankRealROI, userId
+                    JSONObject object = new JSONObject();
+                    object.put("rankTodayData", deptUser.get("cost_amount"));
+                    object.put("rankRank", deptUser.get("rk"));
+                    object.put("rankRealROI", deptUser.get("real_roi"));
+                    object.put("userId", Arrays.asList(mobileMap.get(String.valueOf(deptUser.get("phonenumber")))));
+                    object_list_4.add(object);
+                }
+                template_variable.put("object_list_4", object_list_4);
+            }
+
+
+            JSONArray object_list_5 = new JSONArray();
             Map<String, String> optHour = hourDataMap.get(String.valueOf(optToday.get("user_id")));
             Map<String, String> optLastHour = lastHourDataMap.get(String.valueOf(optToday.get("user_id")));
             String rank = String.valueOf(optToday.get("rk"));
@@ -117,16 +122,9 @@ public class OptimizerRankPushServiceImpl implements IOptimizerRankPushService {
             template_variable.put("object_list_5", object_list_5);
             System.out.println("发送目标: nickName: "+nickName+", userId: "+ userId + ", feishuUserId: "+mobileMap.get(phoneNumber)+", rank: "+rank+", costAmount: "+costAmount);
             sendToFeishu(token, template_variable, mobileMap.get(phoneNumber));
+//            sendToFeishu(token, template_variable, "44fbaed6");
             //clear
-            template_variable.remove("myRank");
-            template_variable.remove("object_list_5");
         }
-
-        template_variable.put("myRank", "0");
-        sendToFeishu(token, template_variable, "44fbaed6");//zhaotx
-        sendToFeishu(token, template_variable, "c5f6b59d");//yuyang
-        sendToFeishu(token, template_variable, "265g9ef1");//wangshu
-        sendToFeishu(token, template_variable, "58e7a98a");//xsq
     }
 
     private void sendToFeishu(String token, JSONObject template_variable, String receive_id) {
@@ -140,7 +138,6 @@ public class OptimizerRankPushServiceImpl implements IOptimizerRankPushService {
 
         JSONObject request = new JSONObject();
         request.put("receive_id", receive_id);
-//        request.put("receive_id", "44fbaed6");
         request.put("msg_type", "interactive");
         request.put("content", content.toJSONString());
         //发送

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/ReportsAdPushServiceImpl.java


+ 188 - 17
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/ToolsSiteServiceImpl.java

@@ -1,9 +1,14 @@
 package cn.com.ctop.job.bytedance.data.service.impl;
 
+import cn.com.ctop.job.bytedance.data.entity.AdvertiserApplet;
+import cn.com.ctop.job.bytedance.data.entity.AdvertiserAvatar;
+import cn.com.ctop.job.bytedance.data.entity.AdvertiserNameInfo;
 import cn.com.ctop.job.bytedance.data.entity.AdvertiserToolsSite;
+import cn.com.ctop.job.bytedance.data.mapper.BytedanceRefreshTokenMapper;
 import cn.com.ctop.job.bytedance.data.mapper.ToolsSiteMapper;
 import cn.com.ctop.job.bytedance.data.service.IToolsSiteService;
 import cn.com.ctop.job.bytedance.data.utils.Check;
+import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
 import cn.com.ctop.job.bytedance.data.utils.Okhttp3Utils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -11,7 +16,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -22,45 +27,211 @@ public class ToolsSiteServiceImpl implements IToolsSiteService {
     @Autowired
     private ToolsSiteMapper toolsSiteMapper;
 
+    @Autowired
+    private BytedanceRefreshTokenMapper tokenMapper;
+
+    @Override
+    public List<Long> getAvatarAdvertiserIds() {
+        return toolsSiteMapper.getAvatarAdvertiserIds();
+    }
+
+    @Override
+    public void updateAvatarStatus(Long advertiserId) {
+        String accessToken = tokenMapper.onlyGetToken(advertiserId);
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", advertiserId);
+        String url = "https://ad.oceanengine.com/open_api/2/advertiser/avatar/get/";
+        JSONObject obj = Okhttp3Utils.bytedanceGetRequest(accessToken, url, params);
+        System.out.println(obj);
+        if (!Check.isNull(obj)) {
+            Integer code = obj.getInteger("code");
+            if (code == 0) {
+                AdvertiserAvatar advertiserAvatar = new AdvertiserAvatar(obj.getJSONObject("data"));
+                if (!toolsSiteMapper.updateAdvertiserAvatar(advertiserAvatar)) {
+                    toolsSiteMapper.insertAdvertiserAvatar(advertiserAvatar);
+                }
+            } else {
+                log.error("更新广告主账户头像失败,返回结果:{}", obj);
+            }
+        }
+    }
+
+    @Override
+    public List<Long> getNameAdvertiserIds() {
+        return toolsSiteMapper.getNameAdvertiserIds();
+    }
+
+    @Override
+    public void updateNameStatus(Long advertiserId) {
+        String accessToken = tokenMapper.onlyGetToken(advertiserId);
+        Map<String, Object> params = new HashMap<>();
+        params.put("account_ids", new JSONArray(Collections.singletonList(advertiserId)));
+        String url = "https://api.oceanengine.com/open_api/2/agent/advertiser_info/query/";
+        String results = HttpUtils.httpGet(url, params, HttpUtils.postMHeaders(accessToken));
+        JSONObject obj = JSONObject.parseObject(results);
+        System.out.println(obj);
+        Integer code = obj.getInteger("code");
+        if (code == 0) {
+            JSONArray array = obj.getJSONObject("data").getJSONArray("account_detail_list");
+            JSONObject object = array.getJSONObject(0);
+            if (!Check.isNull(object)) {
+                AdvertiserNameInfo nameInfo = new AdvertiserNameInfo(advertiserId, object.getString("advertiser_name"), object.getString("advertiser_status"));
+                if (!toolsSiteMapper.updateAdvertiserNameInfo(nameInfo)) {
+                    toolsSiteMapper.insertAdvertiserNameInfo(nameInfo);
+                }
+            }
+        } else {
+            log.error("更新广告主账户名称失败,返回结果:{}", obj);
+        }
+    }
+
+    @Override
+    public List<Long> getAppAdvertiserIds(String platType) {
+        return toolsSiteMapper.getAppAdvertiserIds(platType);
+    }
+
+    @Override
+    public void updateWxAppStatus(Long advertiserId, String searchType, Integer page) {
+        boolean nextPage = false;
+        String accessToken = tokenMapper.onlyGetToken(advertiserId);
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", advertiserId);
+        params.put("page", page);
+        //页面大小,默认值为10,最大值100
+        params.put("page_size", 100);
+        JSONObject filtering = new JSONObject();
+        //CREATE_ONLY本户创建,SHARE_ONLY 只查共享应用
+        filtering.put("search_type", searchType);
+       /*
+       //AUDIT_ACCEPTED 审核通过、AUDITING 审核中、AUDIT_REJECTED 审核不通过。不传表示全部状态
+        filtering.put("audit_status", "AUDIT_ACCEPTED");
+        */
+           /* JSONObject createTime = new JSONObject();
+            createTime.put("start_time", startDate);
+            createTime.put("end_time", DateUtils.getLastDay(endDate, -1));
+            filtering.put("create_time", createTime);*/
+        params.put("filtering", filtering);
+        //获取微信小程序列表
+        String url = "https://api.oceanengine.com/open_api/v3.0/tools/wechat_applet/list/";
+        JSONObject obj = Okhttp3Utils.bytedanceGetRequest(accessToken, url, params);
+        Integer code = obj.getInteger("code");
+        System.out.println(obj);
+        if (code == 0) {
+            JSONObject data = obj.getJSONObject("data");
+            Integer totalPage = data.getJSONObject("page_info").getInteger("total_page");
+            if (totalPage != 0 && totalPage != data.getJSONObject("page_info").getInteger("page")) {
+                nextPage = true;
+            }
+            JSONArray list = data.getJSONArray("list");
+            for (int i = 0; i < list.size(); i++) {
+                JSONObject resultObj = list.getJSONObject(i);
+                AdvertiserApplet advertiserApplet = new AdvertiserApplet(advertiserId, resultObj, "1");
+                if ("SHARE_ONLY".equals(searchType)) {
+                    advertiserApplet.setAppShare("1");
+                    advertiserApplet.setShareAdvertiserId(resultObj.getLong("advertiser_id"));
+                }
+                if (!toolsSiteMapper.updateAdvertiserAppList(advertiserApplet)) {
+                    toolsSiteMapper.insertAdvertiserAppList(advertiserApplet);
+                }
+            }
+        } else {
+            log.error("获取微信小程序列表失败,{}", obj);
+        }
+        if (nextPage) {
+            updateWxAppStatus(advertiserId, searchType, page + 1);
+        }
+    }
+
+
     @Override
-    public void getToolsSiteStatusList(String accessToken, Long advertiserId, int page) {
+    public void updateTTAppStatus(Long advertiserId, String searchType, Integer page) {
+        boolean nextPage = false;
+        String accessToken = tokenMapper.onlyGetToken(advertiserId);
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", advertiserId);
+        params.put("page", page);
+        //页面大小,默认值为10,最大值100
+        params.put("page_size", 100);
+        JSONObject filtering = new JSONObject();
+        //CREATE_ONLY本户创建,SHARE_ONLY 只查共享应用
+        filtering.put("search_type", searchType);
+       /*
+       //AUDIT_ACCEPTED 审核通过、AUDITING 审核中、AUDIT_REJECTED 审核不通过。不传表示全部状态
+        filtering.put("audit_status", "AUDIT_ACCEPTED");
+        */
+           /* JSONObject createTime = new JSONObject();
+            createTime.put("start_time", startDate);
+            createTime.put("end_time", DateUtils.getLastDay(endDate, -1));
+            filtering.put("create_time", createTime);*/
+        params.put("filtering", filtering);
+        //获取微信小程序列表
+        String url = "https://api.oceanengine.com/open_api/v3.0/tools/micro_app/list/";
+        JSONObject obj = Okhttp3Utils.bytedanceGetRequest(accessToken, url, params);
+        Integer code = obj.getInteger("code");
+        System.out.println(obj);
+        if (code == 0) {
+            JSONObject data = obj.getJSONObject("data");
+            Integer totalPage = data.getJSONObject("page_info").getInteger("total_page");
+            if (totalPage != 0 && totalPage != data.getJSONObject("page_info").getInteger("page")) {
+                nextPage = true;
+            }
+            JSONArray list = data.getJSONArray("list");
+            for (int i = 0; i < list.size(); i++) {
+                JSONObject resultObj = list.getJSONObject(i);
+                AdvertiserApplet advertiserApplet = new AdvertiserApplet(advertiserId, resultObj, "2");
+                if ("SHARE_ONLY".equals(searchType)) {
+                    advertiserApplet.setAppShare("1");
+                    advertiserApplet.setShareAdvertiserId(resultObj.getLong("advertiser_id"));
+                }
+                if (!toolsSiteMapper.updateAdvertiserAppList(advertiserApplet)) {
+                    toolsSiteMapper.insertAdvertiserAppList(advertiserApplet);
+                }
+            }
+        } else {
+            log.error("获取字节小程序列表失败,{}", obj);
+        }
+        if (nextPage) {
+            updateTTAppStatus(advertiserId, searchType, page + 1);
+        }
+    }
+
+    @Override
+    public List<Long> getSiteAdvertiserIds() {
+        return toolsSiteMapper.getsiteAdvertiserIds();
+    }
+
+    @Override
+    public void updateSiteStatus(Long advertiserId, Integer page) {
+        String accessToken = tokenMapper.onlyGetToken(advertiserId);
         boolean nextPage = false;
         Map<String, Object> params = new HashMap<>();
         params.put("advertiser_id", advertiserId);
-        /*
-        SITE_ALL:查询所有
-        SITE_ONLINE:已上线(包括建站状态中:enable,auditAccepted,auditDoing)
-        SITE_OFFLINE:已下线(包括建站状态中:disable,edit)
-        SITE_REJECTED:审核不通过(包括建站状态中:auditRejected)
-        SITE_TRASH:删除或者禁止(包括建站状态中:deleted,auditBanned)
-         */
         //查询所有
         params.put("status", "SITE_ALL");
         params.put("page", page);
-        params.put("page_size", 300);//默认值为10,范围:20~300
+        params.put("page_size", 100);//默认值为10,范围:20~300
         String url = "https://ad.oceanengine.com/open_api/2/tools/site/get/";
         JSONObject obj = Okhttp3Utils.bytedanceGetRequest(accessToken, url, params);
         Integer code = obj.getInteger("code");
+        System.out.println(obj);
         if (code == 0) {
             JSONObject data = obj.getJSONObject("data");
             Integer totalPage = data.getJSONObject("page_info").getInteger("total_page");
             if (totalPage != 0 && totalPage != data.getJSONObject("page_info").getInteger("page")) {
                 nextPage = true;
             }
-            List<AdvertiserToolsSite> siteList = new ArrayList<>();
             JSONArray jsList = data.getJSONArray("list");
             for (int i = 0; i < jsList.size(); i++) {
                 AdvertiserToolsSite advertiserToolsSite = new AdvertiserToolsSite(jsList.getJSONObject(i), advertiserId, "1");
-                siteList.add(advertiserToolsSite);
-            }
-            if (!Check.isNull(siteList)) {
-                toolsSiteMapper.replaceAdvertiserToolsSite(siteList);
+                if (!toolsSiteMapper.updateAdvertiserToolsSite(advertiserToolsSite)) {
+                    toolsSiteMapper.insertAdvertiserToolsSite(advertiserToolsSite);
+                }
             }
         } else {
-            log.error("获取字节小程序列表失败,{}", obj.getString("message"));
+            log.error("获取字节小程序列表失败,{}", obj);
         }
         if (nextPage) {
-            getToolsSiteStatusList(accessToken, advertiserId, page + 1);
+            updateSiteStatus(advertiserId, page + 1);
         }
     }
 }

Разница между файлами не показана из-за своего большого размера
+ 156 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/TotalRankPushServiceImpl.java


+ 12 - 10
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/UnbindWarnPushServiceImpl.java

@@ -50,9 +50,11 @@ public class UnbindWarnPushServiceImpl implements IUnbindWarnPushService {
         Long todayLong = Long.parseLong(today.replaceAll("-", ""));
         String last30Day = DateUtils.getNowAddDate("yyyy-MM-dd", -30);
         Long last30DayLong = Long.parseLong(last30Day.substring(0, 10).replaceAll("-", ""));
+        String last90Day = DateUtils.getNowAddDate("yyyy-MM-dd", -90);
+        Long last90DayLong = Long.parseLong(last90Day.substring(0, 10).replaceAll("-", ""));
 
         int unFindCount = 0;
-        List<Map<String, String>> unbindData = reportsPushMapper.unbindData(todayLong, last30DayLong);
+        List<Map<String, String>> unbindData = reportsPushMapper.unbindData(todayLong, last90DayLong);
 
         List<Unbind> unbinds = new ArrayList<>();
         List<Map<String, String>> unFindList = new ArrayList<>();
@@ -132,15 +134,15 @@ public class UnbindWarnPushServiceImpl implements IUnbindWarnPushService {
                 System.out.println("发送给: "+ub.getName());
                 sendToFeishu(token, request);
 
-                //todo 临时加的
-                if (token2 != null){
-                    System.out.println("应用2 发送给: "+ub.getName());
-                    sendToFeishu(token2, request);
-                }
-                if (token3 != null){
-                    System.out.println("应用3 发送给: "+ub.getName());
-                    sendToFeishu(token3, request);
-                }
+//                //todo 临时加的
+//                if (token2 != null){
+//                    System.out.println("应用2 发送给: "+ub.getName());
+//                    sendToFeishu(token2, request);
+//                }
+//                if (token3 != null){
+//                    System.out.println("应用3 发送给: "+ub.getName());
+//                    sendToFeishu(token3, request);
+//                }
             }
         }
 

+ 7 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/utils/HttpUtils.java

@@ -86,6 +86,13 @@ public class HttpUtils {
         return HttpClients.createDefault();
     }
 
+    public static Map<String, String> postMHeaders(String token) {
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token);
+        return headers;
+    }
+
     public static String httpPostRequest(String url, Map<String, Object> param, Map<String, String> headers) {
 
         HttpClient httpClient = createSslClientDefault();

+ 0 - 33
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedancePromoterReportJob.java

@@ -44,39 +44,6 @@ public class BytedancePromoterReportJob {
     private static ExecutorService productDailyRetrExecutor = Executors.newFixedThreadPool(2);
 
 
-    /**
-     * 番茄数据拉取
-     *
-     * @throws Exception
-     */
-    @XxlJob("getPromoterList")
-    public void getPromoterList() throws Exception {
-        List<JSONObject> channelList = promoterReportService.getChannelInfoList();
-        for (int i = 0; i < channelList.size(); i++) {
-            JSONObject jsonObject = channelList.get(i);
-            String channelAccountId = jsonObject.getString("channelAccountId");
-            String secretKey = jsonObject.getString("secretKey");
-            String startDate = DateUtils.getNowAddDate("yyyy-MM-dd", -1);
-            String endDate = DateUtils.getNowDate("yyyy-MM-dd");
-            channelService.getPromotionIdList(startDate, endDate, channelAccountId, secretKey, 0);
-        }
-    }
-
-    @XxlJob("changDuOrder")
-    public void changDuOrder() throws Exception {
-        List<JSONObject> channelList = promoterReportService.getChannelInfoList();
-        for (int i = 0; i < channelList.size(); i++) {
-            JSONObject jsonObject = channelList.get(i);
-            String channelAccountId = jsonObject.getString("channelAccountId");
-            String secretKey = jsonObject.getString("secretKey");
-            String appId = jsonObject.getString("channelAppId");
-            String appName = jsonObject.getString("channelAppName");
-            String date = DateUtils.getNowAddDate("yyyy-MM-dd", -1);
-            channelService.getOrderList(date, date, appId, appName, channelAccountId, secretKey, 1, null, null);
-        }
-    }
-
-
     @XxlJob("yesHourPromoterReport")
     public void yesHourPromoterReport() throws Exception {
         String param = XxlJobHelper.getJobParam(); // 执行参数

+ 65 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ChangDuJob.java

@@ -0,0 +1,65 @@
+package cn.com.ctop.job.bytedance.handler;
+
+
+import cn.com.ctop.job.bytedance.data.service.IBytedancePromoterReportService;
+import cn.com.ctop.job.bytedance.data.service.IChannelService;
+import cn.com.ctop.job.bytedance.data.utils.DateUtils;
+import com.alibaba.fastjson.JSONObject;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Slf4j
+@Component
+public class ChangDuJob {
+    @Autowired
+    private IBytedancePromoterReportService promoterReportService;
+    @Autowired
+    private IChannelService channelService;
+
+    /**
+     * 番茄数据拉取
+     */
+    @XxlJob("getPromoterList")
+    public void getPromoterList() throws Exception {
+        List<JSONObject> channelList = channelService.getChannelInfoList();
+        for (int i = 0; i < channelList.size(); i++) {
+            JSONObject jsonObject = channelList.get(i);
+            String channelAccountId = jsonObject.getString("channelAccountId");
+            String secretKey = jsonObject.getString("secretKey");
+            String startDate = DateUtils.getNowAddDate("yyyy-MM-dd", -1);
+            String endDate = DateUtils.getNowDate("yyyy-MM-dd");
+            channelService.getPromotionIdList(startDate, endDate, channelAccountId, secretKey, 0);
+        }
+    }
+
+    @XxlJob("changDuOrder")
+    public void changDuOrder() throws Exception {
+        List<JSONObject> channelList = channelService.getChannelInfoList();
+        for (int i = 0; i < channelList.size(); i++) {
+            JSONObject jsonObject = channelList.get(i);
+            String channelAccountId = jsonObject.getString("channelAccountId");
+            String secretKey = jsonObject.getString("secretKey");
+            String appId = jsonObject.getString("channelAppId");
+            String appName = jsonObject.getString("channelAppName");
+            String date = DateUtils.getNowAddDate("yyyy-MM-dd", -1);
+            channelService.getOrderList(date, date, appId, appName, channelAccountId, secretKey, 1, null, null);
+        }
+    }
+
+    @XxlJob("distributorConfig")
+    public void distributorConfig() {
+        channelService.getDistributorConfig();
+    }
+
+    @XxlJob("syncMovieId")
+    public void syncMovieId() {
+        String startDate = DateUtils.getNowAddDate("yyyy-MM-dd", -1);
+        String endDate = DateUtils.getNowDate("yyyy-MM-dd");
+        channelService.syncMovieId(startDate, endDate);
+    }
+
+}

+ 15 - 3
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/FeishuPushJob.java

@@ -1,8 +1,6 @@
 package cn.com.ctop.job.bytedance.handler;
 
-import cn.com.ctop.job.bytedance.data.service.IOptimizerRankPushService;
-import cn.com.ctop.job.bytedance.data.service.IReportsAdPushService;
-import cn.com.ctop.job.bytedance.data.service.IUnbindWarnPushService;
+import cn.com.ctop.job.bytedance.data.service.*;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -14,15 +12,24 @@ public class FeishuPushJob {
     @Autowired
     IUnbindWarnPushService unbindWarnPushService;
     @Autowired
+    IBindAppErrorWarnService bindAppErrorWarnService;
+    @Autowired
     IReportsAdPushService reportsAdPushService;
     @Autowired
     IOptimizerRankPushService optimizerRankPushService;
+    @Autowired
+    ITotalRankPushService totalRankPushService;
 
     @XxlJob("unbindWarnPush")
     public void unbindWarnPush(){
         unbindWarnPushService.send();
     }
 
+    @XxlJob("bindAppErrorWarnPush")
+    public void bindAppErrorWarnPush(){
+        bindAppErrorWarnService.send();
+    }
+
     @XxlJob("reportsAdPush")
     public void reportsAdPush(){
         reportsAdPushService.send();
@@ -32,4 +39,9 @@ public class FeishuPushJob {
     public void optimizerRankPush(){
         optimizerRankPushService.send();
     }
+
+    @XxlJob("totalRankPush")
+    public void totalRankPush(){
+        totalRankPushService.send();
+    }
 }

+ 56 - 20
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ToolsSiteJob.java

@@ -3,19 +3,18 @@ package cn.com.ctop.job.bytedance.handler;
 
 import cn.com.ctop.job.bytedance.data.service.IToolsSiteService;
 import cn.com.ctop.job.bytedance.data.utils.Check;
-import cn.com.ctop.job.bytedance.data.utils.DateUtils;
-import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 
 /**
- * 橙子建站定时任务
+ * 批量搭建 各状态更新
  */
 @Slf4j
 @Component
@@ -23,27 +22,64 @@ public class ToolsSiteJob {
     @Autowired
     private IToolsSiteService toolsSiteService;
 
-    private static ExecutorService executorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService avatarExecutorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService nameExecutorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService wxappExecutorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService ttappExecutorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService siteExecutorService = Executors.newFixedThreadPool(3);
 
     @XxlJob("getToolsSiteList")
     public void getToolsSiteList() throws Exception {
-        String param = XxlJobHelper.getJobParam(); // 执行参数
-        if (Check.isNull(param)) {
-            log.error("入参为空");
-            return;
+//        String param = XxlJobHelper.getJobParam(); // 执行参数
+//        if (Check.isNull(param)) {
+//            log.error("入参为空");
+//            return;
+//        }
+        //头像待更新的广告主id集
+        List<Long> avatarIds = toolsSiteService.getAvatarAdvertiserIds();
+        if (!Check.isNull(avatarIds)) {
+            avatarIds.forEach(id -> avatarExecutorService.submit(() -> {
+                toolsSiteService.updateAvatarStatus(id);
+            }));
+        }
+
+        //广告名称待更新的广告主id集
+        List<Long> nameIds = toolsSiteService.getNameAdvertiserIds();
+        if (!Check.isNull(nameIds)) {
+            nameIds.forEach(id -> nameExecutorService.submit(() -> {
+                toolsSiteService.updateNameStatus(id);
+            }));
+        }
+
+        //微信
+        List<Long> wxappIds = toolsSiteService.getAppAdvertiserIds("1");
+        if (!Check.isNull(wxappIds)) {
+            wxappIds.forEach(id -> wxappExecutorService.submit(() -> {
+                //创建
+                toolsSiteService.updateWxAppStatus(id, "CREATE_ONLY", 1);
+                //复制
+                toolsSiteService.updateWxAppStatus(id, "SHARE_ONLY", 1);
+            }));
+        }
+
+        //字节
+        List<Long> ttappIds = toolsSiteService.getAppAdvertiserIds("2");
+        if (!Check.isNull(ttappIds)) {
+            ttappIds.forEach(id -> ttappExecutorService.submit(() -> {
+                //创建
+                toolsSiteService.updateTTAppStatus(id, "CREATE_ONLY", 1);
+                //复制
+                toolsSiteService.updateTTAppStatus(id, "SHARE_ONLY", 1);
+            }));
+        }
+
+        //落地页
+        List<Long> siteIds = toolsSiteService.getSiteAdvertiserIds();
+        if (!Check.isNull(siteIds)) {
+            siteIds.forEach(id -> siteExecutorService.submit(() -> {
+                toolsSiteService.updateSiteStatus(id, 1);
+            }));
         }
-        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-        String data = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
-        String[] s = param.split("_");
-        Long advertiserId = Long.valueOf(s[0]);
-        String accessToken = s[1];
-
-        executorService.submit(new Runnable() {
-            @Override
-            public void run() {
-                toolsSiteService.getToolsSiteStatusList(accessToken, advertiserId, 1);
-            }
-        });
     }
 
 }