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

52 lines
2.0 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
  1. package models
  2. import (
  3. "fmt"
  4. "github.com/ouxuanserver/osmanthuswine/src/core"
  5. "time"
  6. )
  7. const CustomerOrderSubTN = TableNamePrefix + "customer_order_sub"
  8. type CustomerOrderSub struct {
  9. Id int64 `json:"id" xorm:"not null pk autoincr comment('主键') INT(11)"`
  10. IsDelete bool `json:"is_delete" xorm:"not null default 0 comment('软删除') TINYINT(1)"`
  11. CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
  12. UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"`
  13. OrderNo string `json:"order_no" xorm:"not null default 0 comment('订单号') VARCHAR(128)"`
  14. GoodsId int64 `json:"goods_id" xorm:"not null default 0 comment('商品id') INT(11)"`
  15. GoodsNum int `json:"goods_num" xorm:"not null default 0 comment('商品数量') INT(11)"`
  16. GoodName string `json:"good_name" xorm:"not null default '' comment('商品名字') VARCHAR(128)"`
  17. GoodPrice float64 `json:"good_price" xorm:"not null default 0.00 comment('商品价格') DECIMAL(18)"`
  18. // 无关变量
  19. GoodsPicUrl string `json:"goods_pic_url" xorm:"extends"`
  20. }
  21. func (t *CustomerOrderSub) TableName() string {
  22. return CustomerOrderSubTN
  23. }
  24. func (t *CustomerOrderSub) Alias(n string) string {
  25. return fmt.Sprintf("%s as %s", t.TableName(), n)
  26. }
  27. func GetCustomerOrderSubsByOrderNos(orderNos ...string) (subs []map[string]string, err error) {
  28. err = core.GetXormAuto().Table(new(CustomerOrderSub)).Alias("s").
  29. Select("s.order_no, s.goods_id, s.goods_num, s.good_name, s.good_price, g.goods_pic_url").
  30. Join("left", new(CustomerGoods).Alias("g"), "g.id=s.goods_id").
  31. Where("s.is_delete=0").In("s.order_no", orderNos).
  32. Desc("s.created_at").Find(&subs)
  33. return
  34. }
  35. func GetSubOrdersByOrderNo(orderNo string) ([]*CustomerOrderSub, error) {
  36. subs := make([]*CustomerOrderSub, 0)
  37. err := core.GetXormAuto().Where("is_delete=0 and order_no=?", orderNo).Find(&subs)
  38. return subs, err
  39. }
  40. func (t *CustomerOrderSub) IncrStock() {
  41. }