|
@@ -10,6 +10,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -29,8 +31,8 @@ public class ByteDanceQueryToolController {
|
|
|
*/
|
|
|
@PostMapping(value="/queryConvert")
|
|
|
public Result<Map<String,Object>> queryConvertResult(Long accountId, String landingType, String appType,
|
|
|
- String downloadType,String externalUrl,String toutiaoPackage,
|
|
|
- String downloadUrl){
|
|
|
+ String downloadType,String externalUrl,String toutiaoPackage,
|
|
|
+ String downloadUrl){
|
|
|
|
|
|
Result<Map<String,Object>> result=new Result<>();
|
|
|
Map<String, Object> convertQueryMap = byteDanceConvertToolService.queryAdConvert(ctopOauthTokenService.getTokenByAccountId(accountId), accountId,
|
|
@@ -38,17 +40,52 @@ public class ByteDanceQueryToolController {
|
|
|
if(!convertQueryMap.get("code").equals(0)){
|
|
|
result.error500("查询转化目标结果失败");
|
|
|
}else{
|
|
|
- ((List)((JSONObject)convertQueryMap.get("data")).get("list")).forEach(it->{
|
|
|
- if(((Map)it).get("convert_type")!=null){
|
|
|
- ((Map)it).put("name",getName(((Map)it).get("convert_type").toString()));
|
|
|
- }
|
|
|
- });
|
|
|
result.setSuccess(true);
|
|
|
- result.setResult(convertQueryMap);
|
|
|
+ result.setResult(ConvertResultHandle((List)((JSONObject)convertQueryMap.get("data")).get("list")));
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private Map<String,Object> ConvertResultHandle(List convertResult){
|
|
|
+ Map<String,Object> resultMap=new HashMap<>();
|
|
|
+ if(convertResult.isEmpty()){
|
|
|
+ resultMap.put("data",convertResult);
|
|
|
+ }else{
|
|
|
+ List resultList=new ArrayList();
|
|
|
+ convertResult.forEach(it->{
|
|
|
+ if(((JSONObject)it).get("external_actions")!=null){
|
|
|
+ JSONObject jsonObject=(JSONObject)it;
|
|
|
+ Map<String,Object> temp=new HashMap<>();
|
|
|
+ temp.put("convert_type",jsonObject.get("convert_type"));
|
|
|
+ temp.put("name",getName((jsonObject.getString("convert_type"))));
|
|
|
+ if(jsonObject.getJSONArray("external_actions")!=null){
|
|
|
+ List actionList=new ArrayList();
|
|
|
+ jsonObject.getJSONArray("external_actions").forEach(action->{
|
|
|
+ Map<String,Object> actionMap=new HashMap<>();
|
|
|
+ if(((JSONObject)action).get("convert_id")==null){
|
|
|
+ actionMap.put("convertId",getConvertIdByExternalAction(((JSONObject)action).getString("external_action")));
|
|
|
+
|
|
|
+ }else {
|
|
|
+ actionMap.put("convertId",(((JSONObject)action).get("convert_id")));
|
|
|
+ }
|
|
|
+ actionMap.put("external_name",((JSONObject)action).get("external_name"));
|
|
|
+ actionList.add(actionMap);
|
|
|
+ });
|
|
|
+ temp.put("external_actions",actionList);
|
|
|
+ }
|
|
|
+ //处理深度出价
|
|
|
+ if(jsonObject.getJSONObject("deep_external_actions")==null){
|
|
|
+ temp.put("deep_external_action",null);
|
|
|
+ }else {
|
|
|
+ temp.put("deep_external_action",jsonObject.getJSONObject("deep_external_actions").getString("deep_external_action"));
|
|
|
+ }
|
|
|
+ resultList.add(temp);
|
|
|
+ }
|
|
|
+ resultMap.put("data",resultList);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
private String getName(String convertType){
|
|
|
String convertName="";
|
|
|
switch (convertType) {
|
|
@@ -88,4 +125,26 @@ public class ByteDanceQueryToolController {
|
|
|
}
|
|
|
return convertName;
|
|
|
}
|
|
|
+
|
|
|
+ private int getConvertIdByExternalAction(String externalAction){
|
|
|
+ int result=0;
|
|
|
+ switch (externalAction) {
|
|
|
+ case "AD_CONVERT_TYPE_DOWNLOAD_FINISH":
|
|
|
+ result = 4;
|
|
|
+ break;
|
|
|
+ case "AD_CONVERT_TYPE_BUTTON":
|
|
|
+ result = 5;
|
|
|
+ break;
|
|
|
+ case "AD_CONVERT_TYPE_DOWNLOAD_START":
|
|
|
+ result = 9;
|
|
|
+ break;
|
|
|
+ case "AD_CONVERT_TYPE_INSTALL_FINISH":
|
|
|
+ result = 15;
|
|
|
+ break;
|
|
|
+ case "AD_CONVERT_TYPE_REDIRECT":
|
|
|
+ result = 95;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|