|
@@ -4,6 +4,7 @@ package com.dayou.workflow.config;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.db.sql.Order;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.dayou.bo.SimpleParentModel;
|
|
@@ -34,9 +35,13 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.dayou.enums.FinanceInvoiceState.审核拒绝;
|
|
|
import static com.dayou.enums.FinanceInvoiceState.审核通过;
|
|
|
+import static com.dayou.enums.FineRefundReasonEnum.*;
|
|
|
+import static com.dayou.enums.FineRefundStatusEnum.NOT_RETURNED;
|
|
|
import static com.dayou.enums.GlobalConfigEnum.*;
|
|
|
import static com.dayou.enums.MainBusinessEnum.ASSET_BUSINESS;
|
|
|
import static com.dayou.enums.MainBusinessEnum.MAJOR_BUSINESS;
|
|
|
+import static com.dayou.enums.ProductionReturnStatus.APPROVE;
|
|
|
+import static com.dayou.enums.ProductionReturnStatus.REJECTION;
|
|
|
import static com.dayou.enums.workflow.NodeLogEnum.PASS;
|
|
|
import static com.dayou.enums.workflow.NodeStateEnum.*;
|
|
|
import static com.dayou.enums.workflow.WorkflowNodeEnum.LEADER_ALLOCATION;
|
|
@@ -91,6 +96,15 @@ public class WorkNodeProcessable {
|
|
|
@Autowired
|
|
|
private IOrderFundService orderFundService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IProductionReturnService productionReturnService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFinanceFineService financeFineService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFinanceFineRefundService financeFineRefundService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 提交流程前置处理
|
|
@@ -166,6 +180,41 @@ public class WorkNodeProcessable {
|
|
|
commissionDeclareService.update(new LambdaUpdateWrapper<CommissionDeclare>().set(CommissionDeclare::getDeclareResult,审核通过.name())
|
|
|
.eq(BaseEntity::getId,currentInstanceNode.getBusinessId()));
|
|
|
break;
|
|
|
+ case PRODUCTION_RETURN:
|
|
|
+ // 产品退回流程通过后将申请记录改为通过状态
|
|
|
+ productionReturnService.update(new LambdaUpdateWrapper<ProductionReturn>().set(ProductionReturn::getStatus, APPROVE.getCode())
|
|
|
+ .eq(ProductionReturn::getId, currentInstanceNode.getBusinessId())
|
|
|
+ .eq(ProductionReturn::getDeleted, false));
|
|
|
+ ProductionReturn productionReturn = productionReturnService.getById(currentInstanceNode.getBusinessId());
|
|
|
+ // 获取订单收款信息
|
|
|
+ OrderFund orderFund = orderFundService.getOne(new LambdaQueryWrapper<OrderFund>()
|
|
|
+ .eq(BaseEntity::getDeleted, false)
|
|
|
+ .eq(OrderFund::getBusinessType, productionReturn.getBusinessType())
|
|
|
+ .eq(OrderFund::getBusinessId, productionReturn.getBusinessId()));
|
|
|
+ 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::getOrderFundId, orderFund.getId()));
|
|
|
+ // 新增罚款后退款记录
|
|
|
+ FinanceFine financeFine = financeFineService.getFineByFundInfo(orderFund.getId(), productionFund.getId() != null ? productionFund.getId() : null);
|
|
|
+ // 判断罚款记录是否为空,为空说明没有已确认的罚款,不新增罚款退款记录
|
|
|
+ if (ObjectUtil.isNotNull(financeFine)) {
|
|
|
+ FinanceFineRefund financeFineRefund = FinanceFineRefund
|
|
|
+ .builder()
|
|
|
+ .fineId(financeFine.getId())
|
|
|
+ .refundAmount(financeFine.getRealFineAmount())
|
|
|
+ .status(NOT_RETURNED.getCode())
|
|
|
+ .build();
|
|
|
+ if (productionReturn.getReturnInvoice()) {
|
|
|
+ financeFineRefund.setRefundReason(RETURN_PRODUCTION_INVOICE.getCode());
|
|
|
+ } else {
|
|
|
+ financeFineRefund.setRefundReason(RETURN_PRODUCTION.getCode());
|
|
|
+ }
|
|
|
+ financeFineRefundService.saveIfNotExists(financeFineRefund);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -238,6 +287,7 @@ public class WorkNodeProcessable {
|
|
|
@Transactional
|
|
|
public boolean ending(WorkNodeCommit commit){
|
|
|
WorkFlowNodeInstance currentNode = workFlowNodeInstanceService.getById(commit.getInstanceNodeId());
|
|
|
+ //终止前节点控制前置处理。
|
|
|
beforeEnding(currentNode);
|
|
|
//只需将当前节点设置为终止状态。
|
|
|
workFlowNodeInstanceService.update(new LambdaUpdateWrapper<WorkFlowNodeInstance>().set(WorkFlowNodeInstance::getState,CLOSED)
|
|
@@ -457,6 +507,12 @@ public class WorkNodeProcessable {
|
|
|
// 删除节点任务
|
|
|
workTaskRecordService.update(new LambdaUpdateWrapper<WorkTaskRecord>().set(BaseEntity::getDeleted, true).eq(WorkTaskRecord::getInstanceId, currentInstanceNode.getId()));
|
|
|
break;
|
|
|
+ case PRODUCTION_RETURN:
|
|
|
+ // 产品退回流程拒绝后将申请记录改为拒绝状态
|
|
|
+ productionReturnService.update(new LambdaUpdateWrapper<ProductionReturn>().set(ProductionReturn::getStatus, REJECTION.getCode())
|
|
|
+ .eq(ProductionReturn::getId, currentInstanceNode.getBusinessId())
|
|
|
+ .eq(ProductionReturn::getDeleted, false));
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|