Example #1
0
 public function actionRecharge()
 {
     $model = UcenterMember::find()->where('id=' . Yii::$app->user->id)->one();
     $uid = Yii::$app->user->id;
     //判断用户是否实名认证
     if (!member::isAuthentic($uid)) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有实名制认证');</script>";
         echo "<script>location.href='" . \yii\helpers\Url::to(['setting/setting']) . "'</script>";
         exit;
     } else {
         $result = member::isAuthentic($uid);
     }
     //判断用户是否绑定银行卡
     $is_bind = sinapay::isBinding($uid);
     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(['money/bindcard']) . "'</script>";
         exit;
     } elseif ($is_bind['errorNum'] == 0) {
         $result_bind = $is_bind['data'];
         $logo_bind = self::BankInfos();
     }
     //最大提现限额——(后台设置里取值)
     $limitConfig = sinapay::getsiteConfig();
     $deposit_max = 10000;
     $deposit_min = 5;
     $deposit_times = 3;
     if ($limitConfig) {
         $deposit_max = $limitConfig->deposit_max;
         $deposit_min = $limitConfig->deposit_min;
         $deposit_times = $limitConfig->deposit_num;
         //当日充值次数
         $today_num = Log::find()->where('member_id = ' . $uid . '  AND create_at > ' . strtotime(date("Y-m-d")) . ' AND status=1')->count();
     }
     //用户充值操作
     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'])) {
         $money = $_POST['money'];
         //充值金额
         try {
             $info = sinapay::recharge($uid, $money);
             echo json_encode($info);
             exit;
         } catch (ErrorException $e) {
             echo $e->getMessage();
             exit;
         }
     }
     $infos_rar = $this->Ucenter();
     //用户数据包
     return $this->render('recharge', compact("today_num", "infos_rar", "result", "result_bind", "model", "logo_bind", "deposit_times", "deposit_min", "deposit_max"));
 }
Example #2
0
 /**
  * 用户充值
  * @return array|mixed|string
  */
 public function actionRecharge()
 {
     $result = App::AppGet();
     try {
         if ($result['errorNum']) {
             $result = array('errorNum' => $result['errorNum'], 'errorMsg' => $result['errorMsg'], 'data' => null);
         } else {
             $data = $result['data'];
             if (array_key_exists('uid', $data) && array_key_exists('money', $data)) {
                 $uid = $data['uid'];
                 $amount = $data['money'];
                 $result = sinapay::recharge($uid, $amount);
             } else {
                 $result = array('errorNum' => '1', 'errorMsg' => '参数错误', 'data' => null);
             }
         }
     } catch (ErrorException $e) {
         Yii::error("用户充值---异常 方法:actionRecharge 参数:" . json_encode($result['data']), "app");
         Yii::trace($e->getMessage(), "app");
         $result = array('errorNum' => '7', 'errorMsg' => '服务器异常,请联系管理员', 'data' => null);
     }
     $result = App::AppReturn($result);
     return $result;
 }
 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;
         }
     }
 }