|
@@ -1,13 +1,21 @@
|
|
|
package com.dayou.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.dayou.common.BaseEntity;
|
|
|
import com.dayou.dto.ProductionReturnSelectDTO;
|
|
|
import com.dayou.dto.WorkNodeCommit;
|
|
|
+import com.dayou.entity.FinanceFine;
|
|
|
+import com.dayou.entity.OrderFund;
|
|
|
+import com.dayou.entity.ProductionFund;
|
|
|
import com.dayou.entity.ProductionReturn;
|
|
|
import com.dayou.enums.workflow.NodeLogEnum;
|
|
|
import com.dayou.exception.BusinessException;
|
|
|
import com.dayou.exception.ErrorCode;
|
|
|
+import com.dayou.mapper.FinanceInvoiceMapper;
|
|
|
import com.dayou.mapper.ProductionReturnMapper;
|
|
|
+import com.dayou.service.IFinanceFineService;
|
|
|
+import com.dayou.service.IOrderFundService;
|
|
|
+import com.dayou.service.IProductionFundService;
|
|
|
import com.dayou.service.IProductionReturnService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.dayou.service.workflow.IWorkFlowService;
|
|
@@ -53,6 +61,15 @@ public class ProductionReturnServiceImpl extends ServiceImpl<ProductionReturnMap
|
|
|
private ProductionReturnMapper productionReturnMapper;
|
|
|
|
|
|
@Autowired
|
|
|
+ private IProductionFundService productionFundService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOrderFundService orderFundService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FinanceInvoiceMapper financeInvoiceMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private IWorkFlowService workFlowService;
|
|
|
|
|
|
/**
|
|
@@ -199,6 +216,26 @@ public class ProductionReturnServiceImpl extends ServiceImpl<ProductionReturnMap
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean add(ProductionReturn productionReturn){
|
|
|
+ Long orderFundId = null;
|
|
|
+ Long productionFundId = null;
|
|
|
+ // 获取收款信息
|
|
|
+ OrderFund orderFund = orderFundService.getOne(new LambdaQueryWrapper<OrderFund>()
|
|
|
+ .eq(BaseEntity::getDeleted, false)
|
|
|
+ .eq(OrderFund::getBusinessType, productionReturn.getBusinessType())
|
|
|
+ .eq(OrderFund::getBusinessId, productionReturn.getBusinessId()));
|
|
|
+ if(ObjectUtil.isNotNull(orderFund)) { // 判断有没有订单收款信息
|
|
|
+ ProductionFund productionFund = productionFundService.getOne(new LambdaQueryWrapper<ProductionFund>()
|
|
|
+ .eq(BaseEntity::getDeleted, false)
|
|
|
+ .eq(ProductionFund::getBusinessType, productionReturn.getBusinessType())
|
|
|
+ .eq(ProductionFund::getBusinessId, productionReturn.getBusinessId())
|
|
|
+ .eq(ProductionFund::getProductionNo, productionReturn.getProductionNo())
|
|
|
+ .eq(ProductionFund::getProductionType, productionReturn.getProductionType())
|
|
|
+ .eq(ProductionFund::getOrderFundId, orderFund.getId()));
|
|
|
+ orderFundId = orderFund.getId();
|
|
|
+ productionFundId = productionFund != null ? productionFund.getId() : null;
|
|
|
+ }
|
|
|
+ // 获取发票号
|
|
|
+ productionReturn.setInvoiceNo(financeInvoiceMapper.getInvoiceNoByFundId(orderFundId, productionFundId));
|
|
|
Integer count = productionReturnMapper.count(productionReturn);
|
|
|
if (count > 0) {
|
|
|
ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR, "当前已有审核中或已通过的流程,无需重复提交");
|