基础框架同步

This commit is contained in:
2025-08-13 11:16:12 +08:00
parent fb6c1e1600
commit 48a608cdb3
16 changed files with 1276 additions and 6 deletions

View File

@@ -44,6 +44,10 @@ class Theme extends adminApi
} }
$list = db::name($this->table)->where($where)->page($page, $page_limit)->select(); $list = db::name($this->table)->where($where)->page($page, $page_limit)->select();
$count = db::name($this->table)->where($where)->count(); $count = db::name($this->table)->where($where)->count();
foreach ($list as &$value) {
$value['begin_time'] = date('Y-m-d H:i:s',$value['begin_time']);
$value['end_time'] = date('Y-m-d H:i:s',$value['end_time']);
}
$return_data = [ $return_data = [
'page' =>$page, 'page' =>$page,
'page_limit' => $page_limit, 'page_limit' => $page_limit,
@@ -62,6 +66,10 @@ class Theme extends adminApi
$auxiliary_color = input('auxiliary_color', ''); $auxiliary_color = input('auxiliary_color', '');
$file_url = input('file_url', ''); $file_url = input('file_url', '');
$is_active = input('is_active', ''); $is_active = input('is_active', '');
$begin_time = input('begin_time', '');
$end_time = input('end_time', '');
$begin_time = !empty($begin_time) ? strtotime($begin_time) : 0;
$end_time = !empty($end_time) ? strtotime($end_time) : 0;
$data = [ $data = [
'theme_name' => $theme_name, 'theme_name' => $theme_name,
'theme_color' => $theme_color, 'theme_color' => $theme_color,
@@ -69,7 +77,9 @@ class Theme extends adminApi
'file_url' => $file_url, 'file_url' => $file_url,
'is_active' => $is_active, 'is_active' => $is_active,
'admin_id' => $admin_id, 'admin_id' => $admin_id,
'createtime' => time() 'createtime' => time(),
'begin_time' => $begin_time,
'end_time' => $end_time,
]; ];
$res = db::name($this->table)->insert($data); $res = db::name($this->table)->insert($data);
if($res){ if($res){
@@ -87,6 +97,10 @@ class Theme extends adminApi
$auxiliary_color = input('auxiliary_color', ''); $auxiliary_color = input('auxiliary_color', '');
$file_url = input('file_url', ''); $file_url = input('file_url', '');
$is_active = input('is_active', ''); $is_active = input('is_active', '');
$begin_time = input('begin_time', '');
$end_time = input('end_time', '');
$begin_time = !empty($begin_time) ? strtotime($begin_time) : 0;
$end_time = !empty($end_time) ? strtotime($end_time) : 0;
$id = input('id', ''); $id = input('id', '');
$data = [ $data = [
'theme_name' => $theme_name, 'theme_name' => $theme_name,
@@ -94,7 +108,9 @@ class Theme extends adminApi
'auxiliary_color' => $auxiliary_color, 'auxiliary_color' => $auxiliary_color,
'file_url' => $file_url, 'file_url' => $file_url,
'is_active' => $is_active, 'is_active' => $is_active,
'updatetime' => time() 'updatetime' => time(),
'begin_time' => $begin_time,
'end_time' => $end_time,
]; ];
$res = db::name($this->table)->where(['id'=>$id])->update($data); $res = db::name($this->table)->where(['id'=>$id])->update($data);
if($res){ if($res){

View File

@@ -15,12 +15,37 @@ class Theme extends controller
} }
/* /*
* 启动页列表 * 启动页列表
* @return array * app背景图片 app_bg
* * 首页选中 home_sel
* 首页正常 home_nor
* 广场选中 find_sel
* 广场正常 find_nor
* 消息选中 msg_sel
* 消息正常 msg_nor
* 我的选中 mine_sel
* 我的正常 mine_nor
* 主题色 theme_color
* 按钮文字颜色 btn_text_color
*/ */
public function get_theme_data() public function get_theme_data()
{ {
$reslut = DB::name('vs_theme')->where('is_active',1)->where('delete_time',0)->find(); $reslut = DB::name('vs_theme')->field('theme_color,file_url,auxiliary_color')
->where(['delete_time' => 0 ,'is_active' => 1,'begin_time' => ['<',time()],'end_time' => ['>',time()]])->order('id desc')->find();
if($reslut){
$url = $reslut['file_url'];
$reslut['btn_text_color'] = $reslut['auxiliary_color'];
$reslut['app_bg'] = get_system_config_value('web_site').'/static/theme/'.$url.'/app_bg.png';
$reslut['home_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/home_sel.png';
$reslut['home_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/home_nor.png';
$reslut['find_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/find_sel.png';
$reslut['find_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/find_nor.png';
$reslut['msg_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/msg_sel.png';
$reslut['msg_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/msg_nor.png';
$reslut['mine_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/mine_sel.png';
$reslut['mine_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/mine_nor.png';
}
return V(1,'操作成功', $reslut); return V(1,'操作成功', $reslut);
} }
} }

View File

@@ -534,6 +534,20 @@ class RoomPit extends Model
model('Chat')->sendMsg(1034,$room_id,$text); model('Chat')->sendMsg(1034,$room_id,$text);
return ['code' => 1, 'msg' => '上麦成功', 'data' => null]; return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
}elseif($apply_type == 3){ }elseif($apply_type == 3){
if(count($to_user) >= 2){
return ['code' => 0, 'msg' => '拍卖模式下只能一个人上麦', 'data' => null];
}
//拍卖房当前到哪一步了
$step = db::name('vs_room_auction')->where(['room_id' => $room_id])->order('auction_id desc')->value('status');
if($step == 2){
return ['code' => 0, 'msg' => '拍卖已经开始', 'data' => null];
}
//拍卖位上有人吗
$paimai_user = Cache::get('auction_user_'.$room_id);
if($paimai_user){
//有人就让他下麦
return ['code' => 0, 'msg' => '拍卖位上已有人,请先抱对方下麦', 'data' => null];
}
$i = 0; $i = 0;
foreach ($to_user as &$value) { foreach ($to_user as &$value) {
$i++; $i++;

View File

@@ -0,0 +1 @@
<?php

View File

@@ -0,0 +1,6 @@
<?php
//配置文件
return [
'exception_handle' => '\\app\\friendapi\\library\\ExceptionHandle',
];

View File

@@ -0,0 +1,379 @@
<?php
namespace app\api\controller;
use app\common\controller\NumberAuth;
use app\api\controller\Sms;
use http\Client;
use think\Controller;
use think\Loader;
use Firebase\JWT\JWT;
use think\Log;
class Login extends Controller
{
public function _initialize()
{
//允许跨域
header('Access-Control-Allow-Origin: *');
}
/**
* 账号密码登录接口。
*
* @ string $user_login 用户名或手机号
* @ string $password 密码
* @ int $system 登录系统类型(如 iOS, Android
* @ json 返回登录结果信息
*/
public function user_login()
{
$user_name = input('user_login', '');
$password = input('password', '');
$system = input('system','');
if(empty($system)){
$system = request()->header('system');
}
$login_device = input('deviceId','');
if(empty($login_device)){
$login_device = request()->header('deviceId');
}
$reslut = model('Login')->user_login($user_name, $password, $system,$login_device);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
/**
* 验证码登录接口。
*
* @param string $user_login 手机号
* @param int $system 登录系统类型
* @param string $sms_code 短信验证码
* @ json 返回登录结果信息
*/
public function phone_code(){
$system = input('system','');
if(empty($system)){
$system = request()->header('system');
}
$login_device = input('deviceId','');
if(empty($login_device)){
$login_device = request()->header('deviceId');
}
$user_name = input('user_login');
$sms_code = input('sms_code', ''); //短信验证码
// $sms = new Sms;
// $ret = $sms->check($user_name, $sms_code);//$event = default-默认登录1-更换手机号2绑定手机号3-忘记密码4-设置密码5-账号注销6-提现
$ret = model('sms')->verification_code('default',$user_name, $sms_code);
if ($ret['code'] == 0) {
return V($ret['code'], $ret['msg'], null);
}
$reslut = model('Login')->phone_verification_code_log($user_name, $system,$login_device);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
/**
*
* @param string $login_token
* @param string $last_login_device 最后一次登录设备标识
* @param int $system 登录系统类型
* @ json 返回一键登录结果
*/
public function one_click_login()
{
$loginToken = input('login_token', '');
$system = input('system','');
if(empty($system)){
$system = request()->header('system');
}
$login_device = input('deviceId','');
if(empty($login_device)){
$login_device = request()->header('deviceId');
}
if (empty($loginToken)) {
return V(0, '验证码错误' );
}
// 1. 通过Token获取手机号
$mobile = NumberAuth::getMobileByToken($loginToken);
if (!$mobile) {
return V(0, '登录失败, 请更换登录方式!' );
}
if(ctype_digit($mobile)){
$reslut = model('Login')->phone_verification_code_log($mobile,$system,$login_device);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}else{
return V(0, '登录失败' );
}
}
//多账号选号登录
public function multi_account_login()
{
$user_name = input('user_login');
$system = input('system','');
$login_device = input('deviceId','');
if(empty($login_device)){
$login_device = request()->header('deviceId');
}
if(empty($system)){
$system = request()->header('system');
}
$reslut = model('Login')->multi_account_login($user_name, $system,$login_device);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
/**
* 微信登录
*/
public function wechatLogin()
{
$code = input('code');
$system = input('system','');
if(empty($system)){
$system = request()->header('system');
}
$login_device = input('deviceId','');
if(empty($login_device)){
$login_device = request()->header('deviceId');
}
if (empty($code)) {
return V(0, 'code不能为空' );
}
$config = get_system_config();
$appid = $config['wx_app_id'];
$app_secret = $config['wx_app_secret'];
$url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$app_secret}&code={$code}&grant_type=authorization_code";
$result = myCurl($url);
$data = json_decode($result, true);
if (isset($data['errcode'])) {
return V(0, $data['errmsg']);
}
// 获取用户信息
$userInfo = $this->getWechatUserInfo($data['access_token'], $data['openid']);
// 处理用户登录/注册逻辑
$reslut = model('Login')->wechat_ali_Login('wx',$userInfo,$system,$login_device);
if ($reslut['code'] == 1) {
return V(1, $reslut['msg'], $reslut['data'] );
}
return V(0, '登录失败' );
}
/**
* 获取微信用户信息
*/
private function getWechatUserInfo($accessToken, $openid)
{
$url = "https://api.weixin.qq.com/sns/userinfo?access_token={$accessToken}&openid={$openid}";
$result = myCurl($url);
return json_decode($result, true);
}
//给支付宝登录拼接参数
public function AlipayUserInfo()
{
$configs = get_system_config();
$app_id = $configs['alipay_app_id'];
$pid = $configs['alipay_pid'];
$data = [
'app_id' => $app_id,
'pid' => $pid,
'sign_type' => 'RSA2',
'apiname'=>'com.alipay.account.auth',
'method'=>'alipay.open.auth.sdk.code.get',
'app_name'=>'mc',
'biz_type'=>'openservice',
'product_id'=>'APP_FAST_LOGIN',
'scope'=>'kuaijie',
'target_id'=>generateRandom(12),
'auth_type'=>'AUTHACCOUNT',
];
$dd = $this->getCheckSignContent($data);
$sign = $this->aliPaySign($dd, $configs['alipay_private_key']);
//把签名放在最后
$dd = $dd . '&sign=' . urlencode($sign);
return V(1, '获取成功', $dd );
}
//生成签名前数据排序后拼接
/**
* 获取支付宝签名
* @param $params
* @param $rsaPrivateKey
* @return string
*/
function getCheckSignContent($params)
{
ksort($params);
$stringToBeSigned = '';
foreach ($params as $k => $v) {
if ($v && substr($v, 0, 1) != '@') {
$stringToBeSigned .= "$k=$v&";
}
}
$stringToBeSigned = rtrim($stringToBeSigned, '&');
return $stringToBeSigned;
}
/**
* 支付宝登录
* 支付宝开放平台创建应用 获取应用私钥 和应用公钥 然后修改AliPay.php文件里面login方法的配置值
*/
public function aliLogin()
{
$authCode = input('auth_code');
$system = input('system','');
if(empty($system)){
$system = request()->header('system');
}
$login_device = input('deviceId','');
if(empty($login_device)){
$login_device = request()->header('deviceId');
}
if (empty($authCode)) {
return V(0, 'auth_code不能为空' );
}
//引用支付宝sdk
Loader::import('AliPayV2.AliPay', EXTEND_PATH, '.php');
$ali = new \AliPay();
// 使用auth_code获取access_token
$userInfo = $ali->login($authCode);
if ($userInfo['code'] != 1) {
return V($userInfo['code'], $userInfo['msg'],$userInfo['data']);
}
//对象转数组
$userinfo = json_decode(json_encode($userInfo['data']), true);
// 处理用户登录/注册逻辑
$reslut = model('Login')->wechat_ali_Login('ali',$userinfo,$system,$login_device);
if ($reslut['code'] == 1) {
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
return V(0, '登录失败' );
}
/**
* 生成支付宝签名
*/
private function aliPaySign($stringToBeSigned, $privateKey)
{
$res = "-----BEGIN RSA PRIVATE KEY-----\n" .
wordwrap($privateKey, 64, "\n", true) .
"\n-----END RSA PRIVATE KEY-----";
openssl_sign($stringToBeSigned, $sign, $res, OPENSSL_ALGO_SHA256);
return base64_encode($sign);
}
/*
* ios 登录
*/
public function iosLogin()
{
$system = input('system','');
if(empty($system)){
$system = request()->header('system');
}
$login_device = input('deviceId','');
if(empty($login_device)){
$login_device = request()->header('deviceId');
}
$identityToken = input('ios_token');
$appleId = input('apple_id');
// $isValid = $this->verifyIdentityToken($identityToken);
//
// if (!$isValid) {
// return V(0, '无效的token' );
// }
// $decodedToken = JWT::decode( $identityToken, new \Firebase\JWT\Key(config('jwt_secret_key'), 'HS256'));
// $userIdentity = (array) $decodedToken;
//
// $appleId = $userIdentity['sub'];
// Log::record("ios登录信息".json_encode($userIdentity),"info");
// 处理用户登录/注册逻辑
$reslut = model('Login')->wechat_ali_Login('ios',$appleId,$system,$login_device);
if ($reslut['code'] == 1) {
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
return V(0, '登录失败' );
}
// private function verifyIdentityToken($identityToken)
// {
// $client = new Client();
//
// try {
// $response = $client->request('POST', 'https://appleid.apple.com/auth/keys');
//
// if ( $response->getStatusCode() == 200) {
// $publicKeys = json_decode( $response->getBody(), true)['keys'];
//
// foreach ( $publicKeys as $key) {
// $pem = $this->convertPublicKeyToPEM( $key);
// $decodedToken = JWT::decode( $identityToken, new \Firebase\JWT\Key( $pem, 'RS256'));
//
// if ( $decodedToken) {
// return true;
// }
// }
// }
// } catch (\Exception $e) {
// echo 'Error verifying token: ' . $e->getMessage();
// }
//
// return false;
// }
//退出登录
public function logout()
{
$token = input('token');
$reslut = model('Login')->logout($token);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//注销
public function cancel()
{
$token = input('token');
$reslut = model('Login')->cancel($token);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//忘记密码
public function forgot_password()
{
$user_name = input('mobile');
$password = input('new_password');
$sms_code = input('sms_code', ''); //短信验证码
//default-默认登录1-更换手机号2绑定手机号3-忘记密码4-设置密码5-账号注销6-提现
$reslut = model('sms')->verification_code(3,$user_name, $sms_code);
if ($reslut['code'] == 0) {
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
$reslut = model('Login')->forgot_password($user_name, $password);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
}

View File

@@ -0,0 +1,409 @@
<?php
namespace app\api\controller;
use app\common\controller\BaseCom;
use think\Db;
class Room extends BaseCom
{
//创建房间
public function create_room()
{
$room_name = input('room_name', '');
$room_cover = input('room_cover', '');
$room_intro = input('room_intro', '');
$key_name = "api:room:user_create_room:" . $this->uid;
redis_lock_exits($key_name);
$reslut = model('Room')->user_create_room($this->uid, $room_name, $room_cover, $room_intro);
redis_unlock($key_name);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//编辑房间
public function edit_room()
{
$room_id = input('room_id', 0);
$room_name = input('room_name', '');
$room_cover = input('room_cover', '');
$room_intro = input('room_intro', '');
$room_background_id = input('room_background', '');
$reslut = model('Room')->user_edit_room($this->uid, $room_id, $room_name, $room_cover, $room_intro,$room_background_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//关注的用户现在所在房间(废弃)
public function user_follow_in_room_list()
{
$page = input('page', 1);
$page_limit = input('page_limit', 15);
$reslut = model('Room')->user_follow_in_room_list($this->uid, $page, $page_limit);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//房间随机名称
public function room_random_name()
{
return V(1, '获取成功', generateRandomRoomName());
}
// 房间历史足迹
public function user_room_history_list()
{
$page = input('page', 1);
$page_limit = input('page_limit', 15);
$reslut = model('UserData')->user_room_history_list($this->uid, $page, $page_limit);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//删除历史足迹
public function delete_room_history()
{
$reslut = model('UserData')->delete_room_history($this->uid);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//我创建/主持/管理/关注的房间
public function my_associated_room()
{
$page = input('page', 1);
$page_limit = input('page_limit', 15);
$type = input('type', 0);//0-我创建的 1-我主持的 2-我管理的 3-我关注的
$reslut = model('Room')->my_associated_room($this->uid, $type, $page, $page_limit);
return V(1, '获取成功', $reslut);
}
//我的Cp房
public function my_cp_room()
{
$reslut = model('Room')->my_cp_room($this->uid);
return V(1, '获取成功', $reslut);
}
//房间补贴
public function room_ubsidy()
{
$room_id = input('room_id', 0);
$reslut = model('Room')->room_ubsidy($room_id);
return V(1, '获取成功', $reslut);
}
//房间历史补贴记录
public function room_subsidy_history()
{
$room_id = input('room_id', 0);
$page = input('page', 1);
$page_limit = input('page_limit', 15);
$reslut = model('Room')->room_subsidy_history($room_id, $page, $page_limit);
return V(1, '获取成功', $reslut);
}
//房间流水明细
public function room_turnover_detail()
{
$room_id = input('room_id', 0);
$start_time = input('start_time', '');
$end_time = input('end_time', '');
$page = input('page', 1);
$page_limit = input('page_limit', 15);
$reslut = model('Room')->room_turnover_detail($room_id, $start_time, $end_time, $page, $page_limit);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
/*
* 进入房间
*/
public function join_room()
{
$room_id = input('room_id', 0);
$password = input('password', '');
$reslut = model('Room')->join_room($this->uid, $room_id, $password);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//退出房间
public function quit_room()
{
$room_id = input('room_id', 0);
$user_id = input('user_id', 0);
$reslut = model('Room')->quit_room($this->uid, $room_id,$user_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//踢出房间
public function kick_out_room()
{
$room_id = input('room_id', 0);
$user_id = input('user_id', 0);
$reslut = model('Room')->quit_room($this->uid, $room_id,$user_id,1);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//直播间送礼
public function room_give_gift()
{
$room_id = input('room_id', 0);
$gift_id = input('gift_id', 0);
$gift_num = input('gift_num', 0);
$to_uid = input('to_uid', 0);//收礼人ID逗号隔开的字符串
$type = input('type', 1);//1金币购买 2送背包礼物
$pit_number = input('pit_number', 0);
$reslut = model('Room')->room_gift($this->uid, $to_uid, $gift_id, $gift_num, $type, $room_id, $pit_number);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//房间榜单
public function room_rank()
{
$room_id = input('room_id', 0);
$type = input('type', 1);//1财富榜2魅力榜
$timeType = input('time_type', 1);//1小时榜2天榜3周榜
$page = input('page', 1);
$limit = input('limit', 30);
$reslut = model('Room')->room_rank($room_id, $type, $timeType, $page, $limit);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//房间在线列表
public function room_online_list()
{
$room_id = input('room_id', 0);
$page = input('page', 1);
$limit = input('limit', 50);
$reslut = model('Room')->room_online_list($room_id, $page, $limit);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//房间内用户主页(房间内点头像)
public function room_user_home()
{
$room_id = input('room_id', 0);
$user_id = input('user_id', 0);
$reslut = model('Room')->room_user_home($this->uid,$room_id, $user_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//设置开播提醒
public function set_live_reminder()
{
$user_id = input('user_id', 0);
$reslut = model('Room')->set_live_reminder($this->uid, $user_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//当前发(抢)头条需要的数据
public function current_headline()
{
$reslut = model('HeadLine')->current_headline();
return V(1, '成功', $reslut);
}
//发(抢)头条
public function send_headline()
{
$content = input('content', '');
$money = input('money', 0);
$room_id = input('room_id', 0);
$reslut = model('HeadLine')->send_headline($this->uid,$money,$content,$room_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//设置主持
public function set_host()
{
$room_id = input('room_id', 0);
$user_id = input('user_id', 0);
$type = input('type', 1);//1-主持,2管理
$is_add = input('is_add', 1);//1-添加,2-删除
$reslut = model('Room')->set_host($this->uid, $room_id, $user_id,$type,$is_add);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//主持人,管理员列表
public function host_list()
{
$room_id = input('room_id', 0);
$type = input('type', 0);
$reslut = model('Room')->host_list($room_id,$type);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//设置主持人收益
public function set_host_profit()
{
$room_id = input('room_id', 0);
$host_id = input('user_id', 0);
$ratio = input('ratio', 0);
$reslut = model('Room')->set_host_profit($this->uid, $room_id, $host_id,$ratio);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//清除房间用户魅力
public function clear_user_charm()
{
$room_id = input('room_id', 0);
$user_id = input('user_id', 0);
$reslut = model('Room')->clear_user_charm($this->uid, $room_id,$user_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//修改房间类型
public function change_room_type()
{
$room_id = input('room_id', 0);
$type = input('type', 1);//1-点唱,2-拍卖3-男神4-女神
$reslut = model('Room')->change_room_type($this->uid, $room_id, $type);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//更新用户声网的token
public function update_user_sw_token()
{
$room_id = input('room_id', 0);
$reslut = model('Room')->update_user_token($this->uid, $room_id);
return V(1, '成功', $reslut);
}
//更新房间声网的RTM token
public function update_rtm_token()
{
$room_id = input('room_id', 0);
$reslut = model('Room')->update_rtm_token($this->uid, $room_id);
return V(1, '成功', $reslut);
}
//房间信息
public function room_info()
{
$room_id = input('room_id', 0);
$reslut = model('Room')->room_info($this->uid, $room_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//禁言 禁麦 \解禁
public function set_mute()
{
$room_id = input('room_id', 0);
$user_id = input('user_id', 0);
$is_mute = input('is_mute', 1);//1-禁言2-禁麦3-解禁4-解麦
$reslut = model('Room')->set_mute($this->uid, $room_id, $user_id,$is_mute);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//禁麦 \解禁
// public function set_mute_pit()
// {
// $room_id = input('room_id', 0);
// $pit_number = input('pit_number', 0);
// $is_mute = input('is_mute', 0);//0 未禁麦 1已
// $reslut = model('Room')->set_mute_pit($this->uid, $room_id, $pit_number,$is_mute);
// return V($reslut['code'], $reslut['msg'], $reslut['data']);
// }
//锁麦\解锁
public function set_lock_pit()
{
$room_id = input('room_id', 0);
$pit_number = input('pit_number', 0);
$is_mute = input('is_lock', 0);// 0 未锁麦 1已锁麦
$reslut = model('Room')->set_lock_pit($this->uid, $room_id, $pit_number,$is_mute);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//房间背景列表
public function room_bg_list()
{
$reslut['public_bg'] = db::name('vs_room_background')->where(['upload_user'=>0,'status' => 1,'delete_time' => null])->select();
$reslut['private_bg'] = db::name('vs_room_background')->where(['upload_user'=>$this->uid,'status' => 1,'delete_time' => null])->select();
return V(1, '成功', $reslut);
}
//上传背景图片
public function upload_bg_img()
{
$id = input('id', 0);
$image_url = input('image_url', 0);
$reslut = model('Room')->upload_bg_img($this->uid, $image_url, $id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//关系卡,关系位
public function relation_card()
{
$user_id = input('user_id', 0);
$reslut = model('Room')->relation_card($this->uid, $user_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//置顶关系卡,关系位
public function top_relation_card()
{
$relation_card_id = input('id', 0);
$reslut = model('Room')->top_relation_card($this->uid, $relation_card_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//删除关系卡,关系位
public function delete_relation_card()
{
$relation_card_id = input('id', 0);
$reslut = model('Room')->delete_relation_card($this->uid, $relation_card_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//记录房间操作
public function room_operation_record()
{
$room_id = input('room_id', 0);
$type = input('type', 0);//1-禁麦位2-清空消息3-清空魅力值4-加入黑名单5-踢出房间6-关闭麦克风7-申请上麦8-同意上麦9-拒绝上麦10-点歌11-开启PK',
model('Room')->room_operation_record($this->uid,$room_id,$type);
return V(1, '成功', null);
}
//用户状态查询
public function user_online_status()
{
$room_id = input('room_id', 0);
$user_id = input('user_id', '');
$reslut = model('Room')->user_online_status($room_id, $user_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//隐藏房间
public function hide_room()
{
$room_id = input('room_id', 0);
$reslut = model('Room')->hide_room($this->uid, $room_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//房间内在线人数
public function room_online_number()
{
$room_id = input('room_id', 0);
$reslut = model('Room')->room_online_number($room_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//房间在线列表
public function room_online_list_ceshi()
{
$room_id = input('room_id', 0);
$page = input('page', 1);
$limit = input('limit', 50);
$reslut = model('Room')->room_online_list($room_id, $page, $limit);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
}

View File

@@ -0,0 +1,147 @@
<?php
namespace app\api\controller;
use app\common\controller\BaseCom;
use think\Db;
class RoomPit extends BaseCom
{
//申请上麦
public function apply_pit()
{
$room_id = input('room_id', 0);
$pit_number = input('pit_number', 0);
if($room_id == 0){
return V(0, '房间ID不能为空', null);
}
$res = model('Room')->get_room_label($room_id);
if($res['code'] != 1){
return V(0, '房间不存在', null);
}
//查询房间主持麦有人吗
$room_host_info = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9])->value('user_id');
//房主,管理,主持不受此限制
$room_owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $this->uid])->find();
//管理
$room_manager = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $this->uid,'type' => 2,'delete_time' => null])->find();
//主持
$room_host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $this->uid,'type' => 1,'delete_time' => null])->find();
if($room_host_info == 0 && !$room_owner && !$room_manager && !$room_host){
return V(0, '上麦请联系主持', null);
}
$room_label = $res['data']['label_id'];
$room_type = $res['data']['type_id'];
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4))|| $room_type == 2){
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id,$pit_number);
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
$reslut = model('RoomSong')->apply_kpit($this->uid, $room_id,$pit_number);
}else{
return V(0, '房间不存在', null);
}
//1-禁麦位2-清空消息3-清空魅力值4-加入黑名单5-踢出房间6-关闭麦克风7-申请上麦8-同意上麦9-拒绝上麦10-点歌11-开启PK',
model('Room')->room_operation_record($this->uid,$room_id,7,0,$pit_number);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//申请上麦列表
public function apply_pit_list()
{
$room_id = input('room_id', 0);
$reslut = model('RoomPit')->apply_pit_list($this->uid, $room_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//上麦助力
public function help_apply_pit()
{
$room_id = input('room_id', 0);
$user_id = input('user_id', 0);
$reslut = model('RoomPit')->help_apply_pit($this->uid, $room_id, $user_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//同意上麦
public function agree_pit()
{
$room_id = input('room_id', 0);
$user_id = input('user_id', 0);//逗号分割
$reslut = model('RoomPit')->agree_pit($this->uid, $room_id, $user_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//拒绝上麦
public function refuse_pit()
{
$room_id = input('room_id', 0);
$user_id = input('user_id', 0);//逗号分割
$reslut = model('RoomPit')->clear_apply_pit_list($this->uid, $room_id, $user_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//清空上麦申请列表
public function clear_apply_pit_list()
{
$room_id = input('room_id', 0);
$reslut = model('RoomPit')->clear_apply_pit_list($this->uid, $room_id);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//设置房间插麦礼物
public function set_room_pit_apply_help_gift()
{
$room_id = input('room_id', 0);
$gift_id = input('gift_id', 0);
$gift_price = input('gift_price', 0);
$reslut = model('RoomPit')->set_room_pit_apply_help_gift($this->uid, $room_id, $gift_id, $gift_price);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//下麦
public function down_pit()
{
$room_id = input('room_id', 0);
$pit_number = input('pit_number', 0);
if($room_id == 0){
return V(0, '房间ID不能为空', null);
}
$res = model('Room')->get_room_label($room_id);
if($res['code'] != 1){
return V(0, '房间不存在', null);
}
$room_label = $res['data']['label_id'];
$room_type = $res['data']['type_id'];
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4)) || $room_type == 2){
$reslut = model('RoomPit')->DownPit($this->uid, $room_id,$pit_number);
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
$reslut = model('RoomSong')->down_kpit($this->uid, $room_id);
}
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//修改房间上麦模式
public function change_room_up_pit_type()
{
$key_name = "api:room:change_room_up_pit_type:" . $this->uid;
redis_lock_exit($key_name);
$room_id = input('room_id', 0);
// $user_id = input('user_id', 0);
$reslut = model('RoomPit')->change_room_up_pit_type($this->uid, $room_id);
redis_unlock($key_name);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
//抱麦/踢麦
public function host_user_pit()
{
$room_id = input('room_id', 0);
$pit_number = input('pit_number', 0);
$user_id = input('user_id', 0);//
$type = input('type', 0);//1-抱麦 2-踢下去
$reslut = model('RoomPit')->host_user_pit($this->uid, $room_id,$pit_number,$user_id,$type);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}
}

View File

@@ -0,0 +1,129 @@
<?php
return [
'Keep login' => '保持会话',
'Username' => '用户名',
'User id' => '会员ID',
'Nickname' => '昵称',
'Password' => '密码',
'Sign up' => '注 册',
'Sign in' => '登 录',
'Sign out' => '退 出',
'Guest' => '游客',
'Welcome' => '%s你好',
'Add' => '添加',
'Edit' => '编辑',
'Delete' => '删除',
'Move' => '移动',
'Name' => '名称',
'Status' => '状态',
'Weigh' => '权重',
'Operate' => '操作',
'Warning' => '温馨提示',
'Default' => '默认',
'Article' => '文章',
'Page' => '单页',
'OK' => '确定',
'Cancel' => '取消',
'Loading' => '加载中',
'More' => '更多',
'Normal' => '正常',
'Hidden' => '隐藏',
'Submit' => '提交',
'Reset' => '重置',
'Execute' => '执行',
'Close' => '关闭',
'Search' => '搜索',
'Refresh' => '刷新',
'First' => '首页',
'Previous' => '上一页',
'Next' => '下一页',
'Last' => '末页',
'None' => '无',
'Home' => '主页',
'Online' => '在线',
'Logout' => '退出',
'Profile' => '个人资料',
'Index' => '首页',
'Hot' => '热门',
'Recommend' => '推荐',
'Dashboard' => '控制台',
'Code' => '编号',
'Message' => '内容',
'Line' => '行号',
'File' => '文件',
'Menu' => '菜单',
'Type' => '类型',
'Title' => '标题',
'Content' => '内容',
'Append' => '追加',
'Memo' => '备注',
'Parent' => '父级',
'Params' => '参数',
'Permission' => '权限',
'Advance search' => '高级搜索',
'Check all' => '选中全部',
'Expand all' => '展开全部',
'Begin time' => '开始时间',
'End time' => '结束时间',
'Create time' => '创建时间',
'Flag' => '标志',
'Please login first' => '请登录后操作',
'Uploaded successful' => '上传成功',
'You can upload up to %d file%s' => '你最多还可以上传%d个文件',
'You can choose up to %d file%s' => '你最多还可以选择%d个文件',
'Chunk file write error' => '分片写入失败',
'Chunk file info error' => '分片文件错误',
'Chunk file merge error' => '分片合并错误',
'Chunk file disabled' => '未开启分片上传功能',
'Cancel upload' => '取消上传',
'Upload canceled' => '上传已取消',
'No file upload or server upload limit exceeded' => '未上传文件或超出服务器上传限制',
'Uploaded file format is limited' => '上传文件格式受限制',
'Uploaded file is not a valid image' => '上传文件不是有效的图片文件',
'Are you sure you want to cancel this upload?' => '确定取消上传?',
'Remove file' => '移除文件',
'You can only upload a maximum of %s files' => '你最多允许上传 %s 个文件',
'You can\'t upload files of this type' => '不允许上传的文件类型',
'Server responded with %s code' => '服务端响应(Code:%s)',
'File is too big (%sMiB), Max filesize: %sMiB.' => '当前上传(%sM),最大允许上传文件大小:%sM',
'Redirect now' => '立即跳转',
'Operation completed' => '操作成功!',
'Operation failed' => '操作失败!',
'Unknown data format' => '未知的数据格式!',
'Network error' => '网络错误!',
'Advanced search' => '高级搜索',
'Invalid parameters' => '未知参数',
'No results were found' => '记录未找到',
'Parameter %s can not be empty' => '参数%s不能为空',
'You have no permission' => '你没有权限访问',
'An unexpected error occurred' => '发生了一个意外错误,程序猿正在紧急处理中',
'This page will be re-directed in %s seconds' => '页面将在 %s 秒后自动跳转',
'操作成功' => '操作成功',
'操作失败' => '操作失败',
'参数错误' => '参数错误',
'请重试' => '请重试',
'该装扮不存在' => '该装扮不存在',
'该装扮天数不存在' => '该装扮天数不存在',
'该个人靓号已被购买' => '该个人靓号已被购买',
'该房间靓号已被购买' => '该房间靓号已被购买',
'该工会靓号已被购买' => '该工会靓号已被购买',
'用户信息错误' => '用户信息错误',
'非法资金类型' => '非法资金类型',
'当前用户金币已达上限' => '当前用户金币已达上限',
'当前用户钻石已达上限' => '当前用户钻石已达上限',
'非法资金变动类型' => '非法资金变动类型',
'变动的数值必须为数字' => '变动的数值必须为数字',
'金币不足' => '金币不足',
'钻石不足' => '钻石不足',
'购买成功' => '购买成功',
'购买失败' => '购买失败',
'装扮已过期' => '装扮已过期',
'设置失败' => '设置失败',
'设置成功' => '设置成功',
];

View File

@@ -0,0 +1,3 @@
<?php
return [];

View File

@@ -0,0 +1,39 @@
<?php
return [
'User center' => '会员中心',
'Register' => '注册',
'Login' => '登录',
'Sign up successful' => '注册成功',
'Username can not be empty' => '用户名不能为空',
'Username must be 3 to 30 characters' => '用户名必须3-30个字符',
'Username must be 6 to 30 characters' => '用户名必须6-30个字符',
'Password can not be empty' => '密码不能为空',
'Password must be 6 to 30 characters' => '密码必须6-30个字符',
'Mobile is incorrect' => '手机格式不正确',
'Username already exist' => '用户名已经存在',
'Nickname already exist' => '昵称已经存在',
'Email already exist' => '邮箱已经存在',
'Mobile already exist' => '手机号已经存在',
'Username is incorrect' => '用户名不正确',
'Email is incorrect' => '邮箱不正确',
'Account is locked' => '账户已经被锁定',
'Password is incorrect' => '密码不正确',
'Account is incorrect' => '账户不正确',
'Account not exist' => '账户不存在',
'Account can not be empty' => '账户不能为空',
'Username or password is incorrect' => '用户名或密码不正确',
'You are not logged in' => '你当前还未登录',
'You\'ve logged in, do not login again' => '你已经存在,请不要重复登录',
'Profile' => '个人资料',
'Verify email' => '邮箱验证',
'Change password' => '修改密码',
'Captcha is incorrect' => '验证码不正确',
'Logged in successful' => '登录成功',
'Logout successful' => '退出成功',
'Operation failed' => '操作失败',
'Invalid parameters' => '参数不正确',
'Change password failure' => '修改密码失败',
'Change password successful' => '修改密码成功',
'Reset password successful' => '重置密码成功',
];

View File

@@ -0,0 +1,37 @@
<?php
namespace app\api\library;
use Exception;
use think\exception\Handle;
/**
* 自定义API模块的错误显示
*/
class ExceptionHandle extends Handle
{
public function render(Exception $e)
{
// 在生产环境下返回code信息
if (!\think\Config::get('app_debug')) {
$statuscode = $code = 500;
$msg = 'An error occurred';
// 验证异常
if ($e instanceof \think\exception\ValidateException) {
$code = 0;
$statuscode = 200;
$msg = $e->getError();
}
// Http异常
if ($e instanceof \think\exception\HttpException) {
$statuscode = $code = $e->getStatusCode();
}
return json(['code' => $code, 'msg' => $msg, 'time' => time(), 'data' => null], $statuscode);
}
//其它此交由系统处理
return parent::render($e);
}
}

View File

@@ -230,7 +230,7 @@ class YunPay
// 异步回调参数 // 异步回调参数
$notifyReq = new NotifyRequest ($data, $mess, $timestamp, $sign) ;// 发起验签解密 $notifyReq = new NotifyRequest ($data, $mess, $timestamp, $sign) ;// 发起验签解密
try { try {
$result = $notifyClient->verifyAndDescrype($notifyReq) ; $result = $notifyClient->verifyAndDecrypt($notifyReq) ;
Log::record("云账户回调信息-返回:".json_encode($result),"info"); Log::record("云账户回调信息-返回:".json_encode($result),"info");
$result = json_decode($result,true); $result = json_decode($result,true);
if ($result['signRes']) { if ($result['signRes']) {

File diff suppressed because one or more lines are too long