客户管理

This commit is contained in:
PQZ 2024-08-01 17:23:57 +08:00
parent db38ccc609
commit a9fe1187de
11 changed files with 244 additions and 184 deletions

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.common;
/**
* 字典编码常量类
* @author PQZ
* @date 16:20 2024/8/1
**/
public class DictBaseConstants {
/**客户类型字典编码*/
public static final String DICT_CUS_TYPE = "cus_type";
/**客户初始来源字典编码*/
public static final String DICT_CUS_DATA_FROM = "cus_data_from";
/**业务分类字典编码*/
public static final String DICT_CUS_BUSI_TYPE = "cus_busi_type";
/**客户注册方式字典编码*/
public static final String DICT_SIGN_TYPE = "cus_sign_type";
/**性别*/
public static final String DICT_SYS_USER_SEX = "system_user_sex";
}

View File

@ -1,4 +0,0 @@
package cn.iocoder.yudao.common;
public interface TestCommon {
}

View File

@ -1,15 +1,6 @@
package cn.iocoder.yudao.module.custom.controller.admin;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
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.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.company.entity.DlCompany;
import cn.iocoder.yudao.module.company.service.DlCompanyService;
import cn.iocoder.yudao.module.company.vo.CompanyReqVO;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
@ -24,17 +15,13 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* 客户管理每个租户的下属客户信息
* 客户管理每个租户的下的客户信息
*
* @author : http://www.chiner.pro
* @date : 2024-7-31
*/
@ -43,20 +30,67 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - BASE 企业管理")
@Validated
public class CustomerMainController {
@Autowired
private CustomerMainService customerMainService;
/**
* 客户管理分页列表查询
*
* @param pageReqVO 客户管理查询条件封装实体
* @param pageNo 分页参数
* @param pageSize 分页参数
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<com.baomidou.mybatisplus.core.metadata.IPage < ?>>
* @author PQZ
* @date 14:56 2024/8/1
**/
@GetMapping("/page")
@Operation(summary = "获得客户管理分页")
@PreAuthorize("@ss.hasPermission('base:customer-main:query')")
public CommonResult<IPage<?>> getCustomerMainPage(CustomerMainPageReqVO pageReqVO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<CustomerMainRespVO> page = new Page<>(pageNo, pageSize);
return success(customerMainService.queryListPage(pageReqVO, page));
}
/**
* 新增客户
*
* @param saveReqVO 保存客户信息扩展实体
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
* @author PQZ
* @date 15:42 2024/8/1
**/
@PostMapping("/create")
@Operation(summary = "创建客户管理")
@PreAuthorize("@ss.hasPermission('base:customer-main:create')")
public CommonResult<Boolean> createCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO createReqVO) {
public CommonResult<Boolean> createCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
return success(true);
}
/**
* 编辑客户
*
* @param saveReqVO 保存客户信息扩展实体
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
* @author PQZ
* @date 15:44 2024/8/1
**/
@PutMapping("/update")
@Operation(summary = "更新客户管理")
@PreAuthorize("@ss.hasPermission('base:customer-main:update')")
public CommonResult<Boolean> updateCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO updateReqVO) {
public CommonResult<Boolean> updateCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
return success(true);
}
/**
* 删除客户
*
* @param id 保存客户信息扩展实体
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
* @author PQZ
* @date 15:44 2024/8/1
**/
@DeleteMapping("/delete")
@Operation(summary = "删除客户管理")
@Parameter(name = "id", description = "编号", required = true)
@ -65,6 +99,14 @@ public class CustomerMainController {
return success(true);
}
/**
* 通过客户id查询客户信息
*
* @param id 客户id
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
* @author PQZ
* @date 15:44 2024/8/1
**/
@GetMapping("/get")
@Operation(summary = "获得客户管理")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@ -73,23 +115,4 @@ public class CustomerMainController {
return success(true);
}
@GetMapping("/page")
@Operation(summary = "获得客户管理分页")
@PreAuthorize("@ss.hasPermission('base:customer-main:query')")
public CommonResult<Boolean> getCustomerMainPage(@Valid CustomerMainPageReqVO pageReqVO) {
return success(true);
}
@GetMapping("/export-excel")
@Operation(summary = "导出客户管理 Excel")
@PreAuthorize("@ss.hasPermission('base:customer-main:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportCustomerMainExcel(@Valid CustomerMainPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
// List<CustomerMain> list = customerMainService.getCustomerMainPage(pageReqVO).getList();
// // 导出 Excel
// ExcelUtils.write(response, "客户管理.xls", "数据", CustomerMainRespVO.class,
// BeanUtils.toBean(list, CustomerMainRespVO.class));
}
}

View File

@ -1,11 +1,15 @@
package cn.iocoder.yudao.module.custom.entity;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.time.LocalDateTime;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.*;
import static cn.iocoder.yudao.common.DictBaseConstants.*;
/**
* 客户管理 DO
@ -13,7 +17,6 @@ import com.baomidou.mybatisplus.annotation.*;
* @author pqz
*/
@TableName("base_customer_main")
@KeySequence("base_customer_main_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ -25,7 +28,7 @@ public class CustomerMain extends TenantBaseDO {
/**
* uuid
*/
@TableId(type = IdType.INPUT)
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/**
* sys_user表id
@ -34,6 +37,7 @@ public class CustomerMain extends TenantBaseDO {
/**
* 用户类型
*/
@DictFormat(DICT_CUS_TYPE)
private String typeCode;
/**
* 所属企业code部门表code
@ -50,7 +54,7 @@ public class CustomerMain extends TenantBaseDO {
/**
* 生日
*/
private LocalDateTime birthday;
private Date birthday;
/**
* 住址
*/
@ -58,6 +62,7 @@ public class CustomerMain extends TenantBaseDO {
/**
* 性别
*/
@DictFormat(DICT_SYS_USER_SEX)
private String sex;
/**
* 身份证号
@ -70,14 +75,16 @@ public class CustomerMain extends TenantBaseDO {
/**
* 客户初始来源
*/
@DictFormat(DICT_CUS_DATA_FROM)
private String dataFrom;
/**
* 最近业务办理时间
*/
private LocalDateTime nearDoTime;
private Date nearDoTime;
/**
* 最近办理业务数据字典业务标识
*/
@DictFormat(DICT_CUS_BUSI_TYPE)
private String nearDoContent;
/**
* 邀请者user_id
@ -86,6 +93,7 @@ public class CustomerMain extends TenantBaseDO {
/**
* 邀请者类型
*/
@DictFormat(DICT_SIGN_TYPE)
private String inviterType;
/**
* 客户状态

View File

@ -1,8 +1,15 @@
package cn.iocoder.yudao.module.custom.mapper;
import cn.iocoder.yudao.module.company.entity.DlCompany;
import cn.iocoder.yudao.module.company.vo.CompanyReqVO;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 客户管理 Mapper
@ -12,5 +19,16 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CustomerMainMapper extends BaseMapper<CustomerMain> {
/**
* 客户管理分页列表查询
*
* @param pageReqVO 客户管理查询条件封装实体
* @param page 分页参数
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO>
* @author PQZ
* @date 15:01 2024/8/1
**/
IPage<CustomerMainRespVO> selectListPage(@Param("entity") CustomerMainPageReqVO pageReqVO, Page<CustomerMainRespVO> page);
}

View File

@ -1,7 +1,13 @@
package cn.iocoder.yudao.module.custom.service;
import cn.iocoder.yudao.module.company.entity.DlCompany;
import cn.iocoder.yudao.module.company.vo.CompanyReqVO;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
/**
@ -9,8 +15,27 @@ import com.baomidou.mybatisplus.extension.service.IService;
*
* @author pqz
*/
public interface CustomerMainService extends IService<CustomerMain> {
public interface CustomerMainService extends IService<CustomerMain> {
/**
* 客户管理分页列表查询
*
* @param pageReqVO 客户管理查询条件封装实体
* @param page 分页参数
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO>
* @author PQZ
* @date 14:57 2024/8/1
**/
IPage<CustomerMainRespVO> queryListPage(CustomerMainPageReqVO pageReqVO, Page<CustomerMainRespVO> page);
/**
* 保存客户信息
*
* @param saveReqVO 保存客户信息扩展实体
* @return void
* @author PQZ
* @date 15:46 2024/8/1
**/
void saveCustomer(CustomerMainSaveReqVO saveReqVO);
}

View File

@ -1,9 +1,16 @@
package cn.iocoder.yudao.module.custom.service.impl;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import cn.iocoder.yudao.module.custom.mapper.CustomerMainMapper;
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -16,4 +23,34 @@ import org.springframework.validation.annotation.Validated;
@Validated
public class CustomerMainServiceImpl extends ServiceImpl<CustomerMainMapper, CustomerMain> implements CustomerMainService {
@Autowired
private CustomerMainMapper customerMainMapper;
/**
* 客户管理分页列表查询
*
* @param pageReqVO 客户管理查询条件封装实体
* @param page 分页参数
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO>
* @author PQZ
* @date 14:57 2024/8/1
**/
@Override
public IPage<CustomerMainRespVO> queryListPage(CustomerMainPageReqVO pageReqVO, Page<CustomerMainRespVO> page) {
return customerMainMapper.selectListPage(pageReqVO,page);
}
/**
* 保存客户信息
*
* @param saveReqVO 保存客户信息扩展实体
* @return void
* @author PQZ
* @date 15:46 2024/8/1
**/
@Override
public void saveCustomer(CustomerMainSaveReqVO saveReqVO) {
CustomerMain main = JSONUtil.toBean(JSONUtil.parseObj(saveReqVO).toJSONString(0), CustomerMain.class);
this.saveOrUpdate(main);
}
}

View File

@ -1,71 +1,17 @@
package cn.iocoder.yudao.module.custom.vo;
import lombok.*;
import java.util.*;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
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;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 客户管理分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CustomerMainPageReqVO extends PageParam {
@Schema(description = "sys_user表id", example = "17679")
private String userId;
@Schema(description = "用户类型")
private String typeCode;
@Schema(description = "所属企业code部门表code")
private String deptCode;
@Schema(description = "客户名称(政企客户填企业名称)", example = "赵六")
private String cusName;
@Schema(description = "联系方式")
private String phoneNumber;
@Schema(description = "生日")
private LocalDateTime birthday;
@Schema(description = "住址")
private String address;
@Schema(description = "性别")
private String sex;
@Schema(description = "身份证号")
private String idCard;
@Schema(description = "身份证照片")
private String idCardImage;
@Schema(description = "客户初始来源")
private String dataFrom;
@Schema(description = "最近业务办理时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] nearDoTime;
@Schema(description = "最近办理业务(数据字典业务标识)")
private String nearDoContent;
@Schema(description = "邀请者user_id")
private String inviter;
@Schema(description = "邀请者类型", example = "2")
private String inviterType;
@Schema(description = "客户状态", example = "1")
private String status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
public class CustomerMainPageReqVO extends CustomerMain {
/**系统标识*/
private String systemCode;
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.custom.vo;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -10,78 +11,19 @@ import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 客户管理 Response VO")
@Data
@ExcelIgnoreUnannotated
public class CustomerMainRespVO {
@Schema(description = "uuid", requiredMode = Schema.RequiredMode.REQUIRED, example = "29951")
@ExcelProperty("uuid")
private String id;
@Schema(description = "sys_user表id", example = "17679")
@ExcelProperty("sys_user表id")
private String userId;
@Schema(description = "用户类型")
@ExcelProperty("用户类型")
private String typeCode;
@Schema(description = "所属企业code部门表code")
@ExcelProperty("所属企业code部门表code")
private String deptCode;
@Schema(description = "客户名称(政企客户填企业名称)", example = "赵六")
@ExcelProperty("客户名称(政企客户填企业名称)")
private String cusName;
@Schema(description = "联系方式")
@ExcelProperty("联系方式")
private String phoneNumber;
@Schema(description = "生日")
@ExcelProperty("生日")
private LocalDateTime birthday;
@Schema(description = "住址")
@ExcelProperty("住址")
private String address;
@Schema(description = "性别")
@ExcelProperty("性别")
private String sex;
@Schema(description = "身份证号")
@ExcelProperty("身份证号")
private String idCard;
@Schema(description = "身份证照片")
@ExcelProperty("身份证照片")
private String idCardImage;
@Schema(description = "客户初始来源")
@ExcelProperty("客户初始来源")
private String dataFrom;
@Schema(description = "最近业务办理时间")
@ExcelProperty("最近业务办理时间")
private LocalDateTime nearDoTime;
@Schema(description = "最近办理业务(数据字典业务标识)")
@ExcelProperty("最近办理业务(数据字典业务标识)")
private String nearDoContent;
@Schema(description = "邀请者user_id")
@ExcelProperty("邀请者user_id")
private String inviter;
@Schema(description = "邀请者类型", example = "2")
@ExcelProperty("邀请者类型")
private String inviterType;
@Schema(description = "客户状态", example = "1")
@ExcelProperty("客户状态")
private String status;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
public class CustomerMainRespVO extends CustomerMain {
/**客户管理子表id*/
private String itemId;
/**系统标识*/
private String systemCode;
/**用户等级*/
private String userLevel;
/**服务内容*/
private String serContent;
/**服务开始时间*/
private Date serTimeStart;
/**服务结束时间*/
private Date serTimeEnd;
/**大json*/
private String bigJson;
}

View File

@ -2,11 +2,54 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.custom.mapper.CustomerMainMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectListPage" resultType="cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO">
SELECT
main.id AS id,
main.user_id AS userId,
main.type_code AS typeCode,
main.dept_code AS deptCode,
main.cus_name AS cusName,
main.phone_number AS phoneNumber,
main.birthday AS birthday,
main.address AS address,
main.sex AS sex,
main.id_card AS idCard,
main.id_card_image AS idCardImage,
main.data_from AS dataFrom,
main.near_do_time AS nearDoTime,
main.near_do_content AS nearDoContent,
main.inviter AS inviter,
main.inviter_type AS inviterType,
main.status AS status,
item.id AS itemId,
item.system_code AS systemCode,
item.user_level AS userLevel,
item.ser_content AS serContent,
item.ser_time_start AS serTimeStart,
item.ser_time_end AS serTimeEnd,
item.big_json AS bigJson
FROM
base_customer_main main
LEFT JOIN base_customer_item item ON main.id = item.cus_id
<where>
main.deleted = 0
<if test="entity.cusName != null and entity.cusName != ''">
AND main.cus_name LIKE concat('%',#{entity.cusName},'%')
</if>
<if test="entity.typeCode != null and entity.typeCode != ''">
AND main.type_code = #{entity.typeCode}
</if>
<if test="entity.systemCode != null and entity.systemCode != ''">
AND item.system_code = #{entity.systemCode}
</if>
</where>
ORDER BY main.create_time DESC
</select>
</mapper>

View File

@ -175,7 +175,8 @@ logging:
cn.iocoder.yudao.module.crm.dal.mysql: debug
cn.iocoder.yudao.module.erp.dal.mysql: debug
org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿先禁用Spring Boot 3.X 存在部分错误的 WARN 提示
cn.iocoder.yudao.module.custom.mapper.DlCompanyMapper: debug #
cn.iocoder.yudao.module.custom.mapper: debug #
cn.iocoder.yudao.module.company.mapper: debug #
debug: false