Przeglądaj źródła

常读订单拉取弥补push接口缺失部分

huangpingkang 1 rok temu
rodzic
commit
5f04933b82

+ 72 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/ChangDuController.java

@@ -0,0 +1,72 @@
+package cn.com.ctop.job.bytedance.controller;
+
+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.Check;
+import cn.com.ctop.job.bytedance.data.utils.DateUtils;
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/bytedance/changDuController")
+@Api(tags = "常读拉取")
+@Slf4j
+public class ChangDuController {
+    @Autowired
+    private IChannelService channelService;
+    @Autowired
+    private IBytedancePromoterReportService promoterReportService;
+
+    @GetMapping("/changDuOrder")
+    public void changDuOrder(@RequestParam(required = false) String distributorId,
+                             @RequestParam(required = false) String startDate,
+                             @RequestParam(required = false) String endDate) {
+        List<JSONObject> channelList = promoterReportService.getChannelInfoList();
+        for (JSONObject jsonObject : channelList) {
+            String channelAccountId = jsonObject.getString("channelAccountId");
+            if (distributorId != null && !distributorId.equals(channelAccountId)) {
+                continue;
+            }
+            String secretKey = jsonObject.getString("secretKey");
+            String appId = jsonObject.getString("channelAppId");
+            String appName = jsonObject.getString("channelAppName");
+            startDate = startDate == null ? DateUtils.getNowAddDate("yyyy-MM-dd", -1) : startDate;
+            endDate = endDate == null ? DateUtils.getNowAddDate("yyyy-MM-dd", -1) : endDate;
+            channelService.getOrderList(startDate, endDate, appId, appName, channelAccountId, secretKey, 1, null, null);
+        }
+    }
+
+    @GetMapping("/testChangDuRetry")
+    private void testChangDuRetry() {
+        List<JSONObject> changDuRetry = channelService.getChangDuRetry();
+        if (!Check.isNull(changDuRetry)) {
+            for (int i = 0; i < changDuRetry.size(); i++) {
+                JSONObject jsonObject = changDuRetry.get(i);
+                Long id = jsonObject.getLong("id");
+                String startDate = jsonObject.getString("startDate");
+                String endDate = jsonObject.getString("endDate");
+                String dataDimension = jsonObject.getString("dataDimension");
+                Integer isSend = jsonObject.getInteger("isSend");
+                String channelAccountId = jsonObject.getString("channelAccountId");
+                String secretKey = jsonObject.getString("secretKey");
+                String appId = jsonObject.getString("channelAppId");
+                String appName = jsonObject.getString("channelAppName");
+                if ("changdu_order".equals(dataDimension)) {
+                    channelService.getOrderList(startDate, endDate, appId, appName, channelAccountId, secretKey, 1, id, isSend);
+                }
+            }
+        } else {
+            log.info("常读重试列表为空");
+        }
+    }
+
+
+}

+ 10 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/BytedanceErrorLog.java

@@ -40,6 +40,7 @@ public class BytedanceErrorLog {
      */
     private String dataType;
     private Integer isSend;
+    private String msg;
 
     public Long getId() {
         return id;
@@ -97,6 +98,14 @@ public class BytedanceErrorLog {
         this.isSend = isSend;
     }
 
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
     @Override
     public String toString() {
         return "BytedanceErrorLog{" +
@@ -107,6 +116,7 @@ public class BytedanceErrorLog {
                 ", dataDimension='" + dataDimension + '\'' +
                 ", dataType='" + dataType + '\'' +
                 ", isSend=" + isSend +
+                ", msg=" + msg +
                 '}';
     }
 }

+ 40 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/ChangDuOrder.java

@@ -0,0 +1,40 @@
+package cn.com.ctop.job.bytedance.data.entity;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+
+@Data
+public class ChangDuOrder {
+    @JSONField(name = "trade_no")
+    private String orderNo;
+    private String registerTime;
+    private String deviceId;
+    private String openId;
+    private Integer payWay;
+    private Integer status;
+    @JSONField(name = "pay_fee")
+    private Integer payAmount;
+    private String createTime;
+    private String payTime;
+    @JSONField(name = "promotion_id")
+    private String linkId;
+    @JSONField(name = "book_id")
+    private String movieId;
+
+    private Integer fxId;
+    private String distributorId;
+    private String appId;
+    private String appName;
+    private Integer appType;
+    private Integer platType;
+    private Integer statDate;
+    private String uid;
+    private String dyingTime;
+    private String advertiserId;
+    private String aId;
+    private String adId;
+    private String movieName;
+    private String dyingMovieId;
+    private String dyingMovieName;
+    private String code;
+}

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

@@ -1,10 +1,24 @@
 package cn.com.ctop.job.bytedance.data.mapper;
 
+import cn.com.ctop.job.bytedance.data.entity.ChangDuOrder;
 import cn.com.ctop.job.bytedance.data.entity.ChannelChangdunovelInfo;
+import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 public interface ChannelMapper {
     void repalceChannels(@Param("adds") List<ChannelChangdunovelInfo> adds);
+    Integer getAppType(@Param("appId") String appId);
+    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();
+
 }

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

@@ -13,9 +13,12 @@
                  LEFT JOIN deepthink.bytedance_advertiser_list t2 ON t1.advertiser_id = t2.advertiser_id
                  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'
+                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">
@@ -177,7 +180,7 @@
             <if test="endDate != null">end_date,</if>
             <if test="dataDimension != null">data_dimension,</if>
             <if test="dataType != null">data_type,</if>
-
+            <if test="msg != null">msg,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="advertiserId != null">#{advertiserId},</if>
@@ -185,7 +188,7 @@
             <if test="endDate != null">#{endDate},</if>
             <if test="dataDimension != null">#{dataDimension},</if>
             <if test="dataType != null">#{dataType},</if>
-
+            <if test="msg != null">#{msg},</if>
         </trim>
     </insert>
 </mapper>

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

@@ -1,7 +1,13 @@
 <?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="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',
+                t2.channel_app_id as 'channelAppId',t2.channel_app_name as 'channelAppName'
+        FROM media_api.bytedance_error_log t1
+        JOIN deepthink.channel_account_info t2 ON t1.advertiser_id = t2.channel_account_id
+    </select>
 
     <insert id="repalceChannels">
         replace into deepthink.channel_changdunovel_info (
@@ -33,4 +39,72 @@
         </foreach>
 
     </insert>
+
+    <select id="getAppType" resultType="java.lang.Integer">
+        SELECT plat_type from hr_playlet.m_mini_app_info where app_id =  #{appId}
+    </select>
+
+    <select id="getMovieName" resultType="java.lang.String">
+        SELECT movie_name
+        from deepthink.channel_changdunovel_info where movie_id =  #{movieId} limit 1
+    </select>
+
+    <select id="getLinkInfo" resultType="java.util.Map">
+        SELECT promotion_id ,promotion_name ,media_source  from deepthink.channel_changdunovel_info where promotion_id =  #{linkId} limit 1
+    </select>
+
+    <select id="getOrderIds" resultType="java.lang.String">
+        SELECT order_no from third_party_drama.order
+        where stat_date >=  #{startDate} and stat_date &lt;= #{endDate}
+        and pay_time >= #{startPayTime} and pay_time &lt;= #{endPayTime}
+    </select>
+
+    <select id="getUserInfo" resultType="java.util.Map">
+        SELECT advertiser_id ,aid ,ad_id, plat_type,movie_id,movie_name,app_type
+        from third_party_drama.user
+        where distributor_id =  #{distributorId} and uid = #{uid}
+          and register_time &lt;= #{eventTime}
+        order by register_time desc limit 1
+    </select>
+
+    <insert id="insertOrder" parameterType="java.util.List">
+        insert ignore into third_party_drama.order
+        <trim prefix="(" suffix=")" >
+            fx_id,order_no, app_id,distributor_id, app_name,app_type,uid,register_time,dying_time,device_id,open_id,pay_way,
+            status,pay_amount,create_time,pay_time,link_id,code,plat_type,advertiser_id,aid,ad_id,
+            movie_id,movie_name,dying_movie_id,dying_movie_name,stat_date
+        </trim>
+        values
+        <foreach  collection="list" item="item" index="index" separator=",">
+            <trim prefix=" (" suffix=")" suffixOverrides="," >
+                #{item.fxId,jdbcType=INTEGER},
+                #{item.orderNo,jdbcType=VARCHAR},
+                #{item.appId,jdbcType=VARCHAR},
+                #{item.distributorId,jdbcType=VARCHAR},
+                #{item.appName,jdbcType=VARCHAR},
+                #{item.appType,jdbcType=INTEGER},
+                #{item.uid,jdbcType=VARCHAR},
+                #{item.registerTime,jdbcType=TIMESTAMP},
+                #{item.dyingTime,jdbcType=TIMESTAMP},
+                #{item.deviceId,jdbcType=VARCHAR},
+                #{item.openId,jdbcType=VARCHAR},
+                #{item.payWay,jdbcType=INTEGER},
+                #{item.status,jdbcType=INTEGER},
+                #{item.payAmount,jdbcType=INTEGER},
+                #{item.createTime,jdbcType=TIMESTAMP},
+                #{item.payTime,jdbcType=TIMESTAMP},
+                #{item.linkId,jdbcType=VARCHAR},
+                #{item.code,jdbcType=VARCHAR},
+                #{item.platType,jdbcType=INTEGER},
+                #{item.advertiserId,jdbcType=VARCHAR},
+                #{item.aId,jdbcType=VARCHAR},
+                #{item.adId,jdbcType=VARCHAR},
+                #{item.movieId,jdbcType=VARCHAR},
+                #{item.movieName,jdbcType=VARCHAR},
+                #{item.dyingMovieId,jdbcType=VARCHAR},
+                #{item.dyingMovieName,jdbcType=VARCHAR},
+                #{item.statDate,jdbcType=INTEGER},
+            </trim>
+        </foreach>
+    </insert>
 </mapper>

+ 9 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IChannelService.java

@@ -1,5 +1,13 @@
 package cn.com.ctop.job.bytedance.data.service;
 
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+
 public interface IChannelService {
-     void   getPromotionIdList(String startDt,String endDt, String distributorId, String secretKey,Integer offset);
+    void getPromotionIdList(String startDt, String endDt, String distributorId, String secretKey, Integer offset);
+
+    void getOrderList(String startDt, String endDt, String appId, String appName, String distributorId, String secretKey, Integer isLog, Long errId, Integer isSend);
+
+    List<JSONObject> getChangDuRetry();
 }

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

@@ -1,8 +1,12 @@
 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.ChangDuOrder;
 import cn.com.ctop.job.bytedance.data.entity.ChannelChangdunovelInfo;
+import cn.com.ctop.job.bytedance.data.mapper.BytedancePromoterReportMapper;
 import cn.com.ctop.job.bytedance.data.mapper.ChannelMapper;
 import cn.com.ctop.job.bytedance.data.service.IChannelService;
+import cn.com.ctop.job.bytedance.data.utils.AlertUtils;
 import cn.com.ctop.job.bytedance.data.utils.Check;
 import cn.com.ctop.job.bytedance.data.utils.DateUtils;
 import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
@@ -22,6 +26,8 @@ import java.util.Map;
 public class ChannelServiceImpl implements IChannelService {
     @Autowired
     private ChannelMapper channelMapper;
+    @Autowired
+    private BytedancePromoterReportMapper promoterReportMapper;
 
     @Override
     public void getPromotionIdList(String startDt, String endDt, String distributorId, String secretKey, Integer offset) {
@@ -65,6 +71,7 @@ public class ChannelServiceImpl implements IChannelService {
                 }
             } else {
                 log.error("返回数据为空");
+                return;
             }
 
             if (!Check.isNull(adds)) {
@@ -84,10 +91,166 @@ public class ChannelServiceImpl implements IChannelService {
 
     }
 
+    @Override
+    public void getOrderList(String startDt, String endDt, String appId, String appName, String distributorId, String secretKey, Integer isLog, Long errId, Integer isSend) {
+        try {
+            Long dataRangeSeconds = 3600L;//常读订单拉取接口offset > 10000 时会报错,只能分段拉取
+            String startTime = startDt + (startDt.contains(" ") ? "" : " 00:00:00");
+            Long startT = DateUtils.getTimestampFormat("yyyy-MM-dd HH:mm:ss", startTime);
+            String endTime = endDt + (endDt.contains(" ") ? "" : " 23:59:59");
+            Long endT = DateUtils.getTimestampFormat("yyyy-MM-dd HH:mm:ss", endTime);
+            boolean hasMoreTime = true;
+            while (hasMoreTime) {
+                Long thisEndT = startT + dataRangeSeconds;
+                if (thisEndT >= endT) {
+                    thisEndT = endT;
+                }
+                //push接口没有订单创建时间,支付时间作为创建时间,所以查询已入库订单需要延后点时间,延后20分钟
+                long endPayTimestamp = thisEndT + 20 * 60;
+                String endPayTime = DateUtils.formatTimestamp("yyyy-MM-dd HH:mm:ss", endPayTimestamp);
+                Integer endPayDate = Integer.parseInt(DateUtils.formatTimestamp("yyyyMMdd", endPayTimestamp));
+                String startPayTime = DateUtils.formatTimestamp("yyyy-MM-dd HH:mm:ss", startT);
+                Integer startPayDate = Integer.parseInt(DateUtils.formatTimestamp("yyyyMMdd", startT));
+                List<String> orderIds = channelMapper.getOrderIds(startPayDate, startPayTime, endPayDate, endPayTime);
+
+                String thisStartTime = startPayTime;
+                String thisEndTime = DateUtils.formatTimestamp("yyyy-MM-dd HH:mm:ss", thisEndT);
+                int offset = 0;
+                boolean hasMore = true;
+                while (hasMore) {
+                    log.error("常读订单拉取 [{}] {}~{} {}", distributorId, thisStartTime, thisEndTime, offset);
+                    String url = "https://www.changdunovel.com/novelsale/openapi/user/recharge/v1";
+                    String ts = String.valueOf(System.currentTimeMillis()).substring(0, 10);
+                    String sign = getSign(distributorId, secretKey, ts);
+                    Map<String, Object> params = new JSONObject();
+                    params.put("distributor_id", distributorId);
+                    params.put("ts", ts);
+                    params.put("offset", offset);
+                    params.put("limit", 1000);
+                    params.put("sign", sign);
+                    params.put("begin", startT);
+                    params.put("end", thisEndT);
+                    params.put("paid", true);
+                    String s = HttpUtils.httpGet(url, params, null);
+                    JSONObject jsonObject = JSONObject.parseObject(s);
+                    List<ChangDuOrder> adds = new ArrayList<>();
+                    if (!Check.isNull(jsonObject)) {
+                        Integer code = jsonObject.getInteger("code");
+                        if (code == 200) {
+                            hasMore = jsonObject.getBoolean("has_more");
+                            offset = jsonObject.getInteger("next_offset");
+                            JSONArray result = jsonObject.getJSONArray("result");
+                            if (!Check.isNull(result)) {
+                                for (int i = 0; i < result.size(); i++) {
+                                    JSONObject resultJson = result.getJSONObject(i);
+                                    ChangDuOrder order = JSONObject.parseObject(resultJson.toJSONString(), ChangDuOrder.class);
+                                    String orderNo = order.getOrderNo();
+                                    if (orderIds.contains(orderNo)) {
+                                        continue;
+                                    }
+                                    order.setFxId(1);
+                                    order.setDistributorId(distributorId);
+                                    order.setAppId(appId);
+                                    order.setAppName(appName);
+
+                                    String uid = order.getDeviceId();
+                                    order.setUid(uid);
+                                    String payTime = order.getPayTime();
+                                    Map<String, Object> userMap = channelMapper.getUserInfo(distributorId, payTime, uid);
+
+                                    String advertiserId = null;
+                                    String aId = null;
+                                    String adId = null;
+                                    Integer platType = null;
+                                    String dyingMovieId = null;
+                                    String dyingMovieName = null;
+                                    Integer appType = null;
+                                    if (!Check.isNullMap(userMap)) {
+                                        advertiserId = userMap.get("advertiser_id") == null ? null : userMap.get("advertiser_id").toString();
+                                        aId = userMap.get("aid") == null ? null : userMap.get("aid").toString();
+                                        adId = userMap.get("ad_id") == null ? null : userMap.get("ad_id").toString();
+                                        platType = userMap.get("plat_type") == null ? null : Integer.valueOf(userMap.get("plat_type").toString());
+                                        dyingMovieId = userMap.get("movie_id") == null ? null : userMap.get("movie_id").toString();
+                                        dyingMovieName = userMap.get("movie_name") == null ? null : userMap.get("movie_name").toString();
+                                        appType = userMap.get("app_type") == null ? null : Integer.valueOf(userMap.get("app_type").toString());
+                                    }
+                                    if (platType == null) {
+                                        String linkId = order.getLinkId();
+                                        Map<String, Object> linkInfo = channelMapper.getLinkInfo(linkId);
+                                        if (!Check.isNullMap(linkInfo)) {
+                                            String mediaSource = linkInfo.get("media_source").toString();
+                                            if ("1".equals(mediaSource)) {
+                                                platType = 1;
+                                            } else if ("4".equals(mediaSource)) {
+                                                platType = 3;
+                                            }
+                                        }
+                                    }
+                                    order.setAppType(appType == null ? channelMapper.getAppType(appId) : appType);
+                                    order.setPlatType(platType);
+                                    order.setStatDate(Integer.parseInt(order.getCreateTime().substring(0, 10).replace("-", "")));
+                                    order.setDyingTime(order.getRegisterTime());
+                                    order.setAdvertiserId(advertiserId);
+                                    order.setAdId(adId);
+                                    order.setAId(aId);
+                                    order.setMovieName(channelMapper.getMovieName(order.getMovieId()));
+                                    order.setDyingMovieId(dyingMovieId);
+                                    order.setDyingMovieName(dyingMovieName);
+
+                                    adds.add(order);
+                                }
+                            }
+                        } else {
+                            log.error("[{}]番茄订单请求失败{}~{},返回信息:{}", distributorId, thisStartTime, thisEndTime, s);
+                            insertErrorLog(isLog, Long.parseLong(distributorId), thisStartTime, endTime, "changdu_order", "daily", s);
+                            return;
+                        }
+                    } else {
+                        log.error("[{}]番茄订单返回数据为空{}~{}", distributorId, thisStartTime, thisEndTime);
+                        insertErrorLog(isLog, Long.parseLong(distributorId), thisStartTime, endTime, "changdu_order", "daily", "订单返回数据为空");
+                        return;
+                    }
+
+                    if (!Check.isNull(adds)) {
+                        channelMapper.insertOrder(adds);
+                    }
+                }
+                hasMoreTime = thisEndT < endT;
+                startT = thisEndT;
+                if (errId != null) {
+                    promoterReportMapper.deleteInfoByErrorId(errId);
+                }
+                if (isSend != null && isSend == 1) {
+                    AlertUtils.sendMessage(Long.parseLong(distributorId), startDt, endDt, 2, "daily", 1, "changdu_order");
+                }
+            }
+            log.info("[{}]番茄订单请求完成{}~{}.", distributorId, startDt, endDt);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public List<JSONObject> getChangDuRetry() {
+        return channelMapper.getChangDuRetryJob();
+    }
 
     private static String getSign(String distributorId, String secretKey, String ts) {
         return SecureUtil.md5(distributorId + secretKey + ts).toLowerCase();
     }
 
+    private void insertErrorLog(Integer isLog, Long advertiserId, String startDate, String endDate, String dataDimension, String dataType, String msg) {
+        if (isLog != null && 1 == isLog) {
+            BytedanceErrorLog errorInfo = new BytedanceErrorLog();
+            errorInfo.setAdvertiserId(advertiserId);
+            errorInfo.setStartDate(startDate);
+            errorInfo.setEndDate(endDate);
+            errorInfo.setDataDimension(dataDimension);
+            errorInfo.setDataType(dataType);
+            errorInfo.setMsg(msg);
+            promoterReportMapper.replaceErrorInfo(errorInfo);
+        }
+    }
+
 
 }

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

@@ -12,6 +12,14 @@ import java.util.List;
 
 @Slf4j
 public class DateUtils {
+    public static Date getDateByPattern(String day, String pattern) {
+        SimpleDateFormat format = new SimpleDateFormat(pattern);
+        try {
+            return format.parse(day);
+        } catch (ParseException e) {
+            return null;
+        }
+    }
 
     public static Integer getDateInteger(String date) {
         if (!Check.isNull(date)) {
@@ -43,7 +51,17 @@ public class DateUtils {
         } catch (ParseException e) {
             e.printStackTrace();
         }
-        return getDate.getTime()/1000;
+        if (getDate != null) {
+            return getDate.getTime() / 1000;
+        } else {
+            return null;
+        }
+    }
+
+    public static String formatTimestamp(String format, Long ts) {
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        Date date = new Date(ts * 1000);
+        return sdf.format(date);
     }
 
     public static Integer getIntegerDate(String date) {

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

@@ -62,6 +62,20 @@ public class BytedancePromoterReportJob {
         }
     }
 
+    @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 {

+ 27 - 2
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceReportRetryJob.java

@@ -6,9 +6,7 @@ import cn.com.ctop.job.bytedance.data.service.IBytedanceProductReportService;
 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.Check;
-import cn.com.ctop.job.bytedance.data.utils.DateUtils;
 import com.alibaba.fastjson.JSONObject;
-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;
@@ -36,6 +34,9 @@ public class BytedanceReportRetryJob {
     @Autowired
     private IBytedanceAccountReportService accountReportService;
 
+    @Autowired
+    private IChannelService channelService;
+
 
     private static ExecutorService hourAccountRetrExecutorService = Executors.newFixedThreadPool(2);
     private static ExecutorService dailyAccountRetrExecutorService = Executors.newFixedThreadPool(2);
@@ -123,6 +124,30 @@ public class BytedanceReportRetryJob {
             log.info("重试列表为空");
         }
 
+
+        List<JSONObject> changDuRetry = channelService.getChangDuRetry();
+        if (!Check.isNull(changDuRetry)) {
+            for (int i = 0; i < changDuRetry.size(); i++) {
+                JSONObject jsonObject = changDuRetry.get(i);
+                Long id = jsonObject.getLong("id");
+                String startDate = jsonObject.getString("startDate");
+                String endDate = jsonObject.getString("endDate");
+                String dataDimension = jsonObject.getString("dataDimension");
+                //String dataType = jsonObject.getString("dataType");
+                Integer isSend = jsonObject.getInteger("isSend");
+                String channelAccountId = jsonObject.getString("channelAccountId");
+                String secretKey = jsonObject.getString("secretKey");
+                String appId = jsonObject.getString("channelAppId");
+                String appName = jsonObject.getString("channelAppName");
+                if ("changdu_order".equals(dataDimension)) {
+                    channelService.getOrderList(startDate, endDate, appId, appName, channelAccountId, secretKey, 1, id, isSend);
+                }
+            }
+        } else {
+            log.info("常读重试列表为空");
+        }
+
+
     }