Browse Source

双十一活动

gorden 4 months ago
parent
commit
872ae40247
1 changed files with 5 additions and 5 deletions
  1. 5 5
      app/admin/controller/order/GoodsController.php

+ 5 - 5
app/admin/controller/order/GoodsController.php

@@ -1792,10 +1792,7 @@ class GoodsController extends Curd
                 $discountJson = [];
                 if (!empty($params['order_discount_json'])) {
                     $discountJson = json_decode($params['order_discount_json'], true);
-                    foreach ($discountJson as $item) {
-//                        if (!empty($item['coupon_value'])) {
-//                            $item['coupon_value'] = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $params['order_amount_total']) * $item['coupon_value'], 2);
-//                        }
+                    foreach ($discountJson as &$item) {
                         if (!empty($item['coupon_id'])) {
                             $orderAmount = OrderService::countAndAmount($params['goodsContentList'], $item['coupon_id']);
                             $payAmountUseCoupon = $params['order_amount_pay'] - ($params['order_amount_total'] - $orderAmount['amount']);
@@ -1803,9 +1800,12 @@ class GoodsController extends Curd
                                 $amountPay = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $orderAmount['amount']) * $payAmountUseCoupon, 2);
                             }
                         } else {
-                            $orderAmount['amount'] = $params['order_amount_pay'];
+                            $orderAmount['amount'] = $params['order_amount_total'];
                             $amountPay = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $params['order_amount_total']) * $params['order_amount_pay'], 2);
                         }
+                        if (!empty($item['coupon_value'])) {
+                            $item['coupon_value'] = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $orderAmount['amount']) * $item['coupon_value'], 2);
+                        }
                     }
                 }
                 $orderId = 'OD' . date('ymdHi') . random_string(4, 'up');