Ver código fonte

order purchase limit logic edit

abiao 5 anos atrás
pai
commit
5f80c181f5

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

@@ -1,6 +1,7 @@
 package order_controller
 
 import (
+	"fmt"
 	"fohow.com/apps"
 	"fohow.com/apps/models/order_model"
 	"fohow.com/apps/models/product_model"
@@ -45,6 +46,13 @@ func (self *OrderController) CreateCart() {
 		}
 	}
 
+	//限购逻辑
+	if product.PurchaseLimitCount > 0 {
+		if product.PurchaseLimitCount < count {
+			self.ReturnError(403, []string{apps.OverLimitCount[0], fmt.Sprintf("该商品限购%d件", product.PurchaseLimitCount)}, "", nil)
+		}
+	}
+
 	cart := new(order_model.Cart).Create(wxUId, uId, product.Id, count)
 	result := false
 	if cart != nil {