Ingen beskrivning
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

master_store.go 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package tables
  2. import (
  3. "time"
  4. "git.x2erp.com/qdy/go-db/sqldef"
  5. )
  6. func init() {
  7. sqldef.AddRegistration(func(r *sqldef.Registry) {
  8. tb := sqldef.NewTable("master_store", "店铺主数据表").
  9. ID("stor_id", 50).NotNull().Comment("店铺ID").End().
  10. String("tenant_id", 50).NotNull().Comment("租户ID").End().
  11. String("stor_code", 50).NotNull().Comment("店铺编码").End().
  12. String("stor_name", 200).NotNull().Comment("店铺名称").End().
  13. String("stor_short_name", 100).Comment("店铺简称").End().
  14. String("company_id", 50).NotNull().Comment("所属公司ID").End().
  15. String("store_ownership_type", 20).NotNull().Default("'DIRECT'").Comment("店铺所有权类型 DIRECT:直营 FRANCHISE:加盟").End().
  16. BigInt("business_model_id").Comment("经营模式ID(关联master_store_dimension表,type='business_model')").End().
  17. BigInt("store_tier_id").Comment("店铺定位ID(关联master_store_dimension表,type='store_tier')").End().
  18. BigInt("retail_format_id").Comment("零售业态ID(关联master_store_dimension表,type='retail_format')").End().
  19. BigInt("market_tier_id").Comment("市场层级ID(关联master_store_dimension表,type='market_tier')").End().
  20. BigInt("sales_channel_id").Comment("销售渠道ID(关联master_store_dimension表,type='sales_channel')").End().
  21. BigInt("region_id").Comment("区域ID(关联master_store_dimension表,type='region')").End().
  22. String("province", 50).Comment("省份").End().
  23. String("city", 50).Comment("城市").End().
  24. String("address", 500).Comment("详细地址").End().
  25. String("mall_code", 50).Comment("商场/商圈编码").End().
  26. String("mall_name", 200).Comment("商场/商圈名称").End().
  27. Decimal("store_area", 10, 2).Comment("店铺面积(平方米)").End().
  28. Date("opening_date").Comment("开业日期").End().
  29. String("manager_name", 50).Comment("店长姓名").End().
  30. String("contact_phone", 20).Comment("联系电话").End().
  31. Int("employee_count").Comment("员工人数").End().
  32. Int("inventory_capacity").Comment("库存容量(件数或SKU数)").End().
  33. String("stor_status", 20).Comment("店铺状态 (1营业中/2装修中/3停业/4关闭)").End().
  34. Bool("is_active").Comment("是否激活").End().
  35. Text("remark").Comment("备注").End().
  36. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End().
  37. DateTime("updated_at").Comment("更新时间").End().
  38. Date("data_date").Comment("数据日期 (数据仓库快照)").End()
  39. tb.AddUniqueIndex("idx_stor_code", "stor_code")
  40. tb.AddIndex("idx_tenant_id", "tenant_id")
  41. tb.AddIndex("idx_business_model_id", "business_model_id")
  42. tb.AddIndex("idx_store_tier_id", "store_tier_id")
  43. tb.AddIndex("idx_retail_format_id", "retail_format_id")
  44. tb.AddIndex("idx_market_tier_id", "market_tier_id")
  45. tb.AddIndex("idx_sales_channel_id", "sales_channel_id")
  46. tb.AddIndex("idx_region_id", "region_id")
  47. tb.AddIndex("idx_stor_status", "stor_status")
  48. tb.AddIndex("idx_business_region_status", "business_model_id", "region_id", "stor_status")
  49. tb.AddIndex("idx_company_id", "company_id")
  50. tb.AddIndex("idx_store_ownership_type", "store_ownership_type")
  51. r.RegisterTable(tb.Build())
  52. })
  53. }
  54. type MasterStore struct {
  55. StorID string `gorm:"column:stor_id;type:varchar(50);not null;primaryKey;comment:店铺ID"`
  56. TenantID string `gorm:"column:tenant_id;type:varchar(50);not null;comment:租户ID"`
  57. StorCode string `gorm:"column:stor_code;type:varchar(50);not null;comment:店铺编码"`
  58. StorName string `gorm:"column:stor_name;type:varchar(200);not null;comment:店铺名称"`
  59. StorShortName string `gorm:"column:stor_short_name;type:varchar(100);comment:店铺简称"`
  60. CompanyID string `gorm:"column:company_id;type:varchar(50);not null;comment:所属公司ID"`
  61. StoreOwnershipType string `gorm:"column:store_ownership_type;type:varchar(20);not null;default:DIRECT;comment:店铺所有权类型 DIRECT:直营 FRANCHISE:加盟"`
  62. BusinessModelID int64 `gorm:"column:business_model_id;type:bigint;comment:经营模式ID"`
  63. StoreTierID int64 `gorm:"column:store_tier_id;type:bigint;comment:店铺定位ID"`
  64. RetailFormatID int64 `gorm:"column:retail_format_id;type:bigint;comment:零售业态ID"`
  65. MarketTierID int64 `gorm:"column:market_tier_id;type:bigint;comment:市场层级ID"`
  66. SalesChannelID int64 `gorm:"column:sales_channel_id;type:bigint;comment:销售渠道ID"`
  67. RegionID int64 `gorm:"column:region_id;type:bigint;comment:区域ID"`
  68. Province string `gorm:"column:province;type:varchar(50);comment:省份"`
  69. City string `gorm:"column:city;type:varchar(50);comment:城市"`
  70. Address string `gorm:"column:address;type:varchar(500);comment:详细地址"`
  71. MallCode string `gorm:"column:mall_code;type:varchar(50);comment:商场/商圈编码"`
  72. MallName string `gorm:"column:mall_name;type:varchar(200);comment:商场/商圈名称"`
  73. StoreArea float64 `gorm:"column:store_area;type:decimal(10,2);comment:店铺面积(平方米)"`
  74. OpeningDate *time.Time `gorm:"column:opening_date;type:date;comment:开业日期"`
  75. ManagerName string `gorm:"column:manager_name;type:varchar(50);comment:店长姓名"`
  76. ContactPhone string `gorm:"column:contact_phone;type:varchar(20);comment:联系电话"`
  77. EmployeeCount int32 `gorm:"column:employee_count;type:int;comment:员工人数"`
  78. InventoryCapacity int32 `gorm:"column:inventory_capacity;type:int;comment:库存容量(件数或SKU数)"`
  79. StorStatus string `gorm:"column:stor_status;type:varchar(20);comment:店铺状态 (1营业中/2装修中/3停业/4关闭)"`
  80. IsActive bool `gorm:"column:is_active;type:bool;comment:是否激活"`
  81. Remark string `gorm:"column:remark;type:text;comment:备注"`
  82. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  83. UpdatedAt *time.Time `gorm:"column:updated_at;comment:更新时间"`
  84. DataDate *time.Time `gorm:"column:data_date;type:date;comment:数据日期 (数据仓库快照)"`
  85. }
  86. type MasterStoreDB struct {
  87. StorID string `db:"stor_id" json:"storID"`
  88. TenantID string `db:"tenant_id" json:"tenantID"`
  89. StorCode string `db:"stor_code" json:"storCode"`
  90. StorName string `db:"stor_name" json:"storName"`
  91. StorShortName string `db:"stor_short_name" json:"storShortName"`
  92. CompanyID string `db:"company_id" json:"companyID"`
  93. StoreOwnershipType string `db:"store_ownership_type" json:"storeOwnershipType"`
  94. BusinessModelID int64 `db:"business_model_id" json:"businessModelID"`
  95. StoreTierID int64 `db:"store_tier_id" json:"storeTierID"`
  96. RetailFormatID int64 `db:"retail_format_id" json:"retailFormatID"`
  97. MarketTierID int64 `db:"market_tier_id" json:"marketTierID"`
  98. SalesChannelID int64 `db:"sales_channel_id" json:"salesChannelID"`
  99. RegionID int64 `db:"region_id" json:"regionID"`
  100. Province string `db:"province" json:"province"`
  101. City string `db:"city" json:"city"`
  102. Address string `db:"address" json:"address"`
  103. MallCode string `db:"mall_code" json:"mallCode"`
  104. MallName string `db:"mall_name" json:"mallName"`
  105. StoreArea float64 `db:"store_area" json:"storeArea"`
  106. OpeningDate *time.Time `db:"opening_date" json:"openingDate"`
  107. ManagerName string `db:"manager_name" json:"managerName"`
  108. ContactPhone string `db:"contact_phone" json:"contactPhone"`
  109. EmployeeCount int32 `db:"employee_count" json:"employeeCount"`
  110. InventoryCapacity int32 `db:"inventory_capacity" json:"inventoryCapacity"`
  111. StorStatus string `db:"stor_status" json:"storStatus"`
  112. IsActive bool `db:"is_active" json:"isActive"`
  113. Remark string `db:"remark" json:"remark"`
  114. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  115. UpdatedAt *time.Time `db:"updated_at" json:"updatedAt"`
  116. DataDate *time.Time `db:"data_date" json:"dataDate"`
  117. }
  118. func (MasterStore) TableName() string {
  119. return "master_store"
  120. }