Nessuna descrizione
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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. StorCode string `gorm:"column:stor_code;type:varchar(50);not null;comment:店铺编码"`
  57. StorName string `gorm:"column:stor_name;type:varchar(200);not null;comment:店铺名称"`
  58. StorShortName string `gorm:"column:stor_short_name;type:varchar(100);comment:店铺简称"`
  59. CompanyID string `gorm:"column:company_id;type:varchar(50);not null;comment:所属公司ID"`
  60. StoreOwnershipType string `gorm:"column:store_ownership_type;type:varchar(20);not null;default:DIRECT;comment:店铺所有权类型 DIRECT:直营 FRANCHISE:加盟"`
  61. BusinessModelID int64 `gorm:"column:business_model_id;type:bigint;comment:经营模式ID"`
  62. StoreTierID int64 `gorm:"column:store_tier_id;type:bigint;comment:店铺定位ID"`
  63. RetailFormatID int64 `gorm:"column:retail_format_id;type:bigint;comment:零售业态ID"`
  64. MarketTierID int64 `gorm:"column:market_tier_id;type:bigint;comment:市场层级ID"`
  65. SalesChannelID int64 `gorm:"column:sales_channel_id;type:bigint;comment:销售渠道ID"`
  66. RegionID int64 `gorm:"column:region_id;type:bigint;comment:区域ID"`
  67. Province string `gorm:"column:province;type:varchar(50);comment:省份"`
  68. City string `gorm:"column:city;type:varchar(50);comment:城市"`
  69. Address string `gorm:"column:address;type:varchar(500);comment:详细地址"`
  70. MallCode string `gorm:"column:mall_code;type:varchar(50);comment:商场/商圈编码"`
  71. MallName string `gorm:"column:mall_name;type:varchar(200);comment:商场/商圈名称"`
  72. StoreArea float64 `gorm:"column:store_area;type:decimal(10,2);comment:店铺面积(平方米)"`
  73. OpeningDate *time.Time `gorm:"column:opening_date;type:date;comment:开业日期"`
  74. ManagerName string `gorm:"column:manager_name;type:varchar(50);comment:店长姓名"`
  75. ContactPhone string `gorm:"column:contact_phone;type:varchar(20);comment:联系电话"`
  76. EmployeeCount int32 `gorm:"column:employee_count;type:int;comment:员工人数"`
  77. InventoryCapacity int32 `gorm:"column:inventory_capacity;type:int;comment:库存容量(件数或SKU数)"`
  78. StorStatus string `gorm:"column:stor_status;type:varchar(20);comment:店铺状态 (1营业中/2装修中/3停业/4关闭)"`
  79. IsActive bool `gorm:"column:is_active;type:bool;comment:是否激活"`
  80. Remark string `gorm:"column:remark;type:text;comment:备注"`
  81. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  82. UpdatedAt *time.Time `gorm:"column:updated_at;comment:更新时间"`
  83. DataDate *time.Time `gorm:"column:data_date;type:date;comment:数据日期 (数据仓库快照)"`
  84. }
  85. type MasterStoreDB struct {
  86. StorID string `db:"stor_id" json:"storID"`
  87. StorCode string `db:"stor_code" json:"storCode"`
  88. StorName string `db:"stor_name" json:"storName"`
  89. StorShortName string `db:"stor_short_name" json:"storShortName"`
  90. CompanyID string `db:"company_id" json:"companyID"`
  91. StoreOwnershipType string `db:"store_ownership_type" json:"storeOwnershipType"`
  92. BusinessModelID int64 `db:"business_model_id" json:"businessModelID"`
  93. StoreTierID int64 `db:"store_tier_id" json:"storeTierID"`
  94. RetailFormatID int64 `db:"retail_format_id" json:"retailFormatID"`
  95. MarketTierID int64 `db:"market_tier_id" json:"marketTierID"`
  96. SalesChannelID int64 `db:"sales_channel_id" json:"salesChannelID"`
  97. RegionID int64 `db:"region_id" json:"regionID"`
  98. Province string `db:"province" json:"province"`
  99. City string `db:"city" json:"city"`
  100. Address string `db:"address" json:"address"`
  101. MallCode string `db:"mall_code" json:"mallCode"`
  102. MallName string `db:"mall_name" json:"mallName"`
  103. StoreArea float64 `db:"store_area" json:"storeArea"`
  104. OpeningDate *time.Time `db:"opening_date" json:"openingDate"`
  105. ManagerName string `db:"manager_name" json:"managerName"`
  106. ContactPhone string `db:"contact_phone" json:"contactPhone"`
  107. EmployeeCount int32 `db:"employee_count" json:"employeeCount"`
  108. InventoryCapacity int32 `db:"inventory_capacity" json:"inventoryCapacity"`
  109. StorStatus string `db:"stor_status" json:"storStatus"`
  110. IsActive bool `db:"is_active" json:"isActive"`
  111. Remark string `db:"remark" json:"remark"`
  112. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  113. UpdatedAt *time.Time `db:"updated_at" json:"updatedAt"`
  114. DataDate *time.Time `db:"data_date" json:"dataDate"`
  115. }
  116. func (MasterStore) TableName() string {
  117. return "master_store"
  118. }