hasaki_qrcode

package
v0.0.0-...-ec02b94 Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDb

func InitDb(config interface{}) (err error)

func InitDbByConfig

func InitDbByConfig(config interface{}) (err error)

Types

type Api

type Api struct {
	// contains filtered or unexported fields
}

func GetApi

func GetApi(ctx interface{}) *Api

func NewApi

func NewApi(db ...*xorm.Engine) *Api

func (*Api) ExistStadiumQrcode

func (api *Api) ExistStadiumQrcode(uniqueId string) (bool, error)

func (*Api) GetStadiumQrcode

func (api *Api) GetStadiumQrcode(uniqueId string) (*StadiumQrcode, error)

func (*Api) InitDb

func (api *Api) InitDb() (err error)

func (*Api) LogStadiumQrcode

func (api *Api) LogStadiumQrcode(uniqueId string, response map[string]interface{}, err error) error

func (*Api) NewModel

func (api *Api) NewModel() (m *Model)

func (*Api) SaveStadiumQrcode

func (api *Api) SaveStadiumQrcode(qrcode *StadiumQrcode) error

func (*Api) SetStadiumQrcodeFlag

func (api *Api) SetStadiumQrcodeFlag(uniqueId string, flag int) error

func (*Api) UpdateStadiumQrcode

func (api *Api) UpdateStadiumQrcode(uniqueId string, status int, response map[string]interface{}, errlog string) (int64, error)

type Model

type Model struct {
	Db        *xorm.Engine `json:"-" xorm:"-"`
	Id        int          `json:"id" xorm:"not null pk autoincr INT(11)"`
	DeletedAt hsktime.Time `json:"-" xorm:"deleted comment('是否删除') TIMESTAMP"`
	CreatedAt hsktime.Time `json:"created_at" xorm:"created comment('创建时间') TIMESTAMP"`
	UpdatedAt hsktime.Time `json:"updated_at" xorm:"updated comment('更新时间') TIMESTAMP"`
}

func NewModel

func NewModel(eng *xorm.Engine) *Model

func (*Model) ExistStadiumQrcode

func (m *Model) ExistStadiumQrcode(uniqueId string) (bool, error)

func (*Model) Get

func (m *Model) Get(uniqueId string) (*StadiumQrcode, error)

func (*Model) Save

func (m *Model) Save(qr *StadiumQrcode) error

func (*Model) SetFlag

func (m *Model) SetFlag(uniqueId string, flag int) error

func (*Model) UpdateStadiumQrcode

func (m *Model) UpdateStadiumQrcode(uniqueId string, status int, response map[string]interface{}, errlog string) (int64, error)

type QrCodeEvent

type QrCodeEvent struct {
	BrandId       int                    `json:"brand_id"`
	UniqueId      string                 `json:"unique_id"`  //唯一标识符
	EventType     QrCodeEventType        `json:"event_type"` // 时间类型
	ExpiredAt     int64                  `json:"expired_at"` // 有效时间
	Data          map[string]interface{} `json:"data"`       // 时间数据
	LastUpdatedAt time.Time              `json:"updated_at"` // 上一次更新时间
}

func GenQrcode

func GenQrcode(brandId int, eventType QrCodeEventType, expiredAt int64, data map[string]interface{}) (*QrCodeEvent, string, error)

TODO: 把unique_id 作为二维码body

func ParseQrcode

func ParseQrcode(body string) (*QrCodeEvent, error)

type QrCodeEventType

type QrCodeEventType string
var (
	//PersonTimingEnterQrCodeEventType QrCodeEventType = "pt_enter"  // 人时
	//PersonTimingLeaveQrCodeEventType QrCodeEventType = "pt_leave"  // 人时
	PersonTimingQrCodeEventType     QrCodeEventType = "pt_qrcode" // 人时
	VenueTimingQrCodeEventType      QrCodeEventType = "vt_qrcode" // 场时
	VenueNumberQrCodeEventType      QrCodeEventType = "vn_qrcode" // 场次
	PersonNumberQrCodeEventType     QrCodeEventType = "pn_qrcode" // 人次
	VenueNumberShareQrcodeEventType QrCodeEventType = "vn_share"  // 场次分享
	CourseVerifyQrcodeEventType     QrCodeEventType = "kc_qrcode" // 课程核销二维码
	CourseExpVerifyQrcodeEventType  QrCodeEventType = "ce_qrcode" // 预约体验课核销
)

type StadiumQrcode

type StadiumQrcode struct {
	Model `xorm:"extends"`

	UniqueId  string                 `json:"unique_id" xorm:"not null default '' comment('唯一值') VARCHAR(255) INDEX"`
	Status    int                    `json:"status" xorm:"not null default 0 comment('状态') TINYINT(1)"` // 0 尚未扫过 1 一扫过 2失效 3 报错
	EventType QrCodeEventType        `json:"event_type" xorm:"not null default '' comment('二维码事件') VARCHAR(128)"`
	Flag      int                    `json:"flag" xorm:"not null default 0 comment('处理flag[0/1 未/已]') TINYINT(1)"` // 0 已处理 1 为处理
	ExpiredAt int64                  `json:"expired_at" xorm:"not null default 0 comment('二维码时效') INT(11)"`
	Errlog    string                 `json:"errlog" xorm:"not null default '' comment('错误日志') VARCHAR(500)"`
	Request   map[string]interface{} `json:"request" xorm:"json comment('请求数据')"`
	Response  map[string]interface{} `json:"response" xorm:"json comment('响应数据')"`
}

func (*StadiumQrcode) GetQrcodeEvent

func (q *StadiumQrcode) GetQrcodeEvent() *QrCodeEvent

Jump to

Keyboard shortcuts

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