123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package com.sd.business.flow;
- import com.alibaba.fastjson.JSONObject;
- import com.fjhx.flow.core.FlowDelegate;
- import com.fjhx.flow.enums.FlowStatusEnum;
- import com.ruoyi.common.core.domain.BasePo;
- import com.ruoyi.common.utils.SecurityUtils;
- import com.sd.business.entity.order.po.OrderFlowExample;
- import com.sd.business.entity.order.po.OrderInfo;
- import com.sd.business.service.order.OrderFlowExampleService;
- import com.sd.business.service.order.OrderInfoService;
- import com.sd.framework.util.Assert;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.Date;
- /**
- * 发起订单删除流程
- */
- @Service
- public class OrderDeleteFlow extends FlowDelegate {
- @Autowired
- private OrderInfoService orderInfoService;
- @Autowired
- private OrderFlowExampleService orderFlowExampleService;
- @Override
- public String getFlowKey() {
- return "order_delete";
- }
- @Override
- public Long start(Long flowId, JSONObject submitData) {
- Object id = submitData.get("id");
- Assert.notNull(id, "订单Id不能为空");
- OrderInfo orderInfo = orderInfoService.getById(Long.parseLong(id.toString()));
- Assert.notNull(orderInfo, "未找到订单");
- OrderFlowExample orderFlowExample = new OrderFlowExample();
- orderFlowExample.setOrderId(orderInfo.getId());
- orderFlowExample.setFlowId(flowId);
- orderFlowExample.setFlowStatus(FlowStatusEnum.IN_PROGRESS.getKey());
- orderFlowExampleService.save(orderFlowExample);
- return orderInfo.getId();
- }
- @Override
- public void end(Long flowId, Long businessId, JSONObject submitData) {
- orderInfoService.deleteAndStore(businessId);
- orderFlowExampleService.update(q -> q.eq(OrderFlowExample::getOrderId, businessId)
- .eq(OrderFlowExample::getFlowId, flowId)
- .set(OrderFlowExample::getFlowStatus, FlowStatusEnum.PASS.getKey())
- .set(BasePo::getUpdateTime, new Date())
- .set(BasePo::getUpdateUser, SecurityUtils.getUserId()));
- }
- @Override
- public void returnToOriginator(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
- orderFlowExampleService.update(q -> q.eq(OrderFlowExample::getOrderId, businessId)
- .eq(OrderFlowExample::getFlowId, flowId)
- .set(OrderFlowExample::getFlowStatus, flowStatus.getKey())
- .set(BasePo::getUpdateTime, new Date())
- .set(BasePo::getUpdateUser, SecurityUtils.getUserId()));
- }
- @Override
- public void relaunch(Long flowId, Long businessId, FlowStatusEnum flowStatus, JSONObject submitData) {
- orderFlowExampleService.update(q -> q.eq(OrderFlowExample::getOrderId, businessId)
- .eq(OrderFlowExample::getFlowId, flowId)
- .set(OrderFlowExample::getFlowStatus, FlowStatusEnum.IN_PROGRESS.getKey())
- .set(BasePo::getUpdateTime, new Date())
- .set(BasePo::getUpdateUser, SecurityUtils.getUserId()));
- }
- @Override
- public void reject(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
- returnToOriginator(flowId, businessId, flowStatus);
- }
- @Override
- public void cancellation(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
- returnToOriginator(flowId, businessId, flowStatus);
- }
- }
|