yumeng 5 gadi atpakaļ
vecāks
revīzija
1c5382a240

+ 47 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -8,7 +8,9 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.SpendVo;
 import cn.com.ctop.kuaishou.modules.batch.service.IBatchService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -18,10 +20,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
@@ -39,6 +38,10 @@ public class BatchController {
     private IBatchService batchService;
     @Autowired
     private IKuaiShouCampaignService kuaiShouCampaignService;
+    @Autowired
+    private IKuaiShouUpdateService updateService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
 
 
     /**
@@ -103,4 +106,44 @@ public class BatchController {
     }
 
 
+    /**
+     * 批量修改广告计划预算
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchUpdateDayBudget")
+    public Result<JSONObject> batchUpdateDayBudget(@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 campaignIds = requestJson.getJSONArray("campaignIds");
+            if (!Check.isNull(campaignIds)) {
+                for (int i = 0; i < campaignIds.size(); i++) {
+                    Long campaignId = campaignIds.getLong(i);
+                    if (!Check.isNull(campaignId)) {
+                        updateService.updateCampaign(token.getAccessToken(), accountId, campaignId, dayBudget, userId);
+                    }
+                }
+            }
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
 }