public function income($uid = 0) { $moneyModel = new \Common\Model\UserMoneyModel(); if (IS_POST) { $money = I('money', 0, 'float'); $money > 0 or $this->error('请输入正确的金额!'); $remark = I('remark'); $ret = $moneyModel->in(I('uid'), $money, $remark); $ret ? $this->success('更新金额成功!') : $this->error($moneyModel->getError()); return; } $money = $moneyModel->get($uid, true) or $this->error($moneyModel->getError()); $this->assign('money', $money); $user = M('user')->find($uid) or $this->error('找不到此用户信息!'); $this->assign('user', $user); $this->meta_title = '用户充值'; $this->display(); }
/** * @title 获取"我的"信息 * * @param string $os 操作系统 android android/ios(弃用,将改为通过http_user_agent自动分析) * @method get */ public function user($os) { $user = get_user() or ajax_error('USER_NOT_LOGIN', '登录超时,请重新登录!'); $uid = $user['uid']; // 判断此学校的信用额度 $limit_range = '3000~8000元'; $university_config = M('loan_config_university')->find($user['university_id']); if ($university_config) { $money = M('loan_config_university_money')->where(['education' => $university_config['education']])->field('min(money) min,max(money) max')->find(); $limit_range = $money ? number_format($money['min'], 0, '.', '') . '~' . number_format($money['max'], 0, '.', '') : $limit_range; } // 认证状态 $contract_status = M('loan_user_contract')->where(['uid' => $uid])->getField('status'); $auth_status = $contract_status === null ? 0 : $contract_status + 1; $user_money_limit = $limit_range; if ($auth_status == 2) { $user_money_limit = M('loan_user')->where(['uid' => $uid])->getField('money_limit') + 0; } $auth_btn_config = ['0' => '立即认证', '1' => '等待审核', '2' => '认证完成', '3' => '认证失败']; $auth_text_config = ['0' => '立即完成身份认证,即可获得' . $limit_range . '信用额度', '1' => '等待完成身份认证,即可获得' . $limit_range . '信用额度', '2' => '恭喜,已通过身份认证,现已获得' . $user_money_limit . '信用额度', '3' => '等待完成身份认证,即可获得' . $limit_range . '信用额度']; $loan_max_money = $loan_available_money = 0; if ($auth_status == 2) { $loan_user = M('loan_user')->where('uid=' . $uid)->find(); if ($loan_user) { $loan_max_money = $loan_user['money_limit']; $loan_available_money = $loan_user['money_limit'] - ($loan_user['total_money_loan'] - $loan_user['total_money_return']); } } // 'loan_max_money' => number_format ( $loan_max_money, 2, '.', '' ), $userMoneyModel = new \Common\Model\UserMoneyModel(); ajax_success(['user' => ['uname' => $user['uname'], 'realname' => $user['realname']], 'title' => '你好,' . ($user['realname'] ?: $user['uname']), 'sub_title' => isset($auth_text_config[$auth_status]) ? $auth_text_config[$auth_status] : '', 'auth_btn' => ['text' => isset($auth_btn_config[$auth_status]) ? $auth_btn_config[$auth_status] : '', 'title' => '个人认证', 'url' => U('/user/contract@loan') . '?from=' . $os], 'top_menu' => [['title' => '可用额度', 'number' => number_format($loan_available_money, 2, '.', ''), 'url' => U('/user/contract@loan') . '?from=' . $os], ['title' => '我的钱包', 'number' => $userMoneyModel->get($user['uid']), 'url' => U('/wallet/@mobile') . '?from=' . $os], ['title' => '我的积分', 'number' => M('credit')->where('uid=' . $uid)->getField('credit') + 0, 'url' => U('/credit/@mobile') . '?from=' . $os]], 'list_menu' => [['title' => '我的订单', 'icon' => 'http://zjdxdl.qiniudn.com/app_resource_v3_me_order.png', 'tip' => '', 'url' => U('/user/order/@loan') . '?from=' . $os], ['title' => '我的账单', 'icon' => 'http://zjdxdl.qiniudn.com/app_resource_v3_me_bill.png', 'tip' => '', 'url' => U('/user/bill/@loan') . '?from=' . $os], ['title' => '我的兼职', 'icon' => 'http://zjdxdl.qiniudn.com/app_resource_v3_me_job.png', 'tip' => '', 'url' => U('/job/user/@mobile') . '?from=' . $os]], 'feedback' => ['uncheck' => M('feedback_list')->where(['uid' => $uid])->getField('unread_num') ?: 0]]); }