Преглед изворни кода

order add single purcha_limit

abiao пре 5 година
родитељ
комит
0424ca6fce

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

@@ -53,6 +53,11 @@ func (self *OrderController) CreateCart() {
 		}
 	}
 
+	if product.SinglePurchLimit > 0 {
+		if product.SinglePurchLimit < count {
+			self.ReturnError(403, []string{apps.SingleOverLimitCount[0], fmt.Sprintf("该商品单次限购%d件", product.SinglePurchLimit)}, "", nil)
+		}
+	}
 	cart := new(order_model.Cart).Create(wxUId, uId, product.Id, count)
 	result := false
 	if cart != nil {

+ 21 - 2
go/gopath/src/fohow.com/apps/controllers/order_controller/order_controller.go

@@ -52,7 +52,11 @@ func (self *OrderController) Create() {
 	//if user.IsBlackUser == 1 {
 	//	self.ReturnError(403, apps.AccountError, "", nil)
 	//}
-
+	if product.SinglePurchLimit > 0 {
+		if product.SinglePurchLimit < count {
+			self.ReturnError(403, []string{apps.SingleOverLimitCount[0], fmt.Sprintf("该商品单次限购%d件", product.SinglePurchLimit)}, "", nil)
+		}
+	}
 	if product.PurchaseLimitCount > 0 {
 		if product.PurchaseLimitCount < count {
 			self.ReturnError(403, []string{apps.OverLimitCount[0], fmt.Sprintf("该商品限购%d件", product.PurchaseLimitCount)}, "", nil)
@@ -184,7 +188,11 @@ func (self *OrderController) MultipleCreate() {
 		if product == nil {
 			self.ReturnError(403, apps.NoExist, "", nil)
 		}
-
+		if product.SinglePurchLimit > 0 {
+			if product.SinglePurchLimit < cNums {
+				self.ReturnError(403, []string{apps.SingleOverLimitCount[0], fmt.Sprintf("该商品单次限购%d件", product.SinglePurchLimit)}, "", nil)
+			}
+		}
 		if product.PurchaseLimitCount > 0 {
 			if product.PurchaseLimitCount < cNums {
 				self.ReturnError(403, []string{apps.OverLimitCount[0], fmt.Sprintf("%s商品限购%d件", product.Name, product.PurchaseLimitCount)}, "", nil)
@@ -202,6 +210,7 @@ func (self *OrderController) MultipleCreate() {
 			}
 		}
 	}
+
 	//创建订单
 	order := new(order_model.Order).CreateNew(wxUId, uId,
 		totalPrice, int64(0), order_model.ORDER_TYPE_NORMAL, wxUser.Depart, order_model.SOURCE_XCX)
@@ -282,6 +291,11 @@ func (self *OrderController) MultShopCreate() {
 		if product.Ptype != product_model.SHOP_SALE {
 			self.ReturnError(403, apps.NoShopSale, "", nil)
 		}
+		if product.SinglePurchLimit > 0 {
+			if product.SinglePurchLimit < cNums {
+				self.ReturnError(403, []string{apps.SingleOverLimitCount[0], fmt.Sprintf("该商品单次限购%d件", product.SinglePurchLimit)}, "", nil)
+			}
+		}
 		//商品限购判断
 		if product.PurchaseLimitCount > 0 {
 			if product.PurchaseLimitCount < cNums {
@@ -351,6 +365,11 @@ func (self *OrderController) MultCentCreate() {
 		if product.Ptype != product_model.CENT_SALE {
 			self.ReturnError(403, apps.NoShopSale, "", nil)
 		}
+		if product.SinglePurchLimit > 0 {
+			if product.SinglePurchLimit < cNums {
+				self.ReturnError(403, []string{apps.SingleOverLimitCount[0], fmt.Sprintf("该商品单次限购%d件", product.SinglePurchLimit)}, "", nil)
+			}
+		}
 		//商品限购判断
 		if product.PurchaseLimitCount > 0 {
 			if product.PurchaseLimitCount < cNums {

+ 3 - 1
go/gopath/src/fohow.com/apps/init.go

@@ -96,7 +96,9 @@ var (
 	ProductNotApproved    = []string{"productNotApproved", "产品还未上架"}
 	ProductOffSale        = []string{"productOffSale", "产品已经下架"}
 	OverLimitCount        = []string{"overLimitCount", "超过限购数量"}
-	PurchasedReachLimit   = []string{"purchasedReachLimit", "已购买总数已达到限购数量"}
+	SingleOverLimitCount  = []string{"singleOverLimitCount", "超过限购数量"}
+
+	PurchasedReachLimit = []string{"purchasedReachLimit", "已购买总数已达到限购数量"}
 
 	RedirectTo = []string{"redirectTo", "302跳转"}
 	ReduceFail = []string{"reduceFail", "帮砍失败"}

+ 10 - 8
go/gopath/src/fohow.com/apps/models/product_model/product.go

@@ -95,14 +95,16 @@ type Product struct {
 	VideoUrl   string `orm:"column(video_url)"                       json:"video_url"` // varchar(255)
 	VideoImg   string `orm:"-"                       json:"video_img"`                 // varchar(255)
 	//规格相关
-	RelateProductId int64  `orm:"column(relate_product_id)"                          json:"relate_product_id"` // varchar(255)
-	ShowFlag        bool   `orm:"column(show_flag)"                          json:"-"`                         // varchar(255)
-	SizeId          int64  `orm:"column(size_id)"                          json:"size_id"`                     // varchar(255)
-	ColorId         int64  `orm:"column(color_id)"                          json:"color_id"`                   // varchar(255)
-	HaveSize        bool   `orm:"-"                         json:"have_size"`                                  // bool
-	IsZeng          bool   `orm:"-"                         json:"is_zeng"`                                    // bool
-	SizeName        string `orm:"-"                       json:"size_name"`                                    // varchar(255)
-	ColorName       string `orm:"-"                       json:"color_name"`                                   // varchar(255)
+	RelateProductId  int64  `orm:"column(relate_product_id)"                          json:"relate_product_id"` // varchar(255)
+	ShowFlag         bool   `orm:"column(show_flag)"                          json:"-"`                         // varchar(255)
+	SizeId           int64  `orm:"column(size_id)"                          json:"size_id"`                     // varchar(255)
+	ColorId          int64  `orm:"column(color_id)"                          json:"color_id"`                   // varchar(255)
+	HaveSize         bool   `orm:"-"                         json:"have_size"`                                  // bool
+	IsZeng           bool   `orm:"-"                         json:"is_zeng"`                                    // bool
+	SizeName         string `orm:"-"                       json:"size_name"`                                    // varchar(255)
+	ColorName        string `orm:"-"                       json:"color_name"`                                   // varchar(255)
+	SinglePurchLimit int64  `orm:"column(single_purch_limit)"     json:"-"`                                     // varchar(255)
+
 }
 
 //获取最新推荐商品