互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "time"
  5. )
  6. const CustomerGoodsTableName = TableNamePrefix + "customer_goods"
  7. type CustomerGoods struct {
  8. Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
  9. IsDelete bool `json:"is_delete" xorm:"not null default 0 comment('是否删除') TINYINT(1)"`
  10. CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间') TIMESTAMP"`
  11. UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间') TIMESTAMP"`
  12. ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"`
  13. AreaId int64 `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"`
  14. GoodsPicUrl string `json:"goods_pic_url" xorm:"not null default '' comment('商品图片') VARCHAR(255)"`
  15. IsForceAdded int `json:"is_force_added" xorm:"not null default 0 comment('是否强制上架0不强制1强制') TINYINT(1)"`
  16. FixedField string `json:"fixed_field" xorm:"not null default '' comment('固定不可改字段,|分隔') VARCHAR(255)"`
  17. Stock int `json:"stock" xorm:"not null default 0 comment('库存-1的时候无上限') INT(18)"`
  18. Name string `json:"name" xorm:"not null default '' comment('商品名称') VARCHAR(255)"`
  19. Price float64 `json:"price" xorm:"not null default 0.00 comment('商品单价')"`
  20. Desc string `json:"desc" xorm:"not null default '' comment('商品介绍') VARCHAR(255)"`
  21. //// 无关变量
  22. GoodType int `json:"good_type" xorm:"-"`
  23. Postage float64 `json:"postage" xorm:"-"`
  24. Qrcode string `json:"qrcode,omitempty" xorm:"-"`
  25. }
  26. func (t *CustomerGoods) TableName() string {
  27. return CustomerGoodsTableName
  28. }
  29. func (t *CustomerGoods) Alias(name string) string {
  30. return AliasTableName(t, name)
  31. }
  32. func GetGoodsByActivityId(activityId, areaId int64) ([]*CustomerGoods, error) {
  33. goods := make([]*CustomerGoods, 0)
  34. err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and area_id=?", activityId, areaId).
  35. Asc("created_at").Find(&goods)
  36. return goods, err
  37. }
  38. func (t *CustomerGoods) IncrStockById(id, num interface{}) (int64, error) {
  39. return core.GetXormAuto().ID(id).Incr("stock", num).Cols("stock").Update(t)
  40. }