elf 1 year ago
parent 9d6e45a7bb
commit 7b22609ca9

@ -271,7 +271,7 @@ class NotifyController extends AbstractController
'amount' => $apply->amount, 'amount' => $apply->amount,
'status' => $apply->status, 'status' => $apply->status,
'userId' => $apply->user_id, 'userId' => $apply->user_id,
'outWithdrawNo' => $apply->out_withdraw_no, 'outApplyNo' => $apply->out_apply_no,
] ]
); );

@ -1,84 +1,105 @@
<?php <?php
/** ======================================================= */
$params = [ /**
'app_id' => '202306140000001', * 提现申请(资金从平台户到用户电子账户)
'timestamp' => time(), * url: payment/withdraw-apply
'nonce_str' => getRandomString(32), *
'data' => json_encode([ */
'outOrderNo' => time().rand(1000, 9999), $data = [
'outMemberId' => 'T001', 'userId' => 'ELF1990',
'amount' => 100, 'accountName' => '廖金灵',
'notifyUrl' => 'https://www.baidu.com', 'outApplyNo' => time() . rand(1000, 9999),
]), 'amount' => '10',
'summary' => '测试',
'notifyUrl' => 'http://124.223.222.61:9501/notify/test-notify'
]; ];
$params['sign'] = sign($params, 'nM2bUJT89njQGzoeDyK8cLmEYJloUsJX'); /*
$response = post('http://66.42.38.42:9501/payment/pay', json_encode($params)); 同步返回结果data
var_dump(json_decode($response, true));die(); {
// select * from `orders` where `app_id` = '202306140000001' and `out_order_no` = '16869297292619' limit 1 "batchNum": "2023083102511200001",
$params = [ "applyNo": "2023083102511200001"
'app_id' => '202306140000001', }
'timestamp' => time(), */
'nonce_str' => getRandomString(32), /*
'data' => json_encode([ 异步返回结果:
'outOrderNo' => '16869297292619', {
]), "amount": 1,
"status": "SUCCESS",
"userId": "abc",
"outApplyNo": "2023083102511200001"
}
*/
/** ======================================================= */
/**
* 提现到绑定银行卡(资金从用户电子账户到用户绑定银行卡)
* url: payment/withdraw
*
*/
$data = [
'userId' => 'ELF1990',
'agreementNo' => '312023082200002060225',
'outWithdrawNo' => time() . rand(1000, 9999),
'amount' => '1',
'notifyUrl' => 'http://124.223.222.61:9501/notify/test-notify',
'returnUrl' => 'https://www.baidu.com',
]; ];
$params['sign'] = sign($params, 'nM2bUJT89njQGzoeDyK8cLmEYJloUsJX');
$response = post('http://146.70.113.165:9501/payment/query', json_encode($params));
var_dump(json_decode($response, true));
function post($url, $jsonStr) { /*
$ch = curl_init(); 同步返回结果data
curl_setopt($ch, CURLOPT_POST, 1); {
curl_setopt($ch, CURLOPT_URL, $url); "url": "http://xxxxxxx", // 输入支付密码url
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($jsonStr)
)
);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $response;
} }
function sign($params, $secretKey) { 异步返回结果data
$signString = $params['app_id'] . '&' {
. $params['timestamp'] . '&' "amount": 1,
. $params['nonce_str'] . '&' "status": "SUCCESS",
. $params['data'] . '&' "userId": "abc",
. $secretKey; "outWithdrawNo": "2023083102511200001" // 传入的提现号
return md5($signString);
} }
*/
function getRandomString($length, $withSpecialChar = false) /** ======================================================= */
{
$chars = array(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2',
'3', '4', '5', '6', '7', '8', '9'
);
if($withSpecialChar){ /**
$chars = array_merge($chars, array( * 查询提现申请结果
'!', '@', '#', '$', '?', '|', '{', '/', ':', ';', * url: payment/withdraw-apply-query
'%', '^', '&', '*', '(', ')', '-', '_', '[', ']', *
'}', '<', '>', '~', '+', '=', ',', '.' */
)); $data = [
} 'userId' => 'ELF1990',
'outApplyNo' => '16934203547527',
];
/*
同步返回结果data
{
"amount": 1,
"status": "SUCCESS",
"fee": 0, // 手续费
}
*/
/** ======================================================= */
/**
* 查询提现结果(原接口改造)
* url: payment/query-order
*/
$data = [
'type' => 'WITHDRAW',
'outOrderNo' => '16934198607215',
];
$charsLen = count($chars) - 1; // 同步返回结果与原来相同
shuffle($chars);
$password = ''; /** ======================================================= */
for($i=0; $i<$length; $i++){
$password .= $chars[mt_rand(0, $charsLen)];
}
return $password; // 一般有以下状态
} const STATUS_APPLY_SUCCESS = 'APPLY_SUCCESS'; // 申请失败
const STATUS_APPLY_FAILED = 'APPLY_FAILED'; // 申请成功
const STATUS_REFUND = 'REFUND'; // 已退款
const STATUS_PROCESS = 'PROCESS'; // 处理中
const STATUS_SUCCESS = 'SUCCESS'; // 成功
const STATUS_FAILED = 'FAILED'; // 失败
Loading…
Cancel
Save