public function exec() { $param = $this->param; $flag['message'] = 'success'; // $flag['message'] = 'fail'; if ($flag['message'] == 'success') { // 成功 $param['status'] = 1; } else { // 失败 入库,重试机制还没想好. $param['status'] = 0; $this->event_rs['err_no'] = 100; $this->event_rs['err_msg'] = '发送邮件失败'; } $param['create_time'] = time(); $param['mobile'] = ''; $message = new Messages(); $message->attributes = $param; $rs = $message->insert(); return $this->event_rs; }
$this->more = "order by msgid desc limit 20"; } function getMessageFeed() { return $this->doQuery("select m.*, u1.username as username, u2.username as username_rec from (" . "(" . $this->getQueryStr() . ") as m " . "join " . "(select username, id from eyeds) as u1 " . "on u1.id = m.id " . "join " . "(select username, id from eyeds) as u2 " . "on u2.id = m.recid" . ") order by msgid desc"); } } $msgObj = new Messages($r); $msgObj->checkTokenValid(); if ($r['action'] == 'send') { // send message // id, token, content, recid $msgObj->checkInputHas(['content', 'recid']); $msgObj->addInsertsFromArray($r, ['content', 'id', 'recid']); $msgObj->addInsert('doc', date('Y-m-d H:i:s')); $result = $msgObj->insert(ERR_NOUSER); die(json_encode($rarr)); } else { if ($r['action'] == 'feed') { // get feed // id, token $msgObj->addSelection("recid={$r['id']} or id={$r['id']}"); $result = $msgObj->getMessageFeed(); $rarr['messages'] = array(); while ($row = $result->fetch_assoc()) { $rarr['messages'][] = $row; } die(json_encode($rarr)); } else { if ($r['action'] == 'feedbyuser') { // get chat feed with a particular user
public static function publicMessages($uid, $content, $type, $title, $timedate = null, $money = null, $project = null, $total = null, $fee = null, $corpus = null) { $userInfo = User::model()->findByPk($uid); if (!empty($userInfo)) { $user_name = trim($userInfo->user_name); //获取用户名除去左右空格 if ($timedate !== null && $money != null && $project === null && $total === null && $fee === null && $corpus === null) { //提现成功 $content = str_replace(array('#UserName#', '#timedate', '#money'), array($user_name, $timedate, $money), $content); } else { if ($timedate !== null && $money != null && $project !== null && $total !== null && $fee === null && $corpus === null) { //投资成功 $content = str_replace(array('#UserName#', '#timedate', '#project', '#money', '#total'), array($user_name, $timedate, $project, $money, $total), $content); } else { if ($timedate !== null && $money !== null && $total !== null && $project === null && $fee === null && $corpus === null) { //充值成功 $content = str_replace(array('#UserName#', '#timedate', '#money', '#total'), array($user_name, $timedate, $money, $total), $content); } else { if ($fee !== null && $corpus !== null) { //还款成功 $content = str_replace(array('#UserName#', '#project', '#fee', '#corpus', '#total'), array($user_name, $project, $fee, $corpus, $total), $content); } else { $content = str_replace('#UserName#', $user_name, $content); } } } } $messages = new Messages(); $messages->uid = $uid; $messages->title = $title; $messages->contents = $content; $messages->mobile = $userInfo->mobile; $messages->create_time = time(); $messages->email = $userInfo->email; $messages->type = $type; return $messages->insert(); } return false; }