Exemple #1
0
 public function smsLogin()
 {
     $phone = $this->getParam('phone', '');
     $code = $this->getParam('code', '');
     if (Check::isPhone($phone)) {
         $this->ajaxReturn(ERR_PARAMS_ERROR, '您输入的手机号无效');
         return;
     }
     if (Check::isVerifyCode($code)) {
         $this->ajaxReturn(ERR_PARAMS_ERROR, '验证码无效');
         return;
     }
     $nk = Nosql::NK_REG_SMS_CODE . $phone;
     $ret = Nosql::get($nk);
     if (empty($ret) || $ret != $code) {
         $this->ajaxReturn(ERR_PARAMS_ERROR, '验证码错误,请重新输入');
         return;
     }
     Nosql::del($nk);
     $userInfo = UserModel::findUserByPhone($phone);
     if (empty($userInfo)) {
         $this->ajaxReturn(ERR_PARAMS_ERROR, '该手机号码未注册,请先注册~');
         return;
     }
     $this->onLoginOk($userInfo);
     $this->ajaxReturn(0, '登陆成功', '/TODO');
 }
Exemple #2
0
 protected function wxPayReturn()
 {
     $orderId = $this->getParam('orderId', '');
     if (empty($orderId)) {
         // ;
     }
     // 微信支付,看该用户是否关注过
     $nk = Nosql::NK_WX_UNIFIED_PAY_UNSUBSCRIBE . $orderId;
     $ret = Nosql::get($nk);
     $this->display('wxpay_return');
 }
Exemple #3
0
 public function getOrderState()
 {
     $token = $this->getParam('token', '');
     if (empty($token)) {
         $this->ajaxReturn(ERR_PARAMS_ERROR, '参数错误');
         return;
     }
     $ret = Nosql::get($nk);
     if (empty($ret)) {
         $this->ajaxReturn(ERR_OPT_FAIL, '');
         return;
     }
     $ret = json_decode($ret, true);
     $this->ajaxReturn($ret['code'], $ret['desc'], '', $ret['result']);
 }
Exemple #4
0
 public function register()
 {
     $phone = $this->postParam('phone', '');
     $code = $this->postParam('code', '');
     if (Check::isPhone($phone)) {
         $this->ajaxReturn(ERR_PARAMS_ERROR, '您输入的手机号无效');
         return;
     }
     if (Check::isVerifyCode($code)) {
         $this->ajaxReturn(ERR_PARAMS_ERROR, '验证码无效');
         return;
     }
     $nk = Nosql::NK_REG_SMS_CODE . $phone;
     $ret = Nosql::get($nk);
     if (empty($ret) || $ret != $code) {
         $this->ajaxReturn(ERR_PARAMS_ERROR, '验证码错误,请重新输入');
         return;
     }
     Nosql::del($nk);
     $userInfo = UserModel::findUserByPhone($phone);
     if (empty($userInfo)) {
         $this->ajaxReturn(ERR_PARAMS_ERROR, '该手机号码未注册,请先注册~');
         return;
     }
     $nickname = UserModel::getRandomNickname('wx');
     $passwd = '';
     $sex = 0;
     $headimgurl = '';
     $ret = UserModel::newOne($phone, $passwd, $nickname, $sex, $headimgurl, UserModel::USER_ST_DEFAULT);
     if (!$ret) {
         $this->ajaxReturn(ERR_PARAMS_ERROR, '注册失败-系统出现异常,请稍后重试');
         return;
     }
     $userInfo = UserModel::findUserByPhone($phone);
     if (empty($userInfo)) {
         $this->ajaxReturn(ERR_PARAMS_ERROR, '注册失败-系统出现异常,请稍后重试');
         return;
     }
     UserModel::onLoginOk($userInfo['id'], '');
     // TODO 是不是会自动绑定微信?
     $this->ajaxReturn(0, '登录成功', '/TODO');
 }
Exemple #5
0
 public function doLogin()
 {
     $key = Session::getSid('user');
     $userInfo = Nosql::get(Nosql::NK_USER_SESSOIN . $key);
     if (!empty($userInfo)) {
         $userAgent = '';
         if (isset($_SERVER['HTTP_USER_AGENT'])) {
             $userAgent = $_SERVER['HTTP_USER_AGENT'];
         }
         $userInfo = json_decode($userInfo, true);
         if ($userInfo['userAgent'] == $userAgent) {
             if (Util::inWeixin()) {
                 return $this->doLoginInWx($userInfo['openid']);
             } else {
                 return $this->doLoginDefault($userInfo['userId']);
             }
         }
         return false;
     }
     return -1;
 }
Exemple #6
0
 public function wxPayReturn()
 {
     echo 'xxxxx';
     $orderId = $this->getParam('orderId', '');
     if (empty($orderId)) {
         // ;
     }
     // 微信支付,看该用户是否关注过
     $nk = Nosql::NK_WX_UNIFIED_PAY_UNSUBSCRIBE . $orderId;
     $ret = Nosql::get($nk);
 }
Exemple #7
0
 public function aliPay()
 {
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         exit;
     }
     if (!isset($_POST['sign']) || !isset($_POST['sign_type']) || $_POST['sign_type'] != 'RSA') {
         echo 'fail';
         exit;
     }
     $ret = AliSDK::verifySign($_POST, CONFIG_PATH . '/alipay/alipay_public_key.pem', $_POST['sign']);
     $ret = true;
     // TODO
     if ($ret === false) {
         Log::pay('ali wap pay notify fail (sign fail) ' . json_encode($_POST, JSON_UNESCAPED_UNICODE));
         echo 'success';
         exit;
     }
     if (!empty($_POST['notify_id'])) {
         $ret = AliSDK::verifyNotify(ALI_PAY_PARTNER_ID, CONFIG_PATH . '/alipay/cacert.pem', $_POST['notify_id']);
         if ($ret === false) {
             Log::pay('ali wap pay notify fail (verify notify_id fail) ' . json_encode($_POST, JSON_UNESCAPED_UNICODE));
             echo 'fail';
             exit;
         }
     }
     $nk = Nosql::NK_PAY_NOTIFY_DE_DUPLICATION . $data['out_trade_no'];
     $nk = Nosql::get($nk);
     if (!empty($nk)) {
         Log::pay('ali wap pay notify success (had handled): ' . json_encode($_POST, JSON_UNESCAPED_UNICODE));
         echo 'success';
         return;
     }
     if ($_POST['trade_status'] == 'TRADE_SUCCESS') {
         if ($this->onPayNotifyOk($_POST['out_trade_no'], $_POST['total_fee'], $_POST['total_fee']) === true) {
             Nosql::setex($nk, Nosql::NK_PAY_NOTIFY_DE_DUPLICATION_EXPIRE, 'x');
             Log::pay('ali wap pay notify success : ' . json_encode($_POST, JSON_UNESCAPED_UNICODE));
             echo 'success';
             return;
         }
     } else {
         // TRADE_FINISHED WAIT_BUYER_PAY 不处理
         echo 'success';
         return;
     }
     echo 'fail';
 }