|
|
@@ -3,12 +3,14 @@ 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.mapper.BytedancePromoterReportMapper;
|
|
|
import cn.com.ctop.job.bytedance.data.mapper.DianZhongMapper;
|
|
|
+import cn.com.ctop.job.bytedance.data.service.ICacheService;
|
|
|
import cn.com.ctop.job.bytedance.data.service.IDianZhongService;
|
|
|
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;
|
|
|
import cn.com.ctop.job.bytedance.utils.doris.sink.DorisMultiTableStreamLoadManager;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.crypto.SecureUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -24,10 +26,17 @@ import java.nio.charset.StandardCharsets;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
+ private static final ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICacheService cacheService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private DorisMultiTableStreamLoadManager dorisLoadManager;
|
|
|
|
|
|
@@ -46,10 +55,6 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
put(17, 3);//快小
|
|
|
}};
|
|
|
|
|
|
- private static final Map<String, String> clientDomain2AppId = new HashMap<String, String>() {{
|
|
|
- put("10003129" + "14", "dzdyIAP");//抖小
|
|
|
- }};
|
|
|
-
|
|
|
private static final Map<String, String> media2Id = new HashMap<String, String>() {{
|
|
|
put("adq", "3");//腾讯广点通
|
|
|
put("dy", "1");//字节巨量
|
|
|
@@ -128,47 +133,61 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
下载点众IAP数据
|
|
|
*/
|
|
|
public void getUrlData(String statDate) {
|
|
|
- List<JSONObject> tasks = dianZhongMapper.getTaskUrl(statDate.replace("-", ""));
|
|
|
+ List<JSONObject> tasks = dianZhongMapper.getTaskUrl(statDate == null ? null : statDate.replace("-", ""));
|
|
|
if (!Check.isNull(tasks)) {
|
|
|
for (JSONObject task : tasks) {
|
|
|
- String taskId = task.getString("task_id");
|
|
|
- String url = task.getString("url");
|
|
|
- String type = task.getString("type");
|
|
|
- String clientId = task.getString("client_id");
|
|
|
-
|
|
|
- downloadFileRestTemplate.execute(url, org.springframework.http.HttpMethod.GET, null,
|
|
|
- (ResponseExtractor<Void>) response -> {
|
|
|
- try (BufferedReader reader = new BufferedReader(
|
|
|
- new InputStreamReader(response.getBody(), StandardCharsets.UTF_8))) {
|
|
|
- String line;
|
|
|
- while ((line = reader.readLine()) != null) {
|
|
|
- if ("user".equals(type)) {
|
|
|
- JSONObject dzUser = getDZUser(line, clientId);
|
|
|
- dorisLoadManager.add("hr_playlet", "user_event", dzUser);
|
|
|
- JSONObject dzLogin = getDZLogin(line, clientId);
|
|
|
- dorisLoadManager.add("hr_playlet", "server_event", dzLogin);
|
|
|
- } else if ("order".equals(type)) {
|
|
|
- JSONObject dzOrder = getDZOrder(line, clientId);
|
|
|
- dorisLoadManager.add("hr_playlet", "server_event", dzOrder);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- });
|
|
|
- dianZhongMapper.updateTaskDownloaded(taskId);
|
|
|
+ executorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ String taskId = task.getString("task_id");
|
|
|
+ String url = task.getString("url");
|
|
|
+ String type = task.getString("type");
|
|
|
+ String clientId = task.getString("client_id");
|
|
|
+ String dataDate = task.getString("stat_date");
|
|
|
+ try {
|
|
|
+ log.info("开始下载点众数据 taskId:{}, clientId:{}, type:{}", taskId, clientId, type);
|
|
|
+ downloadFileRestTemplate.execute(url, org.springframework.http.HttpMethod.GET, null,
|
|
|
+ (ResponseExtractor<Void>) response -> {
|
|
|
+ try (BufferedReader reader = new BufferedReader(
|
|
|
+ new InputStreamReader(response.getBody(), StandardCharsets.UTF_8))) {
|
|
|
+ String line;
|
|
|
+ while ((line = reader.readLine()) != null) {
|
|
|
+ if ("user".equals(type)) {
|
|
|
+ getDZUser(line);
|
|
|
+ getDZLogin(line);
|
|
|
+ getDZActivation(line);
|
|
|
+ getDZRegister(line, dataDate);
|
|
|
+ } else if ("order".equals(type)) {
|
|
|
+ getDZOrder(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ });
|
|
|
+ dianZhongMapper.updateTaskDownloaded(taskId);
|
|
|
+ log.info("下载点众数据成功 taskId:{}, clientId:{}, type:{}", taskId, clientId, type);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("下载点众数据失败 taskId:{}, clientId:{}, type:{}", taskId, clientId, type, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static String getSignKey(String clientId, String token, long timeStamp) {
|
|
|
+ private String getSignKey(String clientId, String token, long timeStamp) {
|
|
|
return SecureUtil.md5(clientId + token + timeStamp).toLowerCase();
|
|
|
}
|
|
|
|
|
|
- private static JSONObject getDZUser(String line, String clientId) {
|
|
|
+ private void getDZUser(String line) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(line);
|
|
|
+ String channelId = jsonObject.getString("channelId");
|
|
|
+ String appIdByChannelId = cacheService.getDZAppIdByChannelId(channelId);
|
|
|
+ if (StringUtils.isBlank(appIdByChannelId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
JSONObject userJson = new JSONObject();
|
|
|
int domain = jsonObject.getIntValue("domain");
|
|
|
- String appId = clientId + domain;
|
|
|
Long ctime = jsonObject.getLong("ctime");
|
|
|
String statDate = DateUtils.formatDate(ctime * 1000, "yyyyMMdd");
|
|
|
String registerTime = DateUtils.formatDate(ctime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
@@ -176,9 +195,9 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
String promotionId = jsonObject.getString("promotionId");
|
|
|
adId = StringUtils.isNotBlank(promotionId) ? promotionId : adId;
|
|
|
Long dyeTime = jsonObject.getLong("dyeTime");
|
|
|
- String activationTime = DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String activationTime = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss") : null;
|
|
|
String fromMedia = jsonObject.getString("from");
|
|
|
- userJson.put("app_id", clientDomain2AppId.getOrDefault(appId, appId));
|
|
|
+ userJson.put("app_id", appIdByChannelId);
|
|
|
userJson.put("uid", jsonObject.getString("userId"));
|
|
|
userJson.put("stat_date", statDate);
|
|
|
userJson.put("register_time", registerTime);
|
|
|
@@ -186,7 +205,7 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
userJson.put("open_id", jsonObject.getString("openId"));
|
|
|
userJson.put("platform", domain2Platform.getOrDefault(domain, domain));
|
|
|
userJson.put("official_account_open_id", jsonObject.getString("thirdWxId"));
|
|
|
- userJson.put("channel_id", jsonObject.getString("channelId"));
|
|
|
+ userJson.put("channel_id", channelId);
|
|
|
userJson.put("link_id", jsonObject.getString("referralId"));
|
|
|
userJson.put("expiration_time", jsonObject.getString("vipEndDate"));
|
|
|
userJson.put("pay_amount", jsonObject.getString("payAmount"));
|
|
|
@@ -199,36 +218,54 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
userJson.put("ad_id", adId);
|
|
|
userJson.put("activation_time", activationTime);
|
|
|
userJson.put("media_id", media2Id.getOrDefault(fromMedia, fromMedia));
|
|
|
- return userJson;
|
|
|
+
|
|
|
+ if (NumberUtil.isLong(adId) && !"0".equals(adId)) {
|
|
|
+ String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", registerTime.substring(0, 10), -15);
|
|
|
+ Map<String, String> ad2Advertiser = cacheService.getBytedanceAdvertiserByAd(adId, DateUtils.getDateInteger(anotherDay));
|
|
|
+ if (!Check.isNullMap(ad2Advertiser)) {
|
|
|
+ String advertiserId = ad2Advertiser.get("advertiser_id");
|
|
|
+ userJson.put("advertiser_id", advertiserId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dorisLoadManager.add("hr_playlet", "user_event", userJson);
|
|
|
}
|
|
|
|
|
|
- private static JSONObject getDZLogin(String line, String clientId) {
|
|
|
+ private void getDZLogin(String line) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(line);
|
|
|
+ String channelId = jsonObject.getString("channelId");
|
|
|
+ String appIdByChannelId = cacheService.getDZAppIdByChannelId(channelId);
|
|
|
+ if (StringUtils.isBlank(appIdByChannelId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
JSONObject loginJson = new JSONObject();
|
|
|
int domain = jsonObject.getIntValue("domain");
|
|
|
- String appId = clientId + domain;
|
|
|
Long loginTime = jsonObject.getLong("loginTime");
|
|
|
String statDate = DateUtils.formatDate(loginTime * 1000, "yyyyMMdd");
|
|
|
String adId = jsonObject.getString("adid");
|
|
|
String promotionId = jsonObject.getString("promotionId");
|
|
|
adId = StringUtils.isNotBlank(promotionId) ? promotionId : adId;
|
|
|
Long dyeTime = jsonObject.getLong("dyeTime");
|
|
|
- String activationTime = DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String activationTime = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss") : null;
|
|
|
+ String activationDate = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyyMMdd") : null;
|
|
|
+ Long ctime = jsonObject.getLong("ctime");
|
|
|
+ String registerTime = DateUtils.formatDate(ctime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String registerDate = DateUtils.formatDate(ctime * 1000, "yyyyMMdd");
|
|
|
String fromMedia = jsonObject.getString("from");
|
|
|
String userId = jsonObject.getString("userId");
|
|
|
+ loginJson.put("app_id", appIdByChannelId);
|
|
|
loginJson.put("stat_date", statDate);
|
|
|
loginJson.put("event", "LOGIN");
|
|
|
loginJson.put("event_pk", SecureUtil.md5(String.format("dianzhong_login_%s_%s", userId, loginTime)));
|
|
|
loginJson.put("event_tag", "dianzhong_login");
|
|
|
- loginJson.put("app_id", clientDomain2AppId.getOrDefault(appId, appId));
|
|
|
-
|
|
|
+ loginJson.put("activation_date", activationDate);
|
|
|
loginJson.put("uid", userId);
|
|
|
loginJson.put("open_id", jsonObject.getString("openId"));
|
|
|
loginJson.put("platform", domain2Platform.getOrDefault(domain, domain));
|
|
|
loginJson.put("official_account_open_id", jsonObject.getString("thirdWxId"));
|
|
|
- loginJson.put("channel_id", jsonObject.getString("channelId"));
|
|
|
+ loginJson.put("channel_id", channelId);
|
|
|
loginJson.put("link_id", jsonObject.getString("referralId"));
|
|
|
- loginJson.put("register_date", jsonObject.getString("registerDate"));
|
|
|
+ loginJson.put("register_date", registerDate);
|
|
|
+ loginJson.put("register_time", registerTime);
|
|
|
loginJson.put("expiration_time", jsonObject.getString("vipEndDate"));
|
|
|
loginJson.put("last_login_time", jsonObject.getString("loginTime"));
|
|
|
loginJson.put("created_at", loginTime);
|
|
|
@@ -239,28 +276,166 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
loginJson.put("ad_id", adId);
|
|
|
loginJson.put("activation_time", activationTime);
|
|
|
loginJson.put("media_id", media2Id.getOrDefault(fromMedia, fromMedia));
|
|
|
- return loginJson;
|
|
|
+
|
|
|
+ if (NumberUtil.isLong(adId) && !"0".equals(adId)) {
|
|
|
+ String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(loginTime * 1000, "yyyy-MM-dd"), -15);
|
|
|
+ Map<String, String> ad2Advertiser = cacheService.getBytedanceAdvertiserByAd(adId, DateUtils.getDateInteger(anotherDay));
|
|
|
+ if (!Check.isNullMap(ad2Advertiser)) {
|
|
|
+ String advertiserId = ad2Advertiser.get("advertiser_id");
|
|
|
+ loginJson.put("advertiser_id", advertiserId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dorisLoadManager.add("hr_playlet", "server_event", loginJson);
|
|
|
}
|
|
|
|
|
|
- private static JSONObject getDZOrder(String line, String clientId) {
|
|
|
+ private void getDZActivation(String line) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(line);
|
|
|
+ String channelId = jsonObject.getString("channelId");
|
|
|
+ String appIdByChannelId = cacheService.getDZAppIdByChannelId(channelId);
|
|
|
+ if (StringUtils.isBlank(appIdByChannelId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject loginJson = new JSONObject();
|
|
|
+ int domain = jsonObject.getIntValue("domain");
|
|
|
+ Long loginTime = jsonObject.getLong("loginTime");
|
|
|
+ String adId = jsonObject.getString("adid");
|
|
|
+ String promotionId = jsonObject.getString("promotionId");
|
|
|
+ adId = StringUtils.isNotBlank(promotionId) ? promotionId : adId;
|
|
|
+ Long dyeTime = jsonObject.getLong("dyeTime");
|
|
|
+ if (dyeTime == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String statDate = DateUtils.formatDate(dyeTime * 1000, "yyyyMMdd");
|
|
|
+ String activationTime = DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ Long ctime = jsonObject.getLong("ctime");
|
|
|
+ String registerTime = DateUtils.formatDate(ctime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String registerDate = DateUtils.formatDate(ctime * 1000, "yyyyMMdd");
|
|
|
+ String fromMedia = jsonObject.getString("from");
|
|
|
+ String userId = jsonObject.getString("userId");
|
|
|
+ loginJson.put("app_id", appIdByChannelId);
|
|
|
+ loginJson.put("stat_date", statDate);
|
|
|
+ loginJson.put("event", "ACTIVATION");
|
|
|
+ loginJson.put("event_pk", SecureUtil.md5(String.format("dianzhong_activation_%s_%s", userId, dyeTime)));
|
|
|
+ loginJson.put("event_tag", "dianzhong_activation");
|
|
|
+ loginJson.put("activation_date", statDate);
|
|
|
+ loginJson.put("uid", userId);
|
|
|
+ loginJson.put("open_id", jsonObject.getString("openId"));
|
|
|
+ loginJson.put("platform", domain2Platform.getOrDefault(domain, domain));
|
|
|
+ loginJson.put("official_account_open_id", jsonObject.getString("thirdWxId"));
|
|
|
+ loginJson.put("channel_id", channelId);
|
|
|
+ loginJson.put("link_id", jsonObject.getString("referralId"));
|
|
|
+ loginJson.put("register_date", registerDate);
|
|
|
+ loginJson.put("register_time", registerTime);
|
|
|
+ loginJson.put("expiration_time", jsonObject.getString("vipEndDate"));
|
|
|
+ loginJson.put("last_login_time", jsonObject.getString("loginTime"));
|
|
|
+ loginJson.put("created_at", dyeTime);
|
|
|
+ loginJson.put("ip", jsonObject.getString("ip"));
|
|
|
+ loginJson.put("mobile_system", jsonObject.getIntValue("os") == 0 ? "Android" : "ios");
|
|
|
+ loginJson.put("person_id", jsonObject.getString("kdrId"));
|
|
|
+ loginJson.put("a_id", jsonObject.getString("projectId"));
|
|
|
+ loginJson.put("ad_id", adId);
|
|
|
+ loginJson.put("activation_time", activationTime);
|
|
|
+ loginJson.put("media_id", media2Id.getOrDefault(fromMedia, fromMedia));
|
|
|
+
|
|
|
+ if (NumberUtil.isLong(adId) && !"0".equals(adId)) {
|
|
|
+ String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(loginTime * 1000, "yyyy-MM-dd"), -15);
|
|
|
+ Map<String, String> ad2Advertiser = cacheService.getBytedanceAdvertiserByAd(adId, DateUtils.getDateInteger(anotherDay));
|
|
|
+ if (!Check.isNullMap(ad2Advertiser)) {
|
|
|
+ String advertiserId = ad2Advertiser.get("advertiser_id");
|
|
|
+ loginJson.put("advertiser_id", advertiserId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dorisLoadManager.add("hr_playlet", "server_event", loginJson);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getDZRegister(String line, String date) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(line);
|
|
|
+ String channelId = jsonObject.getString("channelId");
|
|
|
+ String appIdByChannelId = cacheService.getDZAppIdByChannelId(channelId);
|
|
|
+ if (StringUtils.isBlank(appIdByChannelId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject loginJson = new JSONObject();
|
|
|
+ int domain = jsonObject.getIntValue("domain");
|
|
|
+ Long ctime = jsonObject.getLong("ctime");
|
|
|
+ String statDate = DateUtils.formatDate(ctime * 1000, "yyyyMMdd");
|
|
|
+ Long loginTime = jsonObject.getLong("loginTime");
|
|
|
+ String adId = jsonObject.getString("adid");
|
|
|
+ String promotionId = jsonObject.getString("promotionId");
|
|
|
+ adId = StringUtils.isNotBlank(promotionId) ? promotionId : adId;
|
|
|
+ Long dyeTime = jsonObject.getLong("dyeTime");
|
|
|
+ String activationTime = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss") : null;
|
|
|
+ String activationDate = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyyMMdd") : null;
|
|
|
+ String registerTime = DateUtils.formatDate(ctime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String registerDate = DateUtils.formatDate(ctime * 1000, "yyyyMMdd");
|
|
|
+ String fromMedia = jsonObject.getString("from");
|
|
|
+ String userId = jsonObject.getString("userId");
|
|
|
+ loginJson.put("app_id", appIdByChannelId);
|
|
|
+ loginJson.put("stat_date", statDate);
|
|
|
+ loginJson.put("event", "REGISTER");
|
|
|
+ loginJson.put("event_pk", SecureUtil.md5(String.format("dianzhong_register_%s_%s", userId, ctime)));
|
|
|
+ loginJson.put("event_tag", "dianzhong_register");
|
|
|
+ loginJson.put("activation_date", activationDate);
|
|
|
+ loginJson.put("uid", userId);
|
|
|
+ loginJson.put("open_id", jsonObject.getString("openId"));
|
|
|
+ loginJson.put("platform", domain2Platform.getOrDefault(domain, domain));
|
|
|
+ loginJson.put("official_account_open_id", jsonObject.getString("thirdWxId"));
|
|
|
+ loginJson.put("channel_id", channelId);
|
|
|
+ loginJson.put("link_id", jsonObject.getString("referralId"));
|
|
|
+ loginJson.put("register_date", registerDate);
|
|
|
+ loginJson.put("register_time", registerTime);
|
|
|
+ loginJson.put("expiration_time", jsonObject.getString("vipEndDate"));
|
|
|
+ loginJson.put("last_login_time", jsonObject.getString("loginTime"));
|
|
|
+ loginJson.put("created_at", ctime);
|
|
|
+ loginJson.put("ip", jsonObject.getString("ip"));
|
|
|
+ loginJson.put("mobile_system", jsonObject.getIntValue("os") == 0 ? "Android" : "ios");
|
|
|
+ loginJson.put("person_id", jsonObject.getString("kdrId"));
|
|
|
+ loginJson.put("a_id", jsonObject.getString("projectId"));
|
|
|
+ loginJson.put("ad_id", adId);
|
|
|
+ loginJson.put("activation_time", activationTime);
|
|
|
+ loginJson.put("media_id", media2Id.getOrDefault(fromMedia, fromMedia));
|
|
|
+
|
|
|
+ if (NumberUtil.isLong(adId) && !"0".equals(adId)) {
|
|
|
+ String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(loginTime * 1000, "yyyy-MM-dd"), -15);
|
|
|
+ Map<String, String> ad2Advertiser = cacheService.getBytedanceAdvertiserByAd(adId, DateUtils.getDateInteger(anotherDay));
|
|
|
+ if (!Check.isNullMap(ad2Advertiser)) {
|
|
|
+ String advertiserId = ad2Advertiser.get("advertiser_id");
|
|
|
+ loginJson.put("advertiser_id", advertiserId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (date.replace("-", "").equals(statDate)) {
|
|
|
+ dorisLoadManager.add("hr_playlet", "server_event", loginJson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getDZOrder(String line) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(line);
|
|
|
JSONObject orderJson = new JSONObject();
|
|
|
+ String channelId = jsonObject.getString("channelId");
|
|
|
+ String appIdByChannelId = cacheService.getDZAppIdByChannelId(channelId);
|
|
|
+ if (StringUtils.isBlank(appIdByChannelId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
String orderId = jsonObject.getString("id");
|
|
|
int domain = jsonObject.getIntValue("domain");
|
|
|
- String appId = clientId + domain;
|
|
|
Long ctime = jsonObject.getLong("ctime");
|
|
|
String statDate = DateUtils.formatDate(ctime * 1000, "yyyyMMdd");
|
|
|
String adId = jsonObject.getString("adid");
|
|
|
String promotionId = jsonObject.getString("promotionId");
|
|
|
adId = StringUtils.isNotBlank(promotionId) ? promotionId : adId;
|
|
|
Long dyeTime = jsonObject.getLong("dyeTime");
|
|
|
- String activationTime = DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String activationTime = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyy-MM-dd HH:mm:ss") : null;
|
|
|
+ String activationDate = dyeTime != null ? DateUtils.formatDate(dyeTime * 1000, "yyyyMMdd") : null;
|
|
|
+ Long registerT = jsonObject.getLong("registerDate");
|
|
|
+ String registerTime = DateUtils.formatDate(registerT * 1000, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String registerDate = DateUtils.formatDate(registerT * 1000, "yyyyMMdd");
|
|
|
String fromMedia = jsonObject.getString("from");
|
|
|
+ orderJson.put("app_id", appIdByChannelId);
|
|
|
orderJson.put("stat_date", statDate);
|
|
|
orderJson.put("event", "PAY");
|
|
|
orderJson.put("event_pk", SecureUtil.md5("dianzhong_order_id:" + orderId));
|
|
|
orderJson.put("event_tag", "dianzhong_order");
|
|
|
- orderJson.put("app_id", clientDomain2AppId.getOrDefault(appId, appId));
|
|
|
orderJson.put("order_no", orderId);
|
|
|
orderJson.put("platform_order_no", jsonObject.getString("outTradeNo"));
|
|
|
orderJson.put("total_fee", jsonObject.getString("discount"));
|
|
|
@@ -269,12 +444,13 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
orderJson.put("created_at", ctime);
|
|
|
orderJson.put("pay_time", jsonObject.getLong("finishTime"));
|
|
|
orderJson.put("uid", jsonObject.getString("userId"));
|
|
|
- orderJson.put("channel_id", jsonObject.getString("channelId"));
|
|
|
+ orderJson.put("channel_id", channelId);
|
|
|
orderJson.put("platform", domain2Platform.getOrDefault(domain, domain));
|
|
|
orderJson.put("video_id", jsonObject.getString("sourceInfo"));
|
|
|
orderJson.put("video_detail_id", jsonObject.getString("chapterId"));
|
|
|
orderJson.put("video_name", jsonObject.getString("sourceDesc"));
|
|
|
- orderJson.put("register_date", jsonObject.getString("registerDate"));
|
|
|
+ orderJson.put("register_date", registerDate);
|
|
|
+ orderJson.put("register_time", registerTime);
|
|
|
orderJson.put("open_id", jsonObject.getString("openId"));
|
|
|
orderJson.put("mobile_system", jsonObject.getIntValue("os") == 0 ? "Android" : "ios");
|
|
|
orderJson.put("link_id", jsonObject.getString("referralId"));
|
|
|
@@ -284,10 +460,20 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
orderJson.put("scene", jsonObject.getString("scene"));
|
|
|
orderJson.put("official_account_open_id", jsonObject.getString("thirdWxId"));
|
|
|
orderJson.put("activation_time", activationTime);
|
|
|
+ orderJson.put("activation_date", activationDate);
|
|
|
orderJson.put("pay_type", jsonObject.getString("orderSubType"));
|
|
|
orderJson.put("media_id", media2Id.getOrDefault(fromMedia, fromMedia));
|
|
|
orderJson.put("money_benefit", jsonObject.getDouble("moneyBenefit"));
|
|
|
orderJson.put("params", jsonObject.toJSONString());
|
|
|
- return orderJson;
|
|
|
+
|
|
|
+ if (NumberUtil.isLong(adId) && !"0".equals(adId)) {
|
|
|
+ String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(ctime * 1000, "yyyy-MM-dd"), -15);
|
|
|
+ Map<String, String> ad2Advertiser = cacheService.getBytedanceAdvertiserByAd(adId, DateUtils.getDateInteger(anotherDay));
|
|
|
+ if (!Check.isNullMap(ad2Advertiser)) {
|
|
|
+ String advertiserId = ad2Advertiser.get("advertiser_id");
|
|
|
+ orderJson.put("advertiser_id", advertiserId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dorisLoadManager.add("hr_playlet", "server_event", orderJson);
|
|
|
}
|
|
|
}
|