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