product_management/models/product_usage_log.json
Hermes Agent 24605f88e8 fix: datetime->timestamp for audit fields + fix sor.U/sor.I misuse in core.py and API dspy
- All 7 models: created_at/updated_at changed from datetime to timestamp type
  (DDL template auto-generates DEFAULT CURRENT_TIMESTAMP for timestamp type)
- core.py: fix all sor.U() calls passing 3 args (id must be in data dict)
- core.py: fix sor.I() misuse for INSERT (should be sor.C())
- API dspy updates: fix sor.U() 3-arg bug in category/product/type_config/resource/subscription/supplier
- product_resource_supplier_update.dspy: add missing updated_at field
2026-06-22 11:04:46 +08:00

216 lines
5.1 KiB
JSON

{
"summary": [
{
"name": "product_usage_log",
"title": "产品消费记录表",
"primary": [
"id"
],
"catelog": "relation"
}
],
"fields": [
{
"name": "id",
"title": "主键ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "product_id",
"title": "产品ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "subscription_id",
"title": "订购ID",
"type": "str",
"length": 32
},
{
"name": "user_id",
"title": "消费者用户ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "user_org_id",
"title": "消费者机构ID",
"type": "str",
"length": 32,
"nullable": "no"
},
{
"name": "product_resource_id",
"title": "产品资源绑定ID",
"type": "str",
"length": 32
},
{
"name": "supplier_org_id",
"title": "供应商机构ID",
"type": "str",
"length": 32
},
{
"name": "resource_type",
"title": "资源类型",
"type": "str",
"length": 32
},
{
"name": "resource_ref_id",
"title": "资源引用ID",
"type": "str",
"length": 32
},
{
"name": "used_amount",
"title": "消耗量",
"type": "double",
"length": 15,
"dec": 4,
"nullable": "no"
},
{
"name": "used_unit",
"title": "消耗单位",
"type": "str",
"length": 32
},
{
"name": "unit_cost",
"title": "单位成本",
"type": "double",
"length": 15,
"dec": 8,
"default": "0"
},
{
"name": "total_cost",
"title": "总成本",
"type": "double",
"length": 15,
"dec": 6,
"default": "0"
},
{
"name": "sell_price",
"title": "客户售价",
"type": "double",
"length": 15,
"dec": 6,
"default": "0"
},
{
"name": "billing_mode",
"title": "计费模式",
"type": "char",
"length": 1,
"nullable": "no"
},
{
"name": "source_ref_table",
"title": "来源表",
"type": "str",
"length": 64
},
{
"name": "source_ref_id",
"title": "来源记录ID",
"type": "str",
"length": 32
},
{
"name": "use_time",
"title": "消费时间",
"type": "datetime",
"nullable": "no"
},
{
"name": "created_at",
"title": "创建时间",
"type": "timestamp",
"nullable": "no"
}
],
"indexes": [
{
"name": "idx_pul_product",
"idxtype": "index",
"idxfields": [
"product_id"
]
},
{
"name": "idx_pul_subscription",
"idxtype": "index",
"idxfields": [
"subscription_id"
]
},
{
"name": "idx_pul_user",
"idxtype": "index",
"idxfields": [
"user_id",
"user_org_id"
]
},
{
"name": "idx_pul_supplier",
"idxtype": "index",
"idxfields": [
"supplier_org_id"
]
},
{
"name": "idx_pul_time",
"idxtype": "index",
"idxfields": [
"use_time"
]
},
{
"name": "idx_pul_source",
"idxtype": "index",
"idxfields": [
"source_ref_table",
"source_ref_id"
]
}
],
"codes": [
{
"field": "product_id",
"table": "product",
"valuefield": "id",
"textfield": "product_name"
},
{
"field": "supplier_org_id",
"table": "supplychain.suppliers",
"valuefield": "org_id",
"textfield": "supplier_name"
},
{
"field": "resource_type",
"table": "appcodes_kv",
"valuefield": "k",
"textfield": "v",
"cond": "parentid='resource_type'"
},
{
"field": "billing_mode",
"table": "appcodes_kv",
"valuefield": "k",
"textfield": "v",
"cond": "parentid='billing_mode'"
}
]
}