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
@@ -2,6 +2,7 @@
namespace app\onlinechip\controller;
use pay\Ybf;
use pay\AlinPay;
use think\Cache;
use \think\Controller;
use think\Db;
@@ -230,6 +231,90 @@ class Crypto Extends Controller{
return $sign == $data['sign'];
}
/**
* AlinPay 越南代付回调
*/
public function alin_payment_callback()
{
$post = Request::instance()->post();
$json = json_encode($post, JSON_UNESCAPED_UNICODE);
addLogToFile('越南代付回调原始数据:' . $json, 'alin_callback', 'alin');
if (!is_array($post) || empty($post['out_trade_no']) || empty($post['sign'])) {
exit('fail');
}
// 记录回调日志
$logId = Db::name('pay_callback_log')->insertGetId([
'pay_channel' => 'ALIN_PAYMENT',
'type' => 'payment',
'json' => $json,
'create_time' => date('Y-m-d H:i:s'),
]);
try {
$alinPay = new AlinPay();
$res = $alinPay->paymentCallback($post, $logId);
exit($res ?: 'fail');
} catch (\Exception $e) {
addLogToFile('越南代付回调异常:' . $e->getMessage(), 'alin_callback_error', 'alin');
exit('fail');
}
}
/**
* AlinPay 越南代收查询
*/
public function alin_query_order()
{
$orderNo = Request::instance()->post('order_no');
if (!$orderNo) {
return json(['code' => 0, 'msg' => '缺少订单号']);
}
try {
$alinPay = new AlinPay();
$result = $alinPay->queryOrder($orderNo);
return json($result);
} catch (\Exception $e) {
return json(['code' => 0, 'msg' => $e->getMessage()]);
}
}
/**
* AlinPay 越南代付查询
*/
public function alin_query_payment()
{
$orderNo = Request::instance()->post('order_no');
if (!$orderNo) {
return json(['code' => 0, 'msg' => '缺少订单号']);
}
try {
$alinPay = new AlinPay();
$result = $alinPay->queryPayment($orderNo);
return json($result);
} catch (\Exception $e) {
return json(['code' => 0, 'msg' => $e->getMessage()]);
}
}
/**
* AlinPay 账户余额查询
*/
public function alin_query_account()
{
try {
$alinPay = new AlinPay();
$result = $alinPay->queryAccount();
return json($result);
} catch (\Exception $e) {
return json(['code' => 0, 'msg' => $e->getMessage()]);
}
}
/**
* 记录日志
* @param $type