crm: 增加基于客户查询回款计划分页

This commit is contained in:
YunaiV
2023-12-01 22:46:13 +08:00
parent f02b9464bd
commit 72969e921e
25 changed files with 241 additions and 578 deletions

View File

@@ -1,4 +0,0 @@
/**
* 线索
*/
package cn.iocoder.yudao.module.crm.controller.admin.clue;

View File

@@ -1,4 +0,0 @@
/**
* 产品表
*/
package cn.iocoder.yudao.module.crm.controller.admin.product;

View File

@@ -99,7 +99,7 @@ public class CrmReceivableController {
@GetMapping("/page-by-customer")
@Operation(summary = "获得回款分页,基于指定客户")
public CommonResult<PageResult<CrmReceivableRespVO>> getContractPageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) {
public CommonResult<PageResult<CrmReceivableRespVO>> getReceivablePageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) {
Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空");
PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePageByCustomer(pageReqVO);
return success(convertDetailReceivablePage(pageResult));
@@ -125,19 +125,19 @@ public class CrmReceivableController {
* @return 详细的回款分页
*/
private PageResult<CrmReceivableRespVO> convertDetailReceivablePage(PageResult<CrmReceivableDO> pageResult) {
List<CrmReceivableDO> contactList = pageResult.getList();
if (CollUtil.isEmpty(contactList)) {
List<CrmReceivableDO> receivableList = pageResult.getList();
if (CollUtil.isEmpty(receivableList)) {
return PageResult.empty(pageResult.getTotal());
}
// 1. 获取客户列表
List<CrmCustomerDO> customerList = customerService.getCustomerList(
convertSet(contactList, CrmReceivableDO::getCustomerId));
convertSet(receivableList, CrmReceivableDO::getCustomerId));
// 2. 获取创建人、负责人列表
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList,
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(receivableList,
contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
// 3. 获得合同列表
List<CrmContractDO> contractList = contractService.getContractList(
convertSet(contactList, CrmReceivableDO::getContractId));
convertSet(receivableList, CrmReceivableDO::getContractId));
return CrmReceivableConvert.INSTANCE.convertPage(pageResult, userMap, customerList, contractList);
}

View File

@@ -1,13 +1,27 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable;
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.number.NumberUtils;
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.receivable.vo.*;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO;
import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivablePlanConvert;
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.dal.dataobject.receivable.CrmReceivableDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivablePlanService;
import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService;
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;
@@ -20,8 +34,12 @@ 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.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;
@Tag(name = "管理后台 - CRM 回款计划")
@@ -31,20 +49,29 @@ import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.E
public class CrmReceivablePlanController {
@Resource
private CrmReceivablePlanService crmReceivablePlanService;
private CrmReceivablePlanService receivablePlanService;
@Resource
private CrmReceivableService receivableService;
@Resource
private CrmContractService contractService;
@Resource
private CrmCustomerService customerService;
@Resource
private AdminUserApi adminUserApi;
@PostMapping("/create")
@Operation(summary = "创建回款计划")
@PreAuthorize("@ss.hasPermission('crm:receivable-plan:create')")
public CommonResult<Long> createReceivablePlan(@Valid @RequestBody CrmReceivablePlanCreateReqVO createReqVO) {
return success(crmReceivablePlanService.createReceivablePlan(createReqVO));
return success(receivablePlanService.createReceivablePlan(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新回款计划")
@PreAuthorize("@ss.hasPermission('crm:receivable-plan:update')")
public CommonResult<Boolean> updateReceivablePlan(@Valid @RequestBody CrmReceivablePlanUpdateReqVO updateReqVO) {
crmReceivablePlanService.updateReceivablePlan(updateReqVO);
receivablePlanService.updateReceivablePlan(updateReqVO);
return success(true);
}
@@ -53,7 +80,7 @@ public class CrmReceivablePlanController {
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('crm:receivable-plan:delete')")
public CommonResult<Boolean> deleteReceivablePlan(@RequestParam("id") Long id) {
crmReceivablePlanService.deleteReceivablePlan(id);
receivablePlanService.deleteReceivablePlan(id);
return success(true);
}
@@ -62,28 +89,63 @@ public class CrmReceivablePlanController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')")
public CommonResult<CrmReceivablePlanRespVO> getReceivablePlan(@RequestParam("id") Long id) {
CrmReceivablePlanDO receivablePlan = crmReceivablePlanService.getReceivablePlan(id);
CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(id);
return success(CrmReceivablePlanConvert.INSTANCE.convert(receivablePlan));
}
@GetMapping("/page")
@Operation(summary = "获得回款计划分页")
@PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')")
public CommonResult<PageResult<CrmReceivablePlanRespVO>> getReceivablePlanPage(@Valid CrmReceivablePlanPageReqVO pageVO) {
PageResult<CrmReceivablePlanDO> pageResult = crmReceivablePlanService.getReceivablePlanPage(pageVO);
return success(CrmReceivablePlanConvert.INSTANCE.convertPage(pageResult));
public CommonResult<PageResult<CrmReceivablePlanRespVO>> getReceivablePlanPage(@Valid CrmReceivablePlanPageReqVO pageReqVO) {
PageResult<CrmReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPage(pageReqVO);
return success(convertDetailReceivablePlanPage(pageResult));
}
@GetMapping("/page-by-customer")
@Operation(summary = "获得回款计划分页,基于指定客户")
public CommonResult<PageResult<CrmReceivablePlanRespVO>> getReceivablePlanPageByCustomer(@Valid CrmReceivablePlanPageReqVO pageReqVO) {
Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空");
PageResult<CrmReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPageByCustomer(pageReqVO);
return success(convertDetailReceivablePlanPage(pageResult));
}
// TODO 芋艿:后面在优化导出
@GetMapping("/export-excel")
@Operation(summary = "导出回款计划 Excel")
@PreAuthorize("@ss.hasPermission('crm:receivable-plan:export')")
@OperateLog(type = EXPORT)
public void exportReceivablePlanExcel(@Valid CrmReceivablePlanExportReqVO exportReqVO,
public void exportReceivablePlanExcel(@Valid CrmReceivablePlanPageReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<CrmReceivablePlanDO> list = crmReceivablePlanService.getReceivablePlanList(exportReqVO);
PageResult<CrmReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPage(exportReqVO);
// 导出 Excel
List<CrmReceivablePlanExcelVO> datas = CrmReceivablePlanConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "回款计划.xls", "数据", CrmReceivablePlanExcelVO.class, datas);
ExcelUtils.write(response, "回款计划.xls", "数据", CrmReceivablePlanRespVO.class,
convertDetailReceivablePlanPage(pageResult).getList());
}
/**
* 转换成详细的回款计划分页,即读取关联信息
*
* @param pageResult 回款计划分页
* @return 详细的回款计划分页
*/
private PageResult<CrmReceivablePlanRespVO> convertDetailReceivablePlanPage(PageResult<CrmReceivablePlanDO> pageResult) {
List<CrmReceivablePlanDO> receivablePlanList = pageResult.getList();
if (CollUtil.isEmpty(receivablePlanList)) {
return PageResult.empty(pageResult.getTotal());
}
// 1. 获取客户列表
List<CrmCustomerDO> customerList = customerService.getCustomerList(
convertSet(receivablePlanList, CrmReceivablePlanDO::getCustomerId));
// 2. 获取创建人、负责人列表
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(receivablePlanList,
contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
// 3. 获得合同列表
List<CrmContractDO> contractList = contractService.getContractList(
convertSet(receivablePlanList, CrmReceivablePlanDO::getContractId));
// 4. 获得还款列表
List<CrmReceivableDO> receivableList = receivableService.getReceivableList(
convertSet(receivablePlanList, CrmReceivablePlanDO::getReceivableId));
return CrmReceivablePlanConvert.INSTANCE.convertPage(pageResult, userMap, customerList, contractList, receivableList);
}
}

View File

@@ -1,70 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.time.LocalDateTime;
// TODO liuhongfeng导出可以等其它功能做完统一在搞
/**
* CRM 回款计划 Excel VO
*
* @author 芋道源码
*/
@Data
public class CrmReceivablePlanExcelVO {
@ExcelProperty("ID")
private Long id;
@ExcelProperty("期数")
private Integer period;
@ExcelProperty("回款ID")
private Long receivableId;
@ExcelProperty(value = "状态", converter = DictConvert.class)
@DictFormat(DictTypeConstants.COMMON_STATUS)
private Integer status;
@ExcelProperty(value = "审批状态", converter = DictConvert.class)
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_AUDIT_STATUS)
private Integer checkStatus;
//@ExcelProperty("工作流编号")
//private Long processInstanceId;
@ExcelProperty("计划回款金额")
private Integer price;
@ExcelProperty("计划回款日期")
private LocalDateTime returnTime;
@ExcelProperty("提前几天提醒")
private Integer remindDays;
@ExcelProperty("提醒日期")
private LocalDateTime remindTime;
@ExcelProperty("客户ID")
private Long customerId;
@ExcelProperty("合同名称")
private Long contractId;
@ExcelProperty("负责人")
private Long ownerUserId;
//@ExcelProperty("显示顺序")
//private Integer sort;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -1,52 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
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;
// TODO liuhongfeng导出可以等其它功能做完统一在搞
@Schema(description = "管理后台 - CRM 回款计划 Excel 导出 Request VO参数和 CrmReceivablePlanPageReqVO 是一致的")
@Data
public class CrmReceivablePlanExportReqVO {
@Schema(description = "期数")
private Integer period;
@Schema(description = "完成状态", example = "2")
private Integer status;
@Schema(description = "审批状态", example = "1")
private Integer checkStatus;
@Schema(description = "计划回款日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] returnTime;
@Schema(description = "提前几天提醒")
private Integer remindDays;
@Schema(description = "提醒日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] remindTime;
@Schema(description = "客户名称", example = "18026")
private Long customerId;
@Schema(description = "合同名称", example = "3473")
private Long contractId;
@Schema(description = "负责人", example = "17828")
private Long ownerUserId;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -1,49 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable.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 CrmReceivablePlanPageReqVO extends PageParam {
// TODO @liuhongfeng可以根据需求去除掉一些不要的过滤条件另外customerId、contractId、ownerUserId 注释不正确,应该都是对应的编号
@Schema(description = "完成状态", example = "2")
private Integer status;
@Schema(description = "审批状态", example = "1")
private Integer checkStatus;
@Schema(description = "计划回款日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] returnTime;
@Schema(description = "提醒日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] remindTime;
@Schema(description = "客户名称", example = "18026")
private Long customerId;
@Schema(description = "合同名称", example = "3473")
private Long contractId;
@Schema(description = "负责人", example = "17828")
private Long ownerUserId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -1,19 +0,0 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - CRM 回款计划 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmReceivablePlanRespVO extends CrmReceivablePlanBaseVO {
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@@ -1,7 +1,5 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
@@ -20,17 +18,9 @@ public class CrmReceivablePlanBaseVO {
@Schema(description = "期数", example = "1")
private Integer period;
// TODO @liuhongfeng回款计划编号
@Schema(description = "回款计划", example = "19852")
@Schema(description = "回款计划编号", example = "19852")
private Long receivableId;
@Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private Integer status;
@Schema(description = "审批状态", example = "1")
@InEnum(CrmAuditStatusEnum.class)
private Integer checkStatus;
@Schema(description = "计划回款金额", example = "29675")
private Integer price;
@@ -45,16 +35,14 @@ public class CrmReceivablePlanBaseVO {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime remindTime;
// TODO @liuhongfeng客户编号
@Schema(description = "客户名称", example = "18026")
private Long customerId;
// TODO @liuhongfeng合同编号
@Schema(description = "合同名称", example = "3473")
@Schema(description = "合同编号", example = "3473")
private Long contractId;
// TODO @liuhongfeng负责人编号
@Schema(description = "负责人", example = "17828")
@Schema(description = "负责人编号", example = "17828")
private Long ownerUserId;
@Schema(description = "显示顺序")

View File

@@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan;
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 = "管理后台 - CRM 回款计划分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmReceivablePlanPageReqVO extends PageParam {
@Schema(description = "客户编号", example = "18026")
private Long customerId;
// TODO @芋艿:这个搜的应该是合同编号 no
@Schema(description = "合同名称", example = "3473")
private Long contractId;
}

View File

@@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - CRM 回款计划 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmReceivablePlanRespVO extends CrmReceivablePlanBaseVO {
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
@Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test")
private String customerName;
@Schema(description = "合同编号", example = "Q110")
private String contractNo;
@Schema(description = "负责人", example = "test")
private String ownerUserName;
@Schema(description = "创建人", example = "25682")
private String creator;
@Schema(description = "创建人名字", example = "test")
private String creatorName;
@Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private Boolean finishStatus;
@Schema(description = "回款方式", example = "1") // 来自 Receivable 的 returnType 字段
private Integer returnType;
}

View File

@@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

View File

@@ -42,7 +42,7 @@ public class CrmReceivableBaseVO {
private LocalDateTime returnTime;
@Schema(description = "回款方式", example = "2")
private String returnType;
private Integer returnType;
@Schema(description = "回款金额,单位:分", example = "31859")
private Integer price;
@@ -51,9 +51,6 @@ public class CrmReceivableBaseVO {
@Schema(description = "负责人", example = "22202")
private Long ownerUserId;
@Schema(description = "批次", example = "2539")
private Long batchId;
@Schema(description = "显示顺序")
private Integer sort;

View File

@@ -1,13 +1,22 @@
package cn.iocoder.yudao.module.crm.convert.receivable;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO;
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.dal.dataobject.receivable.CrmReceivableDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
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
@@ -27,8 +36,31 @@ public interface CrmReceivablePlanConvert {
List<CrmReceivablePlanRespVO> convertList(List<CrmReceivablePlanDO> list);
PageResult<CrmReceivablePlanRespVO> convertPage(PageResult<CrmReceivablePlanDO> page);
default PageResult<CrmReceivablePlanRespVO> convertPage(PageResult<CrmReceivablePlanDO> pageResult, Map<Long, AdminUserRespDTO> userMap,
List<CrmCustomerDO> customerList, List<CrmContractDO> contractList,
List<CrmReceivableDO> receivableList) {
return new PageResult<>(converList(pageResult.getList(), userMap, customerList, contractList, receivableList), pageResult.getTotal());
}
List<CrmReceivablePlanExcelVO> convertList02(List<CrmReceivablePlanDO> list);
default List<CrmReceivablePlanRespVO> converList(List<CrmReceivablePlanDO> receivablePlanList, Map<Long, AdminUserRespDTO> userMap,
List<CrmCustomerDO> customerList, List<CrmContractDO> contractList,
List<CrmReceivableDO> receivableList) {
List<CrmReceivablePlanRespVO> result = convertList(receivablePlanList);
Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId);
Map<Long, CrmContractDO> contractMap = convertMap(contractList, CrmContractDO::getId);
Map<Long, CrmReceivableDO> receivableMap = convertMap(receivableList, CrmReceivableDO::getId);
result.forEach(item -> {
setUserInfo(item, userMap);
findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName()));
findAndThen(contractMap, item.getContractId(), contract -> item.setContractNo(contract.getNo()));
findAndThen(receivableMap, item.getReceivableId(), receivable -> item.setReturnType(receivable.getReturnType()));
});
return result;
}
static void setUserInfo(CrmReceivablePlanRespVO receivablePlan, Map<Long, AdminUserRespDTO> userMap) {
findAndThen(userMap, receivablePlan.getOwnerUserId(), user -> receivablePlan.setOwnerUserName(user.getNickname()));
findAndThen(userMap, Long.parseLong(receivablePlan.getCreator()), user -> receivablePlan.setCreatorName(user.getNickname()));
}
}

View File

@@ -68,7 +68,7 @@ public class CrmReceivableDO extends BaseDO {
/**
* 回款方式
*/
private String returnType;
private Integer returnType;
/**
* 回款金额
*/

View File

@@ -38,26 +38,10 @@ public class CrmReceivablePlanDO extends BaseDO {
* TODO @liuhongfeng少关联实体
*/
private Long receivableId;
// TODO @liuhongfeng还款计划没有 status 和 checkStatus改成 finishStatus Boolean是否完成
/**
* 状态
*
* 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum}
* 完成状态
*/
private Integer status;
/**
* 审批状态
*
* 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_AUDIT_STATUS}
* // TODO @liuhongfeng关联的枚举
*/
private Integer checkStatus;
/**
* 工作流编号
*
* TODO @liuhongfeng少关联实体
*/
private Long processInstanceId;
private Boolean finishStatus;
/**
* 计划回款金额,单位:分
*/

View File

@@ -1,13 +1,11 @@
package cn.iocoder.yudao.module.crm.dal.mysql.receivable;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
/**
* 回款计划 Mapper
@@ -19,30 +17,15 @@ public interface CrmReceivablePlanMapper extends BaseMapperX<CrmReceivablePlanDO
default PageResult<CrmReceivablePlanDO> selectPage(CrmReceivablePlanPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CrmReceivablePlanDO>()
.eqIfPresent(CrmReceivablePlanDO::getStatus, reqVO.getStatus())
.eqIfPresent(CrmReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus())
.betweenIfPresent(CrmReceivablePlanDO::getReturnTime, reqVO.getReturnTime())
.betweenIfPresent(CrmReceivablePlanDO::getRemindTime, reqVO.getRemindTime())
.eqIfPresent(CrmReceivablePlanDO::getCustomerId, reqVO.getCustomerId())
.eqIfPresent(CrmReceivablePlanDO::getContractId, reqVO.getContractId())
.eqIfPresent(CrmReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId())
.betweenIfPresent(CrmReceivablePlanDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(CrmReceivablePlanDO::getId));
}
default List<CrmReceivablePlanDO> selectList(CrmReceivablePlanExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<CrmReceivablePlanDO>()
.eqIfPresent(CrmReceivablePlanDO::getPeriod, reqVO.getPeriod())
.eqIfPresent(CrmReceivablePlanDO::getStatus, reqVO.getStatus())
.eqIfPresent(CrmReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus())
.betweenIfPresent(CrmReceivablePlanDO::getReturnTime, reqVO.getReturnTime())
.eqIfPresent(CrmReceivablePlanDO::getRemindDays, reqVO.getRemindDays())
.betweenIfPresent(CrmReceivablePlanDO::getRemindTime, reqVO.getRemindTime())
.eqIfPresent(CrmReceivablePlanDO::getCustomerId, reqVO.getCustomerId())
default PageResult<CrmReceivablePlanDO> selectPageByCustomer(CrmReceivablePlanPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CrmReceivablePlanDO>()
.eq(CrmReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) // 必须传递
.eqIfPresent(CrmReceivablePlanDO::getContractId, reqVO.getContractId())
.eqIfPresent(CrmReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId())
.eqIfPresent(CrmReceivablePlanDO::getRemark, reqVO.getRemark())
.betweenIfPresent(CrmReceivablePlanDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(CrmReceivablePlanDO::getId));
}

View File

@@ -1,13 +1,18 @@
package cn.iocoder.yudao.module.crm.service.receivable;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
/**
* 回款计划 Service 接口
* CRM 回款计划 Service 接口
*
* @author 芋道源码
*/
@@ -54,17 +59,21 @@ public interface CrmReceivablePlanService {
/**
* 获得回款计划分页
*
* 数据权限:基于 {@link CrmReceivablePlanDO} 读取
*
* @param pageReqVO 分页查询
* @return 回款计划分页
*/
PageResult<CrmReceivablePlanDO> getReceivablePlanPage(CrmReceivablePlanPageReqVO pageReqVO);
/**
* 获得回款计划列表, 用于 Excel 导出
* 获得回款计划分页,基于指定客户
*
* @param exportReqVO 查询条件
* @return 回款计划列表
* 数据权限:基于 {@link CrmCustomerDO} 读取
*
* @param pageReqVO 分页查询
* @return 回款计划分页
*/
List<CrmReceivablePlanDO> getReceivablePlanList(CrmReceivablePlanExportReqVO exportReqVO);
PageResult<CrmReceivablePlanDO> getReceivablePlanPageByCustomer(CrmReceivablePlanPageReqVO pageReqVO);
}

View File

@@ -3,18 +3,18 @@ package cn.iocoder.yudao.module.crm.service.receivable;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanExportReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanUpdateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO;
import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivablePlanConvert;
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.dal.dataobject.receivable.CrmReceivablePlanDO;
import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivablePlanMapper;
import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import org.springframework.stereotype.Service;
@@ -28,6 +28,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
// TODO @liuhongfeng参考 CrmReceivableServiceImpl 写的 todo 哈;
// TODO @puhui999数据权限
/**
* 回款计划 Service 实现类
*
@@ -38,26 +39,22 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService {
@Resource
private CrmReceivablePlanMapper crmReceivablePlanMapper;
private CrmReceivablePlanMapper receivablePlanMapper;
@Resource
private CrmContractService contractService;
@Resource
private CrmCustomerService crmCustomerService;
private CrmCustomerService customerService;
@Override
public Long createReceivablePlan(CrmReceivablePlanCreateReqVO createReqVO) {
// 插入
CrmReceivablePlanDO receivablePlan = CrmReceivablePlanConvert.INSTANCE.convert(createReqVO);
if (ObjectUtil.isNull(receivablePlan.getStatus())){
receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus());
}
if (ObjectUtil.isNull(receivablePlan.getCheckStatus())){
receivablePlan.setCheckStatus(CrmAuditStatusEnum.DRAFT.getStatus());
}
receivablePlan.setFinishStatus(false);
checkReceivablePlan(receivablePlan);
crmReceivablePlanMapper.insert(receivablePlan);
receivablePlanMapper.insert(receivablePlan);
// 返回
return receivablePlan.getId();
}
@@ -73,7 +70,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService {
throw exception(CONTRACT_NOT_EXISTS);
}
CrmCustomerDO customer = crmCustomerService.getCustomer(receivablePlan.getCustomerId());
CrmCustomerDO customer = customerService.getCustomer(receivablePlan.getCustomerId());
if(ObjectUtil.isNull(customer)){
throw exception(CUSTOMER_NOT_EXISTS);
}
@@ -87,7 +84,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService {
// 更新
CrmReceivablePlanDO updateObj = CrmReceivablePlanConvert.INSTANCE.convert(updateReqVO);
crmReceivablePlanMapper.updateById(updateObj);
receivablePlanMapper.updateById(updateObj);
}
@Override
@@ -95,18 +92,18 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService {
// 校验存在
validateReceivablePlanExists(id);
// 删除
crmReceivablePlanMapper.deleteById(id);
receivablePlanMapper.deleteById(id);
}
private void validateReceivablePlanExists(Long id) {
if (crmReceivablePlanMapper.selectById(id) == null) {
if (receivablePlanMapper.selectById(id) == null) {
throw exception(RECEIVABLE_PLAN_NOT_EXISTS);
}
}
@Override
public CrmReceivablePlanDO getReceivablePlan(Long id) {
return crmReceivablePlanMapper.selectById(id);
return receivablePlanMapper.selectById(id);
}
@Override
@@ -114,17 +111,18 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService {
if (CollUtil.isEmpty(ids)) {
return ListUtil.empty();
}
return crmReceivablePlanMapper.selectBatchIds(ids);
return receivablePlanMapper.selectBatchIds(ids);
}
@Override
public PageResult<CrmReceivablePlanDO> getReceivablePlanPage(CrmReceivablePlanPageReqVO pageReqVO) {
return crmReceivablePlanMapper.selectPage(pageReqVO);
return receivablePlanMapper.selectPage(pageReqVO);
}
@Override
public List<CrmReceivablePlanDO> getReceivablePlanList(CrmReceivablePlanExportReqVO exportReqVO) {
return crmReceivablePlanMapper.selectList(exportReqVO);
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ)
public PageResult<CrmReceivablePlanDO> getReceivablePlanPageByCustomer(CrmReceivablePlanPageReqVO pageReqVO) {
return receivablePlanMapper.selectPageByCustomer(pageReqVO);
}
}