feat(withdraw): 落地方案B一体化商城余额提现与手续费内扣模式,完善多端打款退款与对账闭环
这个提交包含在:
66
tests/test_real_prepay_api.php
普通文件
66
tests/test_real_prepay_api.php
普通文件
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
define('APP_PATH', __DIR__ . '/../application/');
|
||||
define('ROOT_PATH', __DIR__ . '/../');
|
||||
$_SERVER['HTTP_HOST'] = 'henglian.gynhc.com';
|
||||
$_SERVER['SERVER_PORT'] = '443';
|
||||
$_SERVER['HTTPS'] = 'on';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
|
||||
require_once ROOT_PATH . 'thinkphp/base.php';
|
||||
require_once ROOT_PATH . 'thinkphp/helper.php';
|
||||
require_once ROOT_PATH . 'application/common.php';
|
||||
\think\Config::set(\think\Config::load(APP_PATH . 'config.php'));
|
||||
\think\Config::set(include APP_PATH . 'database.php', 'database');
|
||||
\think\Loader::addNamespace('app', APP_PATH);
|
||||
\think\Loader::addNamespace('addons\\shopro', ROOT_PATH . 'addons/shopro/');
|
||||
require_once ROOT_PATH . 'addons/shopro/helper/helper.php';
|
||||
|
||||
// 初始化站点与上传配置
|
||||
$site = \think\Db::name('config')->where('group', 'site')->column('value', 'name');
|
||||
\think\Config::set('site', $site);
|
||||
$upload = include APP_PATH . 'extra/upload.php';
|
||||
\think\Config::set('upload', $upload);
|
||||
|
||||
// 触发 epay 配置初始化
|
||||
\think\Hook::listen('epay_config_init');
|
||||
|
||||
// 选用订单 21
|
||||
$order = \app\admin\model\shopro\order\Order::get(21);
|
||||
$oldStatus = $order->status;
|
||||
$oldRemainFee = $order->remain_pay_fee;
|
||||
$order->status = 'unpaid';
|
||||
$order->remain_pay_fee = 0.01;
|
||||
$order->save();
|
||||
|
||||
echo "Order 21 temporarily set to unpaid, remain_pay_fee=0.01\n";
|
||||
|
||||
$auth = \app\common\library\Auth::instance();
|
||||
$auth->direct($order->user_id);
|
||||
|
||||
$request = \think\Request::instance();
|
||||
$request->post([
|
||||
'order_sn' => $order->order_sn,
|
||||
'payment' => 'wechat',
|
||||
]);
|
||||
$request->header([
|
||||
'platform' => 'WechatMiniProgram',
|
||||
]);
|
||||
|
||||
echo "Calling prepay via PayController...\n";
|
||||
$controller = new \addons\shopro\controller\Pay();
|
||||
|
||||
try {
|
||||
$controller->prepay();
|
||||
} catch (\think\exception\HttpResponseException $e) {
|
||||
$data = $e->getResponse()->getData();
|
||||
echo "Prepay Result Data:\n";
|
||||
print_r($data);
|
||||
} catch (\Exception $e) {
|
||||
echo "Exception: " . $e->getMessage() . " at " . $e->getFile() . ":" . $e->getLine() . PHP_EOL;
|
||||
} finally {
|
||||
// 恢复订单 21
|
||||
$order->status = $oldStatus;
|
||||
$order->remain_pay_fee = $oldRemainFee;
|
||||
$order->save();
|
||||
echo "Order 21 restored to status: {$oldStatus}\n";
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户