Browse Source

用户钱包

lizhen_gitee 3 years ago
parent
commit
6bb07ae233

+ 28 - 1
application/admin/controller/Userwallet.php

@@ -3,7 +3,8 @@
 namespace app\admin\controller;
 
 use app\common\controller\Backend;
-
+use think\Db;
+use app\common\model\wallet;
 /**
  * 用户钱包
  *
@@ -71,4 +72,30 @@ class Userwallet extends Backend
         return $this->view->fetch();
     }
 
+    public function updatemoney(){
+        $id = input('id');
+        $info = Db::name('user_wallet')
+            ->where('id',$id)
+            ->find();
+
+        if ($this->request->isPost()) {
+
+            $user_id = input_post('user_id');
+            $gold = input_post('gold');
+
+            Db::startTrans();
+            $rs = model('wallet')->lockChangeAccountRemain($user_id,'gold',$gold,1);
+            if($rs['status'] === false){
+                Db::rollback();
+                $this->error($rs['msg']);
+            }
+
+            Db::commit();
+            $this->success('充值完成');
+        }
+
+        $this->assign('row',$info);
+        return $this->view->fetch();
+    }
+
 }

+ 1 - 1
application/admin/view/useridconfirm/audit.html

@@ -3,7 +3,7 @@
     <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" data-rule="required" data-source="user/user/index" disabled data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" disabled data-field="username" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
         </div>
     </div>
     <div class="form-group">

+ 1 - 1
application/admin/view/userwallet/edit.html

@@ -3,7 +3,7 @@
     <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" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" disabled data-field="username" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
         </div>
     </div>
     <div class="form-group">

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

@@ -25,6 +25,7 @@
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                            data-operate-edit="{:$auth->check('userwallet/edit')}" 
                            data-operate-del="{:$auth->check('userwallet/del')}" 
+                           data-operate-del="{:$auth->check('userwallet/updatemoney')}"
                            width="100%">
                     </table>
                 </div>

+ 24 - 0
application/admin/view/userwallet/updatemoney.html

@@ -0,0 +1,24 @@
+<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">增加金币数量:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-gold" data-rule="required" class="form-control" name="gold" type="number" value="{$row.gold|htmlentities}">
+        </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>

+ 20 - 2
public/assets/js/backend/userwallet.js

@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     index_url: 'userwallet/index' + location.search,
                     add_url: 'userwallet/add',
                     edit_url: 'userwallet/edit',
-                    del_url: 'userwallet/del',
+//                    del_url: 'userwallet/del',
                     multi_url: 'userwallet/multi',
                     import_url: 'userwallet/import',
                     table: 'user_wallet',
@@ -31,7 +31,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'money', title: __('Money'), operate:'BETWEEN'},
                         {field: 'gold', title: __('Gold')},
                         {field: 'vip_endtime', title: __('Vip_endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
-//                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        {field: 'operate', title: __('Operate'), table: table,
+                            buttons:[
+                                {
+                                    name:'updatemoney',
+                                    text:'充值金币',
+                                    title:'充值金币',
+                                    icon:'fa fa-exclamation-circle',
+                                    classname:'btn btn-xs btn-info btn-dialog',
+                                    url:'userwallet/updatemoney/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}
                     ]
                 ]
             });
@@ -45,6 +60,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         edit: function () {
             Controller.api.bindevent();
         },
+        updatemoney: function () {
+            Controller.api.bindevent();
+        },
         api: {
             bindevent: function () {
                 Form.api.bindevent($("form[role=form]"));