find(); $join_member = Lottery::where('status', 0)->count(); $join = Lottery::where('status', 0)->where('uid', $request->uid())->group('num')->field('num,SUM(ticket) as ticket')->select(); $last_100 = LotteryLog::order('time', 'desc')->limit(100)->select(); $award_lake = sys_config('award_lake', 0, true); $all_point = Lottery::where('status', 1)->whereTime('open_time', 'today')->sum('ticket'); if ($all_point <= 0) $all_point = 1; $price = bcdiv($award_lake, bcmul($all_point, 2), 2); $join_price = sys_config('join_integral', 100, true); for ($i = 1; $i <= $num_max; $i++) { $times[$i] = 0; } foreach ($last_100 as $v) { $result = explode(',', $v['result']); $times["$result[0]"]++; } return app('json')->success('ok', compact('join', 'join_price', 'price', 'join_member', 'time_span', 'last_game', 'times')); } public function join(Request $request) { $res = Lottery::joinLottery($request->uid(), $request->post('num'), $request->post('ticket')); if ($res) { return app('json')->success('参加成功'); } else { return app('json')->fail(Lottery::getErrorInfo()); } } public function lastGame(Request $request) { $last_game = Cache::get('last_game', 0); $last_open = Cache::get('last_open', []); $open_time = Cache::get('open_time', 0); if ($last_game) { $my = Lottery::where('name', $last_game)->where('uid', $request->uid())->where('status', 1)->sum('ticket'); } else { $my = 0; } return app('json')->success('ok', compact('last_game', 'last_open', 'open_time', 'my')); } }