From 6305d0c86c23e9a583e8ca798645885d167f4dc5 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 10 六月 2026 17:20:58 +0800
Subject: [PATCH] feat:1.销售台账导出按照查询条件 2.导出订单和产品明细

---
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 1110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 1,090 insertions(+), 20 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index 3f24246..e209855 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -1,18 +1,20 @@
 package com.ruoyi.sales.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.ruoyi.account.service.AccountIncomeService;
+import com.ruoyi.approve.pojo.ApproveProcess;
 import com.ruoyi.approve.service.IApproveProcessService;
 import com.ruoyi.approve.vo.ApproveProcessVO;
-import com.ruoyi.approve.pojo.ApproveProcess;
-import com.ruoyi.common.enums.ApproveTypeEnum;
 import com.ruoyi.basic.mapper.CustomerMapper;
 import com.ruoyi.basic.mapper.ProductMapper;
 import com.ruoyi.basic.mapper.ProductModelMapper;
@@ -21,34 +23,32 @@
 import com.ruoyi.basic.pojo.Product;
 import com.ruoyi.basic.pojo.ProductModel;
 import com.ruoyi.basic.service.ICustomerRegionsService;
-import com.ruoyi.common.enums.FileNameType;
-import com.ruoyi.common.enums.SaleEnum;
-import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum;
-import com.ruoyi.common.enums.StockInUnQualifiedRecordTypeEnum;
-import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum;
-import com.ruoyi.common.enums.StockOutUnQualifiedRecordTypeEnum;
+import com.ruoyi.common.enums.*;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.exception.base.BaseException;
-import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.common.utils.EnumUtil;
-import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.*;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.security.LoginUser;
 import com.ruoyi.other.mapper.TempFileMapper;
 import com.ruoyi.other.pojo.TempFile;
+import com.ruoyi.procurementrecord.utils.StockUtils;
 import com.ruoyi.production.mapper.*;
 import com.ruoyi.production.pojo.ProcessRoute;
 import com.ruoyi.production.pojo.ProcessRouteItem;
 import com.ruoyi.production.service.ProductionProductMainService;
-
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.mapper.SysDeptMapper;
 import com.ruoyi.project.system.mapper.SysUserMapper;
-import com.ruoyi.procurementrecord.utils.StockUtils;
 import com.ruoyi.purchase.dto.SimpleReturnOrderGroupDto;
 import com.ruoyi.purchase.mapper.PurchaseReturnOrderProductsMapper;
 import com.ruoyi.quality.mapper.QualityInspectMapper;
+import com.ruoyi.quality.mapper.QualityInspectParamMapper;
+import com.ruoyi.quality.mapper.QualityTestStandardMapper;
+import com.ruoyi.quality.mapper.QualityTestStandardParamMapper;
+import com.ruoyi.quality.pojo.QualityInspect;
+import com.ruoyi.quality.pojo.QualityInspectParam;
+import com.ruoyi.quality.pojo.QualityTestStandard;
+import com.ruoyi.quality.pojo.QualityTestStandardParam;
 import com.ruoyi.sales.dto.*;
 import com.ruoyi.sales.mapper.*;
 import com.ruoyi.sales.pojo.*;
@@ -58,6 +58,7 @@
 import com.ruoyi.sales.service.ISalesLedgerService;
 import com.ruoyi.stock.dto.StockInventoryDto;
 import com.ruoyi.stock.mapper.StockInRecordMapper;
+import com.ruoyi.stock.mapper.StockInventoryMapper;
 import com.ruoyi.stock.mapper.StockOutRecordMapper;
 import com.ruoyi.stock.pojo.StockInRecord;
 import com.ruoyi.stock.pojo.StockOutRecord;
@@ -77,19 +78,21 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.net.URLEncoder;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.time.ZoneId;
 import java.time.YearMonth;
+import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
@@ -139,6 +142,9 @@
     private final ProductionProductOutputMapper productionProductOutputMapper;
     private final ProductionProductInputMapper productionProductInputMapper;
     private final QualityInspectMapper qualityInspectMapper;
+    private final QualityInspectParamMapper qualityInspectParamMapper;
+    private final QualityTestStandardMapper qualityTestStandardMapper;
+    private final QualityTestStandardParamMapper qualityTestStandardParamMapper;
     private final RedisTemplate<String, String> redisTemplate;
 
     private final ISalesLedgerProductProcessService salesLedgerProductProcessService;
@@ -150,9 +156,12 @@
     private final StockInventoryService stockInventoryService;
     private final StockInRecordMapper stockInRecordMapper;
     private final StockOutRecordMapper stockOutRecordMapper;
+    private final StockInventoryMapper stockInventoryMapper;
     private final StockInRecordService stockInRecordService;
     private final StockOutRecordService stockOutRecordService;
     private final StockUtils stockUtils;
+    private final ShipmentApprovalMapper shipmentApprovalMapper;
+
     @Autowired
     private IApproveProcessService approveProcessService;
 
@@ -326,7 +335,9 @@
     public List getTopFiveList() {
         // 鏌ヨ鍘熷鏁版嵁
         LambdaQueryWrapper<SalesLedger> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.select(SalesLedger::getCustomerId, SalesLedger::getCustomerName, SalesLedger::getContractAmount).orderByDesc(SalesLedger::getContractAmount);
+        queryWrapper.select(SalesLedger::getCustomerId, SalesLedger::getCustomerName, SalesLedger::getContractAmount)
+                .orderByDesc(SalesLedger::getContractAmount)
+                .ne(SalesLedger::getReviewStatus, 2); // 鎺掗櫎鍙嶅鏍告暟鎹�
         List<SalesLedger> records = salesLedgerMapper.selectList(queryWrapper);
 
         // 鎸夊鎴稩D鍒嗙粍骞惰仛鍚堥噾棰�
@@ -385,6 +396,7 @@
 
     @Override
     public IPage<SalesLedger> selectSalesLedgerListPage(Page page, SalesLedgerDto salesLedgerDto) {
+        // 娣诲姞 reviewStatus 鐨勭瓫閫夋潯浠�
         IPage<SalesLedger> iPage = salesLedgerMapper.selectSalesLedgerListPage(page, salesLedgerDto);
 
         if (CollectionUtils.isEmpty(iPage.getRecords())) {
@@ -469,6 +481,14 @@
             salesLedger.setIsFh(isFh);
 
             salesLedger.setIsEdit(!isFh);
+            
+            // 鏍规嵁 reviewStatus 鎺у埗鍙嶅鐩稿叧瀛楁鐨勬樉绀�
+            if (salesLedger.getReviewStatus() != null && salesLedger.getReviewStatus() != 2) {
+                // 褰� reviewStatus 涓嶄负 2 鏃讹紝闅愯棌鍙嶅鏃堕棿銆佸弽瀹′汉鍜屽弽瀹′汉ID
+                salesLedger.setCounterReviewTime(null);
+                salesLedger.setCounterReviewPerson(null);
+                salesLedger.setCounterReviewPersonId(null);
+            }
         }
 
         if (salesLedgerDto.getStatus() != null && salesLedgerDto.getStatus()) {
@@ -714,9 +734,9 @@
                 product.setRegisterDate(LocalDateTime.now());
                 // 鍙戣揣淇℃伅
                 ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>().eq(ShippingInfo::getSalesLedgerProductId, product.getId()).orderByDesc(ShippingInfo::getCreateTime).last("limit 1"));
-                product.setShippingCarNumber(shippingInfo.getShippingCarNumber());
-                product.setShippingDate(shippingInfo.getShippingDate());
                 if (shippingInfo != null) {
+                    product.setShippingCarNumber(shippingInfo.getShippingCarNumber());
+                    product.setShippingDate(shippingInfo.getShippingDate());
                     product.setShippingStatus(shippingInfo.getStatus());
                 }
             }
@@ -793,6 +813,13 @@
         List<Long> idList = Arrays.stream(ids).filter(Objects::nonNull).collect(Collectors.toList());
         if (CollectionUtils.isEmpty(idList)) {
             return 0;
+        }
+        // 鏍¢獙锛氬凡瀹℃牳鐨勮鍗曚笉鑳藉垹闄�
+        List<SalesLedger> ledgers = salesLedgerMapper.selectBatchIds(idList);
+        for (SalesLedger ledger : ledgers) {
+            if (ledger.getReviewStatus() != null && ledger.getReviewStatus() == 1) {
+                throw new ServiceException("宸插鏍哥殑璁㈠崟涓嶈兘鍒犻櫎锛�" + ledger.getSalesContractNo());
+            }
         }
         // 鍒犻櫎閿�鍞鐞嗘暟鎹�
         LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>();
@@ -887,6 +914,27 @@
             } else {
                 if (salesLedger.getDeliveryStatus() == 5) {
                     throw new ServiceException("璁㈠崟宸插彂璐�,绂佹缂栬緫");
+                }
+                // 鏌ヨ鏁版嵁搴撲腑鐨勫師濮嬭褰曠敤浜庢牎楠�
+                SalesLedger existingLedger = salesLedgerMapper.selectById(salesLedger.getId());
+                if (salesLedger.getReviewStatus() != null && salesLedger.getReviewStatus() == 1) {
+                    // 瀹℃牳鎿嶄綔锛氭牎楠屽鏍镐汉涓嶈兘鏄綍鍏ヤ汉锛堜粎瀵规湭瀹℃牳鈫掑凡瀹℃牳鐨勮浆鎹級
+                    if (existingLedger != null && existingLedger.getReviewStatus() != null && existingLedger.getReviewStatus() == 0) {
+                        Long currentUserId = SecurityUtils.getUserId();
+                        String entryPerson = existingLedger.getEntryPerson();
+                        if (entryPerson != null && entryPerson.equals(String.valueOf(currentUserId))) {
+                            throw new ServiceException("涓嶈兘瀹℃牳鏈汉褰曞叆鐨勮鍗�");
+                        }
+                    }
+                    salesLedger.setReviewStatus(salesLedgerDto.getReviewStatus());
+                } else if (salesLedger.getReviewStatus() != null && salesLedger.getReviewStatus() == 2) {
+                    handleCounterReview(salesLedger);
+                } else {
+                    // 鏈鏍哥姸鎬佺殑缂栬緫鎿嶄綔锛氭牎楠屽凡瀹℃牳鐨勮鍗曚笉鑳界紪杈�
+                    if (existingLedger != null && existingLedger.getReviewStatus() != null && existingLedger.getReviewStatus() == 1) {
+                        throw new ServiceException("宸插鏍哥殑璁㈠崟涓嶈兘缂栬緫");
+                    }
+                    salesLedger.setReviewStatus(0);
                 }
                 salesLedgerMapper.updateById(salesLedger);
             }
@@ -2135,9 +2183,13 @@
         if (salesLedger.getDeliveryStatus() != null && salesLedger.getDeliveryStatus() == 5) {
             throw new ServiceException("鍑哄簱澶辫触,璇ラ攢鍞鍗曞凡鍙戣揣");
         }
+        if (salesLedger.getDeliveryStatus() != null && salesLedger.getDeliveryStatus() == 2) {
+            throw new ServiceException("鍑哄簱澶辫触,璇ラ攢鍞鍗曞凡鍙戣捣鍙戣揣瀹℃壒,璇峰厛瀹屾垚瀹℃壒");
+        }
         if (CollectionUtils.isEmpty(dto.getSalesLedgerProductList())) {
             throw new ServiceException("閿�鍞鍗曞嚭搴撳け璐�,鍑哄簱浜у搧涓嶈兘涓虹┖");
         }
+        String scanShippingNo = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SCAN");
         int saleType = SaleEnum.SALE.getCode();
         Map<Long, BigDecimal> outboundQtyByLineId = new LinkedHashMap<>();
         for (SalesLedgerProduct line : dto.getSalesLedgerProductList()) {
@@ -2170,6 +2222,11 @@
             if (dbProduct.getProductModelId() == null) {
                 throw new ServiceException("鍑哄簱澶辫触,浜у搧瑙勬牸鏈淮鎶�,鏃犳硶鍑哄簱");
             }
+            BigDecimal orderQty = defaultDecimal(dbProduct.getQuantity());
+            BigDecimal prevShipped = defaultDecimal(dbProduct.getShippedQuantity());
+            if (prevShipped.add(outboundThisLine).compareTo(orderQty) > 0) {
+                throw new ServiceException("鍑哄簱澶辫触,鏈鍑哄簱鍚庣疮璁″彂璐ф暟閲忎笉鑳藉ぇ浜庤浜у搧璁㈠崟鏁伴噺");
+            }
             stockUtils.assertQualifiedAvailable(dbProduct.getProductModelId(), outboundThisLine);
 
             StockInventoryDto stockInventoryDto = new StockInventoryDto();
@@ -2193,7 +2250,74 @@
         });
         boolean allLinesFull = ledgerAllProducts.stream().allMatch(p -> Objects.equals(p.getProductStockStatus(), 2));
         salesLedger.setStockStatus(allLinesFull ? 2 : (anyInbound ? 1 : 0));
+        List<SalesLedgerProduct> saleLines = ledgerAllProducts.stream()
+                .filter(p -> Objects.equals(p.getType(), saleType))
+                .collect(Collectors.toList());
+        boolean allDelivered = !saleLines.isEmpty() && saleLines.stream().allMatch(p -> {
+            BigDecimal q = defaultDecimal(p.getQuantity());
+            BigDecimal s = defaultDecimal(p.getShippedQuantity());
+            return q.compareTo(BigDecimal.ZERO) <= 0 || s.compareTo(q) >= 0;
+        });
+        if (allDelivered) {
+            salesLedger.setDeliveryStatus(5);
+        } else {
+            boolean anyLineShipped = saleLines.stream()
+                    .anyMatch(p -> defaultDecimal(p.getShippedQuantity()).compareTo(BigDecimal.ZERO) > 0);
+            if (anyLineShipped) {
+                salesLedger.setDeliveryStatus(6);
+            }
+        }
         baseMapper.updateById(salesLedger);
+        syncShippingLedgerAfterQualifiedScan(ledgerId, scanShippingNo);
+    }
+
+    /**
+     * 鎵爜鍚堟牸鍑哄簱鍚庡悓姝ュ彂璐у彴璐﹁褰�
+     */
+    private void syncShippingLedgerAfterQualifiedScan(Long ledgerId, String shippingBatchNo) {
+        if (shippingBatchNo == null) {
+            shippingBatchNo = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SCAN");
+        }
+        int saleType = SaleEnum.SALE.getCode();
+        List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(
+                Wrappers.<SalesLedgerProduct>lambdaQuery()
+                        .eq(SalesLedgerProduct::getSalesLedgerId, ledgerId)
+                        .eq(SalesLedgerProduct::getType, saleType));
+        Date now = new Date();
+        for (SalesLedgerProduct p : products) {
+            if (p.getShippedQuantity() == null || p.getShippedQuantity().compareTo(BigDecimal.ZERO) <= 0) {
+                continue;
+            }
+            ShippingInfo row = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>()
+                    .eq(ShippingInfo::getSalesLedgerProductId, p.getId())
+                    .orderByDesc(ShippingInfo::getId)
+                    .last("LIMIT 1"));
+            BigDecimal lineQty = defaultDecimal(p.getQuantity());
+            BigDecimal shipped = defaultDecimal(p.getShippedQuantity());
+            boolean lineFullyShipped = lineQty.compareTo(BigDecimal.ZERO) <= 0 || shipped.compareTo(lineQty) >= 0;
+            String lineShipStatus = lineFullyShipped ? "宸插彂璐�" : "閮ㄥ垎鍙戣揣";
+
+            if (row == null) {
+                ShippingInfo insert = new ShippingInfo();
+                insert.setSalesLedgerId(ledgerId);
+                insert.setSalesLedgerProductId(p.getId());
+                insert.setShippingNo(shippingBatchNo);
+                insert.setType("鎵爜鍑哄簱");
+                insert.setStatus(lineShipStatus);
+                insert.setShippingDate(now);
+                shippingInfoMapper.insert(insert);
+            } else {
+                if (!StringUtils.hasText(row.getType())) {
+                    row.setType("鎵爜鍑哄簱");
+                }
+                row.setStatus(lineShipStatus);
+                row.setShippingDate(now);
+                if (!StringUtils.hasText(row.getShippingNo())) {
+                    row.setShippingNo(shippingBatchNo);
+                }
+                shippingInfoMapper.updateById(row);
+            }
+        }
     }
 
     @Override
@@ -2354,6 +2478,7 @@
                         throw new ServiceException("瀵煎叆澶辫触,璁㈠崟缂栧彿[" + orderNo + "]瀛樺湪閲嶅鍙戣揣璁板綍,璇峰嬁閲嶅瀵煎叆");
                     }
                     shippingInfoMapper.insert(shippingInfo);
+                    createShippingQualityInspect(ledger, dbProduct, row, allocQty);
                 }
             }
 
@@ -2857,4 +2982,949 @@
         String subCategory = StringUtils.hasText(row.getProductSubCategory()) ? row.getProductSubCategory().trim() : "";
         return ledgerId + "|" + subCategory + "|" + shippingNo + "|" + dateStr + "|" + defaultDecimal(row.getQuantity());
     }
-}
+
+    private void createShippingQualityInspect(SalesLedger ledger, SalesLedgerProduct dbProduct, SalesShippingImportDto row, BigDecimal inspectQty) {
+        if (ledger == null || dbProduct == null || inspectQty == null || inspectQty.compareTo(BigDecimal.ZERO) <= 0) {
+            return;
+        }
+        Date checkDate = row.getReportDate() != null ? row.getReportDate() : new Date();
+        QualityInspect qualityInspect = new QualityInspect();
+        qualityInspect.setInspectType(2);
+        qualityInspect.setCheckTime(checkDate);
+        qualityInspect.setCustomer(StringUtils.hasText(ledger.getCustomerName()) ? ledger.getCustomerName() : row.getCustomerName());
+        qualityInspect.setCheckName(StringUtils.hasText(row.getCreator()) ? row.getCreator().trim() : null);
+        qualityInspect.setProductId(dbProduct.getProductId());
+        qualityInspect.setProductName(dbProduct.getProductCategory());
+        qualityInspect.setModel(dbProduct.getSpecificationModel());
+        qualityInspect.setUnit(resolveInspectUnit(dbProduct));
+        qualityInspect.setQuantity(inspectQty);
+        qualityInspect.setQualifiedQuantity(inspectQty);
+        qualityInspect.setUnqualifiedQuantity(BigDecimal.ZERO);
+        qualityInspect.setPassRate(BigDecimal.valueOf(100));
+        qualityInspect.setCheckResult("鍚堟牸");
+        qualityInspect.setInspectState(1);
+        qualityInspect.setApprovalStatus(1);
+        qualityInspect.setProductModelId(dbProduct.getProductModelId());
+
+        QualityTestStandard selectedStandard = null;
+        if (dbProduct.getProductId() != null) {
+            List<QualityTestStandard> standards = qualityTestStandardMapper.getQualityTestStandardByProductId(dbProduct.getProductId(), 2, null);
+            if (CollectionUtils.isNotEmpty(standards)) {
+                selectedStandard = standards.get(0);
+                qualityInspect.setTestStandardId(selectedStandard.getId());
+            }
+        }
+        qualityInspectMapper.insert(qualityInspect);
+
+        if (selectedStandard == null || selectedStandard.getId() == null) {
+            return;
+        }
+        List<QualityTestStandardParam> standardParams = qualityTestStandardParamMapper.selectList(Wrappers.<QualityTestStandardParam>lambdaQuery().eq(QualityTestStandardParam::getTestStandardId, selectedStandard.getId()));
+        if (CollectionUtils.isEmpty(standardParams)) {
+            return;
+        }
+        List<QualityInspectParam> inspectParams = standardParams.stream().map(item -> {
+            QualityInspectParam param = new QualityInspectParam();
+            param.setInspectId(qualityInspect.getId());
+            param.setParameterItem(item.getParameterItem());
+            param.setUnit(item.getUnit());
+            param.setStandardValue(item.getStandardValue());
+            param.setControlValue(item.getControlValue());
+            param.setTestValue("鏃犵憰鐤�");
+            return param;
+        }).collect(Collectors.toList());
+        inspectParams.forEach(qualityInspectParamMapper::insert);
+    }
+
+    private String resolveInspectUnit(SalesLedgerProduct dbProduct) {
+        if (dbProduct == null) {
+            return null;
+        }
+        if (StringUtils.hasText(dbProduct.getUnit())) {
+            return dbProduct.getUnit();
+        }
+        if (dbProduct.getProductModelId() == null) {
+            return null;
+        }
+        ProductModel productModel = productModelMapper.selectById(dbProduct.getProductModelId());
+        if (productModel == null || !StringUtils.hasText(productModel.getUnit())) {
+            return null;
+        }
+        return productModel.getUnit();
+    }
+
+    private static final String SCAN_SHIP_REMARK_PREFIX = "SCAN_SHIP_DELIVERY_JSON:";
+
+    private static final class ScanShipPayload {
+        private String shippingNo;
+        private Long ledgerId;
+        private String car;
+        private String express;
+        private String shipType;
+        private Map<Long, BigDecimal> linesQty = new LinkedHashMap<>();
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void scanShipApply(SalesScanShipDto dto) {
+        if (dto == null || dto.getSalesLedgerId() == null) {
+            throw new ServiceException("鎵爜鍙戣揣澶辫触锛岃鍗曚笉鑳戒负绌�");
+        }
+        if (StringUtils.isEmpty(dto.getApproveUserIds())) {
+            throw new ServiceException("璇烽�夋嫨瀹℃壒浜�");
+        }
+        if (CollectionUtils.isEmpty(dto.getSalesLedgerProductList())) {
+            throw new ServiceException("璇峰~鍐欏彂璐т骇鍝佽");
+        }
+        String shipType = StringUtils.hasText(dto.getShipType()) ? dto.getShipType().trim() : "璐ц溅";
+        if ("璐ц溅".equals(shipType)) {
+            if (!StringUtils.hasText(dto.getShippingCarNumber())) {
+                throw new ServiceException("璇峰~鍐欒溅鐗屽彿");
+            }
+        } else if ("蹇��".equals(shipType)) {
+            if (!StringUtils.hasText(dto.getExpressNumber())) {
+                throw new ServiceException("璇峰~鍐欏揩閫掑崟鍙�");
+            }
+        }
+        SalesLedger salesLedger = baseMapper.selectById(dto.getSalesLedgerId());
+        if (salesLedger == null) {
+            throw new ServiceException("閿�鍞鍗曚笉瀛樺湪");
+        }
+        if (salesLedger.getDeliveryStatus() != null && salesLedger.getDeliveryStatus() == 5) {
+            throw new ServiceException("璇ラ攢鍞鍗曞凡鍙戣揣");
+        }
+        if (salesLedger.getDeliveryStatus() != null && salesLedger.getDeliveryStatus() == 2) {
+            throw new ServiceException("璇ラ攢鍞鍗曞凡鍙戣捣鍙戣揣瀹℃壒锛岃鍏堝畬鎴愬鎵�");
+        }
+        List<SalesLedgerProduct> notStocked = salesLedgerProductMapper.selectList(new LambdaQueryWrapper<SalesLedgerProduct>()
+                .eq(SalesLedgerProduct::getSalesLedgerId, salesLedger.getId())
+                .eq(SalesLedgerProduct::getType, 1)
+                .ne(SalesLedgerProduct::getProductStockStatus, 2));
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(notStocked)) {
+            throw new ServiceException("鍙戣揣澶辫触,璇ラ攢鍞鍗曞瓨鍦ㄦ湭鍏ュ簱浜у搧,璇峰厛瀹屾垚鍏ㄩ儴鍏ュ簱鍚庡啀鍙戣揣");
+        }
+        int saleType = SaleEnum.SALE.getCode();
+        Map<Long, BigDecimal> shipQtyByLineId = new LinkedHashMap<>();
+        for (SalesLedgerProduct line : dto.getSalesLedgerProductList()) {
+            if (line == null || line.getId() == null) {
+                throw new ServiceException("浜у搧淇℃伅涓嶅畬鏁�");
+            }
+            BigDecimal q = line.getStockedQuantity();
+            if (q == null) {
+                throw new ServiceException("鍙戣揣鏁伴噺涓嶈兘涓虹┖");
+            }
+            if (q.compareTo(BigDecimal.ZERO) < 0) {
+                throw new ServiceException("鍙戣揣鏁伴噺涓嶈兘涓鸿礋鏁�");
+            }
+            shipQtyByLineId.merge(line.getId(), q, BigDecimal::add);
+        }
+        boolean anyPositive = shipQtyByLineId.values().stream().anyMatch(v -> v.compareTo(BigDecimal.ZERO) > 0);
+        if (!anyPositive) {
+            throw new ServiceException("璇疯嚦灏戝~鍐欎竴琛屽ぇ浜� 0 鐨勫彂璐ф暟閲�");
+        }
+        Long ledgerId = salesLedger.getId();
+        for (Map.Entry<Long, BigDecimal> entry : shipQtyByLineId.entrySet()) {
+            if (entry.getValue().compareTo(BigDecimal.ZERO) == 0) {
+                continue;
+            }
+            SalesLedgerProduct dbProduct = salesLedgerProductMapper.selectById(entry.getKey());
+            if (dbProduct == null) {
+                throw new ServiceException("閿�鍞骇鍝佷笉瀛樺湪");
+            }
+            if (!Objects.equals(dbProduct.getSalesLedgerId(), ledgerId) || !Objects.equals(dbProduct.getType(), saleType)) {
+                throw new ServiceException("閿�鍞骇鍝佷笌璁㈠崟涓嶅尮閰�");
+            }
+            if (dbProduct.getProductModelId() == null) {
+                throw new ServiceException("浜у搧瑙勬牸鏈淮鎶わ紝鏃犳硶鍙戣揣");
+            }
+            BigDecimal orderQty = defaultDecimal(dbProduct.getQuantity());
+            BigDecimal prevShipped = defaultDecimal(dbProduct.getShippedQuantity());
+            if (prevShipped.add(entry.getValue()).compareTo(orderQty) > 0) {
+                throw new ServiceException("绱鍙戣揣鏁伴噺涓嶈兘澶т簬璇ヤ骇鍝佽鍗曟暟閲�");
+            }
+            stockUtils.assertQualifiedAvailable(dbProduct.getProductModelId(), entry.getValue());
+        }
+        String shNo = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SH");
+        Map<Long, BigDecimal> positiveLines = new LinkedHashMap<>();
+        for (Map.Entry<Long, BigDecimal> e : shipQtyByLineId.entrySet()) {
+            if (e.getValue().compareTo(BigDecimal.ZERO) > 0) {
+                positiveLines.put(e.getKey(), e.getValue());
+            }
+        }
+        for (Map.Entry<Long, BigDecimal> e : positiveLines.entrySet()) {
+            ShippingInfo si = new ShippingInfo();
+            si.setSalesLedgerId(ledgerId);
+            si.setSalesLedgerProductId(e.getKey());
+            si.setShippingNo(shNo);
+            si.setStatus("寰呭鏍�");
+            si.setType(shipType);
+            if ("璐ц溅".equals(shipType)) {
+                si.setShippingCarNumber(dto.getShippingCarNumber().trim());
+            }
+            if ("蹇��".equals(shipType)) {
+                si.setExpressNumber(dto.getExpressNumber().trim());
+            }
+            shippingInfoMapper.insert(si);
+        }
+        String remarkJson = buildScanShipRemarkJson(shNo, ledgerId, dto, positiveLines);
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        ApproveProcessVO approveProcessVO = new ApproveProcessVO();
+        approveProcessVO.setApproveType(7);
+        approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
+        approveProcessVO.setApproveReason("鍙戣揣瀹℃壒:" + salesLedger.getSalesContractNo());
+        approveProcessVO.setApproveRemark(remarkJson);
+        approveProcessVO.setApproveUserIds(dto.getApproveUserIds().trim());
+        approveProcessVO.setApproveUser(loginUser.getUserId());
+        approveProcessVO.setApproveTime(LocalDate.now().toString());
+        approveProcessVO.setTempFileIds(dto.getTempFileIds());
+        try {
+            approveProcessService.addApprove(approveProcessVO);
+        } catch (Exception e) {
+            throw new ServiceException("鍙戣捣鍙戣揣瀹℃壒澶辫触: " + e.getMessage());
+        }
+        salesLedger.setDeliveryStatus(2);
+        baseMapper.updateById(salesLedger);
+    }
+
+    private String buildScanShipRemarkJson(String shippingNo, Long ledgerId, SalesScanShipDto dto, Map<Long, BigDecimal> lines) {
+        try {
+            ObjectMapper om = new ObjectMapper();
+            ObjectNode root = om.createObjectNode();
+            root.put("shippingNo", shippingNo);
+            root.put("ledgerId", ledgerId);
+            root.put("car", dto.getShippingCarNumber() == null ? "" : dto.getShippingCarNumber().trim());
+            root.put("express", dto.getExpressNumber() == null ? "" : dto.getExpressNumber().trim());
+            root.put("shipType", dto.getShipType() == null ? "璐ц溅" : dto.getShipType().trim());
+            ObjectNode linesNode = om.createObjectNode();
+            for (Map.Entry<Long, BigDecimal> e : lines.entrySet()) {
+                linesNode.put(String.valueOf(e.getKey()), e.getValue().stripTrailingZeros().toPlainString());
+            }
+            root.set("lines", linesNode);
+            return SCAN_SHIP_REMARK_PREFIX + om.writeValueAsString(root);
+        } catch (Exception e) {
+            throw new ServiceException("鏋勫缓鍙戣揣瀹℃壒鍙傛暟澶辫触");
+        }
+    }
+
+    private ScanShipPayload parseScanShipPayload(String remark) {
+        if (!StringUtils.hasText(remark) || !remark.startsWith(SCAN_SHIP_REMARK_PREFIX)) {
+            return null;
+        }
+        try {
+            String json = remark.substring(SCAN_SHIP_REMARK_PREFIX.length());
+            ObjectMapper om = new ObjectMapper();
+            JsonNode n = om.readTree(json);
+            ScanShipPayload p = new ScanShipPayload();
+            p.shippingNo = n.path("shippingNo").asText(null);
+            p.ledgerId = n.path("ledgerId").asLong(0L);
+            p.car = n.path("car").asText("");
+            p.express = n.path("express").asText("");
+            p.shipType = n.path("shipType").asText("璐ц溅");
+            JsonNode lines = n.path("lines");
+            p.linesQty = new LinkedHashMap<>();
+            if (lines.isObject()) {
+                Iterator<String> it = lines.fieldNames();
+                while (it.hasNext()) {
+                    String k = it.next();
+                    p.linesQty.put(Long.valueOf(k), new BigDecimal(lines.get(k).asText()));
+                }
+            }
+            return p;
+        } catch (Exception e) {
+            log.warn("瑙f瀽鎵爜鍙戣揣瀹℃壒澶囨敞澶辫触: {}", e.getMessage());
+            return null;
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void onScanShipDeliveryApproveOutcome(ApproveProcess approveProcess, Integer outcomeStatus) {
+        if (approveProcess == null) {
+            return;
+        }
+        ScanShipPayload ctx = parseScanShipPayload(approveProcess.getApproveRemark());
+        if (ctx == null || ctx.ledgerId == null || ctx.ledgerId <= 0 || !StringUtils.hasText(ctx.shippingNo)) {
+            return;
+        }
+        if (outcomeStatus != null && outcomeStatus == 2) {
+            executeScanShipDeliveryApproved(approveProcess, ctx);
+        } else if (outcomeStatus != null && outcomeStatus == 3) {
+            updateScanShipBatchShippingStatus(ctx.ledgerId, ctx.shippingNo, "瀹℃牳鎷掔粷");
+            SalesLedger sl = baseMapper.selectById(ctx.ledgerId);
+            if (sl != null) {
+                sl.setDeliveryStatus(3);
+                baseMapper.updateById(sl);
+            }
+        } else if (outcomeStatus != null && outcomeStatus == 1) {
+            updateScanShipBatchShippingStatus(ctx.ledgerId, ctx.shippingNo, "瀹℃牳涓�");
+        }
+    }
+
+    private void updateScanShipBatchShippingStatus(Long ledgerId, String shippingNo, String statusText) {
+        if (ledgerId == null || !StringUtils.hasText(shippingNo)) {
+            return;
+        }
+        shippingInfoMapper.update(null, new UpdateWrapper<ShippingInfo>().lambda()
+                .set(ShippingInfo::getStatus, statusText)
+                .eq(ShippingInfo::getSalesLedgerId, ledgerId)
+                .eq(ShippingInfo::getShippingNo, shippingNo));
+    }
+
+    private void executeScanShipDeliveryApproved(ApproveProcess approveProcess, ScanShipPayload ctx) {
+        int saleType = SaleEnum.SALE.getCode();
+        Date now = new Date();
+        List<ShippingInfo> batch = shippingInfoMapper.selectList(Wrappers.<ShippingInfo>lambdaQuery()
+                .eq(ShippingInfo::getSalesLedgerId, ctx.ledgerId)
+                .eq(ShippingInfo::getShippingNo, ctx.shippingNo));
+        if (CollectionUtils.isEmpty(batch)) {
+            log.warn("鎵爜鍙戣揣瀹℃壒閫氳繃浣嗘湭鎵惧埌鍙戣揣鍙拌处 batch ledgerId={} shippingNo={}", ctx.ledgerId, ctx.shippingNo);
+            return;
+        }
+        for (Map.Entry<Long, BigDecimal> entry : ctx.linesQty.entrySet()) {
+            Long productLineId = entry.getKey();
+            BigDecimal shipQty = entry.getValue();
+            if (shipQty == null || shipQty.compareTo(BigDecimal.ZERO) <= 0) {
+                continue;
+            }
+            SalesLedgerProduct dbProduct = salesLedgerProductMapper.selectById(productLineId);
+            if (dbProduct == null) {
+                throw new ServiceException("閿�鍞骇鍝佷笉瀛樺湪");
+            }
+            ShippingInfo row = batch.stream()
+                    .filter(si -> Objects.equals(si.getSalesLedgerProductId(), productLineId))
+                    .findFirst()
+                    .orElse(null);
+            if (row == null) {
+                throw new ServiceException("鏈壘鍒板搴斿彂璐у彴璐﹁");
+            }
+            if (!"宸插彂璐�".equals(row.getStatus())) {
+                stockUtils.substractStock(ctx.ledgerId, productLineId, dbProduct.getProductModelId(), shipQty,
+                        StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), row.getId());
+                BigDecimal oldShipped = defaultDecimal(dbProduct.getShippedQuantity());
+                dbProduct.setShippedQuantity(oldShipped.add(shipQty));
+                dbProduct.fillRemainingQuantity();
+                salesLedgerProductMapper.updateById(dbProduct);
+            }
+            row.setStatus("宸插彂璐�");
+            row.setShippingDate(now);
+            if (StringUtils.hasText(ctx.car)) {
+                row.setShippingCarNumber(ctx.car.trim());
+            }
+            if (StringUtils.hasText(ctx.express)) {
+                row.setExpressNumber(ctx.express.trim());
+            }
+            if (StringUtils.hasText(ctx.shipType)) {
+                row.setType(ctx.shipType.trim());
+            }
+            shippingInfoMapper.updateById(row);
+        }
+        List<Long> shippingIds = batch.stream().map(ShippingInfo::getId).filter(Objects::nonNull).collect(Collectors.toList());
+        commonFileService.copyApproveProcessShipAttachmentsToShippingInfos(approveProcess.getId(), shippingIds);
+        List<SalesLedgerProduct> ledgerAllProducts = salesLedgerProductMapper.selectList(
+                Wrappers.<SalesLedgerProduct>lambdaQuery().eq(SalesLedgerProduct::getSalesLedgerId, ctx.ledgerId));
+        SalesLedger salesLedger = baseMapper.selectById(ctx.ledgerId);
+        if (salesLedger == null) {
+            return;
+        }
+        boolean anyInbound = ledgerAllProducts.stream().anyMatch(p -> {
+            BigDecimal sq = p.getStockedQuantity();
+            return sq != null && sq.compareTo(BigDecimal.ZERO) > 0;
+        });
+        boolean allLinesFull = ledgerAllProducts.stream().allMatch(p -> Objects.equals(p.getProductStockStatus(), 2));
+        salesLedger.setStockStatus(allLinesFull ? 2 : (anyInbound ? 1 : 0));
+        List<SalesLedgerProduct> saleLines = ledgerAllProducts.stream()
+                .filter(p -> Objects.equals(p.getType(), saleType))
+                .collect(Collectors.toList());
+        boolean allDelivered = !saleLines.isEmpty() && saleLines.stream().allMatch(p -> {
+            BigDecimal q = defaultDecimal(p.getQuantity());
+            BigDecimal s = defaultDecimal(p.getShippedQuantity());
+            return q.compareTo(BigDecimal.ZERO) <= 0 || s.compareTo(q) >= 0;
+        });
+        if (allDelivered) {
+            salesLedger.setDeliveryStatus(5);
+        } else {
+            boolean anyLineShipped = saleLines.stream()
+                    .anyMatch(p -> defaultDecimal(p.getShippedQuantity()).compareTo(BigDecimal.ZERO) > 0);
+            if (anyLineShipped) {
+                salesLedger.setDeliveryStatus(6);
+            }
+        }
+        baseMapper.updateById(salesLedger);
+    }
+
+    
+    /**
+     * 澶勭悊閿�鍞彴璐﹀弽瀹¢�昏緫
+     * 1. 璁剧疆鍙嶅鐩稿叧淇℃伅锛堟椂闂淬�佷汉鍛橈級
+     * 2. 澶嶅埗鍘熼攢鍞彴璐﹀強浜у搧鏁版嵁锛岀敓鎴愭柊鐨勫彴璐�
+     * 3. 瀵瑰師鍙拌处鐨勫簱瀛樻暟鎹繘琛屽弽鍚戞搷浣�
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public List<Long> counterReview(CounterReviewDto dto) {
+        if (dto == null || CollectionUtils.isEmpty(dto.getIds())) {
+            throw new ServiceException("璇烽�夋嫨瑕佸弽瀹℃牳鐨勮鍗�");
+        }
+        if (dto.getCounterReviewType() == null || (dto.getCounterReviewType() != 1 && dto.getCounterReviewType() != 2)) {
+            throw new ServiceException("璇烽�夋嫨鍙嶅鏍哥被鍨嬶細浣滃簾鎴栭噸鏂扮敓鎴�");
+        }
+        if (dto.getCounterReviewDesc() == null || dto.getCounterReviewDesc().trim().isEmpty()) {
+            throw new ServiceException("璇疯緭鍏ュ弽瀹℃牳鎻忚堪");
+        }
+
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        List<Long> newLedgerIds = new ArrayList<>();
+
+        for (Long id : dto.getIds()) {
+            SalesLedger originalLedger = salesLedgerMapper.selectById(id);
+            if (originalLedger == null) {
+                throw new ServiceException("璁㈠崟涓嶅瓨鍦紝鏃犳硶鍙嶅鏍�");
+            }
+            if (originalLedger.getReviewStatus() == null || originalLedger.getReviewStatus() != 1) {
+                throw new ServiceException("璁㈠崟" + originalLedger.getSalesContractNo() + "涓嶆槸宸插鏍哥姸鎬侊紝鏃犳硶鍙嶅鏍�");
+            }
+
+            // 1. 鏍囪鍘熻鍗曚负宸插弽瀹�
+            originalLedger.setReviewStatus(2);
+            originalLedger.setCounterReviewTime(LocalDateTime.now());
+            originalLedger.setCounterReviewPerson(loginUser.getUser().getNickName());
+            originalLedger.setCounterReviewPersonId(loginUser.getUserId());
+            originalLedger.setCounterReviewType(dto.getCounterReviewType());
+            originalLedger.setCounterReviewDesc(dto.getCounterReviewDesc());
+            salesLedgerMapper.updateById(originalLedger);
+
+            // 2. 浣滃簾搴撳瓨锛氬叆搴撴墸鍑忋�佸嚭搴撳鍔犮�佸垹闄よ褰�
+            processOriginalOrderStock(id);
+
+            // 3. 娓呴櫎璐ㄦ璁板綍
+            clearQualityInspectRecords(id);
+
+            // 4. 娓呴櫎鍙戣揣淇℃伅鍜屽彂璐у鎵硅褰�
+            clearShippingAndApprovalRecords(id);
+
+            // 5. 鍙栨秷瀹℃壒娴佺▼
+            cancelApproveProcesses(id, originalLedger.getSalesContractNo());
+
+            // 6. 閲嶆柊鐢熸垚锛氬垱寤烘柊鍙拌处鍓湰
+            if (dto.getCounterReviewType() == 2) {
+                SalesLedger newLedger = new SalesLedger();
+                BeanUtils.copyProperties(originalLedger, newLedger);
+                newLedger.setId(null);
+                newLedger.setSalesContractNo(generateSalesContractNo());
+                newLedger.setDeliveryStatus(1);
+                newLedger.setStockStatus(0);
+                newLedger.setReviewStatus(0);
+                newLedger.setCounterReviewTime(null);
+                newLedger.setCounterReviewPerson(null);
+                newLedger.setCounterReviewPersonId(null);
+                newLedger.setCounterReviewType(null);
+                newLedger.setCounterReviewDesc(null);
+                salesLedgerMapper.insert(newLedger);
+
+                // 澶嶅埗浜у搧鍒版柊鍙拌处
+                List<SalesLedgerProduct> originalProducts = salesLedgerProductMapper.selectList(
+                    Wrappers.<SalesLedgerProduct>lambdaQuery()
+                        .eq(SalesLedgerProduct::getSalesLedgerId, id)
+                );
+                for (SalesLedgerProduct originalProduct : originalProducts) {
+                    SalesLedgerProduct newProduct = new SalesLedgerProduct();
+                    BeanUtils.copyProperties(originalProduct, newProduct);
+                    newProduct.setId(null);
+                    newProduct.setSalesLedgerId(newLedger.getId());
+                    newProduct.setStockedQuantity(BigDecimal.ZERO);
+                    newProduct.setShippedQuantity(BigDecimal.ZERO);
+                    newProduct.setUnqualifiedStockedQuantity(BigDecimal.ZERO);
+                    newProduct.setUnqualifiedShippedQuantity(BigDecimal.ZERO);
+                    newProduct.setReturnQuality(BigDecimal.ZERO);
+                    newProduct.setAvailableQuality(newProduct.getQuantity().subtract(newProduct.getReturnQuality()));
+                    newProduct.setProductStockStatus(0);
+                    newProduct.fillRemainingQuantity();
+                    salesLedgerProductMapper.insert(newProduct);
+                }
+                newLedgerIds.add(newLedger.getId());
+            }
+        }
+        return newLedgerIds;
+    }
+
+    /**
+     * 鏃х増鍙嶅澶勭悊锛堝吋瀹� addOrUpdateSalesLedger 涓� reviewStatus=2 鐨勮皟鐢級
+     */
+    private void handleCounterReview(SalesLedger salesLedger) {
+        // 1. 璁剧疆鍙嶅鐩稿叧淇℃伅
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        salesLedger.setCounterReviewTime(LocalDateTime.now());
+        salesLedger.setCounterReviewPerson(loginUser.getUser().getNickName());
+        salesLedger.setCounterReviewPersonId(loginUser.getUserId());
+        salesLedger.setReviewStatus(2);
+        
+        Long originalSalesLedgerId = salesLedger.getId();
+        
+        // 2. 鏌ヨ鍘熼攢鍞彴璐︽暟鎹�
+        SalesLedger originalLedger = salesLedgerMapper.selectById(originalSalesLedgerId);
+        if (originalLedger == null) {
+            throw new ServiceException("鍘熻鍗曚笉瀛樺湪锛屾棤娉曞弽瀹�");
+        }
+        
+        // 3. 鍒涘缓鏂扮殑閿�鍞彴璐︼紝澶嶅埗鍘熷彴璐︽暟鎹�
+        SalesLedger newLedger = new SalesLedger();
+        BeanUtils.copyProperties(originalLedger, newLedger);
+        newLedger.setId(null); // 娓呯┖ID锛屽噯澶囨彃鍏ユ柊璁板綍
+        newLedger.setSalesContractNo(generateSalesContractNo()); // 鐢熸垚鏂板悎鍚屽彿
+        newLedger.setDeliveryStatus(1); // 璁剧疆涓烘湭鍙戣揣鐘舵��
+        newLedger.setStockStatus(0); // 璁剧疆涓烘湭鍏ュ簱鐘舵��
+        newLedger.setReviewStatus(0); // 璁剧疆涓烘湭瀹℃牳鐘舵��
+        newLedger.setCounterReviewTime(null); // 娓呯┖鍙嶅鏃堕棿
+        newLedger.setCounterReviewPerson(null); // 娓呯┖鍙嶅浜�
+        newLedger.setCounterReviewPersonId(null); // 娓呯┖鍙嶅浜篒D
+        
+        // 4. 鎻掑叆鏂扮殑閿�鍞彴璐�
+        salesLedgerMapper.insert(newLedger);
+        
+        // 5. 鏌ヨ骞跺鍒跺師鍙拌处鐨勬墍鏈変骇鍝佹暟鎹�
+        List<SalesLedgerProduct> originalProducts = salesLedgerProductMapper.selectList(
+            Wrappers.<SalesLedgerProduct>lambdaQuery()
+                .eq(SalesLedgerProduct::getSalesLedgerId, originalSalesLedgerId)
+        );
+        
+        for (SalesLedgerProduct originalProduct : originalProducts) {
+            // 5.1 鍒涘缓鏂颁骇鍝佽褰曪紝澶嶅埗鍘熶骇鍝佹暟鎹�
+            SalesLedgerProduct newProduct = new SalesLedgerProduct();
+            BeanUtils.copyProperties(originalProduct, newProduct);
+            newProduct.setId(null); // 娓呯┖ID锛屽噯澶囨彃鍏ユ柊璁板綍
+            newProduct.setSalesLedgerId(newLedger.getId()); // 鍏宠仈鍒版柊鐨勫彴璐D
+            newProduct.setStockedQuantity(BigDecimal.ZERO); // 宸插叆搴撴暟閲忛噸缃负0
+            newProduct.setShippedQuantity(BigDecimal.ZERO); // 宸插嚭搴撴暟閲忛噸缃负0
+            newProduct.setUnqualifiedStockedQuantity(BigDecimal.ZERO); // 涓嶅悎鏍煎叆搴撴暟閲忛噸缃负0
+            newProduct.setUnqualifiedShippedQuantity(BigDecimal.ZERO); // 涓嶅悎鏍煎嚭搴撴暟閲忛噸缃负0
+            newProduct.setReturnQuality(BigDecimal.ZERO); // 閫�璐ф暟閲忛噸缃负0
+            newProduct.setAvailableQuality(newProduct.getQuantity().subtract(newProduct.getReturnQuality())); // 閲嶆柊璁$畻鍙敤鏁伴噺
+            newProduct.setProductStockStatus(0); // 浜у搧搴撳瓨鐘舵�侀噸缃负0
+            newProduct.fillRemainingQuantity(); // 閲嶆柊璁$畻鍓╀綑鏁伴噺
+            
+            // 5.2 鎻掑叆鏂颁骇鍝佽褰�
+            salesLedgerProductMapper.insert(newProduct);
+        }
+        
+        // 6. 澶勭悊鍘熻鍗曠殑搴撳瓨鏁版嵁锛堢敓鎴愬弽瀹″嚭鍏ュ簱璁板綍锛�
+        processOriginalOrderStock(originalSalesLedgerId);
+        
+        // 7. 娓呴櫎鍘熻鍗曠殑璐ㄦ璁板綍
+        clearQualityInspectRecords(originalSalesLedgerId);
+        
+        // 8. 娓呴櫎鍘熻鍗曠殑鍙戣揣淇℃伅鍜屽彂璐у鎵硅褰�
+        clearShippingAndApprovalRecords(originalSalesLedgerId);
+        
+        // 9. 鍙栨秷鍘熻鍗曠浉鍏崇殑瀹℃壒娴佺▼
+        cancelApproveProcesses(originalSalesLedgerId, originalLedger.getSalesContractNo());
+    }
+
+    /**
+     * 娓呴櫎鍘熻鍗曠殑璐ㄦ璁板綍
+     */
+    private void clearQualityInspectRecords(Long originalSalesLedgerId) {
+        // 鍒犻櫎涓庡師璁㈠崟鍏宠仈鐨勮川妫�璁板綍
+        qualityInspectMapper.delete(
+            Wrappers.<QualityInspect>lambdaQuery()
+                .eq(QualityInspect::getPurchaseLedgerId, originalSalesLedgerId)
+        );
+    }
+
+    /**
+     * 娓呴櫎鍘熻鍗曠殑鍙戣揣淇℃伅鍜屽彂璐у鎵硅褰�
+     */
+    private void clearShippingAndApprovalRecords(Long originalSalesLedgerId) {
+        // 1. 鏌ヨ鍘熻鍗曠殑鎵�鏈夊彂璐т俊鎭�
+        List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(
+            Wrappers.<ShippingInfo>lambdaQuery()
+                .eq(ShippingInfo::getSalesLedgerId, originalSalesLedgerId)
+        );
+        
+        // 2. 鍒犻櫎鍙戣揣瀹℃壒璁板綍
+        if (!CollectionUtils.isEmpty(shippingInfos)) {
+            List<Long> shippingInfoIds = shippingInfos.stream()
+                .map(ShippingInfo::getId)
+                .collect(Collectors.toList());
+            
+            shipmentApprovalMapper.delete(
+                Wrappers.<ShipmentApproval>lambdaQuery()
+                    .eq(ShipmentApproval::getSalesLedgerId, originalSalesLedgerId)
+                    .or()
+                    .in(ShipmentApproval::getShippingInfoId, shippingInfoIds)
+            );
+            
+            // 3. 鍒犻櫎鍙戣揣淇℃伅璁板綍
+            shippingInfoMapper.delete(
+                Wrappers.<ShippingInfo>lambdaQuery()
+                    .eq(ShippingInfo::getSalesLedgerId, originalSalesLedgerId)
+            );
+        }
+    }
+
+    /**
+     * 鍙栨秷鍘熻鍗曠浉鍏崇殑瀹℃壒娴佺▼
+     */
+    private void cancelApproveProcesses(Long originalSalesLedgerId, String originalSalesContractNo) {
+        // 鍙栨秷鍏ュ簱瀹℃壒娴佺▼
+        List<ApproveProcess> stockInApproveProcesses = approveProcessService.list(
+            new LambdaQueryWrapper<ApproveProcess>()
+                .eq(ApproveProcess::getApproveType, ApproveTypeEnum.STOCK_IN.getCode())
+                .like(ApproveProcess::getApproveRemark, "salesStock:" + originalSalesLedgerId + ":")
+                .eq(ApproveProcess::getApproveDelete, 0)
+        );
+        
+        for (ApproveProcess process : stockInApproveProcesses) {
+            process.setApproveStatus(3); // 璁剧疆涓哄鎵瑰け璐ョ姸鎬�
+            process.setApproveDelete(1); // 鏍囪涓哄凡鍒犻櫎
+            approveProcessService.updateById(process);
+        }
+        
+        // 鍙栨秷鍙戣揣瀹℃壒娴佺▼
+        List<ApproveProcess> deliveryApproveProcesses = approveProcessService.list(
+            new LambdaQueryWrapper<ApproveProcess>()
+                .eq(ApproveProcess::getApproveType, 7) // 鍙戣揣瀹℃壒绫诲瀷
+                .like(ApproveProcess::getApproveReason, "鍙戣揣瀹℃壒:" + originalSalesContractNo)
+                .eq(ApproveProcess::getApproveDelete, 0)
+        );
+        
+        for (ApproveProcess process : deliveryApproveProcesses) {
+            process.setApproveStatus(3); // 璁剧疆涓哄鎵瑰け璐ョ姸鎬�
+            process.setApproveDelete(1); // 鏍囪涓哄凡鍒犻櫎
+            approveProcessService.updateById(process);
+        }
+    }
+
+    /**
+     * 澶勭悊鍘熻鍗曠殑搴撳瓨鏁版嵁
+     * 1. 鍒犻櫎鍘熻鍗曠殑鎵�鏈夊叆搴撹褰曪紝骞舵墸鍑忓簱瀛�
+     * 2. 鍒犻櫎鍘熻鍗曠殑鎵�鏈夊嚭搴撹褰曪紝骞跺鍔犲簱瀛�
+     */
+    private void processOriginalOrderStock(Long originalSalesLedgerId) {
+        // 1. 鏌ヨ鍘熻鍗曠殑鎵�鏈夊叆搴撹褰�
+        List<StockInRecord> stockInRecords = stockInRecordMapper.selectList(
+            Wrappers.<StockInRecord>lambdaQuery()
+                .eq(StockInRecord::getSalesLedgerId, originalSalesLedgerId)
+        );
+        
+        // 2. 鍒犻櫎鍏ュ簱璁板綍骞舵墸鍑忓簱瀛�
+        for (StockInRecord stockInRecord : stockInRecords) {
+            // 浠庡簱瀛樿〃涓墸鍑忕浉搴旀暟閲�
+            StockInventoryDto stockInventoryDto = new StockInventoryDto();
+            stockInventoryDto.setProductModelId(stockInRecord.getProductModelId());
+            stockInventoryDto.setQualitity(stockInRecord.getStockInNum());
+            stockInventoryMapper.updateSubtractStockInventory(stockInventoryDto);
+        }
+        
+        // 3. 鍒犻櫎鎵�鏈夊叆搴撹褰�
+        stockInRecordMapper.delete(
+            Wrappers.<StockInRecord>lambdaQuery()
+                .eq(StockInRecord::getSalesLedgerId, originalSalesLedgerId)
+        );
+        
+        // 4. 鏌ヨ鍘熻鍗曠殑鎵�鏈夊嚭搴撹褰�
+        List<StockOutRecord> stockOutRecords = stockOutRecordMapper.selectList(
+            Wrappers.<StockOutRecord>lambdaQuery()
+                .eq(StockOutRecord::getSalesLedgerId, originalSalesLedgerId)
+        );
+        
+        // 5. 鍒犻櫎鍑哄簱璁板綍骞跺鍔犲簱瀛�
+        for (StockOutRecord stockOutRecord : stockOutRecords) {
+            // 鍚戝簱瀛樿〃涓鍔犵浉搴旀暟閲�
+            StockInventoryDto stockInventoryDto = new StockInventoryDto();
+            stockInventoryDto.setProductModelId(stockOutRecord.getProductModelId());
+            stockInventoryDto.setQualitity(stockOutRecord.getStockOutNum());
+            stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
+        }
+        
+        // 6. 鍒犻櫎鎵�鏈夊嚭搴撹褰�
+        stockOutRecordMapper.delete(
+            Wrappers.<StockOutRecord>lambdaQuery()
+                .eq(StockOutRecord::getSalesLedgerId, originalSalesLedgerId)
+        );
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void markOrderCompleted(List<Long> ids) {
+        if (CollectionUtils.isEmpty(ids)) {
+            throw new ServiceException("璇烽�夋嫨瑕佹爣璁板畬鎴愮殑璁㈠崟");
+        }
+        for (Long id : ids) {
+            SalesLedger ledger = salesLedgerMapper.selectById(id);
+            if (ledger == null) {
+                throw new ServiceException("璁㈠崟涓嶅瓨鍦紝鏃犳硶鏍囪瀹屾垚");
+            }
+            if (ledger.getReviewStatus() == null || ledger.getReviewStatus() != 1) {
+                throw new ServiceException("璁㈠崟" + ledger.getSalesContractNo() + "涓嶆槸宸插鏍哥姸鎬侊紝鏃犳硶鏍囪瀹屾垚");
+            }
+            if (ledger.getOrderStatus() != null && ledger.getOrderStatus() == 1) {
+                throw new ServiceException("璁㈠崟" + ledger.getSalesContractNo() + "宸插畬鎴愶紝鏃犻渶閲嶅鏍囪");
+            }
+        }
+        salesLedgerMapper.update(null,
+            Wrappers.<SalesLedger>lambdaUpdate()
+                .in(SalesLedger::getId, ids)
+                .set(SalesLedger::getOrderStatus, 1)
+        );
+    }
+
+    @Override
+    public void incrementPrintCount(Long id, String printType) {
+        if (id == null) {
+            throw new ServiceException("閿�鍞彴璐D涓嶈兘涓虹┖");
+        }
+        if (printType == null || (!"label".equals(printType) && !"document".equals(printType))) {
+            throw new ServiceException("鎵撳嵃绫诲瀷蹇呴』涓� label 鎴� document");
+        }
+        SalesLedger ledger = salesLedgerMapper.selectById(id);
+        if (ledger == null) {
+            throw new ServiceException("閿�鍞彴璐︿笉瀛樺湪");
+        }
+        if ("label".equals(printType)) {
+            int currentCount = ledger.getLabelPrintCount() == null ? 0 : ledger.getLabelPrintCount();
+            salesLedgerMapper.update(null,
+                Wrappers.<SalesLedger>lambdaUpdate()
+                    .eq(SalesLedger::getId, id)
+                    .set(SalesLedger::getLabelPrintCount, currentCount + 1)
+            );
+        } else {
+            int currentCount = ledger.getDocumentPrintCount() == null ? 0 : ledger.getDocumentPrintCount();
+            salesLedgerMapper.update(null,
+                Wrappers.<SalesLedger>lambdaUpdate()
+                    .eq(SalesLedger::getId, id)
+                    .set(SalesLedger::getDocumentPrintCount, currentCount + 1)
+            );
+        }
+    }
+
+    @Override
+    public void exportWithProducts(HttpServletResponse response, SalesLedgerDto salesLedgerDto) {
+        try {
+            // 1. 鏌ヨ閿�鍞彴璐﹀垪琛紙瀵煎嚭浣跨敤鍗囧簭鎺掑簭锛�
+            Page<SalesLedger> page = new Page<>(-1, -1);
+            // 浣跨敤 Wrappers 鏋勫缓鍗囧簭鏌ヨ
+            LambdaQueryWrapper<SalesLedger> queryWrapper = Wrappers.<SalesLedger>lambdaQuery()
+                .orderByAsc(SalesLedger::getEntryDate)
+                .orderByAsc(SalesLedger::getId);
+
+            // 娣诲姞鏌ヨ鏉′欢
+            if (salesLedgerDto.getCustomerName() != null && !salesLedgerDto.getCustomerName().isEmpty()) {
+                queryWrapper.like(SalesLedger::getCustomerName, salesLedgerDto.getCustomerName());
+            }
+            if (salesLedgerDto.getSalesContractNo() != null && !salesLedgerDto.getSalesContractNo().isEmpty()) {
+                queryWrapper.like(SalesLedger::getSalesContractNo, salesLedgerDto.getSalesContractNo());
+            }
+            if (salesLedgerDto.getProjectName() != null && !salesLedgerDto.getProjectName().isEmpty()) {
+                queryWrapper.like(SalesLedger::getProjectName, salesLedgerDto.getProjectName());
+            }
+            if (salesLedgerDto.getEntryDateStart() != null && !salesLedgerDto.getEntryDateStart().isEmpty()) {
+                queryWrapper.ge(SalesLedger::getEntryDate, salesLedgerDto.getEntryDateStart());
+            }
+            if (salesLedgerDto.getEntryDateEnd() != null && !salesLedgerDto.getEntryDateEnd().isEmpty()) {
+                queryWrapper.le(SalesLedger::getEntryDate, salesLedgerDto.getEntryDateEnd());
+            }
+            if (salesLedgerDto.getDeliveryStatus() != null) {
+                queryWrapper.eq(SalesLedger::getDeliveryStatus, salesLedgerDto.getDeliveryStatus());
+            }
+            if (salesLedgerDto.getStockStatus() != null) {
+                queryWrapper.eq(SalesLedger::getStockStatus, salesLedgerDto.getStockStatus());
+            }
+            if (salesLedgerDto.getReviewStatus() != null) {
+                queryWrapper.eq(SalesLedger::getReviewStatus, salesLedgerDto.getReviewStatus());
+            }
+            if (salesLedgerDto.getOrderStatus() != null) {
+                queryWrapper.eq(SalesLedger::getOrderStatus, salesLedgerDto.getOrderStatus());
+            }
+            if (salesLedgerDto.getReviewStatusList() != null && !salesLedgerDto.getReviewStatusList().isEmpty()) {
+                queryWrapper.and(w -> w.in(SalesLedger::getReviewStatus, salesLedgerDto.getReviewStatusList())
+                    .or().isNull(SalesLedger::getReviewStatus));
+            }
+
+            List<SalesLedger> ledgerList = salesLedgerMapper.selectList(page, queryWrapper);
+
+            // 2. 鏀堕泦鏁版嵁
+            List<SalesLedgerExportDto> ledgerExportList = new ArrayList<>();
+            List<SalesLedgerProductExportDto> productExportList = new ArrayList<>();
+
+            for (SalesLedger ledger : ledgerList) {
+                // 杞崲鍙拌处鏁版嵁
+                SalesLedgerExportDto ledgerDto = new SalesLedgerExportDto();
+                ledgerDto.setSalesContractNo(ledger.getSalesContractNo());
+                ledgerDto.setCustomerContractNo(ledger.getCustomerContractNo());
+                ledgerDto.setProjectName(ledger.getProjectName());
+                ledgerDto.setCustomerName(ledger.getCustomerName());
+                ledgerDto.setSalesman(ledger.getSalesman());
+                ledgerDto.setEntryPersonName(ledger.getEntryPersonName());
+                ledgerDto.setEntryDate(ledger.getEntryDate());
+                ledgerDto.setExecutionDate(ledger.getExecutionDate() != null ?
+                    java.sql.Date.valueOf(ledger.getExecutionDate()) : null);
+                ledgerDto.setDeliveryDate(ledger.getDeliveryDate() != null ?
+                    java.sql.Date.valueOf(ledger.getDeliveryDate()) : null);
+                ledgerDto.setContractAmount(ledger.getContractAmount());
+                ledgerDto.setRemarks(ledger.getRemarks());
+                ledgerDto.setCustomerRemarks(ledger.getCustomerRemarks());
+                ledgerDto.setDeliveryStatusText(getDeliveryStatusText(ledger.getDeliveryStatus()));
+                ledgerDto.setStockStatusText(getStockStatusText(ledger.getStockStatus()));
+                ledgerDto.setReviewStatusText(getReviewStatusText(ledger.getReviewStatus()));
+                ledgerDto.setOrderStatusText(getOrderStatusText(ledger.getOrderStatus()));
+                ledgerExportList.add(ledgerDto);
+
+                // 鏌ヨ璇ュ彴璐︾殑浜у搧鍒楄〃
+                List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(
+                    Wrappers.<SalesLedgerProduct>lambdaQuery()
+                        .eq(SalesLedgerProduct::getSalesLedgerId, ledger.getId())
+                        .eq(SalesLedgerProduct::getType, 1)
+                );
+
+                for (SalesLedgerProduct product : products) {
+                    SalesLedgerProductExportDto productDto = new SalesLedgerProductExportDto();
+                    productDto.setSalesContractNo(ledger.getSalesContractNo());
+                    productDto.setProductCategory(product.getProductCategory());
+                    productDto.setSpecificationModel(product.getSpecificationModel());
+                    productDto.setThickness(product.getThickness());
+                    productDto.setFloorCode(product.getFloorCode());
+                    productDto.setWidth(product.getWidth());
+                    productDto.setHeight(product.getHeight());
+                    productDto.setQuantity(product.getQuantity());
+                    productDto.setSettlePieceArea(product.getSettlePieceArea());
+                    productDto.setSettleTotalArea(product.getSettleTotalArea());
+                    productDto.setTaxInclusiveUnitPrice(product.getTaxInclusiveUnitPrice());
+                    productDto.setTaxRate(product.getTaxRate());
+                    productDto.setTaxInclusiveTotalPrice(product.getTaxInclusiveTotalPrice());
+                    productDto.setTaxExclusiveTotalPrice(product.getTaxExclusiveTotalPrice());
+                    productDto.setInvoiceType(product.getInvoiceType());
+                    productDto.setProcessRequirement(product.getProcessRequirement());
+                    productDto.setRemark(product.getRemark());
+                    productExportList.add(productDto);
+                }
+            }
+
+            // 3. 浣跨敤ExcelUtil瀵煎嚭锛堝唴閮ㄤ細鍒涘缓Workbook骞跺啓鍏ュ搷搴旓級
+            // 鍏堝垱寤轰复鏃舵枃浠讹紝鍐嶅悎骞朵袱涓猻heet
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+            response.setCharacterEncoding("utf-8");
+            String fileName = URLEncoder.encode("閿�鍞彴璐�.xlsx", "utf-8").replaceAll("\\+", "%20");
+            response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName);
+
+            org.apache.poi.xssf.usermodel.XSSFWorkbook workbook = new org.apache.poi.xssf.usermodel.XSSFWorkbook();
+
+            // Sheet1: 閿�鍞彴璐� - 鎵嬪姩濉厖
+            fillSheetWithData(workbook, "閿�鍞彴璐�", SalesLedgerExportDto.class, ledgerExportList);
+
+            // Sheet2: 浜у搧鏄庣粏 - 鎵嬪姩濉厖
+            fillSheetWithData(workbook, "浜у搧鏄庣粏", SalesLedgerProductExportDto.class, productExportList);
+
+            workbook.write(response.getOutputStream());
+            workbook.close();
+
+        } catch (Exception e) {
+            log.error("瀵煎嚭閿�鍞彴璐﹀け璐�", e);
+            throw new ServiceException("瀵煎嚭澶辫触锛�" + e.getMessage());
+        }
+    }
+
+    /**
+     * 鎵嬪姩濉厖Sheet鏁版嵁
+     */
+    private <T> void fillSheetWithData(org.apache.poi.xssf.usermodel.XSSFWorkbook workbook, String sheetName, Class<T> clazz, List<T> dataList) throws Exception {
+        org.apache.poi.ss.usermodel.Sheet sheet = workbook.createSheet(sheetName);
+
+        // 鑾峰彇瀛楁涓婄殑@Excel娉ㄨВ
+        java.lang.reflect.Field[] fields = clazz.getDeclaredFields();
+        List<java.lang.reflect.Field> excelFields = new ArrayList<>();
+        for (java.lang.reflect.Field field : fields) {
+            com.ruoyi.framework.aspectj.lang.annotation.Excel excel = field.getAnnotation(com.ruoyi.framework.aspectj.lang.annotation.Excel.class);
+            if (excel != null) {
+                excelFields.add(field);
+            }
+        }
+
+        // 鍒涘缓琛ㄥご
+        org.apache.poi.ss.usermodel.Row headerRow = sheet.createRow(0);
+        org.apache.poi.ss.usermodel.CellStyle headerStyle = workbook.createCellStyle();
+        headerStyle.setFillForegroundColor(org.apache.poi.ss.usermodel.IndexedColors.GREY_50_PERCENT.getIndex());
+        headerStyle.setFillPattern(org.apache.poi.ss.usermodel.FillPatternType.SOLID_FOREGROUND);
+        headerStyle.setAlignment(org.apache.poi.ss.usermodel.HorizontalAlignment.CENTER);
+        org.apache.poi.ss.usermodel.Font headerFont = workbook.createFont();
+        headerFont.setBold(true);
+        headerStyle.setFont(headerFont);
+
+        for (int i = 0; i < excelFields.size(); i++) {
+            java.lang.reflect.Field field = excelFields.get(i);
+            field.setAccessible(true);
+            com.ruoyi.framework.aspectj.lang.annotation.Excel excel = field.getAnnotation(com.ruoyi.framework.aspectj.lang.annotation.Excel.class);
+            org.apache.poi.ss.usermodel.Cell cell = headerRow.createCell(i);
+            cell.setCellValue(excel.name());
+            cell.setCellStyle(headerStyle);
+            sheet.setColumnWidth(i, 20 * 256);
+        }
+
+        // 鍒涘缓鏁版嵁琛�
+        org.apache.poi.ss.usermodel.CellStyle dataStyle = workbook.createCellStyle();
+        dataStyle.setAlignment(org.apache.poi.ss.usermodel.HorizontalAlignment.CENTER);
+
+        for (int rowIndex = 0; rowIndex < dataList.size(); rowIndex++) {
+            T data = dataList.get(rowIndex);
+            org.apache.poi.ss.usermodel.Row row = sheet.createRow(rowIndex + 1);
+            for (int colIndex = 0; colIndex < excelFields.size(); colIndex++) {
+                java.lang.reflect.Field field = excelFields.get(colIndex);
+                field.setAccessible(true);
+                Object value = field.get(data);
+                org.apache.poi.ss.usermodel.Cell cell = row.createCell(colIndex);
+                if (value == null) {
+                    cell.setCellValue("");
+                } else if (value instanceof Number) {
+                    cell.setCellValue(((Number) value).doubleValue());
+                } else if (value instanceof Date) {
+                    cell.setCellValue(new java.text.SimpleDateFormat("yyyy-MM-dd").format((Date) value));
+                } else {
+                    cell.setCellValue(value.toString());
+                }
+                cell.setCellStyle(dataStyle);
+            }
+        }
+    }
+
+    private String getDeliveryStatusText(Integer status) {
+        if (status == null) return "鏈煡";
+        switch (status) {
+            case 1: return "鏈彂璐�";
+            case 2: return "瀹℃壒涓�";
+            case 3: return "瀹℃壒涓嶉�氳繃";
+            case 4: return "瀹℃壒閫氳繃";
+            case 5: return "宸插彂璐�";
+            case 6: return "閮ㄥ垎鍙戣揣";
+            default: return "鏈煡";
+        }
+    }
+
+    private String getStockStatusText(Integer status) {
+        if (status == null) return "鏈煡";
+        switch (status) {
+            case 0: return "鏈叆搴�";
+            case 1: return "閮ㄥ垎鍏ュ簱";
+            case 2: return "宸插叆搴�";
+            case 3: return "瀹℃壒涓�";
+            default: return "鏈煡";
+        }
+    }
+
+    private String getReviewStatusText(Integer status) {
+        if (status == null) return "寰呭鏍�";
+        switch (status) {
+            case 0: return "寰呭鏍�";
+            case 1: return "宸插鏍�";
+            case 2: return "宸插弽瀹�";
+            default: return "寰呭鏍�";
+        }
+    }
+
+    private String getOrderStatusText(Integer status) {
+        if (status == null || status == 0) return "杩涜涓�";
+        switch (status) {
+            case 0: return "杩涜涓�";
+            case 1: return "宸插畬鎴�";
+            default: return "杩涜涓�";
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.3