Commit ad4044f9329c80975575319f397f51f03a0e72de
Merge remote-tracking branch 'yudao/develop' into develop
# Conflicts: # yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java
Showing
11 changed files
with
176 additions
and
63 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java
| @@ -38,14 +38,14 @@ public class CrmClueController { | @@ -38,14 +38,14 @@ public class CrmClueController { | ||
| 38 | @PostMapping("/create") | 38 | @PostMapping("/create") |
| 39 | @Operation(summary = "创建线索") | 39 | @Operation(summary = "创建线索") |
| 40 | @PreAuthorize("@ss.hasPermission('crm:clue:create')") | 40 | @PreAuthorize("@ss.hasPermission('crm:clue:create')") |
| 41 | - public CommonResult<Long> createClue(@Valid @RequestBody CrmClueCreateReqVO createReqVO) { | 41 | + public CommonResult<Long> createClue(@Valid @RequestBody CrmClueSaveReqVO createReqVO) { |
| 42 | return success(clueService.createClue(createReqVO)); | 42 | return success(clueService.createClue(createReqVO)); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | @PutMapping("/update") | 45 | @PutMapping("/update") |
| 46 | @Operation(summary = "更新线索") | 46 | @Operation(summary = "更新线索") |
| 47 | @PreAuthorize("@ss.hasPermission('crm:clue:update')") | 47 | @PreAuthorize("@ss.hasPermission('crm:clue:update')") |
| 48 | - public CommonResult<Boolean> updateClue(@Valid @RequestBody CrmClueUpdateReqVO updateReqVO) { | 48 | + public CommonResult<Boolean> updateClue(@Valid @RequestBody CrmClueSaveReqVO updateReqVO) { |
| 49 | clueService.updateClue(updateReqVO); | 49 | clueService.updateClue(updateReqVO); |
| 50 | return success(true); | 50 | return success(true); |
| 51 | } | 51 | } |
| @@ -96,4 +96,13 @@ public class CrmClueController { | @@ -96,4 +96,13 @@ public class CrmClueController { | ||
| 96 | return success(true); | 96 | return success(true); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | + @PostMapping("/transform") | ||
| 100 | + @Operation(summary = "线索转化为客户") | ||
| 101 | + @PreAuthorize("@ss.hasPermission('crm:clue:update')") | ||
| 102 | + // TODO @min:方法改成 translateCustomer | ||
| 103 | + public CommonResult<Boolean> translate(@Valid @RequestBody CrmClueTransformReqVO reqVO) { | ||
| 104 | + clueService.translate(reqVO, getLoginUserId()); | ||
| 105 | + return success(Boolean.TRUE); | ||
| 106 | + } | ||
| 107 | + | ||
| 99 | } | 108 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java
| @@ -3,11 +3,10 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; | @@ -3,11 +3,10 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; | ||
| 3 | import cn.iocoder.yudao.framework.common.validation.Mobile; | 3 | import cn.iocoder.yudao.framework.common.validation.Mobile; |
| 4 | import cn.iocoder.yudao.framework.common.validation.Telephone; | 4 | import cn.iocoder.yudao.framework.common.validation.Telephone; |
| 5 | import io.swagger.v3.oas.annotations.media.Schema; | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | +import jakarta.validation.constraints.NotEmpty; | ||
| 6 | import lombok.Data; | 7 | import lombok.Data; |
| 7 | import org.springframework.format.annotation.DateTimeFormat; | 8 | import org.springframework.format.annotation.DateTimeFormat; |
| 8 | 9 | ||
| 9 | -import jakarta.validation.constraints.NotEmpty; | ||
| 10 | -import jakarta.validation.constraints.NotNull; | ||
| 11 | import java.time.LocalDateTime; | 10 | import java.time.LocalDateTime; |
| 12 | 11 | ||
| 13 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | 12 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| @@ -24,7 +23,6 @@ public class CrmClueBaseVO { | @@ -24,7 +23,6 @@ public class CrmClueBaseVO { | ||
| 24 | private String name; | 23 | private String name; |
| 25 | 24 | ||
| 26 | @Schema(description = "客户 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520") | 25 | @Schema(description = "客户 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520") |
| 27 | - @NotNull(message = "客户不能为空") | ||
| 28 | private Long customerId; | 26 | private Long customerId; |
| 29 | 27 | ||
| 30 | @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") | 28 | @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") |
| @@ -46,6 +44,9 @@ public class CrmClueBaseVO { | @@ -46,6 +44,9 @@ public class CrmClueBaseVO { | ||
| 46 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 44 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 47 | private LocalDateTime contactLastTime; | 45 | private LocalDateTime contactLastTime; |
| 48 | 46 | ||
| 47 | + @Schema(description = "负责人编号") | ||
| 48 | + private Long ownerUserId; | ||
| 49 | + | ||
| 49 | @Schema(description = "备注", example = "随便") | 50 | @Schema(description = "备注", example = "随便") |
| 50 | private String remark; | 51 | private String remark; |
| 51 | 52 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | -import jakarta.validation.constraints.*; | ||
| 7 | - | ||
| 8 | -@Schema(description = "管理后台 - 线索创建 Request VO") | ||
| 9 | -@Data | ||
| 10 | -@EqualsAndHashCode(callSuper = true) | ||
| 11 | -@ToString(callSuper = true) | ||
| 12 | -public class CrmClueCreateReqVO extends CrmClueBaseVO { | ||
| 13 | - | ||
| 14 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.validation.Mobile; | ||
| 4 | +import cn.iocoder.yudao.framework.common.validation.Telephone; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import jakarta.validation.constraints.NotEmpty; | ||
| 7 | +import lombok.Data; | ||
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | + | ||
| 10 | +import java.time.LocalDateTime; | ||
| 11 | + | ||
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | + | ||
| 14 | +@Schema(description = "管理后台 - CRM 线索 创建/更新 Request VO") | ||
| 15 | +@Data | ||
| 16 | +public class CrmClueSaveReqVO { | ||
| 17 | + | ||
| 18 | + @Schema(description = "编号", example = "10969") | ||
| 19 | + private Long id; | ||
| 20 | + | ||
| 21 | + @Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx") | ||
| 22 | + @NotEmpty(message = "线索名称不能为空") | ||
| 23 | + private String name; | ||
| 24 | + | ||
| 25 | + // TODO @min:是不是不传递 customerId? | ||
| 26 | + @Schema(description = "客户 id", example = "520") | ||
| 27 | + private Long customerId; | ||
| 28 | + | ||
| 29 | + @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") | ||
| 30 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 31 | + private LocalDateTime contactNextTime; | ||
| 32 | + | ||
| 33 | + @Schema(description = "电话", example = "18000000000") | ||
| 34 | + @Telephone | ||
| 35 | + private String telephone; | ||
| 36 | + | ||
| 37 | + @Schema(description = "手机号", example = "18000000000") | ||
| 38 | + @Mobile | ||
| 39 | + private String mobile; | ||
| 40 | + | ||
| 41 | + @Schema(description = "地址", example = "北京市海淀区") | ||
| 42 | + private String address; | ||
| 43 | + | ||
| 44 | + @Schema(description = "最后跟进时间") | ||
| 45 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 46 | + private LocalDateTime contactLastTime; | ||
| 47 | + | ||
| 48 | + @Schema(description = "负责人编号", example = "2048") | ||
| 49 | + private Long ownerUserId; | ||
| 50 | + | ||
| 51 | + @Schema(description = "备注", example = "随便") | ||
| 52 | + private String remark; | ||
| 53 | + | ||
| 54 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueTransformReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotEmpty; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import java.util.Set; | ||
| 8 | + | ||
| 9 | +@Schema(description = "管理后台 - 线索转化为客户 Request VO") | ||
| 10 | +@Data | ||
| 11 | +public class CrmClueTransformReqVO { | ||
| 12 | + | ||
| 13 | + @Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024, 1025]") | ||
| 14 | + @NotEmpty(message = "线索编号不能为空") Set<Long> ids; // TODO @min:应该空行噢 | ||
| 15 | + | ||
| 16 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | -import lombok.ToString; | ||
| 7 | - | ||
| 8 | -import jakarta.validation.constraints.NotNull; | ||
| 9 | - | ||
| 10 | -@Schema(description = "管理后台 - 线索更新 Request VO") | ||
| 11 | -@Data | ||
| 12 | -@EqualsAndHashCode(callSuper = true) | ||
| 13 | -@ToString(callSuper = true) | ||
| 14 | -public class CrmClueUpdateReqVO extends CrmClueBaseVO { | ||
| 15 | - | ||
| 16 | - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969") | ||
| 17 | - @NotNull(message = "编号不能为空") | ||
| 18 | - private Long id; | ||
| 19 | - | ||
| 20 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java
| 1 | package cn.iocoder.yudao.module.crm.convert.clue; | 1 | package cn.iocoder.yudao.module.crm.convert.clue; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; | 4 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExcelVO; |
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueRespVO; | ||
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; | ||
| 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; |
| 6 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; | 9 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 7 | import org.mapstruct.Mapper; | 10 | import org.mapstruct.Mapper; |
| @@ -20,9 +23,8 @@ public interface CrmClueConvert { | @@ -20,9 +23,8 @@ public interface CrmClueConvert { | ||
| 20 | 23 | ||
| 21 | CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class); | 24 | CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class); |
| 22 | 25 | ||
| 23 | - CrmClueDO convert(CrmClueCreateReqVO bean); | ||
| 24 | - | ||
| 25 | - CrmClueDO convert(CrmClueUpdateReqVO bean); | 26 | + // TODO @min:这几个 convert,都使用 BeanUtils 替代哈 |
| 27 | + CrmClueDO convert(CrmClueSaveReqVO bean); | ||
| 26 | 28 | ||
| 27 | CrmClueRespVO convert(CrmClueDO bean); | 29 | CrmClueRespVO convert(CrmClueDO bean); |
| 28 | 30 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java
| @@ -4,6 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -4,6 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | 4 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; |
| 5 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerRespVO; | 5 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerRespVO; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO; |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; | ||
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 8 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; | 11 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 9 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | 12 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| @@ -66,4 +69,12 @@ public interface CrmCustomerConvert { | @@ -66,4 +69,12 @@ public interface CrmCustomerConvert { | ||
| 66 | return result; | 69 | return result; |
| 67 | } | 70 | } |
| 68 | 71 | ||
| 72 | + CrmCustomerPoolConfigRespVO convert(CrmCustomerPoolConfigDO customerPoolConfig); | ||
| 73 | + | ||
| 74 | + CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO); | ||
| 75 | + | ||
| 76 | + // TODO @min:使用 BeanUtils 拷贝哈。我们慢慢简单的对象,不再直接基于 convert 做啦。 | ||
| 77 | + @Mapping(ignore = true, target = "id") | ||
| 78 | + CrmCustomerSaveReqVO convert(CrmClueDO bean); | ||
| 79 | + | ||
| 69 | } | 80 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java
| 1 | package cn.iocoder.yudao.module.crm.service.clue; | 1 | package cn.iocoder.yudao.module.crm.service.clue; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO; | ||
| 5 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; | 4 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; |
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO; | ||
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; |
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO; | 7 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransformReqVO; |
| 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; |
| 9 | import jakarta.validation.Valid; | 9 | import jakarta.validation.Valid; |
| 10 | 10 | ||
| @@ -24,14 +24,14 @@ public interface CrmClueService { | @@ -24,14 +24,14 @@ public interface CrmClueService { | ||
| 24 | * @param createReqVO 创建信息 | 24 | * @param createReqVO 创建信息 |
| 25 | * @return 编号 | 25 | * @return 编号 |
| 26 | */ | 26 | */ |
| 27 | - Long createClue(@Valid CrmClueCreateReqVO createReqVO); | 27 | + Long createClue(@Valid CrmClueSaveReqVO createReqVO); |
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| 30 | * 更新线索 | 30 | * 更新线索 |
| 31 | * | 31 | * |
| 32 | * @param updateReqVO 更新信息 | 32 | * @param updateReqVO 更新信息 |
| 33 | */ | 33 | */ |
| 34 | - void updateClue(@Valid CrmClueUpdateReqVO updateReqVO); | 34 | + void updateClue(@Valid CrmClueSaveReqVO updateReqVO); |
| 35 | 35 | ||
| 36 | /** | 36 | /** |
| 37 | * 删除线索 | 37 | * 删除线索 |
| @@ -73,4 +73,12 @@ public interface CrmClueService { | @@ -73,4 +73,12 @@ public interface CrmClueService { | ||
| 73 | */ | 73 | */ |
| 74 | void transferClue(CrmClueTransferReqVO reqVO, Long userId); | 74 | void transferClue(CrmClueTransferReqVO reqVO, Long userId); |
| 75 | 75 | ||
| 76 | + /** | ||
| 77 | + * 线索转化为客户 | ||
| 78 | + * | ||
| 79 | + * @param reqVO 线索编号 | ||
| 80 | + * @param userId 用户编号 | ||
| 81 | + */ | ||
| 82 | + void translate(CrmClueTransformReqVO reqVO, Long userId); | ||
| 83 | + | ||
| 76 | } | 84 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java
| @@ -3,11 +3,12 @@ package cn.iocoder.yudao.module.crm.service.clue; | @@ -3,11 +3,12 @@ package cn.iocoder.yudao.module.crm.service.clue; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.collection.ListUtil; | 4 | import cn.hutool.core.collection.ListUtil; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO; | ||
| 7 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO; | ||
| 8 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; | 8 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO; |
| 9 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO; | 9 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransformReqVO; |
| 10 | import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; | 10 | import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; |
| 11 | +import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; | ||
| 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; | 12 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; |
| 12 | import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; | 13 | import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; |
| 13 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | 14 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| @@ -15,15 +16,20 @@ import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | @@ -15,15 +16,20 @@ import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | ||
| 15 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; | 16 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; |
| 16 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | 17 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| 17 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | 18 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 19 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||
| 18 | import jakarta.annotation.Resource; | 20 | import jakarta.annotation.Resource; |
| 19 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
| 22 | +import org.springframework.transaction.annotation.Transactional; | ||
| 20 | import org.springframework.validation.annotation.Validated; | 23 | import org.springframework.validation.annotation.Validated; |
| 21 | 24 | ||
| 22 | import java.util.Collection; | 25 | import java.util.Collection; |
| 23 | import java.util.List; | 26 | import java.util.List; |
| 27 | +import java.util.Objects; | ||
| 24 | 28 | ||
| 25 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 26 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS; | 30 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS; |
| 31 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; | ||
| 32 | +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; | ||
| 27 | 33 | ||
| 28 | /** | 34 | /** |
| 29 | * 线索 Service 实现类 | 35 | * 线索 Service 实现类 |
| @@ -39,13 +45,19 @@ public class CrmClueServiceImpl implements CrmClueService { | @@ -39,13 +45,19 @@ public class CrmClueServiceImpl implements CrmClueService { | ||
| 39 | 45 | ||
| 40 | @Resource | 46 | @Resource |
| 41 | private CrmCustomerService customerService; | 47 | private CrmCustomerService customerService; |
| 48 | + | ||
| 42 | @Resource | 49 | @Resource |
| 43 | private CrmPermissionService crmPermissionService; | 50 | private CrmPermissionService crmPermissionService; |
| 44 | 51 | ||
| 52 | + @Resource | ||
| 53 | + private AdminUserApi adminUserApi; | ||
| 54 | + | ||
| 45 | @Override | 55 | @Override |
| 46 | - public Long createClue(CrmClueCreateReqVO createReqVO) { | ||
| 47 | - // 校验客户是否存在 | ||
| 48 | - customerService.validateCustomer(createReqVO.getCustomerId()); | 56 | + // TODO @min:补充相关几个方法的操作日志; |
| 57 | + public Long createClue(CrmClueSaveReqVO createReqVO) { | ||
| 58 | + // 校验关联数据 | ||
| 59 | + validateRelationDataExists(createReqVO); | ||
| 60 | + | ||
| 49 | // 插入 | 61 | // 插入 |
| 50 | CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO); | 62 | CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO); |
| 51 | clueMapper.insert(clue); | 63 | clueMapper.insert(clue); |
| @@ -55,11 +67,11 @@ public class CrmClueServiceImpl implements CrmClueService { | @@ -55,11 +67,11 @@ public class CrmClueServiceImpl implements CrmClueService { | ||
| 55 | 67 | ||
| 56 | @Override | 68 | @Override |
| 57 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_LEADS, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) | 69 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_LEADS, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) |
| 58 | - public void updateClue(CrmClueUpdateReqVO updateReqVO) { | ||
| 59 | - // 校验存在 | 70 | + public void updateClue(CrmClueSaveReqVO updateReqVO) { |
| 71 | + // 校验线索是否存在 | ||
| 60 | validateClueExists(updateReqVO.getId()); | 72 | validateClueExists(updateReqVO.getId()); |
| 61 | - // 校验客户是否存在 | ||
| 62 | - customerService.validateCustomer(updateReqVO.getCustomerId()); | 73 | + // 校验关联数据 |
| 74 | + validateRelationDataExists(updateReqVO); | ||
| 63 | 75 | ||
| 64 | // 更新 | 76 | // 更新 |
| 65 | CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO); | 77 | CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO); |
| @@ -108,12 +120,47 @@ public class CrmClueServiceImpl implements CrmClueService { | @@ -108,12 +120,47 @@ public class CrmClueServiceImpl implements CrmClueService { | ||
| 108 | validateClueExists(reqVO.getId()); | 120 | validateClueExists(reqVO.getId()); |
| 109 | 121 | ||
| 110 | // 2.1 数据权限转移 | 122 | // 2.1 数据权限转移 |
| 111 | - crmPermissionService.transferPermission( | ||
| 112 | - CrmClueConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_LEADS.getType())); | 123 | + crmPermissionService.transferPermission(CrmClueConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_LEADS.getType())); |
| 113 | // 2.2 设置新的负责人 | 124 | // 2.2 设置新的负责人 |
| 114 | clueMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); | 125 | clueMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); |
| 115 | 126 | ||
| 116 | // 3. TODO 记录转移日志 | 127 | // 3. TODO 记录转移日志 |
| 117 | } | 128 | } |
| 118 | 129 | ||
| 130 | + @Override | ||
| 131 | + @Transactional(rollbackFor = Exception.class) | ||
| 132 | + public void translate(CrmClueTransformReqVO reqVO, Long userId) { | ||
| 133 | + // 校验线索都存在 | ||
| 134 | + List<CrmClueDO> clues = getClueList(reqVO.getIds(), userId); | ||
| 135 | + if (CollUtil.isEmpty(clues)) { | ||
| 136 | + throw exception(CLUE_NOT_EXISTS); | ||
| 137 | + } | ||
| 138 | + // TODO @min:如果已经转化,则不能重复转化 | ||
| 139 | + | ||
| 140 | + // 遍历线索,创建对应的客户 | ||
| 141 | + clues.forEach(clue -> { | ||
| 142 | + // 创建客户 | ||
| 143 | + customerService.createCustomer(CrmCustomerConvert.INSTANCE.convert(clue), userId); | ||
| 144 | + // 更新线索状态 | ||
| 145 | + // TODO @min:新建一个 CrmClueDO 去更新。尽量规避直接用原本的对象去更新。因为这样万一并发更新,会存在覆盖的问题。 | ||
| 146 | + // TODO @puhui999:如果有跟进记录,需要一起转过去; | ||
| 147 | + clue.setTransformStatus(Boolean.TRUE); | ||
| 148 | + clueMapper.updateById(clue); | ||
| 149 | + }); | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + private void validateRelationDataExists(CrmClueSaveReqVO reqVO) { | ||
| 153 | + // 校验客户 | ||
| 154 | + if (Objects.nonNull(reqVO.getCustomerId()) && | ||
| 155 | + Objects.isNull(customerService.getCustomer(reqVO.getCustomerId()))) { | ||
| 156 | + throw exception(CUSTOMER_NOT_EXISTS); | ||
| 157 | + } | ||
| 158 | + // 校验负责人 | ||
| 159 | + // 2. 校验负责人 | ||
| 160 | + if (Objects.nonNull(reqVO.getOwnerUserId()) && | ||
| 161 | + Objects.isNull(adminUserApi.getUser(reqVO.getOwnerUserId()))) { | ||
| 162 | + throw exception(USER_NOT_EXISTS); | ||
| 163 | + } | ||
| 164 | + } | ||
| 165 | + | ||
| 119 | } | 166 | } |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java
| @@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.crm.service.clue; | @@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.crm.service.clue; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO; | ||
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; | 5 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; |
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO; | 6 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO; |
| 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; |
| 9 | import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; | 8 | import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; |
| 10 | import jakarta.annotation.Resource; | 9 | import jakarta.annotation.Resource; |
| @@ -43,7 +42,7 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { | @@ -43,7 +42,7 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { | ||
| 43 | @Test | 42 | @Test |
| 44 | public void testCreateClue_success() { | 43 | public void testCreateClue_success() { |
| 45 | // 准备参数 | 44 | // 准备参数 |
| 46 | - CrmClueCreateReqVO reqVO = randomPojo(CrmClueCreateReqVO.class); | 45 | + CrmClueSaveReqVO reqVO = randomPojo(CrmClueSaveReqVO.class); |
| 47 | 46 | ||
| 48 | // 调用 | 47 | // 调用 |
| 49 | Long clueId = clueService.createClue(reqVO); | 48 | Long clueId = clueService.createClue(reqVO); |
| @@ -60,7 +59,7 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { | @@ -60,7 +59,7 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { | ||
| 60 | CrmClueDO dbClue = randomPojo(CrmClueDO.class); | 59 | CrmClueDO dbClue = randomPojo(CrmClueDO.class); |
| 61 | clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据 | 60 | clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据 |
| 62 | // 准备参数 | 61 | // 准备参数 |
| 63 | - CrmClueUpdateReqVO reqVO = randomPojo(CrmClueUpdateReqVO.class, o -> { | 62 | + CrmClueSaveReqVO reqVO = randomPojo(CrmClueSaveReqVO.class, o -> { |
| 64 | o.setId(dbClue.getId()); // 设置更新的 ID | 63 | o.setId(dbClue.getId()); // 设置更新的 ID |
| 65 | }); | 64 | }); |
| 66 | 65 | ||
| @@ -74,7 +73,7 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { | @@ -74,7 +73,7 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { | ||
| 74 | @Test | 73 | @Test |
| 75 | public void testUpdateClue_notExists() { | 74 | public void testUpdateClue_notExists() { |
| 76 | // 准备参数 | 75 | // 准备参数 |
| 77 | - CrmClueUpdateReqVO reqVO = randomPojo(CrmClueUpdateReqVO.class); | 76 | + CrmClueSaveReqVO reqVO = randomPojo(CrmClueSaveReqVO.class); |
| 78 | 77 | ||
| 79 | // 调用, 并断言异常 | 78 | // 调用, 并断言异常 |
| 80 | assertServiceException(() -> clueService.updateClue(reqVO), CLUE_NOT_EXISTS); | 79 | assertServiceException(() -> clueService.updateClue(reqVO), CLUE_NOT_EXISTS); |