fix(admin): 下线退款重发功能并优化用户详情页布局
- 移除后台订单和支付流水的退款重发按钮及接口 - 新增用户详情页分区导航和资金流水筛选功能 - 升级账号安全页面为企业资质认证功能 - 新增企业资质相关测试用例和图标 - 升级版本号至1.0.96
这个提交包含在:
@@ -33,6 +33,15 @@ function request(route, data, token, html) { return new Promise((resolve, reject
|
||||
response = await request('/s.php/index/login', null, null, true);
|
||||
let csrf = (response.text.match(/name="__token__"[^>]*value="([^"]+)"/) || [])[1]; assert.ok(csrf, 'admin login CSRF');
|
||||
result = JSON.parse((await request('/s.php/index/login', {username: process.env.TEST_ADMIN_USER || 'admin', password: process.env.TEST_ADMIN_PASSWORD, __token__: csrf})).text); assert.strictEqual(result.code, 1, result.msg);
|
||||
response = await request('/s.php/user/user/detail/ids/' + uid, null, null, true);
|
||||
assert.strictEqual(response.status, 200); assert.ok(response.text.includes('营业执照图片')); assert.ok(response.text.includes(image));
|
||||
assert.ok(response.text.includes('提交时间')); assert.ok(response.text.includes('退款前')); assert.ok(response.text.includes('最近 6 条'));
|
||||
response = await request('/s.php/order/index?scope_user_id=' + uid + '&limit=1');
|
||||
result = JSON.parse(response.text); assert.strictEqual(Number(result.total), Number(sql(`SELECT COUNT(*) FROM fa_order WHERE user_id=${uid}`)), 'orders scoped to user');
|
||||
response = await request('/s.php/wallet_log/index?scope_user_id=' + uid + '&limit=1');
|
||||
result = JSON.parse(response.text); assert.strictEqual(Number(result.total), Number(sql(`SELECT COUNT(*) FROM fa_wallet_log WHERE user_type='user' AND user_id=${uid}`)), 'wallet logs scoped to user');
|
||||
response = await request('/s.php/wallet_log/index?scope_user_id=' + uid, null, null, true);
|
||||
assert.strictEqual(response.status, 200); assert.ok(response.text.includes('table'), 'scoped wallet page renders');
|
||||
// Unselected accounts have a default user_type but must not appear under personal users.
|
||||
sql(`UPDATE fa_user SET identity_selected=0 WHERE id=${uid}`);
|
||||
response = await request('/s.php/user/user/index?filter=' + encodeURIComponent(JSON.stringify({user_type:'personal'})) + '&op=' + encodeURIComponent(JSON.stringify({user_type:'='})) + '&limit=1000');
|
||||
|
||||
46
tests/fund_safety_regression.php
普通文件
46
tests/fund_safety_regression.php
普通文件
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
define('APP_PATH', __DIR__ . '/../server/application/');
|
||||
require __DIR__ . '/../server/thinkphp/base.php';
|
||||
\think\App::initCommon();
|
||||
use app\common\library\PaymentService;
|
||||
use think\Db;
|
||||
$failures = [];
|
||||
function check($name, callable $test) { global $failures; try { $test(); echo "PASS $name\n"; } catch (\Throwable $e) { $failures[] = "$name: " . $e->getMessage(); echo "FAIL $name: " . $e->getMessage() . "\n"; } }
|
||||
Db::startTrans();
|
||||
try {
|
||||
$uid = (int)Db::name('user')->value('id');
|
||||
$user = Db::name('user')->where('id',$uid)->find();
|
||||
$base = Db::name('order')->find();
|
||||
if (!$user || !$base) throw new RuntimeException('Missing local test fixtures');
|
||||
$tag = bin2hex(random_bytes(6));
|
||||
$payId = Db::name('pay_order')->insertGetId(['out_trade_no'=>'TREC'.$tag,'order_id'=>0,'order_no'=>'','user_id'=>$uid,'scene'=>'recharge','openid'=>'TEST','amount'=>'1.00','status'=>'refunded','refund_amount'=>'1.00','refund_status'=>'success']);
|
||||
$tx = ['trade_state'=>'SUCCESS','amount'=>['total'=>100],'transaction_id'=>'TEST'];
|
||||
check('refunded recharge cannot be credited again', function() use($uid,$payId,$tag,$tx) {
|
||||
$before=Db::name('user')->where('id',$uid)->value('money');
|
||||
try { PaymentService::confirmRechargePay('TREC'.$tag,$tx); } catch (\Throwable $e) {}
|
||||
$pay=Db::name('pay_order')->where('id',$payId)->find(); $after=Db::name('user')->where('id',$uid)->value('money');
|
||||
if ($pay['status'] !== 'refunded' || (float)$before !== (float)$after) throw new RuntimeException('refunded recharge credited again');
|
||||
});
|
||||
$wrongId=Db::name('pay_order')->insertGetId(['out_trade_no'=>'TORD'.$tag,'order_id'=>0,'order_no'=>'','user_id'=>$uid,'scene'=>'order','openid'=>'TEST','amount'=>'1.00','status'=>'pending']);
|
||||
check('order payment cannot be confirmed as recharge', function() use($wrongId,$tag,$tx) {
|
||||
try { PaymentService::confirmRechargePay('TORD'.$tag,$tx); } catch (\Throwable $e) {}
|
||||
if (Db::name('pay_order')->where('id',$wrongId)->value('status') !== 'pending') throw new RuntimeException('order treated as recharge');
|
||||
});
|
||||
check('stale order snapshot cannot charge twice', function() use($base,$uid,$tag) {
|
||||
unset($base['id']); $base['order_no']='TST'.$tag; $base['user_id']=$uid; $base['pay_amount']='0.01'; $base['pay_status']=0; $base['status']=0;
|
||||
$id=Db::name('order')->insertGetId($base); $stale=Db::name('order')->where('id',$id)->find();
|
||||
Db::name('order')->where('id',$id)->update(['pay_status'=>1]); Db::name('user')->where('id',$uid)->update(['money'=>'10.00']);
|
||||
try { PaymentService::payOrderByBalance($stale,$uid,'order'); } catch (\Throwable $e) {}
|
||||
if ((float)Db::name('user')->where('id',$uid)->value('money') !== 10.0) throw new RuntimeException('stale snapshot charged');
|
||||
});
|
||||
$master=Db::name('master')->find();
|
||||
if ($master) {
|
||||
$wdId=Db::name('withdraw')->insertGetId(['master_id'=>$master['id'],'amount'=>'1.00','fee'=>'0.00','arrive_amount'=>'1.00','channel'=>'wechat','account'=>'test','status'=>'done','out_bill_no'=>'TEST'.$tag,'transfer_state'=>'SUCCESS','createtime'=>time(),'updatetime'=>time()]);
|
||||
check('late transfer processing does not reopen terminal withdrawal', function() use($wdId) {
|
||||
PaymentService::syncWithdrawTransfer($wdId,['state'=>'PROCESSING']);
|
||||
if (Db::name('withdraw')->where('id',$wdId)->value('status') !== 'done') throw new RuntimeException('terminal withdrawal reopened');
|
||||
});
|
||||
}
|
||||
} finally { Db::rollback(); }
|
||||
if ($failures) exit(1);
|
||||
|
||||
在新工单中引用
屏蔽一个用户