input('lottery_type_id'); $result = $service->saleLotteries($this->customer(), $lotteryTypeId); return $this->jsonSuccess($result); } /** * @api {POST} /api/customer/guan_ya/compute 冠亚军compute * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiParam {Int} lottery_type_id 类型ID * @apiParam {Object} odds 数据 * { * "lottery_type_id":13, * "bets_num":1, 倍数 * "odds":{ id => 赔率 * "1":11, * "2":22 * } * } * * @apiSuccessExample {json} 返回结果 * { * "code":200, * "message":"", * "data":{ * "zhu_num":5, * "bets_num":2, * "expect_bets":0, * "money":10, // 总金额 * "prize_min":0, * "prize_max":0 * } * } */ public function compute(Request $request, GuanYaService $service) { $odds = $request->input('odds'); $lotteryTypeId = $request->input('lottery_type_id'); $betsNum = $request->input('bets_num'); $lott = Lottery::active()->shopAndType($this->customerShopId(), $lotteryTypeId)->first(); ThrowException::isTrue(!$lott, '暂不支持该彩种'); $odds = $service->refreshOdds($odds); $computeInfo = $service->computePrizeInfo($odds, $betsNum); return $this->jsonSuccess($computeInfo); } /** * @api {POST} /api/customer/guan_ya/cart 冠亚军cart * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiParam {Int} lottery_type_id 类型ID * @apiParam {Object} odds 数据 参考compute的odds * * @apiSuccessExample {json} 返回结果 * { * "code": 200, * "message": "", * "data": { * "title": "冠亚军", * "money": 4, * "prize_min": 10.4, * "prize_max": 10.4, * "close_time_str": "1970-01-01 07:50:00截止,请尽快提交投注", * "odds": [ // 这个地方如果格式不对,给我说 * { * "id": 2, * "jczq_guanya_id": 1, * "odds_id": 76, * "team_id": 305, * "team_name": "法国", * "option_num": 2, * "odds": "1.76", * "season": "", * "sales_state": "stopSelling", * "show_state": "out", * "order_state": "stopSelling", * "created_at": "2024-06-05 11:10:14", * "updated_at": "2024-06-05 11:13:17", * "deleted_at": null * } * ], * "has_fadan": false, * "has_union": true, * "prize_optimize": false * } * } */ public function cart(Request $request, GuanYaService $service) { $odds = $request->input('odds'); $betsNum = $request->input('bets_num'); $lotteryTypeId = $request->input('lottery_type_id'); /** @var JczqGuan $guanya */ $guanya = $service->getSellingGuan(); /** @var Lottery $lott */ $lott = Lottery::active()->shopAndType($this->customerShopId(), $lotteryTypeId)->first(); ThrowException::isTrue(!$lott, '暂不支持该彩种'); $odds = $service->refreshOdds($odds); $moneyInfo = $service->computePrizeInfo($odds, $betsNum); $odds = JczqGuanYaOdds::whereIn('id', array_keys($odds))->orderBy('option_num', 'asc')->get(); $data = [ 'title' => '冠亚军', 'money' => $moneyInfo['money'], 'prize_min' => $moneyInfo['prize_min'], 'prize_max' => $moneyInfo['prize_max'], 'zhu_num' => $moneyInfo['zhu_num'], 'close_time_str' => sprintf('%s截止,请尽快提交投注', $guanya->getCloseTime($lott->earlySecond())), 'odds' => $odds, 'has_fadan' => false, 'has_union' => $lott->enableHemai(), 'prize_optimize' => $lott->enableOptimizePrize(), ]; return $this->jsonSuccess($data); } /** * @api {POST} /api/customer/guan_ya/order/create 冠亚军-order-create * @apiVersion 0.1.0 * @apiGroup 客户端 * * @apiParam {Int} lottery_type_id 类型ID * @apiParam {Object} odds 数据 * * @apiSuccessExample {json} 返回结果 * { * "code":200, * "message":"", * "data":{ * "zhu_num":5, * "bets_num":2, * "expect_bets":0, * "money":10, // 总金额 * "prize_min":0, * "prize_max":0 * } * } */ public function orderCreate(Request $request, GuanYaService $service) { $data = $request->all(); $lotteryTypeId = Arr::get($data, 'lottery_type_id'); $lotteryType = LotteryType::find($lotteryTypeId); ThrowException::isTrue(!$lotteryType, '暂不支持该彩种'); /** @var Customer $customer */ $customer = Customer::find($this->customerId()); if (!$this->getPayTypes()) { ThrowException::isTrue($customer->balanceActive()<=0, '该店铺暂未开启支付'); } $order = $service->createOrder($this->customer(), $data); $payMoney = $order->getPayMoney(); /** @var Customer $customer */ $customer = Customer::find($this->customerId()); $balance = $customer->balanceActive(); return $this->jsonSuccess([ 'order_sn' => $order->order_sn, 'balance' => $balance, 'money' => $payMoney, 'need_pay_money' => Helps::floatFormat($balance >= $payMoney ? 0 : $payMoney - $balance), 'username' => $this->customer()->name, 'lottery' => $order->lotteryName(), 'pay_types' => $this->getPayTypes() ]); } }