Commit df2441def9db05044b393c7ab9f95db8017ac98e
Committed by
Gitee
!875 完善 review 提到的问题
Merge pull request !875 from puhui999/develop
Showing
17 changed files
with
80 additions
and
70 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
| @@ -26,6 +26,7 @@ public interface ErrorCodeConstants { | @@ -26,6 +26,7 @@ public interface ErrorCodeConstants { | ||
| 26 | ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); | 26 | ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); |
| 27 | ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode(1_020_003_001, "联系人商机关联不存在"); | 27 | ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode(1_020_003_001, "联系人商机关联不存在"); |
| 28 | ErrorCode CONTACT_DELETE_FAIL_CONTRACT_LINK_EXISTS = new ErrorCode(1_020_003_002, "联系人已关联合同,不能删除"); | 28 | ErrorCode CONTACT_DELETE_FAIL_CONTRACT_LINK_EXISTS = new ErrorCode(1_020_003_002, "联系人已关联合同,不能删除"); |
| 29 | + ErrorCode CONTACT_UPDATE_OWNER_USER_FAIL = new ErrorCode(1_020_003_003, "更新联系人负责人失败"); | ||
| 29 | 30 | ||
| 30 | // ========== 回款 1-020-004-000 ========== | 31 | // ========== 回款 1-020-004-000 ========== |
| 31 | ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在"); | 32 | ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在"); |
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java
| @@ -77,6 +77,8 @@ public interface LogRecordConstants { | @@ -77,6 +77,8 @@ public interface LogRecordConstants { | ||
| 77 | String CRM_CONTACT_TRANSFER_SUCCESS = "将联系人【{{#contact.name}}】的负责人从【{getAdminUserById{#contact.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; | 77 | String CRM_CONTACT_TRANSFER_SUCCESS = "将联系人【{{#contact.name}}】的负责人从【{getAdminUserById{#contact.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; |
| 78 | String CRM_CONTACT_FOLLOW_UP_SUB_TYPE = "联系人跟进"; | 78 | String CRM_CONTACT_FOLLOW_UP_SUB_TYPE = "联系人跟进"; |
| 79 | String CRM_CONTACT_FOLLOW_UP_SUCCESS = "联系人跟进【{{#contactName}}】"; | 79 | String CRM_CONTACT_FOLLOW_UP_SUCCESS = "联系人跟进【{{#contactName}}】"; |
| 80 | + String CRM_CONTACT_UPDATE_OWNER_USER_SUB_TYPE = "更新联系人负责人"; | ||
| 81 | + String CRM_CONTACT_UPDATE_OWNER_USER_SUCCESS = "将联系人【{{#contact.name}}】的负责人从【{getAdminUserById{#contact.ownerUserId}}】变更为了【{getAdminUserById{#ownerUserId}}】"; | ||
| 80 | 82 | ||
| 81 | // ======================= CRM_BUSINESS 商机 ======================= | 83 | // ======================= CRM_BUSINESS 商机 ======================= |
| 82 | 84 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractRespVO.java
| @@ -130,14 +130,13 @@ public class CrmContractRespVO { | @@ -130,14 +130,13 @@ public class CrmContractRespVO { | ||
| 130 | private Integer auditStatus; | 130 | private Integer auditStatus; |
| 131 | 131 | ||
| 132 | @Schema(description = "产品列表") | 132 | @Schema(description = "产品列表") |
| 133 | - private List<CrmContractProductItemRespVO> productItems; | 133 | + private List<Item> items; |
| 134 | 134 | ||
| 135 | - // TODO @puhui999:可以直接叫 Item | ||
| 136 | @Schema(description = "产品列表") | 135 | @Schema(description = "产品列表") |
| 137 | @Data | 136 | @Data |
| 138 | @NoArgsConstructor | 137 | @NoArgsConstructor |
| 139 | @AllArgsConstructor | 138 | @AllArgsConstructor |
| 140 | - public static class CrmContractProductItemRespVO { | 139 | + public static class Item { |
| 141 | 140 | ||
| 142 | @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") | 141 | @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") |
| 143 | private Long id; | 142 | private Long id; |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/CrmContractConvert.java
| @@ -59,8 +59,8 @@ public interface CrmContractConvert { | @@ -59,8 +59,8 @@ public interface CrmContractConvert { | ||
| 59 | 59 | ||
| 60 | default void setContractRespVOProductItems(CrmContractRespVO respVO, Map<Long, CrmContractProductDO> contractProductMap, | 60 | default void setContractRespVOProductItems(CrmContractRespVO respVO, Map<Long, CrmContractProductDO> contractProductMap, |
| 61 | List<CrmProductDO> productList) { | 61 | List<CrmProductDO> productList) { |
| 62 | - respVO.setProductItems(CollectionUtils.convertList(productList, product -> { | ||
| 63 | - CrmContractRespVO.CrmContractProductItemRespVO productItemRespVO = BeanUtils.toBean(product, CrmContractRespVO.CrmContractProductItemRespVO.class); | 62 | + respVO.setItems(CollectionUtils.convertList(productList, product -> { |
| 63 | + CrmContractRespVO.Item productItemRespVO = BeanUtils.toBean(product, CrmContractRespVO.Item.class); | ||
| 64 | findAndThen(contractProductMap, product.getId(), contractProduct -> | 64 | findAndThen(contractProductMap, product.getId(), contractProduct -> |
| 65 | productItemRespVO.setCount(contractProduct.getCount()).setDiscountPercent(contractProduct.getDiscountPercent())); | 65 | productItemRespVO.setCount(contractProduct.getCount()).setDiscountPercent(contractProduct.getDiscountPercent())); |
| 66 | return productItemRespVO; | 66 | return productItemRespVO; |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java
| @@ -57,8 +57,9 @@ public class CrmContractProductDO extends BaseDO { | @@ -57,8 +57,9 @@ public class CrmContractProductDO extends BaseDO { | ||
| 57 | private Integer discountPercent; | 57 | private Integer discountPercent; |
| 58 | /** | 58 | /** |
| 59 | * 总计价格(折扣后价格) | 59 | * 总计价格(折扣后价格) |
| 60 | - * | ||
| 61 | - * TODO @puhui999:可以写下计算公式哈; | 60 | + * = {@link #price} |
| 61 | + * * {@link #count} | ||
| 62 | + * * ({@link #discountPercent / 100}) | ||
| 62 | */ | 63 | */ |
| 63 | private Integer totalPrice; | 64 | private Integer totalPrice; |
| 64 | 65 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java
| @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business; | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business; | ||
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; |
| 7 | import org.apache.ibatis.annotations.Mapper; | 6 | import org.apache.ibatis.annotations.Mapper; |
| 8 | 7 | ||
| @@ -16,18 +15,8 @@ import java.util.List; | @@ -16,18 +15,8 @@ import java.util.List; | ||
| 16 | @Mapper | 15 | @Mapper |
| 17 | public interface CrmBusinessProductMapper extends BaseMapperX<CrmBusinessProductDO> { | 16 | public interface CrmBusinessProductMapper extends BaseMapperX<CrmBusinessProductDO> { |
| 18 | 17 | ||
| 19 | - // TODO @puhui999:用不到的方法,看看是不是删除哈 | ||
| 20 | - default void deleteByBusinessId(Long getBusinessId) { // TODO @lzxhqs:第一个方法,和类之间最好空一行; | ||
| 21 | - delete(CrmBusinessProductDO::getBusinessId, getBusinessId); | ||
| 22 | - } | ||
| 23 | - | ||
| 24 | - default CrmBusinessProductDO selectByBusinessId(Long getBusinessId) { | ||
| 25 | - return selectOne(CrmBusinessProductDO::getBusinessId, getBusinessId); | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | default List<CrmBusinessProductDO> selectListByBusinessId(Long businessId) { | 18 | default List<CrmBusinessProductDO> selectListByBusinessId(Long businessId) { |
| 29 | - // TODO @puhui999:可以简化,selectList(CrmBusinessProductDO::getBusinessId, businessId) | ||
| 30 | - return selectList(new LambdaQueryWrapperX<CrmBusinessProductDO>().eq(CrmBusinessProductDO::getBusinessId, businessId)); | 19 | + return selectList(CrmBusinessProductDO::getBusinessId, businessId); |
| 31 | } | 20 | } |
| 32 | 21 | ||
| 33 | } | 22 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contactbusinesslink/CrmContactBusinessMapper.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactBusinessMapper.java
| 1 | -package cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink; | 1 | +package cn.iocoder.yudao.module.crm.dal.mysql.contact; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; | 4 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; |
| @@ -9,7 +9,7 @@ import java.util.Collection; | @@ -9,7 +9,7 @@ import java.util.Collection; | ||
| 9 | import java.util.List; | 9 | import java.util.List; |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| 12 | - * CRM 联系人与商机的关联 Mapper | 12 | + * CRM 联系人商机关联 Mapper |
| 13 | * | 13 | * |
| 14 | * @author 芋道源码 | 14 | * @author 芋道源码 |
| 15 | */ | 15 | */ |
| @@ -31,4 +31,4 @@ public interface CrmContactBusinessMapper extends BaseMapperX<CrmContactBusiness | @@ -31,4 +31,4 @@ public interface CrmContactBusinessMapper extends BaseMapperX<CrmContactBusiness | ||
| 31 | return selectList(CrmContactBusinessDO::getContactId, contactId); | 31 | return selectList(CrmContactBusinessDO::getContactId, contactId); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | -} | ||
| 35 | \ No newline at end of file | 34 | \ No newline at end of file |
| 35 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java
| @@ -65,4 +65,8 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { | @@ -65,4 +65,8 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { | ||
| 65 | return selectJoinList(CrmContactDO.class, query); | 65 | return selectJoinList(CrmContactDO.class, query); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | + default List<CrmContactDO> selectListByCustomerId(Long customerId) { | ||
| 69 | + return selectList(CrmContactDO::getCustomerId, customerId); | ||
| 70 | + } | ||
| 71 | + | ||
| 68 | } | 72 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractProductMapper.java
| @@ -16,15 +16,6 @@ import java.util.List; | @@ -16,15 +16,6 @@ import java.util.List; | ||
| 16 | @Mapper | 16 | @Mapper |
| 17 | public interface CrmContractProductMapper extends BaseMapperX<CrmContractProductDO> { | 17 | public interface CrmContractProductMapper extends BaseMapperX<CrmContractProductDO> { |
| 18 | 18 | ||
| 19 | - // TODO @puhui999:用不到的方法,看看是不是删除哈 | ||
| 20 | - default void deleteByContractId(Long contractId) { // TODO @lzxhqs:第一个方法,和类之间最好空一行; | ||
| 21 | - delete(CrmContractProductDO::getContractId, contractId); | ||
| 22 | - } | ||
| 23 | - | ||
| 24 | - default CrmContractProductDO selectByContractId(Long contractId) { | ||
| 25 | - return selectOne(CrmContractProductDO::getContractId, contractId); | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | default List<CrmContractProductDO> selectListByContractId(Long contractId) { | 19 | default List<CrmContractProductDO> selectListByContractId(Long contractId) { |
| 29 | return selectList(new LambdaQueryWrapperX<CrmContractProductDO>().eq(CrmContractProductDO::getContractId, contractId)); | 20 | return selectList(new LambdaQueryWrapperX<CrmContractProductDO>().eq(CrmContractProductDO::getContractId, contractId)); |
| 30 | } | 21 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| @@ -100,10 +100,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -100,10 +100,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 100 | businessProducts.forEach(item -> item.setBusinessId(business.getId())); | 100 | businessProducts.forEach(item -> item.setBusinessId(business.getId())); |
| 101 | businessProductMapper.insertBatch(businessProducts); | 101 | businessProductMapper.insertBatch(businessProducts); |
| 102 | } | 102 | } |
| 103 | - | ||
| 104 | - // TODO @puhui999:在联系人的详情页,如果直接【新建商机】,则需要关联下。这里要搞个 CrmContactBusinessDO 表 | ||
| 105 | - createContactBusiness(business.getId(), createReqVO.getContactId()); | ||
| 106 | - | 103 | + // 在联系人的详情页,如果直接【新建商机】,则需要关联下。 |
| 104 | + contactBusinessService.createContactBusiness(createReqVO.getContactId(), business.getId()); | ||
| 107 | // 3. 创建数据权限 | 105 | // 3. 创建数据权限 |
| 108 | // 设置当前操作的人为负责人 | 106 | // 设置当前操作的人为负责人 |
| 109 | permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) | 107 | permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) |
| @@ -114,17 +112,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -114,17 +112,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 114 | return business.getId(); | 112 | return business.getId(); |
| 115 | } | 113 | } |
| 116 | 114 | ||
| 117 | - // TODO @lzxhqs:CrmContactBusinessService 调用这个;这样逻辑才能收敛哈; | ||
| 118 | - private void createContactBusiness(Long businessId, Long contactId) { | ||
| 119 | - if (contactId == null) { | ||
| 120 | - return; | ||
| 121 | - } | ||
| 122 | - CrmContactBusinessDO contactBusiness = new CrmContactBusinessDO(); | ||
| 123 | - contactBusiness.setBusinessId(businessId); | ||
| 124 | - contactBusiness.setContactId(contactId); | ||
| 125 | - contactBusinessService.insert(contactBusiness); | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | @Override | 115 | @Override |
| 129 | @Transactional(rollbackFor = Exception.class) | 116 | @Transactional(rollbackFor = Exception.class) |
| 130 | @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", | 117 | @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/bo/CrmBusinessUpdateProductReqBO.java
| @@ -25,13 +25,13 @@ public class CrmBusinessUpdateProductReqBO { | @@ -25,13 +25,13 @@ public class CrmBusinessUpdateProductReqBO { | ||
| 25 | 25 | ||
| 26 | // TODO @芋艿:再想想 | 26 | // TODO @芋艿:再想想 |
| 27 | @NotEmpty(message = "产品列表不能为空") | 27 | @NotEmpty(message = "产品列表不能为空") |
| 28 | - private List<CrmBusinessProductItem> productItems; | 28 | + private List<Item> items; |
| 29 | 29 | ||
| 30 | @Schema(description = "产品列表") | 30 | @Schema(description = "产品列表") |
| 31 | @Data | 31 | @Data |
| 32 | @NoArgsConstructor | 32 | @NoArgsConstructor |
| 33 | @AllArgsConstructor | 33 | @AllArgsConstructor |
| 34 | - public static class CrmBusinessProductItem { | 34 | + public static class Item { |
| 35 | 35 | ||
| 36 | @Schema(description = "产品编号", example = "20529") | 36 | @Schema(description = "产品编号", example = "20529") |
| 37 | @NotNull(message = "产品编号不能为空") | 37 | @NotNull(message = "产品编号不能为空") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java
| @@ -14,6 +14,15 @@ import java.util.List; | @@ -14,6 +14,15 @@ import java.util.List; | ||
| 14 | public interface CrmContactBusinessService { | 14 | public interface CrmContactBusinessService { |
| 15 | 15 | ||
| 16 | /** | 16 | /** |
| 17 | + * 创建联系人人商机关联 | ||
| 18 | + * | ||
| 19 | + * @param contactId 联系人编号 | ||
| 20 | + * @param businessId 商机编号 | ||
| 21 | + */ | ||
| 22 | + void createContactBusiness(Long contactId, Long businessId); | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + /** | ||
| 17 | * 创建联系人与商机的关联 | 26 | * 创建联系人与商机的关联 |
| 18 | * | 27 | * |
| 19 | * @param createReqVO 创建信息 | 28 | * @param createReqVO 创建信息 |
| @@ -42,11 +51,4 @@ public interface CrmContactBusinessService { | @@ -42,11 +51,4 @@ public interface CrmContactBusinessService { | ||
| 42 | */ | 51 | */ |
| 43 | List<CrmContactBusinessDO> getContactBusinessListByContactId(Long contactId); | 52 | List<CrmContactBusinessDO> getContactBusinessListByContactId(Long contactId); |
| 44 | 53 | ||
| 45 | - /** | ||
| 46 | - * 新增联系人与商机的关联 | ||
| 47 | - * | ||
| 48 | - * @param contactBusiness 新增联系人与商机的对象 | ||
| 49 | - */ | ||
| 50 | - void insert(CrmContactBusinessDO contactBusiness); | ||
| 51 | - | ||
| 52 | } | 54 | } |
| 53 | \ No newline at end of file | 55 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessServiceImpl.java
| @@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusines | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusines | ||
| 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; |
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 8 | -import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessMapper; | 8 | +import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactBusinessMapper; |
| 9 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | 9 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 10 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | 10 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 11 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; | 11 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; |
| @@ -42,6 +42,22 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService | @@ -42,6 +42,22 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService | ||
| 42 | private CrmContactService contactService; | 42 | private CrmContactService contactService; |
| 43 | 43 | ||
| 44 | @Override | 44 | @Override |
| 45 | + public void createContactBusiness(Long contactId, Long businessId) { | ||
| 46 | + // 校验存在 | ||
| 47 | + CrmContactDO contact = contactService.getContact(contactId); | ||
| 48 | + if (contact == null) { | ||
| 49 | + throw exception(CONTACT_NOT_EXISTS); | ||
| 50 | + } | ||
| 51 | + CrmBusinessDO business = businessService.getBusiness(businessId); | ||
| 52 | + if (business == null) { | ||
| 53 | + throw exception(BUSINESS_NOT_EXISTS); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + // 插入 | ||
| 57 | + contactBusinessMapper.insert(new CrmContactBusinessDO(null, contactId, businessId)); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @Override | ||
| 45 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#createReqVO.contactId", level = CrmPermissionLevelEnum.WRITE) | 61 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#createReqVO.contactId", level = CrmPermissionLevelEnum.WRITE) |
| 46 | public void createContactBusinessList(CrmContactBusinessReqVO createReqVO) { | 62 | public void createContactBusinessList(CrmContactBusinessReqVO createReqVO) { |
| 47 | CrmContactDO contact = contactService.getContact(createReqVO.getContactId()); | 63 | CrmContactDO contact = contactService.getContact(createReqVO.getContactId()); |
| @@ -91,9 +107,4 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService | @@ -91,9 +107,4 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService | ||
| 91 | return contactBusinessMapper.selectListByContactId(contactId); | 107 | return contactBusinessMapper.selectListByContactId(contactId); |
| 92 | } | 108 | } |
| 93 | 109 | ||
| 94 | - @Override | ||
| 95 | - public void insert(CrmContactBusinessDO contactBusiness) { | ||
| 96 | - contactBusinessMapper.insert(contactBusiness); | ||
| 97 | - } | ||
| 98 | - | ||
| 99 | } | 110 | } |
| 100 | \ No newline at end of file | 111 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java
| @@ -55,6 +55,7 @@ public interface CrmContactService { | @@ -55,6 +55,7 @@ public interface CrmContactService { | ||
| 55 | 55 | ||
| 56 | /** | 56 | /** |
| 57 | * 更新指定客户的联系人的负责人 | 57 | * 更新指定客户的联系人的负责人 |
| 58 | + * 数据权限基于 【客户】 | ||
| 58 | * | 59 | * |
| 59 | * @param customerId 客户编号 | 60 | * @param customerId 客户编号 |
| 60 | * @param ownerUserId 用户编号 | 61 | * @param ownerUserId 用户编号 |
| @@ -64,8 +65,8 @@ public interface CrmContactService { | @@ -64,8 +65,8 @@ public interface CrmContactService { | ||
| 64 | /** | 65 | /** |
| 65 | * 更新联系人相关跟进信息 | 66 | * 更新联系人相关跟进信息 |
| 66 | * | 67 | * |
| 67 | - * @param id 编号 | ||
| 68 | - * @param contactNextTime 下次联系时间 | 68 | + * @param id 编号 |
| 69 | + * @param contactNextTime 下次联系时间 | ||
| 69 | * @param contactLastContent 最后联系内容 | 70 | * @param contactLastContent 最后联系内容 |
| 70 | */ | 71 | */ |
| 71 | void updateContactFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); | 72 | void updateContactFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); |
| @@ -73,8 +74,8 @@ public interface CrmContactService { | @@ -73,8 +74,8 @@ public interface CrmContactService { | ||
| 73 | /** | 74 | /** |
| 74 | * 更新联系人相关跟进信息 | 75 | * 更新联系人相关跟进信息 |
| 75 | * | 76 | * |
| 76 | - * @param ids 编号数组 | ||
| 77 | - * @param contactNextTime 下次联系时间 | 77 | + * @param ids 编号数组 |
| 78 | + * @param contactNextTime 下次联系时间 | ||
| 78 | * @param contactLastContent 最后联系内容 | 79 | * @param contactLastContent 最后联系内容 |
| 79 | */ | 80 | */ |
| 80 | void updateContactFollowUpBatch(Collection<Long> ids, LocalDateTime contactNextTime, String contactLastContent); | 81 | void updateContactFollowUpBatch(Collection<Long> ids, LocalDateTime contactNextTime, String contactLastContent); |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
| @@ -184,7 +184,7 @@ public class CrmContactServiceImpl implements CrmContactService { | @@ -184,7 +184,7 @@ public class CrmContactServiceImpl implements CrmContactService { | ||
| 184 | 184 | ||
| 185 | // 2.1 数据权限转移 | 185 | // 2.1 数据权限转移 |
| 186 | permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTACT.getType(), | 186 | permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTACT.getType(), |
| 187 | - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); | 187 | + reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); |
| 188 | // 2.2 设置新的负责人 | 188 | // 2.2 设置新的负责人 |
| 189 | contactMapper.updateById(new CrmContactDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId())); | 189 | contactMapper.updateById(new CrmContactDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId())); |
| 190 | 190 | ||
| @@ -193,9 +193,31 @@ public class CrmContactServiceImpl implements CrmContactService { | @@ -193,9 +193,31 @@ public class CrmContactServiceImpl implements CrmContactService { | ||
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | @Override | 195 | @Override |
| 196 | + @Transactional(rollbackFor = Exception.class) | ||
| 197 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#customerId", level = CrmPermissionLevelEnum.OWNER) | ||
| 196 | public void updateOwnerUserIdByCustomerId(Long customerId, Long ownerUserId) { | 198 | public void updateOwnerUserIdByCustomerId(Long customerId, Long ownerUserId) { |
| 197 | - contactMapper.updateOwnerUserIdByCustomerId(customerId, ownerUserId); | ||
| 198 | - // TODO @puhui999:操作日志、数据权限; | 199 | + // 1. 校验存在 |
| 200 | + List<CrmContactDO> contacts = contactMapper.selectListByCustomerId(customerId); | ||
| 201 | + if (CollUtil.isEmpty(contacts)) { | ||
| 202 | + return; | ||
| 203 | + } | ||
| 204 | + int count = contactMapper.updateOwnerUserIdByCustomerId(customerId, ownerUserId); | ||
| 205 | + if (count == 0) { | ||
| 206 | + throw exception(CONTACT_UPDATE_OWNER_USER_FAIL); | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + // 2. 记录操作日志 | ||
| 210 | + for (CrmContactDO contact : contacts) { | ||
| 211 | + receiveContactLog(contact, ownerUserId); | ||
| 212 | + } | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_UPDATE_OWNER_USER_SUB_TYPE, bizNo = "{{#contact.id}", | ||
| 216 | + success = CRM_CONTACT_UPDATE_OWNER_USER_SUCCESS) | ||
| 217 | + public void receiveContactLog(CrmContactDO contact, Long ownerUserId) { | ||
| 218 | + // 记录操作日志上下文 | ||
| 219 | + LogRecordContext.putVariable("contact", contact); | ||
| 220 | + LogRecordContext.putVariable("ownerUserId", ownerUserId); | ||
| 199 | } | 221 | } |
| 200 | 222 | ||
| 201 | @Override | 223 | @Override |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
| @@ -104,7 +104,7 @@ public class CrmContractServiceImpl implements CrmContractService { | @@ -104,7 +104,7 @@ public class CrmContractServiceImpl implements CrmContractService { | ||
| 104 | // 如果存在合同关联了商机则更新商机商品关联 | 104 | // 如果存在合同关联了商机则更新商机商品关联 |
| 105 | if (contract.getBusinessId() != null) { | 105 | if (contract.getBusinessId() != null) { |
| 106 | businessService.updateBusinessProduct(new CrmBusinessUpdateProductReqBO().setId(contract.getBusinessId()) | 106 | businessService.updateBusinessProduct(new CrmBusinessUpdateProductReqBO().setId(contract.getBusinessId()) |
| 107 | - .setProductItems(BeanUtils.toBean(createReqVO.getProductItems(), CrmBusinessUpdateProductReqBO.CrmBusinessProductItem.class))); | 107 | + .setItems(BeanUtils.toBean(createReqVO.getProductItems(), CrmBusinessUpdateProductReqBO.Item.class))); |
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| @@ -412,7 +412,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -412,7 +412,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 412 | return count; | 412 | return count; |
| 413 | } | 413 | } |
| 414 | 414 | ||
| 415 | - @Transactional // 需要 protected 修饰,因为需要在事务中调用 | 415 | + @Transactional(rollbackFor = Exception.class) // 需要 protected 修饰,因为需要在事务中调用 |
| 416 | protected void putCustomerPool(CrmCustomerDO customer) { | 416 | protected void putCustomerPool(CrmCustomerDO customer) { |
| 417 | // 1. 设置负责人为 NULL | 417 | // 1. 设置负责人为 NULL |
| 418 | int updateOwnerUserIncr = customerMapper.updateOwnerUserIdById(customer.getId(), null); | 418 | int updateOwnerUserIncr = customerMapper.updateOwnerUserIdById(customer.getId(), null); |