Browse Source

Merge remote-tracking branch 'origin/test' into test

xuzuoyun 5 years ago
parent
commit
03d5dc9f14
30 changed files with 1429 additions and 106 deletions
  1. 38 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  2. 41 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/DailyFlowsJob.java
  3. 12 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouMaterialsLoadJob.java
  4. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  5. 10 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  6. 14 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  7. 60 54
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/service/impl/KuaishouAppServiceImpl.java
  8. 106 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  9. 23 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java
  10. 248 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouDailyFlowsController.java
  11. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/UpdateController.java
  12. 36 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCampaign.java
  13. 125 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouDailyFlows.java
  14. 7 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouImageGet.java
  15. 33 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/vo/SpendVo.java
  16. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/BatchMapper.java
  17. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouDailyFlowsMapper.java
  18. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouImageGetMapper.java
  19. 46 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/BatchMapper.xml
  20. 10 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml
  21. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouDailyFlowsMapper.xml
  22. 31 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouImageGetMapper.xml
  23. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java
  24. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouDailyFlowsService.java
  25. 5 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouImageGetService.java
  26. 45 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  27. 48 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  28. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouDailyFlowsServiceImpl.java
  29. 13 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouImageGetServiceImpl.java
  30. 371 26
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

+ 38 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.IUserAllocationService;
@@ -58,6 +59,8 @@ public class UserAllocationController {
     private UserAllocationMapper userAllocationMapper;
     @Autowired
     private IProjectService projectService;
+    @Autowired
+    private MaterialReportMapper materialReportMapper;
 
 
     @GetMapping(value = "/getAccountList")
@@ -86,6 +89,41 @@ public class UserAllocationController {
     }
 
 
+    @GetMapping(value = "/getAccountsByProjectId")
+    public Result<List<UserAllocation>> getAccountsByProjectId(String userId, Long projectId) {
+        Result<List<UserAllocation>> result = new Result<>();
+        try {
+            QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("project_id", projectId);
+            Project project = projectService.getById(projectId);
+            if (!Check.isNull(project)) {
+                queryWrapper.eq("media_id", project.getMediaId());
+            }
+
+            String roleCode = materialReportMapper.getRoleCodeByUserId(userId);
+            if (!"admin".equals(roleCode) && !"kuaishouOperationManager".equals(roleCode)) {
+                queryWrapper.eq("user_id", userId);
+            }
+
+            List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
+            result.setSuccess(true);
+            result.setResult(userAllocations);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.success("查询失败");
+        }
+
+        return result;
+
+    }
+
+
+    /**
+     * 统计报表 查看所有账号
+     *
+     * @param projectId
+     * @return
+     */
     @GetMapping(value = "/getAccountListByProjectId")
     public Result<List<UserAllocation>> getAccountListByProjectId(Long projectId) {
         Result<List<UserAllocation>> result = new Result<>();
@@ -97,7 +135,6 @@ public class UserAllocationController {
             if (!Check.isNull(project)) {
                 queryWrapper.eq("media_id", project.getMediaId());
             }
-
             List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
             result.setSuccess(true);
             result.setResult(userAllocations);

+ 41 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/DailyFlowsJob.java

@@ -0,0 +1,41 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+public class DailyFlowsJob implements Job {
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private CtopOauthTokenMapper oauthTokenMapper;
+
+    /**
+     * 刷新token
+     *
+     * @param jobExecutionContext
+     * @throws JobExecutionException
+     */
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) {
+        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("media_id", "2");
+        queryWrapper.groupBy("account_id");
+        List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(queryWrapper);
+        if (!Check.isNull(ctopOauthTokens)) {
+            for (CtopOauthToken ctopOauthToken : ctopOauthTokens) {
+                kuaishouInterfaceService.getDailyFlows(ctopOauthToken);
+            }
+
+        }
+
+    }
+}

+ 12 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouMaterialsLoadJob.java

@@ -5,11 +5,13 @@ import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.Date;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -25,6 +27,10 @@ public class KuaishouMaterialsLoadJob implements Job {
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        //增加接口的开始和结束日期
+        Date startDate = DateUtils.addDay(new Date(),-1);
+        Date endDate = new Date();
+
         //1:查询当日数据
         List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
 
@@ -35,14 +41,15 @@ public class KuaishouMaterialsLoadJob implements Job {
                 public void run() {
                     try {
                         //1:获取全量广告计划数据
-                        kuaishouInterfaceService.getCampaignList(token);
+                        kuaishouInterfaceService.getCampaignList(token,startDate,endDate);
                         //1:获取全量广告组数据
-                        kuaishouInterfaceService.getGroupList(token);
+                        kuaishouInterfaceService.getGroupList(token,startDate,endDate);
                         //1:获取全量创意数据
-                        kuaishouInterfaceService.getCreativeList(token);
+                        kuaishouInterfaceService.getCreativeList(token,startDate,endDate);
                         //2:获取全量视频素材数据
-                        kuaishouInterfaceService.getVideoList(token);
-
+                        kuaishouInterfaceService.getVideoList(token,startDate,endDate);
+                        //3: 获取图片信息数据
+                        kuaishouInterfaceService.getImageList(token,startDate,endDate);
                     } catch (Exception e) {
                         e.printStackTrace();
                     } finally {

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java

@@ -16,6 +16,8 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
 
     CtopOauthToken getOauthTokenByAccountId(String accountId);
 
+    CtopOauthToken getTokenByAccountId(Long accountId);
+
     Map<String, Object> getByteDanceAccessToken(String accountId);
 
     Map<String, Object> getKuaiShouRefreshToken(Long accountId, String refreshToken);

+ 10 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -39,6 +39,16 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
         return cTopOauthToken;
     }
 
+
+    @Override
+    public CtopOauthToken getTokenByAccountId(Long accountId) {
+        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId).orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        CtopOauthToken cTopOauthToken = cTopOauthTokenMapper.selectOne(queryWrapper);
+        return cTopOauthToken;
+    }
+
     /**
      * 刷新token
      *

+ 14 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -84,6 +84,16 @@ public class KuaishouInterfaceConstant {
      */
     public static final String APP_LIST = "/rest/openapi/v1/file/ad/app/list";
 
+    /**
+     * 获取账户余额
+     */
+    public static final String FUND_GET = "/rest/openapi/v1/advertiser/fund/get";
+
+    /**
+     * 获取账户流水数据
+     */
+    public static final String DAILY_FLOWS = "/rest/openapi/v1/advertiser/fund/daily_flows";
+
 
     /**
      * 修改广告计划预算
@@ -126,6 +136,10 @@ public class KuaishouInterfaceConstant {
      */
     public static final String UPDATE_CREATIVE = "/rest/openapi/v2/creative/update";
 
+    /**
+     * 快手-查询图片列表
+     */
+    public static final String IMAGE_LIST = "/rest/openapi/v1/file/ad/image/list";
 
     /**
      * 登录

+ 60 - 54
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/service/impl/KuaishouAppServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.app.service.impl;
 
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.crawler.modules.account.entity.KuaishouAdAccount;
 import cn.com.ctop.crawler.modules.account.entity.KuaishouAppAccount;
 import cn.com.ctop.crawler.modules.account.entity.KuaishouIosAccount;
@@ -40,48 +41,50 @@ public class KuaishouAppServiceImpl implements IKuaishouAppService {
 
     @Override
     public void adFetch(KuaishouAppAccount kuaishouAppAccount, Integer page) {
-        String videoFeeds = kuaishouCrawlerService.getVideoFeeds(kuaishouAppAccount,page);
+        String videoFeeds = kuaishouCrawlerService.getVideoFeeds(kuaishouAppAccount, page);
         ObjectMapper mapper = new ObjectMapper();
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         try {
-            AppResult appResult = mapper.readValue(videoFeeds,new TypeReference<AppResult>(){});
-            if(appResult != null){
-                for(AppFeeds appFeeds : appResult.getFeeds()){
-                    AppAd ad = appFeeds.getAd();
-
-                    if(ad != null){
-                        if (ad.getAdCover() == null ){
-                            continue;
-                        }
-                        ad.setTime(appFeeds.getTime());
-                        ad.setCoverUrl(ad.getAdCover().getCoverUrls().get(0).getUrl().replace(".kpg",".jpg"));
-                        ad.setMvUrl(appFeeds.getMainMvUrls().get(0).getUrl());
-                        ad.setRecoReason(appFeeds.getRecoReason());
-                        ad.setUserId(appFeeds.getUserId());
-                        ad.setPageId(appFeeds.getPhotoId());
-                        ad.setPhotoId(appFeeds.getPhotoId());
-                        ad.setUserName(appFeeds.getUserName());
-                        ad.setPhotoStatus(appFeeds.getPhotoStatus());
-                        ad.setShareInfo(appFeeds.getShareInfo());
-                        ad.setViewCount(appFeeds.getViewCount());
-                        ad.setLikeCount(appFeeds.getLikeCount());
-                        ad.setCommentCount(appFeeds.getCommentCount());
-                        ad.setForwardCount(appFeeds.getForwardCount());
-                        ad.setUnlikeCount(appFeeds.getUnlikeCount());
-                        ad.setCaption(appFeeds.getCaption());
-                        ad.setWidth(ad.getAdCover().getWidth());
-                        ad.setHeight(ad.getAdCover().getHeight());
-                        ad.setType(appFeeds.getType());
-                        appAdService.saveOrUpdate(ad);
-                        try {
-                            KuaishouAdAccount kuaishouAdAccount = kuaishouAdAccountService.getById(ad.getUserId());
-                            if (kuaishouAdAccount == null){
-                                kuaishouAdAccount = new KuaishouAdAccount();
-                                kuaishouAdAccount.setKsid(ad.getUserId());
-                                kuaishouAdAccount.setName(ad.getUserName());
-                                kuaishouAdAccountService.save(kuaishouAdAccount);
-                                this.adAccountFetch(kuaishouAdAccount, "");
+            AppResult appResult = mapper.readValue(videoFeeds, new TypeReference<AppResult>() {
+            });
+            if (appResult != null) {
+                List<AppFeeds> feeds = appResult.getFeeds();
+                if (!Check.isNull(feeds)) {
+                    for (AppFeeds appFeeds : feeds) {
+                        AppAd ad = appFeeds.getAd();
+                        if (ad != null) {
+                            if (ad.getAdCover() == null) {
+                                continue;
                             }
+                            ad.setTime(appFeeds.getTime());
+                            ad.setCoverUrl(ad.getAdCover().getCoverUrls().get(0).getUrl().replace(".kpg", ".jpg"));
+                            ad.setMvUrl(appFeeds.getMainMvUrls().get(0).getUrl());
+                            ad.setRecoReason(appFeeds.getRecoReason());
+                            ad.setUserId(appFeeds.getUserId());
+                            ad.setPageId(appFeeds.getPhotoId());
+                            ad.setPhotoId(appFeeds.getPhotoId());
+                            ad.setUserName(appFeeds.getUserName());
+                            ad.setPhotoStatus(appFeeds.getPhotoStatus());
+                            ad.setShareInfo(appFeeds.getShareInfo());
+                            ad.setViewCount(appFeeds.getViewCount());
+                            ad.setLikeCount(appFeeds.getLikeCount());
+                            ad.setCommentCount(appFeeds.getCommentCount());
+                            ad.setForwardCount(appFeeds.getForwardCount());
+                            ad.setUnlikeCount(appFeeds.getUnlikeCount());
+                            ad.setCaption(appFeeds.getCaption());
+                            ad.setWidth(ad.getAdCover().getWidth());
+                            ad.setHeight(ad.getAdCover().getHeight());
+                            ad.setType(appFeeds.getType());
+                            appAdService.saveOrUpdate(ad);
+                            try {
+                                KuaishouAdAccount kuaishouAdAccount = kuaishouAdAccountService.getById(ad.getUserId());
+                                if (kuaishouAdAccount == null) {
+                                    kuaishouAdAccount = new KuaishouAdAccount();
+                                    kuaishouAdAccount.setKsid(ad.getUserId());
+                                    kuaishouAdAccount.setName(ad.getUserName());
+                                    kuaishouAdAccountService.save(kuaishouAdAccount);
+                                    this.adAccountFetch(kuaishouAdAccount, "");
+                                }
 //                            AppVideo video = appVideoService.getById(ad.getPhotoId());
 
 //                            AppVideo video = new AppVideo();
@@ -89,8 +92,9 @@ public class KuaishouAppServiceImpl implements IKuaishouAppService {
 //                            video.setPhotoId();
 //                            video.setMvUrl();
 //                            video.setCoverUrl();
-                        } catch (Exception e) {
-                            e.printStackTrace();
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
                         }
                     }
                 }
@@ -117,14 +121,15 @@ public class KuaishouAppServiceImpl implements IKuaishouAppService {
             }
             String adAccountVideoFeeds = kuaishouCrawlerService.getAdAccountVideoFeeds(kuaishouAdAccount, pcursor);
             JsonNode node = mapper.readTree(adAccountVideoFeeds);
-            List<AppVideo> list = mapper.readValue(node.get("feeds").toString(),new TypeReference<List<AppVideo>>(){});
+            List<AppVideo> list = mapper.readValue(node.get("feeds").toString(), new TypeReference<List<AppVideo>>() {
+            });
             pcursor = node.get("pcursor").asText();
-            if(list != null){
-                for(AppVideo appVideo : list){
-                    if(appVideo.getCoverThumbnailUrls() != null){
+            if (list != null) {
+                for (AppVideo appVideo : list) {
+                    if (appVideo.getCoverThumbnailUrls() != null) {
                         appVideo.setCoverUrl(appVideo.getCoverThumbnailUrls().get(0).getUrl());
                     }
-                    if(appVideo.getMainMvUrls() != null){
+                    if (appVideo.getMainMvUrls() != null) {
                         appVideo.setMvUrl(appVideo.getMainMvUrls().get(0).getUrl());
                     }
 
@@ -133,7 +138,7 @@ public class KuaishouAppServiceImpl implements IKuaishouAppService {
             }
             Thread.sleep(10000);
             if (pcursor != null && !"no_more".equals(pcursor)) {
-                adAccountFetch(kuaishouAdAccount,pcursor);
+                adAccountFetch(kuaishouAdAccount, pcursor);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -141,21 +146,22 @@ public class KuaishouAppServiceImpl implements IKuaishouAppService {
     }
 
     @Override
-    public void adFetch(KuaishouIosAccount kuaishouIosAccount){
+    public void adFetch(KuaishouIosAccount kuaishouIosAccount) {
         String videoFeeds = kuaishouCrawlerService.getVideoFeeds(kuaishouIosAccount);
         ObjectMapper mapper = new ObjectMapper();
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         try {
-            AppResult appResult = mapper.readValue(videoFeeds,new TypeReference<AppResult>(){});
-            if(appResult != null && appResult.getFeeds() != null){
-                for(AppFeeds appFeeds : appResult.getFeeds()){
+            AppResult appResult = mapper.readValue(videoFeeds, new TypeReference<AppResult>() {
+            });
+            if (appResult != null && appResult.getFeeds() != null) {
+                for (AppFeeds appFeeds : appResult.getFeeds()) {
                     AppAd ad = appFeeds.getAd();
-                    if(ad != null){
-                        if (ad.getAdCover() == null ){
+                    if (ad != null) {
+                        if (ad.getAdCover() == null) {
                             continue;
                         }
                         ad.setTime(appFeeds.getTime());
-                        ad.setCoverUrl(ad.getAdCover().getCoverUrls().get(0).getUrl().replace(".kpg",".jpg"));
+                        ad.setCoverUrl(ad.getAdCover().getCoverUrls().get(0).getUrl().replace(".kpg", ".jpg"));
                         ad.setMvUrl(appFeeds.getMainMvUrls().get(0).getUrl());
                         ad.setRecoReason(appFeeds.getRecoReason());
                         ad.setUserId(appFeeds.getUserId());
@@ -176,7 +182,7 @@ public class KuaishouAppServiceImpl implements IKuaishouAppService {
                         appAdService.saveOrUpdate(ad);
                         try {
                             KuaishouAdAccount kuaishouAdAccount = kuaishouAdAccountService.getById(ad.getUserId());
-                            if (kuaishouAdAccount == null){
+                            if (kuaishouAdAccount == null) {
                                 kuaishouAdAccount = new KuaishouAdAccount();
                                 kuaishouAdAccount.setKsid(ad.getUserId());
                                 kuaishouAdAccount.setName(ad.getUserName());

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

@@ -0,0 +1,106 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+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.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.IKuaishouInterfaceService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+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 javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+
+@Slf4j
+@Api(tags = "快手-批量工具")
+@RestController
+@RequestMapping("/kuaishou/batch")
+public class BatchController {
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    private IKuaishouInterfaceService iKuaishouInterfaceService;
+    @Autowired
+    private IBatchService batchService;
+    @Autowired
+    private IKuaiShouCampaignService kuaiShouCampaignService;
+
+
+    /**
+     * 获取花费信息
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/spend")
+    public Result<SpendVo> spend(Long accountId) {
+        Result<SpendVo> result = new Result<>();
+        try {
+
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            SpendVo spendVo = new SpendVo();
+            JSONObject fundJson = iKuaishouInterfaceService.fundGet(oauthToken);
+            if (!Check.isNull(fundJson)) {
+                spendVo.setBalance(fundJson.getBigDecimal("balance")); // 余额
+            }
+            BigDecimal cost = batchService.getCost(accountId);
+            spendVo.setCost(cost);
+
+            BigDecimal budget = batchService.getBudget(accountId);
+            spendVo.setBudget(budget);
+            result.setSuccess(true);
+            result.setResult(spendVo);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 获取广告计划列表
+     *
+     * @param kuaiShouCampaign
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @GetMapping(value = "/getCampaignList")
+    public Result<IPage<KuaiShouCampaign>> getCampaignList(KuaiShouCampaign kuaiShouCampaign,
+                                                           @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                           HttpServletRequest req) {
+        Result<IPage<KuaiShouCampaign>> result = new Result<IPage<KuaiShouCampaign>>();
+        QueryWrapper<KuaiShouCampaign> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouCampaign, req.getParameterMap());
+        Page<KuaiShouCampaign> page = new Page<KuaiShouCampaign>(pageNo, pageSize);
+        IPage<KuaiShouCampaign> pageList = kuaiShouCampaignService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+
+}

+ 23 - 9
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java

@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.utils.LoadFileUtil;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -17,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -92,25 +94,25 @@ public class KuaiShouController {
 
     @RequestMapping("/getCampaignList")
     public void getCampaignList() {
-        String accessToken = "f60f51a8f7d8938d6147d38357fed70c";
-        Long advertiserId = 23212L;
-        kuaishouInterfaceService.getCampaignList(accessToken, advertiserId, 1);
+        String accessToken = "18cf38d50da314dcbd9cb6db9c43bcbf";
+        Long advertiserId = 1595407L;
+        kuaishouInterfaceService.getCampaignList(accessToken, advertiserId, DateUtils.addDay(new Date(),-1), new Date(), 1);
 
     }
 
     @RequestMapping("/getGroupList")
     public void getGroupList() {
-        String accessToken = "f60f51a8f7d8938d6147d38357fed70c";
-        Long advertiserId = 23212L;
-        kuaishouInterfaceService.getGroupList(accessToken, advertiserId, 1);
+        String accessToken = "604d2f2ffe5573c3500ffee358ba9b3c";
+        Long advertiserId = 1595407L;
+        kuaishouInterfaceService.getGroupList(accessToken, advertiserId, DateUtils.addDay(new Date(),-1), new Date(), 1);
 
     }
 
     @RequestMapping("/getCreativeList")
     public void getCreativeList() {
-        String accessToken = "cbe9caeffcc2c5ccd97a05bf909896da";
-        Long advertiserId = 23212L;
-        kuaishouInterfaceService.getCreativeList(accessToken, advertiserId, 1);
+        String accessToken = "604d2f2ffe5573c3500ffee358ba9b3c";
+        Long advertiserId = 1595407L;
+        kuaishouInterfaceService.getCreativeList(accessToken, advertiserId, DateUtils.addDay(new Date(),-1), new Date(), 1);
     }
 
     @RequestMapping("/getDeepConversionInfos")
@@ -233,6 +235,18 @@ public class KuaiShouController {
         kuaishouInterfaceService.advertiserInfo(23212L, "10b6ad966b7e958d1510a78a5315ec5c");
     }
 
+    @RequestMapping("getImageList")
+    public void getImageList() {
+        String accessToken = "604d2f2ffe5573c3500ffee358ba9b3c";
+        Long advertiserId = 1595407L;
+        kuaishouInterfaceService.getImageList(accessToken, advertiserId, new Date(), new Date(), 1);
+    }
 
+    @RequestMapping("getVideoList")
+    public void getVideoList() {
+        String accessToken = "e8959cf08e59e78b91b22aa4ed593c00";
+        Long advertiserId = 1022694L;
+        kuaishouInterfaceService.getVideoList(accessToken, advertiserId, DateUtils.addDay(new Date(),-1), new Date(), 1);
+    }
 
 }

+ 248 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouDailyFlowsController.java

@@ -0,0 +1,248 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouDailyFlows;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyFlowsService;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 快手-日流水信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-05
+ */
+@Slf4j
+@Api(tags = "快手-日流水信息")
+@RestController
+@RequestMapping("/ctop/kuaiShouDailyFlows")
+public class KuaiShouDailyFlowsController {
+    @Autowired
+    private IKuaiShouDailyFlowsService kuaiShouDailyFlowsService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaiShouDailyFlows
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "快手-日流水信息-分页列表查询")
+    @ApiOperation(value = "快手-日流水信息-分页列表查询", notes = "快手-日流水信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaiShouDailyFlows>> queryPageList(KuaiShouDailyFlows kuaiShouDailyFlows,
+                                                           @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                           HttpServletRequest req) {
+        Result<IPage<KuaiShouDailyFlows>> result = new Result<IPage<KuaiShouDailyFlows>>();
+        QueryWrapper<KuaiShouDailyFlows> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouDailyFlows, req.getParameterMap());
+        Page<KuaiShouDailyFlows> page = new Page<KuaiShouDailyFlows>(pageNo, pageSize);
+        IPage<KuaiShouDailyFlows> pageList = kuaiShouDailyFlowsService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaiShouDailyFlows
+     * @return
+     */
+    @AutoLog(value = "快手-日流水信息-添加")
+    @ApiOperation(value = "快手-日流水信息-添加", notes = "快手-日流水信息-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaiShouDailyFlows> add(@RequestBody KuaiShouDailyFlows kuaiShouDailyFlows) {
+        Result<KuaiShouDailyFlows> result = new Result<KuaiShouDailyFlows>();
+        try {
+            kuaiShouDailyFlowsService.save(kuaiShouDailyFlows);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaiShouDailyFlows
+     * @return
+     */
+    @AutoLog(value = "快手-日流水信息-编辑")
+    @ApiOperation(value = "快手-日流水信息-编辑", notes = "快手-日流水信息-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaiShouDailyFlows> edit(@RequestBody KuaiShouDailyFlows kuaiShouDailyFlows) {
+        Result<KuaiShouDailyFlows> result = new Result<KuaiShouDailyFlows>();
+        KuaiShouDailyFlows kuaiShouDailyFlowsEntity = kuaiShouDailyFlowsService.getById(kuaiShouDailyFlows.getId());
+        if (kuaiShouDailyFlowsEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaiShouDailyFlowsService.updateById(kuaiShouDailyFlows);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "快手-日流水信息-通过id删除")
+    @ApiOperation(value = "快手-日流水信息-通过id删除", notes = "快手-日流水信息-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaiShouDailyFlowsService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "快手-日流水信息-批量删除")
+    @ApiOperation(value = "快手-日流水信息-批量删除", notes = "快手-日流水信息-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaiShouDailyFlows> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaiShouDailyFlows> result = new Result<KuaiShouDailyFlows>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaiShouDailyFlowsService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "快手-日流水信息-通过id查询")
+    @ApiOperation(value = "快手-日流水信息-通过id查询", notes = "快手-日流水信息-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaiShouDailyFlows> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaiShouDailyFlows> result = new Result<KuaiShouDailyFlows>();
+        KuaiShouDailyFlows kuaiShouDailyFlows = kuaiShouDailyFlowsService.getById(id);
+        if (kuaiShouDailyFlows == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaiShouDailyFlows);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaiShouDailyFlows> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaiShouDailyFlows kuaiShouDailyFlows = JSON.parseObject(deString, KuaiShouDailyFlows.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouDailyFlows, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaiShouDailyFlows> pageList = kuaiShouDailyFlowsService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "快手-日流水信息列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaiShouDailyFlows.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("快手-日流水信息列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaiShouDailyFlows> listKuaiShouDailyFlowss = ExcelImportUtil.importExcel(file.getInputStream(), KuaiShouDailyFlows.class, params);
+                kuaiShouDailyFlowsService.saveBatch(listKuaiShouDailyFlowss);
+                return Result.ok("文件导入成功!数据行数:" + listKuaiShouDailyFlowss.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 13 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/UpdateController.java

@@ -0,0 +1,13 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@Api(tags = "快手-修改接口")
+@RestController
+@RequestMapping("/kuaishou/batch")
+public class UpdateController {
+}

+ 36 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCampaign.java

@@ -56,12 +56,48 @@ public class KuaiShouCampaign {
     @Excel(name = "状态", width = 15)
     @ApiModelProperty(value = "状态")
     private Integer status;
+
+
+    /**
+     * 广告计划类型
+     */
+    @Excel(name = "广告计划类型", width = 15)
+    @ApiModelProperty(value = "1:投放中;2:暂停")
+    private Integer campaignType;
+
+    /**
+     * 创建渠道
+     */
+    @Excel(name = "创建渠道", width = 15)
+    @ApiModelProperty(value = "0:投放后台创建;1:Marketing API创建")
+    private Integer createChannel;
+
+    /**
+     * 投放状态
+     */
+    @Excel(name = "投放状态", width = 15)
+    @ApiModelProperty(value = "1:投放中;2:暂停")
+    private Integer putStatus;
+
+
     /**
      * 每日预算
      */
     @Excel(name = "每日预算", width = 15)
     @ApiModelProperty(value = "每日预算")
     private Long dayBudget;
+
+
+    @Excel(name = "广告投放时间", width = 15)
+    @ApiModelProperty(value = "广告投放时间")
+    private String putCreateTime;
+
+
+    @Excel(name = "广告修改时间", width = 15)
+    @ApiModelProperty(value = "广告投放时间")
+    private String putUpdateTime;
+
+
     /**
      * 创建时间
      */

+ 125 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouDailyFlows.java

@@ -0,0 +1,125 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 快手-日流水信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-05
+ */
+@Data
+@TableName("ctop_kuaishou_daily_flows")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_daily_flows对象", description = "快手-日流水信息")
+public class KuaiShouDailyFlows {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private String date;
+    /**
+     * 总花费(元)
+     */
+    @Excel(name = "总花费(元)", width = 15)
+    @ApiModelProperty(value = "总花费(元)")
+    private java.math.BigDecimal dailyCharge;
+    /**
+     * 充值话费(元)
+     */
+    @Excel(name = "充值话费(元)", width = 15)
+    @ApiModelProperty(value = "充值话费(元)")
+    private java.math.BigDecimal realCharged;
+    /**
+     * 框返花费(元)
+     */
+    @Excel(name = "框返花费(元)", width = 15)
+    @ApiModelProperty(value = "框返花费(元)")
+    private java.math.BigDecimal contractRebateRealCharged;
+    /**
+     * 激励花费(元)
+     */
+    @Excel(name = "激励花费(元)", width = 15)
+    @ApiModelProperty(value = "激励花费(元)")
+    private java.math.BigDecimal directRebateRealCharged;
+    /**
+     * 转入(元)
+     */
+    @Excel(name = "转入(元)", width = 15)
+    @ApiModelProperty(value = "转入(元)")
+    private java.math.BigDecimal dailyTransferIn;
+    /**
+     * 转出(元)
+     */
+    @Excel(name = "转出(元)", width = 15)
+    @ApiModelProperty(value = "转出(元)")
+    private java.math.BigDecimal dailyTransferOut;
+    /**
+     * 日终结余(元)
+     */
+    @Excel(name = "日终结余(元)", width = 15)
+    @ApiModelProperty(value = "日终结余(元)")
+    private java.math.BigDecimal balance;
+    /**
+     * 充值转入(元)
+     */
+    @Excel(name = "充值转入(元)", width = 15)
+    @ApiModelProperty(value = "充值转入(元)")
+    private java.math.BigDecimal realRecharged;
+    /**
+     * 框返转入(元)
+     */
+    @Excel(name = "框返转入(元)", width = 15)
+    @ApiModelProperty(value = "框返转入(元)")
+    private java.math.BigDecimal contractRebateRealRecharged;
+    /**
+     * 激励转入(元)
+     */
+    @Excel(name = "激励转入(元)", width = 15)
+    @ApiModelProperty(value = "激励转入(元)")
+    private java.math.BigDecimal directRebateRealRecharged;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 7 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouImageGet.java

@@ -69,7 +69,7 @@ public class KuaiShouImageGet {
     @Excel(name = "图片格式", width = 15)
     @ApiModelProperty(value = "图片格式")
     private String format;
-    private String signature;
+
     /**
      * 图片 token
      */
@@ -77,6 +77,12 @@ public class KuaiShouImageGet {
     @ApiModelProperty(value = "图片 token")
     private Object imageToken;
     /**
+     * 图片 md5
+     */
+    @Excel(name = "图片 md5", width = 15)
+    @ApiModelProperty(value = "图片 md5")
+    private String signature;
+    /**
      * 创建时间
      */
     @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")

+ 33 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/vo/SpendVo.java

@@ -0,0 +1,33 @@
+package cn.com.ctop.kuaishou.modules.batch.entity.vo;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.math.BigDecimal;
+
+/**
+ * @Description: 快手-视频上传
+ * @Author: jeecg-boot
+ * @Date: 2019-07-26
+ * @Version: V1.0
+ */
+@Data
+
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class SpendVo {
+
+    /**
+     * 总花费
+     */
+    private BigDecimal cost;
+    /**
+     * 预算
+     */
+    private BigDecimal budget;
+    /**
+     * 余额
+     */
+    private BigDecimal balance;
+}

+ 13 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/BatchMapper.java

@@ -0,0 +1,13 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+
+public interface BatchMapper {
+    BigDecimal getDailyCost(@Param("accountId") Long accountId);
+
+    BigDecimal getHourCost(@Param("accountId") Long accountId, @Param("statDate") String statDate);
+
+    BigDecimal getBudget(@Param("accountId") Long accountId);
+}

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouDailyFlowsMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouDailyFlows;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手-日流水信息
+ *
+ * @author: jeecg-boot
+ * @date: 2019-12-05
+ * @cersion: V1.0
+ */
+public interface KuaiShouDailyFlowsMapper extends BaseMapper<KuaiShouDailyFlows> {
+
+}

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouImageGetMapper.java

@@ -2,6 +2,9 @@ package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * @Description: 快手-获取图片接口
@@ -11,4 +14,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface KuaiShouImageGetMapper extends BaseMapper<KuaiShouImageGet> {
 
+    void replaceBatch(@Param(value = "images")List<KuaiShouImageGet>imagesGets);
 }

+ 46 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/BatchMapper.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.batch.mapper.BatchMapper">
+
+    <select id="getDailyCost" resultType="java.math.BigDecimal">
+      select
+      (case
+        when sum(charge) != ''
+        then sum(charge)
+        else 0
+        end
+        )
+      from ctop_kuaishou_report_daily_account
+      where account_id = #{accountId}
+    </select>
+
+
+    <select id="getHourCost" resultType="java.math.BigDecimal">
+      select
+      (case
+        when sum(charge) != ''
+        then sum(charge)
+        else 0
+        end
+        )
+
+      from ctop_kuaishou_report_hourly_account
+      where account_id = #{accountId}
+      and stat_date = #{statDate}
+    </select>
+
+    <select id="getBudget" resultType="java.math.BigDecimal">
+      select
+      (case
+        when sum(day_budget) != ''
+        then sum(day_budget)
+        else 0
+        end
+        )
+
+      from ctop_kuaishou_campaign
+      where account_id = #{accountId}
+    </select>
+
+
+</mapper>

+ 10 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml

@@ -9,6 +9,11 @@
         campaign_name,
         status,
         day_budget,
+        campaign_type,
+        put_status,
+        create_channel,
+        put_create_time,
+        put_update_time,
         create_time,
         update_time)
         values
@@ -19,6 +24,11 @@
             #{campaign.campaignName},
             #{campaign.status},
             #{campaign.dayBudget},
+            #{campaign.campaign_type},
+            #{campaign.putStatus},
+            #{campaign.createChannel},
+            #{campaign.putCreateTime},
+            #{campaign.putUpdateTime},
             #{campaign.createTime},
             #{campaign.updateTime})
         </foreach>

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouDailyFlowsMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouDailyFlowsMapper">
+
+</mapper>

+ 31 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouImageGetMapper.xml

@@ -2,4 +2,34 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouImageGetMapper">
 
-</mapper>
+    <insert id="replaceBatch">
+        replace into ctop_kuaishou_image_get(
+        account_id,
+        url,
+        width,
+        height,
+        size,
+        format,
+        signature,
+        image_token,
+        create_time,
+        update_time
+        )
+        values
+        <foreach collection="images" item="image" separator=",">
+            (
+            #{image.accountId},
+            #{image.url},
+            #{image.width},
+            #{image.height},
+            #{image.size},
+            #{image.format},
+            #{image.signature},
+            #{image.imageToken},
+            #{image.createTime},
+            #{image.updateTime}
+            )
+        </foreach>
+    </insert>
+
+</mapper>

+ 21 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import java.math.BigDecimal;
+
+public interface IBatchService {
+    /**
+     * 获取 总花费
+     *
+     * @param accountId
+     * @return
+     */
+    BigDecimal getCost(Long accountId);
+
+    /**
+     * 获取总计划预算
+     *
+     * @param accountId
+     * @return
+     */
+    BigDecimal getBudget(Long accountId);
+}

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouDailyFlowsService.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouDailyFlows;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 快手-日流水信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-05
+ */
+public interface IKuaiShouDailyFlowsService extends IService<KuaiShouDailyFlows> {
+
+}

+ 5 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouImageGetService.java

@@ -1,8 +1,12 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImage;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * @Description: 快手-获取图片接口
  * @Author: jeecg-boot
@@ -10,5 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @Version: V1.0
  */
 public interface IKuaiShouImageGetService extends IService<KuaiShouImageGet> {
-
+    void replaceBatch(List<KuaiShouImageGet> imageGets);
 }

+ 45 - 7
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -66,7 +66,7 @@ public interface IKuaishouInterfaceService {
      * @param accessToken
      * @param advertiserId
      */
-    void getCampaignList(String accessToken, Long advertiserId, Integer page);
+    void getCampaignList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page);
 
 
     /**
@@ -84,7 +84,7 @@ public interface IKuaishouInterfaceService {
      * @param advertiserId
      * @param page
      */
-    void getGroupList(String accessToken, Long advertiserId, Integer page);
+    void getGroupList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page);
 
     /**
      * 获取广告组信息 单条
@@ -96,7 +96,7 @@ public interface IKuaishouInterfaceService {
     void getGroup(String accessToken, Long advertiserId, Long unitId);
 
 
-    void getCreativeList(CtopOauthToken token);
+    void getCreativeList(CtopOauthToken token, Date startDate, Date endDate);
 
     void getVideoInfo(String accessToken, Long advertiserId, String photoId);
 
@@ -106,7 +106,7 @@ public interface IKuaishouInterfaceService {
      * @param accessToken
      * @param advertiserId
      */
-    void getCreativeList(String accessToken, Long advertiserId, Integer page);
+    void getCreativeList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page);
 
     /**
      * 获取token
@@ -239,7 +239,9 @@ public interface IKuaishouInterfaceService {
      */
     Map<String, Object> advertiserInfo(Long accountId, String accessToken);
 
-    void getVideoList(CtopOauthToken token);
+    void getVideoList(CtopOauthToken token, Date startDate, Date endDate);
+
+    void getVideoList(String token, Long advertiserId, Date startDate, Date endDate, int page);
 
     void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate);
 
@@ -257,13 +259,49 @@ public interface IKuaishouInterfaceService {
 
     void getAdvertiserCreativeReportHourly(CtopOauthToken token, Date startDate, Date endDate);
 
-    void getCampaignList(CtopOauthToken token);
+    void getCampaignList(CtopOauthToken token, Date startDate, Date endDate);
 
-    void getGroupList(CtopOauthToken token);
+    void getGroupList(CtopOauthToken token, Date startDate, Date endDate);
 
     void loadData() throws InterruptedException;
 
     void updateCreativeReportHourlyStatistic(CtopOauthToken token, Date getDate);
 
     void deleteHourlyReport(Date deleteDate);
+
+    /**
+     * 获取快手图片列表
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     */
+    void getImageList(CtopOauthToken token, Date startDate, Date endDate);
+
+    /**
+     * 获取快手图片列表--测试使用
+     *
+     * @param token
+     * @param accountId
+     * @param startDate
+     * @param endDate
+     * @param page
+     */
+    void getImageList(String token, Long accountId, Date startDate, Date endDate, int page);
+
+    /**
+     * 获取账户余额
+     *
+     * @param oauthToken
+     * @return
+     */
+    JSONObject fundGet(CtopOauthToken oauthToken);
+
+
+    /**
+     * 获取账户流水数据
+     *
+     * @param token
+     */
+    void getDailyFlows(CtopOauthToken token);
 }

+ 48 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java

@@ -0,0 +1,48 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.kuaishou.modules.batch.mapper.BatchMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IBatchService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Slf4j
+@Service
+public class BatchServiceImpl implements IBatchService {
+    @Autowired
+    private BatchMapper batchMapper;
+
+
+    /**
+     * 获取总花费
+     *
+     * @param accountId
+     * @return
+     */
+    @Override
+    public BigDecimal getCost(Long accountId) {
+        BigDecimal dailyCost = batchMapper.getDailyCost(accountId);
+        BigDecimal hourlyCost = batchMapper.getHourCost(accountId, DateUtils.formatDate(new Date()));
+        BigDecimal totalCost = dailyCost.add(hourlyCost);
+        return totalCost;
+    }
+
+    /**
+     * 获取总计划预算
+     *
+     * @param accountId
+     * @return
+     */
+    @Override
+    public BigDecimal getBudget(Long accountId) {
+        return batchMapper.getBudget(accountId);
+    }
+
+
+}
+
+

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouDailyFlowsServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouDailyFlows;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouDailyFlowsMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyFlowsService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手-日流水信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-05
+ */
+@Service
+public class KuaiShouDailyFlowsServiceImpl extends ServiceImpl<KuaiShouDailyFlowsMapper, KuaiShouDailyFlows> implements IKuaiShouDailyFlowsService {
+
+}

+ 13 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouImageGetServiceImpl.java

@@ -1,18 +1,30 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouImageGetMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouVideoGetMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @Description: 快手-获取图片接口
  * @Author: jeecg-boot
- * @Date: 2019-07-25
+ * @Date: 2019-12-03
  * @Version: V1.0
  */
 @Service
 public class KuaiShouImageGetServiceImpl extends ServiceImpl<KuaiShouImageGetMapper, KuaiShouImageGet> implements IKuaiShouImageGetService {
+    @Autowired
+    private KuaiShouImageGetMapper imageGetMapper;
+
+    @Override
+    public void replaceBatch(List<KuaiShouImageGet> imageGets) {
+        imageGetMapper.replaceBatch(imageGets);
+    }
 
 }

+ 371 - 26
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.type.TypeFactory;
 import lombok.extern.slf4j.Slf4j;
 import lombok.var;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.http.ParseException;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -203,11 +204,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
-    public void getVideoList(CtopOauthToken token) {
-        getVideoListByPage(token, 1);
+    public void getVideoList(CtopOauthToken token, Date startDate, Date endDate) {
+        getVideoListByPage(token, startDate, endDate, 1);
     }
 
-    private void getVideoListByPage(CtopOauthToken token, int page) {
+    private void getVideoListByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", "application/json");
@@ -216,6 +217,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("advertiser_id", token.getAccountId());
         param.put("page_size", 500);
         param.put("page", page);
+        if (startDate != null && endDate != null) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
         Integer code = resultJson.getInteger("code");
@@ -240,7 +245,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             videoGets.add(kuaiShouVideoGet);
         }
         kuaiShouVideoGetService.replaceBatch(videoGets);
-        getVideoListByPage(token, page + 1);
+        getVideoListByPage(token, startDate, endDate, page + 1);
     }
 
     @Autowired
@@ -939,6 +944,17 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             getAdvertiserGroupReportDaily(token, getStartDate, getEndDate);
             //4: 获取广告创意信息数据
             getAdvertiserCreativeReportDaily(token, getStartDate, getEndDate);
+
+            //获取全量广告计划数据
+            getCampaignList(token, null, null);
+            //获取全量广告主数据
+            getGroupList(token, null, null);
+            //获取全量创意数据
+            getCreativeList(token, null, null);
+            //获取全量视频素材数据
+            getVideoList(token, null, null);
+            //获取图片信息数据
+            getImageList(token, null, null);
         }
 
     }
@@ -1066,17 +1082,21 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
-    public void getCampaignList(CtopOauthToken token) {
-        getCampaignListByPage(token.getAccessToken(), token.getAccountId(), 1);
+    public void getCampaignList(CtopOauthToken token, Date startDate, Date endDate) {
+        getCampaignListByPage(token.getAccessToken(), token.getAccountId(), startDate, endDate, 1);
     }
 
-    private void getCampaignListByPage(String accessToken, Long accountId, int page) {
+    private void getCampaignListByPage(String accessToken, Long accountId, Date startDate, Date endDate, int page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
         Map<String, String> headers = new HashMap<>();
         headers.put("Access-Token", accessToken);
         headers.put("Content-Type", " application/json");
         JSONObject param = new JSONObject();
         param.put("advertiser_id", accountId);
+        if (startDate != null && endDate != null) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
         param.put("page", page);
         param.put("page_size", 200);
 
@@ -1098,7 +1118,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             return;
         }
         addCampaign(accountId, details);
-        getCampaignListByPage(accessToken, accountId, page + 1);
+        getCampaignListByPage(accessToken, accountId, startDate, endDate, page + 1);
     }
 
     /**
@@ -1109,13 +1129,17 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * @return
      */
     @Override
-    public void getCampaignList(String accessToken, Long advertiserId, Integer page) {
+    public void getCampaignList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
         Map<String, String> headers = new HashMap<>();
         headers.put("Access-Token", accessToken);
         headers.put("Content-Type", " application/json");
         JSONObject param = new JSONObject();
         param.put("advertiser_id", advertiserId);
+        if (startDate != null && endDate != null) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
         param.put("page", page);
         param.put("page_size", 200);
         try {
@@ -1128,7 +1152,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     JSONArray details = dataJson.getJSONArray("details");
                     if (!Check.isNull(details)) {
                         addCampaign(advertiserId, details);
-                        getCampaignList(accessToken, advertiserId, page + 1);
+                        getCampaignList(accessToken, advertiserId, startDate, endDate, page + 1);
                     }
                 } else {
                     log.error("获取广告计划信息返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
@@ -1191,6 +1215,13 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 campaign.setCampaignName(detail.getString("campaign_name"));
                 campaign.setDayBudget(detail.getLong("day_budget"));
                 campaign.setStatus(detail.getInteger("status"));
+
+                campaign.setPutStatus(detail.getInteger("put_status"));
+                campaign.setCampaignType(detail.getInteger("campaign_type"));
+                campaign.setCreateChannel(detail.getInteger("create_channel"));
+                campaign.setPutCreateTime(detail.getString("create_time"));
+                campaign.setPutUpdateTime(detail.getString("update_time"));
+
                 campaigns.add(campaign);
             }
         }
@@ -1198,8 +1229,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
-    public void getGroupList(CtopOauthToken token) {
-        getGroupListByPage(token, 1);
+    public void getGroupList(CtopOauthToken token, Date startDate, Date endDate) {
+        getGroupListByPage(token, startDate, endDate, 1);
     }
 
     @Autowired
@@ -1224,13 +1255,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 @Override
                 public void run() {
                     //1:获取全量广告计划数据
-                    getCampaignList(token);
+                    getCampaignList(token, null, null);
                     //1:获取全量广告组数据
-                    getGroupList(token);
+                    getGroupList(token, null, null);
                     //1:获取全量创意数据
-                    getCreativeList(token);
+                    getCreativeList(token, null, null);
                     //2:获取全量视频素材数据
-                    getVideoList(token);
+                    getVideoList(token, null, null);
+                    //获取图片信息数据
+                    getImageList(token, null, null);
                     countDownLatch.countDown();
                 }
             });
@@ -1265,12 +1298,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         hourlyCreativeStatisticService.deleteHourlyReport(deleteDate);
     }
 
-    private void getGroupListByPage(CtopOauthToken token, int page) {
+    private void getGroupListByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
         JSONObject param = new JSONObject();
         param.put("advertiser_id", token.getAccountId());
         param.put("page_size", 200);
         param.put("page", page);
+        if (startDate != null && endDate != null) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
         Map<String, String> headers = new HashMap<>();
         headers.put("Access-Token", token.getAccessToken());
         headers.put("Content-Type", " application/json");
@@ -1292,7 +1329,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             return;
         }
         addGroup(token.getAccountId(), details);
-        getGroupListByPage(token, page + 1);
+        getGroupListByPage(token, startDate, endDate, page + 1);
     }
 
     /**
@@ -1303,12 +1340,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * @return
      */
     @Override
-    public void getGroupList(String accessToken, Long advertiserId, Integer page) {
+    public void getGroupList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
         JSONObject param = new JSONObject();
         param.put("advertiser_id", advertiserId);
         param.put("page_size", 200);
         param.put("page", page);
+        if (startDate != null && endDate != null) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
         Map<String, String> headers = new HashMap<>();
         headers.put("Access-Token", accessToken);
         headers.put("Content-Type", " application/json");
@@ -1323,7 +1364,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         JSONArray details = dataJson.getJSONArray("details");
                         if (!Check.isNull(details)) {
                             addGroup(advertiserId, details);
-                            getGroupList(accessToken, advertiserId, page + 1);
+                            getGroupList(accessToken, advertiserId, startDate, endDate, page + 1);
                         }
 
                     } else {
@@ -1463,17 +1504,21 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
-    public void getCreativeList(CtopOauthToken token) {
-        getCreativeListByPage(token.getAccessToken(), token.getAccountId(), 1);
+    public void getCreativeList(CtopOauthToken token, Date startDate, Date endDate) {
+        getCreativeListByPage(token.getAccessToken(), token.getAccountId(), startDate, endDate, 1);
     }
 
-    public void getCreativeListByPage(String accessToken, Long advertiserId, Integer page) {
+    public void getCreativeListByPage(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", " application/json");
         headers.put("Access-Token", accessToken);
         JSONObject param = new JSONObject();
         param.put("advertiser_id", advertiserId);
+        if (startDate != null && endDate != null) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
         param.put("page_size", 200);
         param.put("page", page);
 
@@ -1523,7 +1568,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             }
         }
         creativeService.replaceBatch(creatives);
-        getCreativeListByPage(accessToken, advertiserId, page + 1);
+        getCreativeListByPage(accessToken, advertiserId, startDate, endDate, page + 1);
     }
 
     /**
@@ -1586,13 +1631,17 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * @param advertiserId
      */
     @Override
-    public void getCreativeList(String accessToken, Long advertiserId, Integer page) {
+    public void getCreativeList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
         Map<String, String> headers = new HashMap<String, String>();
         headers.put("Content-Type", " application/json");
         headers.put("Access-Token", accessToken);
         JSONObject param = new JSONObject();
         param.put("advertiser_id", advertiserId);
+        if (startDate != null && endDate != null) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
         param.put("page_size", 200);
         param.put("page", page);
         try {
@@ -1631,7 +1680,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                 }
 
                             }
-                            getCreativeList(accessToken, advertiserId, page + 1);
+                            getCreativeList(accessToken, advertiserId, startDate, endDate, page + 1);
                         }
                     }
                 } else {
@@ -2542,4 +2591,300 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         }
         return null;
     }
+
+    @Autowired
+    IKuaiShouImageGetService kuaiShouImageGetService;
+
+    /**
+     * 查询图片列表
+     */
+    @Override
+    public void getImageList(CtopOauthToken token, Date startDate, Date endDate) {
+        getImageList(token, startDate, endDate, 1);
+    }
+
+    /**
+     * 查询图片列表
+     */
+    private void getImageList(CtopOauthToken token, Date startDate, Date endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_LIST;
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Content-Type", " application/json");
+        headers.put("Access-Token", token.getAccessToken());
+
+        //传参
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", token.getAccountId());
+        if (startDate != null && endDate != null) {
+            param.put("startDate", DateUtils.formatDate(startDate));
+            param.put("endDate", DateUtils.formatDate(endDate));
+        }
+        param.put("page_size", 500);
+        param.put("page", page);
+        //
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手图片列表数据异常:{},accountId:{}", message, token.getAccountId());
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手图片列表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+        List<KuaiShouImageGet> imageGets = new ArrayList<>();
+        for (int i = 0; i < details.size(); i++) {
+            var detailJson = details.getJSONObject(i);
+            var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
+
+            if (StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))) {
+                continue;
+            }
+            kuaiShouImageGet.setAccountId(token.getAccountId());
+            kuaiShouImageGet.setCreateTime(new Date());
+            kuaiShouImageGet.setUpdateTime(new Date());
+            imageGets.add(kuaiShouImageGet);
+        }
+        kuaiShouImageGetService.replaceBatch(imageGets);
+        getImageList(token, startDate, endDate, page + 1);
+    }
+
+    /**
+     * 查询图片列表---测试使用
+     */
+    public void getImageList(String token, Long accountId, Date startDate, Date endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_LIST;
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Content-Type", " application/json");
+        headers.put("Access-Token", token);
+
+        //传参
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        if (startDate != null && endDate != null) {
+            param.put("startDate", DateUtils.formatDate(startDate));
+            param.put("endDate", DateUtils.formatDate(endDate));
+        }
+        param.put("page_size", 500);
+        param.put("page", page);
+        //
+
+        //String result = HttpUtils.httpPostRequest(url, param, headers);
+
+        //test start
+        Map<String, Object> map = new HashMap<>();
+        Map<String, Object> map1 = new HashMap<>();
+
+        List<KuaiShouImageGet> list = new ArrayList<>();
+        KuaiShouImageGet kuaiShouImageGet1 = new KuaiShouImageGet();
+        kuaiShouImageGet1.setUrl("http://static.yximgs.com/udata/pkg/markb21f94845c4350.jpg");
+        kuaiShouImageGet1.setWidth(720L);
+        kuaiShouImageGet1.setHeight(1280L);
+        kuaiShouImageGet1.setSize(441029L);
+        kuaiShouImageGet1.setFormat("jpg");
+        kuaiShouImageGet1.setImageToken("market0a8a3104ee6b4f148ab21f94845c4350.jpg");
+        kuaiShouImageGet1.setSignature("44a20b91b0727fa2abb68b19c0456422");
+        list.add(kuaiShouImageGet1);
+
+        map1.put("details", list);
+        map1.put("total_count", 4);
+        map.put("data", map1);
+        map.put("message", "OK");
+        map.put("code", 0);
+        String result = JSONObject.toJSONString(map);
+        //test end
+
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手图片列表数据异常:{},accountId:{}", message, accountId);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手图片列表信息为空=》accountId:{}", accountId);
+            return;
+        }
+        List<KuaiShouImageGet> imageGets = new ArrayList<>();
+        for (int i = 0; i < details.size(); i++) {
+            var detailJson = details.getJSONObject(i);
+            var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
+
+            if (StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))) {
+                continue;
+            }
+            kuaiShouImageGet.setAccountId(accountId);
+            kuaiShouImageGet.setCreateTime(new Date());
+            kuaiShouImageGet.setUpdateTime(new Date());
+            imageGets.add(kuaiShouImageGet);
+        }
+        kuaiShouImageGetService.replaceBatch(imageGets);
+        getImageList(token, accountId, startDate, endDate, page + 1);
+    }
+
+
+    /**
+     * 获取全量视频素材数据--测试使用
+     *
+     * @param token
+     * @param startDate
+     * @param endDate
+     * @param page
+     */
+    public void getVideoList(String token, Long accountId, Date startDate, Date endDate, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token);
+        Map<String, Object> param = new HashMap<>();
+        param.put("advertiser_id", accountId);
+        param.put("page_size", 500);
+        param.put("page", page);
+        if (startDate != null && endDate != null) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手视频列表数据异常:{},accountId:{}", message, accountId);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手视频列表信息为空=》accountId:{}", accountId);
+            return;
+        }
+        List<KuaiShouVideoGet> videoGets = new ArrayList<>();
+        for (int i = 0; i < details.size(); i++) {
+            var detailJson = details.getJSONObject(i);
+            var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
+            kuaiShouVideoGet.setAccountId(accountId);
+            kuaiShouVideoGet.setId("" + accountId + kuaiShouVideoGet.getPhotoId());
+            kuaiShouVideoGet.setCreateTime(new Date());
+            kuaiShouVideoGet.setUpdateTime(new Date());
+            videoGets.add(kuaiShouVideoGet);
+        }
+        kuaiShouVideoGetService.replaceBatch(videoGets);
+        getVideoList(token, accountId, startDate, endDate, page + 1);
+    }
+
+
+    /**
+     * 获取账户余额
+     *
+     * @param oauthToken
+     * @return
+     */
+    @Override
+    public JSONObject fundGet(CtopOauthToken oauthToken) {
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.FUND_GET;
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Access-Token", oauthToken.getAccessToken());
+            headers.put("Content-Type", " application/json");
+            JSONObject json = new JSONObject();
+            json.put("advertiser_id", oauthToken.getAccountId());
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, json.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject dataJson = resultJson.getJSONObject("data");
+                    if (!Check.isNull(dataJson)) {
+                        return dataJson;
+                    }
+
+                } else {
+                    log.error("获取账户余额失败");
+                }
+            } else {
+                log.error("获取账户余额返回为空");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
+    /**
+     * 获取账户流水数据
+     *
+     * @param token
+     */
+
+    @Autowired
+    private IKuaiShouDailyFlowsService kuaiShouDailyFlowsService;
+
+    @Override
+    public void getDailyFlows(CtopOauthToken token) {
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.DAILY_FLOWS;
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Access-Token", token.getAccessToken());
+            headers.put("Content-Type", " application/json");
+            JSONObject json = new JSONObject();
+            json.put("advertiser_id", token.getAccountId());
+
+
+            String endDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", endDate, -1);
+            json.put("start_date", startDate);
+            json.put("end_date", endDate);
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, json.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject dataJson = resultJson.getJSONObject("data");
+                    if (!Check.isNull(dataJson)) {
+                        JSONArray details = dataJson.getJSONArray("details");
+                        if (!Check.isNull(details)) {
+                            for (int i = 0; i < details.size(); i++) {
+                                JSONObject detailJson = details.getJSONObject(i);
+                                if (!Check.isNull(detailJson)) {
+                                    String date = detailJson.getString("date");
+                                    Map<String, Object> deleteMap = new HashMap<>();
+                                    deleteMap.put("date", date);
+                                    deleteMap.put("account_id", token.getAccountId());
+                                    kuaiShouDailyFlowsService.removeByMap(deleteMap);
+                                    KuaiShouDailyFlows dailyFlows = new KuaiShouDailyFlows();
+                                    dailyFlows.setAccountId(token.getAccountId());
+                                    dailyFlows.setDate(date);
+                                    dailyFlows.setBalance(detailJson.getBigDecimal("balance"));
+                                    dailyFlows.setDailyCharge(detailJson.getBigDecimal("daily_charge"));
+                                    dailyFlows.setRealCharged(detailJson.getBigDecimal("real_charged"));
+                                    dailyFlows.setContractRebateRealCharged(detailJson.getBigDecimal("contract_rebate_real_charged"));
+                                    dailyFlows.setDirectRebateRealCharged(detailJson.getBigDecimal("direct_rebate_real_charged"));
+                                    dailyFlows.setDailyTransferIn(detailJson.getBigDecimal("daily_transfer_in"));
+                                    dailyFlows.setContractRebateRealRecharged(detailJson.getBigDecimal("contract_rebate_real_recharged"));
+                                    dailyFlows.setDirectRebateRealRecharged(detailJson.getBigDecimal("direct_rebate_real_recharged"));
+                                    dailyFlows.setDailyTransferOut(detailJson.getBigDecimal("daily_transfer_out"));
+                                    dailyFlows.setRealRecharged(detailJson.getBigDecimal("real_recharged"));
+                                    kuaiShouDailyFlowsService.save(dailyFlows);
+                                }
+                            }
+                        }
+                    }
+
+                } else {
+                    log.error("获取账户余额失败");
+                }
+            } else {
+                log.error("获取账户余额返回为空");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
 }