Browse Source

双十一活动

gorden 4 tháng trước cách đây
mục cha
commit
29841e1f93

+ 4 - 0
app/admin/controller/coupon/CouponController.php

@@ -358,6 +358,10 @@ class CouponController extends Curd
             $couponJson['premises_range'] = '部分门店可用';
         }
 
+        if (in_array($data['coupon_classify'],['抵用券','立减券','赠品券','福利券','年卡','季卡','月卡'])) {
+            $data['coupon_minimum_limit'] = 0;
+        }
+
         $data['coupon_json'] = json_encode($couponJson, JSON_UNESCAPED_UNICODE);
 
         // 处理周期优惠券

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

@@ -1785,8 +1785,8 @@ class GoodsController extends Curd
                 }
             }
             // 推荐人
-            $orderAmount = [];
             $params['order_extend_json']['referee'] = $params['referee'] ?? '';
+            $orderAmount = [];
             foreach ($params['goodsContentList'] as $goods) {
                 $amountPay = floatval($goods['goods_sales_price']) * $goods['nbr'];
                 $discountJson = [];

+ 15 - 3
app/admin/controller/order/ServicesController.php

@@ -1918,18 +1918,30 @@ class ServicesController extends Curd
             }
             // 推荐人
             $params['order_extend_json']['referee'] = $params['referee'] ?? '';
+            $orderAmount = [];
             foreach ($params['goodsContentList'] as $goods) {
+                $amountPay = floatval($goods['goods_sales_price']) * $goods['nbr'];
                 $discountJson = [];
                 if (!empty($params['order_discount_json'])) {
                     $discountJson = json_decode($params['order_discount_json'], true);
                     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']);
+                            if (in_array($goods['goods_id'], $orderAmount['goodsIds'])) {
+                                $amountPay = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $orderAmount['amount']) * $payAmountUseCoupon, 2);
+                            }
+                        } else {
+                            $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'] / $params['order_amount_total']) * $item['coupon_value'], 2);
+                            $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');
-                $amountPay = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $params['order_amount_total']) * $params['order_amount_pay'], 2);
+//                $amountPay = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $params['order_amount_total']) * $params['order_amount_pay'], 2);
 //                $amountPay = round(floatval($goods['goods_sales_price']) * $goods['nbr'] * $params['order_ratio'], 2);
                 $data = [
                     'order_id' => $orderId,
@@ -1946,7 +1958,7 @@ class ServicesController extends Curd
                     'order_status_storage' => $params['order_status_storage'],
                     'order_platform' => $params['order_platform'],
                     'order_remark' => $params['order_remark'] ?? '',
-                    'order_discount_json' => json_encode($discountJson),
+                    'order_discount_json' => (!empty($orderAmount['goodsIds']) && in_array($goods['goods_id'], $orderAmount['goodsIds'])) || (empty($orderAmount['goodsIds']) && !empty($orderAmount['amount'])) ? json_encode($discountJson) : '[]',
                     'order_config_json' => $params['order_config_json'] ?? '[]',
                     'order_express_json' => $params['order_express_json'] ?? '[]',
                     'order_extend_json' => $params['order_extend_json'] ? json_encode($params['order_extend_json']) : '[]',