From a82d847bbb39e2417d4c9773ebc4fc51fdb0b8fc Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 10 十一月 2026 13:31:31 +0800
Subject: [PATCH] feat(crm): 完善投标保证金与报价单关联及作废功能
---
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java | 91 ++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 85 insertions(+), 6 deletions(-)
diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java
index 0d039ed..dd0bb9b 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java
@@ -8,17 +8,23 @@
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 cn.iocoder.yudao.module.crm.service.quotation.CrmSaleQuotationDocumentRenderer;
+import cn.iocoder.yudao.module.crm.service.quotation.CrmSaleQuotationExcelRenderer;
+import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
import cn.iocoder.yudao.module.crm.service.quotation.CrmSaleQuotationService;
import cn.iocoder.yudao.module.system.service.companyconfig.SystemCompanyConfigService;
import cn.iocoder.yudao.module.mdm.api.item.MdmItemApi;
@@ -45,8 +51,10 @@
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;
@@ -67,6 +75,9 @@
private CrmSaleQuotationService saleQuotationService;
@Resource
+ private CrmBidBondMapper bidBondMapper;
+
+ @Resource
private AdminUserApi adminUserApi;
@Resource
private DeptApi deptApi;
@@ -76,6 +87,8 @@
private MdmUnitMeasureApi mdmUnitMeasureApi;
@Resource
private CrmCustomerService customerService;
+ @Resource
+ private CrmContactService contactService;
@Resource
private CrmBusinessService businessService;
@Resource
@@ -166,8 +179,8 @@
ExcelUtils.write(response, "閿�鍞姤浠峰崟.xls", "鏁版嵁", CrmSaleQuotationRespVO.class, list);
}
- @GetMapping("/export-word")
- @Operation(summary = "瀵煎嚭閿�鍞姤浠峰崟 Word锛堝甫鐢靛瓙绔狅級")
+ @GetMapping({"/export-word", "/export-quotation-excel"})
+ @Operation(summary = "瀵煎嚭閿�鍞姤浠峰崟 Excel锛堝甫鐢靛瓙绔狅級")
@Parameter(name = "id", description = "鎶ヤ环鍗曠紪鍙�", required = true)
@PreAuthorize("@ss.hasPermission('crm:sale-quotation:export')")
@ApiAccessLog(operateType = EXPORT)
@@ -187,12 +200,17 @@
saleQuotationService.getSaleQuotationProductListByQuotationId(id));
var companyConfig = companyConfigService.getCompanyConfig();
String companyName = companyConfig != null ? companyConfig.getCompanyName() : null;
- byte[] content = CrmSaleQuotationDocumentRenderer.render(respVO, companyName);
+ var customer = saleQuotation.getCustomerId() == null ? null : customerService.getCustomer(saleQuotation.getCustomerId());
+ var contact = saleQuotation.getContactId() == null ? null : contactService.getContact(saleQuotation.getContactId());
+ String phone = contact == null ? null : (contact.getMobile() != null && !contact.getMobile().isBlank()
+ ? contact.getMobile() : contact.getTelephone());
+ byte[] content = CrmSaleQuotationExcelRenderer.render(respVO, companyName,
+ customer == null ? null : customer.getDetailAddress(), contact == null ? null : contact.getName(), phone);
String filename = "鎶ヤ环鍗�-" + saleQuotation.getNo()
- + (respVO.getCustomerName() != null ? "-" + respVO.getCustomerName() : "") + ".docx";
+ + (respVO.getCustomerName() != null ? "-" + respVO.getCustomerName() : "") + ".xlsx";
String encoded = URLEncoder.encode(filename, StandardCharsets.UTF_8).replace("+", "%20");
- response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment;filename*=UTF-8''" + encoded);
response.getOutputStream().write(content);
}
@@ -219,6 +237,54 @@
@PreAuthorize("@ss.hasPermission('crm:sale-quotation:convert-contract')")
public CommonResult<Long> convertToContract(@RequestParam("id") Long id) {
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 ====================
@@ -268,6 +334,13 @@
}
// 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;
@@ -304,6 +377,11 @@
// 1.6 鍟嗘満淇℃伅锛堣繃婊� null锛宐usinessId 涓哄彲閫夊瓧娈碉級
Map<Long, CrmBusinessDO> businessMap = businessService.getBusinessMap(
convertSet(pageResult.getList(), CrmSaleQuotationDO::getBusinessId, vo -> vo.getBusinessId() != null));
+ // 1.7 鎶曟爣淇℃伅锛堣繃婊� null锛宐idBondId 涓哄彲閫夊瓧娈碉級
+ 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 -> {
@@ -324,6 +402,7 @@
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()));
});
}
--
Gitblit v1.9.3