|
|
@@ -125,7 +125,7 @@ func (self *OrderController) ChangeItemState() {
|
|
|
//批量调整购物车项目是否购买
|
|
|
func (self *OrderController) MultChangeItemState() {
|
|
|
|
|
|
- uId := self.GetCurrentUserId()
|
|
|
+ //uId := self.GetCurrentUserId()
|
|
|
wxUId := self.GetCurrentWxUserId()
|
|
|
ids := self.GetString("ids")
|
|
|
nums := self.GetString("nums")
|
|
|
@@ -134,7 +134,7 @@ func (self *OrderController) MultChangeItemState() {
|
|
|
self.ReturnError(403, apps.ParamsError, "", nil)
|
|
|
}
|
|
|
//先取消,后设置
|
|
|
- list := order_model.GetCartItemsByUserId(uId)
|
|
|
+ list := order_model.GetCartItemsByWxUserId(wxUId)
|
|
|
for _, item := range list {
|
|
|
item.IsBuy = false
|
|
|
item.Save()
|
|
|
@@ -174,9 +174,9 @@ func (self *OrderController) MultChangeItemState() {
|
|
|
func (self *OrderController) ChangeAllState() {
|
|
|
|
|
|
state, _ := self.GetBool("state", false)
|
|
|
- uId := self.GetCurrentUserId()
|
|
|
+ //uId := self.GetCurrentUserId()
|
|
|
wxUId := self.GetCurrentWxUserId()
|
|
|
- list := order_model.GetCartItemsByUserId(uId)
|
|
|
+ list := order_model.GetCartItemsByWxUserId(wxUId)
|
|
|
for _, item := range list {
|
|
|
cartItem := order_model.GetCartById(item.Id)
|
|
|
if cartItem == nil {
|
|
|
@@ -201,13 +201,13 @@ func (self *OrderController) ChangeAllState() {
|
|
|
//获取会员购物车信息
|
|
|
func (self *OrderController) GetCartList() {
|
|
|
cache, _ := self.GetBool("cache", false)
|
|
|
- uId := self.GetCurrentUserId()
|
|
|
- list := order_model.GetCartItemsByUserId(uId)
|
|
|
+ wxUserId := self.GetCurrentWxUserId()
|
|
|
+ list := order_model.GetCartItemsByWxUserId(wxUserId)
|
|
|
|
|
|
for _, item := range list {
|
|
|
product := product_model.GetProductById(item.ProductId, cache)
|
|
|
if product == nil {
|
|
|
- go ClearProductCart(uId, item.ProductId)
|
|
|
+ go ClearProductCart(wxUserId, item.ProductId)
|
|
|
continue
|
|
|
}
|
|
|
wxUser := user_model.GetWxUserById(item.WxUserId, cache)
|
|
|
@@ -234,12 +234,12 @@ func (self *OrderController) GetCartList() {
|
|
|
}
|
|
|
count := int64(0)
|
|
|
total := int64(0)
|
|
|
- buylist := order_model.GetCartItemsByUserIdAndBuy(uId, true)
|
|
|
- for _, item := range buylist {
|
|
|
- product := product_model.GetProductById(item.ProductId, cache)
|
|
|
- count += item.Count
|
|
|
- total += item.Count * product.Price
|
|
|
- }
|
|
|
+ /* buylist := order_model.GetCartItemsByUserIdAndBuy(uId, true)
|
|
|
+ for _, item := range buylist {
|
|
|
+ product := product_model.GetProductById(item.ProductId, cache)
|
|
|
+ count += item.Count
|
|
|
+ total += item.Count * product.Price
|
|
|
+ }*/
|
|
|
|
|
|
type Ret struct {
|
|
|
List []*order_model.Cart `json:"list"`
|
|
|
@@ -251,7 +251,7 @@ func (self *OrderController) GetCartList() {
|
|
|
}
|
|
|
|
|
|
func ClearProductCart(userId, productId int64) {
|
|
|
- cartItem := order_model.GetCartByUidAndPid(userId, productId)
|
|
|
+ cartItem := order_model.GetCartByWxUidAndPid(userId, productId)
|
|
|
if cartItem != nil {
|
|
|
cartItem.Delete()
|
|
|
}
|