代码初始化
This commit is contained in:
76
application/adminapi/model/Gift.php
Normal file
76
application/adminapi/model/Gift.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
class Gift extends Model
|
||||
{
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'int';
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
|
||||
protected $name = 'vs_gift';
|
||||
|
||||
//礼物类型 1普通 2盲盒 3礼包礼物
|
||||
public $giftType = [
|
||||
1 => '普通礼物',
|
||||
2 => '盲盒礼物',
|
||||
3 => '礼包礼物'
|
||||
];
|
||||
//送礼流水来源:1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏
|
||||
public $GiveGiftFromStr = [
|
||||
1 => '聊天送礼',
|
||||
2 => '房间语聊送礼',
|
||||
3 => '直播送礼',
|
||||
4 => '动态打赏'
|
||||
];
|
||||
|
||||
public function getList($where = [], $page = 1, $limit = 10)
|
||||
{
|
||||
$where['delete_time'] = 0;
|
||||
$list = $this->where($where)->page($page, $limit)->select();
|
||||
$list = collection($list)->toArray();
|
||||
return $list;
|
||||
}
|
||||
public function getCount($where = [])
|
||||
{
|
||||
$where['delete_time'] = 0;
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user