説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

master_store.go 10.0KB

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