互动
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.

48 lines
2.3 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
  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:"not null default 'CURRENT_TIMESTAMP' 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. GoodType int `json:"good_type" xorm:"not null default 0 comment('商品类型0不需要邮寄1需要邮寄') TINYINT(1)"`
  17. FixedField string `json:"fixed_field" xorm:"not null default '' comment('固定不可改字段,|分隔') VARCHAR(255)"`
  18. Stock int `json:"stock" xorm:"not null default 0 comment('库存-1的时候无上限') INT(18)"`
  19. Name string `json:"name" xorm:"not null default '' comment('商品名称') VARCHAR(255)"`
  20. Price float64 `json:"price" xorm:"not null default '' comment('商品单价') DECIMAL(18)"`
  21. Desc string `json:"desc" xorm:"not null default '' comment('商品介绍') VARCHAR(255)"`
  22. // 无关变量
  23. Qrcode string `json:"qrcode,omitempty" xorm:"-"`
  24. }
  25. func (t *CustomerGoods) TableName() string {
  26. return CustomerGoodsTableName
  27. }
  28. func (t *CustomerGoods) Alias(name string) string {
  29. return AliasTableName(t, name)
  30. }
  31. //func (t *CustomerGoods) GetById(gid int64) (bool, error) {
  32. // return core.GetXormAuto().Where("is_delete=0 and id=?", gid).Get(t)
  33. //}
  34. func GetGoodsByActivityId(activityId, areaId int64) ([]*CustomerGoods, error) {
  35. goods := make([]*CustomerGoods, 0)
  36. err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and area_id=?", activityId, areaId).
  37. Asc("created_at").Find(&goods)
  38. return goods, err
  39. }