Browse Source

家族成员列表

zhangxiaobin 1 năm trước cách đây
mục cha
commit
4d5f8cf563

+ 40 - 0
application/admin/controller/conf/Exchmoney.php

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

+ 9 - 0
application/admin/lang/zh-cn/conf/exchmoney.php

@@ -0,0 +1,9 @@
+<?php
+
+return [
+    'Id'         => '主键ID',
+    'Jewel'      => '兑换钻石',
+    'Money'      => '人民币(单位:分)',
+    'Createtime' => '创建时间',
+    'Updatetime' => '更新时间'
+];

+ 40 - 0
application/admin/model/conf/Exchmoney.php

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

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

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

+ 22 - 0
application/admin/view/conf/exchmoney/add.html

@@ -0,0 +1,22 @@
+<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">{:__('Jewel')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-jewel" data-rule="required" class="form-control" name="row[jewel]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-money" data-rule="required" class="form-control" name="row[money]" 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>

+ 22 - 0
application/admin/view/conf/exchmoney/edit.html

@@ -0,0 +1,22 @@
+<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">{:__('Jewel')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-jewel" data-rule="required" class="form-control" name="row[jewel]" type="number" value="{$row.jewel|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-money" data-rule="required" class="form-control" name="row[money]" type="number" value="{$row.money|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/conf/exchmoney/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('conf/exchmoney/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('conf/exchmoney/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('conf/exchmoney/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('conf/exchmoney/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('conf/exchmoney/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('conf/exchmoney/edit')}" 
+                           data-operate-del="{:$auth->check('conf/exchmoney/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 21 - 4
application/api/controller/Guild.php

@@ -534,6 +534,10 @@ class Guild extends Api
                         } else {
                             $onlineTime = get_last_time($user['onlinetime']);
                             $onlineText = $onlineTime.'在线';
+                            $limitTime = time() - (3600 * 6);
+                            if ($user['onlinetime'] < $limitTime) {
+                                $onlineText = '离线';
+                            }
                         }
                     }
                     $v['online_text'] = $onlineText;
@@ -560,20 +564,33 @@ class Guild extends Api
         $where = [];
         $where["a.guild_id"] = $guild_id;
         $where["a.status"] = 1;
-        $where["a.sign_time"] = ["gt",time()];
+        //$where["a.sign_time"] = ["gt",time()];
         // 获取公会成员总数
         $guildMemberCount = \app\common\model\GuildMember::alias("a")->where($where)->count("id");
         // 获取公会成员列表
         $guildMemberList = \app\common\model\GuildMember::alias("a")
-            ->field("a.id,u.avatar,u.nickname,u.gender,u.age,a.role")
+            ->field("a.id,u.avatar,u.nickname,u.gender,u.age,a.role,u.is_online,u.onlinetime")
             ->join("hx_user u","a.user_id = u.id")
             ->where($where)
             ->limit($pageStart,$pageNum)
             ->order("a.role","desc")
             ->select();
         $role = ["","管理","会长"];
-        if($guildMemberList) foreach($guildMemberList as $k => &$v) {
-            $v["role"] = $role[$v["role"]];
+        if($guildMemberList) {
+            foreach($guildMemberList as $k => &$v) {
+                $v["role"] = $role[$v["role"]];
+                if ($v['is_online'] == 1) {
+                    $onlineText = '在线';
+                } else {
+                    $onlineTime = get_last_time($v['onlinetime']);
+                    $onlineText = $onlineTime.'在线';
+                    $limitTime = time() - (3600 * 6);
+                    if ($v['onlinetime'] < $limitTime) {
+                        $onlineText = '离线';
+                    }
+                }
+                $v['online_text'] = $onlineText;
+            }
         }
         $res = [];
         $res["memberCount"] = $guildMemberCount;

+ 54 - 0
public/assets/js/backend/conf/exchmoney.js

@@ -0,0 +1,54 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'conf/exchmoney/index' + location.search,
+                    add_url: 'conf/exchmoney/add',
+                    edit_url: 'conf/exchmoney/edit',
+                    del_url: 'conf/exchmoney/del',
+                    multi_url: 'conf/exchmoney/multi',
+                    import_url: 'conf/exchmoney/import',
+                    table: 'exchmoney_config',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'jewel', title: __('Jewel')},
+                        {field: 'money', title: __('Money')},
+                        {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;
+});