根据如下代码定义,生成UML图 ```
2025-12-14
根据如下代码定义,生成UML图
```
class User:
"""基础用户类"""
def __init__(self):
self.user_id: str
self.email: str
self.password_hash: str
self.created_at: datetime
self.last_login: datetime
def login(self): pass
def logout(self): pass
def update_profile(self): pass
class Customer(User):
"""消费者,继承自 User"""
def __init__(self):
super().__init__()
self.shipping_addresses: List[Address]
self.order_history: List[Order]
self.cart: ShoppingCart # 1对1关系
self.payment_methods: List[PaymentMethod]
class Admin(User):
"""管理员,继承自 User"""
def __init__(self):
super().__init__()
self.role: str # e.g., 'super_admin', 'inventory_manager'
self.permissions: List[str]
def manage_product(self): pass
def manage_order(self): pass
class Address:
"""地址对象"""
def __init__(self):
self.street: str
self.city: str
self.state: str
self.zip_code: str
self.country: str
class Category:
"""商品分类(如:'狗', '猫', '食品', '玩具')"""
def __init__(self):
self.category_id: str
self.name: str
self.description: str
self.parent_category: Category # 支持子分类
class ProductBase:
"""商品基类"""
def __init__(self):
self.product_id: str
self.name: str
self.description: str
self.price: Decimal
self.stock_quantity: int
self.category: Category
self.images: List[str]
self.is_active: bool
class Pet(ProductBase):
"""活体宠物,继承自商品基类"""
def __init__(self):
super().__init__()
self.breed: str # 品种
self.birth_date: date # 出生日期
self.gender: str # 性别
self.color: str
self.vaccination_status: bool # 疫苗状态
self.health_certificate: str # 健康证书URL
class PetSupply(ProductBase):
"""宠物用品/食品,继承自商品基类"""
def __init__(self):
super().__init__()
self.brand: str
self.weight: float
self.dimensions: str
self.expiration_date: date
class ShoppingCart:
"""购物车"""
def __init__(self):
self.cart_id: str
self.owner: Customer
self.items: List[CartItem]
self.updated_at: datetime
def add_item(self, product, quantity): pass
def remove_item(self, product_id): pass
def calculate_total(self): pass
def checkout(self): pass # 转换为 Order
class CartItem:
"""购物车中的单项"""
def __init__(self):
self.product: ProductBase
self.quantity: int
self.added_at: datetime
class Order:
"""正式订单"""
def __init__(self):
self.order_id: str
self.customer: Customer
self.items: List[OrderItem]
self.shipping_address: Address
self.status: OrderStatus # Enum: PENDING, PAID, SHIPPED, DELIVERED, CANCELLED
self.total_amount: Decimal
self.created_at: datetime
self.payment_details: Payment
def confirm_payment(self): pass
def ship_order(self): pass
def cancel_order(self): pass
class OrderItem:
"""订单内的商品快照"""
# 注意:这里不仅链接 Product,还要记录购买时的价格(防止后续商品改价影响历史订单)
def __init__(self):
self.product_id: str
self.product_name: str
self.quantity: int
self.unit_price_at_purchase: Decimal
class Payment:
"""支付记录"""
def __init__(self):
self.transaction_id: str
self.amount: Decimal
self.provider: str # e.g., 'Stripe', 'PayPal'
self.status: str
self.timestamp: datetime
```
思考过程
The user wants me to create a UML class diagram based on the Python code they provided. Let me analyze the classes and their relationships:
**Classes:**
1. **User** (base class)
- Attributes: user_id, email, password_hash, created_at, last_login
- Methods: login(), logout(), update_profile()
2. **Customer** (extends User)
- Attributes: shipping_addresses, order_history, cart, payment_methods
- Relationships: has ShoppingCart (1:1), has Address (1:*), has Order (1:*)
3. **Admin** (extends User)
- Attributes: role, permissions
- Methods: manage_product(), manage_order()
4. **Address**
- Attributes: street, city, state, zip_code, country
5. **Category**
- Attributes: category_id, name, description, parent_category
- Self-referencing relationship (parent_category)
6. **ProductBase** (base class)
- Attributes: product_id, name, description, price, stock_quantity, category, images, is_active
- Relationships: has Category
7. **Pet** (extends ProductBase)
- Attributes: breed, birth_date, gender, color, vaccination_status, health_certificate
8. **PetSupply** (extends ProductBase)
- Attributes: brand, weight, dimensions, expiration_date
9. **ShoppingCart**
- Attributes: cart_id, owner, items, updated_at
- Methods: add_item(), remove_item(), calculate_total(), checkout()
- Relationships: owned by Customer (1:1), contains CartItem (1:*)
10. **CartItem**
- Attributes: product, quantity, added_at
- Relationships: references ProductBase
11. **Order**
- Attributes: order_id, customer, items, shipping_address, status, total_amount, created_at, payment_details
- Methods: confirm_payment(), ship_order(), cancel_order()
- Relationships: belongs to Customer, has Address, contains OrderItem (*), has Payment
12. **OrderItem**
- Attributes: product_id, product_name, quantity, unit_price_at_purchase
13. **Payment**
- Attributes: transaction_id, amount, provider, status, timestamp
**Relationships:**
- User <|-- Customer (inheritance)
- User <|-- Admin (inheritance)
- ProductBase <|-- Pet (inheritance)
- ProductBase <|-- PetSupply (inheritance)
- Customer "1" -- "1" ShoppingCart
- Customer "1" -- "*" Order
- Customer "1" -- "*" Address
- Order "*" -- "1" Address
- Order "*" -- "*" OrderItem
- Order "1" -- "1" Payment
- ShoppingCart "1" -- "*" CartItem
- CartItem "*" -- "1" ProductBase
- ProductBase "*" -- "1" Category
- Category "1" -- "0..1" Category (self-reference for parent_category)
For the diagram layout, I'll position User at the top center with Customer and Admin branching below. Address goes on the left, while Category and ProductBase occupy the middle-left with their subclasses Pet and PetSupply nested underneath. The right side will display ShoppingCart connected to CartItem, alongside Order with its OrderItem and Payment associations. I'll use a standard UML class diagram format to represent these relationships clearly. diagram style with:
- Classes as rectangles with 3 compartments (name, attributes, methods)
- Inheritance arrows (hollow triangle)
- Association lines with multiplicity
I need to organize this layout efficiently across the viewport:
Left section (x=40-200):
- User positioned at top
- Customer and Admin below
- Address nearby
Center section (x=250-450):
- Category, ProductBase, Pet, PetSupply stacked vertically
Right section (x=500-700):
- ShoppingCart with CartItem
- Order with OrderItem
- Payment
Given the number of classes involved, I'll use a compact UML style with distinct sections for class names, attributes, and methods.
我来根据这段代码生成UML类图。让我先分析一下结构:
**类层次结构:**
1. **用户模块**:User(基类)→ Customer, Admin(继承)
2. **商品模块**:ProductBase(基类)→ Pet, PetSupply(继承)
3. **购物模块**:ShoppingCart, CartItem
4. **订单模块**:Order, OrderItem, Payment
5. **辅助类**:Address, Category
**关系:**
- 继承:Customer/Admin ← User,Pet/PetSupply ← ProductBase
- 组合/关联:Customer ↔ ShoppingCart (1:1),ShoppingCart → CartItem (1:*),Order → OrderItem (1:*) 等
- Category 自引用(支持子分类)
我将按模块分区布局,避免连线交叉:
```xml
<mxGraphModel dx="1200" dy="800" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<!-- User Base Class -->
<mxCell id="user" value="<b>User</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#dae8fc;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="40" y="40" width="180" height="190" as="geometry"/>
</mxCell>
<mxCell id="user_attr" value="- user_id: str
- email: str
- password_hash: str
- created_at: datetime
- last_login: datetime" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="user">
<mxGeometry y="26" width="180" height="90" as="geometry"/>
</mxCell>
<mxCell id="user_line" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" vertex="1" parent="user">
<mxGeometry y="116" width="180" height="8" as="geometry"/>
</mxCell>
<mxCell id="user_method" value="+ login()
+ logout()
+ update_profile()" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="user">
<mxGeometry y="124" width="180" height="66" as="geometry"/>
</mxCell>
<!-- Customer Class -->
<mxCell id="customer" value="<b>Customer</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#dae8fc;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="40" y="300" width="180" height="100" as="geometry"/>
</mxCell>
<mxCell id="customer_attr" value="- shipping_addresses: List[Address]
- order_history: List[Order]
- cart: ShoppingCart
- payment_methods: List" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;fontSize=10;" vertex="1" parent="customer">
<mxGeometry y="26" width="180" height="74" as="geometry"/>
</mxCell>
<!-- Admin Class -->
<mxCell id="admin" value="<b>Admin</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#dae8fc;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="40" y="440" width="180" height="130" as="geometry"/>
</mxCell>
<mxCell id="admin_attr" value="- role: str
- permissions: List[str]" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="admin">
<mxGeometry y="26" width="180" height="40" as="geometry"/>
</mxCell>
<mxCell id="admin_line" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" vertex="1" parent="admin">
<mxGeometry y="66" width="180" height="8" as="geometry"/>
</mxCell>
<mxCell id="admin_method" value="+ manage_product()
+ manage_order()" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="admin">
<mxGeometry y="74" width="180" height="56" as="geometry"/>
</mxCell>
<!-- Address Class -->
<mxCell id="address" value="<b>Address</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#fff2cc;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#d6b656;" vertex="1" parent="1">
<mxGeometry x="260" y="300" width="150" height="120" as="geometry"/>
</mxCell>
<mxCell id="address_attr" value="- street: str
- city: str
- state: str
- zip_code: str
- country: str" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="address">
<mxGeometry y="26" width="150" height="94" as="geometry"/>
</mxCell>
<!-- Category Class -->
<mxCell id="category" value="<b>Category</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#e1d5e7;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#9673a6;" vertex="1" parent="1">
<mxGeometry x="260" y="40" width="160" height="110" as="geometry"/>
</mxCell>
<mxCell id="category_attr" value="- category_id: str
- name: str
- description: str
- parent_category: Category" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;fontSize=11;" vertex="1" parent="category">
<mxGeometry y="26" width="160" height="84" as="geometry"/>
</mxCell>
<!-- Category Self-Reference -->
<mxCell id="cat_self" style="edgeStyle=orthogonalEdgeStyle;curved=1;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=open;endFill=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="category_attr" target="category">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="450" y="93"/>
<mxPoint x="450" y="20"/>
<mxPoint x="340" y="20"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="cat_self_label" value="parent" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="440" y="40" width="40" height="20" as="geometry"/>
</mxCell>
<!-- ProductBase Class -->
<mxCell id="productbase" value="<b>ProductBase</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#d5e8d4;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#82b366;" vertex="1" parent="1">
<mxGeometry x="460" y="40" width="180" height="180" as="geometry"/>
</mxCell>
<mxCell id="productbase_attr" value="- product_id: str
- name: str
- description: str
- price: Decimal
- stock_quantity: int
- category: Category
- images: List[str]
- is_active: bool" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="productbase">
<mxGeometry y="26" width="180" height="154" as="geometry"/>
</mxCell>
<!-- Pet Class -->
<mxCell id="pet" value="<b>Pet</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#d5e8d4;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#82b366;" vertex="1" parent="1">
<mxGeometry x="460" y="290" width="180" height="150" as="geometry"/>
</mxCell>
<mxCell id="pet_attr" value="- breed: str
- birth_date: date
- gender: str
- color: str
- vaccination_status: bool
- health_certificate: str" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="pet">
<mxGeometry y="26" width="180" height="124" as="geometry"/>
</mxCell>
<!-- PetSupply Class -->
<mxCell id="petsupply" value="<b>PetSupply</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#d5e8d4;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#82b366;" vertex="1" parent="1">
<mxGeometry x="460" y="480" width="180" height="100" as="geometry"/>
</mxCell>
<mxCell id="petsupply_attr" value="- brand: str
- weight: float
- dimensions: str
- expiration_date: date" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="petsupply">
<mxGeometry y="26" width="180" height="74" as="geometry"/>
</mxCell>
<!-- ShoppingCart Class -->
<mxCell id="cart" value="<b>ShoppingCart</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#f8cecc;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#b85450;" vertex="1" parent="1">
<mxGeometry x="680" y="40" width="170" height="180" as="geometry"/>
</mxCell>
<mxCell id="cart_attr" value="- cart_id: str
- owner: Customer
- items: List[CartItem]
- updated_at: datetime" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="cart">
<mxGeometry y="26" width="170" height="70" as="geometry"/>
</mxCell>
<mxCell id="cart_line" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" vertex="1" parent="cart">
<mxGeometry y="96" width="170" height="8" as="geometry"/>
</mxCell>
<mxCell id="cart_method" value="+ add_item()
+ remove_item()
+ calculate_total()
+ checkout()" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="cart">
<mxGeometry y="104" width="170" height="76" as="geometry"/>
</mxCell>
<!-- CartItem Class -->
<mxCell id="cartitem" value="<b>CartItem</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#f8cecc;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#b85450;" vertex="1" parent="1">
<mxGeometry x="680" y="250" width="170" height="90" as="geometry"/>
</mxCell>
<mxCell id="cartitem_attr" value="- product: ProductBase
- quantity: int
- added_at: datetime" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="cartitem">
<mxGeometry y="26" width="170" height="64" as="geometry"/>
</mxCell>
<!-- Order Class -->
<mxCell id="order" value="<b>Order</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#ffe6cc;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#d79b00;" vertex="1" parent="1">
<mxGeometry x="890" y="40" width="200" height="230" as="geometry"/>
</mxCell>
<mxCell id="order_attr" value="- order_id: str
- customer: Customer
- items: List[OrderItem]
- shipping_address: Address
- status: OrderStatus
- total_amount: Decimal
- created_at: datetime
- payment_details: Payment" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="order">
<mxGeometry y="26" width="200" height="130" as="geometry"/>
</mxCell>
<mxCell id="order_line" value="" style="line;strokeWidth=1;fillColor=none;align=left;verticalAlign=middle;spacingTop=-1;spacingLeft=3;spacingRight=3;rotatable=0;labelPosition=right;points=[];portConstraint=eastwest;" vertex="1" parent="order">
<mxGeometry y="156" width="200" height="8" as="geometry"/>
</mxCell>
<mxCell id="order_method" value="+ confirm_payment()
+ ship_order()
+ cancel_order()" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="order">
<mxGeometry y="164" width="200" height="66" as="geometry"/>
</mxCell>
<!-- OrderItem Class -->
<mxCell id="orderitem" value="<b>OrderItem</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#ffe6cc;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#d79b00;" vertex="1" parent="1">
<mxGeometry x="890" y="300" width="200" height="110" as="geometry"/>
</mxCell>
<mxCell id="orderitem_attr" value="- product_id: str
- product_name: str
- quantity: int
- unit_price_at_purchase: Decimal" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="orderitem">
<mxGeometry y="26" width="200" height="84" as="geometry"/>
</mxCell>
<!-- Payment Class -->
<mxCell id="payment" value="<b>Payment</b>" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=#ffe6cc;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;strokeColor=#d79b00;" vertex="1" parent="1">
<mxGeometry x="890" y="450" width="200" height="130" as="geometry"/>
</mxCell>
<mxCell id="payment_attr" value="- transaction_id: str
- amount: Decimal
- provider: str
- status: str
- timestamp: datetime" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;" vertex="1" parent="payment">
<mxGeometry y="26" width="200" height="104" as="geometry"/>
</mxCell>
<!-- Inheritance: Customer extends User -->
<mxCell id="ext1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;endFill=0;endSize=12;" edge="1" parent="1" source="customer" target="user">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<!-- Inheritance: Admin extends User -->
<mxCell id="ext2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;endFill=0;endSize=12;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="admin" target="user">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="130" y="420"/>
<mxPoint x="10" y="420"/>
<mxPoint x="10" y="135"/>
<mxPoint x="40" y="135"/>
</Array>
</mxGeometry>
</mxCell>
<!-- Inheritance: Pet extends ProductBase -->
<mxCell id="ext3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;endFill=0;endSize=12;" edge="1" parent="1" source="pet" target="productbase">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<!-- Inheritance: PetSupply extends ProductBase -->
<mxCell id="ext4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=block;endFill=0;endSize=12;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="petsupply" target="productbase">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="550" y="460"/>
<mxPoint x="580" y="460"/>
<mxPoint x="580" y="250"/>
<mxPoint x="550" y="250"/>
</Array>
</mxGeometry>
</mxCell>
<!-- Association: ProductBase - Category -->
<mxCell id="assoc1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=open;endFill=0;startArrow=none;dashed=0;" edge="1" parent="1" source="productbase" target="category">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="assoc1_label" value="* 1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="420" y="105" width="40" height="20" as="geometry"/>
</mxCell>
<!-- Association: Customer - ShoppingCart (1:1) -->
<mxCell id="assoc2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=diamondThin;endFill=1;startArrow=none;" edge="1" parent="1" source="cart" target="customer">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="765" y="250"/>
<mxPoint x="245" y="250"/>
<mxPoint x="245" y="350"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="assoc2_label1" value="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="220" y="340" width="20" height="20" as="geometry"/>
</mxCell>
<mxCell id="assoc2_label2" value="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="755" y="220" width="20" height="20" as="geometry"/>
</mxCell>
<!-- Association: ShoppingCart - CartItem (1:*) -->
<mxCell id="assoc3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=diamondThin;endFill=1;startArrow=none;" edge="1" parent="1" source="cartitem" target="cart">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="assoc3_label" value="1 *" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="745" y="220" width="40" height="20" as="geometry"/>
</mxCell>
<!-- Association: CartItem - ProductBase -->
<mxCell id="assoc4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=open;endFill=0;dashed=0;" edge="1" parent="1" source="cartitem" target="productbase">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="660" y="295"/>
<mxPoint x="660" y="130"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="assoc4_label" value="* 1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="630" y="150" width="40" height="20" as="geometry"/>
</mxCell>
<!-- Association: Customer - Order (1:*) -->
<mxCell id="assoc5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=open;endFill=0;dashed=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="customer" target="order_attr">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="230" y="350"/>
<mxPoint x="230" y="10"/>
<mxPoint x="870" y="10"/>
<mxPoint x="870" y="131"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="assoc5_label" value="1 *" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="860" y="90" width="40" height="20" as="geometry"/>
</mxCell>
<!-- Association: Order - OrderItem (1:*) -->
<mxCell id="assoc6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=diamondThin;endFill=1;startArrow=none;" edge="1" parent="1" source="orderitem" target="order">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="assoc6_label" value="1 *" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="970" y="270" width="40" height="20" as="geometry"/>
</mxCell>
<!-- Association: Order - Payment (1:1) -->
<mxCell id="assoc7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=open;endFill=0;dashed=0;" edge="1" parent="1" source="order" target="payment">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="1110" y="155"/>
<mxPoint x="1110" y="515"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="assoc7_label" value="1 1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="1090" y="420" width="40" height="20" as="geometry"/>
</mxCell>
<!-- Association: Customer - Address (1:*) -->
<mxCell id="assoc8" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=open;endFill=0;dashed=0;" edge="1" parent="1" source="customer" target="address">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="assoc8_label" value="1 *" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="220" y="355" width="40" height="20" as="geometry"/>
</mxCell>
<!-- Association: Order - Address -->
<mxCell id="assoc9" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=open;endFill=0;dashed=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" source="order" target="address">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="990" y="600"/>
<mxPoint x="335" y="600"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="assoc9_label" value="* 1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="335" y="420" width="40" height="20" as="geometry"/>
</mxCell>
<!-- Legend -->
<mxCell id="legend_title" value="<b>图例</b>" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=11;" vertex="1" parent="1">
<mxGeometry x="40" y="590" width="60" height="20" as="geometry"/>
</mxCell>
<mxCell id="legend_inherit" value="" style="endArrow=block;endFill=0;endSize=12;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="40" y="625" as="sourcePoint"/>
<mxPoint x="100" y="625" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="legend_inherit_text" value="继承" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="110" y="615" width="40" height="20" as="geometry"/>
</mxCell>
<mxCell id="legend_assoc" value="" style="endArrow=open;endFill=0;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="160" y="625" as="sourcePoint"/>
<mxPoint x="220" y="625" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="legend_assoc_text" value="关联" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="230" y="615" width="40" height="20" as="geometry"/>
</mxCell>
<mxCell id="legend_comp" value="" style="endArrow=diamondThin;endFill=1;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="280" y="625" as="sourcePoint"/>
<mxPoint x="340" y="625" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="legend_comp_text" value="组合" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="350" y="615" width="40" height="20" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
绘制时序图
思考过程
用户希望我根据之前的代码定义绘制时序图。时序图主要展示对象之间的交互顺序。
基于这个宠物商店系统,我可以绘制一个典型的购物流程时序图,包括:
1. 客户登录
2. 浏览商品
3. 添加到购物车
4. 结算
5. 创建订单
6. 支付
7. 订单确认
参与者(Actors/Objects):
- Customer
- ShoppingCart
- ProductBase
- Order
- Payment
让我设计一个清晰的时序图布局:
- 顶部放置参与者(生命线)
- 从上到下展示消息流
- 使用矩形表示激活条
- 使用箭头表示消息
时序图的关键元素:
1. 参与者/对象(顶部的方框)
2. 生命线(垂直虚线)
3. 激活条(矩形)
4. 消息(水平箭头)
5. 返回消息(虚线箭头)
我将绘制一个完整的购物流程时序图。
我来为这个宠物商店系统绘制一个典型购物流程的时序图。
**时序图设计:**
- **参与者**:Customer、ShoppingCart、ProductBase、Order、Payment
- **流程**:登录 → 浏览商品 → 添加购物车 → 结算 → 创建订单 → 支付 → 确认
```xml
<mxGraphModel dx="1100" dy="800" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1200" pageHeight="900" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<!-- Title -->
<mxCell id="title" value="<b>宠物商店购物流程时序图</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;" vertex="1" parent="1">
<mxGeometry x="350" y="10" width="250" height="30" as="geometry"/>
</mxCell>
<!-- Actor: Customer -->
<mxCell id="actor_customer" value="Customer" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="55" y="50" width="30" height="60" as="geometry"/>
</mxCell>
<!-- Object: User -->
<mxCell id="obj_user" value="<b>:User</b>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="130" y="60" width="80" height="40" as="geometry"/>
</mxCell>
<!-- Object: ProductBase -->
<mxCell id="obj_product" value="<b>:ProductBase</b>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
<mxGeometry x="250" y="60" width="100" height="40" as="geometry"/>
</mxCell>
<!-- Object: ShoppingCart -->
<mxCell id="obj_cart" value="<b>:ShoppingCart</b>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" vertex="1" parent="1">
<mxGeometry x="390" y="60" width="100" height="40" as="geometry"/>
</mxCell>
<!-- Object: Order -->
<mxCell id="obj_order" value="<b>:Order</b>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="1">
<mxGeometry x="530" y="60" width="80" height="40" as="geometry"/>
</mxCell>
<!-- Object: Payment -->
<mxCell id="obj_payment" value="<b>:Payment</b>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="1">
<mxGeometry x="650" y="60" width="80" height="40" as="geometry"/>
</mxCell>
<!-- Object: Admin -->
<mxCell id="obj_admin" value="<b>:Admin</b>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1">
<mxGeometry x="770" y="60" width="80" height="40" as="geometry"/>
</mxCell>
<!-- Lifelines (dashed vertical lines) -->
<mxCell id="life_customer" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 2;strokeWidth=1;strokeColor=#999999;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="70" y="110" as="sourcePoint"/>
<mxPoint x="70" y="680" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="life_user" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 2;strokeWidth=1;strokeColor=#999999;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="170" y="100" as="sourcePoint"/>
<mxPoint x="170" y="680" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="life_product" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 2;strokeWidth=1;strokeColor=#999999;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="300" y="100" as="sourcePoint"/>
<mxPoint x="300" y="680" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="life_cart" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 2;strokeWidth=1;strokeColor=#999999;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="440" y="100" as="sourcePoint"/>
<mxPoint x="440" y="680" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="life_order" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 2;strokeWidth=1;strokeColor=#999999;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="570" y="100" as="sourcePoint"/>
<mxPoint x="570" y="680" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="life_payment" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 2;strokeWidth=1;strokeColor=#999999;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="690" y="100" as="sourcePoint"/>
<mxPoint x="690" y="680" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="life_admin" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 2;strokeWidth=1;strokeColor=#999999;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="810" y="100" as="sourcePoint"/>
<mxPoint x="810" y="680" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Activation Bars -->
<mxCell id="act_user1" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="165" y="130" width="10" height="50" as="geometry"/>
</mxCell>
<mxCell id="act_product1" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
<mxGeometry x="295" y="200" width="10" height="50" as="geometry"/>
</mxCell>
<mxCell id="act_cart1" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" vertex="1" parent="1">
<mxGeometry x="435" y="270" width="10" height="50" as="geometry"/>
</mxCell>
<mxCell id="act_cart2" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" vertex="1" parent="1">
<mxGeometry x="435" y="340" width="10" height="50" as="geometry"/>
</mxCell>
<mxCell id="act_cart3" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" vertex="1" parent="1">
<mxGeometry x="435" y="410" width="10" height="70" as="geometry"/>
</mxCell>
<mxCell id="act_order1" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="1">
<mxGeometry x="565" y="430" width="10" height="50" as="geometry"/>
</mxCell>
<mxCell id="act_order2" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="1">
<mxGeometry x="565" y="500" width="10" height="70" as="geometry"/>
</mxCell>
<mxCell id="act_payment1" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="1">
<mxGeometry x="685" y="520" width="10" height="50" as="geometry"/>
</mxCell>
<mxCell id="act_order3" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="1">
<mxGeometry x="565" y="590" width="10" height="50" as="geometry"/>
</mxCell>
<mxCell id="act_admin1" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1">
<mxGeometry x="805" y="610" width="10" height="50" as="geometry"/>
</mxCell>
<!-- Message 1: login() -->
<mxCell id="msg1" value="1: login()" style="endArrow=classic;html=1;rounded=0;strokeColor=#333333;fontStyle=0;fontSize=11;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="70" y="140" as="sourcePoint"/>
<mxPoint x="165" y="140" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 1.1: return success -->
<mxCell id="msg1_ret" value="1.1: 登录成功" style="endArrow=open;html=1;rounded=0;dashed=1;strokeColor=#666666;fontSize=10;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="165" y="170" as="sourcePoint"/>
<mxPoint x="70" y="170" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 2: browse products -->
<mxCell id="msg2" value="2: 浏览商品(category)" style="endArrow=classic;html=1;rounded=0;strokeColor=#333333;fontSize=11;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="70" y="210" as="sourcePoint"/>
<mxPoint x="295" y="210" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 2.1: return product list -->
<mxCell id="msg2_ret" value="2.1: List[ProductBase]" style="endArrow=open;html=1;rounded=0;dashed=1;strokeColor=#666666;fontSize=10;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="295" y="240" as="sourcePoint"/>
<mxPoint x="70" y="240" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 3: add_item() -->
<mxCell id="msg3" value="3: add_item(product, qty)" style="endArrow=classic;html=1;rounded=0;strokeColor=#333333;fontSize=11;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="70" y="280" as="sourcePoint"/>
<mxPoint x="435" y="280" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 3.1: return -->
<mxCell id="msg3_ret" value="3.1: CartItem 已添加" style="endArrow=open;html=1;rounded=0;dashed=1;strokeColor=#666666;fontSize=10;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="435" y="310" as="sourcePoint"/>
<mxPoint x="70" y="310" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 4: calculate_total() -->
<mxCell id="msg4" value="4: calculate_total()" style="endArrow=classic;html=1;rounded=0;strokeColor=#333333;fontSize=11;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="70" y="350" as="sourcePoint"/>
<mxPoint x="435" y="350" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 4.1: return total -->
<mxCell id="msg4_ret" value="4.1: total_amount" style="endArrow=open;html=1;rounded=0;dashed=1;strokeColor=#666666;fontSize=10;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="435" y="380" as="sourcePoint"/>
<mxPoint x="70" y="380" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 5: checkout() -->
<mxCell id="msg5" value="5: checkout()" style="endArrow=classic;html=1;rounded=0;strokeColor=#333333;fontSize=11;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="70" y="420" as="sourcePoint"/>
<mxPoint x="435" y="420" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 5.1: create Order -->
<mxCell id="msg5_1" value="5.1: <<create>> Order" style="endArrow=classic;html=1;rounded=0;strokeColor=#333333;fontSize=11;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="445" y="440" as="sourcePoint"/>
<mxPoint x="565" y="440" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 5.2: return order -->
<mxCell id="msg5_ret" value="5.2: Order 已创建" style="endArrow=open;html=1;rounded=0;dashed=1;strokeColor=#666666;fontSize=10;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="435" y="470" as="sourcePoint"/>
<mxPoint x="70" y="470" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 6: confirm_payment() -->
<mxCell id="msg6" value="6: confirm_payment()" style="endArrow=classic;html=1;rounded=0;strokeColor=#333333;fontSize=11;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="70" y="510" as="sourcePoint"/>
<mxPoint x="565" y="510" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 6.1: process payment -->
<mxCell id="msg6_1" value="6.1: process(amount)" style="endArrow=classic;html=1;rounded=0;strokeColor=#333333;fontSize=11;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="575" y="530" as="sourcePoint"/>
<mxPoint x="685" y="530" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 6.2: payment success -->
<mxCell id="msg6_2" value="6.2: 支付成功" style="endArrow=open;html=1;rounded=0;dashed=1;strokeColor=#666666;fontSize=10;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="685" y="560" as="sourcePoint"/>
<mxPoint x="575" y="560" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 6.3: return confirmed -->
<mxCell id="msg6_ret" value="6.3: 订单已确认 (PAID)" style="endArrow=open;html=1;rounded=0;dashed=1;strokeColor=#666666;fontSize=10;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="565" y="580" as="sourcePoint"/>
<mxPoint x="70" y="580" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 7: ship_order() -->
<mxCell id="msg7" value="7: ship_order()" style="endArrow=classic;html=1;rounded=0;strokeColor=#9673a6;fontSize=11;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="810" y="620" as="sourcePoint"/>
<mxPoint x="575" y="620" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Message 7.1: status updated -->
<mxCell id="msg7_ret" value="7.1: status = SHIPPED" style="endArrow=open;html=1;rounded=0;dashed=1;strokeColor=#666666;fontSize=10;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="575" y="650" as="sourcePoint"/>
<mxPoint x="810" y="650" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Alt Fragment Box -->
<mxCell id="alt_box" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;strokeColor=#666666;strokeWidth=1;dashed=0;" vertex="1" parent="1">
<mxGeometry x="50" y="500" width="660" height="90" as="geometry"/>
</mxCell>
<mxCell id="alt_label" value="<b>alt</b>" style="text;html=1;strokeColor=none;fillColor=#f5f5f5;align=center;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="50" y="500" width="30" height="20" as="geometry"/>
</mxCell>
<mxCell id="alt_cond" value="[支付成功]" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=10;fontStyle=2;" vertex="1" parent="1">
<mxGeometry x="90" y="500" width="80" height="20" as="geometry"/>
</mxCell>
<!-- Note -->
<mxCell id="note1" value="订单状态流转:
PENDING → PAID → SHIPPED → DELIVERED" style="shape=note;whiteSpace=wrap;html=1;size=14;verticalAlign=top;align=left;spacingTop=5;spacingLeft=5;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="720" y="280" width="160" height="60" as="geometry"/>
</mxCell>
<!-- Note connector -->
<mxCell id="note1_conn" value="" style="endArrow=none;dashed=1;html=1;strokeColor=#999999;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="720" y="320" as="sourcePoint"/>
<mxPoint x="575" y="460" as="targetPoint"/>
</mxGeometry>
</mxCell>
<!-- Legend -->
<mxCell id="legend_box" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#cccccc;" vertex="1" parent="1">
<mxGeometry x="720" y="150" width="150" height="110" as="geometry"/>
</mxCell>
<mxCell id="legend_title" value="<b>图例</b>" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=11;" vertex="1" parent="1">
<mxGeometry x="730" y="155" width="60" height="20" as="geometry"/>
</mxCell>
<mxCell id="legend_sync" value="" style="endArrow=classic;html=1;rounded=0;strokeColor=#333333;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="730" y="190" as="sourcePoint"/>
<mxPoint x="790" y="190" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="legend_sync_text" value="同步调用" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="795" y="180" width="60" height="20" as="geometry"/>
</mxCell>
<mxCell id="legend_ret" value="" style="endArrow=open;html=1;rounded=0;dashed=1;strokeColor=#666666;" edge="1" parent="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="730" y="215" as="sourcePoint"/>
<mxPoint x="790" y="215" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="legend_ret_text" value="返回" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="795" y="205" width="60" height="20" as="geometry"/>
</mxCell>
<mxCell id="legend_act" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="750" y="235" width="10" height="20" as="geometry"/>
</mxCell>
<mxCell id="legend_act_text" value="激活条" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=10;" vertex="1" parent="1">
<mxGeometry x="795" y="230" width="60" height="20" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>