Exemplo n.º 1
0
 /**
  * 判定用户是否已经绑定银行卡
  * @param $uid  用户id
  * @return bool
  * @throws ErrorException
  */
 public static function isBinding($uid)
 {
     $info = Bindbankcard::findOne(['uid' => $uid, 'status' => Balance::SUCCEED]);
     if ($info) {
         $data['cardno'] = $info['cardno'];
         $data['idcardno'] = $info['idcardno'];
         $data['username'] = $info['username'];
         $data['phone'] = $info['phone'];
         return $data;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * 判定用户是否已经绑定银行卡
  * @param $uid  用户id
  * @return bool
  * @throws ErrorException
  */
 public static function isBinding($uid)
 {
     $info = Bindbankcard::findOne(['uid' => $uid, 'status' => yeepay::SUCCEED]);
     if ($info) {
         $data['cardno'] = $info['cardno'];
         $data['phone'] = $info['phone'];
         $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => $data);
         return $return;
     } else {
         $return = array('errorNum' => '1', 'errorMsg' => '未进行绑定', 'data' => null);
         return $return;
     }
 }
Exemplo n.º 3
0
 /**
  * 用户提现操作----T+0模式
  * @param $uid 用户id
  * @param $amount 用户提现金额
  * @return bool
  * @throws ErrorException
  */
 public static function withdraw($uid, $amount)
 {
     $info = Bindbankcard::findOne(['uid' => $uid, 'status' => yeepay::SUCCEED]);
     if ($info) {
         $identityid = $info->identityid;
         $requestid = self::verification();
         $card_top = $info->card_top;
         $card_last = $info->card_last;
         $userip = Yii::$app->request->userIP;
         $pay = new yeepayClass();
         $respond = $pay->withdraw($requestid, $identityid, $card_top, $card_last, $amount, $userip);
         //充值信息验证成功
         if (is_array($respond) && $respond['requestid'] == $requestid) {
             $status = $respond['status'];
             if ($status == "FAILURE") {
                 $status = yeepay::ERROR;
                 $msg = '提现请求失败';
                 self::withdrawLog($uid, $identityid, $card_top, $card_last, $amount, $userip, $status, $msg, '', '');
                 $return = array('errorNum' => '1', 'errorMsg' => '提现请求失败', 'data' => null);
                 return $return;
             } elseif ($status == 'SUCCESS') {
                 //TODO
                 $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null);
                 return $return;
             } else {
                 $status = yeepay::ERROR;
                 $msg = '提现未知错误';
                 self::withdrawLog($uid, $identityid, $card_top, $card_last, $amount, $userip, $status, $msg, '', '');
                 $return = array('errorNum' => '1', 'errorMsg' => '提现未知错误', 'data' => null);
                 return $return;
             }
         } else {
             $status = yeepay::ERROR;
             $msg = $respond;
             self::withdrawLog($uid, $identityid, $card_top, $card_last, $amount, $userip, $status, $msg, '', '');
             $return = array('errorNum' => '1', 'errorMsg' => $respond, 'data' => null);
             return $return;
         }
     } else {
         $return = array('errorNum' => '1', 'errorMsg' => '未有绑定银行卡', 'data' => null);
         return $return;
     }
 }
Exemplo n.º 4
0
 /**
  * 用户提现操作
  * @param $uid 用户id
  * @param $amount 用户提现金额
  * @return bool
  * @throws ErrorException
  */
 public static function withdraw($uid, $amount)
 {
     $info = Bindbankcard::findOne(['uid' => $uid, 'status' => yeepay::SUCCEED]);
     if ($info) {
         $identityid = $info->identityid;
         $requestid = self::verification();
         $card_top = $info->card_top;
         $card_last = $info->card_last;
         $userip = Yii::$app->request->userIP;
         $pay = new yeepayClass();
         $respond = $pay->withdraw($requestid, $identityid, $card_top, $card_last, $amount, $userip);
         //充值信息验证成功
         if (is_array($respond) && $respond['requestid'] == $requestid) {
             $status = $respond['status'];
             if ($status == "FAILURE") {
                 throw new ErrorException("请求失败");
             } elseif ($status == 'SUCCESS') {
                 return true;
             } else {
                 throw new ErrorException('未知错误');
             }
         } else {
             throw new ErrorException($respond);
         }
     } else {
         throw new ErrorException("未有绑定银行卡");
     }
 }