Esempio n. 1
0
 public function getVipLevel()
 {
     return $this->hasOne(VipLevel::className(), ['vip_level_id' => 'vip_level_id']);
 }
Esempio n. 2
0
 public function actionImportvipnew()
 {
     $file = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'vip.txt';
     $fh = fopen($file, "r");
     $i = 0;
     while (!feof($fh)) {
         $line = fgets($fh);
         if (empty($line)) {
             continue;
         }
         $line = iconv('GBK', 'UTF-8//IGNORE', $line);
         $arr = explode("\t", $line);
         //$arr[1] = iconv('GBK','UTF-8//IGNORE', $arr[1]);
         //$arr[2] = iconv('GBK','UTF-8//IGNORE', $arr[2]);
         //$arr[3] = iconv('GBK','UTF-8//IGNORE', $arr[3]);
         $custom_mobile = trim($arr[0]);
         $manager_name = trim($arr[1]);
         $manager_mobile = trim($arr[2]);
         $vip_level_title = trim($arr[3]);
         $office_title = trim($arr[4]);
         //$vip_join_time = trim($arr[4]);
         //$vip_join_time = str_replace("/", "-", $vip_join_time);
         //$vip_start_time = trim($arr[5]);
         //$vip_start_time = str_replace("/", "-", $vip_start_time);
         //$vip_end_time = trim($arr[6]);
         //$vip_end_time = str_replace("/", "-", $vip_end_time);
         $vipLevel = VipLevel::findOne(['title' => $vip_level_title]);
         if (empty($vipLevel)) {
             $vipLevel = new VipLevel();
             $vipLevel->title = $vip_level_title;
             if (!$vipLevel->save(false)) {
                 U::W('save vipLevel err');
             }
         }
         $office = MOffice::findOne(['title' => $office_title]);
         $custom = Custom::findOne(['mobile' => $custom_mobile]);
         if (!empty($custom)) {
             U::W("mobile={$custom_mobile} already exists");
             U::W($arr);
             //                continue;
         } else {
             $custom = new Custom();
             $custom->vip_join_time = '0000-00-00 00:00:00';
         }
         $custom->mobile = $custom_mobile;
         $custom->is_vip = 1;
         //$custom->vip_join_time = $vip_join_time;
         //$custom->vip_start_time = $vip_start_time;
         //$custom->vip_end_time = $vip_end_time;
         $custom->vip_level_id = $vipLevel->vip_level_id;
         $custom->office_id = empty($office) ? 0 : $office->office_id;
         $custom->save(false);
         $manager = Manager::findOne(['mobile' => $manager_mobile]);
         if (empty($manager)) {
             $manager = new Manager();
             //$manager->mobile = $manager_mobile;
             $manager->name = $manager_name;
             $manager->save(false);
         }
         $customManager = CustomManager::findOne(['custom_id' => $custom->custom_id, 'manager_id' => $manager->manager_id]);
         if (!empty($customManager)) {
             //U::W('Impossible!!! CustomManager already exists');
             //U::W($arr);
         } else {
             $customManager = new CustomManager();
             $customManager->custom_id = $custom->custom_id;
             $customManager->manager_id = $manager->manager_id;
             if (!$customManager->save(false)) {
                 U::W('customManager SAVE ERR');
             }
         }
         $i++;
         //if($i > 5) break;
         if ($i % 1000 == 1) {
             U::W($i);
         }
     }
     fclose($fh);
 }
Esempio n. 3
0
								</a>
                    </div>
                </div>
                <div class="portlet-body">
                    <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' => [['attribute' => 'mobile', 'value' => function ($model, $key, $index, $column) {
    return $model->mobile;
}], ['attribute' => 'name', 'format' => 'raw', 'value' => function ($model, $key, $index, $column) {
    //VIP级别   加入时间    开始时间    结束时间
    $cusername = $model->name;
    $level = \app\models\VipLevel::items($model->vip_level_id);
    $vip_join_time = $model->isVip() ? $model->getVipJoinTime() : '';
    $vip_start_time = $model->isVip() ? $model->getVipStartTime() : '';
    $vip_end_time = $model->isVip() ? $model->getVipEndTime() : '';
    $customlist = "VIP级别 " . $level . "<br>加入时间 " . $vip_join_time . "<br>开始时间 " . $vip_start_time . "<br>结束时间 " . $vip_end_time;
    //return $model->name."&nbsp;<a style='float:right' tabindex='0' class='btn btn-info glyphicon glyphicon-th-list' role='button' data-trigger='focus' title='".$cusername."' data-toggle='popover' data-placement='right' data-content='".$customlist."'></a>";
    return $model->name;
}], ['label' => '微信信息', 'format' => 'html', 'value' => function ($model, $key, $index, $column) {
    if (empty($model->user)) {
        return "<img width=48 src='/wx/web/images/wxmpres/headimg-nowx-blank.png' title='微信未绑定'>";
    } else {
        $mobiles = $model->user->getBindMobileNumbers();
        $mobile = empty($mobiles) ? '无' : $mobiles[0];
        if (empty($model->user->headimgurl)) {
            return "<img style='float:left;' width=48 src='/wx/web/images/wxmpres/headimg-blank.png'>&nbsp;&nbsp;<span style='color:#aaa'>昵称 " . $model->user->nickname . "<br>&nbsp;&nbsp;地区 " . $model->user->country . "&nbsp;" . $model->user->province . "&nbsp;" . $model->user->city . "<br>&nbsp;&nbsp;绑定手机 " . $mobile . "</span>";
        } else {
Esempio n. 4
0
-->

    <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, 'columns' => ['mobile', 'name', ['attribute' => 'is_vip', 'format' => 'html', 'value' => function ($model, $key, $index, $column) {
    return $model->isVip() ? "是" : "否";
}, 'filter' => ['0' => '否', '1' => '是']], ['label' => '部门名称', 'attribute' => 'office_id', 'value' => function ($model, $key, $index, $column) {
    return empty($model->office->title) ? '' : $model->office->title;
}, 'filter' => MOffice::getOfficeNameOptionSimple2('gh_03a74ac96138', false, false), 'headerOptions' => array('style' => 'width:200px;'), 'visible' => Yii::$app->user->getIsAdmin()], ['attribute' => 'vip_level_id', 'value' => function ($model, $key, $index, $column) {
    return \app\models\VipLevel::items($model->vip_level_id);
}, 'filter' => \app\models\VipLevel::items()], ['attribute' => 'vip_join_time', 'value' => function ($model, $key, $index, $column) {
    return $model->isVip() ? $model->getVipJoinTime() : '';
}], ['attribute' => 'vip_start_time', 'value' => function ($model, $key, $index, $column) {
    return $model->isVip() ? $model->getVipStartTime() : '';
}], ['attribute' => 'vip_end_time', 'value' => function ($model, $key, $index, $column) {
    return $model->isVip() ? $model->getVipEndTime() : '';
}], ['label' => '是否绑定', 'value' => function ($model, $key, $index, $column) {
    return empty($model->openidBindMobile) ? '否' : '是';
}], ['label' => '微信昵称', 'value' => function ($model, $key, $index, $column) {
    return empty($model->openidBindMobile->user->nickname) ? '' : $model->openidBindMobile->user->nickname;
}]]]);
?>

</div>
Esempio n. 5
0
echo $form->field($model, 'mobile')->textInput(['maxlength' => 32]);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 16]);
?>

    <?php 
echo $form->field($model, 'is_vip')->textInput();
?>

    <?php 
echo $form->field($model, 'office_id')->textInput(['maxlength' => 10]);
?>

    <?php 
echo $form->field($model, 'vip_level_id')->dropDownList(\app\models\VipLevel::items());
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>