public function update() { $data = $this->get_post_data(); // 有可能通过修改密码popup修改密码 if ($_REQUEST['newpassword']) { $data = Utils::array_pick($_REQUEST, 'oldpassword', 'newpassword', 'repassword'); } // 校验密码 if ($data['newpassword']) { if ($data['newpassword'] != $data['repassword']) { $this->exit_with_error(11, '两次输入的密码不一致,请重新输入。', 403); } if (!preg_match('/[0-9a-zA-Z$!^#_@%&*.]{6,16}/', $data['newpassword'])) { $this->exit_with_error(12, '新的密码不合规则,请重新输入。', 403); } $auth = new Auth(); if (!$auth->validate($_SESSION['email'], $data['oldpassword'], true)) { $this->exit_with_error(13, '旧密码不正确,请重新输入', 403); } $data['password'] = $auth->encrypt($_SESSION['email'], $data['newpassword']); $data = Utils::array_omit($data, 'oldpassword', 'newpassword', 'repassword'); } $service = new User(); $check = $service->update_me($data); if ($check) { $this->output(['code' => 0, 'msg' => '修改成功', $data]); } else { $this->exit_with_error(400, '修改失败', 1); } }
public function dashboard() { $role = $_SESSION['role']; if (Auth::is_cp()) { $this->dashboard_cp(); } $this->dashboard_sales(); }
/** * 取广告列表 * @author Meathill * @since 0.1.0 */ public function get_list() { $service = new AD(); $job_service = new Job(); $admin = new Admin(); $me = $_SESSION['id']; $im_cp = Auth::is_cp(); $pagesize = isset($_REQUEST['pagesize']) ? (int) $_REQUEST['pagesize'] : 10; $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : 0; $page_start = $page * $pagesize; $order = isset($_REQUEST['order']) ? trim($_REQUEST['order']) : 'create_time'; $seq = isset($_REQUEST['seq']) ? trim($_REQUEST['seq']) : 'DESC'; $filters = array('keyword' => $_REQUEST['keyword'], 'pack_name' => $_REQUEST['pack_name'], 'status' => [0, 1, 2, 3, 4], $im_cp ? 'create_user' : 'salesman' => $me); if (isset($_REQUEST['agreement_id'])) { $filters['agreement_id'] = $_REQUEST['agreement_id']; } if (isset($_REQUEST['channel'])) { $filters['channel'] = $_REQUEST['channel']; } if (isset($_REQUEST['ad_name'])) { $filters['ad_name'] = $_REQUEST['ad_name']; } $ads = $service->get_ad_info($filters, $page_start, $pagesize, array($order => $seq)); $total = $service->get_ad_number($filters); $ad_ids = array_unique(array_keys(array_filter($ads))); $ops = $admin->get_ad_ops($ad_ids); $users = array(); $decline = array(); foreach ($ads as $id => $ad) { $users[] = $ad['execute_owner']; if ($ad['status'] == ADModel::REJECTED) { $decline[] = $id; } } // 取商务名单 $user_service = new Admin(); $users = $user_service->get_user_info(array('id' => array_filter(array_unique($users)))); // 取当前申请 $apply = new Apply(); $applies = $apply->get_list_by_id($ad_ids); $applies_by_ad = array(); foreach ($applies as $id => $apply) { $adid = $apply['adid']; if (!is_array($applies_by_ad[$adid])) { $applies_by_ad[$adid] = array(); } unset($apply['adid']); $apply = array_filter($apply, function ($value) { return isset($value); }); // 同时有每日限量和今日余量说明是要修改每日限量 if (array_key_exists('set_job_num', $apply) && array_key_exists('set_rmb', $apply)) { unset($apply['set_rmb']); } $key = array_keys($apply)[0]; // 因为过滤掉了没有内容的键,又删掉了adid,只剩下要操作的key了 $apply[$key . '_id'] = $id; $applies_by_ad[$adid][] = $apply; } // 取计划任务 $ad_jobs = $job_service->get_ad_daily_job($ad_ids); // 取上下线计划任务 $on_off_jobs = $job_service->get_ad_on_off_job($ad_ids); // 取被拒绝的广告的附言 $decline = array_unique(array_filter($decline)); $declines = null; if ($decline) { $comment_service = new Comment(); $declines = $comment_service->get_comment(array('ad_id' => $decline, 'pack_name' => '')); } // 获取备注记录 $comments = $service->get_ad_comments($ad_ids); $result = array(); foreach ($ads as $id => $ad) { $apply = array(); if (is_array($applies_by_ad[$id])) { foreach ($applies_by_ad[$id] as $item) { $apply = array_merge($apply, $item); } } $decline = (array) $declines[$id]; $job_num = array_key_exists($id, $ad_jobs) ? $ad_jobs[$id]['jobnum'] : 0; $job_num = $job_num > 0 || !$im_cp ? $job_num : (int) $ad['job_num']; $on_off = $on_off_jobs[$id]; $result[] = array_merge($ad, $apply, array('id' => $id, 'status' => (int) $ad['status'], 'execute_owner' => $users[$ad['execute_owner']], 'job_num' => $job_num, 'job_time' => substr($ad_jobs[$id]['jobtime'], 11, 5), 'reject' => $decline, 'cm_others' => $comments[$id], 'op' => $ops[$id], 'search_flag' => (int) $ad['search_flag'], 'on_off' => $on_off)); } $this->output(array('code' => 0, 'msg' => 'get', 'total' => $total, 'list' => $result)); }