瀏覽代碼

Merge branch 'liuxiangxin' into jun

jun 3 月之前
父節點
當前提交
7f2df6f6ae
共有 2 個文件被更改,包括 6 次插入6 次删除
  1. 5 5
      app/Http/Controllers/Api/Orders.php
  2. 1 1
      app/Models/Orders.php

+ 5 - 5
app/Http/Controllers/Api/Orders.php

@@ -259,11 +259,11 @@ class Orders extends Api{
 			foreach ($order['product_list'] as $k=>$product) {
                 //促销活动扣减
                 if (isset($promoProductPrice[$product['product_id']]['promo_rebate_price']) && $promoProductPrice[$product['product_id']]['promo_rebate_price']> 0){
-                    // 总优惠增加
-                    $order['coupon_total']	 = $order['coupon_total']  + $promoProductPrice[$product['product_id']]['promo_rebate_price'];
                     // 当前商品的优惠折扣计算
                     $product['coupon_total'] = number_format( $promoProductPrice[$product['product_id']]['rebate_price'] * ($product['price_total'] / $promoProductPrice[$product['product_id']]['price_total']) , 2 , '.' ,'');
-                    // 成交小计
+                    // 总优惠增加
+                    $order['coupon_total']	 = $order['coupon_total']  + $product['coupon_total'];
+					// 成交小计
                     $product['pay_total']	 = $product['pay_total'] -  $product['coupon_total'];
                 }
 				// 商品不存在,不进行扣减
@@ -272,10 +272,10 @@ class Orders extends Api{
 					$order['product_list'][$k] = $product;
 					continue;
 				}
-				// 总优惠增加
-				$order['coupon_total']	 = $order['coupon_total']  + $productPrice[$product['product_id']]['rebate_price'];
 				// 当前商品的优惠折扣计算
 				$product['coupon_total'] = number_format( $productPrice[$product['product_id']]['rebate_price'] * ($product['price_total'] / $productPrice[$product['product_id']]['price_total']) , 2 , '.' ,'');
+				// 总优惠增加
+				$order['coupon_total']	 = $order['coupon_total']  + $product['coupon_total'];
 				// 成交小计
 				$product['pay_total']	 = $product['pay_total'] -  $product['coupon_total'];
 				// 重组

+ 1 - 1
app/Models/Orders.php

@@ -188,7 +188,7 @@ class Orders extends Model
             // 没有产品就不执行
             if( !$value['product_id'] ) continue;
             // 恢复库存
-            $ProductSkus->query()->where([['product_id','=',$value['product_id']],['sku_attr_names','=',$value['sku_attr_names']]])->update(['stock'=>DB::raw('stock+'.$value['buy_num'])]);
+            $ProductSkus->query()->where([['product_id','=',$value['product_id']],['attr_names','=',$value['sku_attr_names']]])->update(['stock'=>DB::raw('stock+'.$value['buy_num'])]);
             // 恢复库存
             $Product->edit($value['product_id'],['stock'=>DB::raw('stock+'.$value['buy_num'])]);
         }