Ver Fonte

Merge #23 into master from pingkang

Merge branch 'master' of codeup.aliyun.com:60c06368dbbed34fe0f0c263/job/hr_job-adq into pingkang

* pingkang: (2 commits)
  微小广告金数据
  Merge branch 'master' of codeup.aliyun.com:60c06368dbbed34fe0f0c263/job/hr_job-adq into pingkang

Signed-off-by: 黄平康 <accounts_6361eaad7b63b44dd7833e63@mail.teambition.com>
Merged-by: 黄平康 <accounts_6361eaad7b63b44dd7833e63@mail.teambition.com>

CR-link: https://codeup.aliyun.com/60c06368dbbed34fe0f0c263/job/hr_job-adq/change/23
huangpingkang há 7 meses atrás
pai
commit
ad956dc9fa

+ 56 - 0
job-adq/src/main/java/cn/com/ctop/job/adq/controller/AdqAssetController.java

@@ -122,4 +122,60 @@ public class AdqAssetController {
         }
         return MessageModel.ok();
     }
+
+    @GetMapping("/gameGiftList")
+    public MessageModel gameGiftList(@RequestParam(required = false) String appId,
+                                        @RequestParam(required = false) String startDate,
+                                        @RequestParam(required = false) String endDate) {
+        List<JSONObject> adqMiniApp = adqAdIncomeService.getAdqAllMiniApp(appId);
+        String start = startDate == null ? DateUtils.getNowAddDate("yyyy-MM-dd", -1) : startDate;
+        String end = endDate == null ? DateUtils.getNowDate("yyyy-MM-dd") : endDate;
+        for (JSONObject jsonObject : adqMiniApp) {
+            String app = jsonObject.getString("app_id");
+            Long appletId = jsonObject.getLong("applet_id");
+            dailyExecutorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    adqAdIncomeService.getGameGiftList(start, end, app, appletId, 1, 1, null, null);
+                }
+            });
+        }
+        return MessageModel.ok();
+    }
+
+    @GetMapping("/gameDiviceSave")
+    public MessageModel gameDiviceSave(@RequestParam(required = false) String appId) {
+        List<JSONObject> adqMiniApp = adqAdIncomeService.getAdqAllMiniApp(appId);
+        for (JSONObject jsonObject : adqMiniApp) {
+            String app = jsonObject.getString("app_id");
+            Long appletId = jsonObject.getLong("applet_id");
+            dailyExecutorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    adqAdIncomeService.getGameDiviceSave(app, appletId, 1, 1, null, null);
+                }
+            });
+        }
+        return MessageModel.ok();
+    }
+
+    @GetMapping("/gameDiviceTransfer")
+    public MessageModel gameDiviceTransfer(@RequestParam(required = false) String appId,
+                                     @RequestParam(required = false) String startDate,
+                                     @RequestParam(required = false) String endDate) {
+        List<JSONObject> adqMiniApp = adqAdIncomeService.getAdqAllMiniApp(appId);
+        String start = startDate == null ? DateUtils.getNowAddDate("yyyy-MM-dd", -1) : startDate;
+        String end = endDate == null ? DateUtils.getNowDate("yyyy-MM-dd") : endDate;
+        for (JSONObject jsonObject : adqMiniApp) {
+            String app = jsonObject.getString("app_id");
+            Long appletId = jsonObject.getLong("applet_id");
+            dailyExecutorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    adqAdIncomeService.getGameDiviceTransfer(start, end, app, appletId, 1, 1, null, null);
+                }
+            });
+        }
+        return MessageModel.ok();
+    }
 }

+ 7 - 0
job-adq/src/main/java/cn/com/ctop/job/adq/data/mapper/AdqAdIncomeMapper.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public interface AdqAdIncomeMapper {
@@ -23,4 +24,10 @@ public interface AdqAdIncomeMapper {
     void insertAdUnitList(@Param("list") JSONArray list);
 
     void insertAdIncomeRate(@Param("list") JSONArray results);
+
+    void insertAdqGameGiftList(@Param("list") ArrayList<JSONObject> reports);
+
+    void insertAdqGameDiviceSave(@Param("list")ArrayList<JSONObject> reports);
+    void insertAdqGameDiviceSaveDetail(@Param("list")ArrayList<JSONObject> reports);
+    void insertAdqGameDiviceTransfer(@Param("list")ArrayList<JSONObject> reports);
 }

+ 46 - 1
job-adq/src/main/java/cn/com/ctop/job/adq/data/mapper/xml/AdqAdIncomeMapper.xml

@@ -95,6 +95,51 @@
         </foreach>
     </insert>
 
+    <insert id="insertAdqGameGiftList">
+        insert into media_api.adq_game_gift_save_list
+        (stat_date,app_id,ad_fund)
+        VALUES
+        <foreach collection="list" item="item" separator=",">
+            (${item.stat_date}, #{item.app_id}, #{item.ad_fund})
+        </foreach>
+        on duplicate key update ad_fund= VALUES(ad_fund)
+    </insert>
+
+    <insert id="insertAdqGameDiviceSave">
+        insert into media_api.adq_game_gift_save_list
+        (stat_date,app_id,expire_balance,expire_time,total_balance)
+        VALUES
+        <foreach collection="list" item="item" separator=",">
+            (${item.stat_date}, #{item.app_id}, #{item.expire_balance}, #{item.expire_time}, #{item.total_balance})
+        </foreach>
+        on duplicate key update
+        expire_balance= VALUES(expire_balance),
+        expire_time= VALUES(expire_time),
+        total_balance= VALUES(total_balance)
+    </insert>
+
+    <insert id="insertAdqGameDiviceSaveDetail">
+        insert into media_api.adq_game_gift_save_list
+        (stat_date,app_id,game_save_detail_amt,game_save_detail_expire_time,game_save_detail_sett_idx)
+        VALUES
+        <foreach collection="list" item="item" separator=",">
+            (${item.stat_date}, #{item.app_id}, #{item.game_save_detail_amt}, #{item.game_save_detail_expire_time}, #{item.game_save_detail_sett_idx})
+        </foreach>
+        on duplicate key update
+        game_save_detail_amt= VALUES(game_save_detail_amt),
+        game_save_detail_expire_time= VALUES(game_save_detail_expire_time),
+        game_save_detail_sett_idx= VALUES(game_save_detail_sett_idx)
+    </insert>
+    <insert id="insertAdqGameDiviceTransfer">
+        replace into media_api.adq_game_divice_transfer
+        (stat_date,app_id,`type`,amt,out_uuid,remark,src_account)
+        VALUES
+        <foreach collection="list" item="item" separator=",">
+            (${item.stat_date}, #{item.app_id}, #{item.type},
+          #{item.amt}, #{item.out_uuid}, #{item.remark}, #{item.src_account})
+        </foreach>
+    </insert>
+
     <select id="queryAdqIaaMiniApp" resultType="com.alibaba.fastjson.JSONObject">
         select m.app_id,l.id applet_id
         from deepthink.mini_app_info m
@@ -116,6 +161,6 @@
     <select id="queryAdqAdIncomeRetryJob" resultType="com.alibaba.fastjson.JSONObject">
         SELECT t1.msg as 'msg',t1.is_send AS 'isSend', t1.id AS 'id', t1.advertiser_id AS 'advertiserId', t1.start_date AS 'startDate', t1.end_date AS 'endDate', t1.data_dimension AS 'dataDimension', t1.data_type AS 'dataType', t1.msg
         FROM media_api.adq_error_log t1
-        where data_dimension = 'adq_ma_ad_income';
+        where data_dimension like 'adq_ma_%';
     </select>
 </mapper>

+ 3 - 0
job-adq/src/main/java/cn/com/ctop/job/adq/data/service/IAdqAdIncomeService.java

@@ -11,4 +11,7 @@ public interface IAdqAdIncomeService {
     void getAdqAdIncome(String startDt, String endDt, String appId, Long appletId, Integer page, Integer isLog, Long errId, Integer isSend);
     void getAdqAdUnitList(String appId, Long appletId, Integer page);
     void getAdqAdIncomeRate(String appId, Long appletId, String startDate, String endDate);
+    void getGameGiftList(String startDt, String endDt, String appId, Long appletId, Integer page, Integer isLog, Long errId, Integer isSend);
+    void getGameDiviceSave(String appId, Long appletId, Integer page, Integer isLog, Long errId, Integer isSend);
+    void getGameDiviceTransfer(String startDt, String endDt, String appId, Long appletId, Integer page, Integer isLog, Long errId, Integer isSend);
 }

+ 247 - 0
job-adq/src/main/java/cn/com/ctop/job/adq/data/service/impl/AdqAdIncomeServiceImpl.java

@@ -7,6 +7,7 @@ import cn.com.ctop.job.adq.data.mapper.AdqErrorLogMapper;
 import cn.com.ctop.job.adq.data.service.IAdqAdIncomeService;
 import cn.com.ctop.job.adq.data.utils.AlertUtils;
 import cn.com.ctop.job.adq.data.utils.Check;
+import cn.com.ctop.job.adq.data.utils.DateUtils;
 import cn.com.ctop.job.adq.data.utils.HttpUtils;
 import cn.com.ctop.job.adq.utils.doris.sink.DorisMultiTableStreamLoadManager;
 import com.alibaba.fastjson.JSONArray;
@@ -342,4 +343,250 @@ public class AdqAdIncomeServiceImpl implements IAdqAdIncomeService {
         }
     }
 
+    /*
+    查询流量主每日广告金收入
+    https://developers.weixin.qq.com/minigame/dev/guide/open-ability/ad/adq.html#_1%E3%80%81%E6%9F%A5%E8%AF%A2%E6%B5%81%E9%87%8F%E4%B8%BB%E6%AF%8F%E6%97%A5%E5%B9%BF%E5%91%8A%E9%87%91%E6%94%B6%E5%85%A5
+     */
+    public void getGameGiftList(String startDt, String endDt, String appId, Long appletId, Integer page, Integer isLog, Long errId, Integer isSend) {
+        try {
+            String url = "https://api.weixin.qq.com/publisher/stat";
+            Object tokenObj = redis2Template_db5.opsForValue().get("wechat-applet-access-token-key-" + appletId);
+            if (tokenObj == null) {
+                log.error("微小查询流量主每日广告金收入获取token为空 [{}] {}~{} {}", appId, startDt, endDt, appletId);
+                return;
+            }
+            int pageSize = 500;
+            Map<String, Object> paramsMap = new HashMap<>();
+            paramsMap.put("access_token", tokenObj.toString());
+            paramsMap.put("action", "general_action");
+            paramsMap.put("cmd", "get_game_gift_list");
+            paramsMap.put("ad_fund_type", "drama");
+            paramsMap.put("page", page);
+            paramsMap.put("page_size", pageSize);
+            paramsMap.put("begin_date", startDt.replace("-", ""));
+            paramsMap.put("end_date", endDt.replace("-", ""));
+            String s = HttpUtils.httpGet(url, paramsMap, null);
+            JSONObject jsonObject = JSONObject.parseObject(s);
+            int totalPage = 1;
+            ArrayList<JSONObject> reports = new ArrayList<>();
+            if (!Check.isNull(jsonObject)) {
+                Integer code = jsonObject.getInteger("ret");
+                JSONObject baseResp = jsonObject.getJSONObject("base_resp");
+                if (baseResp != null) {
+                    code = baseResp.getInteger("ret");
+                }
+                if (2009 == code) {
+                    return; //无效的流量主
+                }
+                if (code == 0) {
+                    JSONArray list = jsonObject.getJSONArray("game_gift_detail");
+                    Integer totalNum = jsonObject.getInteger("total_num");
+                    totalPage = (int) Math.ceil(totalNum * 1.0 / pageSize);
+                    if (!Check.isNull(list)) {
+                        for (int i = 0; i < list.size(); i++) {
+                            JSONObject dataJson = list.getJSONObject(i);
+                            dataJson.put("stat_date", dataJson.getString("date").replace("-", ""));
+                            dataJson.put("app_id", appId);
+                            reports.add(dataJson);
+                        }
+                    }
+                } else {
+                    log.error("微小查询流量主每日广告金收入拉取失败,app_id:{} {}~{},返回信息:{}", appId, startDt, endDt, jsonObject);
+                    insertErrorLog(isLog, System.currentTimeMillis(), "adq_ma_game_gift_list", startDt, endDt,
+                            jsonObject.fluentPut("app_id", appId).fluentPut("applet_id", appletId).toJSONString());
+                }
+            } else {
+                log.error("微小查询流量主每日广告金收入拉取失败,app_id:{} {}~{},返回为空。", appId, startDt, endDt);
+                insertErrorLog(isLog, System.currentTimeMillis(), "adq_ma_game_gift_list", startDt, endDt,
+                        new JSONObject().fluentPut("app_id", appId).fluentPut("applet_id", appletId).fluentPut("msg", "返回为空").toJSONString());
+            }
+            if (!Check.isNull(reports)) {
+                adqAdIncomeMapper.insertAdqGameGiftList(reports);
+            }
+
+            if (totalPage > page) {
+                getGameGiftList(startDt, endDt, appId, appletId, page + 1, isLog, errId, isSend);
+            } else {
+                log.info("微小查询流量主每日广告金收入拉取完成,app_id:{} {}~{} page:{}。", appId, startDt, endDt, page);
+                if (errId != null) {
+                    adqErrorLogMapper.deleteInfoByErrorId(errId);
+                }
+                if (isSend != null && isSend == 1) {
+                    AlertUtils.sendMessage(System.currentTimeMillis(), startDt, endDt, 3, "daily", 1, "adq_ma_game_gift_list");
+                }
+            }
+        } catch (Exception e) {
+            log.error("微小查询流量主每日广告金收入拉取失败,app_id:{} {}~{}。", appId, startDt, endDt, e);
+        }
+    }
+
+    /*
+    查询流量主广告金账户余额
+    https://developers.weixin.qq.com/minigame/dev/guide/open-ability/ad/adq.html#_1%E3%80%81%E6%9F%A5%E8%AF%A2%E6%B5%81%E9%87%8F%E4%B8%BB%E6%AF%8F%E6%97%A5%E5%B9%BF%E5%91%8A%E9%87%91%E6%94%B6%E5%85%A5
+     */
+    public void getGameDiviceSave(String appId, Long appletId, Integer page, Integer isLog, Long errId, Integer isSend) {
+        try {
+            String url = "https://api.weixin.qq.com/publisher/stat";
+            Object tokenObj = redis2Template_db5.opsForValue().get("wechat-applet-access-token-key-" + appletId);
+            if (tokenObj == null) {
+                log.error("查询流量主广告金账户余额获取token为空 [{}]{}", appId,appletId);
+                return;
+            }
+            int pageSize = 500;
+            Map<String, Object> paramsMap = new HashMap<>();
+            paramsMap.put("access_token", tokenObj.toString());
+            paramsMap.put("action", "general_action");
+            paramsMap.put("cmd", "get_game_divice_save");
+            paramsMap.put("ad_fund_type", "drama");
+            paramsMap.put("sub_account", "GAME_DEVIDE");
+            paramsMap.put("page", page);
+            paramsMap.put("page_size", pageSize);
+            String s = HttpUtils.httpGet(url, paramsMap, null);
+            JSONObject jsonObject = JSONObject.parseObject(s);
+            int totalPage = 1;
+            ArrayList<JSONObject> reports = new ArrayList<>();
+            ArrayList<JSONObject> reportsDaily = new ArrayList<>();
+            if (!Check.isNull(jsonObject)) {
+                Integer code = jsonObject.getInteger("ret");
+                JSONObject baseResp = jsonObject.getJSONObject("base_resp");
+                if (baseResp != null) {
+                    code = baseResp.getInteger("ret");
+                }
+                if (2009 == code) {
+                    return; //无效的流量主
+                }
+                if (code == 0) {
+                    Long expireBalance = jsonObject.getLong("expire_balance");
+                    String expireTime = jsonObject.getString("expire_time");
+                    Long totalBalance = jsonObject.getLong("total_balance");
+                    reports.add(new JSONObject()
+                            .fluentPut("stat_date", DateUtils.getNowDate("yyyyMMdd"))
+                            .fluentPut("app_id", appId)
+                            .fluentPut("expire_balance", expireBalance)
+                            .fluentPut("expire_time", expireTime)
+                            .fluentPut("total_balance", totalBalance));
+
+                    JSONArray list = jsonObject.getJSONArray("game_save_detail");
+                    Integer totalNum = jsonObject.getInteger("total_num");
+                    totalPage = (int) Math.ceil(totalNum * 1.0 / pageSize);
+                    if (!Check.isNull(list)) {
+                        for (int i = 0; i < list.size(); i++) {
+                            JSONObject dataJson = list.getJSONObject(i);
+                            JSONObject report = new JSONObject();
+                            report.put("stat_date", DateUtils.dateFormatTransform(dataJson.getString("date"),"yyyy年MM月dd日","yyyyMMdd"));
+                            report.put("app_id", appId);
+                            report.put("game_save_detail_amt",dataJson.getLong("amt"));
+                            report.put("game_save_detail_expire_time",dataJson.getString("expire_time"));
+                            report.put("game_save_detail_sett_idx",dataJson.getLong("sett_idx"));
+                            reportsDaily.add(report);
+                        }
+                    }
+                } else {
+                    log.error("查询流量主广告金账户余额拉取失败,app_id:{},返回信息:{}", appId,jsonObject);
+                    insertErrorLog(isLog, System.currentTimeMillis(), "adq_ma_game_divice_save", "-", "-",
+                            jsonObject.fluentPut("app_id", appId).fluentPut("applet_id", appletId).toJSONString());
+                }
+            } else {
+                log.error("查询流量主广告金账户余额拉取失败,app_id:{},返回为空。", appId);
+                insertErrorLog(isLog, System.currentTimeMillis(), "adq_ma_game_divice_save","-","-",
+                        new JSONObject().fluentPut("app_id", appId).fluentPut("applet_id", appletId).fluentPut("msg", "返回为空").toJSONString());
+            }
+            if (!Check.isNull(reports)) {
+                adqAdIncomeMapper.insertAdqGameDiviceSave(reports);
+            }
+            if (!Check.isNull(reportsDaily)) {
+                adqAdIncomeMapper.insertAdqGameDiviceSaveDetail(reportsDaily);
+            }
+            if (totalPage > page) {
+                getGameDiviceSave(appId, appletId, page + 1, isLog, errId, isSend);
+            } else {
+                log.info("查询流量主广告金账户余额拉取完成,app_id:{} page:{}。", appId, page);
+                if (errId != null) {
+                    adqErrorLogMapper.deleteInfoByErrorId(errId);
+                }
+                if (isSend != null && isSend == 1) {
+                    AlertUtils.sendMessage(System.currentTimeMillis(), "-", "-", 3, "daily", 1, "adq_ma_game_divice_save");
+                }
+            }
+        } catch (Exception e) {
+            log.error("查询流量主广告金账户余额拉取失败,app_id:{}。", appId, e);
+        }
+    }
+
+    /*
+    查询流量主广告金消耗记录
+    https://developers.weixin.qq.com/minigame/dev/guide/open-ability/ad/adq.html#_1%E3%80%81%E6%9F%A5%E8%AF%A2%E6%B5%81%E9%87%8F%E4%B8%BB%E6%AF%8F%E6%97%A5%E5%B9%BF%E5%91%8A%E9%87%91%E6%94%B6%E5%85%A5
+     */
+    public void getGameDiviceTransfer(String startDt, String endDt, String appId, Long appletId, Integer page, Integer isLog, Long errId, Integer isSend) {
+        try {
+            String url = "https://api.weixin.qq.com/publisher/stat";
+            Object tokenObj = redis2Template_db5.opsForValue().get("wechat-applet-access-token-key-" + appletId);
+            if (tokenObj == null) {
+                log.error("微小查询流量主广告金消耗记录获取token为空 [{}] {}~{} {}", appId, startDt, endDt, appletId);
+                return;
+            }
+            int pageSize = 500;
+            Map<String, Object> paramsMap = new HashMap<>();
+            paramsMap.put("access_token", tokenObj.toString());
+            paramsMap.put("action", "general_action");
+            paramsMap.put("cmd", "get_game_divice_transfer");
+            paramsMap.put("ad_fund_type", "drama");
+            paramsMap.put("page", page);
+            paramsMap.put("page_size", pageSize);
+            paramsMap.put("begin_date", DateUtils.getTimestampFormat("yyyy-MM-dd HH:mm:ss", startDt+" 00:00:00"));
+            paramsMap.put("end_date", DateUtils.getTimestampFormat("yyyy-MM-dd HH:mm:ss", endDt+" 23:59:59"));
+            String s = HttpUtils.httpGet(url, paramsMap, null);
+            JSONObject jsonObject = JSONObject.parseObject(s);
+            int totalPage = 1;
+            ArrayList<JSONObject> reports = new ArrayList<>();
+            if (!Check.isNull(jsonObject)) {
+                Integer code = jsonObject.getInteger("ret");
+                JSONObject baseResp = jsonObject.getJSONObject("base_resp");
+                if (baseResp != null) {
+                    code = baseResp.getInteger("ret");
+                }
+                if (2009 == code) {
+                    return; //无效的流量主
+                }
+                if (code == 0) {
+                    JSONArray list = jsonObject.getJSONArray("game_transfer_detail");
+                    Integer totalNum = jsonObject.getInteger("total_num");
+                    totalPage = (int) Math.ceil(totalNum * 1.0 / pageSize);
+                    if (!Check.isNull(list)) {
+                        for (int i = 0; i < list.size(); i++) {
+                            JSONObject dataJson = list.getJSONObject(i);
+                            dataJson.put("stat_date", dataJson.getString("date").replace("-", ""));
+                            dataJson.put("app_id", appId);
+                            reports.add(dataJson);
+                        }
+                    }
+                } else {
+                    log.error("微小查询流量主广告金消耗记录拉取失败,app_id:{} {}~{},返回信息:{}", appId, startDt, endDt, jsonObject);
+                    insertErrorLog(isLog, System.currentTimeMillis(), "adq_ma_game_divice_transfer", startDt, endDt,
+                            jsonObject.fluentPut("app_id", appId).fluentPut("applet_id", appletId).toJSONString());
+                }
+            } else {
+                log.error("微小查询流量主广告金消耗记录拉取失败,app_id:{} {}~{},返回为空。", appId, startDt, endDt);
+                insertErrorLog(isLog, System.currentTimeMillis(), "adq_ma_game_divice_transfer", startDt, endDt,
+                        new JSONObject().fluentPut("app_id", appId).fluentPut("applet_id", appletId).fluentPut("msg", "返回为空").toJSONString());
+            }
+            if (!Check.isNull(reports)) {
+                adqAdIncomeMapper.insertAdqGameDiviceTransfer(reports);
+            }
+
+            if (totalPage > page) {
+                getGameDiviceTransfer(startDt, endDt, appId, appletId, page + 1, isLog, errId, isSend);
+            } else {
+                log.info("微小查询流量主广告金消耗记录拉取完成,app_id:{} {}~{} page:{}。", appId, startDt, endDt, page);
+                if (errId != null) {
+                    adqErrorLogMapper.deleteInfoByErrorId(errId);
+                }
+                if (isSend != null && isSend == 1) {
+                    AlertUtils.sendMessage(System.currentTimeMillis(), startDt, endDt, 3, "daily", 1, "adq_ma_game_divice_transfer");
+                }
+            }
+        } catch (Exception e) {
+            log.error("微小查询流量主广告金消耗记录拉取失败,app_id:{} {}~{}。", appId, startDt, endDt, e);
+        }
+    }
 }

+ 26 - 0
job-adq/src/main/java/cn/com/ctop/job/adq/data/utils/DateUtils.java

@@ -158,6 +158,32 @@ public class DateUtils {
         return formattedDate;
     }
 
+    public static String dateFormatTransform(String date,String fromFormat,String toFormat) {
+        SimpleDateFormat fdf = new SimpleDateFormat(fromFormat);
+        SimpleDateFormat tdf = new SimpleDateFormat(toFormat);
+        try {
+            return tdf.format(fdf.parse(date));
+        } catch (ParseException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    public static Long getTimestampFormat(String format, String date) {
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        Date getDate = null;
+        try {
+            getDate = sdf.parse(date);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        if (getDate != null) {
+            return getDate.getTime() / 1000;
+        } else {
+            return null;
+        }
+    }
+
     public static Long timeToDate(Long timestamp) {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
         String dateStr = sdf.format(new Date(timestamp * 1000)); // 乘以1000转换为毫秒

+ 34 - 0
job-adq/src/main/java/cn/com/ctop/job/adq/handler/AdqAccountReportJob.java

@@ -178,6 +178,40 @@ public class AdqAccountReportJob {
         }
     }
 
+    @XxlJob("gameGiftList")
+    public void gameGiftList() {
+        List<JSONObject> adqMiniApp = adqAdIncomeService.getAdqAllMiniApp(null);
+        String start = DateUtils.getNowAddDate("yyyy-MM-dd", -3);
+        String end = DateUtils.getNowDate("yyyy-MM-dd");
+        for (JSONObject jsonObject : adqMiniApp) {
+            String app = jsonObject.getString("app_id");
+            Long appletId = jsonObject.getLong("applet_id");
+            adqAdIncomeService.getGameGiftList(start, end, app, appletId, 1, 1, null, null);
+        }
+    }
+
+    @XxlJob("gameDiviceSave")
+    public void gameDiviceSave() {
+        List<JSONObject> adqMiniApp = adqAdIncomeService.getAdqAllMiniApp(null);
+        for (JSONObject jsonObject : adqMiniApp) {
+            String app = jsonObject.getString("app_id");
+            Long appletId = jsonObject.getLong("applet_id");
+            adqAdIncomeService.getGameDiviceSave(app, appletId, 1, 1, null, null);
+        }
+    }
+
+    @XxlJob("gameDiviceTransfer")
+    public void gameDiviceTransfer() {
+        List<JSONObject> adqMiniApp = adqAdIncomeService.getAdqAllMiniApp(null);
+        String start = DateUtils.getNowAddDate("yyyy-MM-dd", -60);
+        String end = DateUtils.getNowDate("yyyy-MM-dd");
+        for (JSONObject jsonObject : adqMiniApp) {
+            String app = jsonObject.getString("app_id");
+            Long appletId = jsonObject.getLong("applet_id");
+            adqAdIncomeService.getGameDiviceTransfer(start, end, app, appletId, 1, 1, null, null);
+        }
+    }
+
 
     @XxlJob("yesDateBalance")
     public void yesDateBalance() throws Exception {

+ 30 - 6
job-adq/src/main/java/cn/com/ctop/job/adq/handler/AdqRetryReportJob.java

@@ -193,18 +193,42 @@ public class AdqRetryReportJob {
             for (int i = 0; i < adqAdIncomeRetryJob.size(); i++) {
                 JSONObject jsonObject = adqAdIncomeRetryJob.get(i);
                 Long id = jsonObject.getLong("id");
+                String dataDimension = jsonObject.getString("dataDimension");
                 String startDate = jsonObject.getString("startDate");
                 String endDate = jsonObject.getString("endDate");
                 Integer isSend = jsonObject.getInteger("isSend");
                 JSONObject msg = jsonObject.getJSONObject("msg");
                 String appId = msg.getString("app_id");
                 Long appletId = msg.getLong("applet_id");
-                adIncomeExecutorService.submit(new Runnable() {
-                    @Override
-                    public void run() {
-                        adqAdIncomeService.getAdqAdIncome(startDate, endDate, appId, appletId, 1, null, id, isSend);
-                    }
-                });
+                if ("adq_ma_ad_income".equals(dataDimension)) {
+                    adIncomeExecutorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            adqAdIncomeService.getAdqAdIncome(startDate, endDate, appId, appletId, 1, null, id, isSend);
+                        }
+                    });
+                } else if ("adq_ma_game_gift_list".equals(dataDimension)) {
+                    adIncomeExecutorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            adqAdIncomeService.getGameGiftList(startDate, endDate, appId, appletId, 1, null, id, isSend);
+                        }
+                    });
+                } else if ("adq_ma_game_divice_save".equals(dataDimension)) {
+                    adIncomeExecutorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            adqAdIncomeService.getGameDiviceSave(appId, appletId, 1, null, id, isSend);
+                        }
+                    });
+                } else if ("adq_ma_game_divice_transfer".equals(dataDimension)) {
+                    adIncomeExecutorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            adqAdIncomeService.getGameDiviceTransfer(startDate, endDate, appId, appletId, 1, null, id, isSend);
+                        }
+                    });
+                }
             }
         } else {
             log.info("微小广告细分数据重试列表为空");