Browse Source

后台给用户增减积分

lizhen_gitee 1 year ago
parent
commit
0e26fcbded

+ 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;
 /**
  * 会员管理
  *
@@ -60,5 +60,39 @@ class User extends Backend
         return $this->view->fetch();
     }
 
+    public function scoreadd(){
+        $id = input('id',0);
+        if($this->request->isAjax()){
+
+            $score   = input('score',0);
+            $remark  = input('remark','');
+
+            if($score == 0){
+                $this->error('积分不能为0');
+            }
+
+            if($score > 0){
+                $logtype = 1;
+            }else{
+                $logtype = 2;
+            }
+
+            Db::startTrans();
+            $rs_wallet = model('wallet')->lockChangeAccountRemain($id,'score',$score,$logtype,$remark,'admin',$this->auth->id);
+            if($rs_wallet['status'] == false){
+                Db::rollback();
+                $this->error($rs_wallet['msg']);
+            }
+            Db::commit();
+            $this->success('操作完成');
+        }
+
+        $row = Db::name('user')->where('id',$id)->find();
+
+        $this->assign('row',$row);
+        $this->assign('id',$id);
+        return $this->view->fetch();
+    }
+
 
 }

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

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

+ 37 - 0
application/admin/view/user/user/scoreadd.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="{$id}">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Username')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-username" class="form-control" disabled  type="text" value="{$row.username|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-nickname" class="form-control" disabled  type="text" value="{$row.nickname|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-score" class="form-control" name="score" type="text" value="0">
+            <font color="red">正数为增加,负数为减少,不能为0</font>
+        </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-remark" class="form-control" name="remark"  type="text" 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-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 1 - 1
application/api/controller/User.php

@@ -65,7 +65,7 @@ class User extends Api
 
         Db::name('user')->where('id',$this->auth->id)->update($data);
 
-        $this->success(1);
+        $this->success();
     }
 
     //用户详细资料

+ 1 - 1
public/assets/js/backend/order.js

@@ -26,7 +26,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
-                        {field: 'order_no', title: __('Order_no'), operate: 'LIKE'},
+//                        {field: 'order_no', title: __('Order_no'), operate: 'LIKE'},
                         {field: 'product_id', title: __('Product_id')},
                         {field: 'product.title', title: __('Product.title'), operate: 'LIKE'},
                         {field: 'user_id', title: __('User_id')},

+ 21 - 3
public/assets/js/backend/user/user.js

@@ -7,8 +7,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 extend: {
                     index_url: 'user/user/index' + location.search,
                     add_url: 'user/user/add',
-                    edit_url: 'user/user/edit',
-                    del_url: 'user/user/del',
+//                    edit_url: 'user/user/edit',
+//                    del_url: 'user/user/del',
                     multi_url: 'user/user/multi',
                     import_url: 'user/user/import',
                     table: 'user',
@@ -61,7 +61,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'introcode', title: __('Introcode'), operate: 'LIKE'},
                         {field: 'intro_uid', title: __('Intro_uid')},
                         {field: 'wallet.score', title: __('wallet.score')},
-//                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        {field: 'operate', title: __('Operate'),
+                            buttons:[
+                                {
+                                    name:'scoreadd',
+                                    text:'增加积分',
+                                    title:'增加积分',
+                                    icon:'fa fa-exclamation-circle',
+                                    classname:'btn btn-xs btn-info btn-dialog',
+                                    url:'user/user/scoreadd/id/{ids}?dialog=1',
+                                    target:'_self',
+                                    /*hidden:function(row){
+                                     return row.status==100 ? false : false;
+                                     }*/
+                                }
+                            ],
+                            table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]
             });
@@ -75,6 +90,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         edit: function () {
             Controller.api.bindevent();
         },
+        scoreadd: function () {
+            Controller.api.bindevent();
+        },
         api: {
             bindevent: function () {
                 Form.api.bindevent($("form[role=form]"));