刮刮后端接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

<?php
namespace app\model;
use \think\Model;
class ZoneGoodsParam extends Model
{
/**
* 获取刮奖参数
* @param $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function getList($where = [])
{
$where['status'] = 1;
$list = self::where($where)->field('amount,image,probability,awards')->select()->toArray();
$ZoneAmountParam = [];
foreach ($list as &$item) {
$item['image'] = get_image_url($item['image']);
if ($item['awards'] != 1) {
# 获取无奖项随机金额
$item['amount'] = ZoneAmountParam::getRandAmount($ZoneAmountParam);
$ZoneAmountParam = $item['data'];
}
}
return $list;
}
/**
* 获取中奖金额
* @author whj
* @date 2023-08-28 17:50
*/
public static function getAwardsAmount($id)
{
$data = self::where(['id' => $id,'awards' => 1])->field('amount')->find();
return $data ?: false;
}
}