/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = MHd201509t6::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['hd201509t6_id' => $this->hd201509t6_id, 'tcnx' => $this->tcnx, 'hbme' => $this->hbme, 'create_time' => $this->create_time, 'status' => $this->status]); $query->andFilterWhere(['like', 'gh_id', $this->gh_id])->andFilterWhere(['like', 'openid', $this->openid])->andFilterWhere(['like', 'mobile', $this->mobile])->andFilterWhere(['like', 'yfzx', $this->yfzx])->andFilterWhere(['like', 'fsc', $this->fsc])->andFilterWhere(['like', 'qdbm', $this->qdbm]); return $dataProvider; }
public function actionUpdateHd201509t6m2($filename = 'errcode1012.csv') { $filepathname = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'imported_data' . 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); $qdbm_ok = trim($fields[1]); $qdbm_ok_utf8 = iconv('GBK', 'UTF-8//IGNORE', $qdbm_ok); $hd201509t6 = MHd201509t6::findOne(['mobile' => $mobile_utf8]); if (empty($hd201509t6)) { echo $mobile_utf8 . "\t\t" . "not found ... \n"; } else { echo $mobile_utf8 . "\t\t" . "update to ->\t" . $qdbm_ok_utf8 . "\n"; $hd201509t6->qdbm = $qdbm_ok_utf8; $hd201509t6->save(false); } } fclose($fh); echo "done\n"; }
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]); }
/** * Finds the MHd201509t6 model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MHd201509t6 the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MHd201509t6::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<//?= $form->field($model, 'hbme')->textInput() ?> <//?= $form->field($model, 'create_time')->textInput() ?> <//?= $form->field($model, 'status')->textInput() ?> <//?= $form->field($model, 'qdbm')->textInput(['maxlength' => 32]) ?> --> <?php echo $form->field($model, 'qdbm')->textInput(['maxlength' => 32]); ?> <?php echo $form->field($model, 'status')->dropDownList(MHd201509t6::gethd201509t6StatusOption()); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? '新增' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
--> <p> <?php echo Html::a('下载 <i class="glyphicon glyphicon-arrow-down"></i>', U::current(['download' => 1]), ['class' => 'btn btn-success', 'data-pjax' => '0']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['label' => '微信昵称', 'format' => 'html', 'value' => function ($model, $key, $index, $column) { $user = $model->user; return empty($user) ? '' : "<img width=48 src=" . $model->user->headimgurl . "><br>" . emoji_unified_to_html(emoji_softbank_to_unified($user->nickname)); }, 'filter' => false, 'headerOptions' => array('style' => 'width:90px;')], 'mobile', 'hbme', 'create_time', ['attribute' => 'status', 'label' => '状态', 'value' => function ($model, $key, $index, $column) { return MHd201509t6::gethd201509t6StatusOption($model->status); }, 'filter' => MHd201509t6::gethd201509t6StatusOption(), 'headerOptions' => array('style' => 'width:80px;')], 'qdbm', ['label' => '归属营服', 'value' => function ($model, $key, $index, $column) { $qdbm = strtolower(trim($model->qdbm)); $qd = MQdbm::findOne(['qdbm' => $qdbm]); if (empty($qd)) { return "--"; } else { return $qd->gsyf; } }, 'headerOptions' => array('style' => 'width:120px;')], ['label' => '渠道名称', 'value' => function ($model, $key, $index, $column) { $qdbm = strtolower(trim($model->qdbm)); $qd = MQdbm::findOne(['qdbm' => $qdbm]); if (empty($qd)) { return "--"; } else { return $qd->qdmc; }