public static function getOfficeNameOptionAll($gh_id, $json = true, $need_prompt = true) { $offices = \app\models\MOffice::find()->where("gh_id = :gh_id", [':gh_id' => $gh_id])->asArray()->orderBy(['title' => SORT_ASC])->all(); $listData = $need_prompt ? ['0' => '全部'] : []; foreach ($offices as $office) { $value = $office['office_id']; $text = $office['title']; $listData[$value] = $text; } return $json ? json_encode($listData) : $listData; }
public function getUser() { if ($this->_user === false) { /* //$this->_user = MUser::findByUsername($this->username); if ($this->username == 'root') $this->_user = MUser::findOne(['gh_id'=>$this->username, 'openid' => $this->username]); else if ($this->username == 'admin') $this->_user = MUser::findOne(['gh_id'=>$this->gh_id, 'openid' => $this->username]); else $this->_user = MUser::findOne(['gh_id'=>$this->gh_id, 'nickname' => $this->username]); */ $this->_user = MOffice::findByUsername($this->username); } return $this->_user; }
public function search($params) { $query = MUser::find(); $query->joinWith('openidBindMobiles'); // $query->select('*'); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); $this->gh_id = Yii::$app->user->getGhid(); $this->addCondition($query, 'wx_user.gh_id'); if (!Yii::$app->user->getIsAdmin()) { $office = Yii::$app->user->identity; $scene_ids = $office->getSceneids(); $query->andWhere(['scene_pid' => $scene_ids]); } $query->andWhere(['subscribe' => 1]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $this->addCondition($query, 'id'); $this->addCondition($query, 'nickname', true); $this->addCondition($query, 'status'); $this->addCondition($query, 'update_time'); $this->addCondition($query, 'scene_pid'); $this->addCondition($query, 'is_liantongstaff'); $query->andFilterWhere(['like', 'wx_openid_bind_mobile.mobile', $this->mobile]); if (!empty($this->office_id)) { $office = MOffice::findOne($this->office_id); if (!empty($office)) { $query->andFilterWhere(['scene_pid' => $office->getSceneids()]); } } if (trim($this->create_time) !== '') { $query->andWhere('date(wx_user.create_time)>=:create_time', [':create_time' => $this->create_time]); } if (trim($this->create_time_2) !== '') { $query->andWhere('date(wx_user.create_time)<=:create_time_2', [':create_time_2' => $this->create_time_2]); } return $dataProvider; }
public function search($params) { $query = MOffice::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['office_id' => SORT_ASC]], 'pagination' => ['pageSize' => 20]]); $this->gh_id = Yii::$app->user->getGhid(); $this->addCondition($query, 'gh_id'); if (!($this->load($params) && $this->validate())) { return $dataProvider; } if (!Yii::$app->user->getIsAdmin()) { $this->office_id = Yii::$app->user->identity->office_id; $this->addCondition($query, 'office_id'); } else { $this->addCondition($query, 'office_id'); } $this->addCondition($query, 'title', true); $this->addCondition($query, 'mobile', true); $this->addCondition($query, 'address', true); $this->addCondition($query, 'manager', true); $this->addCondition($query, 'visable'); $this->addCondition($query, 'is_jingxiaoshang'); return $dataProvider; }
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); }
public function actionProfile() { $user = MOffice::findOne(Yii::$app->user->id); // if (is_numeric(Yii::$app->user->identity->openid)) // $office = MOffice::findOne(Yii::$app->user->identity->openid); if ($user->load(Yii::$app->request->post())) { if ($user->save(false, ['pswd'])) { Yii::$app->session->setFlash('success', '设置成功!'); return $this->refresh(); } else { U::W($user->getErrors()); } } return $this->render('profile', ['model' => $user]); }
public function actionMetronic($office_id = 0) { $this->layout = 'metronic'; if (\Yii::$app->user->isAdmin) { if (0 !== $office_id) { $office = \app\models\MOffice::findOne(['office_id' => $office_id]); } else { $office = null; } } else { if (\Yii::$app->user->isOffice) { $office = \Yii::$app->user->identity; } } return $this->render('blank', ['target_office' => $office]); }
public function actionOrder($filename = 'order.csv', $date = null) { $filepathname = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'exported_data' . DIRECTORY_SEPARATOR . $filename; $fh = fopen($filepathname, 'w'); if (null === $date) { $date = \app\models\U::getFirstDate(date('Y'), date('m')); } $total_count = \app\models\MOrder::find()->where(['>', 'create_time', $date])->count(); //$total_count = \app\models\MUser::find()->count(); $step = 300; $start = 0; while ($start < $total_count) { $orders = \app\models\MOrder::find()->offset($start)->limit($step)->where(['>', 'create_time', $date])->orderBy(['create_time' => SORT_ASC])->all(); fprintf($fh, "营业厅, 订单号, 商品, 价格, 订单时间, 身份证, 用户姓名, 联系电话, 支付方式, 订单状态, 开通, 备注, 用户类型\n"); foreach ($orders as $order) { $office = \app\models\MOffice::findOne(['office_id' => $order->office_id]); if (!empty($office)) { $office_title = $office->title; } else { $office_title = ""; } $user = \app\models\MUser::findOne(['openid' => $order->openid]); $customerFlag = '--'; /* if ($user->bindMobileIsInside('wx_t1')) { $customerFlag = '老'; } elseif ($user->bindMobileIsInside('wx_t2')) { $customerFlag = '老'; }elseif ($user->bindMobileIsInside('wx_t3')) { $customerFlag = '老'; } else { $customerFlag = '新'; } */ if ($user->bindMobileIsInside('wx_oldcustomer')) { $customerFlag = '老'; } else { $customerFlag = '新'; } $pay_kind = \app\models\MOrder::getOrderPayKindOption($order->pay_kind); $price = $order->feesum / 100; $paystatus = \app\models\MOrder::getOrderStatusName($order->status); //echo $office_title."\t".$order->oid."\t".$order->title."\t".$price."\t".$order->create_time."\t".$order->userid."\t".$order->username."\t".$order->usermobile."\t".$pay_kind."\t".$order->memo."\t".$order->customerFlag."\t\n"; fprintf($fh, "%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", $office_title, $order->oid, $order->title, $price, $order->create_time, $order->userid, $order->username, $order->usermobile, $pay_kind, $paystatus, $order->kaitong, $order->memo, $order->customerFlag); } $start += $step; } fclose($fh); }
public static function closeExpiredOrders() { $tableName = MOrder::tableName(); $n = Yii::$app->db->createCommand()->delete($tableName, 'status=:status AND create_time < DATE_SUB(NOW(), INTERVAL 2 day)', [':status' => MOrder::STATUS_DRAFT])->execute(); U::W("UPDATE {$tableName}, {$n} --- 系统删除2天前的僵死订单。"); // auto close the orders exceed 2 days $n = Yii::$app->db->createCommand()->update($tableName, ['status' => MOrder::STATUS_SYSTEM_CLOSED], 'status=:status AND create_time < DATE_SUB(NOW(), INTERVAL 2 day)', [':status' => MOrder::STATUS_SUBMITTED])->execute(); U::W("UPDATE {$tableName}, {$n} --- 系统自动关闭超时2天的提交订单。"); $n = Yii::$app->db->createCommand()->update($tableName, ['status' => MOrder::STATUS_SYSTEM_SUCCEEDED], 'status=:status AND create_time < DATE_SUB(NOW(), INTERVAL 2 day)', [':status' => MOrder::STATUS_FULFILLED])->execute(); U::W("UPDATE {$tableName}, {$n} --- 系统自动确认超时2天的已办理订单。"); //找到超时2天的成功订单, 将其归属的渠道 +积分100 $orders = MOrder::find()->where(['status' => MOrder::STATUS_FULFILLED])->andWhere(['<', 'create_time', 'DATE_SUB(NOW(), INTERVAL 2 day)'])->all(); foreach ($orders as $order) { $user = MUser::findOne(['openid' => $order->openid]); $office = MOffice::findOne(['office_id' => $user->belongto]); if ($office->is_selfOperated == 0) { //wx_office_score_event 增加一条记录 $offce_score_event = new MOfficeScoreEvent(); $offce_score_event->gh_id = $order->gh_id; $offce_score_event->openid = $order->openid; $offce_score_event->office_id = $user->belongto; $offce_score_event->cat = MOfficeScoreEvent::CAT_ADD_ORDER; $offce_score_event->create_time = date('y-m-d h:i:s', time()); $offce_score_event->score = MOfficeScoreEvent::CAT_ADD_ORDER_SCORE; $offce_score_event->memo = '会员订单'; $offce_score_event->save(false); //wx_office表中对应渠道score 加100分 $office->score = $office->score + 100; $office->save(false); } } /* //move the unsuccessful orders exceed 90 days to bak table $n = Yii::$app->db->createCommand("INSERT INTO {$tableName}_arc SELECT * FROM $tableName WHERE status!=:status AND create_time < DATE_SUB(NOW(), INTERVAL 90 day)", [':status'=>MOrder::STATUS_OK])->execute(); U::W("INSERT $tableName, $n"); $n = Yii::$app->db->createCommand("DELETE FROM $tableName WHERE status!=:status AND create_time < DATE_SUB(NOW(), INTERVAL 90 day)", [':status'=>MOrder::STATUS_OK])->execute(); U::W("DELETE $tableName, $n"); */ //release mobile number $tableName = MMobnum::tableName(); $n = Yii::$app->db->createCommand()->update($tableName, ['status' => MMobnum::STATUS_UNUSED, 'locktime' => 0], 'status=:status AND locktime < :locktime', [':status' => MMobnum::STATUS_LOCKED, ':locktime' => time() - 2 * 24 * 3600])->execute(); U::W("UPDATE {$tableName}, {$n}"); $n = Yii::$app->db->createCommand("DELETE FROM {$tableName} WHERE status=:status", [':status' => MMobnum::STATUS_USED])->execute(); U::W("DELETE {$tableName}, {$n}"); }
public static function confirmAjax($office_id, $cat) { $office = MOffice::findOne(['office_id' => $office_id]); if (empty($office)) { $score = 0; } else { $score = $office->score; } if ($cat == self::CAT_30YUAN_DAIJINJUAN) { $dh_score = self::CAT_30YUAN_DAIJINJUAN_SCORE; } else { if ($cat == self::CAT_100YUAN_DAIJINJUAN) { $dh_score = self::CAT_100YUAN_DAIJINJUAN_SCORE; } else { $dh_score = self::CAT_30YUAN_DAIJINJUAN_SCORE; } } if ($score < $dh_score) { U::W("----------score not enough--------"); return \yii\helpers\Json::encode(['code' => 1]); } else { $office_score_event = new MOfficeScoreEvent(); $office_score_event->gh_id = 'gh_03a74ac96138'; $office_score_event->openid = ''; $office_score_event->office_id = $office_id; $office_score_event->cat = $cat; $office_score_event->score = $dh_score; $office_score_event->memo = self::getCatNameOption($cat); $office_score_event->status = 0; $office_score_event->code = ''; $office_score_event->create_time = date('y-m-d h:i:s', time()); $office_score_event->save(false); $office = MOffice::findOne(['office_id' => $office_id]); $office->score = $office->score - $dh_score; $office->save(false); } return \yii\helpers\Json::encode(['code' => 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); } } }
<?php echo $this->render('header2', ['menuId' => 'menu4', 'title' => '流量宝 流量套餐']); ?> <div data-role="content"> <img src="../web/show_res/llb-head.jpg?v3" width="100%"> <p>流量宝 流量套餐</p> <div class="ui-field-contain"> <input type="text" name="username" id="username" placeholder="姓名" data-mini=false value=""> <input type="tel" name="usermobile" id="usermobile" placeholder="手机号码" value=""> <?php echo Html::dropDownList('office', 0, MOffice::getOfficeNameOption($gh_id, false), ["id" => "office"]); ?> </div> <a href="#" id="submitBtn" class="ui-btn" style="background-color: #44B549">我要办理</a> </div> <div data-role="footer" data-position="fixed"> <h4>© 襄阳联通 2015</h4> </div> <div data-role="popup" id="popupDialog-contactPage" data-overlay-theme="c" data-theme="c" data-dismissible="false" style="max-width:400px;"> <div data-role="header" data-theme="c"> <h1>温馨提示</h1>
<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, 'options' => ['class' => 'table-responsive'], 'tableOptions' => ['class' => 'table table-striped'], 'columns' => [['attribute' => 'name', 'format' => 'html', 'value' => function ($model, $key, $index, $column) { if ($model->is_manager) { return (empty($model->name) ? '' : $model->name) . " <img src='/wx/web/images/wxmpres/man_blue.png' title='营业厅主管'>"; } else { return empty($model->name) ? '' : $model->name; } }, 'headerOptions' => array('style' => 'width:10%;')], ['label' => '部门编号', 'attribute' => 'office_id', 'headerOptions' => array('style' => 'width:100px;'), 'filter' => false, 'visible' => false], ['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:20%;'), 'visible' => Yii::$app->user->getIsAdmin()], ['attribute' => 'mobile', 'headerOptions' => array('style' => 'width:10%;')], ['label' => '微信信息', 'format' => 'html', 'value' => function ($model, $key, $index, $column) { //return ''; if (empty($model->openid)) { //$wxbind_info = "微信未绑定"; 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'> <span style='color:#aaa'>昵称 " . $model->user->nickname . "<br> 地区 " . $model->user->country . " " . $model->user->province . " " . $model->user->city . "<br> 绑定手机 " . $mobile . "</span>"; } else { return "<img style='float:left;' width=48 src=" . $model->user->headimgurl . "> <span style='color:#aaa'>昵称 " . $model->user->nickname . "<br> 地区 " . $model->user->country . " " . $model->user->province . " " . $model->user->city . "<br> 绑定手机 " . $mobile . "</span>"; } } }, 'headerOptions' => array('style' => 'width:24%;')], ['attribute' => 'scene_id', 'visible' => false], ['attribute' => 'cat', 'value' => function ($model, $key, $index, $column) { return MStaff::getStaffCatOptionName($model->cat);
</h1> --> <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>
protected function findOfficeModel($id) { if (($model = MOffice::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function getScore($office_id, $date = null) { $pic_categories = MOfficeCampaignPicCategory::find()->all(); $office = \app\models\MOffice::findOne(['office_id' => $office_id]); $total = 0; foreach ($pic_categories as $pic_category) { if (!$office->is_selfOperated && $pic_category->sort_order == 6) { continue; } $scores = self::getScoreByPicCategory($office_id, $pic_category->id, $date); if ($scores['count'] == 0) { return false; } $total += $scores['count'] == 1 ? $scores['total'] : $scores['total'] / $scores['count']; } return $total; }
<input type="radio" name="cardType" id="radio1_1" value="1" /> <label for="radio1_1">Micro卡</label> <input type="radio" name="cardType" id="radio1_2" value="2" /> <label for="radio1_2">Nano卡</label> </fieldset> </div> <img width="100%" style="display:block" src="../web/images/item/card.jpg" alt=""/> <a id="sel-num" href="#number-select" class="ui-btn">请选择手机号码</a> <a id="contact" href="#contactPage" class="ui-btn">用户信息</a> <div id="officeArea"> <?php echo Html::dropDownList('office', 0, MOffice::getOfficeNameOption($gh_id, false)); ?> </div> <input type="button" value="一键购买" id="submitBtn"> <br> <div id="TabbedPanels2" class="TabbedPanels"> <ul class="TabbedPanelsTabGroup"> <li class="TabbedPanelsTab" tabindex="0">图文详情</li> <!-- <li class="TabbedPanelsTab" tabindex="0">商品评价</li> --> </ul> <div class="TabbedPanelsContentGroup"> <div class="TabbedPanelsContent">
public function getOffices() { return $this->hasMany(MOffice::className(), ['office_id' => 'office_id'])->viaTable('wx_rel_office_msc', ['msc_id' => 'id']); }
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'> <span style='color:#aaa'>昵称 " . $model->user->nickname . "<br> 地区 " . $model->user->country . " " . $model->user->province . " " . $model->user->city . "<br> 绑定手机 " . $mobile . "</span>"; } else { return "<img style='float:left;' width=48 src=" . $model->user->headimgurl . "> <span style='color:#aaa'>昵称 " . $model->user->nickname . "<br> 地区 " . $model->user->country . " " . $model->user->province . " " . $model->user->city . "<br> 绑定手机 " . $mobile . "</span>"; } } }, 'attribute' => 'is_bind', 'filter' => ['1' => '绑定', '0' => '未绑定']], ['label' => '关注时间', 'attribute' => 'subscribe_time_start', 'value' => function ($model, $key, $index, $column) { return empty($model->openidBindMobile->user) ? '' : $model->openidBindMobile->user->create_time; }, 'filterType' => \kartik\grid\GridView::FILTER_DATE, 'format' => 'raw', 'filterWidgetOptions' => ['type' => \kartik\widgets\DatePicker::TYPE_RANGE, 'attribute2' => 'subscribe_time_end', 'pluginOptions' => ['format' => 'yyyy-mm-dd', 'language' => 'zh-CN']]], ['label' => '部门名称', 'attribute' => 'office_id', 'value' => function ($model, $key, $index, $column) { return empty($model->office->title) ? '' : $model->office->title; }, 'filter' => \yii\helpers\ArrayHelper::merge(['0' => '非营业厅'], MOffice::getOfficeNameOptionSimple2('gh_03a74ac96138', false, false)), 'visible' => Yii::$app->user->getIsAdmin()], ['attribute' => 'is_vip', 'format' => 'html', 'value' => function ($model, $key, $index, $column) { return $model->isVip() ? "是" : "否"; }, 'filter' => ['0' => '否', '1' => '是']]]]); ?> </div> </div> </div> </div> </div>
public function actionAddbindmobile($gh_id, $openid) { $this->layout = 'wap'; $model = new OpenidBindMobile(); $model->gh_id = $gh_id; $model->openid = $openid; $model->setScenario('bind_mobile'); if ($model->load(Yii::$app->request->post()) && $model->save()) { //非自营厅渠道新增会员时,+积分100 $user = MUser::findOne(['openid' => $openid]); $office = MOffice::findOne(['office_id' => $user->belongto]); if (!empty($office)) { if ($office->is_selfOperated == 0) { //wx_office_score_event 增加一条记录 $offce_score_event = new MOfficeScoreEvent(); $offce_score_event->gh_id = $gh_id; $offce_score_event->openid = $openid; $offce_score_event->office_id = $user->belongto; $offce_score_event->cat = MOfficeScoreEvent::CAT_ADD_NEW_MEMBER; $offce_score_event->create_time = date('y-m-d h:i:s', time()); $offce_score_event->score = MOfficeScoreEvent::CAT_ADD_NEW_MEMBER_SCORE; $offce_score_event->memo = '新增会员'; $offce_score_event->save(false); //wx_office表中对应渠道score 加100分 $office->score = $office->score + 100; $office->save(false); } } Yii::$app->wx->setGhId($gh_id); $url = Url::to(['hyzx1', 'gh_id' => $gh_id, 'openid' => $openid], true); Yii::$app->wx->WxTemplateSend(Wechat::getTemplateBindSuccessNotify($openid, $url, "{$model->user->nickname},您的手机号码已成功绑定襄阳联通官方微信营业厅", "您已成为襄阳联通的会员,可随时查询话费余额,办理业务,参与更多专享优惠!", $model->mobile, date('Y-m-d'))); $url = Yii::$app->getSession()->get('RETURN_URL'); if (!empty($url)) { return $this->redirect($url); } else { Yii::$app->session->setFlash('success', '恭喜您,会员注册成功!'); return $this->refresh(); } } $searchModel = new OpenidBindMobileSearch(); $searchModel->gh_id = $gh_id; $searchModel->openid = $openid; $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('addbindmobile', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'model' => $model]); }
public function getQrImageUrl2() { $gh_id = $this->gh_id; if (empty($this->scene_id)) { // hbhe if (yii::$app->mutex->acquire(MStaff::SCENE_LOCK, MStaff::SCENE_LOCK_WAIT_TIME_SECOND)) { $this->scene_id = MStaff::newSceneId($this->gh_id); $this->save(false); //yii::$app->mutex->release($lock); yii::$app->mutex->release(MStaff::SCENE_LOCK); } else { yii::error('acquire lock error'); } } $scene_id = $this->scene_id; $office_id = $this->office_id; $office = MOffice::findOne(['office_id' => $office_id]); $office_title = $office->title; //$log_file_path = Yii::$app->getRuntimePath().DIRECTORY_SEPARATOR.'qr'.DIRECTORY_SEPARATOR."{$gh_id}_{$scene_id}.jpg"; $log_file_path = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'qr-all-offices' . DIRECTORY_SEPARATOR . "{$scene_id}_{$office_title}.jpg"; if (!file_exists($log_file_path) || filesize($log_file_path) == 0) { Yii::$app->wx->setGhId($gh_id); $arr = Yii::$app->wx->WxgetQRCode($scene_id, true); $url = Yii::$app->wx->WxGetQRUrl($arr['ticket']); Wechat::downloadFile($url, $log_file_path); } //$url = Yii::$app->getRequest()->baseUrl."/../runtime/qr/{$gh_id}_{$scene_id}.jpg"; //return $url; }
<h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('新增消息', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['msg_id', 'title', 'digest', 'author', ['attribute' => 'receiver_type', 'value' => function ($model, $key, $index, $column) { return Messagebox::getReceiverTypeOptionName($model->receiver_type); }, 'filter' => Messagebox::getReceiverTypeOptionName()], ['attribute' => 'receiver', 'value' => function ($model, $key, $index, $column) { $office = MOffice::findOne(['office_id' => $model->receiver]); if ($model->receiver_type == 0) { /*经销商*/ return '--'; } else { return $office->title; } }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
public function getOffice() { return $this->hasOne(MOffice::className(), ['office_id' => 'office_id']); }
public function getOffices() { return $this->hasMany(MOffice::className(), ['gh_id' => 'gh_id']); }
public function actionOfficewb($filename = 'office-wb.csv') { //$xyunicom = \app\models\WosoClient::findOne(['title_abbrev' => '襄阳联通']); //if (empty($xyunicom)) die('不能找到襄阳联通。'); //gh_id,branch,region,title,address,manager,member_cnt,mobile //$filepathname = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . $filename; $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; } //襄阳,樊城,襄阳市城区家客樊东网格逐日电子,李孔恒,13177226622 $fields = explode(",", $line); $branch = trim($fields[0]); $branch_utf8 = iconv('GBK', 'UTF-8//IGNORE', $branch); $region = trim($fields[1]); $region_utf8 = iconv('GBK', 'UTF-8//IGNORE', $region); $title = trim($fields[2]); $title_utf8 = iconv('GBK', 'UTF-8//IGNORE', $title); $manager = trim($fields[3]); $manager_utf8 = iconv('GBK', 'UTF-8//IGNORE', $manager); $mobile = trim($fields[4]); $mobile_utf8 = iconv('GBK', 'UTF-8//IGNORE', $mobile); $office = MOffice::findOne(['title' => $title_utf8]); if (empty($office)) { echo $title_utf8 . "\t\t" . "insert ... \n"; $office = new MOffice(); $office->gh_id = \app\models\MGh::GH_XIANGYANGUNICOM; // 襄阳联通公共ID $office->branch = $branch_utf8; $office->region = $region_utf8; $office->title = $title_utf8; $office->manager = $manager_utf8; $office->mobile = $mobile_utf8; $office->save(false); } else { echo $title_utf8 . "\t\t" . "update ...\n"; $office->branch = $branch_utf8; $office->region = $region_utf8; $office->title = $title_utf8; $office->manager = $manager_utf8; $office->mobile = $mobile_utf8; $office->save(false); } //echo $branch_utf8."\t".$region_utf8."\t".$title_utf8."\t".$manager_utf8."\t".$mobile_utf8."\n"; } fclose($fh); echo "done\n"; }
<p></p> <?php $form = ActiveForm::begin(['id' => "{$basename}_form", 'method' => 'post', 'options' => ['class' => 'ui-corner-all', 'data' => ['ajax' => 'false']], 'fieldConfig' => ['options' => ['class' => 'ui-field-contain'], 'inputOptions' => [], 'labelOptions' => []]]); ?> <?php echo $form->field($model, 'mobile')->input('tel', ['maxlength' => 11, 'data' => ['clear-btn' => 'true'], 'placeholder' => '输入手机号', 'readonly' => true])->label('手机号:'); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => 24, 'data' => ['clear-btn' => 'true'], 'placeholder' => '员工姓名', 'required' => true])->label('姓名:'); ?> <?php echo $form->field($model, 'office_id')->dropDownList(MOffice::getOfficeNameOptionSimple1($model->gh_id, false, false), ['prompt' => '选择营业厅'])->label(false); ?> <div class="ui-field-contain"> <button type="submit" class="ui-shadow ui-btn ui-corner-all">将微信与员工信息进行绑定</button> </div> <?php ActiveForm::end(); ?> </div> <?php echo $this->render('footer', ['title' => "© 襄阳联通 " . date('Y')]); ?>
<//?= $form->field($model, 'score')->textInput() ?> <//?= $form->field($model, 'memo')->textInput(['maxlength' => 128]) ?> <//?= $form->field($model, 'code')->textInput(['maxlength' => 64]) ?> --> <!-- <//?= $form->field($model, 'status')->textInput() ?> --> <br><br> <?php $office = MOffice::findOne(["office_id" => $model->office_id]); if (empty($office)) { $title = "--"; } else { $title = $office->title; } echo "<h1>渠道名称: " . $title . "</h1>"; echo "<h3>代金卷: " . MOfficeScoreEvent::getCatNameOption($model->cat) . "</h3>"; echo "<h3>减积分: " . $model->score . "</h3>"; echo "<h3>时间: " . $model->create_time . "</h3>"; ?> <br> <?php echo $form->field($model, 'status')->dropDownList(MOfficeScoreEvent::getOseStatusOption());
if(localStorage.getItem("num") != null) { //alert(localStorage.getItem("num")); $("#sel-num")[0].innerHTML="选中号码 <span class='title_set_content'>"+localStorage.getItem("num")+"</span>"; //$("#sel-num").trigger('create'); $("#sel-num").removeClass("title_unset").addClass("title_set"); } if(localStorage.getItem("username") != null) { $("#contact")[0].innerHTML="用户信息 <span class='title_set_content'>"+localStorage.getItem("username")+"...</span>"; $("#contact").removeClass("title_unset").addClass("title_set"); } office_name = <?php echo \app\models\MOffice::getOfficeNameOption($gh_id); ?> ; if(localStorage.getItem("office") != null) { $("#officeName")[0].innerHTML="营业厅 <span class='title_set_content'>"+ office_name[localStorage.getItem("office")] +"...</span>"; $("#officeName").removeClass("title_unset").addClass("title_set"); } if(localStorage.getItem("address") != null) { $("#address")[0].innerHTML="收货地址 <span class='title_set_content'>"+localStorage.getItem("address")+"...</span>"; $("#address").removeClass("title_unset").addClass("title_set"); } });
public function actionOutlets() { $outlets = \app\models\ClientOutlet::find()->all(); foreach ($outlets as $outlet) { $office = \app\models\MOffice::find()->where(['title' => $outlet->title])->one(); if (!empty($office)) { echo "found {$outlet->title}" . PHP_EOL; $details = \app\models\MOfficeCampaignDetail::findAll(['office_id' => $office->office_id]); $pics = []; foreach ($details as $detail) { $pic_urls = explode(',', $detail->pic_url); foreach ($pic_urls as $pic_url) { $from = $detail->getPicFileByMedia($pic_url); $media = str_replace('.jpg', '', $pic_url); $to = $outlet->getPicPathname($media); copy($from, $to); $pics[] = $media; } } $outlet->pics = implode(",", $pics); $outlet->original_office_id = $office->office_id; $outlet->latitude = $office->lat; $outlet->longitude = $office->lon; $outlet->save(false); } } }
$this->params['breadcrumbs'][] = ['label' => '员工管理', 'url' => ['stafflist']]; $this->params['breadcrumbs'][] = $model->isNewRecord ? '新增' : '修改'; ?> <div class="muser-update"> <div class="muser-form"> <?php $form = ActiveForm::begin(); ?> <?php if (Yii::$app->user->getIsAdmin()) { ?> <?php echo $form->field($model, 'office_id')->dropDownList(MOffice::getOfficeNameOptionAll(Yii::$app->user->identity->gh_id, false, false)); ?> <?php } else { ?> <?php echo $form->field($model, 'office_id')->hiddenInput(['value' => Yii::$app->user->identity->office_id])->label(false); ?> <?php } ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => 24]); ?>