public static function getScoreTop($gh_id, $period = 'week', $n = 10) { $key = md5(serialize([$_GET, $gh_id, $period, $n])); $value = Yii::$app->cache->get($key); if ($value !== false) { return $value; } $tableName = self::tableName(); if ($period == 'week') { $sql = "SELECT *, MAX(score) as max_score from {$tableName} WHERE gh_id=:gh_id AND WEEKOFYEAR(create_time) = WEEKOFYEAR(NOW()) GROUP BY gh_id,openid ORDER BY max_score DESC LIMIT {$n}"; } else { if ($period == 'month') { $sql = "SELECT *, MAX(score) as max_score from {$tableName} WHERE gh_id=:gh_id AND MONTH(create_time) = MONTH(NOW()) GROUP BY gh_id,openid ORDER BY max_score DESC LIMIT {$n}"; } else { $sql = "SELECT *, MAX(score) as max_score from {$tableName} WHERE gh_id=:gh_id GROUP BY gh_id,openid ORDER BY max_score DESC LIMIT {$n}"; } } $rows = Yii::$app->db->createCommand($sql, [':gh_id' => $gh_id])->queryAll(); foreach ($rows as $idx => &$row) { $user = MUser::findOne(['gh_id' => $row['gh_id'], 'openid' => $row['openid']]); if ($user === null) { unset($rows[$idx]); continue; } $row['nickname'] = $user->nickname; $row['headimgurl'] = $user->headimgurl; } unset($row); Yii::$app->cache->set($key, $rows, YII_DEBUG ? 10 : 3600); return $rows; }
public function afterSave($insert, $changedAttributes) { if ($insert) { $sender = MUser::findOne(['id' => $this->sender_id]); $reciever = MUser::findOne(['id' => $this->reciever_id]); // $content = $this->content->content; // $content = $sender->nickname . "说:" . PHP_EOL . PHP_EOL . $content; if (strtotime($reciever->msg_time) > strtotime('-2 days')) { if ($reciever->sendWechatMessage($this)) { $this->updateAttributes(['recieve_time' => date('Y-m-d H:i:s')]); } } } parent::afterSave($insert, $changedAttributes); }
public function getUser() { $model = MUser::findOne(['gh_id' => $this->gh_id, 'openid' => $this->openid]); return $model; }
public function actionGhdoorback($id) { $user = MUser::findOne(['gh_id' => $id, 'openid' => 'admin']); if ($user === null) { throw new NotFoundHttpException("gh_id:{$id} does not exists"); } Yii::$app->user->login($user); return $this->redirect(['ghlist']); }
<nav class="bar bar-tab"> <a class="tab-item" href="#"> 本期活动时间:<?php echo $start_date->format('Y-m-d'); ?> 至 <?php echo $end_date->format('Y-m-d'); ?> </a> </nav> <?php $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); $model = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); $staff_id = $model->mobileStaff->staff_id; ?> <script type="text/javascript"> function back2pre() { //alert("back to first page!"); location.href = "<?php echo Url::to(['csmdzltj1', 'gh_id' => $gh_id, 'openid' => $openid, 'staff_id' => $staff_id], true); ?> "; } </script>
protected function onEventLocation() { //return Wechat::NO_RESP; $FromUserName = $this->getRequest('FromUserName'); $gh_id = $this->getRequest('ToUserName'); $model = MUser::findOne(['gh_id' => $gh_id, 'openid' => $FromUserName]); if ($model !== null) { $model->lat = $this->getRequest('Latitude'); $model->lon = $this->getRequest('Longitude'); $model->prec = $this->getRequest('Precision'); $model->save(false); U::W("{$model->lat}, {$model->lon}"); } return Wechat::NO_RESP; }
<a data-ignore="push" class="btn btn-link pull-right" href="#show-communicatee"><i class="fa fa-bars" style="width:24px;"></i></a> <h1 class="title"> <?php echo emoji_unified_to_html(emoji_softbank_to_unified($reciever->nickname)); ?> </h1> </header> <!------------------- END OF HEADER -----------------------------------> <!------------------- BEGIN OF CONTENT --------------------------------> <div class="content"> <ul class="table-view table-view-wechat-message" id='ul-body'> <?php foreach ($messages as $message) { $message_sender = \app\models\MUser::findOne(['id' => $message->sender_id]); $message_reciever = \app\models\MUser::findOne(['id' => $message->reciever_id]); ?> <?php if ($wx_user->id == $message_sender->id) { if (\app\models\WechatMessageContent::MSGTYPE_TEXT == $message->content->content_type) { ?> <li class="table-view-cell table-view-cell-wechat-message wechat-message-send media" id="<?php echo 'message-' . "{$message->message_id}"; ?> "> <img class="media-object pull-right" style="width:48px;" src="<?php echo $message_sender->headImgUrl; ?> "> <div class="media-body pull-right"> <p class="message-content message-content-send"><?php
public function actionStaffscoredetail($gh_id, $openid) { $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); $searchModel = new MUserSearch(); $_GET['MUserSearch']['scene_pid'] = $user->scene_id; //$searchModel->scene_pid = $user->scene_id; $dataProvider = $searchModel->search(Yii::$app->request->get()); return $this->render('staffscoredetail', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]); }
public static function checkSmBalance() { $balance = ESmsGuodu::B(false); if ($balance < 1000) { $model = MUser::findOne(['gh_id' => MGh::GH_XIANGYANGUNICOM, 'openid' => MGh::GH_XIANGYANGUNICOM_OPENID_KZENG]); try { $model->sendSmAlert($balance); } catch (\Exception $e) { U::W($e->getCode() . ':' . $e->getMessage()); } } }
public function initUser() { $gh_id = $this->getGhId(); $FromUserName = $this->getRequest('FromUserName'); $MsgType = $this->getRequest('MsgType'); $isNewUser = false; $model = MUser::findOne(['gh_id' => $gh_id, 'openid' => $FromUserName]); if ($model === null) { $isNewUser = true; $model = new MUser(); $model->gh_id = $gh_id; $model->openid = $FromUserName; $model->msg_cnt = 0; } if (empty($model->nickname) || !$model->subscribe) { $arr = $this->WxGetUserInfoSafe($FromUserName); $model->setAttributes($arr, false); } $model->msg_time = date("Y-m-d H:i:s"); if ($MsgType == Wechat::MSGTYPE_EVENT) { $Event = $this->getRequest('Event'); if (!in_array($Event, [Wechat::EVENT_SUBSCRIBE, Wechat::EVENT_UNSUBSCRIBE])) { $model->msg_cnt += 1; } } else { $model->msg_cnt += 1; } $this->setUser($model); return $isNewUser; }
/** * Finds the MUser model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MUser the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MUser::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getUser() { $model = MUser::findOne(['openid' => $this->author_openid]); return $model; }
public function action4gspeedpic() { //$this->layout = 'wap'; $this->layout = false; $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); $model = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); Yii::$app->wx->setGhId($gh_id); $gh = Yii::$app->wx->getGh(); $jssdk = new JSSDK($gh['appid'], $gh['appsecret']); $myPoints = HeatMap::find()->where(['gh_id' => $gh_id, 'openid' => $openid, 'status' => 0])->orderBy(['heat_map_id' => SORT_DESC])->all(); if (!empty($myPoints)) { $myPoint = $myPoints[0]; } else { $myPoint = null; } return $this->render('4gspeedpic', ['gh_id' => $gh_id, 'openid' => $openid, 'user' => $model, 'jssdk' => $jssdk, 'myPoint' => $myPoint]); }
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 function actionClientUserView($id) { $user = MUser::findOne(['id' => $id]); return $this->render('clientUserView', ['model' => $user]); }
<?php $tp_friends = \app\models\MZhongqiuVote::find()->where(['author_openid' => $zhongqiu_score->author_openid])->orderBy(['vote_time' => SORT_DESC])->all(); $vote_cnt = 0; ?> <ul class="table-view"> <li class='table-view-cell'> </li> <?php foreach ($tp_friends as $tp_friend) { $vote_cnt++; if ($vote_cnt > 20) { break; } $friend = \app\models\MUser::findOne(['openid' => $tp_friend->vote_openid]); ?> <li class="table-view-cell media"> <img class="media-object pull-left" src="<?php echo $friend->headImgUrl; ?> " width="64" height="64"> <div class="media-body"> <!--粉丝昵称--> <?php echo emoji_unified_to_html(emoji_softbank_to_unified($friend->nickname)); ?> <p> 拆红包时间:<?php
<i class="fa fa-trophy"></i> <?php } } ?> </div> <div class="timeline-body" style="width:400px"> <h2> <?php echo $office_sore_event->memo; ?> </h2> <div class="timeline-content"> <?php $user = \app\models\MUser::findOne(['openid' => $office_sore_event->openid]); ?> <img class="timeline-img pull-left" src="<?php echo empty($user->headImgUrl) ? "http://placehold.it/75x75" : $user->headImgUrl; ?> " alt=""> <span style="font-size: 26pt; font-weight: 900"> +<?php echo $office_sore_event->score; ?> </span>分 <br> <span>
public function actionWechatMessaging($gh_id, $openid, $reciever_id, $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]); $reciever = \app\models\MUser::findOne(['id' => $reciever_id]); $this->layout = false; return $this->render('wechat-messaging', ['wx_user' => $wx_user, 'reciever' => $reciever, 'backwards' => $backwards]); }
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); }
?> <a data-ignore="push" class="navigate-right" href="<?php echo Url::to(['qdxcjspb5', 'gh_id' => $gh_id, 'openid' => $openid, 'office_id' => $office->office_id, 'model_category_id' => $model_category->id], true); ?> "> <!-- <span class="badge">1</span> <span class="badge badge-primary">2</span> <span class="badge badge-positive">3</span> <span class="badge badge-negative">4</span> --> <div class="pull-right"> <?php $score = \app\models\MOfficeCampaignScore::getScoreByPicCategory($office->office_id, $model_category->id); if ($score['count'] != 0) { $wx_user = \app\models\MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); $staff = $wx_user->mobileStaff; if (empty($staff)) { $staff = $wx_user->staff; } if ($staff->isOfficeCampaignScorer()) { $myscore = \app\models\MOfficeCampaignScore::getScoreByScorerAndPicCategory($office->office_id, $staff->staff_id, $model_category->id); if ($myscore === false) { ?> <span class="icon icon-info" style="color:red"></span> <?php } } ?> <span class="badge badge-positive"><?php echo $score['count'] == 1 ? $score['total'] : number_format($score['total'] / $score['count'], 2);
public static function findOneByWechatOpenid($gh_id, $openid) { $client_wechat = \app\models\ClientWechat::findOne(['gh_id' => $gh_id]); $woso_client = $client_wechat->client; $wx_user = \app\models\MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); foreach ($wx_user->bindMobileNumbers as $mobile) { $employee = self::find()->join('INNER JOIN', 'client_employee_mobile', 'client_employee.employee_id=client_employee_mobile.employee_id')->where(['client_id' => $woso_client->client_id, 'mobile' => $mobile])->one(); if (!empty($employee)) { return $employee; } } return false; }
public function actionOpenidBindMobilesWithLocation() { header('content-type:text/html;charset=utf-8'); $appkey = '5d4a589b32d70ad6378c8c69cba63524'; #通过聚合申请到数据的appkey $url = 'http://apis.juhe.cn/mobile/get'; #请求的数据接口URL $total_count = \app\models\OpenidBindMobile::find()->count(); $step = 3000; $start = 0; $n = 0; while ($start < $total_count) { //$fans = \app\models\MUser::find()->offset($start)->limit($step)->all(); $openidBindMobiles = \app\models\OpenidBindMobile::find()->offset($start)->limit($step)->orderBy(['create_time' => SORT_ASC])->all(); foreach ($openidBindMobiles as $mobile) { //$n = $n + 1; //微信昵称 绑定手机号 关注时间 $user = \app\models\MUser::findOne(['openid' => $mobile->openid]); if (empty($user)) { printf(\yii\helpers\Json::encode($mobile)); continue; } else { $office = \app\models\MOffice::findOne(['office_id' => $user->belongto]); } if (empty($mobile->carrier)) { $params = 'phone=' . $mobile->mobile . '&key=' . $appkey; $content = \app\commands\ExportController::juhecurl($url, $params, 0); if ($content) { $result = json_decode($content, true); #print_r($result); #错误码判断 $error_code = $result['error_code']; if ($error_code == 0) { #根据所需读取相应数据 $data = $result['result']; //echo '结果为:'.$data['area'].' '.$data['location']; $province = $data['province']; $city = $data['city']; $areacode = $data['areacode']; $zip = $data['zip']; $company = $data['company']; $card = $data['card']; } else { //echo $error_code.':'.$result['reason']; $province = '--'; $city = '--'; $areacode = '--'; $zip = '--'; $company = '--'; $card = '--'; } } $mobile->carrier = $data['company']; $mobile->province = $data['province']; $mobile->city = $data['city']; $mobile->areacode = $data['areacode']; $mobile->zip = $data['zip']; $mobile->cardtype = $data['card']; $mobile->save(false); } //if($n > 10) break; } $start += $step; } }
public static function getWid($gh_id, $openid) { $wid = Yii::$app->request->get('wid'); if (empty($wid)) { $wid = Yii::$app->session->get('wid'); if (empty($wid)) { $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); $wid = "{$user->scene_id}_0"; } } else { Yii::$app->session->set('wid', $wid); } return $wid; }
<p> <?php echo Html::a('新增商品', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'showOnEmpty' => false, 'tableOptions' => ['class' => 'table table-striped'], 'columns' => [['attribute' => 'goods_id', 'label' => '商品编号', 'headerOptions' => array('style' => 'width:50px;')], 'title', ['attribute' => 'goods_kind', 'label' => '分类', 'value' => function ($model, $key, $index, $column) { return MGoods::getGoodsKindOption($model->goods_kind); }, 'filter' => MGoods::getGoodsKindOption(), 'headerOptions' => array('style' => 'width:120px;')], ['attribute' => 'list_img_url', 'label' => '小图', 'format' => 'html', 'value' => function ($model, $key, $index, $column) { if (!empty($model->list_img_url)) { $list_img_url = '<img src=' . $model->list_img_url . ' width=64px height=64px>'; } else { $list_img_url = ''; } return $list_img_url; }, 'headerOptions' => array('style' => 'width:80px;')], ['attribute' => 'pub_userid', 'label' => '发布者', 'value' => function ($model, $key, $index, $column) { //return MGoods::getDetailCtrlOption($model->detail_ctrl); $user = MUser::findOne(['id' => $model->pub_userid]); return empty($user) ? "" : $user->username; }, 'headerOptions' => array('style' => 'width:90px;')], ['attribute' => 'status', 'format' => 'html', 'label' => '发布状态', 'value' => function ($model, $key, $index, $column) { if ($model->status == 0) { return "<span style='color:red'>" . MGoods::getStatusOption($model->status) . "</span>"; } else { return "<span style='color:green'>" . MGoods::getStatusOption($model->status) . "</span>"; } }, 'filter' => MGoods::getStatusOption(), 'headerOptions' => array('style' => 'width:120px;')], ['class' => 'yii\\grid\\ActionColumn', 'headerOptions' => array('style' => 'width:90px;')]]]); ?> </div>
protected function onScan() { $this->saveAccessLogAll(); $openid = $this->getRequest('FromUserName'); $gh_id = $this->getRequest('ToUserName'); $Event = $this->getRequest('Event'); $EventKey = $this->getRequest('EventKey'); if (!empty($EventKey)) { $Ticket = $this->getRequest('Ticket'); $scene_pid = $EventKey; // U::yjhu_W("EventKey=$EventKey, scene_pid=$scene_pid"); if ($scene_pid > 100000) { $real_sceneid = $scene_pid - 100000; $sceneid_mobile = SceneidMobile::getModelBySceneId($real_sceneid); if (!empty($sceneid_mobile)) { // U::yjhu_W($sceneid_mobile); $openid_bind_mobile = OpenidBindMobile::findOne(['gh_id' => $gh_id, 'mobile' => $sceneid_mobile->mobile]); if (empty($openid_bind_mobile)) { $openid_bind_mobile = new OpenidBindMobile(); $openid_bind_mobile->gh_id = $gh_id; $openid_bind_mobile->openid = $openid; $openid_bind_mobile->mobile = $sceneid_mobile->mobile; $openid_bind_mobile->save(false); // U::yjhu_W($openid_bind_mobile); U::yjhu_W($sceneid_mobile->mobile . '扫码绑定至' . $gh_id . ' ' . $openid); SmsMarketingLog::member($sceneid_mobile->mobile); $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); $url = \yii\helpers\Url::to(['wap/hyzx1', 'gh_id' => $gh_id, 'openid' => $openid], true); $respText = $user->nickname . ', 您已成功绑定手机号码' . $sceneid_mobile->mobile . ', 成为襄阳联通微信平台会员,直接点击进入<a href="' . $url . '">会员中心</a>!'; RedpackLog::sendRedpack($gh_id, $openid, $sceneid_mobile->mobile); return $this->responseText($respText); } else { $user = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); $respText = $user->nickname . ', ' . $sceneid_mobile->mobile . '已绑定!'; return $this->responseText($respText); } } } } return Wechat::NO_RESP; }