|
@@ -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,17 +53,43 @@ 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;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|