|
@@ -39,17 +39,7 @@ import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListChildrenMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListParentMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouTargetingTagsMapper;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyFlowsService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouOverRunSendMessageService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IWarningOperationService;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.*;
|
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
|
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
|
|
|
import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
|
|
@@ -1265,9 +1255,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
+ @Override
|
|
|
public Map getKuaishouUnitList(CtopOauthToken token, Long unitId, Date startDate,
|
|
|
- Date endDate, int time_filter_type,Integer pageNum, Integer pageSize) {
|
|
|
+ Date endDate, int time_filter_type, Integer pageNum, Integer pageSize) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("advertiser_id", token.getAccountId());
|
|
@@ -1276,16 +1266,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
}
|
|
|
|
|
|
- if (!Check.isNull(unitId)){
|
|
|
+ if (!Check.isNull(unitId)) {
|
|
|
param.put("unit_id", unitId);
|
|
|
}
|
|
|
- param.put("page_size", pageSize);
|
|
|
- param.put("page", pageNum);
|
|
|
- param.put("time_filter_type", time_filter_type);
|
|
|
-
|
|
|
+ param.put("page_size", pageSize);
|
|
|
+ param.put("page", pageNum);
|
|
|
+ param.put("time_filter_type", time_filter_type);
|
|
|
|
|
|
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
|
|
@@ -1303,12 +1292,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
Map resultMap = new HashMap();
|
|
|
JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
|
|
|
Integer totalCount = resultJson.getJSONObject("data").getInteger("total_count");
|
|
|
- resultMap.put("details",details );
|
|
|
- resultMap.put("totalCount",totalCount );
|
|
|
+ resultMap.put("details", details);
|
|
|
+ resultMap.put("totalCount", totalCount);
|
|
|
|
|
|
- if (!Check.isNull(resultMap)){
|
|
|
- return resultMap;
|
|
|
- }
|
|
|
+ if (!Check.isNull(resultMap)) {
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
if (Check.isNull(details)) {
|
|
@@ -1328,6 +1317,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
@Autowired
|
|
|
IRuleKuaiShouPlanService ruleKuaiShouPlanService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IKuaiShouUpdateService updateService;
|
|
|
+
|
|
|
private void getGroupListByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
|
|
|
JSONObject param = new JSONObject();
|
|
@@ -1341,9 +1333,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("K-RealUser-IP", "103.46.170.107");
|
|
|
|
|
|
String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
|
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ System.err.println(resultJson);
|
|
|
if (Check.isNull(resultJson)) {
|
|
|
log.error("获取广告组接口异常,advertiserId:{}", token.getAccountId());
|
|
|
return;
|
|
@@ -1357,8 +1351,18 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
if (Check.isNull(details)) {
|
|
|
return;
|
|
|
}
|
|
|
- addGroup(token.getAccountId(), details);
|
|
|
- // ruleKuaiShouPlanService.insertTarget(token.getAccountId(), details);
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
+ JSONObject jsonObject = details.getJSONObject(i);
|
|
|
+ Long unit_id = jsonObject.getLong("unit_id");
|
|
|
+ JSONObject unitJson = new JSONObject();
|
|
|
+ unitJson.put("advertiser_id", token.getAccountId());
|
|
|
+ unitJson.put("unit_id", unit_id);
|
|
|
+ updateService.updateUnit(token.getAccessToken(), unitJson);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
getGroupListByPage(token, startDate, endDate, page + 1);
|
|
|
}
|
|
|
|
|
@@ -1451,7 +1455,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
if (ocpxActionType == 2 && dayBudget != 0 && dayBudget <= 500 * 1000) {
|
|
|
// 转化目标为2行为数,并且预算小于等于500且不是不限,则允许启动
|
|
|
typeFalg = true;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//通过key未获取值,说明不包含该目标,进行关停
|
|
|
typeFalg = false;
|
|
|
}
|
|
@@ -1461,7 +1465,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
bidFalg = false;
|
|
|
}
|
|
|
}
|
|
|
- }else if (ocpxActionType == 2 && (dayBudget == 0 || dayBudget > 500 * 1000)) {
|
|
|
+ } else if (ocpxActionType == 2 && (dayBudget == 0 || dayBudget > 500 * 1000)) {
|
|
|
// 转化目标为2行为数,并且预算大于500 或者不限,则关停
|
|
|
typeFalg = false;
|
|
|
}
|
|
@@ -2716,7 +2720,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
kuaiShouImageGet.setId(token.getAccountId() + kuaiShouImageGet.getImageToken());
|
|
|
kuaiShouImageGet.setAccountId(token.getAccountId());
|
|
|
|
|
|
- Map<String, Integer> typeBySize = MaterialEnum.getTypeBySize(kuaiShouImageGet.getWidth(), kuaiShouImageGet.getHeight());
|
|
|
+ Map<String, Integer> typeBySize = MaterialEnum.getTypeBySize(kuaiShouImageGet.getWidth(), kuaiShouImageGet.getHeight());
|
|
|
if (!Check.isNullMap(typeBySize)) {
|
|
|
kuaiShouImageGet.setMaterialType(typeBySize.get("type"));
|
|
|
}
|
|
@@ -2904,7 +2908,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
if (!Check.isNull(addList)) {
|
|
|
populationService.replaceBatch(addList);
|
|
|
}
|
|
|
- // getPopulationList(accountId, accessToken, page + 1);
|
|
|
+ // getPopulationList(accountId, accessToken, page + 1);
|
|
|
} else {
|
|
|
log.error("获取人群包管理返回数据为空,accountId:{}", accountId);
|
|
|
|
|
@@ -3447,7 +3451,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
appList.setAppIconUrl(dataJson.getString("app_icon_url"));
|
|
|
appList.setImageToken(dataJson.getString("image_token"));
|
|
|
appList.setPackageName(dataJson.getString("package_name"));
|
|
|
- // appList.setReturnTime(DateUtils.timeStamp2Date(dataJson.getTimestamp("update_time")));
|
|
|
+ // appList.setReturnTime(DateUtils.timeStamp2Date(dataJson.getTimestamp("update_time")));
|
|
|
addList.add(appList);
|
|
|
}
|
|
|
}
|