Esempio n. 1
0
 public function actionHd201509t2()
 {
     $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]);
     }
     $hd201509t1 = \app\models\MHd201509t1::findOne(['mobile' => $bindMobiles->mobile]);
     if (empty($hd201509t1)) {
         //不在能充值的用户表中, 不符合充值条件,显示对不起页面
         return $this->render('hd201509t2_1');
     }
     $hd201509t2 = \app\models\MHd201509t2::findOne(['mobile' => $hd201509t1->mobile]);
     if (empty($hd201509t2)) {
         $hd201509t2 = new \app\models\MHd201509t2();
         $hd201509t2->gh_id = $gh_id;
         $hd201509t2->openid = $openid;
         $hd201509t2->mobile = $bindMobiles->mobile;
         $hd201509t2->status = 0;
         $hd201509t2->yfzx = $hd201509t1->yfzx;
         $hd201509t2->fsc = $hd201509t1->fsc;
         $hd201509t2->save(false);
     }
     return $this->render('hd201509t2', ['observer' => $wx_user, 'hd201509t2' => $hd201509t2]);
 }
Esempio n. 2
0
 public function actionImporthd201509t1()
 {
     $file = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'all-users-20150828.csv';
     $fh = fopen($file, "r");
     $i = 0;
     while (!feof($fh)) {
         $line = fgets($fh);
         if (empty($line)) {
             continue;
         }
         $arr = explode(",", $line);
         $arr[0] = iconv('GBK', 'UTF-8//IGNORE', $arr[0]);
         $mobile = trim($arr[0]);
         $arr[1] = iconv('GBK', 'UTF-8//IGNORE', $arr[1]);
         $yfzx = trim($arr[1]);
         $arr[2] = iconv('GBK', 'UTF-8//IGNORE', $arr[2]);
         $fsc = trim($arr[2]);
         echo $mobile . "\t" . $yfzx . "\t" . $fsc . "\n";
         $hd201509t1 = MHd201509t1::findOne(['mobile' => $mobile]);
         if (!empty($hd201509t1)) {
             //U::W("mobile=$mobile already exists");
             //U::W($arr);
         } else {
             $hd201509t1 = new MHd201509t1();
         }
         $hd201509t1->mobile = $mobile;
         $hd201509t1->yfzx = $yfzx;
         $hd201509t1->fsc = $fsc;
         $hd201509t1->save(false);
         $i++;
         if ($i % 1000 == 1) {
             U::W($i);
         }
     }
     fclose($fh);
 }