feat: 对接越南AlinPay支付网关(代收+代付)

- 新增 AlinPay 网关核心类:签名/验签/代收/代付/查询/账户接口
- 新增 alinPay trait:充值发起 + 代收回调结算(事务+行锁)
- 修改 admin/agent Report:提现审批自动路由 ALIN_VN 发起代付
- 新增 Pcapi:银行卡提现申请 + 越南银行列表接口
- 修改 Crypto:代付回调/订单查询/账户查询入口
- 新增越南区 area_list(id=3) + alinPay pay_list 配置
- DDL: user_withdraw 表增加 pay_channel/ext 字段
This commit is contained in:
li
2026-03-12 22:24:49 +08:00
parent e633c8e27d
commit 79123e079f
9 changed files with 997 additions and 13 deletions
+52 -9
View File
@@ -3,6 +3,7 @@
namespace app\admin\controller;
use pay\Usdt;
use pay\AlinPay;
use think\Db;
use think\Request;
use think\Session;
@@ -405,19 +406,61 @@ class Report extends Common{
die(json_encode(['code'=>0,'msg'=>'非待审核状态无法操作!']));
}
// 审核通过
$Usdt = new Usdt();
$res = $Usdt->applyUserWithdraw($withdraw['order_no'],$withdraw['to_address'],$withdraw['amount']);
if($res['code'] == 0){
Db::name('user_withdraw')->where('id',$id)->update([
// 根据支付渠道路由
$payChannel = $withdraw['pay_channel'] ?: 'USDT';
$withdrawResult = [];
if($payChannel == 'ALIN_VN'){
// 越南AlinPay代付
$ext = json_decode($withdraw['ext'], true) ?: [];
$pay_list = config('pay_list');
$notifyUrl = $pay_list['alinPay']['payment_notify_url'];
$alinPay = new AlinPay();
$res = $alinPay->createPayment(
$withdraw['order_no'],
sprintf('%.2f', $withdraw['amount']),
$ext['accountName'] ?? '',
$ext['accountNumber'] ?? '',
$ext['bankCode'] ?? '',
$ext['bankName'] ?? '',
$notifyUrl
);
$withdrawResult = [
'status' => (is_array($res) && isset($res['code']) && $res['code'] == 200) ? true : false,
'type' => 'ALIN_VN',
'out_trade_no' => $res['data']['trade_no'] ?? '',
'err_msg' => $res['message'] ?? '请求失败',
];
}else{
// 默认USDT
$Usdt = new Usdt();
$res = $Usdt->applyUserWithdraw($withdraw['order_no'],$withdraw['to_address'],$withdraw['amount']);
$withdrawResult = [
'status' => $res['code'] == 0 ? true : false,
'type' => $res['processor']['asset'] ?? 'USDT',
'from_address' => $res['processor']['from_addr'] ?? '',
'err_msg' => $res['debug'] ?? '',
];
}
if($withdrawResult['status']){
$updateData = [
'status' => 'AGREE',
'type' => $res['processor']['asset'],
'from_address' => $res['processor']['from_addr'],
'type' => $withdrawResult['type'] ?? '',
'audit_time' => time(),
'operator_source' => 2,
'operator_id' => $user_info['id'],
'operator_username' => $user_info['admin'],
]);
];
if(!empty($withdrawResult['from_address'])){
$updateData['from_address'] = $withdrawResult['from_address'];
}
if(!empty($withdrawResult['out_trade_no'])){
$updateData['out_trade_no'] = $withdrawResult['out_trade_no'];
}
Db::name('user_withdraw')->where('id',$id)->update($updateData);
die(json_encode(['code'=>1,'msg'=>'审核通过!']));
}else{
Db::startTrans();
@@ -430,7 +473,7 @@ class Report extends Common{
// 更新记录
Db::name('user_withdraw')->where('id',$id)->update([
'status' => 'FAIL',
'err_msg' => $res['debug'],
'err_msg' => $withdrawResult['err_msg'],
'audit_time' => time(),
'operator_source' => 2,
'operator_id' => $user_info['id'],