|
|
@@ -0,0 +1,408 @@
|
|
|
+package org.dromara.bill.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.dromara.bill.domain.*;
|
|
|
+import org.dromara.bill.domain.bo.*;
|
|
|
+import org.dromara.bill.mapper.*;
|
|
|
+import org.dromara.bill.service.IStatementInvoiceService;
|
|
|
+import org.dromara.common.core.enums.InvoiceApplicationStatus;
|
|
|
+import org.dromara.common.core.enums.InvoiceStatus;
|
|
|
+import org.dromara.common.core.enums.LoginType;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.core.utils.ObjectUtils;
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.dromara.common.redis.utils.SequenceUtils;
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
+import org.dromara.system.api.model.LoginUser;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.dromara.bill.domain.vo.InvoiceApplicationVo;
|
|
|
+import org.dromara.bill.service.IInvoiceApplicationService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 开票申请单Service业务层处理
|
|
|
+ *
|
|
|
+ * @author LionLi
|
|
|
+ * @date 2026-03-26
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Service
|
|
|
+public class InvoiceApplicationServiceImpl extends ServiceImpl<InvoiceApplicationMapper, InvoiceApplication> implements IInvoiceApplicationService {
|
|
|
+
|
|
|
+ private final InvoiceApplicationMapper baseMapper;
|
|
|
+
|
|
|
+ private final InvoiceInfoMapper invoiceInfoMapper;
|
|
|
+
|
|
|
+ private final StatementInvoiceMapper statementInvoiceMapper;
|
|
|
+
|
|
|
+ private final StatementOrderMapper statementOrderMapper;
|
|
|
+
|
|
|
+ private final StatementDetailMapper statementDetailMapper;
|
|
|
+
|
|
|
+ private final StatementProductMapper statementProductMapper;
|
|
|
+
|
|
|
+ private final IStatementInvoiceService statementInvoiceService;
|
|
|
+
|
|
|
+ private final StatementInvoiceDetailMapper statementInvoiceDetailMapper;
|
|
|
+
|
|
|
+ private final StatementInvoiceProductMapper statementInvoiceProductMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询开票申请单
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return 开票申请单
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public InvoiceApplicationVo queryById(Long id) {
|
|
|
+ return baseMapper.selectVoById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询开票申请单列表
|
|
|
+ *
|
|
|
+ * @param bo 查询条件
|
|
|
+ * @param pageQuery 分页参数
|
|
|
+ * @return 开票申请单分页列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<InvoiceApplicationVo> queryPageList(InvoiceApplicationBo bo, PageQuery pageQuery) {
|
|
|
+ LambdaQueryWrapper<InvoiceApplication> lqw = buildQueryWrapper(bo);
|
|
|
+ Page<InvoiceApplicationVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+ return TableDataInfo.build(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询符合条件的开票申请单列表
|
|
|
+ *
|
|
|
+ * @param bo 查询条件
|
|
|
+ * @return 开票申请单列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<InvoiceApplicationVo> queryList(InvoiceApplicationBo bo) {
|
|
|
+ LambdaQueryWrapper<InvoiceApplication> lqw = buildQueryWrapper(bo);
|
|
|
+ return baseMapper.selectVoList(lqw);
|
|
|
+ }
|
|
|
+
|
|
|
+ private LambdaQueryWrapper<InvoiceApplication> buildQueryWrapper(InvoiceApplicationBo bo) {
|
|
|
+ Map<String, Object> params = bo.getParams();
|
|
|
+ LambdaQueryWrapper<InvoiceApplication> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.orderByAsc(InvoiceApplication::getId);
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getApplicationNo()), InvoiceApplication::getApplicationNo, bo.getApplicationNo());
|
|
|
+ lqw.eq(bo.getCustomerId() != null, InvoiceApplication::getCustomerId, bo.getCustomerId());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getCustomerName()), InvoiceApplication::getCustomerName, bo.getCustomerName());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getInvoiceType()), InvoiceApplication::getInvoiceType, bo.getInvoiceType());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getInvoiceTitle()), InvoiceApplication::getInvoiceTitle, bo.getInvoiceTitle());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getTaxNumber()), InvoiceApplication::getTaxNumber, bo.getTaxNumber());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getRegAddress()), InvoiceApplication::getRegAddress, bo.getRegAddress());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getRegPhone()), InvoiceApplication::getRegPhone, bo.getRegPhone());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getBankName()), InvoiceApplication::getBankName, bo.getBankName());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getBankAccount()), InvoiceApplication::getBankAccount, bo.getBankAccount());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getReceiverEmail()), InvoiceApplication::getReceiverEmail, bo.getReceiverEmail());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getReceiverPhone()), InvoiceApplication::getReceiverPhone, bo.getReceiverPhone());
|
|
|
+ lqw.eq(bo.getApplyAmount() != null, InvoiceApplication::getApplyAmount, bo.getApplyAmount());
|
|
|
+ lqw.eq(bo.getApplyTaxAmount() != null, InvoiceApplication::getApplyTaxAmount, bo.getApplyTaxAmount());
|
|
|
+ lqw.eq(bo.getTotalAmount() != null, InvoiceApplication::getTotalAmount, bo.getTotalAmount());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getStatementIds()), InvoiceApplication::getStatementIds, bo.getStatementIds());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getStatus()), InvoiceApplication::getStatus, bo.getStatus());
|
|
|
+ lqw.eq(bo.getAuditUserId() != null, InvoiceApplication::getAuditUserId, bo.getAuditUserId());
|
|
|
+ lqw.eq(bo.getAuditTime() != null, InvoiceApplication::getAuditTime, bo.getAuditTime());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getAuditRemark()), InvoiceApplication::getAuditRemark, bo.getAuditRemark());
|
|
|
+ lqw.eq(bo.getFinalInvoiceId() != null, InvoiceApplication::getFinalInvoiceId, bo.getFinalInvoiceId());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getInvoiceCode()), InvoiceApplication::getInvoiceCode, bo.getInvoiceCode());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getInvoiceNumber()), InvoiceApplication::getInvoiceNumber, bo.getInvoiceNumber());
|
|
|
+ lqw.eq(bo.getInvoiceDate() != null, InvoiceApplication::getInvoiceDate, bo.getInvoiceDate());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), InvoiceApplication::getPlatformCode, bo.getPlatformCode());
|
|
|
+ return lqw;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增开票申请单
|
|
|
+ *
|
|
|
+ * @param bo 开票申请单
|
|
|
+ * @return 是否新增成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean insertByBo(InvoiceApplicationBo bo) {
|
|
|
+ InvoiceApplication add = MapstructUtils.convert(bo, InvoiceApplication.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ boolean flag = baseMapper.insert(add) > 0;
|
|
|
+ if (flag) {
|
|
|
+ bo.setId(add.getId());
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改开票申请单
|
|
|
+ *
|
|
|
+ * @param bo 开票申请单
|
|
|
+ * @return 是否修改成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean updateByBo(InvoiceApplicationBo bo) {
|
|
|
+ InvoiceApplication update = MapstructUtils.convert(bo, InvoiceApplication.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ return baseMapper.updateById(update) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改状态
|
|
|
+ *
|
|
|
+ * @param bo 信息
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void auditApplication(InvoiceApplicationBo bo) {
|
|
|
+ Long id = bo.getId();
|
|
|
+ // 1. 查询申请单
|
|
|
+ InvoiceApplication application = baseMapper.selectById(id);
|
|
|
+ if (application == null) {
|
|
|
+ throw new RuntimeException("申请单不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 校验状态 (必须是待审核状态才能操作)
|
|
|
+ if (!InvoiceApplicationStatus.PENDING_AUDIT.getCode().equals(application.getStatus())) {
|
|
|
+ throw new RuntimeException("申请单状态异常,当前状态为:" + application.getStatus());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 更新申请单状态
|
|
|
+ InvoiceApplication updateApp = new InvoiceApplication();
|
|
|
+ updateApp.setId(id);
|
|
|
+ updateApp.setStatus(bo.getStatus());
|
|
|
+ updateApp.setAuditUserId(LoginHelper.getLoginUser().getUserId());
|
|
|
+ updateApp.setAuditTime(new Date());
|
|
|
+ updateApp.setAuditRemark(bo.getAuditRemark());
|
|
|
+
|
|
|
+ // 如果被驳回,不需要做其他操作;如果通过,后续可能会调用生成发票方法
|
|
|
+ baseMapper.updateById(updateApp);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据审核通过的申请单,生成正式发票单据
|
|
|
+ * 逻辑对标 pcInsertByBo,但数据源来自 InvoiceApplication
|
|
|
+ *
|
|
|
+ * @param applicationId 申请单ID
|
|
|
+ * @return 生成的正式发票单ID
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Long generateInvoiceByApplication(Long applicationId) {
|
|
|
+ // 1. 获取申请单信息
|
|
|
+ InvoiceApplication application = baseMapper.selectById(applicationId);
|
|
|
+ if (application == null) {
|
|
|
+ throw new RuntimeException("申请单不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 校验申请单状态 (必须是审核通过才能生成发票)
|
|
|
+ if (!InvoiceApplicationStatus.AUDIT_PASSED.getCode().equals(application.getStatus())) {
|
|
|
+ throw new RuntimeException("申请单尚未审核通过,无法生成发票");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 解析关联的对账单ID
|
|
|
+ if (StringUtils.isEmpty(application.getStatementIds())) {
|
|
|
+ throw new RuntimeException("申请单未关联对账单");
|
|
|
+ }
|
|
|
+ String[] statementIdArr = application.getStatementIds().split(",");
|
|
|
+ List<Long> statementOrderIds = Arrays.stream(statementIdArr).map(Long::parseLong).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 4. 查询对账单详情 (用于获取明细和商品)
|
|
|
+ // 注意:这里复用 pcInsertByBo 的逻辑,查对账单是为了拿明细
|
|
|
+ List<StatementOrder> statementOrders = statementOrderMapper.selectBatchIds(statementOrderIds);
|
|
|
+ if (statementOrders.size() != statementOrderIds.size()) {
|
|
|
+ throw new RuntimeException("关联的对账单部分丢失,无法生成发票");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. 构建正式发票主单 (StatementInvoice)
|
|
|
+ // 使用申请单中的“快照信息”作为发票抬头,而不是对账单的客户信息
|
|
|
+ StatementInvoice formalInvoice = new StatementInvoice();
|
|
|
+ formalInvoice.setStatementInvoiceNo(SequenceUtils.generateOrderCode("INV")); // 生成正式发票流水号
|
|
|
+ formalInvoice.setCustomerNo(statementOrders.get(0).getCustomerNo()); // 客户编号
|
|
|
+ formalInvoice.setCustomerName(application.getInvoiceTitle()); // 【关键】使用申请时填写的抬头
|
|
|
+ formalInvoice.setInvoiceAmount(application.getTotalAmount()); // 申请金额
|
|
|
+ formalInvoice.setInvoiceStatus(InvoiceStatus.INVOICED.getCode()); // 状态:已开具/待开票
|
|
|
+ formalInvoice.setCreateTime(new Date());
|
|
|
+
|
|
|
+
|
|
|
+ // 保存正式发票主单
|
|
|
+ Integer saved = statementInvoiceMapper.insert(formalInvoice);
|
|
|
+ if (saved <= 0) {
|
|
|
+ throw new RuntimeException("保存正式发票主单失败");
|
|
|
+ }
|
|
|
+ Long formalInvoiceId = formalInvoice.getId();
|
|
|
+
|
|
|
+ // 6. 构建明细和商品列表
|
|
|
+ List<StatementInvoiceDetailBo> detailBoList = new ArrayList<>();
|
|
|
+ List<StatementInvoiceProductBo> productBoList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 6.1 查询所有关联的明细
|
|
|
+ List<StatementDetail> allDetails = statementDetailMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<StatementDetail>()
|
|
|
+ .in(StatementDetail::getStatementOrderId, statementOrderIds)
|
|
|
+ );
|
|
|
+
|
|
|
+ // 6.2 提取 Key 用于查询商品
|
|
|
+ Set<String> orderKeys = allDetails.stream()
|
|
|
+ .map(d -> d.getStatementOrderId() + "_" + d.getOrderId())
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ if (!orderKeys.isEmpty()) {
|
|
|
+ // 查询所有关联的商品
|
|
|
+ List<StatementProduct> allProducts = statementProductMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<StatementProduct>()
|
|
|
+ .in(StatementProduct::getStatementOrderId, statementOrderIds)
|
|
|
+ );
|
|
|
+
|
|
|
+ // 建立商品映射
|
|
|
+ Map<String, List<StatementProduct>> productMap = allProducts.stream()
|
|
|
+ .collect(Collectors.groupingBy(p -> p.getStatementOrderId() + "_" + p.getOrderId()));
|
|
|
+
|
|
|
+ // 组装 BO 对象
|
|
|
+ for (StatementDetail detail : allDetails) {
|
|
|
+ // --- 组装明细 ---
|
|
|
+ StatementInvoiceDetailBo detailBo = new StatementInvoiceDetailBo();
|
|
|
+ detailBo.setStatementInvoiceId(formalInvoiceId);
|
|
|
+ detailBo.setStatementInvoiceNo(formalInvoice.getStatementInvoiceNo());
|
|
|
+ detailBo.setStatementAmount(detail.getAmount());
|
|
|
+ detailBo.setOrderId(detail.getOrderId());
|
|
|
+ detailBo.setOrderNo(detail.getOrderNo());
|
|
|
+ detailBo.setOrderAmount(detail.getAmount());
|
|
|
+ detailBo.setOrderTime(detail.getOrderTime());
|
|
|
+ detailBo.setSigningDate(detail.getSigningDate());
|
|
|
+ detailBo.setUserId(LoginHelper.getUserId()); // 操作人
|
|
|
+ detailBo.setUserDeptId(LoginHelper.getDeptId());
|
|
|
+ detailBo.setStatementOrderId(detail.getStatementOrderId());
|
|
|
+ detailBo.setStatementOrderNo(detail.getStatementOrderNo());
|
|
|
+ detailBoList.add(detailBo);
|
|
|
+
|
|
|
+ // --- 组装商品 ---
|
|
|
+ String key = detail.getStatementOrderId() + "_" + detail.getOrderId();
|
|
|
+ List<StatementProduct> products = productMap.get(key);
|
|
|
+ if (CollectionUtil.isNotEmpty(products)) {
|
|
|
+ for (StatementProduct p : products) {
|
|
|
+ StatementInvoiceProductBo productBo = new StatementInvoiceProductBo();
|
|
|
+ productBo.setStatementInvoiceId(formalInvoiceId);
|
|
|
+ productBo.setStatementInvoiceNo(formalInvoice.getStatementInvoiceNo());
|
|
|
+ productBo.setProductId(p.getProductId());
|
|
|
+ productBo.setProductNo(p.getProductNo());
|
|
|
+ productBo.setOrderId(p.getOrderId());
|
|
|
+ productBo.setOrderNo(p.getOrderNo());
|
|
|
+ productBo.setItemName(p.getItemName());
|
|
|
+ productBo.setUnitId(p.getUnitId());
|
|
|
+ productBo.setUnitName(p.getUnitName());
|
|
|
+ productBo.setQuantity(p.getQuantity());
|
|
|
+ productBo.setUnitPrice(p.getUnitPrice());
|
|
|
+ productBoList.add(productBo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 7. 保存子表数据 (复用你提供的公共方法)
|
|
|
+ StatementInvoiceBo saveBo = new StatementInvoiceBo();
|
|
|
+ saveBo.setId(formalInvoiceId);
|
|
|
+ saveBo.setStatementInvoiceNo(formalInvoice.getStatementInvoiceNo());
|
|
|
+ saveBo.setDetailList(detailBoList);
|
|
|
+ saveBo.setProductList(productBoList);
|
|
|
+ saveBo.setInvoiceList(new ArrayList<>()); // 暂不处理发票附件信息
|
|
|
+
|
|
|
+ saveDetailsAndProductsAndInvoiceInfos(saveBo);
|
|
|
+
|
|
|
+ // 8. 【关键】更新申请单状态为“已完成”,并关联正式发票ID
|
|
|
+ InvoiceApplication updateApp = new InvoiceApplication();
|
|
|
+ updateApp.setId(applicationId);
|
|
|
+ updateApp.setStatus(InvoiceApplicationStatus.COMPLETED.getCode());
|
|
|
+ updateApp.setFinalInvoiceId(formalInvoiceId);
|
|
|
+ baseMapper.updateById(updateApp);
|
|
|
+
|
|
|
+ // 9. 【关键】更新对账单的“已开票金额”
|
|
|
+ // 防止同一笔对账单被重复申请开票
|
|
|
+// BigDecimal amountToInvoice = application.getTotalAmount();
|
|
|
+// statementOrderMapper.updateInvoiceAmount(statementOrderIds, amountToInvoice);
|
|
|
+
|
|
|
+ return formalInvoiceId;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 公共方法:保存明细和商品 发票
|
|
|
+ */
|
|
|
+ private void saveDetailsAndProductsAndInvoiceInfos(StatementInvoiceBo bo) {
|
|
|
+ List<StatementInvoiceDetail> details = new ArrayList<>();
|
|
|
+ List<StatementInvoiceProduct> products = new ArrayList<>();
|
|
|
+ List<InvoiceInfo> invoiceInfoList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 1. 先保存所有明细
|
|
|
+ if (CollectionUtil.isNotEmpty(bo.getDetailList())) {
|
|
|
+ for (StatementInvoiceDetailBo detailBo : bo.getDetailList()) {
|
|
|
+ StatementInvoiceDetail detail = MapstructUtils.convert(detailBo, StatementInvoiceDetail.class);
|
|
|
+ detail.setStatementInvoiceId(bo.getId());
|
|
|
+ detail.setStatementInvoiceNo(bo.getStatementInvoiceNo());
|
|
|
+ details.add(detail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(bo.getProductList())) {
|
|
|
+ for (StatementInvoiceProductBo productBo : bo.getProductList()) {
|
|
|
+ StatementInvoiceProduct product = MapstructUtils.convert(productBo, StatementInvoiceProduct.class);
|
|
|
+ product.setStatementInvoiceId(bo.getId());
|
|
|
+ product.setStatementInvoiceNo(bo.getStatementInvoiceNo());
|
|
|
+ products.add(product);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(bo.getInvoiceList())) {
|
|
|
+ for (InvoiceInfoBo invoiceInfoBo : bo.getInvoiceList()) {
|
|
|
+ InvoiceInfo invoiceInfo = MapstructUtils.convert(invoiceInfoBo, InvoiceInfo.class);
|
|
|
+ invoiceInfo.setStatementInvoiceId(bo.getId());
|
|
|
+ invoiceInfo.setStatementInvoiceNo(bo.getStatementInvoiceNo());
|
|
|
+ invoiceInfoList.add(invoiceInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!invoiceInfoList.isEmpty()) {
|
|
|
+ invoiceInfoMapper.insertBatch(invoiceInfoList);
|
|
|
+ }
|
|
|
+ if (!details.isEmpty()) {
|
|
|
+ statementInvoiceDetailMapper.insertBatch(details);
|
|
|
+ }
|
|
|
+ if (!products.isEmpty()) {
|
|
|
+ statementInvoiceProductMapper.insertBatch(products);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存前的数据校验
|
|
|
+ */
|
|
|
+ private void validEntityBeforeSave(InvoiceApplication entity) {
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验并批量删除开票申请单信息
|
|
|
+ *
|
|
|
+ * @param ids 待删除的主键集合
|
|
|
+ * @param isValid 是否进行有效性校验
|
|
|
+ * @return 是否删除成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
+ if (isValid) {
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
+ }
|
|
|
+ return baseMapper.deleteByIds(ids) > 0;
|
|
|
+ }
|
|
|
+}
|