From f67161d150eb5720b28fd3f9fbb40c4145d1146c Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 10 六月 2026 11:42:37 +0800
Subject: [PATCH] feat:1.已审核只能编辑单价 2.添加完成按钮 3.添加标签打印和单据打印次数展示

---
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java |  317 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 275 insertions(+), 42 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 1bd4a41..527268f 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -158,6 +158,8 @@
     private final StockInRecordService stockInRecordService;
     private final StockOutRecordService stockOutRecordService;
     private final StockUtils stockUtils;
+    private final ShipmentApprovalMapper shipmentApprovalMapper;
+
     @Autowired
     private IApproveProcessService approveProcessService;
 
@@ -810,6 +812,13 @@
         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<>();
         queryWrapper.in(SalesLedgerProduct::getSalesLedgerId, idList).select(SalesLedgerProduct::getId);
@@ -904,11 +913,25 @@
                 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);
@@ -3334,6 +3357,97 @@
      * 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();
@@ -3392,13 +3506,96 @@
         
         // 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. 瀵瑰師璁㈠崟鐨勫嚭搴撴暟鎹敓鎴愬弽瀹″叆搴撹褰曪紙閿�鍞�-鍙嶅鍏ュ簱锛�
-     * 3. 鏇存柊搴撳瓨琛ㄦ暟鎹�
+     * 1. 鍒犻櫎鍘熻鍗曠殑鎵�鏈夊叆搴撹褰曪紝骞舵墸鍑忓簱瀛�
+     * 2. 鍒犻櫎鍘熻鍗曠殑鎵�鏈夊嚭搴撹褰曪紝骞跺鍔犲簱瀛�
      */
     private void processOriginalOrderStock(Long originalSalesLedgerId) {
         // 1. 鏌ヨ鍘熻鍗曠殑鎵�鏈夊叆搴撹褰�
@@ -3407,58 +3604,94 @@
                 .eq(StockInRecord::getSalesLedgerId, originalSalesLedgerId)
         );
         
-        // 2. 瀵规瘡鏉″叆搴撹褰曠敓鎴愬搴旂殑鍙嶅鍑哄簱璁板綍
+        // 2. 鍒犻櫎鍏ュ簱璁板綍骞舵墸鍑忓簱瀛�
         for (StockInRecord stockInRecord : stockInRecords) {
-            // 2.1 鍒涘缓鍙嶅鍑哄簱璁板綍
-            StockOutRecord stockOutRecord = new StockOutRecord();
-            stockOutRecord.setOutboundBatches(OrderUtils.countTodayByCreateTime(stockOutRecordMapper, "CK")); // 鐢熸垚鍑哄簱鎵规鍙�
-            stockOutRecord.setStockOutNum(stockInRecord.getStockInNum()); // 鍑哄簱鏁伴噺绛変簬鍘熷叆搴撴暟閲�
-            stockOutRecord.setRecordId(stockInRecord.getId()); // 璁板綍鍘熷叆搴撹褰旾D
-            stockOutRecord.setRecordType(StockOutQualifiedRecordTypeEnum.SALE_COUNTER_REVIEW_STOCK_OUT.getCode()); // 璁剧疆涓洪攢鍞弽瀹″嚭搴撶被鍨�
-            stockOutRecord.setProductModelId(stockInRecord.getProductModelId()); // 浜у搧瑙勬牸ID
-            stockOutRecord.setRemark("閿�鍞�-鍙嶅鍑哄簱"); // 澶囨敞
-            stockOutRecord.setType(stockInRecord.getType()); // 绫诲瀷锛堝悎鏍�/涓嶅悎鏍硷級
-            stockOutRecord.setSalesLedgerId(stockInRecord.getSalesLedgerId()); // 閿�鍞鍗旾D
-            stockOutRecord.setSalesLedgerProductId(stockInRecord.getSalesLedgerProductId()); // 閿�鍞鍗曚骇鍝両D
-            
-            // 2.2 鎻掑叆鍙嶅鍑哄簱璁板綍
-            stockOutRecordMapper.insert(stockOutRecord);
-            
-            // 2.3 浠庡簱瀛樿〃涓墸鍑忕浉搴旀暟閲�
+            // 浠庡簱瀛樿〃涓墸鍑忕浉搴旀暟閲�
             StockInventoryDto stockInventoryDto = new StockInventoryDto();
-            stockInventoryDto.setProductModelId(stockOutRecord.getProductModelId());
-            stockInventoryDto.setQualitity(stockOutRecord.getStockOutNum());
+            stockInventoryDto.setProductModelId(stockInRecord.getProductModelId());
+            stockInventoryDto.setQualitity(stockInRecord.getStockInNum());
             stockInventoryMapper.updateSubtractStockInventory(stockInventoryDto);
         }
         
-        // 3. 鏌ヨ鍘熻鍗曠殑鎵�鏈夊嚭搴撹褰�
+        // 3. 鍒犻櫎鎵�鏈夊叆搴撹褰�
+        stockInRecordMapper.delete(
+            Wrappers.<StockInRecord>lambdaQuery()
+                .eq(StockInRecord::getSalesLedgerId, originalSalesLedgerId)
+        );
+        
+        // 4. 鏌ヨ鍘熻鍗曠殑鎵�鏈夊嚭搴撹褰�
         List<StockOutRecord> stockOutRecords = stockOutRecordMapper.selectList(
             Wrappers.<StockOutRecord>lambdaQuery()
                 .eq(StockOutRecord::getSalesLedgerId, originalSalesLedgerId)
         );
         
-        // 4. 瀵规瘡鏉″嚭搴撹褰曠敓鎴愬搴旂殑鍙嶅鍏ュ簱璁板綍
+        // 5. 鍒犻櫎鍑哄簱璁板綍骞跺鍔犲簱瀛�
         for (StockOutRecord stockOutRecord : stockOutRecords) {
-            // 4.1 鍒涘缓鍙嶅鍏ュ簱璁板綍
-            StockInRecord stockInRecord = new StockInRecord();
-            stockInRecord.setInboundBatches(OrderUtils.countTodayByCreateTime(stockInRecordMapper, "RK")); // 鐢熸垚鍏ュ簱鎵规鍙�
-            stockInRecord.setStockInNum(stockOutRecord.getStockOutNum()); // 鍏ュ簱鏁伴噺绛変簬鍘熷嚭搴撴暟閲�
-            stockInRecord.setRecordId(stockOutRecord.getId()); // 璁板綍鍘熷嚭搴撹褰旾D
-            stockInRecord.setRecordType(StockInQualifiedRecordTypeEnum.SALE_COUNTER_REVIEW_STOCK_IN.getCode()); // 璁剧疆涓洪攢鍞弽瀹″叆搴撶被鍨�
-            stockInRecord.setProductModelId(stockOutRecord.getProductModelId()); // 浜у搧瑙勬牸ID
-            stockInRecord.setRemark("閿�鍞�-鍙嶅鍏ュ簱"); // 澶囨敞
-            stockInRecord.setType(stockOutRecord.getType()); // 绫诲瀷锛堝悎鏍�/涓嶅悎鏍硷級
-            stockInRecord.setSalesLedgerId(stockOutRecord.getSalesLedgerId()); // 閿�鍞鍗旾D
-            stockInRecord.setSalesLedgerProductId(stockOutRecord.getSalesLedgerProductId()); // 閿�鍞鍗曚骇鍝両D
-            
-            // 4.2 鎻掑叆鍙嶅鍏ュ簱璁板綍
-            stockInRecordMapper.insert(stockInRecord);
-            
-            // 4.3 鍚戝簱瀛樿〃涓鍔犵浉搴旀暟閲�
+            // 鍚戝簱瀛樿〃涓鍔犵浉搴旀暟閲�
             StockInventoryDto stockInventoryDto = new StockInventoryDto();
-            stockInventoryDto.setProductModelId(stockInRecord.getProductModelId());
-            stockInventoryDto.setQualitity(stockInRecord.getStockInNum());
+            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)
+            );
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3