Files
midi-php/application/adminapi/model/Room.php

112 lines
3.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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)){
$give_where['createtime'] = ['>=',strtotime($stime)];
}
if(!empty($etime)){
$give_where['createtime'] = ['<=',strtotime($etime)];
}
if(!empty($stime) && !empty($etime)){
$give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]];
}
$total_price = db::name('vs_give_gift')->where($give_where)
->sum('total_price');
return $total_price;
}
/*
* 房间绑定盘
*/
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];
}
}