decibel_goods

package module
v0.0.0-...-b7e77a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2019 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

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 AddWatcher

func AddWatcher(codeType CodeTypeBit, watcher IGenerateWatcher)

注册观察者

func InitEnviroment

func InitEnviroment(codeImageSavePath, codeImageUrlPrefix, codePrefix, logPrefix string, logLevel log.Level, engine *xorm.Engine) (err error)

初始化环境

func WritePngFile

func WritePngFile(filePath string, imageData []byte) (err error)

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:"-"`
}

func (*CodeBase) GetOne

func (self *CodeBase) GetOne(id, merchantId, goodsId, skuId int64, codeTypeBit CodeTypeBit, code string, hash string, lockForUpdate bool) (has bool, err error)

func (*CodeBase) Insert

func (self *CodeBase) Insert() (err error)

func (*CodeBase) TableName

func (self *CodeBase) TableName() string

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 Description struct {
	Type     string `json:"type"`      //可选值 text|image|video
	Content  string `json:"content"`   //内容, image 和 video 时都为 url
	Color    string `json:"color"`     //字体颜色,仅为text时有效
	FontSize int    `json:"font_size"` //字号,仅为text时有效
}

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 GoodsBrand

type GoodsBrand struct {
	Id   int64
	Name string
	Icon string
}

商品品牌

type GoodsFeatureBit

type GoodsFeatureBit int8 //商品特性
const (
	GoodsFeatureOfNew       GoodsFeatureBit = 1 << 0 //商品特性-新品
	GoodsFeatureOfHot       GoodsFeatureBit = 1 << 1 //商品特性-热销
	GoodsFeatureOfRecommend GoodsFeatureBit = 1 << 2 //商品特性-推荐商品
)

type GoodsImage

type GoodsImage struct {
	Url      string `json:"url"`
	ThumbUrl string `json:"thumb_url"`
	Desc     string `json:"desc"`
}

type GoodsNonStandard

type GoodsNonStandard struct {
	*GoodsBasic `xorm:"extends"`
}

func (*GoodsNonStandard) Weigh

func (self *GoodsNonStandard) Weigh()

称重

type GoodsSku

type GoodsSku struct {
	Id         int64
	Uuid       string          //库存唯一码
	GoodsId    int64           //商品id
	MerchantId int64           //商户id
	StoreId    int64           //如果storeId=0 就说明是商户的总库存
	GoodsAttr  []*GoodsSkuAttr //商品特性
	Price      int             //售价
	Amount     int             //库存
	Created    time.Time       `xorm:"created"` //
	Updated    time.Time       `xorm:"updated"` //
}

type GoodsSkuAttr

type GoodsSkuAttr struct {
	GoodsAttrId int64
	Value       string
}

type GoodsStandard

type GoodsStandard struct {
	*GoodsBasic
}

标准化商品

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"`                     //
}

商品标签

func (*GoodsTag) TableName

func (self *GoodsTag) TableName() string

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 GoodsVideo struct {
	Url  string `json:"url"`
	Desc string `json:"desc"`
}

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 ICodeModel interface {
	TableName() string
	GetOne(id, merchantId, goodsId, skuId int64, codeTypeBit CodeTypeBit, code string, hash string, lockForUpdate bool) (has bool, err error)
	Insert() (err error)
}

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 ITrace

type ITrace interface {
	GetTraceInfo(goodsId int64) (brief string, created time.Time, desc []Description, err error)
	AddTrace(goodsId int64, brief string, desc []Description) error
	CheckInfoValid() bool
}

type WatcherGenerateQrCode

type WatcherGenerateQrCode struct {
	*qrcode.QrCode
}

func NewWatcherGenerateQrCode

func NewWatcherGenerateQrCode(fontByte, logoByte []byte, size int, fontSize float64, fontDPI float64, frontColor string, backColor string) (result *WatcherGenerateQrCode, err error)

func (*WatcherGenerateQrCode) GenerateImage

func (self *WatcherGenerateQrCode) GenerateImage(merchantId int64, code, hash string, session *xorm.Session) (data []byte, err error)

type YesOrNo

type YesOrNo int8 //布尔开关
const (
	Yes YesOrNo = 1 << 0 //是
	No  YesOrNo = 1 << 1 //否
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL