Browse Source

提交订单

lizhen_gitee 7 months ago
parent
commit
01db37124b

+ 18 - 10
addons/unishop/behavior/Order.php

@@ -193,11 +193,8 @@ class Order
         // 条件四
         if ($extra['coupon_id']) {
 
-            /*$coupon = Coupon::get($extra['coupon_id']);
+//            $coupon = Coupon::get($extra['coupon_id']);
 
-            if ($coupon['switch'] == Coupon::SWITCH_OFF || $coupon['deletetime'] || $coupon['starttime'] > time() || $coupon['endtime'] < time()) {
-                throw new Exception('此优惠券不可用');
-            }*/
             $coupon = Db::name('unishop_coupon_user')->alias('cu')
                 ->field(['c.id','c.title','c.least','c.value','c.starttime','c.endtime'])
                 ->join('unishop_coupon c','cu.coupon_id = c.id','LEFT')
@@ -205,14 +202,25 @@ class Order
                 ->where('cu.status',0)
                 ->where('c.deletetime',NULL)
                 ->where('c.switch',Coupon::SWITCH_ON)
-                ->where('c.starttime','<',time())
-                ->where('c.endtime','>',time())
-                ->find('c.id',$extra['coupon_id']);
+//                ->where('c.starttime','<',time())
+//                ->where('c.endtime','>',time())
+                ->where('c.id',$extra['coupon_id'])
+                ->find();
+
+            if(!empty($coupon)){
+
+                if ($coupon['starttime'] > time() || $coupon['endtime'] < time()) {
+                    throw new Exception('此优惠券不可用');
+                }
 
-            // 至少消费多少钱
-            if (!empty($coupon) && $coupon['least'] > $orderPrice) {
-                throw new Exception('选中的优惠券不满足使用条件');
+                // 至少消费多少钱
+                if ($coupon['least'] > $orderPrice) {
+                    throw new Exception('选中的优惠券不满足使用条件');
+                }
+            }else{
+                $coupon = [];
             }
+
         } else {
             $coupon = [];
         }

+ 7 - 3
addons/unishop/model/Order.php

@@ -263,20 +263,24 @@ class Order extends Model
             'ip' => $_SERVER['REMOTE_ADDR'] ?? '',
             'remark' => $data['remark'] ?? '',
             'status' => self::STATUS_NORMAL,
+
+            'booktime' => $data['booktime'] ?? '',
+            'book_realname' => $data['book_realname'] ?? '',
+            'book_mobile' => $data['book_mobile'] ?? '',
         ]);
 
+
         (new OrderExtend)->save([
             'user_id' => $userId,
             'order_id' => $id,
             'coupon_id' => $coupon ? $coupon['id'] : 0,
             'coupon_json' => json_encode($coupon),
-            'delivery_id' => $delivery['id'],
+            'delivery_id' => $delivery ? $delivery['id'] : 0,
             'delivery_json' => json_encode($delivery),
-            'address_id' => $address['id'],
+            'address_id' => $address ? $address['id'] : 0,
             'address_json' => json_encode($address),
         ]);
 
-
         $orderProduct = $specNumber = [];
         foreach($products as $key => $product) {
             $orderProduct[] = [

+ 2 - 2
public/assets/js/backend/unishop/order.js

@@ -117,7 +117,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                             events: Table.api.events.operate,
                             formatter: Table.api.formatter.operate,
                             buttons:[
-                                {
+                                /*{
                                     name: 'refund',
                                     text: __('Refund'),
                                     classname: 'btn btn-xs btn-info btn-refund',
@@ -130,7 +130,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     classname: 'btn btn-xs btn-info btn-delivere',
                                     extend: 'data-toggle="tooltip"',
                                     icon: 'fa fa-plane'
-                                },
+                                },*/
                                 {
                                     name: 'product',
                                     text: __('Product'),