Esempio n. 1
0
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionMain()
 {
     // 判断是否微信跳转过来
     if (isset($_SESSION['code'])) {
         $_GET['code'] = $_SESSION['code'];
         $_SESSION['code'] = null;
     }
     $result = User::getInstance()->indexIsShowData(Cookie::getInstance()->getCookie('bhy_id'));
     setcookie('indexIsShowData', json_encode($result));
     if (!isset($_GET['code'])) {
         $user_id = Cookie::getInstance()->getCookie('bhy_id');
         if (empty($user_id)) {
             // 虚拟账号登陆
             $user = User::getInstance()->getUserById(10011);
             Cookie::getInstance()->setLoginCookie($user);
         } else {
             $user = User::getInstance()->getUserById($user_id);
         }
     } else {
         $user = $this->weChatMember();
     }
     if ($user['status'] > 2) {
         Cookie::getInstance()->delLoginCookie();
         if ($user['wx_id']) {
             setcookie('wx_login', 'out', time() + 3600 * 24 * 30, '/wap');
         }
     }
     return $this->render();
 }
Esempio n. 2
0
 /**
  * 发布约会
  * @param $data
  * @return bool
  */
 public function release($data)
 {
     if (isset($data['id']) && ($row = $this->findOne($data['id']))) {
         $row->theme = $data['theme'];
         $row->title = $data['title'];
         $row->content = $data['content'];
         $row->sex = $data['sex'];
         $row->destination = $data['destination'];
         $row->rendezvous_time = is_numeric($data['rendezvous_time']) ? $data['rendezvous_time'] : 0;
         $row->fee_des = $data['fee_des'];
         $row->we_want = $data['we_want'];
         $row->status = 1;
         return $row->save();
     } else {
         $this->user_id = Cookie::getInstance()->getCookie('bhy_id')->value;
         $this->create_time = time();
         $this->theme = $data['theme'];
         $this->title = $data['title'];
         $this->content = $data['content'];
         $this->sex = $data['sex'];
         $this->destination = $data['destination'];
         $this->rendezvous_time = is_numeric($data['rendezvous_time']) ? $data['rendezvous_time'] : 0;
         $this->fee_des = $data['fee_des'];
         $this->we_want = $data['we_want'];
         return $this->save();
     }
 }
Esempio n. 3
0
 public function actionQuickLogin()
 {
     // QQ登陆
     if ($this->get['t'] == 'qq' && isset($this->get['code']) && $this->get['code'] != '') {
         $qqUser = Qq::getInstance()->getUser($this->get['code']);
         if ($qqUser) {
             if (!($user = User::getInstance()->getUser(['username' => $qqUser['openId']]))) {
                 $user = ['username' => $qqUser['openId'], 'password' => $qqUser['openId'], 'login_type' => 2, 'sex' => $qqUser['sex']];
                 $user['id'] = User::getInstance()->addUser($user);
             }
         }
     } else {
         if ($this->get['t'] == 'weibo' && isset($this->get['code']) && $this->get['code'] != '') {
             $weiboUser = Weibo::getInstance()->getUser($this->get['code']);
             print_r($weiboUser);
             exit;
         }
     }
     \common\models\User::getInstance()->loginLog($user['id']);
     Cookie::getInstance()->setLoginCookie($user, '/qt');
     return $this->render();
 }
Esempio n. 4
0
 /**
  * 诚信认证图片上传
  */
 public function actionAuthPictures()
 {
     $user_id = Cookie::getInstance()->getCookie('bhy_id')->value;
     $data = $this->thumb();
     // 保存数据
     if (1 == $data['status']) {
         //删除旧图片
         if ($photo = UserPhoto::getInstance()->getPhotoList($user_id, $this->get['type'])) {
             $thumb_path = __DIR__ . "/../.." . $photo[0]['thumb_path'];
             if (is_file($thumb_path) && unlink($thumb_path)) {
                 $pic_path = str_replace('thumb', 'picture', $thumb_path);
                 unlink($pic_path);
             }
             $photo[0]['thumb_path'] = $data['thumb_path'];
             $photo[0]['pic_path'] = $data['pic_path'];
             $photo[0]['update_time'] = $data['time'];
             $photo[0]['is_check'] = 2;
             if (!UserPhoto::getInstance()->savePhoto($photo, $user_id, $photo[0]['type'])) {
                 $data = ['status' => -1, 'info' => '保存失败!~'];
             }
         } else {
             $photo['type'] = $this->get['type'];
             $photo['thumb_path'] = $data['thumb_path'];
             $photo['pic_path'] = $data['pic_path'];
             $photo['time'] = $data['time'];
             if (!UserPhoto::getInstance()->addPhoto($user_id, $photo)) {
                 $data = ['status' => -1, 'info' => '保存失败!~'];
             }
         }
     }
     $this->renderAjax($data);
 }
Esempio n. 5
0
 /**
  * 申请约会
  */
 public function actionAddApply()
 {
     $user_id = Cookie::getInstance()->getCookie('bhy_id')->value;
     $list = UserRendezvous::getInstance()->addApply($user_id, $this->get);
     $this->renderAjax(['status' => 1, 'data' => $list]);
 }
Esempio n. 6
0
 /**
  * 发送红包
  */
 public function actionSendBribery()
 {
     if (!$this->isLogin()) {
         // 未登录用户返回失败
         return $this->renderAjax(['status' => 0, 'message' => '用户未登录']);
     }
     $get = \Yii::$app->request->get();
     $sendId = $get['sendId'];
     $receiveId = $get['receiveId'];
     $money = (int) ($get['money'] * 100);
     $briMessage = isset($get['bri_message']) ? $get['bri_message'] : '';
     if (\common\util\Cookie::getInstance()->getCookie("bhy_id") != $sendId) {
         // 非自己登陆的账号
         return $this->renderAjax(['status' => -1, 'message' => '非法请求']);
     } else {
         if ($money < 1 || $money > 20000) {
             // 发送金额不符合要求
             return $this->renderAjax(['status' => -2, 'message' => '金额不对']);
         }
     }
     $userInfo = \wechat\models\User::getInstance()->getUserByName(\common\util\Cookie::getInstance()->getCookie('bhy_u_name'));
     if ($userInfo['balance'] < $money) {
         // 账户余额不够
         return $this->renderAjax(['status' => -3, 'message' => '余额不够']);
     }
     if ($id = UserMessage::getInstance()->sendBribery($sendId, $receiveId, $money, $briMessage)) {
         $this->renderAjax(['status' => 1, 'message' => json_encode(["id" => $id, "bri_message" => $briMessage, "money" => $money])]);
     } else {
         $this->renderAjax(['status' => 999, 'message' => '发送失败']);
     }
 }
Esempio n. 7
0
 public function actionProduceOrder()
 {
     /*if (isset($this->get['flag_h'])){  // 微信发红包数据
           $data = [
               'goodsId'=>8,
               'user_id'=>Cookie::getInstance()->getCookie('bhy_id')->value,
               'money'=>$this->get['money'],
               'chargeTypeId'=>5
           ];
       }else{
           $data = $this->get;
       }*/
     $data = $this->get;
     if (isset($data['goodsId'])) {
         $userId = Cookie::getInstance()->getCookie('bhy_id')->value;
         if (!$userId) {
             $this->renderAjax(['status' => -1, 'msg' => '用户未登录']);
         }
         if (isset($data['money'])) {
             if (intval($data['money']) < 1 || intval($data['money']) > 20000) {
                 $this->renderAjax(['status' => -2, 'msg' => '充值金额异常']);
             }
         }
         $orderId = ChargeOrder::getInstance()->createOrder($userId, $data);
         if ($orderId) {
             $this->renderAjax(['status' => 1, 'msg' => '下单成功', 'data' => $orderId]);
         } else {
             $this->renderAjax(['status' => 0, 'msg' => '下单失败']);
         }
     } else {
         $this->renderAjax(['status' => -2, 'msg' => '没有商品信息']);
     }
 }
Esempio n. 8
0
 /**
  * 退出登录
  * @return bool
  */
 public function loginOut()
 {
     Cookie::getInstance()->getCookie('bhy_id') ? Cookie::getInstance()->delCookie('bhy_id') : true;
     Cookie::getInstance()->getCookie('bhy_u_name') ? Cookie::getInstance()->delCookie('bhy_u_name') : true;
     return true;
 }
Esempio n. 9
0
 /**
  * 获取拉黑的总数
  */
 public function actionGetSumBlack()
 {
     $user_id = Cookie::getInstance()->getCookie('bhy_id')->value;
     $data = UserFollow::getInstance()->getSumFollow('black', $user_id);
     return $this->renderAjax(['status' => 1, 'data' => $data]);
 }
Esempio n. 10
0
 /**
  * 首页是否显示数据
  */
 public function actionIndexIsShowData()
 {
     $user_id = Cookie::getInstance()->getCookie('bhy_id');
     $result = User::getInstance()->indexIsShowData($user_id);
     $this->renderAjax($result);
 }
Esempio n. 11
0
 public function actionHonestyPhoto()
 {
     $user_id = isset($this->get['user_id']) ? $this->get['user_id'] : Cookie::getInstance()->getCookie('bhy_id')->value;
     $userInfo = UserInformation::getInstance()->getUserField($user_id, ['honesty_value']);
     if ($userInfo['honesty_value'] & 1) {
         $sfz = 1;
     } else {
         $sfz = UserPhoto::getInstance()->getPhotoList($user_id, 23, 2);
         if (count($sfz) == 2) {
             if ($sfz[0]['is_check'] == 1 && $sfz[1]['is_check'] == 1) {
                 $sfz = 1;
                 UserInformation::getInstance()->updateUserInfo($user_id, ['honesty_value' => $userInfo['honesty_value'] + 1]);
             } elseif ($sfz[0]['is_check'] == 0 || $sfz[1]['is_check'] == 0) {
                 $sfz = 0;
             } else {
                 $sfz = 2;
             }
         } else {
             $sfz = '';
         }
     }
     if (isset($this->get['user_id'])) {
         $this->renderAjax(['status' => 1, 'sfz' => $sfz, 'msg' => '获取成功']);
     } else {
         $marr = $userInfo['honesty_value'] & 2 ? 1 : $this->checkPhoto($user_id, 5, $userInfo['honesty_value']);
         $edu = $userInfo['honesty_value'] & 4 ? 1 : $this->checkPhoto($user_id, 4, $userInfo['honesty_value']);
         $housing = $userInfo['honesty_value'] & 8 ? 1 : $this->checkPhoto($user_id, 6, $userInfo['honesty_value']);
         $this->renderAjax(['status' => 1, 'sfz' => $sfz, 'marr' => $marr, 'edu' => $edu, 'housing' => $housing, 'msg' => '获取成功']);
     }
 }
Esempio n. 12
0
 /**
  * 根据动态ID获取动态内容
  * @param $id
  * @return array
  */
 public function getDynamicById($id)
 {
     $loginUserId = \common\util\Cookie::getInstance()->getCookie('bhy_id')->value;
     return (new Query())->from($this->tablePrefix . "user_dynamic d")->innerJoin($this->tablePrefix . 'user_information i', 'd.user_id=i.user_id')->innerJoin($this->tablePrefix . 'user u', 'd.user_id=u.id')->leftJoin($this->tablePrefix . 'user_click c', 'c.dynamic_id = d.id and c.user_id=' . $loginUserId)->leftJoin($this->tablePrefix . 'user_photo p', 'p.user_id = d.user_id AND p.is_head = 1')->where(['d.id' => $id])->select(["d.*", "u.phone", "i.honesty_value", "i.report_flag", "json_extract(i.info , '\$.level') AS level", "json_extract(i.info , '\$.head_pic') AS head_pic", "json_extract(i.info , '\$.real_name') AS real_name", "json_extract(i.info , '\$.age') AS age", 'u.sex', 'p.thumb_path AS thumb_path', 'p.is_check AS head_status', "c.id as cid"])->one();
 }
Esempio n. 13
0
 /**
  * 微信登录获取微信用户信息
  * @return array|bool
  */
 protected function weChatMember()
 {
     $code = \Yii::$app->request->get('code');
     if ($code == null) {
         return false;
     } else {
         setcookie('wx_login', 'login', time() + 3600 * 24 * 30, '/wap');
     }
     $memberInfo = \Yii::$app->wechat->getMemberByCode($code);
     // 从微信获取用户
     //        $memberInfo['openid'] = 'oEQpts_MMapxllPTfwRw0VfGeLSg'; // 测试
     $data = ['wx_id' => $memberInfo['openid'], 'username' => $memberInfo['openid'], 'password' => 'wx_xx', 'login_type' => 3, 'sex' => isset($memberInfo['sex']) && $memberInfo['sex'] == 2 ? 0 : 1];
     $user = User::getInstance()->getUser(['wx_id' => $data['wx_id']]);
     if (!$user) {
         // 用户不存在,虚拟账号登陆
         setcookie('wx_id', $data['wx_id'], time() + 3600 * 24 * 30, '/');
         $data['sex'] == 1 ? $user = User::getInstance()->getUserById(10011) : ($user = User::getInstance()->getUserById(10016));
     }
     // 登录日志
     \common\models\User::getInstance()->loginLog($user['id']);
     // 设置登录cookie
     Cookie::getInstance()->setLoginCookie($user);
     return $user;
 }