ads回调
This commit is contained in:
parent
9ef81801e6
commit
9fcd15ccdd
|
|
@ -1,11 +1,22 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.Key;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.common.utils.security.Md5Utils;
|
||||
import com.ruoyi.system.domain.ClewPhone;
|
||||
import com.ruoyi.system.domain.OppoCheck;
|
||||
import com.ruoyi.system.service.IClewPhoneService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -21,12 +32,16 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
|||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
/**
|
||||
* 线索Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-05-15
|
||||
*/
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequestMapping("/system/clew")
|
||||
public class ClewController extends BaseController
|
||||
|
|
@ -127,9 +142,43 @@ public class ClewController extends BaseController
|
|||
x.setStatus("1");
|
||||
clewPhoneService.updateClewPhone(x);
|
||||
});
|
||||
// 调用oppo的统计接口
|
||||
try {
|
||||
// 回调
|
||||
if("oppo".equalsIgnoreCase(clew.getRemark())){
|
||||
OppoCheck oppoCheck = new OppoCheck();
|
||||
oppoCheck.setTimestamp(System.currentTimeMillis());
|
||||
if(StringUtils.isNotEmpty(clew.getImei())){
|
||||
oppoCheck.setImei(encode(clew.getImei().getBytes()));
|
||||
}
|
||||
if(StringUtils.isNotEmpty(clew.getOaid())){
|
||||
oppoCheck.setOuId(encode(clew.getOaid().getBytes()));
|
||||
}
|
||||
String content = JSONObject.toJSONString(oppoCheck) + oppoCheck.getTimestamp() + "e0u6fnlag06lc3pl";
|
||||
log.info("请求的content加密前属性{}", content);
|
||||
Map<String, String> headerMap = new HashMap<>();
|
||||
headerMap.put("signature", Md5Utils.hash(content));
|
||||
headerMap.put("timestamp", String.valueOf(oppoCheck.getTimestamp()));
|
||||
headerMap.put("Content-Type", "application/json");
|
||||
log.info("请求https://api.ads.heytapmobi.com/api/uploadActiveData的属性{}", JSONObject.toJSONString(oppoCheck));
|
||||
String s = HttpUtils.sendPost("https://api.ads.heytapmobi.com/api/uploadActiveData", JSONObject.toJSONString(oppoCheck), headerMap);
|
||||
log.info("请求https://api.ads.heytapmobi.com/api/uploadActiveData的响应{}", s);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("回调oppo报错:{}", e.getMessage());
|
||||
}
|
||||
return toAjax(clewService.insertClew(clew));
|
||||
}
|
||||
|
||||
public static String encode(byte[] data) throws GeneralSecurityException {
|
||||
final Key dataKey = new SecretKeySpec(Base64.decodeBase64("XGAXicVG5GMBsx5bueOe4w=="), "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, dataKey);
|
||||
byte[] encryptData = cipher.doFinal(data);
|
||||
return Base64.encodeBase64String(encryptData).replaceAll("\r", "").replaceAll("\n", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改线索
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ public class NoticeController {
|
|||
try {
|
||||
// 回调
|
||||
OppoCheck model = new OppoCheck();
|
||||
model.setDataType(2);
|
||||
model.setTimestamp(System.currentTimeMillis());
|
||||
if(StringUtils.isNotEmpty(request.getImei())){
|
||||
model.setImei(encode(request.getImei().getBytes()));
|
||||
|
|
|
|||
|
|
@ -124,4 +124,8 @@ public class Clew extends BaseEntity
|
|||
@Excel(name = "其他联系方式")
|
||||
private String otherPhone;
|
||||
|
||||
private String imei;
|
||||
|
||||
private String oaid;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,9 @@ public class NoticeRequest {
|
|||
* */
|
||||
private String code;
|
||||
|
||||
|
||||
private String imei;
|
||||
|
||||
private String oaid;
|
||||
|
||||
private String from;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue