|
@@ -34,12 +34,7 @@ class LotteryRecruitmentReward extends Auth{
|
|
|
// 查询数据
|
|
|
$list = $Model->query()->where($map)->orderByDesc('id')->get()->toArray();
|
|
|
// 总奖品份数
|
|
|
- $total = 0;
|
|
|
- // 处理数据
|
|
|
- foreach ($list as $key => $value) {
|
|
|
- // 查询奖品总份数
|
|
|
- if( !$value['status'] ) $total += $value['reward_all'];
|
|
|
- }
|
|
|
+ $total = (int) $Model->query()->where([ ['lottery_id','=',$lotteryId]],['status','=',0])->sum('reward_all');
|
|
|
// 循环处理数据
|
|
|
foreach ($list as $key => $value) {
|
|
|
// 中奖概率,如果不存在的话
|
|
@@ -202,7 +197,7 @@ class LotteryRecruitmentReward extends Auth{
|
|
|
// 启用
|
|
|
if( !$status ) {
|
|
|
// 计算统计数量
|
|
|
- $count = $Model->query()->where([['lottery_id','=',$oldData['lottery_id']]])->count();
|
|
|
+ $count = $Model->query()->where([['lottery_id','=',$oldData['lottery_id']],['status','=',0]])->count();
|
|
|
// 获取统计数量
|
|
|
if( $count >= 7 ) return json_send(['code'=>'error','msg'=>'奖项不可超过7个']);
|
|
|
}
|