Przeglądaj źródła

update pay order product store rules

abiao 4 lat temu
rodzic
commit
347a1e4f09

+ 7 - 7
go/gopath/src/fohow.com/apps/controllers/pay_controller/pay_exchange_controller.go

@@ -63,6 +63,7 @@ func (self *PayController) payExchange(oId, payWay, tradPwd, returnUrl, source,
 		self.ReturnError(403, apps.NotUnPay, "", nil)
 	}
 	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 {
 		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
 		total_price += product.Price * item.Count
 		SaleNumsMap[product.Id] = item.Count
+		storeMap[product.Id] = item.Count
 	}
 	beego.BeeLogger.Error("SaleNumsMap1 %v", SaleNumsMap)
 
-	storeMap := SaleNumsMap
 	resultStore, prdName := FindNotEnoughPrd(storeMap)
 	if resultStore {
 		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) {
-	buyList := storeMap
 	//判断商品库存
-	for pId, nums := range buyList {
+	for pId, nums := range storeMap {
 		product := product_model.GetProductById(pId, true)
 		if product.Package {
 			beego.BeeLogger.Error("product id %d", product.Id)
 			packageList := product_model.GetPackageList(pId, true)
 			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 {
-					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)
 		if product.Count > int64(0) && product.Count < r_nums {
 			return true, product.Name