lizhen_gitee 1 год назад
Родитель
Сommit
396d9b8265

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

@@ -3,7 +3,7 @@
 namespace app\admin\controller;
 
 use app\common\controller\Backend;
-
+use think\Db;
 /**
  * 会员钱包管理
  *
@@ -71,4 +71,38 @@ 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('user_id');
+            $jewel = input('jewel');
+
+            Db::startTrans();
+
+            $mode = '+';
+            if($jewel < 0){
+                $mode = '-';
+            }
+            $rs = model('wallet')->lockChangeAccountRemain($user_id,$jewel,$mode,0,'后台变动',0,'jewel');
+            if($rs['status'] === false){
+                Db::rollback();
+                $this->error($rs['msg']);
+            }
+
+            Db::commit();
+            $this->success('充值完成');
+        }
+
+        $this->assign('row',$info);
+        return $this->view->fetch();
+    }
+
 }

+ 35 - 1
application/admin/controller/user/User.php

@@ -3,7 +3,7 @@
 namespace app\admin\controller\user;
 
 use app\common\controller\Backend;
-
+use think\Db;
 /**
  * 会员管理
  *
@@ -79,4 +79,38 @@ class User 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('user_id');
+            $jewel = input('jewel');
+
+            Db::startTrans();
+
+            $mode = '+';
+            if($jewel < 0){
+                $mode = '-';
+            }
+            $rs = model('wallet')->lockChangeAccountRemain($user_id,$jewel,$mode,0,'后台变动',0,'jewel');
+            if($rs['status'] === false){
+                Db::rollback();
+                $this->error($rs['msg']);
+            }
+
+            Db::commit();
+            $this->success('充值完成');
+        }
+
+        $this->assign('row',$info);
+        return $this->view->fetch();
+    }
+
 }

+ 24 - 0
application/admin/view/user/user/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">用户名:</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="jewel" type="number" value="">
+        </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>

+ 2 - 2
application/admin/view/userwallet/index.html

@@ -7,7 +7,7 @@
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
-                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('userwallet/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                       <!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('userwallet/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
                         <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('userwallet/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('userwallet/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('userwallet/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
@@ -18,7 +18,7 @@
                                 <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
                                 <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
                             </ul>
-                        </div>
+                        </div>-->
 
                         
                     </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="jewel" type="number" value="">
+        </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>

+ 1 - 1
application/extra/wallet.php

@@ -5,7 +5,7 @@
 return [
     'logtype' => [
         //jewel, 从原有代码里找出来的
-        0  => '下单',   //减少    用不到了
+        0  => '后台变动',   //增减
         1  => '充值',  //增加
         2  => '购买锤子',  //减少  用不到了
         3  => '赠送礼物',   //减少

+ 17 - 1
public/assets/js/backend/user/user.js

@@ -69,7 +69,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 //                        {field: 'is_manager', title: __('Is_manager'), searchList: {"0":__('Is_manager 0'),"1":__('Is_manager 1')}, formatter: Table.api.formatter.normal},
                         {field: 'userwallet.money', title: __('Userwallet.money'), operate:'BETWEEN'},
                         {field: 'userwallet.jewel', title: __('Userwallet.jewel')},
-                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        {field: 'operate', title: __('Operate'),
+                            buttons:[
+                                {
+                                    name:'updatemoney',
+                                    text:'充值金币',
+                                    title:'充值金币',
+                                    icon:'fa fa-exclamation-circle',
+                                    classname:'btn btn-xs btn-info btn-dialog',
+                                    url:'user/user/updatemoney/id/{ids}?dialog=1',
+                                    target:'_self',
+                                },
+
+                            ],
+                            table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]
             });
@@ -83,6 +96,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]"));

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

@@ -7,8 +7,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 extend: {
                     index_url: 'userwallet/index' + location.search,
                     add_url: 'userwallet/add',
-                    edit_url: 'userwallet/edit',
-                    del_url: 'userwallet/del',
+//                    edit_url: 'userwallet/edit',
+//                    del_url: 'userwallet/del',
                     multi_url: 'userwallet/multi',
                     import_url: 'userwallet/import',
                     table: 'user_wallet',
@@ -27,10 +27,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
                         {field: 'user_id', title: __('User_id')},
+                        {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
                         {field: 'money', title: __('Money'), operate:'BETWEEN'},
                         {field: 'jewel', title: __('Jewel')},
-                        {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
-                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        {field: 'operate', title: __('Operate'),
+                            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',
+                                },
+
+                            ],
+                            table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]
             });
@@ -44,6 +57,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]"));