OrderDeleteFlow.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package com.sd.business.flow;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.fjhx.flow.core.FlowDelegate;
  4. import com.fjhx.flow.enums.FlowStatusEnum;
  5. import com.ruoyi.common.core.domain.BasePo;
  6. import com.ruoyi.common.utils.SecurityUtils;
  7. import com.sd.business.entity.order.po.OrderFlowExample;
  8. import com.sd.business.entity.order.po.OrderInfo;
  9. import com.sd.business.service.order.OrderFlowExampleService;
  10. import com.sd.business.service.order.OrderInfoService;
  11. import com.sd.framework.util.Assert;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import java.util.Date;
  15. /**
  16. * 发起订单删除流程
  17. */
  18. @Service
  19. public class OrderDeleteFlow extends FlowDelegate {
  20. @Autowired
  21. private OrderInfoService orderInfoService;
  22. @Autowired
  23. private OrderFlowExampleService orderFlowExampleService;
  24. @Override
  25. public String getFlowKey() {
  26. return "order_delete";
  27. }
  28. @Override
  29. public Long start(Long flowId, JSONObject submitData) {
  30. Object id = submitData.get("id");
  31. Assert.notNull(id, "订单Id不能为空");
  32. OrderInfo orderInfo = orderInfoService.getById(Long.parseLong(id.toString()));
  33. Assert.notNull(orderInfo, "未找到订单");
  34. OrderFlowExample orderFlowExample = new OrderFlowExample();
  35. orderFlowExample.setOrderId(orderInfo.getId());
  36. orderFlowExample.setFlowId(flowId);
  37. orderFlowExample.setFlowStatus(FlowStatusEnum.IN_PROGRESS.getKey());
  38. orderFlowExampleService.save(orderFlowExample);
  39. return orderInfo.getId();
  40. }
  41. @Override
  42. public void end(Long flowId, Long businessId, JSONObject submitData) {
  43. orderInfoService.deleteAndStore(businessId);
  44. orderFlowExampleService.update(q -> q.eq(OrderFlowExample::getOrderId, businessId)
  45. .eq(OrderFlowExample::getFlowId, flowId)
  46. .set(OrderFlowExample::getFlowStatus, FlowStatusEnum.PASS.getKey())
  47. .set(BasePo::getUpdateTime, new Date())
  48. .set(BasePo::getUpdateUser, SecurityUtils.getUserId()));
  49. }
  50. @Override
  51. public void returnToOriginator(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
  52. orderFlowExampleService.update(q -> q.eq(OrderFlowExample::getOrderId, businessId)
  53. .eq(OrderFlowExample::getFlowId, flowId)
  54. .set(OrderFlowExample::getFlowStatus, flowStatus.getKey())
  55. .set(BasePo::getUpdateTime, new Date())
  56. .set(BasePo::getUpdateUser, SecurityUtils.getUserId()));
  57. }
  58. @Override
  59. public void relaunch(Long flowId, Long businessId, FlowStatusEnum flowStatus, JSONObject submitData) {
  60. orderFlowExampleService.update(q -> q.eq(OrderFlowExample::getOrderId, businessId)
  61. .eq(OrderFlowExample::getFlowId, flowId)
  62. .set(OrderFlowExample::getFlowStatus, FlowStatusEnum.IN_PROGRESS.getKey())
  63. .set(BasePo::getUpdateTime, new Date())
  64. .set(BasePo::getUpdateUser, SecurityUtils.getUserId()));
  65. }
  66. @Override
  67. public void reject(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
  68. returnToOriginator(flowId, businessId, flowStatus);
  69. }
  70. @Override
  71. public void cancellation(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
  72. returnToOriginator(flowId, businessId, flowStatus);
  73. }
  74. }