jingcai-php/app/Http/Controllers/Api/Customer/LotteryController.php

61 lines
1.6 KiB
PHP
Executable File

<?php
namespace App\Http\Controllers\Api\Customer;
use App\Enums\BoolEnum;
use App\Enums\LottType;
use App\Exceptions\JingCaiException;
use App\Model\Lottery;
use App\Model\LotteryType;
use App\Model\Seller\ShopCooperateLottery;
use App\Service\LotteryService;
use App\Utils\Helps;
use App\Utils\Result;
use App\Utils\ThrowException;
use Illuminate\Http\Request;
class LotteryController extends BaseController
{
/**
* @api {GET} /api/customer/lottery/types 所有彩种
* @apiVersion 0.1.0
* @apiGroup 客户端
*
* @apiParam {Int} [is_fadan] 1代表是发单时使用
*
* @apiSuccessExample {json} 返回结果
* [
* {
* "id": 1, // id
* "name": "第一个", // 名称
* "icon": "xx", // icon
* "info": "", // 信息提示
* },
* ...
* ]
*/
public function types(Request $request)
{
$isFadan = $request->input('is_fadan');
if ($isFadan) {
ThrowException::isTrue(!Helps::genDanEnable(), '系统维护中...');
}
$idList = Lottery::active()
->where('shop_id', $this->customerShopId())
->pluck('lottery_type_id')
->toArray();
if (!$idList) {
return $this->jsonSuccess();
}
$query = LotteryType::whereIn('id', $idList)
->where('status', BoolEnum::YES);
if ($isFadan) {
$query->whereIn('type', [LottType::JCZQ, LottType::JCLQ]);
}
$lotteryTypes = $query->get();
return $this->jsonSuccess($lotteryTypes);
}
}