|
@@ -66,6 +66,7 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
|
|
+ @Override
|
|
public void batchCopyCampaign() {
|
|
public void batchCopyCampaign() {
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
//'状态:1待复制,2成功,3失败'
|
|
//'状态:1待复制,2成功,3失败'
|
|
@@ -75,17 +76,20 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
|
|
try {
|
|
try {
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(copyData.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(copyData.getAccountId());
|
|
//执行删除被复制的计划组+创意
|
|
//执行删除被复制的计划组+创意
|
|
- delOldCampaigns(copyData.getAccountId(), copyData.getNewCampaignId());
|
|
|
|
|
|
+ delOldCampaigns(copyData.getAccountId(), copyData.getOldCampaignId());
|
|
//获取当前最新广告计划组、创意数据并入库
|
|
//获取当前最新广告计划组、创意数据并入库
|
|
JSONObject data = getNewCampaigns(token.getAccessToken(), copyData);
|
|
JSONObject data = getNewCampaigns(token.getAccessToken(), copyData);
|
|
data.put("copyData", copyData);
|
|
data.put("copyData", copyData);
|
|
//根据被复制的组数据和模板、预算和排期数据调用快手创建组接口
|
|
//根据被复制的组数据和模板、预算和排期数据调用快手创建组接口
|
|
createCopyUnits(token, data);
|
|
createCopyUnits(token, data);
|
|
|
|
+ //更新成功,修改状态并发送通知
|
|
|
|
+ updateState(copyData.getId(), NoEn.NO2.valueStr(), "复制成功");
|
|
|
|
+ sendNotification(copyData.getOldCampaignName(), copyData.getCreaterId(), NoEn.NO2.valueStr());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("复制广告计划异常", e);
|
|
log.error("复制广告计划异常", e);
|
|
- //复制过程中失败,更新状态并发送通知
|
|
|
|
|
|
+ //复制过程中失败,更新状态并发送预警
|
|
updateState(copyData.getId(), NoEn.NO3.valueStr(), e.getMessage());
|
|
updateState(copyData.getId(), NoEn.NO3.valueStr(), e.getMessage());
|
|
- sendNotification(copyData, NoEn.NO3.valueStr());
|
|
|
|
|
|
+ sendNotification(copyData.getOldCampaignName(), copyData.getCreaterId(), NoEn.NO3.valueStr());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -130,7 +134,7 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
|
|
if (Check.isNull(kuaiShouGroups)) {
|
|
if (Check.isNull(kuaiShouGroups)) {
|
|
//获取广告组失败,更新状态并发送通知
|
|
//获取广告组失败,更新状态并发送通知
|
|
updateState(copyData.getId(), NoEn.NO3.valueStr(), "被复制的计划更新广告组失败");
|
|
updateState(copyData.getId(), NoEn.NO3.valueStr(), "被复制的计划更新广告组失败");
|
|
- sendNotification(copyData, NoEn.NO3.valueStr());
|
|
|
|
|
|
+ sendNotification(copyData.getOldCampaignName(), copyData.getCreaterId(), NoEn.NO3.valueStr());
|
|
}
|
|
}
|
|
for (KuaiShouGroup kuaiShouGroup : kuaiShouGroups) {
|
|
for (KuaiShouGroup kuaiShouGroup : kuaiShouGroups) {
|
|
kuaiShouGroup.setTarget(kuaiShouGroupTargetService.queryTargetInfoByunitId(copyData.getAccountId(), kuaiShouGroup.getUnitId()));
|
|
kuaiShouGroup.setTarget(kuaiShouGroupTargetService.queryTargetInfoByunitId(copyData.getAccountId(), kuaiShouGroup.getUnitId()));
|
|
@@ -155,264 +159,286 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
private void createCopyUnits(CtopOauthToken token, JSONObject data) throws Exception {
|
|
private void createCopyUnits(CtopOauthToken token, JSONObject data) throws Exception {
|
|
- JSONArray groups = data.getJSONArray("groups");
|
|
|
|
- JSONObject copyData = data.getJSONObject("copyData");
|
|
|
|
- for (int i = 0; i < groups.size(); i++) {
|
|
|
|
- JSONObject group = groups.getJSONObject(i);
|
|
|
|
- JSONObject unitJson = new JSONObject();
|
|
|
|
- unitJson.put("campaign_id", group.getLong("campaignId"));
|
|
|
|
- // 资源位置
|
|
|
|
- JSONArray scene_id = copyData.getJSONArray("sceneId");
|
|
|
|
- if (Check.isNull(scene_id) || scene_id.size() == 0) {
|
|
|
|
- scene_id = group.getJSONArray("sceneId");
|
|
|
|
- }
|
|
|
|
- unitJson.put("scene_id", scene_id);
|
|
|
|
- // 资源创作方式
|
|
|
|
- unitJson.put("unit_type", group.getInteger("unitType"));
|
|
|
|
- // 转化目标id
|
|
|
|
- unitJson.put("convert_id", group.getInteger("convertId"));
|
|
|
|
-
|
|
|
|
- // 优先从系统应用商店下载
|
|
|
|
- unitJson.put("use_app_market", group.getInteger("useAppMarket"));
|
|
|
|
-
|
|
|
|
- // 应用商店列表
|
|
|
|
- unitJson.put("app_store", group.getJSONArray("appStore"));
|
|
|
|
-
|
|
|
|
- //投放开始时间
|
|
|
|
- String beginTime = copyData.getString("beginTime");
|
|
|
|
- if (Check.isNull(beginTime)) {
|
|
|
|
- beginTime = group.getString("beginTime");
|
|
|
|
- }
|
|
|
|
- String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
- boolean beginTimeBoolean = DateUtils.compare(beginTime, nowDate);
|
|
|
|
- if (beginTimeBoolean) {
|
|
|
|
- unitJson.put("begin_time", nowDate);
|
|
|
|
- } else {
|
|
|
|
- unitJson.put("begin_time", beginTime);
|
|
|
|
- }
|
|
|
|
- // 投放结束时间
|
|
|
|
- String endTime = copyData.getString("endTime");
|
|
|
|
- if (Check.isNull(endTime)) {
|
|
|
|
- endTime = group.getString("endTime");
|
|
|
|
- }
|
|
|
|
- unitJson.put("end_time", endTime);
|
|
|
|
- // 投放时间段
|
|
|
|
- String scheduleTime = copyData.getString("scheduleTime");
|
|
|
|
- if (Check.isNull(scheduleTime)) {
|
|
|
|
- scheduleTime = group.getString("scheduleTime");
|
|
|
|
- }
|
|
|
|
- unitJson.put("schedule_time", scheduleTime);
|
|
|
|
- // 广告组单日预算
|
|
|
|
- Long dayBudget = copyData.getLong("dayBudget");
|
|
|
|
- if (Check.isNull(dayBudget)) {
|
|
|
|
- dayBudget = group.getLong("dayBudget");
|
|
|
|
- }
|
|
|
|
- unitJson.put("day_budget", dayBudget);
|
|
|
|
- // url类型
|
|
|
|
- unitJson.put("url_type", group.getInteger("urlType"));
|
|
|
|
- // url
|
|
|
|
- unitJson.put("url", group.getString("url"));
|
|
|
|
- // appId
|
|
|
|
- unitJson.put("app_id", group.getLong("appId"));
|
|
|
|
- // 创意展现方式
|
|
|
|
- unitJson.put("show_mode", group.getInteger("showMode"));
|
|
|
|
- //投放方式
|
|
|
|
- Integer speed = copyData.getInteger("speed");
|
|
|
|
- if (Check.isNull(speed)) {
|
|
|
|
- speed = group.getInteger("speed");
|
|
|
|
- }
|
|
|
|
- unitJson.put("speed", speed);
|
|
|
|
|
|
+ try {
|
|
|
|
+ JSONArray groups = data.getJSONArray("groups");
|
|
|
|
+ JSONObject copyData = data.getJSONObject("copyData");
|
|
|
|
+ for (int i = 0; i < groups.size(); i++) {
|
|
|
|
+ JSONObject group = groups.getJSONObject(i);
|
|
|
|
+ JSONObject unitJson = new JSONObject();
|
|
|
|
+ unitJson.put("campaign_id", copyData.getLong("newCampaignId"));
|
|
|
|
+ // 资源位置
|
|
|
|
+ JSONArray scene_id = copyData.getJSONArray("sceneId");
|
|
|
|
+ if (Check.isNull(scene_id) || scene_id.size() == 0) {
|
|
|
|
+ scene_id = group.getJSONArray("sceneId");
|
|
|
|
+ }
|
|
|
|
+ unitJson.put("scene_id", scene_id);
|
|
|
|
+ // 资源创作方式
|
|
|
|
+ unitJson.put("unit_type", group.getInteger("unitType"));
|
|
|
|
+ // 转化目标id
|
|
|
|
+ unitJson.put("convert_id", group.getInteger("convertId"));
|
|
|
|
|
|
- String templateId = copyData.getString("templateId");
|
|
|
|
- if (!Check.isNull(templateId)) {
|
|
|
|
- unitJson.put("template_id", templateId);
|
|
|
|
- } else {
|
|
|
|
- /*----------------用户定向-----------*/
|
|
|
|
- JSONObject target = group.getJSONObject("target");
|
|
|
|
- JSONObject targetJson = new JSONObject();
|
|
|
|
- // 地域
|
|
|
|
- targetJson.put("region", target.getJSONArray("region"));
|
|
|
|
|
|
+ // 优先从系统应用商店下载
|
|
|
|
+ unitJson.put("use_app_market", group.getInteger("useAppMarket"));
|
|
|
|
|
|
- // 自定义年龄段
|
|
|
|
|
|
+ // 应用商店列表
|
|
|
|
+ unitJson.put("app_store", group.getJSONArray("appStore"));
|
|
|
|
|
|
- if (!Check.isNull(target.getInteger("ageMax")) && !Check.isNull(target.getInteger("ageMin"))) {
|
|
|
|
- JSONObject ageJson = new JSONObject();
|
|
|
|
- ageJson.put("min", target.getInteger("ageMin"));
|
|
|
|
- ageJson.put("max", target.getInteger("ageMax"));
|
|
|
|
- targetJson.put("age", ageJson);
|
|
|
|
|
|
+ //投放开始时间
|
|
|
|
+ String beginTime = copyData.getString("beginTime");
|
|
|
|
+ if (Check.isNull(beginTime)) {
|
|
|
|
+ beginTime = group.getString("beginTime");
|
|
}
|
|
}
|
|
- // 固定年龄段
|
|
|
|
- if (!Check.isNull(target.getJSONArray("agesRange"))) {
|
|
|
|
- targetJson.put("ages_range", target.getJSONArray("agesRange"));
|
|
|
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+ boolean beginTimeBoolean = DateUtils.compare(beginTime, nowDate);
|
|
|
|
+ if (beginTimeBoolean) {
|
|
|
|
+ unitJson.put("begin_time", nowDate);
|
|
|
|
+ } else {
|
|
|
|
+ unitJson.put("begin_time", beginTime);
|
|
}
|
|
}
|
|
- // 性别
|
|
|
|
- if (!Check.isNull(target.getInteger("gender"))) {
|
|
|
|
- targetJson.put("gender", target.getInteger("gender"));
|
|
|
|
|
|
+ // 投放结束时间
|
|
|
|
+ String endTime = copyData.getString("endTime");
|
|
|
|
+ if (Check.isNull(endTime)) {
|
|
|
|
+ endTime = group.getString("endTime");
|
|
}
|
|
}
|
|
- //操作系统
|
|
|
|
- if (!Check.isNull(target.getInteger("platformOs"))) {
|
|
|
|
- targetJson.put("platform_os", target.getInteger("platformOs"));
|
|
|
|
|
|
+ if (!Check.isNull(endTime)) {
|
|
|
|
+ unitJson.put("end_time", endTime);
|
|
}
|
|
}
|
|
- //Android版本
|
|
|
|
- if (!Check.isNull(target.getInteger("androidOsv"))) {
|
|
|
|
- targetJson.put("android_osv", target.getInteger("androidOsv"));
|
|
|
|
|
|
+ // 投放时间段
|
|
|
|
+ String scheduleTime = copyData.getString("scheduleTime");
|
|
|
|
+ if (Check.isNull(scheduleTime)) {
|
|
|
|
+ scheduleTime = group.getString("scheduleTime");
|
|
}
|
|
}
|
|
- // iOS版本
|
|
|
|
- if (!Check.isNull(target.getInteger("iosOsv"))) {
|
|
|
|
- targetJson.put("ios_osv", target.getInteger("iosOsv"));
|
|
|
|
|
|
+ if (!Check.isNull(scheduleTime)) {
|
|
|
|
+ unitJson.put("schedule_time", scheduleTime);
|
|
}
|
|
}
|
|
- //网络环境
|
|
|
|
- if (!Check.isNull(target.getInteger("network"))) {
|
|
|
|
- targetJson.put("network", target.getInteger("network"));
|
|
|
|
|
|
+ // 广告组单日预算
|
|
|
|
+ Long dayBudget = copyData.getLong("dayBudget");
|
|
|
|
+ if (Check.isNull(dayBudget)) {
|
|
|
|
+ dayBudget = group.getLong("dayBudget");
|
|
}
|
|
}
|
|
- //设备品牌
|
|
|
|
- if (!Check.isNull(target.getJSONArray("deviceBrand"))) {
|
|
|
|
- targetJson.put("device_brand", target.getJSONArray("deviceBrand"));
|
|
|
|
|
|
+ if (!Check.isNull(dayBudget)) {
|
|
|
|
+ unitJson.put("day_budget", dayBudget);
|
|
}
|
|
}
|
|
- //设备价格
|
|
|
|
- if (!Check.isNull(target.getJSONArray("devicePrice"))) {
|
|
|
|
- targetJson.put("device_price", target.getJSONArray("devicePrice"));
|
|
|
|
|
|
+ // url类型
|
|
|
|
+ if (!Check.isNull(group.getInteger("urlType"))) {
|
|
|
|
+ unitJson.put("url_type", group.getInteger("urlType"));
|
|
}
|
|
}
|
|
- // APP行为-按分类
|
|
|
|
- if (!Check.isNull(target.getJSONArray("appInterest"))) {
|
|
|
|
- targetJson.put("app_interest", target.getJSONArray("appInterest"));
|
|
|
|
|
|
+ // url
|
|
|
|
+ if (!Check.isNull(group.getString("url"))) {
|
|
|
|
+ unitJson.put("url", group.getString("url"));
|
|
}
|
|
}
|
|
- // APP行为-按APP名称
|
|
|
|
- if (!Check.isNull(target.getJSONArray("appIds"))) {
|
|
|
|
- targetJson.put("app_ids", target.getJSONArray("appIds"));
|
|
|
|
|
|
+ // appId
|
|
|
|
+ if (!Check.isNull(group.getLong("appId"))) {
|
|
|
|
+ unitJson.put("app_id", group.getLong("appId"));
|
|
}
|
|
}
|
|
- // 人群包定向
|
|
|
|
- if (!Check.isNull(target.getJSONArray("population"))) {
|
|
|
|
- targetJson.put("population", target.getJSONArray("population"));
|
|
|
|
|
|
+ // 创意展现方式
|
|
|
|
+ if (!Check.isNull(group.getInteger("showMode"))) {
|
|
|
|
+ unitJson.put("show_mode", group.getInteger("showMode"));
|
|
}
|
|
}
|
|
- // 人群包排除
|
|
|
|
- if (!Check.isNull(target.getJSONArray("excludePopulation"))) {
|
|
|
|
- targetJson.put("exclude_population", target.getJSONArray("excludePopulation"));
|
|
|
|
|
|
+ //投放方式
|
|
|
|
+ Integer speed = copyData.getInteger("speed");
|
|
|
|
+ if (Check.isNull(speed)) {
|
|
|
|
+ speed = group.getInteger("speed");
|
|
}
|
|
}
|
|
- //三方付费人群
|
|
|
|
- if (!Check.isNull(target.getJSONArray("thirdPlatformCode"))) {
|
|
|
|
- targetJson.put("third_platform_code", target.getJSONArray("thirdPlatformCode"));
|
|
|
|
|
|
+ if (!Check.isNull(speed)) {
|
|
|
|
+ unitJson.put("speed", speed);
|
|
}
|
|
}
|
|
- Integer sceneId = valueOf(scene_id.get(0).toString());
|
|
|
|
- if (sceneId != 5) {
|
|
|
|
- //过滤已转化人群纬度
|
|
|
|
- if (!Check.isNull(target.getInteger("filterConvertedLevel"))) {
|
|
|
|
- targetJson.put("filter_converted_level", target.getInteger("filterConvertedLevel"));
|
|
|
|
|
|
+
|
|
|
|
+ String templateId = copyData.getString("templateId");
|
|
|
|
+ if (!Check.isNull(templateId)) {
|
|
|
|
+ unitJson.put("template_id", templateId);
|
|
|
|
+ } else {
|
|
|
|
+ /*----------------用户定向-----------*/
|
|
|
|
+ JSONObject target = group.getJSONObject("target");
|
|
|
|
+ JSONObject targetJson = new JSONObject();
|
|
|
|
+ // 地域
|
|
|
|
+ if (!Check.isNull(target.getJSONArray("region"))) {
|
|
|
|
+ targetJson.put("region", target.getJSONArray("region"));
|
|
|
|
+ }
|
|
|
|
+ // 自定义年龄段
|
|
|
|
+ if (!Check.isNull(target.getInteger("ageMax")) && !Check.isNull(target.getInteger("ageMin"))) {
|
|
|
|
+ JSONObject ageJson = new JSONObject();
|
|
|
|
+ ageJson.put("min", target.getInteger("ageMin"));
|
|
|
|
+ ageJson.put("max", target.getInteger("ageMax"));
|
|
|
|
+ targetJson.put("age", ageJson);
|
|
|
|
+ }
|
|
|
|
+ // 固定年龄段
|
|
|
|
+ if (!Check.isNull(target.getJSONArray("agesRange"))) {
|
|
|
|
+ targetJson.put("ages_range", target.getJSONArray("agesRange"));
|
|
|
|
+ }
|
|
|
|
+ // 性别
|
|
|
|
+ if (!Check.isNull(target.getInteger("gender"))) {
|
|
|
|
+ targetJson.put("gender", target.getInteger("gender"));
|
|
|
|
+ }
|
|
|
|
+ //操作系统
|
|
|
|
+ if (!Check.isNull(target.getInteger("platformOs"))) {
|
|
|
|
+ targetJson.put("platform_os", target.getInteger("platformOs"));
|
|
|
|
+ }
|
|
|
|
+ //Android版本
|
|
|
|
+ if (!Check.isNull(target.getInteger("androidOsv"))) {
|
|
|
|
+ targetJson.put("android_osv", target.getInteger("androidOsv"));
|
|
}
|
|
}
|
|
- //商业兴趣类型
|
|
|
|
- if (!Check.isNull(target.getInteger("businessInterestType"))) {
|
|
|
|
- targetJson.put("business_interest_type", target.getInteger("businessInterestType"));
|
|
|
|
|
|
+ // iOS版本
|
|
|
|
+ if (!Check.isNull(target.getInteger("iosOsv"))) {
|
|
|
|
+ targetJson.put("ios_osv", target.getInteger("iosOsv"));
|
|
}
|
|
}
|
|
- // 商业兴趣
|
|
|
|
- if (!Check.isNull(target.getJSONArray("businessInterest"))) {
|
|
|
|
- targetJson.put("business_interest", target.getJSONArray("businessInterest"));
|
|
|
|
|
|
+ //网络环境
|
|
|
|
+ if (!Check.isNull(target.getInteger("network"))) {
|
|
|
|
+ targetJson.put("network", target.getInteger("network"));
|
|
}
|
|
}
|
|
- //网红粉丝
|
|
|
|
- if (!Check.isNull(target.getJSONArray("fansStar"))) {
|
|
|
|
- targetJson.put("fans_star", target.getJSONArray("fansStar"));
|
|
|
|
|
|
+ //设备品牌
|
|
|
|
+ if (!Check.isNull(target.getJSONArray("deviceBrand"))) {
|
|
|
|
+ targetJson.put("device_brand", target.getJSONArray("deviceBrand"));
|
|
}
|
|
}
|
|
- //兴趣视频用户
|
|
|
|
- if (!Check.isNull(target.getJSONArray("interestVideo"))) {
|
|
|
|
- targetJson.put("interest_video", target.getJSONArray("interestVideo"));
|
|
|
|
|
|
+ //设备价格
|
|
|
|
+ if (!Check.isNull(target.getJSONArray("devicePrice"))) {
|
|
|
|
+ targetJson.put("device_price", target.getJSONArray("devicePrice"));
|
|
}
|
|
}
|
|
- /*----------------智能扩量----------------*/
|
|
|
|
- JSONObject intelliExtendJson = new JSONObject();
|
|
|
|
- // 开启智能扩量
|
|
|
|
- if (!Check.isNull(target.getInteger("isOpen"))) {
|
|
|
|
- intelliExtendJson.put("is_open", target.getInteger("isOpen"));
|
|
|
|
|
|
+ // APP行为-按分类
|
|
|
|
+ if (!Check.isNull(target.getJSONArray("appInterest"))) {
|
|
|
|
+ targetJson.put("app_interest", target.getJSONArray("appInterest"));
|
|
}
|
|
}
|
|
- //不可突破年龄
|
|
|
|
- if (!Check.isNull(target.getInteger("noAgeBreak"))) {
|
|
|
|
- intelliExtendJson.put("no_age_break", target.getInteger("noAgeBreak"));
|
|
|
|
|
|
+ // APP行为-按APP名称
|
|
|
|
+ if (!Check.isNull(target.getJSONArray("appIds"))) {
|
|
|
|
+ targetJson.put("app_ids", target.getJSONArray("appIds"));
|
|
}
|
|
}
|
|
- //不可突破性别
|
|
|
|
- if (!Check.isNull(target.getInteger("noGenderBreak"))) {
|
|
|
|
- intelliExtendJson.put("no_gender_break", target.getInteger("noGenderBreak"));
|
|
|
|
|
|
+ // 人群包定向
|
|
|
|
+ if (!Check.isNull(target.getJSONArray("population"))) {
|
|
|
|
+ targetJson.put("population", target.getJSONArray("population"));
|
|
}
|
|
}
|
|
- // 不可突破地域
|
|
|
|
- if (!Check.isNull(target.getInteger("noAreaBreak"))) {
|
|
|
|
- intelliExtendJson.put("no_area_break", target.getInteger("noAreaBreak"));
|
|
|
|
|
|
+ // 人群包排除
|
|
|
|
+ if (!Check.isNull(target.getJSONArray("excludePopulation"))) {
|
|
|
|
+ targetJson.put("exclude_population", target.getJSONArray("excludePopulation"));
|
|
}
|
|
}
|
|
- if (!Check.isNull(intelliExtendJson)) {
|
|
|
|
- targetJson.put("intelli_extend", intelliExtendJson);
|
|
|
|
|
|
+ //三方付费人群
|
|
|
|
+ if (!Check.isNull(target.getJSONArray("thirdPlatformCode"))) {
|
|
|
|
+ targetJson.put("third_platform_code", target.getJSONArray("thirdPlatformCode"));
|
|
|
|
+ }
|
|
|
|
+ Integer sceneId = valueOf(scene_id.get(0).toString());
|
|
|
|
+ if (sceneId != 5) {
|
|
|
|
+ //过滤已转化人群纬度
|
|
|
|
+ if (!Check.isNull(target.getInteger("filterConvertedLevel"))) {
|
|
|
|
+ targetJson.put("filter_converted_level", target.getInteger("filterConvertedLevel"));
|
|
|
|
+ }
|
|
|
|
+ //商业兴趣类型
|
|
|
|
+ if (!Check.isNull(target.getInteger("businessInterestType"))) {
|
|
|
|
+ targetJson.put("business_interest_type", target.getInteger("businessInterestType"));
|
|
|
|
+ }
|
|
|
|
+ // 商业兴趣
|
|
|
|
+ if (!Check.isNull(target.getJSONArray("businessInterest"))) {
|
|
|
|
+ targetJson.put("business_interest", target.getJSONArray("businessInterest"));
|
|
|
|
+ }
|
|
|
|
+ //网红粉丝
|
|
|
|
+ if (!Check.isNull(target.getJSONArray("fansStar"))) {
|
|
|
|
+ targetJson.put("fans_star", target.getJSONArray("fansStar"));
|
|
|
|
+ }
|
|
|
|
+ //兴趣视频用户
|
|
|
|
+ if (!Check.isNull(target.getJSONArray("interestVideo"))) {
|
|
|
|
+ targetJson.put("interest_video", target.getJSONArray("interestVideo"));
|
|
|
|
+ }
|
|
|
|
+ /*----------------智能扩量----------------*/
|
|
|
|
+ JSONObject intelliExtendJson = new JSONObject();
|
|
|
|
+ // 开启智能扩量
|
|
|
|
+ if (!Check.isNull(target.getInteger("isOpen"))) {
|
|
|
|
+ intelliExtendJson.put("is_open", target.getInteger("isOpen"));
|
|
|
|
+ }
|
|
|
|
+ //不可突破年龄
|
|
|
|
+ if (!Check.isNull(target.getInteger("noAgeBreak"))) {
|
|
|
|
+ intelliExtendJson.put("no_age_break", target.getInteger("noAgeBreak"));
|
|
|
|
+ }
|
|
|
|
+ //不可突破性别
|
|
|
|
+ if (!Check.isNull(target.getInteger("noGenderBreak"))) {
|
|
|
|
+ intelliExtendJson.put("no_gender_break", target.getInteger("noGenderBreak"));
|
|
|
|
+ }
|
|
|
|
+ // 不可突破地域
|
|
|
|
+ if (!Check.isNull(target.getInteger("noAreaBreak"))) {
|
|
|
|
+ intelliExtendJson.put("no_area_break", target.getInteger("noAreaBreak"));
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(intelliExtendJson)) {
|
|
|
|
+ targetJson.put("intelli_extend", intelliExtendJson);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ unitJson.put("target", targetJson);
|
|
}
|
|
}
|
|
- unitJson.put("target", targetJson);
|
|
|
|
- }
|
|
|
|
- // 出价
|
|
|
|
- String bid = copyData.getString("bid");
|
|
|
|
- if (Check.isNull(bid)) {
|
|
|
|
- bid = group.getString("bid");
|
|
|
|
- }
|
|
|
|
- unitJson.put("bid", bid);
|
|
|
|
- // 出价类型
|
|
|
|
- String bidType = copyData.getString("bidType");
|
|
|
|
- if (Check.isNull(bidType)) {
|
|
|
|
- bidType = group.getString("bidType");
|
|
|
|
- }
|
|
|
|
- unitJson.put("bid_type", bidType);
|
|
|
|
- // 深度转化出价
|
|
|
|
- String cpaBid = copyData.getString("cpaBid");
|
|
|
|
- if (Check.isNull(cpaBid)) {
|
|
|
|
- cpaBid = group.getString("cpaBid");
|
|
|
|
- }
|
|
|
|
- unitJson.put("cpa_bid", cpaBid);
|
|
|
|
- // 深度转化目标出价
|
|
|
|
- String deepConversionBid = copyData.getString("deepConversionBid");
|
|
|
|
- if (Check.isNull(deepConversionBid)) {
|
|
|
|
- deepConversionBid = group.getString("deepConversionBid");
|
|
|
|
- }
|
|
|
|
- if (!Check.isNull(deepConversionBid)) {
|
|
|
|
- unitJson.put("deep_conversion_bid", deepConversionBid);
|
|
|
|
- }
|
|
|
|
- // 深度转化目标
|
|
|
|
- String deepConversionType = copyData.getString("deepConversionType");
|
|
|
|
- if (Check.isNull(deepConversionType)) {
|
|
|
|
- deepConversionType = group.getString("deepConversionType");
|
|
|
|
- }
|
|
|
|
- unitJson.put("deep_conversion_type", deepConversionType);
|
|
|
|
- // 优化目标
|
|
|
|
- String ocpxActionType = copyData.getString("ocpxActionType");
|
|
|
|
- if (Check.isNull(ocpxActionType)) {
|
|
|
|
- ocpxActionType = group.getString("ocpxActionType");
|
|
|
|
- }
|
|
|
|
- unitJson.put("ocpx_action_type", ocpxActionType);
|
|
|
|
|
|
+ // 出价
|
|
|
|
+ String bid = copyData.getString("bid");
|
|
|
|
+ if (Check.isNull(bid)) {
|
|
|
|
+ bid = group.getString("bid");
|
|
|
|
+ }
|
|
|
|
+ unitJson.put("bid", bid);
|
|
|
|
+ // 出价类型
|
|
|
|
+ String bidType = copyData.getString("bidType");
|
|
|
|
+ if (Check.isNull(bidType)) {
|
|
|
|
+ bidType = group.getString("bidType");
|
|
|
|
+ }
|
|
|
|
+ unitJson.put("bid_type", bidType);
|
|
|
|
+ // 深度转化出价
|
|
|
|
+ String cpaBid = copyData.getString("cpaBid");
|
|
|
|
+ if (Check.isNull(cpaBid)) {
|
|
|
|
+ cpaBid = group.getString("cpaBid");
|
|
|
|
+ }
|
|
|
|
+ unitJson.put("cpa_bid", cpaBid);
|
|
|
|
+ // 深度转化目标出价
|
|
|
|
+ String deepConversionBid = copyData.getString("deepConversionBid");
|
|
|
|
+ if (Check.isNull(deepConversionBid)) {
|
|
|
|
+ deepConversionBid = group.getString("deepConversionBid");
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(deepConversionBid)) {
|
|
|
|
+ unitJson.put("deep_conversion_bid", deepConversionBid);
|
|
|
|
+ }
|
|
|
|
+ // 深度转化目标
|
|
|
|
+ String deepConversionType = copyData.getString("deepConversionType");
|
|
|
|
+ if (Check.isNull(deepConversionType)) {
|
|
|
|
+ deepConversionType = group.getString("deepConversionType");
|
|
|
|
+ }
|
|
|
|
+ unitJson.put("deep_conversion_type", deepConversionType);
|
|
|
|
+ // 优化目标
|
|
|
|
+ String ocpxActionType = copyData.getString("ocpxActionType");
|
|
|
|
+ if (Check.isNull(ocpxActionType)) {
|
|
|
|
+ ocpxActionType = group.getString("ocpxActionType");
|
|
|
|
+ }
|
|
|
|
+ unitJson.put("ocpx_action_type", ocpxActionType);
|
|
|
|
|
|
- //快手广告组名
|
|
|
|
- String unitName = group.getString("unitName");
|
|
|
|
- if (unitName.contains("CopyFrom")) {
|
|
|
|
- String format = "-".concat(DateUtils.yyyymmddhhmmss.get().format(new Date()));
|
|
|
|
- if (unitName.contains("(update)")) {
|
|
|
|
- int lastIndx = unitName.lastIndexOf("-");
|
|
|
|
- group.put("unit_name", unitName.substring(0, lastIndx).concat(format).concat("(update)"));
|
|
|
|
|
|
+ //快手广告组名
|
|
|
|
+ String unitName = group.getString("unitName");
|
|
|
|
+ if (unitName.contains("CopyFrom")) {
|
|
|
|
+ String format = "-".concat(DateUtils.yyyymmddhhmmss.get().format(new Date()));
|
|
|
|
+ if (unitName.contains("(update)")) {
|
|
|
|
+ int lastIndx = unitName.lastIndexOf("-");
|
|
|
|
+ group.put("unit_name", unitName.substring(0, lastIndx).concat(format).concat("(update)"));
|
|
|
|
+ } else {
|
|
|
|
+ unitJson.put("unit_name", unitName.concat(format).concat("(update)"));
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- unitJson.put("unit_name", unitName.concat(format).concat("(update)"));
|
|
|
|
|
|
+ unitJson.put("unit_name", "CopyFrom-".concat(unitName));
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- unitJson.put("unit_name", "CopyFrom-".concat(unitName));
|
|
|
|
- }
|
|
|
|
- Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitJson, 1);
|
|
|
|
- if (!Check.isNullMap(returnUnitMap)) {
|
|
|
|
- Integer code = (Integer) returnUnitMap.get("code");
|
|
|
|
- if (code == 0) {
|
|
|
|
- Long unitId = (Long) returnUnitMap.get("unitId");
|
|
|
|
- Thread thread = new Thread() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- try {
|
|
|
|
- batchService.copyCreative(token.getAccountId(), unitId, group.getLong("unitId"), new JSONObject());
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitJson, 1);
|
|
|
|
+ if (!Check.isNullMap(returnUnitMap)) {
|
|
|
|
+ Integer code = (Integer) returnUnitMap.get("code");
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ Long unitId = (Long) returnUnitMap.get("unitId");
|
|
|
|
+ Thread thread = new Thread() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ try {
|
|
|
|
+ batchService.copyCreative(token.getAccountId(), unitId, group.getLong("unitId"), null);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("复制创建广告创意异常", e);
|
|
|
|
+ updateState(copyData.getLong("id"), NoEn.NO3.valueStr(), "复制创建广告创意异常");
|
|
|
|
+ sendNotification(copyData.getString("oldCampaignName"), copyData.getString("createrId"), NoEn.NO3.valueStr());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- };
|
|
|
|
- thread.start();
|
|
|
|
|
|
+ };
|
|
|
|
+ thread.start();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ updateState(copyData.getLong("id"), NoEn.NO3.valueStr(), (String) returnUnitMap.get("message"));
|
|
|
|
+ sendNotification(copyData.getString("oldCampaignName"), copyData.getString("createrId"), NoEn.NO3.valueStr());
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- JSONObject failJson = new JSONObject();
|
|
|
|
- failJson.put("unitName", unitName);
|
|
|
|
- failJson.put("failMessage", returnUnitMap.get("message"));
|
|
|
|
}
|
|
}
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("复制过程调用快手接口异常", e);
|
|
|
|
+ throw new Exception("复制过程调用快手接口异常");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -425,7 +451,8 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private void createCopyCreatives(CtopOauthToken token, JSONObject data, KuaishouCampaignCopyData copyData) throws Exception {
|
|
|
|
|
|
+ private void createCopyCreatives(CtopOauthToken token, JSONObject data, KuaishouCampaignCopyData
|
|
|
|
+ copyData) throws Exception {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -437,9 +464,9 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private void sendNotification(KuaishouCampaignCopyData copyData, String state) {
|
|
|
|
- String msg = messageTemplate.getCopyCampaignMessage(copyData.getOldCampaignName(), state);
|
|
|
|
- sendMessageService.sendMessage(copyData.getCreaterId(), msg);
|
|
|
|
|
|
+ private void sendNotification(String name, String userId, String state) {
|
|
|
|
+ String msg = messageTemplate.getCopyCampaignMessage(name, state);
|
|
|
|
+ sendMessageService.sendMessage(userId, msg);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|