代码初始化
This commit is contained in:
196
application/api/controller/Activities.php
Normal file
196
application/api/controller/Activities.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 活动:
|
||||
* 1.首充好礼
|
||||
*
|
||||
*/
|
||||
class Activities extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
|
||||
//首充好礼
|
||||
public function first_charge_gift()
|
||||
{
|
||||
//活动信息
|
||||
$activities_id = 1;//首充
|
||||
$activities_title = DB::name('vs_activities')->where(['id'=>$activities_id,'status'=>1])->value('title');
|
||||
//礼包
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>$activities_id,'status'=>1])->select();
|
||||
$data = [];
|
||||
$data['name'] = $activities_title??"";
|
||||
$data['gift_bag'] = [];
|
||||
foreach ($gift_bag as $k=>$v){
|
||||
$data['gift_bag'][$k]['name'] = $v['title']??"";
|
||||
$ext = json_decode($v['ext'],true);
|
||||
$data['gift_bag'][$k]['title1'] = $ext['title1']??"";
|
||||
$data['gift_bag'][$k]['title2'] = $ext['title2']??"";
|
||||
$data['gift_bag'][$k]['money'] = $ext['money'];
|
||||
$data['gift_bag'][$k]['gift_list'] = [];
|
||||
$detail = DB::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$v['id']])->select();
|
||||
$list = [];
|
||||
foreach ($detail as $kk=>$vv){
|
||||
if($vv['type'] == 1){
|
||||
$list[$kk]['gift_name'] = "金币";
|
||||
$list[$kk]['num'] = $vv['quantity'];
|
||||
$list[$kk]['gift_price'] = $vv['gold'];
|
||||
$list[$kk]['type'] = 1;
|
||||
$list[$kk]['base_image'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
}elseif ($vv['type'] == 2) {
|
||||
$gift = DB::name('vs_gift')->where(['gid'=>$vv['foreign_id']])->find();
|
||||
$list[$kk]['gift_name'] = $gift['gift_name'];
|
||||
$list[$kk]['num'] = $vv['quantity'];
|
||||
$list[$kk]['gift_price'] = $gift['gift_price'];
|
||||
$list[$kk]['type'] =2;
|
||||
$list[$kk]['base_image'] = $gift['base_image'];
|
||||
} elseif ($vv['type'] == 3) {
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$vv['foreign_id']])->find();
|
||||
if($decorate_price){
|
||||
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
||||
$list[$kk]['gift_name'] = $gift['title']??""; //装扮名称
|
||||
$list[$kk]['num'] = $decorate_price['day']??0; //天数
|
||||
$list[$kk]['gift_price'] = $decorate_price['price']??0; //价格
|
||||
$list[$kk]['type'] =3;
|
||||
$list[$kk]['base_image'] = $gift['base_image'] ?? "";
|
||||
}
|
||||
|
||||
}elseif ($vv['type'] == 4) {
|
||||
$list[$kk]['gift_name'] = "钻石";
|
||||
$list[$kk]['num'] = $vv['quantity'];
|
||||
$list[$kk]['gift_price'] = $vv['gold'];
|
||||
$list[$kk]['type'] = 4;
|
||||
$list[$kk]['base_image'] = localpath_to_netpath("static/image/icon/diamond.png");
|
||||
}
|
||||
}
|
||||
$data['gift_bag'][$k]['gift_list'] = array_values($list);
|
||||
}
|
||||
|
||||
return V(1,'操作成功', $data);
|
||||
}
|
||||
//首充好礼权限
|
||||
public function first_charge_gift_permission()
|
||||
{
|
||||
$activities_id = 1;//首充
|
||||
$uid = input('uid',$this->uid);
|
||||
$permission_status = 1;
|
||||
//查询是否首充
|
||||
$is_first_charge = db::name('vs_user_money_log')->where('user_id',$uid)->where('change_type',2)->where('money_type',1)->count();
|
||||
$permission = DB::name('vs_activities_receive')->where(['activities_id'=>$activities_id,'user_id'=>$uid])->find();
|
||||
$system = request()->header('system');
|
||||
$app_version = request()->header('App-Version');
|
||||
if(!$app_version){
|
||||
$app_version = input('App-Version');
|
||||
}
|
||||
$api_version = 0;
|
||||
if ($system == 'iOS') {
|
||||
$api_versions = db::name('version')->where(['type' => 2, 'status' => 1])->order('id', 'desc')->find();
|
||||
$result = version_compare($api_versions['oldversion'],$app_version);
|
||||
if ($result < 0) {
|
||||
$api_version = 1;
|
||||
}
|
||||
}
|
||||
if($is_first_charge > 0){
|
||||
$permission_status = 0;
|
||||
}
|
||||
if($permission){
|
||||
$permission_status = 0;
|
||||
}
|
||||
return V(1,'操作成功', ['permission'=>$permission_status],$api_version);
|
||||
|
||||
}
|
||||
//首充好礼发放
|
||||
public function first_charge_gift_receive()
|
||||
{
|
||||
$uid = input('uid',$this->uid);
|
||||
$money = input('money',0);
|
||||
$reslut = model('Activities')->first_charge_gift_send($uid,$money);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
|
||||
//天降好礼
|
||||
public function day_drop_gift()
|
||||
{
|
||||
$activities_id = 3;//天降好礼
|
||||
$activities = DB::name('vs_activities')->where(['id'=>$activities_id,'status'=>1])->find();
|
||||
//礼包
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>$activities_id,'status'=>1])->find();
|
||||
$data = [];
|
||||
$data['name'] = $activities['title']??"";
|
||||
$data['bag_name'] = $gift_bag['title']??"";
|
||||
$data['effective_time'] = $activities['effective_time']??"";
|
||||
//规则
|
||||
$data['rule'] = get_system_config_value('web_site')."/api/Page/page_show?id=13";
|
||||
$ext = json_decode($gift_bag['ext'],true);
|
||||
$data['money'] = $ext['money'];
|
||||
$data['counter']['counter'] = $ext['counter'];
|
||||
$data['counter']['money'] = $ext['money_str'];
|
||||
$data['counter']['diamond'] = $ext['diamond'];
|
||||
$detail = DB::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$gift_bag['id']])->select();
|
||||
$data['gift_list'] = [];
|
||||
foreach ($detail as $k=>$v){
|
||||
if($v['type'] == 1){
|
||||
$list[$k]['name'] = "金币";
|
||||
$list[$k]['num'] = $v['gold'];
|
||||
$list[$k]['gold'] = $v['gold'];
|
||||
$list[$k]['type'] = 1;
|
||||
$list[$k]['icon'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
}elseif($v['type'] == 2) {
|
||||
$gift = DB::name('vs_gift')->where(['gid'=>$v['foreign_id']])->find();
|
||||
$list[$k]['name'] = $gift['gift_name'];
|
||||
$list[$k]['num'] = $v['quantity'];
|
||||
$list[$k]['gold'] = $gift['gift_price'];
|
||||
$list[$k]['type'] =2;
|
||||
$list[$k]['icon'] = $gift['play_image'];
|
||||
} elseif($v['type'] == 3) {
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$v['foreign_id']])->find();
|
||||
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
||||
$list[$k]['name'] = $gift['title']; //装扮名称
|
||||
$list[$k]['num'] = $decorate_price['day']; //天数
|
||||
$list[$k]['gold'] = $decorate_price['price']; //价格
|
||||
$list[$k]['type'] =3;
|
||||
$list[$k]['icon'] = $gift['base_image'];
|
||||
}elseif($v['type'] == 4) {
|
||||
$list[$k]['name'] = "钻石";
|
||||
$list[$k]['num'] = $v['quantity'];
|
||||
$list[$k]['gold'] = $v['gold'];
|
||||
$list[$k]['type'] = 4;
|
||||
$list[$k]['icon'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
}
|
||||
}
|
||||
$data['gift_list'] = $list;
|
||||
return V(1,'操作成功', $data);
|
||||
}
|
||||
//天降好礼权限
|
||||
public function day_drop_gift_permission()
|
||||
{
|
||||
$activities_id = 3;//天降好礼
|
||||
$uid = input('uid',$this->uid);
|
||||
$permission = DB::name('vs_activities_receive')->where(['activities_id'=>$activities_id,'user_id'=>$uid])->find();
|
||||
if($permission){
|
||||
return V(1,'操作成功', ['permission'=>0]);
|
||||
}else{
|
||||
return V(1,'操作成功', ['permission'=>1]);
|
||||
}
|
||||
|
||||
}
|
||||
//天降好礼发放
|
||||
public function drop_gift_send()
|
||||
{
|
||||
$uid = input('uid',$this->uid);
|
||||
$reslut = model('Activities')->drop_gift_send($uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
51
application/api/controller/Banner.php
Normal file
51
application/api/controller/Banner.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
|
||||
class Banner extends controller
|
||||
{
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
/*
|
||||
* 启动页列表
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public function get_banner_qidonglist()
|
||||
{
|
||||
$reslut = model('Banner')->banner_list(2);
|
||||
return V(1,'操作成功', $reslut);
|
||||
}
|
||||
/*
|
||||
* 单页输出
|
||||
* @param id
|
||||
* @return html
|
||||
*/
|
||||
public function banner_content_show()
|
||||
{
|
||||
$id = input('id', '');
|
||||
$reslut = model('Banner')->find($id);
|
||||
$html = $reslut['content'] ? $reslut['content'] : '';
|
||||
//解析html
|
||||
$html = htmlspecialchars_decode($html);
|
||||
return $html;
|
||||
}
|
||||
|
||||
/*
|
||||
* 广告列表
|
||||
*/
|
||||
public function get_banner_list(){
|
||||
$show_type = input('show_type', '');
|
||||
if (!$show_type) {
|
||||
return V(0,'参数错误');
|
||||
}
|
||||
$reslut = model('Banner')->banner_list($show_type);
|
||||
return V(1,'操作成功', $reslut);
|
||||
}
|
||||
}
|
||||
45
application/api/controller/Bind.php
Normal file
45
application/api/controller/Bind.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
|
||||
class Bind extends BaseCom
|
||||
{
|
||||
//绑定方式
|
||||
public function bindType()
|
||||
{
|
||||
$user_id = input('user_id', 0);
|
||||
$system = input('system','');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$reslut = model('UserData')->bind_withdraw_account($user_id,$system);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//绑定
|
||||
public function bind()
|
||||
{
|
||||
$user_id = input('user_id', 0);
|
||||
$type = input('type', '');
|
||||
// $alipay_name = input('alipay_name','');
|
||||
$alipay_account = input('alipay_account','');
|
||||
$bank_card_number = input('bank_card_number','');
|
||||
$bank_user_name = input('bank_user_name','');
|
||||
$bank_card = input('bank_card','');
|
||||
$open_bank = input('open_bank','');
|
||||
|
||||
$reslut = model('UserData')->bind_xinxi($user_id,$type,$alipay_account,$bank_card_number,$bank_user_name,$bank_card,$open_bank);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//绑定详情api/Bind/bind_detail
|
||||
public function bind_detail()
|
||||
{
|
||||
$user_id = input('user_id', 0);
|
||||
$type = input('type', '');
|
||||
$reslut = model('UserData')->bind_xinxi_detail($user_id,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
803
application/api/controller/Ceshi.php
Normal file
803
application/api/controller/Ceshi.php
Normal file
@@ -0,0 +1,803 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
|
||||
class Ceshi extends Controller
|
||||
{
|
||||
//测试 发送各种消息
|
||||
|
||||
|
||||
//发送群组系统消息
|
||||
public function send_group_system_notification()
|
||||
{
|
||||
$rid = input('rid', '');//群组id 拼接好的id,avchartroom +room,public+g
|
||||
$content = input('content', '');
|
||||
$type = input('type', 1005);
|
||||
if(!$content){
|
||||
$FromUserInfo = db::name('user')->where('id',10)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon(10);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon(10);//魅力图标
|
||||
$ToUserInfo = Db::name('user')->where(['id' => 51])->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$ToUserInfo['icon'][0] = model('UserData')->user_wealth_icon(51);//财富图标
|
||||
$ToUserInfo['icon'][1] = model('UserData')->user_charm_icon(51);//魅力图标
|
||||
$gift_info = Db::name('vs_gift')->where(['gid'=>4])->field('gid as gift_id,gift_name,gift_price,file_type,base_image,play_image,gift_type')->find();
|
||||
$text = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 礼物 ' .$gift_info['gift_name'].' x 2';
|
||||
$content = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfo' => $ToUserInfo,
|
||||
'GiftInfo' => $gift_info,
|
||||
'GiftNum' => 2,
|
||||
'text' => $text
|
||||
];
|
||||
}
|
||||
|
||||
//获取群组id里面的纯数字
|
||||
$roomId = preg_replace('/[^0-9]/', '', $rid);
|
||||
$text = [
|
||||
'MsgType' => $type,
|
||||
'RoomId' => $roomId,
|
||||
'Text' => $content
|
||||
];
|
||||
//发送群组系统消息
|
||||
$reslut = model('Tencent')->send_group_system_notification($rid, json_encode($text));
|
||||
//邀请成员
|
||||
// $reslut = model('Tencent')->add_group_member('g32', '10');
|
||||
//向所有直播群发送消息
|
||||
// $reslut = model('Tencent')->send_broadcast_msg('【请注意!!! 该直播间已经起飞!!!请系好安全带。】');
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
|
||||
|
||||
//发送群组消息
|
||||
// $reslut = model('Tencent')->send_group_msg('room28', '大家好 我是系统消息。由 可爱的空气 下发的!','u10');
|
||||
|
||||
//发送单聊消息(可以模拟系统发送 发送者昵称设置为:系统)
|
||||
// $reslut = model('Tencent')->user_sendmsg('10', '51', '你已违反本平台的协议,账号已被封禁!');
|
||||
// return V(1, '发送成功!', $reslut);
|
||||
}
|
||||
|
||||
//向所有直播群发送消息 要加钱(企业或者旗舰)
|
||||
public function send_broadcast_msg()
|
||||
{
|
||||
$content = input('content', '');
|
||||
if (!$content) {
|
||||
$content = '【请注意!!! 该直播间已经起飞!!!请系好安全带。】';
|
||||
}
|
||||
//向所有直播群发送消息
|
||||
$reslut = model('Tencent')->send_broadcast_msg($content);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//邀请成员
|
||||
public function add_group_member()
|
||||
{
|
||||
$rid = input('rid', '');//群组id 拼接好的id,avchartroom +room,public+g
|
||||
if(!$rid){
|
||||
$rid = 'g32';
|
||||
}
|
||||
$uid = input('uid', '');
|
||||
if(!$uid){
|
||||
$uid = '10';
|
||||
}
|
||||
$reslut = model('Tencent')->add_group_member($rid, $uid);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//发送群组消息
|
||||
public function send_group_msg()
|
||||
{
|
||||
$rid = input('rid', '');//群组id 拼接好的id,avchartroom +room,public+g
|
||||
if(!$rid){
|
||||
$rid = 'room28';
|
||||
}
|
||||
$uid = input('user_id', '');
|
||||
if($uid){
|
||||
$uid = 'u'.$uid;
|
||||
}
|
||||
$content = input('content', '');
|
||||
if (!$content) {
|
||||
$content = '大家好 我是系统消息。由 可爱的空气 下发的!';
|
||||
}
|
||||
//发送群组消息
|
||||
$reslut = model('Tencent')->send_group_msg($rid, $content,$uid);
|
||||
|
||||
return V(1, '发送成功!', $reslut);
|
||||
}
|
||||
|
||||
//发送单聊消息
|
||||
public function user_sendmsg()
|
||||
{
|
||||
$uid = input('uid', '');
|
||||
if(!$uid){
|
||||
$uid = '10';
|
||||
}
|
||||
$receive_uid = input('receive_uid', '');
|
||||
if(!$receive_uid){
|
||||
$receive_uid = '51';
|
||||
}
|
||||
$content = input('content', '');
|
||||
if (!$content) {
|
||||
$content = '你已违反本平台的协议,账号已被封禁!';
|
||||
}
|
||||
//发送单聊消息(可以模拟系统发送 发送者昵称设置为:系统)
|
||||
$reslut = model('Tencent')->user_sendmsg($uid, $receive_uid, $content);
|
||||
return V(1, '发送成功!', $reslut);
|
||||
}
|
||||
|
||||
//获取token
|
||||
public function get_token()
|
||||
{
|
||||
$reslut = model('user_token')->where('token','<>', 1)
|
||||
->field('token,user_id,expiretime')->order('id' , 'desc')->select();
|
||||
if ($reslut) {
|
||||
foreach ($reslut as &$res){
|
||||
$res['expiretime'] = date('Y-m-d H:i:s', $res['expiretime']);
|
||||
$res['nickname'] = model('user')->where('id', $res['user_id'])->value('nickname');
|
||||
}
|
||||
|
||||
}
|
||||
return V(1, '成功', $reslut);
|
||||
}
|
||||
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
public function clear_data()
|
||||
{
|
||||
$i = 0;
|
||||
$res = [];
|
||||
//开启事务
|
||||
Db::startTrans();
|
||||
// $reslut = db::name('admin')->where('username','<>', 'admin')->delete();
|
||||
// if($reslut){
|
||||
// $i ++ ;
|
||||
// }else{
|
||||
// //数组末尾添加元素
|
||||
// array_push($res, '管理员删除失败!');
|
||||
// }
|
||||
$reslut1 = db::name('admin_log')->where('id','<>', 1)->delete();
|
||||
if($reslut1){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '管理员日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut3 = db::name('block')->where('id','>', 0)->delete();
|
||||
if($reslut3){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '封禁表删除失败!');
|
||||
}
|
||||
|
||||
$reslut6 = db::name('sms')->where('id','>', 0)->delete();
|
||||
if($reslut6){
|
||||
$i ++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '短信发送记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut7 = db::name('system_message')->where('id','>', 0)->delete();
|
||||
if($reslut7){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '系统消息删除失败!');
|
||||
}
|
||||
// $reslut8 = db::name('topic')->where('id','>', 0)->delete();
|
||||
// if($reslut8){
|
||||
// $i++ ;
|
||||
// }else{
|
||||
// //数组末尾添加元素
|
||||
// array_push($res, '话题删除失败!');
|
||||
// }
|
||||
|
||||
|
||||
$user = db::name('user')->where('id','>', 0)->select();
|
||||
if($user){
|
||||
foreach ($user as &$v){
|
||||
if($v['id']){
|
||||
$j = 0;
|
||||
$data[$j] = [
|
||||
'UserID' => 'u'.$v['id'],
|
||||
];
|
||||
}
|
||||
model('Tencent')->account_deletes($data);
|
||||
}
|
||||
}
|
||||
|
||||
$reslut9 = db::name('user')->where('id','>', 0)->delete();
|
||||
if($reslut9){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户删除失败!');
|
||||
}
|
||||
|
||||
|
||||
$reslut10 = db::name('user_album')->where('id','>', 0)->delete();
|
||||
if($reslut10){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户相册删除失败!');
|
||||
}
|
||||
|
||||
$reslut11 = db::name('user_album_image')->where('id','>', 0)->delete();
|
||||
if($reslut11){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户相册图片删除失败!');
|
||||
}
|
||||
|
||||
$reslut12 = db::name('user_auth')->where('id','>', 0)->delete();
|
||||
if($reslut12){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户实名删除失败!');
|
||||
}
|
||||
|
||||
$reslut13 = db::name('user_avatar_log')->where('id','>', 0)->delete();
|
||||
if($reslut13){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户头像修改记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut14 = db::name('user_black')->where('id','>', 0)->delete();
|
||||
if($reslut14){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户黑名单删除失败!');
|
||||
}
|
||||
|
||||
$reslut141 = db::name('user_coin_transfer')->where('id','>', 0)->delete();
|
||||
if($reslut141){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户金币转让删除失败!');
|
||||
}
|
||||
|
||||
$reslut15 = db::name('user_data')->where('id','>', 0)->delete();
|
||||
if($reslut15){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户数据删除失败!');
|
||||
}
|
||||
$reslut16 = db::name('user_exchange')->where('id','>', 0)->delete();
|
||||
if($reslut16){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户积分兑换记录删除失败!');
|
||||
}
|
||||
$reslut17 = db::name('user_follow')->where('id','>', 0)->delete();
|
||||
if($reslut17){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户关注删除失败!');
|
||||
}
|
||||
$reslut18 = db::name('user_message')->where('id','>', 0)->delete();
|
||||
if($reslut18){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户消息删除失败!');
|
||||
}
|
||||
// $reslut19 = db::name('user_money_log')->where('id','>', 0)->delete();
|
||||
// if($reslut19){
|
||||
// $i++ ;
|
||||
// }else{
|
||||
// //数组末尾添加元素
|
||||
// array_push($res, '用户余额记录删除失败!');
|
||||
// }
|
||||
$reslut20 = db::name('user_token')->where('id','>', 0)->delete();
|
||||
if($reslut20){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户token删除失败!');
|
||||
}
|
||||
$reslut21 = db::name('user_visit_log')->where('id','>', 0)->delete();
|
||||
if($reslut21){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户访问记录删除失败!');
|
||||
}
|
||||
$reslut22 = db::name('user_wallet')->where('id','>', 0)->delete();
|
||||
if($reslut22){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户钱包删除失败!');
|
||||
}
|
||||
$reslut23 = db::name('user_zone')->where('id','>', 0)->delete();
|
||||
if($reslut23){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户空间删除失败!');
|
||||
}
|
||||
$reslut24 = db::name('user_zone_comment')->where('id','>', 0)->delete();
|
||||
if($reslut24){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户空间评论删除失败!');
|
||||
}
|
||||
$reslut25 = db::name('user_zone_like')->where('id','>', 0)->delete();
|
||||
if($reslut25){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户空间点赞删除失败!');
|
||||
}
|
||||
$reslut26 = db::name('user_zone_rewards')->where('id','>', 0)->delete();
|
||||
if($reslut26){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户空间打赏列表删除失败!');
|
||||
}
|
||||
$reslut261 = db::name('user_zone_topic')->where('id','>', 0)->delete();
|
||||
if($reslut261){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '动态话题关联删除失败!');
|
||||
}
|
||||
|
||||
$reslut262 = db::name('vs_activities_receive')->where('id','>', 0)->delete();
|
||||
if($reslut262){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '活动参加删除失败!');
|
||||
}
|
||||
|
||||
$reslut263 = db::name('vs_admin_recharge_log')->where('arid','>', 0)->delete();
|
||||
if($reslut263){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '后台充值删除失败!');
|
||||
}
|
||||
|
||||
$reslut27 = db::name('vs_gift_bag_receive_log')->where('id','>', 0)->delete();
|
||||
if($reslut27){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户礼物发放删除失败!');
|
||||
}
|
||||
$reslut28 = db::name('vs_give_gift')->where('id','>', 0)->delete();
|
||||
if($reslut28){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户送礼记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut29 = db::name('vs_give_gift_ratio_log')->where('id','>', 0)->delete();
|
||||
if($reslut29){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户送礼当前利率记录删除失败!');
|
||||
}
|
||||
|
||||
//解散群
|
||||
$group = db::name('vs_guild')->select();
|
||||
foreach ($group as &$value){
|
||||
model('Tencent')->delete_group('g'.$value['id']);
|
||||
}
|
||||
$reslut30 = db::name('vs_guild')->where('id','>', 0)->delete();
|
||||
if($reslut30){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户工会删除失败!');
|
||||
}
|
||||
|
||||
$reslut31 = db::name('vs_guild_subsidy')->where('id','>', 0)->delete();
|
||||
if($reslut31){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户工会补贴删除失败!');
|
||||
}
|
||||
|
||||
$reslut32 = db::name('vs_guild_user')->where('id','>', 0)->delete();
|
||||
if($reslut32){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户工会用户删除失败!');
|
||||
}
|
||||
|
||||
$reslut33 = db::name('vs_guild_user_quit_log')->where('id','>', 0)->delete();
|
||||
if($reslut33){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户退出工会记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut34 = db::name('vs_headline')->where('id','>', 0)->delete();
|
||||
if($reslut34){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '头条记录删除失败!');
|
||||
}
|
||||
|
||||
//删除腾讯房间
|
||||
$room = db::name('vs_room')->select();
|
||||
foreach ($room as &$value){
|
||||
model('Tencent')->delete_group('room'.$value['id']);
|
||||
}
|
||||
$reslut35 = db::name('vs_room')->where('id','>', 0)->delete();
|
||||
if($reslut35){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间删除失败!');
|
||||
}
|
||||
|
||||
$reslut36 = db::name('vs_room_auction')->where('auction_id','>', 0)->delete();
|
||||
if($reslut36){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间竞拍删除失败!');
|
||||
}
|
||||
|
||||
$reslut37 = db::name('vs_room_auction_bid_log')->where('id','>', 0)->delete();
|
||||
if($reslut37){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间竞拍记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut371 = db::name('vs_room_auction_relation')->where('id','>', 0)->delete();
|
||||
if($reslut371){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户拍得关系删除失败!');
|
||||
}
|
||||
|
||||
$reslut372 = db::name('vs_room_auction_relation_top')->where('id','>', 0)->delete();
|
||||
if($reslut372){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '关系卡、位 置顶表删除失败!');
|
||||
}
|
||||
|
||||
$reslut373 = db::name('vs_room_background')->where('id','>', 2)->delete();
|
||||
if($reslut373){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间背景图片表删除失败!');
|
||||
}
|
||||
|
||||
$reslut38 = db::name('vs_room_black')->where('id','>', 0)->delete();
|
||||
if($reslut38){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间黑名单删除失败!');
|
||||
}
|
||||
|
||||
$reslut39 = db::name('vs_room_cp_movie')->where('cp_id','>', 0)->delete();
|
||||
if($reslut39){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, 'cp房间删除失败!');
|
||||
}
|
||||
|
||||
$reslut40 = db::name('vs_room_host')->where('id','>', 0)->delete();
|
||||
if($reslut40){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间主持删除失败!');
|
||||
}
|
||||
|
||||
$reslut41 = db::name('vs_room_operation_log')->where('id','>', 0)->delete();
|
||||
if($reslut41){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut42 = db::name('vs_room_pit')->where('id','>', 0)->delete();
|
||||
if($reslut42){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位删除失败!');
|
||||
}
|
||||
|
||||
$reslut43 = db::name('vs_room_pit_apply')->where('id','>', 0)->delete();
|
||||
if($reslut43){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位申请删除失败!');
|
||||
}
|
||||
|
||||
$reslut44 = db::name('vs_room_pit_apply_help')->where('id','>', 0)->delete();
|
||||
if($reslut44){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位申请帮助删除失败!');
|
||||
}
|
||||
|
||||
$reslut45 = db::name('vs_room_pit_apply_help_gift')->where('id','>', 0)->delete();
|
||||
if($reslut45){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位申请帮助礼物删除失败!');
|
||||
}
|
||||
|
||||
$reslut46 = db::name('vs_room_pit_simulate')->where('id','>', 0)->delete();
|
||||
if($reslut46){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位模拟删除失败!');
|
||||
}
|
||||
|
||||
$reslut47 = db::name('vs_room_pk')->where('pk_id','>', 0)->delete();
|
||||
if($reslut47){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间pk删除失败!');
|
||||
}
|
||||
|
||||
$reslut48 = db::name('vs_room_song')->where('did','>', 0)->delete();
|
||||
if($reslut48){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间歌曲删除失败!');
|
||||
}
|
||||
|
||||
$reslut49 = db::name('vs_room_subsidy')->where('id','>', 0)->delete();
|
||||
if($reslut49){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间补贴删除失败!');
|
||||
}
|
||||
|
||||
$reslut50 = db::name('vs_room_user_charm')->where('id','>', 0)->delete();
|
||||
if($reslut50){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间用户魅力删除失败!');
|
||||
}
|
||||
|
||||
$reslut51 = db::name('vs_room_user_muted')->where('id','>', 0)->delete();
|
||||
if($reslut51){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间用户禁言删除失败!');
|
||||
}
|
||||
|
||||
$reslut52 = db::name('vs_room_visitor')->where('id','>', 0)->delete();
|
||||
if($reslut52){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间访客删除失败!');
|
||||
}
|
||||
|
||||
$reslut53 = db::name('vs_suggest')->where('id','>', 0)->delete();
|
||||
if($reslut53){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '建议删除失败!');
|
||||
}
|
||||
|
||||
$reslut54 = db::name('vs_user_daily_tasks')->where('id','>', 0)->delete();
|
||||
if($reslut54){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户日常任务删除失败!');
|
||||
}
|
||||
|
||||
$reslut55 = db::name('vs_user_decorate')->where('udid','>', 0)->delete();
|
||||
if($reslut55){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户装扮表删除失败!');
|
||||
}
|
||||
|
||||
$reslut56 = db::name('vs_user_decorate_log')->where('udid','>', 0)->delete();
|
||||
if($reslut56){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户装扮日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut57 = db::name('vs_user_exp_day')->where('id','>', 0)->delete();
|
||||
if($reslut57){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户每日经验删除失败!');
|
||||
}
|
||||
|
||||
$reslut58 = db::name('vs_user_gift_pack')->where('pid','>', 0)->delete();
|
||||
if($reslut58){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户礼物背包删除失败!');
|
||||
}
|
||||
|
||||
$reslut59 = db::name('vs_user_gift_pack_log')->where('id','>', 0)->delete();
|
||||
if($reslut59){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户礼物背包日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut60 = db::name('vs_user_inform')->where('id','>', 0)->delete();
|
||||
if($reslut60){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户举报删除失败!');
|
||||
}
|
||||
|
||||
$reslut61 = db::name('vs_user_invited')->where('id','>', 0)->delete();
|
||||
if($reslut61){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户邀请删除失败!');
|
||||
}
|
||||
|
||||
$reslut62 = db::name('vs_user_invited_income_log')->where('id','>', 0)->delete();
|
||||
if($reslut62){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户邀请收入日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut63 = db::name('vs_user_live_remind')->where('id','>', 0)->delete();
|
||||
if($reslut63){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户直播提醒删除失败!');
|
||||
}
|
||||
|
||||
$reslut64 = db::name('vs_user_money_log')->where('log_id','>', 0)->delete();
|
||||
if($reslut64){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户钱包日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut641 = db::name('vs_user_pk_close')->where('id','>', 0)->delete();
|
||||
if($reslut641){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户钱包日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut65 = db::name('vs_user_recharge')->where('rid','>', 0)->delete();
|
||||
if($reslut65){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户充值删除失败!');
|
||||
}
|
||||
|
||||
$reslut66 = db::name('vs_user_tasks_sign_in')->where('id','>', 0)->delete();
|
||||
if($reslut66){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户任务签到删除失败!');
|
||||
}
|
||||
|
||||
$reslut661 = db::name('vs_user_withdrawal')->where('wid','>', 0)->delete();
|
||||
if($reslut661){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户提现表删除失败!');
|
||||
}
|
||||
|
||||
$reslut662 = db::name('vs_user_zone_manjiujiang')->where('id','>', 0)->delete();
|
||||
if($reslut662){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户发动态满九张图表删除失败!');
|
||||
}
|
||||
|
||||
$reslut67 = db::name('vs_wealth_level_log')->where('id','>', 0)->delete();
|
||||
if($reslut67){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '财富等级日志删除失败!');
|
||||
}
|
||||
|
||||
|
||||
//数据提交
|
||||
db::commit();
|
||||
return V(1, '成功'.$i.'条数据!', $res);
|
||||
}
|
||||
|
||||
|
||||
//测试富文本消息
|
||||
public function test_rich_text(){
|
||||
$contene = $_POST['contene'];
|
||||
var_dump($contene);
|
||||
}
|
||||
|
||||
|
||||
//测试声网token 过期
|
||||
public function test_agora_token(){
|
||||
$token = input('token','');
|
||||
if(empty($token)){
|
||||
$token = request()->header('token');
|
||||
}
|
||||
Log::record("声网过期了请求更新".json_encode($token),"infos");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
166
application/api/controller/Common.php
Normal file
166
application/api/controller/Common.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use app\common\exception\UploadException;
|
||||
use app\common\library\Upload;
|
||||
use app\common\model\Area;
|
||||
use app\common\model\Version;
|
||||
use fast\Random;
|
||||
use think\captcha\Captcha;
|
||||
use think\Config;
|
||||
use think\Hook;
|
||||
|
||||
/**
|
||||
* 公共接口
|
||||
*/
|
||||
class Common extends Api
|
||||
{
|
||||
protected $noNeedLogin = ['init', 'captcha'];
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
|
||||
if (isset($_SERVER['HTTP_ORIGIN'])) {
|
||||
header('Access-Control-Expose-Headers: __token__');//跨域让客户端获取到
|
||||
}
|
||||
//跨域检测
|
||||
check_cors_request();
|
||||
|
||||
if (!isset($_COOKIE['PHPSESSID'])) {
|
||||
Config::set('session.id', $this->request->server("HTTP_SID"));
|
||||
}
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载初始化
|
||||
*
|
||||
* @ApiParams (name="version", type="string", required=true, description="版本号")
|
||||
* @ApiParams (name="lng", type="string", required=true, description="经度")
|
||||
* @ApiParams (name="lat", type="string", required=true, description="纬度")
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if ($version = $this->request->request('version')) {
|
||||
$lng = $this->request->request('lng');
|
||||
$lat = $this->request->request('lat');
|
||||
|
||||
//配置信息
|
||||
$upload = Config::get('upload');
|
||||
//如果非服务端中转模式需要修改为中转
|
||||
if ($upload['storage'] != 'local' && isset($upload['uploadmode']) && $upload['uploadmode'] != 'server') {
|
||||
//临时修改上传模式为服务端中转
|
||||
set_addon_config($upload['storage'], ["uploadmode" => "server"], false);
|
||||
|
||||
$upload = \app\common\model\Config::upload();
|
||||
// 上传信息配置后
|
||||
Hook::listen("upload_config_init", $upload);
|
||||
|
||||
$upload = Config::set('upload', array_merge(Config::get('upload'), $upload));
|
||||
}
|
||||
|
||||
$upload['cdnurl'] = $upload['cdnurl'] ? $upload['cdnurl'] : cdnurl('', true);
|
||||
$upload['uploadurl'] = preg_match("/^((?:[a-z]+:)?\/\/)(.*)/i", $upload['uploadurl']) ? $upload['uploadurl'] : url($upload['storage'] == 'local' ? '/api/common/upload' : $upload['uploadurl'], '', false, true);
|
||||
|
||||
$content = [
|
||||
'citydata' => Area::getCityFromLngLat($lng, $lat),
|
||||
'versiondata' => Version::check($version),
|
||||
'uploaddata' => $upload,
|
||||
'coverdata' => Config::get("cover"),
|
||||
];
|
||||
$this->success('', $content);
|
||||
} else {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="file", type="file", required=true, description="文件流")
|
||||
*/
|
||||
public function upload()
|
||||
{
|
||||
Config::set('default_return_type', 'json');
|
||||
//必须设定cdnurl为空,否则cdnurl函数计算错误
|
||||
Config::set('upload.cdnurl', '');
|
||||
$chunkid = $this->request->post("chunkid");
|
||||
if ($chunkid) {
|
||||
if (!Config::get('upload.chunking')) {
|
||||
$this->error(__('Chunk file disabled'));
|
||||
}
|
||||
$action = $this->request->post("action");
|
||||
$chunkindex = $this->request->post("chunkindex/d");
|
||||
$chunkcount = $this->request->post("chunkcount/d");
|
||||
$filename = $this->request->post("filename");
|
||||
$method = $this->request->method(true);
|
||||
if ($action == 'merge') {
|
||||
$attachment = null;
|
||||
//合并分片文件
|
||||
try {
|
||||
$upload = new Upload();
|
||||
$attachment = $upload->merge($chunkid, $chunkcount, $filename);
|
||||
} catch (UploadException $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success(__('Uploaded successful'), ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
|
||||
} elseif ($method == 'clean') {
|
||||
//删除冗余的分片文件
|
||||
try {
|
||||
$upload = new Upload();
|
||||
$upload->clean($chunkid);
|
||||
} catch (UploadException $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success();
|
||||
} else {
|
||||
//上传分片文件
|
||||
//默认普通上传文件
|
||||
$file = $this->request->file('file');
|
||||
try {
|
||||
$upload = new Upload($file);
|
||||
$upload->chunk($chunkid, $chunkindex, $chunkcount);
|
||||
} catch (UploadException $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
} else {
|
||||
$attachment = null;
|
||||
//默认普通上传文件
|
||||
$file = $this->request->file('file');
|
||||
try {
|
||||
$upload = new Upload($file);
|
||||
$attachment = $upload->upload();
|
||||
} catch (UploadException $e) {
|
||||
$this->error($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
|
||||
$this->success(__('Uploaded successful'), ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
* @ApiParams (name="id", type="string", required=true, description="要生成验证码的标识")
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function captcha($id = "")
|
||||
{
|
||||
\think\Config::set([
|
||||
'captcha' => array_merge(config('captcha'), [
|
||||
'fontSize' => 44,
|
||||
'imageH' => 150,
|
||||
'imageW' => 350,
|
||||
])
|
||||
]);
|
||||
$captcha = new Captcha((array)Config::get('captcha'));
|
||||
return $captcha->entry($id);
|
||||
}
|
||||
}
|
||||
27
application/api/controller/Cron.php
Normal file
27
application/api/controller/Cron.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
class Cron
|
||||
{
|
||||
//每秒执行
|
||||
public function PerformPerSecond()
|
||||
{
|
||||
$cron = new \app\cron\controller\PerformPerSecond();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//每周执行
|
||||
public function PerformPerWeek()
|
||||
{
|
||||
$cron = new \app\cron\controller\Subsidy();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//每10秒执行
|
||||
public function TenSeconds()
|
||||
{
|
||||
$cron = new \app\cron\controller\TenSeconds();
|
||||
$cron->index();
|
||||
}
|
||||
}
|
||||
83
application/api/controller/Dailytasks.php
Normal file
83
application/api/controller/Dailytasks.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
/*
|
||||
* 每日任务
|
||||
*
|
||||
*/
|
||||
class Dailytasks extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
|
||||
//每日任务列表
|
||||
public function dailyTasksList()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('DailyTasks')->dailyTasksList($user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
|
||||
//完成每日任务
|
||||
public function dailyTasksComplete()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$task_id = input('task_id');
|
||||
if (!$task_id) {
|
||||
return V(0,'请选择任务');
|
||||
}
|
||||
$reslut = model('DailyTasks')->tasks_complete($user_id,$task_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//领取每日任务金币奖励
|
||||
public function dailyTasksReceive()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$task_id = input('task_id');
|
||||
if (!$task_id) {
|
||||
return V(0,'请选择任务');
|
||||
}
|
||||
$reslut = model('DailyTasks')->daily_tasks_receive($user_id,$task_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//开启礼盒
|
||||
public function dailyTasksOpenBox()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$gift_box_id = input('gift_box_id');
|
||||
if (!$gift_box_id) {
|
||||
return V(0,'请选择礼盒');
|
||||
}
|
||||
$reslut = model('DailyTasks')->open_gift_box($user_id,$gift_box_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//礼盒记录
|
||||
public function dailyTasksBoxRecord()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('DailyTasks')->gift_bag_receive_list($user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//签到
|
||||
public function dailyTasksSign(){
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('DailyTasks')->sign_in($user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
//今日签到状态
|
||||
public function dailyTasksSignStatus(){
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('DailyTasks')->daily_tasks_sign_in_status($user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
93
application/api/controller/Decorate.php
Normal file
93
application/api/controller/Decorate.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 装饰控制器
|
||||
*/
|
||||
class Decorate extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
|
||||
//获取装饰标签列表
|
||||
public function get_type_list()
|
||||
{
|
||||
$have_hot = input('have_hot',0);
|
||||
$reslut = model('Decorate')->get_type_list($have_hot);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//获取装饰列表
|
||||
public function get_decorate_list()
|
||||
{
|
||||
$type = input('type',100);
|
||||
$reslut = model('Decorate')->get_decorate_list($type);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//获取装饰详情
|
||||
public function get_decorate_detail()
|
||||
{
|
||||
$did = input('did');
|
||||
if (!$did) {
|
||||
return V(0,'参数错误');
|
||||
}
|
||||
$data = [];
|
||||
$reslut = model('Decorate')->get_decorate_detail($did);
|
||||
//当前用户金币
|
||||
$user_coin = db::name('user_wallet')->where(['user_id' => $this->uid])->value('coin');
|
||||
$data['user_info']['user_id'] = $this->uid;
|
||||
$data['user_info']['user_coin'] = intval($user_coin);
|
||||
$data['decorate'] = $reslut['data'];
|
||||
return V($reslut['code'],$reslut['msg'],$data);
|
||||
}
|
||||
//购买装扮
|
||||
public function pay_decorate(){
|
||||
$uid = $this->uid;
|
||||
$did = input('did', 0);
|
||||
$day = input('day', 1);
|
||||
$user_id = input('user_id', 0);
|
||||
$keyname = "api:Decorate:pay_decorate:uid:".$uid;
|
||||
redis_lock_exit($keyname);
|
||||
if($user_id){//购买装扮 赠送好友
|
||||
$reslut = model('Decorate')->pay_decorate($user_id, $did, $day,4,$uid);
|
||||
}else{
|
||||
$reslut = model('Decorate')->pay_decorate($uid, $did, $day,1);
|
||||
}
|
||||
redis_unlock($keyname);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//用户个性装扮列表
|
||||
public function user_decorate(){
|
||||
$uid = $this->uid;
|
||||
$type = input('type', 0);
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 10);
|
||||
$reslut = model('Decorate')->user_decorate($uid,$type,$page, $limit);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//设置用户装扮
|
||||
public function set_user_decorate(){
|
||||
$uid = $this->uid;
|
||||
$udid = input('udid', 0);
|
||||
$reslut = model('Decorate')->set_user_decorate($uid,$udid);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//取消装扮
|
||||
public function cancel_user_decorate(){
|
||||
$uid = $this->uid;
|
||||
$type = input('type', '');
|
||||
$reslut = model('Decorate')->cancel_user_decorate($uid,$type);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
73
application/api/controller/Demo.php
Normal file
73
application/api/controller/Demo.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\Api;
|
||||
|
||||
/**
|
||||
* 示例接口
|
||||
*/
|
||||
class Demo extends Api
|
||||
{
|
||||
|
||||
//如果$noNeedLogin为空表示所有接口都需要登录才能请求
|
||||
//如果$noNeedRight为空表示所有接口都需要验证权限才能请求
|
||||
//如果接口已经设置无需登录,那也就无需鉴权了
|
||||
//
|
||||
// 无需登录的接口,*表示全部
|
||||
protected $noNeedLogin = ['test', 'test1'];
|
||||
// 无需鉴权的接口,*表示全部
|
||||
protected $noNeedRight = ['test2'];
|
||||
|
||||
/**
|
||||
* 测试方法
|
||||
*
|
||||
* @ApiTitle (测试名称)
|
||||
* @ApiSummary (测试描述信息)
|
||||
* @ApiMethod (POST)
|
||||
* @ApiRoute (/api/demo/test/id/{id}/name/{name})
|
||||
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
||||
* @ApiParams (name="id", type="integer", required=true, description="会员ID")
|
||||
* @ApiParams (name="name", type="string", required=true, description="用户名")
|
||||
* @ApiParams (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据")
|
||||
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
||||
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
||||
* @ApiReturnParams (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据返回")
|
||||
* @ApiReturn ({
|
||||
'code':'1',
|
||||
'msg':'返回成功'
|
||||
})
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
$this->success('返回成功', $this->request->param());
|
||||
}
|
||||
|
||||
/**
|
||||
* 无需登录的接口
|
||||
*
|
||||
*/
|
||||
public function test1()
|
||||
{
|
||||
$this->success('返回成功', ['action' => 'test1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 需要登录的接口
|
||||
*
|
||||
*/
|
||||
public function test2()
|
||||
{
|
||||
$this->success('返回成功', ['action' => 'test2']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 需要登录且需要验证有相应组的权限
|
||||
*
|
||||
*/
|
||||
public function test3()
|
||||
{
|
||||
$this->success('返回成功', ['action' => 'test3']);
|
||||
}
|
||||
|
||||
}
|
||||
133
application/api/controller/Ems.php
Normal file
133
application/api/controller/Ems.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use app\common\library\Ems as Emslib;
|
||||
use app\common\model\User;
|
||||
use think\Hook;
|
||||
|
||||
/**
|
||||
* 邮箱验证码接口
|
||||
*/
|
||||
class Ems extends Api
|
||||
{
|
||||
protected $noNeedLogin = '*';
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="email", type="string", required=true, description="邮箱")
|
||||
* @ApiParams (name="event", type="string", required=true, description="事件名称")
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
$email = $this->request->post("email");
|
||||
$event = $this->request->post("event");
|
||||
$event = $event ? $event : 'register';
|
||||
|
||||
if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$this->error(__('邮箱格式错误'));
|
||||
}
|
||||
if (!preg_match("/^[a-z0-9_\-]{3,30}\$/i", $event)) {
|
||||
$this->error(__('事件名称错误'));
|
||||
}
|
||||
|
||||
//发送前验证码
|
||||
$captcha = config('fastadmin.user_api_captcha') ? true : false;
|
||||
if ($captcha) {
|
||||
|
||||
if (!preg_match("/^[a-z0-9]{4,6}\$/i", $captcha)) {
|
||||
$this->error(__('验证码格式错误'));
|
||||
}
|
||||
|
||||
if (!\think\Validate::is($captcha, 'captcha')) {
|
||||
$this->error("验证码不正确");
|
||||
}
|
||||
}
|
||||
|
||||
$last = Emslib::get($email, $event);
|
||||
if ($last && time() - $last['createtime'] < 60) {
|
||||
$this->error(__('发送频繁'));
|
||||
}
|
||||
|
||||
$ipSendTotal = \app\common\model\Ems::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
|
||||
if ($ipSendTotal >= 5) {
|
||||
$this->error(__('发送频繁'));
|
||||
}
|
||||
|
||||
if ($event) {
|
||||
$userinfo = User::getByEmail($email);
|
||||
if ($event == 'register' && $userinfo) {
|
||||
//已被注册
|
||||
$this->error(__('已被注册'));
|
||||
} elseif (in_array($event, ['changeemail']) && $userinfo) {
|
||||
//被占用
|
||||
$this->error(__('已被占用'));
|
||||
} elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
|
||||
//未注册
|
||||
$this->error(__('未注册'));
|
||||
}
|
||||
}
|
||||
$ret = Emslib::send($email, null, $event);
|
||||
if ($ret) {
|
||||
$this->success(__('发送成功'));
|
||||
} else {
|
||||
$this->error(__('发送失败'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测验证码
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="email", type="string", required=true, description="邮箱")
|
||||
* @ApiParams (name="event", type="string", required=true, description="事件名称")
|
||||
* @ApiParams (name="captcha", type="string", required=true, description="验证码")
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
$email = $this->request->post("email");
|
||||
$event = $this->request->post("event");
|
||||
$event = $event ? $event : 'register';
|
||||
$captcha = $this->request->post("captcha");
|
||||
|
||||
if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$this->error(__('邮箱格式错误'));
|
||||
}
|
||||
if (!preg_match("/^[a-z0-9_\-]{3,30}\$/i", $event)) {
|
||||
$this->error(__('事件名称错误'));
|
||||
}
|
||||
|
||||
if (!preg_match("/^[a-z0-9]{4,6}\$/i", $captcha)) {
|
||||
$this->error(__('验证码格式错误'));
|
||||
}
|
||||
|
||||
if ($event) {
|
||||
$userinfo = User::getByEmail($email);
|
||||
if ($event == 'register' && $userinfo) {
|
||||
//已被注册
|
||||
$this->error(__('已被注册'));
|
||||
} elseif (in_array($event, ['changeemail']) && $userinfo) {
|
||||
//被占用
|
||||
$this->error(__('已被占用'));
|
||||
} elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
|
||||
//未注册
|
||||
$this->error(__('未注册'));
|
||||
}
|
||||
}
|
||||
$ret = Emslib::check($email, $captcha, $event);
|
||||
if ($ret) {
|
||||
$this->success(__('成功'));
|
||||
} else {
|
||||
$this->error(__('验证码不正确'));
|
||||
}
|
||||
}
|
||||
}
|
||||
47
application/api/controller/Gift.php
Normal file
47
application/api/controller/Gift.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
class Gift extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
//获取礼物标签列表
|
||||
public function get_gift_label()
|
||||
{
|
||||
$reslut = model('Gift')->get_gift_label();
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//获取礼物列表
|
||||
public function get_gift_list()
|
||||
{
|
||||
$label = input('label',0);
|
||||
$reslut = model('Gift')->get_gift_list($label);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//聊天送礼物 (音信)
|
||||
public function chat_gift_send()
|
||||
{
|
||||
$user_id = input('user_id',$this->uid);
|
||||
$gid = input('gid',0);
|
||||
$num = input('num',0);
|
||||
$to_uid = input('to_uid',0);
|
||||
$gift_type = input('gift_type',1);
|
||||
if(empty($user_id) || empty($gid) || empty($num) || empty($to_uid)){
|
||||
return V(0,'参数错误', []);
|
||||
}
|
||||
$reslut = model('GiveGift')->chat_give_gift($user_id,$gid,$num,$to_uid,$gift_type);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
221
application/api/controller/Guild.php
Normal file
221
application/api/controller/Guild.php
Normal file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
/*
|
||||
* 工会
|
||||
*/
|
||||
class Guild extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
|
||||
//工会列表
|
||||
public function guild_list()
|
||||
{
|
||||
$page = input('page',1);
|
||||
$page = $page > 0 ? $page : 1;
|
||||
$limit = input('limit',10);
|
||||
$search = input('search_id','');
|
||||
$reslut = model('Guild')->get_guild_list($page,$limit,$search,$this->uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//公会详情
|
||||
public function guild_detail()
|
||||
{
|
||||
$id = input('id',0);
|
||||
$reslut = model('Guild')->get_guild_info($id,$this->uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//加入公会
|
||||
public function join_guild()
|
||||
{
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$key_name = "api:guild:join_guild:".$uid;
|
||||
redis_lock_exit($key_name);
|
||||
$reslut = model('Guild')->join_guild($guild_id,$uid);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//申请列表 【暂时废弃】
|
||||
public function get_apply_guild_list(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 20);
|
||||
$reslut = model('Guild')->get_apply_guild_list($uid, $guild_id, $page, $page_limit);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//同意、拒绝申请 【暂时废弃】
|
||||
public function operate_guild(){
|
||||
$uid = $this->uid;
|
||||
$apply_id = input('id', 0);
|
||||
$type = input('type', 1);
|
||||
$key_name = "api:guild:operate_guild:".$uid;
|
||||
redis_lock_exit($key_name);
|
||||
$reslut = model('Guild')->operate_guild($uid, $apply_id, $type);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//获取公会成员列表
|
||||
public function get_guild_member_list(){
|
||||
$guild_id = input('guild_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 20);
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$reslut = model('Guild')->get_guild_member_list($guild_id,$start_time,$end_time,$page,$page_limit);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//踢出公会
|
||||
public function kick_guild_member(){
|
||||
$uid = $this->uid;
|
||||
$user_id = input('user_id', 0);
|
||||
$guild_id = input('guild_id', 0);
|
||||
$key_name = "api:guild:kick_out_guild:".$uid;
|
||||
redis_lock_exit($key_name);
|
||||
$reslut = model('Guild')->kick_out_guild($uid, $user_id, $guild_id);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//退出公会
|
||||
public function quit_guild(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$type = input('type', 0);
|
||||
$key_name = "api:guild:quit_guild:".$uid;
|
||||
redis_lock_exit($key_name);
|
||||
$reslut = model('Guild')->quit_guild($uid, $guild_id,$type);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//退出申请列表
|
||||
public function quit_apply_list(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$reslut = model('Guild')->quit_apply_list($uid,$guild_id,$page, $page_limit);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//退出工会审核
|
||||
public function quit_apply_audit(){
|
||||
$uid = $this->uid;
|
||||
$apply_id = input('apply_id', 0);
|
||||
$type = input('type', 0);
|
||||
$key_name = "api:guild:quit_apply_audit:".$uid;
|
||||
redis_lock_exit($key_name);
|
||||
$reslut = model('Guild')->quit_apply_audit($uid, $apply_id, $type);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
//解散公会
|
||||
public function diss_guild(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$reslut = model('Guild')->diss_guild($uid, $guild_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//工会房间列表
|
||||
public function guild_room_list(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 20);
|
||||
$reslut = model('Guild')->get_guild_room_list($guild_id, $page, $page_limit);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//工会补贴列表
|
||||
public function guild_subsidy_list(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 20);
|
||||
$reslut = model('Guild')->get_guild_subsidy_list($guild_id, $page, $page_limit);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//工会补贴页面
|
||||
public function guild_subsidy(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$reslut = model('Guild')->get_guild_subsidy($guild_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//工会流水页面
|
||||
public function guild_flow(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', 10);
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$reslut = model('Guild')->get_guild_transaction($guild_id,$start_time, $end_time, $page, $page_size);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//判断用户是否是工会成员
|
||||
public function is_guild_member(){
|
||||
$uid = $this->uid;
|
||||
$reslut = model('Guild')->user_is_join($uid);
|
||||
if($reslut==0){
|
||||
return V(0,'用户不是工会成员');
|
||||
}
|
||||
return V(1,'用户是工会成员', ['guild_id'=>$reslut]);
|
||||
}
|
||||
|
||||
/*
|
||||
* 群成员列表
|
||||
*/
|
||||
public function member_list(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 20);
|
||||
$reslut = model('Guild')->get_guild_user_list($guild_id,$uid,$page,$page_limit);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
/*
|
||||
* 获取群聊信息详情
|
||||
*/
|
||||
public function get_guild_info(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$reslut = model('Guild')->guild_info($guild_id,$uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
/*
|
||||
* 设置群聊信息
|
||||
*/
|
||||
public function set_guild_info(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
//群聊名称
|
||||
$name = input('name', '');
|
||||
//群聊公告
|
||||
$notice = input('notice', '');
|
||||
//群聊头像
|
||||
$avatar = input('avatar', '');
|
||||
$reslut = model('Guild')->set_guild_info($guild_id,$name,$notice,$avatar);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
54
application/api/controller/Help.php
Normal file
54
application/api/controller/Help.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
|
||||
class Help extends BaseCom
|
||||
{
|
||||
/*
|
||||
* 用户反馈
|
||||
*/
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
|
||||
//常见问题分类
|
||||
public function help_type(){
|
||||
$reslut = DB::name('vs_help_type')->where('delete_time',0)->where('status', 1) ->order('sort desc')->select();
|
||||
$reslut = ['code' => 1, 'msg' => '获取成功', 'data' => $reslut];
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//常见问题
|
||||
public function help_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$type = input('type', 0);
|
||||
$map = [];
|
||||
if($type){
|
||||
$map = ['type'=>$type];
|
||||
}
|
||||
$page_list = DB::name('vs_help')->field('id,title')->where('delete_time', 0)->where($map)->order('id desc')->page($page, $page_limit)->select();
|
||||
$reslut = ['code' => 1, 'msg' => '获取成功', 'data' => $page_list];
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//常见问题详情
|
||||
public function help_detail(){
|
||||
$id = input('id',0);
|
||||
$data = DB::name('vs_help')->where('id',$id)->find();
|
||||
if(!$data){
|
||||
$reslut = ['code' => 0, 'msg' => '获取失败', 'data' => null];
|
||||
}
|
||||
$data['createtime'] = date('Y-m-d H:i:s',$data['createtime']);
|
||||
$reslut = ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
46
application/api/controller/Index.php
Normal file
46
application/api/controller/Index.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class Index extends BaseCom
|
||||
{
|
||||
//进入首页弹出的房间
|
||||
public function index_recommend_room()
|
||||
{
|
||||
$reslut = model('Room')->index_recommend_room();
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//房间列表
|
||||
public function room_list()
|
||||
{
|
||||
$is_top = input('is_top', 0); //1非置顶2置顶
|
||||
$label_id = input('label_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 15);
|
||||
|
||||
$reslut = model('Room')->room_list($label_id,$is_top, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data'], $reslut['api_version']);
|
||||
}
|
||||
|
||||
//房间类型列表
|
||||
public function room_type_list()
|
||||
{
|
||||
$list = db::name('vs_room_type')->where('status', 1)->field('id,type_name as label_name')->select();
|
||||
//给前面添加一组数据
|
||||
array_unshift($list, ['id' => -1, 'label_name' => '热门']);
|
||||
return V(1, '获取成功', $list);
|
||||
}
|
||||
|
||||
//首页轮播图
|
||||
public function index_banner()
|
||||
{
|
||||
$type = input('type', 3);//首页轮播图
|
||||
$reslut = model('Banner')->banner_list($type);
|
||||
return V(1, '成功', $reslut);
|
||||
}
|
||||
|
||||
}
|
||||
81
application/api/controller/Invited.php
Normal file
81
application/api/controller/Invited.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
class Invited extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
|
||||
/**
|
||||
* 邀请 手动绑定
|
||||
* @param init_code 邀请码
|
||||
* @return void
|
||||
*/
|
||||
public function invited_bind()
|
||||
{
|
||||
$init_code = input('init_code');
|
||||
if (!$init_code) {
|
||||
return V(0,'请输入邀请码!');
|
||||
}
|
||||
//绑定
|
||||
$reslut = model('api/Invited')->invited_bind($init_code, $this->uid);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//获取个人邀请码
|
||||
public function get_init_code()
|
||||
{
|
||||
$user_id = input('user_id', $this->uid);
|
||||
$reslut = [];
|
||||
//用户收益统计
|
||||
//钻石总额
|
||||
$reslut['diamond_total'] = intval(model('UserWallet')->where('user_id', $user_id)->value('earnings'));
|
||||
//今日收益
|
||||
$reslut['today_earnings'] = db::name('vs_user_invited_income_log')->where('user_id', $user_id)->whereTime('createtime', 'today')->sum('earnings');
|
||||
//总收益
|
||||
$reslut['total_earnings'] = db::name('vs_user_invited_income_log')->where('user_id', $user_id)->sum('earnings');
|
||||
$init_code = model('User')->where('id', $user_id)->value('init_code');
|
||||
if(empty($init_code)){
|
||||
$init_code = model('api/User')->invite_code();
|
||||
db::name('user')->where('id', $user_id)->update(['init_code'=>$init_code]);
|
||||
}
|
||||
$reslut['init_code'] = $init_code ? $init_code:'';
|
||||
$invited_draw = get_system_config_value('invited_draw');
|
||||
//说明
|
||||
$reslut['explain'] = '绑定成功后,您每次充值金额的'.$invited_draw.'%'.'将以钻石形式赠送给邀请人,满足提现金额邀请人可以直接提现';
|
||||
return V(1,'操作成功',$reslut);
|
||||
}
|
||||
//我的邀请列表
|
||||
public function invited_list(){
|
||||
$user_id = input('user_id', $this->uid);
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', 10);
|
||||
$reslut = model('Invited')->alias('a')
|
||||
->join('user b','a.sub_user_id = b.id')
|
||||
->where('a.user_id', $user_id)
|
||||
->field('a.id,b.id as user_id,b.nickname,a.createtime')
|
||||
->order('a.id desc')
|
||||
->page($page,$page_size)
|
||||
->select();
|
||||
foreach ($reslut as &$v) {
|
||||
$v['createtime'] = date('Y年m月d H:i', $v['createtime']);
|
||||
}
|
||||
return V(1,'操作成功',$reslut);
|
||||
}
|
||||
//账单明细
|
||||
public function bill_list(){
|
||||
$user_id = input('user_id', $this->uid);
|
||||
$reslut = model('Invited')->get_bill_list($user_id);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
39
application/api/controller/Level.php
Normal file
39
application/api/controller/Level.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
class Level extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
//魅力等级规则说明
|
||||
public function get_level_rule()
|
||||
{
|
||||
$uid = $this->uid;
|
||||
$reslut = model('Level')->get_level_rule($uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//财富等级规则说明
|
||||
public function get_wealth_rule(){
|
||||
$uid = $this->uid;
|
||||
$reslut = model('Level')->get_wealth_rule($uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//领取金币奖励
|
||||
public function get_gold_reward(){
|
||||
$uid = $this->uid;
|
||||
$reslut = model('Level')->get_wealth_level_reward($uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
379
application/api/controller/Login.php
Normal file
379
application/api/controller/Login.php
Normal 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']);
|
||||
}
|
||||
}
|
||||
66
application/api/controller/Page.php
Normal file
66
application/api/controller/Page.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
class Page extends controller
|
||||
{
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
/*
|
||||
* 单页查询
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public function get_page_by_id()
|
||||
{
|
||||
$id = input('id', '');
|
||||
$reslut = model('Page')->get_page($id);
|
||||
return V(1,'操作成功', $reslut);
|
||||
}
|
||||
/*
|
||||
* 单页输出
|
||||
* @param id
|
||||
* @return html
|
||||
*/
|
||||
public function page_show()
|
||||
{
|
||||
$id = input('id', '');
|
||||
$reslut = model('Page')->get_page($id);
|
||||
$html = $reslut['content'] ? $reslut['content'] : '';
|
||||
//解析html
|
||||
$html = htmlspecialchars_decode($html);
|
||||
return $html;
|
||||
}
|
||||
/*
|
||||
* 用户服务协议
|
||||
*/
|
||||
public function user_agreement()
|
||||
{
|
||||
$id = 1;
|
||||
$reslut = model('Page')->get_page($id);
|
||||
$html = $reslut['content'] ? $reslut['content'] : '';
|
||||
//解析html
|
||||
$html = htmlspecialchars_decode($html);
|
||||
return $html;
|
||||
}
|
||||
|
||||
/*
|
||||
* 盲盒规则链接
|
||||
*/
|
||||
public function get_gift_box_rule(){
|
||||
$box_id = input('box_id',0);
|
||||
$gift_bag = Db::name('vs_gift_bag')->where('id',$box_id)->find();
|
||||
if(empty($gift_bag)){
|
||||
echo '参数错误';
|
||||
}
|
||||
$ext = json_decode($gift_bag['ext'],true);
|
||||
echo $ext['introd']??"";
|
||||
}
|
||||
}
|
||||
303
application/api/controller/Payment.php
Normal file
303
application/api/controller/Payment.php
Normal file
@@ -0,0 +1,303 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Loader;
|
||||
use think\Log;
|
||||
use Yzh\YunPay;
|
||||
|
||||
class Payment extends Controller
|
||||
{
|
||||
//生成订单号
|
||||
private function createOrderSn() {
|
||||
$orderSn = strtoupper(date('Ymd', time())).substr(time(), -5).substr(microtime(), 2, 5).sprintf('%02d',
|
||||
rand(0, 99));
|
||||
return $orderSn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* APP支付
|
||||
*/
|
||||
public function app_pay() {
|
||||
$type = input('type', 0); //1-微信 2-支付宝 4-通联支付宝 5-通联微信
|
||||
$user_id = input('user_id', 0);
|
||||
$money = input('money', 0);
|
||||
$coin = input('coin', 0);
|
||||
if(!$coin){
|
||||
$coin = $money * get_system_config_value('rmb_coin_ratio');
|
||||
}
|
||||
if (!$user_id) {
|
||||
return V(0, '请选择充值用户', null);
|
||||
}
|
||||
|
||||
if (!is_numeric($money) || floor($money) != $money || $money <= 0 || $money >= 2000) {
|
||||
return V(0, '请选择正确的充值金额', null);
|
||||
}
|
||||
$user_code = db::name('user')->where(["id" => $user_id])->value('user_code');
|
||||
$title = "APP充值到用户 " . ($user_code ?? "") . " 余额!";
|
||||
|
||||
$order_number = $this->createOrderSn();
|
||||
$data['order_sn'] = $order_number;
|
||||
$data['money'] = $money;
|
||||
$data['coin'] = $coin;
|
||||
$data['user_id'] = $user_id;
|
||||
$data['pay_type'] = $type;
|
||||
$data['createtime'] = time();
|
||||
$data['remarke'] = '充值到app用户'.($user_code ?? "") ."余额!";;
|
||||
|
||||
$re = db::name('vs_user_recharge')->insert($data);
|
||||
if (!$re) {
|
||||
return V(0, '充值失败', null);
|
||||
}
|
||||
|
||||
if($type == 2){
|
||||
//引用支付宝sdk
|
||||
Loader::import('AliPayV2.AliPay', EXTEND_PATH, '.php');
|
||||
$ali = new \AliPay();
|
||||
$result['ali'] = $ali->aliAppPays($order_number, $money, $title);
|
||||
}elseif($type == 1){
|
||||
//引用微信sdk
|
||||
Loader::import('WxPay.WxPay', EXTEND_PATH, '.php');
|
||||
$wx = new \WxPay();
|
||||
$result['wx'] = $wx->WxPayApp($data);
|
||||
}elseif($type == 4 || $type == 5){
|
||||
//引用通联sdk
|
||||
Loader::import('TongLian.TongLian', EXTEND_PATH, '.php');
|
||||
$tonglian = new \TongLian();
|
||||
$result['tl'] = $tonglian->TongLianPay($data, $type);
|
||||
}
|
||||
|
||||
return V(1, 'app支付', $result);
|
||||
}
|
||||
|
||||
//支付宝回调
|
||||
public function notify_ali() {
|
||||
//引用支付宝sdk
|
||||
Loader::import('AliPayV2.AliPay', EXTEND_PATH, '.php');
|
||||
$ali = new \AliPay();
|
||||
$verify_result = $ali->verify($_POST);
|
||||
Log::record("支付宝回调信息".json_encode($_POST),"info");
|
||||
|
||||
if($verify_result) {//验证成功
|
||||
//商户订单号
|
||||
$out_trade_no = $_POST['out_trade_no'];
|
||||
//支付宝交易号
|
||||
$trade_no = $_POST['trade_no'];
|
||||
|
||||
if ($_POST['trade_status'] == 'TRADE_SUCCESS') {
|
||||
$where['order_sn']=$out_trade_no;
|
||||
$where['order_type']=1;
|
||||
$where['pay_type']=2;
|
||||
|
||||
$data=[
|
||||
'trade_no'=>$trade_no
|
||||
];
|
||||
|
||||
$res = handelCharge($where,$data);
|
||||
if($res==0){
|
||||
echo "fail";
|
||||
return;
|
||||
}
|
||||
|
||||
echo "success"; //请不要修改或删除
|
||||
return;
|
||||
}
|
||||
|
||||
echo "fail";
|
||||
}else {
|
||||
//验证失败
|
||||
echo "fail";
|
||||
//写入日志文件
|
||||
Log::record("支付宝回调验签失败","info");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//微信回调地址 示例
|
||||
public function notify_wx() {
|
||||
//引用微信sdk
|
||||
Loader::import('WxPay.WxPay', EXTEND_PATH, '.php');
|
||||
$wx = new \WxPay();
|
||||
//验证是否是微信发送且数据完整
|
||||
$flag = $wx->WxPayNotifyCheck();
|
||||
|
||||
if ($flag['status']) {
|
||||
if ($flag['data']['return_code'] == 'SUCCESS' && $flag['data']['result_code'] == 'SUCCESS') {
|
||||
$out_trade_no = $flag['data']['out_trade_no'];//订单号
|
||||
// $payType = $flag['data']['attach']; //商家数据包
|
||||
// $time_end = strtotime($flag['data']['time_end']); //支付完成时间
|
||||
$transaction_id = $flag['data']['transaction_id']; //微信支付订单号
|
||||
|
||||
//成功后的业务逻辑处理
|
||||
$where['order_sn']=$out_trade_no;
|
||||
$where['order_type']=1;//1 充值
|
||||
$where['pay_type']=1;//1微信2支付宝 3通联支付宝 4通联微信
|
||||
|
||||
$data=[
|
||||
'trade_no'=>$transaction_id
|
||||
];
|
||||
|
||||
$res = handelCharge($where,$data);
|
||||
if($res==0){
|
||||
$r_arr['return_code'] = 'FAIL';
|
||||
$r_arr['return_msg'] = '回调失败';
|
||||
echo $wx->arrayToXml($r_arr);
|
||||
die;
|
||||
}
|
||||
|
||||
$r_arr['return_code'] = 'SUCCESS';
|
||||
$r_arr['return_msg'] = '回调成功';
|
||||
echo $wx->arrayToXml($r_arr);
|
||||
die;
|
||||
}
|
||||
}
|
||||
$r_arr['return_code'] = 'FAIL';
|
||||
$r_arr['return_msg'] = '回调失败';
|
||||
echo $wx->arrayToXml($r_arr);
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
//通联支付回调地址 示例
|
||||
public function allinpayNotify() {
|
||||
$params = array();
|
||||
foreach($_POST as $key=>$val) {//动态遍历获取所有收到的参数,此步非常关键,因为收银宝以后可能会加字段,动态获取可以兼容由于收银宝加字段而引起的签名异常
|
||||
$params[$key] = $val;
|
||||
}
|
||||
|
||||
if(count($params)<1){//如果参数为空,则不进行处理
|
||||
echo "error";
|
||||
exit();
|
||||
}
|
||||
|
||||
//引用通联sdk
|
||||
Loader::import('TongLian.TongLian', EXTEND_PATH, '.php');
|
||||
$tonglian = new \TongLian();
|
||||
|
||||
$ree = $tonglian->ValidSign($params);
|
||||
// Log::record("通联支付回调信息".json_encode($ree),"info");
|
||||
if($tonglian->ValidSign($params)){//验签成功
|
||||
Log::record("通联支付回调信息验签成功".json_encode($params),"info");
|
||||
//此处进行业务逻辑处理
|
||||
$pay_type =trim($params['trxreserved']);//备注信息remark
|
||||
$out_trade_no = trim($params['cusorderid']); //商户订单号
|
||||
$trade_no = trim($params['trxid']); // 交易号
|
||||
// $gmt_payment = strtotime(trim($_POST['paytime'])); //交易付款时间
|
||||
//成功后的业务逻辑处理
|
||||
$where['order_sn']=$out_trade_no;
|
||||
$where['order_type']=1;//1 充值
|
||||
$where['pay_type']=$pay_type;//1微信2支付宝 3通联支付宝 4通联微信
|
||||
|
||||
$data=[
|
||||
'trade_no'=>$trade_no
|
||||
];
|
||||
|
||||
$res = handelCharge($where,$data);
|
||||
if($res==0){
|
||||
echo "erro";
|
||||
return;
|
||||
}
|
||||
|
||||
echo "success";
|
||||
}else{
|
||||
Log::record("通联支付回调信息验签失败".json_encode($params),"info");
|
||||
echo "erro";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 云账户回调(提现)
|
||||
*/
|
||||
public function yun_callback(){
|
||||
$data = input("data", "");
|
||||
$mess = input("mess", "");
|
||||
$timestamp = input("timestamp", "");
|
||||
$sign = input("sign", "");
|
||||
Log::record("云账户回调信息".json_encode($_POST),"info");
|
||||
$yun_pay = new YunPay();
|
||||
$result = $yun_pay->yun_callback($data,$mess,$timestamp,$sign);
|
||||
if($result['code']==1){
|
||||
$data = $result['data']['data'];
|
||||
if($data){
|
||||
$status = $data['status'];
|
||||
if(!isset($data['status'])){
|
||||
echo 'fail';
|
||||
die;
|
||||
}
|
||||
switch ($status){
|
||||
case "1":
|
||||
// 支付成功(对于支付宝和微信支付是最终状态,对于银行卡大部分情况是终态,小概率会出现"退汇现象",状态由"成功"变为"退汇")
|
||||
db::name('vs_user_withdrawal')
|
||||
->where('order_sn',$data['order_id'])
|
||||
->where('status',4)
|
||||
->update([
|
||||
'status' => 6,
|
||||
'pay_message' => $data['status_message'],
|
||||
'pay_time' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
echo "success";
|
||||
break;
|
||||
case "2":
|
||||
// 支付失败(最终状态)
|
||||
// TODO 更新业务订单状态,提示用户提现失败,若有用户钱包体系,则需将提现金额退回至用户钱包
|
||||
db::name('vs_user_withdrawal')
|
||||
->where('order_sn',$data['order_id'])
|
||||
->where('status',4)
|
||||
->update([
|
||||
'status' => 5,
|
||||
'pay_message' => $data['status_message'],
|
||||
'pay_time' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
//支付失败资金退回
|
||||
$res = model('/UserWithdrawal')->withdrawal_fail($data['order_id']);
|
||||
echo "success";
|
||||
break;
|
||||
break;
|
||||
case "4":
|
||||
// 订单挂单(中间状态,挂单原因会在订单详细状态信息返回)
|
||||
// TODO 提示用户提现中,其他逻辑如:若因余额不足导致的挂单,可通知财务及时充值,72小时内补足余额后可自动继续支付
|
||||
echo "success";
|
||||
break;
|
||||
case "9":
|
||||
// 退汇,(最终状态,银行卡渠道特有现象,会先收到"成功"回调,然后再收到"退汇"的回调,一般以成功状态间隔24小时以上)
|
||||
// TODO 更新业务订单状态为“退汇”(失败),通知用户提现失败,建议用户更换其他银行卡提现,若有用户钱包体系,则需将提现金额退回至用户钱包
|
||||
db::name('vs_user_withdrawal')
|
||||
->where('order_sn',$data['order_id'])
|
||||
->where('status',4)
|
||||
->update([
|
||||
'status' => 5,
|
||||
'pay_message' => $data['status_message'],
|
||||
'pay_time' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
//支付失败资金退回
|
||||
$res = model('/UserWithdrawal')->withdrawal_fail($data['order_id']);
|
||||
echo "success";
|
||||
break;
|
||||
case "15":
|
||||
// 订单取消,(最终状态,只有挂单的订单才可以取消)
|
||||
// TODO 更新业务订单状态为“取消”(失败),通知用户提现失败,若有用户钱包体系,则需将提现金额退回至用户钱包
|
||||
db::name('vs_user_withdrawal')
|
||||
->where('order_sn',$data['order_id'])
|
||||
->where('status',4)
|
||||
->update([
|
||||
'status' => 5,
|
||||
'pay_message' => $data['status_message'],
|
||||
'pay_time' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
//支付失败资金退回
|
||||
$res = model('/UserWithdrawal')->withdrawal_fail($data['order_id']);
|
||||
echo "success";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo "fail";
|
||||
}
|
||||
}
|
||||
}
|
||||
57
application/api/controller/Ranking.php
Normal file
57
application/api/controller/Ranking.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
|
||||
class Ranking extends BaseCom
|
||||
{
|
||||
protected $model, $type, $room_id;
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $page;
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $page_limit;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->type = input('type', 0);//1日榜;2本周榜;3月榜;0 总榜
|
||||
$this->room_id = input('room_id', 0);
|
||||
$this->page = input('page', 0);
|
||||
$this->page_limit = input('page_limit', 0);
|
||||
$this->model = new \app\api\model\Ranking($this->uid, $this->type, $this->room_id, $this->page, $this->page_limit);
|
||||
}
|
||||
|
||||
//财富\魅力 榜
|
||||
public function wealth_ranking()
|
||||
{
|
||||
$ranking_type = input('ranking_type', 1);//1财富 2魅力
|
||||
$reslut = $this->model->ranking($ranking_type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//房间榜
|
||||
public function room_ranking()
|
||||
{
|
||||
$reslut = $this->model->room_ranking();
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//公会榜
|
||||
public function guild_ranking()
|
||||
{
|
||||
$reslut = $this->model->guild_ranking();
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//真爱榜
|
||||
public function love_ranking()
|
||||
{
|
||||
$reslut = $this->model->love_ranking();
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
46
application/api/controller/Report.php
Normal file
46
application/api/controller/Report.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class Report extends BaseCom
|
||||
{
|
||||
//举报类型列表
|
||||
public function report_type_list(){
|
||||
$list = db::name('vs_user_inform_type')->where(['delete_time' => ['<',1]])->select();
|
||||
foreach ($list as &$item) {
|
||||
$item['createtime'] = date('Y-m-d H:i:s', $item['createtime']);
|
||||
}
|
||||
|
||||
return V(1,"成功", $list);
|
||||
}
|
||||
|
||||
|
||||
//举报
|
||||
public function report(){
|
||||
// $user_id = input('user_id', '');//举报者
|
||||
$type_id = input('type_id', '');//举报类型
|
||||
$report_type = input('report_type', '');//1-用户,2房间,3动态
|
||||
$content = input('content', '');//举报内容
|
||||
$image = input('image', '');//举报图片,多个用英文逗号隔开
|
||||
$from_id = input('from_id', '');//举报来源id
|
||||
if($type_id == '' || $report_type == '' || $from_id == ''){
|
||||
return V(0,"参数错误",null);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_id' => $this->uid,
|
||||
'type_id' => $type_id,
|
||||
'report_type' => $report_type,
|
||||
'content' => $content,
|
||||
'image' => $image,
|
||||
'from_id' => $from_id,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$res = db::name('vs_user_inform')->insert($data);
|
||||
return V($res ? 1 : 0, $res ? "成功" : "失败", null);
|
||||
}
|
||||
|
||||
}
|
||||
398
application/api/controller/Room.php
Normal file
398
application/api/controller/Room.php
Normal file
@@ -0,0 +1,398 @@
|
||||
<?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']);
|
||||
}
|
||||
}
|
||||
96
application/api/controller/RoomAuction.php
Normal file
96
application/api/controller/RoomAuction.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
|
||||
class RoomAuction extends BaseCom
|
||||
{
|
||||
//房间关系列表
|
||||
public function room_relation_list()
|
||||
{
|
||||
$type_id = input('type');//1真爱拍 2 亲密拍
|
||||
$reslut = model('RoomAuction')->room_relation_list($type_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//真爱拍选礼物后计算天数
|
||||
public function room_auction_time()
|
||||
{
|
||||
$gift_id = input('gift_id');
|
||||
$reslut = model('RoomAuction')->room_auction_time($gift_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
// 房间竞拍开始(数据提交)
|
||||
public function room_auction()
|
||||
{
|
||||
$room_id = input('room_id');
|
||||
$user_id = input('user_id');
|
||||
$gift_id = input('gift_id');
|
||||
$relation_id = input('relation_id','');
|
||||
$auction_type = input('auction_type',1);//1真爱拍 2 亲密拍
|
||||
$time_day = input('time_day', 0);//小时
|
||||
$reslut = model('RoomAuction')->room_auction($room_id,$user_id,$gift_id,$relation_id,$auction_type,$time_day);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//竞拍开始
|
||||
// public function room_auction_start()
|
||||
// {
|
||||
// $auction_id = input('auction_id',0);
|
||||
// $reslut = model('RoomAuction')->room_auction_start($auction_id);
|
||||
// return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
// }
|
||||
|
||||
//参与竞拍
|
||||
public function room_auction_join()
|
||||
{
|
||||
$auction_id = input('auction_id');
|
||||
$user_id = $this->uid;
|
||||
$gift_id = input('gift_id');
|
||||
$num = input('num');
|
||||
$type = input('type',1);//1金币购买 2送背包礼物
|
||||
|
||||
$reslut = model('RoomAuction')->room_auction_join($auction_id,$user_id,$gift_id,$num,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//房间竞拍列表
|
||||
public function room_auction_list()
|
||||
{
|
||||
$auction_id = input('auction_id');
|
||||
$reslut = model('RoomAuction')->room_auction_list($auction_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//延时
|
||||
public function room_auction_delay()
|
||||
{
|
||||
$auction_id = input('auction_id');
|
||||
$reslut = model('RoomAuction')->room_auction_delay($auction_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//房间竞拍结束
|
||||
public function room_auction_end()
|
||||
{
|
||||
$auction_id = input('auction_id');
|
||||
$room_id = input('room_id');
|
||||
$reslut = model('RoomAuction')->room_auction_end($room_id,$auction_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//修改房间竞拍模式
|
||||
public function room_auction_mode()
|
||||
{
|
||||
$room_id = input('room_id');
|
||||
$mode = input('label_id');//2亲密拍 1真爱拍
|
||||
$reslut = model('RoomAuction')->room_auction_mode($room_id,$mode);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
147
application/api/controller/RoomPit.php
Normal file
147
application/api/controller/RoomPit.php
Normal 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']);
|
||||
}
|
||||
}
|
||||
70
application/api/controller/RoomPk.php
Normal file
70
application/api/controller/RoomPk.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
|
||||
class RoomPk extends BaseCom
|
||||
{
|
||||
//发送PK邀请
|
||||
public function send_pk()
|
||||
{
|
||||
$room_id_a = input('room_id_a', 0);//pk房间A_id
|
||||
$create_user_id = input('create_user_id', 0);//发起人(谁发起,默认A组)
|
||||
$room_id_b = input('room_id_b', 0);//pk房间B_id (默认B组)
|
||||
|
||||
$reslut = model('RoomPk')->send_pk($room_id_a, $create_user_id, $room_id_b);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//接受/拒绝 PK邀请
|
||||
public function accept_pk()
|
||||
{
|
||||
$pk_id = input('pk_id', 0);//pk id
|
||||
$type = input('type', 1);//1接受,2拒绝
|
||||
|
||||
$reslut = model('RoomPk')->accept_pk($pk_id,$type,$this->uid);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//开始PK
|
||||
public function start_pk()
|
||||
{
|
||||
$pk_id = input('pk_id', 0);
|
||||
$pk_times = input('pk_times', 0);//Pk时长 分钟
|
||||
$reslut = model('RoomPk')->start_pk($this->uid,$pk_id,$pk_times);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//搜索 或推荐的pk房间
|
||||
public function search_pk_room()
|
||||
{
|
||||
$room_id = input('room_id', '');
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 15);
|
||||
$reslut = model('RoomPk')->search_pk_room($this->uid,$room_id,$page,$limit);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//pk结束
|
||||
public function end_pk()
|
||||
{
|
||||
$pk_id = input('pk_id', 0);
|
||||
$type = input('type', 1);//1-pk结束,2-断开链接,3-中途关闭,4-没开始结束
|
||||
$user_id = input('user_id', 0);
|
||||
$reslut = model('RoomPk')->end_pk($pk_id,$type,$user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//不再接受 PK
|
||||
public function refuse_pk()
|
||||
{
|
||||
$is_pk = input('is_pk', 1);//1、接受,2、不接受pk
|
||||
$room_id = input('room_id', 0);
|
||||
$reslut = model('RoomPk')->refuse_pk($is_pk,$room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
86
application/api/controller/RoomSong.php
Normal file
86
application/api/controller/RoomSong.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
|
||||
class RoomSong extends BaseCom
|
||||
{
|
||||
//申请点歌
|
||||
public function apply_song(){
|
||||
|
||||
$room_id = input('room_id');
|
||||
$res = model('RoomSong')->apply_song($this->uid,$room_id);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
|
||||
//同意、拒绝点歌
|
||||
public function agree_song(){
|
||||
$room_id = input('room_id');
|
||||
$type = input('type',1);//1同意 2拒绝
|
||||
$res = model('RoomSong')->agree_song($this->uid,$room_id,$type);
|
||||
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
|
||||
//点歌
|
||||
public function song(){
|
||||
$key_name = "api:room:song:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$room_id = input('room_id');
|
||||
$user_id = input('user_id');
|
||||
$song_code = input('song_code');
|
||||
$song_name = input('song_name');
|
||||
$singer = input('singer');
|
||||
$poster = input('poster');
|
||||
$duration = input('duration');
|
||||
$res = model('RoomSong')->song($room_id,$user_id,$song_code,$song_name,$singer,$poster,$duration);
|
||||
redis_unlock($key_name);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
//已点歌曲列表
|
||||
public function song_list(){
|
||||
$room_id = input('room_id');
|
||||
$res = model('RoomSong')->song_list($room_id);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
|
||||
//上移歌 $type 1上移 2置顶
|
||||
public function up_song(){
|
||||
$room_song_id = input('did');
|
||||
$type = input('type');//1上移,2置顶
|
||||
$res = model('RoomSong')->up_song($room_song_id,$type);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
//切歌
|
||||
public function change_song(){
|
||||
$key_name = "api:room:change_song:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$room_id = input('room_id');
|
||||
$now_room_song_id = input('now_did');
|
||||
$res = model('RoomSong')->change_song($room_id,$now_room_song_id);
|
||||
redis_unlock($key_name);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
//结束本场次唱歌
|
||||
public function end_song(){
|
||||
$room_id = input('room_id');
|
||||
$res = model('RoomSong')->end_song($room_id);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
|
||||
//K歌房间用户列表
|
||||
public function get_charm_rank(){
|
||||
$room_id = input('room_id');
|
||||
$res = model('RoomSong')->get_charm_rank($room_id);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
}
|
||||
99
application/api/controller/Search.php
Normal file
99
application/api/controller/Search.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class Search extends BaseCom
|
||||
{
|
||||
//搜索
|
||||
public function search()
|
||||
{
|
||||
$search = input('search', '');
|
||||
$type = input('type', 1);//1用户,2房间,3公会
|
||||
|
||||
//根据类型进行搜索
|
||||
switch ($type) {
|
||||
case 1:
|
||||
$table = 'user';
|
||||
//判断是否纯数字
|
||||
if(is_numeric($search)){
|
||||
$where = [
|
||||
'user_code' => $search,
|
||||
'status' => 1
|
||||
];
|
||||
}else{
|
||||
$where = [
|
||||
'nickname' => ['like', '%'.$search . '%'],
|
||||
'status' => 1
|
||||
];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
$table = 'vs_room';
|
||||
if(is_numeric($search)){
|
||||
$where = [
|
||||
'room_number' => $search,
|
||||
'apply_status' => 2
|
||||
];
|
||||
}else{
|
||||
$where = [
|
||||
'room_name' => ['like', '%'.$search . '%'],
|
||||
'apply_status' => 2
|
||||
];
|
||||
}
|
||||
|
||||
break;
|
||||
case 3:
|
||||
$table = 'vs_guild';
|
||||
if(is_numeric($search)){
|
||||
$where = [
|
||||
'guild_special_id' => $search,
|
||||
'is_show' => 1,
|
||||
'delete_time' => 0
|
||||
];
|
||||
}else{
|
||||
$where = [
|
||||
'guild_name' => ['like', '%'.$search . '%'],
|
||||
'is_show' => 1,
|
||||
'delete_time' => 0
|
||||
];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
if($search == '' || $search == null){
|
||||
return V(0, '请输入搜索内容');
|
||||
}
|
||||
|
||||
$lists = [];
|
||||
$reslut = db::name($table)->where($where)->select();
|
||||
if(isset($reslut)){
|
||||
foreach ($reslut as $k=>$v){
|
||||
if($type == 1){
|
||||
$lists[$k]['id'] = $v['id'];
|
||||
$lists[$k]['name'] = $v['nickname'];
|
||||
$lists[$k]['picture'] = $v['avatar'];
|
||||
$lists[$k]['code'] = $v['user_code'];
|
||||
$lists[$k]['icon'][0] = model('UserData')->user_wealth_icon($v['id']);//财富图标
|
||||
$lists[$k]['icon'][1] = model('UserData')->user_charm_icon($v['id']);//魅力图标
|
||||
}elseif($type == 2){
|
||||
$lists[$k]['id'] = $v['id'];
|
||||
$lists[$k]['name'] = $v['room_name'];
|
||||
$lists[$k]['picture'] = $v['room_cover'];
|
||||
$lists[$k]['code'] = $v['room_number'];
|
||||
$lists[$k]['label_icon'] = db::name('vs_room_label')->where('id', $v['label_id'])->value('label_icon');
|
||||
$lists[$k]['hot_value'] = $v['hot_value'];
|
||||
}elseif($type == 3){
|
||||
$lists[$k]['id'] = $v['id'];
|
||||
$lists[$k]['name'] = $v['guild_name'];
|
||||
$lists[$k]['picture'] = $v['cover'];
|
||||
$lists[$k]['code'] = $v['guild_special_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return V(1, '获取成功', $lists);
|
||||
}
|
||||
}
|
||||
16
application/api/controller/Share.php
Normal file
16
application/api/controller/Share.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
|
||||
class Share extends Controller
|
||||
{
|
||||
//动态详情
|
||||
public function zone_detail()
|
||||
{
|
||||
$zid = input('id', 0);
|
||||
$reslut = model('UserZone')->get_zone_info($zid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
99
application/api/controller/Sms.php
Normal file
99
application/api/controller/Sms.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use app\common\model\User;
|
||||
use think\Db;
|
||||
use think\Env;
|
||||
|
||||
/**
|
||||
* 手机短信接口
|
||||
*/
|
||||
class Sms extends Api
|
||||
{
|
||||
protected $noNeedLogin = '*';
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
|
||||
* @ApiParams (name="event", type="string", required=true, description="事件名称")
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
$mobile = $this->request->post("mobile");
|
||||
$event = $this->request->post("event" , 'default');
|
||||
|
||||
if (!checkMobile($mobile)) {
|
||||
return V(0, '手机号不正确');
|
||||
}
|
||||
//频率控制
|
||||
$last = db::name('sms')->where(['mobile' => $mobile, 'event' => $event])->order('id', 'DESC')->find();
|
||||
if ($last && time() - $last['createtime'] < 60) {
|
||||
return V(0, '发送频繁');
|
||||
}
|
||||
$ipSendTotal = db::name('sms')->where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
|
||||
if ($ipSendTotal >= 7) {
|
||||
return V(0, '发送频繁');
|
||||
}
|
||||
//发送短信
|
||||
$ret = $this->send_smsbao_msg($mobile, $event);
|
||||
if ($ret['code'] == 1) {
|
||||
return V($ret['code'], $ret['msg'],$ret['data']);
|
||||
} else {
|
||||
return V(0, '系统错误,请检查短信配置!');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测验证码
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
|
||||
* @ApiParams (name="event", type="string", required=true, description="事件名称")
|
||||
* @ApiParams (name="captcha", type="string", required=true, description="验证码")
|
||||
*/
|
||||
public function check($mobile, $code, $event = 'default')
|
||||
{
|
||||
if (!checkMobile($mobile)) {
|
||||
return V(0, '手机号不正确');
|
||||
}
|
||||
$is_code = db::name('sms')->where(['mobile' => $mobile, 'event' => $event])->find();
|
||||
if ($is_code && $is_code['code'] == $code) {
|
||||
//验证码正确
|
||||
db::name('sms')->where(['mobile' => $mobile, 'event' => $event])->delete();
|
||||
return V(1, '验证码正确');
|
||||
} else {
|
||||
return V(0, '验证码错误');
|
||||
}
|
||||
}
|
||||
|
||||
private function send_smsbao_msg($mobile,$event = 'default'){
|
||||
$dxb_temp = Env::get('smsbao.dxb_temp');
|
||||
$dxb_name = Env::get('smsbao.dxb_name');
|
||||
$dxb_pwd = Env::get('smsbao.dxb_pwd');
|
||||
$sms_code = generateRandoms();
|
||||
//随机生成4位数
|
||||
$content = str_replace('{code}',$sms_code,$dxb_temp);//要发送的短信内容
|
||||
//短信宝
|
||||
$url = "https://api.smsbao.com/sms?u=".$dxb_name."&p=".md5($dxb_pwd)."&m=".$mobile."&c=".urlencode($content);
|
||||
$result = myCurl($url);
|
||||
$result_arr = json_decode($result, true);
|
||||
if ($result_arr == 0) {
|
||||
db::name('sms')->insert([
|
||||
'event' => $event,
|
||||
'mobile' => $mobile,
|
||||
'code' => $sms_code,
|
||||
'ip' => $this->request->ip(),
|
||||
'createtime' => time(),
|
||||
]);
|
||||
return ['code' => 1, 'msg' => '发送成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '发送失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
42
application/api/controller/Suggest.php
Normal file
42
application/api/controller/Suggest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
|
||||
|
||||
class Suggest extends BaseCom
|
||||
{
|
||||
/*
|
||||
* 用户反馈
|
||||
*/
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
|
||||
//用户反馈
|
||||
public function create_suggest()
|
||||
{
|
||||
$key_name = "api:suggest:create_suggest:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$image = input('image', 0);
|
||||
$content = input('content', 0);
|
||||
$tell = input('tell', 0);
|
||||
$reslut = model('Suggest')->create_suggest($this->uid, $image, $content,$tell);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//我的反馈
|
||||
public function my_suggest(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 15);
|
||||
$reslut = model('Suggest')->suggest_list($this->uid,$page,$page_limit);
|
||||
$reslut['data']['page'] = $page;
|
||||
$reslut['data']['page_limit'] = $page_limit;
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
26
application/api/controller/Theme.php
Normal file
26
application/api/controller/Theme.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
class Theme extends controller
|
||||
{
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
/*
|
||||
* 启动页列表
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public function get_theme_data()
|
||||
{
|
||||
$reslut = DB::name('vs_theme')->where('is_active',1)->where('delete_time',0)->find();
|
||||
return V(1,'操作成功', $reslut);
|
||||
}
|
||||
}
|
||||
42
application/api/controller/Token.php
Normal file
42
application/api/controller/Token.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use fast\Random;
|
||||
|
||||
/**
|
||||
* Token接口
|
||||
*/
|
||||
class Token extends Api
|
||||
{
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = '*';
|
||||
|
||||
/**
|
||||
* 检测Token是否过期
|
||||
*
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
$token = $this->auth->getToken();
|
||||
$tokenInfo = \app\common\library\Token::get($token);
|
||||
$this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新Token
|
||||
*
|
||||
*/
|
||||
public function refresh()
|
||||
{
|
||||
//删除源Token
|
||||
$token = $this->auth->getToken();
|
||||
\app\common\library\Token::delete($token);
|
||||
//创建新Token
|
||||
$token = Random::uuid();
|
||||
\app\common\library\Token::set($token, $this->auth->id, 2592000);
|
||||
$tokenInfo = \app\common\library\Token::get($token);
|
||||
$this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
|
||||
}
|
||||
}
|
||||
267
application/api/controller/User.php
Normal file
267
application/api/controller/User.php
Normal file
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use app\common\library\Ems;
|
||||
use app\common\library\Sms;
|
||||
use fast\Random;
|
||||
use think\Config;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 会员接口
|
||||
*/
|
||||
class User extends BaseCom
|
||||
{
|
||||
//获取用户关注列表
|
||||
public function get_user_follow_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('user')->get_user_follow_list($this->uid, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//获取用户粉丝列表
|
||||
public function get_user_fans_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('user')->get_user_fans_list($this->uid, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//获取用户黑名单
|
||||
public function get_blacklist(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('user')->get_blacklist($this->uid, $page, $page_limit);
|
||||
return V($reslut['code'],$reslut['msg'],$reslut['data']);
|
||||
}
|
||||
|
||||
//添加用户黑名单
|
||||
public function add_blacklist(){
|
||||
$user_id = input('user_id','');
|
||||
$reslut = model('user')->add_blacklist($this->uid, $user_id);
|
||||
return V($reslut['code'],$reslut['msg'],$reslut['data']);
|
||||
}
|
||||
|
||||
//移除用户黑名单
|
||||
public function remove_blacklist(){
|
||||
$user_id = input('uid','');
|
||||
$reslut = model('user')->remove_blacklist($this->uid,$user_id);
|
||||
return V($reslut['code'],$reslut['msg'],$reslut['data']);
|
||||
}
|
||||
|
||||
//用户主页
|
||||
public function get_user_home()
|
||||
{
|
||||
$uid = input('user_id', 0);
|
||||
$reslut = model('user')->get_user_home($this->uid,$uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//用户主页动态
|
||||
public function user_home_zone()
|
||||
{
|
||||
$uid = input('user_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('UserZone')->get_user_zone_list($this->uid, $uid, $page, $page_limit);
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
//用户礼物墙
|
||||
public function user_gift_wall()
|
||||
{
|
||||
$uid = input('user_id', 0);
|
||||
$reslut = model('User')->get_user_gift_wall_info($uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//相册列表
|
||||
public function get_album_list()
|
||||
{
|
||||
$uid = input('user_id', 0);
|
||||
$reslut = model('user')->get_album_list($uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//相册详情
|
||||
public function get_album_detail()
|
||||
{
|
||||
$album_id = input('album_id', 0);
|
||||
$pwd = input('pwd','');
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('user')->get_album_detail($this->uid,$album_id,$pwd, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//创建相册
|
||||
public function create_album()
|
||||
{
|
||||
$name = input('name', '');
|
||||
$pwd = input('pwd','');
|
||||
$image = input('image','');
|
||||
$reslut = model('user')->create_album($this->uid,$name,$pwd,$image);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//添加相册内容
|
||||
public function add_album_content()
|
||||
{
|
||||
$album_id = input('album_id', 0);
|
||||
$image = input('images','');
|
||||
$content = input('content','');
|
||||
$reslut = model('user')->add_album_content($this->uid,$album_id,$image,$content);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//把普通相册转为私密相册
|
||||
public function change_album_pwd()
|
||||
{
|
||||
$album_id = input('album_id', 0);
|
||||
$pwd = input('pwd','');
|
||||
$reslut = model('user')->change_album_pwd($this->uid,$album_id,$pwd);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//删除相册
|
||||
public function delete_album()
|
||||
{
|
||||
$album_id = input('album_id', 0);
|
||||
$reslut = model('user')->delete_album($this->uid,$album_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//移动相册
|
||||
public function move_album_images()
|
||||
{
|
||||
$id = input('id', '');
|
||||
$album_id = input('new_album_id', '');
|
||||
$reslut = model('user')->move_album_images($this->uid,$id,$album_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//相册点赞
|
||||
public function like_album()
|
||||
{
|
||||
$album_id = input('album_id', 0);
|
||||
$reslut = model('user')->like_album($this->uid,$album_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//删除相册图片
|
||||
public function delete_album_images()
|
||||
{
|
||||
$id = input('id', '');
|
||||
$reslut = model('user')->delete_album_images($this->uid,$id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//编辑相册
|
||||
public function edit_album()
|
||||
{
|
||||
$album_id = input('album_id', 0);
|
||||
$name = input('name', '');
|
||||
$pwd = input('pwd','');
|
||||
$image = input('image','');
|
||||
$reslut = model('user')->edit_album($this->uid,$album_id,$name,$pwd,$image);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//编辑用户信息
|
||||
public function edit_user_info()
|
||||
{
|
||||
$nickname = input('nickname', '');
|
||||
$sex = input('sex', 0);
|
||||
$birthday = input('birthday', '');
|
||||
$profile = input('profile', '');
|
||||
$avatar = input('avatar', '');
|
||||
$tag_id = input('tag_id', '');//标签id,逗号分隔的字符串
|
||||
// $image = input('images', '');//背景图
|
||||
$reslut = model('user')->edit_user_info($this->uid,$nickname,$sex,$birthday,$profile,$avatar,$tag_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//修改用户的背景图
|
||||
public function edit_user_bg()
|
||||
{
|
||||
$image = input('images', '');
|
||||
$reslut = model('user')->edit_user_bg($this->uid,$image);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//用户标签列表
|
||||
public function get_user_tag_list()
|
||||
{
|
||||
$reslut = model('UserTag')->get_tag_list();
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//查询用户修改头像的次数
|
||||
public function get_user_avatar_num()
|
||||
{
|
||||
$reslut = model('user')->get_user_avatar_num($this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//看过我的
|
||||
public function get_look_me_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('user')->get_look_me_list($this->uid, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//我的
|
||||
public function get_user_info()
|
||||
{
|
||||
$reslut = model('user')->get_me($this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//关注(回关)
|
||||
public function follow()
|
||||
{
|
||||
$uid = input('user_id', 0);
|
||||
$type = input('type', 1);//1用户,2房间
|
||||
$reslut = model('user')->follow($this->uid, $uid,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//用户关系卡(亲密拍)、关系位(真爱拍)
|
||||
public function user_cp_list()
|
||||
{
|
||||
$user_id = input('user_id', 0);
|
||||
$reslut = model('UserCp')->user_cp_list($this->uid, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//更新用户ip
|
||||
public function update_user_ip()
|
||||
{
|
||||
$ip = input('address_ip', '');
|
||||
$reslut = model('User')->update_user_ip($this->uid, $ip);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//实否可已发起私聊
|
||||
public function can_start_private_chat()
|
||||
{
|
||||
$reslut = model('User')->can_start_private_chat($this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//转币
|
||||
public function give_coin(){
|
||||
$give_uid = input('user_id', 0);
|
||||
$coin = input('coin', 0);
|
||||
$reslut = model('UserWallet')->give_coin($this->uid, $give_uid, $coin);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
152
application/api/controller/UserData.php
Normal file
152
application/api/controller/UserData.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
|
||||
class UserData extends BaseCom
|
||||
{
|
||||
//用户第一次修改信息
|
||||
public function modify_fist_user_info()
|
||||
{
|
||||
// $this->uid = input('user_id', 0);
|
||||
$key_name = "api:user:follow_user:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$nick_name = input('nickname');
|
||||
$birthday = input('birthday');
|
||||
$sex = input('sex', 0);
|
||||
$head_pic = input('avatar', '');
|
||||
$reg_code = input('init_code', '');
|
||||
|
||||
$reslut = model('UserData')->modify_fist_user_info($nick_name, $birthday, $sex, $head_pic, $reg_code,$this->uid);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//根据性别选择用户头像
|
||||
public function modify_user_sex_pic(){
|
||||
$sex = input('sex', 0);
|
||||
$reslut = model('UserData')->modify_pic_user_info($sex);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 随机生成用户昵称
|
||||
*/
|
||||
public function random_nickname()
|
||||
{
|
||||
$nickname = random_nickname(1);
|
||||
return V(1, "获取成功", $nickname);
|
||||
}
|
||||
|
||||
//修改用户 信息
|
||||
public function modify_user_info()
|
||||
{
|
||||
$key_name = "api:user:follow_user:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$nick_name = input('nick_name');
|
||||
$birthday = input('birthday');
|
||||
$sex = input('sex', 1);
|
||||
$head_pic = input('head_pic', '');
|
||||
$images = input('images', '');//背景图(以json字符串的形式可以多图)
|
||||
$autograph = input('autograph', '');//简介)
|
||||
$tag_id = input('tag_id','');//标签id 多选逗号分隔
|
||||
$reslut = model('UserData')->modify_user_info($this->uid, $nick_name, $birthday, $sex, $head_pic, $images, $autograph,$tag_id);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//修改/设置登录密码
|
||||
public function modify_password()
|
||||
{
|
||||
$trade_password = input('new_password');
|
||||
$mobile = input('mobile');
|
||||
$user_id = input('user_id');
|
||||
$sms_code = input('sms_code', ''); //短信验证码
|
||||
//default-默认登录,1-更换手机号,2绑定手机号,3-忘记密码,4-设置密码,5-账号注销,6-提现
|
||||
$reslut = model('sms')->verification_code(4,$mobile, $sms_code);
|
||||
if ($reslut['code'] == 0) {
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
$reslut = model('UserData')->modify_password($trade_password,$user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//绑定手机号
|
||||
public function bind_mobile()
|
||||
{
|
||||
$key_name = "api:user:bind_mobile:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$mobile = input('new_mobile');
|
||||
$sms_code = input('sms_code', '');
|
||||
//default-默认登录,1-更换手机号,2绑定手机号,3-忘记密码,4-设置密码,5-账号注销,6-提现
|
||||
$reslut = model('sms')->verification_code(2,$mobile, $sms_code);
|
||||
if ($reslut['code'] == 0) {
|
||||
redis_unlock($key_name);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
$reslut = model('UserData')->modify_mobile($mobile,$this->uid);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//更换手机号
|
||||
public function modify_mobile()
|
||||
{
|
||||
$key_name = "api:user:modify_mobile:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$mobile = input('mobile');
|
||||
$new_mobile = input('new_mobile');
|
||||
$sms_code = input('sms_code', '');
|
||||
$user_mobile = db::name('user')->where('id',$this->uid)->value('mobile');
|
||||
if ($user_mobile != $mobile){
|
||||
redis_unlock($key_name);
|
||||
return V(0, "旧手机号错误", null);
|
||||
}
|
||||
if ($new_mobile == $user_mobile){
|
||||
redis_unlock($key_name);
|
||||
return V(0, "新手机号不能与旧手机号一致", null);
|
||||
}
|
||||
|
||||
$reslut = model('sms')->verification_code(1,$new_mobile, $sms_code);
|
||||
if ($reslut['code'] == 0) {
|
||||
redis_unlock($key_name);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
$reslut = model('UserData')->modify_mobile($new_mobile,$this->uid);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//实名认证
|
||||
public function real_name()
|
||||
{
|
||||
$key_name = "api:user:real_name:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$real_name = input('real_name');
|
||||
$card_number = input('card_number');
|
||||
|
||||
$reslut = model('UserData')->real_name($this->uid,$real_name, $card_number);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//实名认证结果获取
|
||||
public function real_name_result()
|
||||
{
|
||||
$orderNo = input('orderNo', '');
|
||||
$reslut = model('UserData')->real_name_result($this->uid,$orderNo);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//实名认证后的信息
|
||||
public function real_name_info()
|
||||
{
|
||||
$reslut = model('UserData')->real_name_info($this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
47
application/api/controller/UserGiftPack.php
Normal file
47
application/api/controller/UserGiftPack.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
/*
|
||||
* 每日任务
|
||||
*
|
||||
*/
|
||||
class UserGiftPack extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
//获取背包礼物列表
|
||||
public function get_gift_pack_list()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('UserGiftPack')->get_gift_pack_list($user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//背包收入
|
||||
public function get_gift_pack_income()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$page = input('page',1);
|
||||
$page_limit = input('page_limit',10);
|
||||
$reslut = model('UserGiftPack')->income_user_gift_pack($user_id,$page=1,$page_limit=10);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//背包礼物支出
|
||||
public function get_gift_pack_outcome()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$page = input('page',1);
|
||||
$page_limit = input('page_limit',10);
|
||||
$reslut = model('UserGiftPack')->get_gift_pack_outcome($user_id,$page=1,$page_limit=10);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
34
application/api/controller/UserMessage.php
Normal file
34
application/api/controller/UserMessage.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
|
||||
class UserMessage extends BaseCom
|
||||
{
|
||||
//系统消息接口【废弃】
|
||||
public function get_message()
|
||||
{
|
||||
$message_id = input('message_id', 0);
|
||||
$reslut = model('UserMessage')->get_message($this->uid, $message_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//系统封面消息接口
|
||||
public function get_user_message_cover_info()
|
||||
{
|
||||
$reslut = model('UserMessage')->get_user_message_cover_info($this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//消息列表接口
|
||||
public function get_user_message_list()
|
||||
{
|
||||
$type = input('type', 0); //排序规则
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('UserMessage')->get_user_message_list($this->uid, $type, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
92
application/api/controller/UserWallet.php
Normal file
92
application/api/controller/UserWallet.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class UserWallet extends BaseCom
|
||||
{
|
||||
//钱包
|
||||
public function wallet()
|
||||
{
|
||||
$reslut = model('UserWallet')->wallet($this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
// //给前端的类型组装一个
|
||||
// public function gift_type()
|
||||
// {
|
||||
// // 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// // 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// $data = [
|
||||
//// ['id' => 1, 'name' => '系统调节'],
|
||||
// ['id' => 2, 'name' => '充值'],
|
||||
// ['id' => 3, 'name' => '提现'],
|
||||
// ['id' => 4, 'name' => '金币转增'],
|
||||
// ['id' => 5, 'name' => '每日任务奖励'],
|
||||
// ['id' => 6, 'name' => '充值返利'],
|
||||
// ['id' => 7, 'name' => '购买装扮'],
|
||||
// ['id' => 8, 'name' => '礼盒奖励'],
|
||||
// ['id' => 9, 'name' => '房间补贴'],
|
||||
// ['id' => 10, 'name' => '购买礼物'],
|
||||
// ['id' => 11, 'name' => '收礼增加收益'],
|
||||
// ['id' => 12, 'name' => '工会补贴'],
|
||||
// ['id' => 13, 'name' => '金币转增'],
|
||||
// ['id' => 14, 'name' => '收益兑换'],
|
||||
// ['id' => 15, 'name' => '送礼'],
|
||||
// ];
|
||||
// return V(1, '获取成功', $data);
|
||||
// }
|
||||
|
||||
//金币(钻石)明细
|
||||
public function log_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$in_out_type = input('in_out_type', 1);//1收入2支出
|
||||
$gift_type = input('gift_type', 1);//1金币,2收益(钻石)
|
||||
//开始时间
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
$reslut = model('UserWallet')->log_list($this->uid, $page, $page_limit,$in_out_type,$start_time,$end_time,$gift_type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//收益(钻石)兑换金币
|
||||
public function exchange_coin()
|
||||
{
|
||||
$earnings_num = input('earnings_num', 0);
|
||||
$reslut = model('UserWallet')->exchange_coin($this->uid,$earnings_num);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//收益(钻石)兑换金币汇率
|
||||
public function exchange_coin_rate()
|
||||
{
|
||||
$reslut['data'] = get_system_config()['coin_exchange_rate'];
|
||||
return V(1, '获取成功', $reslut['data']);
|
||||
}
|
||||
/*
|
||||
* 可选充值金额列表
|
||||
*/
|
||||
public function can_recharge_list(){
|
||||
$reslut = db::name("vs_can_recharge")->where("status",1)->where("delete_time",0)->order('money asc')->select();
|
||||
$reslut_data = [];
|
||||
foreach ($reslut as $k=>$v){
|
||||
$reslut_data[$k]['money'] = $v['money'];
|
||||
$reslut_data[$k]['coins'] = $v['coins'];
|
||||
}
|
||||
return V(1, '获取成功', $reslut_data);
|
||||
}
|
||||
/*
|
||||
* 钻石兑换金币比例
|
||||
*/
|
||||
public function get_wallet_config(){
|
||||
$reslut['coin_exchange_rate'] = get_system_config_value('coin_exchange_rate');
|
||||
$reslut['withdrawal_service_fee'] = get_system_config_value('withdrawal_service_fee');
|
||||
$reslut['rmb_coin_ratio'] = get_system_config_value('rmb_coin_ratio');
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
}
|
||||
62
application/api/controller/UserWithdrawal.php
Normal file
62
application/api/controller/UserWithdrawal.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use Yzh\YunPay;
|
||||
|
||||
|
||||
class UserWithdrawal extends BaseCom
|
||||
{
|
||||
//提现
|
||||
public function withdrawal(){
|
||||
$key_name = "api:user:withdrawal:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$number = input('number', 0);//提现金额(钻石)
|
||||
$type = input('type', 1);
|
||||
$sms_code = input('sms_code', '');
|
||||
$reslut = model('UserWithdrawal')->withdrawal($this->uid,$number, $type,$sms_code);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//提现记录
|
||||
public function withdrawal_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$search_stime = input('search_stime', '');
|
||||
$search_etime = input('search_etime', '');
|
||||
$reslut = model('UserWithdrawal')->withdrawal_list($this->uid,$page,$page_limit,$search_stime,$search_etime);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
//获取签约协议链接
|
||||
public function get_sign_url(){
|
||||
$yun_pay = new YunPay();
|
||||
$reslut = $yun_pay->getAgreementPreviewUrl();
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//云账户签约
|
||||
public function sign_yun_account(){
|
||||
$real_name = input('real_name', '');
|
||||
$id_card = input('id_card', '');
|
||||
$yun_pay = new YunPay();
|
||||
$reslut = $yun_pay->apiUserSign($real_name,$id_card);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//获取用户签约状态
|
||||
public function get_yun_account_status(){
|
||||
$real_name = input('real_name', '');
|
||||
$id_card = input('id_card', '');
|
||||
$yun_pay = new YunPay();
|
||||
$reslut = $yun_pay->getApiUserSignStatus($real_name,$id_card);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//用户云账户解约
|
||||
public function cancel_yun_account(){
|
||||
$real_name = input('real_name', '');
|
||||
$id_card = input('id_card', '');
|
||||
$yun_pay = new YunPay();
|
||||
$reslut = $yun_pay->unSignYunAccount($real_name,$id_card);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
235
application/api/controller/UserZone.php
Normal file
235
application/api/controller/UserZone.php
Normal file
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class UserZone extends BaseCom
|
||||
{
|
||||
//发布动态
|
||||
public function publish_zone()
|
||||
{
|
||||
$key_name = "api:usezone:publish_zone:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
$images = input('images', '');
|
||||
$content = input('content', '');
|
||||
$topic_id = input('topic_id', '');
|
||||
$room_id = input('room_id', 0);
|
||||
$ip = input('ip', 0);
|
||||
$reslut = model('UserZone')->publish_zone($this->uid, $images, $content,$topic_id,$room_id,$ip);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//动态列表
|
||||
public function zone_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$reslut = model('UserZone')->get_zone_list($this->uid, $page, $page_limit);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//动态详情
|
||||
public function zone_detail()
|
||||
{
|
||||
$zid = input('id', 0);
|
||||
$reslut = model('UserZone')->get_zone_info($zid,$this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//动态评论
|
||||
public function comment_zone()
|
||||
{
|
||||
$key_name = "api:usezone:comment_zone:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$zid = input('id', 0);
|
||||
$content = input('content', '');
|
||||
$pid = input('pid', 0);
|
||||
$reply_to = input('reply_to', 0);
|
||||
$reslut = model('UserZone')->comment_zone($this->uid, $zid, $content,$pid, $reply_to);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//动态评论列表
|
||||
public function get_comment_list()
|
||||
{
|
||||
$key_name = "api:usezone:get_comment_list:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$zid = input('id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
|
||||
$reslut = model('UserZone')->getCommentsWithReplies($zid, $page, $page_limit);
|
||||
|
||||
redis_unlock($key_name);
|
||||
if($reslut['code'] == 1){
|
||||
$resluts['data']['list'] = $reslut['data'];
|
||||
$total = model('UserZone')->getCommentCount($zid);
|
||||
$resluts['data']['total'] = $total;
|
||||
}
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $resluts['data']);
|
||||
}
|
||||
|
||||
//动态点赞
|
||||
public function like_zone()
|
||||
{
|
||||
$key_name = "api:usezone:praise_zone:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
$zid = input('id', '');
|
||||
$reslut = model('UserZone')->praise_zone($this->uid, $zid);
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//点赞列表
|
||||
public function like_list()
|
||||
{
|
||||
$zid = input('id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('UserZone')->get_like_list($zid, $page, $page_limit);
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
//删除动态
|
||||
public function delete_zone()
|
||||
{
|
||||
$zid = input('id', 0);
|
||||
$reslut = model('UserZone')->delete_zone($this->uid, $zid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//删除评论
|
||||
public function delete_zone_comment()
|
||||
{
|
||||
$cid = input('id', 0);
|
||||
$reslut = model('UserZone')->delete_zone_comment($this->uid, $cid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//话题列表
|
||||
public function topic_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('Topic')->get_topic_list($page, $page_limit);
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
//获取动态引用最多的四条话题
|
||||
public function get_zone_topic()
|
||||
{
|
||||
$reslut = model('Topic')->get_zone_topic();
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
//引用话题的动态
|
||||
public function get_zone_topic_list()
|
||||
{
|
||||
$topic_id = input('topic_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('UserZone')->get_zone_topic_list($this->uid, $topic_id, $page, $page_limit);
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
//用户主页的动态列表
|
||||
// public function get_user_zone_list()
|
||||
// {
|
||||
// $from_id = input('user_id',0);
|
||||
// $page = input('page', 1);
|
||||
// $page_limit = input('page_limit', 30);
|
||||
// $reslut = model('UserZone')->get_user_zone_list($this->uid, $from_id, $page, $page_limit);
|
||||
//
|
||||
// return V(1, '获取成功', $reslut);
|
||||
// }
|
||||
|
||||
|
||||
//扩列
|
||||
public function expand_zone()
|
||||
{
|
||||
$key_name = "api:usezone:expand_zone:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$type = input('type', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('UserZone')->expand_zone($this->uid, $type, $page, $page_limit);
|
||||
redis_unlock($key_name);
|
||||
//版本号
|
||||
$system = request()->header('system');
|
||||
$app_version = request()->header('App-Version');
|
||||
if(!$app_version){
|
||||
$app_version = input('App-Version');
|
||||
}
|
||||
// var_dump($app_version);
|
||||
$api_version = 0;
|
||||
if ($system == 'iOS') {
|
||||
$api_versions = db::name('version')->where(['type' => 2, 'status' => 1])->order('id', 'desc')->find();
|
||||
$result = version_compare($api_versions['oldversion'],$app_version);
|
||||
if ($result < 0) {
|
||||
$api_version = 1;
|
||||
}
|
||||
}
|
||||
return V(1, '获取成功', $reslut, $api_version);
|
||||
}
|
||||
|
||||
//动态打赏
|
||||
public function reward_zone()
|
||||
{
|
||||
$zid = input('id', 0);
|
||||
$gift_id = input('gift_id', 0);
|
||||
$num = input('num', 1);
|
||||
$is_pack = input('is_pack', 1);//2背包 1金币
|
||||
$reslut = model('GiveGift')->reward_zone($this->uid, $zid, $gift_id, $num, $is_pack);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//打赏列表
|
||||
public function reward_list()
|
||||
{
|
||||
$zid = input('id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('GiveGift')->zone_reward_list($this->uid, $zid, $page, $page_limit);
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
//相互关注的用户(分享使用)
|
||||
public function mutual_follow()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('UserZone')->mutual_follow($this->uid, $page, $page_limit);
|
||||
return V(1, '获取成功', $reslut);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
75
application/api/controller/Usermode.php
Normal file
75
application/api/controller/Usermode.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
class Usermode extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
|
||||
//开启/关闭青少年模式
|
||||
public function open_teen_mode(){
|
||||
$uid = UID;
|
||||
$key_name = "api:user:open_teen_mode:".$uid;
|
||||
redis_lock_exit($key_name);
|
||||
$type = input('type', 1);
|
||||
$password = input('password', '');
|
||||
$again_password = input('again_password', '');
|
||||
$reslut = model('UserMode')->open_teen_mode($uid, $type, $password, $again_password);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//关闭青少年模式、确认青少年模式密码
|
||||
public function close_teen_mode(){
|
||||
$uid = $this->uid;
|
||||
$key_name = "api:user:close_teen_mode:".$uid;
|
||||
redis_lock_exit($key_name);
|
||||
$type = input('type', 1);
|
||||
$password = input('password', '');
|
||||
$reslut = model('UserMode')->close_teen_mode($uid, $type, $password);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//青少年模式类型列表
|
||||
public function getUnderageTypeList(){
|
||||
$list = Db::name('vs_underage_mode_type')->where('is_delete', 1)->order(['sort'=>'asc', 'id' => 'desc'])->select();
|
||||
return V(1, "操作成功", $list);
|
||||
}
|
||||
//获取青少年模式列表 带分页
|
||||
public function getUnderageModeList(){
|
||||
$type = $this->request->get('type');
|
||||
$page = $this->request->get('page', 1);
|
||||
$page_limit = $this->request->get('page_limit', 10);
|
||||
if(!$type){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$list = Db::name('vs_underage_mode_content')
|
||||
->where('type_id', $type)
|
||||
->where('is_delete', 1)
|
||||
->order(['sort'=>'asc', 'id' => 'desc'])
|
||||
->paginate($page_limit, false, ['page' => $page]);
|
||||
return V(1, "操作成功", $list);
|
||||
}
|
||||
//获取青少年模式内容
|
||||
public function getUnderageModeContent(){
|
||||
$id = $this->request->get('id');
|
||||
if(!$id){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$data = Db::name('vs_underage_mode_content')
|
||||
->where('is_delete', 1)
|
||||
->where('id', $id)
|
||||
->find();
|
||||
return V(1, "操作成功", $data);
|
||||
}
|
||||
|
||||
}
|
||||
163
application/api/controller/Validate.php
Normal file
163
application/api/controller/Validate.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use app\common\model\User;
|
||||
|
||||
/**
|
||||
* 验证接口
|
||||
*/
|
||||
class Validate extends Api
|
||||
{
|
||||
protected $noNeedLogin = '*';
|
||||
protected $layout = '';
|
||||
protected $error = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测邮箱
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="email", type="string", required=true, description="邮箱")
|
||||
* @ApiParams (name="id", type="string", required=true, description="排除会员ID")
|
||||
*/
|
||||
public function check_email_available()
|
||||
{
|
||||
$email = $this->request->post('email');
|
||||
$id = (int)$this->request->post('id');
|
||||
$count = User::where('email', '=', $email)->where('id', '<>', $id)->count();
|
||||
if ($count > 0) {
|
||||
$this->error(__('邮箱已经被占用'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测用户名
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="username", type="string", required=true, description="用户名")
|
||||
* @ApiParams (name="id", type="string", required=true, description="排除会员ID")
|
||||
*/
|
||||
public function check_username_available()
|
||||
{
|
||||
$username = $this->request->post('username');
|
||||
$id = (int)$this->request->post('id');
|
||||
$count = User::where('username', '=', $username)->where('id', '<>', $id)->count();
|
||||
if ($count > 0) {
|
||||
$this->error(__('用户名已经被占用'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测昵称
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="nickname", type="string", required=true, description="昵称")
|
||||
* @ApiParams (name="id", type="string", required=true, description="排除会员ID")
|
||||
*/
|
||||
public function check_nickname_available()
|
||||
{
|
||||
$nickname = $this->request->post('nickname');
|
||||
$id = (int)$this->request->post('id');
|
||||
$count = User::where('nickname', '=', $nickname)->where('id', '<>', $id)->count();
|
||||
if ($count > 0) {
|
||||
$this->error(__('昵称已经被占用'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测手机
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
|
||||
* @ApiParams (name="id", type="string", required=true, description="排除会员ID")
|
||||
*/
|
||||
public function check_mobile_available()
|
||||
{
|
||||
$mobile = $this->request->post('mobile');
|
||||
$id = (int)$this->request->post('id');
|
||||
$count = User::where('mobile', '=', $mobile)->where('id', '<>', $id)->count();
|
||||
if ($count > 0) {
|
||||
$this->error(__('该手机号已经占用'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测手机
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
|
||||
*/
|
||||
public function check_mobile_exist()
|
||||
{
|
||||
$mobile = $this->request->post('mobile');
|
||||
$count = User::where('mobile', '=', $mobile)->count();
|
||||
if (!$count) {
|
||||
$this->error(__('手机号不存在'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测邮箱
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="email", type="string", required=true, description="邮箱")
|
||||
*/
|
||||
public function check_email_exist()
|
||||
{
|
||||
$email = $this->request->post('email');
|
||||
$count = User::where('email', '=', $email)->count();
|
||||
if (!$count) {
|
||||
$this->error(__('邮箱不存在'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测手机验证码
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
|
||||
* @ApiParams (name="captcha", type="string", required=true, description="验证码")
|
||||
* @ApiParams (name="event", type="string", required=true, description="事件")
|
||||
*/
|
||||
public function check_sms_correct()
|
||||
{
|
||||
$mobile = $this->request->post('mobile');
|
||||
$captcha = $this->request->post('captcha');
|
||||
$event = $this->request->post('event');
|
||||
if (!\app\common\library\Sms::check($mobile, $captcha, $event)) {
|
||||
$this->error(__('验证码不正确'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测邮箱验证码
|
||||
*
|
||||
* @ApiMethod (POST)
|
||||
* @ApiParams (name="email", type="string", required=true, description="邮箱")
|
||||
* @ApiParams (name="captcha", type="string", required=true, description="验证码")
|
||||
* @ApiParams (name="event", type="string", required=true, description="事件")
|
||||
*/
|
||||
public function check_ems_correct()
|
||||
{
|
||||
$email = $this->request->post('email');
|
||||
$captcha = $this->request->post('captcha');
|
||||
$event = $this->request->post('event');
|
||||
if (!\app\common\library\Ems::check($email, $captcha, $event)) {
|
||||
$this->error(__('验证码不正确'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
}
|
||||
51
application/api/controller/Version.php
Normal file
51
application/api/controller/Version.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
|
||||
class Version extends controller
|
||||
{
|
||||
/*
|
||||
* 获取app版本信息
|
||||
* @param string $version 版本号
|
||||
* @return id 版本id
|
||||
* @return string $url 下载地址
|
||||
* @return string $content 更新内容
|
||||
* @return int $is_force 是否强制更新 1 是 0 否
|
||||
* @return string $apiversion api版本号
|
||||
* @return string $code 状态码
|
||||
* @author:
|
||||
* @date: 2025 5/5/14
|
||||
*/
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
//获取app版本信息
|
||||
public function get_app_version()
|
||||
{
|
||||
$system = input('system', '');
|
||||
if ($system == 'iOS') {
|
||||
$type = 2;
|
||||
}else{
|
||||
$type = 1;
|
||||
}
|
||||
$reslut = model('Version')->where(['type' => $type, 'status' => 1])->order('id', 'desc')->find();
|
||||
if (!$reslut) {
|
||||
return V(0,'操作失败');
|
||||
}
|
||||
$data = [
|
||||
'id' => $reslut['id'],
|
||||
'version' => $reslut['newversion'],//新版本号
|
||||
'url' => $reslut['downloadurl'],
|
||||
'content' => $reslut['content'],
|
||||
'is_force' => $reslut['enforce'],
|
||||
'apiversion' => $reslut['apiversion'],
|
||||
'code' => $reslut['code']
|
||||
];
|
||||
return V(1,'操作成功', $data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user