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;
 }
 public function renew($id)
 {
     $mailer = new Mailer();
     $service = new Agreement();
     $admin = new Admin();
     $me = $_SESSION['id'];
     $managers = [4 => '*****@*****.**', 23 => '*****@*****.**', 45 => '*****@*****.**', 129 => '*****@*****.**'];
     $attr = $this->get_post_data();
     $attr['fullname'] = $_SESSION['fullname'];
     $agreement = $service->get_agreement_by_id(['id' => $id]);
     if (!$agreement) {
         $this->exit_with_error(11, '参数错误', 400);
     }
     if ($agreement['owner'] != $me) {
         $this->exit_with_error(10, '你不能对别人的合同进行操作', 403);
     }
     $agreement['company_type'] = Agreement::$TYPE[$agreement['company_type']];
     $content = $mailer->create('agreement-renew', $agreement, $attr);
     $manager = $admin->get_my_manager($me);
     $to = ['*****@*****.**', $managers[$manager]];
     $cc = ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', $_SESSION['user'] . '@dianjoy.com'];
     $check = $mailer->send($to, '商务申请合同续期', $content, $cc);
     if ($check) {
         $this->output(['code' => 0, 'msg' => '发送成功']);
     } else {
         $this->exit_with_error(20, '发送邮件失败', 400, $check);
     }
 }
示例#3
0
 public function testCreate()
 {
     $mail = new Mailer(true);
     $service = new AD();
     $_SESSION['id'] = $_SESSION['role'] = 'test';
     $controller = new ADController();
     $template = 'baobei';
     $ad_id = 'a8b13c843a8f2c598381f9dfe6eec16b';
     $info = $service->get_ad_info(array('id' => $ad_id), 0, 1);
     $info = $controller->translate($info);
     $html = $mail->create($template, $info);
     file_put_contents('tests/mail.html', $html);
     $this->assertNotEmpty($html);
     $this->assertTrue($mail->send('*****@*****.**', 'test', $html));
 }
示例#4
0
 public function log_sm($id, $url, $pack_name, $app_name)
 {
     // 记到表里
     $attr = ['ad_id' => $id, 'url' => $url, 'user' => $_SESSION['id'], 'sm' => self::HAS];
     $DB = $this->get_write_pdo();
     $count = SQLHelper::insert($DB, self::$TABLE, $attr, true);
     $admin = new Admin();
     $me = $admin->get_user_info(['id' => $_SESSION['id']]);
     $me = array_values($me)[0];
     $attr['name'] = $me;
     // 给相关人发邮件
     $mailer = new Mailer();
     $to = ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'];
     $subject = '【点乐自助平台】监测到包含数盟SDK的包上传';
     $content = $mailer->create('spy-sm', array_merge($attr, array('pack_name' => $pack_name, 'app_name' => $app_name)));
     $check = $mailer->send($to, $subject, $content);
     return $count && $check;
 }
 public function send($to, $subject, $content, $cc = null)
 {
     // 留日志
     $DB = $this->get_write_pdo();
     SQLHelper::insert($DB, 't_ad_baobei', array('ad_id' => $content['id'], 'to_email' => $to, 'send_time' => date('Y-m-d H:i:s')));
     $content = $this->translate($content);
     $content['eid'] = SQLHelper::$lastInsertId;
     $template = $content['ad_app_type'] == 1 ? 'baobei' : 'baobei_ios';
     $content = $this->create($template, $content);
     return parent::send($to, $subject, $content, $cc);
 }
 /**
  * 二次申请上线
  * @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);
 }