Commit 34ef544f authored by lcl's avatar lcl

客户合作情况相关接口

parent 12fb1e96
......@@ -4,8 +4,8 @@ import com.dsk.common.annotation.RepeatSubmit;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.common.utils.PageUtils;
import com.dsk.system.domain.customer.Customer;
import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto;
import com.dsk.system.domain.customer.dto.CustomerSearchDto;
import com.dsk.system.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -69,8 +69,18 @@ public class CustomerController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('customer:user:list')")
@GetMapping("/user/list")
public AjaxResult selectUserList(){
public AjaxResult userList(){
return AjaxResult.success(baseService.selectUserList());
}
/**
* 获取客户项目(合作情况)列表
*/
@PreAuthorize("@ss.hasPermi('customer:business:list')")
@GetMapping("/business/list")
public TableDataInfo businessList(CustomerBusinessSearchDto dto){
startPage();
return getDataTable(baseService.selectBusinessList(dto));
}
}
......@@ -54,6 +54,10 @@ public class BusinessAddDto {
* 可见范围
*/
private Integer isPrivate;
/**
* 客户id
*/
private String customerId;
public Double getInvestmentAmount() {
return Double.parseDouble(investmentAmount);
......
package com.dsk.system.domain.customer.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 客户合作情况筛选对象
* @author lcl
* @create 2023/5/16
*/
@Data
public class CustomerBusinessSearchDto implements Serializable {
/**
* 企业id
*/
private String customerId;
/**
* 企业id
*/
private Long userId;
/**
* 项目阶段
*/
private String projectStage;
/**
* 项目状态
*/
private Integer status;
}
package com.dsk.system.domain.customer.vo;
import lombok.Data;
import java.io.Serializable;
/**
* 客户合作情况列表对象
*
* @author lcl
* @create 2023/5/22
*/
@Data
public class CustomerBusinessListVo implements Serializable {
/**
* 项目id
*/
private Integer id;
/**
* 项目名称
*/
private String projcetName;
/**
* 项目阶段
*/
private String projectStage;
/**
* 投资金额
*/
private String investmentAmount;
/**
* 状态
*/
private Integer status;
}
......@@ -37,7 +37,11 @@ public class CustomerListVo {
/**
* 注册资本(字符串)
*/
private String registerCapitalStr;
private String registerCapital;
/**
* 社会统一信用代码
*/
private String creditCode;
/**
* 企业性质
*/
......
......@@ -2,10 +2,12 @@ package com.dsk.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dsk.common.core.domain.entity.BusinessInfo;
import com.dsk.common.dtos.BusinessInfoDto;
import com.dsk.system.domain.BusinessAddDto;
import com.dsk.system.domain.BusinessListDto;
import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto;
import com.dsk.system.domain.customer.vo.CustomerBusinessListVo;
import com.dsk.system.domain.vo.BusinessListVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -15,7 +17,8 @@ import java.util.List;
* @author lxl
* @date 2023-05-17
*/
public interface BusinessInfoMapper
@Mapper
public interface BusinessInfoMapper extends BaseMapper<BusinessInfo>
{
/**
* 查询项目详情
......@@ -70,4 +73,9 @@ public interface BusinessInfoMapper
* @return 结果
*/
public int deleteBusinessInfoByIds(Long[] ids);
int selectCountByStatusAndCustomerId(@Param("status") Integer status,@Param("customerId") String customerId);
List<CustomerBusinessListVo> selectCustomerBusinessList(CustomerBusinessSearchDto dto);
}
......@@ -21,5 +21,9 @@ public interface CustomerMapper extends BaseMapper<Customer> {
List<CustomerListVo> selectList(@Param("dto") CustomerSearchDto dto);
List<Customer> selectUserList(Long userId);
Customer selectByCompanyIdAndUserId(@Param("companyId")Integer companyId,@Param("userId")Long userId);
}
......@@ -5,6 +5,8 @@ import com.dsk.common.core.domain.entity.BusinessInfo;
import com.dsk.common.dtos.BusinessInfoDto;
import com.dsk.system.domain.BusinessAddDto;
import com.dsk.system.domain.BusinessListDto;
import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto;
import com.dsk.system.domain.customer.vo.CustomerBusinessListVo;
import com.dsk.system.domain.vo.BusinessListVo;
import java.util.List;
......@@ -70,4 +72,9 @@ public interface IBusinessInfoService
* @return 结果
*/
public int deleteBusinessInfoById(Long id);
int selectCountByStatusAndCustomerId(Integer status,String customerId);
List<CustomerBusinessListVo> selectCustomerBusinessList(CustomerBusinessSearchDto dto);
}
package com.dsk.system.service;
import com.dsk.system.domain.customer.Customer;
import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto;
import com.dsk.system.domain.customer.dto.CustomerSearchDto;
import com.dsk.system.domain.customer.vo.CustomerBusinessListVo;
import com.dsk.system.domain.customer.vo.CustomerListVo;
import com.dsk.system.domain.customer.vo.CustomerVo;
......@@ -25,4 +27,6 @@ public interface ICustomerService {
List<Customer> selectUserList();
List<CustomerBusinessListVo> selectBusinessList(CustomerBusinessSearchDto dto);
}
......@@ -13,6 +13,8 @@ import com.dsk.common.utils.DateUtils;
import com.dsk.common.utils.SecurityUtils;
import com.dsk.system.domain.BusinessAddDto;
import com.dsk.system.domain.BusinessListDto;
import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto;
import com.dsk.system.domain.customer.vo.CustomerBusinessListVo;
import com.dsk.system.domain.vo.BusinessListVo;
import com.dsk.system.mapper.BusinessInfoMapper;
import com.dsk.system.mapper.BusinessRelateCompanyMapper;
......@@ -31,8 +33,7 @@ import javax.annotation.Resource;
* @date 2023-05-17
*/
@Service
public class BusinessInfoServiceImpl implements IBusinessInfoService
{
public class BusinessInfoServiceImpl implements IBusinessInfoService {
@Resource
private BusinessInfoMapper businessInfoMapper;
@Resource
......@@ -47,8 +48,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService
* @return 项目详情
*/
@Override
public BusinessInfo selectBusinessInfoById(Long id)
{
public BusinessInfo selectBusinessInfoById(Long id) {
return businessInfoMapper.selectBusinessInfoById(id);
}
......@@ -59,8 +59,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService
* @return 项目详情
*/
@Override
public List<BusinessListVo> selectBusinessInfoList(BusinessListDto dto)
{
public List<BusinessListVo> selectBusinessInfoList(BusinessListDto dto) {
return businessInfoMapper.selectBusinessInfoList(dto);
}
......@@ -77,13 +76,12 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService
*/
@Override
@Transactional
public AjaxResult insertBusinessInfo(BusinessAddDto dto)
{
public AjaxResult insertBusinessInfo(BusinessAddDto dto) {
//新增项目主信息
BusinessInfo businessInfo = new BusinessInfo();
BeanUtil.copyProperties(dto,businessInfo);
BeanUtil.copyProperties(dto, businessInfo);
int addBusiness = businessInfoMapper.insertBusinessInfo(businessInfo);
if(addBusiness > 0){
if (addBusiness > 0) {
//获取登陆用户的部门id
// Long deptId = SecurityUtils.getLoginUser().getDeptId();
Long deptId = 100l;
......@@ -91,7 +89,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService
int addbusinessUser = businessUserMapper.insertBusinessUser(new BusinessUser(businessInfo.getId(), deptId.intValue(), dto.getUserId(), 1));
//新增项目-关联企业信息
int addRelateCompany = businessRelateCompanyMapper.insertBusinessRelateCompany(new BusinessRelateCompany(businessInfo.getId(), dto.getCompanyId(), dto.getOwnerCompany(), "业主"));
return addbusinessUser>0 && addRelateCompany>0 ? AjaxResult.success() : AjaxResult.error();
return addbusinessUser > 0 && addRelateCompany > 0 ? AjaxResult.success() : AjaxResult.error();
}
return AjaxResult.error();
......@@ -104,8 +102,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService
* @return 结果
*/
@Override
public int updateBusinessInfo(BusinessInfo businessInfo)
{
public int updateBusinessInfo(BusinessInfo businessInfo) {
businessInfo.setUpdateTime(DateUtils.getNowDate());
return businessInfoMapper.updateBusinessInfo(businessInfo);
}
......@@ -117,8 +114,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService
* @return 结果
*/
@Override
public int deleteBusinessInfoByIds(Long[] ids)
{
public int deleteBusinessInfoByIds(Long[] ids) {
return businessInfoMapper.deleteBusinessInfoByIds(ids);
}
......@@ -129,8 +125,24 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService
* @return 结果
*/
@Override
public int deleteBusinessInfoById(Long id)
{
public int deleteBusinessInfoById(Long id) {
return businessInfoMapper.deleteBusinessInfoById(id);
}
/**
* 查询项目数量
*
* @param status 项目状态
* @param customerId 客户id
* @return 项目数量
*/
@Override
public int selectCountByStatusAndCustomerId(Integer status, String customerId) {
return businessInfoMapper.selectCountByStatusAndCustomerId(status, customerId);
}
@Override
public List<CustomerBusinessListVo> selectCustomerBusinessList(CustomerBusinessSearchDto dto) {
return businessInfoMapper.selectCustomerBusinessList(dto);
}
}
......@@ -4,15 +4,17 @@ import cn.hutool.core.bean.BeanException;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsk.common.exception.ServiceException;
import com.dsk.common.utils.DskOpenApiUtil;
import com.dsk.common.utils.SecurityUtils;
import com.dsk.system.domain.customer.Customer;
import com.dsk.system.domain.customer.CustomerUser;
import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto;
import com.dsk.system.domain.customer.dto.CustomerSearchDto;
import com.dsk.system.domain.customer.vo.CustomerBusinessListVo;
import com.dsk.system.domain.customer.vo.CustomerListVo;
import com.dsk.system.domain.customer.vo.CustomerVo;
import com.dsk.system.mapper.CustomerMapper;
import com.dsk.system.mapper.CustomerUserMapper;
import com.dsk.system.service.IBusinessInfoService;
import com.dsk.system.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -35,23 +37,21 @@ public class CustomerServiceImpl implements ICustomerService {
private CustomerMapper baseMapper;
@Resource
private CustomerUserMapper customerUserMapper;
@Autowired
private DskOpenApiUtil dskOpenApiUtil;
private IBusinessInfoService businessInfoService;
@Override
public List<CustomerListVo> selectList(CustomerSearchDto dto) {
dto.setUserId(SecurityUtils.getUserId());
List<CustomerListVo> vos = baseMapper.selectList(dto);
for (CustomerListVo vo : vos) {
//TODO 客户项目相关统计
vos.parallelStream().forEach(vo -> {
//合作项目
vo.setCooperationProject(1);
vo.setCooperationProject(businessInfoService.selectCountByStatusAndCustomerId(2, vo.getCustomerId()));
//跟进项目
vo.setFollowProject(1);
vo.setFollowProject(businessInfoService.selectCountByStatusAndCustomerId(1, vo.getCustomerId()));
//储备项目
vo.setReserveProject(1);
}
vo.setReserveProject(businessInfoService.selectCountByStatusAndCustomerId(0, vo.getCustomerId()));
});
return vos;
}
......@@ -69,9 +69,15 @@ public class CustomerServiceImpl implements ICustomerService {
@Transactional(rollbackFor = Exception.class)
public boolean add(Customer customer) {
if (ObjectUtils.isEmpty(customer.getCompanyName())) throw new BeanException("企业名称不能为空");
if (ObjectUtils.isEmpty(customer.getCompanyId())) throw new BeanException("企业id不能为空");
final Long userId = SecurityUtils.getUserId();
customer.setCreateId(userId);
customer.setUpdateId(userId);
//查重
Customer verifyCustomer = baseMapper.selectByCompanyIdAndUserId(customer.getCompanyId(), userId);
if (!ObjectUtils.isEmpty(verifyCustomer)) {
throw new ServiceException("当前客户信息已存在,请勿重复添加!");
}
int i = baseMapper.insert(customer);
if (i == 0) throw new ServiceException("客户信息添加错误!");
......@@ -93,6 +99,13 @@ public class CustomerServiceImpl implements ICustomerService {
@Override
public List<Customer> selectUserList() {
return baseMapper.selectList(Wrappers.<Customer>lambdaQuery());
return baseMapper.selectUserList(SecurityUtils.getUserId());
}
@Override
public List<CustomerBusinessListVo> selectBusinessList(CustomerBusinessSearchDto dto) {
if (ObjectUtils.isEmpty(dto.getCustomerId())) throw new BeanException("客户id不能为空");
dto.setUserId(SecurityUtils.getUserId());
return businessInfoService.selectCustomerBusinessList(dto);
}
}
......@@ -236,4 +236,23 @@
#{id}
</foreach>
</delete>
<select id="selectCountByStatusAndCustomerId" resultType="java.lang.Integer">
select count(id) from business_info
<where>
<if test="status != null "> and `status` = #{status} </if>
<if test="customerId != null and customerId != ''"> and `customer_id` = #{customerId} </if>
</where>
</select>
<select id="selectCustomerBusinessList" resultType="com.dsk.system.domain.customer.vo.CustomerBusinessListVo">
select
bi.id, bi.project_name, pi.investment_amount, pi.project_stage, pi.status
from business_info bi
left join business_user bu on bi.id = bu.business_id
where bi.customer_id = #{customerId} and (bu.user_id = #{userId} or bi.is_private = 1))
<if test="projectStage != null and projectStage != '' "> and bi.project_stage = #{projectStage}</if>
<if test="status != null "> and bi.status = #{status}</if>
order by bi.create_time desc
</select>
</mapper>
......@@ -2,13 +2,18 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dsk.system.mapper.CustomerMapper">
<select id="selectList" resultType="com.dsk.system.domain.customer.vo.CustomerListVo">
select
ct.customer_id, ct.company_id, ct.company_name, ct.legal_person, ct.register_capital_str,
<sql id="Base_Bean">
ct.customer_id, ct.company_id, ct.company_name, ct.legal_person, ct.credit_code,
ct.register_capital, ct.company_nature, ct.company_level, ct.credit_level, ct.super_company,
ct.is_on, ct.is_major, ct.company_attribute, ct.main_business, ct.business_scope,
ct.business_characteristic, ct.decision_chain, ct.bid_characteristic, ct.performance_characteristic,
ct.other_ms_characteistic, u.nick_name followUser
ct.other_ms_characteistic, ct.create_id, ct.create_time, ct.update_id, ct.update_time
</sql>
<select id="selectList" resultType="com.dsk.system.domain.customer.vo.CustomerListVo">
select
u.nick_name followUser,
<include refid="Base_Bean"></include>
from customer ct
join customer_user ctu on ct.customer_id = ctu.customer_id
join sys_user u on ctu.user_id = u.user_id
......@@ -16,5 +21,21 @@
<if test="dto.companyName != null and dto.companyName != '' "> and ct.company_name like concat('%',#{dto.companyName},'%')</if>
</select>
<select id="selectUserList" resultType="com.dsk.system.domain.customer.Customer">
select
ct.customer_id, ct.company_name
from customer ct
join customer_user ctu on ct.customer_id = ctu.customer_id
where ctu.user_id = #{userId}
</select>
<select id="selectByCompanyIdAndUserId" resultType="com.dsk.system.domain.customer.Customer">
select
<include refid="Base_Bean"></include>
from customer ct
join customer_user ctu on ct.customer_id = ctu.customer_id
where ct.company_id = ${companyId} and ctu.user_id = #{userId}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment