# Conflicts:
#	yudao-dependencies/pom.xml
#	yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusTypeController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessTransferReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessUpdateReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueSaveReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactSaveReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactUpdateReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/CrmContactBusinessLinkController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contactbusinesslink/vo/CrmContactBusinessLinkSaveReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractSaveReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractUpdateReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerPoolConfigController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerSaveReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerTransferReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigUpdateReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigBaseVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusTypeServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contactbusinesslink/CrmContactBusinessLinkService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contactbusinesslink/CrmContactBusinessLinkServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java
#	yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/util/CrmQueryPageUtils.java
#	yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java
#	yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java
#	yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java
#	yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java
#	yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImplTest.java
#	yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivablePlanServiceImplTest.java
#	yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/sku/ProductSkuApiImpl.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/spu/ProductSpuApiImpl.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategorySaveReqVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentBaseVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertySaveReqVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyUpdateReqVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueSaveReqVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuSaveReqVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java
#	yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
#	yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImplTest.java
#	yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApiImpl.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/DecorateComponentController.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/decorate/vo/DecorateComponentSaveReqVO.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/decorate/AppDecorateController.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyTemplateController.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/decorate/DecorateComponentServiceImpl.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/diy/DiyTemplateServiceImpl.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityService.java
#	yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java
#	yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java
#	yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java
#	yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordServiceImpl.java
#	yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java
#	yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java
#	yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletTransactionController.java
#	yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/OperateLogApi.java
#	yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialUserUnbindReqDTO.java
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/logger/OperateLogApiImpl.java
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java
#	yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java
#	yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImplTest.java
#	yudao-server/src/main/resources/application-local.yaml
This commit is contained in:
YunaiV
2024-01-19 09:13:18 +08:00
555 changed files with 12200 additions and 5949 deletions

View File

@@ -13,5 +13,6 @@ public interface DictTypeConstants {
String CRM_AUDIT_STATUS = "crm_audit_status"; // CRM 审批状态
String CRM_PRODUCT_UNIT = "crm_product_unit"; // CRM 产品单位
String CRM_PRODUCT_STATUS = "crm_product_status"; // CRM 产品状态
String CRM_FOLLOW_UP_TYPE = "crm_follow_up_type"; // CRM 跟进方式
}

View File

@@ -14,9 +14,12 @@ public interface ErrorCodeConstants {
// ========== 线索管理 1-020-001-000 ==========
ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在");
ErrorCode CLUE_ANY_CLUE_NOT_EXISTS = new ErrorCode(1_020_001_001, "线索【{}】不存在");
ErrorCode CLUE_ANY_CLUE_ALREADY_TRANSLATED = new ErrorCode(1_020_001_002, "线索【{}】已经转化过了,请勿重复转化");
// ========== 商机管理 1-020-002-000 ==========
ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在");
ErrorCode BUSINESS_CONTRACT_EXISTS = new ErrorCode(1_020_002_001, "商机已关联合同,不能删除");
// TODO @lilleo商机状态、商机类型都单独错误码段
@@ -24,6 +27,7 @@ public interface ErrorCodeConstants {
// ========== 联系人管理 1-020-003-000 ==========
ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在");
ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode( 1_020_003_001, "联系人商机关联不存在");
ErrorCode CONTACT_DELETE_FAIL_CONTRACT_LINK_EXISTS = new ErrorCode( 1_020_003_002, "联系人已关联合同,不能删除");
// ========== 回款 1-020-004-000 ==========
ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在");
@@ -39,6 +43,11 @@ public interface ErrorCodeConstants {
ErrorCode CUSTOMER_IN_POOL = new ErrorCode(1_020_006_004, "客户【{}】放入公海失败,原因:已经是公海客户");
ErrorCode CUSTOMER_LOCKED_PUT_POOL_FAIL = new ErrorCode(1_020_006_005, "客户【{}】放入公海失败,原因:客户已锁定");
ErrorCode CUSTOMER_UPDATE_OWNER_USER_FAIL = new ErrorCode(1_020_006_006, "更新客户【{}】负责人失败, 原因:系统异常");
ErrorCode CUSTOMER_LOCK_FAIL_IS_LOCK = new ErrorCode(1_020_006_007, "锁定客户失败,它已经处于锁定状态");
ErrorCode CUSTOMER_UNLOCK_FAIL_IS_UNLOCK = new ErrorCode(1_020_006_008, "解锁客户失败,它已经处于未锁定状态");
ErrorCode CUSTOMER_LOCK_EXCEED_LIMIT = new ErrorCode(1_020_006_009, "锁定客户失败,超出锁定规则上限");
ErrorCode CUSTOMER_OWNER_EXCEED_LIMIT = new ErrorCode(1_020_006_010, "操作失败,超出客户数拥有上限");
ErrorCode CUSTOMER_DELETE_FAIL_HAVE_REFERENCE = new ErrorCode(1_020_006_011, "删除客户失败,有关联{}");
// ========== 权限管理 1_020_007_000 ==========
ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在");
@@ -49,6 +58,7 @@ public interface ErrorCodeConstants {
ErrorCode CRM_PERMISSION_DELETE_FAIL_EXIST_OWNER = new ErrorCode(1_020_007_005, "删除数据权限失败,原因:存在负责人");
ErrorCode CRM_PERMISSION_DELETE_DENIED = new ErrorCode(1_020_007_006, "删除数据权限失败,原因:没有权限");
ErrorCode CRM_PERMISSION_DELETE_SELF_PERMISSION_FAIL_EXIST_OWNER = new ErrorCode(1_020_007_007, "删除数据权限失败,原因:不能删除负责人");
ErrorCode CRM_PERMISSION_CREATE_FAIL = new ErrorCode(1_020_007_008, "创建数据权限失败,原因:所加用户已有权限");
// ========== 产品 1_020_008_000 ==========
ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_020_008_000, "产品不存在");
@@ -72,4 +82,8 @@ public interface ErrorCodeConstants {
// ========== 客户公海规则设置 1_020_012_000 ==========
ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_012_000, "客户限制配置不存在");
// ========== 跟进记录 1_020_013_000 ==========
ErrorCode FOLLOW_UP_RECORD_NOT_EXISTS = new ErrorCode(1_020_013_000, "跟进记录不存在");
ErrorCode FOLLOW_UP_RECORD_DELETE_DENIED = new ErrorCode(1_020_013_001, "删除跟进记录失败,原因:没有权限");
}

View File

@@ -0,0 +1,125 @@
package cn.iocoder.yudao.module.crm.enums;
/**
* CRM 操作日志枚举
* 目的:统一管理,也减少 Service 里各种“复杂”字符串
*
* @author HUIHUI
*/
public interface LogRecordConstants {
// ======================= CRM_LEADS 线索 =======================
String CRM_LEADS_TYPE = "CRM 线索";
// ======================= CRM_CUSTOMER 客户 =======================
String CRM_CUSTOMER_TYPE = "CRM 客户";
String CRM_CUSTOMER_CREATE_SUB_TYPE = "创建客户";
String CRM_CUSTOMER_CREATE_SUCCESS = "创建了客户{{#customer.name}}";
String CRM_CUSTOMER_UPDATE_SUB_TYPE = "更新客户";
String CRM_CUSTOMER_UPDATE_SUCCESS = "更新了客户【{{#customerName}}】: {_DIFF{#updateReqVO}}";
String CRM_CUSTOMER_DELETE_SUB_TYPE = "删除客户";
String CRM_CUSTOMER_DELETE_SUCCESS = "删除了客户【{{#customerName}}】";
String CRM_CUSTOMER_TRANSFER_SUB_TYPE = "转移客户";
String CRM_CUSTOMER_TRANSFER_SUCCESS = "将客户【{{#customer.name}}】的负责人从【{getAdminUserById{#customer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
String CRM_CUSTOMER_LOCK_SUB_TYPE = "{{#customer.lockStatus ? '解锁客户' : '锁定客户'}}";
String CRM_CUSTOMER_LOCK_SUCCESS = "{{#customer.lockStatus ? '将客户【' + #customer.name + '】解锁' : '将客户【' + #customer.name + '】锁定'}}";
String CRM_CUSTOMER_POOL_SUB_TYPE = "客户放入公海";
String CRM_CUSTOMER_POOL_SUCCESS = "将客户【{{#customerName}}】放入了公海";
String CRM_CUSTOMER_RECEIVE_SUB_TYPE = "{{#ownerUserName != null ? '分配客户' : '领取客户'}}";
String CRM_CUSTOMER_RECEIVE_SUCCESS = "{{#ownerUserName != null ? '将客户【' + #customer.name + '】分配给【' + #ownerUserName + '】' : '领取客户【' + #customer.name + '】'}}";
// ======================= CRM_CUSTOMER_LIMIT_CONFIG 客户限制配置 =======================
String CRM_CUSTOMER_LIMIT_CONFIG_TYPE = "CRM 客户限制配置";
String CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE = "创建客户限制配置";
String CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS = "创建了【{{#limitType}}】类型的客户限制配置";
String CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE = "更新客户限制配置";
String CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS = "更新了客户限制配置: {_DIFF{#updateReqVO}}";
String CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE = "删除客户限制配置";
String CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS = "删除了【{{#limitType}}】类型的客户限制配置";
// ======================= CRM_CUSTOMER_POOL_CONFIG 客户公海规则 =======================
String CRM_CUSTOMER_POOL_CONFIG_TYPE = "CRM 客户公海规则";
String CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE = "{{#isPoolConfigUpdate ? '更新客户公海规则' : '创建客户公海规则'}}";
String CRM_CUSTOMER_POOL_CONFIG_SUCCESS = "{{#isPoolConfigUpdate ? '更新了客户公海规则' : '创建了客户公海规则'}}";
// ======================= CRM_CONTACT 联系人 =======================
String CRM_CONTACT_TYPE = "CRM 联系人";
String CRM_CONTACT_CREATE_SUB_TYPE = "创建联系人";
String CRM_CONTACT_CREATE_SUCCESS = "创建了联系人{{#contact.name}}";
String CRM_CONTACT_UPDATE_SUB_TYPE = "更新联系人";
String CRM_CONTACT_UPDATE_SUCCESS = "更新了联系人【{{#contactName}}】: {_DIFF{#updateReqVO}}";
String CRM_CONTACT_DELETE_SUB_TYPE = "删除联系人";
String CRM_CONTACT_DELETE_SUCCESS = "删除了联系人【{{#contactName}}】";
String CRM_CONTACT_TRANSFER_SUB_TYPE = "转移联系人";
String CRM_CONTACT_TRANSFER_SUCCESS = "将联系人【{{#contact.name}}】的负责人从【{getAdminUserById{#contact.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
// ======================= CRM_BUSINESS 商机 =======================
String CRM_BUSINESS_TYPE = "CRM 商机";
String CRM_BUSINESS_CREATE_SUB_TYPE = "创建商机";
String CRM_BUSINESS_CREATE_SUCCESS = "创建了商机{{#business.name}}";
String CRM_BUSINESS_UPDATE_SUB_TYPE = "更新商机";
String CRM_BUSINESS_UPDATE_SUCCESS = "更新了商机【{{#businessName}}】: {_DIFF{#updateReqVO}}";
String CRM_BUSINESS_DELETE_SUB_TYPE = "删除商机";
String CRM_BUSINESS_DELETE_SUCCESS = "删除了商机【{{#businessName}}】";
String CRM_BUSINESS_TRANSFER_SUB_TYPE = "转移商机";
String CRM_BUSINESS_TRANSFER_SUCCESS = "将商机【{{#business.name}}】的负责人从【{getAdminUserById{#business.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
// ======================= CRM_CONTRACT 合同 =======================
String CRM_CONTRACT_TYPE = "CRM 合同";
String CRM_CONTRACT_CREATE_SUB_TYPE = "创建合同";
String CRM_CONTRACT_CREATE_SUCCESS = "创建了合同{{#contract.name}}";
String CRM_CONTRACT_UPDATE_SUB_TYPE = "更新合同";
String CRM_CONTRACT_UPDATE_SUCCESS = "更新了合同【{{#contractName}}】: {_DIFF{#updateReqVO}}";
String CRM_CONTRACT_DELETE_SUB_TYPE = "删除合同";
String CRM_CONTRACT_DELETE_SUCCESS = "删除了合同【{{#contractName}}】";
String CRM_CONTRACT_TRANSFER_SUB_TYPE = "转移合同";
String CRM_CONTRACT_TRANSFER_SUCCESS = "将合同【{{#contract.name}}】的负责人从【{getAdminUserById{#contract.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
// ======================= CRM_PRODUCT 产品 =======================
String CRM_PRODUCT_TYPE = "CRM 产品";
String CRM_PRODUCT_CREATE_SUB_TYPE = "创建产品";
String CRM_PRODUCT_CREATE_SUCCESS = "创建了产品【{{#createReqVO.name}}】";
String CRM_PRODUCT_UPDATE_SUB_TYPE = "更新产品";
String CRM_PRODUCT_UPDATE_SUCCESS = "更新了产品【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}";
String CRM_PRODUCT_DELETE_SUB_TYPE = "删除产品";
String CRM_PRODUCT_DELETE_SUCCESS = "删除了产品【{{#product.name}}】";
// ======================= CRM_PRODUCT_CATEGORY 产品分类 =======================
String CRM_PRODUCT_CATEGORY_TYPE = "CRM 产品分类";
String CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE = "创建产品分类";
String CRM_PRODUCT_CATEGORY_CREATE_SUCCESS = "创建了产品分类【{{#createReqVO.name}}】";
String CRM_PRODUCT_CATEGORY_UPDATE_SUB_TYPE = "更新产品分类";
String CRM_PRODUCT_CATEGORY_UPDATE_SUCCESS = "更新了产品分类【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}";
String CRM_PRODUCT_CATEGORY_DELETE_SUB_TYPE = "删除产品分类";
String CRM_PRODUCT_CATEGORY_DELETE_SUCCESS = "删除了产品分类【{{#productCategory.name}}】";
// ======================= CRM_RECEIVABLE 回款 =======================
String CRM_RECEIVABLE_TYPE = "CRM 回款";
String CRM_RECEIVABLE_CREATE_SUB_TYPE = "创建回款";
String CRM_RECEIVABLE_CREATE_SUCCESS = "创建了合同【{getContractById{#receivable.contractId}}】的第【{{#receivable.period}}】期回款";
String CRM_RECEIVABLE_UPDATE_SUB_TYPE = "更新回款";
String CRM_RECEIVABLE_UPDATE_SUCCESS = "更新了合同【{getContractById{#receivable.contractId}}】的第【{{#receivable.period}}】期回款: {_DIFF{#updateReqVO}}";
String CRM_RECEIVABLE_DELETE_SUB_TYPE = "删除回款";
String CRM_RECEIVABLE_DELETE_SUCCESS = "删除了合同【{getContractById{#receivable.contractId}}】的第【{{#receivable.period}}】期回款";
// ======================= CRM_RECEIVABLE_PLAN 回款计划 =======================
String CRM_RECEIVABLE_PLAN_TYPE = "CRM 回款计划";
String CRM_RECEIVABLE_PLAN_CREATE_SUB_TYPE = "创建回款计划";
String CRM_RECEIVABLE_PLAN_CREATE_SUCCESS = "创建了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划";
String CRM_RECEIVABLE_PLAN_UPDATE_SUB_TYPE = "更新回款计划";
String CRM_RECEIVABLE_PLAN_UPDATE_SUCCESS = "更新了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划: {_DIFF{#updateReqVO}}";
String CRM_RECEIVABLE_PLAN_DELETE_SUB_TYPE = "删除回款计划";
String CRM_RECEIVABLE_PLAN_DELETE_SUCCESS = "删除了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划";
}

View File

@@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.crm.enums.business;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.Arrays;
// TODO @lzxhqs1title、description、create 可以删除,非标准的 javadoc 注释哈然后可以在类上加下这个类的注释2CrmBizEndStatus 改成 CrmBusinessEndStatus非必要不缩写哈可阅读比较重要
/**
* @author lzxhqs
* @version 1.0
* @title CrmBizEndStatus
* @description
* @create 2024/1/12
*/
@RequiredArgsConstructor
@Getter
public enum CrmBizEndStatus implements IntArrayValuable {
WIN(1, "赢单"),
LOSE(2, "输单"),
INVALID(3, "无效");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizEndStatus::getStatus).toArray();
// TODO @lzxhqs这里的方法建议放到 49 行之后;一般类里是,静态变量,普通变量;静态方法;普通方法
public static boolean isWin(Integer status) {
return ObjectUtil.equal(WIN.getStatus(), status);
}
public static boolean isLose(Integer status) {
return ObjectUtil.equal(LOSE.getStatus(), status);
}
public static boolean isInvalid(Integer status) {
return ObjectUtil.equal(INVALID.getStatus(), status);
}
/**
* 场景类型
*/
private final Integer status;
/**
* 场景名称
*/
private final String name;
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@@ -22,7 +22,9 @@ public enum CrmBizTypeEnum implements IntArrayValuable {
CRM_CONTACT(3, "联系人"),
CRM_BUSINESS(4, "商机"),
CRM_CONTRACT(5, "合同"),
CRM_PRODUCT(6, "产品")
CRM_PRODUCT(6, "产品"),
CRM_RECEIVABLE(7, "回款"),
CRM_RECEIVABLE_PLAN(8, "回款计划")
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizTypeEnum::getType).toArray();

View File

@@ -7,7 +7,6 @@ import lombok.Getter;
import java.util.Arrays;
// TODO @puhui999这个枚举要不改成 CrmSceneTypeEnum
/**
* CRM 列表检索场景
*
@@ -15,14 +14,13 @@ import java.util.Arrays;
*/
@Getter
@AllArgsConstructor
public enum CrmSceneEnum implements IntArrayValuable {
public enum CrmSceneTypeEnum implements IntArrayValuable {
OWNER(1, "我负责的"),
FOLLOW(2, "关注"),
// TODO @puhui999还有一个我参与的
INVOLVED(2, "参与"),
SUBORDINATE(3, "下属负责的");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneEnum::getType).toArray();
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneTypeEnum::getType).toArray();
/**
* 场景类型
@@ -37,8 +35,8 @@ public enum CrmSceneEnum implements IntArrayValuable {
return ObjUtil.equal(OWNER.getType(), type);
}
public static boolean isFollow(Integer type) {
return ObjUtil.equal(FOLLOW.getType(), type);
public static boolean isInvolved(Integer type) {
return ObjUtil.equal(INVOLVED.getType(), type);
}
public static boolean isSubordinate(Integer type) {

View File

@@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.crm.enums.customer;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -18,24 +20,30 @@ public enum CrmCustomerLimitConfigTypeEnum implements IntArrayValuable {
/**
* 拥有客户数限制
*/
CUSTOMER_QUANTITY_LIMIT(1, "拥有客户数限制"),
CUSTOMER_OWNER_LIMIT(1, "拥有客户数限制"),
/**
* 锁定客户数限制
*/
CUSTOMER_LOCK_LIMIT(2, "锁定客户数限制"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLimitConfigTypeEnum::getCode).toArray();
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLimitConfigTypeEnum::getType).toArray();
/**
* 状态
*/
private final Integer code;
private final Integer type;
/**
* 状态名
*/
private final String name;
public static String getNameByType(Integer type) {
CrmCustomerLimitConfigTypeEnum typeEnum = CollUtil.findOne(CollUtil.newArrayList(CrmCustomerLimitConfigTypeEnum.values()),
item -> ObjUtil.equal(item.type, type));
return typeEnum == null ? null : typeEnum.getName();
}
@Override
public int[] array() {
return ARRAYS;

View File

@@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.crm.enums.message;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.Arrays;
/**
* CRM 联系状态
*
* @author dhb52
*/
@RequiredArgsConstructor
@Getter
public enum CrmContactStatusEnum implements IntArrayValuable {
NEEDED_TODAY(1, "今日需联系"),
EXPIRED(2, "已逾期"),
ALREADY_CONTACT(3, "已联系"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmContactStatusEnum::getType).toArray();
/**
* 状态
*/
private final Integer type;
/**
* 状态名
*/
private final String name;
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.crm.enums.permission;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* Crm 数据权限角色枚举
*
* @author HUIHUI
*/
@Getter
@AllArgsConstructor
public enum CrmPermissionRoleCodeEnum {
CRM_ADMIN("crm_admin", "CRM 管理员");
/**
* 角色标识
*/
private String code;
/**
* 角色名称
*/
private String name;
}

View File

@@ -60,6 +60,10 @@
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-dict</artifactId>
</dependency>
<!-- Test 测试相关 -->
<dependency>

View File

@@ -1,15 +1,15 @@
package cn.iocoder.yudao.module.crm.controller.admin.business;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
@@ -22,22 +22,24 @@ import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
@Tag(name = "管理后台 - 商机")
@RestController
@@ -47,27 +49,24 @@ public class CrmBusinessController {
@Resource
private CrmBusinessService businessService;
@Resource
private CrmCustomerService customerService;
@Resource
private CrmBusinessStatusTypeService businessStatusTypeService;
@Resource
private CrmBusinessStatusService businessStatusService;
@PostMapping("/create")
@Operation(summary = "创建商机")
@PreAuthorize("@ss.hasPermission('crm:business:create')")
public CommonResult<Long> createBusiness(@Valid @RequestBody CrmBusinessCreateReqVO createReqVO) {
public CommonResult<Long> createBusiness(@Valid @RequestBody CrmBusinessSaveReqVO createReqVO) {
return success(businessService.createBusiness(createReqVO, getLoginUserId()));
}
@PutMapping("/update")
@Operation(summary = "更新商机")
@PreAuthorize("@ss.hasPermission('crm:business:update')")
public CommonResult<Boolean> updateBusiness(@Valid @RequestBody CrmBusinessUpdateReqVO updateReqVO) {
public CommonResult<Boolean> updateBusiness(@Valid @RequestBody CrmBusinessSaveReqVO updateReqVO) {
businessService.updateBusiness(updateReqVO);
return success(true);
}
@@ -87,7 +86,26 @@ public class CrmBusinessController {
@PreAuthorize("@ss.hasPermission('crm:business:query')")
public CommonResult<CrmBusinessRespVO> getBusiness(@RequestParam("id") Long id) {
CrmBusinessDO business = businessService.getBusiness(id);
return success(CrmBusinessConvert.INSTANCE.convert(business));
return success(BeanUtils.toBean(business, CrmBusinessRespVO.class));
}
@GetMapping("/list-by-ids")
@Operation(summary = "获得商机列表")
@Parameter(name = "ids", description = "编号", required = true, example = "[1024]")
@PreAuthorize("@ss.hasPermission('crm:business:query')")
public CommonResult<List<CrmBusinessRespVO>> getContactListByIds(@RequestParam("ids") List<Long> ids) {
return success(BeanUtils.toBean(businessService.getBusinessList(ids, getLoginUserId()), CrmBusinessRespVO.class));
}
@GetMapping("/simple-all-list")
@Operation(summary = "获得联系人的精简列表")
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
public CommonResult<List<CrmBusinessRespVO>> getSimpleContactList() {
CrmBusinessPageReqVO reqVO = new CrmBusinessPageReqVO();
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(reqVO, getLoginUserId());
return success(convertList(pageResult.getList(), business -> // 只返回 id、name 字段
new CrmBusinessRespVO().setId(business.getId()).setName(business.getName())));
}
@GetMapping("/page")
@@ -95,60 +113,25 @@ public class CrmBusinessController {
@PreAuthorize("@ss.hasPermission('crm:business:query')")
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) {
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(pageVO, getLoginUserId());
if (CollUtil.isEmpty(pageResult.getList())) {
return success(PageResult.empty(pageResult.getTotal()));
}
// 处理客户名称回显
// TODO @ljlleo可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
Set<Long> customerIds = pageResult.getList().stream()
.map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds);
// 处理商机状态类型名称回显
Set<Long> statusTypeIds = pageResult.getList().stream()
.map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet());
CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO();
queryStatusTypeVO.setIdList(statusTypeIds);
List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO);
// 处理商机状态名称回显
Set<Long> statusIds = pageResult.getList().stream()
.map(CrmBusinessDO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet());
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
queryVO.setIdList(statusIds);
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList));
return success(buildBusinessDetailPageResult(pageResult));
}
@GetMapping("/page-by-customer")
@Operation(summary = "获得商机分页,基于指定客户")
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmContractPageReqVO pageReqVO) {
Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空");
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomer(pageReqVO);
// 处理客户名称回显
// TODO @ljlleo可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
Set<Long> customerIds = pageResult.getList().stream()
.map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds);
// 处理商机状态类型名称回显
Set<Long> statusTypeIds = pageResult.getList().stream()
.map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet());
CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO();
queryStatusTypeVO.setIdList(statusTypeIds);
List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO);
// 处理商机状态名称回显
Set<Long> statusIds = pageResult.getList().stream()
.map(CrmBusinessDO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet());
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
queryVO.setIdList(statusIds);
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList));
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmBusinessPageReqVO pageReqVO) {
if (pageReqVO.getCustomerId() == null) {
throw exception(CUSTOMER_NOT_EXISTS);
}
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomerId(pageReqVO);
return success(buildBusinessDetailPageResult(pageResult));
}
@GetMapping("/pool-page")
@Operation(summary = "获得商机公海分页")
@GetMapping("/page-by-contact")
@Operation(summary = "获得联系人的商机分页")
@PreAuthorize("@ss.hasPermission('crm:business:query')")
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPoolPage(@Valid CrmBusinessPageReqVO pageVO) {
// TODO puhui999: 等数据权限完善后再实现
return null;
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessContactPage(@Valid CrmBusinessPageReqVO pageReqVO) {
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByContact(pageReqVO);
return success(buildBusinessDetailPageResult(pageResult));
}
@GetMapping("/export-excel")
@@ -157,10 +140,30 @@ public class CrmBusinessController {
@OperateLog(type = EXPORT)
public void exportBusinessExcel(@Valid CrmBusinessPageReqVO exportReqVO,
HttpServletResponse response) throws IOException {
exportReqVO.setPageSize(PAGE_SIZE_NONE);
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(exportReqVO, getLoginUserId());
// 导出 Excel
ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class,
CrmBusinessConvert.INSTANCE.convertList02(pageResult.getList()));
ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessRespVO.class,
buildBusinessDetailPageResult(pageResult).getList());
}
/**
* 构建详细的商机分页结果
*
* @param pageResult 简单的商机分页结果
* @return 详细的商机分页结果
*/
private PageResult<CrmBusinessRespVO> buildBusinessDetailPageResult(PageResult<CrmBusinessDO> pageResult) {
if (CollUtil.isEmpty(pageResult.getList())) {
return PageResult.empty(pageResult.getTotal());
}
List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.getBusinessStatusTypeList(
convertSet(pageResult.getList(), CrmBusinessDO::getStatusTypeId));
List<CrmBusinessStatusDO> statusList = businessStatusService.getBusinessStatusList(
convertSet(pageResult.getList(), CrmBusinessDO::getStatusId));
List<CrmCustomerDO> customerList = customerService.getCustomerList(
convertSet(pageResult.getList(), CrmBusinessDO::getCustomerId));
return CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList);
}
@PutMapping("/transfer")

View File

@@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
@@ -24,19 +25,17 @@ import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@@ -85,13 +84,13 @@ public class CrmBusinessStatusTypeController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
public CommonResult<CrmBusinessStatusTypeRespVO> getBusinessStatusType(@RequestParam("id") Long id) {
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeService.getBusinessStatusType(id);
CrmBusinessStatusTypeDO statusType = businessStatusTypeService.getBusinessStatusType(id);
// 处理状态回显
// TODO @ljlleo可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
// TODO @lzxhqs可以在 businessStatusService 加个 getBusinessStatusListByTypeId 方法,直接返回 List<CrmBusinessStatusDO> 哈,常用的,尽量封装个简单易懂的方法,不用追求绝对通用哈;
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
queryVO.setTypeId(id);
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType, statusList));
return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(statusType, statusList));
}
@GetMapping("/page")
@@ -100,12 +99,7 @@ public class CrmBusinessStatusTypeController {
public CommonResult<PageResult<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageReqVO) {
PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO);
// 处理部门回显
// TODO @ljlleo可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
Set<Long> deptIds = pageResult.getList().stream()
.map(CrmBusinessStatusTypeDO::getDeptIds)
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.collect(Collectors.toSet());
Set<Long> deptIds = CollectionUtils.convertSetByFlatMap(pageResult.getList(), CrmBusinessStatusTypeDO::getDeptIds,Collection::stream);
List<DeptRespDTO> deptList = deptApi.getDeptList(deptIds);
return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult, deptList));
}

View File

@@ -1,16 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 商机创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO {
// TODO @ljileo新建的时候应该可以传递添加的产品
}

View File

@@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -18,4 +20,11 @@ public class CrmBusinessPageReqVO extends PageParam {
@Schema(description = "客户编号", example = "10795")
private Long customerId;
@Schema(description = "联系人编号", example = "10795")
private Long contactId;
@Schema(description = "场景类型", example = "1")
@InEnum(CrmSceneTypeEnum.class)
private Integer sceneType; // 场景类型,为 null 时则表示全部
}

View File

@@ -1,18 +1,59 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 商机 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmBusinessRespVO extends CrmBusinessBaseVO {
public class CrmBusinessRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
private Long id;
@Schema(description = "商机名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@NotNull(message = "商机名称不能为空")
private String name;
@Schema(description = "商机状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714")
@NotNull(message = "商机状态类型不能为空")
private Long statusTypeId;
@Schema(description = "商机状态编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "商机状态不能为空")
private Long statusId;
@Schema(description = "下次联系时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime contactNextTime;
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10299")
@NotNull(message = "客户不能为空")
private Long customerId;
@Schema(description = "预计成交日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime dealTime;
@Schema(description = "商机金额", example = "12371")
private Integer price;
// TODO @ljileo折扣使用 Integer 类型,存储时,默认 * 100展示的时候前端需要 / 100避免精度丢失问题
@Schema(description = "整单折扣")
private Integer discountPercent;
@Schema(description = "产品总金额", example = "12025")
private BigDecimal productPrice;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;

View File

@@ -1,57 +1,85 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.product.CrmBusinessProductSaveReqVO;
import cn.iocoder.yudao.module.crm.enums.business.CrmBizEndStatus;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerParseFunction;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 商机 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Schema(description = "管理后台 - CRM 商机创建/更新 Request VO")
@Data
public class CrmBusinessBaseVO {
public class CrmBusinessSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
private Long id;
@Schema(description = "商机名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
@DiffLogField(name = "商机名称")
@NotNull(message = "商机名称不能为空")
private String name;
@Schema(description = "商机状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714")
@DiffLogField(name = "商机状态")
@NotNull(message = "商机状态类型不能为空")
private Long statusTypeId;
@Schema(description = "商机状态编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@DiffLogField(name = "商机状态")
@NotNull(message = "商机状态不能为空")
private Long statusId;
@Schema(description = "下次联系时间")
@DiffLogField(name = "下次联系时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime contactNextTime;
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10299")
@DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME)
@NotNull(message = "客户不能为空")
private Long customerId;
@Schema(description = "预计成交日期")
@DiffLogField(name = "预计成交日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime dealTime;
@Schema(description = "商机金额", example = "12371")
@DiffLogField(name = "商机金额")
private Integer price;
// TODO @ljileo折扣使用 Integer 类型存储时默认 * 100展示的时候前端需要 / 100避免精度丢失问题
// TODO @lzxhqs折扣使用 Integer 类型存储时默认 * 100展示的时候前端需要 / 100避免精度丢失问题
@Schema(description = "整单折扣")
@DiffLogField(name = "整单折扣")
private Integer discountPercent;
@Schema(description = "产品总金额", example = "12025")
@DiffLogField(name = "产品总金额")
private BigDecimal productPrice;
@Schema(description = "备注", example = "随便")
@DiffLogField(name = "备注")
private String remark;
@Schema(description = "结束状态", example = "1")
@InEnum(CrmBizEndStatus.class)
private Integer endStatus;
// TODO @lzxhqs不设置默认 new ArrayList<>()一般 pojo 不设置默认值哈
@Schema(description = "商机产品列表")
private List<CrmBusinessProductSaveReqVO> products = new ArrayList<>();
@Schema(description = "联系人编号", example = "110")
private Long contactId; // 使用场景联系人详情添加商机时如果需要关联两者需要传递 contactId 字段
}

View File

@@ -2,16 +2,15 @@ package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 商机转移 Request VO")
@Data
public class CrmBusinessTransferReqVO {
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
@NotNull(message = "联系人编号不能为空")
@NotNull(message = "商机编号不能为空")
private Long id;
/**

View File

@@ -1,23 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessBaseVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 商机更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
@NotNull(message = "主键不能为空")
private Long id;
// TODO @ljileo修改的时候应该可以传递添加的产品
}

View File

@@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.product;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
// TODO @lzxhqs这个类如果没用到可以考虑删除哈
@Schema(description = "管理后台 - 商机产品分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmBusinessProductPageReqVO extends PageParam {
}

View File

@@ -0,0 +1,11 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.product;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 商机产品关联 Response VO")
@Data
@ExcelIgnoreUnannotated
public class CrmBusinessProductRespVO {
}

View File

@@ -0,0 +1,51 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.product;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.math.BigDecimal;
@Schema(description = "管理后台 - CRM 商机产品关联表 创建/更新 Request VO")
@Data
public class CrmBusinessProductSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
private Long id;
// TODO @lzxhqs这个字段应该是 Long 类型
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "商机编号不能为空")
private Integer businessId;
// TODO @lzxhqs这个字段应该是 Long 类型
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "产品编号不能为空")
private Integer productId;
@Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "产品单价不能为空")
private BigDecimal price;
@Schema(description = "销售价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "销售价格不能为空")
private BigDecimal salesPrice;
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "数量不能为空")
private BigDecimal num;
@Schema(description = "折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "折扣不能为空")
private BigDecimal discount;
@Schema(description = "小计(折扣后价格)", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "小计(折扣后价格)不能为空")
private BigDecimal subtotal;
// TODO @lzxhqs字符串用 @NotEmpty因为要考虑 "" 前端搞了这个玩意
@Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "单位不能为空")
private String unit;
}

View File

@@ -21,11 +21,11 @@ public class CrmBusinessStatusSaveReqVO {
@NotEmpty(message = "状态名不能为空")
private String name;
// TODO @lilleopercent 应该是 Integer
// TODO @lzxhqspercent 应该是 Integer
@Schema(description = "赢单率")
private String percent;
// TODO @lilleo:这个是不是不用前端新增和修改的时候传递,交给顺序计算出来,存储起来就好了;
// TODO @lzxhqs:这个是不是不用前端新增和修改的时候传递,交给顺序计算出来,存储起来就好了;
@Schema(description = "排序")
private Integer sort;

View File

@@ -19,11 +19,11 @@ public class CrmBusinessStatusTypeSaveReqVO {
@NotEmpty(message = "状态类型名不能为空")
private String name;
// TODO @lzxhqs VO 里面,我们不使用默认值哈。这里 Lists.newArrayList() 看看怎么去掉。上面 deptIds 也是类似噢
@Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED)
private List<Long> deptIds = Lists.newArrayList();
// TODO @ljlleo VO 里面,我们不使用默认值哈。这里 Lists.newArrayList() 看看怎么去掉。上面 deptIds 也是类似噢
@Schema(description = "商机状态集合", requiredMode = Schema.RequiredMode.REQUIRED)
private List<CrmBusinessStatusSaveReqVO> statusList = Lists.newArrayList();
private List<CrmBusinessStatusSaveReqVO> statusList;
}

View File

@@ -2,27 +2,29 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
import cn.iocoder.yudao.module.crm.service.clue.CrmClueService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "管理后台 - 线索")
@RestController
@@ -36,14 +38,14 @@ public class CrmClueController {
@PostMapping("/create")
@Operation(summary = "创建线索")
@PreAuthorize("@ss.hasPermission('crm:clue:create')")
public CommonResult<Long> createClue(@Valid @RequestBody CrmClueCreateReqVO createReqVO) {
public CommonResult<Long> createClue(@Valid @RequestBody CrmClueSaveReqVO createReqVO) {
return success(clueService.createClue(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新线索")
@PreAuthorize("@ss.hasPermission('crm:clue:update')")
public CommonResult<Boolean> updateClue(@Valid @RequestBody CrmClueUpdateReqVO updateReqVO) {
public CommonResult<Boolean> updateClue(@Valid @RequestBody CrmClueSaveReqVO updateReqVO) {
clueService.updateClue(updateReqVO);
return success(true);
}
@@ -63,27 +65,43 @@ public class CrmClueController {
@PreAuthorize("@ss.hasPermission('crm:clue:query')")
public CommonResult<CrmClueRespVO> getClue(@RequestParam("id") Long id) {
CrmClueDO clue = clueService.getClue(id);
return success(CrmClueConvert.INSTANCE.convert(clue));
return success(BeanUtils.toBean(clue, CrmClueRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得线索分页")
@PreAuthorize("@ss.hasPermission('crm:clue:query')")
public CommonResult<PageResult<CrmClueRespVO>> getCluePage(@Valid CrmCluePageReqVO pageVO) {
PageResult<CrmClueDO> pageResult = clueService.getCluePage(pageVO);
return success(CrmClueConvert.INSTANCE.convertPage(pageResult));
PageResult<CrmClueDO> pageResult = clueService.getCluePage(pageVO, getLoginUserId());
return success(BeanUtils.toBean(pageResult, CrmClueRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出线索 Excel")
@PreAuthorize("@ss.hasPermission('crm:clue:export')")
@OperateLog(type = EXPORT)
public void exportClueExcel(@Valid CrmClueExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<CrmClueDO> list = clueService.getClueList(exportReqVO);
public void exportClueExcel(@Valid CrmCluePageReqVO pageReqVO, HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PAGE_SIZE_NONE);
List<CrmClueDO> list = clueService.getCluePage(pageReqVO, getLoginUserId()).getList();
// 导出 Excel
List<CrmClueExcelVO> datas = CrmClueConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "线索.xls", "数据", CrmClueExcelVO.class, datas);
List<CrmClueRespVO> datas = BeanUtils.toBean(list, CrmClueRespVO.class);
ExcelUtils.write(response, "线索.xls", "数据", CrmClueRespVO.class, datas);
}
@PutMapping("/transfer")
@Operation(summary = "线索转移")
@PreAuthorize("@ss.hasPermission('crm:clue:update')")
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmClueTransferReqVO reqVO) {
clueService.transferClue(reqVO, getLoginUserId());
return success(true);
}
@PostMapping("/transform")
@Operation(summary = "线索转化为客户")
@PreAuthorize("@ss.hasPermission('crm:clue:update')")
public CommonResult<Boolean> translateCustomer(@Valid @RequestBody CrmClueTransformReqVO reqVO) {
clueService.translateCustomer(reqVO, getLoginUserId());
return success(Boolean.TRUE);
}
}

View File

@@ -1,14 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 线索创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmClueCreateReqVO extends CrmClueBaseVO {
}

View File

@@ -1,66 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
/**
* 线索 Excel VO
*
* @author Wanwan
*/
@Data
public class CrmClueExcelVO {
@ExcelProperty("编号")
private Long id;
@ExcelProperty(value = "转化状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean transformStatus;
@ExcelProperty(value = "跟进状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean followUpStatus;
@ExcelProperty("线索名称")
private String name;
// TODO 这里需要导出成客户名称
@ExcelProperty("客户id")
private Long customerId;
@ExcelProperty("下次联系时间")
private LocalDateTime contactNextTime;
@ExcelProperty("电话")
private String telephone;
@ExcelProperty("手机号")
private String mobile;
@ExcelProperty("地址")
private String address;
@ExcelProperty("负责人的用户编号")
private Long ownerUserId;
@ExcelProperty("最后跟进时间")
private LocalDateTime contactLastTime;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -1,52 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.time.LocalDateTime;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 线索 Excel 导出 Request VO参数和 CrmCluePageReqVO 是一致的")
@Data
public class CrmClueExportReqVO {
@Schema(description = "转化状态", example = "true")
private Boolean transformStatus;
@Schema(description = "跟进状态", example = "true")
private Boolean followUpStatus;
@Schema(description = "线索名称", example = "线索xxx")
private String name;
@Schema(description = "客户id", example = "520")
private Long customerId;
@Schema(description = "下次联系时间", example = "2023-10-18 01:00:00")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] contactNextTime;
@Schema(description = "电话", example = "18000000000")
private String telephone;
@Schema(description = "手机号", example = "18000000000")
private String mobile;
@Schema(description = "地址", example = "北京市海淀区")
private String address;
@Schema(description = "负责人的用户编号", example = "27199")
private Long ownerUserId;
@Schema(description = "最后跟进时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] contactLastTime;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -21,4 +23,11 @@ public class CrmCluePageReqVO extends PageParam {
@Schema(description = "手机号", example = "18000000000")
private String mobile;
@Schema(description = "场景类型", example = "1")
@InEnum(CrmSceneTypeEnum.class)
private Integer sceneType; // 场景类型,为 null 时则表示全部
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
private Boolean pool; // null 则表示为不是公海数据
}

View File

@@ -1,27 +1,80 @@
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.Data;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 线索 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmClueRespVO extends CrmClueBaseVO {
@ExcelIgnoreUnannotated
public class CrmClueRespVO {
@Schema(description = "编号,主键自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969")
@ExcelProperty("编号")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
@Schema(description = "转化状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@ExcelProperty(value = "转化状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean transformStatus;
@Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@ExcelProperty(value = "跟进状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean followUpStatus;
@Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx")
@ExcelProperty("线索名称")
private String name;
@Schema(description = "客户 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520")
// TODO 这里需要导出成客户名称
@ExcelProperty("客户id")
private Long customerId;
@Schema(description = "下次联系时间", example = "2023-10-18 01:00:00")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ExcelProperty("下次联系时间")
private LocalDateTime contactNextTime;
@Schema(description = "电话", example = "18000000000")
@ExcelProperty("电话")
private String telephone;
@Schema(description = "手机号", example = "18000000000")
@ExcelProperty("手机号")
private String mobile;
@Schema(description = "地址", example = "北京市海淀区")
@ExcelProperty("地址")
private String address;
@Schema(description = "负责人编号")
@ExcelProperty("负责人的用户编号")
private Long ownerUserId;
@Schema(description = "最后跟进时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ExcelProperty("最后跟进时间")
private LocalDateTime contactLastTime;
@Schema(description = "备注", example = "随便")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -3,30 +3,25 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
import cn.iocoder.yudao.framework.common.validation.Mobile;
import cn.iocoder.yudao.framework.common.validation.Telephone;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 线索 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Schema(description = "管理后台 - CRM 线索 创建/更新 Request VO")
@Data
public class CrmClueBaseVO {
public class CrmClueSaveReqVO {
@Schema(description = "编号", example = "10969")
private Long id;
@Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx")
@NotEmpty(message = "线索名称不能为空")
private String name;
@Schema(description = "客户 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520")
@NotNull(message = "客户不能为空")
private Long customerId;
@Schema(description = "下次联系时间", example = "2023-10-18 01:00:00")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime contactNextTime;
@@ -46,6 +41,9 @@ public class CrmClueBaseVO {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime contactLastTime;
@Schema(description = "负责人编号", example = "2048")
private Long ownerUserId;
@Schema(description = "备注", example = "随便")
private String remark;

View File

@@ -0,0 +1,25 @@
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Schema(description = "管理后台 - 线索转移 Request VO")
@Data
public class CrmClueTransferReqVO {
@Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
@NotNull(message = "线索编号不能为空")
private Long id;
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
@NotNull(message = "新负责人的用户编号不能为空")
private Long newOwnerUserId;
@Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@InEnum(value = CrmPermissionLevelEnum.class)
private Integer oldOwnerPermissionLevel; // 老负责人加入团队后的权限级别。如果 null 说明移除
}

View File

@@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import java.util.Set;
@Schema(description = "管理后台 - 线索转化为客户 Request VO")
@Data
public class CrmClueTransformReqVO {
@Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024, 1025]")
@NotEmpty(message = "线索编号不能为空")
private Set<Long> ids;
}

View File

@@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 线索更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmClueUpdateReqVO extends CrmClueBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969")
@NotNull(message = "编号不能为空")
private Long id;
}

View File

@@ -4,32 +4,36 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.NumberUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;
import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService;
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2PageReqDTO;
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2RespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import com.google.common.collect.Lists;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
@@ -38,10 +42,11 @@ import java.util.stream.Stream;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CONTACT_TYPE;
@Tag(name = "管理后台 - CRM 联系人")
@RestController
@@ -54,21 +59,26 @@ public class CrmContactController {
private CrmContactService contactService;
@Resource
private CrmCustomerService customerService;
@Resource
private CrmContactBusinessService contactBusinessLinkService;
@Resource
private AdminUserApi adminUserApi;
@Resource
private OperateLogApi operateLogApi;
@PostMapping("/create")
@Operation(summary = "创建联系人")
@PreAuthorize("@ss.hasPermission('crm:contact:create')")
public CommonResult<Long> createContact(@Valid @RequestBody CrmContactCreateReqVO createReqVO) {
public CommonResult<Long> createContact(@Valid @RequestBody CrmContactSaveReqVO createReqVO) {
return success(contactService.createContact(createReqVO, getLoginUserId()));
}
@PutMapping("/update")
@Operation(summary = "更新联系人")
@OperateLog(enable = false)
@PreAuthorize("@ss.hasPermission('crm:contact:update')")
public CommonResult<Boolean> updateContact(@Valid @RequestBody CrmContactUpdateReqVO updateReqVO) {
public CommonResult<Boolean> updateContact(@Valid @RequestBody CrmContactSaveReqVO updateReqVO) {
contactService.updateContact(updateReqVO);
return success(true);
}
@@ -95,34 +105,45 @@ public class CrmContactController {
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(CollUtil.removeNull(Lists.newArrayList(
NumberUtil.parseLong(contact.getCreator()), contact.getOwnerUserId())));
// 2. 获取客户信息
List<CrmCustomerDO> customerList = customerService.getCustomerList(Collections.singletonList(contact.getCustomerId()));
List<CrmCustomerDO> customerList = customerService.getCustomerList(
Collections.singletonList(contact.getCustomerId()));
// 3. 直属上级
List<CrmContactDO> parentContactList = contactService.getContactList(Collections.singletonList(contact.getParentId()));
return success(ContactConvert.INSTANCE.convert(contact, userMap, customerList, parentContactList));
List<CrmContactDO> parentContactList = contactService.getContactList(
Collections.singletonList(contact.getParentId()), getLoginUserId());
return success(CrmContactConvert.INSTANCE.convert(contact, userMap, customerList, parentContactList));
}
@GetMapping("/list-by-ids")
@Operation(summary = "获得联系人列表")
@Parameter(name = "ids", description = "编号", required = true, example = "[1024]")
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
public CommonResult<List<CrmContactRespVO>> getContactListByIds(@RequestParam("ids") List<Long> ids) {
return success(BeanUtils.toBean(contactService.getContactList(ids, getLoginUserId()), CrmContactRespVO.class));
}
@GetMapping("/simple-all-list")
@Operation(summary = "获得联系人列表")
@Operation(summary = "获得联系人的精简列表")
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
public CommonResult<List<CrmContactSimpleRespVO>> getSimpleContactList() {
List<CrmContactDO> list = contactService.getContactList();
return success(ContactConvert.INSTANCE.convertAllList(list));
public CommonResult<List<CrmContactRespVO>> getSimpleContactList() {
List<CrmContactDO> list = contactService.getSimpleContactList(getLoginUserId());
return success(convertList(list, contact -> // 只返回 id、name 字段
new CrmContactRespVO().setId(contact.getId()).setName(contact.getName())));
}
@GetMapping("/page")
@Operation(summary = "获得联系人分页")
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
public CommonResult<PageResult<CrmContactRespVO>> getContactPage(@Valid CrmContactPageReqVO pageVO) {
PageResult<CrmContactDO> pageResult = contactService.getContactPage(pageVO);
return success(convertDetailContactPage(pageResult));
PageResult<CrmContactDO> pageResult = contactService.getContactPage(pageVO, getLoginUserId());
return success(buildContactDetailPage(pageResult));
}
@GetMapping("/page-by-customer")
@Operation(summary = "获得联系人分页,基于指定客户")
public CommonResult<PageResult<CrmContactRespVO>> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) {
Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空");
PageResult<CrmContactDO> pageResult = contactService.getContactPageByCustomer(pageVO);
return success(convertDetailContactPage(pageResult));
PageResult<CrmContactDO> pageResult = contactService.getContactPageByCustomerId(pageVO);
return success(buildContactDetailPage(pageResult));
}
@GetMapping("/export-excel")
@@ -131,19 +152,30 @@ public class CrmContactController {
@OperateLog(type = EXPORT)
public void exportContactExcel(@Valid CrmContactPageReqVO exportReqVO,
HttpServletResponse response) throws IOException {
exportReqVO.setPageNo(PageParam.PAGE_SIZE_NONE);
PageResult<CrmContactDO> pageResult = contactService.getContactPage(exportReqVO);
exportReqVO.setPageNo(PAGE_SIZE_NONE);
PageResult<CrmContactDO> pageResult = contactService.getContactPage(exportReqVO, getLoginUserId());
ExcelUtils.write(response, "联系人.xls", "数据", CrmContactRespVO.class,
convertDetailContactPage(pageResult).getList());
buildContactDetailPage(pageResult).getList());
}
@GetMapping("/operate-log-page")
@Operation(summary = "获得客户操作日志")
@PreAuthorize("@ss.hasPermission('crm:customer:query')")
public CommonResult<PageResult<OperateLogV2RespDTO>> getCustomerOperateLog(@RequestParam("bizId") Long bizId) {
OperateLogV2PageReqDTO reqVO = new OperateLogV2PageReqDTO();
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
reqVO.setBizType(CRM_CONTACT_TYPE);
reqVO.setBizId(bizId);
return success(operateLogApi.getOperateLogPage(BeanUtils.toBean(reqVO, OperateLogV2PageReqDTO.class)));
}
/**
* 转换成详细的联系人分页,即读取关联信息
* 构建详细的联系人分页结果
*
* @param pageResult 联系人分页
* @return 详细的联系人分页
* @param pageResult 简单的联系人分页结果
* @return 详细的联系人分页结果
*/
private PageResult<CrmContactRespVO> convertDetailContactPage(PageResult<CrmContactDO> pageResult) {
private PageResult<CrmContactRespVO> buildContactDetailPage(PageResult<CrmContactDO> pageResult) {
List<CrmContactDO> contactList = pageResult.getList();
if (CollUtil.isEmpty(contactList)) {
return PageResult.empty(pageResult.getTotal());
@@ -156,8 +188,34 @@ public class CrmContactController {
contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
// 3. 直属上级
List<CrmContactDO> parentContactList = contactService.getContactList(
convertSet(contactList, CrmContactDO::getParentId));
return ContactConvert.INSTANCE.convertPage(pageResult, userMap, crmCustomerDOList, parentContactList);
convertSet(contactList, CrmContactDO::getParentId), getLoginUserId());
return CrmContactConvert.INSTANCE.convertPage(pageResult, userMap, crmCustomerDOList, parentContactList);
}
@PutMapping("/transfer")
@Operation(summary = "联系人转移")
@PreAuthorize("@ss.hasPermission('crm:contact:update')")
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmContactTransferReqVO reqVO) {
contactService.transferContact(reqVO, getLoginUserId());
return success(true);
}
// ================== 关联/取关联系人 ===================
@PostMapping("/create-business-list")
@Operation(summary = "创建联系人与商机的关联")
@PreAuthorize("@ss.hasPermission('crm:contact:create-business')")
public CommonResult<Boolean> createContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO createReqVO) {
contactBusinessLinkService.createContactBusinessList(createReqVO);
return success(true);
}
@DeleteMapping("/delete-business-list")
@Operation(summary = "删除联系人与联系人的关联")
@PreAuthorize("@ss.hasPermission('crm:contact:delete-business')")
public CommonResult<Boolean> deleteContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO deleteReqVO) {
contactBusinessLinkService.deleteContactBusinessList(deleteReqVO);
return success(true);
}
}

View File

@@ -1,103 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import cn.iocoder.yudao.framework.common.validation.Mobile;
import cn.iocoder.yudao.framework.common.validation.Telephone;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
// TODO zyna要不按照新的干掉这个 basevo都放子类里
/**
* CRM 联系人 Base VO提供给添加、修改、详细的子 VO 使用
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
*/
@Data
@ExcelIgnoreUnannotated
public class CrmContactBaseVO {
@ExcelProperty(value = "姓名",order = 1)
@Schema(description = "姓名", example = "芋艿")
@NotNull(message = "姓名不能为空")
private String name;
@Schema(description = "客户编号", example = "10795")
private Long customerId;
@ExcelProperty(value = "性别", converter = DictConvert.class, order = 3)
@DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_SEX)
@Schema(description = "性别")
private Integer sex;
@Schema(description = "职位")
@ExcelProperty(value = "职位", order = 3)
private String post;
@Schema(description = "是否关键决策人")
@ExcelProperty(value = "是否关键决策人", converter = DictConvert.class, order = 3)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean master;
@Schema(description = "直属上级", example = "23457")
private Long parentId;
@Schema(description = "手机号",example = "1387171766")
@Mobile
@ExcelProperty(value = "手机号",order = 4)
private String mobile;
@Schema(description = "座机",example = "021-0029922")
@Telephone
@ExcelProperty(value = "座机",order = 4)
private String telephone;
@ExcelProperty(value = "QQ",order = 4)
@Schema(description = "QQ",example = "197272662")
private Long qq;
@ExcelProperty(value = "微信",order = 4)
@Schema(description = "微信",example = "zzz3883")
private String wechat;
@Schema(description = "电子邮箱",example = "1111@22.com")
@Email
@ExcelProperty(value = "邮箱",order = 4)
private String email;
@ExcelProperty(value = "地址",order = 5)
@Schema(description = "地址")
private String address;
@Schema(description = "下次联系时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
@ExcelProperty(value = "下次联系时间",order = 6)
private LocalDateTime nextTime;
@Schema(description = "备注", example = "你说的对")
@ExcelProperty(value = "备注",order = 6)
private String remark;
@Schema(description = "最后跟进时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ExcelProperty(value = "最后跟进时间",order = 6)
private LocalDateTime lastTime;
@Schema(description = "负责人用户编号", example = "14334")
@NotNull(message = "负责人不能为空")
private Long ownerUserId;
@Schema(description = "地区编号", example = "20158")
private Integer areaId;
}

View File

@@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
@Schema(description = "管理后台 - CRM 联系人商机 Request VO") // 用于关联,取消关联的操作
@Data
public class CrmContactBusinessReqVO {
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878")
@NotNull(message="联系人不能为空")
private Long contactId;
@Schema(description = "商机编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638")
@NotEmpty(message="商机不能为空")
private List<Long> businessIds;
}

View File

@@ -1,14 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - CRM 联系人创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmContactCreateReqVO extends CrmContactBaseVO {
}

View File

@@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -33,4 +35,8 @@ public class CrmContactPageReqVO extends PageParam {
@Schema(description = "微信", example = "zzZ98373")
private String wechat;
@Schema(description = "场景类型", example = "1")
@InEnum(CrmSceneTypeEnum.class)
private Integer sceneType; // 场景类型,为 null 时则表示全部
}

View File

@@ -1,28 +1,90 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.Data;
import lombok.ToString;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - CRM 联系人 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ExcelIgnoreUnannotated
public class CrmContactRespVO extends CrmContactBaseVO {
public class CrmContactRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
private Long id;
@Schema(description = "创建时间")
@ExcelProperty(value = "创建时间", order = 8)
private LocalDateTime createTime;
@Schema(description = "姓名", example = "芋艿")
@ExcelProperty(value = "姓名", order = 1)
private String name;
@Schema(description = "更新时间")
@ExcelProperty(value = "更新时间", order = 8)
private LocalDateTime updateTime;
@Schema(description = "客户编号", example = "10795")
private Long customerId;
@Schema(description = "性别")
@ExcelProperty(value = "性别", converter = DictConvert.class, order = 3)
@DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_SEX)
private Integer sex;
@Schema(description = "职位")
@ExcelProperty(value = "职位", order = 3)
private String post;
@Schema(description = "是否关键决策人")
@ExcelProperty(value = "是否关键决策人", converter = DictConvert.class, order = 3)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean master;
@Schema(description = "直属上级", example = "23457")
private Long parentId;
@Schema(description = "手机号", example = "1387171766")
@ExcelProperty(value = "手机号", order = 4)
private String mobile;
@Schema(description = "电话", example = "021-0029922")
@ExcelProperty(value = "电话", order = 4)
private String telephone;
@Schema(description = "QQ", example = "197272662")
@ExcelProperty(value = "QQ", order = 4)
private Long qq;
@Schema(description = "微信", example = "zzz3883")
@ExcelProperty(value = "微信", order = 4)
private String wechat;
@Schema(description = "电子邮箱", example = "1111@22.com")
@ExcelProperty(value = "邮箱", order = 4)
private String email;
@Schema(description = "地区编号", example = "20158")
private Integer areaId;
@Schema(description = "地址")
@ExcelProperty(value = "地址", order = 5)
private String detailAddress;
@Schema(description = "备注", example = "你说的对")
@ExcelProperty(value = "备注", order = 6)
private String remark;
@Schema(description = "负责人用户编号", example = "14334")
private Long ownerUserId;
@Schema(description = "最后跟进时间")
@ExcelProperty(value = "最后跟进时间", order = 6)
private LocalDateTime contactLastTime;
@Schema(description = "下次联系时间")
@ExcelProperty(value = "下次联系时间", order = 6)
private LocalDateTime contactNextTime;
@Schema(description = "创建人", example = "25682")
private String creator;
@@ -31,7 +93,7 @@ public class CrmContactRespVO extends CrmContactBaseVO {
@ExcelProperty(value = "创建人", order = 8)
private String creatorName;
@ExcelProperty(value = "客户名称",order = 2)
@ExcelProperty(value = "客户名称", order = 2)
@Schema(description = "客户名字", example = "test")
private String customerName;

View File

@@ -0,0 +1,103 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import cn.iocoder.yudao.framework.common.validation.Mobile;
import cn.iocoder.yudao.framework.common.validation.Telephone;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.*;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - CRM 联系人创建/更新 Request VO")
@Data
public class CrmContactSaveReqVO {
@Schema(description = "主键", example = "3167")
private Long id;
@Schema(description = "姓名", example = "芋艿")
@NotNull(message = "姓名不能为空")
@DiffLogField(name = "姓名")
private String name;
@Schema(description = "客户编号", example = "10795")
@DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME)
private Long customerId;
@Schema(description = "性别")
@DiffLogField(name = "性别", function = SysSexParseFunction.NAME)
private Integer sex;
@Schema(description = "职位")
@DiffLogField(name = "职位")
private String post;
@Schema(description = "是否关键决策人")
@DiffLogField(name = "关键决策人", function = SysBooleanParseFunction.NAME)
private Boolean master;
@Schema(description = "直属上级", example = "23457")
@DiffLogField(name = "直属上级", function = CrmContactParseFunction.NAME)
private Long parentId;
@Schema(description = "手机号", example = "1387171766")
@Mobile
@DiffLogField(name = "手机号")
private String mobile;
@Schema(description = "电话", example = "021-0029922")
@Telephone
@DiffLogField(name = "电话")
private String telephone;
@Schema(description = "QQ", example = "197272662")
@DiffLogField(name = "QQ")
private Long qq;
@Schema(description = "微信", example = "zzz3883")
@DiffLogField(name = "微信")
private String wechat;
@Schema(description = "电子邮箱", example = "1111@22.com")
@DiffLogField(name = "邮箱")
@Email
private String email;
@Schema(description = "地区编号", example = "20158")
@DiffLogField(name = "所在地", function = SysAreaParseFunction.NAME)
private Integer areaId;
@Schema(description = "地址")
@DiffLogField(name = "地址")
private String detailAddress;
@Schema(description = "备注", example = "你说的对")
@DiffLogField(name = "备注")
private String remark;
@Schema(description = "负责人用户编号", example = "14334")
@NotNull(message = "负责人不能为空")
@DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME)
private Long ownerUserId;
@Schema(description = "最后跟进时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@DiffLogField(name = "最后跟进时间")
private LocalDateTime contactLastTime;
@Schema(description = "下次联系时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
@DiffLogField(name = "下次联系时间")
private LocalDateTime contactNextTime;
@Schema(description = "关联商机 ID", example = "122233")
private Long businessId; // 注意:该字段用于在【商机】详情界面「新建联系人」时,自动进行关联
}

View File

@@ -1,18 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
@Schema(description = "管理后台 - CRM 联系人的精简 Response VO")
@Data
@ToString(callSuper = true)
public class CrmContactSimpleRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
private Long id;
@Schema(description = "姓名", example = "芋艿")
private String name;
}

View File

@@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - CRM 联系人更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmContactUpdateReqVO extends CrmContactBaseVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
@NotNull(message = "主键不能为空")
private Long id;
}

View File

@@ -1,115 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
import cn.iocoder.yudao.module.crm.service.contactbusinesslink.CrmContactBusinessLinkService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
@Tag(name = "管理后台 - CRM 联系人商机关联")
@RestController
@RequestMapping("/crm/contact-business-link")
@Validated
public class CrmContactBusinessLinkController {
@Resource
private CrmContactBusinessLinkService contactBusinessLinkService;
@Resource
private CrmBusinessService crmBusinessService;
// TODO @zynacreateContactBusinessLink 和 createContactBusinessLinkBatch 是不是合并成一个接口contactId、List<businessId>
@PostMapping("/create")
@Operation(summary = "创建联系人商机关联")
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
public CommonResult<Long> createContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO createReqVO) {
return success(contactBusinessLinkService.createContactBusinessLink(createReqVO));
}
@PostMapping("/create-batch")
@Operation(summary = "创建联系人商机关联")
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
@Transactional(rollbackFor = Exception.class)
public CommonResult<Boolean> createContactBusinessLinkBatch(
@Valid @RequestBody List<CrmContactBusinessLinkSaveReqVO> createReqVO) {
createReqVO.stream().forEach(item -> {
CrmBusinessDO crmBusinessDO = crmBusinessService.getBusiness(item.getBusinessId());
if(crmBusinessDO == null){
throw exception(BUSINESS_NOT_EXISTS);
}
});
contactBusinessLinkService.createContactBusinessLinkBatch(createReqVO);
return success(true);
}
// TODO @zyna这个接口是不是可以删除掉了哈应该不存在更新。
@PutMapping("/update")
@Operation(summary = "更新联系人商机关联")
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:update')")
public CommonResult<Boolean> updateContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO updateReqVO) {
contactBusinessLinkService.updateContactBusinessLink(updateReqVO);
return success(true);
}
// TODO @zyna删除是不是传递 ids
@DeleteMapping("/delete-batch")
@Operation(summary = "批量删除联系人商机关联")
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:delete')")
public CommonResult<Boolean> deleteContactBusinessLinkBatch(@Valid @RequestBody List<CrmContactBusinessLinkSaveReqVO> deleteList) {
contactBusinessLinkService.deleteContactBusinessLink(deleteList);
return success(true);
}
// TODO @zyna这个接口是不是可以删除掉了哈应该不存在单个读取
@GetMapping("/get")
@Operation(summary = "获得联系人商机关联")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
public CommonResult<CrmContactBusinessLinkRespVO> getContactBusinessLink(@RequestParam("id") Long id) {
CrmContactBusinessLinkDO contactBusinessLink = contactBusinessLinkService.getContactBusinessLink(id);
return success(BeanUtils.toBean(contactBusinessLink, CrmContactBusinessLinkRespVO.class));
}
// TODO @zyna这个可以转化下使用客户编号去查询就是使用 CrmBusinessController 的 getBusinessPageByCustomer 接口;目的是:复用
@GetMapping("/page-by-contact")
@Operation(summary = "获得联系人商机关联")
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
public CommonResult<PageResult<CrmBusinessRespVO>> getContactBusinessLinkByContact(
@Valid CrmContactBusinessLinkPageReqVO pageReqVO) {
PageResult<CrmBusinessRespVO> contactBusinessLink = contactBusinessLinkService.getContactBusinessLinkPageByContact(pageReqVO);
return success(contactBusinessLink);
}
// TODO @zyna这个优化下搞到 CrmBusinessController 里去,加一个 CrmBusinessController 的 getBusinessPageByContact 接口;目的是:
@GetMapping("/page")
@Operation(summary = "获得联系人商机关联分页")
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
public CommonResult<PageResult<CrmContactBusinessLinkRespVO>> getContactBusinessLinkPage(
@Valid CrmContactBusinessLinkPageReqVO pageReqVO) {
PageResult<CrmContactBusinessLinkDO> pageResult = contactBusinessLinkService.getContactBusinessLinkPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, CrmContactBusinessLinkRespVO.class));
}
// TODO @zyna最终梳理完后应该就 2 个接口,要不直接合并到 CrmContactController 中,不作为独立模块,就关联、接触关联。其实和 user 设置它有哪些岗位、部门是类似的。
}

View File

@@ -1,30 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - CRM 联系人商机关联分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmContactBusinessLinkPageReqVO extends PageParam {
@Schema(description = "联系人编号", example = "20878")
private Long contactId;
@Schema(description = "商机编号", example = "7638")
private Long businessId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -1,26 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - CRM 联系人商机关联 Response VO")
@Data
public class CrmContactBusinessLinkRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220")
@ExcelProperty("主键")
private Long id;
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878")
private Long contactId;
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638")
private Long businessId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@@ -1,23 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - CRM 联系人商机关联新增/修改 Request VO")
@Data
public class CrmContactBusinessLinkSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220")
private Long id;
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878")
@NotNull(message="联系人不能为空")
private Long contactId;
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638")
@NotNull(message="商机不能为空")
private Long businessId;
}

View File

@@ -5,10 +5,11 @@ import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*;
import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert;
import cn.iocoder.yudao.module.crm.convert.contract.CrmContractConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
@@ -18,13 +19,13 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -53,14 +54,14 @@ public class CrmContractController {
@PostMapping("/create")
@Operation(summary = "创建合同")
@PreAuthorize("@ss.hasPermission('crm:contract:create')")
public CommonResult<Long> createContract(@Valid @RequestBody CrmContractCreateReqVO createReqVO) {
public CommonResult<Long> createContract(@Valid @RequestBody CrmContractSaveReqVO createReqVO) {
return success(contractService.createContract(createReqVO, getLoginUserId()));
}
@PutMapping("/update")
@Operation(summary = "更新合同")
@PreAuthorize("@ss.hasPermission('crm:contract:update')")
public CommonResult<Boolean> updateContract(@Valid @RequestBody CrmContractUpdateReqVO updateReqVO) {
public CommonResult<Boolean> updateContract(@Valid @RequestBody CrmContractSaveReqVO updateReqVO) {
contractService.updateContract(updateReqVO);
return success(true);
}
@@ -78,25 +79,25 @@ public class CrmContractController {
@Operation(summary = "获得合同")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('crm:contract:query')")
public CommonResult<ContractRespVO> getContract(@RequestParam("id") Long id) {
public CommonResult<CrmContractRespVO> getContract(@RequestParam("id") Long id) {
CrmContractDO contract = contractService.getContract(id);
return success(ContractConvert.INSTANCE.convert(contract));
return success(BeanUtils.toBean(contract, CrmContractRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得合同分页")
@PreAuthorize("@ss.hasPermission('crm:contract:query')")
public CommonResult<PageResult<ContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) {
PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO);
return success(convertDetailContractPage(pageResult));
public CommonResult<PageResult<CrmContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) {
PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO, getLoginUserId());
return success(buildContractDetailPage(pageResult));
}
@GetMapping("/page-by-customer")
@Operation(summary = "获得联系人分页,基于指定客户")
public CommonResult<PageResult<ContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) {
public CommonResult<PageResult<CrmContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) {
Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空");
PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomer(pageVO);
return success(convertDetailContractPage(pageResult));
PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomerId(pageVO);
return success(buildContractDetailPage(pageResult));
}
@GetMapping("/export-excel")
@@ -105,19 +106,19 @@ public class CrmContractController {
@OperateLog(type = EXPORT)
public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO,
HttpServletResponse response) throws IOException {
PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO);
PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO, getLoginUserId());
// 导出 Excel
ExcelUtils.write(response, "合同.xls", "数据", CrmContractExcelVO.class,
ContractConvert.INSTANCE.convertList02(pageResult.getList()));
BeanUtils.toBean(pageResult.getList(), CrmContractExcelVO.class));
}
/**
* 转换成详细的合同分页,即读取关联信息
* 构建详细的合同分页结果
*
* @param pageResult 合同分页
* @return 详细的合同分页
* @param pageResult 简单的合同分页结果
* @return 详细的合同分页结果
*/
private PageResult<ContractRespVO> convertDetailContractPage(PageResult<CrmContractDO> pageResult) {
private PageResult<CrmContractRespVO> buildContractDetailPage(PageResult<CrmContractDO> pageResult) {
List<CrmContractDO> contactList = pageResult.getList();
if (CollUtil.isEmpty(contactList)) {
return PageResult.empty(pageResult.getTotal());
@@ -128,7 +129,7 @@ public class CrmContractController {
// 2. 获取创建人、负责人列表
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList,
contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
return ContractConvert.INSTANCE.convertPage(pageResult, userMap, customerList);
return CrmContractConvert.INSTANCE.convertPage(pageResult, userMap, customerList);
}
@PutMapping("/transfer")

View File

@@ -1,37 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - CRM 合同 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ContractRespVO extends CrmContractBaseVO {
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
@Schema(description = "创建人", example = "25682")
private String creator;
@Schema(description = "创建人名字", example = "test")
private String creatorName;
@Schema(description = "客户名字", example = "test")
private String customerName;
@Schema(description = "负责人", example = "test")
private String ownerUserName;
@Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
private Integer auditStatus;
}

View File

@@ -1,14 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - CRM 合同创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmContractCreateReqVO extends CrmContractBaseVO {
}

View File

@@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -24,4 +26,8 @@ public class CrmContractPageReqVO extends PageParam {
@Schema(description = "商机编号", example = "10864")
private Long businessId;
@Schema(description = "场景类型", example = "1")
@InEnum(CrmSceneTypeEnum.class)
private Integer sceneType; // 场景类型,为 null 时则表示全部
}

View File

@@ -0,0 +1,116 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - CRM 合同 Response VO")
@Data
@ExcelIgnoreUnannotated
public class CrmContractRespVO {
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
@ExcelProperty("合同编号")
private Long id;
@Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("合同名称")
private String name;
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18336")
@ExcelProperty("客户编号")
private Long customerId;
@Schema(description = "商机编号", example = "10864")
@ExcelProperty("商机编号")
private Long businessId;
@Schema(description = "工作流编号", example = "1043")
@ExcelProperty("工作流编号")
private Long processInstanceId;
@Schema(description = "下单日期", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("下单日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime orderDate;
@Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17144")
@ExcelProperty("负责人的用户编号")
private Long ownerUserId;
// TODO @芋艿:未来应该支持自动生成;
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20230101")
@ExcelProperty("合同编号")
private String no;
@Schema(description = "开始时间")
@ExcelProperty("开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime startTime;
@Schema(description = "结束时间")
@ExcelProperty("结束时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime endTime;
@Schema(description = "合同金额", example = "5617")
@ExcelProperty("合同金额")
private Integer price;
@Schema(description = "整单折扣")
@ExcelProperty("整单折扣")
private Integer discountPercent;
@Schema(description = "产品总金额", example = "19510")
@ExcelProperty("产品总金额")
private Integer productPrice;
@Schema(description = "联系人编号", example = "18546")
@ExcelProperty("联系人编号")
private Long contactId;
@Schema(description = "公司签约人", example = "14036")
@ExcelProperty("公司签约人")
private Long signUserId;
@Schema(description = "最后跟进时间")
@ExcelProperty("最后跟进时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime contactLastTime;
@Schema(description = "备注", example = "你猜")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime createTime;
@Schema(description = "创建人", example = "25682")
@ExcelProperty("创建人")
private String creator;
@Schema(description = "创建人名字", example = "test")
@ExcelProperty("创建人名字")
private String creatorName;
@Schema(description = "客户名字", example = "test")
@ExcelProperty("客户名字")
private String customerName;
@Schema(description = "负责人", example = "test")
@ExcelProperty("负责人")
private String ownerUserName;
@Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
@ExcelProperty("审批状态")
private Integer auditStatus;
}

View File

@@ -1,81 +1,101 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmBusinessParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmContactParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAdminUserParseFunction;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 合同 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Schema(description = "管理后台 - CRM 合同创建/更新 Request VO")
@Data
public class CrmContractBaseVO {
public class CrmContractSaveReqVO {
// TODO @dhb52类似 no 字段的 example 要写xia
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
private Long id;
@Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@DiffLogField(name = "合同名称")
@NotNull(message = "合同名称不能为空")
private String name;
// TODO @dhb52这个必须传递
@Schema(description = "客户编号", example = "18336")
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18336")
@DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME)
@NotNull(message = "客户编号不能为空")
private Long customerId;
@Schema(description = "商机编号", example = "10864")
@DiffLogField(name = "商机", function = CrmBusinessParseFunction.NAME)
private Long businessId;
@Schema(description = "工作流编号", example = "1043")
@DiffLogField(name = "工作流编号")
private Long processInstanceId;
// TODO @dhb52这个必须传递
@Schema(description = "下单日期")
@Schema(description = "下单日期", requiredMode = Schema.RequiredMode.REQUIRED)
@DiffLogField(name = "下单日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@NotNull(message = "下单日期不能为空")
private LocalDateTime orderDate;
// TODO @dhb52这个必须传递
@Schema(description = "负责人的用户编号", example = "17144")
@Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17144")
@DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME)
@NotNull(message = "负责人不能为空")
private Long ownerUserId;
// TODO @芋艿未来应该支持自动生成
// TODO @dhb52这个必须传递
@Schema(description = "合同编号")
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20230101")
@DiffLogField(name = "合同编号")
@NotNull(message = "合同编号不能为空")
private String no;
@Schema(description = "开始时间")
@DiffLogField(name = "开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime startTime;
@Schema(description = "结束时间")
@DiffLogField(name = "结束时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime endTime;
@Schema(description = "合同金额", example = "5617")
@DiffLogField(name = "合同金额")
private Integer price;
@Schema(description = "整单折扣")
@DiffLogField(name = "整单折扣")
private Integer discountPercent;
@Schema(description = "产品总金额", example = "19510")
@DiffLogField(name = "产品总金额")
private Integer productPrice;
@Schema(description = "联系人编号", example = "18546")
@DiffLogField(name = "联系人", function = CrmContactParseFunction.NAME)
private Long contactId;
@Schema(description = "公司签约人", example = "14036")
@DiffLogField(name = "公司签约人", function = SysAdminUserParseFunction.NAME)
private Long signUserId;
@Schema(description = "最后跟进时间")
@DiffLogField(name = "最后跟进时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime contactLastTime;
@Schema(description = "备注", example = "你猜")
@DiffLogField(name = "备注")
private String remark;
// TODO @dhb52增加一个 status 字段具体有哪些值你来枚举下主要页面上有个草稿提交审核的流程可以看看然后要对接工作流这块也可以看看不确定的地方问我
}

View File

@@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - CRM 合同更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmContractUpdateReqVO extends CrmContractBaseVO {
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
@NotNull(message = "合同编号不能为空")
private Long id;
}

View File

@@ -1,6 +1,16 @@
### 请求 /update
GET {{baseUrl}}/crm/customer/page?pageNo=1&pageSize=10&name="张三"
### 请求 /transfer
PUT {{baseUrl}}/crm/customer/transfer
Content-Type: application/-id: {{adminTenentId}}json
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}
tenant
{
"id": 10,
"newOwnerUserId": 127
}
### 自定义日志记录结果
### 操作日志 ===> OperateLogV2CreateReqBO(traceId=, userId=1, userType=2, module=CRM-客户, name=客户转移, bizId=10, content=把客户【张三】的负责人从【芋道源码(15612345678)】变更为了【tttt】, requestMethod=PUT, requestUrl=/admin-api/crm/customer/transfer, userIp=127.0.0.1, userAgent=Apache-HttpClient/4.5.14 (Java/17.0.9))
### diff 日志
### | 操作日志 ===> OperateLogV2CreateReqBO(traceId=, userId=1, userType=2, module=CRM-客户, name=更新客户, bizId=11, content=更新了客户【所属行业】从【H 住宿和餐饮业】修改为【D 电力、热力、燃气及水生产和供应业】【客户等级】从【C 非优先客户】修改为【A (重点客户)】;【客户来源】从【线上咨询】修改为【预约上门】, requestMethod=PUT, requestUrl=/admin-api/crm/customer/update, userIp=0:0:0:0:0:0:0:1, userAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36)

View File

@@ -1,41 +1,50 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2PageReqDTO;
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2RespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.mapstruct.ap.internal.util.Collections;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CUSTOMER_TYPE;
@Tag(name = "管理后台 - CRM 客户")
@RestController
@@ -45,30 +54,33 @@ public class CrmCustomerController {
@Resource
private CrmCustomerService customerService;
@Resource
private CrmCustomerPoolConfigService customerPoolConfigService;
@Resource
private DeptApi deptApi;
@Resource
private AdminUserApi adminUserApi;
@Resource
private OperateLogApi operateLogApi;
@PostMapping("/create")
@Operation(summary = "创建客户")
@PreAuthorize("@ss.hasPermission('crm:customer:create')")
public CommonResult<Long> createCustomer(@Valid @RequestBody CrmCustomerCreateReqVO createReqVO) {
public CommonResult<Long> createCustomer(@Valid @RequestBody CrmCustomerSaveReqVO createReqVO) {
return success(customerService.createCustomer(createReqVO, getLoginUserId()));
}
@PutMapping("/update")
@Operation(summary = "更新客户")
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
public CommonResult<Boolean> updateCustomer(@Valid @RequestBody CrmCustomerUpdateReqVO updateReqVO) {
public CommonResult<Boolean> updateCustomer(@Valid @RequestBody CrmCustomerSaveReqVO updateReqVO) {
customerService.updateCustomer(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除客户")
@Parameter(name = "id", description = "编号", required = true)
@Parameter(name = "id", description = "客户编号", required = true)
@PreAuthorize("@ss.hasPermission('crm:customer:delete')")
public CommonResult<Boolean> deleteCustomer(@RequestParam("id") Long id) {
customerService.deleteCustomer(id);
@@ -103,10 +115,50 @@ public class CrmCustomerController {
}
// 2. 拼接数据
Map<Long, Long> poolDayMap = Boolean.TRUE.equals(pageVO.getPool()) ? null :
getPoolDayMap(pageResult.getList()); // 客户界面,需要查看距离进入公海的时间
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
convertSetByFlatMap(pageResult.getList(), user -> Stream.of(Long.parseLong(user.getCreator()), user.getOwnerUserId())));
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap));
return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap));
}
/**
* 获取距离进入公海的时间
*
* @param customerList 客户列表
* @return Map<key 客户编号, value 距离进入公海的时间>
*/
private Map<Long, Long> getPoolDayMap(List<CrmCustomerDO> customerList) {
CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig();
if (poolConfig == null || !poolConfig.getEnabled()) {
return MapUtil.empty();
}
return convertMap(customerList, CrmCustomerDO::getId, customer -> {
// 1.1 未成交放入公海天数
long dealExpireDay = 0;
if (!customer.getDealStatus()) {
dealExpireDay = poolConfig.getDealExpireDays() - LocalDateTimeUtils.between(customer.getCreateTime());
}
// 1.2 未跟进放入公海天数
LocalDateTime lastTime = ObjUtil.defaultIfNull(customer.getContactLastTime(), customer.getCreateTime());
long contactExpireDay = poolConfig.getContactExpireDays() - LocalDateTimeUtils.between(lastTime);
if (contactExpireDay < 0) {
contactExpireDay = 0;
}
// 2. 返回最小的天数
return Math.min(dealExpireDay, contactExpireDay);
});
}
@GetMapping(value = "/list-all-simple")
@Operation(summary = "获取客户精简信息列表", description = "只包含有读权限的客户,主要用于前端的下拉选项")
public CommonResult<List<CrmCustomerRespVO>> getSimpleDeptList() {
CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO();
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
List<CrmCustomerDO> list = customerService.getCustomerPage(reqVO, getLoginUserId()).getList();
return success(convertList(list, customer -> // 只返回 id、name 精简字段
new CrmCustomerRespVO().setId(customer.getId()).setName(customer.getName())));
}
@GetMapping("/export-excel")
@@ -118,24 +170,35 @@ public class CrmCustomerController {
pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页
List<CrmCustomerDO> list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList();
// 导出 Excel
List<CrmCustomerExcelVO> datas = CrmCustomerConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerExcelVO.class, datas);
ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerRespVO.class,
BeanUtils.toBean(list, CrmCustomerRespVO.class));
}
@PutMapping("/transfer")
@Operation(summary = "客户转移")
@Operation(summary = "转移客户")
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) {
customerService.transferCustomer(reqVO, getLoginUserId());
return success(true);
}
// TODO @Joey单独建一个属于自己业务的 ReqVO因为前端如果模拟请求是不是可以更新其它字段了
@GetMapping("/operate-log-page")
@Operation(summary = "获得客户操作日志")
@Parameter(name = "id", description = "客户编号", required = true)
@PreAuthorize("@ss.hasPermission('crm:customer:query')")
public CommonResult<PageResult<OperateLogV2RespDTO>> getCustomerOperateLog(@RequestParam("id") Long id) {
OperateLogV2PageReqDTO reqDTO = new OperateLogV2PageReqDTO();
reqDTO.setPageSize(PAGE_SIZE_NONE); // 不分页
reqDTO.setBizType(CRM_CUSTOMER_TYPE);
reqDTO.setBizId(id);
return success(operateLogApi.getOperateLogPage(reqDTO));
}
@PutMapping("/lock")
@Operation(summary = "锁定/解锁客户")
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
public CommonResult<Boolean> lockCustomer(@Valid @RequestBody CrmCustomerUpdateReqVO updateReqVO) {
customerService.lockCustomer(updateReqVO);
public CommonResult<Boolean> lockCustomer(@Valid @RequestBody CrmCustomerLockReqVO lockReqVO) {
customerService.lockCustomer(lockReqVO, getLoginUserId());
return success(true);
}
@@ -155,32 +218,16 @@ public class CrmCustomerController {
@Parameter(name = "ids", description = "编号数组", required = true, example = "1,2,3")
@PreAuthorize("@ss.hasPermission('crm:customer:receive')")
public CommonResult<Boolean> receiveCustomer(@RequestParam(value = "ids") List<Long> ids) {
customerService.receiveCustomer(ids, getLoginUserId());
customerService.receiveCustomer(ids, getLoginUserId(), Boolean.TRUE);
return success(true);
}
@PutMapping("/distribute")
@Operation(summary = "分配公海给对应负责人")
@Parameters({
@Parameter(name = "ids", description = "客户编号数组", required = true, example = "1,2,3"),
@Parameter(name = "ownerUserId", description = "分配的负责人编号", required = true, example = "12345")
})
@PreAuthorize("@ss.hasPermission('crm:customer:distribute')")
public CommonResult<Boolean> distributeCustomer(@RequestParam(value = "ids") List<Long> ids,
@RequestParam(value = "ownerUserId") Long ownerUserId) {
// 领取公海数据
customerService.receiveCustomer(ids, ownerUserId);
public CommonResult<Boolean> distributeCustomer(@Valid @RequestBody CrmCustomerDistributeReqVO distributeReqVO) {
customerService.receiveCustomer(distributeReqVO.getIds(), distributeReqVO.getOwnerUserId(), Boolean.FALSE);
return success(true);
}
// TODO 芋艿:这个接口要调整下
@GetMapping("/query-all-list")
@Operation(summary = "查询客户列表")
@PreAuthorize("@ss.hasPermission('crm:customer:all')")
public CommonResult<List<CrmCustomerQueryAllRespVO>> queryAll() {
List<CrmCustomerDO> crmCustomerDOList = customerService.getCustomerList();
List<CrmCustomerQueryAllRespVO> data = CrmCustomerConvert.INSTANCE.convertQueryAll(crmCustomerDOList);
return success(data);
}
}

View File

@@ -3,10 +3,9 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO;
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigService;
@@ -17,12 +16,12 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Collection;
import java.util.Map;
@@ -46,14 +45,14 @@ public class CrmCustomerLimitConfigController {
@PostMapping("/create")
@Operation(summary = "创建客户限制配置")
@PreAuthorize("@ss.hasPermission('crm:customer-limit-config:create')")
public CommonResult<Long> createCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigCreateReqVO createReqVO) {
public CommonResult<Long> createCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigSaveReqVO createReqVO) {
return success(customerLimitConfigService.createCustomerLimitConfig(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新客户限制配置")
@PreAuthorize("@ss.hasPermission('crm:customer-limit-config:update')")
public CommonResult<Boolean> updateCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigUpdateReqVO updateReqVO) {
public CommonResult<Boolean> updateCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigSaveReqVO updateReqVO) {
customerLimitConfigService.updateCustomerLimitConfig(updateReqVO);
return success(true);
}

View File

@@ -1,20 +1,19 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - CRM 客户公海配置")
@@ -30,8 +29,8 @@ public class CrmCustomerPoolConfigController {
@Operation(summary = "获取客户公海规则设置")
@PreAuthorize("@ss.hasPermission('crm:customer-pool-config:query')")
public CommonResult<CrmCustomerPoolConfigRespVO> getCustomerPoolConfig() {
CrmCustomerPoolConfigDO customerPoolConfig = customerPoolConfigService.getCustomerPoolConfig();
return success(CrmCustomerConvert.INSTANCE.convert(customerPoolConfig));
CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig();
return success(BeanUtils.toBean(poolConfig, CrmCustomerPoolConfigRespVO.class));
}
@PutMapping("/save")

View File

@@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - CRM 客户创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmCustomerCreateReqVO extends CrmCustomerBaseVO {
@Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
@NotNull(message = "负责人不能为空")
private Long ownerUserId;
}

View File

@@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
@Schema(description = "管理后台 - CRM 客户分配公海给对应负责人 Request VO")
@Data
public class CrmCustomerDistributeReqVO {
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024]")
@NotEmpty(message = "客户编号不能为空")
private List<Long> ids;
@Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "负责人不能为空")
private Long ownerUserId;
}

View File

@@ -1,93 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
// TODO 芋艿:导出最后做,等基本确认的差不多之后;
/**
* CRM 客户 Excel VO
*
* @author Wanwan
*/
@Data
public class CrmCustomerExcelVO {
@ExcelProperty("编号")
private Long id;
@ExcelProperty("客户名称")
private String name;
@ExcelProperty(value = "跟进状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean followUpStatus;
@ExcelProperty(value = "锁定状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean lockStatus;
@ExcelProperty(value = "成交状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean dealStatus;
@ExcelProperty(value = "所属行业", converter = DictConvert.class)
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY)
private Integer industryId;
@ExcelProperty(value = "客户等级", converter = DictConvert.class)
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL)
private Integer level;
@ExcelProperty(value = "客户来源", converter = DictConvert.class)
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE)
private Integer source;
@ExcelProperty("手机")
private String mobile;
@ExcelProperty("电话")
private String telephone;
@ExcelProperty("网址")
private String website;
@ExcelProperty("QQ")
private String qq;
@ExcelProperty("wechat")
private String wechat;
@ExcelProperty("email")
private String email;
@ExcelProperty("客户描述")
private String description;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("负责人的用户编号")
private Long ownerUserId;
@ExcelProperty("地区编号")
private Integer areaId;
@ExcelProperty("详细地址")
private String detailAddress;
@ExcelProperty("最后跟进时间")
private LocalDateTime contactLastTime;
@ExcelProperty("下次联系时间")
private LocalDateTime contactNextTime;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - CRM 客户锁定/解锁 Request VO")
@Data
public class CrmCustomerLockReqVO {
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
private Long id;
@Schema(description = "客户锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
private Boolean lockStatus;
}

View File

@@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
import cn.iocoder.yudao.module.crm.framework.vo.CrmBasePageReqVO;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -10,7 +12,7 @@ import lombok.ToString;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmCustomerPageReqVO extends CrmBasePageReqVO {
public class CrmCustomerPageReqVO extends PageParam {
@Schema(description = "客户名称", example = "赵六")
private String name;
@@ -27,4 +29,11 @@ public class CrmCustomerPageReqVO extends CrmBasePageReqVO {
@Schema(description = "客户来源", example = "1")
private Integer source;
@Schema(description = "场景类型", example = "1")
@InEnum(CrmSceneTypeEnum.class)
private Integer sceneType; // 场景类型,为 null 时则表示全部
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
private Boolean pool; // null 则表示为不是公海数据
}

View File

@@ -1,17 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
// TODO 芋艿:这块要统一下;
@Schema(description = "管理后台 - CRM 全部客户 Response VO")
@Data
public class CrmCustomerQueryAllRespVO{
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
private Long id;
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
private String name;
}

View File

@@ -1,9 +1,12 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@@ -12,45 +15,124 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Schema(description = "管理后台 - CRM 客户 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmCustomerRespVO extends CrmCustomerBaseVO {
@ExcelIgnoreUnannotated
public class CrmCustomerRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
@ExcelProperty("编号")
private Long id;
@Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
@ExcelProperty("客户名称")
private String name;
@Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
@ExcelProperty(value = "跟进状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean followUpStatus;
@Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
@ExcelProperty(value = "锁定状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean lockStatus;
@Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
@ExcelProperty(value = "成交状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
private Boolean dealStatus;
@Schema(description = "所属行业", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
@ExcelProperty(value = "所属行业", converter = DictConvert.class)
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY)
private Integer industryId;
@Schema(description = "客户等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
@ExcelProperty(value = "客户等级", converter = DictConvert.class)
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL)
private Integer level;
@Schema(description = "客户来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
@ExcelProperty(value = "客户来源", converter = DictConvert.class)
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE)
private Integer source;
@Schema(description = "负责人的用户编号", example = "25682")
@ExcelProperty("手机")
private String mobile;
@Schema(description = "负责人的用户编号", example = "25682")
@ExcelProperty("电话")
private String telephone;
@Schema(description = "负责人的用户编号", example = "25682")
@ExcelProperty("网址")
private String website;
@Schema(description = "负责人的用户编号", example = "25682")
@ExcelProperty("QQ")
private String qq;
@Schema(description = "负责人的用户编号", example = "25682")
@ExcelProperty("wechat")
private String wechat;
@Schema(description = "负责人的用户编号", example = "25682")
@ExcelProperty("email")
private String email;
@Schema(description = "负责人的用户编号", example = "25682")
@ExcelProperty("客户描述")
private String description;
@Schema(description = "负责人的用户编号", example = "25682")
@ExcelProperty("备注")
private String remark;
@Schema(description = "负责人的用户编号", example = "25682")
@ExcelProperty("负责人的用户编号")
private Long ownerUserId;
@Schema(description = "负责人名字", example = "25682")
@ExcelProperty("负责人名字")
private String ownerUserName;
@Schema(description = "负责人部门")
@ExcelProperty("负责人部门")
private String ownerUserDeptName;
@Schema(description = "地区编号", example = "1024")
@ExcelProperty("地区编号")
private Integer areaId;
@Schema(description = "地区名称", example = "北京市")
@ExcelProperty("地区名称")
private String areaName;
@Schema(description = "详细地址", example = "北京市成华大道")
@ExcelProperty("详细地址")
private String detailAddress;
@Schema(description = "最后跟进时间")
@ExcelProperty("最后跟进时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime contactLastTime;
@Schema(description = "下次联系时间")
@ExcelProperty("下次联系时间")
private LocalDateTime contactNextTime;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("更新时间")
private LocalDateTime updateTime;
@Schema(description = "创建人")
@Schema(description = "创建人", example = "1024")
@ExcelProperty("创建人")
private String creator;
@Schema(description = "创建人名字")
@Schema(description = "创建人名字", example = "芋道源码")
@ExcelProperty("创建人名字")
private String creatorName;
@Schema(description = "距离加入公海时间", example = "1")
private Long poolDay;
}

View File

@@ -3,78 +3,104 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.framework.common.validation.Mobile;
import cn.iocoder.yudao.framework.common.validation.Telephone;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerIndustryParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerLevelParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerSourceParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAreaParseFunction;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY;
/**
* 客户 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Schema(description = "管理后台 - CRM 客户新增/修改 Request VO")
@Data
public class CrmCustomerBaseVO {
public class CrmCustomerSaveReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
private Long id;
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@DiffLogField(name = "客户名称")
@NotEmpty(message = "客户名称不能为空")
private String name;
@Schema(description = "所属行业", example = "1")
@DiffLogField(name = "所属行业", function = CrmCustomerIndustryParseFunction.NAME)
@DictFormat(CRM_CUSTOMER_INDUSTRY)
private Integer industryId;
@Schema(description = "客户等级", example = "2")
@DiffLogField(name = "客户等级", function = CrmCustomerLevelParseFunction.NAME)
@InEnum(CrmCustomerLevelEnum.class)
private Integer level;
@Schema(description = "客户来源", example = "3")
@DiffLogField(name = "客户来源", function = CrmCustomerSourceParseFunction.NAME)
private Integer source;
@Schema(description = "手机", example = "18000000000")
@DiffLogField(name = "手机")
@Mobile
private String mobile;
@Schema(description = "电话", example = "18000000000")
@DiffLogField(name = "电话")
@Telephone
private String telephone;
@Schema(description = "网址", example = "https://www.baidu.com")
@DiffLogField(name = "网址")
private String website;
@Schema(description = "QQ", example = "123456789")
@DiffLogField(name = "QQ")
@Size(max = 20, message = "QQ长度不能超过 20 个字符")
private String qq;
@Schema(description = "wechat", example = "123456789")
@Schema(description = "微信", example = "123456789")
@DiffLogField(name = "微信")
@Size(max = 255, message = "微信长度不能超过 255 个字符")
private String wechat;
@Schema(description = "email", example = "123456789@qq.com")
@Schema(description = "邮箱", example = "123456789@qq.com")
@DiffLogField(name = "邮箱")
@Email(message = "邮箱格式不正确")
@Size(max = 255, message = "邮箱长度不能超过 255 个字符")
private String email;
@Schema(description = "客户描述", example = "任意文字")
@DiffLogField(name = "客户描述")
@Size(max = 4096, message = "客户描述长度不能超过 4096 个字符")
private String description;
@Schema(description = "备注", example = "随便")
@DiffLogField(name = "备注")
private String remark;
@Schema(description = "地区编号", example = "20158")
@DiffLogField(name = "地区编号", function = SysAreaParseFunction.NAME)
private Integer areaId;
@Schema(description = "详细地址", example = "北京市海淀区")
@DiffLogField(name = "详细地址")
private String detailAddress;
@Schema(description = "下次联系时间")
@DiffLogField(name = "下次联系时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime contactNextTime;
@Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
private Long ownerUserId;
}

View File

@@ -2,16 +2,15 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - CRM 客户转移 Request VO")
@Data
public class CrmCustomerTransferReqVO {
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
@NotNull(message = "联系人编号不能为空")
@NotNull(message = "客户编号不能为空")
private Long id;
/**

View File

@@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - CRM 客户更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmCustomerUpdateReqVO extends CrmCustomerBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
@NotNull(message = "编号不能为空")
private Long id;
}

View File

@@ -1,33 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 客户限制配置 Base VO提供给添加、修改、详细的子 VO 使用
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
*/
@Data
public class CrmCustomerLimitConfigBaseVO {
@Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "规则类型不能为空")
private Integer type;
@Schema(description = "规则适用人群")
private List<Long> userIds;
@Schema(description = "规则适用部门")
private List<Long> deptIds;
@Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384")
@NotNull(message = "数量上限不能为空")
private Integer maxCount;
@Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)")
private Boolean dealCountEnabled;
}

View File

@@ -1,14 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 客户限制配置创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmCustomerLimitConfigCreateReqVO extends CrmCustomerLimitConfigBaseVO {
}

View File

@@ -4,21 +4,32 @@ import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 客户限制配置 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmCustomerLimitConfigRespVO extends CrmCustomerLimitConfigBaseVO {
public class CrmCustomerLimitConfigRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930")
private Long id;
@Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private Integer type;
@Schema(description = "规则适用人群")
private List<Long> userIds;
@Schema(description = "规则适用部门")
private List<Long> deptIds;
@Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384")
private Integer maxCount;
@Schema(description = "成交客户是否占有拥有客户数")
private Boolean dealCountEnabled;
@Schema(description = "规则适用人群名称")
private List<AdminUserRespDTO> users;

View File

@@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAdminUserParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysDeptParseFunction;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
@Schema(description = "管理后台 - 客户限制配置创建/更新 Request VO")
@Data
public class CrmCustomerLimitConfigSaveReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930")
private Long id;
@Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "规则类型不能为空")
@DiffLogField(name = "规则类型")
private Integer type;
@Schema(description = "规则适用人群")
@DiffLogField(name = "规则适用人群", function = SysAdminUserParseFunction.NAME)
private List<Long> userIds;
@Schema(description = "规则适用部门")
@DiffLogField(name = "规则适用部门", function = SysDeptParseFunction.NAME)
private List<Long> deptIds;
@Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384")
@NotNull(message = "数量上限不能为空")
@DiffLogField(name = "数量上限")
private Integer maxCount;
@Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)")
@DiffLogField(name = "成交客户是否占有拥有客户数")
private Boolean dealCountEnabled;
}

View File

@@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 客户限制配置更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmCustomerLimitConfigUpdateReqVO extends CrmCustomerLimitConfigBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930")
@NotNull(message = "编号不能为空")
private Long id;
}

View File

@@ -1,31 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 客户公海配置 Base VO提供给添加、修改、详细的子 VO 使用
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
*/
@Data
public class CrmCustomerPoolConfigBaseVO {
@Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "是否启用客户公海不能为空")
private Boolean enabled;
@Schema(description = "未跟进放入公海天数", example = "2")
private Integer contactExpireDays;
@Schema(description = "未成交放入公海天数", example = "2")
private Integer dealExpireDays;
@Schema(description = "是否开启提前提醒", example = "true")
private Boolean notifyEnabled;
@Schema(description = "提前提醒天数", example = "2")
private Integer notifyDays;
}

View File

@@ -1,14 +1,27 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - CRM 客户公海规则 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmCustomerPoolConfigRespVO extends CrmCustomerPoolConfigBaseVO {
public class CrmCustomerPoolConfigRespVO {
@Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "是否启用客户公海不能为空")
private Boolean enabled;
@Schema(description = "未跟进放入公海天数", example = "2")
private Integer contactExpireDays;
@Schema(description = "未成交放入公海天数", example = "2")
private Integer dealExpireDays;
@Schema(description = "是否开启提前提醒", example = "true")
private Boolean notifyEnabled;
@Schema(description = "提前提醒天数", example = "2")
private Integer notifyDays;
}

View File

@@ -1,34 +1,61 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.AssertTrue;
import java.util.Objects;
@Schema(description = "管理后台 - CRM 客户公海配置的保存 Request VO")
@Schema(description = "管理后台 - CRM 客户公海配置的创建/更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmCustomerPoolConfigSaveReqVO extends CrmCustomerPoolConfigBaseVO {
public class CrmCustomerPoolConfigSaveReqVO {
// TODO @wanwanAssertTrue 必须 is 开头哈;注意需要 json 忽略下,避免被序列化;
@AssertTrue(message = "客户公海规则设置不正确")
// TODO @wanwan这个方法是不是拆成 2 个,一个校验 contactExpireDays、一个校验 dealExpireDays
public boolean poolEnableValid() {
@Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@DiffLogField(name = "是否启用客户公海")
@NotNull(message = "是否启用客户公海不能为空")
private Boolean enabled;
@Schema(description = "未跟进放入公海天数", example = "2")
@DiffLogField(name = "未跟进放入公海天数")
private Integer contactExpireDays;
@Schema(description = "未成交放入公海天数", example = "2")
@DiffLogField(name = "未成交放入公海天数")
private Integer dealExpireDays;
@Schema(description = "是否开启提前提醒", example = "true")
@DiffLogField(name = "是否开启提前提醒")
private Boolean notifyEnabled;
@Schema(description = "提前提醒天数", example = "2")
@DiffLogField(name = "提前提醒天数")
private Integer notifyDays;
@AssertTrue(message = "未成交放入公海天数不能为空")
@JsonIgnore
public boolean isDealExpireDaysValid() {
if (!BooleanUtil.isTrue(getEnabled())) {
return true;
}
return ObjectUtil.isAllNotEmpty(getContactExpireDays(), getDealExpireDays());
return Objects.nonNull(getDealExpireDays());
}
@AssertTrue(message = "客户公海规则设置不正确")
// TODO @wanwan这个方法是不是改成 isNotifyDaysValid() 更好点?本质校验的是 notifyDays 是否为空
public boolean notifyEnableValid() {
@AssertTrue(message = "未跟进放入公海天数不能为空")
@JsonIgnore
public boolean isContactExpireDaysValid() {
if (!BooleanUtil.isTrue(getEnabled())) {
return true;
}
return Objects.nonNull(getContactExpireDays());
}
@AssertTrue(message = "提前提醒天数不能为空")
@JsonIgnore
public boolean isNotifyDaysValid() {
if (!BooleanUtil.isTrue(getNotifyEnabled())) {
return true;
}

View File

@@ -0,0 +1,92 @@
package cn.iocoder.yudao.module.crm.controller.admin.followup;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO;
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
import cn.iocoder.yudao.module.crm.service.followup.CrmFollowUpRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "管理后台 - 跟进记录")
@RestController
@RequestMapping("/crm/follow-up-record")
@Validated
public class CrmFollowUpRecordController {
@Resource
private CrmFollowUpRecordService followUpRecordService;
@Resource
private CrmContactService contactService;
@Resource
private CrmBusinessService businessService;
@PostMapping("/create")
@Operation(summary = "创建跟进记录")
@PreAuthorize("@ss.hasPermission('crm:follow-up-record:create')")
public CommonResult<Long> createFollowUpRecord(@Valid @RequestBody CrmFollowUpRecordSaveReqVO createReqVO) {
return success(followUpRecordService.createFollowUpRecord(createReqVO));
}
@DeleteMapping("/delete")
@Operation(summary = "删除跟进记录")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('crm:follow-up-record:delete')")
public CommonResult<Boolean> deleteFollowUpRecord(@RequestParam("id") Long id) {
followUpRecordService.deleteFollowUpRecord(id, getLoginUserId());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得跟进记录")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')")
public CommonResult<CrmFollowUpRecordRespVO> getFollowUpRecord(@RequestParam("id") Long id) {
CrmFollowUpRecordDO followUpRecord = followUpRecordService.getFollowUpRecord(id);
return success(BeanUtils.toBean(followUpRecord, CrmFollowUpRecordRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得跟进记录分页")
@PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')")
public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) {
PageResult<CrmFollowUpRecordDO> pageResult = followUpRecordService.getFollowUpRecordPage(pageReqVO);
/// 拼接数据
Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactList(
convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream())), CrmContactDO::getId);
Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList(
convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream())), CrmBusinessDO::getId);
PageResult<CrmFollowUpRecordRespVO> voPageResult = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class, record -> {
record.setContactNames(new ArrayList<>()).setBusinessNames(new ArrayList<>());
record.getContactIds().forEach(id -> MapUtils.findAndThen(contactMap, id,
contact -> record.getContactNames().add(contact.getName())));
record.getContactIds().forEach(id -> MapUtils.findAndThen(businessMap, id,
business -> record.getBusinessNames().add(business.getName())));
});
return success(voPageResult);
}
}

View File

@@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.crm.controller.admin.followup.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 跟进记录分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmFollowUpRecordPageReqVO extends PageParam {
@Schema(description = "数据类型", example = "2")
private Integer bizType;
@Schema(description = "数据编号", example = "5564")
private Long bizId;
}

View File

@@ -0,0 +1,50 @@
package cn.iocoder.yudao.module.crm.controller.admin.followup.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_FOLLOW_UP_TYPE;
@Schema(description = "管理后台 - 跟进记录 Response VO")
@Data
@ExcelIgnoreUnannotated
public class CrmFollowUpRecordRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28800")
private Long id;
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private Integer bizType;
@Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5564")
private Long bizId;
@Schema(description = "跟进类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@DictFormat(CRM_FOLLOW_UP_TYPE)
private Integer type;
@Schema(description = "跟进内容", requiredMode = Schema.RequiredMode.REQUIRED)
private String content;
@Schema(description = "下次联系时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime nextTime;
@Schema(description = "关联的商机编号数组")
private List<Long> businessIds;
@Schema(description = "关联的商机名称数组")
private List<String> businessNames;
@Schema(description = "关联的联系人编号数组")
private List<Long> contactIds;
@Schema(description = "关联的联系人名称数组")
private List<String> contactNames;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,44 @@
package cn.iocoder.yudao.module.crm.controller.admin.followup.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 跟进记录新增/修改 Request VO")
@Data
public class CrmFollowUpRecordSaveReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28800")
private Long id;
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "数据类型不能为空")
private Integer bizType;
@Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5564")
@NotNull(message = "数据编号不能为空")
private Long bizId;
@Schema(description = "跟进类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "跟进类型不能为空")
private Integer type;
@Schema(description = "跟进内容", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "跟进内容不能为空")
private String content;
@Schema(description = "下次联系时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "下次联系时间不能为空")
private LocalDateTime nextTime;
@Schema(description = "关联的商机编号数组")
private List<Long> businessIds;
@Schema(description = "关联的联系人编号数组")
private List<Long> contactIds;
}

View File

@@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.crm.controller.admin.message;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.message.vo.CrmTodayCustomerPageReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.message.CrmMessageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "管理后台 - CRM消息")
@RestController
@RequestMapping("/crm/message")
@Validated
public class CrmMessageController {
@Resource
private CrmMessageService crmMessageService;
// TODO 芋艿:未来可能合并到 CrmCustomerController
@GetMapping("/todayCustomer") // TODO @dbh52【优先级低】url 使用中划线,项目规范。然后叫 today-customer-page通过 page 体现出它是个分页接口
@Operation(summary = "今日需联系客户")
@PreAuthorize("@ss.hasPermission('crm:message:todayCustomer')")
public CommonResult<PageResult<CrmCustomerRespVO>> getTodayCustomerPage(@Valid CrmTodayCustomerPageReqVO pageReqVO) {
PageResult<CrmCustomerDO> pageResult = crmMessageService.getTodayCustomerPage(pageReqVO, getLoginUserId());
return success(BeanUtils.toBean(pageResult, CrmCustomerRespVO.class));
}
}

View File

@@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.crm.controller.admin.message.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
import cn.iocoder.yudao.module.crm.enums.message.CrmContactStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 今日需联系客户 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmTodayCustomerPageReqVO extends PageParam {
// TODO @dbh52CrmContactStatusEnum 可以直接枚举三个 Integer一般来说枚举类尽量给数据模型用这样枚举类少更聚焦这里的枚举更多是专门给这个接口用的哈
@Schema(description = "联系状态", example = "1")
@InEnum(CrmContactStatusEnum.class)
private Integer contactStatus;
@Schema(description = "场景类型", example = "1")
@InEnum(CrmSceneTypeEnum.class)
private Integer sceneType;
}

View File

@@ -8,8 +8,8 @@ import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionR
import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO;
import cn.iocoder.yudao.module.crm.convert.permission.CrmPermissionConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.PostApi;
@@ -21,12 +21,12 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.*;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

View File

@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO;
@@ -15,18 +16,21 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO;
import cn.iocoder.yudao.module.crm.service.product.CrmProductCategoryService;
import cn.iocoder.yudao.module.crm.service.product.CrmProductService;
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2PageReqDTO;
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2RespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
@@ -34,9 +38,12 @@ import java.util.Map;
import java.util.stream.Stream;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_PRODUCT_TYPE;
@Tag(name = "管理后台 - CRM 产品")
@RestController
@@ -48,7 +55,8 @@ public class CrmProductController {
private CrmProductService productService;
@Resource
private CrmProductCategoryService productCategoryService;
@Resource
private OperateLogApi operateLogApi;
@Resource
private AdminUserApi adminUserApi;
@@ -86,7 +94,7 @@ public class CrmProductController {
return success(null);
}
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
SetUtils.asSet( Long.valueOf(product.getCreator()), product.getOwnerUserId()));
SetUtils.asSet(Long.valueOf(product.getCreator()), product.getOwnerUserId()));
CrmProductCategoryDO category = productCategoryService.getProductCategory(product.getCategoryId());
return success(CrmProductConvert.INSTANCE.convert(product, userMap, category));
}
@@ -95,7 +103,7 @@ public class CrmProductController {
@Operation(summary = "获得产品分页")
@PreAuthorize("@ss.hasPermission('crm:product:query')")
public CommonResult<PageResult<CrmProductRespVO>> getProductPage(@Valid CrmProductPageReqVO pageVO) {
PageResult<CrmProductDO> pageResult = productService.getProductPage(pageVO);
PageResult<CrmProductDO> pageResult = productService.getProductPage(pageVO, getLoginUserId());
return success(new PageResult<>(getProductDetailList(pageResult.getList()), pageResult.getTotal()));
}
@@ -104,9 +112,9 @@ public class CrmProductController {
@PreAuthorize("@ss.hasPermission('crm:product:export')")
@OperateLog(type = EXPORT)
public void exportProductExcel(@Valid CrmProductPageReqVO exportReqVO,
HttpServletResponse response) throws IOException {
HttpServletResponse response) throws IOException {
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<CrmProductDO> list = productService.getProductPage(exportReqVO).getList();
List<CrmProductDO> list = productService.getProductPage(exportReqVO, getLoginUserId()).getList();
// 导出 Excel
ExcelUtils.write(response, "产品.xls", "数据", CrmProductRespVO.class,
getProductDetailList(list));
@@ -123,4 +131,14 @@ public class CrmProductController {
return CrmProductConvert.INSTANCE.convertList(list, userMap, productCategoryList);
}
@GetMapping("/operate-log-page")
@Operation(summary = "获得产品操作日志")
@PreAuthorize("@ss.hasPermission('crm:product:query')")
public CommonResult<PageResult<OperateLogV2RespDTO>> getProductOperateLog(@RequestParam("bizId") Long bizId) {
OperateLogV2PageReqDTO reqVO = new OperateLogV2PageReqDTO();
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
reqVO.setBizType(CRM_PRODUCT_TYPE).setBizId(bizId);
return success(operateLogApi.getOperateLogPage(BeanUtils.toBean(reqVO, OperateLogV2PageReqDTO.class)));
}
}

View File

@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category;
import com.mzt.logapi.starter.annotation.DiffLogField;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -14,6 +15,7 @@ public class CrmProductCategoryCreateReqVO{
@Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@NotNull(message = "分类名称不能为空")
@DiffLogField(name = "分类名称")
private String name;
@Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4680")

View File

@@ -1,9 +1,11 @@
package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product;
import lombok.*;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmProductStatusParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmProductUnitParseFunction;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.NotNull;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Schema(description = "管理后台 - CRM 产品创建/修改 Request VO")
@Data
@@ -14,28 +16,35 @@ public class CrmProductSaveReqVO {
@Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "好产品")
@NotNull(message = "产品名称不能为空")
@DiffLogField(name = "产品名称")
private String name;
@Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "12306")
@NotNull(message = "产品编码不能为空")
@DiffLogField(name = "产品编码")
private String no;
@Schema(description = "单位", example = "2")
@DiffLogField(name = "单位", function = CrmProductUnitParseFunction.NAME)
private Integer unit;
@Schema(description = "价格, 单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911")
@NotNull(message = "价格不能为空")
@DiffLogField(name = "价格")
private Long price;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "上架")
@NotNull(message = "状态不能为空")
@DiffLogField(name = "状态", function = CrmProductStatusParseFunction.NAME)
private Integer status;
@Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "产品分类编号不能为空")
@DiffLogField(name = "产品分类编号")
private Long categoryId;
@Schema(description = "产品描述", example = "你说的对")
@DiffLogField(name = "产品描述")
private String description;
@Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926")

View File

@@ -23,22 +23,24 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "管理后台 - CRM 回款")
@RestController
@@ -60,7 +62,7 @@ public class CrmReceivableController {
@Operation(summary = "创建回款")
@PreAuthorize("@ss.hasPermission('crm:receivable:create')")
public CommonResult<Long> createReceivable(@Valid @RequestBody CrmReceivableCreateReqVO createReqVO) {
return success(receivableService.createReceivable(createReqVO));
return success(receivableService.createReceivable(createReqVO, getLoginUserId()));
}
@PutMapping("/update")
@@ -93,16 +95,16 @@ public class CrmReceivableController {
@Operation(summary = "获得回款分页")
@PreAuthorize("@ss.hasPermission('crm:receivable:query')")
public CommonResult<PageResult<CrmReceivableRespVO>> getReceivablePage(@Valid CrmReceivablePageReqVO pageReqVO) {
PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(pageReqVO);
return success(convertDetailReceivablePage(pageResult));
PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(pageReqVO, getLoginUserId());
return success(buildReceivableDetailPage(pageResult));
}
@GetMapping("/page-by-customer")
@Operation(summary = "获得回款分页,基于指定客户")
public CommonResult<PageResult<CrmReceivableRespVO>> getReceivablePageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) {
Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空");
PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePageByCustomer(pageReqVO);
return success(convertDetailReceivablePage(pageResult));
PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePageByCustomerId(pageReqVO);
return success(buildReceivableDetailPage(pageResult));
}
// TODO 芋艿:后面在优化导出
@@ -111,20 +113,21 @@ public class CrmReceivableController {
@PreAuthorize("@ss.hasPermission('crm:receivable:export')")
@OperateLog(type = EXPORT)
public void exportReceivableExcel(@Valid CrmReceivablePageReqVO exportReqVO,
HttpServletResponse response) throws IOException {
PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(exportReqVO);
HttpServletResponse response) throws IOException {
exportReqVO.setPageSize(PAGE_SIZE_NONE);
PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(exportReqVO, getLoginUserId());
// 导出 Excel
ExcelUtils.write(response, "回款.xls", "数据", CrmReceivableRespVO.class,
convertDetailReceivablePage(pageResult).getList());
buildReceivableDetailPage(pageResult).getList());
}
/**
* 转换成详细的回款分页,即读取关联信息
* 构建详细的回款分页结果
*
* @param pageResult 回款分页
* @return 详细的回款分页
* @param pageResult 简单的回款分页结果
* @return 详细的回款分页结果
*/
private PageResult<CrmReceivableRespVO> convertDetailReceivablePage(PageResult<CrmReceivableDO> pageResult) {
private PageResult<CrmReceivableRespVO> buildReceivableDetailPage(PageResult<CrmReceivableDO> pageResult) {
List<CrmReceivableDO> receivableList = pageResult.getList();
if (CollUtil.isEmpty(receivableList)) {
return PageResult.empty(pageResult.getTotal());

View File

@@ -25,22 +25,24 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "管理后台 - CRM 回款计划")
@RestController
@@ -64,7 +66,7 @@ public class CrmReceivablePlanController {
@Operation(summary = "创建回款计划")
@PreAuthorize("@ss.hasPermission('crm:receivable-plan:create')")
public CommonResult<Long> createReceivablePlan(@Valid @RequestBody CrmReceivablePlanCreateReqVO createReqVO) {
return success(receivablePlanService.createReceivablePlan(createReqVO));
return success(receivablePlanService.createReceivablePlan(createReqVO, getLoginUserId()));
}
@PutMapping("/update")
@@ -97,7 +99,7 @@ public class CrmReceivablePlanController {
@Operation(summary = "获得回款计划分页")
@PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')")
public CommonResult<PageResult<CrmReceivablePlanRespVO>> getReceivablePlanPage(@Valid CrmReceivablePlanPageReqVO pageReqVO) {
PageResult<CrmReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPage(pageReqVO);
PageResult<CrmReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPage(pageReqVO, getLoginUserId());
return success(convertDetailReceivablePlanPage(pageResult));
}
@@ -105,7 +107,7 @@ public class CrmReceivablePlanController {
@Operation(summary = "获得回款计划分页,基于指定客户")
public CommonResult<PageResult<CrmReceivablePlanRespVO>> getReceivablePlanPageByCustomer(@Valid CrmReceivablePlanPageReqVO pageReqVO) {
Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空");
PageResult<CrmReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPageByCustomer(pageReqVO);
PageResult<CrmReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPageByCustomerId(pageReqVO);
return success(convertDetailReceivablePlanPage(pageResult));
}
@@ -115,18 +117,19 @@ public class CrmReceivablePlanController {
@PreAuthorize("@ss.hasPermission('crm:receivable-plan:export')")
@OperateLog(type = EXPORT)
public void exportReceivablePlanExcel(@Valid CrmReceivablePlanPageReqVO exportReqVO,
HttpServletResponse response) throws IOException {
PageResult<CrmReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPage(exportReqVO);
HttpServletResponse response) throws IOException {
exportReqVO.setPageSize(PAGE_SIZE_NONE);
PageResult<CrmReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPage(exportReqVO, getLoginUserId());
// 导出 Excel
ExcelUtils.write(response, "回款计划.xls", "数据", CrmReceivablePlanRespVO.class,
convertDetailReceivablePlanPage(pageResult).getList());
}
/**
* 转换成详细的回款计划分页,即读取关联信息
* 构建详细的回款计划分页结果
*
* @param pageResult 回款计划分页
* @return 详细的回款计划分页
* @param pageResult 简单的回款计划分页结果
* @return 详细的回款计划分页结果
*/
private PageResult<CrmReceivablePlanRespVO> convertDetailReceivablePlanPage(PageResult<CrmReceivablePlanDO> pageResult) {
List<CrmReceivablePlanDO> receivablePlanList = pageResult.getList();

View File

@@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -19,4 +21,8 @@ public class CrmReceivablePlanPageReqVO extends PageParam {
@Schema(description = "合同名称", example = "3473")
private Long contractId;
@Schema(description = "场景类型", example = "1")
@InEnum(CrmSceneTypeEnum.class)
private Integer sceneType; // 场景类型,为 null 时则表示全部
}

View File

@@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -21,4 +23,8 @@ public class CrmReceivablePageReqVO extends PageParam {
@Schema(description = "客户编号", example = "4963")
private Long customerId;
@Schema(description = "场景类型", example = "1")
@InEnum(CrmSceneTypeEnum.class)
private Integer sceneType; // 场景类型,为 null 时则表示全部
}

View File

@@ -1,7 +1,9 @@
package cn.iocoder.yudao.module.crm.convert.business;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
@@ -9,7 +11,6 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
@@ -27,35 +28,21 @@ public interface CrmBusinessConvert {
CrmBusinessConvert INSTANCE = Mappers.getMapper(CrmBusinessConvert.class);
CrmBusinessDO convert(CrmBusinessCreateReqVO bean);
CrmBusinessDO convert(CrmBusinessUpdateReqVO bean);
CrmBusinessRespVO convert(CrmBusinessDO bean);
List<CrmBusinessRespVO> convert(List<CrmBusinessDO> bean);
PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> page);
List<CrmBusinessExcelVO> convertList02(List<CrmBusinessDO> list);
@Mappings({
@Mapping(target = "bizId", source = "reqVO.id"),
@Mapping(target = "newOwnerUserId", source = "reqVO.id")
})
@Mapping(target = "bizId", source = "reqVO.id")
CrmPermissionTransferReqBO convert(CrmBusinessTransferReqVO reqVO, Long userId);
default PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> page, List<CrmCustomerDO> customerList,
default PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> pageResult, List<CrmCustomerDO> customerList,
List<CrmBusinessStatusTypeDO> statusTypeList, List<CrmBusinessStatusDO> statusList) {
PageResult<CrmBusinessRespVO> result = convertPage(page);
PageResult<CrmBusinessRespVO> voPageResult = BeanUtils.toBean(pageResult, CrmBusinessRespVO.class);
// 拼接关联字段
Map<Long, String> customerMap = convertMap(customerList, CrmCustomerDO::getId, CrmCustomerDO::getName);
Map<Long, String> statusTypeMap = convertMap(statusTypeList, CrmBusinessStatusTypeDO::getId, CrmBusinessStatusTypeDO::getName);
Map<Long, String> statusMap = convertMap(statusList, CrmBusinessStatusDO::getId, CrmBusinessStatusDO::getName);
result.getList().forEach(type -> type
voPageResult.getList().forEach(type -> type
.setCustomerName(customerMap.get(type.getCustomerId()))
.setStatusTypeName(statusTypeMap.get(type.getStatusTypeId()))
.setStatusName(statusMap.get(type.getStatusId())));
return result;
return voPageResult;
}
}

View File

@@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.crm.convert.businessproduct;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.product.CrmBusinessProductSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
// TODO @lzxhqs看看是不是用 BeanUtils 替代了
/**
* @author lzxhqs
* @version 1.0
* @title CrmBusinessProductConvert
* @description
* @create 2024/1/12
*/
@Mapper
public interface CrmBusinessProductConvert {
CrmBusinessProductConvert INSTANCE = Mappers.getMapper(CrmBusinessProductConvert.class);
CrmBusinessProductDO convert(CrmBusinessProductSaveReqVO product);
}

View File

@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.convert.businessstatus;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@@ -19,10 +18,6 @@ public interface CrmBusinessStatusConvert {
CrmBusinessStatusConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusConvert.class);
CrmBusinessStatusDO convert(CrmBusinessStatusSaveReqVO bean);
CrmBusinessStatusRespVO convert(CrmBusinessStatusDO bean);
List<CrmBusinessStatusRespVO> convertList(List<CrmBusinessStatusDO> list);
PageResult<CrmBusinessStatusRespVO> convertPage(PageResult<CrmBusinessStatusDO> page);

View File

@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.convert.businessstatustype;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
@@ -15,6 +14,7 @@ import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
// TODO @lzxhqs看看是不是用 BeanUtils 替代了
/**
* 商机状态类型 Convert
*
@@ -25,8 +25,6 @@ public interface CrmBusinessStatusTypeConvert {
CrmBusinessStatusTypeConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusTypeConvert.class);
CrmBusinessStatusTypeDO convert(CrmBusinessStatusTypeSaveReqVO bean);
CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean);
PageResult<CrmBusinessStatusTypeRespVO> convertPage(PageResult<CrmBusinessStatusTypeDO> page);
@@ -40,10 +38,7 @@ public interface CrmBusinessStatusTypeConvert {
}
default CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean, List<CrmBusinessStatusDO> statusList) {
// TODO @ljlleo 可以链式赋值,简化成一行;
CrmBusinessStatusTypeRespVO result = convert(bean);
result.setStatusList(statusList);
return result;
return convert(bean).setStatusList(statusList);
}
}

View File

@@ -1,13 +1,10 @@
package cn.iocoder.yudao.module.crm.convert.clue;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
/**
* 线索 Convert
@@ -19,14 +16,7 @@ public interface CrmClueConvert {
CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class);
CrmClueDO convert(CrmClueCreateReqVO bean);
CrmClueDO convert(CrmClueUpdateReqVO bean);
CrmClueRespVO convert(CrmClueDO bean);
PageResult<CrmClueRespVO> convertPage(PageResult<CrmClueDO> page);
List<CrmClueExcelVO> convertList02(List<CrmClueDO> list);
@Mapping(target = "bizId", source = "reqVO.id")
CrmPermissionTransferReqBO convert(CrmClueTransferReqVO reqVO, Long userId);
}

View File

@@ -1,107 +0,0 @@
package cn.iocoder.yudao.module.crm.convert.contact;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
// TODO 芋艿convert 后面在梳理下,略微有点乱
/**
* CRM 联系人 Convert
*
* @author 芋道源码
*/
@Mapper
public interface ContactConvert {
ContactConvert INSTANCE = Mappers.getMapper(ContactConvert.class);
CrmContactDO convert(CrmContactCreateReqVO bean);
CrmContactDO convert(CrmContactUpdateReqVO bean);
CrmContactRespVO convert(CrmContactDO bean);
List<CrmContactRespVO> convertList(List<CrmContactDO> list);
PageResult<CrmContactRespVO> convertPage(PageResult<CrmContactDO> page);
default PageResult<CrmContactRespVO> convertPage(PageResult<CrmContactDO> pageResult, Map<Long, AdminUserRespDTO> userMap,
List<CrmCustomerDO> customerList, List<CrmContactDO> parentContactList) {
List<CrmContactRespVO> list = converList(pageResult.getList(), userMap, customerList, parentContactList);
return convertPage(pageResult).setList(list);
}
List<CrmContactSimpleRespVO> convertAllList(List<CrmContactDO> list);
@Mappings({
@Mapping(target = "bizId", source = "reqVO.id"),
@Mapping(target = "newOwnerUserId", source = "reqVO.id")
})
CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId);
/**
* 转换详情信息
*
* @param contactDO 联系人
* @param userMap 用户列表
* @param crmCustomerDOList 客户
* @return ContactRespVO
*/
default CrmContactRespVO convert(CrmContactDO contactDO, Map<Long, AdminUserRespDTO> userMap, List<CrmCustomerDO> crmCustomerDOList,
List<CrmContactDO> contactList) {
CrmContactRespVO contactVO = convert(contactDO);
setUserInfo(contactVO, userMap);
Map<Long, CrmCustomerDO> ustomerMap = crmCustomerDOList.stream().collect(Collectors.toMap(CrmCustomerDO::getId, v -> v));
Map<Long, CrmContactDO> contactMap = contactList.stream().collect(Collectors.toMap(CrmContactDO::getId, v -> v));
findAndThen(ustomerMap, contactDO.getCustomerId(), customer -> contactVO.setCustomerName(customer.getName()));
findAndThen(contactMap, contactDO.getParentId(), contact -> contactVO.setParentName(contact.getName()));
return contactVO;
}
default List<CrmContactRespVO> converList(List<CrmContactDO> contactList, Map<Long, AdminUserRespDTO> userMap,
List<CrmCustomerDO> customerList, List<CrmContactDO> parentContactList) {
List<CrmContactRespVO> result = convertList(contactList);
Map<Long, CrmContactDO> parentContactMap = convertMap(parentContactList, CrmContactDO::getId);
Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId);
result.forEach(item -> {
setUserInfo(item, userMap);
findAndThen(customerMap, item.getCustomerId(), customer -> { // TODO @zyna这里的 { 可以去掉
item.setCustomerName(customer.getName());
});
findAndThen(parentContactMap, item.getParentId(), contactDO -> { // TODO @zyna这里的 { 可以去掉
item.setParentName(contactDO.getName());
});
});
return result;
}
/**
* 设置用户信息
*
* @param contactRespVO 联系人Response VO
* @param userMap 用户信息 map
*/
static void setUserInfo(CrmContactRespVO contactRespVO, Map<Long, AdminUserRespDTO> userMap) {
contactRespVO.setAreaName(AreaUtils.format(contactRespVO.getAreaId()));
findAndThen(userMap, contactRespVO.getOwnerUserId(), user -> {
contactRespVO.setOwnerUserName(user == null ? "" : user.getNickname());
});
findAndThen(userMap, Long.parseLong(contactRespVO.getCreator()), user -> contactRespVO.setCreatorName(user.getNickname()));
}
}

View File

@@ -0,0 +1,69 @@
package cn.iocoder.yudao.module.crm.convert.contact;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
/**
* CRM 联系人 Convert
*
* @author 芋道源码
*/
@Mapper
public interface CrmContactConvert {
CrmContactConvert INSTANCE = Mappers.getMapper(CrmContactConvert.class);
CrmContactRespVO convert(CrmContactDO bean);
@Mapping(target = "bizId", source = "reqVO.id")
CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId);
default PageResult<CrmContactRespVO> convertPage(PageResult<CrmContactDO> pageResult, Map<Long, AdminUserRespDTO> userMap,
List<CrmCustomerDO> customerList, List<CrmContactDO> parentContactList) {
PageResult<CrmContactRespVO> voPageResult = BeanUtils.toBean(pageResult, CrmContactRespVO.class);
// 拼接关联字段
Map<Long, CrmContactDO> parentContactMap = convertMap(parentContactList, CrmContactDO::getId);
Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId);
voPageResult.getList().forEach(item -> {
setUserInfo(item, userMap);
findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName()));
findAndThen(parentContactMap, item.getParentId(), contactDO -> item.setParentName(contactDO.getName()));
});
return voPageResult;
}
default CrmContactRespVO convert(CrmContactDO contactDO, Map<Long, AdminUserRespDTO> userMap,
List<CrmCustomerDO> customerList, List<CrmContactDO> parentContactList) {
CrmContactRespVO contactVO = convert(contactDO);
setUserInfo(contactVO, userMap);
Map<Long, CrmCustomerDO> customerMap = CollectionUtils.convertMap(customerList, CrmCustomerDO::getId);
Map<Long, CrmContactDO> contactMap = CollectionUtils.convertMap(parentContactList, CrmContactDO::getId);
findAndThen(customerMap, contactDO.getCustomerId(), customer -> contactVO.setCustomerName(customer.getName()));
findAndThen(contactMap, contactDO.getParentId(), contact -> contactVO.setParentName(contact.getName()));
return contactVO;
}
static void setUserInfo(CrmContactRespVO contactRespVO, Map<Long, AdminUserRespDTO> userMap) {
contactRespVO.setAreaName(AreaUtils.format(contactRespVO.getAreaId()));
findAndThen(userMap, contactRespVO.getOwnerUserId(), user -> contactRespVO.setOwnerUserName(user.getNickname()));
findAndThen(userMap, Long.parseLong(contactRespVO.getCreator()), user -> contactRespVO.setCreatorName(user.getNickname()));
}
}

View File

@@ -1,16 +0,0 @@
package cn.iocoder.yudao.module.crm.convert.contactbusinessslink;
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
// TODO @zyna使用 BeanUtils 慢慢替代现有的 mapstruct 哈
@Mapper
public interface CrmContactBusinessLinkConvert {
CrmContactBusinessLinkConvert INSTANCE = Mappers.getMapper(CrmContactBusinessLinkConvert.class);
CrmContactBusinessLinkDO convert(CrmContactBusinessLinkSaveReqVO bean);
List<CrmContactBusinessLinkDO> convert(List<CrmContactBusinessLinkSaveReqVO> bean);
}

View File

@@ -1,69 +0,0 @@
package cn.iocoder.yudao.module.crm.convert.contract;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
/**
* 合同 Convert
*
* @author dhb52
*/
@Mapper
public interface ContractConvert {
ContractConvert INSTANCE = Mappers.getMapper(ContractConvert.class);
CrmContractDO convert(CrmContractCreateReqVO bean);
CrmContractDO convert(CrmContractUpdateReqVO bean);
ContractRespVO convert(CrmContractDO bean);
List<ContractRespVO> convertList(List<CrmContractDO> list);
PageResult<ContractRespVO> convertPage(PageResult<CrmContractDO> page);
List<CrmContractExcelVO> convertList02(List<CrmContractDO> list);
@Mappings({
@Mapping(target = "bizId", source = "reqVO.id"),
@Mapping(target = "newOwnerUserId", source = "reqVO.id")
})
CrmPermissionTransferReqBO convert(CrmContractTransferReqVO reqVO, Long userId);
default PageResult<ContractRespVO> convertPage(PageResult<CrmContractDO> pageResult, Map<Long, AdminUserRespDTO> userMap,
List<CrmCustomerDO> customerList) {
return new PageResult<>(converList(pageResult.getList(), userMap, customerList), pageResult.getTotal());
}
default List<ContractRespVO> converList(List<CrmContractDO> contractList, Map<Long, AdminUserRespDTO> userMap,
List<CrmCustomerDO> customerList) {
List<ContractRespVO> result = convertList(contractList);
Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId);
result.forEach(item -> {
setUserInfo(item, userMap);
findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName()));
});
return result;
}
static void setUserInfo(ContractRespVO contract, Map<Long, AdminUserRespDTO> userMap) {
findAndThen(userMap, contract.getOwnerUserId(), user -> contract.setOwnerUserName(user.getNickname()));
findAndThen(userMap, Long.parseLong(contract.getCreator()), user -> contract.setCreatorName(user.getNickname()));
}
}

View File

@@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.crm.convert.contract;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
/**
* 合同 Convert
*
* @author dhb52
*/
@Mapper
public interface CrmContractConvert {
CrmContractConvert INSTANCE = Mappers.getMapper(CrmContractConvert.class);
@Mapping(target = "bizId", source = "reqVO.id")
CrmPermissionTransferReqBO convert(CrmContractTransferReqVO reqVO, Long userId);
default PageResult<CrmContractRespVO> convertPage(PageResult<CrmContractDO> pageResult, Map<Long, AdminUserRespDTO> userMap,
List<CrmCustomerDO> customerList) {
PageResult<CrmContractRespVO> voPageResult = BeanUtils.toBean(pageResult, CrmContractRespVO.class);
// 拼接关联字段
Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId);
voPageResult.getList().forEach(contract -> {
findAndThen(userMap, contract.getOwnerUserId(), user -> contract.setOwnerUserName(user.getNickname()));
findAndThen(userMap, Long.parseLong(contract.getCreator()), user -> contract.setCreatorName(user.getNickname()));
findAndThen(customerMap, contract.getCustomerId(), customer -> contract.setCustomerName(customer.getName()));
});
return voPageResult;
}
}

View File

@@ -1,21 +1,18 @@
package cn.iocoder.yudao.module.crm.convert.customer;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
@@ -30,18 +27,29 @@ public interface CrmCustomerConvert {
CrmCustomerConvert INSTANCE = Mappers.getMapper(CrmCustomerConvert.class);
CrmCustomerDO convert(CrmCustomerCreateReqVO bean);
default CrmCustomerRespVO convert(CrmCustomerDO customer, Map<Long, AdminUserRespDTO> userMap,
Map<Long, DeptRespDTO> deptMap) {
CrmCustomerRespVO customerResp = BeanUtils.toBean(customer, CrmCustomerRespVO.class);
setUserInfo(customerResp, userMap, deptMap);
return customerResp;
}
CrmCustomerDO convert(CrmCustomerUpdateReqVO bean);
CrmCustomerRespVO convert(CrmCustomerDO bean);
default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> pageResult, Map<Long, AdminUserRespDTO> userMap,
Map<Long, DeptRespDTO> deptMap, Map<Long, Long> poolDayMap) {
PageResult<CrmCustomerRespVO> result = BeanUtils.toBean(pageResult, CrmCustomerRespVO.class);
result.getList().forEach(item -> {
setUserInfo(item, userMap, deptMap);
findAndThen(poolDayMap, item.getId(), item::setPoolDay);
});
return result;
}
/**
* 设置用户信息
*
* @param customer CRM 客户 Response VO
* @param userMap 用户信息 map
* @param deptMap 用户部门信息 map
* @param customer CRM 客户 Response VO
* @param userMap 用户信息 map
* @param deptMap 用户部门信息 map
*/
static void setUserInfo(CrmCustomerRespVO customer, Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {
customer.setAreaName(AreaUtils.format(customer.getAreaId()));
@@ -52,34 +60,7 @@ public interface CrmCustomerConvert {
findAndThen(userMap, Long.parseLong(customer.getCreator()), user -> customer.setCreatorName(user.getNickname()));
}
List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list);
@Mappings({
@Mapping(target = "bizId", source = "reqVO.id"),
@Mapping(target = "newOwnerUserId", source = "reqVO.id")
})
@Mapping(target = "bizId", source = "reqVO.id")
CrmPermissionTransferReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId);
PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page);
default CrmCustomerRespVO convert(CrmCustomerDO customer, Map<Long, AdminUserRespDTO> userMap,
Map<Long, DeptRespDTO> deptMap) {
CrmCustomerRespVO customerResp = convert(customer);
setUserInfo(customerResp, userMap, deptMap);
return customerResp;
}
default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> pageResult, Map<Long, AdminUserRespDTO> userMap,
Map<Long, DeptRespDTO> deptMap) {
PageResult<CrmCustomerRespVO> result = convertPage(pageResult);
result.getList().forEach(item -> setUserInfo(item, userMap, deptMap));
return result;
}
CrmCustomerPoolConfigRespVO convert(CrmCustomerPoolConfigDO customerPoolConfig);
CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO);
List<CrmCustomerQueryAllRespVO> convertQueryAll(List<CrmCustomerDO> crmCustomerDO);
}

Some files were not shown because too many files have changed in this diff Show More