Files
midi-php/application/adminapi/model/Gift.php
2025-08-13 10:43:56 +08:00

77 lines
1.9 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 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;
}
}