//支付宝提现物业后台
public function alitakeOutAdmin($total_amount, $orderNumber,$payee_real_name,$payee_account){
// Loader::import('alipay\aop\AopClient', EXTEND_PATH);
// Loader::import('alipay\aop\request\AlipayFundTransToaccountTransferRequest', EXTEND_PATH);
// $aop = new \alipay\aop\AopClient();
Vendor('alipay.aop.AopClient');
Vendor('alipay.aop.request.AlipayFundTransToaccountTransferRequest');
$aop = new \AopClient();
$request = new \AlipayFundTransToaccountTransferRequest();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = $this->appId;
$aop->rsaPrivateKey = $this->rsaPrivateKey;
$aop->alipayrsaPublicKey = $this->aliPayRsaPublicKey;
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='UTF-8';
$aop->format='json';
// $request = new \alipay\aop\request\AlipayFundTransToaccountTransferRequest();
$arr['out_biz_no'] = $orderNumber;
$arr['payee_type'] = 'ALIPAY_LOGONID';
$arr['payee_account'] = $payee_account;
$arr['amount'] = $total_amount;
$arr['payee_real_name'] = $payee_real_name;
$arr['remark'] = '支付宝提现【联想商务】';
Log::pay('【Alipay/aliPay】-[参数]--' . json_encode($arr));
$json = json_encode($arr);
$request->setBizContent($json);
$result = $aop->execute($request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode;
$resultCode = json_decode(json_encode($resultCode),true);
Log::pay('【Alipay/aliPay】-[参数返回]--' . json_encode($resultCode));
if($resultCode['code'] == 10000){
//提现成功修改状态
Db::startTrans();
try {
$where['orderNumber'] = array('eq',$resultCode['out_biz_no']);
$map['is_pay'] = 1;
$saveorder = M('order_log')->where($where)->update($map);
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
}
$data['code'] = 1;
return $data;
} else {
if ($resultCode['out_biz_no']){
$where['orderNumber'] = array('eq',$resultCode['out_biz_no']);
$outlog['sub_msg'] = $resultCode['sub_msg'];
$saveout = M('take_out_log')->where($where)->update($outlog);
}
$data['code'] = -99;
$data['msg'] = $resultCode['sub_msg'];
return $data;
}
}
支付宝转账(实现用户提现功能)
最新推荐文章于 2024-01-24 08:20:28 发布