|
@@ -35,7 +35,7 @@ public class AdqAdIncomeServiceImpl implements IAdqAdIncomeService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private AdqErrorLogMapper adqErrorLogMapper;
|
|
private AdqErrorLogMapper adqErrorLogMapper;
|
|
|
|
|
|
|
|
- private static final Map<String, String> adSlotMap = new HashMap<String, String>(){{
|
|
|
|
|
|
|
+ private static final Map<String, String> adSlotMap = new HashMap<String, String>() {{
|
|
|
put("SLOT_ID_BIZ_BOTTOM", "公众号底部广告");
|
|
put("SLOT_ID_BIZ_BOTTOM", "公众号底部广告");
|
|
|
put("SLOT_ID_BIZ_MID_CONTEXT", "公众号文中广告");
|
|
put("SLOT_ID_BIZ_MID_CONTEXT", "公众号文中广告");
|
|
|
put("SLOT_ID_BIZ_VIDEO_END", "公众号视频后贴");
|
|
put("SLOT_ID_BIZ_VIDEO_END", "公众号视频后贴");
|
|
@@ -108,7 +108,7 @@ public class AdqAdIncomeServiceImpl implements IAdqAdIncomeService {
|
|
|
//System.out.println(report);
|
|
//System.out.println(report);
|
|
|
reports.add(report);
|
|
reports.add(report);
|
|
|
|
|
|
|
|
- dorisLoadManager.add("media_api","adq_publisher_adunit_general", report);
|
|
|
|
|
|
|
+ dorisLoadManager.add("media_api", "adq_publisher_adunit_general", report);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -189,7 +189,7 @@ public class AdqAdIncomeServiceImpl implements IAdqAdIncomeService {
|
|
|
//System.out.println(report);
|
|
//System.out.println(report);
|
|
|
reports.add(report);
|
|
reports.add(report);
|
|
|
|
|
|
|
|
- dorisLoadManager.add("media_api","adq_publisher_adunit_general",report);
|
|
|
|
|
|
|
+ dorisLoadManager.add("media_api", "adq_publisher_adunit_general", report);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -253,7 +253,6 @@ public class AdqAdIncomeServiceImpl implements IAdqAdIncomeService {
|
|
|
paramsMap.put("page_size", pageSize);
|
|
paramsMap.put("page_size", pageSize);
|
|
|
String s = HttpUtils.httpGet(url, paramsMap, null);
|
|
String s = HttpUtils.httpGet(url, paramsMap, null);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(s);
|
|
JSONObject jsonObject = JSONObject.parseObject(s);
|
|
|
- List<AdqPublisherAdunitGeneral> reports = new ArrayList<>();
|
|
|
|
|
int totalPage = 1;
|
|
int totalPage = 1;
|
|
|
if (!Check.isNull(jsonObject)) {
|
|
if (!Check.isNull(jsonObject)) {
|
|
|
Integer code = jsonObject.getInteger("ret");
|
|
Integer code = jsonObject.getInteger("ret");
|
|
@@ -267,8 +266,8 @@ public class AdqAdIncomeServiceImpl implements IAdqAdIncomeService {
|
|
|
if (!Check.isNull(list)) {
|
|
if (!Check.isNull(list)) {
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
JSONObject adUnitJson = list.getJSONObject(i);
|
|
JSONObject adUnitJson = list.getJSONObject(i);
|
|
|
- adUnitJson.put("ad_unit_size",adUnitJson.getString("ad_unit_size"));
|
|
|
|
|
- adUnitJson.put("templ_type_list",adUnitJson.getString("templ_type_list"));
|
|
|
|
|
|
|
+ adUnitJson.put("ad_unit_size", adUnitJson.getString("ad_unit_size"));
|
|
|
|
|
+ adUnitJson.put("templ_type_list", adUnitJson.getString("templ_type_list"));
|
|
|
adUnitJson.put("app_id", appId);
|
|
adUnitJson.put("app_id", appId);
|
|
|
adUnitJson.put("ad_slot_name", adSlotMap.get(adUnitJson.getString("ad_slot")));
|
|
adUnitJson.put("ad_slot_name", adSlotMap.get(adUnitJson.getString("ad_slot")));
|
|
|
}
|
|
}
|
|
@@ -291,4 +290,56 @@ public class AdqAdIncomeServiceImpl implements IAdqAdIncomeService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void getAdqAdIncomeRate(String appId, Long appletId, String startDate, String endDate) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ Object tokenObj = redis2Template_db5.opsForValue().get("wechat-applet-access-token-key-" + appletId);
|
|
|
|
|
+ if (tokenObj == null) {
|
|
|
|
|
+ log.error("微小广告分成比例获取token为空 {} {}", appId, appletId);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ String url = "https://api.weixin.qq.com/wedata/wedata_get_data?access_token=" + tokenObj;
|
|
|
|
|
+ Map<String, Object> paramsMap = new HashMap<>();
|
|
|
|
|
+ paramsMap.put("chart_id", "1001001002");
|
|
|
|
|
+ paramsMap.put("target_id", "");
|
|
|
|
|
+ paramsMap.put("begin_date", startDate.replace("-", ""));
|
|
|
|
|
+ paramsMap.put("end_date", endDate.replace("-", ""));
|
|
|
|
|
+ paramsMap.put("time_unit", 0);
|
|
|
|
|
+ String s = HttpUtils.httpPostRequest(url, paramsMap, null);
|
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(s);
|
|
|
|
|
+ JSONArray results = new JSONArray();
|
|
|
|
|
+ if (!Check.isNull(jsonObject)) {
|
|
|
|
|
+ Integer code = jsonObject.getInteger("errcode");
|
|
|
|
|
+ if (code == 0) {
|
|
|
|
|
+ JSONArray list = jsonObject.getJSONArray("chart_result");
|
|
|
|
|
+ if (!Check.isNull(list)) {
|
|
|
|
|
+ JSONArray chartData = list.getJSONObject(0).getJSONArray("chart_data");
|
|
|
|
|
+ for (int i = 0; i < chartData.size(); i++) {
|
|
|
|
|
+ JSONObject chartJson = chartData.getJSONObject(i);
|
|
|
|
|
+ JSONArray value = chartJson.getJSONArray("value");
|
|
|
|
|
+ if (!Check.isNull(value)) {
|
|
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
|
|
+ result.put("stat_date", value.getInteger(0));
|
|
|
|
|
+ result.put("app_id", appId);
|
|
|
|
|
+ result.put("share_rate", value.getDoubleValue(1));
|
|
|
|
|
+ result.put("ad_give_rate", value.getDoubleValue(2));
|
|
|
|
|
+ results.add(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.error("微小广告分成比例拉取失败,app_id:{} ,返回信息:{}", appId, jsonObject);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.error("微小广告分成比例拉取失败,app_id:{} ,返回为空。", appId);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!Check.isNull(results)) {
|
|
|
|
|
+ adqAdIncomeMapper.insertAdIncomeRate(results);
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("微小广告分成比例拉取完成,app_id:{} {}~{}", appId, startDate, endDate);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("微小广告分成比例拉取失败,app_id:{}。", appId, e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|