Parcourir la source

购物车更新

abiao il y a 3 ans
Parent
commit
6847ab61e2

+ 1 - 1
go/gopath/src/fohow.com/apps/controllers/order_controller/cart_controller.go

@@ -61,7 +61,7 @@ func (self *OrderController) CreateCart() {
 	}
 
 	wxUser := self.GetCurrentWxUser(false)
-	cart := new(order_model.Cart).Create(wxUId, wxUser.Id, product.Id, count)
+	cart := new(order_model.Cart).Create(wxUId, wxUser.UserId, product.Id, count)
 	result := false
 	if cart != nil {
 		result = true

+ 2 - 2
go/gopath/src/fohow.com/apps/models/order_model/cart.go

@@ -49,7 +49,7 @@ func (self *Cart) TableName() string {
 //创建订单项
 func (self *Cart) Create(wxId, uId, pId,
 	pCount int64) *Cart {
-	item := GetCartItemsByUserIdAndPid(uId, pId)
+	item := GetCartItemsByUserIdAndPid(wxId, pId)
 	if item == nil {
 		item = &Cart{
 			WxUserId:  wxId,
@@ -91,7 +91,7 @@ func (self *Cart) Delete() error {
 //根据会员Id,产品ID获取订单项
 func GetCartItemsByUserIdAndPid(uId, pid int64) (cart *Cart) {
 	cart = &Cart{}
-	if err := orm.NewOrm().QueryTable(cart).Filter("user_id", uId).Filter("product_id", pid).Limit(1).
+	if err := orm.NewOrm().QueryTable(cart).Filter("wx_user_id", uId).Filter("product_id", pid).Limit(1).
 		One(cart); err != nil {
 		//beego.BeeLogger.Error("get cart by user_id=%d  product_id=%d err=%s", uId, pid, err)
 		cart = nil