|
@@ -8,18 +8,68 @@ import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
|
import cn.com.ctop.common.module.service.IMaterialCutFrameService;
|
|
|
import cn.com.ctop.common.module.service.IOauthConfigService;
|
|
|
import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
|
-import cn.com.ctop.common.module.utils.*;
|
|
|
-import cn.com.ctop.kuaishou.modules.ai.service.*;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.entity.*;
|
|
|
+import cn.com.ctop.common.module.utils.Check;
|
|
|
+import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
|
+import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
+import cn.com.ctop.common.module.utils.JsonUtil;
|
|
|
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
|
+import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.IAiCreativeLimitService;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunInfoService;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAdvertiserBaseInfo;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouDailyFlows;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListChildren;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListParent;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouTargetingTags;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouPopulation;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.mapper.*;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.*;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAdvertiserBaseInfoMapper;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppListMapper;
|
|
|
+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.material.entity.KuaishouResult;
|
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
|
|
|
-import cn.com.ctop.kuaishou.modules.report.entity.*;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCampaign;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreative;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreativeStatistic;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyAccount;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCampaign;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreative;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreativeStatistic;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyGroup;
|
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
|
|
|
-import cn.com.ctop.kuaishou.modules.report.service.*;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCampaignService;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCreativeService;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyAccountService;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCampaignService;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCreativeService;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyGroupService;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -54,7 +104,11 @@ import java.io.IOException;
|
|
|
import java.lang.reflect.ParameterizedType;
|
|
|
import java.lang.reflect.Type;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
@@ -848,7 +902,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 创建广告计划
|
|
|
*
|
|
@@ -1242,122 +1295,156 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
static ExecutorService executorBidTypeService = Executors.newFixedThreadPool(20);
|
|
|
static ExecutorService executorMaxBidService = Executors.newFixedThreadPool(5);
|
|
|
|
|
|
- private void addGroup(Long advertiserId, JSONArray details) {
|
|
|
- JSONObject json = warningOperationService.getBidTypeAndMaxBid(advertiserId);
|
|
|
- Long maxBid = json.getLong("maxBid");// 最高出价
|
|
|
- String bidTypeStr = json.getString("bidType"); // 出价方式
|
|
|
- JSONArray bidTypeArr = JSONArray.parseArray(bidTypeStr);
|
|
|
- String ocpxActionTypeStr = json.getString("ocpxActionType"); // 优化目标
|
|
|
- JSONArray ocpxArr = JSONArray.parseArray(ocpxActionTypeStr);
|
|
|
- if (!Check.isNull(details)) {
|
|
|
- List<KuaiShouGroup> groups = new ArrayList<>();
|
|
|
- for (int i = 0; i < details.size(); i++) {
|
|
|
- JSONObject detail = JSONObject.parseObject(details.get(i).toString());
|
|
|
- if (!Check.isNull(detail)) {
|
|
|
- Integer bid_type = detail.getInteger("bid_type");
|
|
|
- Long bid = detail.getLong("bid");
|
|
|
- Long cpa_bid = detail.getLong("cpa_bid");
|
|
|
- Long day_budget = detail.getLong("day_budget");
|
|
|
- Integer ocpx_action_type = detail.getInteger("ocpx_action_type");
|
|
|
- Long unitId = detail.getLong("unit_id");
|
|
|
- String unit_name = detail.getString("unit_name");
|
|
|
- Integer status = detail.getInteger("status");
|
|
|
- Integer put_status = detail.getInteger("put_status");
|
|
|
- if (put_status == 1) { // 组状态为 投放中的
|
|
|
- if (status != 15) { // 广告组状态为非暂停
|
|
|
- Boolean bidTypeTrueOrFalse = false;
|
|
|
- for (int j = 0; j < bidTypeArr.size(); j++) {
|
|
|
- Integer bidType = (Integer) bidTypeArr.get(j);
|
|
|
- if (bidType.equals(bid_type)) {
|
|
|
- bidTypeTrueOrFalse = true;
|
|
|
- break;
|
|
|
+ private void addGroup(Long accountId, JSONArray details) {
|
|
|
+ JSONObject project = warningOperationService.getBidTypeAndMaxBid(accountId);
|
|
|
+ if (Check.isNull(project) || Check.isNull(details)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 最高出价
|
|
|
+ Long maxBid = project.getLong("maxBid");
|
|
|
+
|
|
|
+ //优化目标集
|
|
|
+ List<Integer> bidList = null;
|
|
|
+ String bidTypeStr = project.getString("bidType");
|
|
|
+ if (!Check.isNull(bidTypeStr)) {
|
|
|
+ bidList = JSONArray.parseArray(bidTypeStr, Integer.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ //转化目标map
|
|
|
+ Map<Integer, Long> ocpxMap = new HashMap<>();
|
|
|
+ String ocpxTypeStr = project.getString("ocpxActionType");
|
|
|
+ if (!Check.isNull(ocpxTypeStr)) {
|
|
|
+ JSONArray ocpxArr = JSONArray.parseArray(ocpxTypeStr);
|
|
|
+ for (int i = 0; i < ocpxArr.size(); i++) {
|
|
|
+ JSONObject obj = ocpxArr.getJSONObject(i);
|
|
|
+ ocpxMap.put(obj.getInteger("ocpxCode"), obj.getLong("maxValue"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //深度转化目标map
|
|
|
+ Map<Integer, Long> deepMap = new HashMap<>();
|
|
|
+ String deepTypeStr = project.getString("deepConversionType");
|
|
|
+ if (!Check.isNull(deepTypeStr)) {
|
|
|
+ JSONArray deepArr = JSONArray.parseArray(deepTypeStr);
|
|
|
+ for (int i = 0; i < deepArr.size(); i++) {
|
|
|
+ JSONObject obj = deepArr.getJSONObject(i);
|
|
|
+ ocpxMap.put(obj.getInteger("deepCode"), obj.getLong("deepValue"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<KuaiShouGroup> groups = new ArrayList<>();
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
+ JSONObject detail = JSONObject.parseObject(details.get(i).toString());
|
|
|
+ if (!Check.isNull(detail)) {
|
|
|
+ //优化目标
|
|
|
+ Integer bidType = detail.getInteger("bid_type");
|
|
|
+ //优化出价(只有单击时,才有值)
|
|
|
+ Long bid = detail.getLong("bid");
|
|
|
+ //转化目标
|
|
|
+ Integer ocpxActionType = detail.getInteger("ocpx_action_type");
|
|
|
+ //转化目标出价
|
|
|
+ Long cpaBid = detail.getLong("cpa_bid");
|
|
|
+ //深度转化目标
|
|
|
+ Integer deepConversionType = detail.getInteger("deep_conversion_type");
|
|
|
+ //深度转化目标出价
|
|
|
+ Long deepConversionBid = detail.getLong("deep_conversion_bid");
|
|
|
+ //单日预算
|
|
|
+ Long dayBudget = detail.getLong("day_budget");
|
|
|
+ //组ID
|
|
|
+ Long unitId = detail.getLong("unit_id");
|
|
|
+ //组名称
|
|
|
+ String unitName = detail.getString("unit_name");
|
|
|
+ //状态
|
|
|
+ Integer status = detail.getInteger("status");
|
|
|
+ //投放状态
|
|
|
+ Integer putStatus = detail.getInteger("put_status");
|
|
|
+ if (putStatus == 1 && status != 15) { // 组状态为 投放中的 and 广告组状态为非暂停
|
|
|
+ Boolean typeFalg = true;
|
|
|
+ Boolean bidFalg = true;
|
|
|
+
|
|
|
+ //优化目标
|
|
|
+ if (!bidList.isEmpty()) {
|
|
|
+ if (!bidList.contains(bidType)) {
|
|
|
+ //项目不包含该优化目标,则关停
|
|
|
+ typeFalg = false;
|
|
|
+ } else if (bidType == 2 && bid > maxBid) {
|
|
|
+ //若优化目标为2点击数,并且广告组出价大于项目设置最大出价,则关停
|
|
|
+ bidFalg = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //转化目标
|
|
|
+ if (!Check.isNull(ocpxActionType) && ocpxActionType != 0) {
|
|
|
+ //!=0是设置过转化目标
|
|
|
+ if (!Check.isNullMap(ocpxMap)) {
|
|
|
+ Long ocpxBid = ocpxMap.get(ocpxActionType);
|
|
|
+ if (Check.isNull(ocpxBid)) {
|
|
|
+ if (ocpxActionType == 2 && dayBudget != 0 && dayBudget <= 500 * 1000) {
|
|
|
+ // 转化目标为2行为数,并且预算小于等于500且不是不限,则允许启动
|
|
|
+ typeFalg = true;
|
|
|
+ }else{
|
|
|
+ //通过key未获取值,说明不包含该目标,进行关停
|
|
|
+ typeFalg = false;
|
|
|
}
|
|
|
- }
|
|
|
- Boolean ocpxTrueOrFalse = false;
|
|
|
- if (ocpx_action_type == 0) {
|
|
|
- ocpxTrueOrFalse = true;
|
|
|
} else {
|
|
|
- for (int j = 0; j < ocpxArr.size(); j++) {
|
|
|
- Integer ocpxActionType = (Integer) ocpxArr.get(j);
|
|
|
- if (ocpxActionType.equals(ocpx_action_type)) {
|
|
|
- ocpxTrueOrFalse = true;
|
|
|
- break;
|
|
|
- }
|
|
|
+ if (cpaBid > ocpxBid) {
|
|
|
+ //组转化出价 大于 项目设置最大转化出价,则关停
|
|
|
+ bidFalg = false;
|
|
|
}
|
|
|
}
|
|
|
+ }else if (ocpxActionType == 2 && (dayBudget == 0 || dayBudget > 500 * 1000)) {
|
|
|
+ // 转化目标为2行为数,并且预算大于500 或者不限,则关停
|
|
|
+ typeFalg = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- if (!bidTypeTrueOrFalse || !ocpxTrueOrFalse) { // 出价方式设置非法
|
|
|
- if (day_budget > 500 * 1000 || day_budget == 0) { // 预算大于500 或者不限制预算 需要发送通知 并且进行暂停操作
|
|
|
- executorBidTypeService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- warningOperationService.kuaiShouWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- if (bid > maxBid || cpa_bid > maxBid) {
|
|
|
- executorMaxBidService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- warningOperationService.kuaiShouBidWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
|
|
|
- }
|
|
|
- });
|
|
|
+ //转化目标
|
|
|
+ if (!Check.isNull(deepConversionType) && deepConversionType != 0 && !Check.isNullMap(ocpxMap)) {
|
|
|
+ Long deepBid = deepMap.get(deepConversionType);
|
|
|
+ if (Check.isNull(deepBid)) {
|
|
|
+ //通过key未获取值,说明不包含该目标,进行关停
|
|
|
+ typeFalg = false;
|
|
|
+ } else {
|
|
|
+ if (deepConversionBid > deepBid) {
|
|
|
+ //组深度转化出价 大于 项目设置最大转化出价,则关停
|
|
|
+ bidFalg = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- KuaiShouGroup group = new KuaiShouGroup();
|
|
|
- group.setId("" + advertiserId + unitId);
|
|
|
- group.setAccountId(advertiserId);
|
|
|
- group.setCampaignId(detail.getLong("campaign_id"));
|
|
|
- group.setUnitId(unitId);
|
|
|
- group.setUnitName(unit_name);
|
|
|
- group.setStatus(status);
|
|
|
- group.setPutStatus(put_status);
|
|
|
- group.setStudyStatus(detail.getInteger("study_status"));
|
|
|
- group.setCreateChannel(detail.getInteger("create_channel"));
|
|
|
- group.setReviewDetail(detail.getString("review_detail"));
|
|
|
- group.setBidType(bid_type);
|
|
|
- group.setBid(bid);
|
|
|
- group.setStudyStatus(detail.getInteger("study_status"));
|
|
|
- group.setCpaBid(cpa_bid);
|
|
|
- group.setOcpxActionType(ocpx_action_type);
|
|
|
- group.setDeepConversionType(detail.getInteger("deep_conversion_type"));
|
|
|
- group.setDeepConversionBid(detail.getLong("deep_conversion_bid"));
|
|
|
- group.setDayBudget(day_budget);
|
|
|
- group.setSpeed(detail.getInteger("speed"));
|
|
|
- group.setBeginTime(detail.getString("begin_time"));
|
|
|
- group.setEndTime(detail.getString("end_time"));
|
|
|
- group.setScheduleTime(detail.getString("schedule_time"));
|
|
|
- group.setSceneId(detail.getJSONArray("scene_id") + "");
|
|
|
- group.setShowMode(detail.getInteger("show_mode"));
|
|
|
- group.setUnitType(detail.getInteger("unit_type"));
|
|
|
- group.setUrlType(detail.getInteger("url_type"));
|
|
|
- group.setUrl(detail.getString("url"));
|
|
|
- group.setSchemaUri(detail.getString("schema_uri"));
|
|
|
- group.setAppId(detail.getLong("app_id"));
|
|
|
- group.setAppIconUrl(detail.getString("app_icon_url"));
|
|
|
- group.setGroupCreateTime(detail.getString("create_time"));
|
|
|
- group.setGroupUpdateTime(detail.getString("update_time"));
|
|
|
- group.setConvertId(detail.getLong("convert_id"));
|
|
|
- group.setUseAppMarket(detail.getInteger("use_app_market"));
|
|
|
- group.setAppStore(detail.getJSONArray("app_store") + "");
|
|
|
- group.setCreateTime(new Date());
|
|
|
- group.setUpdateTime(new Date());
|
|
|
- groups.add(group);
|
|
|
- // 添加应用信息
|
|
|
- }
|
|
|
- }
|
|
|
- if (!Check.isNull(groups)) {
|
|
|
- try {
|
|
|
- Thread.sleep(200L);
|
|
|
- groupMapper.replaceBatch(groups);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ if (!typeFalg) { // 出价方式设置非法
|
|
|
+ executorBidTypeService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ warningOperationService.kuaiShouWarningOperation(project.getLong("projectId"), project.getString("projectName"), accountId, unitId, unitName);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!bidFalg) {
|
|
|
+ executorMaxBidService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ warningOperationService.kuaiShouBidWarningOperation(project.getLong("projectId"), project.getString("projectName"), accountId, unitId, unitName);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ KuaiShouGroup group = JSONObject.parseObject(detail.toJSONString(), KuaiShouGroup.class);
|
|
|
+ group.setId("" + accountId + unitId);
|
|
|
+ group.setAccountId(accountId);
|
|
|
+ group.setGroupCreateTime(detail.getString("create_time"));
|
|
|
+ group.setGroupUpdateTime(detail.getString("update_time"));
|
|
|
+ group.setCreateTime(new Date());
|
|
|
+ group.setUpdateTime(new Date());
|
|
|
+ groups.add(group);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!Check.isNull(groups)) {
|
|
|
+ try {
|
|
|
+ Thread.sleep(200L);
|
|
|
+ groupMapper.replaceBatch(groups);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2107,6 +2194,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
returnMap.put("message", "success");
|
|
|
returnMap.put("success", true);
|
|
|
returnMap.put("count", add_creative_ids.size());
|
|
|
+ returnMap.put("ids", add_creative_ids);
|
|
|
}
|
|
|
} else {
|
|
|
if (code == 500000 && count <= 4) {
|