Browse Source

获取流水数据

yumeng 5 years ago
parent
commit
1d5aba5187
21 changed files with 986 additions and 31 deletions
  1. 41 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/DailyFlowsJob.java
  2. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  3. 10 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  4. 11 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  5. 106 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  6. 248 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouDailyFlowsController.java
  7. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/UpdateController.java
  8. 36 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCampaign.java
  9. 125 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouDailyFlows.java
  10. 33 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/vo/SpendVo.java
  11. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/BatchMapper.java
  12. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouDailyFlowsMapper.java
  13. 46 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/BatchMapper.xml
  14. 10 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml
  15. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouDailyFlowsMapper.xml
  16. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java
  17. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouDailyFlowsService.java
  18. 21 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  19. 48 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  20. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouDailyFlowsServiceImpl.java
  21. 148 27
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

+ 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);
+            }
+
+        }
+
+    }
+}

+ 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
      *

+ 11 - 1
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";
+
 
     /**
      * 修改广告计划预算
@@ -129,7 +139,7 @@ public class KuaishouInterfaceConstant {
     /**
      * 快手-查询图片列表
      */
-    public static final String IMAGE_LIST  = "/rest/openapi/v1/file/ad/image/list";
+    public static final String IMAGE_LIST = "/rest/openapi/v1/file/ad/image/list";
 
     /**
      * 登录

+ 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;
+    }
+
+
+}

+ 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;
+}

+ 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> {
+
+}

+ 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>

+ 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> {
+
+}

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

@@ -106,7 +106,7 @@ public interface IKuaishouInterfaceService {
      * @param accessToken
      * @param advertiserId
      */
-    void getCreativeList(String accessToken, Long advertiserId, Date startDate, Date endDate,Integer page);
+    void getCreativeList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page);
 
     /**
      * 获取token
@@ -241,7 +241,7 @@ public interface IKuaishouInterfaceService {
 
     void getVideoList(CtopOauthToken token, Date startDate, Date endDate);
 
-    void getVideoList(String token, Long advertiserId,Date startDate, Date endDate, int page);
+    void getVideoList(String token, Long advertiserId, Date startDate, Date endDate, int page);
 
     void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate);
 
@@ -261,7 +261,7 @@ public interface IKuaishouInterfaceService {
 
     void getCampaignList(CtopOauthToken token, Date startDate, Date endDate);
 
-    void getGroupList(CtopOauthToken token,Date startDate, Date endDate);
+    void getGroupList(CtopOauthToken token, Date startDate, Date endDate);
 
     void loadData() throws InterruptedException;
 
@@ -271,6 +271,7 @@ public interface IKuaishouInterfaceService {
 
     /**
      * 获取快手图片列表
+     *
      * @param token
      * @param startDate
      * @param endDate
@@ -279,6 +280,7 @@ public interface IKuaishouInterfaceService {
 
     /**
      * 获取快手图片列表--测试使用
+     *
      * @param token
      * @param accountId
      * @param startDate
@@ -286,4 +288,20 @@ public interface IKuaishouInterfaceService {
      * @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 {
+
+}

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

@@ -217,7 +217,7 @@ 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){
+        if (startDate != null && endDate != null) {
             param.put("start_date", DateUtils.formatDate(startDate));
             param.put("end_date", DateUtils.formatDate(endDate));
         }
@@ -1093,7 +1093,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         headers.put("Content-Type", " application/json");
         JSONObject param = new JSONObject();
         param.put("advertiser_id", accountId);
-        if(startDate != null && endDate != null){
+        if (startDate != null && endDate != null) {
             param.put("start_date", DateUtils.formatDate(startDate));
             param.put("end_date", DateUtils.formatDate(endDate));
         }
@@ -1136,7 +1136,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         headers.put("Content-Type", " application/json");
         JSONObject param = new JSONObject();
         param.put("advertiser_id", advertiserId);
-        if(startDate != null && endDate != null){
+        if (startDate != null && endDate != null) {
             param.put("start_date", DateUtils.formatDate(startDate));
             param.put("end_date", DateUtils.formatDate(endDate));
         }
@@ -1215,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);
             }
         }
@@ -1248,13 +1255,13 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 @Override
                 public void run() {
                     //1:获取全量广告计划数据
-                    getCampaignList(token,null,null);
+                    getCampaignList(token, null, null);
                     //1:获取全量广告组数据
-                    getGroupList(token,null,null);
+                    getGroupList(token, null, null);
                     //1:获取全量创意数据
-                    getCreativeList(token,null,null);
+                    getCreativeList(token, null, null);
                     //2:获取全量视频素材数据
-                    getVideoList(token,null,null);
+                    getVideoList(token, null, null);
                     //获取图片信息数据
                     getImageList(token, null, null);
                     countDownLatch.countDown();
@@ -1297,7 +1304,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("advertiser_id", token.getAccountId());
         param.put("page_size", 200);
         param.put("page", page);
-        if(startDate != null && endDate != null){
+        if (startDate != null && endDate != null) {
             param.put("start_date", DateUtils.formatDate(startDate));
             param.put("end_date", DateUtils.formatDate(endDate));
         }
@@ -1339,7 +1346,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("advertiser_id", advertiserId);
         param.put("page_size", 200);
         param.put("page", page);
-        if(startDate != null && endDate != null){
+        if (startDate != null && endDate != null) {
             param.put("start_date", DateUtils.formatDate(startDate));
             param.put("end_date", DateUtils.formatDate(endDate));
         }
@@ -1508,7 +1515,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         headers.put("Access-Token", accessToken);
         JSONObject param = new JSONObject();
         param.put("advertiser_id", advertiserId);
-        if(startDate != null && endDate != null){
+        if (startDate != null && endDate != null) {
             param.put("start_date", DateUtils.formatDate(startDate));
             param.put("end_date", DateUtils.formatDate(endDate));
         }
@@ -1631,7 +1638,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         headers.put("Access-Token", accessToken);
         JSONObject param = new JSONObject();
         param.put("advertiser_id", advertiserId);
-        if(startDate != null && endDate != null){
+        if (startDate != null && endDate != null) {
             param.put("start_date", DateUtils.formatDate(startDate));
             param.put("end_date", DateUtils.formatDate(endDate));
         }
@@ -2585,7 +2592,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         return null;
     }
 
-    @Autowired IKuaiShouImageGetService kuaiShouImageGetService;
+    @Autowired
+    IKuaiShouImageGetService kuaiShouImageGetService;
 
     /**
      * 查询图片列表
@@ -2598,7 +2606,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     /**
      * 查询图片列表
      */
-    private void getImageList(CtopOauthToken token, Date startDate, Date endDate, int page ) {
+    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");
@@ -2607,7 +2615,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         //传参
         JSONObject param = new JSONObject();
         param.put("advertiser_id", token.getAccountId());
-        if(startDate != null && endDate != null){
+        if (startDate != null && endDate != null) {
             param.put("startDate", DateUtils.formatDate(startDate));
             param.put("endDate", DateUtils.formatDate(endDate));
         }
@@ -2633,7 +2641,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             var detailJson = details.getJSONObject(i);
             var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
 
-            if(StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))){
+            if (StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))) {
                 continue;
             }
             kuaiShouImageGet.setAccountId(token.getAccountId());
@@ -2648,7 +2656,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     /**
      * 查询图片列表---测试使用
      */
-    public void getImageList(String token, Long accountId, Date startDate, Date endDate, int page ) {
+    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");
@@ -2657,7 +2665,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         //传参
         JSONObject param = new JSONObject();
         param.put("advertiser_id", accountId);
-        if(startDate != null && endDate != null){
+        if (startDate != null && endDate != null) {
             param.put("startDate", DateUtils.formatDate(startDate));
             param.put("endDate", DateUtils.formatDate(endDate));
         }
@@ -2668,8 +2676,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         //String result = HttpUtils.httpPostRequest(url, param, headers);
 
         //test start
-        Map<String,Object> map = new HashMap<>();
-        Map<String,Object> map1 = new HashMap<>();
+        Map<String, Object> map = new HashMap<>();
+        Map<String, Object> map1 = new HashMap<>();
 
         List<KuaiShouImageGet> list = new ArrayList<>();
         KuaiShouImageGet kuaiShouImageGet1 = new KuaiShouImageGet();
@@ -2682,11 +2690,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         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);
+        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
 
@@ -2707,7 +2715,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             var detailJson = details.getJSONObject(i);
             var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
 
-            if(StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))){
+            if (StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))) {
                 continue;
             }
             kuaiShouImageGet.setAccountId(accountId);
@@ -2716,11 +2724,13 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             imageGets.add(kuaiShouImageGet);
         }
         kuaiShouImageGetService.replaceBatch(imageGets);
-        getImageList(token, accountId, startDate, endDate, page+1 );
+        getImageList(token, accountId, startDate, endDate, page + 1);
     }
 
+
     /**
      * 获取全量视频素材数据--测试使用
+     *
      * @param token
      * @param startDate
      * @param endDate
@@ -2735,7 +2745,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("advertiser_id", accountId);
         param.put("page_size", 500);
         param.put("page", page);
-        if(startDate != null && endDate != null){
+        if (startDate != null && endDate != null) {
             param.put("start_date", DateUtils.formatDate(startDate));
             param.put("end_date", DateUtils.formatDate(endDate));
         }
@@ -2766,4 +2776,115 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         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();
+        }
+    }
+
+
 }