|
@@ -2,13 +2,15 @@ package cn.com.ctop.kuaishou.modules.batch.controller;
|
|
|
|
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
|
+import cn.com.ctop.common.module.entity.MaterialInfo;
|
|
|
|
+import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
|
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListParent;
|
|
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.vo.SpendVo;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.vo.SpendVo;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListParentMapper;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListParentMapper;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouTargetingTagsMapper;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.*;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Api(tags = "快手-批量工具")
|
|
@Api(tags = "快手-批量工具")
|
|
@@ -43,11 +46,24 @@ public class BatchController {
|
|
private IKuaiShouUpdateService updateService;
|
|
private IKuaiShouUpdateService updateService;
|
|
@Autowired
|
|
@Autowired
|
|
private ICtopOauthTokenService tokenService;
|
|
private ICtopOauthTokenService tokenService;
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaiShouGroupService kuaiShouGroupService;
|
|
private IKuaiShouGroupService kuaiShouGroupService;
|
|
@Autowired
|
|
@Autowired
|
|
private KuaiShouRegionListParentMapper regionListParentMapper;
|
|
private KuaiShouRegionListParentMapper regionListParentMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouAppListService kuaiShouAppListService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private KuaiShouTargetingTagsMapper targetingTagsMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouImageGetService kuaiShouImageGetService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouVideoGetService kuaiShouVideoGetService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private MaterialInfoMapper materialInfoMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private KuaiShouCampaignMapper campaignMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouActionBarTextService actionBarTextService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -114,6 +130,64 @@ public class BatchController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 批量修改广告计划状态
|
|
|
|
+ *
|
|
|
|
+ * @param requestJson
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/batchUpdateStatus")
|
|
|
|
+ public Result<JSONObject> batchUpdateStatus(@RequestBody JSONObject requestJson) {
|
|
|
|
+ Result<JSONObject> result = new Result<>();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Long accountId = requestJson.getLong("accountId");
|
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if (Check.isNull(token)) {
|
|
|
|
+ throw new Exception("账号信息为空");
|
|
|
|
+ }
|
|
|
|
+ Integer putStatus = requestJson.getInteger("putStatus");
|
|
|
|
+ if (putStatus == null) {
|
|
|
|
+ throw new Exception("请选择状态");
|
|
|
|
+ }
|
|
|
|
+ String userId = requestJson.getString("userId");
|
|
|
|
+ JSONArray campaignIds = requestJson.getJSONArray("campaignIds");
|
|
|
|
+ JSONArray failArr = new JSONArray();
|
|
|
|
+ if (!Check.isNull(campaignIds)) {
|
|
|
|
+ for (int i = 0; i < campaignIds.size(); i++) {
|
|
|
|
+ Long campaignId = campaignIds.getLong(i);
|
|
|
|
+ if (!Check.isNull(campaignId)) {
|
|
|
|
+ Map<String, Object> updateMap = updateService.updateCampaignStatus(token.getAccessToken(), accountId, campaignId, putStatus, userId);
|
|
|
|
+ if (!Check.isNull(updateMap)) {
|
|
|
|
+ Integer code = (Integer) updateMap.get("code");
|
|
|
|
+ if (code != 0) {
|
|
|
|
+ JSONObject failJson = new JSONObject();
|
|
|
|
+ failJson.put("message", updateMap.get("message"));
|
|
|
|
+ KuaiShouCampaign campaign = batchService.getCampaignInfo(accountId, campaignId);
|
|
|
|
+ if (!Check.isNull(campaign)) {
|
|
|
|
+ failJson.put("campaignName", campaign.getCampaignName());
|
|
|
|
+ }
|
|
|
|
+ failArr.add(failJson);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ json.put("totalCount", campaignIds.size());
|
|
|
|
+ json.put("failCount", failArr.size());
|
|
|
|
+ json.put("failInfo", failArr);
|
|
|
|
+ result.setResult(json);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 批量修改广告计划预算
|
|
* 批量修改广告计划预算
|
|
*
|
|
*
|
|
* @param requestJson
|
|
* @param requestJson
|
|
@@ -122,7 +196,6 @@ public class BatchController {
|
|
@PostMapping(value = "/batchUpdateDayBudget")
|
|
@PostMapping(value = "/batchUpdateDayBudget")
|
|
public Result<JSONObject> batchUpdateDayBudget(@RequestBody JSONObject requestJson) {
|
|
public Result<JSONObject> batchUpdateDayBudget(@RequestBody JSONObject requestJson) {
|
|
Result<JSONObject> result = new Result<>();
|
|
Result<JSONObject> result = new Result<>();
|
|
-
|
|
|
|
try {
|
|
try {
|
|
Long accountId = requestJson.getLong("accountId");
|
|
Long accountId = requestJson.getLong("accountId");
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
@@ -135,14 +208,32 @@ public class BatchController {
|
|
}
|
|
}
|
|
String userId = requestJson.getString("userId");
|
|
String userId = requestJson.getString("userId");
|
|
JSONArray campaignIds = requestJson.getJSONArray("campaignIds");
|
|
JSONArray campaignIds = requestJson.getJSONArray("campaignIds");
|
|
|
|
+ JSONArray failArr = new JSONArray();
|
|
if (!Check.isNull(campaignIds)) {
|
|
if (!Check.isNull(campaignIds)) {
|
|
for (int i = 0; i < campaignIds.size(); i++) {
|
|
for (int i = 0; i < campaignIds.size(); i++) {
|
|
Long campaignId = campaignIds.getLong(i);
|
|
Long campaignId = campaignIds.getLong(i);
|
|
if (!Check.isNull(campaignId)) {
|
|
if (!Check.isNull(campaignId)) {
|
|
- updateService.updateCampaign(token.getAccessToken(), accountId, campaignId, dayBudget, userId);
|
|
|
|
|
|
+ Map<String, Object> updateMap = updateService.updateCampaign(token.getAccessToken(), accountId, campaignId, dayBudget, userId);
|
|
|
|
+ if (!Check.isNull(updateMap)) {
|
|
|
|
+ Integer code = (Integer) updateMap.get("code");
|
|
|
|
+ if (code != 0) {
|
|
|
|
+ JSONObject failJson = new JSONObject();
|
|
|
|
+ failJson.put("message", updateMap.get("message"));
|
|
|
|
+ KuaiShouCampaign campaign = batchService.getCampaignInfo(accountId, campaignId);
|
|
|
|
+ if (!Check.isNull(campaign)) {
|
|
|
|
+ failJson.put("campaignName", campaign.getCampaignName());
|
|
|
|
+ }
|
|
|
|
+ failArr.add(failJson);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ json.put("totalCount", campaignIds.size());
|
|
|
|
+ json.put("failCount", failArr.size());
|
|
|
|
+ json.put("failInfo", failArr);
|
|
|
|
+ result.setResult(json);
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -169,6 +260,7 @@ public class BatchController {
|
|
HttpServletRequest req) {
|
|
HttpServletRequest req) {
|
|
Result<IPage<KuaiShouGroup>> result = new Result<IPage<KuaiShouGroup>>();
|
|
Result<IPage<KuaiShouGroup>> result = new Result<IPage<KuaiShouGroup>>();
|
|
QueryWrapper<KuaiShouGroup> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouGroup, req.getParameterMap());
|
|
QueryWrapper<KuaiShouGroup> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouGroup, req.getParameterMap());
|
|
|
|
+ queryWrapper.orderByDesc("unit_id");
|
|
Page<KuaiShouGroup> page = new Page<KuaiShouGroup>(pageNo, pageSize);
|
|
Page<KuaiShouGroup> page = new Page<KuaiShouGroup>(pageNo, pageSize);
|
|
IPage<KuaiShouGroup> pageList = kuaiShouGroupService.page(page, queryWrapper);
|
|
IPage<KuaiShouGroup> pageList = kuaiShouGroupService.page(page, queryWrapper);
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
@@ -180,23 +272,713 @@ public class BatchController {
|
|
/**
|
|
/**
|
|
* 获取区域列表
|
|
* 获取区域列表
|
|
*
|
|
*
|
|
- * @param kuaiShouRegionListParent
|
|
|
|
|
|
+ * @param
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouRegionListParentService kuaiShouRegionListParentService;
|
|
|
|
+
|
|
@GetMapping(value = "/getRegion")
|
|
@GetMapping(value = "/getRegion")
|
|
public Result<List<KuaiShouRegionListParent>> getRegion(KuaiShouRegionListParent kuaiShouRegionListParent, HttpServletRequest req) {
|
|
public Result<List<KuaiShouRegionListParent>> getRegion(KuaiShouRegionListParent kuaiShouRegionListParent, HttpServletRequest req) {
|
|
Result<List<KuaiShouRegionListParent>> result = new Result<>();
|
|
Result<List<KuaiShouRegionListParent>> result = new Result<>();
|
|
|
|
|
|
|
|
+
|
|
try {
|
|
try {
|
|
|
|
+ /*JSONArray regionArr = new JSONArray();
|
|
|
|
+ QueryWrapper<KuaiShouRegionListParent> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("level", 1);
|
|
|
|
+ List<KuaiShouRegionListParent> regionListParents = regionListParentMapper.selectList(queryWrapper);
|
|
|
|
+ if (!Check.isNull(regionListParents)) {
|
|
|
|
+
|
|
|
|
+ for (KuaiShouRegionListParent regionListParent : regionListParents) {
|
|
|
|
+ if (Check.isNull(regionListParent)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ JSONObject parentJson = new JSONObject();
|
|
|
|
+ Long regionId = regionListParent.getRegionId();
|
|
|
|
+ parentJson.put("regionId", regionId);
|
|
|
|
+ parentJson.put("name", regionListParent.getName());
|
|
|
|
+ QueryWrapper<KuaiShouRegionListParent> childrenQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ childrenQueryWrapper.eq("parent", regionId);
|
|
|
|
+ List<KuaiShouRegionListParent> childrenRegions = regionListParentMapper.selectList(childrenQueryWrapper);
|
|
|
|
+
|
|
|
|
+ JSONArray childrenArr = new JSONArray();
|
|
|
|
+ if (!Check.isNull(childrenRegions)) {
|
|
|
|
+ for (KuaiShouRegionListParent childrenRegion : childrenRegions) {
|
|
|
|
+ if (!Check.isNull(childrenRegion)) {
|
|
|
|
+ JSONObject childrenJson = new JSONObject();
|
|
|
|
+ childrenJson.put("regionId", childrenRegion.getRegionId());
|
|
|
|
+ childrenJson.put("name", childrenRegion.getName());
|
|
|
|
+ childrenArr.add(childrenJson);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ parentJson.put("children", childrenArr);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ regionArr.add(parentJson);
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+
|
|
QueryWrapper<KuaiShouRegionListParent> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouRegionListParent, req.getParameterMap());
|
|
QueryWrapper<KuaiShouRegionListParent> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouRegionListParent, req.getParameterMap());
|
|
|
|
|
|
- List<KuaiShouRegionListParent> regionListParents = regionListParentMapper.selectList(queryWrapper);
|
|
|
|
|
|
+ List<KuaiShouRegionListParent> pageList = kuaiShouRegionListParentService.list(queryWrapper);
|
|
|
|
+
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(pageList);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 创建广告计划
|
|
|
|
+ *
|
|
|
|
+ * @param requestJson
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/campaignCreate")
|
|
|
|
+ public Result<Object> campaignCreate(@RequestBody JSONObject requestJson) {
|
|
|
|
+ Result<Object> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ Long accountId = requestJson.getLong("accountId");
|
|
|
|
+ CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if (Check.isNull(oauthToken)) {
|
|
|
|
+ throw new Exception("未获取到账户信息");
|
|
|
|
+ }
|
|
|
|
+ JSONObject campaignJson = new JSONObject();
|
|
|
|
+ campaignJson.put("campaign_name", requestJson.getString("campaignName"));
|
|
|
|
+ campaignJson.put("type", requestJson.getInteger("type"));
|
|
|
|
+ campaignJson.put("day_budget", requestJson.getLong("day_budget"));
|
|
|
|
+ Map<String, Object> campaignMap = iKuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), accountId, campaignJson);
|
|
|
|
+ Integer code = (Integer) campaignMap.get("code");
|
|
|
|
+ if (code != 0) {
|
|
|
|
+ throw new Exception((String) campaignMap.get("message"));
|
|
|
|
+ }
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
- result.setResult(regionListParents);
|
|
|
|
|
|
+ result.setResult(campaignMap.get("campaignId"));
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
result.setSuccess(false);
|
|
result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取应用列表
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/getAppList")
|
|
|
|
+ public Result<List<KuaiShouAppList>> getAppList(KuaiShouAppList kuaiShouAppList, HttpServletRequest req) {
|
|
|
|
+ Result<List<KuaiShouAppList>> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ QueryWrapper<KuaiShouAppList> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouAppList, req.getParameterMap());
|
|
|
|
+ queryWrapper.orderByDesc("return_time");
|
|
|
|
+
|
|
|
|
+ List<KuaiShouAppList> appList = kuaiShouAppListService.list(queryWrapper);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(appList);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取人群包接口
|
|
|
|
+ *
|
|
|
|
+ * @param accountId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/getPopulationList")
|
|
|
|
+ public Result<JSONArray> getAppList(Long accountId) {
|
|
|
|
+ Result<JSONArray> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if (Check.isNull(oauthToken)) {
|
|
|
|
+ throw new Exception("未获取到账户信息");
|
|
|
|
+ }
|
|
|
|
+ JSONArray jsonArray = iKuaishouInterfaceService.getPopulationList(accountId, oauthToken.getAccessToken());
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(jsonArray);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取商业兴趣
|
|
|
|
+ *
|
|
|
|
+ * @param kuaiShouTargetingTags BUSINESS_INTEREST:商业兴趣
|
|
|
|
+ * APP_INTEREST:APP行为
|
|
|
|
+ * FANS_STAR:网红类别
|
|
|
|
+ * INTEREST_VIDEO:兴趣视频
|
|
|
|
+ * @param req
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/getTargetList")
|
|
|
|
+ public Result<List<KuaiShouTargetingTags>> getTargetList(KuaiShouTargetingTags kuaiShouTargetingTags, HttpServletRequest req) {
|
|
|
|
+ Result<List<KuaiShouTargetingTags>> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ QueryWrapper<KuaiShouTargetingTags> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouTargetingTags, req.getParameterMap());
|
|
|
|
+ queryWrapper.orderByAsc("tag_id");
|
|
|
|
+ List<KuaiShouTargetingTags> targetingTagList = targetingTagsMapper.selectList(queryWrapper);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(targetingTagList);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取可选的深度类型
|
|
|
|
+ *
|
|
|
|
+ * @param accountId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/getIsActivate")
|
|
|
|
+ public Result<JSONObject> getIsActivate(Long accountId) {
|
|
|
|
+ Result result = new Result<JSONObject>();
|
|
|
|
+ try {
|
|
|
|
+ CtopOauthToken token = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if (Check.isNull(token)) {
|
|
|
|
+ throw new Exception("未获取授权信息");
|
|
|
|
+ }
|
|
|
|
+ JSONObject deepConversionJson = iKuaishouInterfaceService.getDeepConversionInfosV2(accountId, token.getAccessToken());
|
|
|
|
+ if (Check.isNull(deepConversionJson)) {
|
|
|
|
+ throw new Exception("深度类型数据返回为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(deepConversionJson);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取app列表
|
|
|
|
+ *
|
|
|
|
+ * @param accountId
|
|
|
|
+ * @param appName
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/getAppSearch")
|
|
|
|
+ public Result<JSONObject> getAppSearch(Long accountId, String appName) {
|
|
|
|
+ Result result = new Result<JSONObject>();
|
|
|
|
+ try {
|
|
|
|
+ CtopOauthToken token = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if (Check.isNull(token)) {
|
|
|
|
+ throw new Exception("未获取授权信息");
|
|
|
|
+ }
|
|
|
|
+ JSONArray appArray = iKuaishouInterfaceService.getAppSearch(accountId, token.getAccessToken(), appName);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(appArray);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取项目最高出价
|
|
|
|
+ *
|
|
|
|
+ * @param accountId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/getProjectMaxBid")
|
|
|
|
+ public Result<BigDecimal> getProjectMaxBid(Long accountId) {
|
|
|
|
+ Result<BigDecimal> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ if (Check.isNull(accountId)) {
|
|
|
|
+ throw new Exception("请传入accountId");
|
|
|
|
+ }
|
|
|
|
+ BigDecimal maxBid = batchService.getProjectMaxBid(accountId);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(maxBid);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取项目最高出价
|
|
|
|
+ *
|
|
|
|
+ * @param campaignId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/checkUnitName")
|
|
|
|
+ public Result<Boolean> checkUnitName(Long campaignId, String unitName) {
|
|
|
|
+ Result<Boolean> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ if (Check.isNull(campaignId)) {
|
|
|
|
+ throw new Exception("请传入广告计划id");
|
|
|
|
+ }
|
|
|
|
+ if (Check.isNull(unitName)) {
|
|
|
|
+ throw new Exception("请传入广告组名称");
|
|
|
|
+ }
|
|
|
|
+ Boolean checkUnitName = batchService.checkUnitName(campaignId, unitName);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(checkUnitName);
|
|
|
|
+ if (!checkUnitName) {
|
|
|
|
+ result.setMessage("广告组名称该计划下已存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量创建广告组
|
|
|
|
+ *
|
|
|
|
+ * @param requestJson
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/createUnit")
|
|
|
|
+ public Result<JSONObject> createUnit(@RequestBody JSONObject requestJson) {
|
|
|
|
+ Result<JSONObject> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ if (Check.isNull(requestJson)) {
|
|
|
|
+ throw new Exception("入参为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONObject unitJson = batchService.createUnit(requestJson);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(unitJson);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouCreativeService kuaiShouCreativeService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/getCreativeList")
|
|
|
|
+ public Result<IPage<KuaiShouCreative>> getCreativeList(KuaiShouCreative kuaiShouCreative, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
|
|
|
+ Result<IPage<KuaiShouCreative>> result = new Result<>();
|
|
|
|
+
|
|
|
|
+ QueryWrapper<KuaiShouCreative> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouCreative, req.getParameterMap());
|
|
|
|
+ queryWrapper.orderByDesc("creative_id");
|
|
|
|
+ Page<KuaiShouCreative> page = new Page<>(pageNo, pageSize);
|
|
|
|
+ IPage<KuaiShouCreative> creativeList = kuaiShouCreativeService.page(page, queryWrapper);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(creativeList);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量修改广告组预算
|
|
|
|
+ *
|
|
|
|
+ * @param requestJson
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/batchUpdateUnitBudget")
|
|
|
|
+ public Result<JSONObject> batchUpdateUnitBudget(@RequestBody JSONObject requestJson) {
|
|
|
|
+ Result<JSONObject> result = new Result<>();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Long accountId = requestJson.getLong("accountId");
|
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if (Check.isNull(token)) {
|
|
|
|
+ throw new Exception("账号信息为空");
|
|
|
|
+ }
|
|
|
|
+ Long dayBudget = requestJson.getLong("dayBudget");
|
|
|
|
+ if (Check.isNull(dayBudget)) {
|
|
|
|
+ throw new Exception("预算信息为空");
|
|
|
|
+ }
|
|
|
|
+ String userId = requestJson.getString("userId");
|
|
|
|
+ JSONArray unitIds = requestJson.getJSONArray("unitIds");
|
|
|
|
+ JSONArray failArr = new JSONArray();
|
|
|
|
+ if (!Check.isNull(unitIds)) {
|
|
|
|
+ for (int i = 0; i < unitIds.size(); i++) {
|
|
|
|
+ Long unitId = unitIds.getLong(i);
|
|
|
|
+ if (!Check.isNull(unitId)) {
|
|
|
|
+ Map<String, Object> updateMap = updateService.updateUnitDayBudget(token.getAccessToken(), accountId, unitId, dayBudget, userId);
|
|
|
|
+ if (!Check.isNull(updateMap)) {
|
|
|
|
+ Integer code = (Integer) updateMap.get("code");
|
|
|
|
+ if (code != 0) {
|
|
|
|
+ JSONObject failJson = new JSONObject();
|
|
|
|
+ failJson.put("message", updateMap.get("message"));
|
|
|
|
+ KuaiShouGroup group = batchService.getUnitInfo(accountId, unitId);
|
|
|
|
+ if (!Check.isNull(group)) {
|
|
|
|
+ failJson.put("unitName", group.getUnitName());
|
|
|
|
+ }
|
|
|
|
+ failArr.add(failJson);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ json.put("totalCount", unitIds.size());
|
|
|
|
+ json.put("failCount", failArr.size());
|
|
|
|
+ json.put("failInfo", failArr);
|
|
|
|
+ result.setResult(json);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量修改广告组状态
|
|
|
|
+ *
|
|
|
|
+ * @param requestJson
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/batchUpdateUnitStatus")
|
|
|
|
+ public Result<JSONObject> batchUpdateUnitStatus(@RequestBody JSONObject requestJson) {
|
|
|
|
+ Result<JSONObject> result = new Result<>();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Long accountId = requestJson.getLong("accountId");
|
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if (Check.isNull(token)) {
|
|
|
|
+ throw new Exception("账号信息为空");
|
|
|
|
+ }
|
|
|
|
+ Integer putStatus = requestJson.getInteger("putStatus");
|
|
|
|
+ if (putStatus == null) {
|
|
|
|
+ throw new Exception("请选择状态");
|
|
|
|
+ }
|
|
|
|
+ String userId = requestJson.getString("userId");
|
|
|
|
+ JSONArray unitIds = requestJson.getJSONArray("unitIds");
|
|
|
|
+ JSONArray failArr = new JSONArray();
|
|
|
|
+ if (!Check.isNull(unitIds)) {
|
|
|
|
+ for (int i = 0; i < unitIds.size(); i++) {
|
|
|
|
+ Long unitId = unitIds.getLong(i);
|
|
|
|
+ if (!Check.isNull(unitId)) {
|
|
|
|
+ Map<String, Object> updateMap = updateService.updateUnitStatus(token.getAccessToken(), accountId, unitId, putStatus, userId);
|
|
|
|
+ if (!Check.isNull(updateMap)) {
|
|
|
|
+ Integer code = (Integer) updateMap.get("code");
|
|
|
|
+ if (code != 0) {
|
|
|
|
+ JSONObject failJson = new JSONObject();
|
|
|
|
+ failJson.put("message", updateMap.get("message"));
|
|
|
|
+ KuaiShouGroup group = batchService.getUnitInfo(accountId, unitId);
|
|
|
|
+ if (!Check.isNull(group)) {
|
|
|
|
+ failJson.put("campaignName", group.getUnitName());
|
|
|
|
+ }
|
|
|
|
+ failArr.add(failJson);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ json.put("totalCount", unitIds.size());
|
|
|
|
+ json.put("failCount", failArr.size());
|
|
|
|
+ json.put("failInfo", failArr);
|
|
|
|
+ result.setResult(json);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量修改广告组状态
|
|
|
|
+ *
|
|
|
|
+ * @param requestJson
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/batchUpdateUnitBid")
|
|
|
|
+ public Result<JSONObject> batchUpdateUnitBid(@RequestBody JSONObject requestJson) {
|
|
|
|
+ Result<JSONObject> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ Long accountId = requestJson.getLong("accountId");
|
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if (Check.isNull(token)) {
|
|
|
|
+ throw new Exception("账号信息为空");
|
|
|
|
+ }
|
|
|
|
+ Long bid = requestJson.getLong("bid");
|
|
|
|
+ if (bid == null) {
|
|
|
|
+ throw new Exception("请输入出价");
|
|
|
|
+ }
|
|
|
|
+ String userId = requestJson.getString("userId");
|
|
|
|
+ JSONArray unitIds = requestJson.getJSONArray("unitIds");
|
|
|
|
+ JSONArray failArr = new JSONArray();
|
|
|
|
+ if (!Check.isNull(unitIds)) {
|
|
|
|
+ for (int i = 0; i < unitIds.size(); i++) {
|
|
|
|
+ Long unitId = unitIds.getLong(i);
|
|
|
|
+ if (!Check.isNull(unitId)) {
|
|
|
|
+ Map<String, Object> updateMap = updateService.updateUnitBid(token.getAccessToken(), accountId, unitId, bid, userId);
|
|
|
|
+ if (!Check.isNull(updateMap)) {
|
|
|
|
+ Integer code = (Integer) updateMap.get("code");
|
|
|
|
+ if (code != 0) {
|
|
|
|
+ JSONObject failJson = new JSONObject();
|
|
|
|
+ failJson.put("message", updateMap.get("message"));
|
|
|
|
+ KuaiShouGroup group = batchService.getUnitInfo(accountId, unitId);
|
|
|
|
+ if (!Check.isNull(group)) {
|
|
|
|
+ failJson.put("campaignName", group.getUnitName());
|
|
|
|
+ }
|
|
|
|
+ failArr.add(failJson);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ json.put("totalCount", unitIds.size());
|
|
|
|
+ json.put("failCount", failArr.size());
|
|
|
|
+ json.put("failInfo", failArr);
|
|
|
|
+ result.setResult(json);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取封面列表
|
|
|
|
+ *
|
|
|
|
+ * @param kuaiShouImageGet
|
|
|
|
+ * @param req
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/getImageList")
|
|
|
|
+ public Result<IPage<KuaiShouImageGet>> getImageList(KuaiShouImageGet kuaiShouImageGet, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
|
|
|
+ Result<IPage<KuaiShouImageGet>> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ QueryWrapper<KuaiShouImageGet> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouImageGet, req.getParameterMap());
|
|
|
|
+ queryWrapper.orderByDesc("create_time");
|
|
|
|
+ Page<KuaiShouImageGet> page = new Page<>(pageNo, pageSize);
|
|
|
|
+ IPage<KuaiShouImageGet> pageList = kuaiShouImageGetService.page(page, queryWrapper);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(pageList);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取视频列表
|
|
|
|
+ *
|
|
|
|
+ * @param kuaiShouVideoGet
|
|
|
|
+ * @param req
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/getVideoList")
|
|
|
|
+ public Result<IPage<KuaiShouVideoGet>> getVideoList(KuaiShouVideoGet kuaiShouVideoGet, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
|
|
|
+ Result<IPage<KuaiShouVideoGet>> result = new Result<IPage<KuaiShouVideoGet>>();
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ QueryWrapper<KuaiShouVideoGet> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouVideoGet, req.getParameterMap());
|
|
|
|
+ queryWrapper.orderByDesc("create_time");
|
|
|
|
+ Page<KuaiShouVideoGet> page = new Page<KuaiShouVideoGet>(pageNo, pageSize);
|
|
|
|
+ IPage<KuaiShouVideoGet> pageList = kuaiShouVideoGetService.page(page, queryWrapper);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(pageList);
|
|
|
|
+ return result;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取素材信息
|
|
|
|
+ *
|
|
|
|
+ * @param code
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/getCreativeCopywriter")
|
|
|
|
+ public Result<MaterialInfo> getVideoList(String code) {
|
|
|
|
+ Result<MaterialInfo> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ QueryWrapper<MaterialInfo> materialInfoQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ materialInfoQueryWrapper.eq("code", code);
|
|
|
|
+ materialInfoQueryWrapper.last("limit 1");
|
|
|
|
+ MaterialInfo materialInfo = materialInfoMapper.selectOne(materialInfoQueryWrapper);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(materialInfo);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取行动号召按钮
|
|
|
|
+ *
|
|
|
|
+ * @param campaignId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/getActionBarText")
|
|
|
|
+ public Result<List<KuaiShouActionBarText>> queryPageList(String campaignId) {
|
|
|
|
+ Result<List<KuaiShouActionBarText>> result = new Result<>();
|
|
|
|
+ QueryWrapper<KuaiShouCampaign> wrapper = new QueryWrapper<>();
|
|
|
|
+ wrapper.eq("campaign_id", campaignId);
|
|
|
|
+ wrapper.orderByDesc("create_time");
|
|
|
|
+ wrapper.last("limit 1");
|
|
|
|
+ KuaiShouCampaign campaign = campaignMapper.selectOne(wrapper);
|
|
|
|
+ if (!Check.isNull(campaignId)) {
|
|
|
|
+ QueryWrapper<KuaiShouActionBarText> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("type", campaign.getCampaignType());
|
|
|
|
+ List<KuaiShouActionBarText> list = actionBarTextService.list(queryWrapper);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(list);
|
|
|
|
+ } else {
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage("未获取到广告计划信息");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 创建创意
|
|
|
|
+ *
|
|
|
|
+ * @param requestJson
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/createCreative")
|
|
|
|
+ public Result<JSONObject> createCreative(@RequestBody JSONObject requestJson) {
|
|
|
|
+ Result<JSONObject> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ JSONObject creativeJson = batchService.createCreative(requestJson);
|
|
|
|
+ result.setResult(creativeJson);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量修改广告组状态
|
|
|
|
+ *
|
|
|
|
+ * @param requestJson
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/batchUpdateCreativeStatus")
|
|
|
|
+ public Result<JSONObject> batchUpdateCreativeStatus(@RequestBody JSONObject requestJson) {
|
|
|
|
+ Result<JSONObject> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+ Long accountId = requestJson.getLong("accountId");
|
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if (Check.isNull(token)) {
|
|
|
|
+ throw new Exception("账号信息为空");
|
|
|
|
+ }
|
|
|
|
+ Integer putStatus = requestJson.getInteger("putStatus");
|
|
|
|
+ if (putStatus == null) {
|
|
|
|
+ throw new Exception("请选择状态");
|
|
|
|
+ }
|
|
|
|
+ String userId = requestJson.getString("userId");
|
|
|
|
+ JSONArray creativeIds = requestJson.getJSONArray("creativeIds");
|
|
|
|
+ JSONArray failArr = new JSONArray();
|
|
|
|
+ if (!Check.isNull(creativeIds)) {
|
|
|
|
+ for (int i = 0; i < creativeIds.size(); i++) {
|
|
|
|
+ Long creativeId = creativeIds.getLong(i);
|
|
|
|
+ if (!Check.isNull(creativeId)) {
|
|
|
|
+ Map<String, Object> updateMap = updateService.updateCreativeStatus(token.getAccessToken(), accountId, creativeId, putStatus, userId);
|
|
|
|
+ if (!Check.isNull(updateMap)) {
|
|
|
|
+ Integer code = (Integer) updateMap.get("code");
|
|
|
|
+ if (code != 0) {
|
|
|
|
+ JSONObject failJson = new JSONObject();
|
|
|
|
+ failJson.put("message", updateMap.get("message"));
|
|
|
|
+ KuaiShouCreative creative = batchService.getCreativeInfo(accountId, creativeId);
|
|
|
|
+ if (!Check.isNull(creative)) {
|
|
|
|
+ failJson.put("campaignName", creative.getCreativeName());
|
|
|
|
+ }
|
|
|
|
+ failArr.add(failJson);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ json.put("totalCount", creativeIds.size());
|
|
|
|
+ json.put("failCount", failArr.size());
|
|
|
|
+ json.put("failInfo", failArr);
|
|
|
|
+ result.setResult(json);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|