Esempio n. 1
0
 public function actionSendcode()
 {
     if (!isset($_POST['CellPhone'])) {
         echo '请输入手机号。';
         exit;
     }
     $phone = $_POST['CellPhone'];
     //60秒发送一次验证码
     $time = time() - 60;
     $count = VerifyCode::find()->andWhere(['type' => 1, 'field' => $phone, 'status' => -1])->orderBy('b_time desc')->one();
     if ($time < $count['b_time']) {
         echo '请勿重复点击';
         exit;
     }
     try {
         $result = Port::ValidatePhone($phone);
         if ($result) {
             echo '验证码已发送,请注意查收。';
             exit;
         }
     } catch (ErrorException $ex) {
         echo $ex->getMessage();
         exit;
     }
 }
Esempio n. 2
0
 public function actionDorecharge()
 {
     $uid = Yii::$app->user->id;
     if ($_POST) {
         //用户充值操作
         if (isset($_POST['code']) && isset($_POST['ticket']) && isset($_POST['out_trade_no'])) {
             $validate_code = $_POST['code'];
             $out_trade_no = $_POST['out_trade_no'];
             $ticket = $_POST['ticket'];
             try {
                 $info = sinapay::rechargeComfirm($out_trade_no, $ticket, $validate_code);
                 if ($info['errorNum'] == 0) {
                     echo "充值成功";
                     exit;
                 } elseif ($info['errorNum'] != 0) {
                     echo $info['errorMsg'];
                     exit;
                 }
             } catch (ErrorException $e) {
                 echo $e->getMessage();
                 exit;
             }
         } elseif (isset($_POST['money'])) {
             $phone = Info::find()->andWhere(['member_id' => $uid])->one()->bank_card_phone;
             //60秒发送一次验证码
             $time = time() - 60;
             $count = VerifyCode::find()->andWhere(['type' => 1, 'field' => $phone, 'status' => -1])->orderBy('b_time desc')->one();
             if ($time < $count['b_time']) {
                 $return = array('errorNum' => '1', 'errorMsg' => '请勿重复点击', 'data' => null);
                 echo json_encode($return);
                 exit;
             }
             $money = $_POST['money'];
             //充值金额
             try {
                 $info = sinapay::recharge($uid, $money);
                 echo json_encode($info);
                 exit;
             } catch (ErrorException $e) {
                 echo $e->getMessage();
                 exit;
             }
         } else {
             echo '您提交的信息不完整';
             exit;
         }
     }
 }
Esempio n. 3
0
 /**
  * 手机验证错误记录
  * @param $phone
  * @param $code
  * @param $status
  * @param $remark
  */
 private static function phongLog($phone, $code, $status, $remark)
 {
     $sms = new VerifyCode();
     $sms->code = $code;
     $sms->field = $phone;
     $sms->type = '1';
     $sms->status = $status;
     $sms->remark = $remark;
     $sms->save();
 }