public function send() { $now = date('Y-m-d H:i:s'); // 对同一属性的修改不能同时有多个 $service = new Apply(); if ($service->is_available_same_attr($this->ad_id, $this->key)) { if ($this->key == 'set_ad_url') { $apply = new Apply(); $apply->update_ad_url($this->get($this->key), $this->ad_id); return; } throw new ADException('该属性上次修改申请还未审批,不能再次修改', 41, 400); } $DB = $this->get_write_pdo(); $check = SQLHelper::insert($DB, self::$T_APPLY, $this->attributes); if (!$check) { throw new ADException('创建申请失败', 40, 403, SQLHelper::$info); } $this->id = SQLHelper::$lastInsertId; // 给运营发通知 $notice = new Notification(); $notice_status = $notice->send(array('ad_id' => $this->ad_id, 'uid' => $this->id, 'alarm_type' => $this->replace_id ? Notification::$REPLACE_AD : Notification::$EDIT_AD, 'create_time' => $now, 'app_id' => $this->replace_id)); // 给运营发邮件 $service = new AD(); $info = $service->get_ad_info(array('id' => $this->replace_id ? $this->replace_id : $this->ad_id), 0, 1); $mail = new Mailer(); $subject = $this->replace_id ? '替换成新广告' : '广告属性修改'; $template = $this->replace_id ? 'apply-replace' : 'apply-new'; $mail->send(OP_MAIL, $subject, $mail->create($template, array_merge((array) $info, array('id' => $this->ad_id, 'replace_id' => $this->replace_id, 'label' => $this->label, 'is_status' => $this->get('key') == 'set_status', 'value' => $this->get('value'), 'comment' => $this->get('send_msg'), 'owner' => $_SESSION['fullname'])))); header('HTTP/1.1 201 Created'); return true; }