public function _sentCouponForNewUser($openid, $parentId) { $active = new ActiveModel(); $coupon = new CouponModel(); if ($parentId != 0) { $customer = new CustomerModel(); $parentCustomer = $customer->getCustomerInfoById($parentId); if ($parentCustomer != false) { $parentOpenid = $parentCustomer['openid']; $activeOld = $active->getOldCustomerSendCouponInfo(); if ($activeOld['state'] == 0) { $cover = $activeOld['cover']; //面额 $duration = $activeOld['duration']; $count = $activeOld['count']; $coupon->sendCoupon($parentOpenid, $cover, $duration, $count); } } } $activeNew = $active->getNewCustomerSendCouponInfo(); if ($activeNew['state'] == 0) { $cover = $activeNew['cover']; //面额 $duration = $activeNew['duration']; $count = $activeNew['count']; $coupon->sendCoupon($openid, $cover, $duration, $count); } }
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; }