| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 | <?phpnamespace App\Http\Controllers\admin;use App\Constants\HttpStatus;use App\Http\Controllers\Controller;use App\Services\BetService;use Illuminate\Support\Facades\DB;use Illuminate\Validation\ValidationException;use Exception;class Bet extends Controller{    /**     * @description: 分页数据     * @return {*}     *     * @apiParam {String} [start_time] 开始时间     * - 格式:`yyyy-mm-dd`     * @apiParam {String} [end_time] 截止时间     * - 格式:`yyyy-mm-dd`     */    function index()    {        try {            $params = request()->validate([                'page' => ['nullable', 'integer', 'min:1'],                'limit' => ['nullable', 'integer', 'min:1'],                'member_id' => ['nullable', 'string'],                'keywords' => ['nullable', 'string', 'min:1'],                'issue_no' => ['nullable', 'string'],                'id' => ['nullable', 'string'],                'status' => ['nullable', 'integer', 'in:1,2'],                'username' => ['nullable', 'string', 'min:1'],                'start_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:end_time'],                'end_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:start_time'],                'is_winner'=>['nullable','integer','in:0,1'],            ]);            $result = BetService::paginate($params);        } catch (ValidationException $e) {            return $this->error(HttpStatus::VALIDATION_FAILED, $e->validator->errors()->first());        } catch (Exception $e) {            return $this->error(intval($e->getCode()));        }        return $this->success($result);    }    // 模拟下注    public function fake()    {        BetService::fakeBet();        return $this->success();    }    // /**    //  * @description: 修改|新增    //  * @return {*}    //  */        // public function store()    // {    //     // try {    //         $params = request()->all();    //         $validator = [    //             'issue_no' => 'required|string|max:50|alpha_dash|unique:issues,issue_no',    //             'winning_numbers' => 'nullable|string|max:100',    //             'status' => 'nullable|string',    //         ];    //         request()->validate($validator);    //         $ret = BetService::submit($params);    //         if ($ret['code'] == BetService::NOT) {    //             return $this->error($ret['code'], $ret['msg']);    //         }    //     // } catch (ValidationException $e) {    //     //     return $this->error(HttpStatus::VALIDATION_FAILED, '', $e->errors());    //     // } catch (Exception $e) {    //     //     return $this->error(intval($e->getCode()));    //     // }    //     return $this->success([], $ret['msg']);    // }    // /**    //  * @description: 开始    //  * @return {*}    //  */        // public function betting()    // {    //     $id = request()->input('id');    //     if (!$id) {    //         return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');    //     }    //     $ret = BetService::betting($id);    //     if ($ret['code'] == BetService::NOT) {    //         return $this->error($ret['code'], $ret['msg']);    //     }    //     return $this->success([], $ret['msg']);    // }    // /**    //  * @description: 关闭    //  * @return {*}    //  */        // public function close()    // {    //     $id = request()->input('id');    //     if (!$id) {    //         return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');    //     }    //     $ret = BetService::closeBetting($id);    //     if ($ret['code'] == BetService::NOT) {    //         return $this->error($ret['code'], $ret['msg']);    //     }    //     return $this->success([], $ret['msg']);    // }    // /**    //  * @description: 开奖    //  * @return {*}    //  */        // public function lotteryDraw()    // {    //     $id = request()->input('id');    //     $winning_numbers = request()->input('winning_numbers');    //     $image = request()->input('image');    //     $combo = request()->input('combo');    //     if (!$id) {    //         return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');    //     }    //     if (!$winning_numbers) {    //         return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误');    //     }    //     if(explode(',', $winning_numbers) < 3){    //         return $this->error(HttpStatus::VALIDATION_FAILED, '开奖号码格式错误');    //     }    //     $ret = BetService::lotteryDraw($id,$winning_numbers,$combo,$image);    //     if ($ret['code'] == BetService::NOT) {    //         return $this->error($ret['code'], $ret['msg']);    //     }    //     return $this->success([], $ret['msg']);    // }    // /**    //  * @description: 删除    //  */    // public function destroy()    // {    //     $id = request()->post('id');    //     // 示例:通过 ID 删除    //     $Bet= IssueService::findOne(['id' => $id]);    //     if (!$info) {    //         return $this->error(0, '期数不存在');    //     }    //     $info->delete();    //     return $this->success([], '删除成功');    // }}
 |