mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-29 14:01:07 +00:00
增加抽奖判断必须有一个未中奖
This commit is contained in:
parent
7e913a1df3
commit
6d8a7dd6e1
@ -210,7 +210,9 @@ class LuckLotteryServices extends BaseServices
|
||||
$luckPrizeServices = app()->make(LuckPrizeServices::class);
|
||||
$data = [];
|
||||
$sort = 1;
|
||||
$prizeStatus = false;
|
||||
foreach ($prizes as $prize) {
|
||||
if (isset($prize['type']) && $prize['type'] == 1) $prizeStatus = true;
|
||||
$prize = $luckPrizeServices->checkPrizeData($prize);
|
||||
$prize['lottery_id'] = $lottery->id;
|
||||
unset($prize['id']);
|
||||
@ -219,6 +221,9 @@ class LuckLotteryServices extends BaseServices
|
||||
$data[] = $prize;
|
||||
$sort++;
|
||||
}
|
||||
if (!$prizeStatus) {
|
||||
throw new AdminException('必须设置至少一个未中奖');
|
||||
}
|
||||
if (!$luckPrizeServices->saveAll($data)) {
|
||||
throw new AdminException(400536);
|
||||
}
|
||||
@ -261,7 +266,9 @@ class LuckLotteryServices extends BaseServices
|
||||
$insert = [];
|
||||
$time = time();
|
||||
$sort = 1;
|
||||
$prizeStatus = false;
|
||||
foreach ($newPrizes as $prize) {
|
||||
if (isset($prize['type']) && $prize['type'] == 1) $prizeStatus = true;
|
||||
$prize = $luckPrizeServices->checkPrizeData($prize);
|
||||
$prize['sort'] = $sort;
|
||||
if (isset($prize['id']) && $prize['id']) {
|
||||
@ -280,6 +287,9 @@ class LuckLotteryServices extends BaseServices
|
||||
}
|
||||
$sort++;
|
||||
}
|
||||
if (!$prizeStatus) {
|
||||
throw new AdminException('必须设置至少一个未中奖');
|
||||
}
|
||||
if ($insert) {
|
||||
if (!$luckPrizeServices->saveAll($insert)) {
|
||||
throw new AdminException(100022);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user