瀏覽代碼

增加商品混合支付

abiao 4 年之前
父節點
當前提交
47747866f2

+ 15 - 3
go/gopath/src/fohow.com/apps/controllers/order_controller/order_controller.go

@@ -261,7 +261,7 @@ func (self *OrderController) MultipleCreate() {
 	order.Save()
 
 	//购物册清理
-	go ClearCart(order.UserId, order.OrderId)
+	go ClearCart(order.WxUserId, order.OrderId)
 	//未支付订单加入取消队列
 	cancelKey := lib_redis.GetOrderCancelList()
 	lib_redis.ThrowInRedisList(cancelKey, order.OrderId)
@@ -458,14 +458,26 @@ func (self *OrderController) MultCentCreate() {
 	self.ServeJSON()
 }
 
-func ClearCart(userId int64, orderId string) {
+func ClearCart(wxUserId int64, orderId string) {
 	orderDetails := order_model.GetAllDetailsOrderId(orderId, false)
 	for _, item := range orderDetails {
-		cartItem := order_model.GetCartByUidAndPid(userId, item.ProductId)
+		cartItem := order_model.GetCartByWxUidAndPid(wxUserId, item.ProductId)
 		if cartItem != nil {
 			cartItem.Delete()
 		}
 	}
+	//清除过期的秒杀商品项
+	list := order_model.GetCartItemsByWxUserId(wxUserId)
+	for _, item := range list {
+		product := product_model.GetProductById(item.ProductId, true)
+		if product != nil {
+			if product.SeckilShowPrice > 0 && product.SeckillEndAt < time.Now().Unix() {
+				cartItem := order_model.GetCartByWxUidAndPid(wxUserId, item.ProductId)
+				cartItem.Delete()
+			}
+		}
+
+	}
 }
 
 //获取用户订单详情

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

@@ -140,17 +140,6 @@ func GetCartById(id int64) (cart *Cart) {
 	return cart
 }
 
-// 根据UserId,productId获取购物车记录
-func GetCartByUidAndPid(uId, pId int64) (cart *Cart) {
-	cart = &Cart{}
-	if err := orm.NewOrm().QueryTable(cart).Filter("user_id", uId).Filter("product_id", pId).Limit(1).
-		One(cart); err != nil {
-		beego.BeeLogger.Error("get cart by uId=%d err=%s", uId, err)
-		cart = nil
-	}
-	return cart
-}
-
 // 根据wxUserId,productId获取购物车记录
 func GetCartByWxUidAndPid(wxUserId, pId int64) (cart *Cart) {
 	cart = &Cart{}