| | |
| | | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationOptionRespVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationPageReqVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationRespVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationRevisionRespVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationSaveReqVO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.bidbond.CrmBidBondDO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.quotation.CrmSaleQuotationDO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.quotation.CrmSaleQuotationProductDO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.quotation.CrmSaleQuotationRevisionDO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| | | import cn.iocoder.yudao.module.crm.dal.mysql.bidbond.CrmBidBondMapper; |
| | | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; |
| | | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| | | import cn.iocoder.yudao.module.crm.enums.quotation.CrmSaleQuotationStatusEnum; |
| | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.UPDATE; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; |
| | |
| | | |
| | | @Resource |
| | | private CrmSaleQuotationService saleQuotationService; |
| | | |
| | | @Resource |
| | | private CrmBidBondMapper bidBondMapper; |
| | | |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | |
| | | return success(saleQuotationService.convertToContract(id, getLoginUserId())); |
| | | } |
| | | |
| | | @PutMapping("/void") |
| | | @Operation(summary = "作废销售报价单") |
| | | @Parameter(name = "id", description = "报价单编号", required = true) |
| | | @Parameter(name = "reason", description = "作废原因", required = true) |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:void')") |
| | | @ApiAccessLog(operateType = UPDATE) |
| | | public CommonResult<Boolean> voidSaleQuotation(@RequestParam("id") Long id, |
| | | @RequestParam("reason") String reason) { |
| | | saleQuotationService.voidSaleQuotation(id, reason); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/revision/list") |
| | | @Operation(summary = "获得报价单轮次流水列表") |
| | | @Parameter(name = "quotationId", description = "报价单编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:query')") |
| | | public CommonResult<List<CrmSaleQuotationRevisionRespVO>> getRevisionList( |
| | | @RequestParam("quotationId") Long quotationId) { |
| | | List<CrmSaleQuotationRevisionDO> list = saleQuotationService.getSaleQuotationRevisionList(quotationId); |
| | | return success(BeanUtils.toBean(list, CrmSaleQuotationRevisionRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/revision/export-excel") |
| | | @Operation(summary = "导出报价单轮次流水 Excel") |
| | | @Parameter(name = "quotationId", description = "报价单编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:export')") |
| | | @ApiAccessLog(operateType = EXPORT) |
| | | public void exportRevisionExcel(@RequestParam("quotationId") Long quotationId, |
| | | HttpServletResponse response) throws IOException { |
| | | List<CrmSaleQuotationRevisionRespVO> list = BeanUtils.toBean( |
| | | saleQuotationService.getSaleQuotationRevisionList(quotationId), |
| | | CrmSaleQuotationRevisionRespVO.class); |
| | | ExcelUtils.write(response, "报价轮次流水.xls", "数据", CrmSaleQuotationRevisionRespVO.class, list); |
| | | } |
| | | |
| | | @GetMapping("/bindable-list") |
| | | @Operation(summary = "获得客户下可绑定投标的报价单列表") |
| | | @Parameter(name = "customerId", description = "客户编号", required = true) |
| | | @Parameter(name = "bidBondId", description = "当前投标保证金编号(编辑时用于保留自身绑定)", required = false) |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:query')") |
| | | public CommonResult<List<CrmSaleQuotationOptionRespVO>> getBindableList( |
| | | @RequestParam("customerId") Long customerId, |
| | | @RequestParam(value = "bidBondId", required = false) Long bidBondId) { |
| | | return success(BeanUtils.toBean( |
| | | saleQuotationService.getBindableQuotationList(customerId, bidBondId), |
| | | CrmSaleQuotationOptionRespVO.class)); |
| | | } |
| | | |
| | | // ==================== 构建响应 VO ==================== |
| | | |
| | | private CrmSaleQuotationRespVO buildSaleQuotationRespVO(CrmSaleQuotationDO saleQuotation, List<CrmSaleQuotationProductDO> productList) { |
| | |
| | | } |
| | | // 3. 填充关联信息 |
| | | fillSaleQuotationRelatedFields(respVO); |
| | | // 3.1 填充关联投标的中标结果 |
| | | if (saleQuotation.getBidBondId() != null) { |
| | | CrmBidBondDO bidBond = bidBondMapper.selectById(saleQuotation.getBidBondId()); |
| | | if (bidBond != null) { |
| | | respVO.setBidResult(bidBond.getBidResult()); |
| | | } |
| | | } |
| | | // 4. 填充附件列表 |
| | | respVO.setAttachmentList(storageAttachmentApi.listAttachments("crm_sale_quotation", saleQuotation.getId())); |
| | | return respVO; |
| | |
| | | // 1.6 商机信息(过滤 null,businessId 为可选字段) |
| | | Map<Long, CrmBusinessDO> businessMap = businessService.getBusinessMap( |
| | | convertSet(pageResult.getList(), CrmSaleQuotationDO::getBusinessId, vo -> vo.getBusinessId() != null)); |
| | | // 1.7 投标信息(过滤 null,bidBondId 为可选字段) |
| | | Set<Long> bidBondIds = convertSet(pageResult.getList(), CrmSaleQuotationDO::getBidBondId, |
| | | vo -> vo.getBidBondId() != null); |
| | | Map<Long, CrmBidBondDO> bidBondMap = bidBondIds.isEmpty() ? Map.of() |
| | | : convertMap(bidBondMapper.selectByIds(bidBondIds), CrmBidBondDO::getId); |
| | | |
| | | // 2. 开始拼接 |
| | | return BeanUtils.toBean(pageResult, CrmSaleQuotationRespVO.class, vo -> { |
| | |
| | | MapUtils.findAndThen(userMap, vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname())); |
| | | MapUtils.findAndThen(deptMap, vo.getOwnerUserId(), dept -> vo.setOwnerUserDeptName(dept.getName())); |
| | | MapUtils.findAndThen(businessMap, vo.getBusinessId(), business -> vo.setBusinessName(business.getName())); |
| | | MapUtils.findAndThen(bidBondMap, vo.getBidBondId(), bidBond -> vo.setBidResult(bidBond.getBidResult())); |
| | | }); |
| | | } |
| | | |