/** * 用户提现--新浪处理 * @param $identity_id 用户标识 * @param $out_trade_no 用户订单号 * @return array */ public static function sianWithdraw($identity_id, $out_trade_no) { $sina_withdraw = SinaWithdraw::findOne(['identity_id' => $identity_id, 'out_trade_no' => $out_trade_no, 'status' => SinaWithdraw::STATUS_SITE_BALANCE]); if (!$sina_withdraw) { $return = array('errorNum' => '1', 'errorMsg' => '订单信息错误', 'data' => null); return $return; } $account_type = 'SAVING_POT'; $money = $sina_withdraw->money; $card_id = $sina_withdraw->card_id; //接受异步处理 $notify_url = ''; $sina = new sina(); //用户托管提现 $withdraw = $sina->create_hosting_withdraw($out_trade_no, $identity_id, $account_type, $money, $card_id, $notify_url); if (!$withdraw) { $return = array('errorNum' => '1', 'errorMsg' => '接口错误', 'data' => null); return $return; } if ($withdraw['response_code'] == 'APPLY_SUCCESS') { $sina_withdraw->status = SinaWithdraw::STATUS_SINA_DEAL; $sina_withdraw->msg = $withdraw['withdraw_status']; if ($sina_withdraw->save()) { $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null); return $return; } } else { $sina_withdraw->status = SinaWithdraw::STATUS_ERROR; $sina_withdraw->msg = $withdraw['withdraw_status']; if ($sina_withdraw->save()) { $return = array('errorNum' => '1', 'errorMsg' => $withdraw['response_message'], 'data' => null); return $return; } $return = array('errorNum' => '1', 'errorMsg' => '数据记录失败', 'data' => null); return $return; } }
/** * Finds the SinaWithdraw model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return SinaWithdraw the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = SinaWithdraw::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }