2025-08-13 10:43:56 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace app\adminapi\model;
|
|
|
|
|
|
|
|
|
|
|
|
use think\Model;
|
|
|
|
|
|
use think\Session;
|
|
|
|
|
|
use think\Db;
|
|
|
|
|
|
class Room extends Model
|
|
|
|
|
|
{
|
|
|
|
|
|
// 开启自动写入时间戳字段
|
|
|
|
|
|
protected $autoWriteTimestamp = 'int';
|
|
|
|
|
|
// 定义时间戳字段名
|
|
|
|
|
|
protected $createTime = 'createtime';
|
|
|
|
|
|
protected $updateTime = 'updatetime';
|
|
|
|
|
|
|
|
|
|
|
|
protected $name = 'vs_room';
|
|
|
|
|
|
|
|
|
|
|
|
public $relation_type = [1=>'真爱拍',2=>'友情拍'];
|
|
|
|
|
|
public $room_status = [1=>'正常',2=>'封禁',3=>'关闭'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//房间操作 日志 类型
|
|
|
|
|
|
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
|
|
|
|
|
public $room_log_type = [1=>'禁麦位',2=>'清空消息',3=>'清空魅力值',4=>'加入黑名单',5=>'踢出房间',6=>'关闭麦克风',7=>'申请上麦',8=>'同意上麦',9=>'拒绝上麦',10=>'点歌',11=>'开启PK'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getList($where = [], $page = 1, $limit = 10)
|
|
|
|
|
|
{
|
|
|
|
|
|
$list = $this->where($where)->page($page, $limit)->select();
|
|
|
|
|
|
$list = collection($list)->toArray();
|
|
|
|
|
|
return $list;
|
|
|
|
|
|
}
|
|
|
|
|
|
public function getCount($where = [])
|
|
|
|
|
|
{
|
|
|
|
|
|
return $this->where($where)->count();
|
|
|
|
|
|
}
|
|
|
|
|
|
public function getOne($where = [])
|
|
|
|
|
|
{
|
|
|
|
|
|
$one = $this->where($where)->find();
|
|
|
|
|
|
return $one;
|
|
|
|
|
|
}
|
|
|
|
|
|
public function add($data)
|
|
|
|
|
|
{
|
|
|
|
|
|
$res = $this->save($data);
|
|
|
|
|
|
if (!$res) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
$guild_id = $this->id;
|
|
|
|
|
|
return $guild_id;
|
|
|
|
|
|
}
|
|
|
|
|
|
public function edit($where = [], $data = [])
|
|
|
|
|
|
{
|
|
|
|
|
|
$res = $this->where($where)->update($data);
|
|
|
|
|
|
return $res;
|
|
|
|
|
|
}
|
|
|
|
|
|
public function del($where = [])
|
|
|
|
|
|
{
|
|
|
|
|
|
$res = $this->where($where)->delete();
|
|
|
|
|
|
return $res;
|
|
|
|
|
|
}
|
|
|
|
|
|
//软删除
|
|
|
|
|
|
public function setDel($where = []){
|
|
|
|
|
|
$res = $this->where($where)->setField('delete_time',time());
|
|
|
|
|
|
if(!$res){
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return $res;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* 查询房间流水
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function getRoomFlow($room_id,$stime='',$etime=''){
|
|
|
|
|
|
$give_where = [];
|
|
|
|
|
|
$give_where['from_id'] = $room_id;
|
|
|
|
|
|
$give_where['from'] = ["in",[2,3,6]];
|
|
|
|
|
|
if(!empty($stime)){
|
2025-09-27 17:29:15 +08:00
|
|
|
|
$give_where['createtime'] = ['>=',strtotime($stime)];
|
2025-08-13 10:43:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(!empty($etime)){
|
2025-09-27 17:29:15 +08:00
|
|
|
|
$give_where['createtime'] = ['<=',strtotime($etime)];
|
2025-08-13 10:43:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(!empty($stime) && !empty($etime)){
|
2025-09-27 17:29:15 +08:00
|
|
|
|
$give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]];
|
2025-08-13 10:43:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
$total_price = db::name('vs_give_gift')->where($give_where)
|
|
|
|
|
|
->sum('total_price');
|
|
|
|
|
|
return $total_price;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-25 19:31:12 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* 房间绑定盘
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function bindPan($room_id){
|
|
|
|
|
|
db::name('vs_room_pan')->where(['room_id'=>$room_id])->delete();
|
|
|
|
|
|
$gift_bag = db::name('vs_gift_bag_detail')->where(['gift_bag_id'=>['in',[10,11,12,13]]])->select();
|
|
|
|
|
|
foreach ($gift_bag as $k=>$v){
|
|
|
|
|
|
$data = [
|
|
|
|
|
|
'room_id'=>$room_id,
|
|
|
|
|
|
'gift_bag_id'=>$v['gift_bag_id'],
|
|
|
|
|
|
'gift_bag_detail_id'=>$v['id'],
|
|
|
|
|
|
'remaining_number'=>$v['quantity'],
|
|
|
|
|
|
'createtime'=>time()
|
|
|
|
|
|
];
|
|
|
|
|
|
db::name('vs_room_pan')->insert($data);
|
|
|
|
|
|
}
|
|
|
|
|
|
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
|
|
|
|
|
}
|
2025-08-13 10:43:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|