Browse Source

用户配套订单,取消功能

lizhen_gitee 8 months ago
parent
commit
167df5554f

+ 26 - 0
application/admin/controller/Packageorder.php

@@ -108,6 +108,32 @@ class Packageorder extends Backend
         $this->success(__('已激活'));
 
     }
+    /**
+     * 取消
+     */
+    public function cancel(){
+        $id = input('id',0);
+
+        $package_order = Db::name('package_order')->where('id',$id)->find();
+        if(empty($package_order)){
+            $this->error(__('请刷新重试'));
+        }
+
+        if($package_order['order_status'] != 1){
+            $this->error(__('请刷新重试'));
+        }
+
+        $time = time();
+
+        $update = [
+            'updatetime'   => $time,
+        ];
+        $update['order_status'] = 10;
+
+        $rs = Db::name('package_order')->where('id',$id)->update($update);
+        $this->success(__('已取消'));
+
+    }
 
     /**
      * 添加

+ 2 - 0
application/admin/lang/en/packageorder.php

@@ -15,6 +15,7 @@ return [
     'Order_status'    => 'Order status',
     'Order_status 0'  => 'unpaid',
     'Order_status 1'  => 'have paid',
+    'Order_status 10'  => 'have canceled',
     'Use_status'      => 'activate status',
     'Use_status 0'    => 'not active',
     'Use_status 1'    => 'Active',
@@ -39,5 +40,6 @@ return [
     'Package.name_en' => 'Package name(en)',
     '激活'             => 'Get activation',
     '已激活'           => 'Activation successful',
+    '已取消'           => 'Cancel successful',
     '请刷新重试'           => 'Refresh and try again',
 ];

+ 13 - 0
public/assets/js/backend/packageorder.js

@@ -73,6 +73,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     },
                                     refresh:{silent:true},
                                 },
+                                {
+                                    name:'cancel',
+                                    text:__('取消'),
+                                    title:__('取消'),
+                                    icon:'fa fa-exclamation-circle',
+                                    classname:'btn btn-xs btn-info btn-ajax',
+                                    url:'packageorder/cancel/id/{ids}?dialog=1',
+                                    target:'_self',
+                                    refresh:{silent:true},
+                                },
                             ],
                             events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
@@ -85,6 +95,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         jihuo: function () {
             Controller.api.bindevent();
         },
+        cancel: function () {
+            Controller.api.bindevent();
+        },
         add: function () {
             Controller.api.bindevent();
         },