예제 #1
0
 /**
  * Lists all ClientEmployee models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new ClientEmployeeSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     if (isset($_GET['download'])) {
         $datetime_start = str_replace('\'', '', $_GET['datetime_start']);
         $datetime_end = str_replace('\'', '', $_GET['datetime_end']);
         $filename = Yii::$app->getRuntimePath() . "/员工会员推广排行榜-" . $datetime_start . '到' . $datetime_end . '.csv';
         $fh = fopen($filename, 'w');
         fprintf($fh, "排名,会员推广数量,员工姓名,电话,营业厅" . PHP_EOL);
         $i = 1;
         \Yii::warning('yjhu:' . $datetime_start);
         $rows = \app\models\MUser::getMemberPromotionTopList(0, 5000, $datetime_start . ' 00:00:00', $datetime_end . ' 23:59:59');
         foreach ($rows as $row) {
             $staff = \app\models\MStaff::findOne(['scene_id' => $row['scene_pid']]);
             fprintf($fh, $i++ . ',');
             fprintf($fh, $row['members'] . ',');
             fprintf($fh, $staff->name . ',');
             fprintf($fh, $staff->mobile . ',');
             fprintf($fh, (empty($staff->office) ? '' : $staff->office->title) . PHP_EOL);
         }
         fclose($fh);
         Yii::$app->response->sendFile($filename);
         return;
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
예제 #2
0
 protected function onTextOld()
 {
     $openid = $this->getRequest('FromUserName');
     $gh_id = $this->getRequest('ToUserName');
     while (1) {
         $Content = $this->getRequest('Content');
         $msg = trim($Content);
         $state = $this->getState($gh_id, $openid);
         if ($msg == '0' && $state != self::STATE_NONE) {
             U::W('deleteState');
             $this->deleteState($gh_id, $openid);
             return $this->responseText("谢谢,再见!");
         }
         U::W($state);
         switch ($state) {
             case self::STATE_NONE:
                 //if ($msg !== 'Xy')
                 if ($msg == 'New') {
                     $url = Url::to(['wapx/staffsearch', 'gh_id' => $gh_id, 'openid' => $openid], true);
                     return $this->responseText("see my score? <a href=\"{$url}\">click me</a>");
                 } else {
                     if ($msg == '.debug') {
                         $url = Url::to(['wapx/staffsearch', 'gh_id' => $gh_id, 'openid' => $openid], true);
                         return $this->responseText("see my score? <a href=\"{$url}\">click me</a>");
                     }
                 }
                 if ($msg !== 'Xy') {
                     //return Wechat::NO_RESP;
                     $model = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
                     $items = array(new RespNewsItem("{$model->nickname}, 欢迎进入襄阳联通官方微信营业厅", '猛戳进入首页!', Url::to('images/metro-intro.jpg', true), Url::to(['wap/home', 'gh_id' => $gh_id, 'openid' => $openid], true)));
                     return $this->responseNews($items);
                 }
                 $model = MStaff::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
                 if ($model === null) {
                     $this->setState($gh_id, $openid, self::STATE_MOBILE);
                     return $this->responseText("请输入手机号, 0:退出");
                 } else {
                     if (empty($model->office_id)) {
                         $this->setState($gh_id, $openid, self::STATE_OFFICE);
                         return $this->responseText($this->getOfficePrompt($gh_id));
                     } else {
                         $this->setState($gh_id, $openid, self::STATE_MENU_ONE);
                         return $this->responseText(self::PROMPT_MENU_ONE);
                     }
                 }
                 break;
             case self::STATE_MOBILE:
                 if (!is_numeric($msg) || substr($msg, 0, 1) !== '1' || strlen($msg) != 11) {
                     return $this->responseText("无效的手机号!\n\n" . "请重新输入手机号, 0:退出");
                 }
                 $model = MStaff::findOne(['mobile' => $msg]);
                 if ($model === null) {
                     return $this->responseText("非襄阳联通员工手机号!\n\n" . "请重新输入手机号, 0:退出");
                 }
                 $model->gh_id = $gh_id;
                 $model->openid = $openid;
                 $model->save(false);
                 if (empty($model->office_id)) {
                     $this->setState($gh_id, $openid, self::STATE_OFFICE);
                     $str = $this->getOfficePrompt($gh_id);
                     return $this->responseText("{$model->name},您好!\n,{$str}");
                 } else {
                     $this->setState($gh_id, $openid, self::STATE_MENU_ONE);
                     return $this->responseText(self::PROMPT_MENU_ONE);
                 }
             case self::STATE_OFFICE:
                 //$offices =MOffice::find()->where(['gh_id'=>$gh_id])->asArray()->all();
                 $offices = MOffice::find()->where("gh_id = '{$gh_id}' AND office_id <=25 ")->asArray()->all();
                 $office_ids = [];
                 foreach ($offices as $office) {
                     $office_ids[] = $office['office_id'];
                 }
                 if (!is_numeric($msg) || $msg < 0 || !in_array($msg, $office_ids)) {
                     return $this->responseText("无效的部门号!\n\n" . $this->getOfficePrompt($gh_id));
                 }
                 $model = MStaff::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
                 $model->office_id = $msg;
                 $model->save(false);
                 $this->setState($gh_id, $openid, self::STATE_MENU_ONE);
                 return $this->responseText(self::PROMPT_MENU_ONE);
             case self::STATE_CHANGE_MOBILE:
                 if (!is_numeric($msg) || substr($msg, 0, 1) !== '1' || strlen($msg) != 11) {
                     return $this->responseText("无效的手机号!\n\n" . "请重新输入手机号, 0:退出");
                 }
                 $model = MStaff::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
                 $model->mobile = $msg;
                 $model->save(false);
                 $this->setState($gh_id, $openid, self::STATE_MENU_ONE);
                 return $this->responseText(self::PROMPT_MENU_ONE);
             case self::STATE_MENU_ONE:
                 if (!is_numeric($msg) || $msg < 0 || $msg > 7) {
                     return $this->responseText("输入无效!\n\n" . self::PROMPT_MENU_ONE);
                 }
                 switch ($msg) {
                     case 1:
                         //U::W('enter 111111');
                         $model = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
                         if (empty($model->scene_id)) {
                             $gh = MGh::findOne($gh_id);
                             $scene_id = $gh->newSceneId();
                             $gh->save(false);
                             $model->scene_id = $scene_id;
                             $model->save(false);
                             //U::W("new a scene_id=$scene_id");
                         } else {
                             $scene_id = $model->scene_id;
                             //U::W("old scene_id=$scene_id");
                         }
                         $log_file_path = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'qr' . DIRECTORY_SEPARATOR . "{$gh_id}_{$scene_id}.jpg";
                         //U::W($log_file_path);
                         if (!file_exists($log_file_path)) {
                             $arr = $this->WxgetQRCode($scene_id, true);
                             $url = $this->WxGetQRUrl($arr['ticket']);
                             Wechat::downloadFile($url, $log_file_path);
                         }
                         //$url = Url::to(['wap/aboutqr','name'=>$model->nickname, 'qrurl'=>Yii::$app->getRequest()->baseUrl."/../runtime/qr/{$gh_id}_{$scene_id}.jpg"],true);
                         $url = "http://mp.weixin.qq.com/s?__biz=MzA4ODkwOTYxMA==&mid=203659175&idx=1&sn=0efaf2269fb7ba6a022f5c31d0d5e255#rd";
                         //U::W($url);
                         $msg = ['touser' => $openid, 'msgtype' => 'text', 'text' => ['content' => "如何使用个人的二维码? <a href=\"{$url}\">点击这里...</a>"]];
                         $arr = $this->WxMessageCustomSend($msg);
                         return $this->responseLocalImage('image', $log_file_path);
                     case 2:
                         $model = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
                         if ($model->scene_id == 0) {
                             $count = 0;
                         } else {
                             $count = MUser::find()->where(['gh_id' => $gh_id, 'scene_pid' => $model->scene_id])->count();
                         }
                         return $this->responseText("你的推广人数是:{$count}\n\n" . self::PROMPT_MENU_ONE);
                     case 3:
                         $staff = MStaff::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
                         if (empty($staff->office_id)) {
                             $this->setState($gh_id, $openid, self::STATE_OFFICE);
                             return $this->responseText($this->getOfficePrompt($gh_id));
                         }
                         $model = MOffice::findOne($staff->office_id);
                         if ($model === null) {
                             $this->setState($gh_id, $openid, self::STATE_OFFICE);
                             $str = $this->getOfficePrompt($gh_id);
                             return $this->responseText("invalid office id\n,{$str}");
                         }
                         if (empty($model->scene_id)) {
                             $gh = MGh::findOne($gh_id);
                             $scene_id = $gh->newSceneId();
                             $gh->save(false);
                             $model->scene_id = $scene_id;
                             $model->save(false);
                             U::W("scene_id={$scene_id}");
                         } else {
                             $scene_id = $model->scene_id;
                         }
                         $log_file_path = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'qr' . DIRECTORY_SEPARATOR . "{$gh_id}_{$scene_id}.jpg";
                         //U::W($log_file_path);
                         if (!file_exists($log_file_path)) {
                             $arr = $this->WxgetQRCode($scene_id, true);
                             $url = $this->WxGetQRUrl($arr['ticket']);
                             Wechat::downloadFile($url, $log_file_path);
                         }
                         //$msg = ['touser'=>$openid, 'msgtype'=>'text', 'text'=>['content'=>'如何使用部门的二维码? <a href="http://baidu.com">点击这里...</a>']];
                         //$url = Url::to(['wap/aboutqr','name'=>$model->title, 'qrurl'=>Yii::$app->getRequest()->baseUrl."/../runtime/qr/{$gh_id}_{$scene_id}.jpg"],true);
                         $url = "http://mp.weixin.qq.com/s?__biz=MzA4ODkwOTYxMA==&mid=203659175&idx=1&sn=0efaf2269fb7ba6a022f5c31d0d5e255#rd";
                         $msg = ['touser' => $openid, 'msgtype' => 'text', 'text' => ['content' => "如何使用部门的二维码? <a href=\"{$url}\">点击这里...</a>"]];
                         $arr = $this->WxMessageCustomSend($msg);
                         return $this->responseLocalImage('image', $log_file_path);
                     case 4:
                         $staff = MStaff::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
                         if (empty($staff->office_id)) {
                             $this->setState($gh_id, $openid, self::STATE_OFFICE);
                             return $this->responseText($this->getOfficePrompt($gh_id));
                         }
                         $model = MOffice::findOne($staff->office_id);
                         if ($model === null) {
                             $this->setState($gh_id, $openid, self::STATE_OFFICE);
                             $str = $this->getOfficePrompt($gh_id);
                             return $this->responseText("invalid office id\n,{$str}");
                         }
                         if ($model->scene_id == 0) {
                             $count = 0;
                         } else {
                             $count = MUser::find()->where(['gh_id' => $gh_id, 'scene_pid' => $model->scene_id])->count();
                         }
                         //U::W($user->office_id);
                         //U::W('a1111111111');
                         $staffs = MStaff::find()->where(['gh_id' => $gh_id, 'office_id' => $staff->office_id])->asArray()->all();
                         $openids = [];
                         //U::W($staffs);
                         foreach ($staffs as $staff) {
                             if (!empty($staff['openid'])) {
                                 $openids[] = $staff['openid'];
                             }
                         }
                         if (empty($openids)) {
                             $staff_count = 0;
                         } else {
                             $users = MUser::find()->where(['gh_id' => $gh_id, 'openid' => $openids])->asArray()->all();
                             $scene_ids = [];
                             foreach ($users as $user) {
                                 if ($user['scene_id'] != 0) {
                                     $scene_ids[] = $user['scene_id'];
                                 }
                             }
                             if (empty($scene_ids)) {
                                 $staff_count = 0;
                             } else {
                                 $staff_count = MUser::find()->where(['gh_id' => $gh_id, 'scene_pid' => $scene_ids])->count();
                             }
                         }
                         return $this->responseText("部门所属员工推广人数是:{$staff_count}\n部门推广人数是:{$count}\n\n" . self::PROMPT_MENU_ONE);
                     case 5:
                         $this->setState($gh_id, $openid, self::STATE_CHANGE_MOBILE);
                         return $this->responseText("请重新输入手机号, 0:退出");
                     case 6:
                         $staff = MStaff::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
                         $current_office_id = empty($staff->office_id) ? '' : "当前所属部门号:{$staff->office_id}\n";
                         $this->setState($gh_id, $openid, self::STATE_OFFICE);
                         return $this->responseText($current_office_id . $this->getOfficePrompt($gh_id));
                     case 7:
                         $staff = MStaff::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
                         if ($staff !== null) {
                             $staff->openid = '';
                             $staff->save(false);
                             return $this->responseText("成功解除微信号与员工之间的绑定!\n\n" . self::PROMPT_MENU_ONE);
                         } else {
                             return $this->responseText("你不需要解除绑定\n\n" . self::PROMPT_MENU_ONE);
                         }
                     default:
                         return $this->responseText("输入无效!\n\n" . self::PROMPT_MENU_ONE);
                 }
                 return $this->responseText(self::PROMPT_MENU_ONE);
         }
     }
 }
예제 #3
0
 /**
  * This command import office supervision data.
  * @param string $filename the file to be imported to DB.
  */
 public function actionSupervisor($filename = 'supervisor.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) || trim($line) == '') {
             continue;
         }
         $fields = explode(",", $line);
         $office_name = trim($fields[0]);
         $office_name_utf8 = iconv('GBK', 'UTF-8//IGNORE', $office_name);
         $msc_name = trim(trim($fields[1]), "0..9");
         $msc_name_utf8 = iconv('GBK', 'UTF-8//IGNORE', $msc_name);
         $region_name = trim(trim($fields[2]), "0..9");
         $region_name_utf8 = iconv('GBK', 'UTF-8//IGNORE', $region_name);
         $supervisor_name = trim($fields[3]);
         $supervisor_name_utf8 = iconv('GBK', 'UTF-8//IGNORE', $supervisor_name);
         $supervisor_mobile = trim(isset($fields[4]) ? $fields[4] : '');
         $comment = trim(isset($fields[5]) ? $fields[5] : '');
         $comment_utf8 = iconv('GBK', 'UTF-8//IGNORE', $comment);
         //            echo "comment = ".$comment.", comment_utf8 = ".$comment_utf8.PHP_EOL;
         $need2delete = false;
         if (mb_strpos($comment_utf8, '删除') === false) {
         } else {
             $need2delete = true;
         }
         if ($need2delete) {
             //                echo "deleting ......".PHP_EOL;
             if (!empty($office_name_utf8) && $office_name_utf8 != '') {
                 $office = MOffice::findOne(['title' => $office_name_utf8, 'gh_id' => \app\models\MGh::GH_XIANGYANGUNICOM]);
                 if (!empty($office)) {
                     // 删除督导关系
                     //                       echo "deleting supervision relation ...".$office->title.PHP_EOL;
                     yii::$app->db->createCommand()->delete('wx_rel_supervision_staff_office', ['office_id' => $office->office_id])->execute();
                     // 删除营服所属关系
                     if (!empty($office->msc)) {
                         //                            echo "deleting MSC/MR relation ...".$office->title.PHP_EOL;
                         $office->msc->updateCounters(['office_total_count' => -1]);
                         $office->msc->marketingRegion->updateCounters(['office_total_count' => -1]);
                         if ($office->msc->marketingRegion->office_total_count == 0) {
                             $office->msc->marketingRegion->delete();
                         }
                         if ($office->msc->office_total_count == 0) {
                             $office->msc->delete();
                         }
                         yii::$app->db->createCommand()->delete('wx_rel_office_msc', ['office_id' => $office->office_id])->execute();
                     }
                 }
             }
             continue;
         }
         if (empty($region_name_utf8) || $region_name_utf8 == '') {
             continue;
         }
         $region = MMarketingRegion::findOne(['name' => $region_name_utf8]);
         if (empty($region)) {
             //                $region = new MMarketingRegion;
             //                $region->name = $region_name_utf8;
             //                $region->save(false);
             echo "{$region_name_utf8} 不存在。" . PHP_EOL;
             continue;
         }
         if (empty($msc_name_utf8) || $msc_name_utf8 == '') {
             continue;
         }
         $msc = MMarketingServiceCenter::findOne(['name' => $msc_name_utf8]);
         if (empty($msc)) {
             //                $msc = new MMarketingServiceCenter;
             //                $msc->name = $msc_name_utf8;
             //                $msc->region_id = $region->id;
             //                $msc->save(false);
             echo "{$msc_name_utf8} 不存在。" . PHP_EOL;
             continue;
         }
         if (empty($office_name_utf8) || $office_name_utf8 == '') {
             continue;
         }
         $office = MOffice::findOne(['title' => $office_name_utf8]);
         if (empty($office)) {
             //                $office = new MOffice;
             //                $office->gh_id = \app\models\MGh::GH_XIANGYANGUNICOM; // 襄阳联通公共ID
             //                $office->title = $office_name_utf8;
             //                $office->is_jingxiaoshang = 1;
             //                $office->save(false);
             echo "{$office_name_utf8} 不存在。" . PHP_EOL;
             continue;
         }
         if (empty($office->msc)) {
             yii::$app->db->createCommand()->insert('wx_rel_office_msc', ['office_id' => $office->office_id, 'msc_id' => $msc->id])->execute();
             $msc->updateCounters(['office_total_count' => 1]);
             $region->updateCounters(['office_total_count' => 1]);
         }
         if (empty($supervisor_name_utf8) || $supervisor_name_utf8 == '') {
             continue;
         }
         $staff = MStaff::findOne(['name' => $supervisor_name_utf8, 'gh_id' => \app\models\MGh::GH_XIANGYANGUNICOM]);
         //            if (empty($staff)) {
         //                $staff = new MStaff;
         //                $staff->office_id = 25;
         //                $staff->name = $supervisor_name_utf8;
         //                $staff->gh_id = \app\models\MGh::GH_XIANGYANGUNICOM; // 襄阳联通公共ID
         //                $staff->mobile = $supervisor_mobile;
         //                $staff->cat = 0;
         //                $staff->save(false);
         //            } else if ($staff->mobile != $supervisor_mobile) {
         //                $staff->updateAttributes(['mobile' => $supervisor_mobile]); // 修改员工电话
         //            }
         if (empty($staff) && empty($supervisor_mobile)) {
             echo "{$supervisor_name_utf8} 不在数据库中。" . PHP_EOL;
             continue;
         } else {
             if (empty($staff)) {
                 $staff = new MStaff();
                 $staff->office_id = 25;
                 $staff->name = $supervisor_name_utf8;
                 $staff->gh_id = \app\models\MGh::GH_XIANGYANGUNICOM;
                 // 襄阳联通公共ID
                 $staff->mobile = $supervisor_mobile;
                 $staff->cat = 0;
                 $staff->save(false);
             }
         }
         if (empty($staff->supervisedOffices) || empty($office->supervisor)) {
             yii::$app->db->createCommand()->insert('wx_rel_supervision_staff_office', ['office_id' => $office->office_id, 'staff_id' => $staff->staff_id])->execute();
         } else {
             if ($office->supervisor->staff_id != $staff->staff_id) {
                 // 如果旧有的督导关系需要修改,先要删除原督导关系,再重新建立新的督导关系
                 yii::$app->db->createCommand()->delete('wx_rel_supervision_staff_office', ['office_id' => $office->office_id, 'staff_id' => $office->supervisor->staff_id])->execute();
                 yii::$app->db->createCommand()->insert('wx_rel_supervision_staff_office', ['office_id' => $office->office_id, 'staff_id' => $staff->staff_id])->execute();
             }
         }
     }
     fclose($fh);
 }
예제 #4
0
 public function actionHeatmapsdownload()
 {
     $searchModel = new HeatMapSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $dataProvider->setPagination(false);
     $data = $dataProvider->getModels();
     $rows = [];
     foreach ($data as $model) {
         $row['openid'] = $model->openid;
         $row['nickname'] = $model->user->nickname;
         $staff = MStaff::findOne(['gh_id' => $model->gh_id, 'scene_id' => $model->user->scene_pid]);
         if ($staff->cat == 0) {
             $row['scene_pid_name'] = empty($staff->name) ? '' : $staff->name;
             $row['scene_pid_office'] = empty($staff->office->title) ? '' : $staff->office->title;
             $row['scene_pid_cat'] = '内部员工';
         } else {
             $row['scene_pid_name'] = empty($staff->name) ? '' : $staff->name;
             $row['scene_pid_office'] = '-';
             $row['scene_pid_cat'] = '-';
         }
         //$row['user_account_charge_mobile'] = $model->user->user_account_charge_mobile;
         if (empty($model->user)) {
             //return '';
             $row['user_account_charge_mobile'] = '';
         } else {
             $mobiles = $model->user->getBindMobileNumbers();
             //return empty($mobiles) ? '' : implode(',', $mobiles);
             $row['user_account_charge_mobile'] = empty($mobiles) ? '' : implode(',', $mobiles);
         }
         $row['create_time'] = $model->create_time;
         if ($model->status == 0) {
             $row['status'] = '有效';
         } else {
             $row['status'] = '无效';
         }
         $rows[] = $row;
     }
     $data = $rows;
     $filename = Yii::$app->getRuntimePath() . '/heatmaps.csv';
     $csv = new \app\models\ECSVExport($data);
     $attributes = ['openid', 'nickname', 'scene_pid_name', 'scene_pid_office', 'scene_pid_cat', 'user_account_charge_mobile', 'create_time', 'status'];
     $csv->setInclude($attributes);
     $csv->setHeaders(['openid' => 'openid', 'nickname' => '昵称', 'scene_pid_name' => '粉丝来源', 'scene_pid_office' => '粉丝来源所属部门', 'scene_pid_cat' => '粉丝来源类别', 'user_account_charge_mobile' => '手机号码', 'create_time' => '创建时间', 'status' => '是否有效']);
     $csv->toCSV($filename);
     Yii::$app->response->sendFile($filename);
     return;
 }
예제 #5
0
 protected function findStaffModel($id)
 {
     if (($model = MStaff::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #6
0
 public function actionClientOrder($gh_id, $openid, $backwards = true, $pop = false)
 {
     if (!$backwards) {
         \app\models\utils\BrowserHistory::delete($gh_id, $openid);
         \app\models\utils\BrowserHistory::push($gh_id, $openid);
     } else {
         if ($pop) {
             \app\models\utils\BrowserHistory::pop($gh_id, $openid);
         } else {
             \app\models\utils\BrowserHistory::push($gh_id, $openid);
         }
     }
     $wx_user = \app\models\MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
     $this->layout = false;
     $office_id = $_GET['office_id'];
     $office = MOffice::findOne(['office_id' => $office_id]);
     $staff_id = $_GET['staff_id'];
     $staff = MStaff::findOne(['staff_id' => $staff_id]);
     $oid = $_GET['oid'];
     $order = MOrder::findOne(['oid' => $oid]);
     return $this->render('client-order', ['wx_user' => $wx_user, 'backwards' => $backwards, 'office' => $office, 'staff' => $staff, 'order' => $order]);
 }
예제 #7
0
 public function actionSelfopStaffUpdate($filename = 'staff_20150819.csv')
 {
     $file = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'imported_data' . DIRECTORY_SEPARATOR . $filename;
     $fh = fopen($file, "r");
     $i = 1;
     while (!feof($fh)) {
         $line = fgets($fh);
         $i++;
         if (empty($line)) {
             continue;
         }
         $fields = explode(",", $line);
         $office_title = trim($fields[3]);
         $office_title_utf8 = iconv('GBK', 'UTF-8//IGNORE', $office_title);
         $staff_name = trim($fields[4]);
         $staff_name_utf8 = iconv('GBK', 'UTF-8//IGNORE', $staff_name);
         $staff_role = trim($fields[5]);
         $staff_role_utf8 = iconv('GBK', 'UTF-8//IGNORE', $staff_role);
         if ($staff_role_utf8 == '营业厅经理') {
             $is_manager = 1;
         } else {
             $is_manager = 0;
         }
         $office = MOffice::findOne(['title' => $office_title_utf8]);
         echo $office->office_id . "," . $office->title . "," . $office_title_utf8 . "," . $staff_name_utf8 . "," . $staff_role_utf8 . "," . $is_manager . "\n";
         $staff = MStaff::findOne(['name' => $staff_name_utf8]);
         if (!empty($staff)) {
             $staff->office_id = $office->office_id;
             $staff->is_manager = $is_manager;
             $staff->cat = 0;
             $staff->save(false);
         }
     }
     fclose($fh);
     echo "staff data(20150819) update ok\n";
 }
예제 #8
0
 public function actionFsgl1()
 {
     //$this->layout = 'wap';
     $this->layout = false;
     //    $gh_id = U::getSessionParam('gh_id');
     //    $openid = U::getSessionParam('openid');
     $staff_id = $_GET['staff_id'];
     $staff = MStaff::findOne(['staff_id' => $staff_id]);
     $office = $staff->office;
     return $this->render('fsgl1', ['office' => $office, 'staff' => $staff]);
 }
예제 #9
0
파일: index.php 프로젝트: noikiy/wowewe
                        
                        <span class="caption-helper">
                            员工会员推广
                        </span>
                    </div>
                    <div class="actions">
                        <a href="javascript:;" class="btn btn-sm btn-circle btn-default" id="member-promotion-download">
                        <i class="fa fa-download"></i> 下载 </a>
                    </div>
                </div>
                <div class="portlet-body">
                     <ul class="feeds" id="member-promotion-top-list">
                        <?php 
$rows = \app\models\MUser::getMemberPromotionTopList(0, 20);
foreach ($rows as $row) {
    $staff = \app\models\MStaff::findOne(['scene_id' => $row['scene_pid']]);
    $employee = $staff->clientEmployee;
    ?>
                        <li>
                                <div class="col1">
                                        <div class="cont">
                                                <div class="cont-col1">
                                                        <div>
                                                            <img style="width:32px;height:32px" src="<?php 
    echo $staff->user->headImgUrl;
    ?>
" />          
                                                        </div>
                                                </div>
                                                <div class="cont-col2">
                                                        <div class="desc">
예제 #10
0
파일: index.php 프로젝트: noikiy/wowewe
?>
<div class="heat-map-index">
    <p>
        <?php 
echo Html::a('下载 <span class="glyphicon glyphicon-arrow-down"></span>', ['heatmapsdownload'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['label' => '微信昵称', 'value' => function ($model, $key, $index, $column) {
    return empty($model->user) ? '' : $model->user->nickname;
}], ['label' => '粉丝来源', 'value' => function ($model, $key, $index, $column) {
    if (empty($model->user->scene_pid)) {
        return '';
    }
    $staff = MStaff::findOne(['gh_id' => $model->gh_id, 'scene_id' => $model->user->scene_pid]);
    if (empty($staff)) {
        return '';
    }
    if ($staff->cat == 0) {
        return empty($staff->name) ? '' : $staff->name . '-' . $staff->office->title . '-' . '内部员工';
    } else {
        return empty($staff->name) ? '' : $staff->name;
    }
}], ['label' => '手机号', 'value' => function ($model, $key, $index, $column) {
    if (empty($model->user)) {
        return '';
    }
    $mobiles = $model->user->getBindMobileNumbers();
    return empty($mobiles) ? '' : implode(',', $mobiles);
}], 'lon', 'lat', 'speed_up', 'speed_down', 'create_time', ['label' => '图片大小', 'value' => function ($model, $key, $index, $column) {
예제 #11
0
파일: MUser.php 프로젝트: noikiy/wowewe
 public function getBelongTo()
 {
     if ($this->scene_pid == 0) {
         return 0;
     }
     $staff = MStaff::findOne(['gh_id' => $this->gh_id, 'scene_id' => $this->scene_pid]);
     if (empty($staff)) {
         return 0;
     }
     if ($staff->cat == MStaff::SCENE_CAT_OFFICE || $staff->cat == MStaff::SCENE_CAT_IN) {
         return $staff->office_id;
     }
     $wx_user = $staff->user;
     if (empty($wx_user)) {
         return 0;
     }
     if ($wx_user->scene_pid == $staff->scene_id) {
         return 0;
     }
     //        if ($wx_user->belongto)
     return $wx_user->belongto;
     //        return $wx_user->getBelongTo();
 }
예제 #12
0
파일: MOffice.php 프로젝트: noikiy/wowewe
 public function getOfficeStaff()
 {
     return MStaff::findOne(['office_id' => $this->office_id, 'cat' => MStaff::SCENE_CAT_OFFICE]);
 }