Ver código fonte

Merge branch 'test'

yumeng 5 anos atrás
pai
commit
9e27561fc8
28 arquivos alterados com 992 adições e 123 exclusões
  1. 1 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. 248 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MailLogController.java
  4. 69 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/MailLog.java
  5. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Project.java
  6. 26 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/AccountBidJob.java
  7. 23 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MailLogMapper.java
  8. 41 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MailLogMapper.xml
  9. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IBidWarningService.java
  10. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IMailLogService.java
  11. 115 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java
  12. 19 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MailLogServiceImpl.java
  13. 23 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java
  14. 65 0
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  15. 62 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/CtopCorpWexinUser.java
  16. 17 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/CtopCorpWexinUserMapper.java
  17. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopCorpWexinUserMapper.xml
  18. 14 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopCorpWexinUserService.java
  19. 19 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopCorpWexinUserServiceImpl.java
  20. 46 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/CorpWexinUtils.java
  21. 23 4
      module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java
  22. 21 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/RateUtil.java
  23. 69 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/SendMailUtil.java
  24. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupMapper.java
  25. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml
  26. 39 39
      module-report/src/main/java/cn/com/ctop/bytedance/controller/DailyReportController.java
  27. 0 73
      module-report/src/main/java/cn/com/ctop/bytedance/controller/ExcelExportUtil.java
  28. 1 3
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/DailyReportServiceImpl.java

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

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

+ 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("文件导入失败!");
+    }
+
+}

+ 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;
     /**
      * 创建时间
      */

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

@@ -0,0 +1,26 @@
+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) {
+        bidWarningService.BidWarning();
+    }
+}

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

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

@@ -0,0 +1,115 @@
+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() {
+
+        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);
+                            }
+                        }
+                    }
+                }
+            }
+
+        } 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 {
+
+}

+ 23 - 3
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;
@@ -62,10 +64,12 @@ 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("code") String code) throws Exception {
+    public Result<JSONObject> wxlogin(@RequestParam(name="code") String code) throws Exception {
         Result<JSONObject> result = new Result<JSONObject>();
         val configStorage = new WxCpDefaultConfigImpl();
         configStorage.setCorpId("ww24b8a47826f5875f");
@@ -76,14 +80,18 @@ public class LoginController {
         val service = new WxCpServiceImpl();
 
         service.setWxCpConfigStorage(configStorage);
-        WxCpOAuth2Service wxCpOAuth2Service = new WxCpOAuth2ServiceImpl(service);
+        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.getUserByName(email);
+                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);
@@ -93,9 +101,21 @@ public class LoginController {
                 //用户登录信息
                 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;

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

@@ -10,6 +10,7 @@ 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;
@@ -24,8 +25,15 @@ 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
@@ -158,4 +166,61 @@ public class SampleTest {
 
     }
 
+    @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();
+    }
+
+
 }
+
+
+

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

@@ -0,0 +1,62 @@
+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
+ * @date   2019-12-08
+ * @version V1.0
+ */
+@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;
+}

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

@@ -0,0 +1,17 @@
+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>

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

@@ -0,0 +1,14 @@
+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
+ * @date   2019-12-08
+ * @version V1.0
+ */
+public interface ICtopCorpWexinUserService extends IService<CtopCorpWexinUser> {
+
+}

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

@@ -0,0 +1,19 @@
+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
+ * @date   2019-12-08
+ * @version V1.0
+ */
+@Service
+public class CtopCorpWexinUserServiceImpl extends ServiceImpl<CtopCorpWexinUserMapper, CtopCorpWexinUser> implements ICtopCorpWexinUserService {
+
+}

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

@@ -0,0 +1,46 @@
+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();
+                }
+            }
+        }
+    }
+}

+ 23 - 4
module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java

@@ -6,6 +6,7 @@ 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 {
@@ -24,7 +25,7 @@ public class ExportExcelUtils {
      * @author: evan @ 2014-01-09
      */
     public void exportExcel(XSSFWorkbook workbook, int sheetNum,
-                            String sheetTitle, String[] headers, List<List<String>> result) throws Exception {
+                            String sheetTitle, String[] headers, List<List<Object>> result) throws Exception {
         // 生成一个表格
         XSSFSheet sheet = workbook.createSheet();
         workbook.setSheetName(sheetNum, sheetTitle);
@@ -63,12 +64,29 @@ public class ExportExcelUtils {
         // 遍历集合数据,产生数据行
         if (result != null) {
             int index = 1;
-            for (List<String> m : result) {
+            for (List<Object> m : result) {
                 row = sheet.createRow(index);
                 int cellIndex = 0;
-                for (String str : m) {
+                for (Object obj : m) {
                     XSSFCell cell = row.createCell((short) cellIndex);
-                    cell.setCellValue(str);
+                    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++;
@@ -76,4 +94,5 @@ public class ExportExcelUtils {
         }
     }
 
+
 }

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

@@ -0,0 +1,21 @@
+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));
+        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();
+    }
+
+
+}

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

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

@@ -53,4 +53,18 @@
             #{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})
+   group by unit_id
+    </select>
+
+
 </mapper>

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

@@ -6,6 +6,7 @@ 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;
@@ -49,7 +50,6 @@ public class DailyReportController {
 
     }
 
-
     /**
      * 导出报表
      *
@@ -60,60 +60,60 @@ public class DailyReportController {
     public void export(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
         DailyReportVO dailyReport = dailyReportService.getDailyReport(requestJson);
 
-        List<List<String>> accountData = new ArrayList<>();
+        List<List<Object>> accountData = new ArrayList<>();
         if (!Check.isNull(dailyReport)) {
             DailyAccountReportVO dailyAccountReport = dailyReport.getDailyAccountReport();
             if (!Check.isNull(dailyAccountReport)) {
-                List rowData = new ArrayList();
+                List<Object> rowData = new ArrayList();
                 rowData.add(requestJson.getString("date")); // 时间
-                rowData.add(String.valueOf(dailyAccountReport.getCost())); // 消耗
-                rowData.add(String.valueOf(dailyAccountReport.getContractRebateRealCharged())); // 激励花费
-                rowData.add(String.valueOf(dailyAccountReport.getActualCost())); // 实际花费
-                rowData.add(String.valueOf(dailyAccountReport.getPhotoShow())); // 展示数
-                rowData.add(String.valueOf(dailyAccountReport.getPhotoClick())); // 点击数
-                rowData.add(String.valueOf(dailyAccountReport.getPhotoClickRatio())); // 点击率
-                rowData.add(String.valueOf(dailyAccountReport.getPhotoClickCost())); // 平均点击花费
-                rowData.add(String.valueOf(dailyAccountReport.getBclick())); // 行为数
-                rowData.add(String.valueOf(dailyAccountReport.getActionRatio())); // 行为率
-                rowData.add(String.valueOf(dailyAccountReport.getImpression1kCost())); // 平均千次展现花费
-                rowData.add(String.valueOf(dailyAccountReport.getConversions())); // 转化数
-                rowData.add(String.valueOf(dailyAccountReport.getConversionPrice())); // 转化单价
-                rowData.add(String.valueOf(dailyAccountReport.getConversionRate())); // 转化率
-                rowData.add(String.valueOf(dailyAccountReport.getDiscountConversionPrice())); // 折后转化成本
+                rowData.add(dailyAccountReport.getCost()); // 消耗
+                rowData.add(dailyAccountReport.getContractRebateRealCharged()); // 激励花费
+                rowData.add(dailyAccountReport.getActualCost()); // 实际花费
+                rowData.add(dailyAccountReport.getPhotoShow()); // 展示数
+                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<String>> group = new ArrayList<>();
+        List<List<Object>> group = new ArrayList<>();
         List<DailyGroupReportVO> dailyGroupReport = dailyReport.getDailyGroupReport();
         if (!Check.isNull(dailyGroupReport)) {
             for (DailyGroupReportVO groupReportVO : dailyGroupReport) {
-                List dailyGroup = new ArrayList();
-                dailyGroup.add(String.valueOf(groupReportVO.getAccountId()));
-                dailyGroup.add(String.valueOf(groupReportVO.getAuthName()));
-                dailyGroup.add(String.valueOf(groupReportVO.getStatDate()));
-                dailyGroup.add(String.valueOf(groupReportVO.getCampaignName()));
-                dailyGroup.add(String.valueOf(groupReportVO.getUnitName()));
-                dailyGroup.add(String.valueOf(groupReportVO.getCost()));
-                dailyGroup.add(String.valueOf(groupReportVO.getDisCountCost()));
-                dailyGroup.add(String.valueOf(groupReportVO.getPhotoShow()));
-                dailyGroup.add(String.valueOf(groupReportVO.getPhotoClick()));
-                dailyGroup.add(String.valueOf(groupReportVO.getBclick()));
-                dailyGroup.add(String.valueOf(groupReportVO.getActionRatio()));
-                dailyGroup.add(String.valueOf(groupReportVO.getImpression1kCost()));
-                dailyGroup.add(String.valueOf(groupReportVO.getPhotoClickCost()));
-                dailyGroup.add(String.valueOf(groupReportVO.getConversions()));
-                dailyGroup.add(String.valueOf(groupReportVO.getConversionPrice()));
-                dailyGroup.add(String.valueOf(groupReportVO.getClickConversionRate()));
-                dailyGroup.add(String.valueOf(groupReportVO.getDiscountConversionPrice()));
+                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.getActionRatio())); // 行为率
+                dailyGroup.add(groupReportVO.getImpression1kCost()); // 平均千次展现花费
+                dailyGroup.add(groupReportVO.getPhotoClickCost()); // 平均点击花费
+                dailyGroup.add(groupReportVO.getConversions()); // 转化数
+                dailyGroup.add(groupReportVO.getConversionPrice()); // 转化单价
+                dailyGroup.add(groupReportVO.getClickConversionRate()); // 点击转化率
+                dailyGroup.add(groupReportVO.getDiscountConversionPrice()); // 折后转化成本
                 group.add(dailyGroup);
             }
 
         }
 
-
-        String[] accountHeaders = {"时间", "消耗", "激励花费", "实际消耗", "展示数", "点击数", "点击率", "平均点击花费", "行为数", "行为率", "平均千次展现花费", "转化数", "转化单价", "转化率", "折后转化成本"};
-        String[] groupHeaders = {"账号", "账号名称", "日期", "计划名称", "广告组名称", "消耗", "折后消耗", "展示数", "点击数", "行为数", "行为率", "平均千次展示花费", "平均点击花费", "转化数", "转化单价", "点击转化率", "折后转化成本"};
+        String[] accountHeaders = {"时间", "消耗(元)", "激励花费(元)", "实际消耗(元)", "展示数", "点击数", "点击率", "平均点击花费(元)", "行为数", "行为率", "平均千次展现花费(元)", "转化数(元)", "转化单价", "转化率", "折后转化成本(元)"};
+        String[] groupHeaders = {"账号", "账号名称", "日期", "计划名称", "广告组名称", "消耗(元)", "折后消耗(元)", "展示数", "点击数", "行为数", "行为率", "平均千次展示花费(元)", "平均点击花费(元)", "转化数", "转化单价(元)", "点击转化率", "折后转化成本(元)"};
         OutputStream os = response.getOutputStream();
         ExportExcelUtils eeu = new ExportExcelUtils();
         XSSFWorkbook workbook = new XSSFWorkbook();

+ 0 - 73
module-report/src/main/java/cn/com/ctop/bytedance/controller/ExcelExportUtil.java

@@ -1,73 +0,0 @@
-package cn.com.ctop.bytedance.controller;
-
-import cn.com.ctop.bytedance.entity.ExcelExp;
-import org.apache.poi.hssf.usermodel.*;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.List;
-
-public class ExcelExportUtil {
-    public static void exportManySheetExcel(String file, List<ExcelExp> mysheets) {
-
-        HSSFWorkbook wb = new HSSFWorkbook();//创建工作薄
-        List<ExcelExp> sheets = mysheets;
-
-        //表头样式
-        HSSFCellStyle style = wb.createCellStyle();
-        style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
-        //字体样式
-        HSSFFont fontStyle = wb.createFont();
-        fontStyle.setFontName("微软雅黑");
-        fontStyle.setFontHeightInPoints((short) 12);
-        fontStyle.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
-        style.setFont(fontStyle);
-
-        for (ExcelExp excel : sheets) {
-            //新建一个sheet
-            HSSFSheet sheet = wb.createSheet(excel.getFileName());//获取该sheet名称
-
-            String[] handers = excel.getHanders();//获取sheet的标题名
-            HSSFRow rowFirst = sheet.createRow(0);//第一个sheet的第一行为标题
-            //写标题
-            for (int i = 0; i < handers.length; i++) {
-                //获取第一行的每个单元格
-                HSSFCell cell = rowFirst.createCell(i);
-                //往单元格里写数据
-                cell.setCellValue(handers[i]);
-                cell.setCellStyle(style); //加样式
-                sheet.setColumnWidth(i, 4000); //设置每列的列宽
-            }
-
-            //写数据集
-            List<String[]> dataset = excel.getDataset();
-            for (int i = 0; i < dataset.size(); i++) {
-                String[] data = dataset.get(i);//获取该对象
-
-                //创建数据行
-                HSSFRow row = sheet.createRow(i + 1);
-
-                for (int j = 0; j < data.length; j++) {
-                    //设置对应单元格的值
-                    row.createCell(j).setCellValue(data[j]);
-                }
-            }
-        }
-
-        // 写文件
-        try {
-
-            FileOutputStream out = new FileOutputStream(new File(file));
-            out.flush();
-            wb.write(out);
-            out.close();
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-}

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

@@ -38,8 +38,6 @@ public class DailyReportServiceImpl implements IDailyReportService {
     @Override
     public DailyReportVO getDailyReport(JSONObject requestJson) {
         try {
-
-            System.err.println(requestJson);
             log.info("日报开始统计");
             long startTime = System.currentTimeMillis();
 
@@ -53,7 +51,7 @@ public class DailyReportServiceImpl implements IDailyReportService {
             if (!Check.isNull(dailyAccountReport)) {
                 BigDecimal cost = dailyAccountReport.getCost();
                 BigDecimal contractRebateRealCharged = dailyAccountReport.getContractRebateRealCharged();
-                if (Check.isNull(cost)) {
+                if (!Check.isNull(cost)) {
                     BigDecimal actualCost = ((cost.subtract(contractRebateRealCharged)).divide(discount, 2, RoundingMode.HALF_UP));
                     dailyAccountReport.setActualCost(actualCost);
                 }