success('ok', ['list' => LalaPink::getList([], $page, $limit)]); } public function detail($id, Request $request) { list($page, $limit) = UtilService::getMore([['page', 1], ['limit', 10]], $request, true); $lala_pink_open = sys_config('lala_pink_open'); $lala_pink_close = sys_config('lala_pink_close'); // $next_pink = LalaPinkLog::max('add_time') + 7200; $open_times = open_times(); //上次开奖 $last_log = LalaPinkLog::order('add_time', 'desc')->find(); //下次开奖 $next_pink = []; $next_next_pink = []; foreach ($open_times as $k => $v) { if ($v['value'] > time() && $v['value'] > $last_log['add_time']) { $next_pink = $v; $next_next_pink = $open_times[$k + 1]; break; } } $data = LalaPink::validWhere()->where('id', $id)->find()->toArray(); if ($data['ticket_money_type'] != 'LALA') { $money_types = sys_data('money_type'); $origin_ratio = 0; $target_ratio = 0; foreach ($money_types as $v) { if ($v['code'] == $data['ticket_money_type']) { $origin_ratio = $v['usdt_price']; if ($origin_ratio == 0) { $origin_ratio = get_huobi_price($v['code']); } } if ($v['code'] == 'LALA') { $target_ratio = get_lala_ratio(); } } $ratio = bcdiv($origin_ratio, $target_ratio, 14); $data['ticket'] = bcmul($data['ticket'], $ratio, 8); $data['ticket_money_type'] = 'LALA'; } $data['ticket_money_type_name'] = get_money_name($data['ticket_money_type']); $data['cost_money_type_name'] = get_money_name($data['cost_money_type']); $data['cost_2_money_type_name'] = get_money_name($data['cost_2_money_type']); $data['bingo_money_type_name'] = get_money_name($data['bingo_money_type']); $data['sp_exchange_origin'] = get_money_name($data['sp_exchange_origin']); $data['sp_exchange_target'] = get_money_name($data['sp_exchange_target']); $data['_ticket'] = ($data['ticket'] * 1) . $data['ticket_money_type']; return app('json')->success('ok', [ 'luck_point' => LalaPinkJoin::where('paid', 1)->where('lala_id', $id)->where('status', 1)->where('uid', $request->uid())->count(), 'exchange_point' => LalaSpExchange::where('lala_id', $id)->where('uid', $request->uid())->sum('cost_time') + UserMiningMachine::where('uid', $request->uid())->where('paid', 1)->where('lala_id', $id)->sum('cost_times'), 'close_join' => sys_config('lala_pink_close_join_before_open'), 'open_times' => open_times(), 'next_pink' => $next_pink, 'next_pink_status' => false != LalaPinkJoin::where('paid', 1)->where('lala_id', $id)->where('status', 0)->where('uid', $request->uid())->find(), 'next_next_pink' => $next_next_pink, 'lala_pink_open' => $lala_pink_open, 'lala_pink_close' => $lala_pink_close, 'data' => $data, 'history_list' => LalaPinkJoin::group('group_id')->field('group_id,COUNT(id) as counts,AVG(open_time) as open_time,AVG(group_num) as group_num')->order('open_time desc')->page((int)$page, (int)$limit)->select(), ]); } public function join($id, Request $request) { $user = User::get($request->uid()); UtilService::postMore( [ ['trade_psw', '', '', '', ['not_empty_check', function ($item) use ($user) { return md5(md5($item)) == $user['trade_pwd']; }], ['请输入交易密码', '交易密码错误']], ], $request); $cost_type = $request->post('cost_type', ''); $res = LalaPinkJoin::join($request->uid(), $id, $cost_type); if (!$res) { return app('json')->fail(LalaPinkJoin::getErrorInfo('参与失败')); } else { return app('json')->success('参与成功,等待开奖!'); } } public function joinList(Request $request) { list($page, $limit, $id) = UtilService::getMore([['page', 1], ['limit', 10], ['id', '']], $request, true); return app('json')->success('ok', LalaPinkJoin::getList(['uid' => $request->uid(), 'id' => $id], $page, $limit)); } public function joinDetail($id, Request $request) { return app('json')->success('ok', LalaPinkJoin::getDetail(['uid' => $request->uid(), 'id' => $id])); } public function spExchange($id, Request $request) { $res = LalaPink::spExchange($request->uid(), $id); if (!$res) { return app('json')->fail(LalaPink::getErrorInfo('兑换失败')); } else { return app('json')->success('兑换成功'); } } public function spExchangeList($id, Request $request) { list($page, $limit) = UtilService::getMore([['page', 1], ['limit', 10]], $request, true); return app('json')->success(LalaPink::getExchangeList($id, $request->uid(), $page, $limit)); } //自动拼团列表 public function autoPinkList(Request $request) { list($page, $limit, $lala_id) = UtilService::getMore([['page', 1], ['limit', 10], ['lala_id', '']], $request, true); $where['lala_id'] = $lala_id; return app('json')->success(AutoPink::getList($where, $page, $limit)); } //自动拼团详情 public function autoPinkDetail($id, Request $request) { $info = AutoPink::validWhere()->find($id); if ($info) $info = $info->toArray(); if ($info) $info['money_type'] = get_money_name($info['money_type']); if ($info) { $time = time(); do { $info['my'] = UserAutoPink::where('uid', $request->uid())->where('auto_id', $id)->where('add_time', '<', $time)->order('add_time', 'desc')->find(); $time = $info['my'] ? $info['my']['add_time'] : 0; if ($info['my']['is_forever'] || $info['my']['valid_time'] > time()) break; } while ($info['my']); } if ($info) $info['lalas'] = LalaPink::where('id', 'in', explode(',', $info['lala_id']))->select()->toArray(); return app('json')->success('ok', $info); } //开通自动拼团 public function openAutoPink($id, Request $request) { $user = User::get($request->uid()); UtilService::postMore( [ ['trade_psw', '', '', '', ['not_empty_check', function ($item) use ($user) { return md5(md5($item)) == $user['trade_pwd']; }], ['请输入交易密码', '交易密码错误']], ], $request); $res = UserAutoPink::open($request->uid(), $id); if (!$res) { return app('json')->fail(LalaPinkJoin::getErrorInfo('开通失败')); } else { return app('json')->success('已开通'); } } //修改自动拼团状态 public function switchAutoPinkStatus($id, Request $request) { $info = UserAutoPink::where('uid', $request->uid())->where('id', $id)->find(); if (!$info) { return app('json')->fail('开通记录不存在'); } if (!$info['is_forever'] && $info['valid_time'] < time()) return app('json')->fail('自动拼购已到期'); if ($info['status']) { $res = UserAutoPink::where('id', $id)->update(['status' => 0]); } else { $res = UserAutoPink::where('id', $id)->update(['status' => 1]); } if (!$res) { return app('json')->fail(LalaPinkJoin::getErrorInfo('操作失败')); } else { return app('json')->success('操作成功'); } } }