| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- package tables
-
- import (
- "time"
-
- "git.x2erp.com/qdy/go-db/sqldef"
- )
-
- func init() {
- sqldef.AddRegistration(func(r *sqldef.Registry) {
- tb := sqldef.NewTable("master_store", "店铺主数据表").
- ID("stor_id", 50).NotNull().Comment("店铺ID").End().
- String("tenant_id", 50).NotNull().Comment("租户ID").End().
- String("stor_code", 50).NotNull().Comment("店铺编码").End().
- String("stor_name", 200).NotNull().Comment("店铺名称").End().
- String("stor_short_name", 100).Comment("店铺简称").End().
- String("company_id", 50).NotNull().Comment("所属公司ID").End().
- String("store_ownership_type", 20).NotNull().Default("'DIRECT'").Comment("店铺所有权类型 DIRECT:直营 FRANCHISE:加盟").End().
- BigInt("business_model_id").Comment("经营模式ID(关联master_store_dimension表,type='business_model')").End().
- BigInt("store_tier_id").Comment("店铺定位ID(关联master_store_dimension表,type='store_tier')").End().
- BigInt("retail_format_id").Comment("零售业态ID(关联master_store_dimension表,type='retail_format')").End().
- BigInt("market_tier_id").Comment("市场层级ID(关联master_store_dimension表,type='market_tier')").End().
- BigInt("sales_channel_id").Comment("销售渠道ID(关联master_store_dimension表,type='sales_channel')").End().
- BigInt("region_id").Comment("区域ID(关联master_store_dimension表,type='region')").End().
- String("province", 50).Comment("省份").End().
- String("city", 50).Comment("城市").End().
- String("address", 500).Comment("详细地址").End().
- String("mall_code", 50).Comment("商场/商圈编码").End().
- String("mall_name", 200).Comment("商场/商圈名称").End().
- Decimal("store_area", 10, 2).Comment("店铺面积(平方米)").End().
- Date("opening_date").Comment("开业日期").End().
- String("manager_name", 50).Comment("店长姓名").End().
- String("contact_phone", 20).Comment("联系电话").End().
- Int("employee_count").Comment("员工人数").End().
- Int("inventory_capacity").Comment("库存容量(件数或SKU数)").End().
- String("stor_status", 20).Comment("店铺状态 (1营业中/2装修中/3停业/4关闭)").End().
- Bool("is_active").Comment("是否激活").End().
- Text("remark").Comment("备注").End().
- DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End().
- DateTime("updated_at").Comment("更新时间").End().
- Date("data_date").Comment("数据日期 (数据仓库快照)").End()
-
- tb.AddUniqueIndex("idx_stor_code", "stor_code")
- tb.AddIndex("idx_tenant_id", "tenant_id")
- tb.AddIndex("idx_business_model_id", "business_model_id")
- tb.AddIndex("idx_store_tier_id", "store_tier_id")
- tb.AddIndex("idx_retail_format_id", "retail_format_id")
- tb.AddIndex("idx_market_tier_id", "market_tier_id")
- tb.AddIndex("idx_sales_channel_id", "sales_channel_id")
- tb.AddIndex("idx_region_id", "region_id")
- tb.AddIndex("idx_stor_status", "stor_status")
- tb.AddIndex("idx_business_region_status", "business_model_id", "region_id", "stor_status")
- tb.AddIndex("idx_company_id", "company_id")
- tb.AddIndex("idx_store_ownership_type", "store_ownership_type")
-
- r.RegisterTable(tb.Build())
- })
- }
-
- type MasterStore struct {
- StorID string `gorm:"column:stor_id;type:varchar(50);not null;primaryKey;comment:店铺ID"`
- TenantID string `gorm:"column:tenant_id;type:varchar(50);not null;comment:租户ID"`
- StorCode string `gorm:"column:stor_code;type:varchar(50);not null;comment:店铺编码"`
- StorName string `gorm:"column:stor_name;type:varchar(200);not null;comment:店铺名称"`
- StorShortName string `gorm:"column:stor_short_name;type:varchar(100);comment:店铺简称"`
- CompanyID string `gorm:"column:company_id;type:varchar(50);not null;comment:所属公司ID"`
- StoreOwnershipType string `gorm:"column:store_ownership_type;type:varchar(20);not null;default:DIRECT;comment:店铺所有权类型 DIRECT:直营 FRANCHISE:加盟"`
- BusinessModelID int64 `gorm:"column:business_model_id;type:bigint;comment:经营模式ID"`
- StoreTierID int64 `gorm:"column:store_tier_id;type:bigint;comment:店铺定位ID"`
- RetailFormatID int64 `gorm:"column:retail_format_id;type:bigint;comment:零售业态ID"`
- MarketTierID int64 `gorm:"column:market_tier_id;type:bigint;comment:市场层级ID"`
- SalesChannelID int64 `gorm:"column:sales_channel_id;type:bigint;comment:销售渠道ID"`
- RegionID int64 `gorm:"column:region_id;type:bigint;comment:区域ID"`
- Province string `gorm:"column:province;type:varchar(50);comment:省份"`
- City string `gorm:"column:city;type:varchar(50);comment:城市"`
- Address string `gorm:"column:address;type:varchar(500);comment:详细地址"`
- MallCode string `gorm:"column:mall_code;type:varchar(50);comment:商场/商圈编码"`
- MallName string `gorm:"column:mall_name;type:varchar(200);comment:商场/商圈名称"`
- StoreArea float64 `gorm:"column:store_area;type:decimal(10,2);comment:店铺面积(平方米)"`
- OpeningDate *time.Time `gorm:"column:opening_date;type:date;comment:开业日期"`
- ManagerName string `gorm:"column:manager_name;type:varchar(50);comment:店长姓名"`
- ContactPhone string `gorm:"column:contact_phone;type:varchar(20);comment:联系电话"`
- EmployeeCount int32 `gorm:"column:employee_count;type:int;comment:员工人数"`
- InventoryCapacity int32 `gorm:"column:inventory_capacity;type:int;comment:库存容量(件数或SKU数)"`
- StorStatus string `gorm:"column:stor_status;type:varchar(20);comment:店铺状态 (1营业中/2装修中/3停业/4关闭)"`
- IsActive bool `gorm:"column:is_active;type:bool;comment:是否激活"`
- Remark string `gorm:"column:remark;type:text;comment:备注"`
- CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
- UpdatedAt *time.Time `gorm:"column:updated_at;comment:更新时间"`
- DataDate *time.Time `gorm:"column:data_date;type:date;comment:数据日期 (数据仓库快照)"`
- }
-
- type MasterStoreDB struct {
- StorID string `db:"stor_id" json:"storID"`
- TenantID string `db:"tenant_id" json:"tenantID"`
- StorCode string `db:"stor_code" json:"storCode"`
- StorName string `db:"stor_name" json:"storName"`
- StorShortName string `db:"stor_short_name" json:"storShortName"`
- CompanyID string `db:"company_id" json:"companyID"`
- StoreOwnershipType string `db:"store_ownership_type" json:"storeOwnershipType"`
- BusinessModelID int64 `db:"business_model_id" json:"businessModelID"`
- StoreTierID int64 `db:"store_tier_id" json:"storeTierID"`
- RetailFormatID int64 `db:"retail_format_id" json:"retailFormatID"`
- MarketTierID int64 `db:"market_tier_id" json:"marketTierID"`
- SalesChannelID int64 `db:"sales_channel_id" json:"salesChannelID"`
- RegionID int64 `db:"region_id" json:"regionID"`
- Province string `db:"province" json:"province"`
- City string `db:"city" json:"city"`
- Address string `db:"address" json:"address"`
- MallCode string `db:"mall_code" json:"mallCode"`
- MallName string `db:"mall_name" json:"mallName"`
- StoreArea float64 `db:"store_area" json:"storeArea"`
- OpeningDate *time.Time `db:"opening_date" json:"openingDate"`
- ManagerName string `db:"manager_name" json:"managerName"`
- ContactPhone string `db:"contact_phone" json:"contactPhone"`
- EmployeeCount int32 `db:"employee_count" json:"employeeCount"`
- InventoryCapacity int32 `db:"inventory_capacity" json:"inventoryCapacity"`
- StorStatus string `db:"stor_status" json:"storStatus"`
- IsActive bool `db:"is_active" json:"isActive"`
- Remark string `db:"remark" json:"remark"`
- CreatedAt time.Time `db:"created_at" json:"createdAt"`
- UpdatedAt *time.Time `db:"updated_at" json:"updatedAt"`
- DataDate *time.Time `db:"data_date" json:"dataDate"`
- }
-
- func (MasterStore) TableName() string {
- return "master_store"
- }
|