Files
yusheng-php/application/api/model/Gift.php

69 lines
2.3 KiB
PHP
Raw Normal View History

2025-08-07 20:21:47 +08:00
<?php
namespace app\api\model;
use think\Model;
use think\Db;
use think\Session;
class Gift extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = true;
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 定义字段类型
protected $label = [1=>'热门',2=>'趣味', 3=>'情侣', 4=>'挂件'];
protected $table = 'fa_vs_gift';
//获取礼物类型
public function get_gift_label()
{
$giftTypeData = db::name('vs_gift_label')->where('delete_time',0)->order("sort asc,id desc")->select();
foreach ($giftTypeData as $key => $value) {
$giftType[$key]['id'] = $value['id'];
$giftType[$key]['name'] = $value['name'];
}
return ['code' => 1, 'msg' => '获取成功', 'data' => $giftType];
}
//拉去礼物列表
public function get_gift_list($label=0)
{
$map['delete_time'] = 0;
$where['is_show'] = 1;
if ($label && $label !=99) {
$map['label'] = $label;
}
if ($label == 99) {
$gift_price = get_system_config_value('room_love_auction_cion');
$where['gift_price'] = ['>',$gift_price];
}
$list = $this->field('gid as gift_id,gift_name,base_image,gift_price')->where($map)->where($where)->order('sort asc, gift_price asc')->select();
if($label==2){
foreach ($list as &$v) {
//获取盲盒列表
$box_list = Db::name('vs_gift_bag')->where(['status'=>1])->where('activities_id',4)->select();
foreach ($box_list as $key =>$box) {
$ext = json_decode($box['ext'],true);
if ($ext['gift_id'] == $v['gift_id']) {
$v['gift_bag_name'] = $box['name'];
$v['rule'] = $ext['description'];
$v['rule_url'] = get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$box["id"];
break;
}
}
}
}
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
}
/*
* 盲盒规则链接
*/
public function get_gift_box_rule($box_id){
}
}