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.

56 lines
1.4 KiB

package cart
import (
"github.com/towgo/towgo/dao/basedboperat"
"log"
"src/module/goods"
skuPrice "src/module/skuPrice"
)
func (Cart) TableName() string {
return "cart"
}
// OrderItem 表示订单项信息
type Cart struct {
ID int64 `json:"id"` // 订单项ID
UserID int64 `json:"user_id"` // 用户ID
CartType string `json:"cart_type"` // 购物车类型
GoodsId int64 `json:"goods_id"` // 商品ID
GoodsIds string `json:"goods_ids"` // 商品IDs
GoodsNum int64 `json:"goods_num"` // 商品数量
Goods goods.Goods `json:"goods"xorm:"-"` // 商品
ActivityID int64 `json:"activity_id"` // 活动ID
ActivityType string `json:"activity_type"` // 活动类型
SkuPriceId int64 `json:"sku_price_id"` //规格价格
SkuPrice skuPrice.SKUPrice `json:"sku_price" xorm:"-"` //规格价格
}
type ExtArr struct {
BuyType string `json:"buy_type"`
GrouponId int64 `json:"groupon_id"`
ExpiredTime int64 `json:"expired_time"`
}
func (cart *Cart) AfterQuery(session basedboperat.DbTransactionSession) {
var good goods.Goods
err := session.Get(&good, nil, "id = ?", cart.GoodsId)
if err != nil {
log.Println(err.Error())
return
}
cart.Goods = good
var skuP skuPrice.SKUPrice
err = session.Get(&skuP, nil, "id = ?", cart.SkuPriceId)
if err != nil {
log.Print(err.Error())
return
}
cart.SkuPrice = skuP
}