|
@@ -0,0 +1,90 @@
|
|
|
+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.dto.OrderFlowExampleDto;
|
|
|
+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.OrderService;
|
|
|
+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 OrderService orderService;
|
|
|
+
|
|
|
+ @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 = orderService.getById(Long.parseLong(id.toString()));
|
|
|
+ Assert.notNull(orderInfo, "未找到订单");
|
|
|
+
|
|
|
+ OrderFlowExampleDto orderFlowExample = new OrderFlowExampleDto();
|
|
|
+ orderFlowExample.setOrderId(orderInfo.getId());
|
|
|
+ orderFlowExample.setFlowId(flowId);
|
|
|
+ orderFlowExample.setFlowStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
|
+ orderFlowExampleService.add(orderFlowExample);
|
|
|
+
|
|
|
+ return orderInfo.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void end(Long flowId, Long businessId, JSONObject submitData) {
|
|
|
+ orderService.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);
|
|
|
+ }
|
|
|
+}
|