|
|
@@ -92,6 +92,23 @@ func (self *PayController) payExchange(oId, payWay, tradPwd, returnUrl, source s
|
|
|
self.ReturnError(403, []string{apps.SeckillIsEnd[0], fmt.Sprintf("%s秒杀活动已经结束", product.Name)}, "", nil)
|
|
|
}
|
|
|
}
|
|
|
+ //限购逻辑
|
|
|
+ if product.PurchaseLimitCount > 0 {
|
|
|
+ if product.PurchaseLimitCount < item.Count {
|
|
|
+ self.ReturnError(403, []string{apps.OverLimitCount[0], fmt.Sprintf("%s商品限购%d件", product.Name, product.PurchaseLimitCount)}, "", nil)
|
|
|
+ } else {
|
|
|
+ purchaseTotalCount := order_model.GetOrderCountByPIdAndWxUId(product.Id, wxUId)
|
|
|
+ //历史已经买够到限购数量了
|
|
|
+ if product.PurchaseLimitCount <= purchaseTotalCount {
|
|
|
+ self.ReturnError(403, []string{apps.PurchasedReachLimit[0], fmt.Sprintf("%s商品限购%d件", product.Name, product.PurchaseLimitCount)}, "", nil)
|
|
|
+ }
|
|
|
+ //历史没买够数量,但是历史总数+想购买的数量 超过限购数量
|
|
|
+ if product.PurchaseLimitCount < (purchaseTotalCount + item.Count) {
|
|
|
+ canBuyCount := product.PurchaseLimitCount - purchaseTotalCount
|
|
|
+ self.ReturnError(403, []string{apps.PurchasedReachLimit[0], fmt.Sprintf("%s您还可以购买%d件", product.Name, canBuyCount)}, "", nil)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
buy_price_total += product.BuyPrice * item.Count
|
|
|
total_price += product.Price * item.Count
|
|
|
SaleNumsMap[product.Id] = item.Count
|
|
|
@@ -294,6 +311,23 @@ func (self *PayController) payCentExchange(oId, returnUrl, source string) {
|
|
|
if product.Status == product_model.PRODUCT_STATUS_DOWN {
|
|
|
self.ReturnError(403, []string{apps.ProductOffSale[0], fmt.Sprintf("%s产品已经下架", product.Name)}, "", nil)
|
|
|
}
|
|
|
+ //限购逻辑
|
|
|
+ if product.PurchaseLimitCount > 0 {
|
|
|
+ if product.PurchaseLimitCount < item.Count {
|
|
|
+ self.ReturnError(403, []string{apps.OverLimitCount[0], fmt.Sprintf("%s商品限购%d件", product.Name, product.PurchaseLimitCount)}, "", nil)
|
|
|
+ } else {
|
|
|
+ purchaseTotalCount := order_model.GetOrderCountByPIdAndWxUId(product.Id, wxUId)
|
|
|
+ //历史已经买够到限购数量了
|
|
|
+ if product.PurchaseLimitCount <= purchaseTotalCount {
|
|
|
+ self.ReturnError(403, []string{apps.PurchasedReachLimit[0], fmt.Sprintf("%s商品限购%d件", product.Name, product.PurchaseLimitCount)}, "", nil)
|
|
|
+ }
|
|
|
+ //历史没买够数量,但是历史总数+想购买的数量 超过限购数量
|
|
|
+ if product.PurchaseLimitCount < (purchaseTotalCount + item.Count) {
|
|
|
+ canBuyCount := product.PurchaseLimitCount - purchaseTotalCount
|
|
|
+ self.ReturnError(403, []string{apps.PurchasedReachLimit[0], fmt.Sprintf("%s您还可以购买%d件", product.Name, canBuyCount)}, "", nil)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
buy_price_total += product.BuyPrice * item.Count
|
|
|
total_price += product.Price * item.Count
|
|
|
SaleNumsMap[product.Id] = item.Count
|