Commit 722e9c8a044c9deea0cdf4e3f316bb5fbcc91c7f
1 parent
36a76c5c
CRM-商机:新增商机转移接口
Showing
13 changed files
with
118 additions
and
28 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
| @@ -19,6 +19,8 @@ public interface ErrorCodeConstants { | @@ -19,6 +19,8 @@ public interface ErrorCodeConstants { | ||
| 19 | 19 | ||
| 20 | // ========== 商机管理 1-020-002-000 ========== | 20 | // ========== 商机管理 1-020-002-000 ========== |
| 21 | ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); | 21 | ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); |
| 22 | + ErrorCode BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_002_001, "商机转移失败,原因:没有转移权限"); | ||
| 23 | + ErrorCode BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_002_002, "商机转移失败,原因:负责人不存在"); | ||
| 22 | 24 | ||
| 23 | // TODO @lilleo:商机状态、商机类型,都单独错误码段 | 25 | // TODO @lilleo:商机状态、商机类型,都单独错误码段 |
| 24 | 26 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
| @@ -23,6 +23,7 @@ import java.util.List; | @@ -23,6 +23,7 @@ import java.util.List; | ||
| 23 | 23 | ||
| 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 25 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | 25 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 26 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||
| 26 | 27 | ||
| 27 | @Tag(name = "管理后台 - 商机") | 28 | @Tag(name = "管理后台 - 商机") |
| 28 | @RestController | 29 | @RestController |
| @@ -80,11 +81,19 @@ public class CrmBusinessController { | @@ -80,11 +81,19 @@ public class CrmBusinessController { | ||
| 80 | @PreAuthorize("@ss.hasPermission('crm:business:export')") | 81 | @PreAuthorize("@ss.hasPermission('crm:business:export')") |
| 81 | @OperateLog(type = EXPORT) | 82 | @OperateLog(type = EXPORT) |
| 82 | public void exportBusinessExcel(@Valid CrmBusinessExportReqVO exportReqVO, | 83 | public void exportBusinessExcel(@Valid CrmBusinessExportReqVO exportReqVO, |
| 83 | - HttpServletResponse response) throws IOException { | 84 | + HttpServletResponse response) throws IOException { |
| 84 | List<CrmBusinessDO> list = businessService.getBusinessList(exportReqVO); | 85 | List<CrmBusinessDO> list = businessService.getBusinessList(exportReqVO); |
| 85 | // 导出 Excel | 86 | // 导出 Excel |
| 86 | List<CrmBusinessExcelVO> datas = CrmBusinessConvert.INSTANCE.convertList02(list); | 87 | List<CrmBusinessExcelVO> datas = CrmBusinessConvert.INSTANCE.convertList02(list); |
| 87 | ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class, datas); | 88 | ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class, datas); |
| 88 | } | 89 | } |
| 89 | 90 | ||
| 91 | + @PutMapping("/transfer") | ||
| 92 | + @Operation(summary = "商机转移") | ||
| 93 | + @PreAuthorize("@ss.hasPermission('crm:business:update')") | ||
| 94 | + public CommonResult<Boolean> transfer(@Valid @RequestBody CrmBusinessTransferReqVO reqVO) { | ||
| 95 | + businessService.businessTransfer(reqVO, getLoginUserId()); | ||
| 96 | + return success(true); | ||
| 97 | + } | ||
| 98 | + | ||
| 90 | } | 99 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java
| @@ -5,12 +5,21 @@ import lombok.Data; | @@ -5,12 +5,21 @@ import lombok.Data; | ||
| 5 | import lombok.EqualsAndHashCode; | 5 | import lombok.EqualsAndHashCode; |
| 6 | import lombok.ToString; | 6 | import lombok.ToString; |
| 7 | 7 | ||
| 8 | +import java.util.Set; | ||
| 9 | + | ||
| 8 | @Schema(description = "管理后台 - 商机创建 Request VO") | 10 | @Schema(description = "管理后台 - 商机创建 Request VO") |
| 9 | @Data | 11 | @Data |
| 10 | @EqualsAndHashCode(callSuper = true) | 12 | @EqualsAndHashCode(callSuper = true) |
| 11 | @ToString(callSuper = true) | 13 | @ToString(callSuper = true) |
| 12 | public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO { | 14 | public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO { |
| 13 | 15 | ||
| 16 | + @Schema(description = "只读权限的用户编号数组") | ||
| 17 | + private Set<Long> roUserIds; | ||
| 18 | + | ||
| 19 | + @Schema(description = "读写权限的用户编号数组") | ||
| 20 | + private Set<Long> rwUserIds; | ||
| 21 | + | ||
| 22 | + | ||
| 14 | // TODO @ljileo:新建的时候,应该可以传递添加的产品; | 23 | // TODO @ljileo:新建的时候,应该可以传递添加的产品; |
| 15 | 24 | ||
| 16 | } | 25 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.business.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import javax.validation.constraints.NotNull; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - 商机转移 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class CrmBusinessTransferReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | ||
| 13 | + @NotNull(message = "联系人编号不能为空") | ||
| 14 | + private Long id; | ||
| 15 | + | ||
| 16 | + @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | ||
| 17 | + @NotNull(message = "新负责人的用户编号不能为空") | ||
| 18 | + private Long ownerUserId; // 新的负责人 | ||
| 19 | + | ||
| 20 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java
| @@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode; | @@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode; | ||
| 6 | import lombok.ToString; | 6 | import lombok.ToString; |
| 7 | 7 | ||
| 8 | import javax.validation.constraints.NotNull; | 8 | import javax.validation.constraints.NotNull; |
| 9 | +import java.util.Set; | ||
| 9 | 10 | ||
| 10 | @Schema(description = "管理后台 - 商机更新 Request VO") | 11 | @Schema(description = "管理后台 - 商机更新 Request VO") |
| 11 | @Data | 12 | @Data |
| @@ -17,6 +18,13 @@ public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO { | @@ -17,6 +18,13 @@ public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO { | ||
| 17 | @NotNull(message = "主键不能为空") | 18 | @NotNull(message = "主键不能为空") |
| 18 | private Long id; | 19 | private Long id; |
| 19 | 20 | ||
| 21 | + @Schema(description = "只读权限的用户编号数组") | ||
| 22 | + private Set<Long> roUserIds; | ||
| 23 | + | ||
| 24 | + @Schema(description = "读写权限的用户编号数组") | ||
| 25 | + private Set<Long> rwUserIds; | ||
| 26 | + | ||
| 27 | + | ||
| 20 | // TODO @ljileo:修改的时候,应该可以传递添加的产品; | 28 | // TODO @ljileo:修改的时候,应该可以传递添加的产品; |
| 21 | 29 | ||
| 22 | } | 30 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java
| @@ -5,7 +5,7 @@ import lombok.Data; | @@ -5,7 +5,7 @@ import lombok.Data; | ||
| 5 | 5 | ||
| 6 | import javax.validation.constraints.NotNull; | 6 | import javax.validation.constraints.NotNull; |
| 7 | 7 | ||
| 8 | -@Schema(description = "管理后台 - 联系转移 Request VO") | 8 | +@Schema(description = "管理后台 - 联系人转移 Request VO") |
| 9 | @Data | 9 | @Data |
| 10 | public class CrmContactTransferReqVO { | 10 | public class CrmContactTransferReqVO { |
| 11 | 11 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java
| 1 | package cn.iocoder.yudao.module.crm.convert.business; | 1 | package cn.iocoder.yudao.module.crm.convert.business; |
| 2 | 2 | ||
| 3 | -import java.util.*; | ||
| 4 | - | 3 | +import cn.hutool.core.util.ObjUtil; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | - | ||
| 7 | -import org.mapstruct.Mapper; | ||
| 8 | -import org.mapstruct.factory.Mappers; | ||
| 9 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; | 5 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; |
| 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 7 | +import org.mapstruct.Mapper; | ||
| 8 | +import org.mapstruct.factory.Mappers; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | +import java.util.Set; | ||
| 11 | 12 | ||
| 12 | /** | 13 | /** |
| 13 | * 商机 Convert | 14 | * 商机 Convert |
| @@ -29,4 +30,12 @@ public interface CrmBusinessConvert { | @@ -29,4 +30,12 @@ public interface CrmBusinessConvert { | ||
| 29 | 30 | ||
| 30 | List<CrmBusinessExcelVO> convertList02(List<CrmBusinessDO> list); | 31 | List<CrmBusinessExcelVO> convertList02(List<CrmBusinessDO> list); |
| 31 | 32 | ||
| 33 | + default CrmBusinessDO convert(CrmBusinessDO business, CrmBusinessTransferReqVO reqVO, Long userId) { | ||
| 34 | + Set<Long> rwUserIds = business.getRwUserIds(); | ||
| 35 | + rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 | ||
| 36 | + rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 | ||
| 37 | + return new CrmBusinessDO().setId(business.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 | ||
| 38 | + .setRwUserIds(rwUserIds); | ||
| 39 | + } | ||
| 40 | + | ||
| 32 | } | 41 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java
| @@ -34,7 +34,7 @@ public interface ContactConvert { | @@ -34,7 +34,7 @@ public interface ContactConvert { | ||
| 34 | 34 | ||
| 35 | default ContactDO convert(ContactDO contact, CrmContactTransferReqVO reqVO, Long userId) { | 35 | default ContactDO convert(ContactDO contact, CrmContactTransferReqVO reqVO, Long userId) { |
| 36 | Set<Long> rwUserIds = contact.getRwUserIds(); | 36 | Set<Long> rwUserIds = contact.getRwUserIds(); |
| 37 | - rwUserIds.removeIf(item -> ObjUtil.equal(item, userId.toString())); // 移除老负责人 | 37 | + rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 |
| 38 | rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 | 38 | rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 |
| 39 | return new ContactDO().setId(contact.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 | 39 | return new ContactDO().setId(contact.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 |
| 40 | .setRwUserIds(rwUserIds); | 40 | .setRwUserIds(rwUserIds); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java
| @@ -34,7 +34,7 @@ public interface ContractConvert { | @@ -34,7 +34,7 @@ public interface ContractConvert { | ||
| 34 | 34 | ||
| 35 | default ContractDO convert(ContractDO contract, CrmContractTransferReqVO reqVO, Long userId) { | 35 | default ContractDO convert(ContractDO contract, CrmContractTransferReqVO reqVO, Long userId) { |
| 36 | Set<Long> rwUserIds = contract.getRwUserIds(); | 36 | Set<Long> rwUserIds = contract.getRwUserIds(); |
| 37 | - rwUserIds.removeIf(item -> ObjUtil.equal(item, userId.toString())); // 移除老负责人 | 37 | + rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 |
| 38 | rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 | 38 | rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 |
| 39 | return new ContractDO().setId(contract.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 | 39 | return new ContractDO().setId(contract.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 |
| 40 | .setRwUserIds(rwUserIds); | 40 | .setRwUserIds(rwUserIds); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java
| 1 | package cn.iocoder.yudao.module.crm.dal.dataobject.business; | 1 | package cn.iocoder.yudao.module.crm.dal.dataobject.business; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; | ||
| 4 | import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; | 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; |
| 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; |
| 6 | import com.baomidou.mybatisplus.annotation.KeySequence; | 7 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 8 | +import com.baomidou.mybatisplus.annotation.TableField; | ||
| 7 | import com.baomidou.mybatisplus.annotation.TableId; | 9 | import com.baomidou.mybatisplus.annotation.TableId; |
| 8 | import com.baomidou.mybatisplus.annotation.TableName; | 10 | import com.baomidou.mybatisplus.annotation.TableName; |
| 9 | import lombok.*; | 11 | import lombok.*; |
| 10 | 12 | ||
| 11 | import java.time.LocalDateTime; | 13 | import java.time.LocalDateTime; |
| 14 | +import java.util.Set; | ||
| 12 | 15 | ||
| 13 | /** | 16 | /** |
| 14 | * 商机 DO | 17 | * 商机 DO |
| @@ -85,16 +88,14 @@ public class CrmBusinessDO extends BaseDO { | @@ -85,16 +88,14 @@ public class CrmBusinessDO extends BaseDO { | ||
| 85 | private Long ownerUserId; | 88 | private Long ownerUserId; |
| 86 | /** | 89 | /** |
| 87 | * 只读权限的用户编号数组 | 90 | * 只读权限的用户编号数组 |
| 88 | - * | ||
| 89 | - * TODO @lijie:应该是 List<Long>,然后使用下对应的 typehandler | ||
| 90 | */ | 91 | */ |
| 91 | - private String roUserIds; | 92 | + @TableField(typeHandler = JsonLongSetTypeHandler.class) |
| 93 | + private Set<Long> roUserIds; | ||
| 92 | /** | 94 | /** |
| 93 | * 读写权限的用户编号数组 | 95 | * 读写权限的用户编号数组 |
| 94 | - * | ||
| 95 | - * TODO @lijie:应该是 List<Long>,然后使用下对应的 typehandler | ||
| 96 | */ | 96 | */ |
| 97 | - private String rwUserIds; | 97 | + @TableField(typeHandler = JsonLongSetTypeHandler.class) |
| 98 | + private Set<Long> rwUserIds; | ||
| 98 | /** | 99 | /** |
| 99 | * 1赢单2输单3无效 | 100 | * 1赢单2输单3无效 |
| 100 | * | 101 | * |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java
| 1 | package cn.iocoder.yudao.module.crm.service.business; | 1 | package cn.iocoder.yudao.module.crm.service.business; |
| 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.business.vo.CrmBusinessCreateReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO; | ||
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO; | 4 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; |
| 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 9 | 6 | ||
| 10 | import javax.validation.Valid; | 7 | import javax.validation.Valid; |
| @@ -72,4 +69,12 @@ public interface CrmBusinessService { | @@ -72,4 +69,12 @@ public interface CrmBusinessService { | ||
| 72 | */ | 69 | */ |
| 73 | List<CrmBusinessDO> getBusinessList(CrmBusinessExportReqVO exportReqVO); | 70 | List<CrmBusinessDO> getBusinessList(CrmBusinessExportReqVO exportReqVO); |
| 74 | 71 | ||
| 72 | + /** | ||
| 73 | + * 商机转移 | ||
| 74 | + * | ||
| 75 | + * @param reqVO 请求 | ||
| 76 | + * @param userId 用户编号 | ||
| 77 | + */ | ||
| 78 | + void businessTransfer(CrmBusinessTransferReqVO reqVO, Long userId); | ||
| 79 | + | ||
| 75 | } | 80 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| @@ -3,13 +3,12 @@ package cn.iocoder.yudao.module.crm.service.business; | @@ -3,13 +3,12 @@ package cn.iocoder.yudao.module.crm.service.business; | ||
| 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.business.vo.CrmBusinessCreateReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO; | ||
| 9 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO; | 6 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; |
| 10 | import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; | 7 | import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; |
| 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 12 | import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; | 9 | import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; |
| 10 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||
| 11 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | ||
| 13 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 14 | import org.springframework.validation.annotation.Validated; | 13 | import org.springframework.validation.annotation.Validated; |
| 15 | 14 | ||
| @@ -18,7 +17,8 @@ import java.util.Collection; | @@ -18,7 +17,8 @@ import java.util.Collection; | ||
| 18 | import java.util.List; | 17 | import java.util.List; |
| 19 | 18 | ||
| 20 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 21 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; | 20 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| 21 | +import static cn.iocoder.yudao.module.crm.framework.utils.AuthUtil.isReadAndWrite; | ||
| 22 | 22 | ||
| 23 | /** | 23 | /** |
| 24 | * 商机 Service 实现类 | 24 | * 商机 Service 实现类 |
| @@ -32,6 +32,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -32,6 +32,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 32 | @Resource | 32 | @Resource |
| 33 | private CrmBusinessMapper businessMapper; | 33 | private CrmBusinessMapper businessMapper; |
| 34 | 34 | ||
| 35 | + @Resource | ||
| 36 | + private AdminUserApi adminUserApi; | ||
| 37 | + | ||
| 35 | @Override | 38 | @Override |
| 36 | public Long createBusiness(CrmBusinessCreateReqVO createReqVO) { | 39 | public Long createBusiness(CrmBusinessCreateReqVO createReqVO) { |
| 37 | // 插入 | 40 | // 插入 |
| @@ -58,10 +61,12 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -58,10 +61,12 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 58 | businessMapper.deleteById(id); | 61 | businessMapper.deleteById(id); |
| 59 | } | 62 | } |
| 60 | 63 | ||
| 61 | - private void validateBusinessExists(Long id) { | ||
| 62 | - if (businessMapper.selectById(id) == null) { | 64 | + private CrmBusinessDO validateBusinessExists(Long id) { |
| 65 | + CrmBusinessDO crmBusiness = businessMapper.selectById(id); | ||
| 66 | + if (crmBusiness == null) { | ||
| 63 | throw exception(BUSINESS_NOT_EXISTS); | 67 | throw exception(BUSINESS_NOT_EXISTS); |
| 64 | } | 68 | } |
| 69 | + return crmBusiness; | ||
| 65 | } | 70 | } |
| 66 | 71 | ||
| 67 | @Override | 72 | @Override |
| @@ -87,4 +92,26 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -87,4 +92,26 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 87 | return businessMapper.selectList(exportReqVO); | 92 | return businessMapper.selectList(exportReqVO); |
| 88 | } | 93 | } |
| 89 | 94 | ||
| 95 | + @Override | ||
| 96 | + public void businessTransfer(CrmBusinessTransferReqVO reqVO, Long userId) { | ||
| 97 | + // 1. 校验商机是否存在 | ||
| 98 | + CrmBusinessDO business = validateBusinessExists(reqVO.getId()); | ||
| 99 | + // 1.2. 校验用户是否拥有读写权限 | ||
| 100 | + if (!isReadAndWrite(business.getRwUserIds(), userId)) { | ||
| 101 | + throw exception(BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED); | ||
| 102 | + } | ||
| 103 | + // 2. 校验新负责人是否存在 | ||
| 104 | + AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId()); | ||
| 105 | + if (user == null) { | ||
| 106 | + throw exception(BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + // 3. 更新新的负责人 | ||
| 110 | + CrmBusinessDO updateBusiness = CrmBusinessConvert.INSTANCE.convert(business, reqVO, userId); | ||
| 111 | + businessMapper.updateById(updateBusiness); | ||
| 112 | + | ||
| 113 | + // 4. TODO 记录商机转移日志 | ||
| 114 | + | ||
| 115 | + } | ||
| 116 | + | ||
| 90 | } | 117 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java
| @@ -110,8 +110,8 @@ public class ContactServiceImpl implements ContactService { | @@ -110,8 +110,8 @@ public class ContactServiceImpl implements ContactService { | ||
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | // 3. 更新新的负责人 | 112 | // 3. 更新新的负责人 |
| 113 | - ContactDO updateContract = ContactConvert.INSTANCE.convert(contact, reqVO, userId); | ||
| 114 | - contactMapper.updateById(updateContract); | 113 | + ContactDO updateContact = ContactConvert.INSTANCE.convert(contact, reqVO, userId); |
| 114 | + contactMapper.updateById(updateContact); | ||
| 115 | 115 | ||
| 116 | // 4. TODO 记录联系人转移日志 | 116 | // 4. TODO 记录联系人转移日志 |
| 117 | 117 |