M4-scene.yaml
5.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# M4 业务Saga场景编排 (v2.2:新增 SCENE_CREATE_EMPLOYEE/SCENE_MODIFY_EMPLOYEE;含 SCENE_AUDIT_ORDER 审核 + SCENE_DEMO_STEPTYPES 全 stepType 演示)
# M8页面模板绑定SceneId,一套模板对应完整端到端业务流程。
sceneModel:
globalConfig:
engine: saga
consistency: eventual
maxRetry: 2
sceneDefinitions:
- sceneId: SCENE_CREATE_ORDER
sceneName: 用户创建订单完整流程
aggregateScope: [CustomerAggregate, ProductAggregate, OrderAggregate]
permissionBind: [order_create]
flowSteps:
- stepType: readOnlyCheck
bindAggregate: CustomerAggregate
- stepType: bindCommand
bindAggregate: OrderAggregate
bindCommand: CreateOrder
- stepType: return
- sceneId: SCENE_MODIFY_ORDER_ADDR
sceneName: 修改订单收货地址
aggregateScope: [OrderAggregate]
permissionBind: [order_modify_addr]
flowSteps:
- stepType: bindCommand
bindAggregate: OrderAggregate
bindCommand: ModifyOrderDeliveryAddress
- stepType: return
- sceneId: SCENE_CANCEL_ORDER
sceneName: 取消订单、归还库存
aggregateScope: [OrderAggregate, ProductAggregate]
permissionBind: [order_cancel]
flowSteps:
- stepType: bindCommand
bindAggregate: OrderAggregate
bindCommand: CancelOrder
- stepType: return
- sceneId: SCENE_AUDIT_ORDER
sceneName: 审核订单(bizSteps 闭指令集程序演示)
aggregateScope: [OrderAggregate, EmployeeAggregate]
permissionBind: [order_audit]
flowSteps:
- stepType: bindCommand
bindAggregate: OrderAggregate
bindCommand: AuditOrder
- stepType: return
- sceneId: SCENE_CREATE_CUSTOMER
sceneName: 新增客户主数据
aggregateScope: [CustomerAggregate]
permissionBind: [customer_create]
flowSteps:
- stepType: bindCommand
bindAggregate: CustomerAggregate
bindCommand: CreateCustomer
- stepType: return
- sceneId: SCENE_MODIFY_CUSTOMER
sceneName: 修改客户信息
aggregateScope: [CustomerAggregate]
permissionBind: [customer_modify]
flowSteps:
- stepType: bindCommand
bindAggregate: CustomerAggregate
bindCommand: ModifyCustomerInfo
- stepType: return
- sceneId: SCENE_CREATE_PRODUCT
sceneName: 新增商品档案
aggregateScope: [ProductAggregate]
permissionBind: [product_create]
flowSteps:
- stepType: bindCommand
bindAggregate: ProductAggregate
bindCommand: CreateProduct
- stepType: return
- sceneId: SCENE_MODIFY_PRODUCT_PRICE
sceneName: 修改商品售价
aggregateScope: [ProductAggregate]
permissionBind: [product_modify_price]
flowSteps:
- stepType: bindCommand
bindAggregate: ProductAggregate
bindCommand: ModifyProductPrice
- stepType: return
- sceneId: SCENE_CREATE_EMPLOYEE
sceneName: 新增员工
aggregateScope: [EmployeeAggregate]
permissionBind: [employee_create]
flowSteps:
- stepType: bindCommand
bindAggregate: EmployeeAggregate
bindCommand: CreateEmployee
- stepType: return
- sceneId: SCENE_MODIFY_EMPLOYEE
sceneName: 修改员工信息
aggregateScope: [EmployeeAggregate]
permissionBind: [employee_modify]
flowSteps:
- stepType: bindCommand
bindAggregate: EmployeeAggregate
bindCommand: ModifyEmployee
- stepType: return
# 演示场景:集中展示新增的全部通用 stepType(控制流/数据/Saga/EDA/人工)。
# 不落库(无 bindCommand),字段为合成变量(非 M1 领域字段),故不绑定 M8 表单模板;
# 前端对无模板场景提供"无表单直接运行"入口(空 payload),引擎逐条通用解释 flowSteps 产出可读 trace。可安全删除。
- sceneId: SCENE_DEMO_STEPTYPES
sceneName: 演示:全部 stepType 通用解释
aggregateScope: [OrderAggregate]
permissionBind: [order_create]
flowSteps:
- stepType: start
triggerType: manual
- stepType: assign
assignments:
- { targetField: qty, expression: "3" }
- { targetField: unitPrice, expression: "100" }
- stepType: script
expression: "qty * unitPrice"
assignTo: amount
- stepType: condition
when: "amount > 200"
then:
- stepType: assign
targetField: tier
expression: "'BIG'"
else:
- stepType: assign
targetField: tier
expression: "'SMALL'"
- stepType: switch
switchOn: "tier"
cases:
- equals: "BIG"
steps:
- { stepType: assign, targetField: discount, expression: "0.9" }
- equals: "SMALL"
steps:
- { stepType: assign, targetField: discount, expression: "1" }
default:
- { stepType: assign, targetField: discount, expression: "1" }
- stepType: while
when: "qty > 0"
maxIterations: 10
body:
- { stepType: assign, targetField: qty, expression: "qty - 1" }
- stepType: parallel
branches:
- steps:
- { stepType: callService, method: GET, endpoint: /ext/credit-check }
- steps:
- { stepType: timer, delayMs: 500 }
- { stepType: waitEvent, waitEvent: OrderCreatedEvent }
- stepType: userTask
role: 主管
# 无表单演示场景不设 approveParam,审批网关自动放行;真实场景可设 approveParam 卡在待审批(缺 true 即 PENDING)
- stepType: retry
maxAttempts: 2
body:
- { stepType: script, expression: "amount * discount", assignTo: payable }
- stepType: return