wesmiler 11 часов назад
Родитель
Сommit
de474e3c18
1 измененных файлов с 18 добавлено и 11 удалено
  1. 18 11
      app/Services/Api/GoodsService.php

+ 18 - 11
app/Services/Api/GoodsService.php

@@ -349,15 +349,18 @@ class GoodsService extends BaseService
                     $couponTotal = isset($couponData['coupon_total'])?$couponData['coupon_total'] : 0;
                     $payTotal = isset($couponData['total'])?$couponData['total'] : 0;
                     if($payTotal){
-                        $total = $payTotal;
+                        $item['total'] = $payTotal;
+                        //$total = $payTotal;
                         $item['coupon_id'] = $couponId;
                         $item['coupon_total'] = floatval($couponTotal);
                         $result['coupon_id'] = $couponId;
                         $result['coupon_total'] = floatval($couponTotal);
                         $isGoodsCoupon = true;
+                    }else{
+                        $item['total'] = $total;
                     }
 
-                    $item['total'] = $total;
+
                     $item['thumb'] = $orderNo?get_image_path($item['thumb']):$item['thumb'];
                     $result['goods'][] = $item;
                     $result['goods_total'] += $total;
@@ -366,25 +369,29 @@ class GoodsService extends BaseService
                 }
             }
 
-            // 会员折扣
-            $orderTotal = $result['order_total'];
-            if($discountPoint>0 && $discountPoint<10){
-                $result['order_total'] = floatval(moneyFormat( $result['order_total']*$discountPoint/10,2));
-                $result['discount_total'] = floatval(moneyFormat($orderTotal - $result['order_total'],2));
-            }
-
             // 非商品优惠券,整个订单的优惠券
+            $discountTotal = 0;
+            $couponTotal =  $result['coupon_total'];
             if($couponId && !$isGoodsCoupon){
-                $couponData = $this->countCouponTotal(0, $orderTotal, $couponInfo);
+                $couponData = $this->countCouponTotal(0, $result['order_total'], $couponInfo);
                 if(!$couponData){
                     return false;
                 }
 
                 $couponTotal = isset($couponData['coupon_total'])?$couponData['coupon_total'] : 0;
-                $result['order_total'] = floatval(isset($couponData['total'])?$couponData['total'] : 0);
                 $result['coupon_total'] = floatval($couponTotal);
             }
 
+            // 会员折扣
+            if($discountPoint>0 && $discountPoint<10){
+                $discountTotal = floatval(moneyFormat( $result['order_total']*(1-$discountPoint/10),2));
+                $result['discount_total'] = $discountTotal;
+            }
+
+            // 折后订单总金额
+            $result['order_total'] = floatval(moneyFormat($result['order_total']-$couponTotal-$discountTotal,2));
+
+            // 实付订单总金额加上运费
             $result['pay_total'] = floatval(moneyFormat($result['order_total'] + $result['delivery_fee'],2));
             return $result;
         }