public function indexAction() { //取出openId数据组 $accessToken = get_access_token(); $url = 'https://api.weixin.qq.com/cgi-bin/user/get?access_token=' . $accessToken; $jsonData = http_get_data($url); $data = json_decode($jsonData); $openids = $data->data->openid; //取出openid对应的其它信息 $userInfo = array(); foreach ($openids as $key => $value) { $userInfo[] = get_weichat_user_info($value, $accessToken); } $customer = D('Customer'); $customer->addUserInfo($userInfo); $this->success('列表获取完成', U('Index/index'), 2); }
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; }
public function registeAction() { $customer = new CustomerModel(); $openId = I('get.openid', ''); $checkCode = I('get.checkcode', ''); $weixinId = I('get.weixinid', ''); if ($openId == '' || $checkCode == '' || $weixinId == '') { return false; } //取用户信息 $customerInfo = get_customer_info($openId); if ($customerInfo == false) { $customer->setOpenid($openId); $customer->addCustomer(); $customerInfo = get_customer_info($openId); } $customerType = $customerInfo['subscribe_state']; //判断用户类型 if ((int) $customerType & 1 == 1) { echo "请务重复注册"; return; } if ($checkCode != session($openId . 'checkCode')) { echo "验证码错语"; return; } if (time() - session($openId . 'lastTime') > 300) { echo "验证码已过期,请重新获取"; return; } //用户状态更新 $customer->setWeixinId($weixinId); $customer->updateState(); //调用关注送券活动 $active = new ActiveModel(); $active->setopenId($openId); $accessToken = get_access_token(); $data = get_weichat_user_info($openId, $accessToken); //用出客户基本信息 // $obj = get_postObj(); if (isset($obj->EventKey)) { $pcid = (int) $obj->EventKey; } else { $pcid = 0; } $data['parentid'] = $pcid; $active->setParentId($pcid); $active->subscribe(); // echo "success"; }