Ejemplo n.º 1
0
 private static function sms($mobile)
 {
     //        \Yii::$app->wx->setGhId(\app\models\MGh::GH_XIANGYANGUNICOM);
     $long_url = 'http://wosotech.com/wx/web/index.php?r=wapx/sm-qr' . '&mobile=' . $mobile;
     //        $short_url = \Yii::$app->wx->WxGetShortUrl($long_url);
     $short_url = DwzService::baidu($long_url);
     if (false == $short_url) {
         $short_url = DwzService::qqurl($long_url);
         if (false == $short_url) {
             $short_url = DwzService::so985($long_url);
             if (false == $short_url) {
                 \Yii::$app->wx->setGhId(MGh::GH_XIANGYANGUNICOM);
                 $short_url = \Yii::$app->wx->WxGetShortUrl($long_url);
             }
         }
     }
     $content = "【襄阳联通】诚邀您({$mobile})关注官方微信号,猛戳" . $short_url . '!最高50元红包即送!';
     U::yjhu_W(mb_strlen($content));
     //        $content = mb_substr($content, 0, 67);
     //        $content = $mobile . ' ' . $short_url;
     $s = \Yii::$app->sm->S($mobile, $content, '', null, true);
     //        $ret = \app\models\sm\ESmsGuodu::yjhu_test($mobile, $content);
     $ret = $s->isSendOk();
     if ($ret) {
         $smslog = SmsMarketingLog::findOne(['mobile' => $mobile]);
         if (empty($smslog)) {
             $smslog = new SmsMarketingLog();
             $smslog->mobile = $mobile;
             $smslog->first_sendtime = time();
             $smslog->last_sendtime = time();
             $smslog->send_count = 1;
             $smslog->save(false);
         } else {
             $smslog->send_count++;
             $smslog->last_sendtime = time();
             $smslog->save(false);
         }
     }
     return $ret;
 }
Ejemplo n.º 2
0
 public static function yjhu_test($mobile, $message)
 {
     U::yjhu_W('before=' . self::B());
     $s = new ESmsGuodu();
     $s->mobiles_str = $mobile;
     $s->message = $message;
     $s->sendtime = ESmsGuodu::getNewSendTime(date("Y-m-d H:i:s"));
     $s->send();
     $ret = $s->isSendOk();
     if ($ret) {
         U::W('Send OK');
     } else {
         U::W('Send ERR');
     }
     U::W($s->resp);
     U::yjhu_W('after=' . self::B());
     return $ret;
 }
Ejemplo n.º 3
0
 public function checkWxApiResp($resp, $params = [])
 {
     if (!empty($resp['errcode'])) {
         U::yjhu_W([$resp, $params]);
         if ($resp['errcode'] == 40001) {
             U::W('checkWxApiResp, refresh token.');
             $this->getAccessToken(true);
             return true;
         }
         throw new WxException($resp);
     }
     return true;
 }
Ejemplo n.º 4
0
 protected function onScan()
 {
     $this->saveAccessLogAll();
     $openid = $this->getRequest('FromUserName');
     $gh_id = $this->getRequest('ToUserName');
     $Event = $this->getRequest('Event');
     $EventKey = $this->getRequest('EventKey');
     if (!empty($EventKey)) {
         $Ticket = $this->getRequest('Ticket');
         $scene_pid = $EventKey;
         //            U::yjhu_W("EventKey=$EventKey, scene_pid=$scene_pid");
         if ($scene_pid > 100000) {
             $real_sceneid = $scene_pid - 100000;
             $sceneid_mobile = SceneidMobile::getModelBySceneId($real_sceneid);
             if (!empty($sceneid_mobile)) {
                 //                    U::yjhu_W($sceneid_mobile);
                 $openid_bind_mobile = OpenidBindMobile::findOne(['gh_id' => $gh_id, 'mobile' => $sceneid_mobile->mobile]);
                 if (empty($openid_bind_mobile)) {
                     $openid_bind_mobile = new OpenidBindMobile();
                     $openid_bind_mobile->gh_id = $gh_id;
                     $openid_bind_mobile->openid = $openid;
                     $openid_bind_mobile->mobile = $sceneid_mobile->mobile;
                     $openid_bind_mobile->save(false);
                     //                        U::yjhu_W($openid_bind_mobile);
                     U::yjhu_W($sceneid_mobile->mobile . '扫码绑定至' . $gh_id . ' ' . $openid);
                     SmsMarketingLog::member($sceneid_mobile->mobile);
                     $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
                     $url = \yii\helpers\Url::to(['wap/hyzx1', 'gh_id' => $gh_id, 'openid' => $openid], true);
                     $respText = $user->nickname . ', 您已成功绑定手机号码' . $sceneid_mobile->mobile . ', 成为襄阳联通微信平台会员,直接点击进入<a href="' . $url . '">会员中心</a>!';
                     RedpackLog::sendRedpack($gh_id, $openid, $sceneid_mobile->mobile);
                     return $this->responseText($respText);
                 } else {
                     $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
                     $respText = $user->nickname . ', ' . $sceneid_mobile->mobile . '已绑定!';
                     return $this->responseText($respText);
                 }
             }
         }
     }
     return Wechat::NO_RESP;
 }