public function search($params)
 {
     $query = \app\models\MUser::find()->join('INNER JOIN', 'wx_openid_bind_mobile', 'wx_openid_bind_mobile.gh_id = wx_user.gh_id and wx_openid_bind_mobile.openid = wx_user.openid')->where(['wx_user.subscribe' => 1])->orderBy(['wx_user.create_time' => SORT_DESC]);
     $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if (!empty($this->page)) {
         $dataProvider->pagination->page = $this->page;
     }
     if (!empty($this->searchStr)) {
         $query->andWhere(['or', ['like', 'wx_user.nickname', $this->searchStr], ['like', 'wx_openid_bind_mobile.mobile', $this->searchStr]]);
     }
     $this->addCondition($query, 'nickname', true);
     if (!empty($this->gh_id)) {
         $query->andWhere(['wx_user.gh_id' => $this->gh_id]);
     }
     if (!empty($this->office_id)) {
         $query->andWhere(['wx_user.belongto' => $this->office_id]);
     }
     $query->andFilterWhere(['like', 'wx_openid_bind_mobile.mobile', $this->mobile]);
     if (trim($this->create_time_start) !== '') {
         $query->andWhere('date(wx_user.create_time)>=:create_time', [':create_time' => $this->create_time_start]);
     }
     if (trim($this->create_time_end) !== '') {
         $query->andWhere('date(wx_user.create_time)<=:create_time_2', [':create_time_2' => $this->create_time_end]);
     }
     return $dataProvider;
 }
Beispiel #2
0
 public function search($params)
 {
     $query = MChannel::find();
     // method #1
     //        $query->with('fans');
     // method #2
     //        $query->with(['fans'=>function($query) { $query->andWhere('subscribe=1'); }]);
     // method #3
     $subQuery = MUser::find()->select('gh_id as gh_id_x, scene_pid as scene_pid_x, count(*) as fans_cnt')->where('scene_pid!=0')->groupBy(['gh_id', 'scene_pid']);
     $query->leftJoin(['wx_user' => $subQuery], 'gh_id=gh_id_x AND scene_id = scene_pid_x');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => [], 'attributes' => ['title', 'mobile', 'fansCount' => ['asc' => ['wx_user.fans_cnt' => SORT_ASC], 'desc' => ['wx_user.fans_cnt' => SORT_DESC]]]], 'pagination' => ['pageSize' => 20]]);
     /*        
             if (Yii::$app->user->identity->gh_id == 'root')
                  throw new NotFoundHttpException("Please selected one gh_id for the root first!");
             else if (Yii::$app->user->identity->openid == 'admin')
             {
                 $this->gh_id = Yii::$app->user->identity->gh_id;
                 $this->addCondition($query, 'gh_id');        
             }
     */
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->addCondition($query, 'id');
     $this->addCondition($query, 'title', true);
     $this->addCondition($query, 'mobile', true);
     $query->andFilterWhere(['wx_user.fans_cnt' => $this->fansCount]);
     return $dataProvider;
 }
 /**
  * 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]);
 }
Beispiel #4
0
 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;
 }
Beispiel #5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MUser::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'role' => $this->role, 'usertype' => $this->usertype]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'mobile', $this->mobile])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
Beispiel #6
0
 public function afterSave($insert, $changedAttributes)
 {
     // \Yii::warning('yjhu:'.__METHOD__);
     // \Yii::warning(\yii\helpers\Json::encode($this));
     if (1 == $this->receiver_type) {
         $wechat = \Yii::$app->user->getWechat();
         //   \Yii::warning(\yii\helpers\Json::encode($wechat));
         $articles = [['title' => $this->title, 'description' => $this->digest, 'url' => \yii\helpers\Url::to(['wapx/messageboxdetail', 'msg_id' => $this->msg_id], true), 'picurl' => self::PICURL]];
         $receivers = MUser::getValidRecvFans($this->receiver);
         // \Yii::warning(\yii\helpers\Json::encode($receivers));
         foreach ($receivers as $recvr) {
             //                $wechat->WxMessageCustomSendNews($recvr->openid, $articles);
             $ret = $wechat->WxMessageCustomSendNews(MGh::GH_XIANGYANGUNICOM_OPENID_KZENG, $articles);
             //  \Yii::warning(\yii\helpers\Json::encode($ret));
         }
     }
     parent::afterSave($insert, $changedAttributes);
 }
Beispiel #7
0
 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;
 }
Beispiel #8
0
 public function actionSceneId()
 {
     $sql = 'select scene_id, count(*) as c from wx_staff where scene_id != 0 group by scene_id having c > 1 order by c desc';
     $rows = \Yii::$app->db->createCommand($sql)->queryAll();
     foreach ($rows as $row) {
         //            echo $row['scene_id'] . ': ' . $row['c'] . PHP_EOL;
         $staffs = MStaff::findAll(['scene_id' => $row['scene_id']]);
         $cat_staffs = [];
         foreach ($staffs as $staff) {
             $cat_staffs[$staff->cat][] = $staff;
         }
         $cat_staffs['individual'] = [];
         if (!empty($cat_staffs[MStaff::SCENE_CAT_IN])) {
             $cat_staffs['individual'] = array_merge($cat_staffs['individual'], $cat_staffs[MStaff::SCENE_CAT_IN]);
         }
         if (!empty($cat_staffs[MStaff::SCENE_CAT_OUT])) {
             $cat_staffs['individual'] = array_merge($cat_staffs['individual'], $cat_staffs[MStaff::SCENE_CAT_OUT]);
         }
         if (!empty($cat_staffs[MStaff::SCENE_CAT_FAN])) {
             $cat_staffs['individual'] = array_merge($cat_staffs['individual'], $cat_staffs[MStaff::SCENE_CAT_FAN]);
         }
         $first = null;
         foreach ($cat_staffs['individual'] as $individual_staff) {
             if (null === $first) {
                 $first = $individual_staff;
                 continue;
             }
             if ($individual_staff->openid == $first->openid) {
                 echo "duplicate staff! " . $individual_staff->openid . ' ' . $individual_staff->name . PHP_EOL;
                 $individual_staff->delete();
             }
         }
         if (empty($cat_staffs[MStaff::SCENE_CAT_OFFICE])) {
         } else {
             if (count($cat_staffs[MStaff::SCENE_CAT_OFFICE]) > 1) {
                 $all_offices = [];
                 $first = null;
                 foreach ($cat_staffs[MStaff::SCENE_CAT_OFFICE] as $cat_staff) {
                     echo $cat_staff->scene_id . $cat_staff->name . PHP_EOL;
                     if (null === $first) {
                         $first = $cat_staff;
                         $all_offices[] = $first;
                         continue;
                     }
                     if ($cat_staff->office_id == $first->office_id) {
                         echo "duplicate staff! " . $cat_staff->office_id . ' ' . $cat_staff->name . PHP_EOL;
                         $cat_staff->delete();
                     } else {
                         $cat_staff->scene_id = MStaff::newSceneId($cat_staff->gh_id);
                         $cat_staff->save(false);
                         echo 'change OFFICE sceneid: ' . $cat_staff->name . ' ' . $first->scene_id . ' -> ' . $cat_staff->scene_id . PHP_EOL;
                         $all_offices[] = $cat_staff;
                     }
                 }
                 $musers = MUser::findAll(['scene_pid' => $first->scene_id]);
                 foreach ($musers as $muser) {
                     $cnt = count($all_offices);
                     $index = rand(0, $cnt - 1);
                     echo 'change USER belongto: ' . $muser->nickname . ' ' . $muser->belongto . ' -> ' . $all_offices[$index]->office_id . PHP_EOL;
                     $muser->belongto = $all_offices[$index]->office_id;
                     $muser->scene_pid = $all_offices[$index]->scene_id;
                     $muser->save(false);
                 }
             } else {
                 $cat_staff = $cat_staffs[MStaff::SCENE_CAT_OFFICE][0];
                 echo $cat_staff->scene_id . $cat_staff->name . PHP_EOL;
                 $musers = MUser::findAll(['scene_pid' => $cat_staff->scene_id]);
                 foreach ($musers as $muser) {
                     echo 'change USER belongto: ' . $muser->nickname . ' ' . $muser->belongto . ' -> ' . $cat_staff->office_id . PHP_EOL;
                     $muser->belongto = $cat_staff->office_id;
                     $muser->save(false);
                 }
             }
             foreach ($cat_staffs['individual'] as $individual_staff) {
                 $individual_staff->scene_id = MStaff::newSceneId($individual_staff->gh_id);
                 $individual_staff->save(false);
                 echo 'change INDIVIDUAL sceneid: ' . $individual_staff->name . ' ' . $cat_staff->scene_id . ' -> ' . $individual_staff->scene_id . PHP_EOL;
             }
         }
     }
 }
Beispiel #9
0
    echo \app\models\MOrder::getOfficeOrderInfoCount($outlet->original_office_id);
    ?>
                    <?php 
}
?>
                    </span>
                    门店订单
                </a>
            </li>
            <li class="table-view-cell">
                <a class="navigate-right" data-ignore="push" href="<?php 
echo \yii\helpers\Url::to(['client-wechat-fan-list', 'gh_id' => $wx_user->gh_id, 'openid' => $wx_user->openid, 'backwards' => true, 'ClientWechatFanSearch' => ['gh_id' => $wx_user->gh_id, 'office_id' => $outlet->original_office_id]]);
?>
">
                    <span class="badge badge-primary"><?php 
echo \app\models\MUser::getBoundWechatFanCount($wx_user->gh_id, $outlet->original_office_id);
?>
</span>
                    门店发展用户
                </a>
            </li>
            <li class="table-view-cell">
                <a class="navigate-right" data-ignore="push" href="<?php 
echo \yii\helpers\Url::to(['client-customer-list', 'gh_id' => $wx_user->gh_id, 'openid' => $wx_user->openid, 'backwards' => true, 'ClientCustomerSearch' => ['gh_id' => $wx_user->gh_id, 'office_id' => $outlet->original_office_id]]);
?>
">
                    <span class="badge badge-primary"><?php 
echo \app\models\Custom::getBoundCustomerCount($wx_user->gh_id, $outlet->original_office_id);
?>
</span>
                    门店存量用户
Beispiel #10
0
 public function getFanBoundCount()
 {
     return MUser::find()->joinWith('openidBindMobiles')->where(['wx_user.gh_id' => $this->gh_id, 'scene_pid' => $this->scene_id, 'subscribe' => 1])->andWhere(['not', ['wx_openid_bind_mobile.mobile' => '']])->count();
 }
Beispiel #11
0
 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]);
 }
Beispiel #12
0
 public function getWechat()
 {
     return \app\models\MUser::find()->join('INNER JOIN', 'wx_openid_bind_mobile', 'wx_user.gh_id = wx_openid_bind_mobile.gh_id and wx_user.openid = wx_openid_bind_mobile.openid')->where(['in', 'wx_openid_bind_mobile.mobile', $this->mobiles])->andWhere(['subscribe' => 1])->one();
 }
Beispiel #13
0
 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);
 }
Beispiel #14
0
 public function getFan()
 {
     return $this->hasOne(MUser::className(), ['gh_id' => 'newfan_ghid', 'openid' => 'newfan_openid']);
 }
Beispiel #15
0
                                                <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>
Beispiel #16
0
 public function getClaimer()
 {
     return $this->hasOne(MUser::className(), ['gh_id' => 'claimer_ghid', 'openid' => 'claimer_openid']);
 }
Beispiel #17
0
 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());
         }
     }
 }
Beispiel #18
0
 public function getUser()
 {
     return $this->hasOne(MUser::className(), ['gh_id' => 'ToUserName', 'openid' => 'FromUserName']);
 }
Beispiel #19
0
 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]);
 }
Beispiel #20
0
 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;
 }
Beispiel #21
0
        ?>
                    <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);
Beispiel #22
0
 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']);
 }
Beispiel #23
0
            <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 
Beispiel #24
0
 public function getUser()
 {
     $model = MUser::findOne(['gh_id' => $this->gh_id, 'openid' => $this->openid]);
     return $model;
 }
Beispiel #25
0
 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;
     }
 }
Beispiel #26
0
 public function actionClientUserView($id)
 {
     $user = MUser::findOne(['id' => $id]);
     return $this->render('clientUserView', ['model' => $user]);
 }
Beispiel #27
0
 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;
 }
Beispiel #28
0
 public function getScore()
 {
     if ($this->scene_id == 0) {
         $count = 0;
     } else {
         $count = MUser::find()->where(['gh_id' => $this->gh_id, 'scene_pid' => $this->scene_id, 'subscribe' => 1])->count();
     }
     return $count;
 }
Beispiel #29
0
    <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>
Beispiel #30
0
            <?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