/中奖数量
$prize = $maxPrizeNumber;
if($prize >= $ticket->select_number) {
$prize = $ticket->select_number;
}
if($prizeTimes >= $mustGet) {
$prizes = GrabBlindBox::where('is_grab',0)
->where('user_id','<>',$ticket->user_id)
->where('price','<',288)
->orderByRaw("RAND()")
->limit($prize)
->get();
}else{
$curTotal = $prizeCurTimes->count();
//达到100次
if(($curTotal + $ticket->select_number) >= 100) {
$remain = $mustGet - $prizeTimes;
$limit = min($remain, $prize);
$prizes = GrabBlindBox::where('is_grab',0)
->where('user_id','<>',$ticket->user_id)
->where('price','=',288)
->limit($limit)
->get();
//如果没有抽取到288,则释放次数,用于下一步算法计算获得小于288的盒子
if($prizes->isEmpty()) {
$limit = 0;
}
if($prize - $limit > 0) {
$rPrizes = GrabBlindBox::where('is_grab',0)
->where('user_id','<>',$ticket->user_id)
->where('price','<',288)
->limit($prize - $limit)
->get();
$prizes = $prizes->merge($rPrizes);
}
}else{
$prizes = GrabBlindBox::where('is_grab',0)
->where('user_id','<>',$ticket->user_id)
->orderByRaw("RAND()")
->limit($prize)
->get();
$cPrizes= clone $prizes;
//100次内获得超过2个288的盒子
if($cPrizes->where('price',288)->count() > ($mustGet - $prizeTimes)) {
$prizes = GrabBlindBox::where('is_grab',0)->where('price','<',288)->limit($prize)->get();
}
}
}
if($config['grab']['box_no_pay_money']) {
$kou =
评论