/** * 我要卖 */ public function sellAction() { $session = session('login'); if (empty($session)) { $this->redirect('Test/login'); } $user_id = $session['id']; $user_sdk = new User(); $user_info = $user_sdk->getUserInfo($user_id, true); if (empty($user_info['bank_info'])) { $this->redirect('Test/makeBankInfo'); } if (IS_POST) { $num = I('post.num'); if (empty($num)) { $this->error('请输入卖数量'); } $trade = new Trade(); $trade->makeTrade($user_id, 'sell', $num); $this->success('success'); } else { $account = D('Account')->where(array('user_id' => $user_id))->find(); $this->assign('account', $account); $this->display(); } }
function getUserInfo($user_id, $field = 'email') { $user = new User(); $user_info = $user->getUserInfo($user_id); return $user_info[$field]; }