Browse Source

基础配置

lizhen_gitee 1 năm trước cách đây
mục cha
commit
febe6c8d47

+ 29 - 0
application/api/controller/Banner.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ * 示例接口
+ */
+class Banner extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+    //轮播图
+    public function banner()
+    {
+        $type = input('type',1);
+
+        $where = [
+            'status' => 1,
+            'type'   => $type,
+        ];
+        $list = Db::name('banner')->field('id, title, image, url')->where($where)->order('weigh', 'desc')->select();
+        $list = list_domain_image($list, ['image']);
+
+        $this->success(1, $list);
+    }
+}

+ 107 - 0
application/api/controller/Baseconfig.php

@@ -0,0 +1,107 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ * 基础配置接口
+ */
+class Baseconfig extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+    //
+    public function index(){
+
+        $config = [
+            'kefu_userids'    => config('site.kefu_userids'), //在线客服用户ids
+//            'index_pipei_switch'    => config('site.index_pipei_switch'), //首页匹配功能开关
+        ];
+
+        $this->success('success',$config);
+    }
+
+
+    /**
+     * 获取安卓版本更新信息
+     */
+    public function getandroidEdition() {
+        // 获取二维码
+        $is_force = config("site.android_is_force");
+        $apkUrl = config("site.android_apkUrl");
+        $apkName = config("site.android_apkName");
+        $desc = config("site.android_desc");
+        $versionCode = config("site.android_versionCode");
+        $this->success("获取成功!",["versionCode"=>$versionCode,"isForceUpdate"=>$is_force,"apkUrl"=>$apkUrl,"apkName"=>$apkName,"desc"=>$desc]);
+    }
+
+    /**
+     * 获取ios版本更新信息
+     */
+    public function getiosEdition() {
+        // 获取二维码
+        $is_force = config("site.iso_is_force");
+        $apkUrl = config("site.ios_downurl");
+        $apkName = config("site.iso_appname");
+        $desc = config("site.iso_desc");
+        $versionCode = config("site.iso_versioncode");
+        $this->success("获取成功!",["versionCode"=>$versionCode,"isForceUpdate"=>$is_force,"apkUrl"=>$apkUrl,"apkName"=>$apkName,"desc"=>$desc]);
+    }
+
+    //启动广告图
+    public function start_advert(){
+        $info = Db::name('start_advert')->where('is_show',1)->order('id desc')->find();
+        $info = info_domain_image($info,['images','video_file']);
+        $this->success_find('success',$info);
+    }
+
+    /**
+     * 年龄段列表
+     * @return void
+     */
+    public function ageList()
+    {
+        try {
+            $field = 'id,name';
+            $where['status'] = 1;
+            $result = model('Age')->field($field)->where($where)->order('weigh asc')->select();
+
+            $this->success('获取成功',$result);
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
+
+
+    //个人资料的一下枚举
+    public function userinfo_enum(){
+//        $enum_hobby = Db::name('enum_hobby')->field('id,name')->order('weight desc,id desc')->select();
+        $enum_job = Db::name('enum_job')->field('id,name')->order('weight desc,id desc')->select();
+//        $enum_marital = Db::name('enum_marital')->field('id,name')->order('weight desc,id desc')->select();
+//        $enum_education = Db::name('enum_education')->field('id,name')->order('weight desc,id desc')->select();
+//        $enum_tag = Db::name('enum_tag')->field('id,name')->order('weight desc,id desc')->select();
+//        $enum_wages = Db::name('enum_wages')->field('id,name')->order('weight desc,id desc')->select();
+
+        $data = [
+//            'enum_hobby' => $enum_hobby,
+            'enum_job' => $enum_job,
+//            'enum_marital' => $enum_marital,
+//            'enum_education' => $enum_education,
+//            'enum_tag' => $enum_tag,
+//            'enum_wages' => $enum_wages,
+        ];
+
+        $this->success('success',$data);
+    }
+
+    //关键字过滤
+    public function keyworld_config(){
+        $config = config('keyworld');
+        $this->success('success',$config);
+    }
+
+
+
+}

+ 33 - 1
application/index/controller/Index.php

@@ -3,7 +3,7 @@
 namespace app\index\controller;
 
 use app\common\controller\Frontend;
-
+use think\Db;
 class Index extends Frontend
 {
 
@@ -16,4 +16,36 @@ class Index extends Frontend
         return $this->view->fetch();
     }
 
+    //基础文章网页
+    public function basedata(){
+        $key = input('key','');
+        if(!$key){
+            exit;
+        }
+        $content = Db::name('basedata')->where('key',$key)->find();
+        $this->assign('content',$content['content']);
+        return $this->fetch();
+    }
+
+
+    /**
+     * app下载页
+     * 判断是安卓还是ios
+     */
+    public function appdownload() {
+
+        if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
+            header("Location: ".config('site.ios_downurl'));
+        }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){
+            $this->view->assign('downurl', config("site.android_apkUrl"));
+            return $this->view->fetch();
+        }else{
+            $this->view->assign('downurl', config("site.android_apkUrl"));
+            return $this->view->fetch();
+        }
+
+    }
+
+
+
 }

+ 199 - 0
application/index/controller/Plantask.php

@@ -0,0 +1,199 @@
+<?php
+
+namespace app\index\controller;
+
+use think\Controller;
+
+use Redis;
+use think\Db;
+use app\common\library\Easemob;
+class Plantask extends Controller
+{
+    //关于本文件里的计划任务
+    //只有 public 方法,auto_开头的才是计划任务,其他private 方法都是工具方法
+
+////////////////////////////////////////下面都是计划任务方法///////////////////////////////////////////////////////////////
+
+
+    //送礼物(api/party/giveGiftToYou)拆分出来的异步用户升级方法,
+    public function auto_user_level_up(){
+        Db::startTrans();
+        $tasklist = Db::name('gift_user_party')->where('task_status',0)->limit(20)->lock(true)->select();
+        if(empty($tasklist)){
+            Db::rollback();
+            echo 'empty';
+            exit;
+        }
+
+        try {
+            //redis
+            $redis = new Redis();
+            $redisconfig = config("redis");
+            $redis->connect($redisconfig["host"], $redisconfig["port"]);
+            if ($redisconfig['redis_pwd']) {
+                $redis->auth($redisconfig['redis_pwd']);
+            }
+            if($redisconfig['redis_selectdb'] > 0){
+                $redis->select($redisconfig['redis_selectdb']);
+            }
+
+            $money_to_jewel = config('site.money_to_jewel') ?: 10; //余额兑换金币
+//            $getempirical_conf = config("site.getempirical");
+
+            foreach($tasklist as $key => $giftuserparty){
+                echo $giftuserparty['id'].'<br>';
+
+                $giftValue = $giftuserparty['value'];
+                $hotValue  = $giftValue;
+
+                //用户信息
+                $authuser_info = Db::name('user')->field('nickname')->where('id',$giftuserparty['user_id'])->find();
+                $touserInfo    = Db::name('user')->field('nickname')->where('id',$giftuserparty['user_to_id'])->find();
+                $party_id = $giftuserparty['party_id'];
+
+
+                //添加获赠用户余额
+                $user_id = $giftuserparty['user_to_id'];
+                if($giftuserparty['getvalue'] > 0){
+                    $getMoney = bcdiv($giftuserparty['getvalue'],$money_to_jewel,2);
+                    if($getMoney > 0){
+                        $rs_wallet = model('wallet')->lockChangeAccountRemain($user_id,$getMoney,'+',0,"{$authuser_info['nickname']}送你{$giftuserparty['gift_name']}x{$giftuserparty['number']}",101,'money');
+                        if($rs_wallet['status'] == false){
+                            Db::rollback();
+                            $this->error($rs_wallet['msg']);
+                        }
+                    }
+                }
+                $partyInfo = \app\common\model\Party::field("id,room_type,party_name,party_hot,user_id,platRate,guilderRate,easemob_room_id")->where(["id"=>$giftuserparty['party_id']])->find();
+                //增加房主抽成
+                if ($partyInfo && $giftuserparty['guildervalue'] > 0) {
+                    $guilderMoney = bcdiv($giftuserparty['guildervalue'],$money_to_jewel,2);
+                    if($guilderMoney > 0){
+                        $rs_wallet = model('wallet')->lockChangeAccountRemain($partyInfo->user_id,$guilderMoney,'+',0,"{$authuser_info['nickname']}送礼物{$giftuserparty['gift_name']}x{$giftuserparty['number']}给{$touserInfo['nickname']},房间礼物抽成",102,'money');
+                        if($rs_wallet['status'] == false){
+                            Db::rollback();
+                            $this->error($rs_wallet['msg']);
+                        }
+                    }
+                }
+
+                //更新麦位魅力值
+                $this->updateSeatCharm($partyInfo['easemob_room_id'],$giftuserparty['seat_num'],$hotValue,$partyInfo);
+
+                // 如果是主播,则添加魅力值记录做榜单统计,这个表和送礼物日志表重复了,无意义
+                /*if($partyInfo) {
+                    $data = [];
+                    $data["user_id"] = $giftuserparty['user_to_id'];
+                    $data["party_id"] = $party_id;
+                    $data["charm"] = $hotValue;
+                    $data["createtime"] = time();
+                    \app\common\model\UserCharmRank::insert($data);
+
+                }*/
+
+                //用户经验升级
+                //$getempirical = $getempirical_conf * $hotValue;
+                // 获取用户贵族信息
+                /*$noble = \app\common\model\User::getUserNoble($giftuserparty['user_id']);
+                if(isset($noble["noble_on"]) && $noble["noble_on"] == 1) {
+                    $getempirical = $getempirical + $getempirical * ($noble["explain"]/100);
+                }*/
+
+                // 增加用户经验值
+                //$res = \app\common\model\User::addEmpirical($giftuserparty['user_id'],$getempirical);
+                /*if ($res){
+                    $this->auth->level = $res->level;
+                }*/
+
+                //增加被送礼物用户的魅力等级
+                $res_charm = \app\common\model\User::add_charm_level($giftuserparty['user_to_id'],$giftValue);
+
+                // +exp
+//                \app\common\model\TaskLog::tofinish($giftuserparty['user_id'],"OBHqCX4g",$giftuserparty['number']);
+
+                // +message
+                \app\common\model\Message::addMessage($giftuserparty['user_to_id'],"礼物通知","收到 ".$authuser_info['nickname']." 赠送的".$giftuserparty['gift_name']." x".$giftuserparty['number']." 价值 ".$giftValue ." 金币");
+
+                //增加送礼用户的财富等级
+                $res_wealth = \app\common\model\User::add_wealth_level($giftuserparty['user_id'],$giftValue);
+
+                // tcp 获取房间用户周前三名 getPartyUserTop里面摘出来的一部分
+                //[环信]更新财富榜前3。
+                $avatarArr = $redis->hGet("user_jewel_top3",$partyInfo['id']);
+                $easemob = new Easemob();
+                $matedata = [
+                    'wealth_top3_userlist'  => $avatarArr,
+                ];
+                $easemob->room_setRoomCustomAttributeForced($partyInfo['easemob_room_id'],$partyInfo['user_id'],$matedata);
+
+                //结束
+                $rs_up = Db::name('gift_user_party')->where('id',$giftuserparty['id'])->update(['task_status'=>1]);
+                if($rs_up === false){
+                    Db::rollback();
+                    echo '更新错误'.$giftuserparty['id'];
+                    exit;
+                }
+            }
+            Db::commit();
+        } 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());
+        }
+
+    }
+
+/////////////////////////////////////////下面都是工具方法////////////////////////////////////////////////
+
+    /**
+     *  用户赠送礼物后房间内麦位魅力值增加,更新到麦位自定义信息
+     * $seatnum 座位数字 1,不是键名 seat1
+     */
+    private function updateSeatCharm($easemob_room_id,$seatnum,$giftValue,$party_info) {
+        //获取已有信息
+        $key = 'seat'.$seatnum;
+        $easemob = new Easemob();
+        $seatdata = $easemob->room_getRoomCustomAttribute($easemob_room_id,[$key]);
+
+        if(empty($seatdata)){
+            //默认为空
+            $seatdata = [
+                'charm'    => 0,                    //红心,魅力值
+
+                'isMaster'       => false,            // 是否是房主
+                'headUrl'        => '',              // 头像
+                'userNo'         => '',               // 座位上用户no
+                'rtcUid'         => '',               // 座位上用户id,与rtc的userId一致
+                'name'           => '',                 // 座位上用户昵称
+                'seatIndex'      => $seatnum,               // 座位编号
+                'chorusSongCode' => '',             // 是否合唱
+                'isAudioMuted'   => 1,            // 是否静音
+                'isVideoMuted'   => 0,            // 是否开启视频
+                'checked'        => false,       // 用于送礼物选择用户
+                'isUsed'         => true,          // 用于送礼物选择用户
+                'gender'         => 1, //性别
+            ];
+        }else{
+            $seatdata = json_decode($seatdata[$key],true);
+        }
+
+        //魅力值自增
+        $seatdata['charm'] = intval($seatdata['charm']);
+        $seatdata['charm'] += $giftValue;
+
+        //重新设置
+        $matedata = [
+            $key  => json_encode($seatdata),
+        ];
+        $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$party_info['user_id'],$matedata);
+
+        return true;
+    }
+
+
+}

+ 82 - 0
application/index/view/index/appdownload.html

@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>TKEN下载</title>
+    <script src="../../assets/js/fontSize.js"></script>
+</head>
+<style>
+    .wxtip{background: rgba(0,0,0,0.8); text-align: center; position: fixed; left:0; top: 0; width: 100%; height: 100%; z-index: 998; display: none;}
+    .wxtip-icon{width: 52px; height: 67px; background: url(../../assets/img/weixin-tip.png) no-repeat; display: block; position: absolute; right: 20px; top: 20px;}
+    .wxtip-txt{margin-top: 107px; color: #fff; font-size: 16px; line-height: 1.5;}
+
+    * {
+        margin:0;
+        padding:0;
+    }
+    body {
+        background:#edf0f0;
+        font-family:Helvetica Neue,Helvetica,Arial,sans-serif;
+        font-size:14px;
+        color:#333;
+        padding:0;
+        margin:0;
+    }
+    .page{
+        position: relative;
+        left: 0;
+        top: 0;
+        right: 0;
+        bottom: 0;
+        width: 100vw;
+        height: 100vh;
+        background: url(../../assets/img/download.png) no-repeat center/cover;
+    }
+    .btn{
+        width: 290px;
+        height: 45px;
+        background: linear-gradient(90deg, #8F68DD, #6B7DDB);
+        box-shadow: 0px 1px 2px 0px rgba(126, 114, 220, 0.59);
+        line-height: 45px;
+        text-align: center;
+        font-size: 17px;
+        color: #FFFFFF;
+        border-radius: 35px;
+        bottom:26px;
+        left: 50%;
+        transform: translateX(-50%);
+        position: absolute;
+    }
+</style>
+
+<body >
+<div class="page">
+    <a class="btn" href="{$downurl}"  id="JdownApp">点击下载</a>
+</div>
+<div class="wxtip" id="JweixinTip">
+    <span class="wxtip-icon"></span>
+    <p class="wxtip-txt">点击右上角<br/>选择在浏览器中打开</p>
+</div>
+
+</body>
+<script>
+
+    function weixinTip(ele){
+        var ua = navigator.userAgent;
+        var isWeixin = !!/MicroMessenger/i.test(ua);
+        if(isWeixin){
+            ele.onclick=function(e){
+                window.event? window.event.returnValue = false : e.preventDefault();
+                document.getElementById('JweixinTip').style.display='block';
+            }
+            document.getElementById('JweixinTip').onclick=function(){
+                this.style.display='none';
+            }
+        }
+    }
+    var btn1 = document.getElementById('JdownApp');//下载一
+    weixinTip(btn1);
+</script>

+ 63 - 0
application/index/view/index/basedata.html

@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+    <style>
+        html, body, div, span, applet, object, iframe,
+        h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+        a, abbr, acronym, address, big, cite, code,
+        del, dfn, em, img, ins, kbd, q, s, samp,
+        small, strike, strong, sub, sup, tt, var,
+        b, u, i, center,
+        dl, dt, dd, ol, ul, li,
+        fieldset, form, label, legend,
+        table, caption, tbody, tfoot, thead, tr, th, td,
+        article, aside, canvas, details, embed, 
+        figure, figcaption, footer, header, hgroup, 
+        menu, nav, output, ruby, section, summary,
+        time, mark, audio, video {
+            margin: 0;
+            padding: 0;
+            border: 0;
+            font-size: 100%;
+            font: inherit;
+            vertical-align: baseline;
+            box-sizing: border-box;
+            font-family: Source Han Sans CN;
+        }
+        .page{
+            padding: 15px;
+            font-size: 14px;
+            line-height: 16px;
+            color:#333;
+        }
+    </style>
+</head>
+<body>
+    <div class="page">
+        {$content}
+    </div>
+</body>
+</html>
+<script src="/assets/js/jquery-3.1.1.min.js"></script>
+<script>
+
+    function replaceDetail(){
+        var details = $('.page').html();
+	   //newContent仅是details替换后内容;
+        let newContent = details.replace(/<img[^>]*>/gi, function (match, capture) { //去除三标签
+            match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
+            match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
+            match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
+            return match;
+        });
+        newContent = newContent.replace(/<br[^>]*\/>/gi, '');
+        newContent = newContent.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block;margin:0 auto;"');
+        $('.page').html('');
+        $('.page').html(newContent);
+    }
+    replaceDetail();
+</script>