From 0bc2c552b180afa16e4aae3c8c12746b15ba6fc8 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期四, 02 四月 2026 17:35:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_长治_健齿齿科器材' into dev_长治_健齿齿科器材

---
 src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java |   78 ++++++++++++++++++++++++++-------------
 1 files changed, 52 insertions(+), 26 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
index 104a712..b5d0fe8 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
@@ -4,8 +4,12 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
+import com.ruoyi.approve.pojo.ApproveProcess;
+import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl;
+import com.ruoyi.approve.vo.ApproveGetAndUpdateVo;
+import com.ruoyi.common.utils.OrderUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.sales.dto.SalesQuotationDto;
 import com.ruoyi.sales.mapper.SalesQuotationMapper;
@@ -15,10 +19,10 @@
 import com.ruoyi.sales.service.SalesQuotationProductService;
 import com.ruoyi.sales.service.SalesQuotationService;
 import org.springframework.beans.factory.annotation.Autowired;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -31,6 +35,9 @@
     private SalesQuotationProductMapper salesQuotationProductMapper;
     @Autowired
     private SalesQuotationProductService salesQuotationProductService;
+
+    @Autowired
+    private ApproveProcessServiceImpl approveProcessService;
     @Override
     public IPage<SalesQuotationDto> listPage(Page page, SalesQuotationDto salesQuotationDto) {
         IPage<SalesQuotationDto> salesQuotationDtoIPage = salesQuotationMapper.listPage(page, salesQuotationDto);
@@ -48,31 +55,10 @@
     public boolean add(SalesQuotationDto salesQuotationDto) {
         SalesQuotation salesQuotation = new SalesQuotation();
         BeanUtils.copyProperties(salesQuotationDto, salesQuotation);
-        String quotationNo = salesQuotation.getQuotationNo();
+        String quotationNo = OrderUtils.countTodayByCreateTime(salesQuotationMapper, "QT");
+        salesQuotation.setQuotationNo(quotationNo);
+        salesQuotation.setStatus("寰呭鎵�");
         salesQuotationMapper.insert(salesQuotation);
-//        if(salesQuotationMapper.insert(salesQuotation)!=1){
-//            return false;
-//        }
-        if(CollectionUtils.isEmpty(salesQuotationDto.getProducts())){
-            return true;
-        }
-        List<SalesQuotationProduct> products = salesQuotationDto.getProducts().stream().map(product -> {
-            SalesQuotationProduct salesQuotationProduct = new SalesQuotationProduct();
-            BeanUtils.copyProperties(product, salesQuotationProduct);
-            salesQuotationProduct.setSalesQuotationId(salesQuotationMapper.selectOne(new LambdaQueryWrapper<SalesQuotation>().eq(SalesQuotation::getQuotationNo, quotationNo)).getId());
-            return salesQuotationProduct;
-        }).collect(Collectors.toList());
-        salesQuotationProductService.saveBatch(products);
-        return true;
-    }
-    @Override
-    public boolean edit(SalesQuotationDto salesQuotationDto) {
-        SalesQuotation salesQuotation = new SalesQuotation();
-        BeanUtils.copyProperties(salesQuotationDto, salesQuotation);
-        if(salesQuotationMapper.updateById(salesQuotation)!=1){
-            return false;
-        }
-        salesQuotationProductMapper.delete(new LambdaQueryWrapper<SalesQuotationProduct>().eq(SalesQuotationProduct::getSalesQuotationId, salesQuotationDto.getId()));
         if(CollectionUtils.isEmpty(salesQuotationDto.getProducts())){
             return true;
         }
@@ -86,9 +72,49 @@
         return true;
     }
     @Override
+    public boolean edit(SalesQuotationDto salesQuotationDto) {
+        SalesQuotation salesQuotation = new SalesQuotation();
+        BeanUtils.copyProperties(salesQuotationDto, salesQuotation);
+        ApproveGetAndUpdateVo vo = new ApproveGetAndUpdateVo();
+        if("鎷掔粷".equals(salesQuotationDto.getStatus())){
+            vo.setApproveStatus(0);
+            salesQuotation.setStatus("寰呭鎵�");
+        }
+        if(salesQuotationMapper.updateById(salesQuotation)!=1){
+            return false;
+        }
+        salesQuotationProductMapper.delete(new LambdaQueryWrapper<SalesQuotationProduct>().eq(SalesQuotationProduct::getSalesQuotationId, salesQuotationDto.getId()));
+        if(CollectionUtils.isEmpty(salesQuotationDto.getProducts())){
+            return true;
+        }
+        List<SalesQuotationProduct> products = salesQuotationDto.getProducts().stream().map(product -> {
+            SalesQuotationProduct salesQuotationProduct = new SalesQuotationProduct();
+            BeanUtils.copyProperties(product, salesQuotationProduct);
+            salesQuotationProduct.setSalesQuotationId(salesQuotation.getId());
+            return salesQuotationProduct;
+        }).collect(Collectors.toList());
+
+        salesQuotationProductService.saveBatch(products);
+        // 淇敼鎶ヤ环瀹℃壒
+        vo.setApproveUserIds(salesQuotationDto.getApproveUserIds());
+        vo.setApproveType(6);
+        vo.setApproveReason(salesQuotationDto.getQuotationNo());
+        approveProcessService.updateApproveUser(vo);
+        return true;
+    }
+    @Override
     public boolean delete(Long id) {
+        SalesQuotation salesQuotation = salesQuotationMapper.selectById(id);
+        if(salesQuotation==null) return false;
         salesQuotationMapper.deleteById(id);
         salesQuotationProductMapper.delete(new LambdaQueryWrapper<SalesQuotationProduct>().eq(SalesQuotationProduct::getSalesQuotationId, id));
+        // 鍒犻櫎鎶ヤ环瀹℃壒
+        ApproveProcess one = approveProcessService.getOne(new LambdaQueryWrapper<ApproveProcess>()
+                .eq(ApproveProcess::getApproveType, 6)
+                .eq(ApproveProcess::getApproveReason, salesQuotation.getQuotationNo()));
+        if(one != null){
+            approveProcessService.delByIds(Collections.singletonList(one.getId()));
+        }
         return true;
     }
 

--
Gitblit v1.9.3