| | |
| | | import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; |
| | | import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; |
| | | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| | | import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi; |
| | | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| | | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | |
| | | |
| | | @Resource |
| | | private CrmCustomerService customerService; |
| | | @Resource |
| | | private CrmCustomerApi customerApi; |
| | | @Resource |
| | | private CrmBusinessService businessService; |
| | | @Resource |
| | |
| | | |
| | | @Override |
| | | public PageResult<CrmSaleQuotationDO> getSaleQuotationPage(CrmSaleQuotationPageReqVO pageReqVO, Long userId) { |
| | | // 获取用户有权限的客户 ID 列表 |
| | | List<Long> permittedCustomerIds = customerApi.getPermittedCustomerIds(); |
| | | return saleQuotationMapper.selectPage(pageReqVO, userId, permittedCustomerIds); |
| | | // 可见性完全由 appendPermissionCondition 控制(报价团队 ∪ 客户团队), |
| | | // 不再额外按「有权限的客户」过滤,避免不在客户团队、但属于报价负责人/报价团队的用户被错误过滤 |
| | | return saleQuotationMapper.selectPage(pageReqVO, userId, null); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // 2. 获取报价明细 |
| | | List<CrmSaleQuotationProductDO> quotationProducts = saleQuotationProductMapper.selectListByQuotationId(id); |
| | | |
| | | // 合同明细使用整数数量,禁止截断小数或溢出后生成错误订单。 |
| | | for (CrmSaleQuotationProductDO product : quotationProducts) { |
| | | try { |
| | | if (product.getCount() == null || product.getCount().intValueExact() <= 0) { |
| | | throw exception(SALE_QUOTATION_CONVERT_INVALID_COUNT); |
| | | } |
| | | } catch (ArithmeticException ex) { |
| | | throw exception(SALE_QUOTATION_CONVERT_INVALID_COUNT); |
| | | } |
| | | } |
| | | // 3. 构建合同创建 VO |
| | | CrmContractSaveReqVO contractVO = new CrmContractSaveReqVO(); |
| | | contractVO.setName(saleQuotation.getName() + "-合同"); |