|
@@ -27,6 +27,8 @@ import cn.com.ctop.common.module.service.ISendMessageService;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.SendMailUtil;
|
|
import cn.com.ctop.common.module.utils.SendMailUtil;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
|
|
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
|
|
|
|
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -85,6 +87,13 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
private AlarmEventSendMapper alarmEventSendMapper;
|
|
private AlarmEventSendMapper alarmEventSendMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private UserAllocationMapper userAllocationMapper;
|
|
private UserAllocationMapper userAllocationMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IByteDanceAdvertisePlanService byteDanceAdvertisePlanService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IByteDanceCreativeService byteDanceCreativeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICtopOauthTokenService ctopOauthTokenService;
|
|
|
|
+
|
|
private JSONObject userObj = null;
|
|
private JSONObject userObj = null;
|
|
private final static String ACCOUNT = "account";
|
|
private final static String ACCOUNT = "account";
|
|
private final static String PLAN = "plan";
|
|
private final static String PLAN = "plan";
|
|
@@ -428,7 +437,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
} else {
|
|
} else {
|
|
String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, isNullCreativeJoiner.toString(), isNull);
|
|
String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, isNullCreativeJoiner.toString(), isNull);
|
|
- sendMsg(message, ruleGroup, user, CREATIVE);
|
|
|
|
|
|
+ sendMsg(message, ruleGroup, user, CREATIVE, isNullCreativeJoiner.toString(), accountId);
|
|
isNullCreativeJoiner = new StringJoiner(",");
|
|
isNullCreativeJoiner = new StringJoiner(",");
|
|
isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
}
|
|
}
|
|
@@ -437,13 +446,13 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
isNullPlanJoiner.add(obj.getString("planId"));
|
|
isNullPlanJoiner.add(obj.getString("planId"));
|
|
} else {
|
|
} else {
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, isNullPlanJoiner.toString(), isNull);
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, isNullPlanJoiner.toString(), isNull);
|
|
- sendMsg(msg, ruleGroup, user, PLAN);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, PLAN, isNullPlanJoiner.toString(), accountId);
|
|
isNullPlanJoiner = new StringJoiner(",");
|
|
isNullPlanJoiner = new StringJoiner(",");
|
|
isNullPlanJoiner.add(obj.getString("planId"));
|
|
isNullPlanJoiner.add(obj.getString("planId"));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, isNull);
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, isNull);
|
|
- sendMsg(msg, ruleGroup, user, ACCOUNT);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, ACCOUNT, null, accountId);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (!Check.isNull(obj.getString("creativeId"))) {
|
|
if (!Check.isNull(obj.getString("creativeId"))) {
|
|
@@ -452,7 +461,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
} else {
|
|
} else {
|
|
String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, creativeJoiner.toString(), isNull);
|
|
String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, creativeJoiner.toString(), isNull);
|
|
- sendMsg(message, ruleGroup, user, CREATIVE);
|
|
|
|
|
|
+ sendMsg(message, ruleGroup, user, CREATIVE, creativeJoiner.toString(), accountId);
|
|
creativeJoiner = new StringJoiner(",");
|
|
creativeJoiner = new StringJoiner(",");
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
}
|
|
}
|
|
@@ -461,31 +470,31 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
planJoiner.add(obj.getString("planId"));
|
|
planJoiner.add(obj.getString("planId"));
|
|
} else {
|
|
} else {
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, planJoiner.toString(), isNull);
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, planJoiner.toString(), isNull);
|
|
- sendMsg(msg, ruleGroup, user, PLAN);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, PLAN, planJoiner.toString(), accountId);
|
|
planJoiner = new StringJoiner(",");
|
|
planJoiner = new StringJoiner(",");
|
|
planJoiner.add(obj.getString("planId"));
|
|
planJoiner.add(obj.getString("planId"));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, isNull);
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, isNull);
|
|
- sendMsg(msg, ruleGroup, user, ACCOUNT);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, ACCOUNT, null, accountId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!Check.isNull(creativeJoiner.toString())) {
|
|
if (!Check.isNull(creativeJoiner.toString())) {
|
|
String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, creativeJoiner.toString(), false);
|
|
String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, creativeJoiner.toString(), false);
|
|
- sendMsg(creativeMsg, ruleGroup, user, CREATIVE);
|
|
|
|
|
|
+ sendMsg(creativeMsg, ruleGroup, user, CREATIVE, creativeJoiner.toString(), accountId);
|
|
}
|
|
}
|
|
if (!Check.isNull(planJoiner.toString())) {
|
|
if (!Check.isNull(planJoiner.toString())) {
|
|
String planMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, planJoiner.toString(), false);
|
|
String planMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, planJoiner.toString(), false);
|
|
- sendMsg(planMsg, ruleGroup, user, PLAN);
|
|
|
|
|
|
+ sendMsg(planMsg, ruleGroup, user, PLAN, planJoiner.toString(), accountId);
|
|
}
|
|
}
|
|
if (!Check.isNull(isNullCreativeJoiner.toString())) {
|
|
if (!Check.isNull(isNullCreativeJoiner.toString())) {
|
|
String isNullCreativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, isNullCreativeJoiner.toString(), true);
|
|
String isNullCreativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, isNullCreativeJoiner.toString(), true);
|
|
- sendMsg(isNullCreativeMsg, ruleGroup, user, CREATIVE);
|
|
|
|
|
|
+ sendMsg(isNullCreativeMsg, ruleGroup, user, CREATIVE, isNullCreativeJoiner.toString(), accountId);
|
|
}
|
|
}
|
|
if (!Check.isNull(isNullPlanJoiner.toString())) {
|
|
if (!Check.isNull(isNullPlanJoiner.toString())) {
|
|
String isNullPlanMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, isNullPlanJoiner.toString(), true);
|
|
String isNullPlanMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, isNullPlanJoiner.toString(), true);
|
|
- sendMsg(isNullPlanMsg, ruleGroup, user, PLAN);
|
|
|
|
|
|
+ sendMsg(isNullPlanMsg, ruleGroup, user, PLAN, isNullPlanJoiner.toString(), accountId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -500,17 +509,20 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private void sendMsg(String msg, RuleGroup ruleGroup, JSONObject user, String type) {
|
|
|
|
|
|
+ private void sendMsg(String msg, RuleGroup ruleGroup, JSONObject user, String type, String ids, Long accountId) {
|
|
try {
|
|
try {
|
|
- //TODO 关停操作
|
|
|
|
- boolean isPause = false;
|
|
|
|
- /* "PAUSE".equals(ruleGroup.getOperate());
|
|
|
|
- if (isPause) {
|
|
|
|
- if (shutDown(accountId, planId, creativeId, user.getString("id"))) {
|
|
|
|
- isPause = true;
|
|
|
|
|
|
+ boolean isPause = "PAUSE".equals(ruleGroup.getOperate());
|
|
|
|
+ if (isPause) {
|
|
|
|
+ //type 1:头条2:快手
|
|
|
|
+ if (NoEn.NO1.valueStr().equals(type)) {
|
|
|
|
+ isPause = touTiaoshutDown(accountId, ids, type);
|
|
|
|
+ } else {
|
|
|
|
+ msg = kuaiShoushutDown(accountId, ids, type, user.getString("id"), msg);
|
|
|
|
+ if (msg.getBytes().length >= 2048) {
|
|
|
|
+ msg = msg.replace(",", ",");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- type 1:头条2:快手
|
|
|
|
- }*/
|
|
|
|
if (isPause) {
|
|
if (isPause) {
|
|
msg += "现已被关停,请您及时查看并调整!";
|
|
msg += "现已被关停,请您及时查看并调整!";
|
|
} else {
|
|
} else {
|
|
@@ -578,21 +590,50 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private boolean shutDown(Long accountId, Long planId, Long creativeId, String userId) {
|
|
|
|
|
|
+ private String kuaiShoushutDown(Long accountId, String ids, String type, String userId, String msg) {
|
|
CtopOauthToken token = oauthTokenService.getTokenByAccountId(accountId);
|
|
CtopOauthToken token = oauthTokenService.getTokenByAccountId(accountId);
|
|
Map<String, Object> updateMap = new HashMap<>();
|
|
Map<String, Object> updateMap = new HashMap<>();
|
|
- if (!Check.isNull(token)) {
|
|
|
|
- if (!Check.isNull(creativeId)) {
|
|
|
|
- updateMap = kuaiShouUpdateService.updateCreativeStatus(token.getAccessToken(), accountId, creativeId, NoEn.NO2.valueInt(), userId);
|
|
|
|
- log.info("---------规则关停创意:{}", creativeId);
|
|
|
|
- } else if (!Check.isNull(planId) && Check.isNull(creativeId)) {
|
|
|
|
- updateMap = kuaiShouUpdateService.updateCampaignStatus(token.getAccessToken(), accountId, planId, NoEn.NO2.valueInt(), userId);
|
|
|
|
- log.info("---------规则关停计划:{}", planId);
|
|
|
|
|
|
+ if (!Check.isNull(token) && !Check.isNull(ids)) {
|
|
|
|
+ String[] idSplit = ids.split(",");
|
|
|
|
+ for (String id : idSplit) {
|
|
|
|
+ if (CREATIVE.equals(type)) {
|
|
|
|
+ updateMap = kuaiShouUpdateService.updateCreativeStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
|
|
|
|
+ if (!(boolean) updateMap.get("success")) {
|
|
|
|
+ msg = msg.replace(id, id + "(F)");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ updateMap = kuaiShouUpdateService.updateCampaignStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
|
|
|
|
+ if (!(boolean) updateMap.get("success")) {
|
|
|
|
+ msg = msg.replace(id, id + "(F)");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private boolean touTiaoshutDown(Long accountId, String ids, String type) {
|
|
|
|
+ Boolean flag = false;
|
|
|
|
+ if (!Check.isNull(ids)) {
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ if (PLAN.equals(type)) {
|
|
|
|
+ JSONArray planId = new JSONArray();
|
|
|
|
+ String[] split = ids.split(",");
|
|
|
|
+ for (String id : split) {
|
|
|
|
+ planId.add(id);
|
|
|
|
+ }
|
|
|
|
+ CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId(accountId);
|
|
|
|
+ result = byteDanceAdvertisePlanService.updateAdvertiserPlanStatus(token, planId, "AD_STATUS_DISABLE");
|
|
|
|
+ } else {
|
|
|
|
+ result = byteDanceCreativeService.advertiserCreativeUpdateStatus(accountId, ids.replace(",", ","), "disable");
|
|
}
|
|
}
|
|
|
|
+ flag = !Check.isNull(result.get("code")) && (int) result.get("code") == 0;
|
|
}
|
|
}
|
|
- return (boolean) updateMap.get("success");
|
|
|
|
|
|
+ return flag;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
//整理阈值数据
|
|
//整理阈值数据
|
|
public JSONObject getThreshold(Long accountId, boolean isCopy) {
|
|
public JSONObject getThreshold(Long accountId, boolean isCopy) {
|
|
JSONObject obj = new JSONObject();
|
|
JSONObject obj = new JSONObject();
|