2026-05-11 99e26030611fdc06ee3dd523072fe5516b78dc5b
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -23,6 +23,9 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.other.mapper.TempFileMapper;
import com.ruoyi.other.pojo.TempFile;
import com.ruoyi.procurementrecord.mapper.ReturnManagementMapper;
import com.ruoyi.procurementrecord.pojo.ReturnManagement;
import com.ruoyi.procurementrecord.service.ReturnManagementService;
import com.ruoyi.production.mapper.*;
import com.ruoyi.production.pojo.*;
import com.ruoyi.production.service.ProductionProductMainService;
@@ -98,6 +101,10 @@
    private final CommonFileServiceImpl commonFileService;
    private final ShippingInfoMapper shippingInfoMapper;
    private final ReturnManagementMapper returnManagementMapper;
    private final ReturnManagementService returnManagementService;
    private final InvoiceLedgerMapper invoiceLedgerMapper;
@@ -405,9 +412,19 @@
                    salesLedgerProduct.setSalesLedgerId(salesLedger.getId());
                    salesLedgerProduct.setType(1);
                    // 计算不含税总价
                    salesLedgerProduct.setTaxExclusiveTotalPrice(salesLedgerProduct.getTaxInclusiveTotalPrice().divide(new BigDecimal(1).add(salesLedgerProduct.getTaxRate().divide(new BigDecimal(100))), 2, RoundingMode.HALF_UP));
                    if (salesLedgerProduct.getTaxInclusiveTotalPrice() != null && salesLedgerProduct.getTaxRate() != null) {
                        salesLedgerProduct.setTaxExclusiveTotalPrice(
                                salesLedgerProduct.getTaxInclusiveTotalPrice().divide(
                                        new BigDecimal(1).add(salesLedgerProduct.getTaxRate().divide(new BigDecimal(100))),
                                        2,
                                        RoundingMode.HALF_UP
                                )
                        );
                    } else {
                        salesLedgerProduct.setTaxExclusiveTotalPrice(salesLedgerProduct.getTaxInclusiveTotalPrice());
                    }
                    salesLedgerProduct.setNoInvoiceNum(salesLedgerProduct.getQuantity());
                    salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxExclusiveTotalPrice());
                    salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxInclusiveTotalPrice());
                    list.stream()
                            .filter(map -> map.get("productName").equals(salesLedgerProduct.getProductCategory()) && map.get("model").equals(salesLedgerProduct.getSpecificationModel()))
                            .findFirst()
@@ -428,7 +445,7 @@
                    salesLedgerProduct.setRegister(loginUser.getNickName());
                    salesLedgerProduct.setRegisterDate(LocalDateTime.now());
                    salesLedgerProduct.setApproveStatus(0);
                    salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProductImportDto.getTaxInclusiveTotalPrice());
                    salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProduct.getTaxInclusiveTotalPrice());
                    salesLedgerProductMapper.insert(salesLedgerProduct);
                    // 添加生产数据
                    salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct);
@@ -558,8 +575,17 @@
        List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>()
                .in(ShippingInfo::getSalesLedgerId, idList));
        if (CollectionUtils.isNotEmpty(shippingInfos)) {
            shippingInfoServiceImpl.delete(shippingInfos.stream().map(ShippingInfo::getId).collect(Collectors.toList()));
            List<Long> shippingIds = shippingInfos.stream().map(ShippingInfo::getId).collect(Collectors.toList());
            shippingInfoServiceImpl.delete(shippingIds);
            // 删除退货台账记录
            List<ReturnManagement> returnManagements = returnManagementMapper.selectList(new LambdaQueryWrapper<ReturnManagement>()
                    .in(ReturnManagement::getShippingId, shippingIds));
            if (CollectionUtils.isNotEmpty(returnManagements)) {
                List<Long> returnIds = returnManagements.stream().map(ReturnManagement::getId).collect(Collectors.toList());
                returnManagementService.delete(returnIds);
            }
        }
        // 删除附件表
        commonFileService.deleteByBusinessIds(idList, FileNameType.SALE.getValue());