| | |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.invoice.vo.invoice.CrmInvoiceRespVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableItemRespVO; |
| | | 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.CrmReceivableSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.invoice.CrmInvoiceDO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableItemDO; |
| | | import cn.iocoder.yudao.module.crm.enums.receivable.CrmReceivableBizTypeEnum; |
| | | 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.invoice.CrmInvoiceService; |
| | |
| | | @GetMapping("/get") |
| | | @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 = receivableService.getReceivable(id); |
| | | return success(buildReceivableDetail(receivable)); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得回款分页") |
| | | @PreAuthorize("@ss.hasPermission('crm:receivable:query')") |
| | | public CommonResult<PageResult<CrmReceivableRespVO>> getReceivablePage(@Valid CrmReceivablePageReqVO pageReqVO) { |
| | | PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(pageReqVO, getLoginUserId()); |
| | | return success(new PageResult<>(buildReceivableDetailList(pageResult.getList()), pageResult.getTotal())); |
| | |
| | | }); |
| | | } |
| | | |
| | | @PutMapping("/submit") |
| | | @Operation(summary = "提交回款审批") |
| | | @PutMapping("/update-status") |
| | | @Operation(summary = "更新回款的状态(审核/反审核)") |
| | | @PreAuthorize("@ss.hasPermission('crm:receivable:update')") |
| | | public CommonResult<Boolean> submitContract(@RequestParam("id") Long id) { |
| | | receivableService.submitReceivable(id, getLoginUserId()); |
| | | public CommonResult<Boolean> updateReceivableStatus(@RequestParam("id") Long id, |
| | | @RequestParam("status") Integer status) { |
| | | receivableService.updateReceivableStatus(id, status); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/audit-count") |
| | | @Operation(summary = "获得待审核回款数量") |
| | | @PreAuthorize("@ss.hasPermission('crm:receivable:query')") |
| | | public CommonResult<Long> getAuditReceivableCount() { |
| | | return success(receivableService.getAuditReceivableCount(getLoginUserId())); |
| | | } |
| | | |
| | | @GetMapping("/item-list") |
| | | @Operation(summary = "获得回款的核销明细") |
| | | @Parameter(name = "receivableId", description = "回款编号", required = true) |
| | | public CommonResult<List<CrmReceivableItemRespVO>> getReceivableItemList(@RequestParam("receivableId") Long receivableId) { |
| | | CrmReceivableDO receivable = receivableService.getReceivable(receivableId); |
| | | return success(buildReceivableItemList(receivableService.getReceivableItemList(receivableId), |
| | | receivable == null ? Collections.emptyList() : Collections.singletonList(receivable))); |
| | | } |
| | | |
| | | @GetMapping("/item-list-by-customer") |
| | | @Operation(summary = "获得客户下全部回款的核销明细") |
| | | @Parameter(name = "customerId", description = "客户编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('crm:receivable:query')") |
| | | public CommonResult<List<CrmReceivableItemRespVO>> getReceivableItemListByCustomerId( |
| | | @RequestParam("customerId") Long customerId) { |
| | | List<CrmReceivableItemDO> items = receivableService.getReceivableItemListByCustomerId(customerId); |
| | | if (CollUtil.isEmpty(items)) { |
| | | return success(Collections.emptyList()); |
| | | } |
| | | Map<Long, CrmReceivableDO> receivableMap = receivableService.getReceivableMap( |
| | | convertSet(items, CrmReceivableItemDO::getReceivableId)); |
| | | return success(buildReceivableItemList(items, receivableMap.values())); |
| | | } |
| | | |
| | | private List<CrmReceivableItemRespVO> buildReceivableItemList(List<CrmReceivableItemDO> items, |
| | | java.util.Collection<CrmReceivableDO> receivables) { |
| | | if (CollUtil.isEmpty(items)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | Map<Long, CrmReceivableDO> receivableMap = receivables.stream() |
| | | .collect(java.util.stream.Collectors.toMap(CrmReceivableDO::getId, item -> item, (a, b) -> a)); |
| | | return BeanUtils.toBean(items, CrmReceivableItemRespVO.class, vo -> { |
| | | vo.setBizTypeName(CrmReceivableBizTypeEnum.getNameByType(vo.getBizType())); |
| | | CrmReceivableDO receivable = receivableMap.get(vo.getReceivableId()); |
| | | if (receivable != null) { |
| | | vo.setReceivableNo(receivable.getNo()); |
| | | vo.setCustomerId(receivable.getCustomerId()); |
| | | vo.setReturnTime(receivable.getReturnTime()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |