|
@@ -63,6 +63,7 @@ func (self *PayController) payExchange(oId, payWay, tradPwd, returnUrl, source,
|
|
|
self.ReturnError(403, apps.NotUnPay, "", nil)
|
|
self.ReturnError(403, apps.NotUnPay, "", nil)
|
|
|
}
|
|
}
|
|
|
SaleNumsMap := make(map[int64]int64)
|
|
SaleNumsMap := make(map[int64]int64)
|
|
|
|
|
+ storeMap := make(map[int64]int64)
|
|
|
//支付方式判断
|
|
//支付方式判断
|
|
|
if (order.OrderType == order_model.ORDER_TYPE_SEKILL || order.OrderType == order_model.ORDER_TYPE_SHOP) && payWay == pay_model.PAYWAY_BALANCE {
|
|
if (order.OrderType == order_model.ORDER_TYPE_SEKILL || order.OrderType == order_model.ORDER_TYPE_SHOP) && payWay == pay_model.PAYWAY_BALANCE {
|
|
|
self.ReturnError(403, apps.NotRightPayWay, "", nil)
|
|
self.ReturnError(403, apps.NotRightPayWay, "", nil)
|
|
@@ -110,10 +111,10 @@ func (self *PayController) payExchange(oId, payWay, tradPwd, returnUrl, source,
|
|
|
buy_price_total += product.BuyPrice * item.Count
|
|
buy_price_total += product.BuyPrice * item.Count
|
|
|
total_price += product.Price * item.Count
|
|
total_price += product.Price * item.Count
|
|
|
SaleNumsMap[product.Id] = item.Count
|
|
SaleNumsMap[product.Id] = item.Count
|
|
|
|
|
+ storeMap[product.Id] = item.Count
|
|
|
}
|
|
}
|
|
|
beego.BeeLogger.Error("SaleNumsMap1 %v", SaleNumsMap)
|
|
beego.BeeLogger.Error("SaleNumsMap1 %v", SaleNumsMap)
|
|
|
|
|
|
|
|
- storeMap := SaleNumsMap
|
|
|
|
|
resultStore, prdName := FindNotEnoughPrd(storeMap)
|
|
resultStore, prdName := FindNotEnoughPrd(storeMap)
|
|
|
if resultStore {
|
|
if resultStore {
|
|
|
self.ReturnError(403, []string{apps.ProductStockNotEnough[0], fmt.Sprintf("%s商品库存不足", prdName)}, "", nil)
|
|
self.ReturnError(403, []string{apps.ProductStockNotEnough[0], fmt.Sprintf("%s商品库存不足", prdName)}, "", nil)
|
|
@@ -426,24 +427,23 @@ func CreateOrderNotify(order *order_model.Order, product *product_model.Product)
|
|
|
|
|
|
|
|
//获取库存不足商品
|
|
//获取库存不足商品
|
|
|
func FindNotEnoughPrd(storeMap map[int64]int64) (bool, string) {
|
|
func FindNotEnoughPrd(storeMap map[int64]int64) (bool, string) {
|
|
|
- buyList := storeMap
|
|
|
|
|
//判断商品库存
|
|
//判断商品库存
|
|
|
- for pId, nums := range buyList {
|
|
|
|
|
|
|
+ for pId, nums := range storeMap {
|
|
|
product := product_model.GetProductById(pId, true)
|
|
product := product_model.GetProductById(pId, true)
|
|
|
if product.Package {
|
|
if product.Package {
|
|
|
beego.BeeLogger.Error("product id %d", product.Id)
|
|
beego.BeeLogger.Error("product id %d", product.Id)
|
|
|
packageList := product_model.GetPackageList(pId, true)
|
|
packageList := product_model.GetPackageList(pId, true)
|
|
|
for _, one := range packageList {
|
|
for _, one := range packageList {
|
|
|
- if _, ok := buyList[one.ItemId]; ok {
|
|
|
|
|
|
|
+ if _, ok := storeMap[one.ItemId]; ok {
|
|
|
//基本商品存在
|
|
//基本商品存在
|
|
|
- buyList[one.ItemId] = buyList[one.ItemId] + nums*one.Nums
|
|
|
|
|
|
|
+ storeMap[one.ItemId] = storeMap[one.ItemId] + nums*one.Nums
|
|
|
} else {
|
|
} else {
|
|
|
- buyList[one.ItemId] = nums * one.Nums
|
|
|
|
|
|
|
+ storeMap[one.ItemId] = nums * one.Nums
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- for r_pid, r_nums := range buyList {
|
|
|
|
|
|
|
+ for r_pid, r_nums := range storeMap {
|
|
|
product := product_model.GetProductById(r_pid, true)
|
|
product := product_model.GetProductById(r_pid, true)
|
|
|
if product.Count > int64(0) && product.Count < r_nums {
|
|
if product.Count > int64(0) && product.Count < r_nums {
|
|
|
return true, product.Name
|
|
return true, product.Name
|