Commit bee6f41211ce9702aef054e4577d059f9faedd9e

Authored by ljlleo
1 parent 439edcd1

商机

Showing 16 changed files with 1128 additions and 0 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
... ... @@ -15,4 +15,7 @@ public interface ErrorCodeConstants {
15 15 // TODO @wanwan:要单独一个分段噢
16 16 ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_000_001, "线索不存在");
17 17  
  18 + // ========== 商机管理 1-020-001-000 ==========
  19 + ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_001_000, "商机不存在");
  20 +
18 21 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.business;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  6 +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*;
  8 +import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
  9 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
  10 +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
  11 +import io.swagger.v3.oas.annotations.Operation;
  12 +import io.swagger.v3.oas.annotations.Parameter;
  13 +import io.swagger.v3.oas.annotations.tags.Tag;
  14 +import org.springframework.security.access.prepost.PreAuthorize;
  15 +import org.springframework.validation.annotation.Validated;
  16 +import org.springframework.web.bind.annotation.*;
  17 +
  18 +import javax.annotation.Resource;
  19 +import javax.servlet.http.HttpServletResponse;
  20 +import javax.validation.Valid;
  21 +import java.io.IOException;
  22 +import java.util.Collection;
  23 +import java.util.List;
  24 +
  25 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  26 +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
  27 +
  28 +@Tag(name = "管理后台 - 商机")
  29 +@RestController
  30 +@RequestMapping("/crm/business")
  31 +@Validated
  32 +public class CrmBusinessController {
  33 +
  34 + @Resource
  35 + private CrmBusinessService businessService;
  36 +
  37 + @PostMapping("/create")
  38 + @Operation(summary = "创建商机")
  39 + @PreAuthorize("@ss.hasPermission('crm:business:create')")
  40 + public CommonResult<Long> createBusiness(@Valid @RequestBody CrmBusinessCreateReqVO createReqVO) {
  41 + return success(businessService.createBusiness(createReqVO));
  42 + }
  43 +
  44 + @PutMapping("/update")
  45 + @Operation(summary = "更新商机")
  46 + @PreAuthorize("@ss.hasPermission('crm:business:update')")
  47 + public CommonResult<Boolean> updateBusiness(@Valid @RequestBody CrmBusinessUpdateReqVO updateReqVO) {
  48 + businessService.updateBusiness(updateReqVO);
  49 + return success(true);
  50 + }
  51 +
  52 + @DeleteMapping("/delete")
  53 + @Operation(summary = "删除商机")
  54 + @Parameter(name = "id", description = "编号", required = true)
  55 + @PreAuthorize("@ss.hasPermission('crm:business:delete')")
  56 + public CommonResult<Boolean> deleteBusiness(@RequestParam("id") Long id) {
  57 + businessService.deleteBusiness(id);
  58 + return success(true);
  59 + }
  60 +
  61 + @GetMapping("/get")
  62 + @Operation(summary = "获得商机")
  63 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  64 + @PreAuthorize("@ss.hasPermission('crm:business:query')")
  65 + public CommonResult<CrmBusinessRespVO> getBusiness(@RequestParam("id") Long id) {
  66 + CrmBusinessDO business = businessService.getBusiness(id);
  67 + return success(CrmBusinessConvert.INSTANCE.convert(business));
  68 + }
  69 +
  70 + @GetMapping("/list")
  71 + @Operation(summary = "获得商机列表")
  72 + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
  73 + @PreAuthorize("@ss.hasPermission('crm:business:query')")
  74 + public CommonResult<List<CrmBusinessRespVO>> getBusinessList(@RequestParam("ids") Collection<Long> ids) {
  75 + List<CrmBusinessDO> list = businessService.getBusinessList(ids);
  76 + return success(CrmBusinessConvert.INSTANCE.convertList(list));
  77 + }
  78 +
  79 + @GetMapping("/page")
  80 + @Operation(summary = "获得商机分页")
  81 + @PreAuthorize("@ss.hasPermission('crm:business:query')")
  82 + public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) {
  83 + PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(pageVO);
  84 + return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult));
  85 + }
  86 +
  87 + @GetMapping("/export-excel")
  88 + @Operation(summary = "导出商机 Excel")
  89 + @PreAuthorize("@ss.hasPermission('crm:business:export')")
  90 + @OperateLog(type = EXPORT)
  91 + public void exportBusinessExcel(@Valid CrmBusinessExportReqVO exportReqVO,
  92 + HttpServletResponse response) throws IOException {
  93 + List<CrmBusinessDO> list = businessService.getBusinessList(exportReqVO);
  94 + // 导出 Excel
  95 + List<CrmBusinessExcelVO> datas = CrmBusinessConvert.INSTANCE.convertList02(list);
  96 + ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class, datas);
  97 + }
  98 +
  99 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +import org.springframework.format.annotation.DateTimeFormat;
  6 +
  7 +import javax.validation.constraints.NotNull;
  8 +import java.math.BigDecimal;
  9 +import java.time.LocalDateTime;
  10 +
  11 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  12 +
  13 +/**
  14 + * 商机 Base VO,提供给添加、修改、详细的子 VO 使用
  15 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
  16 + */
  17 +@Data
  18 +public class CrmBusinessBaseVO {
  19 +
  20 + @Schema(description = "商机名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
  21 + @NotNull(message = "商机名称不能为空")
  22 + private String name;
  23 +
  24 + @Schema(description = "商机状态类型编号", example = "25714")
  25 + @NotNull(message = "商机状态类型不能为空")
  26 + private Long statusTypeId;
  27 +
  28 + @Schema(description = "商机状态编号", example = "30320")
  29 + @NotNull(message = "商机状态不能为空")
  30 + private Long statusId;
  31 +
  32 + @Schema(description = "下次联系时间")
  33 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  34 + private LocalDateTime contactNextTime;
  35 +
  36 + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10299")
  37 + @NotNull(message = "客户不能为空")
  38 + private Long customerId;
  39 +
  40 + @Schema(description = "预计成交日期")
  41 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  42 + private LocalDateTime dealTime;
  43 +
  44 + @Schema(description = "商机金额", example = "12371")
  45 + private BigDecimal price;
  46 +
  47 + @Schema(description = "整单折扣")
  48 + private BigDecimal discountPercent;
  49 +
  50 + @Schema(description = "产品总金额", example = "12025")
  51 + private BigDecimal productPrice;
  52 +
  53 + @Schema(description = "备注", example = "随便")
  54 + private String remark;
  55 +
  56 + @Schema(description = "负责人的用户编号", example = "25562")
  57 + private Long ownerUserId;
  58 +
  59 + @Schema(description = "只读权限的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED)
  60 + private String roUserIds;
  61 +
  62 + @Schema(description = "读写权限的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED)
  63 + private String rwUserIds;
  64 +
  65 + @Schema(description = "1赢单2输单3无效", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  66 + private Integer endStatus;
  67 +
  68 + @Schema(description = "结束时的备注", example = "你说的对")
  69 + private String endRemark;
  70 +
  71 + @Schema(description = "最后跟进时间")
  72 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  73 + private LocalDateTime contactLastTime;
  74 +
  75 + @Schema(description = "跟进状态", example = "1")
  76 + private Integer followUpStatus;
  77 +
  78 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import javax.validation.constraints.*;
  7 +
  8 +@Schema(description = "管理后台 - 商机创建 Request VO")
  9 +@Data
  10 +@EqualsAndHashCode(callSuper = true)
  11 +@ToString(callSuper = true)
  12 +public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO {
  13 +
  14 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExcelVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import java.time.LocalDateTime;
  7 +import java.time.LocalDateTime;
  8 +import java.math.BigDecimal;
  9 +import java.math.BigDecimal;
  10 +import java.math.BigDecimal;
  11 +import java.time.LocalDateTime;
  12 +import java.time.LocalDateTime;
  13 +import java.time.LocalDateTime;
  14 +
  15 +import com.alibaba.excel.annotation.ExcelProperty;
  16 +
  17 +/**
  18 + * 商机 Excel VO
  19 + *
  20 + * @author ljlleo
  21 + */
  22 +@Data
  23 +public class CrmBusinessExcelVO {
  24 +
  25 + @ExcelProperty("主键")
  26 + private Long id;
  27 +
  28 + @ExcelProperty("商机名称")
  29 + private String name;
  30 +
  31 + @ExcelProperty("商机状态类型编号")
  32 + private Long statusTypeId;
  33 +
  34 + @ExcelProperty("商机状态编号")
  35 + private Long statusId;
  36 +
  37 + @ExcelProperty("下次联系时间")
  38 + private LocalDateTime contactNextTime;
  39 +
  40 + @ExcelProperty("客户编号")
  41 + private Long customerId;
  42 +
  43 + @ExcelProperty("预计成交日期")
  44 + private LocalDateTime dealTime;
  45 +
  46 + @ExcelProperty("商机金额")
  47 + private BigDecimal price;
  48 +
  49 + @ExcelProperty("整单折扣")
  50 + private BigDecimal discountPercent;
  51 +
  52 + @ExcelProperty("产品总金额")
  53 + private BigDecimal productPrice;
  54 +
  55 + @ExcelProperty("备注")
  56 + private String remark;
  57 +
  58 + @ExcelProperty("负责人的用户编号")
  59 + private Long ownerUserId;
  60 +
  61 + @ExcelProperty("创建时间")
  62 + private LocalDateTime createTime;
  63 +
  64 + @ExcelProperty("只读权限的用户编号数组")
  65 + private String roUserIds;
  66 +
  67 + @ExcelProperty("读写权限的用户编号数组")
  68 + private String rwUserIds;
  69 +
  70 + @ExcelProperty("1赢单2输单3无效")
  71 + private Integer endStatus;
  72 +
  73 + @ExcelProperty("结束时的备注")
  74 + private String endRemark;
  75 +
  76 + @ExcelProperty("最后跟进时间")
  77 + private LocalDateTime contactLastTime;
  78 +
  79 + @ExcelProperty("跟进状态")
  80 + private Integer followUpStatus;
  81 +
  82 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExportReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +import org.springframework.format.annotation.DateTimeFormat;
  6 +
  7 +import java.math.BigDecimal;
  8 +import java.time.LocalDateTime;
  9 +
  10 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  11 +
  12 +@Schema(description = "管理后台 - 商机 Excel 导出 Request VO,参数和 CrmBusinessPageReqVO 是一致的")
  13 +@Data
  14 +public class CrmBusinessExportReqVO {
  15 +
  16 + @Schema(description = "商机名称", example = "李四")
  17 + private String name;
  18 +
  19 + @Schema(description = "商机状态类型编号", example = "25714")
  20 + private Long statusTypeId;
  21 +
  22 + @Schema(description = "商机状态编号", example = "30320")
  23 + private Long statusId;
  24 +
  25 + @Schema(description = "下次联系时间")
  26 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  27 + private LocalDateTime[] contactNextTime;
  28 +
  29 + @Schema(description = "客户编号", example = "10299")
  30 + private Long customerId;
  31 +
  32 + @Schema(description = "预计成交日期")
  33 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  34 + private LocalDateTime[] dealTime;
  35 +
  36 + @Schema(description = "商机金额", example = "12371")
  37 + private BigDecimal price;
  38 +
  39 + @Schema(description = "整单折扣")
  40 + private BigDecimal discountPercent;
  41 +
  42 + @Schema(description = "产品总金额", example = "12025")
  43 + private BigDecimal productPrice;
  44 +
  45 + @Schema(description = "备注", example = "随便")
  46 + private String remark;
  47 +
  48 + @Schema(description = "负责人的用户编号", example = "25562")
  49 + private Long ownerUserId;
  50 +
  51 + @Schema(description = "创建时间")
  52 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  53 + private LocalDateTime[] createTime;
  54 +
  55 + @Schema(description = "只读权限的用户编号数组")
  56 + private String roUserIds;
  57 +
  58 + @Schema(description = "读写权限的用户编号数组")
  59 + private String rwUserIds;
  60 +
  61 + @Schema(description = "1赢单2输单3无效", example = "1")
  62 + private Integer endStatus;
  63 +
  64 + @Schema(description = "结束时的备注", example = "你说的对")
  65 + private String endRemark;
  66 +
  67 + @Schema(description = "最后跟进时间")
  68 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  69 + private LocalDateTime[] contactLastTime;
  70 +
  71 + @Schema(description = "跟进状态", example = "1")
  72 + private Integer followUpStatus;
  73 +
  74 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +import lombok.ToString;
  8 +import org.springframework.format.annotation.DateTimeFormat;
  9 +
  10 +import java.math.BigDecimal;
  11 +import java.time.LocalDateTime;
  12 +
  13 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  14 +
  15 +@Schema(description = "管理后台 - 商机分页 Request VO")
  16 +@Data
  17 +@EqualsAndHashCode(callSuper = true)
  18 +@ToString(callSuper = true)
  19 +public class CrmBusinessPageReqVO extends PageParam {
  20 +
  21 + @Schema(description = "商机名称", example = "李四")
  22 + private String name;
  23 +
  24 + @Schema(description = "商机状态类型编号", example = "25714")
  25 + private Long statusTypeId;
  26 +
  27 + @Schema(description = "商机状态编号", example = "30320")
  28 + private Long statusId;
  29 +
  30 + @Schema(description = "下次联系时间")
  31 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  32 + private LocalDateTime[] contactNextTime;
  33 +
  34 + @Schema(description = "客户编号", example = "10299")
  35 + private Long customerId;
  36 +
  37 + @Schema(description = "预计成交日期")
  38 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  39 + private LocalDateTime[] dealTime;
  40 +
  41 + @Schema(description = "商机金额", example = "12371")
  42 + private BigDecimal price;
  43 +
  44 + @Schema(description = "整单折扣")
  45 + private BigDecimal discountPercent;
  46 +
  47 + @Schema(description = "产品总金额", example = "12025")
  48 + private BigDecimal productPrice;
  49 +
  50 + @Schema(description = "备注", example = "随便")
  51 + private String remark;
  52 +
  53 + @Schema(description = "负责人的用户编号", example = "25562")
  54 + private Long ownerUserId;
  55 +
  56 + @Schema(description = "创建时间")
  57 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  58 + private LocalDateTime[] createTime;
  59 +
  60 + @Schema(description = "只读权限的用户编号数组")
  61 + private String roUserIds;
  62 +
  63 + @Schema(description = "读写权限的用户编号数组")
  64 + private String rwUserIds;
  65 +
  66 + @Schema(description = "1赢单2输单3无效", example = "1")
  67 + private Integer endStatus;
  68 +
  69 + @Schema(description = "结束时的备注", example = "你说的对")
  70 + private String endRemark;
  71 +
  72 + @Schema(description = "最后跟进时间")
  73 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  74 + private LocalDateTime[] contactLastTime;
  75 +
  76 + @Schema(description = "跟进状态", example = "1")
  77 + private Integer followUpStatus;
  78 +
  79 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.time.LocalDateTime;
  6 +
  7 +@Schema(description = "管理后台 - 商机 Response VO")
  8 +@Data
  9 +@EqualsAndHashCode(callSuper = true)
  10 +@ToString(callSuper = true)
  11 +public class CrmBusinessRespVO extends CrmBusinessBaseVO {
  12 +
  13 + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
  14 + private Long id;
  15 +
  16 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  17 + private LocalDateTime createTime;
  18 +
  19 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.business.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import javax.validation.constraints.*;
  7 +
  8 +@Schema(description = "管理后台 - 商机更新 Request VO")
  9 +@Data
  10 +@EqualsAndHashCode(callSuper = true)
  11 +@ToString(callSuper = true)
  12 +public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO {
  13 +
  14 + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
  15 + @NotNull(message = "主键不能为空")
  16 + private Long id;
  17 +
  18 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.convert.business;
  2 +
  3 +import java.util.*;
  4 +
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +
  7 +import org.mapstruct.Mapper;
  8 +import org.mapstruct.factory.Mappers;
  9 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*;
  10 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
  11 +
  12 +/**
  13 + * 商机 Convert
  14 + *
  15 + * @author ljlleo
  16 + */
  17 +@Mapper
  18 +public interface CrmBusinessConvert {
  19 +
  20 + CrmBusinessConvert INSTANCE = Mappers.getMapper(CrmBusinessConvert.class);
  21 +
  22 + CrmBusinessDO convert(CrmBusinessCreateReqVO bean);
  23 +
  24 + CrmBusinessDO convert(CrmBusinessUpdateReqVO bean);
  25 +
  26 + CrmBusinessRespVO convert(CrmBusinessDO bean);
  27 +
  28 + List<CrmBusinessRespVO> convertList(List<CrmBusinessDO> list);
  29 +
  30 + PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> page);
  31 +
  32 + List<CrmBusinessExcelVO> convertList02(List<CrmBusinessDO> list);
  33 +
  34 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.dal.dataobject.business;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import com.baomidou.mybatisplus.annotation.KeySequence;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import lombok.*;
  8 +
  9 +import java.math.BigDecimal;
  10 +import java.time.LocalDateTime;
  11 +
  12 +/**
  13 + * 商机 DO
  14 + *
  15 + * @author ljlleo
  16 + */
  17 +@TableName("crm_business")
  18 +@KeySequence("crm_business_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  19 +@Data
  20 +@EqualsAndHashCode(callSuper = true)
  21 +@ToString(callSuper = true)
  22 +@Builder
  23 +@NoArgsConstructor
  24 +@AllArgsConstructor
  25 +public class CrmBusinessDO extends BaseDO {
  26 +
  27 + /**
  28 + * 主键
  29 + */
  30 + @TableId
  31 + private Long id;
  32 + /**
  33 + * 商机名称
  34 + */
  35 + private String name;
  36 + /**
  37 + * 商机状态类型编号
  38 + */
  39 + private Long statusTypeId;
  40 + /**
  41 + * 商机状态编号
  42 + */
  43 + private Long statusId;
  44 + /**
  45 + * 下次联系时间
  46 + */
  47 + private LocalDateTime contactNextTime;
  48 + /**
  49 + * 客户编号
  50 + */
  51 + private Long customerId;
  52 + /**
  53 + * 预计成交日期
  54 + */
  55 + private LocalDateTime dealTime;
  56 + /**
  57 + * 商机金额
  58 + */
  59 + private BigDecimal price;
  60 + /**
  61 + * 整单折扣
  62 + */
  63 + private BigDecimal discountPercent;
  64 + /**
  65 + * 产品总金额
  66 + */
  67 + private BigDecimal productPrice;
  68 + /**
  69 + * 备注
  70 + */
  71 + private String remark;
  72 + /**
  73 + * 负责人的用户编号
  74 + */
  75 + private Long ownerUserId;
  76 + /**
  77 + * 只读权限的用户编号数组
  78 + */
  79 + private String roUserIds;
  80 + /**
  81 + * 读写权限的用户编号数组
  82 + */
  83 + private String rwUserIds;
  84 + /**
  85 + * 1赢单2输单3无效
  86 + */
  87 + private Integer endStatus;
  88 + /**
  89 + * 结束时的备注
  90 + */
  91 + private String endRemark;
  92 + /**
  93 + * 最后跟进时间
  94 + */
  95 + private LocalDateTime contactLastTime;
  96 + /**
  97 + * 跟进状态
  98 + */
  99 + private Integer followUpStatus;
  100 +
  101 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.dal.mysql.business;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
  9 +import org.apache.ibatis.annotations.Mapper;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * 商机 Mapper
  15 + *
  16 + * @author ljlleo
  17 + */
  18 +@Mapper
  19 +public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> {
  20 +
  21 + default PageResult<CrmBusinessDO> selectPage(CrmBusinessPageReqVO reqVO) {
  22 + return selectPage(reqVO, new LambdaQueryWrapperX<CrmBusinessDO>()
  23 + .likeIfPresent(CrmBusinessDO::getName, reqVO.getName())
  24 + .eqIfPresent(CrmBusinessDO::getStatusTypeId, reqVO.getStatusTypeId())
  25 + .eqIfPresent(CrmBusinessDO::getStatusId, reqVO.getStatusId())
  26 + .betweenIfPresent(CrmBusinessDO::getContactNextTime, reqVO.getContactNextTime())
  27 + .eqIfPresent(CrmBusinessDO::getCustomerId, reqVO.getCustomerId())
  28 + .betweenIfPresent(CrmBusinessDO::getDealTime, reqVO.getDealTime())
  29 + .eqIfPresent(CrmBusinessDO::getPrice, reqVO.getPrice())
  30 + .eqIfPresent(CrmBusinessDO::getDiscountPercent, reqVO.getDiscountPercent())
  31 + .eqIfPresent(CrmBusinessDO::getProductPrice, reqVO.getProductPrice())
  32 + .eqIfPresent(CrmBusinessDO::getRemark, reqVO.getRemark())
  33 + .eqIfPresent(CrmBusinessDO::getOwnerUserId, reqVO.getOwnerUserId())
  34 + .betweenIfPresent(CrmBusinessDO::getCreateTime, reqVO.getCreateTime())
  35 + .eqIfPresent(CrmBusinessDO::getRoUserIds, reqVO.getRoUserIds())
  36 + .eqIfPresent(CrmBusinessDO::getRwUserIds, reqVO.getRwUserIds())
  37 + .eqIfPresent(CrmBusinessDO::getEndStatus, reqVO.getEndStatus())
  38 + .eqIfPresent(CrmBusinessDO::getEndRemark, reqVO.getEndRemark())
  39 + .betweenIfPresent(CrmBusinessDO::getContactLastTime, reqVO.getContactLastTime())
  40 + .eqIfPresent(CrmBusinessDO::getFollowUpStatus, reqVO.getFollowUpStatus())
  41 + .orderByDesc(CrmBusinessDO::getId));
  42 + }
  43 +
  44 + default List<CrmBusinessDO> selectList(CrmBusinessExportReqVO reqVO) {
  45 + return selectList(new LambdaQueryWrapperX<CrmBusinessDO>()
  46 + .likeIfPresent(CrmBusinessDO::getName, reqVO.getName())
  47 + .eqIfPresent(CrmBusinessDO::getStatusTypeId, reqVO.getStatusTypeId())
  48 + .eqIfPresent(CrmBusinessDO::getStatusId, reqVO.getStatusId())
  49 + .betweenIfPresent(CrmBusinessDO::getContactNextTime, reqVO.getContactNextTime())
  50 + .eqIfPresent(CrmBusinessDO::getCustomerId, reqVO.getCustomerId())
  51 + .betweenIfPresent(CrmBusinessDO::getDealTime, reqVO.getDealTime())
  52 + .eqIfPresent(CrmBusinessDO::getPrice, reqVO.getPrice())
  53 + .eqIfPresent(CrmBusinessDO::getDiscountPercent, reqVO.getDiscountPercent())
  54 + .eqIfPresent(CrmBusinessDO::getProductPrice, reqVO.getProductPrice())
  55 + .eqIfPresent(CrmBusinessDO::getRemark, reqVO.getRemark())
  56 + .eqIfPresent(CrmBusinessDO::getOwnerUserId, reqVO.getOwnerUserId())
  57 + .betweenIfPresent(CrmBusinessDO::getCreateTime, reqVO.getCreateTime())
  58 + .eqIfPresent(CrmBusinessDO::getRoUserIds, reqVO.getRoUserIds())
  59 + .eqIfPresent(CrmBusinessDO::getRwUserIds, reqVO.getRwUserIds())
  60 + .eqIfPresent(CrmBusinessDO::getEndStatus, reqVO.getEndStatus())
  61 + .eqIfPresent(CrmBusinessDO::getEndRemark, reqVO.getEndRemark())
  62 + .betweenIfPresent(CrmBusinessDO::getContactLastTime, reqVO.getContactLastTime())
  63 + .eqIfPresent(CrmBusinessDO::getFollowUpStatus, reqVO.getFollowUpStatus())
  64 + .orderByDesc(CrmBusinessDO::getId));
  65 + }
  66 +
  67 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.service.business;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessCreateReqVO;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
  9 +
  10 +import javax.validation.Valid;
  11 +import java.util.Collection;
  12 +import java.util.List;
  13 +
  14 +/**
  15 + * 商机 Service 接口
  16 + *
  17 + * @author ljlleo
  18 + */
  19 +public interface CrmBusinessService {
  20 +
  21 + /**
  22 + * 创建商机
  23 + *
  24 + * @param createReqVO 创建信息
  25 + * @return 编号
  26 + */
  27 + Long createBusiness(@Valid CrmBusinessCreateReqVO createReqVO);
  28 +
  29 + /**
  30 + * 更新商机
  31 + *
  32 + * @param updateReqVO 更新信息
  33 + */
  34 + void updateBusiness(@Valid CrmBusinessUpdateReqVO updateReqVO);
  35 +
  36 + /**
  37 + * 删除商机
  38 + *
  39 + * @param id 编号
  40 + */
  41 + void deleteBusiness(Long id);
  42 +
  43 + /**
  44 + * 获得商机
  45 + *
  46 + * @param id 编号
  47 + * @return 商机
  48 + */
  49 + CrmBusinessDO getBusiness(Long id);
  50 +
  51 + /**
  52 + * 获得商机列表
  53 + *
  54 + * @param ids 编号
  55 + * @return 商机列表
  56 + */
  57 + List<CrmBusinessDO> getBusinessList(Collection<Long> ids);
  58 +
  59 + /**
  60 + * 获得商机分页
  61 + *
  62 + * @param pageReqVO 分页查询
  63 + * @return 商机分页
  64 + */
  65 + PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO);
  66 +
  67 + /**
  68 + * 获得商机列表, 用于 Excel 导出
  69 + *
  70 + * @param exportReqVO 查询条件
  71 + * @return 商机列表
  72 + */
  73 + List<CrmBusinessDO> getBusinessList(CrmBusinessExportReqVO exportReqVO);
  74 +
  75 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.service.business;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessCreateReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO;
  8 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO;
  9 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO;
  10 +import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
  11 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
  12 +import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
  13 +import org.springframework.stereotype.Service;
  14 +import org.springframework.validation.annotation.Validated;
  15 +
  16 +import javax.annotation.Resource;
  17 +import java.util.Collection;
  18 +import java.util.List;
  19 +
  20 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  21 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
  22 +
  23 +/**
  24 + * 商机 Service 实现类
  25 + *
  26 + * @author ljlleo
  27 + */
  28 +@Service
  29 +@Validated
  30 +public class CrmBusinessServiceImpl implements CrmBusinessService {
  31 +
  32 + @Resource
  33 + private CrmBusinessMapper businessMapper;
  34 +
  35 + @Override
  36 + public Long createBusiness(CrmBusinessCreateReqVO createReqVO) {
  37 + // 插入
  38 + CrmBusinessDO business = CrmBusinessConvert.INSTANCE.convert(createReqVO);
  39 + businessMapper.insert(business);
  40 + // 返回
  41 + return business.getId();
  42 + }
  43 +
  44 + @Override
  45 + public void updateBusiness(CrmBusinessUpdateReqVO updateReqVO) {
  46 + // 校验存在
  47 + validateBusinessExists(updateReqVO.getId());
  48 + // 更新
  49 + CrmBusinessDO updateObj = CrmBusinessConvert.INSTANCE.convert(updateReqVO);
  50 + businessMapper.updateById(updateObj);
  51 + }
  52 +
  53 + @Override
  54 + public void deleteBusiness(Long id) {
  55 + // 校验存在
  56 + validateBusinessExists(id);
  57 + // 删除
  58 + businessMapper.deleteById(id);
  59 + }
  60 +
  61 + private void validateBusinessExists(Long id) {
  62 + if (businessMapper.selectById(id) == null) {
  63 + throw exception(BUSINESS_NOT_EXISTS);
  64 + }
  65 + }
  66 +
  67 + @Override
  68 + public CrmBusinessDO getBusiness(Long id) {
  69 + return businessMapper.selectById(id);
  70 + }
  71 +
  72 + @Override
  73 + public List<CrmBusinessDO> getBusinessList(Collection<Long> ids) {
  74 + if (CollUtil.isEmpty(ids)) {
  75 + return ListUtil.empty();
  76 + }
  77 + return businessMapper.selectBatchIds(ids);
  78 + }
  79 +
  80 + @Override
  81 + public PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO) {
  82 + return businessMapper.selectPage(pageReqVO);
  83 + }
  84 +
  85 + @Override
  86 + public List<CrmBusinessDO> getBusinessList(CrmBusinessExportReqVO exportReqVO) {
  87 + return businessMapper.selectList(exportReqVO);
  88 + }
  89 +
  90 +}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/business/CrmBusinessMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper">
  4 +
  5 + <!--
  6 + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  7 + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  8 + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  9 + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  10 + -->
  11 +
  12 +</mapper>
... ...
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.service.business;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessCreateReqVO;
  6 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO;
  7 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO;
  8 +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO;
  9 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
  10 +import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
  11 +import org.junit.jupiter.api.Disabled;
  12 +import org.junit.jupiter.api.Test;
  13 +import org.springframework.context.annotation.Import;
  14 +
  15 +import javax.annotation.Resource;
  16 +import java.util.List;
  17 +
  18 +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
  19 +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
  20 +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
  21 +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
  22 +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
  23 +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
  24 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
  25 +import static org.junit.jupiter.api.Assertions.*;
  26 +
  27 +/**
  28 + * {@link CrmBusinessServiceImpl} 的单元测试类
  29 + *
  30 + * @author ljlleo
  31 + */
  32 +@Import(CrmBusinessServiceImpl.class)
  33 +public class CrmBusinessServiceImplTest extends BaseDbUnitTest {
  34 +
  35 + @Resource
  36 + private CrmBusinessServiceImpl businessService;
  37 +
  38 + @Resource
  39 + private CrmBusinessMapper businessMapper;
  40 +
  41 + @Test
  42 + public void testCreateBusiness_success() {
  43 + // 准备参数
  44 + CrmBusinessCreateReqVO reqVO = randomPojo(CrmBusinessCreateReqVO.class);
  45 +
  46 + // 调用
  47 + Long businessId = businessService.createBusiness(reqVO);
  48 + // 断言
  49 + assertNotNull(businessId);
  50 + // 校验记录的属性是否正确
  51 + CrmBusinessDO business = businessMapper.selectById(businessId);
  52 + assertPojoEquals(reqVO, business);
  53 + }
  54 +
  55 + @Test
  56 + public void testUpdateBusiness_success() {
  57 + // mock 数据
  58 + CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class);
  59 + businessMapper.insert(dbBusiness);// @Sql: 先插入出一条存在的数据
  60 + // 准备参数
  61 + CrmBusinessUpdateReqVO reqVO = randomPojo(CrmBusinessUpdateReqVO.class, o -> {
  62 + o.setId(dbBusiness.getId()); // 设置更新的 ID
  63 + });
  64 +
  65 + // 调用
  66 + businessService.updateBusiness(reqVO);
  67 + // 校验是否更新正确
  68 + CrmBusinessDO business = businessMapper.selectById(reqVO.getId()); // 获取最新的
  69 + assertPojoEquals(reqVO, business);
  70 + }
  71 +
  72 + @Test
  73 + public void testUpdateBusiness_notExists() {
  74 + // 准备参数
  75 + CrmBusinessUpdateReqVO reqVO = randomPojo(CrmBusinessUpdateReqVO.class);
  76 +
  77 + // 调用, 并断言异常
  78 + assertServiceException(() -> businessService.updateBusiness(reqVO), BUSINESS_NOT_EXISTS);
  79 + }
  80 +
  81 + @Test
  82 + public void testDeleteBusiness_success() {
  83 + // mock 数据
  84 + CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class);
  85 + businessMapper.insert(dbBusiness);// @Sql: 先插入出一条存在的数据
  86 + // 准备参数
  87 + Long id = dbBusiness.getId();
  88 +
  89 + // 调用
  90 + businessService.deleteBusiness(id);
  91 + // 校验数据不存在了
  92 + assertNull(businessMapper.selectById(id));
  93 + }
  94 +
  95 + @Test
  96 + public void testDeleteBusiness_notExists() {
  97 + // 准备参数
  98 + Long id = randomLongId();
  99 +
  100 + // 调用, 并断言异常
  101 + assertServiceException(() -> businessService.deleteBusiness(id), BUSINESS_NOT_EXISTS);
  102 + }
  103 +
  104 + @Test
  105 + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
  106 + public void testGetBusinessPage() {
  107 + // mock 数据
  108 + CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class, o -> { // 等会查询到
  109 + o.setName(null);
  110 + o.setStatusTypeId(null);
  111 + o.setStatusId(null);
  112 + o.setContactNextTime(null);
  113 + o.setCustomerId(null);
  114 + o.setDealTime(null);
  115 + o.setPrice(null);
  116 + o.setDiscountPercent(null);
  117 + o.setProductPrice(null);
  118 + o.setRemark(null);
  119 + o.setOwnerUserId(null);
  120 + o.setCreateTime(null);
  121 + o.setRoUserIds(null);
  122 + o.setRwUserIds(null);
  123 + o.setEndStatus(null);
  124 + o.setEndRemark(null);
  125 + o.setContactLastTime(null);
  126 + o.setFollowUpStatus(null);
  127 + });
  128 + businessMapper.insert(dbBusiness);
  129 + // 测试 name 不匹配
  130 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setName(null)));
  131 + // 测试 statusTypeId 不匹配
  132 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusTypeId(null)));
  133 + // 测试 statusId 不匹配
  134 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusId(null)));
  135 + // 测试 contactNextTime 不匹配
  136 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactNextTime(null)));
  137 + // 测试 customerId 不匹配
  138 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCustomerId(null)));
  139 + // 测试 dealTime 不匹配
  140 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDealTime(null)));
  141 + // 测试 price 不匹配
  142 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setPrice(null)));
  143 + // 测试 discountPercent 不匹配
  144 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDiscountPercent(null)));
  145 + // 测试 productPrice 不匹配
  146 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setProductPrice(null)));
  147 + // 测试 remark 不匹配
  148 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRemark(null)));
  149 + // 测试 ownerUserId 不匹配
  150 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setOwnerUserId(null)));
  151 + // 测试 createTime 不匹配
  152 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCreateTime(null)));
  153 + // 测试 roUserIds 不匹配
  154 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRoUserIds(null)));
  155 + // 测试 rwUserIds 不匹配
  156 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRwUserIds(null)));
  157 + // 测试 endStatus 不匹配
  158 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndStatus(null)));
  159 + // 测试 endRemark 不匹配
  160 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndRemark(null)));
  161 + // 测试 contactLastTime 不匹配
  162 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactLastTime(null)));
  163 + // 测试 followUpStatus 不匹配
  164 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setFollowUpStatus(null)));
  165 + // 准备参数
  166 + CrmBusinessPageReqVO reqVO = new CrmBusinessPageReqVO();
  167 + reqVO.setName(null);
  168 + reqVO.setStatusTypeId(null);
  169 + reqVO.setStatusId(null);
  170 + reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  171 + reqVO.setCustomerId(null);
  172 + reqVO.setDealTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  173 + reqVO.setPrice(null);
  174 + reqVO.setDiscountPercent(null);
  175 + reqVO.setProductPrice(null);
  176 + reqVO.setRemark(null);
  177 + reqVO.setOwnerUserId(null);
  178 + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  179 + reqVO.setRoUserIds(null);
  180 + reqVO.setRwUserIds(null);
  181 + reqVO.setEndStatus(null);
  182 + reqVO.setEndRemark(null);
  183 + reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  184 + reqVO.setFollowUpStatus(null);
  185 +
  186 + // 调用
  187 + PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(reqVO);
  188 + // 断言
  189 + assertEquals(1, pageResult.getTotal());
  190 + assertEquals(1, pageResult.getList().size());
  191 + assertPojoEquals(dbBusiness, pageResult.getList().get(0));
  192 + }
  193 +
  194 + @Test
  195 + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
  196 + public void testGetBusinessList() {
  197 + // mock 数据
  198 + CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class, o -> { // 等会查询到
  199 + o.setName(null);
  200 + o.setStatusTypeId(null);
  201 + o.setStatusId(null);
  202 + o.setContactNextTime(null);
  203 + o.setCustomerId(null);
  204 + o.setDealTime(null);
  205 + o.setPrice(null);
  206 + o.setDiscountPercent(null);
  207 + o.setProductPrice(null);
  208 + o.setRemark(null);
  209 + o.setOwnerUserId(null);
  210 + o.setCreateTime(null);
  211 + o.setRoUserIds(null);
  212 + o.setRwUserIds(null);
  213 + o.setEndStatus(null);
  214 + o.setEndRemark(null);
  215 + o.setContactLastTime(null);
  216 + o.setFollowUpStatus(null);
  217 + });
  218 + businessMapper.insert(dbBusiness);
  219 + // 测试 name 不匹配
  220 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setName(null)));
  221 + // 测试 statusTypeId 不匹配
  222 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusTypeId(null)));
  223 + // 测试 statusId 不匹配
  224 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusId(null)));
  225 + // 测试 contactNextTime 不匹配
  226 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactNextTime(null)));
  227 + // 测试 customerId 不匹配
  228 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCustomerId(null)));
  229 + // 测试 dealTime 不匹配
  230 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDealTime(null)));
  231 + // 测试 price 不匹配
  232 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setPrice(null)));
  233 + // 测试 discountPercent 不匹配
  234 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDiscountPercent(null)));
  235 + // 测试 productPrice 不匹配
  236 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setProductPrice(null)));
  237 + // 测试 remark 不匹配
  238 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRemark(null)));
  239 + // 测试 ownerUserId 不匹配
  240 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setOwnerUserId(null)));
  241 + // 测试 createTime 不匹配
  242 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCreateTime(null)));
  243 + // 测试 roUserIds 不匹配
  244 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRoUserIds(null)));
  245 + // 测试 rwUserIds 不匹配
  246 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRwUserIds(null)));
  247 + // 测试 endStatus 不匹配
  248 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndStatus(null)));
  249 + // 测试 endRemark 不匹配
  250 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndRemark(null)));
  251 + // 测试 contactLastTime 不匹配
  252 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactLastTime(null)));
  253 + // 测试 followUpStatus 不匹配
  254 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setFollowUpStatus(null)));
  255 + // 准备参数
  256 + CrmBusinessExportReqVO reqVO = new CrmBusinessExportReqVO();
  257 + reqVO.setName(null);
  258 + reqVO.setStatusTypeId(null);
  259 + reqVO.setStatusId(null);
  260 + reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  261 + reqVO.setCustomerId(null);
  262 + reqVO.setDealTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  263 + reqVO.setPrice(null);
  264 + reqVO.setDiscountPercent(null);
  265 + reqVO.setProductPrice(null);
  266 + reqVO.setRemark(null);
  267 + reqVO.setOwnerUserId(null);
  268 + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  269 + reqVO.setRoUserIds(null);
  270 + reqVO.setRwUserIds(null);
  271 + reqVO.setEndStatus(null);
  272 + reqVO.setEndRemark(null);
  273 + reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  274 + reqVO.setFollowUpStatus(null);
  275 +
  276 + // 调用
  277 + List<CrmBusinessDO> list = businessService.getBusinessList(reqVO);
  278 + // 断言
  279 + assertEquals(1, list.size());
  280 + assertPojoEquals(dbBusiness, list.get(0));
  281 + }
  282 +
  283 +}
... ...