mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	Merge branch 'feature/crm' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into feature/crm
This commit is contained in:
		| @@ -5,21 +5,12 @@ import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
|  | ||||
| import java.util.Set; | ||||
|  | ||||
| @Schema(description = "管理后台 - 商机创建 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO { | ||||
|  | ||||
|     @Schema(description = "只读权限的用户编号数组") | ||||
|     private Set<Long> roUserIds; | ||||
|  | ||||
|     @Schema(description = "读写权限的用户编号数组") | ||||
|     private Set<Long> rwUserIds; | ||||
|  | ||||
|  | ||||
|     // TODO @ljileo:新建的时候,应该可以传递添加的产品; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,18 +1,11 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.business.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
| import java.math.BigDecimal; | ||||
| import java.math.BigDecimal; | ||||
| import java.math.BigDecimal; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| import com.alibaba.excel.annotation.ExcelProperty; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.math.BigDecimal; | ||||
| import java.time.LocalDateTime; | ||||
| import java.util.Set; | ||||
|  | ||||
| /** | ||||
|  * 商机 Excel VO | ||||
| @@ -62,10 +55,10 @@ public class CrmBusinessExcelVO { | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
|     @ExcelProperty("只读权限的用户编号数组") | ||||
|     private String roUserIds; | ||||
|     private Set<Long> roUserIds; | ||||
|  | ||||
|     @ExcelProperty("读写权限的用户编号数组") | ||||
|     private String rwUserIds; | ||||
|     private Set<Long> rwUserIds; | ||||
|  | ||||
|     @ExcelProperty("1赢单2输单3无效") | ||||
|     private Integer endStatus; | ||||
|   | ||||
| @@ -15,6 +15,6 @@ public class CrmBusinessTransferReqVO { | ||||
|  | ||||
|     @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | ||||
|     @NotNull(message = "新负责人的用户编号不能为空") | ||||
|     private Long ownerUserId; // 新的负责人 | ||||
|     private Long ownerUserId; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
|  | ||||
| import javax.validation.constraints.NotNull; | ||||
| import java.util.Set; | ||||
|  | ||||
| @Schema(description = "管理后台 - 商机更新 Request VO") | ||||
| @Data | ||||
| @@ -18,13 +17,6 @@ public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO { | ||||
|     @NotNull(message = "主键不能为空") | ||||
|     private Long id; | ||||
|  | ||||
|     @Schema(description = "只读权限的用户编号数组") | ||||
|     private Set<Long> roUserIds; | ||||
|  | ||||
|     @Schema(description = "读写权限的用户编号数组") | ||||
|     private Set<Long> rwUserIds; | ||||
|  | ||||
|  | ||||
|     // TODO @ljileo:修改的时候,应该可以传递添加的产品; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -5,8 +5,6 @@ import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
|  | ||||
| import java.util.Set; | ||||
|  | ||||
| @Schema(description = "管理后台 - crm联系人更新 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @@ -16,10 +14,4 @@ public class ContactUpdateReqVO extends ContactBaseVO { | ||||
|     @Schema(description = "主键", example = "23210") | ||||
|     private Long id; | ||||
|  | ||||
|     @Schema(description = "只读权限的用户编号数组") | ||||
|     private Set<Long> roUserIds; | ||||
|  | ||||
|     @Schema(description = "读写权限的用户编号数组") | ||||
|     private Set<Long> rwUserIds; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -15,6 +15,6 @@ public class CrmContactTransferReqVO { | ||||
|  | ||||
|     @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | ||||
|     @NotNull(message = "新负责人的用户编号不能为空") | ||||
|     private Long ownerUserId; // 新的负责人 | ||||
|     private Long ownerUserId; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -95,5 +95,4 @@ public class ContractController { | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -5,18 +5,10 @@ import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
|  | ||||
| import java.util.Set; | ||||
|  | ||||
| @Schema(description = "管理后台 - 合同创建 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class ContractCreateReqVO extends ContractBaseVO { | ||||
|  | ||||
|     @Schema(description = "只读权限的用户编号数组") | ||||
|     private Set<Long> roUserIds; | ||||
|  | ||||
|     @Schema(description = "读写权限的用户编号数组") | ||||
|     private Set<Long> rwUserIds; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
|  | ||||
| import javax.validation.constraints.NotNull; | ||||
| import java.util.Set; | ||||
|  | ||||
| @Schema(description = "管理后台 - 合同更新 Request VO") | ||||
| @Data | ||||
| @@ -18,10 +17,4 @@ public class ContractUpdateReqVO extends ContractBaseVO { | ||||
|     @NotNull(message = "合同编号不能为空") | ||||
|     private Long id; | ||||
|  | ||||
|     @Schema(description = "只读权限的用户编号数组") | ||||
|     private Set<Long> roUserIds; | ||||
|  | ||||
|     @Schema(description = "读写权限的用户编号数组") | ||||
|     private Set<Long> rwUserIds; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -15,6 +15,6 @@ public class CrmContractTransferReqVO { | ||||
|  | ||||
|     @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | ||||
|     @NotNull(message = "新负责人的用户编号不能为空") | ||||
|     private Long ownerUserId; // 新的负责人 | ||||
|     private Long ownerUserId; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -32,8 +32,10 @@ public interface CrmBusinessConvert { | ||||
|  | ||||
|     default CrmBusinessDO convert(CrmBusinessDO business, CrmBusinessTransferReqVO reqVO, Long userId) { | ||||
|         Set<Long> rwUserIds = business.getRwUserIds(); | ||||
|         rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 | ||||
|         rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 TODO puhui999:是不是直接 rwUserIds.remove(userId) | ||||
|         // TODO @puhui999:ownerUserId 不用添加到进去,它就是 ownerUserId 就够;因为一共有 3 个角色:负责人、读写、只读; | ||||
|         rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 | ||||
|         // TODO @puhui999:对原负责人,加个类似的处理:移除、转化为团队成员(只读、读写) | ||||
|         return new CrmBusinessDO().setId(business.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 | ||||
|                 .setRwUserIds(rwUserIds); | ||||
|     } | ||||
|   | ||||
| @@ -32,6 +32,7 @@ public interface ContactConvert { | ||||
|  | ||||
|     List<ContactExcelVO> convertList02(List<ContactDO> list); | ||||
|  | ||||
|     // TODO @puhui999:参考 CrmBusinessConvert 的修改建议 | ||||
|     default ContactDO convert(ContactDO contact, CrmContactTransferReqVO reqVO, Long userId) { | ||||
|         Set<Long> rwUserIds = contact.getRwUserIds(); | ||||
|         rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 | ||||
|   | ||||
| @@ -32,6 +32,7 @@ public interface ContractConvert { | ||||
|  | ||||
|     List<ContractExcelVO> convertList02(List<ContractDO> list); | ||||
|  | ||||
|     // TODO @puhui999:参考 CrmBusinessConvert 的修改建议 | ||||
|     default ContractDO convert(ContractDO contract, CrmContractTransferReqVO reqVO, Long userId) { | ||||
|         Set<Long> rwUserIds = contract.getRwUserIds(); | ||||
|         rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 | ||||
|   | ||||
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.framework.utils; | ||||
|  | ||||
| import java.util.Collection; | ||||
|  | ||||
| // TODO @puhui999:改成 CrmPermissionUtils; | ||||
| /** | ||||
|  * 数据读写权限校验工具类 | ||||
|  * | ||||
| @@ -9,6 +10,8 @@ import java.util.Collection; | ||||
|  */ | ||||
| public class AuthUtil { | ||||
|  | ||||
|     // TODO @puhui999:负责人是单独的字段哈; | ||||
|     // TODO @puhui999:额外校验,如果是管理员,可以查看所有;看着要做成有状态的了,可能要搞个 CrmPermissionService 咧; | ||||
|     /** | ||||
|      * 判断当前数据对用户来说是否是只读的 | ||||
|      * | ||||
| @@ -17,6 +20,7 @@ public class AuthUtil { | ||||
|      * @return boolean 是/否 | ||||
|      */ | ||||
|     public static boolean isReadOnly(Collection<Long> roUserIds, Long userId) { | ||||
|         // TODO @puhui999:从代码角度来说,最好使用 CollUtil.contains | ||||
|         return roUserIds.contains(userId); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -92,26 +92,27 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||||
|         return businessMapper.selectList(exportReqVO); | ||||
|     } | ||||
|  | ||||
|     // TODO @puhui999:动名词哈。transferBusiness | ||||
|     @Override | ||||
|     public void businessTransfer(CrmBusinessTransferReqVO reqVO, Long userId) { | ||||
|         // 1. 校验商机是否存在 | ||||
|         // 1.1 校验商机是否存在 | ||||
|         CrmBusinessDO business = validateBusinessExists(reqVO.getId()); | ||||
|         // 1.2. 校验用户是否拥有读写权限 | ||||
|         // 1.2 校验用户是否拥有读写权限 | ||||
|         if (!isReadAndWrite(business.getRwUserIds(), userId)) { | ||||
|             throw exception(BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED); | ||||
|         } | ||||
|         // 2. 校验新负责人是否存在 | ||||
|         // TODO @puhui999:如果已经是该负责人,抛个业务异常; | ||||
|         // 1.3 校验新负责人是否存在 | ||||
|         AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId()); | ||||
|         if (user == null) { | ||||
|             throw exception(BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS); | ||||
|         } | ||||
|  | ||||
|         // 3. 更新新的负责人 | ||||
|         // 2. 更新新的负责人 | ||||
|         CrmBusinessDO updateBusiness = CrmBusinessConvert.INSTANCE.convert(business, reqVO, userId); | ||||
|         businessMapper.updateById(updateBusiness); | ||||
|  | ||||
|         // 4. TODO 记录商机转移日志 | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -95,6 +95,7 @@ public class ContactServiceImpl implements ContactService { | ||||
|         return contactMapper.selectList(exportReqVO); | ||||
|     } | ||||
|  | ||||
|     // TODO @puhui999:参考 CrmBusinessServiceImpl 修改建议 | ||||
|     @Override | ||||
|     public void contactTransfer(CrmContactTransferReqVO reqVO, Long userId) { | ||||
|         // 1. 校验联系人是否存在 | ||||
|   | ||||
| @@ -92,6 +92,7 @@ public class ContractServiceImpl implements ContractService { | ||||
|         return contractMapper.selectList(exportReqVO); | ||||
|     } | ||||
|  | ||||
|     // TODO @puhui999:参考 CrmBusinessServiceImpl 修改建议 | ||||
|     @Override | ||||
|     public void contractTransfer(CrmContractTransferReqVO reqVO, Long userId) { | ||||
|         // 1. 校验合同是否存在 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 liuhongfeng
					liuhongfeng