Commit 872fe53585a21edcbadc2f3998a9c6bdeab60ccb
Merge remote-tracking branch 'yudao/develop' into develop
Showing
15 changed files
with
166 additions
and
35 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
| @@ -21,6 +21,8 @@ public interface ErrorCodeConstants { | @@ -21,6 +21,8 @@ public interface ErrorCodeConstants { | ||
| 21 | // ========== 商机管理 1-020-002-000 ========== | 21 | // ========== 商机管理 1-020-002-000 ========== |
| 22 | ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); | 22 | ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); |
| 23 | ErrorCode BUSINESS_DELETE_FAIL_CONTRACT_EXISTS = new ErrorCode(1_020_002_001, "商机已关联合同,不能删除"); | 23 | ErrorCode BUSINESS_DELETE_FAIL_CONTRACT_EXISTS = new ErrorCode(1_020_002_001, "商机已关联合同,不能删除"); |
| 24 | + ErrorCode BUSINESS_UPDATE_STATUS_FAIL_END_STATUS = new ErrorCode(1_020_002_002, "更新商机状态失败,原因:已经是结束状态"); | ||
| 25 | + ErrorCode BUSINESS_UPDATE_STATUS_FAIL_STATUS_EQUALS = new ErrorCode(1_020_002_003, "更新商机状态失败,原因:已经是该状态"); | ||
| 24 | 26 | ||
| 25 | // ========== 联系人管理 1-020-003-000 ========== | 27 | // ========== 联系人管理 1-020-003-000 ========== |
| 26 | ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); | 28 | ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); |
| @@ -81,6 +83,7 @@ public interface ErrorCodeConstants { | @@ -81,6 +83,7 @@ public interface ErrorCodeConstants { | ||
| 81 | ErrorCode BUSINESS_STATUS_TYPE_NAME_EXISTS = new ErrorCode(1_020_010_001, "商机状态组的名称已存在"); | 83 | ErrorCode BUSINESS_STATUS_TYPE_NAME_EXISTS = new ErrorCode(1_020_010_001, "商机状态组的名称已存在"); |
| 82 | ErrorCode BUSINESS_STATUS_UPDATE_FAIL_USED = new ErrorCode(1_020_010_002, "已经被使用的商机状态组,无法进行更新"); | 84 | ErrorCode BUSINESS_STATUS_UPDATE_FAIL_USED = new ErrorCode(1_020_010_002, "已经被使用的商机状态组,无法进行更新"); |
| 83 | ErrorCode BUSINESS_STATUS_DELETE_FAIL_USED = new ErrorCode(1_020_010_002, "已经被使用的商机状态组,无法进行删除"); | 85 | ErrorCode BUSINESS_STATUS_DELETE_FAIL_USED = new ErrorCode(1_020_010_002, "已经被使用的商机状态组,无法进行删除"); |
| 86 | + ErrorCode BUSINESS_STATUS_NOT_EXISTS = new ErrorCode(1_020_010_003, "商机状态不存在"); | ||
| 84 | 87 | ||
| 85 | // ========== 客户公海规则设置 1_020_012_000 ========== | 88 | // ========== 客户公海规则设置 1_020_012_000 ========== |
| 86 | ErrorCode CUSTOMER_POOL_CONFIG_NOT_EXISTS_OR_DISABLED = new ErrorCode(1_020_012_000, "客户公海配置不存在或未启用"); | 89 | ErrorCode CUSTOMER_POOL_CONFIG_NOT_EXISTS_OR_DISABLED = new ErrorCode(1_020_012_000, "客户公海配置不存在或未启用"); |
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java
| @@ -93,6 +93,9 @@ public interface LogRecordConstants { | @@ -93,6 +93,9 @@ public interface LogRecordConstants { | ||
| 93 | String CRM_BUSINESS_TRANSFER_SUCCESS = "将商机【{{#business.name}}】的负责人从【{getAdminUserById{#business.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; | 93 | String CRM_BUSINESS_TRANSFER_SUCCESS = "将商机【{{#business.name}}】的负责人从【{getAdminUserById{#business.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; |
| 94 | String CRM_BUSINESS_FOLLOW_UP_SUB_TYPE = "商机跟进"; | 94 | String CRM_BUSINESS_FOLLOW_UP_SUB_TYPE = "商机跟进"; |
| 95 | String CRM_BUSINESS_FOLLOW_UP_SUCCESS = "商机跟进【{{#businessName}}】"; | 95 | String CRM_BUSINESS_FOLLOW_UP_SUCCESS = "商机跟进【{{#businessName}}】"; |
| 96 | + String CRM_BUSINESS_UPDATE_STATUS_SUB_TYPE = "更新商机状态"; | ||
| 97 | + String CRM_BUSINESS_UPDATE_STATUS_SUCCESS = "更新了商机【{{#businessName}}】的状态从【{{#oldStatusName}}】变更为了【{{#newStatusName}}】"; | ||
| 98 | +// String CRM_BUSINESS_UPDATE_STATUS_SUCCESS = "阿巴阿巴"; | ||
| 96 | 99 | ||
| 97 | // ======================= CRM_CONTRACT 合同 ======================= | 100 | // ======================= CRM_CONTRACT 合同 ======================= |
| 98 | 101 |
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/business/CrmBizEndStatus.java renamed to yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/business/CrmBusinessEndStatusEnum.java
| 1 | package cn.iocoder.yudao.module.crm.enums.business; | 1 | package cn.iocoder.yudao.module.crm.enums.business; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.util.ObjectUtil; | ||
| 4 | import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | 3 | import cn.iocoder.yudao.framework.common.core.IntArrayValuable; |
| 5 | import lombok.Getter; | 4 | import lombok.Getter; |
| 6 | import lombok.RequiredArgsConstructor; | 5 | import lombok.RequiredArgsConstructor; |
| 7 | 6 | ||
| 8 | import java.util.Arrays; | 7 | import java.util.Arrays; |
| 9 | 8 | ||
| 10 | -// TODO @lzxhqs:1)title、description、create 可以删除,非标准的 javadoc 注释哈,然后可以在类上加下这个类的注释;2)CrmBizEndStatus 改成 CrmBusinessEndStatus,非必要不缩写哈,可阅读比较重要 | ||
| 11 | /** | 9 | /** |
| 10 | + * 商机的结束状态枚举 | ||
| 11 | + * | ||
| 12 | * @author lzxhqs | 12 | * @author lzxhqs |
| 13 | - * @version 1.0 | ||
| 14 | - * @title CrmBizEndStatus | ||
| 15 | - * @description | ||
| 16 | - * @create 2024/1/12 | ||
| 17 | */ | 13 | */ |
| 18 | @RequiredArgsConstructor | 14 | @RequiredArgsConstructor |
| 19 | @Getter | 15 | @Getter |
| 20 | -public enum CrmBizEndStatus implements IntArrayValuable { | 16 | +public enum CrmBusinessEndStatusEnum implements IntArrayValuable { |
| 21 | 17 | ||
| 22 | WIN(1, "赢单"), | 18 | WIN(1, "赢单"), |
| 23 | LOSE(2, "输单"), | 19 | LOSE(2, "输单"), |
| 24 | INVALID(3, "无效"); | 20 | INVALID(3, "无效"); |
| 25 | 21 | ||
| 26 | - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizEndStatus::getStatus).toArray(); | ||
| 27 | - | ||
| 28 | - // TODO @lzxhqs:这里的方法,建议放到 49 行之后;一般类里是,静态变量,普通变量;静态方法;普通方法 | ||
| 29 | - public static boolean isWin(Integer status) { | ||
| 30 | - return ObjectUtil.equal(WIN.getStatus(), status); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - public static boolean isLose(Integer status) { | ||
| 34 | - return ObjectUtil.equal(LOSE.getStatus(), status); | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | - public static boolean isInvalid(Integer status) { | ||
| 38 | - return ObjectUtil.equal(INVALID.getStatus(), status); | ||
| 39 | - } | 22 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBusinessEndStatusEnum::getStatus).toArray(); |
| 40 | 23 | ||
| 41 | /** | 24 | /** |
| 42 | * 场景类型 | 25 | * 场景类型 |
| @@ -52,4 +35,11 @@ public enum CrmBizEndStatus implements IntArrayValuable { | @@ -52,4 +35,11 @@ public enum CrmBizEndStatus implements IntArrayValuable { | ||
| 52 | return ARRAYS; | 35 | return ARRAYS; |
| 53 | } | 36 | } |
| 54 | 37 | ||
| 38 | + public static CrmBusinessEndStatusEnum fromStatus(Integer status) { | ||
| 39 | + return Arrays.stream(values()) | ||
| 40 | + .filter(value -> value.getStatus().equals(status)) | ||
| 41 | + .findFirst() | ||
| 42 | + .orElse(null); | ||
| 43 | + } | ||
| 44 | + | ||
| 55 | } | 45 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
| @@ -8,10 +8,7 @@ import cn.iocoder.yudao.framework.common.util.number.NumberUtils; | @@ -8,10 +8,7 @@ import cn.iocoder.yudao.framework.common.util.number.NumberUtils; | ||
| 8 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 8 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 9 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 9 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 10 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 10 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 11 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; | ||
| 12 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; | ||
| 13 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; | ||
| 14 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; | 11 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*; |
| 15 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 12 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 16 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; |
| 17 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; |
| @@ -87,6 +84,14 @@ public class CrmBusinessController { | @@ -87,6 +84,14 @@ public class CrmBusinessController { | ||
| 87 | return success(true); | 84 | return success(true); |
| 88 | } | 85 | } |
| 89 | 86 | ||
| 87 | + @PutMapping("/update-status") | ||
| 88 | + @Operation(summary = "更新商机状态") | ||
| 89 | + @PreAuthorize("@ss.hasPermission('crm:business:update')") | ||
| 90 | + public CommonResult<Boolean> updateBusinessStatus(@Valid @RequestBody CrmBusinessUpdateStatusReqVO updateStatusReqVO) { | ||
| 91 | + businessService.updateBusinessStatus(updateStatusReqVO); | ||
| 92 | + return success(true); | ||
| 93 | + } | ||
| 94 | + | ||
| 90 | @DeleteMapping("/delete") | 95 | @DeleteMapping("/delete") |
| 91 | @Operation(summary = "删除商机") | 96 | @Operation(summary = "删除商机") |
| 92 | @Parameter(name = "id", description = "编号", required = true) | 97 | @Parameter(name = "id", description = "编号", required = true) |
| @@ -116,7 +121,8 @@ public class CrmBusinessController { | @@ -116,7 +121,8 @@ public class CrmBusinessController { | ||
| 116 | convertSet(businessProducts, CrmBusinessProductDO::getProductId)); | 121 | convertSet(businessProducts, CrmBusinessProductDO::getProductId)); |
| 117 | businessVO.setProducts(BeanUtils.toBean(businessProducts, CrmBusinessRespVO.Product.class, businessProductVO -> | 122 | businessVO.setProducts(BeanUtils.toBean(businessProducts, CrmBusinessRespVO.Product.class, businessProductVO -> |
| 118 | MapUtils.findAndThen(productMap, businessProductVO.getProductId(), | 123 | MapUtils.findAndThen(productMap, businessProductVO.getProductId(), |
| 119 | - product -> businessProductVO.setProductNo(product.getNo()).setProductUnit(product.getUnit())))); | 124 | + product -> businessProductVO.setProductName(product.getName()) |
| 125 | + .setProductNo(product.getNo()).setProductUnit(product.getUnit())))); | ||
| 120 | return businessVO; | 126 | return businessVO; |
| 121 | } | 127 | } |
| 122 | 128 | ||
| @@ -209,7 +215,8 @@ public class CrmBusinessController { | @@ -209,7 +215,8 @@ public class CrmBusinessController { | ||
| 209 | }); | 215 | }); |
| 210 | // 2.3 设置商机状态 | 216 | // 2.3 设置商机状态 |
| 211 | MapUtils.findAndThen(statusTypeMap, businessVO.getStatusTypeId(), statusType -> businessVO.setStatusTypeName(statusType.getName())); | 217 | MapUtils.findAndThen(statusTypeMap, businessVO.getStatusTypeId(), statusType -> businessVO.setStatusTypeName(statusType.getName())); |
| 212 | - MapUtils.findAndThen(statusMap, businessVO.getStatusId(), status -> businessVO.setStatusName(status.getName())); | 218 | + MapUtils.findAndThen(statusMap, businessVO.getStatusId(), status -> businessVO.setStatusName( |
| 219 | + businessService.getBusinessStatusName(businessVO.getEndStatus(), status))); | ||
| 213 | }); | 220 | }); |
| 214 | } | 221 | } |
| 215 | 222 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessRespVO.java
| @@ -134,7 +134,7 @@ public class CrmBusinessRespVO { | @@ -134,7 +134,7 @@ public class CrmBusinessRespVO { | ||
| 134 | private BigDecimal businessPrice; | 134 | private BigDecimal businessPrice; |
| 135 | 135 | ||
| 136 | @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") | 136 | @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") |
| 137 | - private Integer count; | 137 | + private BigDecimal count; |
| 138 | 138 | ||
| 139 | @Schema(description = "总计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") | 139 | @Schema(description = "总计价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "123.00") |
| 140 | private BigDecimal totalPrice; | 140 | private BigDecimal totalPrice; |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessUpdateStatusReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 4 | +import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import jakarta.validation.constraints.AssertTrue; | ||
| 7 | +import jakarta.validation.constraints.NotNull; | ||
| 8 | +import lombok.Data; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - CRM 商机更新状态 Request VO") | ||
| 11 | +@Data | ||
| 12 | +public class CrmBusinessUpdateStatusReqVO { | ||
| 13 | + | ||
| 14 | + @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") | ||
| 15 | + @NotNull(message = "商机编号不能为空") | ||
| 16 | + private Long id; | ||
| 17 | + | ||
| 18 | + @Schema(description = "状态编号", example = "1") | ||
| 19 | + private Long statusId; | ||
| 20 | + | ||
| 21 | + @Schema(description = "结束状态", example = "1") | ||
| 22 | + @InEnum(value = CrmBusinessEndStatusEnum.class) | ||
| 23 | + private Integer endStatus; | ||
| 24 | + | ||
| 25 | + @AssertTrue(message = "变更状态不正确") | ||
| 26 | + public boolean isStatusValid() { | ||
| 27 | + return statusId != null || endStatus != null; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | +} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java
| @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.business; | @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.business; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | 4 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 5 | -import cn.iocoder.yudao.module.crm.enums.business.CrmBizEndStatus; | 5 | +import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; |
| 6 | import com.baomidou.mybatisplus.annotation.KeySequence; | 6 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 7 | import com.baomidou.mybatisplus.annotation.TableId; | 7 | import com.baomidou.mybatisplus.annotation.TableId; |
| 8 | import com.baomidou.mybatisplus.annotation.TableName; | 8 | import com.baomidou.mybatisplus.annotation.TableName; |
| @@ -77,7 +77,7 @@ public class CrmBusinessDO extends BaseDO { | @@ -77,7 +77,7 @@ public class CrmBusinessDO extends BaseDO { | ||
| 77 | /** | 77 | /** |
| 78 | * 结束状态 | 78 | * 结束状态 |
| 79 | * | 79 | * |
| 80 | - * 枚举 {@link CrmBizEndStatus} | 80 | + * 枚举 {@link CrmBusinessEndStatusEnum} |
| 81 | */ | 81 | */ |
| 82 | private Integer endStatus; | 82 | private Integer endStatus; |
| 83 | /** | 83 | /** |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessProductDO.java
| @@ -10,7 +10,7 @@ import lombok.*; | @@ -10,7 +10,7 @@ import lombok.*; | ||
| 10 | import java.math.BigDecimal; | 10 | import java.math.BigDecimal; |
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| 13 | - * 商机产品关联表 DO | 13 | + * CRM 商机产品关联表 DO |
| 14 | * | 14 | * |
| 15 | * CrmBusinessDO : CrmBusinessProductDO = 1 : N | 15 | * CrmBusinessDO : CrmBusinessProductDO = 1 : N |
| 16 | * | 16 | * |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusDO.java
| @@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.annotation.TableName; | @@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.annotation.TableName; | ||
| 6 | import lombok.*; | 6 | import lombok.*; |
| 7 | 7 | ||
| 8 | /** | 8 | /** |
| 9 | - * 商机状态 DO | 9 | + * CRM 商机状态 DO |
| 10 | + * | ||
| 11 | + * 注意,它是个配置表 | ||
| 10 | * | 12 | * |
| 11 | * @author ljlleo | 13 | * @author ljlleo |
| 12 | */ | 14 | */ |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessStatusTypeDO.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessStatusMapper.java
| @@ -22,4 +22,9 @@ public interface CrmBusinessStatusMapper extends BaseMapperX<CrmBusinessStatusDO | @@ -22,4 +22,9 @@ public interface CrmBusinessStatusMapper extends BaseMapperX<CrmBusinessStatusDO | ||
| 22 | return selectList(CrmBusinessStatusDO::getTypeId, typeId); | 22 | return selectList(CrmBusinessStatusDO::getTypeId, typeId); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | + default CrmBusinessStatusDO selectByTypeIdAndId(Long statusTypeId, Long statusId) { | ||
| 26 | + return selectOne(CrmBusinessStatusDO::getTypeId, statusTypeId, | ||
| 27 | + CrmBusinessStatusDO::getId, statusId); | ||
| 28 | + } | ||
| 29 | + | ||
| 25 | } | 30 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java
| @@ -4,10 +4,13 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -4,10 +4,13 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; | 4 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; |
| 5 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; | 5 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; | 6 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateStatusReqVO; | ||
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; |
| 10 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | ||
| 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | 12 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 13 | +import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; | ||
| 11 | import cn.iocoder.yudao.module.crm.service.business.bo.CrmBusinessUpdateProductReqBO; | 14 | import cn.iocoder.yudao.module.crm.service.business.bo.CrmBusinessUpdateProductReqBO; |
| 12 | import jakarta.validation.Valid; | 15 | import jakarta.validation.Valid; |
| 13 | 16 | ||
| @@ -56,6 +59,13 @@ public interface CrmBusinessService { | @@ -56,6 +59,13 @@ public interface CrmBusinessService { | ||
| 56 | void updateBusinessContactNextTime(Collection<Long> ids, LocalDateTime contactNextTime); | 59 | void updateBusinessContactNextTime(Collection<Long> ids, LocalDateTime contactNextTime); |
| 57 | 60 | ||
| 58 | /** | 61 | /** |
| 62 | + * 更新商机的状态 | ||
| 63 | + * | ||
| 64 | + * @param reqVO 更新请求 | ||
| 65 | + */ | ||
| 66 | + void updateBusinessStatus(CrmBusinessUpdateStatusReqVO reqVO); | ||
| 67 | + | ||
| 68 | + /** | ||
| 59 | * 删除商机 | 69 | * 删除商机 |
| 60 | * | 70 | * |
| 61 | * @param id 编号 | 71 | * @param id 编号 |
| @@ -156,4 +166,18 @@ public interface CrmBusinessService { | @@ -156,4 +166,18 @@ public interface CrmBusinessService { | ||
| 156 | */ | 166 | */ |
| 157 | Long getBusinessCountByStatusTypeId(Long statusTypeId); | 167 | Long getBusinessCountByStatusTypeId(Long statusTypeId); |
| 158 | 168 | ||
| 169 | + /** | ||
| 170 | + * 获得商机状态名称 | ||
| 171 | + * | ||
| 172 | + * @param endStatus 结束状态 | ||
| 173 | + * @param status 商机状态 | ||
| 174 | + * @return 商机状态名称 | ||
| 175 | + */ | ||
| 176 | + default String getBusinessStatusName(Integer endStatus, CrmBusinessStatusDO status) { | ||
| 177 | + if (endStatus != null) { | ||
| 178 | + return CrmBusinessEndStatusEnum.fromStatus(endStatus).getName(); | ||
| 179 | + } | ||
| 180 | + return status.getName(); | ||
| 181 | + } | ||
| 182 | + | ||
| 159 | } | 183 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| @@ -8,9 +8,11 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | @@ -8,9 +8,11 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 8 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; | 8 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; |
| 9 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; | 9 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; |
| 10 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; | 10 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; |
| 11 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateStatusReqVO; | ||
| 11 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; | 12 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO; |
| 12 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; |
| 15 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; | ||
| 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; | 16 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; |
| 15 | import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; | 17 | import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; |
| 16 | import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessProductMapper; | 18 | import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessProductMapper; |
| @@ -44,8 +46,7 @@ import java.util.List; | @@ -44,8 +46,7 @@ import java.util.List; | ||
| 44 | 46 | ||
| 45 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 47 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 46 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | 48 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 47 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_DELETE_FAIL_CONTRACT_EXISTS; | ||
| 48 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; | 49 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| 49 | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; | 50 | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; |
| 50 | 51 | ||
| 51 | /** | 52 | /** |
| @@ -218,6 +219,40 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -218,6 +219,40 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 218 | business.setTotalPrice(business.getTotalProductPrice().subtract(discountPrice)); | 219 | business.setTotalPrice(business.getTotalProductPrice().subtract(discountPrice)); |
| 219 | } | 220 | } |
| 220 | 221 | ||
| 222 | + | ||
| 223 | + @Override | ||
| 224 | + @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_UPDATE_STATUS_SUB_TYPE, bizNo = "{{#reqVO.id}}", | ||
| 225 | + success = CRM_BUSINESS_UPDATE_STATUS_SUCCESS) | ||
| 226 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.WRITE) | ||
| 227 | + public void updateBusinessStatus(CrmBusinessUpdateStatusReqVO reqVO) { | ||
| 228 | + // 1.1 校验存在 | ||
| 229 | + CrmBusinessDO business = validateBusinessExists(reqVO.getId()); | ||
| 230 | + // 1.2 校验商机未结束 | ||
| 231 | + if (business.getEndStatus() != null) { | ||
| 232 | + throw exception(BUSINESS_UPDATE_STATUS_FAIL_END_STATUS); | ||
| 233 | + } | ||
| 234 | + // 1.3 校验商机状态 | ||
| 235 | + CrmBusinessStatusDO status = null; | ||
| 236 | + if (reqVO.getStatusId() != null) { | ||
| 237 | + status = businessStatusService.validateBusinessStatus(business.getStatusTypeId(), reqVO.getStatusId()); | ||
| 238 | + } | ||
| 239 | + // 1.4 校验是不是状态没变更 | ||
| 240 | + if ((reqVO.getStatusId() != null && reqVO.getStatusId().equals(business.getStatusId())) | ||
| 241 | + || (reqVO.getEndStatus() != null && reqVO.getEndStatus().equals(business.getEndStatus()))) { | ||
| 242 | + throw exception(BUSINESS_UPDATE_STATUS_FAIL_STATUS_EQUALS); | ||
| 243 | + } | ||
| 244 | + | ||
| 245 | + // 2. 更新商机状态 | ||
| 246 | + businessMapper.updateById(new CrmBusinessDO().setId(reqVO.getId()).setStatusId(reqVO.getStatusId()) | ||
| 247 | + .setEndStatus(reqVO.getEndStatus())); | ||
| 248 | + | ||
| 249 | + // 3. 记录操作日志上下文 | ||
| 250 | + LogRecordContext.putVariable("businessName", business.getName()); | ||
| 251 | + LogRecordContext.putVariable("oldStatusName", getBusinessStatusName(business.getEndStatus(), | ||
| 252 | + businessStatusService.getBusinessStatus(business.getStatusId()))); | ||
| 253 | + LogRecordContext.putVariable("newStatusName", getBusinessStatusName(reqVO.getEndStatus(), status)); | ||
| 254 | + } | ||
| 255 | + | ||
| 221 | @Override | 256 | @Override |
| 222 | @Transactional(rollbackFor = Exception.class) | 257 | @Transactional(rollbackFor = Exception.class) |
| 223 | @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_DELETE_SUB_TYPE, bizNo = "{{#id}}", | 258 | @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_DELETE_SUB_TYPE, bizNo = "{{#id}}", |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusService.java
| @@ -116,4 +116,20 @@ public interface CrmBusinessStatusService { | @@ -116,4 +116,20 @@ public interface CrmBusinessStatusService { | ||
| 116 | return convertMap(getBusinessStatusList(ids), CrmBusinessStatusDO::getId); | 116 | return convertMap(getBusinessStatusList(ids), CrmBusinessStatusDO::getId); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | + /** | ||
| 120 | + * 获得商机状态 | ||
| 121 | + * | ||
| 122 | + * @param id 编号 | ||
| 123 | + * @return 商机状态 | ||
| 124 | + */ | ||
| 125 | + CrmBusinessStatusDO getBusinessStatus(Long id); | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * 校验商机状态 | ||
| 129 | + * | ||
| 130 | + * @param statusTypeId 商机状态组编号 | ||
| 131 | + * @param statusId 商机状态编号 | ||
| 132 | + */ | ||
| 133 | + CrmBusinessStatusDO validateBusinessStatus(Long statusTypeId, Long statusId); | ||
| 134 | + | ||
| 119 | } | 135 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessStatusServiceImpl.java
| @@ -178,4 +178,18 @@ public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { | @@ -178,4 +178,18 @@ public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { | ||
| 178 | return businessStatusMapper.selectBatchIds(ids); | 178 | return businessStatusMapper.selectBatchIds(ids); |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | + @Override | ||
| 182 | + public CrmBusinessStatusDO getBusinessStatus(Long id) { | ||
| 183 | + return businessStatusMapper.selectById(id); | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + @Override | ||
| 187 | + public CrmBusinessStatusDO validateBusinessStatus(Long statusTypeId, Long statusId) { | ||
| 188 | + CrmBusinessStatusDO status = businessStatusMapper.selectByTypeIdAndId(statusTypeId, statusId); | ||
| 189 | + if (status == null) { | ||
| 190 | + throw exception(BUSINESS_STATUS_NOT_EXISTS); | ||
| 191 | + } | ||
| 192 | + return status; | ||
| 193 | + } | ||
| 194 | + | ||
| 181 | } | 195 | } |