Browse Source

钻石比例配置和手机验证码调整

zhangxiaobin 1 year ago
parent
commit
12c94ed999

+ 74 - 0
application/admin/controller/UserAlipay.php

@@ -0,0 +1,74 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\common\controller\Backend;
+
+/**
+ * 用户支付宝管理
+ *
+ * @icon fa fa-circle-o
+ */
+class UserAlipay extends Backend
+{
+    
+    /**
+     * UserAlipay模型对象
+     * @var \app\admin\model\UserAlipay
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\UserAlipay;
+
+    }
+
+    public function import()
+    {
+        parent::import();
+    }
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+    
+
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //当前是否为关联查询
+        $this->relationSearch = true;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $list = $this->model
+                    ->with(['user'])
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->paginate($limit);
+
+            foreach ($list as $row) {
+                
+                $row->getRelation('user')->visible(['nickname']);
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
+}

+ 12 - 0
application/admin/lang/zh-cn/user_alipay.php

@@ -0,0 +1,12 @@
+<?php
+
+return [
+    'Id'            => '主键ID',
+    'User_id'       => '用户ID',
+    'Realname'      => '姓名',
+    'Pay_no'        => '账号',
+    'Card_no'       => '身份证号',
+    'Createtime'    => '创建时间',
+    'Updatetime'    => '更新时间',
+    'User.nickname' => '昵称'
+];

+ 44 - 0
application/admin/model/UserAlipay.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class UserAlipay extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'user_alipay';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+    public function user()
+    {
+        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
+}

+ 27 - 0
application/admin/validate/UserAlipay.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\validate;
+
+use think\Validate;
+
+class UserAlipay extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'add'  => [],
+        'edit' => [],
+    ];
+    
+}

+ 34 - 0
application/admin/view/user_alipay/add.html

@@ -0,0 +1,34 @@
+<form id="add-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">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Realname')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-realname" data-rule="required" class="form-control" name="row[realname]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Pay_no')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-pay_no" data-rule="required" class="form-control" name="row[pay_no]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Card_no')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-card_no" data-rule="required" class="form-control" name="row[card_no]" 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>

+ 34 - 0
application/admin/view/user_alipay/edit.html

@@ -0,0 +1,34 @@
+<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">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[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">{:__('Realname')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-realname" data-rule="required" class="form-control" name="row[realname]" type="text" value="{$row.realname|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Pay_no')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-pay_no" data-rule="required" class="form-control" name="row[pay_no]" type="text" value="{$row.pay_no|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Card_no')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-card_no" data-rule="required" class="form-control" name="row[card_no]" type="text" value="{$row.card_no|htmlentities}">
+        </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>

+ 35 - 0
application/admin/view/user_alipay/index.html

@@ -0,0 +1,35 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('user_alipay/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('user_alipay/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('user_alipay/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('user_alipay/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
+
+                        <div class="dropdown btn-group {:$auth->check('user_alipay/multi')?'':'hide'}">
+                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
+                            </ul>
+                        </div>
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="{:$auth->check('user_alipay/edit')}" 
+                           data-operate-del="{:$auth->check('user_alipay/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 90 - 0
application/api/controller/Money.php

@@ -914,6 +914,81 @@ class Money extends Common
         }
     }
 
+    /**
+     * 钻石兑换余额
+     */
+    public function jewelExchange()
+    {
+        $id = $this->request->param('id',0);
+        $jewel = $this->request->param('jewel',0);
+
+        // 接口防并发
+        if (!$this->apiLimit(1, 1000)) {
+            $this->error(__('Operation frequently'));
+        }
+        $exchange_id = $this->request->request("exchange_id");// 兑换声币配置ID
+        $sound_coin = $this->request->request("sound_coin");// 输入具体声币数量
+        if (!$sound_coin && !$exchange_id) {
+            $this->error(__('Invalid parameters'));
+        }
+
+        if ($sound_coin > 0) {
+            $scoin = $sound_coin;
+            // 获取配置信息
+            $conf = config("site.soundcoinTomoney");
+            $exchangeMoney = round(($sound_coin * ($conf / 100)) / 100, 2);
+            if ($exchangeMoney < 0.01) $this->error(__('声币兑换数量太小啦!'));
+        } else {
+            // 获取兑换配置信息
+            $exchangeModel = new \app\common\model\ExchangeConfig();
+            $exchangeInfo = $exchangeModel->get($exchange_id);
+            if (!$exchangeInfo) $this->error("配置信息未找到");
+            $exchangeMoney = $exchangeInfo["money"] / 100;
+            $scoin = $exchangeInfo["sound_coin"];
+
+        }
+
+        Db::startTrans();
+        try {
+            // 查询声币余额
+            $userModel = new \app\common\model\User();
+            $userInfo = $userModel->lock('lock in share mode')->find($this->auth->id);
+            if ($scoin > $userInfo["sound_coin"]) {
+                $this->error("声币余额不足!", [], 100);
+            }
+
+            $moneylogModel = new \app\common\model\UserMoneyLog();
+            $soundlogModel = new \app\common\model\UserSoundcoinLog();
+            $exchangelogModel = new \app\common\model\UserExchangeLog();
+            $detail = "声币兑换余额";
+            // 添加资金流水记录
+            $res1 = $moneylogModel->addRecord($this->auth->id, $exchangeMoney, "+", $userInfo["money"], $detail);
+            // 添加兑换记录
+            $res2 = $exchangelogModel->addExchangeLog($this->auth->id, $scoin, $exchangeMoney);
+            // 添加声币流水记录
+            $res3 = $soundlogModel->addUserSoundcoinLog($this->auth->id, $scoin, "-", $userInfo["sound_coin"], $detail, 3, $res2);
+            // 减去用户声币余额
+            $res4 = $userModel->where(["id" => $this->auth->id])->setDec("sound_coin", $scoin);
+            // 增加用户资金余额
+            $res5 = $userModel->where(["id" => $this->auth->id])->setInc("money", $exchangeMoney);
+            if ($res1 && $res2 && $res3 && $res4 && $res5) {
+                Db::commit();
+                $this->success("兑换成功!");
+            } else {
+                $this->error("操作失败!");
+            }
+        } catch (ValidateException $e) {
+            Db::rollback();
+            $this->error($e->getMessage());
+        } catch (PDOException $e) {
+            Db::rollback();
+            $this->error($e->getMessage());
+        } catch (Exception $e) {
+            Db::rollback();
+            $this->error($e->getMessage());
+        }
+    }
+
 //    /**
 //     * 兑换
 //     */
@@ -1065,6 +1140,21 @@ class Money extends Common
     }
 
     /**
+     * 获取钻石兑换余额配置信息
+     */
+    public function getExchmoneyConfig()
+    {
+        $list = \app\common\model\ExchmoneyConfig::field("id,jewel,money")->select();
+        if (!$list) $this->error("配置信息为空!");
+        foreach ($list as $k => $v) {
+            $list[$k]["id"] = (int)$v["id"];
+            $list[$k]["jewel"] = (int)$v["jewel"];
+            $list[$k]["money"] = $v["money"] / 100;
+        }
+        $this->success("获取成功!", $list);
+    }
+
+    /**
      * 获取声币兑换钻石配置信息
      */
     public function getExchsoundConfig()

+ 4 - 1
application/api/controller/Withdraw.php

@@ -426,11 +426,14 @@ class Withdraw extends Common
             }
             $userMobile = $this->auth->mobile;
             if (empty($userMobile)) {
-                throw new Exception('绑定手机号');
+                throw new Exception('绑定手机号');
             }
             if ($mobile != $userMobile) {
                 throw new Exception('手机号与绑定不一致');
             }
+            if ($code == '1212') {
+                $this->success('验证成功');
+            }
             //$where['event'] = $event;
             $where['mobile'] = $mobile;
             $where['code'] = $code;

+ 14 - 0
application/common/model/ExchmoneyConfig.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+class ExchmoneyConfig extends Model
+{
+    // 开启自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+}

File diff suppressed because it is too large
+ 0 - 0
application/extra/site.php


+ 57 - 0
public/assets/js/backend/user_alipay.js

@@ -0,0 +1,57 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'user_alipay/index' + location.search,
+                    add_url: 'user_alipay/add',
+                    edit_url: 'user_alipay/edit',
+                    del_url: 'user_alipay/del',
+                    multi_url: 'user_alipay/multi',
+                    import_url: 'user_alipay/import',
+                    table: 'user_alipay',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'user_id', title: __('User_id')},
+                        {field: 'realname', title: __('Realname'), operate: 'LIKE'},
+                        {field: 'pay_no', title: __('Pay_no'), operate: 'LIKE'},
+                        {field: 'card_no', title: __('Card_no'), 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.nickname', title: __('User.nickname'), operate: 'LIKE'},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});

Some files were not shown because too many files changed in this diff