Documentation
¶
Index ¶
- Variables
- func AddWatcher(codeType CodeTypeBit, watcher IGenerateWatcher)
- func InitEnviroment(codeImageSavePath, codeImageUrlPrefix, codePrefix, logPrefix string, ...) (err error)
- func WritePngFile(filePath string, imageData []byte) (err error)
- type CodeBarCode
- type CodeBase
- type CodeQrCode
- type CodeTypeBit
- type CodeWxMicroApp
- type Description
- type GoodsAttr
- type GoodsBasic
- func (self *GoodsBasic) AddTrace(goodsId int64, brief string, desc []Description) (err error)
- func (self *GoodsBasic) CheckInfoValid() (valid bool)
- func (self *GoodsBasic) GetOne(id, merchantId, categoryId int64, tagBit GoodsTagBit, uuid string, name string, ...) (has bool, err error)
- func (self *GoodsBasic) GetTraceInfo(goodsId int64) (brief string, created time.Time, desc []Description, err error)
- func (self *GoodsBasic) Insert() (err error)
- func (self *GoodsBasic) TableName() string
- type GoodsBrand
- type GoodsFeatureBit
- type GoodsImage
- type GoodsNonStandard
- type GoodsSku
- type GoodsSkuAttr
- type GoodsStandard
- type GoodsStateBit
- type GoodsTag
- type GoodsTagBit
- type GoodsTraceBlock
- type GoodsTypeBit
- type GoodsVideo
- type GoodsVirtual
- type ICode
- type ICodeModel
- type ICodeService
- type IGenerateWatcher
- type IGoods
- type IGoodsModel
- type ITrace
- type WatcherGenerateQrCode
- type YesOrNo
Constants ¶
This section is empty.
Variables ¶
View Source
var CodeImageSavePath string //码图片保存路径
View Source
var CodeImageUrlPrefix string //码图片访问路径前缀
View Source
var CodePrefix string //码前缀
View Source
var Engine *xorm.Engine
View Source
var GenerateWatchers map[CodeTypeBit]IGenerateWatcher
Functions ¶
func InitEnviroment ¶
func InitEnviroment(codeImageSavePath, codeImageUrlPrefix, codePrefix, logPrefix string, logLevel log.Level, engine *xorm.Engine) (err error)
初始化环境
func WritePngFile ¶
Types ¶
type CodeBarCode ¶
type CodeBarCode struct {
*CodeBase
}
func (*CodeBarCode) GenerateCode ¶
func (self *CodeBarCode) GenerateCode(merchantId, goodsId, skuId int64, code string, hash string) (err error)
code,hash 可以为空,为空时自动生成
func (*CodeBarCode) GetBasicInfo ¶
func (self *CodeBarCode) GetBasicInfo() (id, merchantId, goodsId, skuId int64, codeTypeBit CodeTypeBit)
type CodeBase ¶
type CodeBase struct {
Id int64 `json:"id"`
CodeTypeBit CodeTypeBit `json:"code_type_bit" xorm:"default 0 index"` //二维码类型
MerchantId int64 `json:"merchant_id" xorm:"default 0 index"` // 商户ID
GoodsId int64 `json:"goods_id" xorm:"default 0 index"` //商品id
SkuId int64 `json:"sku_id" xorm:"default 0 index"` //skuId
Code string `json:"code" xorm:"varchar(100) default '' index"` //码值
Hash string `json:"hash" xorm:"varchar(100) default '' index"` //码值hash
ImageUrl string `json:"image_url" xorm:"varchar(200) default ''"` //码图片url
Created time.Time `json:"created" xorm:"created"` //
Updated time.Time `json:"updated" xorm:"updated"` //
Session *xorm.Session `json:"-" xorm:"-"`
}
type CodeQrCode ¶
type CodeQrCode struct {
*CodeBase
}
func (*CodeQrCode) GenerateCode ¶
func (self *CodeQrCode) GenerateCode(merchantId, goodsId, skuId int64, code string, hash string) (err error)
code,hash 可以为空,为空时自动生成
func (*CodeQrCode) GetBasicInfo ¶
func (self *CodeQrCode) GetBasicInfo() (id, merchantId, goodsId, skuId int64, codeTypeBit CodeTypeBit)
type CodeTypeBit ¶
type CodeTypeBit int8
const ( CodeTypeOfBarCode CodeTypeBit = 1 << 0 //条码 CodeTypeOfQrCode CodeTypeBit = 1 << 1 //二维码 CodeTypeOfWxMicroApp CodeTypeBit = 1 << 2 //微信小程序码 )
type CodeWxMicroApp ¶
type CodeWxMicroApp struct {
*CodeBase
}
func (*CodeWxMicroApp) GenerateCode ¶
func (self *CodeWxMicroApp) GenerateCode(merchantId, goodsId, skuId int64, code string, hash string) (err error)
code,hash 可以为空,为空时自动生成
func (*CodeWxMicroApp) GetBasicInfo ¶
func (self *CodeWxMicroApp) GetBasicInfo() (id, merchantId, goodsId, skuId int64, codeTypeBit CodeTypeBit)
type Description ¶
type GoodsAttr ¶
type GoodsAttr struct {
Id int64 `json:"id"` //
Uuid string `json:"uuid" xorm:"varchar(100) default '' "` //属性唯一码
MerchantId int64 //商户id,为1时为平台所有
CateId int64 //栏目
AttrName string //属性名称
AttrValues []string //属性可选值
Sequence int //排序
}
商品属性-不同的栏目有不同的属性集
type GoodsBasic ¶
type GoodsBasic struct {
Id int64 `json:"id"` //
MerchantId int64 `json:"merchant_id" xorm:"default 0 index"` //商户ID
CategoryId int64 `json:"category_id" xorm:"default 0 index"` //栏目ID
BrandId int64 `json:"brand_id" xorm:"default 0 index"` //品牌id
TagsBit GoodsTagBit `json:"tags_bit" xorm:"default 0 index"` //拥有的标签
Uuid string `json:"uuid" xorm:"varchar(100) default '' index"` //商品唯一码
Name string `json:"name" xorm:"varchar(500) default '' index"` //商品名称
StateBit GoodsStateBit `json:"state_bit" xorm:"tinyint(2) default 0 index"` //商品状态
UnitName string `json:"unit_name" xorm:"varchar(20) default ''"` //单位名称
TypeBit GoodsTypeBit `json:"type_bit" xorm:"tinyint(2) default 0 index"` //商品类型
FeatureBit GoodsFeatureBit `json:"feature_bit" xorm:"tinyint(2) default 0 index"` //商品特性
Sequence int `json:"sequence" xorm:" default 0 index"` //排序
Gallery []*GoodsImage `json:"gallery" xorm:"json"` //商品图片集
Videos []*GoodsVideo `json:"videos" xorm:"json"` //商品视频集,打通腾讯视频
Brief string `json:"brief" xorm:"varchar(2000) default ''"` //简介
Description []*Description `json:"description" xorm:"json"` //描述
ClickCount int64 `json:"click_count" xorm:"default 0 index"` //点击量
FavoriteCount int64 `json:"favorite_count" xorm:"default 0 index"` //收藏量
BuyCount int64 `json:"buy_count" xorm:"default 0 index"` //购买量
ReturnCount int64 `json:"return_count" xorm:"default 0 index"` //退货量
MarketPrice int `json:"market_price" xorm:"default 0"` //市场价
MallPrice int `json:"mall_price" xorm:"default 0 index"` //商城价格
Attrs []*GoodsAttr `xorm:"-"` //拥有的属性
Session *xorm.Session `json:"-" xorm:"-"`
}
func (*GoodsBasic) AddTrace ¶
func (self *GoodsBasic) AddTrace(goodsId int64, brief string, desc []Description) (err error)
func (*GoodsBasic) CheckInfoValid ¶
func (self *GoodsBasic) CheckInfoValid() (valid bool)
func (*GoodsBasic) GetOne ¶
func (self *GoodsBasic) GetOne(id, merchantId, categoryId int64, tagBit GoodsTagBit, uuid string, name string, stateBit GoodsStateBit, typeBit GoodsTagBit, featureBit GoodsFeatureBit, lockForUpdate bool) (has bool, err error)
func (*GoodsBasic) GetTraceInfo ¶
func (self *GoodsBasic) GetTraceInfo(goodsId int64) (brief string, created time.Time, desc []Description, err error)
func (*GoodsBasic) Insert ¶
func (self *GoodsBasic) Insert() (err error)
func (*GoodsBasic) TableName ¶
func (self *GoodsBasic) TableName() string
type GoodsFeatureBit ¶
type GoodsFeatureBit int8 //商品特性
const ( GoodsFeatureOfNew GoodsFeatureBit = 1 << 0 //商品特性-新品 GoodsFeatureOfHot GoodsFeatureBit = 1 << 1 //商品特性-热销 GoodsFeatureOfRecommend GoodsFeatureBit = 1 << 2 //商品特性-推荐商品 )
type GoodsImage ¶
type GoodsNonStandard ¶
type GoodsNonStandard struct {
*GoodsBasic `xorm:"extends"`
}
type GoodsSkuAttr ¶
type GoodsStateBit ¶
type GoodsStateBit int8 //商品状态
const ( GoodsStateOn GoodsStateBit = 1 << 0 //上架 GoodsStateOff GoodsStateBit = 1 << 1 //下架 )
type GoodsTag ¶
type GoodsTag struct {
Id int64 `json:"id"` //
MerchantId int64 `json:"merchant_id" xorm:"default 0 index"` //商户id
TagBit GoodsTagBit `json:"tag_bit" xorm:"default 0 index"` //标示位,限制了一个商户的最大标签数不超过64
Sequence int8 `json:"sequence" xorm:"tinyint(2) default 0 index"` //最大256,越大越靠前
Name string `json:"name" xorm:"varchar(200) default ''"` //名称
Icon string `json:"icon" xorm:"varchar(500) default ''"` //图标
Desc string `json:"desc" xorm:"varchar(2000) default ''"` //简介
Created time.Time `json:"created" xorm:"created"` //
Updated time.Time `json:"updated" xorm:"updated"` //
}
商品标签
type GoodsTagBit ¶
type GoodsTagBit int64 //限制了一个商户的最大标签数不超过64,如果要更长此处需要改成varchar
func (GoodsTagBit) GetTagList ¶
func (self GoodsTagBit) GetTagList(session *xorm.Session) (result []*GoodsTag, err error)
type GoodsTraceBlock ¶
type GoodsTraceBlock struct {
Id int64 `json:"id"`
GoodsId int64 `json:"goods_id" xorm:"default 0 index"` //商品id
Brief string `json:"brief" xorm:"varchar(2000) default ''"` //记录简介
Description []*Description `json:"description" xorm:"json"` //记录内容
ByUid int64 `json:"by_uid" xorm:"default 0"` //上传用户
Created time.Time `json:"created" xorm:"created"` //创建时间
CurHash string `json:"cur_hash" xorm:"varchar(200) default ''"` //用户私钥后的HASH
PreHash string `json:"pre_hash" xorm:"varchar(100) default ''"` //上个区块系统私钥后的HASH
}
商品跟踪记录
type GoodsTypeBit ¶
type GoodsTypeBit int8 //商品类型
const ( GoodsTypeOfStandard GoodsTypeBit = 1 << 0 //标准品 GoodsTypeOfNonStandard GoodsTypeBit = 1 << 1 //非标品 GoodsTypeOfVirtual GoodsTypeBit = 1 << 2 //虚拟商品 )
type GoodsVideo ¶
type GoodsVirtual ¶
type GoodsVirtual struct {
*GoodsBasic
}
type ICode ¶
type ICode interface {
ICodeModel
ICodeService
}
码接口
func GenerateCodeProvider ¶
func GenerateCodeProvider(bit CodeTypeBit, session *xorm.Session) ICode
func NewCode ¶
func NewCode(merchantId, goodsId, skuId int64, code string, hashStr string, codeType CodeTypeBit, session *xorm.Session) (result ICode, err error)
生成码
func SearchCode ¶
func SearchCode(code, hash string, codeType CodeTypeBit, session *xorm.Session) (result ICode, has bool, err error)
根据hash 或 code 查询码
type ICodeModel ¶
type ICodeService ¶
type ICodeService interface {
GetBasicInfo() (id, merchantId, goodsId, skuId int64, codeTypeBit CodeTypeBit)
GenerateCode(merchantId, goodsId, skuId int64, code string, hash string) (err error)
}
码对外服务接口
type IGenerateWatcher ¶
type IGenerateWatcher interface {
GenerateImage(merchantId int64, code, hash string, session *xorm.Session) (imageData []byte, err error)
}
码生成观察者
type IGoods ¶
type IGoods interface {
IGoodsModel
ITrace
}
func GenerateGoodsProvider ¶
func GenerateGoodsProvider(bit GoodsTypeBit, session *xorm.Session) IGoods
type IGoodsModel ¶
type IGoodsModel interface {
GetOne(id, merchantId, categoryId int64, tagBit GoodsTagBit, uuid string, name string, stateBit GoodsStateBit, typeBit GoodsTagBit, featureBit GoodsFeatureBit, lockForUpdate bool) (has bool, err error)
Insert() (err error)
}
type WatcherGenerateQrCode ¶
func (*WatcherGenerateQrCode) GenerateImage ¶
Click to show internal directories.
Click to hide internal directories.