5 天以前 d3a5c4420a7daf89bc9832f22ca8ed9d7e1adaf9
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;
@@ -558,8 +565,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());
@@ -592,9 +608,12 @@
            // 3. 新增或更新主表
            if (salesLedger.getId() == null) {
                String contractNo = generateSalesContractNo();
                salesLedger.setSalesContractNo(contractNo);
                salesLedger.setSalesContractNo(salesLedgerDto.getSalesContractNo() == null ? contractNo : salesLedgerDto.getSalesContractNo());
                salesLedgerMapper.insert(salesLedger);
            } else {
                if(StringUtils.isNotEmpty(salesLedgerDto.getSalesContractNo())){
                    salesLedger.setSalesContractNo(salesLedgerDto.getSalesContractNo());
                }
                salesLedgerMapper.updateById(salesLedger);
            }