|
|
@@ -1,10 +1,17 @@
|
|
|
package cn.com.ctop.kuaishou.modules.batch.service.impl;
|
|
|
|
|
|
+import cn.com.ctop.common.module.mapper.KuaiShouOcpxActionTypeConfigMapper;
|
|
|
+import cn.com.ctop.common.module.service.IMessageTemplate;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
|
import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.entity.*;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppInfo;
|
|
|
+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.KuaiShouGroup;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTarget;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouSchedule;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppInfoMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupTargetMapper;
|
|
|
@@ -22,7 +29,11 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-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;
|
|
|
|
|
|
@@ -49,7 +60,10 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
|
|
|
private static ExecutorService executorService = Executors.newFixedThreadPool(10);
|
|
|
@Autowired
|
|
|
private IKuaiShouCreativeService creativeService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private KuaiShouOcpxActionTypeConfigMapper ocpxActionTypeConfigMapper;
|
|
|
+ @Autowired
|
|
|
+ private IMessageTemplate messageTemplate;
|
|
|
|
|
|
/**
|
|
|
* 获取广告组
|
|
|
@@ -86,7 +100,7 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("advertiser_id", accountId);
|
|
|
- if(!Check.isNull(campaignId)){
|
|
|
+ if (!Check.isNull(campaignId)) {
|
|
|
param.put("campaign_id", campaignId);
|
|
|
}
|
|
|
param.put("page_size", 500);
|
|
|
@@ -132,9 +146,9 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Integer queryToDayBuiltCount(Long accountId,Integer unitType) {
|
|
|
+ public Integer queryToDayBuiltCount(Long accountId, Integer unitType) {
|
|
|
String date = DateUtil.formatDate(new Date());
|
|
|
- return groupMapper.queryToDayBuiltCount(accountId, date,unitType);
|
|
|
+ return groupMapper.queryToDayBuiltCount(accountId, date, unitType);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -368,6 +382,12 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
|
|
|
}
|
|
|
}
|
|
|
if (!Check.isNull(details)) {
|
|
|
+ Map<Integer, String> textMap = new HashMap<>();
|
|
|
+ List<JSONObject> lists = ocpxActionTypeConfigMapper.getKuaiShouOcpxTypeList();
|
|
|
+ for (JSONObject da : lists) {
|
|
|
+ textMap.put(da.getInteger("ocpxActionType"), da.getString("ocpxActionName"));
|
|
|
+ }
|
|
|
+
|
|
|
List<KuaiShouGroup> groups = new ArrayList<>();
|
|
|
List<KuaiShouAppInfo> appInfos = new ArrayList<>();
|
|
|
List<KuaiShouSchedule> schedules = new ArrayList<>();
|
|
|
@@ -398,6 +418,9 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
|
|
|
//投放状态
|
|
|
Integer putStatus = detail.getInteger("put_status");
|
|
|
if (putStatus == 1 && status != 15) { // 组状态为 投放中的 and 广告组状态为非暂停
|
|
|
+ String msgType = "";
|
|
|
+ String msgBid = "";
|
|
|
+
|
|
|
Boolean typeFalg = true;
|
|
|
Boolean bidFalg = true;
|
|
|
|
|
|
@@ -405,14 +428,18 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
|
|
|
if (!bidList.isEmpty()) {
|
|
|
if (!bidList.contains(bidType)) {
|
|
|
//项目不包含该优化目标,则关停
|
|
|
+ String msg = Check.isNull(textMap.get(bidType)) ? String.valueOf(bidType) : textMap.get(bidType);
|
|
|
+ msgType = "组优化目标:" + msg;
|
|
|
typeFalg = false;
|
|
|
} else if (bidType == 2 && bid > maxBid) {
|
|
|
//若优化目标为2点击数,并且广告组出价大于项目设置最大出价,则关停
|
|
|
bidFalg = false;
|
|
|
+ msgBid = "优化为点击且优化出价:" + bid + " > 项目最大出价:" + maxBid;
|
|
|
}
|
|
|
}
|
|
|
//转化目标
|
|
|
if (!Check.isNull(ocpxActionType) && ocpxActionType != 0) {
|
|
|
+ String msg = Check.isNull(textMap.get(ocpxActionType)) ? String.valueOf(ocpxActionType) : textMap.get(ocpxActionType);
|
|
|
//!=0是设置过转化目标
|
|
|
if (!Check.isNullMap(ocpxMap)) {
|
|
|
Long ocpxBid = ocpxMap.get(ocpxActionType);
|
|
|
@@ -420,35 +447,43 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
|
|
|
if (ocpxActionType == 2 && dayBudget != 0 && dayBudget <= 500 * 1000) {
|
|
|
// 转化目标为2行为数,并且预算小于等于500且不是不限,则允许启动
|
|
|
typeFalg = true;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//通过key未获取值,说明不包含该目标,进行关停
|
|
|
typeFalg = false;
|
|
|
+ msgType = "组转化目标:" + msg + ",日预算为:" + dayBudget;
|
|
|
}
|
|
|
} else {
|
|
|
if (cpaBid > ocpxBid) {
|
|
|
//组转化出价 大于 项目设置最大转化出价,则关停
|
|
|
bidFalg = false;
|
|
|
+ msgBid = "转化出价:" + cpaBid + " > 项目出价:" + ocpxBid;
|
|
|
}
|
|
|
}
|
|
|
- }else if (ocpxActionType == 2 && (dayBudget == 0 || dayBudget > 500 * 1000)) {
|
|
|
+ } else if (ocpxActionType == 2 && (dayBudget == 0 || dayBudget > 500 * 1000)) {
|
|
|
// 转化目标为2行为数,并且预算大于500 或者不限,则关停
|
|
|
typeFalg = false;
|
|
|
+ msgType = "组转化目标:" + msg + ",日预算为:" + dayBudget;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//转化目标
|
|
|
if (!Check.isNull(deepConversionType) && deepConversionType != 0 && !deepMap.isEmpty()) {
|
|
|
+ String msg = Check.isNull(textMap.get(deepConversionType)) ? String.valueOf(deepConversionType) : textMap.get(deepConversionType);
|
|
|
Long deepBid = deepMap.get(deepConversionType);
|
|
|
if (Check.isNull(deepBid)) {
|
|
|
//通过key未获取值,说明不包含该目标,进行关停
|
|
|
typeFalg = false;
|
|
|
+ msgType = "组深度转化目标:" + msg;
|
|
|
} else {
|
|
|
if (deepConversionBid > deepBid) {
|
|
|
//组深度转化出价 大于 项目设置最大转化出价,则关停
|
|
|
bidFalg = false;
|
|
|
+ msgBid = "深度转化出价:" + deepConversionBid + " > 项目出价:" + deepBid;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ String typeText = messageTemplate.getKuaiShouBidTypeMessage(json.getString("projectName"), advertiserId, unitId, unitName, msgType);
|
|
|
+ String bidText = messageTemplate.getKuaiShouBidMessage(json.getString("projectName"), advertiserId, unitId, unitName, msgBid);
|
|
|
|
|
|
if (!typeFalg) { // 出价方式设置非法
|
|
|
executorBidTypeService.submit(new Runnable() {
|