Commit e6a972e8 authored by 宋新宇's avatar 宋新宇

Merge branch '3-抖音短剧及短剧app归因接入' into 'release_20240327_01'

短剧APP归因

See merge request !16
parents c77b32ab e2c3a4ca
......@@ -64,7 +64,7 @@ public class DyVideoUniversalProcess extends UniversalProcess {
ddi.setDevice_id(String.valueOf(action.getUserId()));
ddi.setActive_time(System.currentTimeMillis());
ddi.setChannel(String.valueOf(action.getChannelId()));
ddi.setUserId(action.getUserId());
ddi.setOpenId(action.getOpenId());
String jsonString = JSONObject.toJSONString(ddi);
ListenableFuture<SendResult<String, String>> active_result = novelKafkaTemplate.send(topic, jsonString);
......
package com.lwby.marketing.notify.media.jrtt;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lwby.marketing.notify.MobileNotify;
import com.lwby.marketing.notify.media.jrtt.dto.JrttAttributeRequest;
import com.lwby.marketing.util.HttpUtil;
import com.lwby.marketing.util.Signature;
import com.lwby.marketing.vo.ClientInfo;
import com.lwby.marketing.vo.DeliveryDeviceInfo;
import com.lwby.marketing.vo.NovelAction;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.util.HashMap;
import java.util.Objects;
@Slf4j
public class VideoAppJRTTNotify extends MobileNotify {
public static final String ATTRIBUTE_URL = "https://analytics.oceanengine.com/api/v2/conversion";
public static final String uploadAndroidUrl = "https://www.csjplatform.com/growth_dispatcher/api/attribution_callback_self_built/276cbd93-aae4-9b66-68be-b086f7a419d1/android?pg_site_id=5385181&signature=";
public static final String uploadIosUrl = "https://www.csjplatform.com/growth_dispatcher/api/attribution_callback_self_built/155005fb-6940-4134-8729-f7eb9fb993d6/ios?pg_site_id=5443881&signature=";
@Override
public boolean android(NovelAction na) {
return na.getType() == 0 ? android(na,"active") :android(na,"game_addiction");
return Objects.equals(na.getType(),0) ? android(na,"active") :android(na,"game_addiction");
}
@Override
public boolean ios(NovelAction na) {
return na.getType() == 0 ? android(na,"active") :android(na,"game_addiction");
return Objects.equals(na.getType(),0) ? ios(na,"active") :ios(na,"game_addiction");
}
public boolean android(NovelAction na,String eventType){
......@@ -48,6 +62,9 @@ public class VideoAppJRTTNotify extends MobileNotify {
// Integer resultCode = (Integer) JSON.parseObject(result).get("code");
// return resultCode == 0;
log.info("VideoAppJRTTNotify android Callback info:{}",userJson);
//if (Objects.equals(na.getType(),0)) {
// sendAutoAttribute(ci,ddi,uploadAndroidUrl);
//}
return true;
} catch (Exception e) {
return false;
......@@ -79,9 +96,96 @@ public class VideoAppJRTTNotify extends MobileNotify {
// Integer resultCode = (Integer) JSON.parseObject(result).get("code");
// return resultCode == 0;
log.info("VideoAppJRTTNotify ios Callback info:{}",userJson);
//if (Objects.equals(na.getType(),0)) {
// sendAutoAttribute(ci,ddi,uploadIosUrl);
//}
return true;
} catch (Exception e) {
return false;
}
}
private void sendAutoAttribute(ClientInfo clientInfo, DeliveryDeviceInfo deliveryDeviceInfo,String url) {
try {
String clientIp = clientInfo.getClientIp();
String ua = clientInfo.getUa();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("time_ts",System.currentTimeMillis());
map.put("ad_platform","toutiao_v2");
if ("0".equals(clientInfo.getOs())) {
if (StringUtils.isNotEmpty(clientInfo.getImei())) {
map.put("imei",clientInfo.getImei());
map.put("imei_md5",SecureUtil.md5(clientInfo.getImei()));
}
if (StringUtils.isNotEmpty(clientInfo.getOaid())) {
map.put("oaid",clientInfo.getOaid());
map.put("oaid_md5",SecureUtil.md5(clientInfo.getOaid()));
}
if (StringUtils.isNotEmpty(clientInfo.getDID())) {
map.put("android_id",clientInfo.getDID());
map.put("android_id_md5", SecureUtil.md5(clientInfo.getDID()));
}
} else if ("1".equals(clientInfo.getOs())){
if (StringUtils.isNotEmpty(clientInfo.getIdfa()) && !"00000000-0000-0000-0000-000000000000".equals(clientInfo.getIdfa())) {
map.put("idfa",clientInfo.getIdfa());
map.put("idfa_md5",SecureUtil.md5(clientInfo.getIdfa()));
} else {
map.put("idfa",clientInfo.getDID());
map.put("idfa_md5",SecureUtil.md5(clientInfo.getDID()));
}
if (StringUtils.isNotEmpty(clientIp) && StringUtils.isNotEmpty(ua)) {
map.put("ip",clientIp);
map.put("ua",ua);
}
}
map.put("ad_id",deliveryDeviceInfo.getPromotion_id());
map.put("ad_name",deliveryDeviceInfo.getPromotion_name());
map.put("campaign_id",deliveryDeviceInfo.getProject_id());
map.put("campaign_name",deliveryDeviceInfo.getProject_name());
map.put("ad_account_id",deliveryDeviceInfo.getAdvertiser_id());
if (StringUtils.isNotBlank(deliveryDeviceInfo.getMid1())) {
map.put("mid1",deliveryDeviceInfo.getMid1());
}
if (StringUtils.isNotBlank(deliveryDeviceInfo.getMid2())) {
map.put("mid2",deliveryDeviceInfo.getMid2());
}
if (StringUtils.isNotBlank(deliveryDeviceInfo.getMid3())) {
map.put("mid3",deliveryDeviceInfo.getMid3());
}
if (StringUtils.isNotBlank(deliveryDeviceInfo.getMid4())) {
map.put("mid4",deliveryDeviceInfo.getMid4());
}
if (StringUtils.isNotBlank(deliveryDeviceInfo.getMid5())) {
map.put("mid5",deliveryDeviceInfo.getMid5());
}
if (StringUtils.isNotBlank(deliveryDeviceInfo.getMid6())) {
map.put("mid6",deliveryDeviceInfo.getMid6());
}
String signature = Signature.getSignature(map);
String mapAction = JSONObject.toJSONString(map);
try {
String result = HttpUtil.post(url+signature, mapAction);
JSONObject bresp = (JSONObject) JSON.parseObject(result).get("base_resp");
Integer resultCode = (Integer) bresp.get("status");
if (resultCode == 0) {
log.info("JrttFreeVideoActiveImpl.sendAutoAttribute success, clientInfo = {}, deliveryDeviceInfo = {}",
JSON.toJSONString(clientInfo),JSON.toJSONString(deliveryDeviceInfo));
} else {
log.info("JrttFreeVideoActiveImpl.sendAutoAttribute fail, result={}, clientInfo = {} , deliveryDeviceInfo = {}",
result,JSON.toJSONString(clientInfo),JSON.toJSONString(deliveryDeviceInfo));
}
} catch (IOException e) {
e.printStackTrace();
}
} catch (Throwable e) {
log.info("JrttFreeVideoActiveImpl.sendAutoAttribute error,clientInfo={}",JSON.toJSONString(clientInfo),e);
}
}
}
package com.lwby.marketing.util;
import org.apache.commons.codec.digest.DigestUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
/**
* @author songxinyu
* @version Signature.java, v 0.1 2023年06月28日 11:28 songxinyu Exp $
*/
public class Signature {
private static final String apiKey = "436a49808b0ed157";
private static final String apiKeyIos = "1749844bed13f705";
public static String getSignature(Map<String, Object> data) {
TreeMap<String, Object> sorted = new TreeMap<>();
sorted.putAll(data);
String dataBeforeMD5 = "";
for(Map.Entry<String, Object> entry : sorted.entrySet()) {
if(!"".equals(entry.getValue())) {
dataBeforeMD5 += entry.getKey() + "=" + entry.getValue() + "&";
}
}
dataBeforeMD5 += "secretKey=" + apiKey;
String signature = DigestUtils.md5Hex(dataBeforeMD5.getBytes());
System.out.println(dataBeforeMD5);
return signature;
}
public static String getSignatureIos(Map<String, Object> data) {
TreeMap<String, Object> sorted = new TreeMap<>();
sorted.putAll(data);
String dataBeforeMD5 = "";
for(Map.Entry<String, Object> entry : sorted.entrySet()) {
if(!"".equals(entry.getValue())) {
dataBeforeMD5 += entry.getKey() + "=" + entry.getValue() + "&";
}
}
dataBeforeMD5 += "secretKey=" + apiKeyIos;
String signature = DigestUtils.md5Hex(dataBeforeMD5.getBytes());
System.out.println(dataBeforeMD5);
return signature;
}
public static void main(String[] args) {
Map<String, Object> data = new HashMap<>();
data.put("paramC", "c");
data.put("paramD", "");
data.put("paramE", "e");
data.put("paramA", "a");
data.put("paramB", "b");
System.out.println(data);
System.out.println(getSignature(data));
}
}
......@@ -122,4 +122,7 @@ public class DeliveryDeviceInfo {
private String mid4;
private String mid5;
private String mid6;
private String openId;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment