Exemplo n.º 1
0
 /**
  * Updates an existing SinaFreeze model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUnlock($id)
 {
     $model = $this->findModel($id);
     $return = sinapay::balanceUnfreeze($model->out_freeze_no, $model->freeze_money, '解冻金额');
     if ($return['errorNum'] == 0) {
         \Yii::$app->getSession()->setFlash('warning', $return['errorMsg']);
         $info = new Info();
         $info->freeze -= $model->freeze_money;
         $info->balance += $model->freeze_money;
         $info->save();
     } else {
         \Yii::$app->getSession()->setFlash('warning', $return['errorMsg']);
     }
     return $this->redirect(['index']);
 }
Exemplo n.º 2
0
 /**
  * 用户短信确认充值
  * @param $orderid 充值订单号
  * @param $validatecode 短信验证码
  * @return string
  * @throws ErrorException
  */
 public static function confirmSet($orderid, $validatecode)
 {
     $orderid = (string) $orderid;
     $validatecode = (string) $validatecode;
     $yeepay = yeepay::confirmPayment($orderid, $validatecode);
     if (is_array($yeepay)) {
         $uid = $yeepay['uid'];
         $money = (double) $yeepay['money'] / 100;
         $customer = Info::find()->where(['member_id' => $uid])->one();
         if ($customer) {
             $balance = $customer->balance;
             $customer->balance = $money + $balance;
             $flag = $customer->save();
             if ($flag) {
                 $log = self::logSave($uid, $money, "setBalabce", self::SUCCEED, $yeepay['orderid'], "充值成功");
                 if ($log) {
                     return "充值成功!";
                 } else {
                     throw new ErrorException("充值记录错误");
                 }
             } else {
                 self::logSave($uid, $money, "setBalabce", self::ERROR, $yeepay['orderid'], "更新账户数据失败");
                 throw new ErrorException("更新账户数据失败");
             }
         } else {
             $customer = new Info();
             $customer->member_id = $uid;
             $customer->balance = $money;
             $flag = $customer->save();
             if ($flag) {
                 $log = self::logSave($uid, $money, "setBalabce", self::SUCCEED, $yeepay['orderid'], "充值成功");
                 if ($log) {
                     return "充值成功!";
                 } else {
                     throw new ErrorException("充值记录错误");
                 }
             } else {
                 self::logSave($uid, $money, "setBalabce", self::ERROR, $yeepay['orderid'], "更新账户数据失败");
                 throw new ErrorException("更新账户数据失败");
             }
         }
     } else {
         throw new ErrorException("短息确认失败");
     }
 }
Exemplo n.º 3
0
 public function actionSignup()
 {
     //判断注册URL中是否包含邀请码参数
     if (isset($_GET['code'])) {
         $code = $_GET['code'];
         //$_code_source = UcenterMember::find()->where(['invitation_code'=>$code])->one();
         //if(count($_code_source) != 1)
         $flag = \frontend\actions\app\member::verify_code($code);
         if (!$flag) {
             header("Content-type: text/html; charset=utf-8");
             echo "<script>alert('来源链接不合法!')</script>";
             echo "<script>window.location.href='" . \yii\helpers\Url::to(['site/signup']) . "'</script>";
             exit;
         }
     }
     $model = new SignupForm();
     //是否邀请注册
     $test_invite = 1;
     if ($model->load(Yii::$app->request->post())) {
         if ($_POST['SignupForm']['username'] && $_POST['SignupForm']['validate_code'] && $_POST['SignupForm']['password'] && $_POST['SignupForm']['password_repeat']) {
             $invite_code = $_POST["SignupForm"]['invitation_code'];
             //使用测试邀请码
             if ($test_invite) {
                 //使用测试邀请
                 $flag = \frontend\actions\app\member::verify_code($invite_code);
                 //验证码通过
                 if (!$flag) {
                     echo "<script>alert('" . '邀请码错误' . "')</script>";
                 }
             }
             $_phone = $_POST['SignupForm']['username'];
             $_code = $_POST['SignupForm']['validate_code'];
             try {
                 $result = Port::checkPhnoe($_phone, $_code);
                 if (is_bool($result)) {
                 }
             } catch (ErrorException $e) {
                 header("Content-type: text/html; charset=utf-8");
                 echo "<script>alert('" . $e->getMessage() . "')</script>";
                 echo "<script>location.href='" . \yii\helpers\Url::to(['site/signup']) . "'</script>";
                 exit;
             }
             $user = new UcenterMember();
             $user->username = $_POST["SignupForm"]['username'];
             $user->phone = $_POST["SignupForm"]['username'];
             $user->invitation_code = $_POST["SignupForm"]['invitation_code'];
             $password = $_POST["SignupForm"]['password'];
             $user->setPassword($password);
             $user->create_ip = Yii::$app->request->userIp;
             $app_pwd = md5(sha1($password) . time());
             $user->app_pwd = $app_pwd;
             try {
                 $area = self::get_area(Yii::$app->request->userIp);
                 $user->create_area = $area;
             } catch (ErrorException $e) {
             }
             $user->generateAuthKey();
             if ($user->save()) {
                 $uid = $user['id'];
                 if ($test_invite) {
                     //使用验证码
                     $flag = \frontend\actions\app\member::verify_code($invite_code);
                     $invite_flag = \frontend\actions\app\member::use_code($flag, $uid);
                     if (!$invite_flag) {
                         $return = array('errorNum' => '1', 'errorMsg' => '注册失败', 'data' => null);
                         return $return;
                     }
                 }
                 if (Yii::$app->getUser()->login($user)) {
                     $newModel = UcenterMember::find()->where(['id' => Yii::$app->user->id])->one();
                     //$newModel->invitation_id= \yii::$app->params['invitation_id'];
                     $invitation_code = Utils::createcode();
                     $newModel->invitation_code = $invitation_code;
                     $newModel->person_face = Setting::find()->where("code='img'")->one()->value;
                     if ($_POST['url_code']) {
                         $code_source = UcenterMember::find()->where(['invitation_code' => $_POST["url_code"]])->asArray()->one();
                         if ($code_source) {
                             $newModel->invitation_id = $code_source['id'];
                         }
                         //好友注册领取体验金
                         $rule = Rule::find()->where(['title' => '好友注册', 'status' => Rule::STATUS_ACTIVE])->one();
                         if ($rule) {
                             $rid = $rule->id;
                             $r_money = $rule->money;
                             $model_gold = new Gold();
                             $model_gold->rid = $rid;
                             $model_gold->money = $r_money;
                             $model_gold->uid = $code_source['id'];
                             $model_gold->created_at = strtotime("now");
                             $model_gold->save();
                         }
                     } elseif ($_POST['SignupForm']['invitation_code']) {
                         $code_source = UcenterMember::find()->where(['invitation_code' => $_POST["SignupForm"]["invitation_code"]])->asArray()->one();
                         if ($code_source) {
                             $newModel->invitation_id = $code_source['id'];
                         }
                         //好友注册领取体验金
                         $rule = Rule::find()->where(['title' => '好友注册', 'status' => Rule::STATUS_ACTIVE])->one();
                         if ($rule) {
                             $rid = $rule->id;
                             $r_money = $rule->money;
                             $model_gold = new Gold();
                             $model_gold->rid = $rid;
                             $model_gold->money = $r_money;
                             $model_gold->uid = $code_source['id'];
                             $model_gold->created_at = strtotime("now");
                             $model_gold->save();
                         }
                     }
                     $newModel->save(false);
                     $model_asset_info = new Info();
                     $model_asset_info->member_id = yii::$app->user->id;
                     $model_asset_info->create_at = strtotime("now");
                     $model_asset_info->save(false);
                     //手机号注册领取体验金
                     $rule = Rule::find()->where(['title' => '手机号注册', 'status' => Rule::STATUS_ACTIVE])->one();
                     if ($rule) {
                         $rid = $rule->id;
                         $r_money = $rule->money;
                         $model_gold = new Gold();
                         $model_gold->rid = $rid;
                         $model_gold->money = $r_money;
                         $model_gold->uid = $code_source['id'];
                         $model_gold->created_at = strtotime("now");
                         $model_gold->save();
                     }
                     return $this->goHome();
                 }
             }
         }
     }
     return $this->render('signup', compact("model", "code"));
 }
Exemplo n.º 4
0
 /**
  * 用户短信确认充值
  * @param $orderid 充值订单号
  * @param $validatecode 短信验证码
  * @return string
  * @throws ErrorException
  */
 public static function confirmSet($orderid, $validatecode)
 {
     $orderid = (string) $orderid;
     $validatecode = (string) $validatecode;
     $yeepay = yeepay::confirmPayment($orderid, $validatecode);
     //易宝接口完成充值行为
     if (!$yeepay['errorNum']) {
         $yeepay = $yeepay['data'];
         $uid = $yeepay['uid'];
         $money = (double) ($yeepay['money'] / 100);
         $customer = Info::find()->where(['member_id' => $uid])->one();
         //写入网站的账户信息
         if ($customer) {
             $balance = $customer->balance;
             $customer->balance = $money + $balance;
             $flag = $customer->save();
             if ($flag) {
                 $log = self::logSave($uid, $money, "setBalabce", self::SUCCEED, $yeepay['orderid'], "充值成功");
                 if ($log) {
                     $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
                     return $return;
                 } else {
                     $return = array('errorNum' => '1', 'errorMsg' => '充值记录错误', 'data' => null);
                     return $return;
                 }
             } else {
                 self::logSave($uid, $money, "setBalabce", self::ERROR, $yeepay['orderid'], "更新账户数据失败");
                 $return = array('errorNum' => '1', 'errorMsg' => '更新账户数据失败', 'data' => null);
                 return $return;
             }
         } else {
             $customer = new Info();
             $customer->member_id = $uid;
             $customer->balance = $money;
             $flag = $customer->save();
             if ($flag) {
                 $log = self::logSave($uid, $money, "setBalabce", self::SUCCEED, $yeepay['orderid'], "充值成功");
                 if ($log) {
                     $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
                     return $return;
                 } else {
                     $return = array('errorNum' => '1', 'errorMsg' => '充值记录错误', 'data' => null);
                     return $return;
                 }
             } else {
                 self::logSave($uid, $money, "setBalabce", self::ERROR, $yeepay['orderid'], "更新账户数据失败");
                 $return = array('errorNum' => '1', 'errorMsg' => '更新账户数据失败', 'data' => null);
                 return $return;
             }
         }
     } else {
         $return = array('errorNum' => '1', 'errorMsg' => '短息确认失败', 'data' => null);
         return $return;
     }
 }
Exemplo n.º 5
0
 /**
  * Creates a new Info model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Info();
     if ($model->load(\App::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->member_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 6
0
 /**
  *以后做推广活动进行的注册操作
  * @param $phone 手机号
  * @param $pwd  密码
  * @param $phone_code 手机验证码
  * @param $from 用户来源
  * @param string  $userIp 注册ip
  * @param string  $from  注册来源
  * @return array
  */
 public static function the_promotion_register($phone, $pwd, $phone_code, $from)
 {
     //注册来源
     $from = $from;
     //判定手机号是否注册
     $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;
     }
     //手机短息验证码验证
     $check = Port::checkPhnoe($phone, $phone_code);
     $session_key = "";
     //生成app的密码
     $app_pwd = md5(sha1($pwd) . time());
     // 根据ip获取地区---Yii::$app->request->userIp
     $userIp = Yii::$app->request->userIp;
     $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->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'];
                     //注册动作完成---进行登录操作
                     $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();
                             //新用户注册送体验金---6666
                             self::give_experience_gold(1, $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;
     }
 }