xieruidong il y a 2 ans
Parent
commit
08d956f19e

+ 1 - 0
application/common/model/OrderInfo.php

@@ -7,6 +7,7 @@ use think\Model;
 
 /**
  * @property Orders orders
+ * @property int id
  * @property int order_id
  * @property float amount_goods_real
  * @property Refund refund

+ 9 - 5
application/common/service/RefundService.php

@@ -38,11 +38,14 @@ class RefundService extends BaseService {
             }else{
                 $orderInfoAmount=OrderInfo::where('order_id',$orderInfo->order_id)->whereIn('goods_id',$goodsId)->column('amount_goods_real','id');
             }
-            $totalAmount=array_sum(array_values($orderInfoAmount));
-            $per=bcdiv($couponAmountTotal,$totalAmount);
-            $num=$orderInfo['num'];
-            $thisAmount=$orderInfo->amount_goods_real;
-            $couponAmount=bcdiv($thisAmount/$per,$num);
+            if(isset($orderInfoAmount[$orderInfo->id])) {
+                $totalAmount = array_sum(array_values($orderInfoAmount));
+                $per = bcdiv($couponAmountTotal, $totalAmount);
+                $num = $orderInfo['num'];
+                $thisAmount = $orderInfo->amount_goods_real;
+                $couponAmount = bcdiv($thisAmount * $per, $num);
+                dd($couponAmount);
+            }
         }
 
         $amount=bcsub($amount,$couponAmount);
@@ -54,6 +57,7 @@ class RefundService extends BaseService {
         }
         #退商品金额,退安装费金额
         $arr=[$amount,$amount_install];
+
         if($total){
             return bcadd($arr[0],$arr[1]);
         }