代码初始化
This commit is contained in:
93
application/adminapi/model/Room.php
Normal file
93
application/adminapi/model/Room.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?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.' 00:00:00')];
|
||||
}
|
||||
if(!empty($etime)){
|
||||
$give_where['createtime'] = ['<=',strtotime($etime.' 23:59:59')];
|
||||
}
|
||||
if(!empty($stime) && !empty($etime)){
|
||||
$give_where['createtime'] = ['between',[strtotime($stime.' 00:00:00'),strtotime($etime.' 23:59:59')]];
|
||||
}
|
||||
$total_price = db::name('vs_give_gift')->where($give_where)
|
||||
->sum('total_price');
|
||||
return $total_price;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user