70 lines
2.1 KiB
PHP
Executable File
70 lines
2.1 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Service;
|
|
|
|
use App\Enums\LottType;
|
|
use App\Model\Lottery;
|
|
use App\Model\Order;
|
|
use App\Model\Seller\ShopCooperateLottery;
|
|
use App\Utils\ThrowException;
|
|
|
|
class LotteryService
|
|
{
|
|
public static function getJingcaiServiceByOrder(Order $order) {
|
|
return self::getJingcaiService($order->lotteryType->type);
|
|
}
|
|
/**
|
|
* @param $lotteryType
|
|
* @return IJingcai
|
|
*/
|
|
public static function getJingcaiService($lotteryType) {
|
|
switch ($lotteryType) {
|
|
case LottType::JCZQ:
|
|
return app(JczqService::class);
|
|
case LottType::JCLQ:
|
|
return app(JclqService::class);
|
|
case LottType::CTZQ_JQC:
|
|
return app(CtzqJqcService::class);
|
|
case LottType::CTZQ_BQC:
|
|
return app(CtzqBqcService::class);
|
|
case LottType::CTZQ_SFC14:
|
|
return app(CtzqSfc14Service::class);
|
|
case LottType::CTZQ_SFC9:
|
|
return app(CtzqSfc9Service::class);
|
|
case LottType::DLT:
|
|
return app(DltService::class);
|
|
case LottType::QXC:
|
|
return app(QxcService::class);
|
|
case LottType::PLS:
|
|
return app(PlsService::class);
|
|
case LottType::PLW:
|
|
return app(PlwService::class);
|
|
case LottType::BJDC:
|
|
return app(BjdcService::class);
|
|
case LottType::BJDC_SFGG:
|
|
return app(BjdcSfggService::class);
|
|
case LottType::GUAN:
|
|
return app(GuanService::class);
|
|
case LottType::GUAN_YA:
|
|
return app(GuanYaService::class);
|
|
}
|
|
ThrowException::run('无此服务彩种');
|
|
}
|
|
|
|
/**
|
|
* @param $shopId
|
|
* @param $lotteryTypeId
|
|
* @param $active
|
|
* @return Lottery | null
|
|
*/
|
|
public static function getLottery($shopId, $lotteryTypeId, $active=true)
|
|
{
|
|
$query = Lottery::shopAndType($shopId, $lotteryTypeId);
|
|
if ($active) {
|
|
$query = $query->active();
|
|
}
|
|
$selfLottery = $query->first();
|
|
return $selfLottery;
|
|
}
|
|
}
|