|
|
@@ -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;
|
|
|
@@ -29,6 +31,9 @@ import java.util.Map;
|
|
|
@Slf4j
|
|
|
public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
@Autowired
|
|
|
+ private ICacheService cacheService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private DorisMultiTableStreamLoadManager dorisLoadManager;
|
|
|
|
|
|
@Autowired
|
|
|
@@ -160,11 +165,11 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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 JSONObject getDZUser(String line, String clientId) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(line);
|
|
|
JSONObject userJson = new JSONObject();
|
|
|
int domain = jsonObject.getIntValue("domain");
|
|
|
@@ -199,10 +204,20 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
userJson.put("ad_id", adId);
|
|
|
userJson.put("activation_time", activationTime);
|
|
|
userJson.put("media_id", media2Id.getOrDefault(fromMedia, fromMedia));
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return userJson;
|
|
|
}
|
|
|
|
|
|
- private static JSONObject getDZLogin(String line, String clientId) {
|
|
|
+ private JSONObject getDZLogin(String line, String clientId) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(line);
|
|
|
JSONObject loginJson = new JSONObject();
|
|
|
int domain = jsonObject.getIntValue("domain");
|
|
|
@@ -239,10 +254,19 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
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);
|
|
|
+ }
|
|
|
+ }
|
|
|
return loginJson;
|
|
|
}
|
|
|
|
|
|
- private static JSONObject getDZOrder(String line, String clientId) {
|
|
|
+ private JSONObject getDZOrder(String line, String clientId) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(line);
|
|
|
JSONObject orderJson = new JSONObject();
|
|
|
String orderId = jsonObject.getString("id");
|
|
|
@@ -288,6 +312,15 @@ public class DianZhongServiceImpl implements IDianZhongService {
|
|
|
orderJson.put("media_id", media2Id.getOrDefault(fromMedia, fromMedia));
|
|
|
orderJson.put("money_benefit", jsonObject.getDouble("moneyBenefit"));
|
|
|
orderJson.put("params", jsonObject.toJSONString());
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
return orderJson;
|
|
|
}
|
|
|
}
|