Beispiel #1
0
 /**
  * 验证邀请码
  */
 public function invitationCode($attribute, $params)
 {
     $model = UcenterMember::findOne(['invitation_code' => $this->invitation_code]);
     if (!$model) {
         $this->addError($attribute, Yii::t('app', '邀请码无效。'));
     }
 }
Beispiel #2
0
 /**
  * 判定用户手机号是否存在
  * @return bool
  */
 public function actionSmsphone()
 {
     $phone = $_POST['CellPhone'];
     $res = UcenterMember::findOne(['phone' => $phone]);
     if ($res) {
         return false;
         exit;
     } else {
         return true;
         exit;
     }
 }
Beispiel #3
0
 public function actionIndex()
 {
     $uid = Yii::$app->user->id;
     Utils::ensureOpenId();
     $openId = Yii::$app->request->get('open_id');
     if (($usermodel = UcenterMember::findOne(['openid' => $openId])) !== null) {
         Yii::$app->user->login($usermodel);
     } elseif (empty(Yii::$app->user->id)) {
         return $this->redirect(['site/signin']);
     }
     $isAuthentic = member::isAuthentic(yii::$app->user->id);
     if ($isAuthentic['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有实名制认证')</script>";
         echo "<script>window.location.href='" . \yii\helpers\Url::to(['site/step2']) . "'</script>";
         exit;
     }
     //判断用户是否绑定银行卡
     $is_bind = sinapay::isBinding($uid);
     $model = UcenterMember::find()->where(['id' => $uid])->one();
     if ($is_bind['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有绑定银行卡');</script>";
         echo "<script>location.href='" . \yii\helpers\Url::to(['site/bindcard']) . "'</script>";
         exit;
     }
     //全部记录
     $logs = AloneMethod::total_log($uid, 1, 15);
     $logs_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid])->andWhere(['>', 'status', '0'])->andWhere(['<>', 'step', '0.00'])->asArray()->all();
     $logs_pages = ceil(count($logs_pages) / 15);
     //$logs = Log::find()->select(['step','create_at','status'])->where(['member_id'=>$uid])->andWhere(['in','status',[1,2,3,4]])->orderBy('id desc')->asArray()->all();
     //充值
     $recharge = AloneMethod::recharge_log($uid, 1, 15);
     $recharge_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid, 'status' => Log::STATUS_RECHAR_SUC])->asArray()->all();
     $recharge_pages = ceil(count($recharge_pages) / 15);
     //投资
     $invest = AloneMethod::invest_log($uid, 1, 15);
     $invest_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid, 'status' => Log::STATUS_INVEST_SUC])->asArray()->all();
     $invest_pages = ceil(count($invest_pages) / 15);
     //赎回
     $ransom = AloneMethod::redeem_log($uid, 1, 15);
     $ransom_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid, 'status' => Log::STATUS_REDEM_SUC])->asArray()->all();
     $ransom_pages = ceil(count($recharge_pages) / 15);
     //提现
     $withdraw = AloneMethod::withdrawals_log($uid, 1, 15);
     $withdraw_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid, 'status' => Log::STATUS_WITHDRAW_SUC])->asArray()->all();
     $withdraw_pages = ceil(count($recharge_pages) / 15);
     return $this->view('index', compact('invest', 'recharge', 'withdraw', 'ransom', 'logs', 'logs_pages', 'recharge_pages', 'invest_pages', 'ransom_pages', 'withdraw_pages'));
 }
 public function actionLogout()
 {
     Utils::ensureOpenId();
     $request = Yii::$app->request;
     if ($request->isPost) {
         if (($model = UcenterMember::findOne(['openid' => $request->post('open_id')])) !== null) {
             /** @var MemberOther $model */
             $model->openid = '';
             $model->save();
         }
         Yii::$app->user->logout();
         return $this->goBack(['info' => "解绑成功"], Url::to(['site/signin']));
     }
     return $this->view('logout');
 }
Beispiel #5
0
 public function actionGindex()
 {
     Utils::ensureOpenId();
     $openId = Yii::$app->request->get('open_id');
     if (($usermodel = UcenterMember::findOne(['openid' => $openId])) !== null) {
         Yii::$app->user->login($usermodel);
     } elseif (empty(Yii::$app->user->id)) {
         return $this->redirect(['site/signin']);
     }
     $uid = yii::$app->user->id;
     $gold = Gold::find()->select('uid,sum(money) as smoney')->where(['uid' => $uid])->asArray()->one();
     $allgold = Gold::find()->select('uid,rid,sum(money) as smoney')->where(['uid' => $uid])->asArray()->groupBy('rid')->all();
     $invitation_code = UcenterMember::findIdentity($uid)->invitation_code;
     $goldincome = Income::find()->select('member_id,sum(goldincome) as sincome')->where(['member_id' => $uid])->asArray()->one();
     $jssdk = new Jssdk('wx32814d588c44c17c', '23b0f218574551f18db1dc991dbee87f');
     $signpack = $jssdk->getSignPackage();
     return $this->view('gindex', compact('gold', 'allgold', 'goldincome', 'invitation_code', 'signpack'));
 }
 /**
  * Finds the UcenterMember model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UcenterMember the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UcenterMember::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionDorepass()
 {
     $uid = Yii::$app->user->id;
     if ($_POST) {
         $member = member::changePassword($uid, $_POST['oldpass'], $_POST['password'], $_POST['repassword']);
         if ($member['errorNum'] == 1) {
             return $member['errorMsg'];
         } else {
             Utils::ensureOpenId();
             $openId = Yii::$app->request->get('open_id');
             if ($openId) {
                 $model = UcenterMember::findOne(['openid' => $openId]);
                 if ($model) {
                     $model->openid = '';
                     $model->save();
                 }
             }
             Yii::$app->user->logout();
             return '修改成功';
         }
     }
 }
 public function actionSetting()
 {
     if (\yii::$app->user->isGuest) {
         $this->redirect(['site/login']);
     }
     $uid = yii::$app->user->id;
     $is_Authentic = member::isAuthentic($uid);
     $model = UcenterMember::find()->where("id=" . $uid)->one();
     if (isset($_POST['prepassword']) && isset($_POST['newpassword']) && isset($_POST['repeatpassword'])) {
         $_model = UcenterMember::findIdentity($uid);
         if (!yii::$app->security->validatePassword($_POST['prepassword'], $_model->password_hash)) {
             echo '原始密码错误';
             exit;
         } elseif ($_POST['newpassword'] == $_POST['repeatpassword']) {
             $_model->password_hash = Yii::$app->security->generatePasswordHash($_POST['newpassword']);
             $app_pwd = md5(sha1($_POST['newpassword']) . time());
             $_model->app_pwd = $app_pwd;
             $_model->save(false);
             echo '密码修改成功';
             exit;
         } else {
             echo '两次密码不一致';
             exit;
         }
     }
     if (isset($_POST['realname']) && isset($_POST['idcard'])) {
         $realname = $_POST['realname'];
         $idcard = $_POST['idcard'];
         try {
             $idcard_result = Port::baiduIdentity($idcard);
             if (!$idcard) {
                 echo '身份认号不匹配,请核对后重新输入';
                 exit;
             }
         } catch (ErrorException $e) {
             echo '认证失败';
             exit;
         }
         try {
             $result = member::authentication($uid, $realname, $idcard);
             if ($result) {
                 echo '身份认证成功';
                 exit;
             }
         } catch (ErrorException $e) {
             echo $e->getMessage();
             exit;
         }
     }
     if (isset($_POST['UcenterMember']['person_face'])) {
         $model->person_face = UploadedFile::getInstance($model, 'person_face');
         if ($model->person_face) {
             if ($model->validate()) {
                 $old_face = UcenterMember::findOne(['id' => $uid])->person_face;
                 //旧头像
                 $init_face = Setting::findOne(['code' => 'img'])->value;
                 //初始头像
                 $Name = mt_rand(1100, 9900) . time() . '.' . $model->person_face->extension;
                 $model->person_face->saveAs('upload/' . $Name);
                 //保存头像名到数据表
                 $model->person_face = $Name;
                 if ($model->update()) {
                     //若不是初始头像,删除旧头像。
                     if ($old_face != $init_face) {
                         @unlink('../web/upload/' . $old_face);
                     }
                     header("Content-type: text/html; charset=utf-8");
                     echo '<script>alert("头像修改完成~");</script>';
                 }
             }
         }
     }
     $infos_rar = $this->Ucenter();
     //用户数据包
     return $this->render('setting', compact("infos_rar", "model", "model_password", "is_Authentic"));
 }
 /**
  * 推广大师活动
  * @return string
  */
 public function actionFestival20151015()
 {
     $invite_code = Yii::$app->request->get('code', '0');
     //活动期间利率调整TODO
     date_default_timezone_set('PRC');
     //活动开始时间
     $begin_time = strtotime('2015-10-15');
     //活动结束时间
     $end_time = strtotime('2016-1-16');
     //当前时间
     $now_time = time();
     if ($now_time > $end_time) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('活动已经过期')</script>";
         echo "<script>window.location.href='//www.huoqiwang.com'</script>";
     }
     //解析链接中的手机号
     $invite_phone = \frontend\actions\App\AloneMethod::decrypt($invite_code);
     //判定手机号的合法性
     $res = UcenterMember::findOne(['phone' => $invite_phone, 'username' => $invite_phone]);
     if ($res == null) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('来源链接不合法')</script>";
         echo "<script>window.location.href='//www.huoqiwang.com'</script>";
     }
     $invite_phone = substr($invite_phone, 0, 3) . '****' . substr($invite_phone, -4);
     if ($this->IsMobile()) {
         return $this->renderPartial('TheMasterM', compact("invite_phone"));
     } else {
         return $this->renderPartial('TheMasterM', compact("invite_phone"));
     }
 }
Beispiel #10
0
 public function actionLogout()
 {
     Utils::ensureOpenId();
     $openId = Yii::$app->request->get('open_id');
     if ($openId) {
         $model = UcenterMember::findOne(['openid' => $openId]);
         if ($model) {
             $model->openid = '';
             $model->save();
         }
     }
     Yii::$app->user->logout();
     return $this->redirect(['site/main']);
 }
Beispiel #11
0
 /**
  * 获取用户推荐关系列表
  * @param $uid
  * @param $page
  * @param $num
  * @return array|\yii\db\ActiveRecord[]
  */
 public static function get_recommend_relation($uid, $page = 1, $num = 10)
 {
     //获取推荐列表
     $page = ($page - 1) * $num;
     //一级推荐人列表
     $leval_one_list = UserRecommend::find()->select(['sender_phone', 'is_grant', 'sender_register_time', 'update_at', 'red_packet', 'red_packet_name'])->where(['owner_uid' => $uid, 'level' => 1])->orderBy('is_grant desc')->limit($num)->offset($page)->asArray()->all();
     //一级推荐人的总人数
     $leval_one_count = UserRecommend::find()->where(['owner_uid' => $uid, 'level' => 1])->count();
     //一级推荐人中,用户尚未领取的人数
     $leval_one_count_get_false = UserRecommend::find()->where(['owner_uid' => $uid, 'level' => 1, 'is_grant' => UserRecommend::GRANT_FALSE])->count();
     //一级推荐人中--用户尚未领取的红包总金额
     $leval_one_money_get_false = UserRecommend::find()->where(['owner_uid' => $uid, 'level' => 1, 'is_grant' => UserRecommend::GRANT_FALSE])->sum('red_packet');
     //推荐人--已经领取的人数
     $leval_one_count_get_true = UserRecommend::find()->where(['owner_uid' => $uid, 'level' => 1, 'is_grant' => UserRecommend::GRANT_TRUE])->count();
     //推荐人--已经领取的红包金额
     $leval_one_money_get_true = UserRecommend::find()->where(['owner_uid' => $uid, 'level' => 1, 'is_grant' => UserRecommend::GRANT_TRUE])->sum('red_packet');
     //二级推荐总的人数
     $leval_two_count = UserRecommend::find()->where(['owner_uid' => $uid, 'level' => 2])->count();
     //二级推荐人中,用户尚未领取的人数
     $leval_two_count_get_false = UserRecommend::find()->where(['owner_uid' => $uid, 'level' => 2, 'is_grant' => UserRecommend::GRANT_FALSE])->count();
     //二级推荐人中,用户尚未领取的红包总额度
     $leval_two_money_get_false = UserRecommend::find()->where(['owner_uid' => $uid, 'level' => 2, 'is_grant' => UserRecommend::GRANT_FALSE])->sum('red_packet');
     //二级推荐人中--已经领取的人数
     $leval_two_count_get_true = UserRecommend::find()->where(['owner_uid' => $uid, 'level' => 2, 'is_grant' => UserRecommend::GRANT_TRUE])->count();
     //二级推荐人中 --已经放到红包表里面了的红包总金额
     $leval_two_money_get_true = UserRecommend::find()->where(['owner_uid' => $uid, 'level' => 2, 'is_grant' => UserRecommend::GRANT_TRUE])->sum('red_packet');
     ///获取用户手机号
     $user_phone = '186****1725';
     $user = UcenterMember::findOne(['id' => $uid]);
     if ($user !== null) {
         $user_phone = $user->phone;
         $user_code = \frontend\actions\App\AloneMethod::encrypt($user_phone);
     }
     $user_phone = substr_replace($user_phone, '****', 3, 4);
     $data = array(array('level' => 1, 'people_sum' => $leval_one_count, 'get_num' => $leval_one_count_get_true, 'get_money' => $leval_one_money_get_true ? $leval_one_money_get_true : 0, 'not_get_num' => $leval_one_count_get_false, 'not_get_money' => $leval_one_money_get_false ? $leval_one_money_get_false : 0, 'people_list' => $leval_one_list), array('level' => 2, 'people_sum' => $leval_two_count, 'get_num' => $leval_two_count_get_true, 'get_money' => $leval_two_money_get_true ? $leval_two_money_get_true : 0, 'not_get_num' => $leval_two_count_get_false, 'not_get_money' => $leval_two_money_get_false ? $leval_two_money_get_false : 0, 'people_list' => null), 'share' => array('share_link' => 'https://www.huoqiwang.com/events/festival20151015?code=' . $user_code, 'share_title' => '活琪王壕送大礼啦!', 'share_info' => '您的朋友' . $user_phone . '给您送来了8888元大红包,快来看看吧~~~', 'share_logo' => 'http://static.huoqiwang.com/imgs/logo180180.png'));
     $return_array = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => $data);
     return $return_array;
 }
Beispiel #12
0
 public static function idcardIsAuthentic($idcard)
 {
     $member = UcenterMember::findOne(['idcard' => $idcard]);
     if ($member) {
         return true;
     } else {
         return false;
     }
 }
Beispiel #13
0
 /**
  *推广大师注册方法
  * @param $phone 手机号
  * @param $pwd  密码
  * @param $phone_code 手机验证码
  * @param $from 用户来源
  * @param string $invite_code 邀请码
  * @return array
  */
 public static function the_master_register($phone, $pwd, $phone_code, $invitation_id, $userIp = '')
 {
     $from = 1015;
     //开启推广大师
     $recommend_the_master = 1;
     //判定手机号是否注册
     $flag = self::phoneIsRegister($phone);
     if ($flag) {
         $return = array('errorNum' => '1', 'errorMsg' => '此手机号已注册,请直接登录', 'data' => null);
         return $return;
     } elseif (!preg_match('/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)[0-9a-zA-Z]{6,16}$/', $pwd)) {
         $return = array('errorNum' => '1', 'errorMsg' => '密码应该是数字、字母组成的6到16位字符', 'data' => null);
         return $return;
     }
     //邀请者id
     $user = UcenterMember::findOne(['id' => $invitation_id]);
     //不存在邀请者
     if ($user == null) {
         $return = array('errorNum' => '1', 'errorMsg' => '邀请者不存在', 'data' => null);
         return $return;
     }
     //手机短息验证码验证
     $check = Port::checkPhnoe($phone, $phone_code);
     $session_key = "";
     //生成app的密码
     $app_pwd = md5(sha1($pwd) . time());
     // 根据ip获取地区
     $area = self::get_area($userIp);
     $area = $area ? $area : '地球';
     if (!$check['errorNum']) {
         //事物回滚
         $transaction = \Yii::$app->db->beginTransaction();
         try {
             $user = new UcenterMember();
             $user->username = $phone;
             $user->phone = $phone;
             $user->setPassword(trim($pwd));
             $user->create_ip = $userIp;
             $user->create_area = $area;
             $user->create_channel = (int) $from;
             $user->invitation_code = self::random();
             $user->invitation_id = (int) $invitation_id;
             $user->status = UcenterMember::STATUS_ACTIVE;
             $user->lock = UcenterMember::TYPE_UNLOCK;
             //app密码设定
             $user->app_pwd = $app_pwd;
             ///
             $user->generateAuthKey();
             if ($user->save()) {
                 //生成邀请码
                 $new_uid = $user->id;
                 $invitation_code = 'v' . $new_uid * 99;
                 $user->invitation_code = $invitation_code;
                 $user->save();
                 //初始换用户账户
                 $asset_info = new Info();
                 $asset_info->member_id = $user['id'];
                 $asset_info->balance = 0;
                 $asset_info->freeze = 0;
                 if ($asset_info->save()) {
                     $uid = $user['id'];
                     if ($recommend_the_master) {
                         //推荐大师活动开启了
                         //用户注册--增加数据表
                         $produce = \frontend\actions\AloneMethod::produce_recommend($uid);
                         if ($produce['errorNum'] == '1') {
                             $return = array('errorNum' => '1', 'errorMsg' => '推荐大师活动错误', 'data' => null);
                             return $return;
                         }
                     }
                     //注册动作完成---进行登录操作
                     $log = new Log();
                     $log->member_id = $uid;
                     $log->login_ip = Yii::$app->request->userIp;
                     $log->login_time = time();
                     $log->login_area = $area;
                     $log->status = self::LOG_CONFIM;
                     $res = $log->save();
                     if ($res) {
                         $session_key = self::verification($uid) . '--' . $from;
                         $session = new Sessionkey();
                         $session->uid = $uid;
                         $session->sessionkey = $session_key;
                         $session->status = self::STATUS_ACTIVE;
                         $res = $session->save();
                         if ($res) {
                             $log->status = self::LOG_SUSSESS;
                             $log->save();
                             //新用户注册送体验金---区分推荐用户和非推荐用户
                             if ($invitation_id == 0) {
                                 //普通注册
                                 self::give_experience_gold(1, $user['id']);
                             } else {
                                 self::give_experience_gold(7, $user['id']);
                             }
                         } else {
                             $return = array('errorNum' => '1', 'errorMsg' => '登陆失败', 'data' => null);
                             return $return;
                         }
                     } else {
                         $return = array('errorNum' => '1', 'errorMsg' => '登陆记录失败', 'data' => null);
                         return $return;
                     }
                 } else {
                     $return = array('errorNum' => '1', 'errorMsg' => '账户初始化失败', 'data' => null);
                     return $return;
                 }
             } else {
                 $return = array('errorNum' => '1', 'errorMsg' => '注册失败', 'data' => null);
                 return $return;
             }
             $transaction->commit();
             //事务成功提交后返回数据
             $data = array('sessionkey' => $session_key, 'balance' => 0, 'phone' => $phone, 'app_pwd' => $app_pwd);
             $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => $data);
             return $return;
         } catch (\Exception $e) {
             $transaction->rollBack();
             $remark = $e->getMessage();
             $result = array('errorNum' => '1', 'errorMsg' => $remark, 'data' => null);
             return $result;
         }
     } else {
         $return = array('errorNum' => '1', 'errorMsg' => $check['errorMsg'], 'data' => null);
         return $return;
     }
 }