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.
49 lines
1.3 KiB
49 lines
1.3 KiB
<?php
|
|
|
|
namespace app\model;
|
|
|
|
use think\Model;
|
|
use think\model\concern\SoftDelete;
|
|
|
|
class ZoneGoodsParam extends Model
|
|
{
|
|
use SoftDelete;
|
|
protected $deleteTime = 'delete_time';
|
|
|
|
/**
|
|
* 获取刮奖参数
|
|
* @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('id,amount,image,probability,awards')->order('probability')->select()->toArray();
|
|
|
|
$ZoneAmountParam = [];
|
|
foreach ($list as &$item) {
|
|
|
|
if ($item['image']) $item['image'] = get_image_url($item['image']);
|
|
if ($item['awards'] != 1) {
|
|
# 获取无奖项随机金额
|
|
$res = ZoneAmountParam::getRandAmount($ZoneAmountParam);
|
|
$item['amount'] = $res['amount'];
|
|
$ZoneAmountParam = $res['data'];
|
|
}
|
|
}
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* 获取中奖金额
|
|
*/
|
|
public static function getAwardsAmount($id)
|
|
{
|
|
$data = self::where(['id' => $id,'awards' => 1])->field('amount')->find();
|
|
return $data ?: false;
|
|
}
|
|
|
|
}
|