504 lines
23 KiB
PHP
504 lines
23 KiB
PHP
<?php
|
||
|
||
namespace app\api\model;
|
||
|
||
use think\Cache;
|
||
use think\Db;
|
||
use think\Model;
|
||
|
||
class RoomAuction extends Model
|
||
{
|
||
//房间关系列表
|
||
public function room_relation_list($type_id)
|
||
{
|
||
$list = db::name('vs_relation')->field('id as relation_id,name,type,icon')->where('type',$type_id)->select();
|
||
return ['code' => 1, 'msg' => '操作成功','data' => $list];
|
||
}
|
||
|
||
//礼物计算时间
|
||
public function room_auction_time($gift_id)
|
||
{
|
||
//获取礼物价格
|
||
$gift_price = db::name('vs_gift')->where('gid',$gift_id)->value('gift_price') ?? 0;
|
||
if($gift_price == 0){
|
||
return ['code' => 0, 'msg' => '礼物不存在!','data' => null];
|
||
}
|
||
return floor($gift_price/get_system_config_value('room_love_auction_cion')) * get_system_config_value('room_love_auction_hour');
|
||
}
|
||
|
||
|
||
// 房间竞拍开始
|
||
public function room_auction($room_id,$user_id,$gift_id,$relation_id,$auction_type,$time_day)
|
||
{
|
||
if(!$room_id){
|
||
return ['code' => 0, 'msg' => '房间ID不能为空','data' => null];
|
||
}
|
||
if(!$user_id){
|
||
return ['code' => 0, 'msg' => '用户ID不能为空','data' => null];
|
||
}
|
||
if(!$gift_id){
|
||
return ['code' => 0, 'msg' => '礼物ID不能为空','data' => null];
|
||
}
|
||
|
||
if(!$auction_type){
|
||
return ['code' => 0, 'msg' => '竞拍类型不能为空','data' => null];
|
||
}
|
||
if(!$time_day){
|
||
if($auction_type == 1){
|
||
$time_day = $this->room_auction_time($gift_id);
|
||
if($time_day <= 0){
|
||
return ['code' => 0, 'msg' => '价值过低,请重新选择礼物!','data' => null];
|
||
}
|
||
}else{
|
||
return ['code' => 0, 'msg' => '请选择时间!','data' => null];
|
||
}
|
||
}
|
||
//查询房间是否正在拍卖
|
||
$auction = db::name('vs_room_auction')->where('room_id',$room_id)->where('status',2)->find();
|
||
if($auction){
|
||
return ['code' => 0, 'msg' => '房间正在竞拍中!请稍后继续','data' => null];
|
||
}
|
||
$user_ids = Cache::get('auction_user_'.$room_id);
|
||
if($user_ids != $user_id){
|
||
return ['code' => 0, 'msg' => '您已被管理员取消本场次竞拍,请联系管理员','data' => null];
|
||
}
|
||
|
||
$gift_price = db::name('vs_gift')->where('gid',$gift_id)->value('gift_price') ?? 0;
|
||
//数据写入数据库
|
||
$res = Db::name('vs_room_auction')->insertGetId([
|
||
'auction_type' => $auction_type,
|
||
'room_id' => $room_id,
|
||
'user_id' => $user_id,
|
||
'gift_id' => $gift_id,
|
||
'gift_price' => $gift_price,
|
||
'relation_id' => $relation_id,
|
||
'time_day' => $time_day * 60 * 60,//s
|
||
'createtime' => time(),
|
||
'status'=> 2,
|
||
'updatetime' => time(),
|
||
'duration' => time() + 60 * 3 //截止时间
|
||
]);
|
||
|
||
if(!$res){
|
||
return ['code' => 0, 'msg' => '操作失败','data' => null];
|
||
}
|
||
$auction = db::name('vs_room_auction')->alias('a')->join('user b', 'a.user_id = b.id', 'left')
|
||
->field('a.auction_id,a.user_id,b.nickname,b.avatar,b.sex,b.user_code,a.auction_type,a.relation_id,a.gift_id,a.gift_price,a.time_day,a.duration')
|
||
->where(['a.auction_id' => $res])->find();
|
||
|
||
if($auction){
|
||
$auction['dress'] = model('Decorate')->user_decorate_detail($auction['user_id'], 1);
|
||
$auction['relation_name'] = db::name('vs_relation')->where('id',$auction['relation_id'])->value('name');
|
||
$auction['relation_icon'] = db::name('vs_relation')->where('id',$auction['relation_id'])->value('icon');
|
||
$auction['base_image'] = db::name('vs_gift')->where('gid',$auction['gift_id'])->value('base_image');
|
||
$auction['gift_name'] = db::name('vs_gift')->where('gid',$auction['gift_id'])->value('gift_name');
|
||
$auction['time_day'] = $auction['time_day'] / 60 / 60;
|
||
}
|
||
// var_dump($auction);
|
||
//推送消息
|
||
$text = [
|
||
'FromUserInfo' => null,
|
||
'auction_user' => $auction ,
|
||
'text' => '拍卖开始'
|
||
];
|
||
model('api/Chat')->sendMsg(1023,$room_id,$text);
|
||
return ['code' => 1, 'msg' => '操作成功','data' => ['auction_id'=>$res]];
|
||
}
|
||
|
||
|
||
|
||
|
||
//参与竞拍
|
||
public function room_auction_join($auction_id,$user_id,$gift_id,$num,$type)
|
||
{
|
||
if(!$auction_id){
|
||
return ['code' => 0, 'msg' => '拍卖已经结束','data' => null];
|
||
}
|
||
if(!$user_id){
|
||
return ['code' => 0, 'msg' => '用户ID不能为空','data' => null];
|
||
}
|
||
if(!$gift_id){
|
||
return ['code' => 0, 'msg' => '礼物ID不能为空','data' => null];
|
||
}
|
||
$auction = db::name('vs_room_auction')->where('auction_id',$auction_id)->field('room_id,gift_price,user_id,status')->find();
|
||
$gift_price = db::name('vs_gift')->where('gid',$gift_id)->value('gift_price') ?? 0;
|
||
if($user_id == $auction['user_id']){
|
||
return ['code' => 0, 'msg' => '不能参与自己的竞拍!','data' => null];
|
||
}
|
||
|
||
//走送礼流程
|
||
$ree = model('GiveGift')->give_gift($user_id,$auction['user_id'],$gift_id,$num,2,$type,$auction['room_id'],0,0);
|
||
if($ree['code'] != 1){
|
||
return ['code' => $ree['code'], 'msg' => $ree['msg'],'data' => null];
|
||
}
|
||
if($auction['status'] == 2){//1未开启 2进行中 3已结束
|
||
//数据写入数据库
|
||
$res = db::name('vs_room_auction_bid_log')->insert([
|
||
'auction_id' => $auction_id,
|
||
'user_id' => $user_id,
|
||
'gift_id' => $gift_id,
|
||
'gift_price' => $num * $gift_price,
|
||
'createtime' => time()
|
||
]);
|
||
if(!$res){
|
||
return ['code' => 0, 'msg' => '操作失败,','data' => null];
|
||
}
|
||
|
||
//整理数据 排序
|
||
$list = $this->room_auction_list_on($auction_id);
|
||
//推送消息
|
||
$text = [
|
||
'FromUserInfo' => null,
|
||
'auction_user' => null ,
|
||
'auction_list' => $list,
|
||
'text' => '参与竞拍'
|
||
];
|
||
model('api/Chat')->sendMsg(1024,$auction['room_id'],$text);
|
||
}
|
||
return ['code' => 1, 'msg' => '操作成功','data' => $list];
|
||
}
|
||
|
||
|
||
//房间竞拍上麦列表
|
||
public function room_auction_list_on($auction_id)
|
||
{
|
||
$auction = db::name('vs_room_auction')->where('auction_id',$auction_id)->field('room_id,gift_price')->find();
|
||
$list = db::name('vs_room_auction_bid_log')->field('user_id, SUM(gift_price) AS gift_prices')
|
||
->where(['auction_id' => $auction_id])
|
||
->group('user_id')
|
||
->having('gift_prices >= ' . $auction['gift_price'])
|
||
->order('gift_prices DESC')
|
||
->limit(6)
|
||
->select();
|
||
if($list){
|
||
foreach ($list as &$v){
|
||
$v['charm'] = db::name('vs_room_user_charm')->where(['room_id' => $auction['room_id'],'user_id' => $v['user_id']])->value('charm');
|
||
$v['dress'] = model('Decorate')->user_decorate_detail($v['user_id'],1);
|
||
$v['user_code'] = model('Decorate')->user_decorate_detail($v['user_id'],6);
|
||
$v['nickname'] = db::name('user')->where('id',$v['user_id'])->value('nickname');//nickname,b.avatar,b.sex
|
||
$v['avatar'] = db::name('user')->where('id',$v['user_id'])->value('avatar');
|
||
$v['sex'] = db::name('user')->where('id',$v['user_id'])->value('sex');
|
||
}
|
||
}
|
||
return $list;
|
||
}
|
||
|
||
//房间竞拍全部列表
|
||
public function room_auction_list($auction_id)
|
||
{
|
||
if(!$auction_id){
|
||
return ['code' => 1, 'msg' => '操作成功','data' => null];
|
||
}
|
||
$auction = db::name('vs_room_auction')->where('auction_id',$auction_id)->field('room_id,gift_price,user_id,status')->find();
|
||
$list = db::name('vs_room_auction_bid_log')->field('user_id,sum(gift_price) as gift_prices')
|
||
->where('auction_id',$auction_id)->group('user_id')->order('gift_prices desc')->select();
|
||
if($list){
|
||
foreach ($list as &$v){
|
||
$v['charm'] = db::name('vs_room_user_charm')->where(['room_id' => $auction['room_id'],'user_id' => $v['user_id']])->value('charm');
|
||
$v['dress'] = model('Decorate')->user_decorate_detail($v['user_id'],1);
|
||
$v['user_code'] = model('Decorate')->user_decorate_detail($v['user_id'],6);
|
||
$v['nickname'] = db::name('user')->where('id',$v['user_id'])->value('nickname');
|
||
$v['avatar'] = db::name('user')->where('id',$v['user_id'])->value('avatar');
|
||
$v['sex'] = db::name('user')->where('id',$v['user_id'])->value('sex');
|
||
$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 room_auction_delay($auction_id)
|
||
{
|
||
if(!$auction_id){
|
||
return ['code' => 0, 'msg' => '参数有误','data' => null];
|
||
}
|
||
$res = db::name('vs_room_auction')->where('auction_id',$auction_id)->find();
|
||
if($res['status'] != 2){
|
||
return ['code' => 0, 'msg' => '房间竞拍已结束','data' => null];
|
||
}
|
||
$res1 = db::name('vs_room_auction')->where('auction_id',$auction_id)->update(['duration' => $res['duration'] + 60]);
|
||
if(!$res1){
|
||
return ['code' => 0, 'msg' => '操作失败,','data' => null];
|
||
}
|
||
//推送消息1026
|
||
$text = [
|
||
'FromUserInfo' => null,
|
||
'auction_user' => null ,
|
||
'auction_list' => null,
|
||
'duration'=> $res['duration'] + 60,
|
||
'text' => '延时到'.($res['duration'] + 60).'秒'
|
||
];
|
||
model('api/Chat')->sendMsg(1026,$res['room_id'],$text);
|
||
return ['code' => 1, 'msg' => '操作成功','data' => null];
|
||
}
|
||
|
||
//房间竞拍结束
|
||
public function room_auction_end($room_id,$auction_id)
|
||
{
|
||
if(!$room_id){
|
||
return ['code' => 0, 'msg' => '参数有误,无房间','data' => null];
|
||
}
|
||
if(!$auction_id){
|
||
//拍卖位下麦
|
||
$host = db::name('vs_room')->where(['id' => $room_id])->value('user_id');
|
||
model('api/RoomPit')->host_user_pit($host,$room_id,888,Cache::get('auction_user_'.$room_id),2);
|
||
return ['code' => 1, 'msg' => '操作成功','data' => null];
|
||
}
|
||
$res = db::name('vs_room_auction')->where('auction_id',$auction_id)->find();
|
||
if(!$res){
|
||
return ['code' => 0, 'msg' => '房间竞拍已结束','data' => null];
|
||
}
|
||
//获取出价列表
|
||
$list = db::name('vs_room_auction_bid_log')->field('user_id,sum(gift_price) as gift_prices')
|
||
->where('auction_id',$auction_id)->group('user_id')->order('gift_prices desc')->find();
|
||
|
||
if(!$list){
|
||
$list_gift_prices = 0;
|
||
}else{
|
||
$list_gift_prices = $list['gift_prices'];
|
||
}
|
||
|
||
$auction = null;
|
||
$recipient = null;
|
||
if($list_gift_prices < $res['gift_price']){ //流拍
|
||
//修改竞拍状态
|
||
$ress1 = db::name('vs_room_auction')->where('auction_id',$auction_id)->update(['status' => 3,'end_time' => time()]);
|
||
if(!$ress1){
|
||
return ['code' => 0, 'msg' => '操作失败','data' => null];
|
||
}
|
||
$texts = '很遗憾,本次竞拍未成功,请加油,下次再接再厉';
|
||
}else{
|
||
$cp_room_id = null;
|
||
$auction = db::name('vs_room_auction')->alias('a')->join('user b', 'a.user_id = b.id', 'left')
|
||
->field('a.auction_id,a.user_id,b.nickname,b.avatar,b.sex,b.user_code,a.auction_type,a.relation_id,a.gift_id,a.gift_price,a.time_day,a.duration')
|
||
->where(['a.auction_id' => $res['auction_id']])->find();
|
||
if($auction){
|
||
$auction['dress'] = model('Decorate')->user_decorate_detail($auction['user_id'], 1);
|
||
$auction['relation_name'] = db::name('vs_relation')->where('id',$auction['relation_id'])->value('name');
|
||
$auction['relation_icon'] = db::name('vs_relation')->where('id',$auction['relation_id'])->value('icon');
|
||
$auction['base_image'] = db::name('vs_gift')->where('gid',$auction['gift_id'])->value('base_image');
|
||
$auction['gift_name'] = db::name('vs_gift')->where('gid',$auction['gift_id'])->value('gift_name');
|
||
$auction['time_day'] = $auction['time_day'] / 60 / 60;
|
||
}
|
||
$recipient = db::name('user')->field('id as user_id,nickname,avatar,sex,user_code')->where('id',$list['user_id'])->find();
|
||
$recipient['dress'] = model('api/Decorate')->user_decorate_detail($list['user_id'], 1);
|
||
$recipient['user_code'] = model('api/Decorate')->user_decorate_detail($list['user_id'], 6);
|
||
|
||
if($res['relation_id'] != 0){
|
||
//是否开启电影房
|
||
$is_cp_movie = db::name('vs_relation')->where('id',$res['relation_id'])->value('is_open_movie');
|
||
if($is_cp_movie == 1){
|
||
//查询是否有电影房
|
||
$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']];
|
||
}
|
||
$cp_room_id = $cp_movie['data']['cp_room_id'];
|
||
}
|
||
$texts = '恭喜'.$auction['nickname'].' 和 '.$recipient['nickname'].',获得'.$auction['relation_name'].' 关系'.$auction['time_day'].'小时';
|
||
}else{//拍得无关系
|
||
$texts = '恭喜'.$recipient['nickname'].' 拍得 '.$auction['nickname'].'的拍卖关系'.$auction['time_day'].'小时';
|
||
}
|
||
|
||
//修改竞拍状态
|
||
$res1 = db::name('vs_room_auction')->where('auction_id',$auction_id)->update(
|
||
[
|
||
'status' => 3,
|
||
'end_time' => time(),
|
||
'bidder_user_id' => $list['user_id'],
|
||
'auction_num' => $list['gift_prices'],
|
||
'relation_end_time' => time() + $res['time_day'],
|
||
'updatetime' => time(),
|
||
'cp_room_id' => $cp_room_id
|
||
]);
|
||
if(!$res1){
|
||
return ['code' => 0, 'msg' => '操作失败,','data' => null];
|
||
}
|
||
//关系增加时间
|
||
$room_auction = $this->room_auction_create_or_add($list['user_id'],$res['user_id'],$res['relation_id'],$res['time_day'],$cp_room_id);
|
||
if($room_auction['code'] != 1){
|
||
return ['code' => 0, 'msg'=>$room_auction['msg'], 'data'=>$room_auction['data']];
|
||
}
|
||
}
|
||
//拍卖位下麦
|
||
$host = db::name('vs_room')->where(['id' => $res['room_id']])->value('user_id');
|
||
model('api/RoomPit')->host_user_pit($host,$res['room_id'],888,$res['user_id'],2);
|
||
|
||
//推送消息
|
||
$text = [
|
||
'room_id' => $res['room_id'],
|
||
'auction_user' => $auction,
|
||
'recipient' => $recipient,
|
||
'text' => $texts
|
||
];
|
||
model('api/Chat')->sendMsg(1025,$res['room_id'],$text);
|
||
|
||
//结束拍卖 右侧推空
|
||
//推送消息
|
||
$text = [
|
||
'FromUserInfo' => null,
|
||
'auction_user' => null ,
|
||
'auction_list' => null,
|
||
'text' => '竞拍结束'
|
||
];
|
||
model('api/Chat')->sendMsg(1024,$res['room_id'],$text);
|
||
//本场心动值清0
|
||
$roomUser = db::name('vs_room_visitor')->where(['room_id' => $res['room_id']])->select();
|
||
if($roomUser){
|
||
$host = db::name('vs_room')->where(['id' => $room_id])->value('user_id');
|
||
foreach ($roomUser as $v){
|
||
model('Room')->clear_user_charm($host, $room_id,$v['user_id']);
|
||
}
|
||
}
|
||
return ['code' => 1, 'msg' => '操作成功','data' => null];
|
||
}
|
||
|
||
|
||
//电影房创建或时间累加
|
||
public function movie_room_create_or_add($user_id,$user_id1,$relation_id,$time_day){
|
||
//查询两人是否已创建该关系的房间
|
||
$room = db::name('vs_room_cp_movie')
|
||
->where(['user_id' => $user_id,'user_id1' => $user_id1,'relation_id' => $relation_id])->field('cp_id,room_id,status,time_day')->order('cp_id desc')->find();
|
||
if(!$room){
|
||
$room = db::name('vs_room_cp_movie')
|
||
->where(['user_id1' => $user_id,'user_id' => $user_id1,'relation_id' => $relation_id])->field('cp_id,room_id,status,time_day')->order('cp_id desc')->find();
|
||
}
|
||
if($room){
|
||
if($room['status'] == 1 && $room['time_day'] > time()){
|
||
$room_time = db::name('vs_room_cp_movie')->where('cp_id',$room['cp_id'])->setInc('time_day',$time_day);
|
||
if(!$room_time){
|
||
return ['code' => 0, 'msg' => 'cp电影房时间累加失败,请联系管理员','data' => null];
|
||
}
|
||
return ['code' => 1, 'msg' => '操作成功,','data' => ['cp_room_id' => $room['room_id']]];
|
||
}else{
|
||
//销毁过期的腾讯IM的房间群组
|
||
model('Tencent')->delete_group('room'.$room['room_id']);
|
||
|
||
//开启电影房
|
||
$nickname = db::name('user')->where('id',$user_id)->value('nickname');
|
||
$nickname1 = db::name('user')->where('id',$user_id1)->value('nickname');
|
||
//创建房间
|
||
$room_id = model('api/Room')->user_create_room($user_id,'的电影房',get_system_config_value('web_site').'/data/avatar/head_pic.png',$nickname.' 和 '.$nickname1.' 的Cp电影房',$user_id.$user_id1);
|
||
if($room_id['code'] != 1){
|
||
return ['code' => 0, 'msg' => 'cp电影房创建失败,请联系管理员','data' => null];
|
||
}
|
||
//添加到数据库
|
||
$res2 = db::name('vs_room_cp_movie')->insert([
|
||
'relation_id' => $relation_id,
|
||
'room_id' => $room_id['data'],
|
||
'user_id' => $user_id,
|
||
'user_id1' => $user_id1,
|
||
'time_day' => time() + $time_day,
|
||
'createtime' => time(),
|
||
'status' => 1
|
||
]);
|
||
if(!$res2){
|
||
return ['code' => 0, 'msg' => '操作失败了,','data' => null];
|
||
}
|
||
return ['code' => 1, 'msg' => '操作成功,','data' => ['cp_room_id' => $room_id['data']]];
|
||
}
|
||
}else{
|
||
//开启电影房
|
||
$nickname = db::name('user')->where('id',$user_id)->value('nickname');
|
||
$nickname1 = db::name('user')->where('id',$user_id1)->value('nickname');
|
||
//创建房间
|
||
$room_id = model('api/Room')->user_create_room($user_id,'的电影房',get_system_config_value('web_site').'/data/avatar/head_pic.png',$nickname.' 和 '.$nickname1.' 的Cp电影房',$user_id.$user_id1);
|
||
if($room_id['code'] != 1){
|
||
return ['code' => 0, 'msg' => 'cp电影房创建失败,请联系管理员','data' => null];
|
||
}
|
||
//添加到数据库
|
||
$res2 = db::name('vs_room_cp_movie')->insert([
|
||
'relation_id' => $relation_id,
|
||
'room_id' => $room_id['data'],
|
||
'user_id' => $user_id,
|
||
'user_id1' => $user_id1,
|
||
'time_day' => time() + $time_day,
|
||
'createtime' => time(),
|
||
'status' => 1
|
||
]);
|
||
if(!$res2){
|
||
return ['code' => 0, 'msg' => '操作失败了,','data' => null];
|
||
}
|
||
//查询拍卖者的房间
|
||
$room_id1 = db::name('vs_room_cp_movie')->where(['user_id1' => $user_id1,'relation_id' => $relation_id,'status' => 1])
|
||
->where(['user_id' => ['<>', $user_id]])->value('cp_id');
|
||
if($room_id1){
|
||
//修改房间时间
|
||
$res3 = db::name('vs_room_cp_movie')->where('cp_id',$room_id1)->update(['status' =>4]);
|
||
if(!$res3){
|
||
return ['code' => 0, 'msg' => '操作失败了,','data' => null];
|
||
}
|
||
}
|
||
return ['code' => 1, 'msg' => '操作成功,','data' => ['cp_room_id' => $room_id['data']]];
|
||
}
|
||
}
|
||
|
||
|
||
public function room_auction_create_or_add($user_id,$user_id1,$relation_id,$time_day,$cp_room_id){
|
||
//查询两人是否已创建该关系
|
||
$room = db::name('vs_room_auction_relation')
|
||
->where(['user_id1' => $user_id,'user_id2' => $user_id1,'relation_id' => $relation_id,'end_time'=>['>',time()]])->order('id desc')->find();
|
||
if(!$room){
|
||
$room = db::name('vs_room_auction_relation')
|
||
->where(['user_id2' => $user_id,'user_id1' => $user_id1,'relation_id' => $relation_id,'end_time'=>['>',time()]])->order('id desc')->find();
|
||
}
|
||
if($room){
|
||
|
||
$data = [
|
||
'end_time' => $room['end_time'] + $time_day,
|
||
'time_day' => $room['time_day'] + $time_day,
|
||
'updatetime' => time()
|
||
];
|
||
$room_time = db::name('vs_room_auction_relation')->where('id',$room['id'])->update($data);
|
||
if(!$room_time){
|
||
return ['code' => 0, 'msg' => '关系卡时间累加失败,请联系管理员','data' => null];
|
||
}
|
||
return ['code' => 1, 'msg' => '操作成功,','data' => null];
|
||
|
||
}else{
|
||
//添加到数据库
|
||
$res2 = db::name('vs_room_auction_relation')->insert([
|
||
'relation_id' => $relation_id,
|
||
'user_id2' => $user_id,
|
||
'user_id1' => $user_id1,
|
||
'end_time' => time() + $time_day,
|
||
'time_day' => $time_day,
|
||
'updatetime' => time(),
|
||
'cp_room_id' => $cp_room_id
|
||
]);
|
||
if(!$res2){
|
||
return ['code' => 0, 'msg' => '操作失败了,','data' => null];
|
||
}
|
||
}
|
||
return ['code' => 1, 'msg' => '操作成功,','data' => null];
|
||
}
|
||
|
||
|
||
//房间竞拍模式
|
||
public function room_auction_mode($room_id,$mode = 2)
|
||
{
|
||
if(!$room_id || !$mode){
|
||
return ['code' => 0, 'msg' => '参数有误','data' => null];
|
||
}
|
||
//2亲密拍 1真爱拍
|
||
if($mode == 2){
|
||
$label_id = 3;
|
||
}elseif ($mode == 1){
|
||
$label_id = 4;
|
||
}
|
||
|
||
$res = db::name('vs_room')->where('id',$room_id)->update(['label_id' => $label_id]);
|
||
if(!$res){
|
||
return ['code' => 0, 'msg' => '操作失败了,','data' => null];
|
||
}
|
||
//推送消息
|
||
$text = [
|
||
'room_id' => $room_id,
|
||
'type' => $mode,
|
||
'text' => '房间拍卖类型已修改'
|
||
];
|
||
model('api/Chat')->sendMsg(1027,$room_id,$text);
|
||
return ['code' => 1, 'msg' => '操作成功,','data' => null];
|
||
}
|
||
} |