Browse Source

三种货币后台充值

lizhen_gitee 8 months ago
parent
commit
2ca9ad68ce

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

@@ -75,7 +75,7 @@ class Userwallet extends Backend
     /**
      * 充值金币
      */
-    public function updatemoney(){
+    public function updategold(){
         $id = input('id');
         $info = Db::name('user_wallet')
             ->where('id',$id)
@@ -132,5 +132,74 @@ class Userwallet extends Backend
         $this->assign('row',$info);
         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');
+            $money = input_post('money', 0, 'intval');
+
+            $user_info = Db::name('user')->find($user_id);
+            if (!$user_info) {
+                $this->error('用户不存在');
+            }
+
+            Db::startTrans();
+
+            $rs = model('wallet')->lockChangeAccountRemain($user_id,0,'money',$money,2, '系统调节','',0, 0);
+            if($rs['status'] === false){
+                Db::rollback();
+                $this->error($rs['msg']);
+            }
+
+            Db::commit();
+            $this->success('充值完成');
+        }
+
+        $this->assign('row',$info);
+        return $this->view->fetch();
+    }
+
+    /**
+     * 充值钻石
+     */
+    public function updatejewel(){
+        $id = input('id');
+        $info = Db::name('user_wallet')
+            ->where('id',$id)
+            ->find();
+
+        if ($this->request->isPost()) {
+
+            $user_id = input_post('user_id');
+            $jewel = input_post('jewel', 0, 'intval');
+
+            $user_info = Db::name('user')->find($user_id);
+            if (!$user_info) {
+                $this->error('用户不存在');
+            }
+
+            Db::startTrans();
+
+            $rs = model('wallet')->lockChangeAccountRemain($user_id,0,'jewel',$jewel,3, '系统调节','',0, 0);
+            if($rs['status'] === false){
+                Db::rollback();
+                $this->error($rs['msg']);
+            }
+
+            Db::commit();
+            $this->success('充值完成');
+        }
+
+        $this->assign('row',$info);
+        return $this->view->fetch();
+    }
 
 }

+ 2 - 1
application/admin/lang/zh-cn/userwallet.php

@@ -3,8 +3,9 @@
 return [
     'Id'            => 'ID',
     'User_id'       => '用户ID',
-    'Money'         => '余额',
+    'Money'         => '积分',
     'Gold'          => '金币',
+    'Jewel'          => '钻石',
     'Vip_endtime'   => 'vip到期时间',
     'User.username' => '用户名',
     'User.nickname' => '昵称',

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

@@ -25,7 +25,9 @@
                     <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-updategold="{:$auth->check('userwallet/updategold')}"
                            data-operate-updatemoney="{:$auth->check('userwallet/updatemoney')}"
+                           data-operate-updatejewel="{:$auth->check('userwallet/updatejewel')}"
                            width="100%">
                     </table>
                 </div>

+ 24 - 0
application/admin/view/userwallet/updategold.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="">
+        </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>

+ 24 - 0
application/admin/view/userwallet/updatejewel.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>

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

@@ -8,9 +8,9 @@
     </div>
 
     <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">增加金币数量:</label>
+        <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="">
+            <input id="c-gold" data-rule="required" class="form-control" name="money" type="number" value="">
         </div>
     </div>
 

+ 2 - 0
application/extra/wallet.php

@@ -5,6 +5,8 @@
 return [
     'logtype' => [
         1 => '系统调节',//gold  增加、减少
+        2 => '系统调节',//money  增加、减少
+        3 => '系统调节',//jewel  增加、减少
 
 
         10 => '金币充值',//gold 增加

+ 31 - 6
public/assets/js/backend/userwallet.js

@@ -30,8 +30,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {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: 'money', title: __('Money'), operate:'BETWEEN'},
                         {field: 'gold', title: __('Gold')},
+                        {field: 'money', title: __('Money')},
+                        {field: 'jewel', title: __('Jewel')},
                         {field: 'vip_endtime', title: __('Vip_endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         // {field: 'vip_level', title: __('Vip_level'),searchList: {"0":__('Vip_level 0'),"10":__('Vip_level 10'),"20":__('Vip_level 20'),"30":__('Vip_level 30'),"40":__('Vip_level 40')}, formatter: Table.api.formatter.status},
                         {field: 'pay_money', title: __('累计消费金额')},
@@ -39,17 +40,35 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'operate', title: __('Operate'), table: table,
                             buttons:[
                                 {
-                                    name:'updatemoney',
+                                    name:'updategold',
                                     text:'充值金币',
                                     title:'充值金币',
                                     icon:'fa fa-exclamation-circle',
                                     classname:'btn btn-xs btn-info btn-dialog',
+                                    url:'userwallet/updategold/id/{ids}?dialog=1',
+                                    target:'_self',
+
+                                },
+                                {
+                                    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;
-                                     }*/
-                                }
+
+                                },
+                                {
+                                    name:'updatejewel',
+                                    text:'充值钻石',
+                                    title:'充值钻石',
+                                    icon:'fa fa-exclamation-circle',
+                                    classname:'btn btn-xs btn-info btn-dialog',
+                                    url:'userwallet/updatejewel/id/{ids}?dialog=1',
+                                    target:'_self',
+
+                                },
                             ],
                             events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
@@ -65,9 +84,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         edit: function () {
             Controller.api.bindevent();
         },
+        updategold: function () {
+            Controller.api.bindevent();
+        },
         updatemoney: function () {
             Controller.api.bindevent();
         },
+        updatejewel: function () {
+            Controller.api.bindevent();
+        },
         api: {
             bindevent: function () {
                 Form.api.bindevent($("form[role=form]"));