mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
Merge branch 'feature/crm' of https://gitee.com/SummerQing/ruoyi-vue-pro into feature/crm
# Conflicts: # yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.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/service/customer/CrmCustomerServiceImpl.java
This commit is contained in:
commit
e519b41244
@ -34,6 +34,10 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
// ========== 客户管理 1_020_006_000 ==========
|
// ========== 客户管理 1_020_006_000 ==========
|
||||||
ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_006_000, "客户不存在");
|
ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_006_000, "客户不存在");
|
||||||
|
ErrorCode CUSTOMER_OWNER_EXISTS = new ErrorCode(1_020_006_001, "客户已存在所属负责人");
|
||||||
|
ErrorCode CUSTOMER_LOCKED = new ErrorCode(1_020_006_002, "客户状态已锁定");
|
||||||
|
ErrorCode CUSTOMER_ALREADY_DEAL = new ErrorCode(1_020_006_003, "客户已交易");
|
||||||
|
// TODO @wanwan:这 2 个单独配置段噢
|
||||||
ErrorCode CUSTOMER_POOL_CONFIG_ERROR = new ErrorCode(1_020_006_001, "客户公海规则设置不正确");
|
ErrorCode CUSTOMER_POOL_CONFIG_ERROR = new ErrorCode(1_020_006_001, "客户公海规则设置不正确");
|
||||||
ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_006_002, "客户限制配置不存在");
|
ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_006_002, "客户限制配置不存在");
|
||||||
|
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.customer;
|
package cn.iocoder.yudao.module.crm.controller.admin.customer;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||||
|
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
@ -21,6 +25,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -33,6 +38,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
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.convertMap;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
@ -178,4 +184,28 @@ public class CrmCustomerController {
|
|||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("/receive")
|
||||||
|
@Operation(summary = "根据客户id领取公海任务")
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:customer:receive')")
|
||||||
|
public CommonResult<String> receiveByIds(List<Long> cIds){
|
||||||
|
// 判断是否为空
|
||||||
|
if(CollectionUtils.isEmpty(cIds))
|
||||||
|
return error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(),GlobalErrorCodeConstants.BAD_REQUEST.getMsg());
|
||||||
|
// 领取公海任务
|
||||||
|
customerService.receive(cIds);
|
||||||
|
return success("领取成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/distributeByIds")
|
||||||
|
@Operation(summary = "分配公海给对应负责人")
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:customer:distributeByIds')")
|
||||||
|
public CommonResult<String> distributeByIds(Long ownerId,List<Long>cIds){
|
||||||
|
//判断参数不能为空
|
||||||
|
if(ownerId==null || CollectionUtils.isEmpty(cIds))
|
||||||
|
return error(GlobalErrorCodeConstants.BAD_REQUEST.getCode(),GlobalErrorCodeConstants.BAD_REQUEST.getMsg());
|
||||||
|
customerService.distributeByIds(cIds,ownerId);
|
||||||
|
return success("分配成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -85,4 +85,20 @@ public interface CrmCustomerService {
|
|||||||
*/
|
*/
|
||||||
void lockCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO);
|
void lockCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述 :接受公海客户
|
||||||
|
* Author :xiaqing
|
||||||
|
* Date :2023-11-07 22:47:40
|
||||||
|
*/
|
||||||
|
void receive(List<Long>ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*功能描述: 分配负责人
|
||||||
|
* @param cIds 要分配的客户id
|
||||||
|
* @param ownerId 分配的负责人id
|
||||||
|
* @author xiaqing
|
||||||
|
* @date 2023-11-08 10:40:22
|
||||||
|
*/
|
||||||
|
void distributeByIds(List<Long>cIds,Long ownerId);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
|
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.convert.customer.CrmCustomerConvert;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||||
@ -21,6 +22,8 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -28,6 +31,7 @@ import java.util.Set;
|
|||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
|
||||||
|
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户 Service 实现类
|
* 客户 Service 实现类
|
||||||
@ -162,4 +166,56 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
|||||||
customerMapper.updateById(updateObj);
|
customerMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void receive(List <Long> ids) {
|
||||||
|
transferCustomerOwner(ids,SecurityFrameworkUtils.getLoginUserId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void distributeByIds(List <Long> cIds, Long ownerId) {
|
||||||
|
transferCustomerOwner(cIds,ownerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void transferCustomerOwner(List <Long> cIds, Long ownerId){
|
||||||
|
//先一次性校验完成客户是否可用
|
||||||
|
for (Long cId : cIds) {
|
||||||
|
//校验是否存在
|
||||||
|
validateCustomerExists(cId);
|
||||||
|
//todo 校验是否已有负责人
|
||||||
|
validCustomerOwnerExist(cId);
|
||||||
|
//todo 校验是否锁定
|
||||||
|
validCustomerIsLocked(cId);
|
||||||
|
//todo 校验成交状态
|
||||||
|
validCustomerDeal(cId);
|
||||||
|
}
|
||||||
|
List<CrmCustomerDO> updateDos = new ArrayList <>();
|
||||||
|
for (Long cId : cIds){
|
||||||
|
CrmCustomerDO customerDO = new CrmCustomerDO();
|
||||||
|
customerDO.setId(cId);
|
||||||
|
customerDO.setOwnerUserId(SecurityFrameworkUtils.getLoginUserId());
|
||||||
|
}
|
||||||
|
//统一修改状态
|
||||||
|
customerMapper.updateBatch(updateDos);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validCustomerOwnerExist(Long id) {
|
||||||
|
if (customerMapper.selectById(id).getOwnerUserId()!=null) {
|
||||||
|
throw exception(CUSTOMER_OWNER_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validCustomerIsLocked(Long id) {
|
||||||
|
if (customerMapper.selectById(id).getLockStatus() ==true) {
|
||||||
|
throw exception(CUSTOMER_LOCKED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validCustomerDeal(Long id) {
|
||||||
|
if (customerMapper.selectById(id).getDealStatus() ==true) {
|
||||||
|
throw exception(CUSTOMER_DEALED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user