|
@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.kuaishoustrategycampaignRel;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouStrategyMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
|
|
@@ -49,28 +50,43 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
|
|
|
@Autowired
|
|
|
private IKuaiShouUpdateService kuaiShouUpdateService;
|
|
|
@Autowired
|
|
|
+ private kuaishoustrategycampaignRelServiceImpl kuaishoustrategycampaignRelService;
|
|
|
+ @Autowired
|
|
|
private ICtopOauthTokenService tokenService;
|
|
|
|
|
|
- //TODO
|
|
|
@Override
|
|
|
- public Result<?> shutDownPlan(JSONArray ids) {
|
|
|
+ public Result<?> shutDownPlan(JSONObject data) {
|
|
|
+ JSONArray ids = data.getJSONArray("ids");
|
|
|
+ Integer state = data.getInteger("state");
|
|
|
JSONObject obj = new JSONObject();
|
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
String userId = null;
|
|
|
if (!Check.isNull(sysUser)) {
|
|
|
userId = sysUser.getId();
|
|
|
}
|
|
|
- userId = "test";
|
|
|
for (Object id : ids) {
|
|
|
boolean flag = true;
|
|
|
- List<JSONObject> list = kuaishouStrategyMapper.queryPlanIdsByStrategyId(Long.valueOf(id.toString()));
|
|
|
+ List<JSONObject> list = null;
|
|
|
+ //开启
|
|
|
+ if (state == 1) {
|
|
|
+ list = kuaishoustrategycampaignRelService.queryPlanIdsByStrategyId(Long.valueOf(id.toString()));
|
|
|
+ } else {
|
|
|
+ list = kuaishouStrategyMapper.queryPlanIdsByStrategyId(Long.valueOf(id.toString()));
|
|
|
+ }
|
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(list.get(0).getLong("accountId"));
|
|
|
+ kuaishoustrategycampaignRel rel = new kuaishoustrategycampaignRel();
|
|
|
+ rel.setAccountId(token.getAccountId());
|
|
|
+ rel.setStrategyId(Long.valueOf(id.toString()));
|
|
|
+ rel.setStrategyState(state.toString());
|
|
|
for (JSONObject object : list) {
|
|
|
+ rel.setId(object.getLong("id"));
|
|
|
+ rel.setCampaignId(object.getLong("campaignId"));
|
|
|
if (flag) {
|
|
|
- flag = EditAdvertisingPlanStatus(token.getAccessToken(), token.getAccountId(), object.getLong("campaignId"), NoEn.NO2.valueInt(), userId, NoEn.NO1.valueInt());
|
|
|
+ flag = EditAdvertisingPlanStatus(token.getAccessToken(), token.getAccountId(), object.getLong("campaignId"), state, userId, NoEn.NO1.valueInt());
|
|
|
} else {
|
|
|
- EditAdvertisingPlanStatus(token.getAccessToken(), token.getAccountId(), object.getLong("campaignId"), NoEn.NO2.valueInt(), userId, NoEn.NO1.valueInt());
|
|
|
+ EditAdvertisingPlanStatus(token.getAccessToken(), token.getAccountId(), object.getLong("campaignId"), state, userId, NoEn.NO1.valueInt());
|
|
|
}
|
|
|
+ kuaishoustrategycampaignRelService.saveOrUpdate(rel);
|
|
|
}
|
|
|
if (flag) {
|
|
|
obj.put(id.toString(), true);
|
|
@@ -81,6 +97,12 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
|
|
|
return Result.ok(obj);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param
|
|
|
+ * @return boolean
|
|
|
+ * @throws
|
|
|
+ * @author ZHAOXA
|
|
|
+ */
|
|
|
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");
|
|
@@ -434,6 +456,7 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
|
|
|
return kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson, 1);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 根据策略创建创意
|
|
|
*
|