浏览代码

Merge branch 'test' of https://gitee.com/hcst/adsp-boot into test

# Conflicts:
#	jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyReportLoadJob.java
#	module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
syh 5 年之前
父节点
当前提交
e440bfa5bd
共有 82 个文件被更改,包括 3916 次插入394 次删除
  1. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 3 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java
  3. 74 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java
  4. 248 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MailLogController.java
  5. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  6. 50 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  7. 69 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/MailLog.java
  8. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Project.java
  9. 3 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/ProjectMember.java
  10. 33 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/AccountBidJob.java
  11. 41 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/DailyFlowsJob.java
  12. 18 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouAdvertiserCrawlerJob.java
  13. 60 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCampaignGroupJob.java
  14. 22 15
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoDelete.java
  15. 56 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportLoadJob.java
  16. 57 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCampaignReportLoadJob.java
  17. 56 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCreativeReportLoadJob.java
  18. 58 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyGroupReportLoadJob.java
  19. 0 52
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyReportLoadJob.java
  20. 83 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyAccountReportLoadJob.java
  21. 85 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCampaignReportLoadJob.java
  22. 88 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyCreativeReportLoadJob.java
  23. 84 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyGroupReportLoadJob.java
  24. 0 84
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouHourlyReportLoadJob.java
  25. 35 31
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouMaterialsLoadJob.java
  26. 8 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/RefreshTokenJob.java
  27. 23 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MailLogMapper.java
  28. 41 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MailLogMapper.xml
  29. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IBidWarningService.java
  30. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IMailLogService.java
  31. 116 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java
  32. 19 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MailLogServiceImpl.java
  33. 162 158
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/mock/MockController.java
  34. 69 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java
  35. 120 0
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  36. 80 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/CtopCorpWexinUser.java
  37. 18 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/CtopCorpWexinUserMapper.java
  38. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopCorpWexinUserMapper.xml
  39. 4 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICorpWeixinService.java
  40. 15 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopCorpWexinUserService.java
  41. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  42. 56 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CorpWeixinServiceImpl.java
  43. 20 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopCorpWexinUserServiceImpl.java
  44. 10 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  45. 49 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/CorpWexinUtils.java
  46. 98 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java
  47. 11 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  48. 20 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/RateUtil.java
  49. 69 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/SendMailUtil.java
  50. 106 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  51. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java
  52. 248 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouDailyFlowsController.java
  53. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/UpdateController.java
  54. 36 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCampaign.java
  55. 125 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouDailyFlows.java
  56. 33 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/vo/SpendVo.java
  57. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/BatchMapper.java
  58. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouDailyFlowsMapper.java
  59. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupMapper.java
  60. 46 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/BatchMapper.xml
  61. 10 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml
  62. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouDailyFlowsMapper.xml
  63. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml
  64. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java
  65. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouDailyFlowsService.java
  66. 22 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  67. 48 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  68. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouDailyFlowsServiceImpl.java
  69. 227 39
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  70. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyGroup.java
  71. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyGroup.java
  72. 8 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportHourlyGroupMapper.xml
  73. 150 0
      module-report/src/main/java/cn/com/ctop/bytedance/controller/DailyReportController.java
  74. 39 0
      module-report/src/main/java/cn/com/ctop/bytedance/entity/ExcelExp.java
  75. 13 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/DailyReportMapper.java
  76. 235 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/DailyReportMapper.xml
  77. 18 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/IDailyReportService.java
  78. 74 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/DailyReportServiceImpl.java
  79. 25 0
      module-report/src/main/java/cn/com/ctop/bytedance/vo/DailyAccountReportVO.java
  80. 30 0
      module-report/src/main/java/cn/com/ctop/bytedance/vo/DailyGroupReportVO.java
  81. 13 0
      module-report/src/main/java/cn/com/ctop/bytedance/vo/DailyReportVO.java
  82. 5 1
      pom.xml

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -44,6 +44,7 @@ public class ShiroConfig {
 		// 配置不会被拦截的链接 顺序判断
         //登录接口排除
         filterChainDefinitionMap.put("/sys/login", "anon");
+        filterChainDefinitionMap.put("/sys/wxlogin", "anon");
 
         //获取加密串
         filterChainDefinitionMap.put("/sys/getEncryptedString", "anon");
@@ -123,6 +124,8 @@ public class ShiroConfig {
 
 
         filterChainDefinitionMap.put("/system/userCompany/**", "anon");
+        filterChainDefinitionMap.put("/qywexin", "anon");
+        filterChainDefinitionMap.put("/test/getGroupData/**", "anon");
 
 
 

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

@@ -95,7 +95,9 @@ public class AdvertiserController {
             userCompanyQueryWrapper.orderByDesc("create_time");
             userCompanyQueryWrapper.last("limit 1");
             UserCompany userCompany = userCompanyMapper.selectOne(userCompanyQueryWrapper);
-            queryWrapper.eq("company_id", userCompany.getCompanyId());
+            if (!Check.isNull(userCompany)) {
+                queryWrapper.eq("company_id", userCompany.getCompanyId());
+            }
         }
         Page<Advertiser> page = new Page<Advertiser>(pageNo, pageSize);
         IPage<Advertiser> pageList = advertiserService.page(page, queryWrapper);

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

@@ -13,7 +13,27 @@ import cn.com.ctop.toutiao.entity.ByteDanceAdvertiser;
 import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.val;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.api.WxCpOAuth2Service;
+import me.chanjar.weixin.cp.api.WxCpUserService;
+import me.chanjar.weixin.cp.api.impl.WxCpOAuth2ServiceImpl;
+import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
+import me.chanjar.weixin.cp.api.impl.WxCpUserServiceImpl;
+import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
+import me.chanjar.weixin.cp.bean.WxCpUser;
+import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
 import org.apache.commons.lang.StringUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.system.api.ISysBaseApi;
+import org.jeecg.common.system.util.JwtUtil;
+import org.jeecg.common.util.RedisUtil;
+import org.jeecg.modules.system.entity.SysDepart;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.ISysDepartService;
+import org.jeecg.modules.system.service.ISysLogService;
+import org.jeecg.modules.system.service.ISysUserService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,14 +45,25 @@ import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 @Controller
 public class CallbackController {
     private static final Logger logger = LoggerFactory.getLogger(CallbackController.class);
-
+    @Autowired
+    private ISysUserService sysUserService;
+    @Autowired
+    private ISysBaseApi sysBaseApi;
+    @Autowired
+    private ISysLogService logService;
+    @Autowired
+    private RedisUtil redisUtil;
+    @Autowired
+    private ISysDepartService sysDepartService;
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
 
@@ -45,8 +76,50 @@ public class CallbackController {
     @Autowired
     private ICtopOauthTokenService ctopOauthTokenService;
 
+    @GetMapping("/qywexin")
+    @ResponseBody
+    public void qywexin(HttpServletRequest request,
+                        HttpServletResponse response,
+                        @RequestParam("code") String code,
+                        @RequestParam("state") String state) throws IOException {
+        response.sendRedirect(state + "?code=" + code);
+    }
 
     /**
+     * 用户信息
+     *
+     * @param sysUser
+     * @param result
+     * @return
+     */
+    private Result<JSONObject> userInfo(SysUser sysUser, Result<JSONObject> result) {
+        String syspassword = sysUser.getPassword();
+        String username = sysUser.getUsername();
+        // 生成token
+        String token = JwtUtil.sign(username, syspassword);
+        redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
+        // 设置超时时间
+        redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
+
+        // 获取用户部门信息
+        JSONObject obj = new JSONObject();
+        List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
+        obj.put("departs", departs);
+        if (departs == null || departs.size() == 0) {
+            obj.put("multi_depart", 0);
+        } else if (departs.size() == 1) {
+            sysUserService.updateUserDepart(username, departs.get(0).getOrgCode());
+            obj.put("multi_depart", 1);
+        } else {
+            obj.put("multi_depart", 2);
+        }
+        obj.put("token", token);
+        obj.put("userInfo", sysUser);
+        result.setResult(obj);
+        result.success("登录成功");
+        return result;
+    }
+    /**
      * TODO 授权绑定成功/失败 需要跳转特定页面
      *
      * @param request

+ 248 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MailLogController.java

@@ -0,0 +1,248 @@
+package org.jeecg.modules.ctop.controller;
+
+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.jeecg.modules.ctop.entity.MailLog;
+import org.jeecg.modules.ctop.service.IMailLogService;
+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-08
+ */
+@Slf4j
+@Api(tags = "邮箱记录表")
+@RestController
+@RequestMapping("/top/mailLog")
+public class MailLogController {
+    @Autowired
+    private IMailLogService mailLogService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param mailLog
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "邮箱记录表-分页列表查询")
+    @ApiOperation(value = "邮箱记录表-分页列表查询", notes = "邮箱记录表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<MailLog>> queryPageList(MailLog mailLog,
+                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                HttpServletRequest req) {
+        Result<IPage<MailLog>> result = new Result<IPage<MailLog>>();
+        QueryWrapper<MailLog> queryWrapper = QueryGenerator.initQueryWrapper(mailLog, req.getParameterMap());
+        Page<MailLog> page = new Page<MailLog>(pageNo, pageSize);
+        IPage<MailLog> pageList = mailLogService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param mailLog
+     * @return
+     */
+    @AutoLog(value = "邮箱记录表-添加")
+    @ApiOperation(value = "邮箱记录表-添加", notes = "邮箱记录表-添加")
+    @PostMapping(value = "/add")
+    public Result<MailLog> add(@RequestBody MailLog mailLog) {
+        Result<MailLog> result = new Result<MailLog>();
+        try {
+            mailLogService.save(mailLog);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param mailLog
+     * @return
+     */
+    @AutoLog(value = "邮箱记录表-编辑")
+    @ApiOperation(value = "邮箱记录表-编辑", notes = "邮箱记录表-编辑")
+    @PutMapping(value = "/edit")
+    public Result<MailLog> edit(@RequestBody MailLog mailLog) {
+        Result<MailLog> result = new Result<MailLog>();
+        MailLog mailLogEntity = mailLogService.getById(mailLog.getId());
+        if (mailLogEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = mailLogService.updateById(mailLog);
+            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 {
+            mailLogService.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<MailLog> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<MailLog> result = new Result<MailLog>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.mailLogService.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<MailLog> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<MailLog> result = new Result<MailLog>();
+        MailLog mailLog = mailLogService.getById(id);
+        if (mailLog == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(mailLog);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<MailLog> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                MailLog mailLog = JSON.parseObject(deString, MailLog.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(mailLog, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<MailLog> pageList = mailLogService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "邮箱记录表列表");
+        mv.addObject(NormalExcelConstants.CLASS, MailLog.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<MailLog> listMailLogs = ExcelImportUtil.importExcel(file.getInputStream(), MailLog.class, params);
+                mailLogService.saveBatch(listMailLogs);
+                return Result.ok("文件导入成功!数据行数:" + listMailLogs.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("文件导入失败!");
+    }
+
+}

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

@@ -122,6 +122,7 @@ public class ProjectMemberController {
                         projectMember.setAdvertiserName(project.getAdvertiserName());
                         projectMember.setAdvertiserId(project.getAdvertiserId());
                         projectMember.setMediaId(project.getMediaId());
+                        projectMember.setMaxBid(project.getMaxBid());
                         projectMemberList.add(projectMember);
                     }
 

+ 50 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -1,12 +1,19 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.service.ICreateInternalService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -46,4 +53,47 @@ public class TestController {
     }
 
 
+    @Autowired
+    private CtopOauthTokenMapper tokenMapper;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @GetMapping(value = "/getGroupData")
+    public String getGroupData() {
+
+
+        Date endDate = new Date();
+        QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+        tokenQueryWrapper.eq("media_id", 2);
+        List<CtopOauthToken> ctopOauthTokens = tokenMapper.selectList(tokenQueryWrapper);
+        for (CtopOauthToken token : ctopOauthTokens) {
+
+
+            for (int i = 0; i < 7; i++) {
+                Date getStartDate = DateUtils.addDay(endDate, -i);
+
+                //3:获取广告组信息数据
+                kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, getStartDate, getStartDate);
+
+            }
+            for (int i = 0; i < 6; i++) {
+                Date getStartDate = new Date();
+                Date getEndDate = new Date();
+                if (i == 0) {
+                    getStartDate = DateUtils.addDay(endDate, -175 + i * 30);
+                    getEndDate = DateUtils.addDay(endDate, -150 + i * 30);
+                } else {
+                    getStartDate = DateUtils.addDay(endDate, -180 + i * 30);
+                    getEndDate = DateUtils.addDay(endDate, -150 + i * 30);
+                }
+
+                //3:获取广告组信息数据
+                kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, getStartDate, getEndDate);
+
+            }
+
+
+        }
+        return "Success";
+    }
 }

+ 69 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/MailLog.java

@@ -0,0 +1,69 @@
+package org.jeecg.modules.ctop.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+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 java.util.Date;
+
+/**
+ * 邮箱记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-08
+ */
+@Data
+@TableName("ctop_mail_log")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_mail_log对象", description = "邮箱记录表")
+public class MailLog {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 发送邮箱
+     */
+    @Excel(name = "发送邮箱", width = 15)
+    @ApiModelProperty(value = "发送邮箱")
+    private String sendEmil;
+    /**
+     * 标题
+     */
+    @Excel(name = "标题", width = 15)
+    @ApiModelProperty(value = "标题")
+    private String subject;
+    /**
+     * 内容
+     */
+    @Excel(name = "内容", width = 15)
+    @ApiModelProperty(value = "内容")
+    private String content;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Project.java

@@ -77,6 +77,11 @@ public class Project {
     @Excel(name = "媒体类型", width = 15)
     @ApiModelProperty(value = "媒体类型")
     private String mediaId;
+
+    /**
+     * 最高出价
+     */
+    private Long maxBid;
     /**
      * 创建时间
      */

+ 3 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/ProjectMember.java

@@ -59,6 +59,9 @@ public class ProjectMember {
 
     private String roleCode;
 
+    @TableField(exist = false)
+    private Long maxBid;
+
 
     @TableField(exist = false)
     private String responsibleName;
@@ -73,7 +76,6 @@ public class ProjectMember {
     private String mediaId;
 
 
-
     /**
      * 创建时间
      */

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

@@ -0,0 +1,33 @@
+package org.jeecg.modules.ctop.job;
+
+import org.jeecg.modules.ctop.service.IBidWarningService;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 出价预警
+ */
+public class AccountBidJob implements Job {
+    @Autowired
+    private IBidWarningService bidWarningService;
+
+    /**
+     * 出价预警
+     *
+     * @param jobExecutionContext
+     * @throws JobExecutionException
+     */
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                bidWarningService.BidWarning();
+            }
+        };
+        thread.start();
+
+    }
+}

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

+ 18 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouAdvertiserCrawlerJob.java

@@ -15,17 +15,28 @@ public class KuaishouAdvertiserCrawlerJob implements Job {
     private IKuaishouAdAccountService kuaishouAdAccountService;
     @Autowired
     private IKuaishouAppService kuaishouAppService;
+
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        try{
+        try {
 
-            List<KuaishouAdAccount> list = kuaishouAdAccountService.querySyncAccount();
-            if (list != null){
-                for(KuaishouAdAccount account : list){
-                    kuaishouAppService.adAccountFetch(account,"");
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    List<KuaishouAdAccount> list = kuaishouAdAccountService.querySyncAccount();
+                    if (list != null) {
+                        for (KuaishouAdAccount account : list) {
+                            kuaishouAppService.adAccountFetch(account, "");
+                        }
+                    }
                 }
-            }
-        }catch (Exception e){
+
+
+            };
+            thread.start();
+
+
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }

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

@@ -0,0 +1,60 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+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.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+public class KuaishouCampaignGroupJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    static ExecutorService executorService = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                executorService = Executors.newFixedThreadPool(8);
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                //1:获取全量广告计划数据
+                                kuaishouInterfaceService.getCampaignList(token, null, null);
+                                //1:获取全量广告组数据
+                                kuaishouInterfaceService.getGroupList(token, null, null);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                            }
+                        }
+                    });
+                });
+                log.info("快手物料数据同步完成");
+            }
+
+        };
+        thread.start();
+
+
+    }
+}

+ 22 - 15
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoDelete.java

@@ -1,8 +1,8 @@
 package org.jeecg.modules.ctop.job;
 
-import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.quartz.Job;
@@ -22,21 +22,28 @@ public class KuaishouCommentAutoDelete implements Job {
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<BindAccountLogin>();
-        queryWrapper.eq("login_type", "kuaishou");
-        queryWrapper.eq("status", 1);
-        List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
-        if (list != null && list.size() > 0) {
-            for (BindAccountLogin account : list) {
-                try {
-                    log.info("正在删除评论:{}", account.getAccountName());
-                    kuaishouWebInterfaceService.adkuaishouWebLogin(account.getAccountName(), account.getPassword());
-                    kuaishouWebInterfaceService.deleteAllComment(new HashMap<>());
-                    Thread.sleep(10000);
-                } catch (Exception e) {
-                    e.printStackTrace();
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<BindAccountLogin>();
+                queryWrapper.eq("login_type", "kuaishou");
+                queryWrapper.eq("status", 1);
+                List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
+                if (list != null && list.size() > 0) {
+                    for (BindAccountLogin account : list) {
+                        try {
+                            log.info("正在删除评论:{}", account.getAccountName());
+                            kuaishouWebInterfaceService.adkuaishouWebLogin(account.getAccountName(), account.getPassword());
+                            kuaishouWebInterfaceService.deleteAllComment(new HashMap<>());
+                            Thread.sleep(10000);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
                 }
             }
-        }
+        };
+        thread.start();
+
     }
 }

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

@@ -0,0 +1,56 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+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;
+
+/**
+ * 快手广告主分天数据
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouDailyAccountReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date deleteDate = DateUtils.addDay(new Date(), -2);
+                kuaishouInterfaceService.deleteHourlyReport(deleteDate);
+                Date getDate = DateUtils.addDay(new Date(), -1);
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+
+                log.info("快手物料数据同步完成");
+
+                tokens.forEach(token -> {
+                    //1: 获取广告主信息数据
+                    kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate);
+
+                });
+            }
+        };
+        thread.start();
+
+    }
+}

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

@@ -0,0 +1,57 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+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;
+
+/**
+ * 广告计划分天报表
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouDailyCampaignReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date deleteDate = DateUtils.addDay(new Date(), -2);
+                kuaishouInterfaceService.deleteHourlyReport(deleteDate);
+                Date getDate = DateUtils.addDay(new Date(), -1);
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+
+                log.info("快手物料数据同步完成");
+
+                tokens.forEach(token -> {
+
+                    //获取广告计划信息数据
+                    kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate);
+
+                });
+            }
+        };
+        thread.start();
+
+    }
+}

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

@@ -0,0 +1,56 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+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;
+
+/**
+ * 获取创意分天报表
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouDailyCreativeReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date deleteDate = DateUtils.addDay(new Date(), -2);
+                kuaishouInterfaceService.deleteHourlyReport(deleteDate);
+                Date getDate = DateUtils.addDay(new Date(), -1);
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+
+                log.info("快手物料数据同步完成");
+
+                tokens.forEach(token -> {
+
+                    // 获取广告创意信息数据
+                    kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate);
+                });
+            }
+        };
+        thread.start();
+
+    }
+}

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

@@ -0,0 +1,58 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+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;
+
+/**
+ * 获取广告组分天报表
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouDailyGroupReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date deleteDate = DateUtils.addDay(new Date(), -2);
+                kuaishouInterfaceService.deleteHourlyReport(deleteDate);
+                Date getDate = DateUtils.addDay(new Date(), -1);
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+
+                log.info("快手物料数据同步完成");
+
+                tokens.forEach(token -> {
+
+                    //获取广告组信息数据
+                    kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, getDate, getDate);
+
+                });
+            }
+
+        };
+        thread.start();
+
+    }
+}

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

@@ -1,52 +0,0 @@
-package org.jeecg.modules.ctop.job;
-
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-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;
-
-/**
- * @author syh
- */
-@Slf4j
-public class KuaishouDailyReportLoadJob implements Job {
-    @Autowired
-    private ICtopOauthTokenService tokenService;
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-    @Override
-    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        Date deleteDate = DateUtils.addDay(new Date(), -2);
-        kuaishouInterfaceService.deleteHourlyReport(deleteDate);
-        Date getDate = DateUtils.addDay(new Date(), -1);
-        //1:查询当日数据
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-        if (null == tokens || tokens.size() <= 0) {
-            log.info("定时获取头条数据异常:为获取到可用的token");
-            return;
-        }
-
-        log.info("快手物料数据同步完成");
-
-        tokens.forEach(token -> {
-            //1: 获取广告主信息数据
-            kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate);
-            //2:获取广告计划信息数据
-            kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate);
-            //3:获取广告组信息数据
-            kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, getDate, getDate);
-            //4: 获取广告创意信息数据
-            kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate);
-//            kuaishouInterfaceService.loadAdvertiserCreativeReportDailyStatistic(token, getDate);
-        });
-    }
-}

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

@@ -0,0 +1,83 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+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.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 获取广告主分时报表
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouHourlyAccountReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    static ExecutorService executorService = null;
+    //线程计数器
+    static CountDownLatch countDownLatch = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date getDate = new Date();
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
+                String hour = simpleDateFormat.format(getDate);
+                if (null != hour && "00".equals(hour)) {
+                    getDate = DateUtils.addDay(getDate, -1);
+                }
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+                executorService = Executors.newFixedThreadPool(7);
+                countDownLatch = new CountDownLatch(tokens.size());
+                Date finalGetDate = getDate;
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                // 获取广告主时报
+                                kuaishouInterfaceService.getAdvertiserReportHourly(token, finalGetDate, finalGetDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                                countDownLatch.countDown();
+                            }
+                        }
+                    });
+                });
+                try {
+                    countDownLatch.await();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                executorService.shutdown();
+            }
+        };
+        thread.start();
+
+    }
+}

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

@@ -0,0 +1,85 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+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.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 获取广告计划分时报表
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouHourlyCampaignReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    static ExecutorService executorService = null;
+    //线程计数器
+    static CountDownLatch countDownLatch = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date getDate = new Date();
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
+                String hour = simpleDateFormat.format(getDate);
+                if (null != hour && "00".equals(hour)) {
+                    getDate = DateUtils.addDay(getDate, -1);
+                }
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+                executorService = Executors.newFixedThreadPool(5);
+                countDownLatch = new CountDownLatch(tokens.size());
+                Date finalGetDate = getDate;
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                // 获取 广告计划时报
+                                kuaishouInterfaceService.getAdvertiserCampaignReportHourly(token, finalGetDate, finalGetDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                                countDownLatch.countDown();
+                            }
+                        }
+                    });
+                });
+                try {
+                    countDownLatch.await();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                executorService.shutdown();
+            }
+        };
+        thread.start();
+
+
+    }
+}

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

@@ -0,0 +1,88 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+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.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 获取 广告创意分时数据
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouHourlyCreativeReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    static ExecutorService executorService = null;
+    //线程计数器
+    static CountDownLatch countDownLatch = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date getDate = new Date();
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
+                String hour = simpleDateFormat.format(getDate);
+                if (null != hour && "00".equals(hour)) {
+                    getDate = DateUtils.addDay(getDate, -1);
+                }
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+                executorService = Executors.newFixedThreadPool(5);
+                countDownLatch = new CountDownLatch(tokens.size());
+                Date finalGetDate = getDate;
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+
+                                //4: 获取广告创意信息数据
+                                kuaishouInterfaceService.getAdvertiserCreativeReportHourly(token, finalGetDate, finalGetDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                                countDownLatch.countDown();
+                            }
+                        }
+                    });
+                });
+                try {
+                    countDownLatch.await();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                executorService.shutdown();
+                for (CtopOauthToken token : tokens) {
+                    kuaishouInterfaceService.updateCreativeReportHourlyStatistic(token, getDate);
+                }
+            }
+
+        };
+        thread.start();
+
+    }
+}

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

@@ -0,0 +1,84 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+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.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 获取 广告组分时数据
+ *
+ * @author syh
+ */
+@Slf4j
+public class KuaishouHourlyGroupReportLoadJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+    static ExecutorService executorService = null;
+    //线程计数器
+    static CountDownLatch countDownLatch = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date getDate = new Date();
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
+                String hour = simpleDateFormat.format(getDate);
+                if (null != hour && "00".equals(hour)) {
+                    getDate = DateUtils.addDay(getDate, -1);
+                }
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取头条数据异常:为获取到可用的token");
+                    return;
+                }
+                executorService = Executors.newFixedThreadPool(5);
+                countDownLatch = new CountDownLatch(tokens.size());
+                Date finalGetDate = getDate;
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                //3:获取广告组信息数据
+                                kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, finalGetDate, finalGetDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                                countDownLatch.countDown();
+                            }
+                        }
+                    });
+                });
+                try {
+                    countDownLatch.await();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+
+                executorService.shutdown();
+            }
+        };
+        thread.start();
+
+    }
+}

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

@@ -1,84 +0,0 @@
-package org.jeecg.modules.ctop.job;
-
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-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.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * @author syh
- */
-@Slf4j
-public class KuaishouHourlyReportLoadJob implements Job {
-    @Autowired
-    private ICtopOauthTokenService tokenService;
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-
-    static ExecutorService executorService = null;
-    /**
-     * 线程计数器
-     */
-    static CountDownLatch countDownLatch = null;
-
-    @Override
-    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        Date getDate = new Date();
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
-        String hour = simpleDateFormat.format(getDate);
-        if (null != hour && "00".equals(hour)) {
-            getDate = DateUtils.addDay(getDate, -1);
-        }
-        //1:查询当日数据
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-        if (null == tokens || tokens.size() <= 0) {
-            log.info("定时获取头条数据异常:为获取到可用的token");
-            return;
-        }
-        executorService = Executors.newFixedThreadPool(10);
-        countDownLatch = new CountDownLatch(tokens.size());
-        Date finalGetDate = getDate;
-        tokens.forEach(token -> {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        kuaishouInterfaceService.getAdvertiserReportHourly(token, finalGetDate, finalGetDate);
-                        //2:获取广告计划信息数据
-                        kuaishouInterfaceService.getAdvertiserCampaignReportHourly(token, finalGetDate, finalGetDate);
-                        //3:获取广告组信息数据
-                        kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, finalGetDate, finalGetDate);
-                        //4: 获取广告创意信息数据
-                        kuaishouInterfaceService.getAdvertiserCreativeReportHourly(token, finalGetDate, finalGetDate);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                        countDownLatch.countDown();
-                    }
-                }
-            });
-        });
-        try {
-            countDownLatch.await();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-        executorService.shutdown();
-        for (CtopOauthToken token : tokens) {
-            kuaishouInterfaceService.updateCreativeReportHourlyStatistic(token, getDate);
-        }
-    }
-}

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

@@ -27,36 +27,40 @@ 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);
-
-        executorService = Executors.newFixedThreadPool(10);
-        tokens.forEach(token -> {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        //1:获取全量广告计划数据
-                        kuaishouInterfaceService.getCampaignList(token,startDate,endDate);
-                        //1:获取全量广告组数据
-                        kuaishouInterfaceService.getGroupList(token,startDate,endDate);
-                        //1:获取全量创意数据
-                        kuaishouInterfaceService.getCreativeList(token,startDate,endDate);
-                        //2:获取全量视频素材数据
-                        kuaishouInterfaceService.getVideoList(token,startDate,endDate);
-                        //3: 获取图片信息数据
-                        kuaishouInterfaceService.getImageList(token,startDate,endDate);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                    }
-                }
-            });
-        });
-        log.info("快手物料数据同步完成");
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                //增加接口的开始和结束日期
+                Date startDate = DateUtils.addDay(new Date(), -1);
+                Date endDate = new Date();
+
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+
+                executorService = Executors.newFixedThreadPool(5);
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+
+                                //1:获取全量创意数据
+                                kuaishouInterfaceService.getCreativeList(token, startDate, endDate);
+                                //2:获取全量视频素材数据
+                                kuaishouInterfaceService.getVideoList(token, startDate, endDate);
+                                //3: 获取图片信息数据
+                                kuaishouInterfaceService.getImageList(token, startDate, endDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                            }
+                        }
+                    });
+                });
+                log.info("快手物料数据同步完成");
+            }
+        };
+        thread.start();
+
     }
 }

+ 8 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/RefreshTokenJob.java

@@ -18,6 +18,13 @@ public class RefreshTokenJob implements Job {
      */
     @Override
     public void execute(JobExecutionContext jobExecutionContext) {
-        refreshTokenService.getRefresh();
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                refreshTokenService.getRefresh();
+            }
+        };
+        thread.start();
+
     }
 }

+ 23 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MailLogMapper.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.ctop.entity.MailLog;
+
+import java.util.List;
+
+/**
+ * 邮箱记录表
+ *
+ * @author: jeecg-boot
+ * @date: 2019-12-08
+ * @cersion: V1.0
+ */
+public interface MailLogMapper extends BaseMapper<MailLog> {
+
+    Integer selectCountByAccountIdAndDate(@Param("accountId") Long accountId, @Param("createTime") String createTime);
+
+    List<String> selectMailList(@Param("projectId") Long projectId);
+
+    List<String> selectWeiXinIdList(@Param("projectId") Long projectId);
+}

+ 41 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MailLogMapper.xml

@@ -0,0 +1,41 @@
+<?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="org.jeecg.modules.ctop.mapper.MailLogMapper">
+
+
+    <select id="selectCountByAccountIdAndDate" resultType="java.lang.Integer">
+
+        select
+        count(1)
+        from
+        ctop_mail_log
+        where account_id = #{accountId}
+        and DATE_FORMAT(create_time,'%Y-%m-%d') = #{createTime}
+
+
+    </select>
+    <select id="selectMailList" resultType="java.lang.String">
+     select
+     t2.email
+     from
+     ctop_project_member t1
+     left join sys_user t2
+     on t1.user_id = t2.id
+     where t1.project_id = #{projectId}
+     and t2.email != ''
+    </select>
+
+
+    <select id="selectWeiXinIdList" resultType="java.lang.String">
+     select
+     t2.wexin_id
+     from
+     ctop_project_member t1
+     left join ctop_corp_wexin_user t2
+     on t1.user_id = t2.user_id
+     where t1.project_id = #{projectId}
+     and t2.wexin_id != ''
+    </select>
+
+
+</mapper>

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IBidWarningService.java

@@ -0,0 +1,7 @@
+package org.jeecg.modules.ctop.service;
+
+public interface IBidWarningService {
+    void BidWarning();
+
+
+}

+ 15 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IMailLogService.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.ctop.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ctop.entity.MailLog;
+
+/**
+ * 邮箱记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-08
+ */
+public interface IMailLogService extends IService<MailLog> {
+
+}

+ 116 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java

@@ -0,0 +1,116 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import cn.com.ctop.common.module.utils.SendMailUtil;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.entity.MailLog;
+import org.jeecg.modules.ctop.entity.Project;
+import org.jeecg.modules.ctop.mapper.MailLogMapper;
+import org.jeecg.modules.ctop.mapper.ProjectMapper;
+import org.jeecg.modules.ctop.service.IBidWarningService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+
+/**
+ * 出价预警
+ */
+@Slf4j
+@Service
+public class BidWarningServiceImpl implements IBidWarningService {
+
+    @Autowired
+    private ProjectMapper projectMapper;
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+    @Autowired
+    private KuaiShouGroupMapper groupMapper;
+    @Autowired
+    private MailLogMapper mailLogMapper;
+
+
+    /**
+     * 预警
+     */
+
+    @Override
+    public void BidWarning() {
+        log.info("开始出价预警定时任务");
+        long l = System.currentTimeMillis();
+        try {
+            QueryWrapper<Project> projectQueryWrapper = new QueryWrapper<>();
+            projectQueryWrapper.eq("media_id", "2");
+            List<Project> projects = projectMapper.selectList(projectQueryWrapper);
+            if (!Check.isNull(projects)) {
+                for (Project project : projects) {
+                    Long maxBid = project.getMaxBid();
+                    Long projectId = project.getId();
+                    QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+                    userAllocationQueryWrapper.eq("project_id", projectId);
+                    List<UserAllocation> userAllocations = userAllocationMapper.selectList(userAllocationQueryWrapper);
+                    if (!Check.isNull(userAllocations)) {
+                        for (UserAllocation userAllocation : userAllocations) {
+                            Long accountId = userAllocation.getAccountId();
+                            List<String> unitWarning = groupMapper.selectWarningGroup(accountId, maxBid);
+                            if (!Check.isNull(unitWarning)) {
+                                sendMessage(accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
+                            }
+                        }
+                    }
+                }
+            }
+            log.info("出价预警定时任务执行完毕,共耗时:{} s", (System.currentTimeMillis() - l) / 1000);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+
+    }
+
+
+    private void sendMessage(Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) {
+
+        String createTime = DateUtils.getNowDate("yyyy-MM-dd");
+        Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime);
+        StringBuilder text = new StringBuilder();
+
+
+        String s = "";
+        for (int i = 0; i < unitWarning.size(); i++) {
+            s += unitWarning.get(i) + "," + "<br/>";
+
+        }
+        text.append("您的项目:").append(projectName + ",").append("<br/>")
+                .append("授权名称为:" + authName + " 下的,").append("<br/>").append(s)
+                .append("大于项目设置的最高出价:").append(maxBid / 1000).append(" 元! 请您及时调整。");
+        if (count < 3) {
+            List<String> mailList = mailLogMapper.selectMailList(projectId);
+            String subject = "广告组出价预警";
+            try {
+                SendMailUtil.sendMail(mailList, subject, text.toString());
+                MailLog mailLog = new MailLog();
+                mailLog.setAccountId(accountId);
+                mailLog.setContent(text.toString());
+                mailLog.setSendEmil(JSON.toJSONString(mailList));
+                mailLog.setSubject(subject);
+                mailLogMapper.insert(mailLog);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+
+
+    }
+}

+ 19 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MailLogServiceImpl.java

@@ -0,0 +1,19 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ctop.entity.MailLog;
+import org.jeecg.modules.ctop.mapper.MailLogMapper;
+import org.jeecg.modules.ctop.service.IMailLogService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 邮箱记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-08
+ */
+@Service
+public class MailLogServiceImpl extends ServiceImpl<MailLogMapper, MailLog> implements IMailLogService {
+
+}

+ 162 - 158
jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/mock/MockController.java

@@ -1,205 +1,209 @@
 package org.jeecg.modules.demo.mock;
 
+import cn.com.ctop.common.module.utils.Check;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.swing.filechooser.FileSystemView;
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.swing.filechooser.FileSystemView;
-
-import org.apache.commons.io.IOUtils;
-import org.jeecg.common.api.vo.Result;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import lombok.extern.slf4j.Slf4j;
-
 @RestController
 @RequestMapping("/api")
 @Slf4j
 public class MockController {
 
-	private final String JSON_PATH = "classpath:org/jeecg/modules/demo/mock/json";
+    private final String JSON_PATH = "classpath:org/jeecg/modules/demo/mock/json";
 
-	/**
-	 * 通用json访问接口
-	 * 格式: http://localhost:8080/jeecg-boot/api/json/{filename}
-	 * @param filename
-	 * @return
-	 */
-	@RequestMapping(value = "/json/{filename}", method = RequestMethod.GET)
-	public String getJsonData(@PathVariable String filename) {
-		String jsonpath = "classpath:org/jeecg/modules/demo/mock/json/"+filename+".json";
-		return readJson(jsonpath);
-	}
+    /**
+     * 通用json访问接口
+     * 格式: http://localhost:8080/jeecg-boot/api/json/{filename}
+     *
+     * @param filename
+     * @return
+     */
+    @RequestMapping(value = "/json/{filename}", method = RequestMethod.GET)
+    public String getJsonData(@PathVariable String filename) {
+        String jsonpath = "classpath:org/jeecg/modules/demo/mock/json/" + filename + ".json";
+        return readJson(jsonpath);
+    }
 
     @GetMapping(value = "/asynTreeList")
-	public String asynTreeList(String id) {
-		return readJson(JSON_PATH + "/asyn_tree_list_" + id + ".json");
-	}
+    public String asynTreeList(String id) {
+        return readJson(JSON_PATH + "/asyn_tree_list_" + id + ".json");
+    }
 
     @GetMapping(value = "/user")
-	public String user() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/user.json");
-	}
+    public String user() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/user.json");
+    }
 
     /**
-	 * 老的登录获取用户信息接口
-	 * @return
-	 */
-	@GetMapping(value = "/user/info")
-	public String userInfo() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/user_info.json");
-	}
-
-	@GetMapping(value = "/role")
-	public String role() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/role.json");
-	}
-
-	@GetMapping(value = "/service")
-	public String service() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/service.json");
-	}
-
-	@GetMapping(value = "/permission")
-	public String permission() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/permission.json");
-	}
-
-	@GetMapping(value = "/permission/no-pager")
+     * 老的登录获取用户信息接口
+     *
+     * @return
+     */
+    @GetMapping(value = "/user/info")
+    public String userInfo() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/user_info.json");
+    }
+
+    @GetMapping(value = "/role")
+    public String role() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/role.json");
+    }
+
+    @GetMapping(value = "/service")
+    public String service() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/service.json");
+    }
+
+    @GetMapping(value = "/permission")
+    public String permission() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/permission.json");
+    }
+
+    @GetMapping(value = "/permission/no-pager")
     public String permissionNoPage() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/permission_no_page.json");
-	}
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/permission_no_page.json");
+    }
 
     /**
-	 * 省市县
-	 */
-	@GetMapping(value = "/area")
-	public String area() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/area.json");
-	}
+     * 省市县
+     */
+    @GetMapping(value = "/area")
+    public String area() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/area.json");
+    }
 
     /**
-	  * 测试报表数据
-	 */
-	@GetMapping(value = "/report/getYearCountInfo")
-	public String getYearCountInfo() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
-	}
-	@GetMapping(value = "/report/getMonthCountInfo")
-	public String getMonthCountInfo() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
-	}
-	@GetMapping(value = "/report/getCntrNoCountInfo")
-	public String getCntrNoCountInfo() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
-	}
-	@GetMapping(value = "/report/getCabinetCountInfo")
-	public String getCabinetCountInfo() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
-	}
+     * 测试报表数据
+     */
+    @GetMapping(value = "/report/getYearCountInfo")
+    public String getYearCountInfo() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
+    }
+
+    @GetMapping(value = "/report/getMonthCountInfo")
+    public String getMonthCountInfo() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
+    }
+
+    @GetMapping(value = "/report/getCntrNoCountInfo")
+    public String getCntrNoCountInfo() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
+    }
+
+    @GetMapping(value = "/report/getCabinetCountInfo")
+    public String getCabinetCountInfo() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/getCntrNoCountInfo.json");
+    }
 
     /**
-	   * 实时磁盘监控
-	 * @param request
-	 * @param response
-	 * @return
-	 */
-	@GetMapping("/queryDiskInfo")
-	public Result<List<Map<String,Object>>> queryDiskInfo(HttpServletRequest request, HttpServletResponse response){
-		Result<List<Map<String,Object>>> res = new Result<>();
-		try {
-			// 当前文件系统类
-	        FileSystemView fsv = FileSystemView.getFileSystemView();
-	        // 列出所有windows 磁盘
-	        File[] fs = File.listRoots();
-	        log.info("查询磁盘信息:"+fs.length+"个");
-	        List<Map<String,Object>> list = new ArrayList<>();
+     * 实时磁盘监控
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @GetMapping("/queryDiskInfo")
+    public Result<List<Map<String, Object>>> queryDiskInfo(HttpServletRequest request, HttpServletResponse response) {
+        Result<List<Map<String, Object>>> res = new Result<>();
+        try {
+            // 当前文件系统类
+            FileSystemView fsv = FileSystemView.getFileSystemView();
+            // 列出所有windows 磁盘
+            File[] fs = File.listRoots();
+            log.info("查询磁盘信息:" + fs.length + "个");
+            List<Map<String, Object>> list = new ArrayList<>();
 
             for (int i = 0; i < fs.length; i++) {
-	        	if(fs[i].getTotalSpace()==0) {
-	        		continue;
-	        	}
-	        	Map<String,Object> map = new HashMap<>();
-	        	map.put("name", fsv.getSystemDisplayName(fs[i]));
-	        	map.put("max", fs[i].getTotalSpace());
-	        	map.put("rest", fs[i].getFreeSpace());
-	        	map.put("restPPT", fs[i].getFreeSpace()*100/fs[i].getTotalSpace());
-	        	list.add(map);
-	        	log.info(map.toString());
-	        }
-	        res.setResult(list);
-	        res.success("查询成功");
-		} catch (Exception e) {
-			res.error500("查询失败"+e.getMessage());
-		}
-		return res;
-	}
-
-	/**
-	 * 工作台首页的数据
-	 * @return
-	 */
-	@GetMapping(value = "/list/search/projects")
-	public String projects() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_projects.json");
-	}
-
-	@GetMapping(value = "/workplace/activity")
-	public String activity() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_activity.json");
-	}
+                if (fs[i].getTotalSpace() == 0) {
+                    continue;
+                }
+                Map<String, Object> map = new HashMap<>();
+                map.put("name", fsv.getSystemDisplayName(fs[i]));
+                map.put("max", fs[i].getTotalSpace());
+                map.put("rest", fs[i].getFreeSpace());
+                map.put("restPPT", fs[i].getFreeSpace() * 100 / fs[i].getTotalSpace());
+                list.add(map);
+                log.info(map.toString());
+            }
+            res.setResult(list);
+            res.success("查询成功");
+        } catch (Exception e) {
+            res.error500("查询失败" + e.getMessage());
+        }
+        return res;
+    }
+
+    /**
+     * 工作台首页的数据
+     *
+     * @return
+     */
+    @GetMapping(value = "/list/search/projects")
+    public String projects() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_projects.json");
+    }
+
+    @GetMapping(value = "/workplace/activity")
+    public String activity() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_activity.json");
+    }
 
     @GetMapping(value = "/workplace/teams")
-	public String teams() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_teams.json");
-	}
+    public String teams() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_teams.json");
+    }
 
     @GetMapping(value = "/workplace/radar")
-	public String radar() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_radar.json");
-	}
+    public String radar() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/workplace_radar.json");
+    }
 
     @GetMapping(value = "/task/process")
-	public String taskProcess() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/task_process.json");
-	}
+    public String taskProcess() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/task_process.json");
+    }
 
     /**
      * author:lvdandan-----date:20190315---for:添加数据日志json----
      *
      * @return 数据日志
      */
-	public String sysDataLogJson() {
-		return readJson("classpath:org/jeecg/modules/demo/mock/json/sysdatalog.json");
-	}
+    public String sysDataLogJson() {
+        return readJson("classpath:org/jeecg/modules/demo/mock/json/sysdatalog.json");
+    }
 
     /**
-	 * 读取json格式文件
-	 * @param jsonSrc
-	 * @return
-	 */
-	private String readJson(String jsonSrc) {
-		String json = "";
-		try {
-			//File jsonFile = ResourceUtils.getFile(jsonSrc);
-			//json = FileUtils.re.readFileToString(jsonFile);
-			//换个写法,解决springboot读取jar包中文件的问题
-			InputStream stream = getClass().getClassLoader().getResourceAsStream(jsonSrc.replace("classpath:", ""));
-            json = stream.toString();
+     * 读取json格式文件
+     *
+     * @param jsonSrc
+     * @return
+     */
+    private String readJson(String jsonSrc) {
+        String json = "";
+        try {
+            //File jsonFile = ResourceUtils.getFile(jsonSrc);
+            //json = FileUtils.re.readFileToString(jsonFile);
+            //换个写法,解决springboot读取jar包中文件的问题
+            InputStream stream = getClass().getClassLoader().getResourceAsStream(jsonSrc.replace("classpath:", ""));
+            if (!Check.isNull(stream)) {
+                json = stream.toString();
+            }
+
 //			json = IOUtils.toString(stream);
         } catch (Exception e) {
-			log.error(e.getMessage(),e);
-		}
-		return json;
-	}
+            log.error(e.getMessage(), e);
+        }
+        return json;
+    }
 }

+ 69 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.system.controller;
 
+import cn.com.ctop.common.module.entity.CtopCorpWexinUser;
+import cn.com.ctop.common.module.service.ICtopCorpWexinUserService;
 import cn.com.ctop.common.module.utils.AesEncryptUtil;
 import cn.com.ctop.common.module.utils.EncryptedString;
 import cn.hutool.core.util.RandomUtil;
@@ -8,6 +10,16 @@ import com.aliyuncs.exceptions.ClientException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import lombok.val;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.api.WxCpOAuth2Service;
+import me.chanjar.weixin.cp.api.WxCpUserService;
+import me.chanjar.weixin.cp.api.impl.WxCpOAuth2ServiceImpl;
+import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
+import me.chanjar.weixin.cp.api.impl.WxCpUserServiceImpl;
+import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
+import me.chanjar.weixin.cp.bean.WxCpUser;
+import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.subject.Subject;
 import org.jeecg.common.api.vo.Result;
@@ -52,6 +64,63 @@ public class LoginController {
     private RedisUtil redisUtil;
     @Autowired
     private ISysDepartService sysDepartService;
+    @Autowired
+    private ICtopCorpWexinUserService ctopCorpWexinUserService;
+
+    @RequestMapping(value = "/wxlogin", method = RequestMethod.POST)
+    @ApiOperation("企业微信登录接口")
+    public Result<JSONObject> wxlogin(@RequestParam(name = "code") String code) throws Exception {
+        Result<JSONObject> result = new Result<JSONObject>();
+        val configStorage = new WxCpDefaultConfigImpl();
+        configStorage.setCorpId("ww24b8a47826f5875f");
+        configStorage.setAgentId(1000002);
+        configStorage.setCorpSecret("MJIlySADGPlgvADnkFQPUpfZD4yV-4WN6066OgNnb0s");
+        configStorage.setToken("hcst2019");
+        configStorage.setAesKey("hcst2019");
+        val service = new WxCpServiceImpl();
+
+        service.setWxCpConfigStorage(configStorage);
+        WxCpOAuth2Service wxCpOAuth2Service = service.getOauth2Service();
+        ;
+        try {
+            WxCpOauth2UserInfo userInfo = wxCpOAuth2Service.getUserInfo(1000002, code);
+            if (userInfo != null && userInfo.getUserId() != null) {
+                WxCpUserService wxCpUserService = new WxCpUserServiceImpl(service);
+                WxCpUser user = wxCpUserService.getById(userInfo.getUserId());
+                String email = user.getEmail();
+                SysUser sysUser = sysUserService.getUserByEmail(email);
+                if (sysUser == null) {
+                    result.error500("该用户未注册系统账户,请联系管理员");
+                    return result;
+                }
+                String departId = sysDepartService.selectIdByOrdCode(sysUser.getOrgCode());
+                sysUser.setDepartId(departId);
+                result = sysUserService.checkUserIsEffective(sysUser);
+                if (!result.isSuccess()) {
+                    return result;
+                }
+                //用户登录信息
+                userInfo(sysUser, result);
+                sysBaseApi.addLog("用户名: " + email + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
+                CtopCorpWexinUser ctopCorpWexinUser = ctopCorpWexinUserService.getById(sysUser.getId());
+                if (ctopCorpWexinUser == null) {
+                    ctopCorpWexinUser = new CtopCorpWexinUser();
+                    ctopCorpWexinUser.setUserId(sysUser.getId());
+                    ctopCorpWexinUser.setWexinEmail(user.getEmail());
+                    ctopCorpWexinUser.setWexinGender(user.getGender().getGenderName());
+                    ctopCorpWexinUser.setWexinName(user.getName());
+                    ctopCorpWexinUser.setWexinId(user.getUserId());
+                    ctopCorpWexinUser.setWexinMobile(user.getMobile());
+                    ctopCorpWexinUserService.save(ctopCorpWexinUser);
+                }
+                return result;
+            }
+        } catch (WxErrorException e) {
+            result.error500("企业微信授权错误");
+            e.printStackTrace();
+        }
+        return result;
+    }
 
     @RequestMapping(value = "/login", method = RequestMethod.POST)
     @ApiOperation("登录接口")

+ 120 - 0
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,10 +1,16 @@
 package org.jeecg;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumJobService;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.impl.client.BasicCookieStore;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.service.IBidWarningService;
 import org.jeecg.modules.ctop.service.ICreateInternalService;
 import org.jeecg.modules.mq.Sender;
 import org.junit.Test;
@@ -19,6 +25,16 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import javax.mail.Message;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
 @RunWith(SpringRunner.class)
 @SpringBootTest
 @Slf4j
@@ -31,6 +47,7 @@ public class SampleTest {
     private ICreateInternalService createInternalService;
     @Autowired
     private IAppiumTaskService appiumTaskService;
+
     @Test
     public void testKs() throws InterruptedException {
         String url = "https://ad.e.kuaishou.com/#/welcome?redirectUrl=https%3A%2F%2Fad.e.kuaishou.com%2F%23%2Findex";
@@ -103,4 +120,107 @@ public class SampleTest {
         Sender sender = new Sender();
         sender.send();
     }
+
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private CtopOauthTokenMapper tokenMapper;
+
+    @Test
+    public void loadKuaishouDataSingle() {
+
+
+        Date endDate = new Date();
+        QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+        tokenQueryWrapper.eq("media_id", 2);
+        List<CtopOauthToken> ctopOauthTokens = tokenMapper.selectList(tokenQueryWrapper);
+        for (CtopOauthToken token : ctopOauthTokens) {
+
+
+            for (int i = 0; i < 7; i++) {
+                Date getStartDate = DateUtils.addDay(endDate, -i);
+
+                //3:获取广告组信息数据
+                kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, getStartDate, getStartDate);
+
+            }
+            for (int i = 0; i < 6; i++) {
+                Date getStartDate = new Date();
+                Date getEndDate = new Date();
+                if (i == 0) {
+                    getStartDate = DateUtils.addDay(endDate, -175 + i * 30);
+                    getEndDate = DateUtils.addDay(endDate, -150 + i * 30);
+                } else {
+                    getStartDate = DateUtils.addDay(endDate, -180 + i * 30);
+                    getEndDate = DateUtils.addDay(endDate, -150 + i * 30);
+                }
+
+                //3:获取广告组信息数据
+                kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, getStartDate, getEndDate);
+
+            }
+
+
+        }
+
+
+    }
+
+    @Test
+    public void testMail() throws Exception {
+        Properties properties = new Properties();
+        properties.put("mail.transport.protocol", "smtp");// 连接协议
+        properties.put("mail.smtp.host", "smtp.exmail.qq.com");// 主机名
+        properties.put("mail.smtp.port", 465);// 端口号
+        properties.put("mail.smtp.auth", "true");
+        properties.put("mail.smtp.ssl.enable", "true");// 设置是否使用ssl安全连接 ---一般都使用
+        properties.put("mail.debug", "true");// 设置是否显示debug信息 true 会在控制台显示相关信息
+        // 得到回话对象
+        Session session = Session.getInstance(properties);
+        // 获取邮件对象
+        Message message = new MimeMessage(session);
+        // 设置发件人邮箱地址
+        message.setFrom(new InternetAddress("notice@c-top.com.cn"));
+        // 设置收件人邮箱地址
+
+
+        List<String> mails = new ArrayList<>();
+        mails.add("yumengmeng@c-top.com.cn");
+        mails.add("zhuxinbo@c-top.com.cn");
+
+        InternetAddress[] internetAddresses = new InternetAddress[mails.size()];
+        for (int i = 0; i < mails.size(); i++) {
+            InternetAddress addr = new InternetAddress(mails.get(i));
+            internetAddresses[i] = addr;
+        }
+
+        message.setRecipients(Message.RecipientType.TO, internetAddresses);
+        //  message.setRecipients(Message.RecipientType.TO, new InternetAddress[]{new InternetAddress("yumengmeng@c-top.com.cn"),new InternetAddress("zhuxinbo@c-top.com.cn")});
+        //message.setRecipient(Message.RecipientType.TO, new InternetAddress("xxx@qq.com"));//一个收件人
+        // 设置邮件标题
+        message.setSubject("测试邮件");
+        // 设置邮件内容
+        message.setText("你好啊");
+        // 得到邮差对象
+        Transport transport = session.getTransport();
+        // 连接自己的邮箱账户
+        transport.connect("notice@c-top.com.cn", "Hcst@2019");// 密码为QQ邮箱开通的stmp服务后得到的客户端授权码
+        // 发送邮件
+        transport.sendMessage(message, message.getAllRecipients());
+        transport.close();
+    }
+
+
+    @Autowired
+    private IBidWarningService bidWarningService;
+
+    @Test
+    public void testMa() throws Exception {
+        bidWarningService.BidWarning();
+    }
+
+
 }
+
+
+

+ 80 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/CtopCorpWexinUser.java

@@ -0,0 +1,80 @@
+package cn.com.ctop.common.module.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 企业微信用户表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-08
+ */
+@Data
+@TableName("ctop_corp_wexin_user")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_corp_wexin_user对象", description = "企业微信用户表")
+public class CtopCorpWexinUser {
+
+    /**
+     * userId
+     */
+    @TableId(type = IdType.INPUT)
+    @Excel(name = "userId", width = 15)
+    @ApiModelProperty(value = "userId")
+    private String userId;
+    /**
+     * wexinId
+     */
+    @Excel(name = "wexinId", width = 15)
+    @ApiModelProperty(value = "wexinId")
+    private String wexinId;
+    /**
+     * wexinName
+     */
+    @Excel(name = "wexinName", width = 15)
+    @ApiModelProperty(value = "wexinName")
+    private String wexinName;
+    /**
+     * wexinMobile
+     */
+    @Excel(name = "wexinMobile", width = 15)
+    @ApiModelProperty(value = "wexinMobile")
+    private String wexinMobile;
+    /**
+     * wexinEmail
+     */
+    @Excel(name = "wexinEmail", width = 15)
+    @ApiModelProperty(value = "wexinEmail")
+    private String wexinEmail;
+    /**
+     * wexinGender
+     */
+    @Excel(name = "wexinGender", width = 15)
+    @ApiModelProperty(value = "wexinGender")
+    private String wexinGender;
+    /**
+     * createTime
+     */
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+}

+ 18 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/CtopCorpWexinUserMapper.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.common.module.mapper;
+
+import java.util.List;
+
+import cn.com.ctop.common.module.entity.CtopCorpWexinUser;
+import org.apache.ibatis.annotations.Param;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 企业微信用户表
+ *
+ * @author: jeecg-boot
+ * @date: 2019-12-08
+ * @cersion: V1.0
+ */
+public interface CtopCorpWexinUserMapper extends BaseMapper<CtopCorpWexinUser> {
+
+}

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopCorpWexinUserMapper.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.common.module.mapper.CtopCorpWexinUserMapper">
+
+</mapper>

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/ICorpWeixinService.java

@@ -0,0 +1,4 @@
+package cn.com.ctop.common.module.service;
+
+public interface ICorpWeixinService {
+}

+ 15 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/ICtopCorpWexinUserService.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.CtopCorpWexinUser;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 企业微信用户表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-08
+ */
+public interface ICtopCorpWexinUserService extends IService<CtopCorpWexinUser> {
+
+}

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

+ 56 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CorpWeixinServiceImpl.java

@@ -0,0 +1,56 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.service.ICorpWeixinService;
+import com.google.gson.Gson;
+import lombok.extern.slf4j.Slf4j;
+import lombok.val;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.api.WxCpChatService;
+import me.chanjar.weixin.cp.api.WxCpOAuth2Service;
+import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.api.WxCpUserService;
+import me.chanjar.weixin.cp.api.impl.WxCpChatServiceImpl;
+import me.chanjar.weixin.cp.api.impl.WxCpOAuth2ServiceImpl;
+import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
+import me.chanjar.weixin.cp.api.impl.WxCpUserServiceImpl;
+import me.chanjar.weixin.cp.bean.WxCpAppChatMessage;
+import me.chanjar.weixin.cp.bean.WxCpMessage;
+import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
+import me.chanjar.weixin.cp.bean.WxCpUser;
+import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class CorpWeixinServiceImpl implements ICorpWeixinService {
+    public static void main(String[] args) {
+        val configStorage = new WxCpDefaultConfigImpl();
+        configStorage.setCorpId("ww24b8a47826f5875f");
+        configStorage.setAgentId(1000002);
+        configStorage.setCorpSecret("MJIlySADGPlgvADnkFQPUpfZD4yV-4WN6066OgNnb0s");
+        configStorage.setToken("hcst2019");
+        configStorage.setAesKey("hcst2019");
+        val service = new WxCpServiceImpl();
+
+        service.setWxCpConfigStorage(configStorage);
+        WxCpOAuth2Service wxCpOAuth2Service = new WxCpOAuth2ServiceImpl(service);
+        try {
+//            WxCpOauth2UserInfo userInfo = wxCpOAuth2Service.getUserInfo(1000002,"_Mq0Dx1dynryHsgBkoU1dAk5A3Y7lrfg8V0GDv4ocWQ");
+//            System.out.println(new Gson().toJson(userInfo));
+//            WxCpUserService wxCpUserService = new WxCpUserServiceImpl(service);
+//            WxCpUser user = wxCpUserService.getById("YiErSanSi");
+//            System.out.println(new Gson().toJson(user));
+            WxCpMessage message = new WxCpMessage();
+            message.setToUser("YiErSanSi");
+            message.setAgentId(1000002);
+            message.setContent("测试消息");
+            message.setMsgType("text");
+            service.messageSend(message);
+//            service.post("https://qyapi.weixin.qq.com/cgi-bin/message/send","touser=YiErSanSi&content=123&agentid=1000002&msgtype=text");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+}

+ 20 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopCorpWexinUserServiceImpl.java

@@ -0,0 +1,20 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopCorpWexinUser;
+import cn.com.ctop.common.module.mapper.CtopCorpWexinUserMapper;
+import cn.com.ctop.common.module.service.ICtopCorpWexinUserService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * 企业微信用户表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-08
+ */
+@Service
+public class CtopCorpWexinUserServiceImpl extends ServiceImpl<CtopCorpWexinUserMapper, CtopCorpWexinUser> implements ICtopCorpWexinUserService {
+
+}

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

+ 49 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/CorpWexinUtils.java

@@ -0,0 +1,49 @@
+package cn.com.ctop.common.module.utils;
+
+import lombok.val;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
+import me.chanjar.weixin.cp.bean.WxCpMessage;
+import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
+
+import java.util.List;
+
+public class CorpWexinUtils {
+    private static WxCpService wxCpService;
+
+    {
+        initService();
+    }
+
+    public static void initService() {
+        val configStorage = new WxCpDefaultConfigImpl();
+        configStorage.setCorpId("ww24b8a47826f5875f");
+        configStorage.setAgentId(1000002);
+        configStorage.setCorpSecret("MJIlySADGPlgvADnkFQPUpfZD4yV-4WN6066OgNnb0s");
+        configStorage.setToken("hcst2019");
+        configStorage.setAesKey("hcst2019");
+        wxCpService = new WxCpServiceImpl();
+        wxCpService.setWxCpConfigStorage(configStorage);
+    }
+
+    public static void sendMessage(List<String> wxUserList, String content) {
+        if (wxCpService == null) {
+            initService();
+        }
+        if (wxUserList != null && wxUserList.size() > 0) {
+            for (String userId : wxUserList) {
+                WxCpMessage message = new WxCpMessage();
+                message.setMsgType("text");
+                message.setContent(content);
+                message.setAgentId(1000002);
+                message.setToUser(userId);
+                try {
+                    wxCpService.messageSend(message);
+                } catch (WxErrorException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+}

+ 98 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java

@@ -0,0 +1,98 @@
+package cn.com.ctop.common.module.utils;
+
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
+import org.apache.poi.hssf.usermodel.HSSFFont;
+import org.apache.poi.hssf.usermodel.HSSFRichTextString;
+import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.xssf.usermodel.*;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+public class ExportExcelUtils {
+
+
+    /**
+     * @param workbook
+     * @param sheetNum   (sheet的位置,0表示第一个表格中的第一个sheet)
+     * @param sheetTitle (sheet的名称)
+     * @param headers    (表格的标题)
+     * @param result     (表格的数据)
+     * @return
+     * @throws Exception
+     * @Title: exportExcel
+     * @Description: 导出Excel的方法
+     * @author: evan @ 2014-01-09
+     */
+    public void exportExcel(XSSFWorkbook workbook, int sheetNum,
+                            String sheetTitle, String[] headers, List<List<Object>> result) throws Exception {
+        // 生成一个表格
+        XSSFSheet sheet = workbook.createSheet();
+        workbook.setSheetName(sheetNum, sheetTitle);
+        // 设置表格默认列宽度为20个字节
+        sheet.setDefaultColumnWidth((short) 20);
+        // 生成一个样式
+        XSSFCellStyle style = workbook.createCellStyle();
+        // 设置这些样式
+        style.setFillForegroundColor(HSSFColor.PALE_BLUE.index);
+        style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
+        style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+        style.setBorderRight(HSSFCellStyle.BORDER_THIN);
+        style.setBorderTop(HSSFCellStyle.BORDER_THIN);
+        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        // 生成一个字体
+        XSSFFont font = workbook.createFont();
+        font.setColor(HSSFColor.BLACK.index);
+        font.setFontHeightInPoints((short) 12);
+        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+        // 把字体应用到当前的样式
+        style.setFont(font);
+
+        // 指定当单元格内容显示不下时自动换行
+        style.setWrapText(true);
+
+        // 产生表格标题行
+        XSSFRow row = sheet.createRow(0);
+        for (int i = 0; i < headers.length; i++) {
+            XSSFCell cell = row.createCell((short) i);
+
+            cell.setCellStyle(style);
+            HSSFRichTextString text = new HSSFRichTextString(headers[i]);
+            cell.setCellValue(text.toString());
+        }
+        // 遍历集合数据,产生数据行
+        if (result != null) {
+            int index = 1;
+            for (List<Object> m : result) {
+                row = sheet.createRow(index);
+                int cellIndex = 0;
+                for (Object obj : m) {
+                    XSSFCell cell = row.createCell((short) cellIndex);
+                    if (!Check.isNull(obj)) {
+                        if (obj instanceof String) {
+                            cell.setCellValue((String) obj);
+                        } else if (obj instanceof Double) {
+                            cell.setCellValue((Double) obj);
+                        } else if (obj instanceof BigDecimal) {
+                            BigDecimal bigDecimal = (BigDecimal) obj;
+                            cell.setCellValue(bigDecimal.doubleValue());
+                        } else if (obj instanceof Long) {
+                            Long aLong = Long.valueOf(String.valueOf(obj));
+                            cell.setCellValue(aLong.doubleValue());
+                        } else {
+                            cell.setCellValue(obj.toString());
+                        }
+                    } else {
+                        cell.setCellValue(0);
+                    }
+
+                    cellIndex++;
+                }
+                index++;
+            }
+        }
+    }
+
+
+}

+ 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";
 
     /**
      * 登录

+ 20 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/RateUtil.java

@@ -0,0 +1,20 @@
+package cn.com.ctop.common.module.utils;
+
+import java.math.BigDecimal;
+
+public class RateUtil {
+
+    public static String getRate(BigDecimal value) {
+        if (Check.isNull(value)) {
+            return 0 + "%";
+        }
+        if (value.compareTo(new BigDecimal(0)) == 0) {
+            return 0 + "%";
+        }
+
+        BigDecimal multiply = value.multiply(new BigDecimal(100)).setScale(2);
+        return multiply + "%";
+
+
+    }
+}

+ 69 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/SendMailUtil.java

@@ -0,0 +1,69 @@
+package cn.com.ctop.common.module.utils;
+
+import javax.mail.*;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.util.List;
+import java.util.Properties;
+
+public class SendMailUtil {
+    private static String protocol = "smtp";
+    private static String host = "smtp.exmail.qq.com";
+    private static Integer port = 465;
+    private static String fromEmil = "notice@c-top.com.cn";
+    private static String connectUser = "notice@c-top.com.cn";
+    private static String connectPassWord = "Hcst@2019";
+
+
+    public static void sendMail(List<String> mails, String subject, String text) throws Exception {
+        if (Check.isNull(mails)) {
+            throw new Exception("请输入邮箱");
+        }
+
+        Properties properties = new Properties();
+        properties.put("mail.transport.protocol", protocol);// 连接协议
+        properties.put("mail.smtp.host", host);// 主机名
+        properties.put("mail.smtp.port", port);// 端口号
+        properties.put("mail.smtp.auth", "true");
+        properties.put("mail.smtp.ssl.enable", "true");// 设置是否使用ssl安全连接 ---一般都使用
+        properties.put("mail.debug", "false");// 设置是否显示debug信息 true 会在控制台显示相关信息
+        // 得到回话对象
+        Session session = Session.getInstance(properties);
+        // 获取邮件对象
+        Message message = new MimeMessage(session);
+        // 设置发件人邮箱地址
+        message.setFrom(new InternetAddress(fromEmil));
+        // 设置收件人邮箱地址
+
+        InternetAddress[] internetAddresses = new InternetAddress[mails.size()];
+        for (int i = 0; i < mails.size(); i++) {
+            InternetAddress addr = new InternetAddress(mails.get(i));
+            internetAddresses[i] = addr;
+        }
+        message.setRecipients(Message.RecipientType.TO, internetAddresses);
+        // 设置邮件标题
+        message.setSubject(subject);
+        // 设置邮件内容
+        // message.setText(text);
+
+        BodyPart html = new MimeBodyPart();
+        Multipart mainPart = new MimeMultipart();
+        // 设置HTML内容
+        html.setContent(text, "text/html; charset=utf-8");
+        mainPart.addBodyPart(html);
+        message.setContent(mainPart);
+
+
+        // 得到邮差对象
+        Transport transport = session.getTransport();
+        // 连接自己的邮箱账户
+        transport.connect(connectUser, connectPassWord);// 密码为QQ邮箱开通的stmp服务后得到的客户端授权码
+        // 发送邮件
+        transport.sendMessage(message, message.getAllRecipients());
+        transport.close();
+    }
+
+
+}

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

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

@@ -206,5 +206,11 @@ public class KuaiShouController {
         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;
+}

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

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

@@ -14,4 +14,6 @@ import java.util.List;
  */
 public interface KuaiShouGroupMapper extends BaseMapper<KuaiShouGroup> {
     void replaceBatch(@Param(value = "groups") List<KuaiShouGroup> groups);
+
+    List<String> selectWarningGroup(@Param("accountId") Long accountId, @Param("maxBid") Long maxBid);
 }

+ 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.campaignType},
+            #{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>

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

@@ -53,4 +53,19 @@
             #{getGroup.updateTime})
         </foreach>
     </insert>
+
+
+    <select id="selectWarningGroup" resultType="java.lang.String">
+
+
+   SELECT
+   unit_name
+   FROM ctop_kuaishou_group
+   WHERE account_id = #{accountId}
+   and (cpa_bid &gt; #{maxBid} or bid &gt; #{maxBid})
+   and status = 20
+   group by unit_id
+    </select>
+
+
 </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> {
+
+}

+ 22 - 2
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,6 +241,8 @@ public interface IKuaishouInterfaceService {
 
     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);
 
     void getAdvertiserCampaignReportDaily(CtopOauthToken token, Date startDate, Date endDate);
@@ -259,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;
 
@@ -269,6 +271,7 @@ public interface IKuaishouInterfaceService {
 
     /**
      * 获取快手图片列表
+     *
      * @param token
      * @param startDate
      * @param endDate
@@ -277,6 +280,7 @@ public interface IKuaishouInterfaceService {
 
     /**
      * 获取快手图片列表--测试使用
+     *
      * @param token
      * @param accountId
      * @param startDate
@@ -284,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 {
+
+}

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

@@ -217,9 +217,9 @@ 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(new Date()));
-            param.put("end_date", DateUtils.formatDate(new Date()));
+        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);
@@ -263,8 +263,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", token.getAccessToken());
         Map<String, Object> param = new HashMap<>();
-        param.put("start_date", DateUtils.formatDate(startDate));
-        param.put("end_date", DateUtils.formatDate(endDate));
+        if (!Check.isNull(startDate)) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+        }
+
+        if (!Check.isNull(endDate)) {
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
+
+
         param.put("advertiser_id", token.getAccountId());
         param.put("temporal_granularity", "DAILY");
         param.put("page_size", 500);
@@ -350,8 +357,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", token.getAccessToken());
         Map<String, Object> param = new HashMap<>();
-        param.put("start_date", DateUtils.formatDate(startDate));
-        param.put("end_date", DateUtils.formatDate(endDate));
+
+        if (!Check.isNull(startDate)) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+        }
+        if (Check.isNull(endDate)) {
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
+
+
         param.put("advertiser_id", token.getAccountId());
         param.put("temporal_granularity", "DAILY");
         param.put("page_size", 500);
@@ -523,8 +537,14 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", token.getAccessToken());
         Map<String, Object> param = new HashMap<>();
-        param.put("start_date", DateUtils.formatDate(startDate));
-        param.put("end_date", DateUtils.formatDate(endDate));
+        if (!Check.isNull(startDate)) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+        }
+
+        if (!Check.isNull(endDate)) {
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
+
         param.put("advertiser_id", token.getAccountId());
         param.put("temporal_granularity", "DAILY");
         param.put("page_size", 500);
@@ -947,7 +967,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
             //获取全量广告计划数据
             getCampaignList(token, null, null);
-            //获取全量广主数据
+            //获取全量广主数据
             getGroupList(token, null, null);
             //获取全量创意数据
             getCreativeList(token, null, null);
@@ -1093,7 +1113,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 +1156,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 +1235,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);
             }
         }
@@ -1229,9 +1256,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Autowired
     private ICtopOauthTokenService tokenService;
     static ExecutorService executorService = null;
-    /**
-     * 线程计数器          如果不用执行完后统一走流程,可以不要这个
-     */
+    //线程计数器          如果不用执行完后统一走流程,可以不要这个
     static CountDownLatch countDownLatch = null;
 
     @Override
@@ -1250,13 +1275,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();
@@ -1299,7 +1324,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));
         }
@@ -1341,7 +1366,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));
         }
@@ -1416,6 +1441,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         } catch (Exception e) {
             e.printStackTrace();
         }
+
+
     }
 
     private void addGroup(Long advertiserId, JSONArray details) {
@@ -1508,7 +1535,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 +1658,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 +2612,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         return null;
     }
 
-    @Autowired IKuaiShouImageGetService kuaiShouImageGetService;
+    @Autowired
+    IKuaiShouImageGetService kuaiShouImageGetService;
 
     /**
      * 查询图片列表
@@ -2598,7 +2626,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 +2635,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 +2661,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,8 +2676,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     /**
      * 查询图片列表---测试使用
      */
-    @Override
-    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");
@@ -2658,7 +2685,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));
         }
@@ -2669,8 +2696,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();
@@ -2683,11 +2710,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
 
@@ -2708,7 +2735,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);
@@ -2717,6 +2744,167 @@ 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
+     * @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();
+        }
+    }
+
+
 }

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyGroup.java

@@ -19,8 +19,13 @@ public class KuaishouReportDailyGroup implements Serializable {
 
     private Long accountId;
 
+    private Long campaignId;
+    private String campaignName;
+
     @JsonProperty("unit_id")
     private Long unitId;
+    private String unitName;
+    private Integer status;
 
     @JsonProperty("stat_date")
     private String statDate;

+ 7 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyGroup.java

@@ -17,8 +17,15 @@ public class KuaishouReportHourlyGroup implements Serializable {
     @TableId
     private String id;
     private Long accountId;
+
+    private Long campaignId;
+    private String campaignName;
+
     @JsonProperty("unit_id")
     private Long unitId;
+    private String unitName;
+    private Integer status;
+
     @JsonProperty("stat_date")
     private String statDate;
     @JsonProperty("stat_hour")

+ 8 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportHourlyGroupMapper.xml

@@ -5,7 +5,11 @@
         replace into ctop_kuaishou_report_hourly_group(
         id,
         account_id,
+        campaign_id,
+        campaign_name,
         unit_id,
+        unit_name,
+        status,
         stat_date,
         stat_hour,
         charge,
@@ -59,7 +63,11 @@
         <foreach collection="groups" item="campaign" separator=",">
             (#{campaign.id},
             #{campaign.accountId},
+            #{campaign.campaignId},
+            #{campaign.campaignName},
             #{campaign.unitId},
+            #{campaign.unitName},
+            #{campaign.status},
             #{campaign.statDate},
             #{campaign.statHour},
             #{campaign.charge},

+ 150 - 0
module-report/src/main/java/cn/com/ctop/bytedance/controller/DailyReportController.java

@@ -0,0 +1,150 @@
+package cn.com.ctop.bytedance.controller;
+
+import cn.com.ctop.bytedance.service.IDailyReportService;
+import cn.com.ctop.bytedance.vo.DailyAccountReportVO;
+import cn.com.ctop.bytedance.vo.DailyGroupReportVO;
+import cn.com.ctop.bytedance.vo.DailyReportVO;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.RateUtil;
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Slf4j
+@Api(tags = "广告主日报表")
+@RestController
+@RequestMapping("/ctop/daily")
+public class DailyReportController {
+    @Autowired
+    private IDailyReportService dailyReportService;
+
+
+    @PostMapping(value = "/getDailyReport")
+    public Result<DailyReportVO> getDailyReport(@RequestBody JSONObject requestJson) {
+
+        Result<DailyReportVO> result = new Result<>();
+        try {
+            DailyReportVO dailyReport = dailyReportService.getDailyReport(requestJson);
+            result.setSuccess(true);
+            result.setResult(dailyReport);
+
+        } catch (Exception e) {
+            result.setSuccess(false);
+
+            e.printStackTrace();
+
+        }
+        return result;
+
+    }
+
+    /**
+     * 导出报表
+     *
+     * @return
+     */
+    @RequestMapping(value = "/exportDailyReport")
+    @ResponseBody
+    public void export(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
+        DailyReportVO dailyReport = dailyReportService.getDailyReport(requestJson);
+
+        List<List<Object>> accountData = new ArrayList<>();
+        if (!Check.isNull(dailyReport)) {
+            DailyAccountReportVO dailyAccountReport = dailyReport.getDailyAccountReport();
+            if (!Check.isNull(dailyAccountReport)) {
+                List<Object> rowData = new ArrayList();
+                rowData.add(requestJson.getString("date")); // 时间
+                rowData.add(dailyAccountReport.getCost()); // 消耗
+                rowData.add(dailyAccountReport.getContractRebateRealCharged()); // 激励花费
+                rowData.add(dailyAccountReport.getActualCost()); // 实际花费
+                rowData.add(dailyAccountReport.getPhotoShow()); // 展示数
+                rowData.add(dailyAccountReport.getAclick()); // 素材曝光数数
+                rowData.add(dailyAccountReport.getPhotoClick()); // 点击数
+
+                rowData.add(RateUtil.getRate(dailyAccountReport.getPhotoClickRatio())); // 点击率
+                rowData.add(dailyAccountReport.getPhotoClickCost()); // 平均点击花费
+                rowData.add(dailyAccountReport.getBclick()); // 行为数
+                rowData.add(RateUtil.getRate(dailyAccountReport.getActionRatio())); // 行为率
+                rowData.add(dailyAccountReport.getImpression1kCost()); // 平均千次展现花费
+                rowData.add(dailyAccountReport.getConversions()); // 转化数
+                rowData.add(dailyAccountReport.getConversionPrice()); // 转化单价
+                rowData.add(RateUtil.getRate(dailyAccountReport.getConversionRate())); // 转化率
+                rowData.add(dailyAccountReport.getDiscountConversionPrice()); // 折后转化成本
+                accountData.add(rowData);
+            }
+        }
+
+        List<List<Object>> group = new ArrayList<>();
+        List<DailyGroupReportVO> dailyGroupReport = dailyReport.getDailyGroupReport();
+        if (!Check.isNull(dailyGroupReport)) {
+            for (DailyGroupReportVO groupReportVO : dailyGroupReport) {
+                List<Object> dailyGroup = new ArrayList();
+                dailyGroup.add(groupReportVO.getAccountId());
+                dailyGroup.add(groupReportVO.getAuthName());
+                dailyGroup.add(groupReportVO.getStatDate());
+                dailyGroup.add(groupReportVO.getCampaignName());
+                dailyGroup.add(groupReportVO.getUnitName());
+                dailyGroup.add(groupReportVO.getCost()); // 花费
+                dailyGroup.add(groupReportVO.getDisCountCost()); // 折后花费
+                dailyGroup.add(groupReportVO.getPhotoShow()); // 展示数
+                dailyGroup.add(groupReportVO.getPhotoClick()); // 点击数
+                dailyGroup.add(groupReportVO.getBclick());   // 行为数
+                dailyGroup.add(RateUtil.getRate(groupReportVO.getPhotoClickRatio())); // 点击率
+                dailyGroup.add(RateUtil.getRate(groupReportVO.getActionRatio())); // 行为率
+
+                dailyGroup.add(groupReportVO.getImpression1kCost()); // 平均千次展现花费
+                dailyGroup.add(groupReportVO.getPhotoClickCost()); // 平均点击花费
+                dailyGroup.add(groupReportVO.getConversions()); // 转化数
+                //  dailyGroup.add(groupReportVO.getConversionPrice()); // 转化单价
+                dailyGroup.add(groupReportVO.getDiscountConversionPrice()); // 折后转化成本
+                dailyGroup.add(RateUtil.getRate(groupReportVO.getClickConversionRate())); // 点击转化率
+
+                group.add(dailyGroup);
+            }
+
+        }
+
+        String[] accountHeaders = {"时间", "消耗(元)", "激励花费(元)", "实际消耗(元)", "展示数", "素材曝光数", "点击数", "点击率", "平均点击花费(元)", "行为数", "行为率", "平均千次展现花费(元)", "转化数(元)", "转化单价", "转化率", "折后转化成本(元)"};
+        String[] groupHeaders = {"账号", "账号名称", "日期", "计划名称", "广告组名称", "消耗(元)", "折后消耗(元)", "展现", "点击数", "行为数", "点击率", "行为率", "平均千次展现费用(元)", "平均点击费用(元)", "转化数", "折后转化成本(元)", "点击转化率",};
+        OutputStream os = response.getOutputStream();
+        ExportExcelUtils eeu = new ExportExcelUtils();
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        eeu.exportExcel(workbook, 0, "分日数据", accountHeaders, accountData);
+        eeu.exportExcel(workbook, 1, "分组数据", groupHeaders, group);
+        this.setResponseHeader(response, "日报.xls");
+        workbook.write(os);
+        os.flush();
+        os.close();
+    }
+
+    //发送响应流方法
+    public void setResponseHeader(HttpServletResponse response, String fileName) {
+        try {
+            try {
+                fileName = new String(fileName.getBytes(), "ISO8859-1");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            response.setContentType("application/octet-stream;charset=ISO8859-1");
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
+            response.addHeader("Pargam", "no-cache");
+            response.addHeader("Cache-Control", "no-cache");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+
+
+}

+ 39 - 0
module-report/src/main/java/cn/com/ctop/bytedance/entity/ExcelExp.java

@@ -0,0 +1,39 @@
+package cn.com.ctop.bytedance.entity;
+
+import java.util.List;
+
+public class ExcelExp {
+    private String fileName;// sheet的名称
+    private String[] handers;// sheet里的标题
+    private List<String[]> dataset;// sheet里的数据集
+
+    public ExcelExp(String fileName, String[] handers, List<String[]> dataset) {
+        this.fileName = fileName;
+        this.handers = handers;
+        this.dataset = dataset;
+    }
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public String[] getHanders() {
+        return handers;
+    }
+
+    public void setHanders(String[] handers) {
+        this.handers = handers;
+    }
+
+    public List<String[]> getDataset() {
+        return dataset;
+    }
+
+    public void setDataset(List<String[]> dataset) {
+        this.dataset = dataset;
+    }
+}

+ 13 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/DailyReportMapper.java

@@ -0,0 +1,13 @@
+package cn.com.ctop.bytedance.mapper;
+
+import cn.com.ctop.bytedance.vo.DailyAccountReportVO;
+import cn.com.ctop.bytedance.vo.DailyGroupReportVO;
+
+import java.util.List;
+import java.util.Map;
+
+public interface DailyReportMapper {
+    DailyAccountReportVO getDailyReport(Map<String, Object> requestMap);
+
+    List<DailyGroupReportVO> getDailyGroupReport(Map<String, Object> requestMap);
+}

+ 235 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/DailyReportMapper.xml

@@ -0,0 +1,235 @@
+<?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.bytedance.mapper.DailyReportMapper">
+
+    <select id="getDailyReport" parameterType="Map" resultType="cn.com.ctop.bytedance.vo.DailyAccountReportVO">
+        SELECT
+        t1.*,
+        truncate((t1.conversions / t1.bclick),4) conversionRate, -- 转化率
+
+        truncate(t1.conversionPrice / #{discount},2) discountConversionPrice, -- 折后转化成本
+
+        (SELECT sum(contract_rebate_real_charged)
+        from ctop_kuaishou_daily_flows
+        <where>
+            <if test="date != null">
+                and date = #{date}
+            </if>
+
+            <if test="accountIds != null">
+                and account_id in
+                <foreach collection="accountIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+
+            </if>
+        </where>
+        ) contractRebateRealCharged -- 激励花费
+
+        FROM (
+        SELECT
+        sum(charge) cost, -- 消耗
+        sum(photo_show) photoShow, -- 展现数
+        sum(aclick) aclick, -- 素材曝光数
+        sum(photo_click) photoClick, -- 点击数
+        (
+        CASE
+        WHEN sum(photo_show) != 0 THEN
+        (
+        truncate( sum(photo_click) / sum(photo_show),4)
+        )
+        ELSE
+        0
+        END
+        ) photoClickRatio, -- 点击率
+        (
+        CASE
+        WHEN sum(charge) != 0 THEN
+        (
+        truncate(sum(photo_click) / sum(charge),4)
+        )
+        ELSE
+        0
+        END
+        ) photoClickCost, -- 平均点击花费
+
+        sum(bclick) bclick, -- 行为数
+
+        (
+        CASE
+        WHEN sum(aclick) != 0 THEN
+        truncate(sum(bclick) / sum(aclick),4)
+        ELSE
+        0
+        END
+        ) actionRatio, -- 行为率
+        (
+        CASE
+        WHEN sum(photo_show) != 0 THEN
+        truncate( (sum(charge) / sum(photo_show)
+        ) * 1000,2)
+        ELSE
+        0
+        END
+        ) impression1kCost, -- 平均千次展现花费
+        (
+        CASE
+        WHEN sum(form_count) != 0 THEN
+        sum(form_count)
+        WHEN sum(activation) != 0 THEN
+        sum(activation)
+        ELSE
+        0
+        END
+        ) conversions, -- 转化数
+        (
+        CASE
+        WHEN sum(form_count) != 0 THEN
+        (
+        truncate(sum(charge) / sum(form_count),2)
+        )
+        WHEN sum(activation) != 0 THEN
+        (
+        truncate(sum(charge) / sum(activation),2)
+        )
+        ELSE
+        0
+        END
+        ) conversionPrice -- 转化单价
+        FROM
+        ctop_kuaishou_report_daily_account
+        <where>
+            <if test="date != null">
+                and stat_date = #{date}
+            </if>
+
+            <if test="accountIds != null">
+                and account_id in
+                <foreach collection="accountIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+
+            </if>
+
+        </where>
+        ) t1
+
+    </select>
+
+
+    <select id="getDailyGroupReport" parameterType="Map" resultType="cn.com.ctop.bytedance.vo.DailyGroupReportVO">
+        SELECT
+        t1.*,
+        truncate(t1.conversions / t1.photoClick,4) clickConversionRate, -- 点击转化率
+        truncate(t1.conversionPrice / #{discount},2) discountConversionPrice-- 折后转化单价
+        FROM
+        (
+        SELECT
+        account_id accountId,
+        (
+        SELECT
+        auth_name
+        FROM
+        ctop_user_allocation
+        WHERE
+        account_id = accountId
+        ) authName, -- 账户名称
+        stat_date statDate, -- 报表日期
+        campaign_name campaignName, -- 计划名称
+        unit_name unitName, -- 广告组名称
+        sum(charge) cost, -- 花费
+        truncate((sum(charge) / #{discount}),2) disCountCost, -- 折后消费
+        sum(photo_show) photoShow, -- 展现数
+        sum(photo_click) photoClick, -- 点击数
+        sum(bclick) bclick, -- 行为数
+        (
+        CASE
+        WHEN sum(aclick) != 0 THEN
+        truncate(sum(bclick) / sum(aclick),4)
+        ELSE
+        0
+        END
+        ) actionRatio, -- 行为率
+
+
+        (
+        CASE
+        WHEN sum(aclick) != 0 THEN
+        truncate(sum(photo_click) / sum(aclick),4)
+        ELSE
+        0
+        END
+        ) photoClickRatio, -- 点击率
+
+
+        (
+        CASE
+        WHEN sum(photo_show) != 0
+        THEN
+        truncate((sum(charge) / sum(photo_show)
+        ) * 1000,2)
+        ELSE
+        0
+        END
+        ) impression1kCost, -- 平均千次展现花费
+        (
+        CASE
+        WHEN sum(charge) != 0 THEN
+        (
+        truncate(sum(photo_click) / sum(charge),2)
+        )
+        ELSE
+        0
+        END
+        ) photoClickCost, -- 平均点击花费
+        (
+        CASE
+        WHEN sum(form_count) != 0 THEN
+        sum(form_count)
+        WHEN sum(activation) != 0 THEN
+        sum(activation)
+        ELSE
+        0
+        END
+        ) conversions, -- 转化数
+        (
+        CASE
+        WHEN sum(form_count) != 0 THEN
+        (
+        truncate(sum(charge) / sum(form_count),2)
+        )
+        WHEN sum(activation) != 0 THEN
+        (
+        truncate(sum(charge) / sum(activation),2)
+        )
+        ELSE
+        0
+        END
+        ) conversionPrice -- 转化单价
+
+        FROM
+        ctop_kuaishou_report_daily_group
+        <where>
+            <if test="date != null">
+                and stat_date = #{date}
+            </if>
+
+            <if test="accountIds != null">
+                and account_id in
+                <foreach collection="accountIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+
+            </if>
+        </where>
+        GROUP BY unit_id
+        order by account_id
+
+        ) t1
+    </select>
+
+
+</mapper>

+ 18 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/IDailyReportService.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.bytedance.service;
+
+import cn.com.ctop.bytedance.vo.DailyReportVO;
+import com.alibaba.fastjson.JSONObject;
+
+/**
+ * 日报
+ */
+public interface IDailyReportService {
+    /**
+     * 获取日报数据
+     *
+     * @param requestJson
+     * @return
+     */
+    DailyReportVO getDailyReport(JSONObject requestJson);
+
+}

+ 74 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/DailyReportServiceImpl.java

@@ -0,0 +1,74 @@
+package cn.com.ctop.bytedance.service.impl;
+
+import cn.com.ctop.bytedance.mapper.DailyReportMapper;
+import cn.com.ctop.bytedance.service.IDailyReportService;
+import cn.com.ctop.bytedance.vo.DailyAccountReportVO;
+import cn.com.ctop.bytedance.vo.DailyGroupReportVO;
+import cn.com.ctop.bytedance.vo.DailyReportVO;
+import cn.com.ctop.common.module.utils.Check;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 日报报表
+ */
+
+@Slf4j
+@Service
+public class DailyReportServiceImpl implements IDailyReportService {
+
+    @Autowired
+    private DailyReportMapper dailyReportMapper;
+
+    /**
+     * 获取日报数据
+     *
+     * @param requestJson
+     * @return
+     */
+    @Override
+    public DailyReportVO getDailyReport(JSONObject requestJson) {
+        try {
+            log.info("日报开始统计");
+            long startTime = System.currentTimeMillis();
+
+            JSONArray accountIds = requestJson.getJSONArray("accountIds");
+            BigDecimal discount = requestJson.getBigDecimal("discount");
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("accountIds", accountIds);
+            requestMap.put("discount", discount);
+            requestMap.put("date", requestJson.getString("date"));
+            DailyAccountReportVO dailyAccountReport = dailyReportMapper.getDailyReport(requestMap);
+            if (!Check.isNull(dailyAccountReport)) {
+                BigDecimal cost = dailyAccountReport.getCost();
+                BigDecimal contractRebateRealCharged = dailyAccountReport.getContractRebateRealCharged();
+                if (!Check.isNull(cost) && !Check.isNull(contractRebateRealCharged)) {
+                    BigDecimal actualCost = ((cost.subtract(contractRebateRealCharged)).divide(discount, 2, RoundingMode.HALF_UP));
+                    dailyAccountReport.setActualCost(actualCost);
+                }
+
+            }
+            List<DailyGroupReportVO> dailyGroupReport = dailyReportMapper.getDailyGroupReport(requestMap);
+            DailyReportVO dailyReport = new DailyReportVO();
+            dailyReport.setDailyAccountReport(dailyAccountReport);
+            dailyReport.setDailyGroupReport(dailyGroupReport);
+            log.info("日报统计完成,用时: " + ((System.currentTimeMillis() - startTime) / 1000) + " s");
+            return dailyReport;
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+
+    }
+
+}

+ 25 - 0
module-report/src/main/java/cn/com/ctop/bytedance/vo/DailyAccountReportVO.java

@@ -0,0 +1,25 @@
+package cn.com.ctop.bytedance.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class DailyAccountReportVO implements Serializable {
+    private BigDecimal cost; // 消耗
+    private Long photoShow; // 展示数
+    private Long aclick; // 素材曝光数
+    private Long photoClick; // 点击数
+    private BigDecimal photoClickRatio; // 点击率
+    private BigDecimal photoClickCost; // 平均点击花费
+    private Long bclick; // 行为数
+    private BigDecimal actionRatio; // 行为率
+    private BigDecimal impression1kCost; // 平均千次展现花费
+    private Long conversions; // 转化数
+    private BigDecimal conversionPrice; // 转化单价
+    private BigDecimal conversionRate; // 转化率
+    private BigDecimal discountConversionPrice; // 折后转化成本
+    private BigDecimal contractRebateRealCharged; // 激励花费
+    private BigDecimal actualCost; // 实际消耗
+}

+ 30 - 0
module-report/src/main/java/cn/com/ctop/bytedance/vo/DailyGroupReportVO.java

@@ -0,0 +1,30 @@
+package cn.com.ctop.bytedance.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class DailyGroupReportVO implements Serializable {
+
+    private Long accountId; // 账号
+    private String statDate; // 日期
+    private String authName; // 账号名称
+    private String campaignName; // 计划名称
+    private String unitName; // 广告组名称
+    private BigDecimal cost; // 消耗
+    private BigDecimal disCountCost; // 折后消耗
+    private Long photoShow; // 展示数
+    private Long photoClick; // 点击数
+    private Long bclick; // 行为数
+    private BigDecimal actionRatio; // 行为率
+    private BigDecimal photoClickRatio; // 点击率
+    private BigDecimal impression1kCost; // 平均千次展现花费
+    private BigDecimal photoClickCost; // 平均点击花费
+    private Long conversions; // 转化数
+    private BigDecimal conversionPrice; // 转化单价
+    private BigDecimal clickConversionRate; // 点击转化率
+    private BigDecimal discountConversionPrice; // 折后转化成本
+
+}

+ 13 - 0
module-report/src/main/java/cn/com/ctop/bytedance/vo/DailyReportVO.java

@@ -0,0 +1,13 @@
+package cn.com.ctop.bytedance.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+public class DailyReportVO implements Serializable {
+
+    private DailyAccountReportVO dailyAccountReport;
+    private List<DailyGroupReportVO> dailyGroupReport;
+}

+ 5 - 1
pom.xml

@@ -303,7 +303,11 @@
             <artifactId>guava</artifactId>
             <version>25.0-jre</version>
         </dependency>
-
+        <dependency>
+            <groupId>com.github.binarywang</groupId>
+            <artifactId>weixin-java-cp</artifactId>
+            <version>3.6.0</version>
+        </dependency>
         <dependency>
             <groupId>us.codecraft</groupId>
             <artifactId>webmagic-core</artifactId>