Commit 6a934842608ed6142d0e69333addf2bf3a42b002
1 parent
e4936725
📖 CRM:code review 线索模块
Showing
7 changed files
with
32 additions
and
26 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java
| ... | ... | @@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 6 | 6 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 7 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; |
| 8 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; | |
| 9 | 8 | import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; |
| 10 | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; |
| 11 | 10 | import cn.iocoder.yudao.module.crm.service.clue.CrmClueService; |
| ... | ... | @@ -100,6 +99,7 @@ public class CrmClueController { |
| 100 | 99 | @PostMapping("/transform") |
| 101 | 100 | @Operation(summary = "线索转化为客户") |
| 102 | 101 | @PreAuthorize("@ss.hasPermission('crm:clue:update')") |
| 102 | + // TODO @min:方法改成 translateCustomer | |
| 103 | 103 | public CommonResult<Boolean> translate(@Valid @RequestBody CrmClueTransformReqVO reqVO) { |
| 104 | 104 | clueService.translate(reqVO, getLoginUserId()); |
| 105 | 105 | return success(Boolean.TRUE); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueSaveReqVO.java
| ... | ... | @@ -4,31 +4,26 @@ import cn.iocoder.yudao.framework.common.validation.Mobile; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.validation.Telephone; |
| 5 | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 6 | import jakarta.validation.constraints.NotEmpty; |
| 7 | -import jakarta.validation.constraints.NotNull; | |
| 8 | 7 | import lombok.Data; |
| 9 | -import lombok.EqualsAndHashCode; | |
| 10 | -import lombok.ToString; | |
| 11 | 8 | import org.springframework.format.annotation.DateTimeFormat; |
| 12 | 9 | |
| 13 | 10 | import java.time.LocalDateTime; |
| 14 | 11 | |
| 15 | 12 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 16 | 13 | |
| 17 | -/** | |
| 18 | - * @author minhx | |
| 19 | - */ | |
| 20 | 14 | @Schema(description = "管理后台 - CRM 线索 创建/更新 Request VO") |
| 21 | 15 | @Data |
| 22 | 16 | public class CrmClueSaveReqVO { |
| 23 | 17 | |
| 24 | - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969") | |
| 18 | + @Schema(description = "编号", example = "10969") | |
| 25 | 19 | private Long id; |
| 26 | 20 | |
| 27 | 21 | @Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx") |
| 28 | 22 | @NotEmpty(message = "线索名称不能为空") |
| 29 | 23 | private String name; |
| 30 | 24 | |
| 31 | - @Schema(description = "客户 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520") | |
| 25 | + // TODO @min:是不是不传递 customerId? | |
| 26 | + @Schema(description = "客户 id", example = "520") | |
| 32 | 27 | private Long customerId; |
| 33 | 28 | |
| 34 | 29 | @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") |
| ... | ... | @@ -50,9 +45,10 @@ public class CrmClueSaveReqVO { |
| 50 | 45 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 51 | 46 | private LocalDateTime contactLastTime; |
| 52 | 47 | |
| 53 | - @Schema(description = "负责人编号") | |
| 48 | + @Schema(description = "负责人编号", example = "2048") | |
| 54 | 49 | private Long ownerUserId; |
| 55 | 50 | |
| 56 | 51 | @Schema(description = "备注", example = "随便") |
| 57 | 52 | private String remark; |
| 53 | + | |
| 58 | 54 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueTransformReqVO.java
| ... | ... | @@ -6,14 +6,11 @@ import lombok.Data; |
| 6 | 6 | |
| 7 | 7 | import java.util.Set; |
| 8 | 8 | |
| 9 | -/** | |
| 10 | - * @author min | |
| 11 | - */ | |
| 12 | 9 | @Schema(description = "管理后台 - 线索转化为客户 Request VO") |
| 13 | 10 | @Data |
| 14 | 11 | public class CrmClueTransformReqVO { |
| 15 | 12 | |
| 16 | 13 | @Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024, 1025]") |
| 17 | - @NotEmpty(message = "线索编号不能为空") Set<Long> ids; | |
| 14 | + @NotEmpty(message = "线索编号不能为空") Set<Long> ids; // TODO @min:应该空行噢 | |
| 18 | 15 | |
| 19 | 16 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.convert.clue; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; | |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; | |
| 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; | |
| 6 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; |
| 7 | 9 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 8 | 10 | import org.mapstruct.Mapper; |
| ... | ... | @@ -21,6 +23,7 @@ public interface CrmClueConvert { |
| 21 | 23 | |
| 22 | 24 | CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class); |
| 23 | 25 | |
| 26 | + // TODO @min:这几个 convert,都使用 BeanUtils 替代哈 | |
| 24 | 27 | CrmClueDO convert(CrmClueSaveReqVO bean); |
| 25 | 28 | |
| 26 | 29 | CrmClueRespVO convert(CrmClueDO bean); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java
| ... | ... | @@ -78,6 +78,8 @@ public interface CrmCustomerConvert { |
| 78 | 78 | |
| 79 | 79 | CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO); |
| 80 | 80 | |
| 81 | + // TODO @min:使用 BeanUtils 拷贝哈。我们慢慢简单的对象,不再直接基于 convert 做啦。 | |
| 81 | 82 | @Mapping(ignore = true, target = "id") |
| 82 | 83 | CrmCustomerSaveReqVO convert(CrmClueDO bean); |
| 84 | + | |
| 83 | 85 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.service.clue; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; | |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; | |
| 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; | |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransformReqVO; | |
| 6 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; |
| 7 | 9 | import jakarta.validation.Valid; |
| 8 | 10 | |
| ... | ... | @@ -78,4 +80,5 @@ public interface CrmClueService { |
| 78 | 80 | * @param userId 用户编号 |
| 79 | 81 | */ |
| 80 | 82 | void translate(CrmClueTransformReqVO reqVO, Long userId); |
| 83 | + | |
| 81 | 84 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java
| ... | ... | @@ -3,8 +3,10 @@ package cn.iocoder.yudao.module.crm.service.clue; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.collection.ListUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; | |
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO; | |
| 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; | |
| 9 | +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransformReqVO; | |
| 8 | 10 | import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; |
| 9 | 11 | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; |
| 10 | 12 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; |
| ... | ... | @@ -51,6 +53,7 @@ public class CrmClueServiceImpl implements CrmClueService { |
| 51 | 53 | private AdminUserApi adminUserApi; |
| 52 | 54 | |
| 53 | 55 | @Override |
| 56 | + // TODO @min:补充相关几个方法的操作日志; | |
| 54 | 57 | public Long createClue(CrmClueSaveReqVO createReqVO) { |
| 55 | 58 | // 校验关联数据 |
| 56 | 59 | validateRelationDataExists(createReqVO); |
| ... | ... | @@ -58,7 +61,6 @@ public class CrmClueServiceImpl implements CrmClueService { |
| 58 | 61 | // 插入 |
| 59 | 62 | CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO); |
| 60 | 63 | clueMapper.insert(clue); |
| 61 | - System.out.println(1); | |
| 62 | 64 | // 返回 |
| 63 | 65 | return clue.getId(); |
| 64 | 66 | } |
| ... | ... | @@ -128,18 +130,20 @@ public class CrmClueServiceImpl implements CrmClueService { |
| 128 | 130 | @Override |
| 129 | 131 | @Transactional(rollbackFor = Exception.class) |
| 130 | 132 | public void translate(CrmClueTransformReqVO reqVO, Long userId) { |
| 133 | + // 校验线索都存在 | |
| 131 | 134 | List<CrmClueDO> clues = getClueList(reqVO.getIds(), userId); |
| 132 | - // 不存在抛出异常 | |
| 133 | 135 | if (CollUtil.isEmpty(clues)) { |
| 134 | 136 | throw exception(CLUE_NOT_EXISTS); |
| 135 | 137 | } |
| 138 | + | |
| 136 | 139 | // 遍历线索,创建对应的客户 |
| 137 | - clues.forEach(clueDO -> { | |
| 140 | + clues.forEach(clue -> { | |
| 138 | 141 | // 创建客户 |
| 139 | - customerService.createCustomer(CrmCustomerConvert.INSTANCE.convert(clueDO), userId); | |
| 142 | + customerService.createCustomer(CrmCustomerConvert.INSTANCE.convert(clue), userId); | |
| 140 | 143 | // 更新线索状态 |
| 141 | - clueDO.setTransformStatus(Boolean.TRUE); | |
| 142 | - clueMapper.updateById(clueDO); | |
| 144 | + // TODO @min:新建一个 CrmClueDO 去更新。尽量规避直接用原本的对象去更新。因为这样万一并发更新,会存在覆盖的问题。 | |
| 145 | + clue.setTransformStatus(Boolean.TRUE); | |
| 146 | + clueMapper.updateById(clue); | |
| 143 | 147 | }); |
| 144 | 148 | } |
| 145 | 149 | |
| ... | ... | @@ -156,4 +160,5 @@ public class CrmClueServiceImpl implements CrmClueService { |
| 156 | 160 | throw exception(USER_NOT_EXISTS); |
| 157 | 161 | } |
| 158 | 162 | } |
| 163 | + | |
| 159 | 164 | } | ... | ... |