Exemple #1
0
// 获取最新的购物车
func (this *shoppingRep) GetLatestCart(buyerId int) (*shopping.ValueCart, error) {
	var v = new(shopping.ValueCart)
	err := this.Connector.GetOrm().GetBy(v, "buyer_id=? ORDER BY id DESC", buyerId)
	if v == nil || err != nil {
		return nil, err
	}

	var items = []*shopping.ValueCartItem{}
	err = this.Connector.GetOrm().Select(&items, "cart_id=?", v.Id)
	if err == nil {
		v.Items = items
	}
	return v, err
}
Exemple #2
0
// 获取购物车
func (this *shoppingRep) GetShoppingCart(key string) (*shopping.ValueCart, error) {
	var v = new(shopping.ValueCart)
	err := this.Connector.GetOrm().GetBy(v, "cart_key=?", key)
	if v == nil || err != nil {
		return nil, err
	}

	var items = []*shopping.ValueCartItem{}
	err = this.Connector.GetOrm().Select(&items, "cart_id=?", v.Id)
	if err == nil {
		v.Items = items
	}

	return v, err
}
Exemple #3
0
// 获取未结算的购物车
func (this *shoppingRep) GetNotBoughtCart(buyerId int) (*shopping.ValueCart, error) {
	var v = new(shopping.ValueCart)
	err := this.Connector.GetOrm().GetBy(v, "is_bought=0 AND buyer_id=?", buyerId)
	if v == nil || err != nil {
		return nil, err
	}

	var items = []*shopping.ValueCartItem{}
	err = this.Connector.GetOrm().Select(&items, "cart_id=?", v.Id)
	if err == nil {
		v.Items = items
	}
	this.setAttachGoodsInfo(v.Items)

	return v, err
}