更新
This commit is contained in:
@@ -32,6 +32,7 @@ class Activities extends BaseCom
|
||||
$data['name'] = $activities_title??"";
|
||||
$data['gift_bag'] = [];
|
||||
foreach ($gift_bag as $k=>$v){
|
||||
$data['gift_bag'][$k]['gift_bag_id'] = $v['id']??0;
|
||||
$data['gift_bag'][$k]['name'] = $v['title']??"";
|
||||
$ext = json_decode($v['ext'],true);
|
||||
$data['gift_bag'][$k]['title1'] = $ext['title1']??"";
|
||||
@@ -49,11 +50,13 @@ class Activities extends BaseCom
|
||||
$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'];
|
||||
if($gift){
|
||||
$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){
|
||||
@@ -85,8 +88,8 @@ class Activities extends BaseCom
|
||||
$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();
|
||||
$is_first_charge = db::name('vs_user_money_log')->where('user_id',$uid)->where('change_type',2)->where('money_type',1)->where(['createtime'=>['>=',"1760666400"]])->count();
|
||||
$permission = DB::name('vs_activities_receive')->where(['activities_id'=>$activities_id,'user_id'=>$uid])->where(['createtime'=>['>=',"1760666400"]])->find();
|
||||
$system = request()->header('system');
|
||||
$app_version = request()->header('App-Version');
|
||||
if(!$app_version){
|
||||
@@ -127,46 +130,51 @@ class Activities extends BaseCom
|
||||
//礼包
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>$activities_id,'status'=>1])->find();
|
||||
$data = [];
|
||||
$data['gift_bag_id'] = $gift_bag['id']??0;
|
||||
$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'];
|
||||
$data['money'] = $gift_bag['money'];
|
||||
$data['counter'] = $ext['counter'];
|
||||
$data['money_str'] = $ext['money_str'];
|
||||
$data['diamond'] = $ext['diamond'];
|
||||
$data['effective_time'] = $ext['activity_end_time']??"";
|
||||
if(strtotime($ext['activity_end_time']) < time()){
|
||||
return V(0,'活动已结束!',null);
|
||||
}
|
||||
$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]['gift_name'] = "金币";
|
||||
$list[$k]['num'] = $v['gold'];
|
||||
$list[$k]['gold'] = $v['gold'];
|
||||
$list[$k]['gift_price'] = $v['gold'];
|
||||
$list[$k]['type'] = 1;
|
||||
$list[$k]['icon'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
$list[$k]['base_image'] = 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]['gift_name'] = $gift['gift_name'];
|
||||
$list[$k]['num'] = $v['quantity'];
|
||||
$list[$k]['gold'] = $gift['gift_price'];
|
||||
$list[$k]['gift_price'] = $gift['gift_price'];
|
||||
$list[$k]['type'] =2;
|
||||
$list[$k]['icon'] = $gift['play_image'];
|
||||
$list[$k]['base_image'] = $gift['base_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]['gift_name'] = $gift['title']; //装扮名称
|
||||
$list[$k]['num'] = $decorate_price['day']; //天数
|
||||
$list[$k]['gold'] = $decorate_price['price']; //价格
|
||||
$list[$k]['gift_price'] = $decorate_price['price']; //价格
|
||||
$list[$k]['type'] =3;
|
||||
$list[$k]['icon'] = $gift['base_image'];
|
||||
$list[$k]['base_image'] = $gift['base_image'];
|
||||
}elseif($v['type'] == 4) {
|
||||
$list[$k]['name'] = "钻石";
|
||||
$list[$k]['gift_name'] = "钻石";
|
||||
$list[$k]['num'] = $v['quantity'];
|
||||
$list[$k]['gold'] = $v['gold'];
|
||||
$list[$k]['gift_price'] = $v['gold'];
|
||||
$list[$k]['type'] = 4;
|
||||
$list[$k]['icon'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
$list[$k]['base_image'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
}
|
||||
}
|
||||
$data['gift_list'] = $list;
|
||||
@@ -177,20 +185,183 @@ class Activities extends BaseCom
|
||||
{
|
||||
$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]);
|
||||
//礼包
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>3,'status'=>1])->find();
|
||||
$permission = 0;
|
||||
if($gift_bag){
|
||||
$ext = json_decode($gift_bag['ext'],true);
|
||||
if($ext['activity_end_time'] <= time()){
|
||||
$permission = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return V(1,'操作成功', ['permission'=>$permission]);
|
||||
}
|
||||
//天降好礼发放
|
||||
public function drop_gift_send()
|
||||
{
|
||||
$uid = input('uid',$this->uid);
|
||||
$reslut = model('Activities')->drop_gift_send($uid);
|
||||
$reslut = model('Activities')->drop_gift_send($uid,16);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//新人好礼
|
||||
public function new_charge_gift()
|
||||
{
|
||||
//活动信息
|
||||
$activities_id = 7;
|
||||
$activities_title = DB::name('vs_activities')->where(['id'=>$activities_id,'status'=>1,'delete_time'=>0])->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'] = [];
|
||||
//一键领取
|
||||
$bag_receive_all = DB::name('vs_gift_bag_receive_log')->where(['gift_bag_id'=>17,'user_id'=>$this->uid])->find();
|
||||
foreach ($gift_bag as $k=>$v){
|
||||
$data['gift_bag'][$k]['gift_bag_id'] = $v['id']??0;
|
||||
$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();
|
||||
if($gift){
|
||||
$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);
|
||||
if($bag_receive_all){
|
||||
$data['gift_bag'][$k]['status'] = 0;
|
||||
}else{
|
||||
if($v['id']!=17){
|
||||
$bag_receive_log = DB::name('vs_gift_bag_receive_log')->where(['gift_bag_id'=>$v['id'],'user_id'=>$this->uid])->find();
|
||||
if($bag_receive_log){
|
||||
$data['gift_bag'][$k]['status'] = 0;
|
||||
} else {
|
||||
$data['gift_bag'][$k]['status'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return V(1,'操作成功', $data);
|
||||
}
|
||||
|
||||
//新人好礼发放
|
||||
public function new_charge_gift_receive()
|
||||
{
|
||||
$uid = input('uid',$this->uid);
|
||||
$money = input('money',0);
|
||||
$reslut = model('Activities')->new_charge_gift_send($uid,$money);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 活动权限
|
||||
*/
|
||||
public function activities_permission(){
|
||||
$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;
|
||||
}
|
||||
}
|
||||
//首充
|
||||
$activities_id = 1;
|
||||
$uid = input('uid',$this->uid);
|
||||
$first_charge_permission = 1;
|
||||
//查询是否首充
|
||||
$is_first_charge = db::name('vs_user_money_log')->where('user_id',$uid)->where('change_type',2)->where('money_type',1)->where(['createtime'=>['>=',"1760666400"]])->count();
|
||||
$permission = DB::name('vs_activities_receive')->where(['activities_id'=>$activities_id,'user_id'=>$uid])->where(['createtime'=>['>=',"1760666400"]])->find();
|
||||
if($is_first_charge > 0){
|
||||
$first_charge_permission = 0;
|
||||
}
|
||||
if($permission){
|
||||
$first_charge_permission = 0;
|
||||
}
|
||||
|
||||
//天降好礼
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>3,'status'=>1])->find();
|
||||
$day_drop_permission = 0;
|
||||
if($gift_bag){
|
||||
$ext = json_decode($gift_bag['ext'],true);
|
||||
if(strtotime($ext['activity_end_time']) >= time()){
|
||||
$day_drop_permission = 1;
|
||||
}
|
||||
}
|
||||
//新人充值好礼
|
||||
$activities = DB::name('vs_activities')->where(['id'=>7,'status'=>1,'delete_time'=>0])->find();
|
||||
if($activities){
|
||||
$effective_time = $activities['effective_time'];
|
||||
}else{
|
||||
$effective_time = 0;
|
||||
}
|
||||
$bag_data = DB::name('vs_gift_bag')->where(['activities_id'=>7,'status'=>1,'delete_time'=>0])->select();
|
||||
$bag_receive_log = DB::name('vs_gift_bag_receive_log')->where(['gift_bag_id'=>['in',array_column($bag_data,'id')],'user_id'=>$uid])->select();
|
||||
$new_permission = 0;
|
||||
$user_info = DB::name('user')->where(['id'=>$uid])->find();
|
||||
if($user_info['createtime']<"1760666400"){
|
||||
$user_info['createtime'] = 1760666400;
|
||||
}
|
||||
if($user_info['createtime'] + $effective_time >= time()){
|
||||
$new_permission = 1;
|
||||
}
|
||||
$gift_bag_log_ids = array_column($bag_receive_log,'gift_bag_id');
|
||||
if(in_array(17,$gift_bag_log_ids)){
|
||||
$new_permission = 0;
|
||||
}else{
|
||||
$gift_bag_log_ids = array_intersect([14,15,16],$gift_bag_log_ids);
|
||||
if(count($gift_bag_log_ids) == 3){
|
||||
$new_permission = 0;
|
||||
}
|
||||
}
|
||||
return V(1,'操作成功',[
|
||||
'first_charge_permission'=>$first_charge_permission,
|
||||
'day_drop_permission'=>$day_drop_permission,
|
||||
'n_people_permission'=>$new_permission
|
||||
],$api_version);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use think\Controller;
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
|
||||
class Ceshi extends Controller
|
||||
class Ceshi extends Controllers
|
||||
{
|
||||
//设置白名单ip访问本类接口
|
||||
protected $allowIp = [
|
||||
@@ -150,7 +150,7 @@ class Ceshi extends Controller
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
public function clear_data()
|
||||
public function qing_chu_data()
|
||||
{
|
||||
//ip
|
||||
$ip = request()->ip();
|
||||
@@ -211,17 +211,17 @@ class Ceshi extends Controller
|
||||
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
// 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){
|
||||
@@ -458,9 +458,9 @@ class Ceshi extends Controller
|
||||
|
||||
//删除腾讯房间
|
||||
$room = db::name('vs_room')->select();
|
||||
foreach ($room as &$value){
|
||||
model('Tencent')->delete_group('room'.$value['id']);
|
||||
}
|
||||
// foreach ($room as &$value){
|
||||
// // model('Tencent')->delete_group('room'.$value['id']);
|
||||
// }
|
||||
$reslut35 = db::name('vs_room')->where('id','>', 0)->delete();
|
||||
if($reslut35){
|
||||
$i++ ;
|
||||
@@ -772,7 +772,63 @@ class Ceshi extends Controller
|
||||
//数组末尾添加元素
|
||||
array_push($res, '财富等级日志删除失败!');
|
||||
}
|
||||
$reslut68 = db::name('vs_user_friending')->where('id','>', 0)->delete();
|
||||
if($reslut68){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户好友删除失败!');
|
||||
}
|
||||
$reslut69 = db::name('vs_user_friending_heart')->where('id','>', 0)->delete();
|
||||
if($reslut69){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户好友心跳删除失败!');
|
||||
}
|
||||
$reslut70 = db::name('vs_room_hot_value_log')->where('id','>', 0)->delete();
|
||||
if($reslut70){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间热度值日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut71 = db::name('vs_blind_box_turntable_results_log')->where('id','>', 0)->delete();
|
||||
if($reslut71){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '盲盒转盘结果日志删除失败!');
|
||||
}
|
||||
$reslut72 = db::name('vs_blind_box_turntable_log')->where('id','>', 0)->delete();
|
||||
if($reslut72){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '盲盒转盘日志删除失败!');
|
||||
}
|
||||
$reslut73 = db::name('vs_room_pan_xlh')->where('id','>', 0)->delete();
|
||||
if($reslut73){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间寻乐会删除失败!');
|
||||
}
|
||||
$reslut74 = db::name('vs_room_pan_xlh_log')->where('id','>', 0)->delete();
|
||||
if($reslut74){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间寻乐会日志删除失败!');
|
||||
}
|
||||
$reslut75 = db::name('vs_room_pan')->where('id','>', 0)->delete();
|
||||
if($reslut75){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间盘删除失败!');
|
||||
}
|
||||
|
||||
//数据提交
|
||||
db::commit();
|
||||
|
||||
@@ -31,4 +31,22 @@ class Cron
|
||||
$cron = new \app\cron\controller\DaySeconds();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//巡乐会结束 礼物发放
|
||||
public function XlhSend(){
|
||||
$cron = new \app\cron\controller\RoomPan();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//交友房结束
|
||||
public function FriendEnd(){
|
||||
$cron = new \app\cron\controller\FriendEnd();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//房间小时榜发礼物(每小时执行一次)
|
||||
public function RoomHourRanking(){
|
||||
$cron = new \app\cron\controller\RoomHourRanking();
|
||||
$cron->index();
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,8 @@ class Gift extends BaseCom
|
||||
public function get_gift_list()
|
||||
{
|
||||
$label = input('label',0);
|
||||
$reslut = model('Gift')->get_gift_list($label);
|
||||
$room_id = input('room_id',0);
|
||||
$reslut = model('Gift')->get_gift_list($label,$room_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//聊天送礼物 (音信)
|
||||
|
||||
@@ -22,7 +22,6 @@ class Guild extends BaseCom
|
||||
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);
|
||||
|
||||
@@ -20,7 +20,7 @@ class Index extends BaseCom
|
||||
$is_top = input('is_top', 0); //1非置顶2置顶
|
||||
$label_id = input('label_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 15);
|
||||
$page_limit = input('page_limit', 20);
|
||||
|
||||
$reslut = model('Room')->room_list($label_id,$is_top, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data'], $reslut['api_version']);
|
||||
@@ -29,7 +29,7 @@ class Index extends BaseCom
|
||||
//房间类型列表
|
||||
public function room_type_list()
|
||||
{
|
||||
$list = db::name('vs_room_type')->where('status', 1)->field('id,type_name as label_name')->select();
|
||||
$list = db::name('vs_room_type')->where(['status' => 1, 'deletetime' => 0])->field('id,type_name as label_name')->order('sort asc')->select();
|
||||
//给前面添加一组数据
|
||||
array_unshift($list, ['id' => -1, 'label_name' => '热门']);
|
||||
return V(1, '获取成功', $list);
|
||||
|
||||
@@ -49,6 +49,7 @@ class Invited extends BaseCom
|
||||
}
|
||||
$reslut['init_code'] = $init_code ? $init_code:'';
|
||||
$invited_draw = get_system_config_value('invited_draw');
|
||||
$reslut['invited_draw'] = $invited_draw;
|
||||
//说明
|
||||
$reslut['explain'] = '绑定成功后,您每次充值金额的'.$invited_draw.'%'.'将以钻石形式赠送给邀请人,满足提现金额邀请人可以直接提现';
|
||||
return V(1,'操作成功',$reslut);
|
||||
|
||||
@@ -26,18 +26,35 @@ class Payment extends Controller
|
||||
$user_id = input('user_id', 0);
|
||||
$money = input('money', 0);
|
||||
$coin = input('coin', 0);
|
||||
$type_params = input('type_params', 0);
|
||||
$type_id = input('type_id', 0);
|
||||
|
||||
if(!$coin){
|
||||
$coin = $money * get_system_config_value('rmb_coin_ratio');
|
||||
}
|
||||
if (!$user_id) {
|
||||
return V(0, '请选择充值用户', null);
|
||||
}
|
||||
//获取用户的手机号
|
||||
$user_phone = db::name('user')->where(["id" => $user_id])->value('mobile');
|
||||
if(!$user_phone){
|
||||
return V(0, '请先绑定手机号!', null);
|
||||
}
|
||||
//获取用户的实名信息
|
||||
$real_name = db::name('user_auth')->where(["mobile" => $user_phone,'is_real' => 1])->find();
|
||||
if(!$real_name){
|
||||
return V(0, '请先实名认证', null);
|
||||
}
|
||||
//获取用户的年龄
|
||||
if(!getAgeId($real_name['card_id'])){
|
||||
return V(0, '未成年不可充值!', null);
|
||||
}
|
||||
|
||||
if (!is_numeric($money) || floor($money) != $money || $money <= 0 || $money >= 2000) {
|
||||
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 ?? "") . " 余额!";
|
||||
$title = "APP充值到用户". ($user_code ?? "") ."余额!";
|
||||
|
||||
$order_number = $this->createOrderSn();
|
||||
$data['order_sn'] = $order_number;
|
||||
@@ -46,7 +63,9 @@ class Payment extends Controller
|
||||
$data['user_id'] = $user_id;
|
||||
$data['pay_type'] = $type;
|
||||
$data['createtime'] = time();
|
||||
$data['remarke'] = '充值到app用户'.($user_code ?? "") ."余额!";;
|
||||
$data['remarke'] = '充值到app用户'.($user_code ?? "") ."余额!";
|
||||
$data['type_params'] = $type_params;
|
||||
$data['type_id'] = $type_id;
|
||||
|
||||
$re = db::name('vs_user_recharge')->insert($data);
|
||||
if (!$re) {
|
||||
@@ -91,6 +110,7 @@ class Payment extends Controller
|
||||
$where['order_sn']=$out_trade_no;
|
||||
$where['order_type']=1;
|
||||
$where['pay_type']=2;
|
||||
$where['pay_status']=1;
|
||||
|
||||
$data=[
|
||||
'trade_no'=>$trade_no
|
||||
@@ -135,6 +155,7 @@ class Payment extends Controller
|
||||
$where['order_sn']=$out_trade_no;
|
||||
$where['order_type']=1;//1 充值
|
||||
$where['pay_type']=1;//1微信2支付宝 3通联支付宝 4通联微信
|
||||
$where['pay_status']=1;
|
||||
|
||||
$data=[
|
||||
'trade_no'=>$transaction_id
|
||||
@@ -190,6 +211,7 @@ class Payment extends Controller
|
||||
$where['order_sn']=$out_trade_no;
|
||||
$where['order_type']=1;//1 充值
|
||||
$where['pay_type']=$pay_type;//1微信2支付宝 3通联支付宝 4通联微信
|
||||
$where['pay_status']=1;
|
||||
|
||||
$data=[
|
||||
'trade_no'=>$trade_no
|
||||
@@ -211,21 +233,18 @@ class Payment extends Controller
|
||||
* 云账户回调(提现)
|
||||
*/
|
||||
public function yun_callback(){
|
||||
$data = input("data", "");
|
||||
$mess = input("mess", "");
|
||||
$timestamp = input("timestamp", "");
|
||||
$sign = input("sign", "");
|
||||
$log_data = [
|
||||
"data"=>$data,
|
||||
"mess"=>$mess,
|
||||
"timestamp"=>$timestamp,
|
||||
"sign"=>$sign
|
||||
];
|
||||
Log::record("云账户回调信息".json_encode($log_data),"info");
|
||||
// $data = input("data", "");
|
||||
// $mess = input("mess", "");
|
||||
// $timestamp = input("timestamp", "");
|
||||
// $sign = input("sign", "");
|
||||
$data = $_POST['data']??"";
|
||||
$mess = $_POST['mess']??"";
|
||||
$timestamp = $_POST['timestamp']?? "";
|
||||
$sign = $_POST['sign']??"";
|
||||
|
||||
write_log_redis("yunzhanghu_huidiao_原始数据",$_POST);
|
||||
$yun_pay = new YunPay();
|
||||
$result = $yun_pay->yun_callback($data,$mess,$timestamp,$sign);
|
||||
echo 'success';
|
||||
die;
|
||||
if($result['code']==1){
|
||||
$data = $result['data'];
|
||||
if($data){
|
||||
|
||||
@@ -149,14 +149,29 @@ class Room extends BaseCom
|
||||
//直播间送礼
|
||||
public function room_give_gift()
|
||||
{
|
||||
$key_name = "api:room:gift:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$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);
|
||||
$heart_id = input('heart_id', 0);
|
||||
|
||||
$reslut = model('Room')->room_gift($this->uid, $to_uid, $gift_id, $gift_num, $type, $room_id, $pit_number);
|
||||
$reslut = model('Room')->room_gift($this->uid, $to_uid, $gift_id, $gift_num, $type, $room_id, $pit_number,$heart_id);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//房间送礼 背包一键全清
|
||||
public function room_gift_all_clear()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$to_uid = input('to_uid', 0);//收礼人ID
|
||||
$heart_id = input('heart_id', 0);//交友
|
||||
$auction_id = input('auction_id');//竞拍
|
||||
$reslut = model('Room')->room_gift_all_clear($this->uid, $room_id, $to_uid,$heart_id,$auction_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
@@ -260,7 +275,7 @@ class Room extends BaseCom
|
||||
public function change_room_type()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-点唱,2-拍卖,3-男神,4-女神
|
||||
$type = input('type', 1);//1-点唱,2-拍卖,3-男神,4-女神,7-交友
|
||||
$reslut = model('Room')->change_room_type($this->uid, $room_id, $type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -406,4 +421,43 @@ class Room extends BaseCom
|
||||
$reslut = model('Room')->room_online_list($room_id, $page, $limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//房间用户当前魅力值列表
|
||||
public function room_user_charm_list()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$user_id = input('user_id', '');
|
||||
$reslut = model('Room')->room_user_charm_list($room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
// //创建房间
|
||||
// public function create_rooms()
|
||||
// {
|
||||
// //查询所有的房间信息
|
||||
// $room = db::name('vs_room')->field('id,user_id')->where(['room_status' => ['<>',3]])->select();
|
||||
// $i = 0;
|
||||
// foreach ($room as $value) {
|
||||
// $reslut = model('Tencent')->create_group($value['user_id'],'room'.$value['id']);
|
||||
// $i++;
|
||||
// }
|
||||
// return['code' => 1, 'msg' => '成功创建了'.$i.'个房间', 'data' => null];
|
||||
// }
|
||||
|
||||
//用户重连
|
||||
public function user_reconnect()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$reslut = model('Room')->user_reconnect($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//用户在房间内切后台保留机制
|
||||
public function user_in_room_background()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-切后台,2-切前台
|
||||
$reslut = model('Room')->user_in_room_background($this->uid, $room_id,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ class RoomPit extends BaseCom
|
||||
//申请上麦
|
||||
public function apply_pit()
|
||||
{
|
||||
$key_name = "api:room:apply_pit:" . $this->uid;
|
||||
|
||||
$room_id = input('room_id', 0);
|
||||
$pit_number = input('pit_number', 0);
|
||||
if($room_id == 0){
|
||||
@@ -19,27 +21,19 @@ class RoomPit extends BaseCom
|
||||
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){
|
||||
redis_lock_exits($key_name);
|
||||
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8))|| $room_type == 2 || $room_type == 7){
|
||||
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id,$pit_number);
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
||||
$reslut = model('RoomSong')->apply_kpit($this->uid, $room_id,$pit_number);
|
||||
}else{
|
||||
redis_unlocks($key_name);
|
||||
return V(0, '房间不存在', null);
|
||||
}
|
||||
redis_unlocks($key_name);
|
||||
//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);
|
||||
|
||||
@@ -113,9 +107,9 @@ class RoomPit extends BaseCom
|
||||
}
|
||||
$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){
|
||||
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)) || $room_type == 2 || $room_type == 7){
|
||||
$reslut = model('RoomPit')->DownPit($this->uid, $room_id,$pit_number);
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
||||
$reslut = model('RoomSong')->down_kpit($this->uid, $room_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class RoomSong extends BaseCom
|
||||
public function up_song(){
|
||||
$room_song_id = input('did');
|
||||
$type = input('type');//1上移,2置顶
|
||||
$res = model('RoomSong')->up_song($room_song_id,$type);
|
||||
$res = model('RoomSong')->up_song($this->uid,$room_song_id,$type);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,12 +35,16 @@ class Search extends BaseCom
|
||||
if(is_numeric($search)){
|
||||
$where = [
|
||||
'room_number' => $search,
|
||||
'apply_status' => 2
|
||||
'apply_status' => 2,
|
||||
'type_id' => ['<>',6],
|
||||
'room_status' => 1
|
||||
];
|
||||
}else{
|
||||
$where = [
|
||||
'room_name' => ['like', '%'.$search . '%'],
|
||||
'apply_status' => 2
|
||||
'apply_status' => 2,
|
||||
'type_id' => ['<>',6],
|
||||
'room_status' => 1
|
||||
];
|
||||
}
|
||||
|
||||
@@ -96,4 +100,59 @@ class Search extends BaseCom
|
||||
|
||||
return V(1, '获取成功', $lists);
|
||||
}
|
||||
|
||||
|
||||
//搜索
|
||||
public function search_list()
|
||||
{
|
||||
$search = input('search', '');
|
||||
|
||||
if(is_numeric($search)){
|
||||
$where = [
|
||||
'user_code' => $search,
|
||||
'status' => 1
|
||||
];
|
||||
$where1 = [
|
||||
'room_number' => $search,
|
||||
'apply_status' => 2,
|
||||
'type_id' => ['<>',6],
|
||||
'room_status' => 1
|
||||
];
|
||||
}else{
|
||||
$where = [
|
||||
'nickname' => ['like', '%'.$search . '%'],
|
||||
'status' => 1
|
||||
];
|
||||
$where1 = [
|
||||
'room_name' => ['like', '%'.$search . '%'],
|
||||
'apply_status' => 2,
|
||||
'type_id' => ['<>',6],
|
||||
'room_status' => 1
|
||||
];
|
||||
}
|
||||
|
||||
$users = db::name('user')->field('id as user_id,nickname,avatar,user_code,sex')->where($where)->select();
|
||||
|
||||
if(isset($users)){
|
||||
foreach ($users as &$v){
|
||||
$v['room_id'] = 0;
|
||||
//是否在房间
|
||||
$is_room = db::name('vs_room_visitor')->where(['user_id' => $v['user_id'], 'is_delete' => 1])->order('id desc')->value('room_id');
|
||||
if ($is_room) {
|
||||
$v['room_id'] = $is_room;
|
||||
}
|
||||
$v['icon'][0] = model('UserData')->user_wealth_icon($v['user_id']);//财富图标
|
||||
$v['icon'][1] = model('UserData')->user_charm_icon($v['user_id']);//魅力图标
|
||||
}
|
||||
}
|
||||
|
||||
$rooms = db::name('vs_room')->field('id as room_id,room_name,room_cover,room_number,label_id,today_hot_value')->where($where1)->select();
|
||||
if(isset($rooms)){
|
||||
foreach ($rooms as $vv){
|
||||
$vv['label_icon'] = db::name('vs_room_label')->where('id', $vv['label_id'])->value('label_icon');
|
||||
$vv['hot_value'] = $vv['today_hot_value'];
|
||||
}
|
||||
}
|
||||
return V(1, '获取成功', ['users' => $users, 'rooms' => $rooms]);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Db;
|
||||
|
||||
class UpDataAv extends \think\Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$users = db::name('user')->field('id,nickname,avatar')->where(['status' => ['<>',0],'is_robot' => 0])->select();
|
||||
$num = count($users);
|
||||
$n = 0;
|
||||
$m = 0;
|
||||
if($users){
|
||||
foreach ($users as $user){
|
||||
if($n >= 50){
|
||||
sleep(1);
|
||||
}
|
||||
$user_id = $user['id'];
|
||||
$member_name = $user['nickname'];
|
||||
$member_face_url = $user['avatar'];
|
||||
$res = model('api/Tencent')->modify_user_infos($user_id, $member_name, $member_face_url);
|
||||
if($res['code'] == 1){
|
||||
echo '更新用户信息成功:'.$user_id.'<br>';
|
||||
$n++;
|
||||
}else{
|
||||
echo '更新用户信息失败:'.$user_id.'<br>';
|
||||
$m++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return '更新完成!总共:'.$num.'有效 用户,更新了:'.$n.'个用户信息.失败了:'.$m.'个用户信息.';
|
||||
}
|
||||
}
|
||||
@@ -234,6 +234,15 @@ class User extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//关注房间(红包专用)
|
||||
public function follow_room()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-收藏,0-取消收藏
|
||||
$reslut = model('user')->follow_room($this->uid, $room_id,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//用户关系卡(亲密拍)、关系位(真爱拍)
|
||||
public function user_cp_list()
|
||||
{
|
||||
|
||||
@@ -24,13 +24,21 @@ class UserGiftPack extends BaseCom
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//获取背包礼物列表总值
|
||||
public function get_gift_pack_list_count()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('UserGiftPack')->get_gift_pack_list_count($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);
|
||||
$reslut = model('UserGiftPack')->income_user_gift_pack($user_id,$page,$page_limit);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
@@ -40,7 +48,7 @@ class UserGiftPack extends BaseCom
|
||||
$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);
|
||||
$reslut = model('UserGiftPack')->get_gift_pack_outcome($user_id,$page,$page_limit);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ return [
|
||||
'该装扮天数不存在' => '该装扮天数不存在',
|
||||
'该个人靓号已被购买' => '该个人靓号已被购买',
|
||||
'该房间靓号已被购买' => '该房间靓号已被购买',
|
||||
'该工会靓号已被购买' => '该工会靓号已被购买',
|
||||
'该公会靓号已被购买' => '该公会靓号已被购买',
|
||||
'用户信息错误' => '用户信息错误',
|
||||
'非法资金类型' => '非法资金类型',
|
||||
'当前用户金币已达上限' => '当前用户金币已达上限',
|
||||
|
||||
@@ -25,7 +25,8 @@ class Activities extends Model
|
||||
public static function first_charge_gift_send($user_id,$money=0)
|
||||
{
|
||||
//礼包
|
||||
$gift_bag_id = DB::name('vs_gift_bag')->where(['activities_id'=>1,'status'=>1,'money'=>$money])->value('id');
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>1,'status'=>1,'delete_time'=>0,'money'=>['<=',$money]])->order('money desc')->find();
|
||||
$gift_bag_id = $gift_bag['id'] ?? 0;
|
||||
if (!$gift_bag_id) {
|
||||
return ['code' => 0, 'msg' => '礼包不存在','data' => null];
|
||||
}
|
||||
@@ -98,14 +99,19 @@ class Activities extends Model
|
||||
/*
|
||||
* 天降好礼发放
|
||||
*/
|
||||
public static function drop_gift_send($user_id)
|
||||
public static function drop_gift_send($user_id,$money=0)
|
||||
{
|
||||
$activities_id = 3;
|
||||
//礼包
|
||||
$gift_bag_id = DB::name('vs_gift_bag')->where(['activities_id'=>$activities_id,'status'=>1])->value('id');
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>$activities_id,'status'=>1])->find();
|
||||
$gift_bag_id = $gift_bag['id'] ?? 0;
|
||||
|
||||
if (!$gift_bag_id) {
|
||||
return ['code' => 0, 'msg' => '礼包不存在','data' => null];
|
||||
}
|
||||
if($money != $gift_bag['money']){
|
||||
return ['code' => 0, 'msg' => '充值金额未命中天降好礼礼包','data' => null];
|
||||
}
|
||||
$gift_bag_detail = DB::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$gift_bag_id])->select();
|
||||
if (!$gift_bag_detail) {
|
||||
return ['code' => 0, 'msg' => '礼包不存在','data' => null];
|
||||
@@ -136,15 +142,20 @@ class Activities extends Model
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
// 记录日志
|
||||
//添加礼盒记录
|
||||
$reslut = Db::name('vs_gift_bag_receive_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'parent_id' => $v['id'],
|
||||
'gift_id'=> $v['foreign_id'],
|
||||
'num' => $v['quantity'],
|
||||
'bag_price' => $gift_bag['money'],
|
||||
'gift_price' => $v['gold'],
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
}
|
||||
// 记录日志
|
||||
//添加礼盒记录
|
||||
$reslut = Db::name('vs_gift_bag_receive_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
// 添加活动记录
|
||||
$reslut = Db::name('vs_activities_receive')->insert([
|
||||
'user_id' => $user_id,
|
||||
@@ -160,4 +171,85 @@ class Activities extends Model
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 新人好礼发放
|
||||
*/
|
||||
public static function new_charge_gift_send($user_id,$money=0)
|
||||
{
|
||||
//礼包
|
||||
$activities_id = 7;
|
||||
$gift_bag = DB::name('vs_gift_bag')->where(['activities_id'=>$activities_id,'status'=>1,'delete_time'=>0,'money'=>$money])->order('money desc')->find();
|
||||
$gift_bag_id = $gift_bag['id'] ?? 0;
|
||||
if (!$gift_bag_id) {
|
||||
return ['code' => 0, 'msg' => '礼包不存在','data' => null];
|
||||
}
|
||||
$gift_bag_detail = DB::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$gift_bag_id])->select();
|
||||
if (!$gift_bag_detail) {
|
||||
return ['code' => 0, 'msg' => '礼包未配置','data' => null];
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach ($gift_bag_detail as $k=>$v){
|
||||
$gift_id =0;
|
||||
$gift_price = 0;
|
||||
$gift_num = $v['quantity'];
|
||||
switch ($v['type']) {
|
||||
case 1: //金币 方法1:直接添加到用户钱包
|
||||
$gift_price = $v['quantity'];
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $v['quantity'], model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::NEW_USER_CHARGE_GIFT,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::NEW_USER_CHARGE_GIFT));
|
||||
break;
|
||||
case 2: //礼物 方法2:添加到用户礼物背包
|
||||
$gift_id = $v['foreign_id'];
|
||||
$res = model('UserGiftPack')->change_user_gift_pack($user_id,$v['foreign_id'],$v['quantity'],model('UserGiftPack')::NEW_CHARGE_GIFT,"新人好礼获得礼物");
|
||||
break;
|
||||
case 3: //坐骑 方法3:添加到用户装扮
|
||||
$gift_id = $v['foreign_id'];
|
||||
$decorate_price_info = db::name('vs_decorate_price')->where(['id'=>$v['foreign_id']])->find();
|
||||
if(empty($decorate_price_info)){
|
||||
break;
|
||||
}
|
||||
$gift_price = $decorate_price_info['price'];
|
||||
$res = model('Decorate')->pay_decorate($user_id,$decorate_price_info['did'],$decorate_price_info['day'],8);
|
||||
break;
|
||||
case 4: //道具 方法5:钻石
|
||||
$gift_price = $v['quantity'];
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $v['quantity'], model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::NEW_USER_CHARGE_GIFT,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::NEW_USER_CHARGE_GIFT));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ($res['code'] != 1) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
// 记录日志
|
||||
//添加礼盒记录
|
||||
$reslut = Db::name('vs_gift_bag_receive_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'parent_id' => $v['id'],
|
||||
'gift_id'=> $v['foreign_id'],
|
||||
'num' => $v['quantity'],
|
||||
'bag_price' => $gift_bag['money'],
|
||||
'gift_price' => $v['gold'],
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
}
|
||||
// 添加活动记录
|
||||
$reslut = Db::name('vs_activities_receive')->insert([
|
||||
'user_id' => $user_id,
|
||||
'activities_id' => 1,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => null];
|
||||
}catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ class Banner extends Model
|
||||
{
|
||||
protected $table = 'fa_vs_banner';
|
||||
public $ShowType = [
|
||||
// 1 => '引导页',
|
||||
// 2 => '启动页',
|
||||
1 => '引导页',
|
||||
2 => '启动页',
|
||||
3 => '首页轮播图',
|
||||
4 => '工会',
|
||||
5 => '帮助反馈'
|
||||
4 => '房间首页',
|
||||
5 => '工会列表页广告位'
|
||||
];
|
||||
//1纯展示 2文章 3房间 4个人主页 5外站'
|
||||
public $Type = [
|
||||
|
||||
@@ -89,6 +89,41 @@ class Chat extends Model
|
||||
// RoomAuctionPK = 1037,
|
||||
//送盲盒礼物推送文字消息
|
||||
// RoomGiftBlindBox = 1038,
|
||||
//换麦
|
||||
// RoomChangePit = 1039,
|
||||
|
||||
//交友房间内发送消息
|
||||
//交友房游戏阶段
|
||||
// FriendRoomGameStart = 1049,
|
||||
//交友房延时
|
||||
// FriendRoomDelay = 1050,
|
||||
//交友结束推送是否创建小房间
|
||||
// FriendRoomEnd = 1051,
|
||||
//交友房 私密小屋送礼增加结束时间
|
||||
// FriendRoomGiftBlindBox = 1052,
|
||||
//交友 房间换麦位
|
||||
// FriendRoomChangePit = 1053,
|
||||
//交友 心动值变化
|
||||
// FriendRoomChangeCharm = 1054,
|
||||
//交友 退出小房间
|
||||
// FriendRoomQuit = 1055,
|
||||
|
||||
//盲盒转盘相关推送
|
||||
//巡乐会进度推送
|
||||
// BlindBoxTurnTableProgress = 1056,
|
||||
//巡乐会抽奖结果推送
|
||||
// BlindBoxTurnTableResult = 1057,
|
||||
|
||||
//直播群成员在离线状态变更
|
||||
// RoomMemberOffline = 1058,
|
||||
|
||||
//清空个人魅力
|
||||
// ClearUserCharm = 1059,
|
||||
//发红包
|
||||
// RedPacket = 1060,
|
||||
//红包领完推送
|
||||
// RedPacketComplete = 1061,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -135,13 +135,13 @@ class DailyTasks extends Model
|
||||
$v['processing_type'] = 2;
|
||||
$v['processing_type_str'] = $this->processing_type_str[$v['processing_type']];
|
||||
//跳转的房间路径
|
||||
$v['from_id'] = db::name('vs_room')->where(['delete_time'=>0,'room_status'=>1,'type_id'=>['<>',6]])->orderRaw('rand()')->value('id');
|
||||
$v['from_id'] = db::name('vs_room')->where(['delete_time'=>0,'room_status'=>1,'type_id'=>['<>',6],'apply_status'=>2])->orderRaw('rand()')->value('id');
|
||||
$v['target_quantity'] = $v['target_quantity'] * 60;
|
||||
$v['is_time'] = 1;
|
||||
}elseif(in_array($v['task_id'],[10])){
|
||||
$v['processing_type'] = 7;
|
||||
$v['processing_type_str'] = $this->processing_type_str[$v['processing_type']];
|
||||
$v['from_id'] = db::name('vs_room')->where(['delete_time'=>0,'room_status'=>1,'type_id'=>['<>',6]])->orderRaw('rand()')->value('id');
|
||||
$v['from_id'] = db::name('vs_room')->where(['delete_time'=>0,'room_status'=>1,'type_id'=>['<>',6],'apply_status'=>2])->orderRaw('rand()')->value('id');
|
||||
} else{
|
||||
$v['processing_type'] = 9;
|
||||
$v['processing_type_str'] = $this->processing_type_str[$v['processing_type']];
|
||||
@@ -342,10 +342,10 @@ class DailyTasks extends Model
|
||||
public function gift_bag_receive_list($user_id){
|
||||
//查询每日任务礼盒记录
|
||||
$gift_bag_receive_list = Db::name('vs_gift_bag_receive_log')
|
||||
->field('bag.name as gift_bag_name,de.name as gift_name,re.createtime as createtime,de.quantity,de.type,de.foreign_id,de.days,de.gold')
|
||||
->field('bag.name as gift_bag_name,re.createtime as createtime,de.name as gift_name,de.quantity,de.type,de.foreign_id,de.days,de.gold')
|
||||
->alias('re')
|
||||
->join('vs_gift_bag bag', 'bag.id = re.gift_bag_id', 'LEFT')
|
||||
->join('vs_gift_bag_detail de', 'de.gift_bag_id = re.gift_bag_id','LEFT')
|
||||
->join('vs_gift_bag_detail de', 'de.id = re.parent_id', 'LEFT')
|
||||
->where(['re.user_id'=>$user_id,'bag.activities_id'=>2,'bag.status'=>1])
|
||||
->order('re.createtime desc')
|
||||
->select();
|
||||
|
||||
@@ -15,9 +15,9 @@ class Decorate extends Model
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
// 定义字段类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8工会靓号
|
||||
public $TypeArray = [1=>'头像框',2=>'坐骑',3=>'麦圈',6=>'个人靓号',7=>'房间靓号',8=>'工会靓号'];
|
||||
protected $FromType = [1=>'购买',2=>'后台赠送',3=>'礼盒开奖',4=>'好友赠送',5=>'首充赠送',6=>'天降好礼获得',7=>'财富等级特权赠送'];
|
||||
// 定义字段类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8公会靓号
|
||||
public $TypeArray = [1=>'头像框',2=>'坐骑',3=>'麦圈',6=>'个人靓号',7=>'房间靓号',8=>'公会靓号'];
|
||||
protected $FromType = [1=>'购买',2=>'后台赠送',3=>'礼盒开奖',4=>'好友赠送',5=>'首充赠送',6=>'天降好礼获得',7=>'财富等级特权赠送',8=>'新人充值好礼'];
|
||||
public function __construct($data = [])
|
||||
{
|
||||
parent::__construct($data);
|
||||
@@ -125,7 +125,6 @@ class Decorate extends Model
|
||||
$map = [];
|
||||
$map = [
|
||||
'did' => $did,
|
||||
'is_buy' => 1,
|
||||
'delete_time' => 0,
|
||||
];
|
||||
$decorate_info = DB::name($this->table)->where($map)->find();
|
||||
@@ -150,7 +149,7 @@ class Decorate extends Model
|
||||
return ['code' => 0, 'msg' => '该房间靓号已被购买', 'data' => null];
|
||||
}
|
||||
if($decorate_info['type'] == 8 && $decorate_info['is_user_buy'] == 1){
|
||||
return ['code' => 0, 'msg' => '该工会靓号已被购买', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '该公会靓号已被购买', 'data' => null];
|
||||
}
|
||||
$start_time = $now_time = time();
|
||||
Db::startTrans();
|
||||
@@ -207,6 +206,9 @@ class Decorate extends Model
|
||||
if($decorate_price_info['price']<=0 && $user_decorate_data['end_time'] > $now_time + $change_time){
|
||||
return ['code' => 0, 'msg' => '您已购买过此装扮,请勿重复购买', 'data' => null];
|
||||
}
|
||||
if($user_decorate_data['end_time'] < $now_time){
|
||||
$user_decorate_data['end_time'] = 0;
|
||||
}
|
||||
$change_time = $day * 24 * 3600;
|
||||
$update['is_using'] = 2;
|
||||
$update['end_time'] = $user_decorate_data['end_time'] + $change_time;
|
||||
@@ -368,7 +370,7 @@ class Decorate extends Model
|
||||
//用户装扮详情
|
||||
/*
|
||||
* @param $id 对象id
|
||||
* @param $type 装扮类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8工会靓号
|
||||
* @param $type 装扮类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8公会靓号
|
||||
*/
|
||||
public function user_decorate_detail($id, $type){
|
||||
//根据$type 组装查询条件
|
||||
|
||||
@@ -19,7 +19,7 @@ class Gift extends Model
|
||||
//获取礼物类型
|
||||
public function get_gift_label()
|
||||
{
|
||||
$giftTypeData = db::name('vs_gift_label')->where('delete_time',0)->order("sort asc,id desc")->select();
|
||||
$giftTypeData = db::name('vs_gift_label')->where('delete_time',0)->where('tid',1)->order("sort asc,id desc")->select();
|
||||
foreach ($giftTypeData as $key => $value) {
|
||||
$giftType[$key]['id'] = $value['id'];
|
||||
$giftType[$key]['name'] = $value['name'];
|
||||
@@ -28,7 +28,7 @@ class Gift extends Model
|
||||
}
|
||||
|
||||
//拉去礼物列表
|
||||
public function get_gift_list($label=0)
|
||||
public function get_gift_list($label=0,$room_id=0)
|
||||
{
|
||||
$map['delete_time'] = 0;
|
||||
$where['is_show'] = 1;
|
||||
@@ -39,30 +39,42 @@ class Gift extends Model
|
||||
$gift_price = get_system_config_value('room_love_auction_cion');
|
||||
$where['gift_price'] = ['>',$gift_price];
|
||||
}
|
||||
$is_open_blind_box_turntable = 0;
|
||||
if($room_id){
|
||||
$is_open_blind_box_turntable = Db::name('vs_room')->where(['id'=>$room_id])->value('is_open_blind_box_turntable');
|
||||
}
|
||||
$list = $this->field('gid as gift_id,gift_name,base_image,gift_price')->where($map)->where($where)->order('sort asc, gift_price asc')->select();
|
||||
|
||||
if($label==2){
|
||||
$list_data = [];
|
||||
foreach ($list as &$v) {
|
||||
//获取盲盒列表
|
||||
$box_list = Db::name('vs_gift_bag')->where(['status'=>1])->where('activities_id',4)->select();
|
||||
$box_list = Db::name('vs_gift_bag')->where(['status'=>1])->where(['activities_id'=>["in",[4,5]]])->select();
|
||||
foreach ($box_list as $key =>$box) {
|
||||
$ext = json_decode($box['ext'],true);
|
||||
if ($ext['gift_id'] == $v['gift_id']) {
|
||||
$v['gift_bag_name'] = $box['name'];
|
||||
$v['rule'] = $ext['description'];
|
||||
$v['rule_url'] = get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$box["id"];
|
||||
$v['activities_id'] = $box['activities_id'];
|
||||
$v['gift_bag'] = $box['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($list as $gift) {
|
||||
if($is_open_blind_box_turntable == 1){
|
||||
$list_data[] = $gift;
|
||||
}else{
|
||||
if(isset($gift['activities_id']) && $gift['activities_id'] == 4){
|
||||
$list_data[] = $gift;
|
||||
}
|
||||
}
|
||||
}
|
||||
usort($list_data, function($a, $b) {
|
||||
return $a['gift_id'] <=> $b['gift_id'];
|
||||
});
|
||||
$list = $list_data;
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
|
||||
/*
|
||||
* 盲盒规则链接
|
||||
*/
|
||||
public function get_gift_box_rule($box_id){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,12 @@ class GiveGift extends Model
|
||||
* @return array
|
||||
* 用户,在房间中,给谁,送了什么礼物,多少个,来源
|
||||
*/
|
||||
public function give_gift($uid,$to_uid,$gid,$num,$from_type,$type,$from_id = 0,$pit_number = 0,$change_type = 0)
|
||||
public function give_gift($uid,$to_uid,$gid,$num,$from_type,$type,$from_id = 0,$pit_number = 0,$change_type = 0,$ext = [])
|
||||
{
|
||||
if(isset($ext['is_draw_gift']) && $ext['is_draw_gift'] == 1) {
|
||||
$return_pan = $this->give_gift_to_pan($uid, $to_uid, $gid, $num, $from_type, $type, $from_id, $pit_number, $change_type, $ext);
|
||||
return $return_pan;
|
||||
}
|
||||
//送的礼物信息
|
||||
$gift_info = Db::name('vs_gift')->where(['gid'=>$gid])
|
||||
->field('gid as gift_id,gift_name,gift_price,file_type,base_image,play_image,gift_type,label,is_public_server')->find();
|
||||
@@ -79,24 +83,26 @@ class GiveGift extends Model
|
||||
}
|
||||
//金币购买送礼 1金币购买 2送背包礼物
|
||||
if ($type == 1) {
|
||||
//送给所有人的总价格
|
||||
$all_gift_price = $gift_info['gift_price'] * $num * count($toarray);
|
||||
//判断是否有足够的金币
|
||||
$user_waller = db::name('user_wallet')->where(['user_id'=>$uid])->find();
|
||||
if ($user_waller['coin'] < $all_gift_price) {
|
||||
return ['code' => 0, 'msg' => '用户金币不足', 'data' => null];
|
||||
}
|
||||
//扣除用户金币并记录日志
|
||||
$wallet_update = $this -> change_user_cion_or_earnings_log($uid,$all_gift_price,$from_id,1,10,'用户金币购买礼物');
|
||||
if(!$wallet_update){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '扣除用户金币失败', 'data' => null];
|
||||
}
|
||||
//用户财富等级更新
|
||||
$user_level = model('Level')->user_level_data_update($uid,$all_gift_price,1,$roomId);
|
||||
if(!$user_level){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null];
|
||||
if(!isset($ext['is_draw_gift']) || $ext['is_draw_gift'] != 1){// 非盲盒转盘
|
||||
//送给所有人的总价格
|
||||
$all_gift_price = $gift_info['gift_price'] * $num * count($toarray);
|
||||
//判断是否有足够的金币
|
||||
$user_waller = db::name('user_wallet')->where(['user_id'=>$uid])->find();
|
||||
if ($user_waller['coin'] < $all_gift_price) {
|
||||
return ['code' => 0, 'msg' => '用户金币不足', 'data' => null];
|
||||
}
|
||||
//扣除用户金币并记录日志
|
||||
$wallet_update = $this -> change_user_cion_or_earnings_log($uid,$all_gift_price,$from_id,1,10,'用户金币购买礼物');
|
||||
if(!$wallet_update){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '扣除用户金币失败', 'data' => null];
|
||||
}
|
||||
//用户财富等级更新
|
||||
$user_level = model('Level')->user_level_data_update($uid,$all_gift_price,1,$roomId);
|
||||
if(!$user_level){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//背包礼物是否充足
|
||||
@@ -127,28 +133,43 @@ class GiveGift extends Model
|
||||
//循环送礼
|
||||
$gift_total = 0;
|
||||
$give_gift = 0;
|
||||
foreach ($toarray as $to_id){
|
||||
$gift_user_data = [];
|
||||
foreach ($toarray as $k => $to_id){
|
||||
$gift_user_data[]['user_id'] = $to_id;
|
||||
$gift_box1 = [];
|
||||
$gift_box = [];
|
||||
//查询礼物是否是盲盒
|
||||
if($gift_info['label'] == 2){//趣味礼物(盲盒)
|
||||
$gift_price_box = 0;
|
||||
for($i = 0; $i < $num; $i++){
|
||||
$gift_box1[$i] = $this -> open_box($gid,$uid,$to_id,$from_id);
|
||||
if($gift_box1[$i]['code'] != 1){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '盲盒配置有误请联系管理员'.$gift_box1[$i]['msg'], 'data' => null];
|
||||
}
|
||||
$gift_box[$i] = $gift_box1[$i]['data'];
|
||||
//记录一下收礼记录
|
||||
$give_gift = $this -> change_user_give_gift_log($uid,$gift_box[$i]['gift_id'],$gift_box[$i]['gift_price'],1,$to_id,$from_type,$type,$from_id,$pit_number,2);
|
||||
if(isset($ext['is_draw_gift']) && $ext['is_draw_gift'] == 1){
|
||||
//收礼记录行为日志
|
||||
$give_gift = $this -> change_user_give_gift_log($uid,$ext['gift_id'],$ext['all_gift_price'],$ext['count'],$to_id,$from_type,$type,$from_id,$pit_number,2);
|
||||
if(!$give_gift){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '送礼失败', 'data' => null];
|
||||
}
|
||||
$gift_box[$i]['give_gift_id'] = $give_gift;
|
||||
$gift_price_box += $gift_box[$i]['gift_price'];
|
||||
Log::record("盲盒礼物".json_encode($gift_box1),"info");
|
||||
$gift_price_box = $ext['all_gift_price'];
|
||||
$gift_box[0]['gift_id'] = $ext['gift_id'];
|
||||
$gift_box[0]['gift_price'] = $ext['all_gift_price'];
|
||||
$gift_box[0]['give_gift_id'] = $give_gift;
|
||||
}else{
|
||||
for($i = 0; $i < $num; $i++){
|
||||
$gift_box1[$i] = $this -> open_box($gid,$uid,$to_id,$from_id);
|
||||
if($gift_box1[$i]['code'] != 1){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '盲盒配置有误请联系管理员'.$gift_box1[$i]['msg'], 'data' => null];
|
||||
}
|
||||
$gift_box[$i] = $gift_box1[$i]['data'];
|
||||
//记录一下收礼记录
|
||||
$give_gift = $this -> change_user_give_gift_log($uid,$gift_box[$i]['gift_id'],$gift_box[$i]['gift_price'],1,$to_id,$from_type,$type,$from_id,$pit_number,2);
|
||||
if(!$give_gift){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '送礼失败', 'data' => null];
|
||||
}
|
||||
$gift_box[$i]['give_gift_id'] = $give_gift;
|
||||
$gift_price_box += $gift_box[$i]['gift_price'];
|
||||
Log::record("盲盒礼物".json_encode($gift_box1),"info");
|
||||
}
|
||||
}
|
||||
$gift_total += $gift_price_box;
|
||||
$gift_price = $gift_price_box;
|
||||
@@ -161,6 +182,7 @@ class GiveGift extends Model
|
||||
return ['code' => 0, 'msg' => '送礼失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
$gift_user_data[$k]['gift_price'] = $gift_price;
|
||||
|
||||
//计算收礼人得益
|
||||
$receiver_earnings = $this -> receiver_earnings($to_id,$gift_price,$from_type);
|
||||
@@ -227,14 +249,14 @@ class GiveGift extends Model
|
||||
}else{
|
||||
$room_owner = Db::name('vs_room')->where(['id'=>$from_id,'apply_status'=>2])->value('user_id');
|
||||
//计算房主收益//room_author_ratio
|
||||
$room_owner_earnings = $this -> receiver_earnings($room_owner,$gift_price,99);
|
||||
$room_owner_earnings = $this -> receiver_earnings($room_owner,$gift_price,99);//结果是钻石
|
||||
if($room_owner_earnings > 0){
|
||||
//主持人收益
|
||||
//在主持位的主持人
|
||||
$host_id = Db::name('vs_room_pit')->where(['room_id'=>$from_id,'pit_number'=>9])->value('user_id');
|
||||
if($host_id){
|
||||
//计算主持人收益
|
||||
$host_earnings = $this -> receiver_earnings($host_id,$room_owner_earnings,98,$from_id);
|
||||
$host_earnings = $this -> receiver_earnings($host_id,$room_owner_earnings*get_system_config_value('rmb_coin_ratio'),98,$from_id);
|
||||
if($host_earnings > 0){
|
||||
//增加主持人收益并记录日志
|
||||
$host_earnings_earning = $this -> change_user_cion_or_earnings_log($host_id,$host_earnings,$from_id,2,19,'主持人收益');
|
||||
@@ -244,11 +266,14 @@ class GiveGift extends Model
|
||||
}
|
||||
//增加房主收益并记录日志
|
||||
$room_owner_earningss = $room_owner_earnings - $host_earnings;
|
||||
$room_owner_earning = $this -> change_user_cion_or_earnings_log($room_owner,$room_owner_earningss,$from_id,2,18,'房主收益');
|
||||
if(!$room_owner_earning){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '房主收益失败', 'data' => null];
|
||||
if($room_owner_earningss > 0){
|
||||
$room_owner_earning = $this -> change_user_cion_or_earnings_log($room_owner,$room_owner_earningss,$from_id,2,18,'房主收益');
|
||||
if(!$room_owner_earning){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '房主收益失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
//增加房主收益并记录日志
|
||||
$room_owner_earning = $this -> change_user_cion_or_earnings_log($room_owner,$room_owner_earnings,$from_id,2,18,'房主收益');
|
||||
@@ -257,6 +282,13 @@ class GiveGift extends Model
|
||||
return ['code' => 0, 'msg' => '房主收益失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//增加房主收益并记录日志
|
||||
$room_owner_earning = $this -> change_user_cion_or_earnings_log($room_owner,$room_owner_earnings,$from_id,2,18,'房主收益');
|
||||
if(!$room_owner_earning){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '房主收益失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,7 +317,9 @@ class GiveGift extends Model
|
||||
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
||||
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
||||
$app_earning = coin_earning($gv['gift_price'], $app_ratio);
|
||||
$gift_rate = $this->change_give_gift_profit($gv['give_gift_id'], $ratio, $receiver_earnings, $configs['room_author_ratio'], $room_owner_earnings, $app_ratio, $app_earning);
|
||||
$receiver_earningss = $this -> receiver_earnings($to_id,$gv['gift_price'],$from_type);
|
||||
$room_owner_earningss = $this -> receiver_earnings($room_owner,$gv['gift_price'],99);//结果是钻石
|
||||
$gift_rate = $this->change_give_gift_profit($gv['give_gift_id'], $ratio, $receiver_earningss, $configs['room_author_ratio'], $room_owner_earningss, $app_ratio, $app_earning);
|
||||
if (!$gift_rate) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
||||
@@ -365,136 +399,147 @@ class GiveGift extends Model
|
||||
}
|
||||
}
|
||||
//推送礼物特效
|
||||
if($gift_info['label'] == 2){
|
||||
//循环开出来的盲盒,相同的礼物只推送一次,消息推送为$FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 趣味礼物 ' .$gift_inf['gift_name'].' x 多少';
|
||||
if($gift_box){
|
||||
// 统计相同礼物的数量
|
||||
$giftCount = [];
|
||||
foreach ($gift_box as $gv) {
|
||||
if (isset($giftCount[$gv['gift_id']])) {
|
||||
$giftCount[$gv['gift_id']]['count']++;
|
||||
} else {
|
||||
$giftCount[$gv['gift_id']] = [
|
||||
'gift_info' => Db::name('vs_gift')->where(['gid'=>$gv['gift_id']])
|
||||
->field('gid as gift_id,gift_name,gift_price,file_type,base_image,play_image,gift_type,label,is_public_server')->find(),
|
||||
'count' => 1
|
||||
];
|
||||
if(!isset($ext['is_draw_gift']) || $ext['is_draw_gift'] != 1){// 非盲盒转盘 推送
|
||||
if($gift_info['label'] == 2){
|
||||
//循环开出来的盲盒,相同的礼物只推送一次,消息推送为$FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 趣味礼物 ' .$gift_inf['gift_name'].' x 多少';
|
||||
if($gift_box){
|
||||
// 统计相同礼物的数量
|
||||
$giftCount = [];
|
||||
foreach ($gift_box as $key=>$gv) {
|
||||
$gift_info = Db::name('vs_gift')->where(['gid'=>$gv['gift_id']])
|
||||
->field('gid as gift_id,gift_name,gift_price,file_type,base_image,play_image,gift_type,label,is_public_server')->find();
|
||||
if (isset($giftCount[$gv['gift_id']])) {
|
||||
$giftCount[$gv['gift_id']]['count']++;
|
||||
} else {
|
||||
$giftCount[$gv['gift_id']] = [
|
||||
'gift_info' => $gift_info,
|
||||
'count' => 1
|
||||
];
|
||||
}
|
||||
$gift_box[$key]['gift_name'] = $gift_info['gift_name'];
|
||||
}
|
||||
}
|
||||
|
||||
// 构建文字消息内容
|
||||
$giftTextList = [];
|
||||
foreach ($giftCount as $giftData) {
|
||||
$gift_inf = $giftData['gift_info'];
|
||||
$count = $giftData['count'];
|
||||
$giftTextList[] = $gift_inf['gift_name'].' X'.$count;
|
||||
}
|
||||
// 构建文字消息内容
|
||||
$giftTextList = [];
|
||||
foreach ($giftCount as $giftData) {
|
||||
$gift_inf = $giftData['gift_info'];
|
||||
$count = $giftData['count'];
|
||||
$giftTextList[] = $gift_inf['gift_name'].' X'.$count;
|
||||
}
|
||||
|
||||
// 推送文字消息 (格式: 张三 送给 李四 趣味礼物 礼物名1 X2,礼物2 X4)
|
||||
$textMessage = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 趣味礼物 ' . implode(',', $giftTextList);
|
||||
$textData = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
// 'ToUserInfo' => $ToUserInfo,
|
||||
// 'GiftInfo' => $gift_info,
|
||||
// 'GiftNum' => $num,
|
||||
'text' => $textMessage
|
||||
];
|
||||
// 聊天室推送文字消息
|
||||
model('Chat')->sendMsg(1038,$from_id,$textData);
|
||||
|
||||
// 循环推送每个礼物的特效消息
|
||||
foreach ($giftCount as $giftId => $giftData) {
|
||||
$gift_inf = $giftData['gift_info'];
|
||||
$count = $giftData['count'];
|
||||
|
||||
// 推送礼物特效消息
|
||||
$effectData = [
|
||||
// 推送文字消息 (格式: 张三 送给 李四 趣味礼物 礼物名1 X2,礼物2 X4)
|
||||
$textMessage = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 趣味礼物 ' . implode(',', $giftTextList);
|
||||
$textData = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfo' => $ToUserInfo,
|
||||
'GiftInfo' => $gift_inf,
|
||||
'GiftNum' => $count,
|
||||
'text' => null
|
||||
'GiftInfos' => array_values($gift_box),
|
||||
'GiftNum' => $num,
|
||||
'text' => $textMessage
|
||||
];
|
||||
// 聊天室推送文字消息
|
||||
model('Chat')->sendMsg(1038,$from_id,$textData);
|
||||
|
||||
// 聊天室推送礼物特效消息
|
||||
model('Chat')->sendMsg(1005,$from_id,$effectData);
|
||||
// 循环推送每个礼物的特效消息
|
||||
foreach ($giftCount as $giftId => $giftData) {
|
||||
$gift_inf = $giftData['gift_info'];
|
||||
$count = $giftData['count'];
|
||||
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $from_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息
|
||||
$hot_value = db::name('vs_give_gift')->where('from_id', $from_id)->where('from',6)
|
||||
->sum('total_price');
|
||||
$text1 = [
|
||||
'room_id' => $from_id,
|
||||
'hot_value' => $hot_value * 10,
|
||||
'text' => '房间心动值变化'
|
||||
// 推送礼物特效消息
|
||||
$effectData = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfo' => $ToUserInfo,
|
||||
'GiftInfo' => $gift_inf,
|
||||
'GiftNum' => $count,
|
||||
'text' => null
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1028,$from_id,$text1);
|
||||
}else{
|
||||
if($gift_inf['is_public_server'] == 1){
|
||||
//推送礼物横幅
|
||||
$push = new Push(UID, $from_id);
|
||||
$room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name');
|
||||
$bannerText = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $gift_inf['gift_name'] . 'X' . $count;
|
||||
$text_list_new = [
|
||||
'text' => $bannerText,
|
||||
'gift_picture' => $gift_inf['base_image'],
|
||||
|
||||
// 聊天室推送礼物特效消息
|
||||
model('Chat')->sendMsg(1005,$from_id,$effectData);
|
||||
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $from_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息
|
||||
$hot_value = db::name('vs_give_gift')->where('from_id', $from_id)->where('from',6)
|
||||
->sum('total_price');
|
||||
$text1 = [
|
||||
'room_id' => $from_id,
|
||||
'fromUserName' => $FromUserInfo['nickname'],
|
||||
'toUserName' => $ToUserInfo['nickname'],
|
||||
'giftName' => $gift_inf['gift_name'],
|
||||
'roomId' => $from_id,
|
||||
'number' => $count,
|
||||
'hot_value' => $hot_value * 10,
|
||||
'text' => '房间心动值变化'
|
||||
];
|
||||
$push->giftBanner($text_list_new);
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1028,$from_id,$text1);
|
||||
|
||||
//电影房推送结束时间点
|
||||
$text2 = [
|
||||
'room_id' => $from_id,
|
||||
'end_time' => time() + 60 * 60 * 24 * 7,
|
||||
'text' => '房间结束时间点'
|
||||
];
|
||||
model('Chat')->sendMsg(1042,$from_id,$text2);
|
||||
}else{
|
||||
if($gift_inf['is_public_server'] == 1){
|
||||
//推送礼物横幅
|
||||
$push = new Push(UID, $from_id);
|
||||
$room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name');
|
||||
$bannerText = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $gift_inf['gift_name'] . 'X' . $count;
|
||||
$text_list_new[] = [
|
||||
'text' => $bannerText,
|
||||
'gift_picture' => $gift_inf['base_image'],
|
||||
'room_id' => $from_id,
|
||||
'fromUserName' => $FromUserInfo['nickname'],
|
||||
'toUserName' => $ToUserInfo['nickname'],
|
||||
'giftName' => $gift_inf['gift_name'],
|
||||
'roomId' => $from_id,
|
||||
'number' => $count,
|
||||
];
|
||||
$push->giftBanner($text_list_new);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
$text = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 礼物 ' .$gift_info['gift_name'].' x ' .$num;
|
||||
$text = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfo' => $ToUserInfo,
|
||||
'GiftInfo' => $gift_info,
|
||||
'GiftNum' => $num,
|
||||
'text' => $text
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1005,$from_id,$text);
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $from_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息
|
||||
$hot_value = db::name('vs_give_gift')->where('from_id', $from_id)->where('from',6)
|
||||
->sum('total_price');
|
||||
$text1 = [
|
||||
'room_id' => $from_id,
|
||||
'hot_value' => $hot_value * 10,
|
||||
'text' => '房间心动值变化'
|
||||
}else{
|
||||
$text = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 礼物 ' .$gift_info['gift_name'].' x ' .$num;
|
||||
$text = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfo' => $ToUserInfo,
|
||||
'GiftInfo' => $gift_info,
|
||||
'GiftNum' => $num,
|
||||
'text' => $text
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1028,$from_id,$text1);
|
||||
}else{
|
||||
if($gift_info['is_public_server'] == 1){
|
||||
//推送礼物横幅
|
||||
$push = new Push(UID, $from_id);
|
||||
$room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name');
|
||||
$text = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $gift_info['gift_name'] . 'X' . $num;
|
||||
$text_list_new = [
|
||||
'text' => $text,
|
||||
'gift_picture' => $gift_info['base_image'],
|
||||
model('Chat')->sendMsg(1005,$from_id,$text);
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $from_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息
|
||||
$hot_value = db::name('vs_give_gift')->where('from_id', $from_id)->where('from',6)
|
||||
->sum('total_price');
|
||||
$text1 = [
|
||||
'room_id' => $from_id,
|
||||
'fromUserName' => $FromUserInfo['nickname'],
|
||||
'toUserName' => $ToUserInfo['nickname'],
|
||||
'giftName' => $gift_info['gift_name'],
|
||||
'roomId' => $from_id,
|
||||
'number' => $num,
|
||||
'hot_value' => $hot_value * 10,
|
||||
'text' => '房间心动值变化'
|
||||
];
|
||||
$push->giftBanner($text_list_new);
|
||||
}
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1028,$from_id,$text1);
|
||||
}else{
|
||||
if($gift_info['is_public_server'] == 1){
|
||||
//推送礼物横幅
|
||||
$push = new Push($uid, $from_id);
|
||||
$room_name = Db::name('vs_room')->where(['id' => $from_id, 'apply_status' => 2])->value('room_name');
|
||||
$text = $FromUserInfo['nickname'] . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $gift_info['gift_name'] . 'X' . $num;
|
||||
$text_list_new[] = [
|
||||
'text' => $text,
|
||||
'gift_picture' => $gift_info['base_image'],
|
||||
'room_id' => $from_id,
|
||||
'fromUserName' => $FromUserInfo['nickname'],
|
||||
'toUserName' => $ToUserInfo['nickname'],
|
||||
'giftName' => $gift_info['gift_name'],
|
||||
'roomId' => $from_id,
|
||||
'number' => $num,
|
||||
];
|
||||
$push->giftBanner($text_list_new);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//直播间送礼物 每日任务
|
||||
@@ -504,11 +549,330 @@ class GiveGift extends Model
|
||||
|
||||
//增加房间火热值hot_value
|
||||
$gift_totalaa = $gift_total * get_system_config_value('coin_charm_exp');
|
||||
Db::name('vs_room')->where(['id'=>$from_id,'apply_status'=>2])->setInc('hot_value',$gift_totalaa);
|
||||
Db::name('vs_room')->where(['id'=>$from_id,'apply_status'=>2])->setInc('today_hot_value',$gift_totalaa);
|
||||
db::name('vs_room')->where(['id' => $from_id])->inc('hot_value', $gift_totalaa)->inc('today_hot_value', $gift_totalaa)->update();
|
||||
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $from_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息 交友房创建的私密房 倒计时增加
|
||||
$value = db::name('vs_room_cp_movie')->where('room_id', $from_id)->where('type',1)
|
||||
->value('time_day');
|
||||
if($value){
|
||||
db::name('vs_room_cp_movie')->where('room_id', $from_id)->where('type',1)
|
||||
->setInc('time_day', $gift_total);
|
||||
$text111 = [
|
||||
'room_id' => $from_id,
|
||||
'time_day' => db::name('vs_room_cp_movie')->where('room_id', $from_id)->where('type',1)->value('time_day'),
|
||||
'text' => '房间结束时间变化'
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1052,$from_id,$text111);
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => '送礼成功', 'data' => null];
|
||||
return ['code' => 1, 'msg' => '送礼成功', 'data' => ['gift_total' => $gift_total,'gift_user_data' =>$gift_user_data]];
|
||||
}
|
||||
|
||||
/*
|
||||
* 送礼物-盲盒转盘专用
|
||||
* @param int $uid 用户id
|
||||
* @param int $from_id 来源id
|
||||
* @param str $to_uid 接收礼物用户id字符串逗号分隔
|
||||
* @param int $gid 礼物id
|
||||
* @param int $num 礼物数量
|
||||
* @param int $from_type 来源 1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼
|
||||
* @param int $type 金币购买 1金币购买 2送背包礼物
|
||||
* @param int $pit_number 坑位编号
|
||||
* @return array
|
||||
* 用户,在房间中,给谁,送了什么礼物,多少个,来源
|
||||
*/
|
||||
public function give_gift_to_pan($uid,$to_uid,$gid,$num,$from_type,$type,$from_id = 0,$pit_number = 0,$change_type = 0,$ext = [])
|
||||
{
|
||||
//送的礼物信息
|
||||
$gift_info = Db::name('vs_gift')->where(['gid'=>$gid])
|
||||
->field('gid as gift_id,gift_name,gift_price,file_type,base_image,play_image,gift_type,label,is_public_server')->find();
|
||||
if(empty($gift_info)){
|
||||
return ['code' => 0, 'msg' => '礼物不存在', 'data' => null];
|
||||
}
|
||||
if(!$to_uid){
|
||||
return ['code' => 0, 'msg' => '请选择收礼人', 'data' => null];
|
||||
}
|
||||
$toarray = explode(',',$to_uid);
|
||||
if(in_array($uid,$toarray)){
|
||||
return ['code' => 0, 'msg' => '收礼人不能包含自己', 'data' => null];
|
||||
}
|
||||
if (ceil($num) != $num) {
|
||||
return ['code' => 0, 'msg' => '打赏礼物数量必须为整数', 'data' => null];
|
||||
}
|
||||
if ($num < 1) {
|
||||
return ['code' => 0, 'msg' => '打赏礼物数量必须大于零', 'data' => null];
|
||||
}
|
||||
$user_info = Db::name('user')->where(['id'=>$uid,'status'=>1])->find();
|
||||
if(empty($user_info)){
|
||||
return ['code' => 301, 'msg' => '当前用户登录失效', 'data' => null];
|
||||
}
|
||||
|
||||
//获取送礼用户昵称
|
||||
$FromUserInfo = db::name('user')->where('id',$uid)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($uid);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($uid);//魅力图标
|
||||
|
||||
//送给一人礼物的总价格(扣除用户的数额)
|
||||
$gift_price = $gift_info['gift_price'] * $num;
|
||||
|
||||
$roomId = 0;
|
||||
if($from_type == 2 || $from_type == 3 || $from_type == 6){
|
||||
$roomId = $from_id;
|
||||
}
|
||||
|
||||
//循环送礼
|
||||
$gift_total = 0;
|
||||
$give_gift = 0;
|
||||
$gift_user_data = [];
|
||||
foreach ($toarray as $k => $to_id){
|
||||
$gift_user_data[]['user_id'] = $to_id;
|
||||
$gift_box1 = [];
|
||||
$gift_box = [];
|
||||
$gift_total += $gift_price;
|
||||
//收礼记录行为日志
|
||||
$give_gift = $this -> change_user_give_gift_log($uid,$gid,$gift_price,$num,$to_id,$from_type,$type,$from_id,$pit_number);
|
||||
if(!$give_gift){
|
||||
return ['code' => 0, 'msg' => '送礼失败', 'data' => null];
|
||||
}
|
||||
$gift_user_data[$k]['gift_price'] = $gift_price;
|
||||
|
||||
//计算收礼人得益
|
||||
$receiver_earnings = $this -> receiver_earnings($to_id,$gift_price,$from_type);
|
||||
if($receiver_earnings <= 0){
|
||||
return ['code' => 0, 'msg' => '收礼人收益配置有误', 'data' => null];
|
||||
}
|
||||
//1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼
|
||||
if($from_type == 1 || $from_type == 2 || $from_type == 3 ||$from_type == 4 || $from_type == 6){
|
||||
//增加收益并记录日志
|
||||
$receiver = $this -> change_user_cion_or_earnings_log($to_id,$receiver_earnings,$from_id,2,11,'收礼增加收益');
|
||||
}elseif($from_type == 5){
|
||||
//增加收益并记录日志
|
||||
$receiver = $this -> change_user_cion_or_earnings_log($to_id,$receiver_earnings,$from_id,1,$change_type,'活动增加金币');
|
||||
}else{
|
||||
$receiver = false;
|
||||
}
|
||||
if(!$receiver){
|
||||
return ['code' => 0, 'msg' => '收礼人收益失败', 'data' => null];
|
||||
}
|
||||
//用户魅力等级更新
|
||||
$user_level = model('Level')->user_level_data_update($to_id,$gift_price,2,$roomId);
|
||||
if(!$user_level){
|
||||
return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null];
|
||||
}
|
||||
|
||||
$room_owner_earnings = 0;//房主收益
|
||||
$room_owner_earningsg = 0;//公会会长收益
|
||||
//是否在房间
|
||||
if(isset($from_id) && ($from_type == 2 || $from_type == 6)){
|
||||
if($from_type == 6){ //cp电影房
|
||||
//房主有收益
|
||||
if(get_system_config_value('room_cp_room_user_ratio') > 0){
|
||||
$room_owner = Db::name('vs_room')->where(['id'=>$from_id,'apply_status'=>2])->value('user_id');
|
||||
//计算房主收益//room_author_ratio
|
||||
$room_owner_earnings = $this -> receiver_earnings($room_owner,$gift_price,699);
|
||||
if($room_owner_earnings > 0){
|
||||
//增加收益并记录日志
|
||||
$room_owner_earning = $this -> change_user_cion_or_earnings_log($room_owner,$room_owner_earnings,$from_id,2,18,'房主收益');
|
||||
if(!$room_owner_earning){
|
||||
return ['code' => 0, 'msg' => '房主收益失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
//公会长收益
|
||||
if(get_system_config_value('room_cp_guild_user_ratio') > 0){
|
||||
$guild_id = Db::name('vs_guild_user')->where(['user_id'=>$to_uid,'status'=>1])->value('guild_id');
|
||||
if($guild_id){
|
||||
$room_guild = Db::name('vs_guild')->where(['id'=>$guild_id])->value('user_id');
|
||||
//计算会长收益
|
||||
$room_owner_earningsg = $this -> receiver_earnings($room_guild,$gift_price,698);
|
||||
//增加收益并记录日志
|
||||
$room_owner_earningg = $this -> change_user_cion_or_earnings_log($room_guild,$room_owner_earningsg,$from_id,2,21,'工会长收益');
|
||||
if(!$room_owner_earningg){
|
||||
return ['code' => 0, 'msg' => '工会长收益失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
$room_owner = Db::name('vs_room')->where(['id'=>$from_id,'apply_status'=>2])->value('user_id');
|
||||
//计算房主收益//room_author_ratio
|
||||
$room_owner_earnings = $this -> receiver_earnings($room_owner,$gift_price,99);//结果是钻石
|
||||
if($room_owner_earnings > 0){
|
||||
//主持人收益
|
||||
//在主持位的主持人
|
||||
$host_id = Db::name('vs_room_pit')->where(['room_id'=>$from_id,'pit_number'=>9])->value('user_id');
|
||||
if($host_id){
|
||||
//计算主持人收益
|
||||
$host_earnings = $this -> receiver_earnings($host_id,$room_owner_earnings*get_system_config_value('rmb_coin_ratio'),98,$from_id);
|
||||
if($host_earnings > 0){
|
||||
//增加主持人收益并记录日志
|
||||
$host_earnings_earning = $this -> change_user_cion_or_earnings_log($host_id,$host_earnings,$from_id,2,19,'主持人收益');
|
||||
if(!$host_earnings_earning){
|
||||
return ['code' => 0, 'msg' => '主持人收益失败', 'data' => null];
|
||||
}
|
||||
//增加房主收益并记录日志
|
||||
$room_owner_earningss = $room_owner_earnings - $host_earnings;
|
||||
if($room_owner_earningss > 0){
|
||||
$room_owner_earning = $this -> change_user_cion_or_earnings_log($room_owner,$room_owner_earningss,$from_id,2,18,'房主收益');
|
||||
if(!$room_owner_earning){
|
||||
return ['code' => 0, 'msg' => '房主收益失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
//增加房主收益并记录日志
|
||||
$room_owner_earning = $this -> change_user_cion_or_earnings_log($room_owner,$room_owner_earnings,$from_id,2,18,'房主收益');
|
||||
if(!$room_owner_earning){
|
||||
return ['code' => 0, 'msg' => '房主收益失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//增加房主收益并记录日志
|
||||
$room_owner_earning = $this -> change_user_cion_or_earnings_log($room_owner,$room_owner_earnings,$from_id,2,18,'房主收益');
|
||||
if(!$room_owner_earning){
|
||||
return ['code' => 0, 'msg' => '房主收益失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($gift_info['label'] == 2){
|
||||
foreach ($gift_box as $gv) {
|
||||
//记录送礼利率和各方收益
|
||||
//收礼人是否加入公会
|
||||
$configs = get_system_config();
|
||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id' => $to_uid, 'status' => 1, 'quit_time' => 0])->field('guild_id')->find();
|
||||
//收益增加 加入工会的收益
|
||||
if ($is_join_guild) {
|
||||
$ratiog = $configs['room_gift_guild_ratio'];
|
||||
} else {
|
||||
$ratiog = 0;
|
||||
}
|
||||
//未加入工会的收益
|
||||
$ratiogr = $configs['room_gift_ratio'];
|
||||
//收礼人最终的收益比例
|
||||
$ratio = $ratiogr + $ratiog;
|
||||
//房主收益大于0 就代表有收益 且在房间
|
||||
if ($room_owner_earningsg > 0) {
|
||||
$guid_ratio = $configs['room_cp_guild_user_ratio'];
|
||||
} else {
|
||||
$guid_ratio = 0;
|
||||
}
|
||||
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
||||
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
||||
$app_earning = coin_earning($gv['gift_price'], $app_ratio);
|
||||
$receiver_earningss = $this -> receiver_earnings($to_id,$gv['gift_price'],$from_type);
|
||||
$room_owner_earningss = $this -> receiver_earnings($room_owner,$gv['gift_price'],99);//结果是钻石
|
||||
$gift_rate = $this->change_give_gift_profit($gv['give_gift_id'], $ratio, $receiver_earningss, $configs['room_author_ratio'], $room_owner_earningss, $app_ratio, $app_earning);
|
||||
if (!$gift_rate) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//记录送礼利率和各方收益
|
||||
//收礼人是否加入公会
|
||||
$configs = get_system_config();
|
||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id' => $to_uid, 'status' => 1, 'quit_time' => 0])->field('guild_id')->find();
|
||||
//收益增加 加入工会的收益
|
||||
if ($is_join_guild) {
|
||||
$ratiog = $configs['room_gift_guild_ratio'];
|
||||
} else {
|
||||
$ratiog = 0;
|
||||
}
|
||||
//未加入工会的收益
|
||||
$ratiogr = $configs['room_gift_ratio'];
|
||||
//收礼人最终的收益比例
|
||||
$ratio = $ratiogr + $ratiog;
|
||||
//房主收益大于0 就代表有收益 且在房间
|
||||
if ($room_owner_earningsg > 0) {
|
||||
$guid_ratio = $configs['room_cp_guild_user_ratio'];
|
||||
} else {
|
||||
$guid_ratio = 0;
|
||||
}
|
||||
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
||||
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
||||
$app_earning = coin_earning($gift_price, $app_ratio);
|
||||
$gift_rate = $this->change_give_gift_profit($give_gift, $ratio, $receiver_earnings, $configs['room_author_ratio'], $room_owner_earnings, $app_ratio, $app_earning);
|
||||
if (!$gift_rate) {
|
||||
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ToUserInfo = Db::name('user')->where(['id' => $to_id])->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$ToUserInfo['icon'][0] = model('UserData')->user_wealth_icon($to_id);//财富图标
|
||||
$ToUserInfo['icon'][1] = model('UserData')->user_charm_icon($to_id);//魅力图标
|
||||
$ToUserInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $to_id,'room_id' => $from_id])->value('charm');//魅力
|
||||
|
||||
if(isset($from_id) && ($from_type == 2 || $from_type == 6)){
|
||||
//查询房间是否在PK中 是fa_vs_room_pk 表中的 room_id_a,还是room_id_b
|
||||
$room_pk = Db::name('vs_room_pk')->where(['status' => 3, 'room_id_a' => $from_id])->field('pk_id')->find();
|
||||
if (!empty($room_pk)) {
|
||||
// 当前 room_id 是 room_id_a 修改create_value_a
|
||||
$rooma = Db::name('vs_room_pk')->where('pk_id', $room_pk['pk_id'])->setInc('create_value_a', $gift_price * 10);
|
||||
$roomPKinfo = Db::name('vs_room_pk')->where('pk_id', $room_pk['pk_id'])->find();
|
||||
//推送变化
|
||||
$text = [
|
||||
'room_id_a' => $roomPKinfo['room_id_a'],//发起者房间id
|
||||
'create_value_a' => $roomPKinfo['create_value_a'],//发起者房间值
|
||||
'room_id_b' => $roomPKinfo['room_id_b'],//接受者房间id
|
||||
'receive_value_b' => $roomPKinfo['receive_value_b'],//接受者房间值
|
||||
'text' => ''
|
||||
];
|
||||
model('Chat')->sendMsg(1015,$roomPKinfo['room_id_a'],$text);
|
||||
model('Chat')->sendMsg(1015,$roomPKinfo['room_id_b'],$text);
|
||||
} else {
|
||||
// 当前 room_id 不是 room_id_a,可能是 room_id_b 或者不存在
|
||||
$room_pk_b = Db::name('vs_room_pk')->where(['status' => 3, 'room_id_b' => $from_id])->field('pk_id')->find();
|
||||
if (!empty($room_pk_b)) {
|
||||
// 当前 room_id 是 room_id_b
|
||||
$roomb = Db::name('vs_room_pk')->where('pk_id', $room_pk_b['pk_id'])->setInc('receive_value_b', $gift_price * 10);
|
||||
$roomPKinfo = Db::name('vs_room_pk')->where('pk_id', $room_pk_b['pk_id'])->find();
|
||||
//推送变化
|
||||
$text = [
|
||||
'room_id_a' => $roomPKinfo['room_id_a'],//发起者房间id
|
||||
'create_value_a' => $roomPKinfo['create_value_a'],//发起者房间值
|
||||
'room_id_b' => $roomPKinfo['room_id_b'],//接受者房间id
|
||||
'receive_value_b' => $roomPKinfo['receive_value_b'],//接受者房间值
|
||||
'text' => ''
|
||||
];
|
||||
model('Chat')->sendMsg(1015,$roomPKinfo['room_id_a'],$text);
|
||||
model('Chat')->sendMsg(1015,$roomPKinfo['room_id_b'],$text);
|
||||
}
|
||||
}
|
||||
//直播间送礼物 每日任务
|
||||
model('DailyTasks')->tasks_complete($uid,3);
|
||||
}
|
||||
}
|
||||
|
||||
//增加房间火热值hot_value
|
||||
$gift_totalaa = $gift_total * get_system_config_value('coin_charm_exp');
|
||||
db::name('vs_room')->where(['id' => $from_id])->inc('hot_value', $gift_totalaa)->inc('today_hot_value', $gift_totalaa)->update();
|
||||
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $from_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息 交友房创建的私密房 倒计时增加
|
||||
$value = db::name('vs_room_cp_movie')->where('room_id', $from_id)->where('type',1)
|
||||
->value('time_day');
|
||||
if($value){
|
||||
db::name('vs_room_cp_movie')->where('room_id', $from_id)->where('type',1)
|
||||
->setInc('time_day', $gift_total);
|
||||
$text111 = [
|
||||
'room_id' => $from_id,
|
||||
'time_day' => db::name('vs_room_cp_movie')->where('room_id', $from_id)->where('type',1)->value('time_day'),
|
||||
'text' => '房间结束时间变化'
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1052,$from_id,$text111);
|
||||
}
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '送礼成功', 'data' => ['gift_total' => $gift_total,'gift_user_data' =>$gift_user_data]];
|
||||
}
|
||||
|
||||
//送礼特效
|
||||
@@ -612,7 +976,7 @@ class GiveGift extends Model
|
||||
}
|
||||
}elseif(in_array($change_type,$out_types)){
|
||||
//减少用户金币
|
||||
$res1 = Db::name('user_wallet')->where(['user_id'=>$user_id])->setDec('coin',$money);
|
||||
$res1 = Db::name('user_wallet')->where(['user_id'=>$user_id,'coin'=>['>=',$money]])->setDec('coin',$money);
|
||||
if(!$res1){
|
||||
return false;
|
||||
}
|
||||
@@ -1015,7 +1379,7 @@ class GiveGift extends Model
|
||||
/*
|
||||
* 开盲盒
|
||||
*/
|
||||
public function open_box($gift_id,$user_id,$gift_user_id,$room_id=0){
|
||||
public function open_box($gift_id,$user_id,$gift_user_id,$room_id=0,$gift_bag_id=0){
|
||||
//获取盲盒配置
|
||||
$bag_list = db::name("vs_gift_bag")->field('id,name,ext,periods')->where(['activities_id'=>4,'status'=>1])->select();
|
||||
$gift_bag_id = 0;
|
||||
|
||||
@@ -17,9 +17,9 @@ class Guild extends Model
|
||||
* @param $page
|
||||
* @param $limit
|
||||
*/
|
||||
public function get_guild_list($page,$limit=10,$search='',$user_id=0)
|
||||
public function get_guild_list($page,$page_limit,$search='',$user_id=0)
|
||||
{
|
||||
$where ="1=1";
|
||||
$where =[];
|
||||
if ($search) {
|
||||
$where = ['guild_special_id'=>['like',$search.'%']]; //通过工会ID搜索
|
||||
}
|
||||
@@ -28,8 +28,7 @@ class Guild extends Model
|
||||
->field('id,guild_special_id,user_id,guild_name,cover,num,intro,createtime,income')
|
||||
->where(['is_show'=>1,'delete_time'=>0])
|
||||
->where($where)
|
||||
->order('income desc')
|
||||
->page($page,$limit)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$count = Db::name('vs_guild')
|
||||
->where(['is_show'=>1,'delete_time'=>0])
|
||||
@@ -62,7 +61,7 @@ class Guild extends Model
|
||||
}
|
||||
$data =[
|
||||
'page' => $page,
|
||||
'limit' => $limit,
|
||||
'limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'list' => $list
|
||||
];
|
||||
@@ -525,7 +524,7 @@ class Guild extends Model
|
||||
//成员解散
|
||||
db::name('vs_guild_user')->where(['guild_id'=>$guild_id,'status'=>1,'delete_time'=>0])->update(['delete_time'=>time(),'quit_type'=>3,'quit_time'=>time()]);
|
||||
//解散公会
|
||||
db::name('vs_guild')->where('id',$guild_id)->update(['delete_time'=>time(),'is_show'=>2,'num'=>0,'guild_special_id'=>""]);
|
||||
db::name('vs_guild')->where('id',$guild_id)->update(['delete_time'=>time(),'status'=>2]);
|
||||
//解散群
|
||||
model('Tencent')->delete_group('g'.$guild_id);
|
||||
Db::commit();
|
||||
@@ -610,8 +609,8 @@ class Guild extends Model
|
||||
//规则
|
||||
$data['rule'] = get_system_config_value('web_site').'/api/Page/page_show?id=15';
|
||||
//上周流水
|
||||
$week_start = date('Y-m-d', strtotime('last monday'));
|
||||
$week_end = date('Y-m-d', strtotime('last monday +6 days'));
|
||||
$week_start = date('Y-m-d 00:00:00', strtotime('last week Monday'));
|
||||
$week_end = date('Y-m-d 23:59:59', strtotime('last week Monday +6 days'));
|
||||
$guild_subsidy = db::name('vs_guild_subsidy')
|
||||
->where(["guild_id"=>$guild_id,'start_time' => $week_start, 'end_time' => $week_end])
|
||||
->find();
|
||||
@@ -622,18 +621,38 @@ class Guild extends Model
|
||||
$data['list'][0]['status_str'] = isset( $guild_subsidy['status'])&& $guild_subsidy['status']==1 ? "已发放" : "未发放";
|
||||
//本周流水
|
||||
//本周的第一天
|
||||
$week = strtotime(date('Y-m-d', strtotime('this week Monday')));
|
||||
$guild_user = db::name('vs_guild_user')->where(['guild_id' => $guild_id,'status'=>1,"delete_time"=>null])->select();
|
||||
$guild_user_ids = array_column($guild_user,'room_id');
|
||||
$total_transaction = db::name('vs_give_gift')
|
||||
->where(['from'=>2,'from_id' => ['in',$guild_user_ids],'createtime' => ['between', [$week, time()]]])
|
||||
->sum('total_price');
|
||||
$week = strtotime(date('Y-m-d 00:00:00', strtotime('this week Monday')));
|
||||
$guild_user = db::name('vs_guild_user')->where(['guild_id' => $guild_id])->select();
|
||||
$transaction = 0;
|
||||
foreach ($guild_user as $k => $v){
|
||||
$week_start_time_seach = $week;
|
||||
$week_end_time_seach = time();
|
||||
if($v['createtime'] && $week_start_time_seach < $v['createtime']){
|
||||
$week_start_time_seach = $v['createtime'];
|
||||
}
|
||||
if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){
|
||||
$week_end_time_seach = $v['quit_time'];
|
||||
}
|
||||
$transaction_one = db::name('vs_give_gift')
|
||||
->whereIn('from_id',$v['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]])
|
||||
->sum('total_price');
|
||||
$transaction += $transaction_one;
|
||||
|
||||
}
|
||||
$total_transaction = $transaction;
|
||||
$ss = 0;
|
||||
if($total_transaction){
|
||||
//根据工会流水 获取补贴比例 单位%
|
||||
$subsidy_config = db::name('vs_guild_subsidy_config')->where('start_amount <= '. $total_transaction)
|
||||
->where('end_amount > '. $total_transaction)->getField('subsidy_ratio');
|
||||
$ss = $total_transaction * ($subsidy_config / 100);
|
||||
//获取补贴配置
|
||||
$config = db::name('vs_guild_subsidy_config')->where(['status' => 1])->order('end_amount desc')->select(); //配置查询
|
||||
foreach ($config as $k => $v) {
|
||||
if ($total_transaction >= $v['end_amount']) {
|
||||
$subsidy_ratio = $v['subsidy_ratio'];
|
||||
$ss = ($total_transaction * ($subsidy_ratio / 100)) / get_system_config_value('rmb_coin_ratio');//转为钻石
|
||||
break; // 找到匹配项后提前退出循环
|
||||
}
|
||||
}
|
||||
}
|
||||
//待开发
|
||||
$data['list'][1]['name'] = "本周流水";
|
||||
@@ -651,62 +670,68 @@ class Guild extends Model
|
||||
$coin_consumption_type_array = model('common/UserWallet')->coin_consumption_type_array;
|
||||
$coin_consumption_type_array = array_diff($coin_consumption_type_array, [model('common/UserWallet')::OPERATION_CONSUME]);
|
||||
|
||||
// // 获取所有工会成员的 user_id
|
||||
// $all_guild_users = Db::name('vs_guild_user')
|
||||
// ->where(['guild_id' => $guild_id, 'status' => 1, 'delete_time' => 0])
|
||||
// ->column('user_id');
|
||||
//
|
||||
// // 批量查询总消费
|
||||
// $total_consumption = Db::name('vs_user_money_log')
|
||||
// ->whereIn('change_type', $coin_consumption_type_array)
|
||||
// ->where(['money_type' => 1, 'createtime' => ['between', [$start_time, $end_time]]])
|
||||
// ->whereIn('user_id', $all_guild_users)
|
||||
// ->sum('change_value');
|
||||
//总消费
|
||||
//所有工会成员
|
||||
// 总消费 - 需要按时间限制并只统计加入工会后的消费
|
||||
if (!$start_time || !$end_time) {
|
||||
// 如果没有指定时间范围,则查询所有记录
|
||||
$start_time_filter = 0;
|
||||
$end_time_filter = time();
|
||||
} else {
|
||||
$start_time_filter = strtotime($start_time." 00:00:00");
|
||||
$end_time_filter = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
|
||||
// 所有工会成员
|
||||
$all_guild_user = db::name('vs_guild_user')->where(['guild_id' => $guild_id,'status'=>1,"delete_time"=>0])->select();
|
||||
$total_consumption = 0;
|
||||
foreach ($all_guild_user as $key => $value) {
|
||||
if(!$start_time){
|
||||
$start_time_all = $value['createtime'];
|
||||
$end_time_all = time();
|
||||
}else{
|
||||
$start_time_all = strtotime($start_time." 00:00:00");
|
||||
$end_time_all = strtotime($end_time." 23:59:59");
|
||||
// 计算时间范围:取工会加入时间和指定时间范围的较大值作为开始时间
|
||||
$actual_start_time = max($value['createtime'], $start_time_filter);
|
||||
$actual_end_time = $end_time_filter;
|
||||
|
||||
// 如果开始时间大于结束时间,则跳过该用户
|
||||
if ($actual_start_time > $actual_end_time) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$consumption = db::name('vs_user_money_log')
|
||||
->whereIn('change_type',$coin_consumption_type_array)
|
||||
->where(['money_type'=>1,'user_id' => $value['user_id'],'createtime' => ['between', [$start_time_all, $end_time_all]]])
|
||||
->where(['money_type'=>1,'user_id' => $value['user_id']])
|
||||
->where('createtime', '>=', $actual_start_time)
|
||||
->where('createtime', '<=', $actual_end_time)
|
||||
->sum('change_value');
|
||||
$total_consumption = $total_consumption+$consumption;
|
||||
$total_consumption = $total_consumption + ($consumption ?: 0);
|
||||
}
|
||||
|
||||
if (!$start_time || !$end_time) {
|
||||
$start_time = strtotime('-1 month'); // 默认最近一个月
|
||||
// 如果没有指定时间范围,则查询所有记录
|
||||
$start_time = 0;
|
||||
$end_time = time();
|
||||
}else{
|
||||
$start_time = strtotime($start_time." 00:00:00");
|
||||
$end_time = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
|
||||
// 查询成员列表及各自消费
|
||||
$list = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_user_money_log c', 'a.user_id = c.user_id AND c.money_type = 1 AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime BETWEEN ' . $start_time . ' AND ' . $end_time, 'LEFT')
|
||||
->join('vs_user_money_log c', 'a.user_id = c.user_id AND c.money_type = 1 AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime >= a.createtime' . ($start_time ? ' AND c.createtime >= ' . $start_time : '') . ($end_time ? ' AND c.createtime <= ' . $end_time : ''), 'LEFT')
|
||||
->field('a.id, a.user_id, a.guild_id, a.room_id, a.status, a.is_deacon, b.nickname, b.avatar, b.user_code, a.createtime, a.apply_time, SUM(c.change_value) AS total_consumption')
|
||||
->where(['a.guild_id' => $guild_id, 'a.status' => 1,'a.delete_time' => 0])
|
||||
->group('a.user_id')
|
||||
->order('a.id asc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
|
||||
$count = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_user_money_log c', 'a.user_id = c.user_id AND c.money_type = 1 AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime BETWEEN ' . $start_time . ' AND ' . $end_time, 'LEFT')
|
||||
->join('vs_user_money_log c', 'a.user_id = c.user_id AND c.money_type = 1 AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime >= a.createtime' . ($start_time ? ' AND c.createtime >= ' . $start_time : '') . ($end_time ? ' AND c.createtime <= ' . $end_time : ''), 'LEFT')
|
||||
->field('a.id, a.user_id, a.guild_id, a.room_id, a.status, a.is_deacon, b.nickname, b.avatar, b.user_code, a.createtime, a.apply_time, SUM(c.change_value) AS total_consumption')
|
||||
->where(['a.guild_id' => $guild_id, 'a.status' => 1,'a.delete_time' => 0])
|
||||
->group('a.user_id')
|
||||
->count();
|
||||
|
||||
$data = [];
|
||||
foreach ($list as $k => $v) {
|
||||
$data[$k]['id'] = $v['id'];
|
||||
@@ -748,9 +773,15 @@ class Guild extends Model
|
||||
$start_time_all = strtotime($start_time." 00:00:00");
|
||||
$end_time_all = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
$start_time_all = $value['createtime'];
|
||||
}
|
||||
if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
$end_time_all = $value['quit_time'];
|
||||
}
|
||||
$transaction = db::name('vs_give_gift')
|
||||
->where('from_id',$value['room_id'])
|
||||
->where(['from'=>2,'createtime' => ['between', [$start_time_all, $end_time_all]]])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_all, $end_time_all]]])
|
||||
->sum('total_price');
|
||||
$total_transaction = $total_transaction+$transaction;
|
||||
}
|
||||
@@ -765,11 +796,17 @@ class Guild extends Model
|
||||
$i=0;
|
||||
foreach ($list as $k=>$v){
|
||||
if(!$start_time){
|
||||
$start_time = $v['createtime'];
|
||||
$end_time = time();
|
||||
$start_time_seach = $value['createtime'];
|
||||
$end_time_seach = time();
|
||||
}else{
|
||||
$start_time = strtotime($start_time." 00:00:00");
|
||||
$end_time = strtotime($end_time." 23:59:59");
|
||||
$start_time_seach = strtotime($start_time." 00:00:00");
|
||||
$end_time_seach = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
$start_time_seach = $value['createtime'];
|
||||
}
|
||||
if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
$end_time_seach = $value['quit_time'];
|
||||
}
|
||||
$room_info = db::name('vs_room')->where(['id'=>$v['room_id'],'room_status'=>1,'delete_time'=>0])->find();
|
||||
if($room_info){
|
||||
@@ -779,7 +816,7 @@ class Guild extends Model
|
||||
$room_data[$i]['room_cover'] = localpath_to_netpath($room_info['room_cover']);
|
||||
$room_data[$i]['total_price'] = db::name('vs_give_gift')
|
||||
->where('from_id',$v['room_id'])
|
||||
->where(['from'=>2,'createtime' => ['between', [$start_time, $end_time]]])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_seach, $end_time_seach]]])
|
||||
->sum('total_price');
|
||||
$i++;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ class Invited extends Model
|
||||
$invited_draw_conf = get_system_config_value('invited_draw');//分成比例
|
||||
$invited_draw = $invited_draw_conf / 100;
|
||||
$invited_draw_money = $money * $invited_draw;
|
||||
$invited_draw_money = $invited_draw_money / intval(get_system_config_value('rmb_coin_ratio')); //金币换算成钻石
|
||||
//修改用户资金
|
||||
$reslut = model('common/UserWallet')->change_user_money($invited_user_id, $invited_draw_money, model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::OPERATION_INVITE_REBATE, '邀请用户充值返利');
|
||||
if($reslut['code'] == 1){
|
||||
@@ -103,7 +104,7 @@ class Invited extends Model
|
||||
//查询用户昵称
|
||||
$v['nickname'] = model('User')->where('id', $v['sub_user_id'])->value('nickname');
|
||||
$v['coin'] = intval($v['coin']);
|
||||
$v['earnings'] = intval($v['earnings']);
|
||||
$v['earnings'] = number_format($v['earnings'], 2, '.', ''); // 保留两位小数
|
||||
$v['proportion'] = intval($v['proportion']);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
|
||||
@@ -27,6 +27,7 @@ class Level extends Model
|
||||
{
|
||||
//规则
|
||||
$return['rule_url'] = get_system_config_value('web_site')."/api/Page/page_show?id=10";
|
||||
$return['coin_charm_exp'] = get_system_config_value('coin_charm_exp');
|
||||
//用户信息
|
||||
$user = model('User')->get_user_info($uid);
|
||||
//用户头像
|
||||
@@ -53,14 +54,15 @@ class Level extends Model
|
||||
//距离下个等级需要的经验
|
||||
$return['user']['next_level'] = $user['charm_level']+1;
|
||||
$return['user']['next_level_str'] = 'Lv.'.$return['user']['next_level'];
|
||||
$return['user']['next_exp'] = $user_level['next_level_exp'] - $user['wealth_exp'];
|
||||
$next_exp = $user_level['next_level_exp'] - $user['charm_exp'];
|
||||
$return['user']['next_exp'] = $next_exp <= 0 ? 0 : $next_exp;
|
||||
$return['user']['next_rights_icon'] = $user_level['next_rights_icon'];
|
||||
}
|
||||
|
||||
//获取等级
|
||||
// 获取用户当前等级
|
||||
$currentUserLevel = $user['charm_level'];
|
||||
if($currentUserLevel == 0){
|
||||
if($currentUserLevel == 1){
|
||||
$level = Db::name('vs_charm_level')
|
||||
->where('status', 1)
|
||||
->order('level', 'asc')
|
||||
@@ -89,7 +91,7 @@ class Level extends Model
|
||||
$return['level'][$key]['name'] = $value['name'];
|
||||
$return['level'][$key]['change_value'] = $value['change_value'];
|
||||
//当前用户距离当前段位的距离
|
||||
$return['level'][$key]['distance'] = $value['change_value'] - $user['wealth_exp'];
|
||||
$return['level'][$key]['distance'] = $value['change_value'] - $user['charm_exp'];
|
||||
$return['level'][$key]['rights_icon'] = $value['rights_icon'];
|
||||
}
|
||||
}
|
||||
@@ -107,6 +109,7 @@ class Level extends Model
|
||||
{
|
||||
//规则
|
||||
$return['rule_url'] = get_system_config_value('web_site')."/api/Page/page_show?id=11";
|
||||
$return['coin_wealth_exp'] = get_system_config_value('coin_wealth_exp');
|
||||
//用户信息
|
||||
$user = model('User')->get_user_info($uid);
|
||||
//用户头像
|
||||
@@ -142,13 +145,14 @@ class Level extends Model
|
||||
//距离下个等级需要的经验
|
||||
$return['user']['next_level'] = $user['wealth_level']+1;
|
||||
$return['user']['next_level_str'] = 'Lv.'.$return['user']['next_level'];
|
||||
$return['user']['next_exp'] = $user_level['next_level_exp'] - $user['wealth_exp'];
|
||||
$next_exp = $user_level['next_level_exp'] - $user['wealth_exp'];
|
||||
$return['user']['next_exp'] = $next_exp <= 0 ? 0 : $next_exp;
|
||||
$return['user']['next_coins'] = $user_level['next_coins'];
|
||||
}
|
||||
//获取等级
|
||||
// 获取用户当前等级
|
||||
$currentUserLevel = $user['wealth_level'];
|
||||
if($currentUserLevel == 0){
|
||||
if($currentUserLevel == 1){
|
||||
$level = Db::name('vs_wealth_level')
|
||||
->where('status', 1)
|
||||
->order('level', 'asc')
|
||||
@@ -226,11 +230,11 @@ class Level extends Model
|
||||
$return['next_level_icon'] = $next_level_data['image'];
|
||||
$return['next_coins'] = $next_level_data['coins'];
|
||||
}else{
|
||||
$return['next_level'] = 0;
|
||||
$return['next_level_name'] = '';
|
||||
$return['next_level_exp'] = 0;
|
||||
$return['next_level_icon'] = '';
|
||||
$return['next_coins'] = 0;
|
||||
$return['next_level'] = $level_data['level'];
|
||||
$return['next_level_name'] = $level_data['name'];
|
||||
$return['next_level_exp'] = $level_data['change_value'];
|
||||
$return['next_level_icon'] = $level_data['image'];
|
||||
$return['next_coins'] = $level_data['coins'];
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
@@ -264,11 +268,11 @@ class Level extends Model
|
||||
$return['next_level_icon'] = $next_level_data['image'];
|
||||
$return['next_rights_icon'] = $next_level_data['rights_icon'];
|
||||
}else{
|
||||
$return['next_level'] = 0;
|
||||
$return['next_level_name'] = '';
|
||||
$return['next_level_exp'] = 0;
|
||||
$return['next_level_icon'] = '';
|
||||
$return['next_rights_icon'] = "";
|
||||
$return['next_level'] = $level_data['level'];
|
||||
$return['next_level_name'] = $level_data['name'];
|
||||
$return['next_level_exp'] = $level_data['change_value'];
|
||||
$return['next_level_icon'] = $level_data['image'];
|
||||
$return['next_rights_icon'] = $level_data['rights_icon'];
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
@@ -289,10 +293,11 @@ class Level extends Model
|
||||
$user_wealth_level = $user['wealth_level'];
|
||||
$user_wealth_exp = $user['wealth_exp'] + $wealth_exp;
|
||||
//判断是否达到下一级别
|
||||
$user_wealth = $this->get_wealth_level_to_level($user_wealth_level);
|
||||
if($user_wealth_exp>= $user_wealth['exp']){
|
||||
$user_wealth_level= $user_wealth['next_level'];
|
||||
}
|
||||
$user_wealth = $this->get_wealth_level_to_level_vlue($user_wealth_exp);
|
||||
// if($user_wealth_level>= $user_wealth['level']){
|
||||
// $user_wealth_level= $user_wealth['level'];
|
||||
// }
|
||||
$user_wealth_level= $user_wealth['level'];
|
||||
$update_data = [];
|
||||
$update_data['wealth_level'] = $user_wealth_level;
|
||||
$update_data['wealth_exp'] = $user_wealth_exp;
|
||||
@@ -319,10 +324,11 @@ class Level extends Model
|
||||
$user_charm_level = $user['charm_level'];
|
||||
$user_charm_exp = $user['charm_exp'] + $charm_exp;
|
||||
//判断是否达到下一级别
|
||||
$user_charm = $this->get_charm_level_to_level($user_charm_level);
|
||||
if($user_charm_exp>= $user_charm['exp']){
|
||||
$user_charm_level= $user_charm['next_level'];
|
||||
}
|
||||
$user_charm = $this->get_charm_level_to_level_vlue($user_charm_exp);
|
||||
// if($user_charm_level != $user_charm['level']){
|
||||
// $user_charm_level = $user_charm['level'];
|
||||
// }
|
||||
$user_charm_level = $user_charm['level'];
|
||||
$update_data = [];
|
||||
$update_data['charm_level'] = $user_charm_level;
|
||||
$update_data['charm_exp'] = $user_charm_exp;
|
||||
@@ -412,4 +418,45 @@ class Level extends Model
|
||||
}
|
||||
return ['code' => 1, 'msg' => "成功", 'data' => null];
|
||||
}
|
||||
|
||||
/*
|
||||
* 通过魅力值获取对应等级
|
||||
*/
|
||||
public function get_charm_level_to_level_vlue($charm_level){
|
||||
$return = [];
|
||||
$level_data = Db::name('vs_charm_level')->where(["change_value"=>['<',$charm_level]])->order('change_value','desc')->find();
|
||||
if($level_data){
|
||||
$return['level'] = $level_data['level'];
|
||||
$return['level_name'] = $level_data['name'];
|
||||
$return['exp'] = $level_data['change_value'];
|
||||
$return['level_icon'] = $level_data['image'];
|
||||
}else{
|
||||
$return['level'] = 0;
|
||||
$return['level_name'] = '';
|
||||
$return['exp'] = 0;
|
||||
$return['level_icon'] = '';
|
||||
$return['rights_icon'] = "";
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
/*
|
||||
* 通过财富值获取对应等级
|
||||
*/
|
||||
public function get_wealth_level_to_level_vlue($wealth_level){
|
||||
$return = [];
|
||||
$level_data = Db::name('vs_wealth_level')->where(["change_value"=>['<',$wealth_level]])->order('change_value','desc')->find();
|
||||
if($level_data){
|
||||
$return['level'] = $level_data['level'];
|
||||
$return['level_name'] = $level_data['name'];
|
||||
$return['exp'] = $level_data['change_value'];
|
||||
$return['level_icon'] = $level_data['image'];
|
||||
}else{
|
||||
$return['level'] = 0;
|
||||
$return['level_name'] = '';
|
||||
$return['exp'] = 0;
|
||||
$return['level_icon'] = '';
|
||||
$return['rights_icon'] = "";
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,16 +107,44 @@ class Login extends Model
|
||||
$block = db::name('block')->where(['type_text' => $user_info['id'],'type' => 1])->find();
|
||||
|
||||
if ($block) {
|
||||
return ['code' => 0, 'msg' => '用户已被封禁', 'data' => null];
|
||||
if($block['block_time'] != 0 && $block['block_time'] <= time()){
|
||||
db('block')->where(['id' => $block['id']])->delete();
|
||||
$sms_error = db::name('sms_error')->where(['mobile' => $user_info['mobile']])->find();
|
||||
if($sms_error){
|
||||
db::name('sms_error')->where(['mobile' => $user_info['mobile']])->delete();
|
||||
}
|
||||
}else{
|
||||
if($block['block_time'] == 0){
|
||||
return ['code' => 301, 'msg' => '用户已被永久封禁', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 301, 'msg' => '用户已被封禁,解封时间:'.date('Y-m-d H:i:s',$block['block_time']), 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
$block = db::name('block')->where(['type_text' => $login_device,'type' => 2])->find();
|
||||
if ($block) {
|
||||
return ['code' => 0, 'msg' => '设备已被封禁', 'data' => null];
|
||||
if($block['block_time'] != 0 && $block['block_time'] <= time()){
|
||||
db('block')->where(['id' => $block['id']])->delete();
|
||||
}else{
|
||||
if($block['block_time'] == 0){
|
||||
return ['code' => 301, 'msg' => '设备已被永久封禁', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 301, 'msg' => '设备已被封禁,解封时间:'.date('Y-m-d H:i:s',$block['block_time']), 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
$ip = request()->ip();
|
||||
$block = db::name('block')->where(['type_text' => $ip,'type' => 3])->find();
|
||||
if ($block) {
|
||||
return ['code' => 0, 'msg' => 'ip已被封禁', 'data' => null];
|
||||
if($block['block_time'] != 0 && $block['block_time'] <= time()){
|
||||
db('block')->where(['id' => $block['id']])->delete();
|
||||
}else{
|
||||
if($block['block_time'] == 0){
|
||||
return ['code' => 301, 'msg' => 'ip已被永久封禁', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 301, 'msg' => 'ip已被封禁,解封时间:'.date('Y-m-d H:i:s',$block['block_time']), 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$save_data = [];
|
||||
@@ -181,6 +209,17 @@ class Login extends Model
|
||||
}
|
||||
$return_res[0]['auth'] = $isAuth;
|
||||
|
||||
//是否可以发布动态
|
||||
$user_rechange = db::name('vs_user_recharge')->field('sum(money) as money')->where(['user_id' => $user_info['id'],'pay_status' => 2])->find();
|
||||
//系统配置
|
||||
$config_money = get_system_config_value('private_chat_recharge_money');
|
||||
if(($config_money > 0) && ($user_rechange['money'] < $config_money)){
|
||||
$return_res[0]['is_can_chat'] = 0;
|
||||
}else{
|
||||
$return_res[0]['is_can_chat'] = 1;
|
||||
}
|
||||
$return_res[0]['can_chat_money'] = $config_money;
|
||||
|
||||
return ['code' => 1, 'msg' => '登录成功', 'data' => $return_res];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '登录失败,账号失效', 'data' => null];
|
||||
@@ -254,28 +293,52 @@ class Login extends Model
|
||||
return ['code' => 0, 'msg' => '密码不能为空', 'data' => null];
|
||||
}
|
||||
|
||||
$user_info = model('User')->where(['mobile' => $user_name,'status'=>1])->find();
|
||||
$user_info = model('User')->where(['mobile' => $user_name,'status'=>['<>',0]])->find();
|
||||
if (empty($user_info)) {
|
||||
return ['code' => 0, 'msg' => '用户不存在', 'data' => null];
|
||||
}
|
||||
//今天误次数
|
||||
$sms_count = db::name('sms_error')->where(['mobile' => $user_name,'createtime' => ['between', [strtotime(date('Y-m-d')), time()]]])->count();
|
||||
|
||||
if (md5($password) != $user_info['password']) {
|
||||
return ['code' => 0, 'msg' => '密码错误', 'data' => null];
|
||||
if ($sms_count >= 5) {
|
||||
$user_id = db::name('user')->where('mobile', $user_name)->value('id');
|
||||
$block_num = db::name('block')->where(['type' => 1, 'type_text' => $user_id])->find();
|
||||
if(!$block_num){
|
||||
//封禁账号
|
||||
$error_data = [
|
||||
'type' => 1,
|
||||
'type_text' => $user_id,
|
||||
'block_time' => time() + 60 * 60 * 24,
|
||||
'block_note' => '账号登录异常被封禁24小时',
|
||||
'createtime'=> time(),
|
||||
];
|
||||
db::name('block')->insert($error_data);
|
||||
db::name('user')->where('id', $user_id)->update(['status' => 2]);
|
||||
}
|
||||
|
||||
return ['code' => 0, 'msg' => '登录错误次数过多,账号已被封禁,请联系管理员处理','data' =>null];
|
||||
}
|
||||
|
||||
$count_sms = max(5 - $sms_count, 0);
|
||||
if (md5($password) != $user_info['password']) {
|
||||
$data = [
|
||||
'mobile' => $user_name,
|
||||
'type' => 2,
|
||||
'sms' => $password,
|
||||
'createtime'=> time(),
|
||||
];
|
||||
db::name('sms_error')->insert($data);
|
||||
return ['code' => 0, 'msg' => '密码错误,'.$count_sms.'次后账号将被封禁24小时', 'data' => null];
|
||||
}
|
||||
// $multi_user = [];
|
||||
// //查询手机号绑定的账号
|
||||
// $phone_user = $this->phone_login_query($user_name);
|
||||
// if($phone_user['code'] == 1){
|
||||
// //获取返回数据的长度
|
||||
// if(count($phone_user['data']) >= 2){
|
||||
// $multi_user = $phone_user['data'];
|
||||
// }
|
||||
// }
|
||||
|
||||
$login = $this->login($user_info,$system,$login_device);
|
||||
if($login['code'] != 1){
|
||||
return $login;
|
||||
}
|
||||
|
||||
//登陆成功后 把所有的登录错误删除掉
|
||||
db::name('sms_error')->where(['mobile' => $user_name])->delete();
|
||||
|
||||
return ['code' => 1, 'msg' => '登录成功', 'data' => $login['data']];
|
||||
}
|
||||
|
||||
@@ -300,12 +363,24 @@ class Login extends Model
|
||||
if($type == 'wx'){
|
||||
$openid = $userinfo['openid'];
|
||||
$user_info_data = model('UserData')->where(['wx_openid' => $openid,'deletetime'=>0])->find();
|
||||
$config_time = get_system_config_value('cancel_to_reset_reg');
|
||||
if(isset($user_info_data) && $user_info_data['deletetime'] != 0 && time() - $user_info_data['deletetime'] < 86400 * $config_time){
|
||||
return ['code' => 0, 'msg' => '注销后需等待'.$config_time.'天才能重新注册', 'data' => null];
|
||||
}
|
||||
}elseif ($type == 'ali'){
|
||||
$ali_userid = $userinfo['open_id'];
|
||||
$user_info_data = model('UserData')->where(['ali_userid' => $ali_userid,'deletetime'=>0])->find();
|
||||
$config_time = get_system_config_value('cancel_to_reset_reg');
|
||||
if(isset($user_info_data) && $user_info_data['deletetime'] != 0 && time() - $user_info_data['deletetime'] < 86400 * $config_time){
|
||||
return ['code' => 0, 'msg' => '注销后需等待'.$config_time.'天才能重新注册', 'data' => null];
|
||||
}
|
||||
}elseif ($type == 'ios'){
|
||||
$apple_id = $userinfo;
|
||||
$user_info_data = model('UserData')->where(['apple_id' => $userinfo,'deletetime'=>0])->find();
|
||||
$config_time = get_system_config_value('cancel_to_reset_reg');
|
||||
if(isset($user_info_data) && $user_info_data['deletetime'] != 0 && time() - $user_info_data['deletetime'] < 86400 * $config_time){
|
||||
return ['code' => 0, 'msg' => '注销后需等待'.$config_time.'天才能重新注册', 'data' => null];
|
||||
}
|
||||
}
|
||||
else{
|
||||
return ['code' => 0, 'msg' => '登录类型错误', 'data' => null];
|
||||
@@ -371,10 +446,23 @@ class Login extends Model
|
||||
//注销
|
||||
public function cancel($token){
|
||||
$user_info = model('UserToken')->where('token', $token)->find();
|
||||
//用户注册时间
|
||||
$register_time = db::name('user')->where('id', $user_info['user_id'])->value('createtime');
|
||||
$config_time = get_system_config_value('reg_to_cancel');
|
||||
if(time() - $register_time < 86400 * $config_time){
|
||||
return ['code' => 0, 'msg' => '注册'.$config_time.'天内不能注销!', 'data' => null];
|
||||
}
|
||||
if($user_info){
|
||||
model('UserToken')->where('id', $user_info['id'])->update(['token' => 1]);
|
||||
$isstatus = model('User')->where('id', $user_info['user_id'])->update(['status' => 0]);
|
||||
if($isstatus){
|
||||
//查询用户所在房间
|
||||
$room_list = db::name('vs_room_visitor')->where('user_id', $user_info['user_id'])->select();
|
||||
if($room_list){
|
||||
foreach ($room_list as &$value) {
|
||||
model('Room')->quit_room($user_info['user_id'], $value['room_id'],$user_info['user_id']);
|
||||
}
|
||||
}
|
||||
//删除用户
|
||||
// model('Tencent')->account_delete($user_info['user_id']);
|
||||
model('User')->where('id', $user_info['user_id'])->update(['delete_time' => time()]);
|
||||
@@ -387,25 +475,16 @@ class Login extends Model
|
||||
db::name('vs_room')->where('id', $value['id'])->update(['room_status' => 3]);
|
||||
}
|
||||
}
|
||||
//查询用户所在房间
|
||||
$room_list = db::name('vs_room_visitor')->where('user_id', $user_info['user_id'])->select();
|
||||
if($room_list){
|
||||
foreach ($room_list as &$value) {
|
||||
model('Room')->quit_room($user_info['user_id'], $value['room_id'],$user_info['user_id']);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '注销失败', 'data' => null];
|
||||
}
|
||||
|
||||
//查询绑定的手机号
|
||||
$mob = db::name('user')->where('id', $user_info['user_id'])->value('mobile');
|
||||
$mobile = db::name('user')->where('mobile', $mob)->select();
|
||||
$mobile = db::name('user')->where(['mobile' => $mob,'status' => ['<>',0]])->select();
|
||||
if(isset($mobile) && count($mobile) < 2){
|
||||
$user_auth = db::name('user_auth')->where('mobile', $mobile[0]['mobile'])->find();
|
||||
if($user_auth){
|
||||
db::name('user_auth')->where('id', $user_auth['id'])->delete();
|
||||
}
|
||||
db::name('user_auth')->where('mobile', $mob)->delete();
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '注销成功', 'data' => null];
|
||||
|
||||
@@ -55,7 +55,7 @@ class Ranking extends Model
|
||||
->where($where)
|
||||
->order('total desc')
|
||||
->group('a.user_id')
|
||||
->page($this->page, $this->page_limit)
|
||||
// ->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
|
||||
if($lists){
|
||||
@@ -105,7 +105,7 @@ class Ranking extends Model
|
||||
->where($where)
|
||||
->order('total desc')
|
||||
->group('a.gift_user')
|
||||
->page($this->page, $this->page_limit)
|
||||
// ->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
|
||||
if($lists){
|
||||
@@ -149,7 +149,8 @@ class Ranking extends Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//截取20条
|
||||
$lists = array_slice($lists,0,20);
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
@@ -161,15 +162,17 @@ class Ranking extends Model
|
||||
//房间榜
|
||||
public function room_ranking()
|
||||
{
|
||||
//金币与魅力比例
|
||||
$ratio = get_system_config_value('coin_charm_exp');
|
||||
$where['a.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$where['b.type_id'] = ['<>', 6];
|
||||
$where['b.room_status'] = 1;
|
||||
$field = ['sum(a.total_price) as total,b.room_name,a.from_id as room_id,b.room_cover,b.room_number'];
|
||||
$field = ['sum(a.total_price) *'.$ratio.' as total,b.room_name,a.from_id as room_id,b.room_cover,b.room_number'];
|
||||
$lists = db::name('vs_give_gift')->alias('a')
|
||||
->join('vs_room b','a.from_id = b.id','left')
|
||||
->where($where)->field($field)->group('a.from_id')
|
||||
->order('total desc')
|
||||
->page($this->page, $this->page_limit)
|
||||
// ->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
$my_ranking = null;
|
||||
if($lists){
|
||||
@@ -240,6 +243,8 @@ class Ranking extends Model
|
||||
$my_ranking['room_name'] = $myRoom['room_name'];
|
||||
$my_ranking['room_cover'] = $myRoom['room_cover'];
|
||||
}
|
||||
//截取20条
|
||||
$lists = array_slice($lists,0,20);
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
@@ -278,7 +283,12 @@ class Ranking extends Model
|
||||
}
|
||||
|
||||
$lists = $guilds ;
|
||||
$my_ranking = null;
|
||||
// $my_ranking = null;
|
||||
$my_ranking['guild_name'] = '';
|
||||
$my_ranking['cover'] = '';
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = 0;
|
||||
if($lists){
|
||||
//获取当前用户的工会
|
||||
$myGuild = db::name('vs_guild_user')->where(['user_id' => UID])->find();
|
||||
|
||||
@@ -28,10 +28,20 @@ class Room extends Model
|
||||
return ['code' => 0, 'msg' => '请先进行实名认证通过后操作', 'data' => null];
|
||||
}
|
||||
|
||||
//检查房间名称是否包含官方等词
|
||||
//名称中不能有 系统管理 等关键字
|
||||
if(!nickname_filter($room_name)){
|
||||
return ['code' => 0, 'msg' => '名称中不能有 系统、管理、官方等相关敏感字', 'data' => null];
|
||||
}
|
||||
|
||||
if($type <= 0){
|
||||
$room_info = db::name('vs_room')->where(['user_id' => $uid, 'type_id' => ['<>',6]])->find();
|
||||
$room_info = db::name('vs_room')->where(['user_id' => $uid, 'type_id' => ['<>',6], 'apply_status' => ['<>',3]])->find();
|
||||
if (!empty($room_info)) {
|
||||
return ['code' => 0, 'msg' => '已有直播间请勿重复创建', 'data' => null];
|
||||
if($room_info['apply_status'] == 2){
|
||||
return ['code' => 0, 'msg' => '已有直播间请勿重复创建', 'data' => null];
|
||||
}elseif($room_info['apply_status'] == 1){
|
||||
return ['code' => 0, 'msg' => '房间审核中,请耐心等待', 'data' => null];
|
||||
}
|
||||
}else{
|
||||
//首次建立房间【完成任务】
|
||||
model('DailyTasks')->tasks_complete($uid,15);
|
||||
@@ -42,20 +52,29 @@ class Room extends Model
|
||||
$data['room_number'] = $this->get_user_code();
|
||||
$data['type_id'] = 1;
|
||||
$data['apply_status'] = 1;
|
||||
}else{//cp电影房
|
||||
$data['label_id'] = 1;
|
||||
}elseif ($type == 7){
|
||||
$data['room_number'] = $this->get_user_code();
|
||||
$data['type_id'] = 6;//cp电影房
|
||||
$room_intro = $room_intro.'('.$type.')';
|
||||
$data['apply_status'] = 2;
|
||||
$data['label_id'] = 5;
|
||||
}
|
||||
else{//cp电影房
|
||||
$data['room_number'] = $this->get_user_code();
|
||||
$data['type_id'] = 6;//cp电影房
|
||||
$room_intro = $room_intro.'('.$type.')';
|
||||
$data['apply_status'] = 2;
|
||||
$data['label_id'] = 1;
|
||||
}
|
||||
|
||||
$data['user_id'] = $uid;
|
||||
$data['room_name'] = $room_name;
|
||||
$data['room_cover'] = $room_cover;
|
||||
$data['room_intro'] = $room_intro;
|
||||
$data['room_background'] = get_system_config_value('web_site').'/data/default/delfultroombackground.jpg';
|
||||
$room_bg_img = db::name('vs_room_background')->where(['id' => 2])->value('image_url');
|
||||
$data['room_background'] = $room_bg_img ?? get_system_config_value('web_site').'/data/default/delfultroombackground.jpg';
|
||||
$data['is_earnings'] = 1;
|
||||
$data['label_id'] = 1;
|
||||
$data['createtime'] = time();
|
||||
|
||||
Db::startTrans();
|
||||
@@ -143,7 +162,7 @@ class Room extends Model
|
||||
if(!empty($data)){
|
||||
$reslut = $this->where('id', $room_id)->update($data);
|
||||
if (!$reslut) {
|
||||
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '请勿重复提交', 'data' => null];
|
||||
}
|
||||
}
|
||||
//推送消息
|
||||
@@ -182,24 +201,14 @@ class Room extends Model
|
||||
}
|
||||
|
||||
$list = db::name('vs_room')->field('id as room_id,room_number,user_id,room_name,room_cover,room_password,today_hot_value as hot_value,label_id,is_show_room')
|
||||
->where($map)->order('hot_value desc')->page($page, $page_limit)->select();
|
||||
// var_dump($list);
|
||||
foreach ($list as $k => &$v){
|
||||
if($v['is_show_room'] == 2){ //是否显示房间 1是2否
|
||||
//查询当前房间是否有主持在麦上
|
||||
$room_host_info = db::name('vs_room_pit')->where(['room_id' => $v['room_id'], 'pit_number' => 9])->value('user_id');
|
||||
if($room_host_info == 0){
|
||||
unset($list[$k]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// $v['hot_value'] = $v['hot_value'] * 10;
|
||||
->where($map)->order('hot_value desc, id asc')->page($page, $page_limit)->select();
|
||||
|
||||
foreach ($list as &$v){
|
||||
$v['user_list'] = model('RoomUser')->get_room_user_list($v['room_id']);
|
||||
$v['label_name'] = db::name('vs_room_label')->where('id', $v['label_id'])->value('label_name');
|
||||
$v['label_icon'] = db::name('vs_room_label')->where('id', $v['label_id'])->value('label_icon');
|
||||
}
|
||||
//$list 不为空 数组重组
|
||||
$list = array_values((array)$list);
|
||||
|
||||
//版本号
|
||||
$app_version = request()->header('App-Version');
|
||||
$system = request()->header('system');
|
||||
@@ -215,32 +224,6 @@ class Room extends Model
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list, 'api_version' => $api_version];
|
||||
}
|
||||
|
||||
//关注的用户现在所在房间(废弃)
|
||||
public function user_follow_in_room_list($uid ,$page, $page_limit)
|
||||
{
|
||||
//关注的用户列表
|
||||
$follow_list = db::name('user_follow')->where('user_id', $uid)->field('follow_user_id')->select();
|
||||
if(!empty($follow_list)){
|
||||
$user_room_list = [];
|
||||
foreach ($follow_list as $k => $v){
|
||||
//用户是否在房间中
|
||||
$user_room_info = db::name('vs_room_visitor')->where('user_id', $v['follow_user_id'])->field('room_id')->find();
|
||||
if(!empty($user_room_info)){
|
||||
$user_room_list[] = $user_room_info['room_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!empty($user_room_list)){
|
||||
$list = db::name('vs_room')->field('id as room_id,room_number,user_id,room_name,room_cover,room_password,today_hot_value as hot_value')
|
||||
->where('id', 'in', $user_room_list)->order('hot_value desc')->page($page, $page_limit)->select();
|
||||
foreach ($list as $k => &$v){
|
||||
// $v['hot_value'] = $v['hot_value'] * 10;
|
||||
$v['user_list'] = model('RoomUser')->get_room_user_list($v['id']);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => []];
|
||||
}
|
||||
|
||||
//首页弹出的房间
|
||||
public function index_recommend_room()
|
||||
@@ -289,7 +272,7 @@ class Room extends Model
|
||||
$roomInfo = db::name('vs_room')
|
||||
->field('id as room_id,room_number,user_id,room_name,room_cover,apply_status,type_id,room_status,label_id')
|
||||
->where('user_id' , $uid)
|
||||
->where(['type_id' => ['<>',6],'room_status' =>1])
|
||||
->where(['type_id' => ['<>',6],'room_status' =>1,'apply_status' => ['<>',3]])
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
}
|
||||
@@ -305,8 +288,15 @@ class Room extends Model
|
||||
$v['is_use_code'] = 1;
|
||||
$v['room_number'] = $liang;
|
||||
}
|
||||
//今日收益
|
||||
$v['today_profit'] = $this->get_room_today_profit($v['room_id']) * 10;
|
||||
if($type == 1) {//1-我主持的
|
||||
//今日收益
|
||||
$v['today_profit'] = round( $this->get_room_today_earnings($v['room_id'],$uid),4);
|
||||
}else{
|
||||
//今日流水
|
||||
//金币与魅力比例
|
||||
$ratio = get_system_config_value('coin_charm_exp');
|
||||
$v['today_profit'] = $this->get_room_today_profit($v['room_id']) * $ratio;
|
||||
}
|
||||
//关注数
|
||||
$v['follow_num'] = db::name('user_follow')->where('follow_id', $v['room_id'])->where('type', 2)->count();
|
||||
//访问数
|
||||
@@ -352,7 +342,6 @@ class Room extends Model
|
||||
}
|
||||
|
||||
$cp_room[$i]['room_id'] = $v['room_id'];
|
||||
// $cp_room[$i]['room_name'] = '我 ❤️ '.$room_name.db::name('vs_room')->where('id', $v['room_id'])->value('room_name');
|
||||
$cp_room[$i]['room_name'] = '我 ❤️ '.$room_name;
|
||||
$cp_room[$i]['room_number'] = db::name('vs_room')->where('id', $v['room_id'])->value('room_number');
|
||||
$cp_room[$i]['end_time'] = $v['time_day'];
|
||||
@@ -366,7 +355,7 @@ class Room extends Model
|
||||
return $cp_room;
|
||||
}
|
||||
|
||||
//房间今日收益
|
||||
//房间今日流水
|
||||
public function get_room_today_profit($room_id)
|
||||
{
|
||||
$room_type = db::name('vs_room')->where('id', $room_id)->value('type_id');
|
||||
@@ -381,6 +370,17 @@ class Room extends Model
|
||||
return $profit;
|
||||
}
|
||||
|
||||
//房间今日主持收益
|
||||
public function get_room_today_earnings($room_id,$user_id)
|
||||
{
|
||||
$today_start_time = strtotime(date('Y-m-d'));
|
||||
$today_end_time = $today_start_time + 86400;
|
||||
return Db::name('vs_user_money_log')
|
||||
->where(['room_id' => $room_id,'user_id' => $user_id,'change_type' =>19])
|
||||
->whereBetween('createtime', [$today_start_time, $today_end_time])
|
||||
->sum('change_value');
|
||||
}
|
||||
|
||||
//房间补贴
|
||||
public function room_ubsidy($room_id){
|
||||
$room_type = db::name('vs_room')->where('id', $room_id)->value('type_id');
|
||||
@@ -461,17 +461,8 @@ class Room extends Model
|
||||
if(!$room){
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
//获取房间名称
|
||||
// $room_name = $room['room_name'];
|
||||
|
||||
//查询房主是否加入公会
|
||||
// $guild_id = model('Guild')->user_is_join($room['user_id']);
|
||||
// //获取房主收益比例
|
||||
// if($guild_id > 0){
|
||||
// $room_user_ratio = get_system_config_value('room_author_guild_ratio')/100;
|
||||
// }else{
|
||||
$room_user_ratio = get_system_config_value('room_author_ratio')/100;
|
||||
// }
|
||||
$room_user_ratio = get_system_config_value('room_author_ratio')/100;
|
||||
|
||||
//根据日期查询房间流水
|
||||
$field = "b.nickname as sender_nickname,b.avatar as sender_avatar,c.nickname as receive_nickname,c.avatar as receive_avatar,dd.gift_name,a.number,a.total_price,{$group_field} as time";
|
||||
@@ -487,17 +478,9 @@ class Room extends Model
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}
|
||||
|
||||
// $count = db::name('vs_give_gift')->alias('a')->field($field)
|
||||
// ->join('user b', 'a.user_id = b.id')
|
||||
// ->join('user c', 'a.gift_user = c.id')
|
||||
// ->join('vs_give_gift d', 'a.gift_id = d.id')
|
||||
// ->where($where)
|
||||
// ->count();
|
||||
|
||||
$list = db::name('vs_give_gift')->alias('a')->field($field)
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('user c', 'a.gift_user = c.id')
|
||||
// ->join('vs_give_gift d', 'a.gift_id = d.id')
|
||||
->join('vs_gift dd', 'a.gift_id = dd.gid')
|
||||
->where($where)
|
||||
->page($page,$page_limit)
|
||||
@@ -547,10 +530,13 @@ class Room extends Model
|
||||
|
||||
//进入房间
|
||||
public function join_room($user_id, $room_id, $password) {
|
||||
$room = db::name('vs_room')->where(['id' => $room_id,'apply_status' => 2])->find();
|
||||
$room = db::name('vs_room')->where(['id' => $room_id,'apply_status' => ['in',[1,2]]])->find();
|
||||
if (!isset($room)) {
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => ''];
|
||||
}
|
||||
if($room['apply_status'] == 1){
|
||||
return ['code' => 0, 'msg' => '房间正在审核中……', 'data' => ''];
|
||||
}
|
||||
if(isset($room['password']) && $user_id != $room['user_id']){
|
||||
if (empty($password) || $room['password'] != md5($password)) {
|
||||
return ['code' => 0, 'msg' => '密码错误', 'data' => ''];
|
||||
@@ -584,19 +570,18 @@ class Room extends Model
|
||||
}
|
||||
|
||||
//用户是否在其他房间
|
||||
$room_user = db::name('vs_room_visitor')->where(['user_id' => $user_id])->value('room_id');
|
||||
if (isset($room_user) && $room_user != $room_id) {
|
||||
// return ['code' => 0, 'msg' => '您已在其他房间', 'data' => ''];
|
||||
//根据房间状态判断是否要退出房间并且下麦
|
||||
$room_user = db::name('vs_room_visitor')->where(['user_id' => $user_id])->order('id desc')->value('room_id');
|
||||
if (isset($room_user) && $room_user != $room_id && $room_user != 0) {
|
||||
//根据所在房间状态判断是否要退出房间并且下麦
|
||||
$roomInfo = db::name('vs_room')->where(['id' => $room_user,'apply_status' => 2])->find();
|
||||
if(($roomInfo['type_id'] == 1 || $roomInfo['type_id'] == 3 || $roomInfo['type_id'] == 4)&& $roomInfo['label_id'] == 1){
|
||||
if(($roomInfo['type_id'] == 1 || $roomInfo['type_id'] == 3 || $roomInfo['type_id'] == 4 || $roomInfo['type_id'] == 8)&& $roomInfo['label_id'] == 1){
|
||||
//退出其他房间
|
||||
$this->quit_room($user_id, $room_user,$user_id);
|
||||
}elseif(($roomInfo['type_id'] == 1 || $roomInfo['type_id'] == 3 || $roomInfo['type_id'] == 4)&& $roomInfo['label_id'] == 2){//k歌
|
||||
}elseif(($roomInfo['type_id'] == 1 || $roomInfo['type_id'] == 3 || $roomInfo['type_id'] == 4 || $roomInfo['type_id'] == 8)&& $roomInfo['label_id'] == 2){//k歌
|
||||
//他的点歌列表
|
||||
$song_list = db::name('vs_room_song')->where(['room_id' => $room_user, 'user_id' => $user_id])->select();
|
||||
if(count($song_list) > 0){
|
||||
foreach ($song_list as $key => $value){
|
||||
foreach ($song_list as $value){
|
||||
if($value['status'] == 2 && $value['times_status'] == 1){
|
||||
//切歌
|
||||
model('api/RoomSong')->change_song($room_id,$value['did']);
|
||||
@@ -608,7 +593,7 @@ class Room extends Model
|
||||
}
|
||||
//记录用户退出房
|
||||
$this->quit_room($user_id, $room_user,$user_id);
|
||||
}elseif($roomInfo['type_id'] == 3){
|
||||
}elseif($roomInfo['type_id'] == 2){
|
||||
//是否在拍卖位
|
||||
$pitNumber = Cache::get('auction_user_'.$room_user);
|
||||
if(isset($pitNumber) && $pitNumber == $user_id){
|
||||
@@ -636,7 +621,7 @@ class Room extends Model
|
||||
$user_pit = 0;
|
||||
$pit_list = [];
|
||||
$cp_users = null;
|
||||
if($room['type_id'] == 1 || $room['type_id'] == 3 || $room['type_id'] == 4) {//1点唱,3男神,4女神
|
||||
if($room['type_id'] == 1 || $room['type_id'] == 3 || $room['type_id'] == 4 || $room['type_id'] == 7 || $room['type_id'] == 8) {//1点唱,3男神,4女神
|
||||
if($room['label_id'] == 2){//K歌
|
||||
$song = $this->get_song_info($room_id,$user_id);
|
||||
$song_list = $song['song_user_info'];
|
||||
@@ -706,6 +691,7 @@ class Room extends Model
|
||||
if (!$is_join) {
|
||||
db::name('vs_room_visitor')->insert(['room_id' => $room_id, 'user_id' => $user_id, 'createtime' => time()]);
|
||||
}
|
||||
db::name('user_data')->where('user_id', $user_id)->update(['room_id' => $room_id]);
|
||||
|
||||
$room['is_use_code'] = 0;
|
||||
$liang = model('api/Decorate')->user_decorate_detail($room['id'],7);
|
||||
@@ -853,6 +839,27 @@ class Room extends Model
|
||||
if($user_id != $room_owner['user_id']){
|
||||
model('api/User')->add_user_visit_log(2,$user_id, $room_id);
|
||||
}
|
||||
|
||||
//交友相关回值
|
||||
if($room['type_id'] == 7){
|
||||
$friend = $this->getRoomFriendData($room_id);
|
||||
//交友状态 交友进行到第几步 1等待邂逅 2心动连线 3牵手良缘
|
||||
$friend['step'] =$room['step'];
|
||||
}else{
|
||||
$friend = null;
|
||||
}
|
||||
|
||||
$xlh_info['xlh_info'] = model('BlindBoxTurntableGift')->get_user_xlh_info($room_id);
|
||||
$open_time = db::name('vs_hour_ranking_config')->where('id', 1)->value('open_time');
|
||||
if($open_time > 0){
|
||||
if($open_time <= time()){
|
||||
$hour_open = 1;//开启
|
||||
}else{
|
||||
$hour_open = 0;//关闭
|
||||
}
|
||||
}else{
|
||||
$hour_open = 0;//关闭
|
||||
}
|
||||
return ['code' => 1,
|
||||
'msg' => '成功',
|
||||
'data' => ['room_info' => $room_info,
|
||||
@@ -863,7 +870,10 @@ class Room extends Model
|
||||
'room_auction'=>$roomauction,
|
||||
'cp_user'=>$cp_users,
|
||||
'pk_info' => $pk_info,
|
||||
'song_pit_list' => $song_pit_list
|
||||
'song_pit_list' => $song_pit_list,
|
||||
'friend_info' => $friend,
|
||||
'gift_cycle' => $xlh_info,
|
||||
'hour_ranking_open' => $hour_open
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -1072,10 +1082,14 @@ class Room extends Model
|
||||
$room_label = $res['data']['label_id'];
|
||||
$room_type = $res['data']['type_id'];
|
||||
$apply_type = 0;
|
||||
if($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
if($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
||||
$apply_type = 1;
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
||||
$apply_type = 2;
|
||||
}elseif ($room_type == 7){//交友房 再开始阶段在麦位上不下麦
|
||||
$apply_type = 3;
|
||||
}elseif($room_type == 6 && $room_label == 5){ //交友私密屋
|
||||
$apply_type = 4;
|
||||
}
|
||||
|
||||
if($apply_type == 1){
|
||||
@@ -1101,7 +1115,18 @@ class Room extends Model
|
||||
$text['pit_number'] = '';
|
||||
model('api/Chat')->sendMsg(1004,$room_id,$text);
|
||||
}
|
||||
}else{
|
||||
}elseif ($apply_type == 3){
|
||||
$roomInfoStep = db::name('vs_room')->where(['id' => $room_id])->value('step');
|
||||
$room_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->find();
|
||||
if($roomInfoStep == 1 || ($roomInfoStep == 2 && ($room_pit['pit_number'] == 9 || $room_pit['pit_number'] == 10))){
|
||||
if (isset($room_pit)) {
|
||||
model('api/RoomPit')->DownPit($user_id, $room_id, $room_pit['pit_number']);
|
||||
}
|
||||
}
|
||||
}elseif ($apply_type == 4){
|
||||
model('api/Friend')->outRoom($uid, $room_id);
|
||||
}
|
||||
else{
|
||||
//在麦位上 移除用户
|
||||
$room_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->find();
|
||||
if (isset($room_pit)) {
|
||||
@@ -1132,7 +1157,7 @@ class Room extends Model
|
||||
}else{
|
||||
$room_typer = '管理员';
|
||||
}
|
||||
db::name('vs_room_black')->insert(['room_id' => $room_id, 'user_id' => $uid,'black_id' => $user_id,'type' => 1,'kick_time' => time()+300,'createtime' => time()]);
|
||||
db::name('vs_room_black')->insert(['room_id' => $room_id, 'user_id' => $uid,'black_id' => $user_id,'type' => 1,'kick_time' => time()+600,'createtime' => time()]);
|
||||
//发送消息
|
||||
|
||||
$text['text'] = '用户 ' . $nickname . ' 被 '. $room_typer .' 踢出房间';
|
||||
@@ -1140,6 +1165,12 @@ class Room extends Model
|
||||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||||
model('api/Room')->room_operation_record($uid,$room_id,5,$user_id);
|
||||
}
|
||||
if($type == 2){
|
||||
$text['text'] = '用户 ' . $nickname . ' 被 踢出房间';
|
||||
model('api/Chat')->sendMsg(1011,$room_id,$text,$user_id);
|
||||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||||
model('api/Room')->room_operation_record($uid,$room_id,5,$user_id);
|
||||
}
|
||||
if($type == 0){
|
||||
//发送消息
|
||||
$text['text'] = '用户 ' . $nickname .' 退出了房间';
|
||||
@@ -1168,13 +1199,6 @@ class Room extends Model
|
||||
$where['a.createtime'] = ['between', [strtotime('this week Monday'), time()]];
|
||||
}
|
||||
if($type == 1){//1财富榜,2魅力榜
|
||||
// $list = db::name('vs_room_user_charm')->alias('a')
|
||||
// ->join('user b', 'a.user_id = b.id')
|
||||
// ->field('a.user_id,b.nickname,b.avatar,a.total_wealth as total')
|
||||
// ->where($where)
|
||||
// ->order('a.total_wealth desc')
|
||||
// ->page($page, $limit)
|
||||
// ->select();
|
||||
$list = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field('a.user_id,b.nickname,b.avatar,sum(a.total_price) * 10 as total')
|
||||
@@ -1184,13 +1208,6 @@ class Room extends Model
|
||||
->page($page, $limit)
|
||||
->select();
|
||||
}else{
|
||||
// $list = db::name('vs_room_user_charm')->alias('a')
|
||||
// ->join('user b', 'a.user_id = b.id')
|
||||
// ->field('a.user_id,b.nickname,b.avatar,a.total_charm as total')
|
||||
// ->where($where)
|
||||
// ->order('a.total_charm desc')
|
||||
// ->page($page, $limit)
|
||||
// ->select();
|
||||
$list = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.gift_user = b.id')
|
||||
->field('a.gift_user as user_id,b.nickname,b.avatar,sum(a.total_price) * 10 as total')
|
||||
@@ -1213,7 +1230,7 @@ class Room extends Model
|
||||
|
||||
|
||||
//房间送礼
|
||||
public function room_gift($uid, $to_uid, $gift_id, $gift_num,$type, $room_id, $pit_number)
|
||||
public function room_gift($uid, $to_uid, $gift_id, $gift_num,$type, $room_id, $pit_number, $heart_id,$give_gift_ext="")
|
||||
{
|
||||
$label_type = model('Room')->get_room_label($room_id);
|
||||
if($label_type['code'] != 1){
|
||||
@@ -1228,11 +1245,11 @@ class Room extends Model
|
||||
//$from_type 来源 1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼
|
||||
//$type 1金币购买 2送背包礼物
|
||||
//送礼人,接收者(群),礼物id,礼物数量,来源,类型,来源id(房间id),麦位
|
||||
$res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number);
|
||||
$res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number,0,$give_gift_ext);
|
||||
return $res;
|
||||
}elseif (($label_type['data']['type_id'] == 1 || $label_type['data']['type_id'] == 3 || $label_type['data']['type_id'] == 4) && $label_type['data']['label_id'] == 2)//K歌,type_id = 1,label_id = 2
|
||||
}elseif (($label_type['data']['type_id'] == 1 || $label_type['data']['type_id'] == 3 || $label_type['data']['type_id'] == 4 || $label_type['data']['type_id'] == 8) && $label_type['data']['label_id'] == 2)//K歌,type_id = 1,label_id = 2
|
||||
{
|
||||
$res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number);
|
||||
$res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number,0,$give_gift_ext);
|
||||
if($res['code'] == 1){
|
||||
$room_pits = model('RoomSong')->get_charm_rank($room_id);
|
||||
if($room_pits['code'] == 1){
|
||||
@@ -1246,13 +1263,31 @@ class Room extends Model
|
||||
}
|
||||
return $res;
|
||||
}elseif($label_type['data']['type_id'] == 6){
|
||||
return model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num,6,$type, $room_id,$pit_number);
|
||||
return model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num,6,$type, $room_id,$pit_number,0,$give_gift_ext);
|
||||
}elseif($label_type['data']['type_id'] == 7){
|
||||
return model('Friend')->room_give_gift($uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number,$heart_id,$give_gift_ext);
|
||||
}else{
|
||||
$res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number);
|
||||
return $res;
|
||||
return model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number,0,$give_gift_ext);
|
||||
}
|
||||
}
|
||||
|
||||
//背包礼物一键全清
|
||||
public function room_gift_all_clear($uid, $room_id, $user_id,$heart_id,$auction_id = 0)
|
||||
{
|
||||
$user_gift_pack = db::name('vs_user_gift_pack')->where(['user_id'=>$uid,'is_tester'=>1,'is_use_give'=>1,'num'=>['>',0]])->select();
|
||||
if (empty($user_gift_pack)) {
|
||||
return ['code' => 0, 'msg' => '用户背包礼物不足', 'data' => null];
|
||||
}
|
||||
foreach ($user_gift_pack as $v){
|
||||
if($auction_id){//竞拍
|
||||
model('RoomAuction')->room_auction_join($auction_id,$uid,$v['gid'],$v['num'],2);
|
||||
}else{
|
||||
$this->room_gift($uid, $user_id, $v['gid'], $v['num'],2,$room_id, 0,$heart_id);
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
//房间在线列表
|
||||
public function room_online_list($room_id, $page, $limit)
|
||||
@@ -1263,83 +1298,29 @@ class Room extends Model
|
||||
if ($label_type['code'] != 1) {
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
|
||||
//获取在房间的用户
|
||||
$in_room_users = db::name('vs_room_visitor')->where(['room_id' => $room_id])->field('user_id')->select();
|
||||
if($in_room_users){
|
||||
foreach ($in_room_users as $v){
|
||||
$userss = db::name('user')->where(['id' => $v['user_id']])->field('is_online,is_robot')->find();
|
||||
if($userss['is_online'] == 1 && $userss['is_robot'] == 1){//在线或者机器人都设置为在线
|
||||
db::name('vs_room_visitor')->where(['id' => $v['id']])->update(['on_line' => 1]);
|
||||
//查询房间里面的用户
|
||||
$room_user = db::name('vs_room_visitor')->where(['room_id' => $room_id])->select();
|
||||
if($room_user){
|
||||
foreach ($room_user as $vv){
|
||||
if(($label_type['data']['type_id'] == 1 || $label_type['data']['type_id'] == 8) && $label_type['data']['label_id'] == 1){
|
||||
//不做处理
|
||||
}else{
|
||||
db::name('vs_room_visitor')->where(['id' => $v['id']])->update(['on_line' => 0]);
|
||||
//查询是否有切后台的操作
|
||||
$bg_room = db::name('vs_user_in_room_bg')->where(['room_id' => $room_id,'user_id' => $vv['user_id']])->find();
|
||||
|
||||
if(Db::name('user')->where('id', $vv['user_id'])->value('is_online') == 0 && !$bg_room){
|
||||
model('Room')->quit_room($vv['user_id'], $room_id,$vv['user_id'],2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// //查找数据库用户
|
||||
// $dblist = db::name('vs_room_visitor')->where(['room_id' => $room_id])->field('user_id')->select();
|
||||
// //循环获取在线用户ID 拼接数据
|
||||
// $user_id_array = [];
|
||||
// //机器人user_id
|
||||
// $robot_user_id = [];
|
||||
// foreach ($dblist as $v) {
|
||||
// //机器人
|
||||
// if(db::name('user')->where(['id' => $v['user_id']])->value('is_robot')){
|
||||
// $robot_user_id[] = $v['user_id'];
|
||||
// continue;
|
||||
// }
|
||||
// $user_id_array[] = 'u'.$v['user_id'];
|
||||
// }
|
||||
// //获取腾讯的在线用户
|
||||
// $online_users = model('Tencent')->query_user_online_status($user_id_array);
|
||||
// $online_user = [];
|
||||
// if(isset($online_users['ActionStatus']) && $online_users['ActionStatus'] == 'OK'){
|
||||
// if($online_users['QueryResult']){
|
||||
// foreach ($online_users['QueryResult'] as $v){
|
||||
// if($v['Status'] == "Online"){
|
||||
// //截取用户ID前面的 u 并获取用户ID
|
||||
// $user_id = substr($v['To_Account'],1);
|
||||
// $online_user[] = $user_id;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if($dblist){
|
||||
// $onpit = db::name('vs_room_pit')->field('user_id')->where(['room_id' => $room_id])->select();
|
||||
// //合并数组
|
||||
// $array = array_merge($online_user,$robot_user_id);
|
||||
//// $array = $online_user;
|
||||
// $arraypit = array_values((array)$onpit);
|
||||
// foreach ($dblist as &$v){
|
||||
//// if(in_array($v['user_id'],$arraypit)){
|
||||
//// //跳过本次循环
|
||||
//// continue;
|
||||
//// }
|
||||
// if(!in_array($v['user_id'],$array)){
|
||||
// //修改他的状态
|
||||
// db::name('vs_room_visitor')->where(['user_id' => $v['user_id'],'room_id'=>$room_id])->update(['on_line' => 0]);
|
||||
// //查询他是否在其他房间
|
||||
// $room_id_list = db::name('vs_room_visitor')->where(['user_id' => $v['user_id'],'room_id'=>['neq',$room_id]])->find();
|
||||
// if($room_id_list){
|
||||
// db::name('vs_room_visitor')->where(['user_id' => $v['user_id']])->delete();
|
||||
// }
|
||||
// }else{
|
||||
// //修改他的状态
|
||||
// db::name('vs_room_visitor')->where(['user_id' => $v['user_id'],'room_id'=>$room_id])->update(['on_line' => 1]);
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// $lists = ['on_pit' => [], 'off_pit' => []];
|
||||
// return ['code' => 1, 'msg' => '成功', 'data' => $lists];
|
||||
// }
|
||||
|
||||
|
||||
$list = db::name('vs_room_visitor')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field('a.user_id,b.nickname,b.avatar')
|
||||
->where(['a.room_id' => $room_id,'on_line' => 1])
|
||||
->where(['a.room_id' => $room_id,'b.is_online' => 1])
|
||||
->group('a.user_id')
|
||||
->order('a.id asc')
|
||||
->page($page, $limit)
|
||||
->select();
|
||||
@@ -1361,17 +1342,16 @@ class Room extends Model
|
||||
});
|
||||
}
|
||||
|
||||
if($label_type['data']['type_id'] == 7 || ($label_type['data']['type_id'] == 1 || $label_type['data']['type_id'] == 3 || $label_type['data']['type_id'] == 4) && $label_type['data']['label_id'] == 1) {//2卡八麦(聊天)type_id = 1 || 7(交友),label_id = 1
|
||||
foreach ($list as &$val) {
|
||||
if($label_type['data']['type_id'] == 7 || ($label_type['data']['type_id'] == 1 || $label_type['data']['type_id'] == 3 || $label_type['data']['type_id'] == 4 || $label_type['data']['type_id'] == 8) && $label_type['data']['label_id'] == 1) {//2卡八麦(聊天)type_id = 1 || 7(交友),label_id = 1
|
||||
foreach ($list as $val) {
|
||||
if ($val['pit_number'] > 0) {
|
||||
$lists['on_pit'][] = $val;
|
||||
} else {
|
||||
$lists['off_pit'][] = $val;
|
||||
}
|
||||
}
|
||||
}elseif(($label_type['data']['type_id'] == 1 || $label_type['data']['type_id'] == 3 || $label_type['data']['type_id'] == 4) && $label_type['data']['label_id'] == 2){
|
||||
foreach ($list as &$val) {
|
||||
// var_dump($val['pit_number']);exit;
|
||||
}elseif(($label_type['data']['type_id'] == 1 || $label_type['data']['type_id'] == 3 || $label_type['data']['type_id'] == 4 || $label_type['data']['type_id'] == 8) && $label_type['data']['label_id'] == 2){
|
||||
foreach ($list as $val) {
|
||||
if (db::name('vs_room_pit_simulate')->where(['room_id' => $room_id,'user_id' => $val['user_id']])->find() || $val['pit_number'] > 0) {
|
||||
$lists['on_pit'][] = $val;
|
||||
} else {
|
||||
@@ -1391,7 +1371,7 @@ class Room extends Model
|
||||
if($auct){
|
||||
//获取数组里面的用户ID 组成新的数组
|
||||
$user_ids = array_column((array)$auct, 'user_id');
|
||||
foreach ($list as &$val) {
|
||||
foreach ($list as $val) {
|
||||
if (in_array($val['user_id'], $user_ids) || $val['pit_number'] > 0) {
|
||||
$lists['on_pit'][] = $val;
|
||||
} else {
|
||||
@@ -1399,7 +1379,7 @@ class Room extends Model
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach ($list as &$val) {
|
||||
foreach ($list as $val) {
|
||||
if ($val['pit_number'] > 0) {
|
||||
$lists['on_pit'][] = $val;
|
||||
} else {
|
||||
@@ -1409,8 +1389,7 @@ class Room extends Model
|
||||
}
|
||||
|
||||
}else{
|
||||
foreach ($list as &$val) {
|
||||
// $lists['off_pit'][] = $val;
|
||||
foreach ($list as $val) {
|
||||
if ($val['pit_number'] > 0) {
|
||||
$lists['on_pit'][] = $val;
|
||||
} else {
|
||||
@@ -1420,6 +1399,7 @@ class Room extends Model
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $lists];
|
||||
}
|
||||
|
||||
@@ -1472,7 +1452,7 @@ class Room extends Model
|
||||
$user_info['is_in_pit'] = 1;
|
||||
}
|
||||
}
|
||||
}elseif (($room_type['type_id'] == 1 || $room_type['type_id'] == 3 || $room_type['type_id'] == 4) && $room_type['label_id'] == 1){
|
||||
}elseif ($room_type['type_id'] == 7 || ($room_type['type_id'] == 1 || $room_type['type_id'] == 3 || $room_type['type_id'] == 4 || $room_type['type_id'] == 8) && $room_type['label_id'] == 1){
|
||||
$hah = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->find();
|
||||
if($hah){
|
||||
$user_info['is_in_pit'] = 1;
|
||||
@@ -1558,6 +1538,7 @@ class Room extends Model
|
||||
'GiftInfo' => null,
|
||||
'GiftNum' => null
|
||||
];
|
||||
$typee = 0;
|
||||
if($type == 1){//1-主持,2管理
|
||||
if($is_add == 1){//1-添加,2-删除
|
||||
$typee = 1007;
|
||||
@@ -1633,6 +1614,9 @@ class Room extends Model
|
||||
if(!$is_host){
|
||||
return ['code' => 0, 'msg' => '用户不是主持人,不能设置收益', 'data' => null];
|
||||
}
|
||||
if($profit < 0 || $profit > 100){
|
||||
return ['code' => 0, 'msg' => '请输入正确的比例 0-100', 'data' => null];
|
||||
}
|
||||
$res = db::name('vs_room_host')->where(['room_id' => $room_id,'user_id' => $user_id,'type' => 1,'delete_time' => null])
|
||||
->update(['ratio' => $profit]);
|
||||
if(!$res){
|
||||
@@ -1642,10 +1626,8 @@ class Room extends Model
|
||||
}
|
||||
|
||||
//清除房间用户的魅力值
|
||||
public function clear_user_charm($user_id ,$room_id,$uid)
|
||||
public function clear_user_charm($user_id ,$room_id,$uid='')
|
||||
{
|
||||
//判断用户是否在主持麦
|
||||
// $is_host = db::name('vs_room_pit')->where(['room_id' => $room_id,'user_id' => $user_id,'pit_number' => 9])->find();
|
||||
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$management = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->find();
|
||||
if(!$owner && !$management){
|
||||
@@ -1653,24 +1635,18 @@ class Room extends Model
|
||||
}
|
||||
|
||||
if($uid <= 0){
|
||||
//获取房间内所有用户
|
||||
$list = db::name('vs_room_visitor')->field('user_id')->where(['room_id' => $room_id])->select();
|
||||
|
||||
//循环清除用户魅力值
|
||||
if($list){
|
||||
foreach ($list as $v){
|
||||
//清除有魅力值的用户
|
||||
if(db::name('vs_room_user_charm')->where(['room_id' => $room_id,'user_id' => $v['user_id']])->find()){
|
||||
db::name('vs_room_user_charm')->where(['room_id' => $room_id,'user_id' => $v['user_id']])->update(['charm' => 0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
db::name('vs_room_user_charm')->where(['room_id' => $room_id])->update(['charm' => 0,'clear_time' => time()]);
|
||||
//发送消息
|
||||
$text['text'] = '清除魅力成功';
|
||||
model('Chat')->sendMsg(1021,$room_id,$text);
|
||||
}else{
|
||||
$dd = db::name('vs_room_user_charm')->where(['room_id' => $room_id,'user_id' => $uid])->update(['charm' => 0]);
|
||||
db::name('vs_room_user_charm')->where(['room_id' => $room_id,'user_id' => $uid])->update(['charm' => 0,'clear_time' => time()]);
|
||||
//发送消息
|
||||
$text['text'] = '清除魅力成功';
|
||||
$text['user_id'] = $uid;
|
||||
model('Chat')->sendMsg(1059,$room_id,$text);
|
||||
}
|
||||
//发送消息
|
||||
$text['text'] = '清除魅力成功';
|
||||
model('Chat')->sendMsg(1021,$room_id,$text);
|
||||
|
||||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||||
model('Room')->room_operation_record($user_id,$room_id,3);
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
@@ -1694,9 +1670,21 @@ class Room extends Model
|
||||
return ['code' => 0, 'msg' => '房间类型已存在', 'data' => null];
|
||||
}
|
||||
|
||||
if($roomInfo['type_id'] == 7 && ($roomInfo['step'] == 2 || $roomInfo['step'] == 3)){
|
||||
return ['code' => 0, 'msg' => '请先结束交友后在修改房间类型', 'data' => null];
|
||||
}
|
||||
|
||||
if($roomInfo['type_id'] == 2){
|
||||
$room_auction = db::name('vs_room_auction')->where(['room_id' => $room_id,'status' => 2])->select();
|
||||
if($room_auction){
|
||||
return ['code' => 0, 'msg' => '请先结束竞拍后在修改房间类型', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
if($type == 1 || $type == 3 || $type == 4){
|
||||
$data = [];
|
||||
if($type == 1 || $type == 3 || $type == 4 || $type == 8){
|
||||
$data = [
|
||||
'label_id' => 1,
|
||||
'type_id' => $type,
|
||||
@@ -1712,6 +1700,14 @@ class Room extends Model
|
||||
'is_song' => 1
|
||||
];
|
||||
}
|
||||
//交友房(互娱)
|
||||
if($type == 7){
|
||||
$data = [
|
||||
'label_id' => 5,
|
||||
'type_id' => $type,
|
||||
'room_up_pit_type' => 1,
|
||||
];
|
||||
}
|
||||
$res = db::name('vs_room')->where(['id' => $room_id])->update($data);
|
||||
|
||||
if(!$res){
|
||||
@@ -1737,12 +1733,8 @@ class Room extends Model
|
||||
db::name('vs_room_pit_simulate')->where(['room_id' => $room_id])->delete();
|
||||
//申请上麦的全部下麦
|
||||
model('RoomPit')->clear_apply_pit_list($uid, $room_id);
|
||||
//处理之前修改的用户房间信息
|
||||
if($type == 1 || $type == 3 || $type == 4){
|
||||
db::name('vs_room_pit')->where(['pit_number' =>['>',10]])->update(['status' => 2]);
|
||||
}
|
||||
|
||||
if($type == 1 || $type == 3 || $type == 4){
|
||||
if($type == 1 || $type == 3 || $type == 4 || $type == 7 || $type == 8){
|
||||
//查询拍卖房的状态
|
||||
$room_auction = db::name('vs_room_auction')->where(['room_id' => $room_id,'status' => 2])->select();
|
||||
if($room_auction){
|
||||
@@ -1750,10 +1742,16 @@ class Room extends Model
|
||||
model('RoomAuction')->room_auction_end($room_id,$v['auction_id']);
|
||||
}
|
||||
}
|
||||
//拍卖位上是否有人
|
||||
$an = Cache::get('auction_user_'.$room_id);
|
||||
if($an){
|
||||
//拍卖位下麦
|
||||
model('api/RoomPit')->host_user_pit($uid,$room_id,888,$an,2);
|
||||
}
|
||||
}
|
||||
if($type == 2){
|
||||
//清除房间此前的魅力值
|
||||
db::name('vs_room_user_charm')->where(['room_id' => $room_id])->update(['charm' => 0]);
|
||||
db::name('vs_room_user_charm')->where(['room_id' => $room_id])->update(['charm' => 0,'clear_time' => time()]);
|
||||
//10号麦有人就下去
|
||||
$pit_10 = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => 10])->find();
|
||||
if($pit_10 && $pit_10['user_id'] > 0){
|
||||
@@ -1769,6 +1767,15 @@ class Room extends Model
|
||||
'text' => '房间类型已修改type--'.$type
|
||||
];
|
||||
model('Chat')->sendMsg(1012,$room_id,$text);
|
||||
//查询房间里面的用户
|
||||
$room_user = db::name('vs_room_visitor')->where(['room_id' => $room_id])->select();
|
||||
if($room_user){
|
||||
foreach ($room_user as $v){
|
||||
if(Db::name('user')->where('id', $v['user_id'])->value('is_online') == 0){
|
||||
model('Room')->quit_room($v['user_id'], $room_id,$v['user_id'],2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
|
||||
@@ -1805,6 +1812,11 @@ class Room extends Model
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
$user_in_room = db::name('vs_room_visitor')->where(['room_id' => $room_id,'user_id' => $user_id])->find();
|
||||
if(!$user_in_room){
|
||||
// return ['code' => 0, 'msg' => '您已不在此房间', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '', 'data' => null];
|
||||
}
|
||||
$room = db::name('vs_room')->where(['id' => $room_id])->find();
|
||||
$song_list = null;
|
||||
$next_song_info = null;
|
||||
@@ -1813,8 +1825,8 @@ class Room extends Model
|
||||
$pit_list = null;
|
||||
$roomauction = null;
|
||||
$cp_users = null;
|
||||
if($room['type_id'] == 1 || $room['type_id'] == 3 || $room['type_id'] == 4) {
|
||||
if($room['label_id'] == 1){
|
||||
if($room['type_id'] == 1 || $room['type_id'] == 3 || $room['type_id'] == 4 || $room['type_id'] == 7 || $room['type_id'] == 8) {
|
||||
if($room['label_id'] == 1 || $room['label_id'] == 5){
|
||||
//麦位信息
|
||||
$pit_list = db::name('vs_room_pit')->alias('a')->join('user b', 'a.user_id = b.id', 'left')
|
||||
->where(['a.room_id' => $room['id'],'a.status' => 1])
|
||||
@@ -2002,6 +2014,27 @@ class Room extends Model
|
||||
$user_info = $this ->get_user_info($room_id,$user_id,$user_pit);
|
||||
$user_info['is_room_owner'] = ($user_id == $room['user_id']) ? 1 : 0;
|
||||
|
||||
//交友相关回值
|
||||
if($room['type_id'] == 7){
|
||||
$friend = $this->getRoomFriendData($room_id);
|
||||
//交友状态 交友进行到第几步 1等待邂逅 2心动连线 3牵手良缘
|
||||
$friend['step'] =$room['step'];
|
||||
}else{
|
||||
$friend = null;
|
||||
}
|
||||
|
||||
$xlh_info['xlh_info'] = model('BlindBoxTurntableGift')->get_user_xlh_info($room_id);
|
||||
$open_time = db::name('vs_hour_ranking_config')->order('id', 'desc')->value('open_time');
|
||||
if($open_time > 0){
|
||||
if($open_time <= time()){
|
||||
$hour_open = 1;//开启
|
||||
}else{
|
||||
$hour_open = 0;//关闭
|
||||
}
|
||||
}else{
|
||||
$hour_open = 0;//关闭
|
||||
}
|
||||
|
||||
return ['code' => 1,
|
||||
'msg' => '成功',
|
||||
'data' => ['room_info' => $room_info,
|
||||
@@ -2012,7 +2045,10 @@ class Room extends Model
|
||||
'room_auction'=>$roomauction,
|
||||
'cp_user'=>$cp_users,
|
||||
'pk_info'=>$pk_info,
|
||||
'song_pit_list'=>$song_pit_list
|
||||
'song_pit_list'=>$song_pit_list,
|
||||
'friend_info' => $friend,
|
||||
'gift_cycle' => $xlh_info,
|
||||
'hour_ranking_open' => $hour_open
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -2032,11 +2068,7 @@ class Room extends Model
|
||||
if(!$is_host && !$is_room_owner){
|
||||
return ['code' => 0, 'msg' => '您没有权限', 'data' => null];
|
||||
}
|
||||
//是否在主持麦位上
|
||||
// $is_pit = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => 9])->value('user_id');
|
||||
// if($uid != $is_pit){
|
||||
// return ['code' => 0, 'msg' => '您没有权限', 'data' => null];
|
||||
// }
|
||||
|
||||
if(!in_array($is_mute, [1,2,3,4])){
|
||||
return ['code' => 0, 'msg' => '参数错误!', 'data' => null];
|
||||
}
|
||||
@@ -2222,7 +2254,7 @@ class Room extends Model
|
||||
->join('user c','a.user_id2 = c.id','left')
|
||||
->join('vs_relation d','a.relation_id = d.id','left')//关系
|
||||
->field('a.relation_id,a.cp_room_id,a.id,a.user_id1,a.user_id2,a.updatetime,a.time_day,a.end_time,b.nickname as nickname1,b.avatar as avatar1,c.nickname as nickname2,c.avatar as avatar2,d.name as relation_name,d.icon as image')
|
||||
->where(['a.user_id1' => $user_id,'a.end_time' =>['>',time()],'a.delete_time' => 0])
|
||||
->where(['a.user_id1' => $user_id,'a.end_time' =>['>',time()],'a.delete_time' => 0,'a.relation_id' => ['>',0]])
|
||||
->order('a.updatetime desc')
|
||||
->select();
|
||||
$room_auction2 = db::name('vs_room_auction_relation')->alias('a')
|
||||
@@ -2230,7 +2262,7 @@ class Room extends Model
|
||||
->join('user c','a.user_id2 = c.id','left')
|
||||
->join('vs_relation d','a.relation_id = d.id','left')//关系
|
||||
->field('a.relation_id,a.cp_room_id,a.id,a.user_id1,a.user_id2,a.updatetime,a.time_day,a.end_time,b.nickname as nickname1,b.avatar as avatar1,c.nickname as nickname2,c.avatar as avatar2,d.name as relation_name,d.icon as image')
|
||||
->where(['a.user_id2' => $user_id,'a.end_time' =>['>',time()],'a.delete_time' => 0])
|
||||
->where(['a.user_id2' => $user_id,'a.end_time' =>['>',time()],'a.delete_time' => 0,'a.relation_id' => ['>',0]])
|
||||
->order('a.updatetime desc')
|
||||
->select();
|
||||
|
||||
@@ -2475,4 +2507,128 @@ class Room extends Model
|
||||
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => $data];
|
||||
}
|
||||
|
||||
public function getRoomFriendData($room_id)
|
||||
{
|
||||
//交友相关回值
|
||||
$friend = [];
|
||||
$friend['friend_id'] = 0;//场次ID
|
||||
//查询用户交友表
|
||||
$friend_info = db::name('vs_user_friending')->where(['room_id' => $room_id,'status' => 1])->order('id', 'desc')->find();
|
||||
$friend['room_on_line_cp'] = 0;
|
||||
$friend['heart_list'] = [];
|
||||
$friend['is_preside'] = 0;
|
||||
$friend['end_time'] = 0;
|
||||
if($friend_info){
|
||||
$friend['friend_id'] = $friend_info['id'];
|
||||
$friend['end_time'] = $friend_info['end_time'];
|
||||
$friend['heart_list'] = model('Friend')->pullHeartChange($room_id, $friend_info['id']);
|
||||
}
|
||||
return $friend;
|
||||
}
|
||||
|
||||
|
||||
//房间用户当前魅力值列表
|
||||
public function room_user_charm_list($room_id, $user_id)
|
||||
{
|
||||
if($room_id == '' || $user_id == ''){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
$clear_time = db::name('vs_room_user_charm')->where(['room_id' => $room_id, 'user_id' => $user_id])
|
||||
->order('id', 'desc')->value('clear_time') ?? 0;
|
||||
$list = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.user_id=b.id')
|
||||
->field('a.user_id,sum(a.total_price) as total_price,b.nickname,b.avatar,b.user_code')
|
||||
->where(['a.from_id' => $room_id, 'a.gift_user' => $user_id, 'a.createtime' => ['>',$clear_time],'a.from' => 2])
|
||||
->group('a.user_id')->select();
|
||||
if($list){
|
||||
foreach ($list as &$v){
|
||||
$v['charm'] = $v['total_price'] * get_system_config_value('coin_charm_exp');
|
||||
$v['icon'][0] = model('UserData')->user_wealth_icon($v['user_id']);//财富图标
|
||||
$v['icon'][1] = model('UserData')->user_charm_icon($v['user_id']);//魅力图标
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => $list];
|
||||
}
|
||||
|
||||
//用户重连
|
||||
public function user_reconnect($user_id,$room_id)
|
||||
{
|
||||
if(!$room_id){
|
||||
// $room_id = Db::name('user_data')->where('user_id', $user_id)->value('room_id');
|
||||
}
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
//查询用户在几个房间
|
||||
$room = db::name('vs_room_visitor')->where('user_id', $user_id)->select();
|
||||
if($room){
|
||||
$userinroom = 0;
|
||||
foreach ($room as $v){
|
||||
if($v['room_id'] == $room_id){
|
||||
$userinroom = $room_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($userinroom == $room_id){
|
||||
$room_info = db::name('vs_room_visitor')->where(['id' => $room_id])->update(['room_id' => $room_id, 'user_id' => $user_id, 'updatetime' => time(),'remarks' =>'断线后重连']);
|
||||
if(!$room_info){
|
||||
return ['code' => 0, 'msg' => '更新加入房间失败', 'data' => null];
|
||||
}
|
||||
}else
|
||||
{
|
||||
$room_info = db::name('vs_room_visitor')->insert(['room_id' => $room_id, 'user_id' => $user_id, 'createtime' => time(),'remarks' =>'断线后重连']);
|
||||
if(!$room_info){
|
||||
return ['code' => 0, 'msg' => '加入房间失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
$room_info = db::name('vs_room_visitor')->insert(['room_id' => $room_id, 'user_id' => $user_id, 'createtime' => time(),'remarks' =>'断线后重连']);
|
||||
if(!$room_info){
|
||||
return ['code' => 0, 'msg' => '加入房间失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
//用户在房间内切后台保留机制
|
||||
public function user_in_room_background($user_id,$room_id,$type)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
$room_t = db::name('vs_room')->field('type_id,label_id')->where('id',$room_id)->find();
|
||||
if(!(($room_t['type_id'] == 1 || $room_t['type_id'] == 8) && $room_t['label_id'] == 1)){
|
||||
if($type == 1){//1-切后台,2-切前台
|
||||
$is_bg = db::name('vs_user_in_room_bg')->where(['user_id' => $user_id,'room_id' => $room_id])->find();
|
||||
if($is_bg){
|
||||
$up_bg = [
|
||||
'updatetime' => time(),
|
||||
];
|
||||
db::name('vs_user_in_room_bg')->where('id',$is_bg['id'])->update($up_bg);
|
||||
}else{
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'room_id' => $room_id,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
];
|
||||
$room_background = db::name('vs_user_in_room_bg')->insert($data);
|
||||
if(!$room_background){
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
db::name('vs_user_in_room_bg')->where(['user_id' => $user_id,'room_id' => $room_id])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class RoomAuction extends Model
|
||||
|
||||
|
||||
//参与竞拍
|
||||
public function room_auction_join($auction_id,$user_id,$gift_id,$num,$type)
|
||||
public function room_auction_join($auction_id,$user_id,$gift_id,$num,$type,$ext=[])
|
||||
{
|
||||
if(!$auction_id){
|
||||
return ['code' => 0, 'msg' => '拍卖已经结束','data' => null];
|
||||
@@ -127,7 +127,7 @@ class RoomAuction extends Model
|
||||
}
|
||||
|
||||
//走送礼流程
|
||||
$ree = model('GiveGift')->give_gift($user_id,$auction['user_id'],$gift_id,$num,2,$type,$auction['room_id'],0,0);
|
||||
$ree = model('GiveGift')->give_gift($user_id,$auction['user_id'],$gift_id,$num,2,$type,$auction['room_id'],0,0,$ext);
|
||||
if($ree['code'] != 1){
|
||||
return ['code' => $ree['code'], 'msg' => $ree['msg'],'data' => null];
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class RoomAuction extends Model
|
||||
'auction_id' => $auction_id,
|
||||
'user_id' => $user_id,
|
||||
'gift_id' => $gift_id,
|
||||
'gift_price' => $num * $gift_price,
|
||||
'gift_price' => $ree['data']['gift_total'],
|
||||
'createtime' => time()
|
||||
]);
|
||||
if(!$res){
|
||||
@@ -167,7 +167,7 @@ class RoomAuction extends Model
|
||||
->where(['auction_id' => $auction_id])
|
||||
->group('user_id')
|
||||
->having('gift_prices >= ' . $auction['gift_price'])
|
||||
->order('gift_prices DESC')
|
||||
->order('gift_prices DESC, id ASC')
|
||||
->limit(6)
|
||||
->select();
|
||||
if($list){
|
||||
@@ -292,9 +292,11 @@ class RoomAuction extends Model
|
||||
//查询是否有电影房
|
||||
$cp_movie = $this->movie_room_create_or_add($list['user_id'],$res['user_id'],$res['relation_id'],$res['time_day']);
|
||||
if($cp_movie['code'] != 1){
|
||||
return ['code' => 0, 'msg'=>$cp_movie['msg'], 'data'=>$cp_movie['data']];
|
||||
// return ['code' => 0, 'msg'=>$cp_movie['msg'], 'data'=>$cp_movie['data']];
|
||||
}else{
|
||||
$cp_room_id = $cp_movie['data']['cp_room_id'];
|
||||
}
|
||||
$cp_room_id = $cp_movie['data']['cp_room_id'];
|
||||
|
||||
}
|
||||
$texts = '恭喜'.$auction['nickname'].' 和 '.$recipient['nickname'].',获得'.$auction['relation_name'].' 关系'.$auction['time_day'].'小时';
|
||||
}else{//拍得无关系
|
||||
|
||||
@@ -98,6 +98,16 @@ class RoomPit extends Model
|
||||
];
|
||||
model('Tencent')->batchsendmsg($remind_user,json_encode($content));
|
||||
}
|
||||
$reslut = db::name('vs_room_pit_apply')->where(['user_id' => $user_id, 'room_id' => $room_id, 'status' => 0])->delete();
|
||||
if($reslut){
|
||||
$count = db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count();
|
||||
//申请上麦推送消息(数据重置)
|
||||
$text = [
|
||||
'text' => '申请上麦',
|
||||
'count' => $count
|
||||
];
|
||||
model('Chat')->sendMsg(1034,$room_id,$text);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}
|
||||
|
||||
@@ -126,6 +136,10 @@ class RoomPit extends Model
|
||||
if($is_pk > 0 && $pit_number == 9){
|
||||
return ['code' => 0, 'msg' => '当前房间正在pk中', 'data' => null];
|
||||
}
|
||||
$step = db::name('vs_room')->where(['id' => $room_id, 'type_id' => 7])->value('step');
|
||||
if($step && $step != 1 && $pit_number < 9){
|
||||
return ['code' => 0, 'msg' => '交友房 此阶段不可操作', 'data' => null];
|
||||
}
|
||||
$FromUserInfo = db::name('user')->where('id',$user_id)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($user_id);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($user_id);//魅力图标
|
||||
@@ -170,7 +184,7 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
//查询房间状态
|
||||
$room_info = db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->field('id,room_status,room_up_pit_type,label_id')->find();
|
||||
$room_info = db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->field('id,room_status,room_up_pit_type,label_id,step')->find();
|
||||
if(!$room_info){
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
@@ -178,19 +192,39 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '房间违规或关闭', 'data' => null];
|
||||
}
|
||||
|
||||
if($pit_number == 9){
|
||||
//检查用户是否是房主或主持
|
||||
$is_room_owner =db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$is_room_host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->field('id')->find();
|
||||
if(!$is_room_owner && !$is_room_host){
|
||||
return ['code' => 0, 'msg' => '没有权限', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
if($pit_number == 10){
|
||||
return ['code' => 0, 'msg' => '请等待主持抱麦', 'data' => null];
|
||||
}
|
||||
|
||||
//检查是否在坑位上
|
||||
$pit_infos = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->field('id,pit_number')->find();
|
||||
if($pit_infos){
|
||||
return ['code' => 0, 'msg' => '您已上麦', 'data' => null];
|
||||
|
||||
if($room_info['label_id'] == 5 && $room_info['step'] != 1 && $pit_number < 9){
|
||||
return ['code' => 0, 'msg' => '互娱房 此阶段不可此操作', 'data' => null];
|
||||
}
|
||||
|
||||
//自由麦
|
||||
if($room_info['room_up_pit_type'] == 2){
|
||||
if($pit_number > 0){
|
||||
if($room_info['label_id'] == 5){//交友(互娱)
|
||||
if($pit_number == 7 || $pit_number == 8){
|
||||
return ['code' => 0, 'msg' => '该麦位已锁定了', 'data' => null];
|
||||
}
|
||||
if($pit_number == 9){
|
||||
if($pit_infos){
|
||||
return ['code' => 0, 'msg' => '您已上麦', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
//查询当前麦位是否有人
|
||||
$pit_info = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_number])->field('id,user_id,is_lock')->find();
|
||||
if($pit_info['user_id'] > 0){
|
||||
@@ -200,106 +234,118 @@ class RoomPit extends Model
|
||||
if($pit_info['is_lock'] == 1){
|
||||
return ['code' => 0, 'msg' => '该麦位被锁定', 'data' => null];
|
||||
}
|
||||
if($pit_number ==9){
|
||||
//检查用户是否是房主或主持
|
||||
$is_room_owner =db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$is_room_host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->field('id')->find();
|
||||
if(!$is_room_owner && !$is_room_host){
|
||||
return ['code' => 0, 'msg' => '您还不是房间主持人', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
// if($room_info['label_id'] == 2){
|
||||
if($room_info['label_id'] == 5){//交友
|
||||
$pit_number = $this->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
}else{
|
||||
$pit_number = $this->getRoomNullPitWithout($room_id, [9, 10]);
|
||||
// }else{
|
||||
// $pit_number = $this->getRoomNullPitWithout($room_id, [9, 10, 11,12,13,14,15,16,17,18,19,20,21,22]);
|
||||
// }
|
||||
}
|
||||
|
||||
if(!$pit_number){
|
||||
return ['code' => 0, 'msg' => '当前房间没有空麦位', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//换麦使用
|
||||
if(isset($pit_infos) && $pit_infos['pit_number'] > 0){
|
||||
//下麦
|
||||
$dow = $this ->DownPit($user_id,$room_id,$pit_infos['pit_number']);
|
||||
if($dow['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
$exchange1 = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_infos['pit_number']])->update([ 'user_id' => 0]);
|
||||
$exchange = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_number])->update([ 'user_id' => $user_id]);
|
||||
if(!$exchange || !$exchange1){
|
||||
return ['code' => 0, 'msg' => '换麦失败', 'data' => null];
|
||||
}
|
||||
$FromUserInfo = db::name('user')->where('id',$user_id)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($user_id);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($user_id);//魅力图标
|
||||
$FromUserInfo['dress'] = model('Decorate')->user_decorate_detail($user_id,1);
|
||||
$FromUserInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $user_id,'room_id' => $room_id])->value('charm');
|
||||
if($pit_number == 9){
|
||||
$pit_text = '主持麦';
|
||||
}elseif ($pit_number == 10) {
|
||||
$pit_text = '嘉宾麦';
|
||||
}else{
|
||||
$pit_text = $pit_number . '号麦';
|
||||
}
|
||||
$text['text'] = $FromUserInfo['nickname'].' 换到 ' . $pit_text;
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['from_pit_number'] = $pit_infos['pit_number'];
|
||||
$text['to_pit_number'] = $pit_number;
|
||||
model('Chat')->sendMsg(1039,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}else{
|
||||
$ompit = $this->OnPit($user_id,$room_id,$pit_number);//用户上了这个房间的几号麦位
|
||||
if($ompit['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '上麦失败', 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}
|
||||
$ompit = $this->OnPit($user_id,$room_id,$pit_number);//用户上了这个房间的几号麦位
|
||||
if($ompit['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '上麦失败', 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}else{
|
||||
}else{//排麦
|
||||
if($pit_number == 9){
|
||||
//检查用户是否是房主或主持
|
||||
$is_room_owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$is_room_host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->field('id')->find();
|
||||
//查看主持坑9坑
|
||||
$host_pit = $this->where(['room_id' => $room_id, 'pit_number' => 9])->value('user_id');
|
||||
if(($is_room_owner || $is_room_host) && $host_pit == 0){
|
||||
//查询用户是否在麦位上
|
||||
$is_on = $this->where(['room_id' => $room_id, 'user_id' => $user_id])->value('pit_number');
|
||||
if($is_on){
|
||||
//下麦
|
||||
$dow = $this ->DownPit($user_id,$room_id,$is_on);
|
||||
if($dow['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
if ($host_pit > 0) {
|
||||
if ($host_pit == $user_id) {
|
||||
return ['code' => 0, 'msg' => '您已在主持麦位', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '该麦位有人', 'data' => null];
|
||||
}
|
||||
}else{
|
||||
if(isset($pit_infos) && $pit_infos['pit_number'] > 0){
|
||||
$exchange1 = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_infos['pit_number']])->update([ 'user_id' => 0]);
|
||||
$exchange = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_number])->update([ 'user_id' => $user_id]);
|
||||
if(!$exchange || !$exchange1){
|
||||
return ['code' => 0, 'msg' => '换麦失败', 'data' => null];
|
||||
}
|
||||
$FromUserInfo = db::name('user')->where('id',$user_id)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($user_id);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($user_id);//魅力图标
|
||||
$FromUserInfo['dress'] = model('Decorate')->user_decorate_detail($user_id,1);
|
||||
$FromUserInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $user_id,'room_id' => $room_id])->value('charm');
|
||||
|
||||
$text['text'] = $FromUserInfo['nickname'].' 换到主持麦 ';
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['from_pit_number'] = $pit_infos['pit_number'];
|
||||
$text['to_pit_number'] = $pit_number;
|
||||
model('Chat')->sendMsg(1039,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}else{
|
||||
//直接上主持麦
|
||||
$ont = $this->OnPit($user_id,$room_id,$pit_number);//用户上了这个房间的几号麦位
|
||||
if($ont['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '上麦失败', 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}
|
||||
//直接上主持麦
|
||||
$ont = $this->OnPit($user_id,$room_id,9);//用户上了这个房间的几号麦位
|
||||
if($ont['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '上麦失败', 'data' => null];
|
||||
}
|
||||
//查找是否在申请列表里
|
||||
$apply_pit = db::name('vs_room_pit_apply')->where(['room_id' => $room_id, 'user_id' => $user_id])->find();
|
||||
if($apply_pit){
|
||||
$this->clear_apply_pit_list($user_id, $room_id, $user_id);
|
||||
// db::name('vs_room_pit_apply')->where(['room_id' => $room_id, 'user_id' => $user_id])->delete();
|
||||
// $count = db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count();
|
||||
// //申请上麦推送消息
|
||||
// $text = [
|
||||
// 'text' => '申请上麦',
|
||||
// 'count' => $count
|
||||
// ];
|
||||
// model('Chat')->sendMsg(1034,$room_id,$text);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
//检查用户是否已经申请
|
||||
$apply_pit_info = db::name('vs_room_pit_apply')->where(['room_id' => $room_id, 'user_id' => $user_id,'apply_type' =>1])->field('id')->find();
|
||||
if($apply_pit_info){
|
||||
return ['code' => 0, 'msg' => '请勿重复申请', 'data' => null];
|
||||
}
|
||||
}else{
|
||||
//检查用户是否已经申请
|
||||
$apply_pit_info = db::name('vs_room_pit_apply')->where(['room_id' => $room_id, 'user_id' => $user_id,'apply_type' =>1])->field('id')->find();
|
||||
if($apply_pit_info){
|
||||
return ['code' => 0, 'msg' => '请勿重复申请', 'data' => null];
|
||||
}
|
||||
|
||||
if(isset($pit_infos) && $pit_infos['pit_number'] > 0){
|
||||
return ['code' => 0, 'msg' => '用户已在麦上,请先下麦后再申请', 'data' => null];
|
||||
}
|
||||
if(isset($pit_infos) && $pit_infos['pit_number'] > 0){
|
||||
return ['code' => 0, 'msg' => '用户已在麦上,请先下麦后再申请', 'data' => null];
|
||||
}
|
||||
|
||||
//放入等待区
|
||||
$data = [
|
||||
'room_id' => $room_id,
|
||||
'user_id' => $user_id,
|
||||
'status' => 0,
|
||||
'apply_type' => 1
|
||||
];
|
||||
$reslut = db::name('vs_room_pit_apply')->insert($data);
|
||||
if(!$reslut){
|
||||
return ['code' => 0, 'msg' => '申请失败', 'data' => null];
|
||||
//放入等待区
|
||||
$data = [
|
||||
'room_id' => $room_id,
|
||||
'user_id' => $user_id,
|
||||
'status' => 0,
|
||||
'apply_type' => 1
|
||||
];
|
||||
$reslut = db::name('vs_room_pit_apply')->insert($data);
|
||||
if(!$reslut){
|
||||
return ['code' => 0, 'msg' => '申请失败', 'data' => null];
|
||||
}
|
||||
$count = db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count();
|
||||
//申请上麦推送消息
|
||||
$text = [
|
||||
'text' => '申请上麦',
|
||||
'count' => $count
|
||||
];
|
||||
model('Chat')->sendMsg(1034,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '申请成功,请等待房主审核', 'data' => null];
|
||||
}
|
||||
$count = db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count();
|
||||
//申请上麦推送消息
|
||||
$text = [
|
||||
'text' => '申请上麦',
|
||||
'count' => $count
|
||||
];
|
||||
model('Chat')->sendMsg(1034,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '申请成功,请等待房主审核', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,15 +361,6 @@ class RoomPit extends Model
|
||||
'a.status' => 0,
|
||||
];
|
||||
|
||||
// $res = model('Room')->get_room_label($room_id);
|
||||
// $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)){
|
||||
// $where['a.apply_type'] = 1;
|
||||
// }elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
// $where['a.apply_type'] = 2;
|
||||
// }
|
||||
|
||||
$list['regular'] = db::name('vs_room_pit_apply')->alias('a')->join('user b','a.user_id = b.id')
|
||||
->where($where)->where('a.type',0)->field('a.user_id,a.rank_value,b.nickname,b.avatar')
|
||||
->order('a.rank_value desc')->select();
|
||||
@@ -432,6 +469,8 @@ class RoomPit extends Model
|
||||
$apply_type = 2;//K歌
|
||||
}elseif($room_type == 2){
|
||||
$apply_type = 3;//拍卖
|
||||
}elseif($room_type == 7){
|
||||
$apply_type = 7;//交友
|
||||
}else{
|
||||
$apply_type = 1;//聊天
|
||||
}
|
||||
@@ -469,7 +508,7 @@ class RoomPit extends Model
|
||||
continue;
|
||||
}
|
||||
//删除他的申请上麦
|
||||
$reslut = db::name('vs_room_pit_apply')->where(['user_id' => $value, 'room_id' => $room_id, 'status' => 0,'apply_type' => 1])->delete();
|
||||
$reslut = db::name('vs_room_pit_apply')->where(['user_id' => $value, 'room_id' => $room_id, 'status' => 0])->delete();
|
||||
if (!$reslut) {
|
||||
continue;
|
||||
}
|
||||
@@ -499,7 +538,7 @@ class RoomPit extends Model
|
||||
break;
|
||||
}
|
||||
//删除他的申请上麦
|
||||
$reslut = db::name('vs_room_pit_apply')->where(['user_id' => $value, 'room_id' => $room_id, 'status' => 0,'apply_type' => 2])->delete();
|
||||
$reslut = db::name('vs_room_pit_apply')->where(['user_id' => $value, 'room_id' => $room_id, 'status' => 0])->delete();
|
||||
if (!$reslut) {
|
||||
continue;
|
||||
}
|
||||
@@ -548,14 +587,16 @@ class RoomPit extends Model
|
||||
//有人就让他下麦
|
||||
return ['code' => 0, 'msg' => '拍卖位上已有人,请先抱对方下麦', 'data' => null];
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($to_user as &$value) {
|
||||
$i++;
|
||||
// $i = 0;
|
||||
// foreach ($to_user as &$value) {
|
||||
// $i++;
|
||||
$value = $to_user[0];
|
||||
//删除他的申请上麦
|
||||
$reslut = db::name('vs_room_pit_apply')->where(['user_id' => $value, 'room_id' => $room_id, 'status' => 0])->delete();
|
||||
if (!$reslut) {
|
||||
continue;
|
||||
}
|
||||
// if (!$reslut) {
|
||||
// continue;
|
||||
// }
|
||||
Cache::set('auction_user_'.$room_id,$value);
|
||||
//聊天室推送系统消息
|
||||
$FromUserInfo = db::name('user')->where('id',$value)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($value);//财富图标
|
||||
@@ -566,13 +607,13 @@ class RoomPit extends Model
|
||||
$text['pit_number'] = 888;
|
||||
$text['type'] = 1 ;
|
||||
model('Chat')->sendMsg(1022,$room_id,$text);
|
||||
Cache::set('auction_user_'.$room_id,$value);
|
||||
|
||||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||||
model('Room')->room_operation_record($user_id,$room_id,8,$value);
|
||||
if($i >= 1){
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if($i >= 1){
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
$count = db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count();
|
||||
//申请上麦推送消息
|
||||
$text = [
|
||||
@@ -581,6 +622,41 @@ class RoomPit extends Model
|
||||
];
|
||||
model('Chat')->sendMsg(1034,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}elseif($apply_type == 7) {
|
||||
$i = 0;
|
||||
foreach ($to_user as &$value) {
|
||||
//查询当前空麦位
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
if (!$empty_pit) {
|
||||
//退出循环 并终止循环
|
||||
break;
|
||||
}
|
||||
//查询是否已经上麦
|
||||
$is_on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $value])->field('id')->find();
|
||||
if ($is_on_pit) {
|
||||
continue;
|
||||
}
|
||||
//删除他的申请上麦
|
||||
$reslut = db::name('vs_room_pit_apply')->where(['user_id' => $value, 'room_id' => $room_id, 'status' => 0])->delete();
|
||||
if (!$reslut) {
|
||||
continue;
|
||||
}
|
||||
$on = $this->OnPit($value, $room_id, $empty_pit);//用户上了这个房间的几号麦位
|
||||
if ($on['code'] != 1) {
|
||||
continue;
|
||||
}
|
||||
$i++;
|
||||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||||
model('Room')->room_operation_record($user_id,$room_id,8,$value,$empty_pit);
|
||||
}
|
||||
$count = db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count();
|
||||
//申请上麦推送消息(数据重置)
|
||||
$text = [
|
||||
'text' => '申请上麦',
|
||||
'count' => $count
|
||||
];
|
||||
model('Chat')->sendMsg(1034,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => $i . '位用户上麦成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
return ['code' => 0, 'msg' => '请选择申请上麦的用户', 'data' => null];
|
||||
@@ -738,10 +814,19 @@ class RoomPit extends Model
|
||||
}
|
||||
|
||||
if($type == 1){//抱麦
|
||||
$on_9_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9])->value('user_id');
|
||||
if($on_9_pit <= 0){
|
||||
return ['code' => 0, 'msg' => '您暂未上主持麦位,请先上麦', 'data' => null];
|
||||
if($pit_number == 10){
|
||||
$on_9_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9])->value('user_id');
|
||||
if($on_9_pit != $user_id){
|
||||
return ['code' => 0, 'msg' => '请等待麦上主持抱麦', 'data' => null];
|
||||
}
|
||||
}
|
||||
//房主
|
||||
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->find();
|
||||
if(!$owner && !$host){
|
||||
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
||||
}
|
||||
|
||||
if(!$pit_number){
|
||||
$room_type = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($room_type == 2){
|
||||
@@ -826,7 +911,7 @@ class RoomPit extends Model
|
||||
|
||||
if(!$pit_number || $pit_number == 888){
|
||||
$roomInfo = db::name('vs_room')->where('id',$room_id)->field('label_id,type_id')->find();
|
||||
if($roomInfo['type_id'] == 2){//拍卖
|
||||
if($roomInfo['type_id'] == 2 || Cache::get('auction_user_'.$room_id)){//拍卖
|
||||
//查询当前是否处于拍卖中
|
||||
$auctioning = db::name('vs_room_auction')
|
||||
->where(['room_id' => $room_id, 'status' => 2, 'user_id' => $accept_user_id])->find();
|
||||
@@ -856,6 +941,10 @@ class RoomPit extends Model
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$step = db::name('vs_room')->where(['id' => $room_id, 'type_id' => 7])->value('step');
|
||||
if($step && $step != 1 && $pit_number < 9){
|
||||
return ['code' => 0, 'msg' => '交友房 此阶段不可操作', 'data' => null];
|
||||
}
|
||||
$where['room_id'] = $room_id;
|
||||
$where['pit_number'] = $pit_number;
|
||||
$where['user_id'] = $accept_user_id;
|
||||
|
||||
@@ -285,9 +285,14 @@ class RoomSong extends Model
|
||||
|
||||
|
||||
//上移歌 $type 1上移 2置顶
|
||||
public function up_song($room_song_id,$type=1){
|
||||
public function up_song($user_id,$room_song_id,$type=1){
|
||||
//查询当前数据的信息
|
||||
$sort = db::name('vs_room_song')->where('did',$room_song_id)->field('room_id,sort,times')->find();
|
||||
//查询当前用户是否是在9号麦的主持
|
||||
$is_host = db::name('vs_room_pit')->where(['user_id' => $user_id,'room_id' => $sort['room_id'],'pit_number' =>9])->find();
|
||||
if(!$is_host){
|
||||
return ['code'=>0,'msg'=>'您没有权限操作','data'=>null];
|
||||
}
|
||||
//根据房间ID查询当前房间中正在排序的歌曲 并获取当前排序的前一位的ID
|
||||
$sort_up = db::name('vs_room_song')->where(['room_id' => $sort['room_id'],'status' => 1,'times' =>$sort['times'],'times_status' => 1])->field('did')->order('sort desc')->select();
|
||||
if($sort_up[0]['did'] == $room_song_id){
|
||||
|
||||
@@ -20,6 +20,28 @@ class Sms extends Model
|
||||
if (!checkMobile($mobile)) {
|
||||
return ['code' => 0, 'msg' => '手机号不正确','data' =>null];
|
||||
}
|
||||
|
||||
//今天验证码错误次数
|
||||
$sms_count = db::name('sms_error')->where(['mobile' => $mobile,'createtime' => ['between', [strtotime(date('Y-m-d')), time()]]])->count();
|
||||
if ($sms_count >= 5) {
|
||||
$user_id = db::name('user')->where('mobile', $mobile)->value('id');
|
||||
$block_num = db::name('block')->where(['type' => 1, 'type_text' => $user_id])->find();
|
||||
if(!$block_num){
|
||||
//封禁账号
|
||||
$error_data = [
|
||||
'type' => 1,
|
||||
'type_text' => $user_id,
|
||||
'block_time' => time() + 60 * 60 * 24,
|
||||
'block_note' => '账号登录异常被封禁24小时',
|
||||
'createtime'=> time(),
|
||||
];
|
||||
db::name('block')->insert($error_data);
|
||||
db::name('user')->where('id', $user_id)->update(['status' => 2]);
|
||||
}
|
||||
|
||||
return ['code' => 0, 'msg' => '验证码错误次数过多,账号已被封禁,请联系管理员处理','data' =>null];
|
||||
}
|
||||
|
||||
$is_code = db::name('sms')->where(['mobile' => $mobile, 'event' => $type])->order('id desc')->find();
|
||||
if ($is_code && $is_code['code'] == $code) {
|
||||
//验证码正确
|
||||
@@ -34,9 +56,19 @@ class Sms extends Model
|
||||
}
|
||||
}
|
||||
db::name('sms')->where(['mobile' => $mobile, 'event' => $type])->delete();
|
||||
//登陆成功后 把所有的登录错误删除掉
|
||||
db::name('sms_error')->where(['mobile' => $mobile])->delete();
|
||||
return ['code' =>1, 'msg' =>'验证码正确','data' =>null];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '验证码错误','data' =>null];
|
||||
//验证码错误次数
|
||||
$count_sms = max(5 - $sms_count, 0);
|
||||
$data = [
|
||||
'mobile' => $mobile,
|
||||
'sms' => $code,
|
||||
'createtime'=> time(),
|
||||
];
|
||||
db::name('sms_error')->insert($data);
|
||||
return ['code' => 0, 'msg' => '验证码错误,'.$count_sms.'次后账号将被封禁24小时','data' =>null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ use fast\Tencentst;
|
||||
|
||||
class Tencent extends Model
|
||||
{
|
||||
|
||||
|
||||
//获取腾讯IM UserSig信息
|
||||
//$uid => 用户id
|
||||
public function tencent_user_sig_info($uid){
|
||||
@@ -39,7 +39,7 @@ class Tencent extends Model
|
||||
'UserID' => 'u'.$uid,
|
||||
'Nick' => '',
|
||||
'FaceUrl' => '',
|
||||
);
|
||||
);
|
||||
if($data){
|
||||
//添加用户信息 昵称和头像
|
||||
$curlPost['Nick'] = $data['nick'];
|
||||
@@ -99,7 +99,7 @@ class Tencent extends Model
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => $reslut];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//查询账号
|
||||
//$uid => 用户id
|
||||
public function account_check($uid){
|
||||
@@ -108,19 +108,19 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/im_open_login_svc/account_check?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'CheckItem' => array(
|
||||
array(
|
||||
'UserID' => 'u'.$uid, //
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
// var_dump($reslut);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
@@ -134,7 +134,7 @@ class Tencent extends Model
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//拉入黑名单
|
||||
public function black_list_add($uid, $receive_uid){
|
||||
$config = get_system_config();
|
||||
@@ -142,25 +142,25 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/sns/black_list_add?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'From_Account' => $uid,
|
||||
'To_Account' => [$receive_uid],
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("腾讯用户拉入黑名单".json_encode($reslut),"infos");
|
||||
// Log::record("腾讯用户拉入黑名单".json_encode($reslut),"infos");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 201, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//移除黑名单
|
||||
public function black_list_delete($uid, $receive_uid){
|
||||
$config = get_system_config();
|
||||
@@ -168,16 +168,16 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/sns/black_list_delete?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'From_Account' => $uid,
|
||||
'To_Account' => [$receive_uid],
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 200, 'msg' => '移除成功', 'data' => null];
|
||||
@@ -185,7 +185,7 @@ class Tencent extends Model
|
||||
return ['code' => 201, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//发送群内系统消息
|
||||
public function send_group_system_notification($rid, $message_data){
|
||||
Log::record("腾讯群内系统消息发送结果".json_encode($rid.$message_data),"info");
|
||||
@@ -196,16 +196,16 @@ class Tencent extends Model
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/send_group_system_notification?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'GroupId' => $rid,
|
||||
'Content' => $message_data,
|
||||
);
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("腾讯群内系统消息发送结果".json_encode($reslut),"info");
|
||||
// Log::record("腾讯群内系统消息发送结果".json_encode($reslut),"info");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '发送成功', 'data' => $reslut];
|
||||
}else{
|
||||
@@ -241,28 +241,28 @@ class Tencent extends Model
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("广播消息信息".json_encode($reslut),"info");
|
||||
Log::record("广播消息信息3".json_encode($admin_sig),"info");
|
||||
Log::record("广播消息信息2".$admin_sig,"info");
|
||||
// Log::record("广播消息信息".json_encode($reslut),"info");
|
||||
// Log::record("广播消息信息3".json_encode($admin_sig),"info");
|
||||
// Log::record("广播消息信息2".$admin_sig,"info");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '发送成功', 'data' => $reslut];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => $reslut];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//发送群内普通消息
|
||||
public function send_group_msg($rid, $message_data, $uid=''){
|
||||
|
||||
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$random = time().rand(111,999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/send_group_msg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'GroupId' => $rid,
|
||||
'From_Account' => $uid,
|
||||
@@ -272,18 +272,18 @@ class Tencent extends Model
|
||||
'MsgType' => 'TIMTextElem',
|
||||
'MsgContent' => array(
|
||||
'Text' => $message_data,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
// $txt = date('Y-m-d H:i:s').'测试';
|
||||
// error_log($txt, 3, 'a.txt');
|
||||
return $reslut;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -305,8 +305,8 @@ class Tencent extends Model
|
||||
'GroupId' => strval($rid),
|
||||
'Name' => $group_name,
|
||||
'FaceUrl' => $url
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
|
||||
@@ -337,7 +337,7 @@ class Tencent extends Model
|
||||
'Member_Account' => 'u'.$uid,
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
@@ -359,12 +359,12 @@ class Tencent extends Model
|
||||
$curlPost = array(
|
||||
'GroupId' => strval($rid),
|
||||
'MemberToDel_Account' => array(
|
||||
'u'.$uid
|
||||
'u'.$uid
|
||||
),
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("腾讯群内删除成员结果".json_encode($reslut),"info");
|
||||
// Log::record("腾讯群内删除成员结果".json_encode($reslut),"info");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}else{
|
||||
@@ -382,7 +382,7 @@ class Tencent extends Model
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/destroy_group?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost = array(
|
||||
'GroupId' => strval($rid),
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
@@ -391,7 +391,7 @@ class Tencent extends Model
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//指定用户发送消息给用户
|
||||
public function user_sendmsg($uid, $receive_uid, $message, $machine_type = 2, $OnlineOnlyFlag = 0){
|
||||
$config = get_system_config();
|
||||
@@ -399,7 +399,7 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/openim/sendmsg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
$curlPost = array(
|
||||
@@ -412,18 +412,18 @@ class Tencent extends Model
|
||||
'MsgType' => 'TIMTextElem',
|
||||
'MsgContent' => array(
|
||||
'Text' => $message,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
if($OnlineOnlyFlag == 1){
|
||||
$curlPost['OnlineOnlyFlag'] = 1;
|
||||
}
|
||||
Log::record("xitong消息信息1:".$admin_sig,"info");
|
||||
// Log::record("xitong消息信息1:".$admin_sig,"info");
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("xitong消息信息2:".$reslut,"info");
|
||||
// Log::record("xitong消息信息2:".$reslut,"info");
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ class Tencent extends Model
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
//获取APP中的所有群组
|
||||
public function get_appid_group_list(){
|
||||
$config = get_system_config();
|
||||
@@ -464,40 +464,40 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/get_appid_group_list?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'Limit' => 20,
|
||||
'Next' => 0,
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function txt(){
|
||||
$postUrl = 'https://app.yayinyy.com/api/Agora/get_sstoken';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'code' => '44863d01cd628e583efeb3b9eda510fd',
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
//腾讯IM请求封装方法
|
||||
public function tencent_post_url($postUrl, $curlPost){
|
||||
|
||||
|
||||
$headerArray =array(
|
||||
"Content-type:application/json",
|
||||
"Accept:application/json",
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$ch = curl_init();//初始化curl
|
||||
curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页
|
||||
// curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
|
||||
@@ -514,7 +514,7 @@ class Tencent extends Model
|
||||
// dump($data);exit;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
//指定用户发送自定义消息给注册用户
|
||||
public function user_custom_sendmsg($uid, $receive_uid, $message, $machine_type = 2){
|
||||
$config = get_system_config();
|
||||
@@ -522,9 +522,9 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/openim/sendmsg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'SyncOtherMachine' => $machine_type,
|
||||
'From_Account' => strval($uid),
|
||||
@@ -537,16 +537,16 @@ class Tencent extends Model
|
||||
// 'Text' => $message,
|
||||
'Data' => $message,
|
||||
// 'Desc' => 'notification',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
//获取用户在线状态
|
||||
public function query_user_online_status($to_uid_arr)
|
||||
{
|
||||
@@ -558,16 +558,16 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/openim/query_online_status?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'To_Account' => $to_uid_arr,
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
|
||||
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
@@ -581,13 +581,13 @@ class Tencent extends Model
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/get_online_member_num?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost = array(
|
||||
'GroupId' => 'room'.$group_id,
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//主动审核接口
|
||||
public function content_moderation($type_name, $content){
|
||||
return ['code' => 1, 'msg' => '通过审核', 'data' => null];
|
||||
@@ -597,17 +597,17 @@ class Tencent extends Model
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$random = time().rand(111,999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/im_msg_audit/content_moderation?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'AuditName' => 'C2C', //表明送审策略,取值:C2C/Group/UserInfo/GroupInfo/GroupMemberInfo/RelationChain
|
||||
'ContentType' => $type_name, //送审类型,取值:Text/Image/Audio/Video。
|
||||
'Content' => $content //送审内容,最大限制8KB,当审核文件时,填对应 URL。其中图片审核最大不超过5MB
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
if($reslut['Result'] == 'Pass'){
|
||||
@@ -655,14 +655,14 @@ class Tencent extends Model
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/modify_group_base_info?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost['GroupId'] = $group_id;
|
||||
if($group_name){
|
||||
$curlPost['Name'] = $group_name;
|
||||
}
|
||||
if($group_face_url){
|
||||
$curlPost['FaceUrl'] = $group_face_url;
|
||||
}
|
||||
if($group_notice){
|
||||
$curlPost['Notification'] = $group_notice;
|
||||
}
|
||||
$curlPost['Name'] = $group_name;
|
||||
}
|
||||
if($group_face_url){
|
||||
$curlPost['FaceUrl'] = $group_face_url;
|
||||
}
|
||||
if($group_notice){
|
||||
$curlPost['Notification'] = $group_notice;
|
||||
}
|
||||
// $curlPost = array(
|
||||
// 'GroupId' => $group_id,
|
||||
// 'Name' => $group_name,//群名称
|
||||
@@ -692,7 +692,7 @@ class Tencent extends Model
|
||||
$curlPost['GroupId'] = $group_id;
|
||||
$curlPost['Member_Account'] = $member_id;//群成员帐号
|
||||
if($member_role == 1){
|
||||
$curlPost['Role'] = 'Admin';//群成员角色,取值:Owner(群主),Admin(群管理员),Member(普通群成员)
|
||||
$curlPost['Role'] = 'Admin';//群成员角色,取值:Owner(群主),Admin(群管理员),Member(普通群成员)
|
||||
}elseif ($member_role == 2){
|
||||
$curlPost['Role'] = 'Member';
|
||||
}
|
||||
@@ -754,7 +754,7 @@ class Tencent extends Model
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//====新写的↓=====上面的 能用则用=============================================================================================================
|
||||
|
||||
// 获取 Access Token(需缓存并定时刷新,每20分钟一次)
|
||||
@@ -838,7 +838,13 @@ class Tencent extends Model
|
||||
|
||||
// 处理响应
|
||||
if ($httpCode == 200) {
|
||||
return json_decode($response, true)['result']['faceId'];
|
||||
$red = json_decode($response, true);
|
||||
if ($red['code'] == 0) {
|
||||
return $red['result']['faceId'];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => $red['msg'], 'data' => null];
|
||||
}
|
||||
// return json_decode($response, true)['result']['faceId'];
|
||||
} else {
|
||||
return ['code' => $httpCode, 'msg' => '接口请求失败'];
|
||||
}
|
||||
@@ -909,24 +915,163 @@ class Tencent extends Model
|
||||
}
|
||||
|
||||
//腾讯IM监控在线状态更新
|
||||
public function tencent_member_status_change($info){
|
||||
public function tencent_member_status_changeee($info){
|
||||
$uid = substr($info['To_Account'],1);
|
||||
$action = $info['Action'];
|
||||
|
||||
if($action == 'Disconnect') {
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
$quit_room = Db::name('vs_room_visitor')->where('user_id', $uid)->select();
|
||||
|
||||
Log::record("腾讯离线推送,房间信息".json_encode($quit_room),"infos");
|
||||
if($quit_room) {
|
||||
foreach ($quit_room as &$v){
|
||||
model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id']);
|
||||
if(isset($v['room_id'])){
|
||||
$room_type = db::name('vs_room')->where(['id' => $v['room_id']])->field('step,type_id,label_id')->find();
|
||||
Log::record("腾讯离线推送,房间类型".json_encode($room_type),"infos");
|
||||
if($room_type['label_id'] == 1 && ($room_type['type_id'] == 1 || $room_type['type_id'] == 8)){
|
||||
Log::record("腾讯离线推送,我是二卡八","infos");
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
}else{
|
||||
if(isset($room_type) && ($room_type['type_id'] == 7 && ($room_type['step'] == 2 ||$room_type['step'] == 3)) || $room_type == 2){
|
||||
$text['text'] = '掉线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 2;
|
||||
model('Chat')->sendMsg(1058,$v['room_id'],$text);
|
||||
}else {
|
||||
//查询是否有切后台的操作
|
||||
$bg_room = db::name('vs_user_in_room_bg')->where(['room_id' => $v['room_id'],'user_id' => $v['user_id']])->find();
|
||||
if(!$bg_room){
|
||||
Log::record("腾讯离线推送,要踢你","infos");
|
||||
model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$room_type = null;
|
||||
}
|
||||
}
|
||||
|
||||
} elseif ($action == 'Login') {
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
$room = Db::name('vs_room_visitor')->where('user_id', $uid)->order('id desc')->value('room_id');
|
||||
|
||||
$text['text'] = '重新上线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 1;
|
||||
model('Chat')->sendMsg(1058,$room,$text);
|
||||
}elseif ($action == 'Logout'){
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
// Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
// $room = Db::name('vs_room_visitor')->where('user_id', $uid)->order('id desc')->value('room_id');
|
||||
// $text['text'] = '掉线!';
|
||||
// $text['user_id'] = $uid;
|
||||
// $text['type'] = 2;
|
||||
// model('Chat')->sendMsg(1058,$room,$text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//腾讯IM监控在线状态更新
|
||||
public function tencent_member_status_change($info){
|
||||
$uid = substr($info['To_Account'],1);
|
||||
$action = $info['Action'];
|
||||
|
||||
if($action == 'Disconnect') {
|
||||
$is_keep = 1;
|
||||
$keep = db::name('vs_xintiao')->where('user_id' , $uid)->find();
|
||||
if(isset($keep)){
|
||||
if(time() - $keep['updatetime'] >= 60){
|
||||
$is_keep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//判断保活用户是否安卓用户
|
||||
$user_system = db::name('user')->where('id' , $uid)->value('system');
|
||||
if($user_system == 'android'){
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
$quit_room = Db::name('vs_room_visitor')->where('user_id', $uid)->select();
|
||||
Log::record("腾讯离线推送,用户安卓所在房间信息".json_encode($quit_room),"infos");
|
||||
if($quit_room) {
|
||||
foreach ($quit_room as &$v){
|
||||
if(isset($v['room_id'])){
|
||||
$room_type = db::name('vs_room')->where(['id' => $v['room_id']])->field('step,type_id,label_id')->find();
|
||||
// Log::record("腾讯离线推送,房间类型".json_encode($room_type),"infos");
|
||||
if($room_type['label_id'] == 1 && ($room_type['type_id'] == 1 || $room_type['type_id'] == 8)){
|
||||
// Log::record("腾讯离线推送,我是二卡八","infos");
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
}else{
|
||||
if(isset($room_type) && ($room_type['type_id'] == 7 && ($room_type['step'] == 2 ||$room_type['step'] == 3)) || $room_type == 2){
|
||||
$text['text'] = '掉线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 2;
|
||||
model('Chat')->sendMsg(1058,$v['room_id'],$text);
|
||||
}else {
|
||||
//查询是否有切后台的操作
|
||||
// $bg_room = db::name('vs_user_in_room_bg')->where(['room_id' => $v['room_id'],'user_id' => $v['user_id']])->find();
|
||||
// if(!$bg_room){
|
||||
// // Log::record("腾讯离线推送,要踢你","infos");
|
||||
// model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
// }
|
||||
Log::record("腾讯离线推送,判断心跳".$is_keep,"infos");
|
||||
if($is_keep == 0){
|
||||
model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$room_type = null;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
$quit_room = Db::name('vs_room_visitor')->where('user_id', $uid)->select();
|
||||
// Log::record("腾讯离线推送,房间信息".json_encode($quit_room),"infos");
|
||||
if($quit_room) {
|
||||
foreach ($quit_room as &$v){
|
||||
if(isset($v['room_id'])){
|
||||
$room_type = db::name('vs_room')->where(['id' => $v['room_id']])->field('step,type_id,label_id')->find();
|
||||
// Log::record("腾讯离线推送,房间类型".json_encode($room_type),"infos");
|
||||
if($room_type['label_id'] == 1 && ($room_type['type_id'] == 1 || $room_type['type_id'] == 8)){
|
||||
// Log::record("腾讯离线推送,我是二卡八","infos");
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
}else{
|
||||
if(isset($room_type) && ($room_type['type_id'] == 7 && ($room_type['step'] == 2 ||$room_type['step'] == 3)) || $room_type == 2){
|
||||
$text['text'] = '掉线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 2;
|
||||
model('Chat')->sendMsg(1058,$v['room_id'],$text);
|
||||
}else {
|
||||
//查询是否有切后台的操作
|
||||
$bg_room = db::name('vs_user_in_room_bg')->where(['room_id' => $v['room_id'],'user_id' => $v['user_id']])->find();
|
||||
if(!$bg_room){
|
||||
// Log::record("腾讯离线推送,要踢你","infos");
|
||||
model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$room_type = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} elseif ($action == 'Login') {
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
$room = Db::name('vs_room_visitor')->where('user_id', $uid)->order('id desc')->value('room_id');
|
||||
|
||||
$text['text'] = '重新上线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 1;
|
||||
model('Chat')->sendMsg(1058,$room,$text);
|
||||
}elseif ($action == 'Logout'){
|
||||
// Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
// $room = Db::name('vs_room_visitor')->where('user_id', $uid)->order('id desc')->value('room_id');
|
||||
// $text['text'] = '掉线!';
|
||||
// $text['user_id'] = $uid;
|
||||
// $text['type'] = 2;
|
||||
// model('Chat')->sendMsg(1058,$room,$text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class Topic extends Model
|
||||
if($list){
|
||||
foreach ($list as &$item){
|
||||
$item['content'] = $this->where(['id'=>$item['topic_id']])->value('content');
|
||||
$item['pic'] = $this->where(['id'=>$item['topic_id']])->value('pic');
|
||||
$item['pic'] = $this->where(['id'=>$item['topic_id']])->value('pic') ?? get_system_config_value('web_site').'/data/avatar/head_pic.png';;
|
||||
$item['title'] = $this->where(['id'=>$item['topic_id']])->value('title');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
|
||||
class User extends Model
|
||||
@@ -150,6 +149,17 @@ class User extends Model
|
||||
$user_info['dress'] = model('Decorate')->user_decorate_detail($user_info['user_id'],1);
|
||||
$user_info['auth'] = db::name('user_auth')->where(['mobile' => $user_info['mobile'],'is_real' => 1])->find() ? 1 : 0;
|
||||
|
||||
//是否可以发布动态
|
||||
$user_rechange = db::name('vs_user_recharge')->field('sum(money) as money')->where(['user_id' => $uid,'pay_status' => 2])->find();
|
||||
//系统配置
|
||||
$config_money = get_system_config_value('private_chat_recharge_money');
|
||||
if(($config_money > 0) && ($user_rechange['money'] < $config_money)){
|
||||
$user_info['is_can_chat'] = 0;
|
||||
}else{
|
||||
$user_info['is_can_chat'] = 1;
|
||||
}
|
||||
$user_info['can_chat_money'] = $config_money;
|
||||
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $user_info];
|
||||
}
|
||||
|
||||
@@ -340,10 +350,11 @@ class User extends Model
|
||||
public function get_user_gift_wall_info($uid)
|
||||
{
|
||||
//查询用户礼物墙 以gift_id,send_user_id分组 同一用户送的同一礼物相加
|
||||
$result = db::name('vs_give_gift')
|
||||
->where(['gift_user' => $uid])
|
||||
->field('gift_id,user_id,sum(number) as total')
|
||||
->group('gift_id,user_id')
|
||||
$result = db::name('vs_give_gift')->alias('a')
|
||||
->join('vs_gift g', 'a.gift_id = g.gid')
|
||||
->where(['a.gift_user' => $uid,'g.label'=>['<>',2]])
|
||||
->field('a.gift_id,a.user_id,sum(a.number) as total')
|
||||
->group('a.gift_id,a.user_id')
|
||||
->order('total desc')
|
||||
->select();
|
||||
// var_dump($result);exit;
|
||||
@@ -392,7 +403,7 @@ class User extends Model
|
||||
}
|
||||
$data = array_values($data);
|
||||
//查询所有的礼物
|
||||
$gift_list = db::name('vs_gift')->field('gid as gift_id,gift_name,base_image,gift_price')->where(['delete_time' => 0,'is_show' => 1])->select();
|
||||
$gift_list = db::name('vs_gift')->field('gid as gift_id,gift_name,base_image,gift_price')->where(['delete_time' => 0,'label'=>['<>',2]])->select();
|
||||
//对比去除$data 里面的礼物
|
||||
$gift_list = array_filter((array)$gift_list, function ($item) use ($data) {
|
||||
return !in_array($item['gift_id'], array_column($data, 'gift_id'));
|
||||
@@ -558,7 +569,7 @@ class User extends Model
|
||||
//移动相册图片
|
||||
public function move_album_images($user_id,$id,$album_id){
|
||||
if(empty($id)){
|
||||
return ['code' => 0, 'msg' => '强选择想要移动的图片', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '请选择想要移动的图片', 'data' => null];
|
||||
}
|
||||
|
||||
if(empty($album_id)){
|
||||
@@ -662,7 +673,13 @@ class User extends Model
|
||||
if(!empty($nickname)){
|
||||
//名称中不能有 系统管理 等关键字
|
||||
if(!nickname_filter($nickname)){
|
||||
return ['code' => 0, 'msg' => '名称中不能有 系统管理 等相关字', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '名称中不能有 系统、管理、官方 等相关字', 'data' => null];
|
||||
}
|
||||
$nick_name_info = db::name('user')->where(['nickname' => $nickname,'status' => ['<>',0]])->find();
|
||||
if(!empty($nick_name_info)){
|
||||
if($user_id != $nick_name_info['id']){
|
||||
return['code' => 0, 'msg' => '该昵称已被占用','data' =>null];
|
||||
}
|
||||
}
|
||||
$data['nickname'] = $nickname;
|
||||
}
|
||||
@@ -685,7 +702,7 @@ class User extends Model
|
||||
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
// try{
|
||||
try{
|
||||
$data['updatetime'] = time();
|
||||
|
||||
$re = db::name('user')->where(['id' => $user_id])->update($data);
|
||||
@@ -722,18 +739,18 @@ class User extends Model
|
||||
$text['text'] = '用户 ' . $text['FromUserInfo']['nickname'] .' 修改了信息';
|
||||
model('Chat')->sendMsg(1035,$room_id,$text,$user_id);
|
||||
}
|
||||
Log::record("修改用户信息:".$user_id,"infos");
|
||||
|
||||
//给腾讯同步用户信息
|
||||
$member_name = db::name('user')->where('id' , $user_id)->value('nickname');
|
||||
$member_face_url = db::name('user')->where('id' , $user_id)->value('avatar');
|
||||
model('api/Tencent')->modify_user_infos($user_id, $member_name, $member_face_url);
|
||||
model('Tencent')->modify_user_infos($user_id, $member_name, $member_face_url);
|
||||
|
||||
return ['code' => 1, 'msg' => '修改成功', 'data' => null];
|
||||
// }
|
||||
// catch(\Exception $e){
|
||||
// db::rollback();
|
||||
// return ['code' => 0, 'msg' => $e, 'data' => null];
|
||||
// }
|
||||
}
|
||||
catch(\Exception $e){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => $e, 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//修改用户背景图
|
||||
@@ -824,8 +841,41 @@ class User extends Model
|
||||
}
|
||||
|
||||
|
||||
//关注房间(红包专用)
|
||||
public function follow_room($user_id,$room_id,$type){
|
||||
if(empty($room_id)){
|
||||
return ['code' => 0, 'msg' => '房间ID不能为空', 'data' => null];
|
||||
}
|
||||
if($type == 0){
|
||||
//取消关注
|
||||
$re = db::name('user_follow')->where(['user_id' => $user_id,'follow_id' => $room_id,'type' => 2])->delete();
|
||||
if(!$re){
|
||||
return ['code' => 0, 'msg' => '取消关注失败', 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '取消关注成功', 'data' => null];
|
||||
}else{
|
||||
//关注
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'follow_id' => $room_id,
|
||||
'type' => 2,
|
||||
'createtime' => time()
|
||||
];
|
||||
$re = db::name('user_follow')->insert($data);
|
||||
if(!$re){
|
||||
return ['code' => 0, 'msg' => '关注失败', 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '关注成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//更新用户ip
|
||||
public function update_user_ip($user_id,$ip){
|
||||
//判断$ip是否是汉字
|
||||
if(preg_match('/[\x{4e00}-\x{9fa5}]+/u', $ip)){
|
||||
$ip = '未知';
|
||||
}
|
||||
$data = [
|
||||
'address_ip' => $ip
|
||||
];
|
||||
|
||||
@@ -49,7 +49,7 @@ class UserData extends Model
|
||||
$data['id'] = $uid;
|
||||
if (!empty($nick_name)) {
|
||||
$data['nickname'] = $nick_name;
|
||||
$nick_name_info = db::name('user')->where('nickname', $nick_name)->find();
|
||||
$nick_name_info = db::name('user')->where(['nickname' => $nick_name,'status' => ['<>',0]])->find();
|
||||
if(!empty($nick_name_info)){
|
||||
if($uid != $nick_name_info['id']){
|
||||
return['code' => 0, 'msg' => '该昵称已被占用','data' =>null];
|
||||
@@ -58,6 +58,10 @@ class UserData extends Model
|
||||
if(mb_strlen($nick_name) > 24){
|
||||
return['code' => 0, 'msg' => '昵称长度不能超过24个字符','data' =>null];
|
||||
}
|
||||
//名称中不能有 系统管理 等关键字
|
||||
if(!nickname_filter($nick_name)){
|
||||
return ['code' => 0, 'msg' => '名称中不能有 系统、管理、官方 等相关字', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($birthday)) {
|
||||
@@ -133,8 +137,7 @@ class UserData extends Model
|
||||
$data['uid'] = $uid;
|
||||
if (!empty($nick_name)) {
|
||||
$data['nick_name'] = $nick_name;
|
||||
$data['base64_nick_name'] = base64_encode($nick_name);
|
||||
$nick_name_info = db::name('user')->where('base64_nick_name', $data['base64_nick_name'])->find();
|
||||
$nick_name_info = db::name('user')->where(['nickname' => $nick_name,'status' => ['<>',0]])->find();
|
||||
if(!empty($nick_name_info)){
|
||||
if($uid != $nick_name_info['uid']){
|
||||
return['code' => 0, 'msg' => '该昵称已被占用','data' =>null];
|
||||
@@ -254,6 +257,11 @@ class UserData extends Model
|
||||
//修改手机号
|
||||
public function modify_mobile($new_mobile,$user_id)
|
||||
{
|
||||
//查询新手机号绑定的数量
|
||||
$new_mobile_num = db::name('user')->where(['username' => $new_mobile,'status' => ['neq', 0]])->count();
|
||||
if ($new_mobile_num >= 3) {
|
||||
return ['code' => 0, 'msg' => '该手机号已达绑定上限','data' =>null];
|
||||
}
|
||||
//查询旧手机号
|
||||
$mobile = db::name('user')->where(['id' => $user_id])->value('username');
|
||||
//查询是否实名
|
||||
@@ -287,6 +295,16 @@ class UserData extends Model
|
||||
if(empty($user_mobile)){
|
||||
return ['code' => 0, 'msg' => '请先绑定手机号','data' =>null];
|
||||
}
|
||||
$card_id_count = db::name('user_auth')->where(['card_id' => $id_card,'is_real' => 1])->count();
|
||||
if($card_id_count >= 3){
|
||||
return ['code' => 0, 'msg' => '该身份证实名已达上限!','data' =>null];
|
||||
}
|
||||
//查询是否已经提交过数据了
|
||||
$is_real = db::name('user_auth')->where(['card_id' => $id_card,'is_real' => 1,'mobile' =>$user_mobile])->find();
|
||||
if($is_real){
|
||||
return ['code' => 0, 'msg' => '已经审核通过!请勿重复提交!','data' =>null];
|
||||
}
|
||||
|
||||
$auth = [
|
||||
'mobile' => $user_mobile,
|
||||
'real_name' => $real_name,
|
||||
@@ -321,6 +339,9 @@ class UserData extends Model
|
||||
$sign = model('Tencent')->getSign($user_id,$nonceStr,$sign_ticket,$config['tencent_app_id']);
|
||||
//生成faceId
|
||||
$faceId = model('Tencent')->getFaceId($orderNo,$real_name,$id_card,$sign,$user_id,$config['tencent_app_id'],$nonceStr);
|
||||
if(isset($faceId['code'])){
|
||||
return ['code' => 0, 'msg' => $faceId['msg'],'data' =>null];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'userid' => 'u'.$user_id,
|
||||
@@ -339,11 +360,21 @@ class UserData extends Model
|
||||
public function real_name_result($user_id,$orderNo)
|
||||
{
|
||||
$user_mobile = db::name('user')->where(['id' => $user_id,'status'=>1])->value('mobile');
|
||||
$id = db::name('user_auth')->where(['mobile' => $user_mobile,'is_real' => 3])->value('id');
|
||||
if($id){
|
||||
$res = db::name('user_auth')->where(['id' => ['<>',$id],'mobile' => $user_mobile])->select();
|
||||
if($res){
|
||||
foreach ($res as $key => $value) {
|
||||
db::name('user_auth')->where('id' , $value['id'])->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
//修改状态
|
||||
$reslut = db::name('user_auth')->where('mobile' , $user_mobile)->update(['is_real' => 1]);
|
||||
$reslut = db::name('user_auth')->where('id' , $id)->update(['is_real' => 1]);
|
||||
if(!$reslut){
|
||||
return ['code' => 0, 'msg' => '实名失败','data' =>null];
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '实名成功','data' =>null];
|
||||
}
|
||||
|
||||
@@ -524,7 +555,7 @@ class UserData extends Model
|
||||
];
|
||||
$reslut = db::name('user_data')->where('user_id',$user_id)->update($data);
|
||||
if(!$reslut){
|
||||
return ['code' => 0, 'msg' => '绑定失败!','data' =>null];
|
||||
return ['code' => 0, 'msg' => '绑定失败','data' =>null];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,7 +568,7 @@ class UserData extends Model
|
||||
];
|
||||
$reslut = db::name('user_data')->where('user_id',$user_id)->update($data);
|
||||
if(!$reslut){
|
||||
return ['code' => 0, 'msg' => '绑定失败,','data' =>null];
|
||||
return ['code' => 0, 'msg' => '绑定失败','data' =>null];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,12 +587,23 @@ class UserData extends Model
|
||||
//绑定的详情
|
||||
public function bind_xinxi_detail($user_id,$type)
|
||||
{
|
||||
$data = null;
|
||||
if($type == 2){
|
||||
$data = db::name('user_data')->where('user_id',$user_id)->field('id,alipay_name,alipay_account')->find();
|
||||
}
|
||||
if($type == 3){
|
||||
$data = db::name('user_data')->where('user_id',$user_id)->field('id,bank_card_number,bank_user_name,bank_card,open_bank')->find();
|
||||
}
|
||||
if($data['bank_card_number']==0){
|
||||
$data['bank_card_number'] = '';
|
||||
}
|
||||
if($data['bank_card']==0){
|
||||
$data['bank_card'] = '';
|
||||
}
|
||||
if($data['open_bank']==0){
|
||||
$data['open_bank'] = '';
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '获取成功','data' =>$data];
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,12 @@ class UserGiftPack extends Model
|
||||
const FIRST_CHARGE = 6;
|
||||
//天降好礼
|
||||
const DRAW_GIFT = 7;
|
||||
//巡乐会抽奖所得
|
||||
const XLH_DRAW_GIFT_GET = 8;
|
||||
//小时榜获得
|
||||
const HOUR_RANK_GET = 9;
|
||||
//新人充值好礼
|
||||
const NEW_CHARGE_GIFT = 10;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
@@ -48,7 +54,10 @@ class UserGiftPack extends Model
|
||||
self::SYSTEM_DEDUCTION => '系统扣除',
|
||||
self::GIFT_USE => '礼物使用',
|
||||
self::FIRST_CHARGE => '首充获得',
|
||||
self::DRAW_GIFT => '天降好礼获得'
|
||||
self::DRAW_GIFT => '天降好礼获得',
|
||||
self::XLH_DRAW_GIFT_GET => '巡乐会抽奖所得',
|
||||
self::HOUR_RANK_GET => '小时榜获得',
|
||||
self::NEW_CHARGE_GIFT => '新人充值好礼'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -68,6 +77,25 @@ class UserGiftPack extends Model
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $return_data];
|
||||
}
|
||||
|
||||
|
||||
//现有背包礼物总值
|
||||
public function get_gift_pack_list_count($uid)
|
||||
{
|
||||
$list = Db::name('vs_user_gift_pack')->alias('a')
|
||||
->join('fa_vs_gift b', 'a.gid = b.gid')
|
||||
->where(['a.user_id'=>$uid,'a.is_use_give'=>1,'a.num'=>['>',0]])
|
||||
->field('a.num,b.gift_price')
|
||||
->select();
|
||||
|
||||
$data = 0;
|
||||
foreach ($list as $v) {
|
||||
$data += $v['num'] * $v['gift_price'];
|
||||
}
|
||||
$count['count'] = $data;
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' =>$count ];
|
||||
}
|
||||
|
||||
//背包收入
|
||||
public function income_user_gift_pack($uid,$page=1,$page_limit=10)
|
||||
{
|
||||
@@ -76,7 +104,10 @@ class UserGiftPack extends Model
|
||||
self::GIFT_PACK_GET,
|
||||
// self::GIFT_SEND,
|
||||
self::FIRST_CHARGE,
|
||||
self::DRAW_GIFT
|
||||
self::DRAW_GIFT,
|
||||
self::XLH_DRAW_GIFT_GET
|
||||
,self::HOUR_RANK_GET
|
||||
,self::NEW_CHARGE_GIFT
|
||||
];
|
||||
//获取背包日志列表
|
||||
$log_model = Db::name('vs_user_gift_pack_log')->where(['user_id'=>$uid])->whereIn('type', $type)
|
||||
@@ -84,14 +115,14 @@ class UserGiftPack extends Model
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
if (empty($log_model)) {
|
||||
return ['code' => 0, 'msg' => '没有数据', 'data' => null];
|
||||
return ['code' => 0, 'msg' => ' ', 'data' => null];
|
||||
}
|
||||
$list = [];
|
||||
foreach ($log_model as $k => $v){
|
||||
$gift_info = db::name('vs_gift')->where(['gid'=>$v['gid']])->find();
|
||||
$list[$k]['remarks'] = $v['remarks'];
|
||||
$list[$k]['gift_num'] = $v['change_num'];
|
||||
$list[$k]['gift_name'] = "X".$v['change_num'].$gift_info['gift_name'];
|
||||
$list[$k]['gift_name'] = $gift_info['gift_name']." X ".$v['change_num'];
|
||||
$list[$k]['gift_image'] = $gift_info['play_image'];
|
||||
$list[$k]['time'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
}
|
||||
@@ -111,14 +142,14 @@ class UserGiftPack extends Model
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
if (empty($log_model)) {
|
||||
return ['code' => 0, 'msg' => '没有数据', 'data' => null];
|
||||
return ['code' => 0, 'msg' => ' ', 'data' => null];
|
||||
}
|
||||
$list = [];
|
||||
foreach ($log_model as $k => $v){
|
||||
$gift_info = db::name('vs_gift')->where(['gid'=>$v['gid']])->find();
|
||||
$list[$k]['remarks'] = $v['remarks'];
|
||||
$list[$k]['gift_num'] = $v['change_num'];
|
||||
$list[$k]['gift_name'] = "-".$v['change_num'].$gift_info['gift_name'];
|
||||
$list[$k]['gift_name'] = $gift_info['gift_name']." - ".$v['change_num'];
|
||||
$list[$k]['gift_image'] = $gift_info['play_image'];
|
||||
$list[$k]['time'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ class UserMessage extends Model
|
||||
|
||||
$system_no_read_count = $system_message - $user_read_message;
|
||||
$system_last_message = db::name('system_message')
|
||||
->field('id,type,title,content,url')
|
||||
->where('type', 1)//1系统消息 3公告下的房间推荐,4公告下的活动'
|
||||
->where('FIND_IN_SET(:user_id, receiving_id)', ['user_id' => $uid])
|
||||
->order('id desc')
|
||||
@@ -77,6 +78,7 @@ class UserMessage extends Model
|
||||
$announcement_read_count = count($system_message1) - count($user_read_message1);
|
||||
unset($map['user_id']);
|
||||
$announcement_last_message = db::name('system_message')
|
||||
->field('id,type,title,content,url')
|
||||
->where($map)
|
||||
->where('FIND_IN_SET(:user_id, receiving_id)', ['user_id' => $uid])
|
||||
->order('id desc')
|
||||
|
||||
@@ -50,17 +50,18 @@ class UserWallet extends Model
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益,20.发布头条扣除余额,21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币
|
||||
//27.小时榜获得,28-新人充值好礼,32-发红包(金币),29-发红包(钻石),30-抢红包(金币),31-抢红包(钻石) 33-红包剩余退回(金币),34-红包剩余退回(钻石)
|
||||
if($gift_type == 1){ //1金币,2收益(钻石)
|
||||
if($in_out_type == 1){//1收入
|
||||
$in_out_types = [2,5,6,8,13,14,15,16,22,23,26];
|
||||
$in_out_types = [2,5,6,8,13,14,15,16,22,23,26,27,30,28,33];
|
||||
}elseif($in_out_type == 2){//2支出
|
||||
$in_out_types = [4,7,10,17,20,24,25];
|
||||
$in_out_types = [4,7,10,17,20,24,25,32];
|
||||
}
|
||||
}elseif($gift_type == 2){ //1金币,2收益(钻石)
|
||||
if($in_out_type == 1){//1收入
|
||||
$in_out_types = [6,9,11,12,18,19,21];
|
||||
$in_out_types = [6,9,11,12,18,19,21,22,31,28,34];
|
||||
}elseif($in_out_type == 2){//2支出
|
||||
$in_out_types = [3,14];
|
||||
$in_out_types = [3,14,29];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,10 +107,11 @@ class UserWallet extends Model
|
||||
return ['code' => 0, 'msg' => '钻石数量不足', 'data' => null];
|
||||
}
|
||||
|
||||
$ear_exchange_coin = get_system_config_value('coin_exchange_rate');
|
||||
$data = [
|
||||
'user_id' => $uid,
|
||||
'earnings_num' => $earnings_num,
|
||||
'coin_num' => $earnings_num * 10,
|
||||
'coin_num' => $earnings_num * $ear_exchange_coin,
|
||||
'createtime' => time(),
|
||||
];
|
||||
//开启事务
|
||||
@@ -130,7 +132,7 @@ class UserWallet extends Model
|
||||
$account_log[] = [
|
||||
'user_id' => $uid,
|
||||
'money_type' => 1,
|
||||
'change_value' => $earnings_num * 10,
|
||||
'change_value' => $earnings_num * $ear_exchange_coin,
|
||||
'remarks' => '收益兑换',
|
||||
'change_type' => 14,
|
||||
'createtime' => time(),
|
||||
@@ -138,7 +140,7 @@ class UserWallet extends Model
|
||||
];
|
||||
$re = db::name('vs_user_money_log')->insertAll($account_log);
|
||||
$re1 = db::name('user_wallet')->where('user_id',$uid)->setDec('earnings',$earnings_num);
|
||||
$re2 = db::name('user_wallet')->where('user_id',$uid)->setInc('coin',$earnings_num * 10);
|
||||
$re2 = db::name('user_wallet')->where('user_id',$uid)->setInc('coin',$earnings_num * $ear_exchange_coin);
|
||||
if($re && $re1 && $re2){
|
||||
db::commit();
|
||||
return ['code' => 1, 'msg' => '兑换成功', 'data' => null];
|
||||
|
||||
@@ -43,6 +43,13 @@ class UserWithdrawal extends Model
|
||||
if(!$age){
|
||||
return ['code' => 0, 'msg' => '该身份证号未满18岁', 'data' => null];
|
||||
}
|
||||
if(empty($type)){
|
||||
return ['code' => 0, 'msg' => '请选择提现方式', 'data' => null];
|
||||
}
|
||||
//提现不能有小数
|
||||
if($number != floor($number)){
|
||||
return ['code' => 0, 'msg' => '提现不能有小数!', 'data' => null];
|
||||
}
|
||||
//判断用户是否签约云账户
|
||||
$yun_pay = new YunPay();
|
||||
$sign_status = $yun_pay->getApiUserSignStatus($user_info['real_name'],$user_info['card_id']);
|
||||
@@ -192,10 +199,10 @@ class UserWithdrawal extends Model
|
||||
$where['createtime'] = ['>=',strtotime($search_stime)];
|
||||
}
|
||||
if($search_etime){
|
||||
$where['createtime'] = ['<=',strtotime($search_etime.' 23:59:59')];
|
||||
$where['createtime'] = ['<=',strtotime($search_etime)];
|
||||
}
|
||||
if(!empty($search_stime) && !empty($search_etime)){
|
||||
$where['createtime'] = ['between',[strtotime($search_stime),strtotime($search_etime.' 23:59:59')]];
|
||||
$where['createtime'] = ['between',[strtotime($search_stime),strtotime($search_etime)]];
|
||||
}
|
||||
$withdraw_list = db::name('vs_user_withdrawal')
|
||||
->where($where)
|
||||
@@ -207,6 +214,26 @@ class UserWithdrawal extends Model
|
||||
$return_data[$key]['money'] = $value['money'];
|
||||
$return_data[$key]['status'] = $value['status'];
|
||||
$return_data[$key]['status_str'] = $this->withdraw_status[$value['status']];
|
||||
//手续费
|
||||
$return_data[$key]['withdraw_fee'] = $value['server_money'] ?? 0;
|
||||
$return_data[$key]['personal_tax_rate'] = $value['personal_tax_rate'] ?? 0; //税率
|
||||
$return_data[$key]['received_tax_amount'] = $value['received_tax_amount'] ?? 0; //税费
|
||||
//预计到账金额
|
||||
//1待处理2已通过3已拒绝 4打款中[云账户]5打款失败[云账户]6已打款[云账户]
|
||||
if($value['status'] == 1 || $value['status'] == 2 || $value['status'] ==4){
|
||||
$surplus_money = $value['money'] - $value['server_money'];
|
||||
$return_data[$key]['received_tax_amount'] = 0;
|
||||
}elseif($value['status'] == 3 || $value['status'] ==5){
|
||||
$surplus_money = $value['money'];
|
||||
$return_data[$key]['withdraw_fee'] = 0;
|
||||
$return_data[$key]['received_tax_amount'] = 0;
|
||||
}elseif($value['status'] == 6){
|
||||
$surplus_money = $value['money'] - $value['server_money'] - $value['received_tax_amount'];
|
||||
}else{
|
||||
$surplus_money = $value['money'];
|
||||
}
|
||||
$return_data[$key]['surplus_money'] = round($surplus_money,2);
|
||||
|
||||
$return_data[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $return_data];
|
||||
|
||||
@@ -301,13 +301,13 @@ class UserZone extends Model
|
||||
return ['code' => 0, 'msg' => '请重试,', 'data' => null];
|
||||
}
|
||||
//评论別人的帖子- 每天第一条奖励【完成任务】
|
||||
if($info['user_id'] != $uid){
|
||||
// if($info['user_id'] != $uid){
|
||||
//今天的第一条评论奖励
|
||||
$first_comment = db::name('user_zone_comment')->where(['user_id' => $uid, 'createtime' => ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]])->count();
|
||||
if ($first_comment ==1) {
|
||||
model('DailyTasks')->tasks_complete($uid,5);
|
||||
}
|
||||
}
|
||||
// }
|
||||
//增加评论数量
|
||||
$reslut = db::name('user_zone')->where('id', $zid)->setInc('comment_num', 1);
|
||||
if (!$reslut) {
|
||||
@@ -641,9 +641,10 @@ class UserZone extends Model
|
||||
//获取字符串的长度和 判断字符串里面是否有,
|
||||
if((mb_strlen($v['loginip'], 'utf-8') > 8 && mb_strpos($v['loginip'], ',') !== false)){
|
||||
$ipd = explode(',', $v['loginip']);
|
||||
// $v['loginip'] = $ipd[0].' · '.$ipd[1];//省·市
|
||||
$sheng = $ipd[0] =='(null)' ? '' : $ipd[0];
|
||||
$shi = $ipd[1] ?? '';
|
||||
$v['loginip'] = $sheng.' '.$shi;//省·市
|
||||
$v['loginip'] = $sheng.' '.$shi;//省·市
|
||||
}else{
|
||||
$v['loginip'] = '未知';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user