|
|
@@ -52,6 +52,24 @@ func (self *OrderController) Create() {
|
|
|
//if user.IsBlackUser == 1 {
|
|
|
// self.ReturnError(403, apps.AccountError, "", nil)
|
|
|
//}
|
|
|
+
|
|
|
+ if product.PurchaseLimitCount > 0 {
|
|
|
+ if product.PurchaseLimitCount < count {
|
|
|
+ self.ReturnError(403, []string{apps.OverLimitCount[0], fmt.Sprintf("该商品限购%d件", product.PurchaseLimitCount)}, "", nil)
|
|
|
+ } else {
|
|
|
+ purchaseTotalCount := order_model.GetOrderCountByPIdAndWxUId(pId, wxUId)
|
|
|
+ //历史已经买够到限购数量了
|
|
|
+ if product.PurchaseLimitCount <= purchaseTotalCount {
|
|
|
+ self.ReturnError(403, []string{apps.PurchasedReachLimit[0], fmt.Sprintf("该商品限购%d件", product.PurchaseLimitCount)}, "", nil)
|
|
|
+ }
|
|
|
+ //历史没买够数量,但是历史总数+想购买的数量 超过限购数量
|
|
|
+ if product.PurchaseLimitCount < (purchaseTotalCount + count) {
|
|
|
+ canBuyCount := product.PurchaseLimitCount - purchaseTotalCount
|
|
|
+ self.ReturnError(403, []string{apps.PurchasedReachLimit[0], fmt.Sprintf("您还可以购买%d件", canBuyCount)}, "", nil)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
wxUser := user_model.GetWxUserById(wxUId, true)
|
|
|
if wxUser == nil {
|
|
|
self.ReturnError(403, apps.NoExist, "", nil)
|