コード例 #1
0
 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;
 }
コード例 #2
0
 /**
  * 二次申请上线
  * @param $id
  * @param $attr
  * @param ADModel $ad
  *
  * @return array
  */
 private function reapply_ad($id, $attr, ADModel $ad)
 {
     $now = date('Y-m-d H:i:s');
     $ad->update(array('status' => 2, 'create_time' => $now));
     $notice = new Notification();
     $notice->send(array('ad_id' => $id, 'alarm_type' => Notification::$NEW_AD, 'create_time' => $now));
     $mail = new Mailer();
     $subject = '商务[' . $_SESSION['fullname'] . ']再次提交广告:' . $attr['channel'] . ' ' . $attr['ad_name'];
     $mail->send(OP_MAIL, $subject, $mail->create('ad-new', $ad->attributes));
     $this->output(['code' => 0, 'msg' => '已发送申请', 'ad' => ['status' => 2]]);
     return array($notice, $mail);
 }
コード例 #3
0
 /**
  * 撤回某个申请
  * @param $id
  */
 public function delete($id)
 {
     $me = $_SESSION['id'];
     $service = $this->get_service();
     // 禁止操作别人的申请
     if (!$service->is_owner($id, $me)) {
         $this->exit_with_error(10, '您无权操作此申请', 403);
     }
     // 禁止操作已操作的申请
     if (!$service->is_available($id)) {
         $this->exit_with_error(11, '此申请已处理,您不能再次操作', 403);
     }
     // 禁止操作正在处理的申请
     $this->judge_check($id);
     $attr = array('handler' => $me, 'status' => Apply::WITHDRAWN);
     $check = $service->update($attr, $id);
     if (!$check) {
         $this->exit_with_error(20, '操作失败', 400);
     }
     // 同时撤回相关通知
     $notice = new Notification();
     $notice->set_status(array('uid' => $id), Notification::$HANDLED);
     $this->output(array('code' => 0, 'msg' => 'deleted'));
 }
コード例 #4
0
 public function send_notice($invoice)
 {
     // 发送通知给指定运营(王媛媛、来雪利、耿帅)
     $notice = new Notification();
     foreach (InvoiceModel::$OPER_INVOICE as $operation_id) {
         // 记录到通知表
         $notice->send(array('uid' => $invoice['id'], 'admin_id' => $operation_id, 'user_id' => $_SESSION['id'], 'alarm_type' => Notification::$NEW_INVOICE, 'create_time' => date('Y-m-d H:i:s')));
     }
 }