Browse Source

后台开通vip

lizhen_gitee 3 weeks ago
parent
commit
18e030bd87

+ 34 - 0
application/admin/controller/Userwallet.php

@@ -24,6 +24,9 @@ class Userwallet extends Backend
         parent::_initialize();
         $this->model = new \app\admin\model\Userwallet;
 
+        $VipLevelList = $this->model->getVipLevelList();
+        $this->assign('VipLevelList',$VipLevelList);
+
     }
 
     public function import()
@@ -167,6 +170,37 @@ class Userwallet extends Backend
         return $this->view->fetch();
     }
 
+    /**
+     * 充值VIP
+     */
+    public function updatevip(){
+        $id = input('id');
+        $info = Db::name('user_wallet')->where('id',$id)->find();
+
+        if ($this->request->isPost()) {
+
+            $user_id = input_post('user_id');
+            $vip_level = input_post('vip_level');
+            $vip_endtime = strtotime(input_post('vip_endtime'));
+
+            Db::startTrans();
+            $info = Db::name('user_wallet')->where('user_id',$user_id)->update([
+                'vip_endtime'=>$vip_endtime,
+                'vip_level'=>$vip_level,
+            ]);
+            if($info === false){
+                Db::rollback();
+                $this->error('修改失败');
+            }
+
+            Db::commit();
+            $this->success('充值完成');
+        }
+
+        $this->assign('row',$info);
+        return $this->view->fetch();
+    }
+
 
 
 }

+ 1 - 1
application/admin/model/Userwallet.php

@@ -26,7 +26,7 @@ class Userwallet extends Model
     // 追加属性
     protected $append = [
         'vip_endtime_text',
-       // 'vip_level_text'
+        'vip_level_text'
     ];
     
 

+ 1 - 0
application/admin/view/userwallet/index.html

@@ -27,6 +27,7 @@
                            data-operate-del="{:$auth->check('userwallet/del')}" 
                            data-operate-updategold="{:$auth->check('userwallet/updategold')}"
                            data-operate-updatemoney="{:$auth->check('userwallet/updatemoney')}"
+                           data-operate-updatevip="{:$auth->check('userwallet/updatevip')}"
                            width="100%">
                     </table>
                 </div>

+ 37 - 0
application/admin/view/userwallet/updatevip.html

@@ -0,0 +1,37 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    <input type="hidden" name="id" value="{$row.id}">
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" disabled data-rule="required" data-source="user/user/index" data-field="username" class="form-control selectpage" name="user_id" type="text" value="{$row.user_id|htmlentities}">
+        </div>
+    </div>
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">VIP结束时间:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-vip_endtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="vip_endtime" type="text" value="{:$row.vip_endtime?datetime($row.vip_endtime):''}">
+        </div>
+    </div>
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Vip_level')}:</label>
+        <div class="col-xs-12 col-sm-8">
+
+            <div class="radio">
+                {foreach name="VipLevelList" item="vo"}
+                <label for="row[vip_level]-{$key}"><input id="row[vip_level]-{$key}" name="vip_level" type="radio" value="{$key}" {in name="key" value="$row.vip_level"}checked{/in} /> {$vo}</label>
+                {/foreach}
+            </div>
+
+        </div>
+    </div>
+
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 15 - 0
public/assets/js/backend/userwallet.js

@@ -58,6 +58,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     target:'_self',
 
                                 },
+                                {
+                                    name:'updatevip',
+                                    text:'充值vip会员',
+                                    title:'充值vip会员',
+                                    icon:'fa fa-exclamation-circle',
+                                    classname:'btn btn-xs btn-info btn-dialog',
+                                    url:'userwallet/updatevip/id/{ids}?dialog=1',
+                                    target:'_self',
+                                    /*hidden:function(row){
+                                     return row.status==100 ? false : false;
+                                     }*/
+                                }
 
                             ],
                             events: Table.api.events.operate, formatter: Table.api.formatter.operate}
@@ -80,6 +92,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         updatemoney: function () {
             Controller.api.bindevent();
         },
+        updatevip: function () {
+            Controller.api.bindevent();
+        },
 
         api: {
             bindevent: function () {