Browse Source

用户关系

lizhen_gitee 2 months ago
parent
commit
3f6870830d

+ 40 - 0
application/admin/controller/Userrelation.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\common\controller\Backend;
+
+/**
+ * 用户关系管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Userrelation extends Backend
+{
+    
+    /**
+     * Userrelation模型对象
+     * @var \app\admin\model\Userrelation
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\Userrelation;
+
+    }
+
+    public function import()
+    {
+        parent::import();
+    }
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+    
+
+}

+ 11 - 0
application/admin/lang/zh-cn/userrelation.php

@@ -0,0 +1,11 @@
+<?php
+
+return [
+    'Id'           => 'ID',
+    'Uid'          => '用户ID',
+    'Relationname' => '关系名',
+    'Price'        => '金币价格',
+    'To_uid'       => '被关联用户ID',
+    'Createtime'   => '创建时间',
+    'Updatetime'   => '更新时间'
+];

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

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

+ 40 - 0
application/admin/model/Userrelation.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class Userrelation extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'user_relation';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+}

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

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

+ 34 - 0
application/admin/view/userrelation/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">{:__('Uid')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-uid" data-rule="required" class="form-control" name="row[uid]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Relationname')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-relationname" data-rule="required" class="form-control" name="row[relationname]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Price')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-price" data-rule="required" class="form-control" name="row[price]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('To_uid')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-to_uid" data-rule="required" class="form-control" name="row[to_uid]" 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>

+ 34 - 0
application/admin/view/userrelation/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">{:__('Uid')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-uid" data-rule="required" class="form-control" name="row[uid]" type="number" value="{$row.uid|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Relationname')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-relationname" data-rule="required" class="form-control" name="row[relationname]" type="text" value="{$row.relationname|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Price')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-price" data-rule="required" class="form-control" name="row[price]" type="number" value="{$row.price|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('To_uid')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-to_uid" data-rule="required" class="form-control" name="row[to_uid]" type="number" value="{$row.to_uid|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/userrelation/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('userrelation/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('userrelation/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('userrelation/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('userrelation/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('userrelation/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('userrelation/edit')}" 
+                           data-operate-del="{:$auth->check('userrelation/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

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

@@ -8,7 +8,7 @@
     </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="money" type="number" value="">
         </div>

+ 56 - 0
public/assets/js/backend/userrelation.js

@@ -0,0 +1,56 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'userrelation/index' + location.search,
+                    add_url: 'userrelation/add',
+                    edit_url: 'userrelation/edit',
+                    del_url: 'userrelation/del',
+                    multi_url: 'userrelation/multi',
+                    import_url: 'userrelation/import',
+                    table: 'user_relation',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'uid', title: __('Uid')},
+                        {field: 'relationname', title: __('Relationname'), operate: 'LIKE'},
+                        {field: 'price', title: __('Price')},
+                        {field: 'to_uid', title: __('To_uid')},
+                        {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: '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;
+});

+ 2 - 3
public/assets/js/backend/userwallet.js

@@ -32,7 +32,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
                         {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: __('累计消费金额')},
@@ -51,8 +50,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 },
                                 {
                                     name:'updatemoney',
-                                    text:'充值积分',
-                                    title:'充值积分',
+                                    text:'充值余额',
+                                    title:'充值余额',
                                     icon:'fa fa-exclamation-circle',
                                     classname:'btn btn-xs btn-info btn-dialog',
                                     url:'userwallet/updatemoney/id/{ids}?dialog=1',