Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = OpenidBindMobile::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->andFilterWhere(['gh_id' => $this->gh_id, 'openid' => $this->openid]);
     $query->andFilterWhere(['like', 'mobile', $this->mobile]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     return $dataProvider;
 }
Ejemplo n.º 2
0
 public static function confirmAjax($mobile, $score)
 {
     $hd201509t3 = \app\models\MHd201509t3::findOne(['mobile' => $mobile]);
     $hd201509t3->status = 1;
     //提交状态
     $hd201509t3->score = $score;
     $hd201509t3->create_time = date('y-m-d h:i:s', time());
     $hd201509t3->save(false);
     $hd201509t4 = new \app\models\MHd201509t4();
     $bm = \app\models\OpenidBindMobile::findOne(['mobile' => $mobile]);
     $hd201509t4->gh_id = $bm->gh_id;
     $hd201509t4->openid = $bm->openid;
     $hd201509t4->mobile = $mobile;
     $hd201509t4->score = $score;
     $hd201509t4->status = 1;
     $hd201509t4->create_time = date('y-m-d h:i:s', time());
     $hd201509t4->save(false);
     return \yii\helpers\Json::encode(['code' => 0]);
 }
Ejemplo n.º 3
0
 public function actionOfficeCampaignScorer()
 {
     $scorers = \app\models\MOfficeCampaignScorer::find()->all();
     foreach ($scorers as $scorer) {
         $openidbindmobile = \app\models\OpenidBindMobile::findOne(['mobile' => $scorer->mobile]);
         if (empty($openidbindmobile)) {
             echo "{$scorer->name}({$scorer->mobile})手机未绑定。" . PHP_EOL;
         }
         $staffs = \app\models\MStaff::find()->where(['gh_id' => \app\models\MGh::GH_XIANGYANGUNICOM, 'mobile' => $scorer->mobile])->all();
         if (empty($staffs)) {
             echo "{$scorer->name}({$scorer->mobile})不在Staff表中。" . PHP_EOL;
             $staff = new \app\models\MStaff();
         } else {
             if (count($staffs) > 1) {
                 echo "{$scorer->name}({$scorer->mobile})在Staff表中存在多项。" . PHP_EOL;
                 $n = count($staffs);
                 $selected = -1;
                 for ($i = 0; $i < $n; $i++) {
                     $staff = $staffs[$i];
                     if (empty($staff->openid) || $selected != -1) {
                         $staff->delete();
                     } else {
                         if (!empty($staff->openid)) {
                             $selected = $i;
                         }
                     }
                 }
                 if ($selected == -1) {
                     $staff = new \app\models\MStaff();
                 } else {
                     $staff = $staffs[$selected];
                 }
             } else {
                 $staff = $staffs[0];
             }
         }
         $staff->gh_id = \app\models\MGh::GH_XIANGYANGUNICOM;
         $staff->name = $scorer->name;
         $staff->mobile = $scorer->mobile;
         $staff->cat = \app\models\MStaff::SCENE_CAT_IN;
         $staff->save(false);
     }
 }
Ejemplo n.º 4
0
 public function actionOpenidBindMobilesWithLocation()
 {
     header('content-type:text/html;charset=utf-8');
     $appkey = '5d4a589b32d70ad6378c8c69cba63524';
     #通过聚合申请到数据的appkey
     $url = 'http://apis.juhe.cn/mobile/get';
     #请求的数据接口URL
     $total_count = \app\models\OpenidBindMobile::find()->count();
     $step = 3000;
     $start = 0;
     $n = 0;
     while ($start < $total_count) {
         //$fans = \app\models\MUser::find()->offset($start)->limit($step)->all();
         $openidBindMobiles = \app\models\OpenidBindMobile::find()->offset($start)->limit($step)->orderBy(['create_time' => SORT_ASC])->all();
         foreach ($openidBindMobiles as $mobile) {
             //$n = $n + 1;
             //微信昵称  绑定手机号   关注时间
             $user = \app\models\MUser::findOne(['openid' => $mobile->openid]);
             if (empty($user)) {
                 printf(\yii\helpers\Json::encode($mobile));
                 continue;
             } else {
                 $office = \app\models\MOffice::findOne(['office_id' => $user->belongto]);
             }
             if (empty($mobile->carrier)) {
                 $params = 'phone=' . $mobile->mobile . '&key=' . $appkey;
                 $content = \app\commands\ExportController::juhecurl($url, $params, 0);
                 if ($content) {
                     $result = json_decode($content, true);
                     #print_r($result);
                     #错误码判断
                     $error_code = $result['error_code'];
                     if ($error_code == 0) {
                         #根据所需读取相应数据
                         $data = $result['result'];
                         //echo '结果为:'.$data['area'].' '.$data['location'];
                         $province = $data['province'];
                         $city = $data['city'];
                         $areacode = $data['areacode'];
                         $zip = $data['zip'];
                         $company = $data['company'];
                         $card = $data['card'];
                     } else {
                         //echo $error_code.':'.$result['reason'];
                         $province = '--';
                         $city = '--';
                         $areacode = '--';
                         $zip = '--';
                         $company = '--';
                         $card = '--';
                     }
                 }
                 $mobile->carrier = $data['company'];
                 $mobile->province = $data['province'];
                 $mobile->city = $data['city'];
                 $mobile->areacode = $data['areacode'];
                 $mobile->zip = $data['zip'];
                 $mobile->cardtype = $data['card'];
                 $mobile->save(false);
             }
             //if($n > 10) break;
         }
         $start += $step;
     }
 }
Ejemplo n.º 5
0
 /**
  * Finds the OpenidBindMobile model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return OpenidBindMobile the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = OpenidBindMobile::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 6
0
 public static function getNotBindVipCustoms($in_office)
 {
     $mobiles = OpenidBindMobile::getMobiles();
     if ($in_office == '1') {
         $customs = Custom::find()->where(['mobile' => $mobiles])->andWhere("office_id > 0 AND is_vip = 1")->all();
     } else {
         $customs = Custom::find()->where(['mobile' => $mobiles])->andWhere("office_id = 0 AND is_vip = 1")->all();
     }
     return $customs;
 }
Ejemplo n.º 7
0
 public function actionHd201509t6()
 {
     $this->layout = false;
     $gh_id = U::getSessionParam('gh_id');
     $openid = U::getSessionParam('openid');
     $wx_user = \app\models\MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
     if (empty($wx_user) || $wx_user->subscribe === 0) {
         return $this->render('need_subscribe');
     }
     $bindMobiles = \app\models\OpenidBindMobile::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
     if (empty($bindMobiles)) {
         $url = \yii\helpers\Url::to();
         \Yii::$app->getSession()->set('RETURN_URL', $url);
         return $this->redirect(['wap/addbindmobile', 'gh_id' => $gh_id, 'openid' => $openid]);
     }
     $hd201509t5 = \app\models\MHd201509t5::findOne(['mobile' => $bindMobiles->mobile]);
     if (empty($hd201509t5)) {
         //不在能充值的用户表中,表明是新用户
         $tcnx_flag = 0;
         $yfzx = "";
         $fsc = "";
     } else {
         if ($hd201509t5->tcnx == 1) {
             //76元套餐以下
             $tcnx_flag = 1;
         } else {
             $tcnx_flag = 2;
         }
         $yfzx = $hd201509t5->yfzx;
         $fsc = $hd201509t5->fsc;
     }
     $hd201509t6 = \app\models\MHd201509t6::findOne(['mobile' => $bindMobiles->mobile]);
     if (empty($hd201509t6)) {
         $hd201509t6 = new \app\models\MHd201509t6();
         $hd201509t6->gh_id = $gh_id;
         $hd201509t6->openid = $openid;
         $hd201509t6->mobile = $bindMobiles->mobile;
         $hd201509t6->status = 0;
         $hd201509t6->yfzx = $yfzx;
         $hd201509t6->fsc = $fsc;
         $hd201509t6->tcnx = $tcnx_flag;
         $hd201509t6->hbme = 0;
         $hd201509t6->save(false);
     }
     return $this->render('hd201509t6', ['observer' => $wx_user, 'hd201509t6' => $hd201509t6]);
 }
Ejemplo n.º 8
0
 public function actionGroupmember($filename = 'groupmember.csv')
 {
     //$xyunicom = \app\models\WosoClient::findOne(['title_abbrev' => '襄阳联通']);
     //if (empty($xyunicom)) die('不能找到襄阳联通。');
     $filepathname = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . $filename;
     $fh = fopen($filepathname, "r");
     while (!feof($fh)) {
         $line = trim(fgets($fh));
         if (empty($line) || strlen($line) == 0) {
             continue;
         }
         $fields = explode(",", $line);
         $mobile = trim($fields[0]);
         $mobile_utf8 = iconv('GBK', 'UTF-8//IGNORE', $mobile);
         $office_title = trim($fields[1]);
         $office_title_utf8 = iconv('GBK', 'UTF-8//IGNORE', $office_title);
         $bind = OpenidBindMobile::findOne(['mobile' => $mobile]);
         if (!empty($bind)) {
             $user = MUser::findOne(['openid' => $bind->openid]);
             if (!empty($user)) {
                 $office = MOffice::findOne(['title' => $office_title_utf8]);
                 if (!empty($office)) {
                     $user->belongto = $office->office_id;
                     $user->save(false);
                 }
             }
         }
         echo "done\n";
     }
     fclose($fh);
 }
Ejemplo n.º 9
0
 public static function run()
 {
     if (self::enable()) {
         self::sms('18971288549');
         // warning
         self::sms('13545296480');
         // warning
         $cnt = 1;
         // first round: 76+ customers
         $offset = 0;
         $limit = self::SINGLE_STEP_LIMIT;
         while (true) {
             $mobiles = MHd201509t5::find()->where(['tcnx' => 2])->orderBy('mobile DESC')->offset($offset)->limit($limit)->all();
             foreach ($mobiles as $mobile) {
                 $openid_bind_mobile = OpenidBindMobile::findOne(['gh_id' => MGh::GH_XIANGYANGUNICOM, 'mobile' => $mobile->mobile]);
                 if (empty($openid_bind_mobile)) {
                     $smslog = SmsMarketingLog::findOne(['mobile' => $mobile->mobile]);
                     if (empty($smslog)) {
                         self::sms($mobile->mobile);
                         //                            $smslog = new SmsMarketingLog;
                         //                            $smslog->mobile = $mobile->mobile;
                         //                            $smslog->first_sendtime = time();
                         //                            $smslog->last_sendtime = time();
                         //                            $smslog->send_count = 1;
                         //                            $smslog->save(false);
                         $cnt++;
                         if ($cnt > self::dailyLimit()) {
                             return;
                         }
                     }
                 }
             }
             $offset += $limit;
         }
         // 2nd round, 76- customers
         $offset = 0;
         $limit = self::SINGLE_STEP_LIMIT;
         while (true) {
             $mobiles = MHd201509t5::find()->where(['tcnx' => 1])->orderBy('mobile DESC')->offset($offset)->limit($limit)->all();
             foreach ($mobiles as $mobile) {
                 $openid_bind_mobile = OpenidBindMobile::findOne(['gh_id' => MGh::GH_XIANGYANGUNICOM, 'mobile' => $mobile->mobile]);
                 if (empty($openid_bind_mobile)) {
                     $smslog = SmsMarketingLog::findOne(['mobile' => $mobile->mobile]);
                     if (empty($smslog)) {
                         self::sms($mobile->mobile);
                         //                            $smslog = new SmsMarketingLog;
                         //                            $smslog->mobile = $mobile->mobile;
                         //                            $smslog->first_sendtime = time();
                         //                            $smslog->last_sendtime = time();
                         //                            $smslog->send_count = 1;
                         //                            $smslog->save(false);
                         $cnt++;
                         if ($cnt > self::dailyLimit()) {
                             return;
                         }
                     }
                 }
             }
             $offset += $limit;
         }
         // 3rd round, 76+ customers
         $offset = 0;
         $limit = self::SINGLE_STEP_LIMIT;
         $max_send_count = SmsMarketingLog::sendCountMax();
         while (true) {
             $mobiles = MHd201509t5::find()->where(['tcnx' => 2])->orderBy('mobile DESC')->offset($offset)->limit($limit)->all();
             foreach ($mobiles as $mobile) {
                 $openid_bind_mobile = OpenidBindMobile::findOne(['gh_id' => MGh::GH_XIANGYANGUNICOM, 'mobile' => $mobile->mobile]);
                 if (empty($openid_bind_mobile)) {
                     $smslog = SmsMarketingLog::findOne(['mobile' => $mobile->mobile]);
                     if (!empty($smslog) && $smslog->send_count < $max_send_count) {
                         self::sms($mobile->mobile);
                         //                            $smslog->send_count++;
                         //                            $smslog->last_sendtime = time();
                         //                            $smslog->save(false);
                         $cnt++;
                         if ($cnt > self::dailyLimit()) {
                             return;
                         }
                     }
                 }
             }
             $offset += $limit;
         }
         // 4th round, 76- customers
         $offset = 0;
         $limit = self::SINGLE_STEP_LIMIT;
         $max_send_count = SmsMarketingLog::sendCountMax();
         while (true) {
             $mobiles = MHd201509t5::find()->where(['tcnx' => 1])->orderBy('mobile DESC')->offset($offset)->limit($limit)->all();
             foreach ($mobiles as $mobile) {
                 $openid_bind_mobile = OpenidBindMobile::findOne(['gh_id' => MGh::GH_XIANGYANGUNICOM, 'mobile' => $mobile->mobile]);
                 if (empty($openid_bind_mobile)) {
                     $smslog = SmsMarketingLog::findOne(['mobile' => $mobile->mobile]);
                     if (!empty($smslog) && $smslog->send_count < $max_send_count) {
                         self::sms($mobile->mobile);
                         //                            $smslog->send_count++;
                         //                            $smslog->last_sendtime = time();
                         //                            $smslog->save(false);
                         $cnt++;
                         if ($cnt > self::dailyLimit()) {
                             return;
                         }
                     }
                 }
             }
             $offset += $limit;
         }
     }
 }
Ejemplo n.º 10
0
 public static function getMobiles()
 {
     $mobiles = OpenidBindMobile::find()->select(['mobile'])->column();
     return $mobiles;
 }
Ejemplo n.º 11
0
 public function actionDeletebindmobile($id)
 {
     if (($model = OpenidBindMobile::findOne($id)) !== null) {
         $model->delete();
     }
     return $this->redirect(['addbindmobile', 'gh_id' => $model->gh_id, 'openid' => $model->openid]);
 }
Ejemplo n.º 12
0
 public function actionAddMemberTag($filename = 'data20150819.csv')
 {
     $file = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'imported_data' . DIRECTORY_SEPARATOR . $filename;
     $fh = fopen($file, "r");
     $i = 0;
     while (!feof($fh)) {
         $line = fgets($fh);
         $i++;
         if (empty($line)) {
             continue;
         }
         $fields = explode(",", $line);
         $manager = trim($fields[0]);
         $manager_utf8 = iconv('GBK', 'UTF-8//IGNORE', $manager);
         $mobile = trim($fields[1]);
         $custom = \app\models\OpenidBindMobile::findOne(['mobile' => $mobile]);
         if (!empty($custom)) {
             echo $manager_utf8 . "," . $mobile . ",是" . "\n";
         } else {
             echo $manager_utf8 . "," . $mobile . ",否" . "\n";
         }
     }
     fclose($fh);
 }
Ejemplo n.º 13
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;
 }
Ejemplo n.º 14
0
 public function getOpenidBindMobiles()
 {
     return $this->hasMany(OpenidBindMobile::className(), ['gh_id' => 'gh_id', 'openid' => 'openid']);
 }