mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	crm: 增加基于客户查询回款分页
This commit is contained in:
		| @@ -112,10 +112,10 @@ public class CrmContractController { | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 转换成详细的联系人分页,即读取关联信息 | ||||
|      * 转换成详细的合同分页,即读取关联信息 | ||||
|      * | ||||
|      * @param pageResult 联系人分页 | ||||
|      * @return 详细的联系人分页 | ||||
|      * @param pageResult 合同分页 | ||||
|      * @return 详细的合同分页 | ||||
|      */ | ||||
|     private PageResult<ContractRespVO> convertDetailContractPage(PageResult<CrmContractDO> pageResult) { | ||||
|         List<CrmContractDO> contactList = pageResult.getList(); | ||||
|   | ||||
| @@ -1,13 +1,25 @@ | ||||
| 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.receivable.CrmReceivableCreateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivableConvert; | ||||
| 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.service.contract.CrmContractService; | ||||
| import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | ||||
| 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,71 +32,113 @@ 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 回款管理") | ||||
| @Tag(name = "管理后台 - CRM 回款") | ||||
| @RestController | ||||
| @RequestMapping("/crm/receivable") | ||||
| @Validated | ||||
| public class CrmReceivableController { | ||||
|  | ||||
|     // TODO @liuhongfeng:crmReceivableService 可以使用 receivableService ;在自己模块里,相对简洁一点; | ||||
|     @Resource | ||||
|     private CrmReceivableService crmReceivableService; | ||||
|     private CrmReceivableService receivableService; | ||||
|     @Resource | ||||
|     private CrmContractService contractService; | ||||
|     @Resource | ||||
|     private CrmCustomerService customerService; | ||||
|  | ||||
|     @Resource | ||||
|     private AdminUserApi adminUserApi; | ||||
|  | ||||
|     @PostMapping("/create") | ||||
|     @Operation(summary = "创建回款管理") | ||||
|     @Operation(summary = "创建回款") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:receivable:create')") | ||||
|     public CommonResult<Long> createReceivable(@Valid @RequestBody CrmReceivableCreateReqVO createReqVO) { | ||||
|         return success(crmReceivableService.createReceivable(createReqVO)); | ||||
|         return success(receivableService.createReceivable(createReqVO)); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/update") | ||||
|     @Operation(summary = "更新回款管理") | ||||
|     @Operation(summary = "更新回款") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:receivable:update')") | ||||
|     public CommonResult<Boolean> updateReceivable(@Valid @RequestBody CrmReceivableUpdateReqVO updateReqVO) { | ||||
|         crmReceivableService.updateReceivable(updateReqVO); | ||||
|         receivableService.updateReceivable(updateReqVO); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @DeleteMapping("/delete") | ||||
|     @Operation(summary = "删除回款管理") | ||||
|     @Operation(summary = "删除回款") | ||||
|     @Parameter(name = "id", description = "编号", required = true) | ||||
|     @PreAuthorize("@ss.hasPermission('crm:receivable:delete')") | ||||
|     public CommonResult<Boolean> deleteReceivable(@RequestParam("id") Long id) { | ||||
|         crmReceivableService.deleteReceivable(id); | ||||
|         receivableService.deleteReceivable(id); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/get") | ||||
|     @Operation(summary = "获得回款管理") | ||||
|     @Operation(summary = "获得回款") | ||||
|     @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:receivable:query')") | ||||
|     public CommonResult<CrmReceivableRespVO> getReceivable(@RequestParam("id") Long id) { | ||||
|         CrmReceivableDO receivable = crmReceivableService.getReceivable(id); | ||||
|         CrmReceivableDO receivable = receivableService.getReceivable(id); | ||||
|         return success(CrmReceivableConvert.INSTANCE.convert(receivable)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/page") | ||||
|     @Operation(summary = "获得回款管理分页") | ||||
|     @Operation(summary = "获得回款分页") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:receivable:query')") | ||||
|     public CommonResult<PageResult<CrmReceivableRespVO>> getReceivablePage(@Valid CrmReceivablePageReqVO pageVO) { | ||||
|         PageResult<CrmReceivableDO> pageResult = crmReceivableService.getReceivablePage(pageVO); | ||||
|         return success(CrmReceivableConvert.INSTANCE.convertPage(pageResult)); | ||||
|     public CommonResult<PageResult<CrmReceivableRespVO>> getReceivablePage(@Valid CrmReceivablePageReqVO pageReqVO) { | ||||
|         PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(pageReqVO); | ||||
|         return success(convertDetailReceivablePage(pageResult)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/page-by-customer") | ||||
|     @Operation(summary = "获得回款分页,基于指定客户") | ||||
|     public CommonResult<PageResult<CrmReceivableRespVO>> getContractPageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) { | ||||
|         Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); | ||||
|         PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePageByCustomer(pageReqVO); | ||||
|         return success(convertDetailReceivablePage(pageResult)); | ||||
|     } | ||||
|  | ||||
|     // TODO 芋艿:后面在优化导出 | ||||
|     @GetMapping("/export-excel") | ||||
|     @Operation(summary = "导出回款管理 Excel") | ||||
|     @Operation(summary = "导出回款 Excel") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:receivable:export')") | ||||
|     @OperateLog(type = EXPORT) | ||||
|     public void exportReceivableExcel(@Valid CrmReceivableExportReqVO exportReqVO, | ||||
|     public void exportReceivableExcel(@Valid CrmReceivablePageReqVO exportReqVO, | ||||
|               HttpServletResponse response) throws IOException { | ||||
|         List<CrmReceivableDO> list = crmReceivableService.getReceivableList(exportReqVO); | ||||
|         PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(exportReqVO); | ||||
|         // 导出 Excel | ||||
|         List<CrmReceivableExcelVO> datas = CrmReceivableConvert.INSTANCE.convertList02(list); | ||||
|         ExcelUtils.write(response, "回款管理.xls", "数据", CrmReceivableExcelVO.class, datas); | ||||
|         ExcelUtils.write(response, "回款.xls", "数据", CrmReceivableRespVO.class, | ||||
|                 convertDetailReceivablePage(pageResult).getList()); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 转换成详细的回款分页,即读取关联信息 | ||||
|      * | ||||
|      * @param pageResult 回款分页 | ||||
|      * @return 详细的回款分页 | ||||
|      */ | ||||
|     private PageResult<CrmReceivableRespVO> convertDetailReceivablePage(PageResult<CrmReceivableDO> pageResult) { | ||||
|         List<CrmReceivableDO> contactList = pageResult.getList(); | ||||
|         if (CollUtil.isEmpty(contactList)) { | ||||
|             return PageResult.empty(pageResult.getTotal()); | ||||
|         } | ||||
|         // 1. 获取客户列表 | ||||
|         List<CrmCustomerDO> customerList = customerService.getCustomerList( | ||||
|                 convertSet(contactList, CrmReceivableDO::getCustomerId)); | ||||
|         // 2. 获取创建人、负责人列表 | ||||
|         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, | ||||
|                 contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); | ||||
|         // 3. 获得合同列表 | ||||
|         List<CrmContractDO> contractList = contractService.getContractList( | ||||
|                 convertSet(contactList, CrmReceivableDO::getContractId)); | ||||
|         return CrmReceivableConvert.INSTANCE.convertPage(pageResult, userMap, customerList, contractList); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,4 +0,0 @@ | ||||
| /** | ||||
|  * 回款 | ||||
|  */ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.receivable; | ||||
| @@ -1,62 +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:导出可以等其它功能做完,统一在搞; | ||||
| @Data | ||||
| public class CrmReceivableExcelVO { | ||||
|  | ||||
|     @ExcelProperty("ID") | ||||
|     private Long id; | ||||
|  | ||||
|     @ExcelProperty("回款编号") | ||||
|     private String no; | ||||
|  | ||||
|     @ExcelProperty("回款计划ID") | ||||
|     private Long planId; | ||||
|  | ||||
|     @ExcelProperty("客户名称") | ||||
|     private Long customerId; | ||||
|  | ||||
|     @ExcelProperty("合同名称") | ||||
|     private Long contractId; | ||||
|  | ||||
|     @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 LocalDateTime returnTime; | ||||
|  | ||||
|     @ExcelProperty("回款方式") | ||||
|     private String returnType; | ||||
|  | ||||
|     @ExcelProperty("回款金额") | ||||
|     private Integer price; | ||||
|  | ||||
|     @ExcelProperty("负责人") | ||||
|     private Long ownerUserId; | ||||
|  | ||||
|     @ExcelProperty("批次") | ||||
|     private Long batchId; | ||||
|  | ||||
|     @ExcelProperty(value = "状态", converter = DictConvert.class) | ||||
|     @DictFormat(DictTypeConstants.COMMON_STATUS) | ||||
|     private Integer status; | ||||
|  | ||||
|     @ExcelProperty("备注") | ||||
|     private String remark; | ||||
|  | ||||
|     @ExcelProperty("创建时间") | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
| } | ||||
| @@ -1,57 +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,参数和 CrmReceivablePageReqVO 是一致的") | ||||
| @Data | ||||
| public class CrmReceivableExportReqVO { | ||||
|  | ||||
|     @Schema(description = "回款编号") | ||||
|     private String no; | ||||
|  | ||||
|     @Schema(description = "回款计划", example = "31177") | ||||
|     private Long planId; | ||||
|  | ||||
|     @Schema(description = "客户名称", example = "4963") | ||||
|     private Long customerId; | ||||
|  | ||||
|     @Schema(description = "合同名称", example = "30305") | ||||
|     private Long contractId; | ||||
|  | ||||
|     @Schema(description = "审批状态", example = "1") | ||||
|     private Integer checkStatus; | ||||
|  | ||||
|     @Schema(description = "回款日期") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] returnTime; | ||||
|  | ||||
|     @Schema(description = "回款方式", example = "2") | ||||
|     private String returnType; | ||||
|  | ||||
|     @Schema(description = "回款金额", example = "31859") | ||||
|     private Integer price; | ||||
|  | ||||
|     @Schema(description = "负责人", example = "22202") | ||||
|     private Long ownerUserId; | ||||
|  | ||||
|     @Schema(description = "批次", example = "2539") | ||||
|     private Long batchId; | ||||
|  | ||||
|     @Schema(description = "状态", example = "1") | ||||
|     private Integer status; | ||||
|  | ||||
|     @Schema(description = "备注", example = "随便") | ||||
|     private String remark; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] createTime; | ||||
|  | ||||
| } | ||||
| @@ -1,58 +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 CrmReceivablePageReqVO extends PageParam { | ||||
|  | ||||
|     // TODO @liuhongfeng:可以根据需求,去除掉一些不要的过滤条件;另外,planId、customerId、contractId、ownerUserId 注释不正确,应该都是对应的编号 | ||||
|  | ||||
|     @Schema(description = "回款编号") | ||||
|     private String no; | ||||
|  | ||||
|     @Schema(description = "回款计划ID", example = "31177") | ||||
|     private Long planId; | ||||
|  | ||||
|     @Schema(description = "客户名称", example = "4963") | ||||
|     private Long customerId; | ||||
|  | ||||
|     @Schema(description = "合同名称", example = "30305") | ||||
|     private Long contractId; | ||||
|  | ||||
|     @Schema(description = "审批状态", example = "1") | ||||
|     private Integer checkStatus; | ||||
|  | ||||
|     @Schema(description = "回款日期") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] returnTime; | ||||
|  | ||||
|     @Schema(description = "回款方式", example = "2") | ||||
|     private String returnType; | ||||
|  | ||||
|     @Schema(description = "回款金额", example = "31859") | ||||
|     private Integer price; | ||||
|  | ||||
|     @Schema(description = "负责人", example = "22202") | ||||
|     private Long ownerUserId; | ||||
|  | ||||
|  | ||||
|     @Schema(description = "状态", example = "1") | ||||
|     private Integer status; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] createTime; | ||||
|  | ||||
| } | ||||
| @@ -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 CrmReceivableRespVO extends CrmReceivableBaseVO { | ||||
|  | ||||
|     @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") | ||||
|     private Long id; | ||||
|  | ||||
|     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
| } | ||||
| @@ -1,4 +1,4 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; | ||||
| 
 | ||||
| import cn.iocoder.yudao.framework.common.validation.InEnum; | ||||
| import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; | ||||
| @@ -11,7 +11,7 @@ import java.time.LocalDateTime; | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
| 
 | ||||
| /** | ||||
|  * 回款管理 Base VO,提供给添加、修改、详细的子 VO 使用 | ||||
|  * 回款 Base VO,提供给添加、修改、详细的子 VO 使用 | ||||
|  * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||||
|  */ | ||||
| @Data | ||||
| @@ -60,8 +60,5 @@ public class CrmReceivableBaseVO { | ||||
|     @Schema(description = "备注", example = "备注") | ||||
|     private String remark; | ||||
| 
 | ||||
|     // TODO @liuhongfeng:这个字段,这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; | ||||
|     @Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||||
|     private Integer status; | ||||
| 
 | ||||
| } | ||||
| @@ -1,4 +1,4 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; | ||||
| 
 | ||||
| import lombok.*; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| @@ -0,0 +1,24 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; | ||||
|  | ||||
| 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 CrmReceivablePageReqVO extends PageParam { | ||||
|  | ||||
|     @Schema(description = "回款编号") | ||||
|     private String no; | ||||
|  | ||||
|     @Schema(description = "回款计划编号", example = "31177") | ||||
|     private Long planId; | ||||
|  | ||||
|     @Schema(description = "客户编号", example = "4963") | ||||
|     private Long customerId; | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,38 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| // TODO 芋艿:导出的 VO,可以考虑使用 @Excel 注解,实现导出功能 | ||||
| @Schema(description = "管理后台 - CRM 回款 Response VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class CrmReceivableRespVO extends CrmReceivableBaseVO { | ||||
|  | ||||
|     @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") | ||||
|     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 = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||||
|     private Integer auditStatus; | ||||
|  | ||||
|     @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; | ||||
|  | ||||
| } | ||||
| @@ -1,4 +1,4 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; | ||||
| 
 | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| @@ -1,16 +1,24 @@ | ||||
| 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.receivable.CrmReceivableCreateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; | ||||
| 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.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 | ||||
|  * 回款 Convert | ||||
|  * | ||||
|  * @author 赤焰 | ||||
|  */ | ||||
| @@ -27,8 +35,27 @@ public interface CrmReceivableConvert { | ||||
|  | ||||
|     List<CrmReceivableRespVO> convertList(List<CrmReceivableDO> list); | ||||
|  | ||||
|     PageResult<CrmReceivableRespVO> convertPage(PageResult<CrmReceivableDO> page); | ||||
|     default PageResult<CrmReceivableRespVO> convertPage(PageResult<CrmReceivableDO> pageResult, Map<Long, AdminUserRespDTO> userMap, | ||||
|                                                         List<CrmCustomerDO> customerList, List<CrmContractDO> contractList) { | ||||
|         return new PageResult<>(converList(pageResult.getList(), userMap, customerList, contractList), pageResult.getTotal()); | ||||
|     } | ||||
|  | ||||
|     List<CrmReceivableExcelVO> convertList02(List<CrmReceivableDO> list); | ||||
|     default List<CrmReceivableRespVO> converList(List<CrmReceivableDO> receivableList, Map<Long, AdminUserRespDTO> userMap, | ||||
|                                                  List<CrmCustomerDO> customerList, List<CrmContractDO> contractList) { | ||||
|         List<CrmReceivableRespVO> result = convertList(receivableList); | ||||
|         Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId); | ||||
|         Map<Long, CrmContractDO> contractMap = convertMap(contractList, CrmContractDO::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())); | ||||
|         }); | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
|     static void setUserInfo(CrmReceivableRespVO receivable, Map<Long, AdminUserRespDTO> userMap) { | ||||
|         findAndThen(userMap, receivable.getOwnerUserId(), user -> receivable.setOwnerUserName(user.getNickname())); | ||||
|         findAndThen(userMap, Long.parseLong(receivable.getCreator()), user -> receivable.setCreatorName(user.getNickname())); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -10,7 +10,7 @@ import lombok.*; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| /** | ||||
|  * 回款管理 DO | ||||
|  * 回款 DO | ||||
|  * | ||||
|  * @author 赤焰 | ||||
|  */ | ||||
| @@ -54,12 +54,6 @@ public class CrmReceivableDO extends BaseDO { | ||||
|      * 对应实体 {@link CrmContractDO} | ||||
|      */ | ||||
|     private Long contractId; | ||||
|     // TODO @liuhongfeng:“对应字典”,参考别的模块,枚举 {@link XXXX};另外,这个字段就叫 status,整体状态,不只审批 | ||||
|     /** | ||||
|      * 审批状态 | ||||
|      * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_AUDIT_STATUS} | ||||
|      */ | ||||
|     private Integer checkStatus; | ||||
|     /** | ||||
|      * 工作流编号 | ||||
|      * | ||||
| @@ -84,31 +78,16 @@ public class CrmReceivableDO extends BaseDO { | ||||
|      * 负责人 | ||||
|      */ | ||||
|     private Long ownerUserId; | ||||
|     // TODO @liuhongfeng:应该不需要 batchId 字段 | ||||
|     /** | ||||
|      * 批次 | ||||
|      */ | ||||
|     private Long batchId; | ||||
|     /** | ||||
|      * 显示顺序 | ||||
|      */ | ||||
|     private Integer sort; | ||||
|     // TODO 芋艿:dataScope、dataScopeDeptIds 在想下; | ||||
|     /** | ||||
|      * 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) | ||||
|      */ | ||||
|     private Integer dataScope; | ||||
|     /** | ||||
|      * 数据范围(指定部门数组) | ||||
|      */ | ||||
|     private String dataScopeDeptIds; | ||||
|     /** | ||||
|      * 状态 | ||||
|      * | ||||
|      * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} | ||||
|      * 审核状态 | ||||
|      * | ||||
|      * 枚举 {@link cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum} | ||||
|      */ | ||||
|     private Integer status; | ||||
|     private Integer auditStatus; | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|   | ||||
| @@ -1,4 +0,0 @@ | ||||
| /** | ||||
|  * 合同 | ||||
|  */ | ||||
| package cn.iocoder.yudao.module.crm.dal.mysql.contract; | ||||
| @@ -1,4 +1,4 @@ | ||||
| package cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig; | ||||
| package cn.iocoder.yudao.module.crm.dal.mysql.customer; | ||||
| 
 | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||||
| @@ -1,4 +0,0 @@ | ||||
| /** | ||||
|  * 客户 | ||||
|  */ | ||||
| package cn.iocoder.yudao.module.crm.dal.mysql.customer; | ||||
| @@ -1,16 +1,14 @@ | ||||
| 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.receivable.CrmReceivablePageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; | ||||
| import org.apache.ibatis.annotations.Mapper; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; | ||||
|  | ||||
| /** | ||||
|  * 回款管理 Mapper | ||||
|  * 回款 Mapper | ||||
|  * | ||||
|  * @author 赤焰 | ||||
|  */ | ||||
| @@ -22,32 +20,14 @@ public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> { | ||||
|                 .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getPlanId, reqVO.getPlanId()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getContractId, reqVO.getContractId()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getCheckStatus, reqVO.getCheckStatus()) | ||||
|                 .betweenIfPresent(CrmReceivableDO::getReturnTime, reqVO.getReturnTime()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getReturnType, reqVO.getReturnType()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getPrice, reqVO.getPrice()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getStatus, reqVO.getStatus()) | ||||
|                 .betweenIfPresent(CrmReceivableDO::getCreateTime, reqVO.getCreateTime()) | ||||
|                 .orderByDesc(CrmReceivableDO::getId)); | ||||
|     } | ||||
|  | ||||
|     default List<CrmReceivableDO> selectList(CrmReceivableExportReqVO reqVO) { | ||||
|         return selectList(new LambdaQueryWrapperX<CrmReceivableDO>() | ||||
|     default PageResult<CrmReceivableDO> selectPageByCustomer(CrmReceivablePageReqVO reqVO) { | ||||
|         return selectPage(reqVO, new LambdaQueryWrapperX<CrmReceivableDO>() | ||||
|                 .eq(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 | ||||
|                 .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getPlanId, reqVO.getPlanId()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getContractId, reqVO.getContractId()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getCheckStatus, reqVO.getCheckStatus()) | ||||
|                 .betweenIfPresent(CrmReceivableDO::getReturnTime, reqVO.getReturnTime()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getReturnType, reqVO.getReturnType()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getPrice, reqVO.getPrice()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getBatchId, reqVO.getBatchId()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getStatus, reqVO.getStatus()) | ||||
|                 .eqIfPresent(CrmReceivableDO::getRemark, reqVO.getRemark()) | ||||
|                 .betweenIfPresent(CrmReceivableDO::getCreateTime, reqVO.getCreateTime()) | ||||
|                 .orderByDesc(CrmReceivableDO::getId)); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -1,4 +0,0 @@ | ||||
| /** | ||||
|  * 回款 | ||||
|  */ | ||||
| package cn.iocoder.yudao.module.crm.dal.mysql.receivable; | ||||
| @@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmC | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | ||||
| import cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig.CrmCustomerLimitConfigMapper; | ||||
| import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; | ||||
| import cn.iocoder.yudao.module.system.api.dept.DeptApi; | ||||
| import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||||
| import org.springframework.stereotype.Service; | ||||
|   | ||||
| @@ -1,21 +1,25 @@ | ||||
| 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.CrmReceivableDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; | ||||
|  | ||||
| import javax.validation.Valid; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 回款管理 Service 接口 | ||||
|  * CRM 回款 Service 接口 | ||||
|  * | ||||
|  * @author 赤焰 | ||||
|  */ | ||||
| public interface CrmReceivableService { | ||||
|  | ||||
|     /** | ||||
|      * 创建回款管理 | ||||
|      * 创建回款 | ||||
|      * | ||||
|      * @param createReqVO 创建信息 | ||||
|      * @return 编号 | ||||
| @@ -23,49 +27,53 @@ public interface CrmReceivableService { | ||||
|     Long createReceivable(@Valid CrmReceivableCreateReqVO createReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 更新回款管理 | ||||
|      * 更新回款 | ||||
|      * | ||||
|      * @param updateReqVO 更新信息 | ||||
|      */ | ||||
|     void updateReceivable(@Valid CrmReceivableUpdateReqVO updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除回款管理 | ||||
|      * 删除回款 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      */ | ||||
|     void deleteReceivable(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得回款管理 | ||||
|      * 获得回款 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      * @return 回款管理 | ||||
|      * @return 回款 | ||||
|      */ | ||||
|     CrmReceivableDO getReceivable(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得回款管理列表 | ||||
|      * 获得回款列表 | ||||
|      * | ||||
|      * @param ids 编号 | ||||
|      * @return 回款管理列表 | ||||
|      * @return 回款列表 | ||||
|      */ | ||||
|     List<CrmReceivableDO> getReceivableList(Collection<Long> ids); | ||||
|  | ||||
|     /** | ||||
|      * 获得回款管理分页 | ||||
|      * 获得回款分页 | ||||
|      * | ||||
|      * 数据权限:基于 {@link CrmReceivableDO} 读取 | ||||
|      * | ||||
|      * @param pageReqVO 分页查询 | ||||
|      * @return 回款管理分页 | ||||
|      * @return 回款分页 | ||||
|      */ | ||||
|     PageResult<CrmReceivableDO> getReceivablePage(CrmReceivablePageReqVO pageReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 获得回款管理列表, 用于 Excel 导出 | ||||
|      * 获得回款分页,基于指定客户 | ||||
|      * | ||||
|      * @param exportReqVO 查询条件 | ||||
|      * @return 回款管理列表 | ||||
|      * 数据权限:基于 {@link CrmCustomerDO} 读取 | ||||
|      * | ||||
|      * @param pageReqVO 分页查询 | ||||
|      * @return 回款分页 | ||||
|      */ | ||||
|     List<CrmReceivableDO> getReceivableList(CrmReceivableExportReqVO exportReqVO); | ||||
|     PageResult<CrmReceivableDO> getReceivablePageByCustomer(CrmReceivablePageReqVO pageReqVO); | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -5,10 +5,9 @@ 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.CrmReceivableCreateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableExportReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableUpdateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivableConvert; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||||
| @@ -16,6 +15,9 @@ 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.dal.mysql.receivable.CrmReceivableMapper; | ||||
| 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; | ||||
| @@ -29,7 +31,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU | ||||
| import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | ||||
|  | ||||
| /** | ||||
|  * 回款管理 Service 实现类 | ||||
|  * CRM 回款 Service 实现类 | ||||
|  * | ||||
|  * @author 赤焰 | ||||
|  */ | ||||
| @@ -37,34 +39,31 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | ||||
| @Validated | ||||
| public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|  | ||||
|     // TODO @liuhongfeng:crm 前缀,变量可以不带哈; | ||||
|     @Resource | ||||
|     private CrmReceivableMapper crmReceivableMapper; | ||||
|     private CrmReceivableMapper receivableMapper; | ||||
|  | ||||
|     @Resource | ||||
|     private CrmContractService contractService; | ||||
|     @Resource | ||||
|     private CrmCustomerService crmCustomerService; | ||||
|     private CrmCustomerService customerService; | ||||
|     @Resource | ||||
|     private CrmReceivablePlanService crmReceivablePlanService; | ||||
|     private CrmReceivablePlanService receivablePlanService; | ||||
|  | ||||
|     // TODO @liuhongfeng:创建还款后,是不是什么时候,要更新 plan? | ||||
|     @Override | ||||
|     public Long createReceivable(CrmReceivableCreateReqVO createReqVO) { | ||||
|         // 插入 | ||||
|         CrmReceivableDO receivable = CrmReceivableConvert.INSTANCE.convert(createReqVO); | ||||
|         // TODO @liuhongfeng:这里的括号要注意排版; | ||||
|         if (ObjectUtil.isNull(receivable.getStatus())){ | ||||
|             receivable.setStatus(CommonStatusEnum.ENABLE.getStatus()); | ||||
|         } | ||||
|         if (ObjectUtil.isNull(receivable.getCheckStatus())){ | ||||
|             receivable.setCheckStatus(CrmAuditStatusEnum.DRAFT.getStatus()); | ||||
|         if (ObjectUtil.isNull(receivable.getAuditStatus())) { | ||||
|             receivable.setAuditStatus(CommonStatusEnum.ENABLE.getStatus()); | ||||
|         } | ||||
|         receivable.setAuditStatus(CrmAuditStatusEnum.DRAFT.getStatus()); | ||||
|  | ||||
|         // TODO @liuhongfeng:一般来说,逻辑的写法,是要先检查,后操作 db;所以,你这个 check 应该放到  CrmReceivableDO receivable 之前; | ||||
|         // 校验 | ||||
|         checkReceivable(receivable); | ||||
|  | ||||
|         crmReceivableMapper.insert(receivable); | ||||
|         receivableMapper.insert(receivable); | ||||
|         return receivable.getId(); | ||||
|     } | ||||
|  | ||||
| @@ -80,12 +79,12 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|             throw exception(CONTRACT_NOT_EXISTS); | ||||
|         } | ||||
|  | ||||
|         CrmCustomerDO customer = crmCustomerService.getCustomer(receivable.getCustomerId()); | ||||
|         CrmCustomerDO customer = customerService.getCustomer(receivable.getCustomerId()); | ||||
|         if(ObjectUtil.isNull(customer)){ | ||||
|             throw exception(CUSTOMER_NOT_EXISTS); | ||||
|         } | ||||
|  | ||||
|         CrmReceivablePlanDO receivablePlan = crmReceivablePlanService.getReceivablePlan(receivable.getPlanId()); | ||||
|         CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(receivable.getPlanId()); | ||||
|         if(ObjectUtil.isNull(receivablePlan)){ | ||||
|             throw exception(RECEIVABLE_PLAN_NOT_EXISTS); | ||||
|         } | ||||
| @@ -99,7 +98,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|  | ||||
|         // 更新 | ||||
|         CrmReceivableDO updateObj = CrmReceivableConvert.INSTANCE.convert(updateReqVO); | ||||
|         crmReceivableMapper.updateById(updateObj); | ||||
|         receivableMapper.updateById(updateObj); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
| @@ -107,18 +106,19 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|         // 校验存在 | ||||
|         validateReceivableExists(id); | ||||
|         // 删除 | ||||
|         crmReceivableMapper.deleteById(id); | ||||
|         receivableMapper.deleteById(id); | ||||
|     } | ||||
|  | ||||
|     private void validateReceivableExists(Long id) { | ||||
|         if (crmReceivableMapper.selectById(id) == null) { | ||||
|         if (receivableMapper.selectById(id) == null) { | ||||
|             throw exception(RECEIVABLE_NOT_EXISTS); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // TODO @芋艿:数据权限 | ||||
|     @Override | ||||
|     public CrmReceivableDO getReceivable(Long id) { | ||||
|         return crmReceivableMapper.selectById(id); | ||||
|         return receivableMapper.selectById(id); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
| @@ -126,17 +126,19 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|         if (CollUtil.isEmpty(ids)) { | ||||
|             return ListUtil.empty(); | ||||
|         } | ||||
|         return crmReceivableMapper.selectBatchIds(ids); | ||||
|         return receivableMapper.selectBatchIds(ids); | ||||
|     } | ||||
|  | ||||
|     // TODO @芋艿:数据权限 | ||||
|     @Override | ||||
|     public PageResult<CrmReceivableDO> getReceivablePage(CrmReceivablePageReqVO pageReqVO) { | ||||
|         return crmReceivableMapper.selectPage(pageReqVO); | ||||
|         return receivableMapper.selectPage(pageReqVO); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<CrmReceivableDO> getReceivableList(CrmReceivableExportReqVO exportReqVO) { | ||||
|         return crmReceivableMapper.selectList(exportReqVO); | ||||
|     @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) | ||||
|     public PageResult<CrmReceivableDO> getReceivablePageByCustomer(CrmReceivablePageReqVO pageReqVO) { | ||||
|         return receivableMapper.selectPageByCustomer(pageReqVO); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmC | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | ||||
| import cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig.CrmCustomerLimitConfigMapper; | ||||
| import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; | ||||
| import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigServiceImpl; | ||||
| import org.junit.jupiter.api.Disabled; | ||||
| import org.junit.jupiter.api.Test; | ||||
|   | ||||
| @@ -2,10 +2,9 @@ package cn.iocoder.yudao.module.crm.service.receivable; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableCreateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableExportReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableUpdateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; | ||||
| import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper; | ||||
| import org.junit.jupiter.api.Disabled; | ||||
| @@ -13,9 +12,7 @@ import org.junit.jupiter.api.Test; | ||||
| import org.springframework.context.annotation.Import; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | ||||
| import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | ||||
| import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | ||||
| import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | ||||
| @@ -121,7 +118,7 @@ public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest { | ||||
|            o.setSort(null); | ||||
|            o.setDataScope(null); | ||||
|            o.setDataScopeDeptIds(null); | ||||
|            o.setStatus(null); | ||||
|            o.setAuditStatus(null); | ||||
|            o.setRemark(null); | ||||
|            o.setCreateTime(null); | ||||
|        }); | ||||
| @@ -132,47 +129,11 @@ public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest { | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null))); | ||||
|        // 测试 customerId 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null))); | ||||
|        // 测试 contractId 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setContractId(null))); | ||||
|        // 测试 checkStatus 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCheckStatus(null))); | ||||
|        // 测试 processInstanceId 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setProcessInstanceId(null))); | ||||
|        // 测试 returnTime 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnTime(null))); | ||||
|        // 测试 returnType 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnType(null))); | ||||
|        // 测试 price 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPrice(null))); | ||||
|        // 测试 ownerUserId 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setOwnerUserId(null))); | ||||
|        // 测试 batchId 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setBatchId(null))); | ||||
|        // 测试 sort 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setSort(null))); | ||||
|        // 测试 dataScope 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScope(null))); | ||||
|        // 测试 dataScopeDeptIds 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScopeDeptIds(null))); | ||||
|        // 测试 status 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setStatus(null))); | ||||
|        // 测试 remark 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setRemark(null))); | ||||
|        // 测试 createTime 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCreateTime(null))); | ||||
|        // 准备参数 | ||||
|        CrmReceivablePageReqVO reqVO = new CrmReceivablePageReqVO(); | ||||
|        reqVO.setNo(null); | ||||
|        reqVO.setPlanId(null); | ||||
|        reqVO.setCustomerId(null); | ||||
|        reqVO.setContractId(null); | ||||
|        reqVO.setCheckStatus(null); | ||||
|        reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||||
|        reqVO.setReturnType(null); | ||||
|        reqVO.setPrice(null); | ||||
|        reqVO.setOwnerUserId(null); | ||||
|        reqVO.setStatus(null); | ||||
|        reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||||
|  | ||||
|        // 调用 | ||||
|        PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(reqVO); | ||||
| @@ -182,85 +143,4 @@ public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest { | ||||
|        assertPojoEquals(dbReceivable, pageResult.getList().get(0)); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     @Disabled  // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | ||||
|     public void testGetReceivableList() { | ||||
|        // mock 数据 | ||||
|        CrmReceivableDO dbReceivable = randomPojo(CrmReceivableDO.class, o -> { // 等会查询到 | ||||
|            o.setNo(null); | ||||
|            o.setPlanId(null); | ||||
|            o.setCustomerId(null); | ||||
|            o.setContractId(null); | ||||
|            o.setCheckStatus(null); | ||||
|            o.setProcessInstanceId(null); | ||||
|            o.setReturnTime(null); | ||||
|            o.setReturnType(null); | ||||
|            o.setPrice(null); | ||||
|            o.setOwnerUserId(null); | ||||
|            o.setBatchId(null); | ||||
|            o.setSort(null); | ||||
|            o.setDataScope(null); | ||||
|            o.setDataScopeDeptIds(null); | ||||
|            o.setStatus(null); | ||||
|            o.setRemark(null); | ||||
|            o.setCreateTime(null); | ||||
|        }); | ||||
|        crmReceivableMapper.insert(dbReceivable); | ||||
|        // 测试 no 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null))); | ||||
|        // 测试 planId 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null))); | ||||
|        // 测试 customerId 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null))); | ||||
|        // 测试 contractId 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setContractId(null))); | ||||
|        // 测试 checkStatus 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCheckStatus(null))); | ||||
|        // 测试 processInstanceId 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setProcessInstanceId(null))); | ||||
|        // 测试 returnTime 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnTime(null))); | ||||
|        // 测试 returnType 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnType(null))); | ||||
|        // 测试 price 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPrice(null))); | ||||
|        // 测试 ownerUserId 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setOwnerUserId(null))); | ||||
|        // 测试 batchId 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setBatchId(null))); | ||||
|        // 测试 sort 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setSort(null))); | ||||
|        // 测试 dataScope 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScope(null))); | ||||
|        // 测试 dataScopeDeptIds 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScopeDeptIds(null))); | ||||
|        // 测试 status 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setStatus(null))); | ||||
|        // 测试 remark 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setRemark(null))); | ||||
|        // 测试 createTime 不匹配 | ||||
|        crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCreateTime(null))); | ||||
|        // 准备参数 | ||||
|        CrmReceivableExportReqVO reqVO = new CrmReceivableExportReqVO(); | ||||
|        reqVO.setNo(null); | ||||
|        reqVO.setPlanId(null); | ||||
|        reqVO.setCustomerId(null); | ||||
|        reqVO.setContractId(null); | ||||
|        reqVO.setCheckStatus(null); | ||||
|        reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||||
|        reqVO.setReturnType(null); | ||||
|        reqVO.setPrice(null); | ||||
|        reqVO.setOwnerUserId(null); | ||||
|        reqVO.setBatchId(null); | ||||
|        reqVO.setStatus(null); | ||||
|        reqVO.setRemark(null); | ||||
|        reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||||
|  | ||||
|        // 调用 | ||||
|        List<CrmReceivableDO> list = receivableService.getReceivableList(reqVO); | ||||
|        // 断言 | ||||
|        assertEquals(1, list.size()); | ||||
|        assertPojoEquals(dbReceivable, list.get(0)); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -72,7 +72,7 @@ CREATE TABLE IF NOT EXISTS "crm_receivable" ( | ||||
|     "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||||
|     "deleted" bit NOT NULL DEFAULT FALSE, | ||||
|     PRIMARY KEY ("id") | ||||
| ) COMMENT '回款管理'; | ||||
| ) COMMENT '回款'; | ||||
|  | ||||
| CREATE TABLE IF NOT EXISTS "crm_receivable_plan" ( | ||||
|      "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV