Commit f8385223 authored by zhengyaoqiu's avatar zhengyaoqiu

feat(colorway): 平台店铺枚举

parent bc3d33f5
......@@ -3,3 +3,5 @@ package mongo
//go:generate goctl template init --home ./templates
//go:generate goctl model mongo --type Product --dir product --home ./templates
//go:generate goctl model mongo --type SitePlatformPriceConfig --dir site_platform_price_config --home ./templates --style go_zero
......@@ -73,8 +73,6 @@ type ProductColors []ProductColor
type ProductColorSku struct {
Pc3SkuId string `bson:"pc3SkuId"`
Pc3ProductId string `bson:"pc3ProductId"`
ColorSpuStyleNumber string `bson:"colorSpuStyleNumber"`
ColorSpuColorCode string `bson:"colorSpuColorCode"`
SourceId string `bson:"sourceId"`
SiteId string `bson:"siteId"`
Size string `bson:"size"`
......
package model
import (
"errors"
"github.com/zeromicro/go-zero/core/stores/mon"
)
var (
ErrNotFound = mon.ErrNotFound
ErrInvalidObjectId = errors.New("invalid objectId")
)
package model
import "github.com/zeromicro/go-zero/core/stores/mon"
var _ SitePlatformPriceConfigModel = (*customSitePlatformPriceConfigModel)(nil)
type (
// SitePlatformPriceConfigModel is an interface to be customized, add more methods here,
// and implement the added methods in customSitePlatformPriceConfigModel.
SitePlatformPriceConfigModel interface {
sitePlatformPriceConfigModel
}
customSitePlatformPriceConfigModel struct {
*defaultSitePlatformPriceConfigModel
}
)
// NewSitePlatformPriceConfigModel returns a model for the mongo.
func NewSitePlatformPriceConfigModel(url, db, collection string) SitePlatformPriceConfigModel {
conn := mon.MustNewModel(url, db, collection)
return &customSitePlatformPriceConfigModel{
defaultSitePlatformPriceConfigModel: newDefaultSitePlatformPriceConfigModel(conn),
}
}
// Code generated by goctl. DO NOT EDIT.
package model
import (
model "git.chillcy.com/golang/colorway/internal/pkg/database/mongo/base"
"github.com/zeromicro/go-zero/core/stores/mon"
)
type sitePlatformPriceConfigModel interface {
model.Model[SitePlatformPriceConfig]
}
type defaultSitePlatformPriceConfigModel struct {
conn *mon.Model
model.Model[SitePlatformPriceConfig]
}
func newDefaultSitePlatformPriceConfigModel(conn *mon.Model) *defaultSitePlatformPriceConfigModel {
return &defaultSitePlatformPriceConfigModel{
conn: conn,
Model: model.NewBaseModel[SitePlatformPriceConfig](conn),
}
}
package model
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type SitePlatformPriceConfig struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
Site string `json:"site" bson:"site"`
Seller embed.Seller `json:"seller" bson:"seller"` // 销售平台
Enable bool `json:"enable" bson:"enable"` // 是否启用
embed.RoutePriceConfig `bson:",inline"` // 路线价格配置
UpdateAt time.Time `bson:"updateAt,omitempty" json:"updateAt,omitempty"`
CreateAt time.Time `bson:"createAt,omitempty" json:"createAt,omitempty"`
}
type Seller struct {
Platform string `json:"platform" bson:"platform"` // 销售平台
Store string `json:"store" bson:"store"` // 销售平台具体店铺
}
package platform
type Platform string
const (
Mezzanine Platform = "mezzanine"
Tmall2b Platform = "tmall2b"
Taobao Platform = "taobao"
Poizon2b Platform = "poizon2b"
OldPoizon Platform = "oldpoizon"
Jd Platform = "jingdong"
Im2b Platform = "im2b"
Tmall2c Platform = "tmall"
B2B Platform = "b2b"
Open Platform = "open"
)
func (p Platform) GetName() string {
switch p {
case Mezzanine:
return "迷衣"
case Tmall2b:
return "天猫ToB"
case Taobao:
return "淘宝"
case Poizon2b:
return "得物"
case OldPoizon:
return "旧得物"
case Jd:
return "京东"
case Im2b:
return "ImToB"
case Tmall2c:
return "天猫"
case B2B:
return "B2B"
case Open:
return "开放平台"
}
return string(p)
}
func GetAllPlatforms() []Platform {
return []Platform{
Mezzanine,
Tmall2b,
Taobao,
Poizon2b,
Jd,
Im2b,
Tmall2c,
B2B,
Open,
OldPoizon,
}
}
func IsPlatform(s string) bool {
for _, p := range GetAllPlatforms() {
if string(p) == s {
return true
}
}
return false
}
package store
type Store string
const (
MezzanineApp Store = "mezzanine_app"
MezzanineMiniApp Store = "mezzanine_mini_app"
Tmall2bHK Store = "tmall2b_hk"
Tmall2bUS Store = "tmall2b_us"
Tmall2bEUR Store = "tmall2b_eur"
Poizon2bStore1 Store = "mezzanine1"
Poizon2bStore2 Store = "mezzanine2"
JDStore2015 Store = "150558"
JDStore2017 Store = "208456"
JDStoreGongxiao Store = "208456gx"
JDStore2019 Store = "754589"
JDStore2024 Store = "13888912"
Im2b Store = "im2b"
Tmall2cStore1 Store = "mezzanine"
B2bStore1 Store = "alfamoda"
B2bStore2 Store = "alfa_mp"
TbStore1 Store = "taobao_store1"
TbStore2 Store = "taobao_store2"
TbStore3 Store = "taobao_store3"
TbStore4 Store = "taobao_store4"
TbStore5 Store = "taobao_store5"
TbStore6 Store = "taobao_store6"
TbStore7 Store = "taobao_store7"
TbStore8 Store = "taobao_store8"
TbStore9 Store = "taobao_store9"
OpenStore1 Store = "open_store1"
OldPoizon1 Store = "oldpoizon1"
OldPoizon2 Store = "oldpoizon2"
)
func GetAllStores() []Store {
return []Store{
MezzanineApp,
Tmall2bHK,
Tmall2bUS,
Tmall2bEUR,
Poizon2bStore1,
Poizon2bStore2,
Im2b,
Tmall2cStore1,
JDStore2015,
JDStore2017,
JDStoreGongxiao,
JDStore2019,
JDStore2024,
B2bStore1,
B2bStore2,
TbStore1,
TbStore2,
TbStore3,
TbStore4,
TbStore5,
TbStore6,
TbStore7,
TbStore8,
TbStore9,
OpenStore1,
OldPoizon1,
OldPoizon2,
}
}
func (store Store) GetStoreName() string {
switch store {
case MezzanineApp:
return "迷衣App"
case MezzanineMiniApp:
return "迷衣小程序"
case Tmall2bHK:
return "天猫ToB HK"
case Tmall2bUS:
return "天猫ToB US"
case Tmall2bEUR:
return "天猫ToB EUR"
case Poizon2bStore1:
return "得物一店"
case Poizon2bStore2:
return "得物二店"
case Im2b:
return "ImToB"
case JDStore2015:
return "XIYANGHUI2015"
case JDStore2017:
return "XIYANGHUI2017"
case JDStoreGongxiao:
return "京东供销"
case JDStore2019:
return "XIYANGHUI2019"
case Tmall2cStore1:
return "迷衣时尚海外旗舰店"
case TbStore1:
return "huzhijie1991"
case TbStore2:
return "足尚潮鞋店"
case TbStore3:
return "冰蕙儿"
case TbStore4:
return "mezzanine"
case TbStore5:
return "西洋汇"
case TbStore6:
return "huangjiawei44"
case TbStore7:
return "soulsoulsu"
case TbStore8:
return "ys狼牙俱乐部"
case TbStore9:
return "旧店铺"
case B2bStore1:
return "ALFAMODA"
case B2bStore2:
return "ALFA-MP"
case OpenStore1:
return "开放平台"
case OldPoizon1:
return "旧得物一店"
case OldPoizon2:
return "旧得物二店"
}
return string(store)
}
//func GetPlatformStores(platform Platform) []Store {
// switch platform {
// case PlatformMezzanine:
// return []Store{StoreMezzanineApp}
// case PlatformTmall2b:
// return []Store{StoreTmall2bHK, StoreTmall2bUS, StoreTmall2bEUR}
// case PlatformPoizon2b:
// return []Store{StorePoizon2bStore1, StorePoizon2bStore2}
// case PlatformIm2b:
// return []Store{StoreIm2b}
// case PlatformJd:
// return []Store{StoreJDStore2015, StoreJDStore2017, StoreJDStoreGongxiao, StoreJDStore2019, StoreJDStore2024}
// case PlatformTmall2c:
// return []Store{StoreTmall2cStore1}
// case PlatformB2B:
// return []Store{StoreB2bStore1, StoreB2bStore2}
// case PlatformTaobao:
// return []Store{StoreTbStore1, StoreTbStore2, StoreTbStore3, StoreTbStore4, StoreTbStore5,
// StoreTbStore6, StoreTbStore7, StoreTbStore8, StoreTbStore9}
// case PlatformOpen:
// return []Store{StoreOpenStore1}
// case PlatformOldPoizon:
// return []Store{StoreOldPoizon1, StoreOldPoizon2}
// }
// return nil
//}
......@@ -2,3 +2,5 @@ Name: colorway.rpc
ListenOn: 0.0.0.0:5200
Mode: dev
Timeout: 30000
Log:
Stat: false
\ No newline at end of file
......@@ -142,8 +142,6 @@ func buildProductColor(colorProduct *pc4.ColorProduct, styleNumber string, ws we
pc.Skus = append(pc.Skus, model.ProductColorSku{
Pc3SkuId: sku.GetId(),
Pc3ProductId: product.GetId(),
ColorSpuStyleNumber: styleNumber,
ColorSpuColorCode: colorProduct.GetColorNumber(),
SourceId: product.GetSourceId(),
SiteId: product.GetSiteId(),
Size: sku.GetRawSize(),
......
......@@ -23,7 +23,7 @@ type ServiceContext struct {
func NewServiceContext(c config.Config) *ServiceContext {
etcd.Init(etcd.Env(c.Mode))
pc4RpcProductServiceTarget := etcd.Get(etcd.KeyRpcPc4)
mongoManager := mongo.NewManager(etcd.Get(etcd.KeyMongoPlatformUri))
mongoManager := mongo.NewManager(etcd.Get(etcd.KeyMongoProductUri))
if etcd.GetEnv() == etcd.EnvDev {
pc4RpcProductServiceTarget = "127.0.0.1:5100"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment