瀏覽代碼

Merge branch 'master' of http://git.huxiukeji.com/zhangxiaobin/ggyuyin

lizhen_gitee 1 年之前
父節點
當前提交
d077ac156d

+ 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>

+ 101 - 26
application/api/controller/Guild.php

@@ -102,7 +102,7 @@ class Guild extends Api
         $guildInfo = \app\common\model\Guild::field("id,image,name,g_id,user_id,party_id,desc,notice,status")->where(["id"=>$guild_id])->find();
         // 获取公会成员信息
         $guildMemberInfo = \app\common\model\GuildMember::alias("a")
-            ->field("a.user_id,a.role,u.nickname,u.avatar")
+            ->field("a.id,a.user_id,a.role,u.nickname,u.avatar")
             ->join("hx_user u","a.user_id = u.id")
             ->where(["a.guild_id"=>$guild_id])->limit(5)->order("a.role","desc")->select();
         if(!$guildInfo || !$guildMemberInfo) $this->error("公会信息获取失败!");
@@ -328,9 +328,9 @@ class Guild extends Api
      * 公会签约申请
      */
     public function guildJoinin() {
-        $join_time = $this->request->request("join_time"); //签约时长:1=3个月,2=6个月,3=12个月
+        $join_time = $this->request->request("join_time",1); //签约时长:1=3个月,2=6个月,3=12个月
         $guild_id = $this->request->request("guild_id"); //公会ID
-        if(!in_array($join_time,[1,2,3]) || !$guild_id) $this->error("参数错误!");
+        //if(!in_array($join_time,[1,2,3]) || !$guild_id) $this->error("参数错误!");
 
         // 一个身份证号只能申请一次
         $user_id = $this->auth->id;
@@ -349,15 +349,15 @@ class Guild extends Api
         // 获取用户实名认证信息
         $authUserIdcard = \app\common\model\UserAuth::where(["user_id"=>$user_id])->value("idcard");
         // 搜索签约申请中是否有此身份证号
-        $idcardfind = \app\common\model\GuildJoinin::where(["user_id"=>$user_id,"status"=>0])->find();
+        $idcardfind = \app\common\model\GuildJoinin::where(["user_id"=>$user_id,'guild_id'=>$guild_id,"status"=>0])->find();
         if($idcardfind) $this->error("当前账号正在审核,请耐心等待!");
 
-        $memberfind = \app\common\model\GuildMember::where(["user_id"=>$user_id,"status"=>1,"sign_time"=>["gt",time()]])->find();
+        $memberfind = \app\common\model\GuildMember::where(["user_id"=>$user_id,"status"=>1])->find();
         if($memberfind) $this->error("一个账号只能加入一个公会哟!");
 
         // 查看是否申请过
-        $applyInfo = \app\common\model\GuildApply::where(["user_id"=>$user_id,"status"=>0])->find();
-        if($applyInfo && $applyInfo->status>=0) $this->error("您已经发送过开厅申请了,请勿重复发送!");
+        /*$applyInfo = \app\common\model\GuildApply::where(["user_id"=>$user_id,"status"=>0])->find();
+        if($applyInfo && $applyInfo->status>=0) $this->error("您已经发送过开厅申请了,请勿重复发送!");*/
 
 //        // 获取公会信息
 //        $guildInfo = \app\common\model\Guild::where(["user_id"=>$user_id,"status"=>1])->find();
@@ -396,12 +396,27 @@ class Guild extends Api
         $is_pass = $this->request->request("is_pass"); // 是否通过:1=通过,-1=拒绝
         if(!in_array($is_pass,[1,-1]) || !$joinin_id) $this->error("参数错误!");
         $user_id = $this->auth->id;
+        $memberfind = \app\common\model\GuildMember::where(["user_id"=>$user_id,"status"=>1])->find();
+        if($memberfind) $this->error("该用户已有家族!");
         // 获取申请信息
         $joininInfo =  \app\common\model\GuildJoinin::where(["id"=>$joinin_id])->find();
+        if ($is_pass == 1) {//清理其他公会未审核的数据
+            if (!empty($joininInfo)) {
+                $joinWhere['user_id'] = $joininInfo['user_id'];
+                $joinWhere['guild_id'] = ['neq',$joininInfo['guild_id']];
+                $joinWhere['status'] = 0;
+                $joinData = model('GuildJoinin')->where($joinWhere)->select();
+                if (!empty($joinData)) {
+                    $joinIds = array_column($joinData,'id');
+                    $delWhere['id'] = ['in',$joinIds];
+                    model('GuildJoinin')->where($delWhere)->delete();
+                }
+            }
+        }
         // 获取公会信息
         $guildInfo = \app\common\model\Guild::where(["id"=>$joininInfo->guild_id])->find();
         // 验证更新条件
-        if($user_id !== $guildInfo->user_id) $this->error("身份验证失败!您不是公会长,无权限更改!");
+        if($user_id !== $guildInfo->user_id) $this->error("身份验证失败!您不是长,无权限更改!");
 
         // 获取用户信息
         $userInfo = \app\common\model\User::field("id,u_id,mobile,nickname")->where(["id"=>$joininInfo->user_id])->find();
@@ -443,14 +458,14 @@ class Guild extends Api
                 $res4 = \app\common\model\Guild::where(["id"=>$guildInfo->id])->setInc("member");
                 if($res1 && $res2 && $res3 && $res4) {
                     // +message
-                    \app\common\model\Message::addMessage($joininInfo->user_id,"公会审核通知","恭喜,您的加入公会审核通过啦!公会ID:".$guildInfo->g_id);
+                    \app\common\model\Message::addMessage($joininInfo->user_id,"家族审核通知","恭喜,您的加入家族审核通过啦!家族ID:".$guildInfo->g_id);
                     Db::commit();
                     $this->success("已审核通过!");
                 }
             } else {
                 if($res1 && $res2) {
                     // +message
-                    \app\common\model\Message::addMessage($joininInfo->user_id,"公会审核通知","您的公会加入申请,公会长审核失败,没关系,调整姿势再来一遍!");
+                    \app\common\model\Message::addMessage($joininInfo->user_id,"家族审核通知","您的家族加入申请,族长审核失败,没关系,调整姿势再来一遍!");
                     Db::commit();
                     $this->success("已审核拒绝!");
                 }
@@ -534,6 +549,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 +579,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"]];
+        $role = [0=>'成员',1=>'副族长',2=>'族长'];
+        if($guildMemberList) {
+            foreach($guildMemberList as $k => &$v) {
+                $v["role_text"] = $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;
@@ -588,14 +620,33 @@ class Guild extends Api
     public function getGuildMemberInfo() {
         $member_id = $this->request->request("member_id",0,"intval"); //公会成员ID
         if($member_id <= 0) $this->error("参数错误!");
-        $memberInfo = \app\common\model\GuildMember::alias("a")
-            ->join("hx_user u","u.id = a.user_id")
-            ->field("u.id,u.avatar,u.nickname,u.gender,u.age,a.wealth,a.charm,a.gift_num,a.role,a.guild_id,a.createtime,u.logintime")
-            ->find($member_id);
+        $memberInfo = model('GuildMember')
+            ->field('id,user_id,wealth,charm,gift_num,role,guild_id,createtime')
+            ->with(['user'=>function($uQuery){
+                $uQuery->field('id,avatar,nickname,gender,age,logintime,age_id,constellation_id,province_id,city_id');
+            }])->find($member_id);
         if(!$memberInfo) $this->error("用户信息获取失败!");
-        $memberInfo["createtime"] = date("Y-m-d",$memberInfo["createtime"]);
-        $memberInfo["logintime"] = date("Y-m-d",$memberInfo["logintime"]);
-        $memberInfo["my_role"] = \app\common\model\GuildMember::where(["user_id"=>$this->auth->id,"guild_id"=>$memberInfo->guild_id])->value("role");
+        $userData  = isset($memberInfo['user']) ? $memberInfo['user'] : [];
+        $gender    = isset($userData['gender']) ? $userData['gender'] : 1;
+        $logintime = isset($userData['logintime']) ? $userData['logintime'] : 0;
+        $userFieldInt = ['age'];
+        $userFieldStr = ['avatar','nickname','age_text','constellation_text','province_text','city_text'];
+        foreach ($userFieldInt as $keyInt => $valInt) {
+            if (!isset($memberInfo[$valInt])) {
+                $memberInfo[$valInt] = isset($userData[$valInt]) ? $userData[$valInt] : 0;
+            }
+        }
+        foreach ($userFieldStr as $keyStr => $valStr) {
+            if (!isset($memberInfo[$valStr])) {
+                $memberInfo[$valStr] = isset($userData[$valStr]) ? $userData[$valStr] : '';
+            }
+        }
+        unset($memberInfo['user']);
+        $memberInfo['gender_text'] = $gender == 1 ? '男' : '女';
+        $memberInfo["createtime"] = !empty($memberInfo["createtime"]) ? date("Y-m-d", $memberInfo["createtime"]) : '';
+        $memberInfo["logintime"] = !empty($logintime) ? date("Y-m-d", $logintime) : '';
+        $myGuildMember = model('GuildMember')->field('role')->where(["user_id"=>$this->auth->id,"guild_id"=>$memberInfo->guild_id])->find();
+        $memberInfo["my_role"] = !empty($myGuildMember) ? $myGuildMember['role'] : -1;
         $this->success("获取成功!",$memberInfo);
     }
 
@@ -714,22 +765,46 @@ class Guild extends Api
             $id = $this->request->param('guild_id',0);
             $guildMemberWhere['guild_id'] = $id;
             $guildMemberWhere['status'] = 1;
-            $guildMember = model('GuildMember')->field('id,user_id')->where($guildMemberWhere)->select();
+            $guildMember = model('GuildMember')->field('id,user_id,role')->where($guildMemberWhere)->select();
             $list = [];
             if (!empty($guildMember)) {
                 $userIds = array_column($guildMember,'user_id');
                 $where = [];
                 $where['a.user_to_id'] = ['in', $userIds];
                 $list = model('GiftUserParty')->alias("a")
-                    ->field('sum(a.value) as total_price,a.user_id,u.avatar,u.nickname')
+                    ->field('sum(a.value) as total_price,a.user_to_id,u.avatar,u.nickname,u.is_online,u.onlinetime')
                     ->where($where)
-                    ->join('hx_user u','u.id = a.user_id')
+                    ->join('hx_user u','u.id = a.user_to_id')
                     ->group('a.user_to_id')
                     ->order('total_price',"desc")
-                    ->limit(100)
+                    ->autopage()
                     ->select();
                 if (!empty($list)) {
+                    $role = [0=>'成员',1=>'副族长',2=>'族长'];
+                    $guildMemberData = [];
+                    foreach ($guildMember as $mKey => $mVal) {
+                        $guildMemberData[$mVal['user_id']] = [
+                            'id' => $mVal['id'],
+                            'role' => $mVal['role'],
+                            'role_text' => isset($role[$mVal['role']]) ? $role[$mVal['role']] : '',
+                        ];
+                    }
                     foreach ($list as $key => &$value) {
+                        $member = isset($guildMemberData[$value['user_to_id']]) ? $guildMemberData[$value['user_to_id']] : [];
+                        $value['member_id'] = isset($member['id']) ? $member['id'] : 0;
+                        $value['role'] = isset($member['role']) ? $member['role'] : 0;
+                        $value['role_text'] = isset($member['role_text']) ? $member['role_text'] : '';
+                        if ($value['is_online'] == 1) {
+                            $onlineText = '在线';
+                        } else {
+                            $onlineTime = get_last_time($value['onlinetime']);
+                            $onlineText = $onlineTime.'在线';
+                            $limitTime = time() - (3600 * 6);
+                            if ($value['onlinetime'] < $limitTime) {
+                                $onlineText = '离线';
+                            }
+                        }
+                        $value['online_text'] = $onlineText;
                         $value['total_price_text'] = $value['total_price'];
                         if ($value['total_price'] >= 10000) {
                             $value['total_price_text'] = bcdiv($value['total_price'],10000,1).'w';

+ 4 - 0
application/common/model/GuildMember.php

@@ -14,4 +14,8 @@ class GuildMember extends Model
     // 定义时间戳字段名
     protected $createTime = 'createtime';
 
+    public function user()
+    {
+        return $this->hasOne('User', 'id', 'user_id',[],'LEFT');
+    }
 }

+ 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;
+});