public function test_send_notification($uid, $couponId) { $user = $this->user->get($uid); $completeTitle = $this->coupon->get_complete_title($couponId); // var_dump($user); $mobile = $user['username']; $device = $user['device']; if ($device == 'iOS') { // echo 'iOS'; $sms = new Kqsms(); $response = $sms->send_coupon_accepted_sms($mobile, $completeTitle); echo $response; } else { // echo 'Android'; $umengpush = new UmengPush(); $title = '优惠券承兑完成'; $text = "您的" . $completeTitle . "快券已使用,更多优惠在等着你哦!"; $umengpush->send_customized_notification($uid, $title, $text); } }
/** * * 注册新用户, 要保证用户是要有银联帐号的 * * @param string username * @param string password * * @return * status: 1: 成功 * data: objectId, sessionToken * * status: 202 * msg: username is taken */ public function user_post() { $username = $this->post('username'); $password = $this->post('password'); // $this->load->model('user2_m','user'); if (empty($username) || empty($password)) { return $this->output_error(ErrorEmptyUsernamePwd); } $count = $this->user->count_by('username', $username); // 如果用户已经有了 if ($count > 0) { return $this->output_error(ErrorUsernameExists); } $data['username'] = $username; $data['password'] = $password; $data['sessionToken'] = randomCharacter(20); $data['expireDate'] = date('Y-m-d H:i:s', strtotime('+2 week')); // session有效期2周 $data['nickname'] = 'KQ_' . randomCharacter(8); $data['createdAt'] = NULL; $id = $this->user->insert($data); if (empty($id)) { // 如果没有注册成功,报出错 return $this->output_error(ErrorDBInsert); } $this->db->select('id,username,nickname,avatarUrl,sessionToken'); $user = $this->user->get($id); // 发送站内信 unset($data); $data['uid'] = $id; $data['title'] = '注册成功'; $data['text'] = '您已成功注册快券,多来这里看看哦,关注快券多一秒,更多优惠带给您'; $this->load->model('news2_m', 'news'); $newsId = $this->news->insert($data); if (empty($newsId)) { // 如果没有insert成功 log_message('error', 'Register insert news error, uid #' . $id); } return $this->output_results($user); }