コード例 #1
0
 /**
  * Creates a new OpenidBindMobile model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new OpenidBindMobile();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->openid_bind_mobile_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
ファイル: WapController.php プロジェクト: noikiy/wowewe
 public function actionAddbindmobile($gh_id, $openid)
 {
     $this->layout = 'wap';
     $model = new OpenidBindMobile();
     $model->gh_id = $gh_id;
     $model->openid = $openid;
     $model->setScenario('bind_mobile');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         //非自营厅渠道新增会员时,+积分100
         $user = MUser::findOne(['openid' => $openid]);
         $office = MOffice::findOne(['office_id' => $user->belongto]);
         if (!empty($office)) {
             if ($office->is_selfOperated == 0) {
                 //wx_office_score_event 增加一条记录
                 $offce_score_event = new MOfficeScoreEvent();
                 $offce_score_event->gh_id = $gh_id;
                 $offce_score_event->openid = $openid;
                 $offce_score_event->office_id = $user->belongto;
                 $offce_score_event->cat = MOfficeScoreEvent::CAT_ADD_NEW_MEMBER;
                 $offce_score_event->create_time = date('y-m-d h:i:s', time());
                 $offce_score_event->score = MOfficeScoreEvent::CAT_ADD_NEW_MEMBER_SCORE;
                 $offce_score_event->memo = '新增会员';
                 $offce_score_event->save(false);
                 //wx_office表中对应渠道score 加100分
                 $office->score = $office->score + 100;
                 $office->save(false);
             }
         }
         Yii::$app->wx->setGhId($gh_id);
         $url = Url::to(['hyzx1', 'gh_id' => $gh_id, 'openid' => $openid], true);
         Yii::$app->wx->WxTemplateSend(Wechat::getTemplateBindSuccessNotify($openid, $url, "{$model->user->nickname},您的手机号码已成功绑定襄阳联通官方微信营业厅", "您已成为襄阳联通的会员,可随时查询话费余额,办理业务,参与更多专享优惠!", $model->mobile, date('Y-m-d')));
         $url = Yii::$app->getSession()->get('RETURN_URL');
         if (!empty($url)) {
             return $this->redirect($url);
         } else {
             Yii::$app->session->setFlash('success', '恭喜您,会员注册成功!');
             return $this->refresh();
         }
     }
     $searchModel = new OpenidBindMobileSearch();
     $searchModel->gh_id = $gh_id;
     $searchModel->openid = $openid;
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('addbindmobile', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'model' => $model]);
 }
コード例 #3
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;
 }