Commit 2d1e57554dda75a62d091f3e6c423be3ca8e4779
1 parent
3c7f63c3
📖 CRM:code review CRM 客户逻辑
Showing
17 changed files
with
62 additions
and
104 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java
| @@ -122,6 +122,7 @@ public class LocalDateTimeUtils { | @@ -122,6 +122,7 @@ public class LocalDateTimeUtils { | ||
| 122 | return date.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX); | 122 | return date.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX); |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | + // TODO @puhui999:加下注释哈; | ||
| 125 | public static Long between(LocalDateTime dateTime) { | 126 | public static Long between(LocalDateTime dateTime) { |
| 126 | return LocalDateTimeUtil.between(dateTime, LocalDateTime.now(), ChronoUnit.DAYS); | 127 | return LocalDateTimeUtil.between(dateTime, LocalDateTime.now(), ChronoUnit.DAYS); |
| 127 | } | 128 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java
| @@ -46,7 +46,7 @@ import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | @@ -46,7 +46,7 @@ import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | ||
| 46 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | 46 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 47 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | 47 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 48 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | 48 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 49 | -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CONTACT; | 49 | +import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CONTACT_TYPE; |
| 50 | 50 | ||
| 51 | @Tag(name = "管理后台 - CRM 联系人") | 51 | @Tag(name = "管理后台 - CRM 联系人") |
| 52 | @RestController | 52 | @RestController |
| @@ -156,7 +156,7 @@ public class CrmContactController { | @@ -156,7 +156,7 @@ public class CrmContactController { | ||
| 156 | public CommonResult<PageResult<OperateLogV2RespDTO>> getCustomerOperateLog(@RequestParam("bizId")Long bizId) { | 156 | public CommonResult<PageResult<OperateLogV2RespDTO>> getCustomerOperateLog(@RequestParam("bizId")Long bizId) { |
| 157 | OperateLogV2PageReqDTO reqVO = new OperateLogV2PageReqDTO(); | 157 | OperateLogV2PageReqDTO reqVO = new OperateLogV2PageReqDTO(); |
| 158 | reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 | 158 | reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 |
| 159 | - reqVO.setBizType(CRM_CONTACT); | 159 | + reqVO.setBizType(CRM_CONTACT_TYPE); |
| 160 | reqVO.setBizId(bizId); | 160 | reqVO.setBizId(bizId); |
| 161 | return success(operateLogApi.getOperateLogPage(BeanUtils.toBean(reqVO, OperateLogV2PageReqDTO.class))); | 161 | return success(operateLogApi.getOperateLogPage(BeanUtils.toBean(reqVO, OperateLogV2PageReqDTO.class))); |
| 162 | } | 162 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| @@ -112,37 +112,42 @@ public class CrmCustomerController { | @@ -112,37 +112,42 @@ public class CrmCustomerController { | ||
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | // 2. 拼接数据 | 114 | // 2. 拼接数据 |
| 115 | - // 距离进入公海的时间 | ||
| 116 | - Map<Long, Long> poolDayMap = getPoolDayMap(pageResult); | 115 | + Map<Long, Long> poolDayMap = getPoolDayMap(pageResult); // 距离进入公海的时间 |
| 117 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | 116 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 118 | convertSetByFlatMap(pageResult.getList(), user -> Stream.of(Long.parseLong(user.getCreator()), user.getOwnerUserId()))); | 117 | convertSetByFlatMap(pageResult.getList(), user -> Stream.of(Long.parseLong(user.getCreator()), user.getOwnerUserId()))); |
| 119 | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); | 118 | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); |
| 120 | return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap)); | 119 | return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap)); |
| 121 | } | 120 | } |
| 122 | 121 | ||
| 122 | + // TODO @puhui999:加下注释哈; | ||
| 123 | private Map<Long, Long> getPoolDayMap(PageResult<CrmCustomerDO> pageResult) { | 123 | private Map<Long, Long> getPoolDayMap(PageResult<CrmCustomerDO> pageResult) { |
| 124 | Map<Long, Long> poolDayMap = null; | 124 | Map<Long, Long> poolDayMap = null; |
| 125 | CrmCustomerPoolConfigDO customerPoolConfig = customerPoolConfigService.getCustomerPoolConfig(); | 125 | CrmCustomerPoolConfigDO customerPoolConfig = customerPoolConfigService.getCustomerPoolConfig(); |
| 126 | + // TODO @puhui999:if return 减少括号 | ||
| 126 | if (customerPoolConfig != null && customerPoolConfig.getEnabled()) { // 有公海配置的情况 | 127 | if (customerPoolConfig != null && customerPoolConfig.getEnabled()) { // 有公海配置的情况 |
| 128 | + // TODO @puhui999:item 改成 customer 更好,容易理解; | ||
| 127 | poolDayMap = convertMap(pageResult.getList(), CrmCustomerDO::getId, item -> { | 129 | poolDayMap = convertMap(pageResult.getList(), CrmCustomerDO::getId, item -> { |
| 128 | long dealExpireDay = 0; | 130 | long dealExpireDay = 0; |
| 129 | if (!item.getDealStatus()) { // 检查是否成交 | 131 | if (!item.getDealStatus()) { // 检查是否成交 |
| 130 | dealExpireDay = customerPoolConfig.getDealExpireDays() - LocalDateTimeUtils.between(item.getCreateTime()); | 132 | dealExpireDay = customerPoolConfig.getDealExpireDays() - LocalDateTimeUtils.between(item.getCreateTime()); |
| 131 | } | 133 | } |
| 134 | + // TODO @puhui999:需要考虑 contactLastTime 为空的情况哈; | ||
| 132 | long contactExpireDay = customerPoolConfig.getContactExpireDays() - LocalDateTimeUtils.between(item.getContactLastTime()); | 135 | long contactExpireDay = customerPoolConfig.getContactExpireDays() - LocalDateTimeUtils.between(item.getContactLastTime()); |
| 133 | return dealExpireDay == 0 ? contactExpireDay : Math.min(dealExpireDay, contactExpireDay); | 136 | return dealExpireDay == 0 ? contactExpireDay : Math.min(dealExpireDay, contactExpireDay); |
| 134 | }); | 137 | }); |
| 138 | + // TODO @puhui999:需要考虑 lock 的情况么? | ||
| 135 | } | 139 | } |
| 136 | return poolDayMap; | 140 | return poolDayMap; |
| 137 | } | 141 | } |
| 138 | 142 | ||
| 139 | @GetMapping(value = "/list-all-simple") | 143 | @GetMapping(value = "/list-all-simple") |
| 140 | @Operation(summary = "获取客户精简信息列表", description = "只包含有读权限的客户,主要用于前端的下拉选项") | 144 | @Operation(summary = "获取客户精简信息列表", description = "只包含有读权限的客户,主要用于前端的下拉选项") |
| 141 | - public CommonResult<List<CrmCustomerSimpleRespVO>> getSimpleDeptList() { | 145 | + public CommonResult<List<CrmCustomerRespVO>> getSimpleDeptList() { |
| 142 | CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); | 146 | CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); |
| 143 | reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 | 147 | reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 |
| 144 | List<CrmCustomerDO> list = customerService.getCustomerPage(reqVO, getLoginUserId()).getList(); | 148 | List<CrmCustomerDO> list = customerService.getCustomerPage(reqVO, getLoginUserId()).getList(); |
| 145 | - return success(BeanUtils.toBean(list, CrmCustomerSimpleRespVO.class)); | 149 | + return success(convertList(list, customer -> // 只返回 id、name 精简字段 |
| 150 | + new CrmCustomerRespVO().setId(customer.getId()).setName(customer.getName()))); | ||
| 146 | } | 151 | } |
| 147 | 152 | ||
| 148 | @GetMapping("/export-excel") | 153 | @GetMapping("/export-excel") |
| @@ -154,8 +159,8 @@ public class CrmCustomerController { | @@ -154,8 +159,8 @@ public class CrmCustomerController { | ||
| 154 | pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页 | 159 | pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页 |
| 155 | List<CrmCustomerDO> list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList(); | 160 | List<CrmCustomerDO> list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList(); |
| 156 | // 导出 Excel | 161 | // 导出 Excel |
| 157 | - List<CrmCustomerRespVO> datas = CrmCustomerConvert.INSTANCE.convertList02(list); | ||
| 158 | - ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerRespVO.class, datas); | 162 | + ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerRespVO.class, |
| 163 | + BeanUtils.toBean(list, CrmCustomerRespVO.class)); | ||
| 159 | } | 164 | } |
| 160 | 165 | ||
| 161 | @PutMapping("/transfer") | 166 | @PutMapping("/transfer") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerDistributeReqVO.java
| @@ -11,7 +11,7 @@ import java.util.List; | @@ -11,7 +11,7 @@ import java.util.List; | ||
| 11 | public class CrmCustomerDistributeReqVO { | 11 | public class CrmCustomerDistributeReqVO { |
| 12 | 12 | ||
| 13 | @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024]") | 13 | @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024]") |
| 14 | - @NotNull(message = "客户编号不能为空") | 14 | + @NotNull(message = "客户编号不能为空") // TODO @puhui999:list 是 @NotEmpty |
| 15 | private List<Long> ids; | 15 | private List<Long> ids; |
| 16 | 16 | ||
| 17 | @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 17 | @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerSimpleRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.AllArgsConstructor; | ||
| 5 | -import lombok.Data; | ||
| 6 | -import lombok.NoArgsConstructor; | ||
| 7 | - | ||
| 8 | -@Schema(description = "管理后台 - 客户精简信息 Response VO") | ||
| 9 | -@Data | ||
| 10 | -@NoArgsConstructor | ||
| 11 | -@AllArgsConstructor | ||
| 12 | -public class CrmCustomerSimpleRespVO { | ||
| 13 | - | ||
| 14 | - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 15 | - private Long id; | ||
| 16 | - | ||
| 17 | - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") | ||
| 18 | - private String name; | ||
| 19 | - | ||
| 20 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java
| @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; | ||
| 3 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | 3 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| 4 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 4 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 5 | import io.swagger.v3.oas.annotations.media.Schema; | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | -import jakarta.validation.constraints.NotNull; | ||
| 7 | import lombok.Data; | 6 | import lombok.Data; |
| 8 | 7 | ||
| 9 | import java.time.LocalDateTime; | 8 | import java.time.LocalDateTime; |
| @@ -17,7 +16,6 @@ public class CrmCustomerLimitConfigRespVO { | @@ -17,7 +16,6 @@ public class CrmCustomerLimitConfigRespVO { | ||
| 17 | private Long id; | 16 | private Long id; |
| 18 | 17 | ||
| 19 | @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | 18 | @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 20 | - @NotNull(message = "规则类型不能为空") | ||
| 21 | private Integer type; | 19 | private Integer type; |
| 22 | 20 | ||
| 23 | @Schema(description = "规则适用人群") | 21 | @Schema(description = "规则适用人群") |
| @@ -27,10 +25,9 @@ public class CrmCustomerLimitConfigRespVO { | @@ -27,10 +25,9 @@ public class CrmCustomerLimitConfigRespVO { | ||
| 27 | private List<Long> deptIds; | 25 | private List<Long> deptIds; |
| 28 | 26 | ||
| 29 | @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") | 27 | @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") |
| 30 | - @NotNull(message = "数量上限不能为空") | ||
| 31 | private Integer maxCount; | 28 | private Integer maxCount; |
| 32 | 29 | ||
| 33 | - @Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)") | 30 | + @Schema(description = "成交客户是否占有拥有客户数") |
| 34 | private Boolean dealCountEnabled; | 31 | private Boolean dealCountEnabled; |
| 35 | 32 | ||
| 36 | @Schema(description = "规则适用人群名称") | 33 | @Schema(description = "规则适用人群名称") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java
| @@ -15,10 +15,11 @@ public class CrmCustomerLimitConfigSaveReqVO { | @@ -15,10 +15,11 @@ public class CrmCustomerLimitConfigSaveReqVO { | ||
| 15 | private Long id; | 15 | private Long id; |
| 16 | 16 | ||
| 17 | @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | 17 | @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 18 | - @DiffLogField(name = "规则类型") | ||
| 19 | @NotNull(message = "规则类型不能为空") | 18 | @NotNull(message = "规则类型不能为空") |
| 19 | + @DiffLogField(name = "规则类型") | ||
| 20 | private Integer type; | 20 | private Integer type; |
| 21 | 21 | ||
| 22 | + // TODO @puhui999:可以把 Function 那的 functionName 搞成 NAME 枚举,这里直接引用。这样后续改动更方便哈。 | ||
| 22 | @Schema(description = "规则适用人群") | 23 | @Schema(description = "规则适用人群") |
| 23 | @DiffLogField(name = "规则适用人群", function = "getAdminUserById") | 24 | @DiffLogField(name = "规则适用人群", function = "getAdminUserById") |
| 24 | private List<Long> userIds; | 25 | private List<Long> userIds; |
| @@ -28,8 +29,8 @@ public class CrmCustomerLimitConfigSaveReqVO { | @@ -28,8 +29,8 @@ public class CrmCustomerLimitConfigSaveReqVO { | ||
| 28 | private List<Long> deptIds; | 29 | private List<Long> deptIds; |
| 29 | 30 | ||
| 30 | @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") | 31 | @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") |
| 31 | - @DiffLogField(name = "数量上限") | ||
| 32 | @NotNull(message = "数量上限不能为空") | 32 | @NotNull(message = "数量上限不能为空") |
| 33 | + @DiffLogField(name = "数量上限") | ||
| 33 | private Integer maxCount; | 34 | private Integer maxCount; |
| 34 | 35 | ||
| 35 | @Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)") | 36 | @Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java
| @@ -16,7 +16,6 @@ import org.mapstruct.Mapper; | @@ -16,7 +16,6 @@ import org.mapstruct.Mapper; | ||
| 16 | import org.mapstruct.Mapping; | 16 | import org.mapstruct.Mapping; |
| 17 | import org.mapstruct.factory.Mappers; | 17 | import org.mapstruct.factory.Mappers; |
| 18 | 18 | ||
| 19 | -import java.util.List; | ||
| 20 | import java.util.Map; | 19 | import java.util.Map; |
| 21 | 20 | ||
| 22 | import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | 21 | import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; |
| @@ -31,6 +30,7 @@ public interface CrmCustomerConvert { | @@ -31,6 +30,7 @@ public interface CrmCustomerConvert { | ||
| 31 | 30 | ||
| 32 | CrmCustomerConvert INSTANCE = Mappers.getMapper(CrmCustomerConvert.class); | 31 | CrmCustomerConvert INSTANCE = Mappers.getMapper(CrmCustomerConvert.class); |
| 33 | 32 | ||
| 33 | + // TODO @puhui999:可以清理掉可以用 BeanUtil 替代的方法哈 | ||
| 34 | CrmCustomerDO convert(CrmCustomerSaveReqVO bean); | 34 | CrmCustomerDO convert(CrmCustomerSaveReqVO bean); |
| 35 | 35 | ||
| 36 | CrmCustomerRespVO convert(CrmCustomerDO bean); | 36 | CrmCustomerRespVO convert(CrmCustomerDO bean); |
| @@ -51,8 +51,6 @@ public interface CrmCustomerConvert { | @@ -51,8 +51,6 @@ public interface CrmCustomerConvert { | ||
| 51 | findAndThen(userMap, Long.parseLong(customer.getCreator()), user -> customer.setCreatorName(user.getNickname())); | 51 | findAndThen(userMap, Long.parseLong(customer.getCreator()), user -> customer.setCreatorName(user.getNickname())); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | - List<CrmCustomerRespVO> convertList02(List<CrmCustomerDO> list); | ||
| 55 | - | ||
| 56 | @Mapping(target = "bizId", source = "reqVO.id") | 54 | @Mapping(target = "bizId", source = "reqVO.id") |
| 57 | CrmPermissionTransferReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId); | 55 | CrmPermissionTransferReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId); |
| 58 | 56 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerLimitConfigConvert.java
| @@ -23,6 +23,7 @@ public interface CrmCustomerLimitConfigConvert { | @@ -23,6 +23,7 @@ public interface CrmCustomerLimitConfigConvert { | ||
| 23 | 23 | ||
| 24 | CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class); | 24 | CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class); |
| 25 | 25 | ||
| 26 | + // TODO @puhui999:可以把 convert 改成 BeanUtils | ||
| 26 | CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigSaveReqVO bean); | 27 | CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigSaveReqVO bean); |
| 27 | 28 | ||
| 28 | CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO bean); | 29 | CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO bean); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java
| @@ -48,9 +48,7 @@ public interface CrmPermissionConvert { | @@ -48,9 +48,7 @@ public interface CrmPermissionConvert { | ||
| 48 | return CollectionUtils.convertList(convert(permission), item -> { | 48 | return CollectionUtils.convertList(convert(permission), item -> { |
| 49 | findAndThen(userMap, item.getUserId(), user -> { | 49 | findAndThen(userMap, item.getUserId(), user -> { |
| 50 | item.setNickname(user.getNickname()); | 50 | item.setNickname(user.getNickname()); |
| 51 | - findAndThen(deptMap, user.getDeptId(), deptRespDTO -> { | ||
| 52 | - item.setDeptName(deptRespDTO.getName()); | ||
| 53 | - }); | 51 | + findAndThen(deptMap, user.getDeptId(), deptRespDTO -> item.setDeptName(deptRespDTO.getName())); |
| 54 | List<PostRespDTO> postRespList = MapUtils.getList(Multimaps.forMap(postMap), user.getPostIds()); | 52 | List<PostRespDTO> postRespList = MapUtils.getList(Multimaps.forMap(postMap), user.getPostIds()); |
| 55 | if (CollUtil.isEmpty(postRespList)) { | 53 | if (CollUtil.isEmpty(postRespList)) { |
| 56 | item.setPostNames(Collections.emptySet()); | 54 | item.setPostNames(Collections.emptySet()); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java
| @@ -40,12 +40,12 @@ public class CrmPermissionAspect { | @@ -40,12 +40,12 @@ public class CrmPermissionAspect { | ||
| 40 | 40 | ||
| 41 | @Before("@annotation(crmPermission)") | 41 | @Before("@annotation(crmPermission)") |
| 42 | public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) { | 42 | public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) { |
| 43 | - // 获取相关属性值 | 43 | + // 1.1 获取相关属性值 |
| 44 | Map<String, Object> expressionValues = parseExpressions(joinPoint, crmPermission); | 44 | Map<String, Object> expressionValues = parseExpressions(joinPoint, crmPermission); |
| 45 | Integer bizType = StrUtil.isEmpty(crmPermission.bizTypeValue()) ? | 45 | Integer bizType = StrUtil.isEmpty(crmPermission.bizTypeValue()) ? |
| 46 | crmPermission.bizType()[0].getType() : (Integer) expressionValues.get(crmPermission.bizTypeValue()); // 模块类型 | 46 | crmPermission.bizType()[0].getType() : (Integer) expressionValues.get(crmPermission.bizTypeValue()); // 模块类型 |
| 47 | - // 处理兼容多个 bizId 的情况 | ||
| 48 | - Object object = expressionValues.get(crmPermission.bizId());// 模块数据编号 | 47 | + // 1.2 处理兼容多个 bizId 的情况 |
| 48 | + Object object = expressionValues.get(crmPermission.bizId()); // 模块数据编号 | ||
| 49 | Set<Long> bizIds = new HashSet<>(); | 49 | Set<Long> bizIds = new HashSet<>(); |
| 50 | if (object instanceof Collection<?>) { | 50 | if (object instanceof Collection<?>) { |
| 51 | bizIds.addAll(convertSet((Collection<?>) object, item -> Long.parseLong(item.toString()))); | 51 | bizIds.addAll(convertSet((Collection<?>) object, item -> Long.parseLong(item.toString()))); |
| @@ -53,11 +53,11 @@ public class CrmPermissionAspect { | @@ -53,11 +53,11 @@ public class CrmPermissionAspect { | ||
| 53 | bizIds.add(Long.parseLong(object.toString())); | 53 | bizIds.add(Long.parseLong(object.toString())); |
| 54 | } | 54 | } |
| 55 | Integer permissionLevel = crmPermission.level().getLevel(); // 需要的权限级别 | 55 | Integer permissionLevel = crmPermission.level().getLevel(); // 需要的权限级别 |
| 56 | + | ||
| 57 | + // 2. 逐个校验权限 | ||
| 56 | List<CrmPermissionDO> permissionList = crmPermissionService.getPermissionListByBiz(bizType, bizIds); | 58 | List<CrmPermissionDO> permissionList = crmPermissionService.getPermissionListByBiz(bizType, bizIds); |
| 57 | Map<Long, List<CrmPermissionDO>> multiMap = convertMultiMap(permissionList, CrmPermissionDO::getBizId); | 59 | Map<Long, List<CrmPermissionDO>> multiMap = convertMultiMap(permissionList, CrmPermissionDO::getBizId); |
| 58 | - bizIds.forEach(bizId -> { | ||
| 59 | - validatePermission(bizType, multiMap.get(bizId), permissionLevel); | ||
| 60 | - }); | 60 | + bizIds.forEach(bizId -> validatePermission(bizType, multiMap.get(bizId), permissionLevel)); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | private void validatePermission(Integer bizType, List<CrmPermissionDO> bizPermissions, Integer permissionLevel) { | 63 | private void validatePermission(Integer bizType, List<CrmPermissionDO> bizPermissions, Integer permissionLevel) { |
| @@ -71,7 +71,6 @@ public class CrmPermissionAspect { | @@ -71,7 +71,6 @@ public class CrmPermissionAspect { | ||
| 71 | if (CrmPermissionLevelEnum.isRead(permissionLevel)) { | 71 | if (CrmPermissionLevelEnum.isRead(permissionLevel)) { |
| 72 | return; | 72 | return; |
| 73 | } | 73 | } |
| 74 | - | ||
| 75 | // 没有数据权限的情况下超出了读权限直接报错,避免后面校验空指针 | 74 | // 没有数据权限的情况下超出了读权限直接报错,避免后面校验空指针 |
| 76 | throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType)); | 75 | throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType)); |
| 77 | } else { // 1.2 有数据权限但是没有负责人的情况 | 76 | } else { // 1.2 有数据权限但是没有负责人的情况 |
| @@ -102,9 +101,8 @@ public class CrmPermissionAspect { | @@ -102,9 +101,8 @@ public class CrmPermissionAspect { | ||
| 102 | } | 101 | } |
| 103 | } | 102 | } |
| 104 | } | 103 | } |
| 105 | - // 2.4 没有权限! | ||
| 106 | - // 打个 info 日志,方便后续排查问题、审计 | ||
| 107 | - log.info("[doBefore][userId({}) 要求权限({}) 实际权限({}) 数据校验错误]", | 104 | + // 2.4 没有权限,抛出异常 |
| 105 | + log.info("[doBefore][userId({}) 要求权限({}) 实际权限({}) 数据校验错误]", // 打个 info 日志,方便后续排查问题、审计 | ||
| 108 | getUserId(), permissionLevel, toJsonString(userPermission)); | 106 | getUserId(), permissionLevel, toJsonString(userPermission)); |
| 109 | throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType)); | 107 | throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType)); |
| 110 | } | 108 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
| @@ -33,7 +33,7 @@ import java.util.List; | @@ -33,7 +33,7 @@ import java.util.List; | ||
| 33 | 33 | ||
| 34 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 34 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 35 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | 35 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| 36 | -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CONTACT; | 36 | +import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CONTACT_TYPE; |
| 37 | import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; | 37 | import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; |
| 38 | import static java.util.Collections.singletonList; | 38 | import static java.util.Collections.singletonList; |
| 39 | 39 | ||
| @@ -65,7 +65,7 @@ public class CrmContactServiceImpl implements CrmContactService { | @@ -65,7 +65,7 @@ public class CrmContactServiceImpl implements CrmContactService { | ||
| 65 | 65 | ||
| 66 | @Override | 66 | @Override |
| 67 | @Transactional(rollbackFor = Exception.class) | 67 | @Transactional(rollbackFor = Exception.class) |
| 68 | - @LogRecord(type = CRM_CONTACT, subType = "创建联系人", bizNo = "{{#contactId}}", success = "创建了联系人[{{#contactName}}]") | 68 | + @LogRecord(type = CRM_CONTACT_TYPE, subType = "创建联系人", bizNo = "{{#contactId}}", success = "创建了联系人[{{#contactName}}]") |
| 69 | public Long createContact(CrmContactSaveReqVO createReqVO, Long userId) { | 69 | public Long createContact(CrmContactSaveReqVO createReqVO, Long userId) { |
| 70 | // 1. 校验 | 70 | // 1. 校验 |
| 71 | validateRelationDataExists(createReqVO); | 71 | validateRelationDataExists(createReqVO); |
| @@ -93,7 +93,7 @@ public class CrmContactServiceImpl implements CrmContactService { | @@ -93,7 +93,7 @@ public class CrmContactServiceImpl implements CrmContactService { | ||
| 93 | 93 | ||
| 94 | @Override | 94 | @Override |
| 95 | @Transactional(rollbackFor = Exception.class) | 95 | @Transactional(rollbackFor = Exception.class) |
| 96 | - @LogRecord(type = CRM_CONTACT, subType = "更新联系人", bizNo = "{{#updateReqVO.id}}", success = "更新了联系人{_DIFF{#updateReqVO}}") | 96 | + @LogRecord(type = CRM_CONTACT_TYPE, subType = "更新联系人", bizNo = "{{#updateReqVO.id}}", success = "更新了联系人{_DIFF{#updateReqVO}}") |
| 97 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) | 97 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) |
| 98 | public void updateContact(CrmContactSaveReqVO updateReqVO) { | 98 | public void updateContact(CrmContactSaveReqVO updateReqVO) { |
| 99 | // 1. 校验存在 | 99 | // 1. 校验存在 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java
| @@ -44,7 +44,8 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig | @@ -44,7 +44,8 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig | ||
| 44 | private AdminUserApi adminUserApi; | 44 | private AdminUserApi adminUserApi; |
| 45 | 45 | ||
| 46 | @Override | 46 | @Override |
| 47 | - @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE, bizNo = "{{#limitId}}", success = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS) | 47 | + @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE, bizNo = "{{#limitId}}", |
| 48 | + success = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS) | ||
| 48 | public Long createCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO createReqVO) { | 49 | public Long createCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO createReqVO) { |
| 49 | validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds()); | 50 | validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds()); |
| 50 | // 插入 | 51 | // 插入 |
| @@ -54,12 +55,12 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig | @@ -54,12 +55,12 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig | ||
| 54 | // 记录操作日志上下文 | 55 | // 记录操作日志上下文 |
| 55 | LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(customerLimitConfig.getType())); | 56 | LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(customerLimitConfig.getType())); |
| 56 | LogRecordContext.putVariable("limitId", customerLimitConfig.getId()); | 57 | LogRecordContext.putVariable("limitId", customerLimitConfig.getId()); |
| 57 | - // 返回 | ||
| 58 | return customerLimitConfig.getId(); | 58 | return customerLimitConfig.getId(); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | @Override | 61 | @Override |
| 62 | - @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", success = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS) | 62 | + @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", |
| 63 | + success = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS) | ||
| 63 | public void updateCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO updateReqVO) { | 64 | public void updateCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO updateReqVO) { |
| 64 | // 校验存在 | 65 | // 校验存在 |
| 65 | CrmCustomerLimitConfigDO oldLimitConfig = validateCustomerLimitConfigExists(updateReqVO.getId()); | 66 | CrmCustomerLimitConfigDO oldLimitConfig = validateCustomerLimitConfigExists(updateReqVO.getId()); |
| @@ -73,7 +74,8 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig | @@ -73,7 +74,8 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig | ||
| 73 | } | 74 | } |
| 74 | 75 | ||
| 75 | @Override | 76 | @Override |
| 76 | - @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE, bizNo = "{{#id}}", success = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS) | 77 | + @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE, bizNo = "{{#id}}", |
| 78 | + success = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS) | ||
| 77 | public void deleteCustomerLimitConfig(Long id) { | 79 | public void deleteCustomerLimitConfig(Long id) { |
| 78 | // 校验存在 | 80 | // 校验存在 |
| 79 | CrmCustomerLimitConfigDO limitConfigDO = validateCustomerLimitConfigExists(id); | 81 | CrmCustomerLimitConfigDO limitConfigDO = validateCustomerLimitConfigExists(id); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java
| @@ -34,6 +34,7 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe | @@ -34,6 +34,7 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe | ||
| 34 | */ | 34 | */ |
| 35 | @Override | 35 | @Override |
| 36 | public CrmCustomerPoolConfigDO getCustomerPoolConfig() { | 36 | public CrmCustomerPoolConfigDO getCustomerPoolConfig() { |
| 37 | + // TODO @puhui999:这个要搞到 mapper 里噢。 | ||
| 37 | return customerPoolConfigMapper.selectOne(new LambdaQueryWrapperX<CrmCustomerPoolConfigDO>().last("LIMIT 1")); | 38 | return customerPoolConfigMapper.selectOne(new LambdaQueryWrapperX<CrmCustomerPoolConfigDO>().last("LIMIT 1")); |
| 38 | } | 39 | } |
| 39 | 40 | ||
| @@ -43,7 +44,8 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe | @@ -43,7 +44,8 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe | ||
| 43 | * @param saveReqVO 更新信息 | 44 | * @param saveReqVO 更新信息 |
| 44 | */ | 45 | */ |
| 45 | @Override | 46 | @Override |
| 46 | - @LogRecord(type = CRM_CUSTOMER_POOL_CONFIG_TYPE, subType = CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE, bizNo = "{{#poolConfigId}}", success = CRM_CUSTOMER_POOL_CONFIG_SUCCESS) | 47 | + @LogRecord(type = CRM_CUSTOMER_POOL_CONFIG_TYPE, subType = CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE, bizNo = "{{#poolConfigId}}", |
| 48 | + success = CRM_CUSTOMER_POOL_CONFIG_SUCCESS) | ||
| 47 | public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) { | 49 | public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) { |
| 48 | // 存在,则进行更新 | 50 | // 存在,则进行更新 |
| 49 | CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig(); | 51 | CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig(); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| @@ -65,7 +65,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -65,7 +65,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 65 | 65 | ||
| 66 | @Override | 66 | @Override |
| 67 | @Transactional(rollbackFor = Exception.class) | 67 | @Transactional(rollbackFor = Exception.class) |
| 68 | - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}", success = CRM_CUSTOMER_CREATE_SUCCESS) | 68 | + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}", |
| 69 | + success = CRM_CUSTOMER_CREATE_SUCCESS) | ||
| 69 | public Long createCustomer(CrmCustomerSaveReqVO createReqVO, Long userId) { | 70 | public Long createCustomer(CrmCustomerSaveReqVO createReqVO, Long userId) { |
| 70 | createReqVO.setId(null); | 71 | createReqVO.setId(null); |
| 71 | // 1. 校验拥有客户是否到达上限 | 72 | // 1. 校验拥有客户是否到达上限 |
| @@ -89,12 +90,12 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -89,12 +90,12 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 89 | 90 | ||
| 90 | @Override | 91 | @Override |
| 91 | @Transactional(rollbackFor = Exception.class) | 92 | @Transactional(rollbackFor = Exception.class) |
| 92 | - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", success = CRM_CUSTOMER_UPDATE_SUCCESS) | 93 | + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", |
| 94 | + success = CRM_CUSTOMER_UPDATE_SUCCESS) | ||
| 93 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) | 95 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) |
| 94 | public void updateCustomer(CrmCustomerSaveReqVO updateReqVO) { | 96 | public void updateCustomer(CrmCustomerSaveReqVO updateReqVO) { |
| 95 | Assert.notNull(updateReqVO.getId(), "客户编号不能为空"); | 97 | Assert.notNull(updateReqVO.getId(), "客户编号不能为空"); |
| 96 | - // 更新的时候,要把 updateReqVO 负责人设置为空,避免修改。 | ||
| 97 | - updateReqVO.setOwnerUserId(null); | 98 | + updateReqVO.setOwnerUserId(null); // 更新的时候,要把 updateReqVO 负责人设置为空,避免修改 |
| 98 | // 1. 校验存在 | 99 | // 1. 校验存在 |
| 99 | CrmCustomerDO oldCustomer = validateCustomerExists(updateReqVO.getId()); | 100 | CrmCustomerDO oldCustomer = validateCustomerExists(updateReqVO.getId()); |
| 100 | 101 | ||
| @@ -109,7 +110,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -109,7 +110,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 109 | 110 | ||
| 110 | @Override | 111 | @Override |
| 111 | @Transactional(rollbackFor = Exception.class) | 112 | @Transactional(rollbackFor = Exception.class) |
| 112 | - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_DELETE_SUB_TYPE, bizNo = "{{#id}}", success = CRM_CUSTOMER_DELETE_SUCCESS) | 113 | + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_DELETE_SUB_TYPE, bizNo = "{{#id}}", |
| 114 | + success = CRM_CUSTOMER_DELETE_SUCCESS) | ||
| 113 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) | 115 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) |
| 114 | public void deleteCustomer(Long id) { | 116 | public void deleteCustomer(Long id) { |
| 115 | // 校验存在 | 117 | // 校验存在 |
| @@ -128,7 +130,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -128,7 +130,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 128 | 130 | ||
| 129 | @Override | 131 | @Override |
| 130 | @Transactional(rollbackFor = Exception.class) | 132 | @Transactional(rollbackFor = Exception.class) |
| 131 | - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", success = CRM_CUSTOMER_TRANSFER_SUCCESS) | 133 | + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", |
| 134 | + success = CRM_CUSTOMER_TRANSFER_SUCCESS) | ||
| 132 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) | 135 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) |
| 133 | public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) { | 136 | public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) { |
| 134 | // 1.1 校验客户是否存在 | 137 | // 1.1 校验客户是否存在 |
| @@ -144,11 +147,13 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -144,11 +147,13 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 144 | 147 | ||
| 145 | // 3. TODO 记录转移日志 | 148 | // 3. TODO 记录转移日志 |
| 146 | // 记录操作日志上下文 | 149 | // 记录操作日志上下文 |
| 150 | + // TODO @puhui999:crmCustomer=》customer,也看看其他有没类似的情况哈 | ||
| 147 | LogRecordContext.putVariable("crmCustomer", customer); | 151 | LogRecordContext.putVariable("crmCustomer", customer); |
| 148 | } | 152 | } |
| 149 | 153 | ||
| 150 | @Override | 154 | @Override |
| 151 | - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_LOCK_SUB_TYPE, bizNo = "{{#lockReqVO.id}}", success = CRM_CUSTOMER_LOCK_SUCCESS) | 155 | + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_LOCK_SUB_TYPE, bizNo = "{{#lockReqVO.id}}", |
| 156 | + success = CRM_CUSTOMER_LOCK_SUCCESS) | ||
| 152 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#lockReqVO.id", level = CrmPermissionLevelEnum.OWNER) | 157 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#lockReqVO.id", level = CrmPermissionLevelEnum.OWNER) |
| 153 | public void lockCustomer(CrmCustomerLockReqVO lockReqVO, Long userId) { | 158 | public void lockCustomer(CrmCustomerLockReqVO lockReqVO, Long userId) { |
| 154 | // 1.1 校验当前客户是否存在 | 159 | // 1.1 校验当前客户是否存在 |
| @@ -165,7 +170,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -165,7 +170,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 165 | // 2. 更新锁定状态 | 170 | // 2. 更新锁定状态 |
| 166 | customerMapper.updateById(BeanUtils.toBean(lockReqVO, CrmCustomerDO.class)); | 171 | customerMapper.updateById(BeanUtils.toBean(lockReqVO, CrmCustomerDO.class)); |
| 167 | 172 | ||
| 168 | - // 3. 记录操作日志上下文. tips: 因为这里使用的是老的状态所以记录时反着记录,也就是 lockStatus 为 true 那么就是解锁反之为锁定 | 173 | + // 3. 记录操作日志上下文 |
| 174 | + // tips: 因为这里使用的是老的状态所以记录时反着记录,也就是 lockStatus 为 true 那么就是解锁反之为锁定 | ||
| 169 | LogRecordContext.putVariable("crmCustomer", customer); | 175 | LogRecordContext.putVariable("crmCustomer", customer); |
| 170 | } | 176 | } |
| 171 | 177 | ||
| @@ -173,7 +179,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -173,7 +179,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 173 | 179 | ||
| 174 | @Override | 180 | @Override |
| 175 | @Transactional(rollbackFor = Exception.class) | 181 | @Transactional(rollbackFor = Exception.class) |
| 176 | - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_POOL_SUB_TYPE, bizNo = "{{#id}}", success = CRM_CUSTOMER_POOL_SUCCESS) | 182 | + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_POOL_SUB_TYPE, bizNo = "{{#id}}", |
| 183 | + success = CRM_CUSTOMER_POOL_SUCCESS) | ||
| 177 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) | 184 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) |
| 178 | public void putCustomerPool(Long id) { | 185 | public void putCustomerPool(Long id) { |
| 179 | // 1. 校验存在 | 186 | // 1. 校验存在 |
| @@ -252,7 +259,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -252,7 +259,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 252 | } | 259 | } |
| 253 | } | 260 | } |
| 254 | 261 | ||
| 255 | - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}", success = CRM_CUSTOMER_RECEIVE_SUCCESS) | 262 | + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}", |
| 263 | + success = CRM_CUSTOMER_RECEIVE_SUCCESS) | ||
| 256 | public void receiveCustomerLog(CrmCustomerDO customer, String ownerUserName) { | 264 | public void receiveCustomerLog(CrmCustomerDO customer, String ownerUserName) { |
| 257 | // 记录操作日志上下文 | 265 | // 记录操作日志上下文 |
| 258 | LogRecordContext.putVariable("customer", customer); | 266 | LogRecordContext.putVariable("customer", customer); |
| @@ -280,7 +288,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -280,7 +288,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 280 | return customerMapper.selectPage(pageReqVO, userId); | 288 | return customerMapper.selectPage(pageReqVO, userId); |
| 281 | } | 289 | } |
| 282 | 290 | ||
| 283 | - //======================= 校验相关 ======================= | 291 | + // ======================= 校验相关 ======================= |
| 284 | 292 | ||
| 285 | /** | 293 | /** |
| 286 | * 校验客户是否存在 | 294 | * 校验客户是否存在 |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java
| @@ -138,38 +138,4 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest { | @@ -138,38 +138,4 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest { | ||
| 138 | //assertPojoEquals(dbCustomer, pageResult.getList().get(0)); | 138 | //assertPojoEquals(dbCustomer, pageResult.getList().get(0)); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | - @Test | ||
| 142 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | ||
| 143 | - public void testGetCustomerList() { | ||
| 144 | - // mock 数据 | ||
| 145 | - CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class, o -> { // 等会查询到 | ||
| 146 | - o.setName(null); | ||
| 147 | - o.setMobile(null); | ||
| 148 | - o.setTelephone(null); | ||
| 149 | - o.setWebsite(null); | ||
| 150 | - }); | ||
| 151 | - customerMapper.insert(dbCustomer); | ||
| 152 | - // 测试 name 不匹配 | ||
| 153 | - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setName(null))); | ||
| 154 | - // 测试 mobile 不匹配 | ||
| 155 | - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setMobile(null))); | ||
| 156 | - // 测试 telephone 不匹配 | ||
| 157 | - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setTelephone(null))); | ||
| 158 | - // 测试 website 不匹配 | ||
| 159 | - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null))); | ||
| 160 | - // 准备参数 | ||
| 161 | - CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); | ||
| 162 | - reqVO.setName("张三"); | ||
| 163 | - reqVO.setMobile("13888888888"); | ||
| 164 | - reqVO.setPageSize(PAGE_SIZE_NONE); | ||
| 165 | - //reqVO.setTelephone(null); | ||
| 166 | - //reqVO.setWebsite(null); | ||
| 167 | - | ||
| 168 | - // 调用 | ||
| 169 | - PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(reqVO, 1L); | ||
| 170 | - // 断言 | ||
| 171 | - assertEquals(1, pageResult.getList().size()); | ||
| 172 | - assertPojoEquals(dbCustomer, pageResult.getList().get(0)); | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | } | 141 | } |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java
| @@ -74,6 +74,7 @@ public class MpMessageServiceImpl implements MpMessageService { | @@ -74,6 +74,7 @@ public class MpMessageServiceImpl implements MpMessageService { | ||
| 74 | Assert.notNull(account, "公众号账号({}) 不存在", appId); | 74 | Assert.notNull(account, "公众号账号({}) 不存在", appId); |
| 75 | 75 | ||
| 76 | // 订阅事件不记录,因为此时公众号粉丝表中还没有此粉丝的数据 | 76 | // 订阅事件不记录,因为此时公众号粉丝表中还没有此粉丝的数据 |
| 77 | + // TODO @芋艿:这个修复,后续看看还有啥问题 | ||
| 77 | if (ObjUtil.equal(wxMessage.getEvent(), WxConsts.EventType.SUBSCRIBE)) { | 78 | if (ObjUtil.equal(wxMessage.getEvent(), WxConsts.EventType.SUBSCRIBE)) { |
| 78 | return; | 79 | return; |
| 79 | } | 80 | } |