فهرست منبع

Merge branch 'test'

yumeng 5 سال پیش
والد
کامیت
da8f2806fb
16فایلهای تغییر یافته به همراه773 افزوده شده و 10 حذف شده
  1. 19 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  2. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  3. 321 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TransferAccountController.java
  4. 9 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  5. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Project.java
  6. 115 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/TransferAccount.java
  7. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/TransferAccountMapper.java
  8. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/TransferAccountMapper.xml
  9. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ITransferAccountService.java
  10. 19 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/TransferAccountServiceImpl.java
  11. 142 7
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  12. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/MailLogMapper.java
  13. 13 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MailLogMapper.xml
  14. 12 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMailLogService.java
  15. 55 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MailLogServiceImpl.java
  16. 24 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/CorpWexinUtils.java

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

@@ -2,6 +2,7 @@ package org.jeecg.modules.ctop.controller;
 
 
 import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
+import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -19,11 +20,13 @@ import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.ctop.entity.Advertiser;
 import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
+import org.jeecg.modules.ctop.entity.TransferAccount;
 import org.jeecg.modules.ctop.mapper.ProjectMapper;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IAdvertiserService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.ctop.service.IProjectService;
+import org.jeecg.modules.ctop.service.ITransferAccountService;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.mapper.UserCompanyMapper;
 import org.jeecg.modules.system.service.ISysUserService;
@@ -71,6 +74,8 @@ public class ProjectController {
     private MaterialReportMapper materialReportMapper;
     @Autowired
     private UserCompanyMapper userCompanyMapper;
+    @Autowired
+    private ITransferAccountService transferAccountService;
 
     /**
      * 根据 项目 媒体类型 查看项目
@@ -143,14 +148,22 @@ public class ProjectController {
                     List<Project> designResponsibles = projectMapper.selectList(projectQueryWrapper);
                     projects = designResponsibles;
                 }
-
-
             }
         } else {
             queryWrapper.orderByDesc("create_time");
             projects = projectMapper.selectList(queryWrapper);
         }
 
+        if (!Check.isNull(projects)) {
+            for (Project project : projects) {
+                QueryWrapper<TransferAccount> transferAccountQueryWrapper = new QueryWrapper<>();
+                transferAccountQueryWrapper.eq("project_id", project.getId());
+                transferAccountQueryWrapper.eq("status", 0);
+                List<TransferAccount> list = transferAccountService.list(transferAccountQueryWrapper);
+                project.setNeedExamine(list.size());
+            }
+        }
+
         map.put("success", true);
         map.put("code", 0);
         map.put("result", projects);
@@ -223,7 +236,6 @@ public class ProjectController {
                 memberMap.put(sysUser.getId(), sysUser.getRealname());
             }
 
-
             SysUser designSysUser = sysUserService.getById(project.getDesignResponsibleId());
             if (!Check.isNull(designSysUser)) {
                 project.setDesignResponsibleName(designSysUser.getRealname());
@@ -307,6 +319,9 @@ public class ProjectController {
         return result;
     }
 
+    @Autowired
+    private IUserAllocationService userAllocationService;
+
     /**
      * 通过id删除
      *
@@ -322,6 +337,7 @@ public class ProjectController {
             Map<String, Object> deleteMap = new HashMap<>();
             deleteMap.put("project_id", id);
             projectMemberService.removeByMap(deleteMap);
+            userAllocationService.removeByMap(deleteMap);
         } catch (Exception e) {
             log.error("删除失败", e.getMessage());
             return Result.error("删除失败!");

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

@@ -821,6 +821,7 @@ public class TestController {
 
         try {
 
+
             QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
             oauthTokenQueryWrapper.eq("media_id", 2);
             List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);

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

@@ -0,0 +1,321 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.MailLogMapper;
+import cn.com.ctop.common.module.service.IMailLogService;
+import cn.com.ctop.common.module.service.IMaterialInfoService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+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.Project;
+import org.jeecg.modules.ctop.entity.ProjectMember;
+import org.jeecg.modules.ctop.entity.TransferAccount;
+import org.jeecg.modules.ctop.service.IProjectMemberService;
+import org.jeecg.modules.ctop.service.IProjectService;
+import org.jeecg.modules.ctop.service.ITransferAccountService;
+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 2020-03-26
+ */
+@Slf4j
+@Api(tags = "转户记录表")
+@RestController
+@RequestMapping("/ctop/transferAccount")
+public class TransferAccountController {
+    @Autowired
+    private ITransferAccountService transferAccountService;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private IProjectService projectService;
+    @Autowired
+    private IMailLogService mailLogService;
+    @Autowired
+    private MailLogMapper mailLogMapper;
+    @Autowired
+    private IProjectMemberService projectMemberService;
+
+    @Autowired
+    private IMaterialInfoService materialInfoService;
+
+    /**
+     * 添加
+     *
+     * @param transferAccount
+     * @return
+     */
+    @AutoLog(value = "转户记录表-添加")
+    @ApiOperation(value = "转户记录表-添加", notes = "转户记录表-添加")
+    @PostMapping(value = "/add")
+    public Result<TransferAccount> add(@RequestBody TransferAccount transferAccount) {
+        Result<TransferAccount> result = new Result<TransferAccount>();
+        try {
+            QueryWrapper<TransferAccount> transferAccountQueryWrapper = new QueryWrapper<>();
+            transferAccountQueryWrapper.eq("account_id", transferAccount.getAccountId());
+            transferAccountQueryWrapper.eq("status", 0);
+            List<TransferAccount> list = transferAccountService.list(transferAccountQueryWrapper);
+            if (!Check.isNull(list)) {
+                result.setSuccess(false);
+                result.setMessage("此账户有未完成的转户操作");
+                return result;
+            }
+
+            transferAccountService.save(transferAccount);
+            Long projectId = transferAccount.getProjectId();
+            Project project = projectService.getById(projectId);
+            if (!Check.isNull(project)) {
+                String responsibleId = project.getResponsibleId();
+                mailLogService.sendWeChat(responsibleId, transferAccount.getAccountId(), project.getProjectName(), transferAccount.getTransferor(), transferAccount.getAssignee());
+            }
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+
+    /**
+     * 分页列表查询
+     *
+     * @param transferAccount
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "转户记录表-分页列表查询")
+    @ApiOperation(value = "转户记录表-分页列表查询", notes = "转户记录表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<List<TransferAccount>> queryPageList(TransferAccount transferAccount, HttpServletRequest req) {
+        Result<List<TransferAccount>> result = new Result<>();
+        QueryWrapper<TransferAccount> queryWrapper = QueryGenerator.initQueryWrapper(transferAccount, req.getParameterMap());
+        List<TransferAccount> records = transferAccountService.list(queryWrapper);
+        if (!Check.isNull(records)) {
+            for (TransferAccount transfer : records) {
+                String transferorName = mailLogMapper.getUserNameByUserId(transfer.getTransferor()); // 转让人姓名
+                transfer.setTransferorName(transferorName);
+                String assigneeName = mailLogMapper.getUserNameByUserId(transfer.getAssignee()); // 转让人姓名
+                transfer.setAssigneeName(assigneeName);
+            }
+        }
+
+        result.setSuccess(true);
+        result.setResult(records);
+        return result;
+    }
+
+
+    /**
+     * 编辑
+     *
+     * @param transferAccount
+     * @return
+     */
+    @AutoLog(value = "转户记录表-编辑")
+    @ApiOperation(value = "转户记录表-编辑", notes = "转户记录表-编辑")
+    @PutMapping(value = "/edit")
+    public Result<TransferAccount> edit(@RequestBody TransferAccount transferAccount) {
+        Result<TransferAccount> result = new Result<TransferAccount>();
+        TransferAccount transferAccountEntity = transferAccountService.getById(transferAccount.getId());
+        if (transferAccountEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            Integer status = transferAccount.getStatus();
+
+            Long projectId = transferAccountEntity.getProjectId();
+            Project project = projectService.getById(projectId);
+
+            if (status == 1) { // 审核通过 修改账户所属人信息 添加受让人到项目成员列表
+                QueryWrapper<UserAllocation> updateQueryWrapper = new QueryWrapper<>();
+                updateQueryWrapper.eq("account_id", transferAccountEntity.getAccountId());
+                updateQueryWrapper.eq("project_id", transferAccountEntity.getProjectId());
+                UserAllocation updateUserAllocation = new UserAllocation();
+                updateUserAllocation.setUserId(transferAccountEntity.getAssignee());
+                String userName = mailLogMapper.getUserNameByUserId(transferAccountEntity.getAssignee()); // 转让人姓名
+                updateUserAllocation.setUserName(userName);
+                userAllocationService.update(updateUserAllocation, updateQueryWrapper);
+                QueryWrapper<ProjectMember> projectMemberQueryWrapper = new QueryWrapper<>();
+                projectMemberQueryWrapper.eq("project_id", transferAccountEntity.getProjectId());
+                projectMemberQueryWrapper.eq("user_id", transferAccountEntity.getAssignee());
+                projectMemberQueryWrapper.last("limit 1");
+                ProjectMember projectMember = projectMemberService.getOne(projectMemberQueryWrapper);
+                if (Check.isNull(projectMember)) {
+                    ProjectMember addProjectMember = new ProjectMember();
+                    String roleCode = materialInfoService.getRoleCodeByUserId(transferAccountEntity.getAssignee());
+                    addProjectMember.setRoleCode(roleCode);
+                    addProjectMember.setUserId(transferAccountEntity.getAssignee());
+                    addProjectMember.setUserName(userName);
+                    addProjectMember.setProjectId(project.getId());
+                    addProjectMember.setProjectName(project.getProjectName());
+                    projectMemberService.save(addProjectMember);
+                }
+            }
+            mailLogService.sendWeChatByStatus(project.getProjectName(), status, transferAccountEntity.getTransferor(), transferAccountEntity.getAccountId());
+            mailLogService.sendWeChatByStatus(project.getProjectName(), status, transferAccountEntity.getAssignee(), transferAccountEntity.getAccountId());
+            boolean ok = transferAccountService.updateById(transferAccount);
+            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 {
+            transferAccountService.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<TransferAccount> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<TransferAccount> result = new Result<TransferAccount>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.transferAccountService.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<TransferAccount> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<TransferAccount> result = new Result<TransferAccount>();
+        TransferAccount transferAccount = transferAccountService.getById(id);
+        if (transferAccount == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(transferAccount);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<TransferAccount> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                TransferAccount transferAccount = JSON.parseObject(deString, TransferAccount.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(transferAccount, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<TransferAccount> pageList = transferAccountService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "转户记录表列表");
+        mv.addObject(NormalExcelConstants.CLASS, TransferAccount.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<TransferAccount> listTransferAccounts = ExcelImportUtil.importExcel(file.getInputStream(), TransferAccount.class, params);
+                transferAccountService.saveBatch(listTransferAccounts);
+                return Result.ok("文件导入成功!数据行数:" + listTransferAccounts.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("文件导入失败!");
+    }
+
+}

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

@@ -70,6 +70,15 @@ public class UserAllocationController {
     private IProjectMemberService projectMemberService;
 
 
+    @PostMapping(value = "/transferAccount")
+    public Result transferAccount(Long accountId, Long projectId) {
+
+
+        return null;
+
+    }
+
+
     @GetMapping(value = "/accountTurnProject")
     public Result getAccountList(Long accountId, Long projectId) {
         Result result = new Result<>();

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

@@ -1,6 +1,7 @@
 package org.jeecg.modules.ctop.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -112,4 +113,8 @@ public class Project {
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "修改时间")
     private Date updateTime;
+
+
+    @TableField(exist = false)
+    private Integer needExamine;
 }

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

@@ -0,0 +1,115 @@
+package org.jeecg.modules.ctop.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+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 2020-03-26
+ */
+@Data
+@TableName("ctop_transfer_account")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_transfer_account对象", description = "转户记录表")
+public class TransferAccount {
+
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "主键ID")
+    private Long id;
+    /**
+     * 转户账号
+     */
+    @Excel(name = "转户账号", width = 15)
+    @ApiModelProperty(value = "转户账号")
+    private Long accountId;
+    /**
+     * 项目id
+     */
+    @Excel(name = "项目id", width = 15)
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+    /**
+     * 转户人
+     */
+    @Excel(name = "转户人", width = 15)
+    @ApiModelProperty(value = "转户人")
+    private String transferor;
+    /**
+     * 受让人
+     */
+    @Excel(name = "受让人", width = 15)
+    @ApiModelProperty(value = "受让人")
+    private String assignee;
+    /**
+     * 转户人绩效统计截止日期
+     */
+    @Excel(name = "转户人绩效统计截止日期", width = 15)
+    @ApiModelProperty(value = "转户人绩效统计截止日期")
+    private String transferorDate;
+    /**
+     * 受让人绩效统计开始日期
+     */
+    @Excel(name = "受让人绩效统计开始日期", width = 15)
+    @ApiModelProperty(value = "受让人绩效统计开始日期")
+    private String assigneeDate;
+    /**
+     * 审核人
+     */
+    @Excel(name = "审核人", width = 15)
+    @ApiModelProperty(value = "审核人")
+    private String auditor;
+    /**
+     * 审核状态 0:新建 1:通过 2:拒绝
+     */
+    @Excel(name = "审核状态 0:新建 1:通过 2:拒绝", width = 15)
+    @ApiModelProperty(value = "审核状态 0:新建 1:通过 2:拒绝")
+    private Integer status;
+    /**
+     * 备注
+     */
+    @Excel(name = "备注", width = 15)
+    @ApiModelProperty(value = "备注")
+    private Object remarks;
+    /**
+     * 创建时间
+     */
+    @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;
+
+    @TableField(exist = false)
+    private String transferorName;
+
+
+    @TableField(exist = false)
+    private String assigneeName;
+}

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

@@ -0,0 +1,15 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ctop.entity.TransferAccount;
+
+/**
+ * 转户记录表
+ *
+ * @author: jeecg-boot
+ * @date: 2020-03-26
+ * @cersion: V1.0
+ */
+public interface TransferAccountMapper extends BaseMapper<TransferAccount> {
+
+}

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/TransferAccountMapper.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="org.jeecg.modules.ctop.mapper.TransferAccountMapper">
+
+</mapper>

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

@@ -0,0 +1,15 @@
+package org.jeecg.modules.ctop.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ctop.entity.TransferAccount;
+
+/**
+ * 转户记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-03-26
+ */
+public interface ITransferAccountService extends IService<TransferAccount> {
+
+}

+ 19 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/TransferAccountServiceImpl.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.TransferAccount;
+import org.jeecg.modules.ctop.mapper.TransferAccountMapper;
+import org.jeecg.modules.ctop.service.ITransferAccountService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 转户记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-03-26
+ */
+@Service
+public class TransferAccountServiceImpl extends ServiceImpl<TransferAccountMapper, TransferAccount> implements ITransferAccountService {
+
+}

+ 142 - 7
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -6,8 +6,9 @@ import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
-import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONArray;
@@ -22,8 +23,7 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -158,14 +158,14 @@ public class SampleTest {
 
         // 1629785592929294
 
-        conditions.put("advertiser_id", "109437044830");
+        conditions.put("advertiser_id", "1659671533108238");
         JSONObject job = new JSONObject();
         job.put("job_conf_id", 10);
         JSONArray input = new JSONArray();
         JSONObject inputJson = new JSONObject();
         inputJson.put("task_id", 1);
         JSONArray videoIds = new JSONArray();
-        videoIds.add("v02033290000bgq1cejpqv6e4k29b2jg");
+        videoIds.add("v02033aa0000bpspgippskdk4jcuso80");
         inputJson.put("video_ids", videoIds);
         JSONArray music_id = new JSONArray();
         JSONArray image_urls = new JSONArray();
@@ -201,13 +201,148 @@ public class SampleTest {
         conditions.put("job", job);
 
 
-        JSONObject jsonObject = HttpUtils.bytedancePostRequest("8ea30cb02cab8d92b480c4ab01cfc4545fdce33e", url, conditions);
+        JSONObject jsonObject = HttpUtils.bytedancePostRequest("f925c180e05d585f7a9fce048ba62eecc5dab7c2", url, conditions);
         System.err.println(jsonObject);
 
 
     }
 
 
+    @Autowired
+    private IKuaiShouCreativeService creativeService;
+
+    @Test
+    public void suZhao() {
+
+
+        /*Long accountId = 3917130L;
+        String token = "9f2caae880367a9477cf1b6bf86e3858";
+
+        String url = "https://ad.e.kuaishou.com/rest/openapi/v1/file/ad/video/su_zao/list";
+
+
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token);
+        Map<String, Object> param = new HashMap<String, Object>();
+
+        param.put("advertiser_id", accountId);
+        param.put("temporal_granularity", "HOURLY");
+        param.put("page_size", 499);
+        param.put("page", 1);
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        System.err.println(result);*/
+
+
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", " application/json");
+        headers.put("Access-Token", "bd90c55f01d79450c66260bcb15b5c0a");
+        Long advertiserId = 23212L;
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", 23212);
+        //   param.put("creative_id", creativeId);
+        param.put("page_size", 500);
+        param.put("page", 1);
+
+        System.err.println(param);
+        System.err.println(headers);
+
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        System.err.println(resultJson);
+
+
+        if (Check.isNull(resultJson)) {
+            log.error("获取广告创意返回结果为空,advertiserId:{}", advertiserId);
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取广告创意返回结果异常,advertiserId:{},message:{}", advertiserId, message);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+//            log.error("获取广告创意返回结果数据为空,advertiserId:{}", advertiserId);
+            return;
+        }
+        List<KuaiShouCreative> creatives = new ArrayList<>();
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
+            if (!Check.isNull(detailJson)) {
+                KuaiShouCreative creative = new KuaiShouCreative();
+                creative.setId("" + advertiserId + detailJson.getLong("creative_id"));
+                creative.setAccountId(advertiserId);
+                creative.setCampaignId(detailJson.getLong("campaign_id"));
+                creative.setUnitId(detailJson.getLong("unit_id"));
+                creative.setCreativeId(detailJson.getLong("creative_id"));
+                creative.setCreativeName(detailJson.getString("creative_name"));
+                creative.setCreativeMaterialType(detailJson.getInteger("creative_material_type"));
+                //
+                if (!Check.isNull(detailJson.getJSONArray("material_url"))) {
+                    creative.setMaterialUrl(detailJson.getJSONArray("material_url").toJSONString());
+                }
+
+                if (!Check.isNull(detailJson.getJSONArray("image_tokens"))) {
+                    creative.setImageTokens(detailJson.getJSONArray("image_tokens").toJSONString());
+                }
+                creative.setStatus(detailJson.getInteger("status"));
+                creative.setPutStatus(detailJson.getInteger("put_status"));
+                creative.setCreateChannel(detailJson.getInteger("create_channel"));
+                creative.setReviewDetail(detailJson.getString("review_detail"));
+                creative.setCoverUrl(detailJson.getString("cover_url"));
+                creative.setImageToken(detailJson.getString("image_token"));
+                creative.setCoverWidth(detailJson.getString("cover_width"));
+                creative.setCoverHeight(detailJson.getString("cover_height"));
+                creative.setOverlayBgUrl(detailJson.getString("overlay_bg_url"));
+                creative.setOverlayBgImageToken(detailJson.getString("overlay_bg_image_token"));
+                creative.setStickerTitle(detailJson.getString("sticker_title"));
+                creative.setOverlayType(detailJson.getString("overlay_type"));
+                creative.setClickTrackUrl(detailJson.getString("click_track_url"));
+                creative.setImpressionUrl(detailJson.getString("impression_url"));
+                creative.setAdPhotoPlayedT3sUrl(detailJson.getString("ad_photo_played_t3s_url"));
+                creative.setCreativeCreateTime(detailJson.getDate("create_time"));
+                JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
+                if (!Check.isNull(displayInfoJson)) {
+                    creative.setDescription(displayInfoJson.getString("description"));
+                    creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
+                }
+                creative.setCreateTime(new Date());
+                creative.setUpdateTime(new Date());
+
+                if (detailJson.getLong("photo_id") == 0) {
+                    JSONObject programmed_creative_material = detailJson.getJSONObject("programmed_creative_material");
+                    if (!Check.isNull(programmed_creative_material)) {
+                        JSONArray materials = programmed_creative_material.getJSONArray("materials");
+                        if (!Check.isNull(materials)) {
+                            for (int j = 0; j < materials.size(); j++) {
+                                JSONObject materialJson = materials.getJSONObject(j);
+                                if (!Check.isNull(materialJson)) {
+                                    Long photo_id = materialJson.getLong("photo_id");
+                                    creative.setPhotoId(String.valueOf(photo_id));
+                                    creatives.add(creative);
+                                }
+                            }
+                        }
+                    }
+
+
+                } else {
+                    creative.setPhotoId(detailJson.getString("photo_id"));
+                    creatives.add(creative);
+                }
+
+
+            }
+        }
+        creativeService.replaceBatch(creatives);
+
+
+    }
+
+
 }
 
 

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/MailLogMapper.java

@@ -21,4 +21,7 @@ public interface MailLogMapper extends BaseMapper<MailLog> {
 
     List<String> selectWeiXinIdList(@Param("projectId") Long projectId);
 
+    String getWChatIdByUserId(@Param("userId") String responsibleId);
+
+    String getUserNameByUserId(@Param("userId") String transferor);
 }

+ 13 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MailLogMapper.xml

@@ -38,6 +38,19 @@
      and t2.wexin_id != ''
     </select>
 
+    <select id="getWChatIdByUserId" resultType="java.lang.String">
+    select wexin_id
+    from ctop_corp_wexin_user
+    where  user_id = #{userId}
+
+    </select>
+
+    <select id="getUserNameByUserId" resultType="java.lang.String">
+    select
+    realname
+    from sys_user
+    where id = #{userId}
+    </select>
 
 
 </mapper>

+ 12 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMailLogService.java

@@ -12,4 +12,16 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IMailLogService extends IService<MailLog> {
 
+    /**
+     * 发送转户申请信息
+     *
+     * @param responsibleId
+     * @param accountId
+     * @param projectName
+     * @param transferor
+     * @param assignee
+     */
+    void sendWeChat(String responsibleId, Long accountId, String projectName, String transferor, String assignee);
+
+    void sendWeChatByStatus(String projectName, Integer status, String transferor, Long accountId);
 }

+ 55 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MailLogServiceImpl.java

@@ -3,7 +3,10 @@ package cn.com.ctop.common.module.service.impl;
 import cn.com.ctop.common.module.entity.MailLog;
 import cn.com.ctop.common.module.mapper.MailLogMapper;
 import cn.com.ctop.common.module.service.IMailLogService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CorpWexinUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 /**
@@ -15,5 +18,57 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class MailLogServiceImpl extends ServiceImpl<MailLogMapper, MailLog> implements IMailLogService {
+    @Autowired
+    private MailLogMapper mailLogMapper;
 
+
+    @Override
+    public void sendWeChat(String responsibleId, Long accountId, String projectName, String transferor, String assignee) {
+        String weChatId = mailLogMapper.getWChatIdByUserId(responsibleId);
+        if (!Check.isNull(weChatId)) {
+            String transferorName = mailLogMapper.getUserNameByUserId(transferor); // 转让人姓名
+            String assigneeName = mailLogMapper.getUserNameByUserId(assignee); // 转让人姓名
+            StringBuilder text = new StringBuilder();
+            text.append("转户申请").append("<br/>").
+                    append("您的项目:").append(projectName + ",").append("<br/>")
+                    .append("账号:" + accountId).append(",申请由:" + transferorName + "转户于:" + assigneeName).append("<br/>")
+                    .append("等待您的审核,请您及时处理!");
+
+            CorpWexinUtils.sendMessageByWeChatId(weChatId, text.toString());
+        }
+    }
+
+
+    /**
+     * 转户通过或失败发送通知
+     *
+     * @param projectName
+     * @param status
+     * @param userId
+     */
+    @Override
+    public void sendWeChatByStatus(String projectName, Integer status, String userId, Long accountId) {
+
+        String weChatId = mailLogMapper.getWChatIdByUserId(userId);
+        if (!Check.isNull(weChatId)) {
+            String statusName = "";
+
+            if (status == 1) {
+                statusName = "通过";
+            } else if (status == 2) {
+                statusName = "拒绝";
+            }
+
+            StringBuilder text = new StringBuilder();
+            text.append("转户申请审核通知").append("<br/>").
+                    append("您的项目:").append(projectName + ",").append("<br/>")
+                    .append("账号:" + accountId).append("<br/>")
+                    .append("申请的转户操作已:" + statusName).append("<br/>")
+                    .append("请您前往验证,谢谢!");
+
+            CorpWexinUtils.sendMessageByWeChatId(weChatId, text.toString());
+        }
+
+
+    }
 }

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

@@ -46,4 +46,28 @@ public class CorpWexinUtils {
             }
         }
     }
+
+
+    public static void sendMessageByWeChatId(String weChatId, String content) {
+        if (wxCpService == null) {
+            initService();
+        }
+
+        if (!Check.isNull(weChatId)) {
+            WxCpMessage message = new WxCpMessage();
+            message.setMsgType("text");
+            message.setContent(content);
+            message.setAgentId(1000002);
+            message.setToUser(weChatId);
+            try {
+                wxCpService.messageSend(message);
+            } catch (WxErrorException e) {
+                e.printStackTrace();
+            }
+
+        }
+
+
+    }
+
 }