input('phone'); $password = $request->input('password'); $shopsn = $request->input('shopsn'); $agentId = $request->input('agtcid'); if (!Helps::validPhone($phone)) { ThrowException::run('手机号码格式错误'); } ThrowException::isTrue(!$shopsn, '404-1', Result::NOT_FOUND); $shop = Shop::where('shop_sn', $shopsn)->first(); ThrowException::isTrue(!$shop, '404-2', Result::NOT_FOUND); $customer = Customer::where('phone', $phone) ->where('shop_id', $shop->id) ->first(); if ($customer) { return $this->jsonSuccess([], '已注册,请登录...'); } $agent = null; if ($agentId) { $agent = Customer::find($agentId); } $customer = new Customer(); $customer->phone = $phone; $customer->password = Customer::encryPassword($password); $customer->shop_id = $shop->id; if ($agent) { $customer->agent_id = $agent->id; $customer->regist_agent_at = date('Y-m-d H:i:s'); $customer->regist_agent_date = date('Ymd'); } $customer->name = substr($phone, -5); $customer->nickname = substr($phone, -5); $customer->useragent = strval($request->userAgent()); $customer->client_type = Helps::getClientType($customer->useragent); $customer->save(); CustomerShop::where('phone', $phone)->update([ 'logined' => BoolEnum::NO ]); $customerShop = new CustomerShop(); $customerShop->customer_id = $customer->id; $customerShop->phone = $phone; $customerShop->shop_id = $shop->id; $customerShop->logined = BoolEnum::YES; $customerShop->save(); return $this->jsonSuccess([ 'redirect' => Helps::appBuyerDownloadUrl() ], '注册成功,请登录...'); } /** * @api {POST} /api/customer/login auth-登录 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiParam {String} phone 手机号码 * @apiParam {String} password 密码 * * @apiSuccessExample {json} 返回结果 * { * "code": 200, * "message": "", * "data": { * "access_token": "eyJ0eXA5z7uNNgL76GgVGFFMOuINwHJnG73s", // token * "token_type": "bearer", * "expires_in": 36000 // 有效时长(秒) * } * } */ public function login(Request $request) { $error = AuthValidator::loginErrors($request); ThrowException::isTrue($error, $error); $phone = $request->input('phone'); $password = $request->input('password'); if (!preg_match('/^1[3-9]\d{9}$/i', $phone)) { ThrowException::run('手机号码格式错误'); } $customers = Customer::where('phone', $phone)->get(); ThrowException::isTrue(count($customers) <= 0, '手机号或密码错误'); $loginCustomer = null; foreach ($customers as $customer) { if (Customer::checkPassword($password, $customer->password)) { $loginCustomer = $customer; $exist = CustomerShop::where('customer_id', $customer->id) ->where('shop_id', $customer->shop_id) ->where('logined', BoolEnum::YES) ->first(); if ($exist) { break; } } } ThrowException::isTrue(!$loginCustomer, '手机号或密码错误'); $customerShop = CustomerShop::where('phone', $phone) ->where('shop_id', $loginCustomer->shop_id) ->first(); if (!$customerShop) { ThrowException::run('登录失败,请联系网站管理员'); } $token = auth('customer')->login($loginCustomer); ThrowException::isTrue(!$token, '登录失败!'); CustomerShop::where('phone', $phone)->update([ 'logined' => BoolEnum::NO ]); CustomerShop::where('id', $customerShop->id)->update([ 'logined' => BoolEnum::YES ]); return $this->respondWithToken($token); } protected function respondWithToken($token) { return $this->jsonSuccess([ 'access_token' => $token, 'token_type' => 'bearer', 'expires_in' => auth('customer')->factory()->getTTL() * 60 ]); } /** * @api {POST} /api/customer/refresh_token auth-刷新token * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiSuccessExample {json} 返回结果 * { * "code": 200, * "message": "", * "data": { * "access_token": "eyJ0eXA5z7uNNgL76GgVGFFMOuINwHJnG73s", // token * "token_type": "bearer", * "expires_in": 36000 // 有效时长(秒) * } * } */ public function refreshToken() { return $this->respondWithToken(auth('customer')->refresh()); } /** * @api {POST} /api/customer/switch_account auth-切换账号(更换店铺) * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiParam {Int} shop_id 店铺id * @apiParam {Int} customer_id 用户id * * @apiSuccessExample {json} 返回结果 * { * "code": 200, * "message": "", * "data": { * "access_token": "eyJ0eXA5z7uNNgL76GgVGFFMOuINwHJnG73s", // token * "token_type": "bearer", * "expires_in": 36000 // 有效时长(秒) * } * } */ public function switchAccount(Request $request) { $targetShopId = $request->input('shop_id'); $password = $request->input('password'); $target = Customer::where('phone', $this->customer()->phone) ->where('shop_id', $targetShopId)->first(); ThrowException::isTrue(!$target, '店铺不存在'); ThrowException::isTrue(!Customer::checkPassword($password, $target->password), '密码错误'); $customerShop = CustomerShop::where('phone', $target->phone) ->where('shop_id', $targetShopId) ->first(); ThrowException::isTrue(!$customerShop, '店铺不存在!'); if ($target->phone != $this->customer()->phone) { ThrowException::run('无法更换店铺'); } $token = auth('customer')->login($target); ThrowException::isTrue(!$token, '更换店铺失败'); CustomerShop::where('phone', $target->phone)->update([ 'logined' => BoolEnum::NO ]); CustomerShop::where('id', $customerShop->id)->update([ 'logined' => BoolEnum::YES ]); return $this->respondWithToken($token); } /** * @api {GET|POST} /api/customer/logout auth-退出 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiSuccessExample {json} 返回结果 * { * "code":200, * "message":"", * "data":[] * } */ public function logout() { auth('customer')->logout(); return $this->jsonSuccess(); } /** * @api {GET} /api/customer/winning_info 首页-播报和海报 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiSuccessExample {json} 返回结果 * { * "broadcast": [ // 播报 * "xxxxxxxxxxxxxxx", * "bbbbbbbbbbbbbbbbb" * ], * "poster": [ // 海报 * { * "id": 1, // 数据id * "customer": { // * "id": 1, // 用户id * "avatar": "xxxx", // 用户头像 * "level_name": "xxxx", // 级别名称 * "name": "xxxx" // 用户名称 * }, * "lottery_name": 'xxxx', // 彩种名称 * "money": 2222.22, // 方案金额 * "prize": 2222.22, // 奖金 * "cdate": "2022-01-01" // 日期 * }, * ... * ] * } * */ public function winningInfo(Request $request) { $broadcasts = ReportDayWin::with([ 'customer:id,name,nickname,avatar,level_score,phone', 'lottery:id,name' ]) ->where('shop_id', $this->customerShopId()) ->orderBy('cdate', 'desc') ->orderBy('order_prize', 'desc') ->limit(50) ->get(); $broadcast = []; $poster = []; foreach ($broadcasts as $item) { $itemPrize = $item->order_send_prize > 0 ? $item->order_send_prize : $item->order_tax_prize; $broadcast[] = sprintf('恭喜%s%s收米%d元', $item->customer->hide_name, $item->lottery->name, $itemPrize); } $poster = ReportDayWin::with([ 'customer:id,name,nickname,avatar,level_score,phone', 'lottery:id,name' ]) ->where('shop_id', $this->customerShopId()) ->where('cdate', date('Ymd', strtotime('-1 day'))) ->orderBy('order_prize', 'desc') ->limit(2) ->get(); $data = [ 'broadcast' => $broadcast, 'poster' => $poster ]; return $this->jsonSuccess($data); } /** * @api {GET} /api/customer/win_poster 首页-中奖海报 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiParam {String} type all全部,my我的 * @apiParam {Int} [page] 页数 * @apiParam {Int} [size] 每页条数,默认20 * * @apiSuccessExample {json} 返回结果 * { * "code":200, * "message":"", * "data":[ * { * "cdate":"昨日", // 日期 * "poster":[{ * "id":1, * "order_sn":"xxx", * "customer":{ * "id":1, * "name":"aaa", // 用户名 * "level_name":"", // 级别名称 * "avatar":"" // 用户头像 * }, * "prize":1000, // 奖金 * "money":1000, // 方案金额 * "lottery_name":"x", // 彩种名称 * "cdate":"2023-04-06" * } * }] * ] * } */ public function winPoster(Request $request) { $allowDates = []; for ($date = date('Ymd'); $date >= date('Ymd', strtotime('-7 day')); $date = date('Ymd', strtotime('-1 day', strtotime($date)))) { $allowDates[] = $date; } // my|all,我的和全部 $type = $request->input('type'); $query = ReportDayWin::select([ DB::raw('count(*) as c'), 'cdate' ]) ->whereIn('cdate', $allowDates) ->where('shop_id', $this->customerShopId()); if ($type == 'my') { $query->where('customer_id', $this->customerId()); } $query->groupBy('cdate'); $total = $query->count(); $size = $request->input('size'); $page = $request->input('page'); if ($page < 1) { $page = 1; } if ($size < 1) { $size = 5; } if ($size > 30) { $size = 30; } $offset = ($page - 1) * $size; $winDays = $query->orderBy('cdate', 'desc') ->offset($offset) ->limit( $size) ->get(); if (count($winDays) < 1) { $result = [ 'data' => [], 'total' => 0, 'per_page' => $size, 'current_page' => $page, ]; return $this->jsonSuccess($result); } $cdates = $winDays->pluck('cdate')->toArray(); $reports = []; foreach ($cdates as $cdate) { $reportDay = ReportDayWin::with([ 'customer:id,name,nickname,avatar,level_score', 'lottery:id,name' ]) ->where('shop_id', $this->customerShopId()) ->where('cdate', $cdate) ->orderBy('order_prize', 'desc') ->limit(4) ->get(); $reports[date('Y-m-d', strtotime($cdate))] = $reportDay; } $result = [ 'data' => $reports, 'total' => $total, 'per_page' => $size, 'current_page' => $page, ]; return $this->jsonSuccess($result); } /** * @api {GET} /api/customer/shop 首页-店铺信息 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiSuccessExample {json} 返回结果 * { * "id": 1, * "seller_id": 1, * "name": "shop1", // 名称 * "seller_name": "******", // 店主名 * "seller_phone": "******", // 店主电话 * "seller_wechat": "qerewrwq", // 微信 * "addr": "******", // 地址 * "announcement": "fdsafdsafdsa", // 公告 * } * */ public function shop(Request $request) { $shop = $this->customer()->shopWithHideContacts(); return $this->jsonSuccess($shop); } /** * @api {GET} /api/customer/win_jclq_result 开奖公告-竞彩篮球 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiParam {String} [issue_num] 期号 * * @apiSuccessExample {json} 返回结果 * { * "code":200, * "message":"", * "data":{ * "issue_nums":[ * "2023-05-04/周四" * ], * "result":[ * { * "id":1, * "jclq_odds_id":1, * "odds_id":5131, * "match_id":97866, * "issue_num":"2023-05-04/周四", * "issue_date":"2023-05-04", // 日期 * "issue_week":"2023-05-04", // 周 * "play_num":"301", * "is_reverse":0, * "home_score":104, // 主队比分 * "away_score":69, // 客队比分 * "q1home_score":17, * "q1away_score":24, * "q2home_score":30, * "q2away_score":12, * "q3home_score":32, * "q3away_score":17, * "q4home_score":25, * "q4away_score":16, * "othome_score":0, * "otaway_score":0, * "lottery_state":"hasLottery", * "lottery_time":"2023-05-05 08:59:00", * "sf_field":"win", // 胜负 * "sf_name":"主胜", * "sf_odds":"1.76", // 让分 * "rf_handicap":"-4.50", * "rf_field":"win", * "rf_name":"让分主胜", * "rf_odds":"1.70", * "sfc_field":"w6", // 胜分差 * "sfc_name":"主胜26+", * "sfc_odds":"17.00", * "dxf_total_score":"162.50", // 大小分 * "dxf_field":"big", * "dxf_name":"大", * "dxf_odds":"1.70", * "created_at":"2023-05-05 20:37:15", * "updated_at":"2023-05-05 20:37:15", * "deleted_at":null, * "match":{ // 比赛信息 * "id":84864, * "match_id":97866, * "competition_name":"欧篮联", // 赛事名 * "home_team_name":"特拉维夫马卡比", // 主队 * "away_team_name":"摩纳哥", // 客队 * "start_week":"", * "start_time_str":"" * } * }, * ] * } * } */ public function winJclqResult(Request $request) { $issueNum = $request->input('issue_num'); $monthStartDate = date('Y-m-d', strtotime('-30 day')); $query = JclqResult::with('match:id,match_id,competition_name,home_team_name,away_team_name') ->where('lottery_state', 'hasLottery'); $issueNums = $query->where('issue_date', '>', $monthStartDate) ->orderBy('issue_date', 'desc') ->pluck('issue_num') ->toArray(); if (!$issueNums) { return $this->jsonSuccess([ 'issue_nums' => [], 'result' => [] ]); } if (!$issueNum) { $issueNums = array_values(array_unique($issueNums)); $issueNum = $issueNums[0]; } $result = $query->where('issue_num', $issueNum) ->get(); return $this->jsonSuccess([ 'issue_nums' => $issueNums, 'result' => $result ]); } /** * @api {GET} /api/customer/win_jczq_result 开奖公告-竞彩足球 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiParam {String} [issue_num] 期号 * * @apiSuccessExample {json} 返回结果 * { * "code":200, * "message":"", * "data":{ * "issue_nums":[ * "2023-05-03/周三" * ], * "result":[ * { * "id":1, * "jczq_odds_id":0, * "odds_id":0, * "match_id":392837, * "issue_num":"2023-05-03/周三", * "issue_date":"2023-05-03", // 日期 * "issue_week":"2023-05-04", // 周 * "play_num":3, // 场次 * "half_time_score":"2 : 1", // 半场比分 * "full_time_score":"2 : 1", // 全场比分 * "is_reverse":0, * "lottery_state":"hasLottery", * "lottery_time":"2023-05-04 09:18:00", // 开奖时间 * "spf_odds":"1.37", // 胜平负赔率 * "spf_field":"win", // 胜 * "spf_name":"胜", // 名称 * "rq_odds":"3.10", // 让球 * "rq_handicap":"-1.00", // 让几个 * "rq_field":"draw", // 字段 * "rq_name":"平", // 名称 * "bf_odds":"7.50", // 比分 * "bf_field":"wh2a1", // 字段 * "bf_name":"2:1", // 名称 * "jq_odds":"4.00", // 总进球 * "jq_field":"g3", * "jq_name":"3", * "bqc_odds":"2.15", * "bqc_field":"ww", // 半全场 * "bqc_name":"胜胜", * "created_at":"2023-05-04 21:42:56", * "updated_at":"2023-05-04 21:42:56", * "match":{ * "competition_name":xx, //赛事名 * "home_team_name":xx, //主队名 * "away_team_name":xx, //客队 * } * }, * ] * } * } * */ public function winJczqResult(Request $request) { $issueNum = $request->input('issue_num'); $monthStartDate = date('Y-m-d', strtotime('-30 day')); $query = JczqResult::with('match:id,match_id,competition_name,home_team_name,away_team_name') ->where('lottery_state', 'hasLottery'); $issueNums = $query->where('issue_date', '>', $monthStartDate) ->orderBy('issue_date', 'desc') ->pluck('issue_num') ->toArray(); if (!$issueNums) { return $this->jsonSuccess([ 'issue_nums' => [], 'result' => [] ]); } if (!$issueNum) { $issueNums = array_values(array_unique($issueNums)); $issueNum = $issueNums[0]; } $result = $query->where('issue_num', $issueNum) ->get(); return $this->jsonSuccess([ 'issue_nums' => $issueNums, 'result' => $result ]); } /** * @api {GET} /api/customer/win_ctzq_jqc_result 开奖公告-传统足球-4场进球彩 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiSuccessExample {json} 返回结果 * { * "code":200, * "message":"", * "data":{ * "current_page":1, * "data":[ * { * "id":1, * "ret_id":473, * "type":"ctzq_jqc", * "issue_num":"23070", // 期号 * "state":"hasLottery", * "start_time":"2023-04-30 20:00:00", * "end_time":"2023-05-03 22:00:00", * "prize_time":"2023-05-04 10:02:04", // 开奖时间 * "result_info":"3+010213+1", // 开奖结果 * "result_array":"3+010213+1", // 开奖结果 * "sales":"2765664.00", * "jackpot":"0.00", * "first_prize_num":255, * "first_prize_value":6941, * "created_at":"2023-05-04 21:32:16", * "updated_at":"2023-05-04 21:32:16", * "deleted_at":null, * }, * ], * "per_page":20, * "total":2 * } * } */ public function winCtzqJqcResult(Request $request) { $size = $request->input('size'); $list = CtzqJqc::where('state', 'hasLottery') ->orderBy('issue_num', 'desc') ->paging($size); return $this->jsonSuccess($list); } /** * @api {GET} /api/customer/win_ctzq_jqc_detail_result 开奖公告-传统足球-4场进球彩详情 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiSuccessExample {json} 返回结果 * { * "code":200, * "message":"", * "data":{ * "current_page":1, * "data":[ * { * "id":1, * "ret_id":473, * "type":"ctzq_jqc", * "issue_num":"23070", // 期号 * "state":"hasLottery", * "start_time":"2023-04-30 20:00:00", * "end_time":"2023-05-03 22:00:00", * "prize_time":"2023-05-04 10:02:04", // 开奖时间 * "result_info":"3+010213+1", // 开奖结果 * "result_array":"3+010213+1", // 开奖结果 * "sales":"2765664.00", * "jackpot":"0.00", * "first_prize_num":255, * "first_prize_value":6941, * "created_at":"2023-05-04 21:32:16", * "updated_at":"2023-05-04 21:32:16", * "deleted_at":null, * "matchs": [ * { * "no":0, // 编号 * "result":0, // 结果 * "jcAwayTeamName":0, // 客队 * "jcHomeTeamName":0, // 主队 * "half_time_score":0, // 半场比分 * "full_time_score":0, // 整场比分 * } * ], * }, * ], * "per_page":20, * "total":2 * } * } */ public function winCtzqJqcDetailResult(Request $request) { $id = $request->input('ctzq_jqc_id'); $ctzq = CtzqJqc::find($id); if ($ctzq->matchs) { $matchIds = array_column($ctzq->matchs, 'matchId'); $matchs = ZqMatch::whereIn('match_id', $matchIds)->get()->keyBy('match_id'); foreach ($ctzq->matchs as &$item) { $item['half_time_score'] = Arr::get($matchs, $item['matchId'] . '.half_time_score', ''); $item['full_time_score'] = Arr::get($matchs, $item['matchId'] . '.half_time_score', ''); } } return $this->jsonSuccess($ctzq); } /** * @api {GET} /api/customer/win_ctzq_bqc_result 开奖公告-传统足球-6场半全场 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiSuccessExample {json} 返回结果 * { * "code":200, * "message":"", * "data":{ * "current_page":1, * "data":[ * { * "id":1, * "ret_id":473, * "type":"ctzq_jqc", * "issue_num":"23070", // 期号 * "state":"hasLottery", * "start_time":"2023-04-30 20:00:00", * "end_time":"2023-05-03 22:00:00", * "prize_time":"2023-05-04 10:02:04", // 开奖时间 * "result_info":"3+010213+1", // 开奖结果 * "result_array":"3+010213+1", // 开奖结果 * "sales":"2765664.00", * "jackpot":"0.00", * "first_prize_num":255, * "first_prize_value":6941, * "created_at":"2023-05-04 21:32:16", * "updated_at":"2023-05-04 21:32:16", * "deleted_at":null, * }, * ], * "per_page":20, * "total":2 * } * } */ public function winCtzqBqcResult(Request $request) { $size = $request->input('size'); $list = CtzqBqc::where('state', 'hasLottery') ->orderBy('issue_num', 'desc') ->paging($size); return $this->jsonSuccess($list); } /** * @api {GET} /api/customer/win_ctzq_bqc_detail_result 开奖公告-传统足球-6场半全场详情 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiSuccessExample {json} 返回结果 * { * "code":200, * "message":"", * "data":{ * "current_page":1, * "data":[ * { * "id":1, * "ret_id":473, * "type":"ctzq_jqc", * "issue_num":"23070", // 期号 * "state":"hasLottery", * "start_time":"2023-04-30 20:00:00", * "end_time":"2023-05-03 22:00:00", * "prize_time":"2023-05-04 10:02:04", // 开奖时间 * "result_info":"3+010213+1", // 开奖结果 * "result_array":"3+010213+1", // 开奖结果 * "sales":"2765664.00", * "jackpot":"0.00", * "first_prize_num":255, * "first_prize_value":6941, * "created_at":"2023-05-04 21:32:16", * "updated_at":"2023-05-04 21:32:16", * "deleted_at":null, * "matchs": [ * { * "no":0, // 编号 * "result":0, // 结果 * "jcAwayTeamName":0, // 客队 * "jcHomeTeamName":0, // 主队 * "half_time_score":0, // 半场比分 * "full_time_score":0, // 整场比分 * } * ], * }, * ], * "per_page":20, * "total":2 * } * } */ public function winCtzqBqcDetailResult(Request $request) { $id = $request->input('ctzq_bqc_id'); $ctzq = CtzqBqc::find($id); if ($ctzq->matchs) { $matchIds = array_column($ctzq->matchs, 'matchId'); $matchs = ZqMatch::whereIn('match_id', $matchIds)->get()->keyBy('match_id'); foreach ($ctzq->matchs as &$item) { $item['half_time_score'] = Arr::get($matchs, $item['matchId'] . '.half_time_score', ''); $item['full_time_score'] = Arr::get($matchs, $item['matchId'] . '.half_time_score', ''); } } return $this->jsonSuccess($ctzq); } /** * @api {GET} /api/customer/win_shuzi_result 开奖公告-数字彩 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiSuccessExample {json} 返回结果 * { * "code":200, * "message":"", * "data":[ * { * "lottery_type":"dlt", // 彩种 * "dlt":{ // 大乐透的数据格式 * "id":11, * "issue_num":"23063", // 期号 * "state":1, * "enable":0, * "close_time":null, * "prize_time":null, // 开奖时间 * "qian":[ // 红球 * "04", * "18", * "29", * "31", * "34" * ], * "hou":[ // 篮球 * "06", * "09" * ], * "result_time":"2023-06-06T14:00:09.000000Z" // 抓取开奖时间 * } * } * ] * } */ public function winShuziResult(Request $request) { $dlt = Dlt::where('state', BoolEnum::YES) ->orderBy('issue_num', 'desc') ->first(); $qxc = Qxc::where('state', BoolEnum::YES) ->orderBy('issue_num', 'desc') ->first(); $pls = Pls::where('state', BoolEnum::YES) ->orderBy('issue_num', 'desc') ->first(); $plw = Plw::where('state', BoolEnum::YES) ->orderBy('issue_num', 'desc') ->first(); $list = [ [ 'lottery_type' => LottType::DLT, 'result' => $dlt ], [ 'lottery_type' => LottType::QXC, 'result' => $qxc ], [ 'lottery_type' => LottType::PLS, 'result' => $pls ], [ 'lottery_type' => LottType::PLW, 'result' => $plw ] ]; return $this->jsonSuccess($list); } /** * @api {GET} /api/customer/win_shuzi_detail_result 开奖公告-数字彩详情 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiParam {String} lottery_type 彩种类型 * * @apiSuccessExample {json} 返回结果 * { * "code":200, * "message":"", * "data":{ * "current_page":1, * "data":[ // 大乐透的数据格式 * { * "id":11, * "issue_num":"23063", * "state":1, * "enable":0, * "close_time":null, * "prize_time":null, * "qian":[ * "04", * "18", * "29", * "31", * "34" * ], * "hou":[ * "06", * "09" * ], * "prize":"0.0000", // 奖池 * "base1_num":6, // 一等奖注数 * "base2_num":91, // 二等奖注数 * "base3_num":186, // 三等奖注数 * "base1_prize":"6757853.0000", // 一等奖金 * "add1_num":2, // 二等奖追加注数 * "base2_prize":"129591.0000", // 二等奖金 * "add2_num":28, // 二等奖追加注数 * "base3_prize":"10000.0000", // 三等奖金 * "add3_num":0, // 三等奖追加注数 * "add1_prize":"5406282.0000", // 一等奖追加奖金 * "add2_prize":"103672.0000", // 二等奖追加奖金 * "add3_prize":"0.0000", // 三等奖追加奖金 * "created_at":"2023-06-06 22:00:09", * "updated_at":"2023-06-06 22:00:09", * "deleted_at":null, * "result_time":"2023-06-06T14:00:09.000000Z" * }, * ], * "from":1, * "per_page":20, * "to":20, * "total":20 * } * } */ public function winShuziDetailResult(Request $request) { switch ($request->input('lottery_type')) { case LottType::DLT: return $this->winDltResult($request); case LottType::QXC: return $this->winQxcResult($request); case LottType::PLS: return $this->winPlsResult($request); case LottType::PLW: return $this->winPlwResult($request); } return $this->jsonSuccess(); } private function winDltResult(Request $request) { $size = $request->input('size'); $list = Dlt::where('state', BoolEnum::YES) ->orderBy('issue_num', 'desc') ->paging($size); return $this->jsonSuccess($list); } private function winQxcResult(Request $request) { $size = $request->input('size'); $list = Qxc::where('state', BoolEnum::YES) ->orderBy('issue_num', 'desc') ->paging($size); return $this->jsonSuccess($list); } private function winPlsResult(Request $request) { $size = $request->input('size'); $list = Pls::where('state', BoolEnum::YES) ->orderBy('issue_num', 'desc') ->paging($size); return $this->jsonSuccess($list); } private function winPlwResult(Request $request) { $size = $request->input('size'); $list = Plw::where('state', BoolEnum::YES) ->orderBy('issue_num', 'desc') ->paging($size); return $this->jsonSuccess($list); } /** * @api {GET} /api/customer/qrcode 二维码-生成 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiParam {String} content 二维码内容 * @apiParam {Int} [size] 大小,默认80 * @apiParam {String} [format] 格式(png,svg,eps),默认png * */ public function qrcode(Request $request) { // if (!$this->customer()) { // return response('', 404); // } $content = strval($request->input('content')); $size = $request->input('size'); $format = $request->input('format'); // png,svg,eps $formats = [ 'png', 'svg', 'eps', ]; if (!$format) { $format = 'png'; } ThrowException::isTrue(!$content, '404', Result::NOT_FOUND); ThrowException::isTrue(!in_array($format, $formats), '格式有误'); if (!$size) { $size = 80; } $resp = QrCode::format($format) ->size($size) ->generate($content); return response($resp)->header('Content-Type', ['octet-stream']); } /** * @api {GET} /api/customer/current_win 特效-展示 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiSuccessExample {json} 返回结果,参考订单列表 * {} */ public function currentWin() { $orders = Order::with([ 'lotteryType', 'customer:id,name,nickname,avatar,level_score' ]) ->where('customer_id', $this->customerId()) ->where('win_date', date('Ymd')) ->whereIn('lottery_state', Order::zhongJiangStates()) ->where('win_viewed', BoolEnum::NO) ->get(); $result = []; foreach ($orders as $order) { $result[] = [ 'id' => $order->id, 'order_sn' => $order->order_sn, 'order_prize' => $order->lottery_should_send_prize, 'order_money' => $order->money, 'lottery_name' => $order->lotteryType->name, 'cdate' => date('Y-m-d', strtotime($order->win_date)), 'customer' => $order->customer, ]; } return $this->jsonSuccess($result); } /** * @api {POST} /api/customer/current_win_viewed 特效-查看 * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiParam {String} order_sn 订单编号 * */ public function currentWinViewed(Request $request) { $orderSn = $request->input('order_sn'); ThrowException::isTrue(!$orderSn, '无订单编号'); $order = Order::sn($orderSn) ->where('customer_id', $this->customerId()) ->where('win_viewed', BoolEnum::NO) ->whereIn('lottery_state', Order::zhongJiangStates()) ->first(); if ($order) { $order->win_viewed = BoolEnum::YES; $order->save(); } return $this->jsonSuccess(); } }