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

点击

parent e1d0b2e9
......@@ -158,7 +158,11 @@ public class ClickbackService extends ServiceHelper{
clientInfo.setIdfa(params.get("idfaMd5"));
clientInfo.setClientIp(params.get("ip"));
clientInfo.setUa(params.get("ua"));
clientInfo.setPhoneModel(encode(params.get("model")));
String model = encode(params.get("model"));
if (StringUtils.isEmpty(model) && StringUtils.isNotEmpty(clientInfo.getUa())) {
model = getModelByUa(clientInfo.getUa());
}
clientInfo.setPhoneModel(model);
DeliveryDeviceInfo deliveryDeviceInfo = new DeliveryDeviceInfo();
deliveryDeviceInfo.setClick_time(System.currentTimeMillis());
deliveryDeviceInfo.setAd_group_id(params.get("campaign_id"));
......@@ -217,7 +221,11 @@ public class ClickbackService extends ServiceHelper{
clientInfo.setOaid(params.get("hash_oaid"));
clientInfo.setClientIp(params.get("ip"));
clientInfo.setUa(params.get("user_agent"));
clientInfo.setPhoneModel(encode(params.get("model")));
String model = encode(params.get("model"));
if (StringUtils.isEmpty(model) && StringUtils.isNotEmpty(clientInfo.getUa())) {
model = getModelByUa(clientInfo.getUa());
}
clientInfo.setPhoneModel(model);
DeliveryDeviceInfo deliveryDeviceInfo = new DeliveryDeviceInfo();
deliveryDeviceInfo.setClick_time(System.currentTimeMillis());
deliveryDeviceInfo.setClick_id(params.get("click_id"));
......@@ -268,7 +276,11 @@ public class ClickbackService extends ServiceHelper{
clientInfo.setClientIp(params.get("ip"));
clientInfo.setUa(params.get("ua"));
clientInfo.setOs(params.get("os"));
clientInfo.setPhoneModel(encode(params.get("model")));
String model = encode(params.get("model"));
if (StringUtils.isEmpty(model) && StringUtils.isNotEmpty(clientInfo.getUa())) {
model = getModelByUa(clientInfo.getUa());
}
clientInfo.setPhoneModel(model);
DeliveryDeviceInfo deliveryDeviceInfo = new DeliveryDeviceInfo();
deliveryDeviceInfo.setClick_time(System.currentTimeMillis());
deliveryDeviceInfo.setAd_group_id(params.get("campaign_id"));
......
......@@ -52,4 +52,23 @@ public class ServiceHelper {
}
return null;
}
public String getModelByUa(String ua) {
String uasplit = ua.split("Build")[0];
String model = null;
try {
if (ua.startsWith("com.")) {
String[] split = uasplit.split(";");
model = split[4].trim();
} else {
if (uasplit.split(";").length >= 3 && StringUtils.isNotEmpty(uasplit.split(";")[2].trim())) {
model = uasplit.substring(uasplit.lastIndexOf(";") + 2, uasplit.length() - 1);
model = URLEncoder.encode(model, "utf-8");
}
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return model;
}
}
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