예제 #1
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;
     }
 }
예제 #2
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("未有绑定银行卡");
     }
 }