/** * @title 申请兑换 * * @param int $gift_id 物品编号 * * @method get */ public function apply($gift_id = 0) { $user = get_user() or ajax_error('USER_NOT_LOGIN', '登录超时,请重新登录!'); $creditModel = D('Credit'); $creditModel->apply($user['uid'], $gift_id) or ajax_error($creditModel->getError()); ajax_success(); }
public function vote() { $id = I('get.id'); $vote = $model = M('common_vote')->find($id) or $this->error('此投票不存在!'); $vote['status'] == 1 or $this->errror('投票已结束!'); if (IS_POST) { $user = get_user() or $this->error('请先登录!'); $model = M("common_vote_log"); $model->where(['vote_id' => $vote['id'], 'uid' => $user['uid']])->count() && ajax_error('每人仅限投一票!'); $option_id = I('get.option_id'); $option_title = M('common_vote_option')->where(['id' => $option_id, 'status' => 1])->getField('title') or ajax_error('此投票项不存在!'); $model->add(['vote_id' => $vote['id'], 'option_id' => $option_id, 'option_title' => $option_title, 'uid' => $user['uid'], 'uname' => $user['uname'], 'created' => time()]); M('common_vote_option')->where(['id' => $option_id])->setInc('votes'); ajax_success(); } $option = M('common_vote_option')->where(['vote_id' => $vote['id'], 'status' => 1])->order('id')->select(); $total_votes = 0; foreach ($option as $key => $vo) { $total_votes += $vo['votes']; } foreach ($option as $key => $vo) { $option[$key]['rate'] = $total_votes > 0 ? intval($vo['votes'] / $total_votes * 100) : 0; } $this->assign('vote', $vote); $this->assign('_option', $option); $this->display(); }
/** * @title 读取地区信息 * * @method get */ public function region() { $province = []; $region = M('common_region')->where('status=1')->order('sort,name')->field('id,parent_id,name')->select(); foreach ($region as $first) { if ($first['parent_id'] != 0) { continue; } $province_vo = ['id' => $first['id'], 'name' => $first['name'], 'city' => []]; foreach ($region as $second) { if ($second['parent_id'] != $first['id']) { continue; } $city = ['id' => $second['id'], 'name' => $second['name'], 'distrct' => []]; foreach ($region as $third) { if ($third['parent_id'] != $second['id']) { continue; } $distrct_vo = ['id' => $third['id'], 'name' => $third['name'], 'distrct' => []]; $city['distrct'][] = $distrct_vo; } $province_vo['city'][] = $city; } $province[] = $province_vo; } ajax_success($province); }
public function upload() { $_FILES && isset($_FILES['file']) or ajax_error('FILE_NOT_FOUND', '请选择上传文件!'); $upload = new \Think\Upload(['maxSize' => 0, 'subName' => 'loan_' . date('YmdH'), 'exts' => ['jpg', 'gif', 'png', 'jpeg']]); $info = $upload->upload() or ajax_error('UPLOAD_ERROR', $upload->getError()); $url = array_shift($info)['url']; ajax_success(['url' => $url]); }
protected function _success($data) { if (IS_AJAX) { ajax_success($data); } else { $this->success($data); } }
public function get_resumes($job_id) { $job_rel = M()->table('__JOB_IMPORT_REL__ jir')->join('__JOB__ j ON j.id = jir.job_id')->where(['j.from_type' => static::TYPE, 'jir.externel_id' => $job_id])->find(); if (!$job_rel) { ajax_error('not found job'); } $resumes = $this->_get_resumes_by_job_id($job_rel['job_id']); ajax_success($resumes); }
/** * 输入用户真实姓名 */ public function input_realname() { if (IS_POST) { $realname = I('post.realname') or ajax_error('请输入真实姓名'); M('user')->where(['uid' => $this->user->self()['uid'], 'realname' => ''])->save(['realname' => $realname]); ajax_success(); } else { $this->display(); } }
public function reply() { if (IS_POST) { $service_user = get_user(); $uid = I('post.uid', 0, 'intval') or $this->error('uid错误'); $content = I('post.content', '') or $this->error('回复内容不能为空'); M('feedback')->add(['uid' => $uid, 'created' => time(), 'content' => $content, 'service_uid' => $service_user['uid']]); M('feedback_list')->where(['uid' => $uid])->save(['unread_num' => ['exp', 'unread_num + 1'], 'status' => 1, 'check_time' => time()]); ajax_success(); } }
public function index() { $key = I('key', false); $token = I('token', false); if ($key && $token) { // $class = '\\Job\\Controller\\OuterService\\' . ucfirst($key) . 'Controller'; // if (class_exists($class) && $class::TOKEN === $token) { ajax_success(['auth' => password_hash($key . $token, PASSWORD_DEFAULT)]); // } else { // ajax_error('Accounts Error'); // } } else { ajax_error(); } }
public function index() { if (I('id') > 0) { $this->_action(); return; } if (I('get.type') == 'check') { $notificationModel = new \Common\Model\SystemNotificationModel(); $notificationModel->updateStatus() or system_warn($notificationModel->getError()); $where = $this->_getWhere(); $unread = M($this->_table)->where($where)->count(); $last_id = session('SYSTEM_NOTIFICATION_LAST_ID') + 0; $where['id'] = ['gt', $last_id]; $unread_new = M($this->_table)->where($where)->count(); session('SYSTEM_NOTIFICATION_LAST_ID', max($last_id, M($this->_table)->where($where)->max('id'))); ajax_success(['unread' => $unread, 'new' => $unread_new]); } parent::index(); }
public function import_vvjob_ajax($job, $type) { if (IS_POST) { $job = json_decode($job, true); $vvjob = new Vvjob(); switch ($type) { case 'import': $vvjob->importJob($job); break; case 'ignore': $vvjob->ignoreJob($job); break; default: $this->error('参数错误'); break; } ajax_success($job); } }
/** * @title 获取学院列表(二级) * * @param int $universityId 大学编号 0 * @param int $type 返回类型 1 1简单;2全部。 * @method get */ public function college($universityId = 0, $type = 1) { $collegeModel = M('university_college'); $college = $collegeModel->field('id,name')->where(['status' => 1, 'university_id' => $universityId])->order('sort ASC')->select(); // 简单 $type == 1 && ajax_success(['college' => $college]); $universityModel = M('university'); $university = $universityModel->field('id,code,name')->where(['status' => 1, 'id' => $universityId])->find() or ajax_error('UNIVERSITY_NOT_FOUND', '找不到此大学信息。'); // 专业 $collegeMajorModel = M('university_college_major'); foreach ($college as &$vo) { $vo['major'] = $collegeMajorModel->field('id,name')->where(['status' => 1, 'college_id' => $vo['id']])->order('sort ASC')->select(); } // 校区 $campusModel = M('university_campus'); $campus = $campusModel->field('id,name')->where(['status' => 1, 'university_id' => $universityId])->select(); $ret = ['university' => $university, 'college' => $college, 'campus' => $campus, 'start_year' => range(2010, date('Y'))]; ajax_success($ret); }
/** * @title 获取首页数据 * 3.0 版本起,不再使用 * * @method get */ public function index() { $campus_id = [0]; // 判断用户所在校区 $user = get_user(); if ($user) { $uid = $user['uid']; $user_campus_id = M('user_info')->where('uid=' . $uid)->getField('campus_id'); if ($user_campus_id) { $campus_id[] = $user_campus_id; } } $where = ['status' => ['egt', 1], 'campus_id' => ['in', $campus_id]]; $ads = M('common_advertisement')->where($where)->order('sort asc,id desc')->field('id,pic,title,title_show,url,duration')->select(); foreach ($ads as &$vo) { $vo['url'] = $vo['url'] ? $vo['url'] : U('public/page/common_ad/' . $vo['id'] . '@mobile'); $vo['title'] = $vo['title_show'] > 0 ? $vo['title'] : ''; } // 输出结果 ajax_success(['banner' => $ads]); }
/** * @title 验证已登录用户信息 * * @param string $access_key 访问授权码 zhSlIyYzTppqY2XT * @method get */ public function checkLogin($access_key = '', $return_type = 1) { $access_key == 'zhSlIyYzTppqY2XT' or ajax_error('ACCESS_KEY_ERROR', '系统授权码错误,请检查!'); $user = get_user() or ajax_error('USER_NOT_LOGIN', '登录超时,请重新登录!'); ajax_success($user); }
public function logout() { D('Common/User')->logout(); ajax_success(); }
public function contract_auth() { $uid = $this->user['uid']; $auth_id = I('auth_id', 0, 'intval'); $url = I('url') or ajax_error('上传图片异常!'); $url_watermark = \Common\Util\ImageUtil::qiniu_watermark($url); $auth = M('loan_user_contract_auth')->where(['uid' => $uid, 'auth_id' => $auth_id])->find(); if ($auth) { M('loan_user_contract_auth')->where(['uid' => $uid, 'auth_id' => $auth_id])->save(['created' => time(), 'url' => $url, 'url_watermark' => $url_watermark]); } else { $auth = M('loan_config_auth')->find($auth_id) or $this->error('找不到此认证项资料!'); M('loan_user_contract_auth')->add(['uid' => $uid, 'auth_id' => $auth_id, 'auth_name' => $auth['name'], 'auth_sort' => $auth['sort'], 'created' => time(), 'url' => $url, 'url_watermark' => $url_watermark]); } ajax_success(); }
public function financeUpdate() { if (I('get.method') == 'payee') { $account = I('get.account') or ajax_error('请输入账号'); $list = M('loan_system_order_finance')->where(['payee_account' => ['like', '%' . $account . '%']])->limit(100)->order('id desc')->select(); int_to_string($list, ['payee_user_type' => ['未设定', '对公', '对私'], 'payee_bank_type' => ['未设定', '行内', '跨行']]); ajax_success($list); } $order = M('loan_order')->field('goods_id,title')->find(I('post.order_id')); $order or $this->error('找不到此订单信息!'); // 若已同意打款,则不允许修改收款人信息 $finance = M('loan_order_finance')->where(['order_id' => I('post.order_id')])->find() or $this->error('找不到此订单财务信息!'); $finance['is_allow_lend'] == 1 && $this->error('已同意打款,禁止修改!'); $finance['lend_status'] == 0 or $this->error('已打款,禁止修改!'); $data = ['payee_account' => I('payee_account'), 'payee_name' => I('payee_name'), 'payee_bank' => I('payee_bank'), 'payee_bank_id' => I('payee_bank_id'), 'payee_account' => I('payee_account'), 'payee_user_type' => I('payee_user_type'), 'payee_bank_type' => I('payee_bank_type')]; M('loan_order_finance')->where(['order_id' => I('post.order_id')])->save($data); // 保存到历史记录中 if ($data['payee_account']) { $model = M('loan_system_order_finance'); $history_id = $model->where($order['goods_id'] > 0 ? ['goods_id' => $order['goods_id']] : ['payee_account' => $data['payee_account']])->getField('id'); if ($history_id > 0) { $data['id'] = $history_id; $model->save($data); } else { $data['goods_id'] = $order['goods_id']; $data['title'] = $order['title']; $model->add($data); } } $this->success('更新财务信息成功!'); }
/** * @title 获取订单统计 * * @param string $company_id 商铺编号 * * @method get */ public function order_stat($company_id) { $uid = $this->_user['uid']; M('loan_company')->where(['id' => $company_id, 'uid' => $uid])->count() or ajax_error('无权访问此商铺!'); $orderModel = new \Loan\Model\OrderModel(); $where = ['company_id' => $company_id, 'status' => ['neq', $orderModel::STATUS_CLOSED]]; ajax_success(['statistiscs' => [['label' => '订单统计', 'content' => [['text' => '进行中的订单', 'value' => $orderModel->where($where + ['check_status' => ['neq', 1]])->count() + 0 . ''], ['text' => '已签约订单', 'value' => $orderModel->where($where + ['check_status' => 1])->count() + 0 . '']]], ['label' => '签约订单贷款金额统计', 'content' => [['text' => '待付款金额(元)', 'value' => number_format($orderModel->where($where + ['check_status' => 1, 'lend_status' => ['neq', 2]])->sum('loan_money'), 2)], ['text' => '已付款金额(元)', 'value' => number_format($orderModel->where($where + ['check_status' => 1, 'lend_status' => 2])->sum('loan_money'), 2)]]]]]); }
/** * @title 新增反馈 * * @param string $app_version App版本 * @param string $os 操作系统 '' (Android or iOS) * @param string $os_version 操作系统版本 * @param string $api_level API级别 * @param string $phone_model 手机型号 * @param string $content 反馈内容 * @param string $url 附件url,多个使用逗号分隔 * * @method post */ public function add() { $os = I('post.os'); $os_version = I('post.os_version'); $api_level = I('post.api_level'); $phone_model = I('post.phone_model'); $content = I('post.content'); $url = I('post.url'); if (!$content && !$url) { ajax_error('请填写反馈内容或选择上传的图片!'); } $user = get_user() or ajax_error('USER_NOT_LOGIN', '登录超时,请重新登录!'); // 写入登录信息 $feecback_id = M('feedback')->add(['uid' => $user['uid'], 'created' => time(), 'content' => $content, 'url' => $url]); M('feedback_source')->add(['feedback_id' => $feecback_id, 'os' => $os, 'os_version' => $os_version, 'app_version' => I('post.app_version'), 'api_level' => $api_level, 'phone_model' => $phone_model, 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '', 'ip' => get_client_ip(1)]); M('feedback_list')->add(['uid' => $user['uid'], 'uname' => $user['uname'], 'created' => time(), 'content' => $content, 'status' => 0], null, true); // 输出结果 ajax_success(''); }
/** * @title 获取最后一次保存的数据 * * @param string $type 操作类型 subject,score,exam 可选值subject,score,exam,可三者自由组合(逗号分隔) * @method get */ public function cache($type) { $user = get_user() or ajax_error('USER_NOT_LOGIN', '尚未登录,请更新客户端版本!'); $types = []; foreach (explode(',', $type) as $type) { if (in_array($type, ['subject', 'score', 'exam'])) { $types[] = $type; } } $types or ajax_error('请选择需要获取的数据!'); $data = M('user_eas')->field('university,' . implode(',', $types))->find($user['uid']); $data or ajax_error('NO_DATA', '尚未获取过此数据,请先下载客户端!'); foreach ($data as $key => $vo) { $data[$key] = json_decode($vo, true); } ajax_success($data); }
/** * @title 测算用户额度及最大分期数 * * @param int $university_id 学校编号 * @param int $start_year 入学年份 * @param int $study_year 学年制 * @method get */ public function get_user_limit($university_id, $start_year, $study_year) { $university_id = intval($university_id); $university_config = M('loan_config_university')->find($university_id); if (!$university_config) { system_warn('暂不支持此学校!'); ajax_error('暂不支持此学校!'); } // 几年级? $grade = 0; $now_year = date('Y'); $start_year = intval($start_year); $start_year >= 2000 && $start_year <= $now_year or ajax_error('入学年份有误!'); if ($start_year >= $now_year) { $grade = 1; } else { $grade = date('Y') - $start_year + 1; if (date('m') < 7) { $grade -= 1; } } // 读取配置值 $config = M('loan_config_university_money')->where(['study_year' => $study_year, 'current_year' => $grade, 'education' => $university_config['education']])->field('money,month')->find(); if (!$config) { ajax_error('不支持此学年制!'); } // 距离毕业剩余月份 $restMonth = 0; $start_date = time(); $end_day = $start_year + intval($study_year) . '-07-01'; if (date('Y-m-d') < $end_day) { for ($m = 1; $m <= 12 * 6; $m++) { if (date('Y-m-d', strtotime('+ ' . $m . ' month', $start_date)) >= $end_day) { $restMonth = $m - 1; break; } } } ajax_success(['max_money' => number_format($config['money'], 2, '.', ''), 'max_month' => min(24, max(0, $restMonth - 2), $config['month'])]); }
public function user_my_join() { $this->_need_login(); if (IS_POST || IS_AJAX) { $where = ['jj.uid' => $this->user->self()['uid'], 'jj.status' => ['neq', -2]]; $max_join_created = I('post.max_join_created'); if ($max_join_created) { $where['jj.created'] = ['lt', $max_join_created]; } $applys = M()->table('__JOB_JOIN__ jj')->join('__JOB__ j on j.id=jj.job_id')->join('__JOB_APPLY__ ja ON ja.job_id=jj.job_id AND ja.uid=jj.uid', 'left')->join('__JOB_CATEGORY__ jc on jc.id=j.category_id', 'left')->join('__JOB_COMPANY__ jcp ON jcp.uid=j.uid', 'left')->join('__USER__ u on u.uid=j.uid', 'left')->where($where)->field(['ja.id', 'jj.created join_created', 'jj.status', 'jj.job_id', 'jj.id join_id', 'jj.is_student_paid', '(jj.status=2) is_join_company', 'j.title', 'j.salary', 'j.city_name', 'j.district_name', 'j.created', 'j.uname job_uname', 'u.uname', 'jcp.name company_name', 'jc.pic category_pic'])->order('jj.created desc')->limit(10)->select(); $applys = array_map(function ($apply) { if ($apply['join_id']) { $apply['paid_money'] = D('Job/Pay')->joinMoney($apply['join_id']); } $apply['is_student_paid'] = boolval($apply['is_student_paid']); $apply_status = intval($apply['status']); $apply['status_key'] = [1 => 'pass', 0 => 'audit', -1 => 'reject', -2 => 'cancel'][$apply_status]; return $apply; }, $applys); ajax_success($this->_jobsExtract($applys)); } else { $this->display(); } }
/** * @title 商品管理(损耗) * * @param string $goods_id 商品编号 * @param string $quantity 损耗数量 * @method GET */ public function goodsLoss($goods_id, $quantity) { $shop = M('snack_shop')->where(['uid' => $this->_user['uid'], 'status' => ['egt', 0]])->field('id,warehouse_id')->find() or ajax_error('店铺不存在或已被禁用!'); $shop_id = $shop['id']; $where = ['sg.shop_id' => $shop_id, 'sg.goods_id' => $goods_id]; $shopGoodsModel = M('snack_shop_goods'); $goods = $shopGoodsModel->where(['shop_id' => $shop_id, 'goods_id' => $goods_id])->find() or ajax_error('此商品不存在!'); $quantity_old = $goods['stock']; $quantity <= $quantity_old or ajax_error('损耗数量不能大于库存数!'); $shopGoodsModel->where(['shop_id' => $shop_id, 'goods_id' => $goods_id])->setDec('stock', $quantity); M('snack_shop_goods_log')->add(['type' => 3, 'shop_id' => $shop_id, 'goods_id' => $goods_id, 'order_id' => 0, 'price' => $goods['price_campus'], 'quantity' => $quantity, 'quantity_old' => $quantity_old, 'quantity_new' => $quantity_old - $quantity, 'created' => time()]); ajax_success(); }
ajax_error(); } } } $DB->query("\n\tUPDATE reports\n\tSET Status = 'Resolved',\n\t\tResolvedTime = '" . sqltime() . "',\n\t\tResolverID = '" . $LoggedUser['ID'] . "'\n\tWHERE ID = '" . db_string($ReportID) . "'"); $Channels = array(); if ($Type == 'request_update') { $Channels[] = '#requestedits'; $Cache->decrement('num_update_reports'); } if (in_array($Type, array('comment', 'post', 'thread'))) { $Channels[] = '#forumreports'; $Cache->decrement('num_forum_reports'); } $DB->query("\n\tSELECT COUNT(ID)\n\tFROM reports\n\tWHERE Status = 'New'"); list($Remaining) = $DB->next_record(); foreach ($Channels as $Channel) { send_irc("PRIVMSG {$Channel} :Report {$ReportID} resolved by " . preg_replace('/^(.{2})/', '$1·', $LoggedUser['Username']) . ' on site (' . (int) $Remaining . ' remaining).'); } $Cache->delete_value('num_other_reports'); ajax_success(); function ajax_error($Error = 'error') { echo json_encode(array('status' => $Error)); die; } function ajax_success() { echo json_encode(array('status' => 'success')); die; }
/** * @title 获取当前登录用户信息 * * @method get */ public function info() { $user = get_user() or ajax_error('USER_NOT_LOGIN', '登录超时,请重新登录!'); $university = M('user_info')->where(['uid' => $user['uid']])->field('university_id,university_name,college_id,college_name,major_id,major_name,campus_id,campus_name,start_year')->find(); ajax_success(['user' => ['mobile' => $user['mobile'], 'uname' => $user['uname'], 'realname' => $user['realname'], 'gender' => $user['gender'], 'avatar' => $user['avatar']], 'university' => $university]); }
public function send_sms_message($club_id = 0) { $this->_must_in_club($club_id); $club = $this->_get_valid_club($club_id); if (IS_POST) { $content = trim(strip_tags($_POST['content'])) or $this->_error('请输入内容!'); mb_strlen($content) < 200 or $this->_error('内容长度不能大于200!'); // 获取用户id 并过滤 自己的id $uids = array_filter(array_keys($this->_get_selected_users('sms_message', $club_id)), function ($uid) { return $uid != $this->user['uid']; }); empty($uids) && $this->_error('发送用户不能为空'); $all_users = M('app_club_user')->where(['club_id' => $club_id])->getField('uid,mobile,realname'); $all_uids = array_keys($all_users); foreach ($uids as $uid) { if (!in_array($uid, $all_uids)) { $user = M('user')->where(['uid' => $uid])->find(); ajax_error($user['realname'] . '不在本社团中'); return; } } // 获取用户电话 $users_info = []; foreach ($uids as $uid) { if ($all_users[$uid]['mobile']) { array_push($users_info, $all_users[$uid]); } } $club = $this->_get_valid_club($club_id); $count_sms = count($users_info); // 每月清零 if (date('m', $club['last_send_sms']) != date('m', time())) { $club['total_send_sms_month'] = 0; } // 每月限额 if ($club['total_send_sms_month'] + $count_sms > $club['total_user'] * 10) { ajax_error('短信数量超出限额'); } $club['total_send_sms'] += $count_sms; $club['total_send_sms_month'] += $count_sms; $club['last_send_sms'] = time(); M('app_club')->where(['id' => $club_id])->save(['total_send_sms' => $club['total_send_sms'], 'total_send_sms_month' => $club['total_send_sms_month'], 'last_send_sms' => $club['last_send_sms']]); // 发送 foreach ($users_info as $user_info) { $this->_sms($user_info['mobile'], $user_info['realname'], $club['name'], $content, '指尖社团'); } ajax_success(); } else { $users_map = $this->_get_selected_users('sms_message', $club_id); if ($users_map) { $this->assign('realnames', implode(',', array_slice($users_map, 0, 4))); $this->assign('selected_count', count($users_map)); } $this->assign('club_id', $club_id); } $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]]); }
public function add($id = 0) { $this->user = get_user() or $this->error('登录超时,请先登录!'); $category = M('app_trade_category')->where('status>0')->order('sort,name')->getField('id,name'); $type = I('get.type', 0, 'intval'); if (IS_POST) { $category_id = I('post.category_id', 0, 'intval'); isset($category[$category_id]) or ajax_error('此分类不存在!'); $recency = I('post.recency', '', 'intval'); if (array_key_exists($recency, $this->recency_list)) { $recency = $this->recency_list[$recency]; } else { $recency = ''; } M('app_trade')->add(['category_id' => $category_id, 'category_name' => $category[$category_id], 'university_id' => $this->user['campus_id'], 'university_name' => $this->user['university_name'] . ($this->user['campus_name'] == '主校区' ? '' : $this->user['campus_name']), 'uid' => $this->user['uid'], 'uname' => $this->user['uname'], 'title' => I('post.title'), 'price' => I('post.price'), 'price_old' => I('post.price_old'), 'content' => I('post.content'), 'created' => time(), 'telephone' => I('post.telephone'), 'pic' => I('post.pic'), 'status' => 1, 'check_status' => 0, 'click' => 0, 'recency' => $recency, 'type' => $type, 'qq' => I('post.qq'), 'contact' => I('post.contact')]); ajax_success('发布成功,请等待审核'); } // 分类 $this->assign('category', $category); $this->assign('recency_list', $this->recency_list); $this->assign('user', $this->user); $this->assign('type', $type); $this->assign('title', $type ? '发布求购' : '发布出售'); $this->display(); }
public function uploadToken() { $expires = 600; $ext = pathinfo(I('filename'), PATHINFO_EXTENSION); if (!in_array(strtolower($ext), ['png', 'jpg', 'jpeg', 'gif'])) { system_warn('检测到错误的上传图片格式:' . I('filename') . ',提交参数:' . print_r($_REQUEST, true)); ajax_error(strpos(I('filename'), '.') > 0 ? '仅限上传png/jpg/gif图片' : '服务器无法读取图片格式!'); } $file_name = (I('type') ?: 'loan') . '_auth_' . date('YmdH') . '_' . uniqid() . '.' . $ext; $policy['scope'] = 'yszjdx:' . $file_name; $policy['deadline'] = time() + $expires; $policy['fsizeLimit'] = 5 * 1024 * 1024; $policy = json_encode($policy); function base64_urlSafeEncode($data) { $find = array('+', '/'); $replace = array('-', '_'); return str_replace($find, $replace, base64_encode($data)); } $policy = base64_urlSafeEncode($policy); $qiniu = C('UPLOAD_TYPE_CONFIG'); $sign = hash_hmac('sha1', $policy, $qiniu['secrectKey'], true); $token = $qiniu['accessKey'] . ':' . base64_urlSafeEncode($sign) . ':' . $policy; ajax_success(['file_name' => $file_name, 'token' => $token]); }
public function change_salesman() { $order = $this->_order(); // 验证输入 $account = I('request.mobile'); $user = M('loan_salesman')->where(['mobile' => $account])->find() or $this->error('此手机号尚未设置为校园专员!'); $salesModel = new \Loan\Model\OrderSalesmanModel(); $history = $salesModel->where(['order_id' => $order['id']])->find(); if ($history) { if ($history['uid'] != $this->_user['uid']) { ajax_error('无权操作:此订单已指派给别人!'); } } $salesModel->assign($order['id'], $user['uid']) or ajax_error($salesModel->getError()); ajax_success(); }