| | |
| | | .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("销售台账ID不能为空"); |
| | | } |
| | | 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) |
| | | ); |
| | | } |
| | | } |
| | | } |