public function update($id) { $attr = $this->get_post_data(); // 禁止用户修改运营正在审核的申请 $this->judge_check($id); // 取当前申请 $apply_service = new Apply(); $apply_res = $apply_service->get_by_applyid($id); if (!$apply_res) { $this->exit_with_error(42, '该申请已经审核过,你不得修改该申请。', 401); } $apply_res = array_filter($apply_res, function ($value) { return isset($value); }); // 修改每日限额同时修改今日余量 if (array_key_exists('set_rmb', $apply_res) && array_key_exists('set_job_num', $apply_res)) { $res['attr'] = 'set_job_num'; } else { // 普通处理 foreach ($apply_res as $res_key => $value) { if (preg_match('/^set_\\w+/', $res_key)) { $res['attr'] = $res_key; break; } } } // 修改量级数据 if (isset($attr['after'])) { if ($res['attr'] == 'set_job_num') { $attr = array_merge(array('set_job_num' => $attr['after'], 'set_rmb' => $attr['after']), $attr); } else { $attr[$res['attr']] = $attr['after']; } unset($attr['after']); } // 修改更换包地址 if (isset($attr['ad_url'])) { $attr = array_merge(array('set_ad_url' => $attr['ad_url']), $attr); if (isset($attr['message'])) { unset($attr['message']); } unset($attr['ad_url']); } $apply = new ApplyModel($id, $attr); try { $res = $apply->update(); } catch (ADException $e) { $this->exit_with_error($e->getCode(), $e->getMessage(), 400, SQLHelper::$info); } $this->output(array('code' => 0, 'msg' => '修改申请成功', 'apply' => $res)); }