Quellcode durchsuchen

后台用户充值/编辑调整

zhangxiaobin vor 1 Jahr
Ursprung
Commit
4158563044

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

@@ -162,6 +162,7 @@ class User extends Backend
                 }
                 if (!empty($params['u_id'])) {
                     $userWhere['u_id'] = $params['u_id'];
+                    $userWhere['id'] = ['neq',$ids];
                     $user = $this->model->where($userWhere)->find();
                     if (!empty($user)) {
                         throw new Exception('前端用户ID已存在');
@@ -314,4 +315,76 @@ class User extends Backend
         ]);
         return $this->view->fetch();
     }
+
+    /**
+     * 钻石充值
+     * @param null $ids
+     * @return string
+     */
+    public function addJewel($ids=null)
+    {
+        /* 判断数据是否存在*/
+        $row = $this->model->get($ids);
+        if (!$row) {
+            $this->error(__('No Results were found'));
+        }
+        /* 判断是否有权限访问*/
+        $adminIds = $this->getDataLimitAdminIds();
+        if (is_array($adminIds)) {
+            if (!in_array($row[$this->dataLimitField], $adminIds)) {
+                $this->error(__('You have no permission'));
+            }
+        }
+        if ($this->request->isPost()) {
+            $params = $this->request->post("row/a");
+            if (!$params) {
+                $this->error(__('Parameter %s can not be empty', ''));
+            }
+            $params = $this->preExcludeFields($params);
+            Db::startTrans();
+            try {
+                //是否采用模型验证
+                if ($this->modelValidate) {
+                    $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+                    $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
+                    $row->validateFailException(true)->validate($validate);
+                }
+                if (!empty($params['jewel_add'])) {//钻石充值
+                    $userWhere['id'] = $row['id'];
+                    $user = Db::name('user')->where($userWhere)->lock(true)->find();
+                    $before = isset($user['jewel']) ? $user['jewel'] : 0;
+                    $jewelRes = model('Wallet')->lockChangeAccountRemain($row['id'],$params['jewel_add'],'+',$before,$remark='钻石充值()',17,'jewel');
+                    if (!$jewelRes['status']) {
+                        throw new Exception($jewelRes['msg']);
+                    }
+                    $params['jewel'] = bcadd($user['jewel'],$params['jewel_add']);
+                    //充值日志记录
+                    //判断是否首充
+                    $jewellogWhere['user_id'] = $row['id'];
+                    $jewellogWhere['type'] = 1;
+                    $userJewelLog = model('UserJewelLog')->where($jewellogWhere)->find();
+                    $isFirst = 1;
+                    if (!empty($userJewelLog)) {
+                        $isFirst = 0;
+                    }
+                    $preUserId = $user['pre_userid'];
+                    $userRechargeLogRes = model('UserRechargeLog')->addRecord($row['id'], $params['jewel_add'], $user['money'], $params['jewel'], $user['money'], 4, 4,$isFirst,$preUserId);
+                    if (!$userRechargeLogRes) {
+                        throw new Exception('充值记录生成失败');
+                    }
+                }
+                $result = $row->allowField(true)->save($params);
+                if ($result == false) {
+                    throw new Exception(__('No rows were updated'));
+                }
+                Db::commit();
+                $this->success();
+            } catch (ValidateException|PDOException|Exception $e) {
+                Db::rollback();
+                $this->error($e->getMessage());
+            }
+        }
+        $this->view->assign("row", $row);
+        return $this->view->fetch();
+    }
 }

+ 2 - 0
application/admin/lang/zh-cn/user/user.php

@@ -26,6 +26,8 @@ return [
     'Empirical'                                   => '经验值',
     'Money'                                       => '账户余额',
     'Jewel'                                       => '钻石余额',
+    'Money_add'                                   => '余额充值',
+    'Jewel_add'                                   => '钻石充值',
     'Sound_coin'                                  => '声币余额',
     'Noble'                                       => '贵族',
     'NobleDuetime'                                => '贵族到期时间',

+ 41 - 0
application/admin/view/user/user/add_jewel.html

@@ -0,0 +1,41 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    {:token()}
+    <input type="hidden" name="row[id]" value="{$row.id}">
+    <div class="form-group">
+        <label for="c-u_id" class="control-label col-xs-12 col-sm-2">{:__('Uid')}:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input id="c-u_id" data-rule="required" disabled class="form-control" name="row[u_id]" type="text" value="{$row.u_id|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input id="c-nickname" data-rule="required" disabled class="form-control" name="row[nickname]" type="text" value="{$row.nickname|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input id="c-mobile" data-rule="required" disabled class="form-control" name="row[mobile]" type="text" value="{$row.mobile|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('Jewel')}:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input id="c-jewel" data-rule="required" disabled class="form-control" name="row[jewel]" type="number" value="{$row.jewel|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('Jewel_add')}:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input id="c-jewel_add" data-rule="required" min="1" class="form-control" name="row[jewel_add]" type="number" value="0">
+        </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/api/controller/Notify.php

@@ -58,7 +58,7 @@ class Notify extends Api
                 $detail = "钻石充值";
                 $res3 = $jewellogModel->addUserJewelLog($userInfo["id"], $orderInfo["jewel"], "+", $userInfo["jewel"], $detail, 1);
                 // 添加充值记录
-                $res4 = $rechargelogModel->addRecord($userInfo["id"], $orderInfo["jewel"], $payamount, bcadd($userInfo["jewel"], $orderInfo["jewel"], 2), $userInfo["money"], $orderInfo["platform"], 1,$isFirst,$preUserId);
+                $res4 = $rechargelogModel->addRecord($userInfo["id"], $orderInfo["jewel"], 0, bcadd($userInfo["jewel"], $orderInfo["jewel"], 2), $userInfo["money"], $orderInfo["platform"], 1,$isFirst,$preUserId);
                 if ($res1 && $res2 && $res3 && $res4) {
                     // 添加统计
                     $userInfo->chargecount = $userInfo->chargecount + $payamount;

+ 2 - 0
application/extra/wallet.php

@@ -22,6 +22,7 @@ return [
         14 => '余额兑换钻石', //增加
         //15已被占用
         16 => '签到得钻石',//增加
+        17 => '平台充值',//增加
 
         //money
         101 => '获赠礼物', //增加
@@ -30,6 +31,7 @@ return [
         104 => '申请提现', //减少
         105 => '申请提现驳回', //增加
         106 => '接单收益', //增加
+        107 => '平台充值', //增加
     ],
     'moneyname' => [
         'jewel'    => '钻石',

+ 16 - 6
public/assets/js/backend/user/user.js

@@ -10,6 +10,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     edit_url: 'user/user/edit',
                     multi_url: 'user/user/multi',
                     infocheck_url: 'user/user/infocheck',
+                    addjewel_url: 'user/user/add_jewel',
                     table: 'user',
                 }
             });
@@ -69,12 +70,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {
                             field: 'operate', title: __('Operate'), buttons: [
                                 {
-                                    name: 'detail',
-                                    title: __('查看详情'),
-                                    classname: 'btn btn-xs btn-primary btn-dialog',
-                                    icon: 'fa fa-list',
-                                    url: 'user/user/detail',
-                                }, {
                                     name: 'infocheck',
                                     title: __('信息审核'),
                                     classname: 'btn btn-xs btn-warning btn-dialog',
@@ -87,6 +82,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                             return false;
                                         }
                                     }
+                                },{
+                                    name: 'detail',
+                                    title: __('查看详情'),
+                                    classname: 'btn btn-xs btn-primary btn-dialog',
+                                    icon: 'fa fa-list',
+                                    url: 'user/user/detail',
+                                }, {
+                                    name: 'addjewel',
+                                    title: __('充值'),
+                                    classname: 'btn btn-xs btn-info btn-dialog',
+                                    icon: 'fa fa-diamond',
+                                    url: 'user/user/addJewel',
                                 },
                             ], table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate
                         }
@@ -110,6 +117,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         infocheck: function () {
             Controller.api.bindevent();
         },
+        addjewel: function () {
+            Controller.api.bindevent();
+        },
         api: {
             bindevent: function () {
                 Form.api.bindevent($("form[role=form]"));