get('type', 'XCH'); $all = UserMiningMachine::where('get_money_type', 'in', $type)->where('uid', $request->uid())->sum('num'); $doing = UserMiningMachine::where('get_money_type', 'in', $type)->where('uid', $request->uid())->where('status', 'in', [1, 2])->sum('num'); $stand = UserMiningMachine::where('get_money_type', 'in', $type)->where('uid', $request->uid())->where('status', 0)->sum('num'); $umids = UserMiningMachine::where('uid', $request->uid())->column('id'); $all_mining = UserMining::where('get_money_type', 'in', $type)->where('umid', 'in', $umids)->sum('get_money'); $all_lock = UserMining::where('get_money_type', 'in', $type)->where('umid', 'in', $umids)->sum('lock_money'); return app('json')->success('ok', compact('all', 'doing', 'stand', 'all_mining', 'all_lock')); } /** * 算力产品 * @param Request $request * @return mixed */ public function lst(Request $request) { $page = $request->get('page', 1); $limit = $request->get('limit', 10); $uid = $request->get('uid', $request->uid()); $get_money_type = $request->get('get_money_type', ''); $type = $request->get('type', ''); return app('json')->success('ok', MiningMachine::getList($page, $limit, ['get_money_type' => $get_money_type, 'type' => $type, 'uid' => $uid])); } /** * @param $id * @param Request $request * @return mixed * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function detail($id, Request $request) { $res = MiningMachine::valid()->where('id', $id)->find()->toArray(); $money_type = init_money_type(); $res['_day_get'] = $res['day_get'] . $money_type[$res['get_money_type']] . '/T'; $res['_cost_money'] = $res['cost_money'] . $money_type[$res['cost_money_type']]; $res['_stand_money'] = $res['stand_money'] . $money_type[$res['get_money_type']]; $res['lala'] = LalaPink::get($res['lala_id']); $res['luck_point'] = LalaPinkJoin::where('paid', 1)->where('lala_id', $res['lala_id'])->where('status', 1)->where('uid', $request->uid())->count(); $res['exchange_point'] = LalaSpExchange::where('lala_id', $res['lala_id'])->where('uid', $request->uid())->sum('cost_time') + UserMiningMachine::where('uid', $request->uid())->where('paid', 1)->where('lala_id', $id)->sum('cost_times'); $res['tags'] = explode(',', $res['tags']); $res['_cost_money_type'] = $money_type[$res['cost_money_type']]; $res['get_money_type'] = $money_type[$res['get_money_type']]; $res['cost_money_type'] = $money_type[$res['cost_money_type']]; return app('json')->success('ok', $res); } public function buy($id, Request $request) { $user = $request->user(); list($num,) = UtilService::postMore( [ ['num', 0,], ['trade_psw', '', '', '', ['not_empty_check', function ($item) use ($user) { // var_dump($user); return md5(md5($item)) == $user['trade_pwd']; }], ['请输入交易密码', '交易密码错误']], ], $request, true); $res = MiningMachine::buyMachine($id, $request->uid(), $num); if ($res) { return app('json')->success('购买成功'); } else { return app('json')->fail(MiningMachine::getErrorInfo()); } } public function my(Request $request) { $where = UtilService::getMore([ ['page', 1], ['limit', 10], ]); $where['uid'] = $request->uid(); return app('json')->success('ok', UserMiningMachine::getList($where)); } public function newList(Request $request) { $where = UtilService::getMore([ ['page', 1], ['limit', 10], ]); $userStair = []; $users = [$request->uid()]; while ($users) { $users = User::where('spread_uid', 'in', $users)->column('uid'); if ($users) $userStair = array_merge($userStair, $users); } $where['uid'] = $userStair; return app('json')->success('ok', UserMiningMachine::getList($where)); } public function mining_get(Request $request) { $where = UtilService::getMore([ ['page', 1], ['limit', 10], ['type', 'XCH'] ]); $where['uid'] = $request->uid(); $umid = UserMiningMachine::where('uid', $where['uid'])->column('id'); return app('json')->success('ok', [ 'all_get' => UserMining::where('get_money_type', $where['type'])->where('umid', 'in', $umid)->sum('get_money'), 'all_recommend' => UserBill::where('category', $where['type'])->where('uid', $where['uid'])->where('type', 'group_create_brokerage')->where('status', 1)->sum('number'), 'today_recommend' => UserBill::where('category', $where['type'])->where('uid', $where['uid'])->where('type', 'group_create_brokerage')->where('status', 1)->whereTime('add_time', 'today')->sum('number'), 'all_unlock' => UserMining::where('get_money_type', $where['type'])->where('umid', 'in', $umid)->sum('unlock'), 'all_unstand' => UserMining::where('get_money_type', $where['type'])->where('umid', 'in', $umid)->sum('unstand'), 'all_lock' => UserMining::where('get_money_type', $where['type'])->where('umid', 'in', $umid)->sum('lock_money'), 'stand' => UserMiningMachine::where('get_money_type', $where['type'])->where('uid', $where['uid'])->sum('stand_money'), 'list' => UserMining::getList($where) ]); } public function mortgage($id, Request $request) { $user = $request->user(); UtilService::postMore( [ ['trade_psw', '', '', '', ['not_empty_check', function ($item) use ($user) { // var_dump($user); return md5(md5($item)) == $user['trade_pwd']; }], ['请输入交易密码', '交易密码错误']], ], $request, true); $res = UserMiningMachine::mortgageMachine($id, $request->uid()); if ($res) { return app('json')->success('抵押成功'); } else { return app('json')->fail(UserMiningMachine::getErrorInfo()); } } public function redeem($id, Request $request) { $user = $request->user(); UtilService::postMore( [ ['trade_psw', '', '', '', ['not_empty_check', function ($item) use ($user) { // var_dump($user); return md5(md5($item)) == $user['trade_pwd']; }], ['请输入交易密码', '交易密码错误']], ], $request, true); $res = UserMiningMachine::redeemMachine($id, $request->uid()); if ($res) { return app('json')->success('购买成功'); } else { return app('json')->fail(UserMiningMachine::getErrorInfo()); } } }