Commit 2d756946 authored by zhengyi's avatar zhengyi

费用申请业务校验拦截调整

parent 8544e562
......@@ -40,7 +40,6 @@ public enum OrderApprovalTypeEnum {
DISCOUNT_APPLY_BATCH(31, "批量优惠申请", Arrays.asList(1, 2, 6, 11, 14, 23, 28, 32)), // 拆单申请/合单申请/订单修改/退仓/撤销拆单审批/优惠申请(当前商品有在途申请)/批量管理折扣申请(当前商品有在途申请)/管理优惠(当前商品有在途申请)
ADMIN_DISCOUNT_BATCH(32, "批量管理折扣申请", Arrays.asList(1, 2, 6, 11, 14, 23, 28, 31)), // 拆单申请/合单申请/订单修改/退仓/撤销拆单审批/优惠申请(当前商品有在途申请)/批量优惠申请(当前商品有在途申请)/管理优惠(当前商品有在途申请)
//分拣
sorting(50, "分拣审批", Arrays.asList(6, 11, 13, 14, 22, 23, 28)), // 自编号全部申请互斥,跟原本一致,不修改, 自编号下订单除拆单申请/合单申请/调仓申请/订单修改/入仓申请/退仓申请外,其他申请不受限制,允许封柜反审批
......
package cn.iocoder.yudao.module.order.service.order.impl;
import cn.iocoder.yudao.framework.apollo.core.event.Order.OrderApprovalTypeCheckEvent;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
......@@ -21,6 +22,7 @@ import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderFeeApplication.OrderFeeApplicationDO;
import cn.iocoder.yudao.module.order.dal.mysql.orderFeeApplication.OrderFeeApplicationMapper;
import cn.iocoder.yudao.module.order.enums.ApprovalResultStatusEnum;
import cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum;
import cn.iocoder.yudao.module.order.enums.OrderApprovalTypeResultEnum;
import cn.iocoder.yudao.module.order.service.approval.OrderApprovalService;
import cn.iocoder.yudao.module.order.service.order.OrderBusinessService;
......@@ -38,6 +40,7 @@ import cn.iocoder.yudao.module.wealth.service.receivable.ReceivableService;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableCreateReqVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -49,8 +52,9 @@ import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.FEE_APPLICATION_NOT_EXISTS;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.ORDER_FEE_APPLICATION_EXIST;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.ORDER_UPDATE;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.expense_apply;
/**
* 订单费用申请 Service 实现类
......@@ -90,6 +94,8 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
private CurrencyService currencyService;
@Resource
private OrderApprovalService orderApprovalService;
@Resource
private ApplicationContext applicationContext;
@Transactional
@Override
......@@ -117,8 +123,7 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
//创建审批流
OrderDO orderDO = orderService.selectOne(OrderDO::getOrderId, createReqVO.getOrderId());
String bpmProcessId = bpmCreateServiceFactory.createBmp(userId, feeApplication.getId(), WorkFlowEmus.ORDER_FREE_APPLY.getKey(), orderDO.getOrderNo(), createReqVO.getCopyUserId());
Integer auditType = OrderApprovalTypeResultEnum.expense_apply_processing.getType();
orderService.updateStatus(orderDO.getOrderId(), null, null, null, null, null, auditType, OrderApprovalTypeResultEnum.expense_apply_processing.getDesc());
orderService.updateStatus(orderDO.getOrderId(), null, null, null, null, null, OrderApprovalTypeResultEnum.expense_apply_processing.getType(), OrderApprovalTypeResultEnum.expense_apply_processing.getDesc());
feeApplication.setBpmProcessId(bpmProcessId);
feeApplicationMapper.updateById(feeApplication);
DictDataRespDTO dictDataFromCache = DictFrameworkUtils.getDictDataFromCache(DictTypeConstants.RECEIVABLE_FEE_TYPE, String.valueOf(createReqVO.getFeeType()));
......@@ -143,12 +148,21 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
@Override
@Transactional
public void createFeeBatchApplication(OrderFeeBatchApplicationCreateReqVO createReqVO) {
LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapperX<OrderApprovalDO>()
.eq(OrderApprovalDO::getOrderId, createReqVO.getOrderId())
.eq(OrderApprovalDO::getType, 41)
.eq(OrderApprovalDO::getStatus, ApprovalResultStatusEnum.processing.getValue());
if (orderApprovalService.count(lambdaQueryWrapper) > 0) {
throw exception(ORDER_FEE_APPLICATION_EXIST);
// OrderDO orderDO = orderService.getById(createReqVO.getOrderId());
// if (orderDO.getAuditType() != 0) {
// throw exception(ORDER_HAS_PROCESSING_APPROVAL, orderDO.getOrderNo());
// }
// LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapperX<OrderApprovalDO>()
// .eq(OrderApprovalDO::getOrderId, createReqVO.getOrderId())
// .eq(OrderApprovalDO::getType, expense_apply.getValue())
// .eq(OrderApprovalDO::getStatus, ApprovalResultStatusEnum.processing.getValue());
// if (orderApprovalService.count(lambdaQueryWrapper) > 0) {
// throw exception(ORDER_FEE_APPLICATION_EXIST);
// }
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(createReqVO.getOrderId(), null, expense_apply.getValue(), null, false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_IS_APPROVAL_IN_PROCESS);
}
// 批量插入费用
......@@ -166,7 +180,7 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
orderApprovalDO.setFollowUpSalesmanId(String.valueOf(SecurityFrameworkUtils.getLoginUserId()));
orderApprovalDO.setOrderId(createReqVO.getOrderId());
//批量费用申请
orderApprovalDO.setType(41);
orderApprovalDO.setType(expense_apply.getValue());
orderApprovalDO.setStatus(ApprovalResultStatusEnum.processing.getValue());
Long bpmProcessId = orderApprovalService.applyAndCreate(orderApprovalDO, WorkFlowEmus.ORDER_BATCH_FREE_APPLY, createReqVO.getCopyUserId());
......@@ -174,8 +188,7 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
//创建审批流
OrderDO orderDO = orderService.selectOne(OrderDO::getOrderId, createReqVO.getOrderId());
Integer auditType = OrderApprovalTypeResultEnum.expense_apply_processing.getType();
orderService.updateStatus(orderDO.getOrderId(), null, null, null, null, null, auditType, OrderApprovalTypeResultEnum.expense_apply_processing.getDesc());
orderService.updateStatus(orderDO.getOrderId(), null, null, null, null, null, OrderApprovalTypeResultEnum.expense_apply_processing.getType(), OrderApprovalTypeResultEnum.expense_apply_processing.getDesc());
//更新费用列表对应的流程申请ID
for (OrderFeeApplicationDO feeApplication : batchFeeList) {
......
......@@ -92,10 +92,6 @@ public class OrderFeeApplicationController {
return error(ORDER_FEE_APPLICATION_REPEAT_COMMIT);
}
redisHelper.expire(redisKey, 1, TimeUnit.MINUTES);
OrderDO orderDO = orderService.getById(createReqVO.getOrderId());
if (orderDO.getAuditType() != 0) {
throw exception(ORDER_HAS_PROCESSING_APPROVAL, orderDO.getOrderNo());
}
feeApplicationService.createFeeBatchApplication(createReqVO);
redisHelper.delete(redisKey);
return success(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment