# 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