public function responseSubscribeMsg() { //个性化二维码 if (isset($this->postObj->EventKey)) { $eventKey = (string) $this->postObj->EventKey; $pcid = substr($eventKey, 8); } else { $pcid = 0; } //取用户的基本信息 $openid = (string) $this->postObj->FromUserName; $accessToken = get_access_token(); $data = get_weichat_user_info($openid, $accessToken); //用出客户基本信息 //添加或更新用户信息 $customerInfo = get_customer_info($openid); $customer = new \Customer\Model\CustomerModel(); $data['subcribe_time'] = time(); if ($customerInfo == FALSE) { //进行注册送券活动 $this->_sentCouponForNewUser($openid, $pcid); //取上线用户信息 $oldCustomerInfo = $customer->getCustomerInfoById($pcid); if ($oldCustomerInfo != false) { $oldOpendid = $oldCustomerInfo['openid']; } else { $oldOpendid = ''; } //进行注册送红包活动 $SendRedGiftController = new SendRedGiftController(); $SendRedGiftController->sendRedGiftForCustomer($openid, $oldOpendid); //加上邀请码 $code = $customer->checkCode(); $data['parentid'] = $pcid; $data['customer_code'] = $code; } else { if ($customerInfo['parentid'] == 0) { $data['parentid'] = $pcid; } } $userInfo[] = $data; $customer->addUserInfo($userInfo); $reply = new ReplyModel(); $id = 1; $reply->setId($id); $message = $reply->getInfoById(); //获取附件信息 $attch = new AttachmentModel(); $key = 'picurl'; $attch->setKey($key); $attch->setInfo($message); $message = $attch->findInfo(); if ($message['news_type'] == 0) { $replyMessage = A('ReplyMessage'); $replyMessage->setText($message['description']); $replyMessage->replyTextMessage(); } elseif ($message['news_type'] == 1) { $replyMessage = A('ReplyMessage'); $data['title'] = $message['title']; $data['description'] = $message['description']; $data['url'] = $message['url']; $data['picurl'] = add_host($message[$key]['url']); $news[] = $data; $replyMessage->setNews($news); $replyMessage->replyNewsMessage(); } else { $replyMessage = A('ReplyMessage'); $replyMessage->setText('系统错误'); $replyMessage->replyTextMessage(); } return; }