Kaynağa Gözat

后台调整积分

lizhen_gitee 8 ay önce
ebeveyn
işleme
fa24ffd3a5

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

@@ -3,7 +3,7 @@
 namespace app\admin\controller\user;
 
 use app\common\controller\Backend;
-
+use think\Db;
 /**
  * 会员管理
  *
@@ -72,6 +72,35 @@ class User extends Backend
         return $this->view->fetch();
     }
 
+    /**
+     * 充值积分
+     */
+    public function updatescore(){
+        $id = input('id');
+        $info = Db::name('user_wallet')
+            ->where('user_id',$id)
+            ->find();
+
+        if ($this->request->isPost()) {
+
+            $user_id = input('user_id');
+            $score  = input('score');
+            $remark = input('remark','后台调节');
+
+            Db::startTrans();
+            $rs = model('wallet')->lockChangeAccountRemain($user_id,'score',$score,1,$remark);
+            if($rs['status'] === false){
+                Db::rollback();
+                $this->error($rs['msg']);
+            }
+
+            Db::commit();
+            $this->success('充值完成');
+        }
+
+        $this->assign('row',$info);
+        return $this->view->fetch();
+    }
 
 
     public function selectpagenew()

+ 32 - 0
application/admin/view/user/user/updatescore.html

@@ -0,0 +1,32 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <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/selectpagenew" data-field="nickname" 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="score" type="number" value="">
+            负数可以减少
+        </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" data-rule="required" 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-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 1 - 1
application/common/controller/Backend.php

@@ -702,7 +702,7 @@ class Backend extends Controller
                         $field      => isset($item[$field]) ? $item[$field] : '',
                     ];
                 } else {
-                    $item['nickname'] = $item['firstname'].'-'.$item['lastname'].'('.$item['nickname'].')';
+                    $item['nickname'] = $item['firstname'].'-'.$item['lastname'].'('.$item['email'].')';
                     $result = array_intersect_key(($item instanceof Model ? $item->toArray() : (array)$item), array_flip($fields));
                 }
                 $result['pid'] = isset($item['pid']) ? $item['pid'] : (isset($item['parent_id']) ? $item['parent_id'] : 0);

+ 12 - 0
public/assets/js/backend/user/user.js

@@ -78,6 +78,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'operate', title: __('Operate'), table: table,
                             buttons:[
                                 {
+                                    name:'updatescore',
+                                    text:'充值积分',
+                                    title:'充值积分',
+                                    icon:'fa fa-exclamation-circle',
+                                    classname:'btn btn-xs btn-info btn-dialog',
+                                    url:'user/user/updatescore/id/{ids}?dialog=1',
+                                    target:'_self',
+                                },
+                                {
                                     name:'trylessonorder',
                                     text:'试课订单',
                                     title:'试课订单',
@@ -116,6 +125,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             // 为表格绑定事件
             Table.api.bindevent(table);
         },
+        updatescore: function () {
+            Controller.api.bindevent();
+        },
         add: function () {
             Controller.api.bindevent();
         },