Bläddra i källkod

后台增加减少积分和收益

lizhen_gitee 1 år sedan
förälder
incheckning
bcf3e34202

+ 72 - 0
application/admin/controller/user/User.php

@@ -325,5 +325,77 @@ 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 = 11;
+            }
+
+            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();
+    }
+    /**
+     * 增加收益
+     */
+    public function shouyiadd(){
+        $id = input('id',0);
+        if($this->request->isAjax()){
+
+            $shouyi   = input('shouyi',0);
+            $remark  = input('remark','');
+
+            if($shouyi == 0){
+                $this->error('收益不能为0');
+            }
+
+            if($shouyi > 0){
+                $logtype = 8;
+            }else{
+                $logtype = 81;
+            }
+
+            Db::startTrans();
+            $rs_wallet = model('wallet')->lockChangeAccountRemain($id,'shouyi',$shouyi,$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();
+    }
 
 }

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

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

+ 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>

+ 38 - 0
application/admin/view/user/user/shouyiadd.html

@@ -0,0 +1,38 @@
+<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="shouyi" type="text" value="0">
+            <font color="red">正数为增加,负数为减少,不能为0</font><br><br>
+            <font color="red">收益的额度已经增加到了积分里,收益只是积分里刨除本金的部分,它和积分是有重复的,有交集的,收益的金额是用来部分提现的。如果收益又增减,需要酌情在积分里一起增减</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>

+ 6 - 0
application/extra/wallet.php

@@ -4,6 +4,9 @@
  */
 return [
     'logtype' => [
+        1  => '后台增加',  //score +
+        11 => '后台减少',  //score -
+
         2  => '积分兑换', //score -
         21 => '积分兑换(被拒返回)', //score +
 
@@ -16,6 +19,9 @@ return [
 
 //        6  => '总代奖励',    //订单10日结算 score +     废弃了
 //        7  => '总代奖励(间推)',//订单10日结算 score +    废弃了
+
+        8  => '后台增加',  //shouyi +
+        81 => '后台减少',  //shouyi -
     ],
     'moneyname' => [
         'money'    => '佣金',

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

@@ -68,7 +68,34 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 //                        {field: 'intro_ids', title: __('Intro_ids')},
 //                        {field: 'intro_level', title: __('Intro_level')},
 
-                        {field: 'operate', title: __('Operate'),table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        {field: 'operate', title: __('Operate'),table: table,
+                            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;
+                                     }*/
+                                },
+                                {
+                                    name:'shouyiadd',
+                                    text:'增加收益',
+                                    title:'增加收益',
+                                    icon:'fa fa-exclamation-circle',
+                                    classname:'btn btn-xs btn-info btn-dialog',
+                                    url:'user/user/shouyiadd/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}
                     ]
                 ]
             });
@@ -172,6 +199,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         add: function () {
             Controller.api.bindevent();
         },
+        scoreadd: function () {
+            Controller.api.bindevent();
+        },
+        shouyiadd: function () {
+            Controller.api.bindevent();
+        },
         edit: function () {
             Controller.api.bindevent();
         },

+ 4 - 3
public/assets/js/backend/usershouyilog.js

@@ -29,6 +29,9 @@ 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: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
+                        {field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
 //                        {field: 'log_type', title: __('Log_type')},
                         {field: 'log_type_text', title: __('Log_type'),operate:false},
                         {field: 'before', title: __('Before')},
@@ -40,9 +43,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'remark', title: __('Remark'), operate: 'LIKE'},
                         {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
-                        {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
-                        {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
-                        {field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
+
 //                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]