增加归因数据回传
This commit is contained in:
parent
b2dc343c93
commit
cde30ab1f9
|
|
@ -6,6 +6,7 @@ import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
|
|||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import com.google.gson.Gson;
|
||||
import com.ruoyi.common.config.BaiduConfig;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.CacheUtils;
|
||||
|
|
@ -18,7 +19,10 @@ import com.ruoyi.system.domain.NoticeRequest;
|
|||
import com.ruoyi.system.domain.OppoCheck;
|
||||
import com.ruoyi.system.service.IClewPhoneService;
|
||||
import com.ruoyi.web.core.config.GlobalLogHelper;
|
||||
import io.swagger.models.Model;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
|
@ -36,6 +40,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.ruoyi.common.utils.http.HttpUtils.sendPost;
|
||||
|
||||
/**
|
||||
* @author clunt
|
||||
* 通知模块
|
||||
|
|
@ -82,6 +88,23 @@ public class NoticeController {
|
|||
@RequestParam("actionType")String actionType,
|
||||
@RequestParam("callBack")String callBack){
|
||||
log.info("归因转化回调内容,{},{},{},{},{},{},{}", aid, appId, oaid, idType, uniqueId, actionType, callBack);
|
||||
HuaweiRequest huaweiRequest=new HuaweiRequest();
|
||||
huaweiRequest.setActionType(actionType);
|
||||
huaweiRequest.setActionTime(System.currentTimeMillis());
|
||||
huaweiRequest.setDeviceIdType(idType);
|
||||
huaweiRequest.setAppId(appId);
|
||||
huaweiRequest.setCallBack(callBack);
|
||||
huaweiRequest.setDeviceId(oaid);
|
||||
huaweiRequest.setActionParam("[{'name':'付费金额','value':8}]"); // 根据业务需要调整
|
||||
Map<String, String> headerMap = new HashMap<>();
|
||||
headerMap.put("Content-Type", "application/json");
|
||||
headerMap.put("client_id", "1273883745547493824");
|
||||
headerMap.put("Authorization", "Bearer "+getToken());
|
||||
log.info("请求https://connect-api.cloud.huawei.com/api/datasource/v1/track/activate的属性{}", JSONObject.toJSONString(huaweiRequest));
|
||||
String s = sendPost("https://connect-api.cloud.huawei.com/api/datasource/v1/track/activate", JSONObject.toJSONString(huaweiRequest), headerMap);
|
||||
log.info("请求https://connect-api.cloud.huawei.com/api/datasource/v1/track/activate的响应{}", s);
|
||||
|
||||
|
||||
return AjaxResult.success("下载成功!");
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +197,7 @@ public class NoticeController {
|
|||
headerMap.put("timestamp", String.valueOf(model.getTimestamp()));
|
||||
headerMap.put("Content-Type", "application/json");
|
||||
log.info("请求https://api.ads.heytapmobi.com/api/uploadActiveData的属性{}", JSONObject.toJSONString(model));
|
||||
String s = HttpUtils.sendPost("https://api.ads.heytapmobi.com/api/uploadActiveData", JSONObject.toJSONString(model), headerMap);
|
||||
String s = sendPost("https://api.ads.heytapmobi.com/api/uploadActiveData", JSONObject.toJSONString(model), headerMap);
|
||||
log.info("请求https://api.ads.heytapmobi.com/api/uploadActiveData的响应{}", s);
|
||||
}else if("vivo".equalsIgnoreCase(request.getFrom())){
|
||||
String token = "9cd4cddcfc7c9f81fdaf4c94e826926bf0f84259462a57dbfc448f29cc8815c3";
|
||||
|
|
@ -185,7 +208,7 @@ public class NoticeController {
|
|||
Map<String, String> headerMap = new HashMap<>();
|
||||
headerMap.put("Content-Type", "application/json");
|
||||
log.info("请求{}的属性{}", url, content);
|
||||
String s = HttpUtils.sendPost(url, content, headerMap);
|
||||
String s = sendPost(url, content, headerMap);
|
||||
log.info("请求{}的响应{}", url, s);
|
||||
}else if("xiaomi".equalsIgnoreCase(request.getFrom())){
|
||||
log.info("oaid : {}, imei:{}", request.getOaid(), request.getImei());
|
||||
|
|
@ -268,5 +291,47 @@ public class NoticeController {
|
|||
config.endpoint = "dysmsapi.aliyuncs.com";
|
||||
return new Client(config);
|
||||
}
|
||||
@Data
|
||||
static class HuaweiRequest {
|
||||
private String actionType;
|
||||
private long actionTime;
|
||||
private String deviceIdType;
|
||||
private String appId;
|
||||
private String callBack;
|
||||
private String deviceId;
|
||||
private String actionParam;
|
||||
|
||||
}
|
||||
public static String getToken(){
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Content-Type", "application/json");
|
||||
|
||||
Map<String,String> params=new HashMap<>();
|
||||
headers.put("grant_type", "client_credentials");
|
||||
headers.put("client_id", "1273883745547493824"); // 从配置读取
|
||||
headers.put("client_secret", "BBA385787FE8D5CA4F0C889915C6FBA752F7B18C19E99FFE6B09ACCC92C60181"); // 从配置读取
|
||||
String s;
|
||||
try {
|
||||
s= sendPost(
|
||||
"https://connect-api.cloud.huawei.com/api/oauth2/v1/token",
|
||||
JSONObject.toJSONString(params),
|
||||
headers
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.error("华为API调用失败", e);
|
||||
return "ERROR: " + e.getMessage();
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(s)){
|
||||
Gson gson = new Gson();
|
||||
Map<String, String> map = gson.fromJson(s, Map.class);
|
||||
String token=map.get("access_token");
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue