|
@@ -24,7 +24,6 @@ import org.jeecg.common.util.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -40,6 +39,8 @@ import java.util.Map;
|
|
@Service
|
|
@Service
|
|
public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMapper, KuaishouStrategy> implements IKuaishouStrategyService {
|
|
public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMapper, KuaishouStrategy> implements IKuaishouStrategyService {
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private KuaishouStrategyMapper kuaishouStrategyMapper;
|
|
|
|
+ @Autowired
|
|
private IKuaishouInterfaceService kuaishouInterfaceService;
|
|
private IKuaishouInterfaceService kuaishouInterfaceService;
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaiShouImageGetService imageGetService;
|
|
private IKuaiShouImageGetService imageGetService;
|
|
@@ -52,26 +53,53 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
|
|
|
|
|
|
//TODO
|
|
//TODO
|
|
@Override
|
|
@Override
|
|
- public Result<Object> shutDownPlan(JSONArray ids) {
|
|
|
|
|
|
+ public Result<?> shutDownPlan(JSONArray ids) {
|
|
|
|
+ JSONObject obj = new JSONObject();
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
- String userId = sysUser.getId();
|
|
|
|
|
|
+ String userId = null;
|
|
|
|
+ if (!Check.isNull(sysUser)) {
|
|
|
|
+ userId = sysUser.getId();
|
|
|
|
+ }
|
|
|
|
+ userId = "test";
|
|
for (Object id : ids) {
|
|
for (Object id : ids) {
|
|
- List<JSONObject> list = new ArrayList<>();
|
|
|
|
|
|
+ boolean flag = true;
|
|
|
|
+ List<JSONObject> list = kuaishouStrategyMapper.queryPlanIdsByStrategyId(Long.valueOf(id.toString()));
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(list.get(0).getLong("accountId"));
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(list.get(0).getLong("accountId"));
|
|
for (JSONObject object : list) {
|
|
for (JSONObject object : list) {
|
|
- kuaiShouUpdateService.updateCampaignStatus(token.getAccessToken(), token.getAccountId(), object.getLong("campaignId"), NoEn.NO2.valueInt(), userId);
|
|
|
|
|
|
+ if (flag) {
|
|
|
|
+ flag = EditAdvertisingPlanStatus(token.getAccessToken(), token.getAccountId(), object.getLong("campaignId"), NoEn.NO2.valueInt(), userId, NoEn.NO1.valueInt());
|
|
|
|
+ } else {
|
|
|
|
+ EditAdvertisingPlanStatus(token.getAccessToken(), token.getAccountId(), object.getLong("campaignId"), NoEn.NO2.valueInt(), userId, NoEn.NO1.valueInt());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (flag) {
|
|
|
|
+ obj.put(id.toString(), true);
|
|
|
|
+ } else {
|
|
|
|
+ obj.put(id.toString(), false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return Result.ok(obj);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean EditAdvertisingPlanStatus(String token, Long accountId, Long campaignId, Integer state, String userId, int count) {
|
|
|
|
+ Map<String, Object> map = kuaiShouUpdateService.updateCampaignStatus(token, accountId, campaignId, state, userId);
|
|
|
|
+ boolean success = (boolean) map.get("success");
|
|
|
|
+ if (!success) {
|
|
|
|
+ if (count < 3) {
|
|
|
|
+ return EditAdvertisingPlanStatus(token, accountId, campaignId, state, userId, ++count);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return null;
|
|
|
|
|
|
+ return success;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* @param oauthToken token签名
|
|
* @param oauthToken token签名
|
|
- * @param groupJson 广告计划
|
|
|
|
|
|
+ * @param data 广告计划
|
|
* @return void
|
|
* @return void
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
|
|
+ @Override
|
|
public Map<String, Object> createPlanLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
|
|
public Map<String, Object> createPlanLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
|
|
JSONObject planJson = new JSONObject();
|
|
JSONObject planJson = new JSONObject();
|
|
/**计划类型
|
|
/**计划类型
|
|
@@ -97,6 +125,7 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
|
|
return kuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), planJson);
|
|
return kuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), planJson);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
public JSONArray createGroupLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
|
|
public JSONArray createGroupLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
|
|
JSONArray resultArr = new JSONArray();
|
|
JSONArray resultArr = new JSONArray();
|
|
JSONArray groupInfo = data.getJSONArray("groupInfo");
|
|
JSONArray groupInfo = data.getJSONArray("groupInfo");
|
|
@@ -379,9 +408,8 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
|
|
if (!Check.isNull(groupJson.getInteger("noAreaBreak"))) {
|
|
if (!Check.isNull(groupJson.getInteger("noAreaBreak"))) {
|
|
intelliExtendJson.put("no_area_break", groupJson.getInteger("noAreaBreak"));
|
|
intelliExtendJson.put("no_area_break", groupJson.getInteger("noAreaBreak"));
|
|
}
|
|
}
|
|
- if (!Check.isNull(intelliExtendJson)) {
|
|
|
|
- targetJson.put("intelli_extend", intelliExtendJson);
|
|
|
|
- }
|
|
|
|
|
|
+ targetJson.put("intelli_extend", intelliExtendJson);
|
|
|
|
+
|
|
}
|
|
}
|
|
// APP行为-按分类
|
|
// APP行为-按分类
|
|
if (!Check.isNull(groupJson.getJSONArray("appInterest"))) {
|
|
if (!Check.isNull(groupJson.getJSONArray("appInterest"))) {
|