diff --git a/app/Controller/Payment/NotifyController.php b/app/Controller/Payment/NotifyController.php index e8f77d7..85aaf18 100644 --- a/app/Controller/Payment/NotifyController.php +++ b/app/Controller/Payment/NotifyController.php @@ -271,7 +271,7 @@ class NotifyController extends AbstractController 'amount' => $apply->amount, 'status' => $apply->status, 'userId' => $apply->user_id, - 'outWithdrawNo' => $apply->out_withdraw_no, + 'outApplyNo' => $apply->out_apply_no, ] ); diff --git a/test.php b/test.php index 81819f5..945cccc 100644 --- a/test.php +++ b/test.php @@ -1,84 +1,105 @@ '202306140000001', - 'timestamp' => time(), - 'nonce_str' => getRandomString(32), - 'data' => json_encode([ - 'outOrderNo' => time().rand(1000, 9999), - 'outMemberId' => 'T001', - 'amount' => 100, - 'notifyUrl' => 'https://www.baidu.com', - ]), +/** ======================================================= */ +/** + * 提现申请(资金从平台户到用户电子账户) + * url: payment/withdraw-apply + * + */ +$data = [ + 'userId' => 'ELF1990', + 'accountName' => '廖金灵', + '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)); -var_dump(json_decode($response, true));die(); -// select * from `orders` where `app_id` = '202306140000001' and `out_order_no` = '16869297292619' limit 1 -$params = [ - 'app_id' => '202306140000001', - 'timestamp' => time(), - 'nonce_str' => getRandomString(32), - 'data' => json_encode([ - 'outOrderNo' => '16869297292619', - ]), +/* +同步返回结果data: +{ + "batchNum": "2023083102511200001", + "applyNo": "2023083102511200001" +} +*/ +/* +异步返回结果: +{ + "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(); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_URL, $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; +/* +同步返回结果data: +{ + "url": "http://xxxxxxx", // 输入支付密码url } -function sign($params, $secretKey) { - $signString = $params['app_id'] . '&' - . $params['timestamp'] . '&' - . $params['nonce_str'] . '&' - . $params['data'] . '&' - . $secretKey; - return md5($signString); +异步返回结果data: +{ + "amount": 1, + "status": "SUCCESS", + "userId": "abc", + "outWithdrawNo": "2023083102511200001" // 传入的提现号 } +*/ + +/** ======================================================= */ + +/** + * 查询提现申请结果 + * 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', +]; + +// 同步返回结果与原来相同 -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( - '!', '@', '#', '$', '?', '|', '{', '/', ':', ';', - '%', '^', '&', '*', '(', ')', '-', '_', '[', ']', - '}', '<', '>', '~', '+', '=', ',', '.' - )); - } - - $charsLen = count($chars) - 1; - shuffle($chars); - - $password = ''; - for($i=0; $i<$length; $i++){ - $password .= $chars[mt_rand(0, $charsLen)]; - } +/** ======================================================= */ - return $password; - } \ No newline at end of file +// 一般有以下状态 +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'; // 失败 \ No newline at end of file