feat(admin-frontend): 补齐活跃筛选与支付快照能力
新增用户管理“活跃状态”高级筛选,并在后端支持 activity_status 复合规则,支持按活跃与非活跃筛选用户。 补齐订单支付成功快照落库与后台展示,保存支付渠道、 支付方法、实付金额和支付 IP,并在订单详情中优先展示。 同时增强节点页在线/离线筛选与批量删除、仪表盘快捷入口, 并修复已关闭工单再次回复后自动重开的统一语义。 附带同步测试、迁移、CI 工作流命名及知识库记录
This commit is contained in:
@@ -23,7 +23,7 @@ class PaymentController extends Controller
|
||||
return $this->fail([422, 'verify error']);
|
||||
}
|
||||
HookManager::call('payment.notify.verified', $verify);
|
||||
if (!$this->handle($verify['trade_no'], $verify['callback_no'])) {
|
||||
if (!$this->handle($verify)) {
|
||||
return $this->fail([400, 'handle error']);
|
||||
}
|
||||
return (isset($verify['custom_result']) ? $verify['custom_result'] : 'success');
|
||||
@@ -33,8 +33,17 @@ class PaymentController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
private function handle($tradeNo, $callbackNo)
|
||||
/**
|
||||
* @param array<string, mixed> $verify
|
||||
*/
|
||||
private function handle(array $verify)
|
||||
{
|
||||
$tradeNo = (string) ($verify['trade_no'] ?? '');
|
||||
$callbackNo = (string) ($verify['callback_no'] ?? '');
|
||||
if ($tradeNo === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$order = Order::where('trade_no', $tradeNo)->first();
|
||||
if (!$order) {
|
||||
return $this->fail([400202, 'order is not found']);
|
||||
@@ -42,7 +51,7 @@ class PaymentController extends Controller
|
||||
if ($order->status !== Order::STATUS_PENDING)
|
||||
return true;
|
||||
$orderService = new OrderService($order);
|
||||
if (!$orderService->paid($callbackNo)) {
|
||||
if (!$orderService->paid($callbackNo, $verify)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,9 +67,6 @@ class TicketController extends Controller
|
||||
if (!$ticket) {
|
||||
return $this->fail([400, __('Ticket does not exist')]);
|
||||
}
|
||||
if ($ticket->status) {
|
||||
return $this->fail([400, __('The ticket is closed and cannot be replied')]);
|
||||
}
|
||||
if ((int) admin_setting('ticket_must_wait_reply', 0) && $request->user()->id == $this->getLastMessage($ticket->id)->user_id) {
|
||||
return $this->fail(codeResponse: [400, __('Please wait for the technical enginneer to reply')]);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class OrderController extends Controller
|
||||
|
||||
public function detail(Request $request)
|
||||
{
|
||||
$order = Order::with(['user', 'plan', 'commission_log', 'invite_user'])->find($request->input('id'));
|
||||
$order = Order::with(['user', 'plan', 'commission_log', 'invite_user', 'payment'])->find($request->input('id'));
|
||||
if (!$order)
|
||||
return $this->fail([400202, '订单不存在']);
|
||||
if ($order->surplus_order_ids) {
|
||||
|
||||
@@ -70,6 +70,14 @@ class UserController extends Controller
|
||||
// Build one filter query condition.
|
||||
private function buildFilterQuery(Builder|QueryBuilder $query, string $field, mixed $value): void
|
||||
{
|
||||
if ($field === 'activity_status') {
|
||||
$activityStatus = $this->resolveActivityStatusValue($value);
|
||||
if ($activityStatus !== null) {
|
||||
$this->applyActivityStatusFilter($query, $activityStatus);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理关联查询
|
||||
if (str_contains($field, '.')) {
|
||||
if (!method_exists($query, 'whereHas')) {
|
||||
@@ -119,6 +127,60 @@ class UserController extends Controller
|
||||
$this->applyQueryCondition($query, $queryField, $operator, $filterValue);
|
||||
}
|
||||
|
||||
private function resolveActivityStatusValue(mixed $value): ?bool
|
||||
{
|
||||
if (is_bool($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (is_numeric($value)) {
|
||||
$numericValue = (int) $value;
|
||||
return match ($numericValue) {
|
||||
1 => true,
|
||||
0 => false,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
if (!is_string($value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$normalized = trim($value);
|
||||
if (str_contains($normalized, ':')) {
|
||||
[$operator, $normalized] = explode(':', $normalized, 2);
|
||||
if (strtolower($operator) !== 'eq') {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return match (strtolower(trim($normalized))) {
|
||||
'1', 'true', 'active', 'yes' => true,
|
||||
'0', 'false', 'inactive', 'no' => false,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
private function applyActivityStatusFilter(Builder|QueryBuilder $query, bool $active): void
|
||||
{
|
||||
$threshold = now()->subMonths(6);
|
||||
|
||||
if ($active) {
|
||||
$query->whereNotNull('plan_id')
|
||||
->whereRaw('COALESCE(transfer_enable, 0) > COALESCE(u, 0) + COALESCE(d, 0)')
|
||||
->whereNotNull('last_online_at')
|
||||
->where('last_online_at', '>=', $threshold);
|
||||
return;
|
||||
}
|
||||
|
||||
$query->where(function ($activityQuery) use ($threshold) {
|
||||
$activityQuery->whereNull('plan_id')
|
||||
->orWhereRaw('COALESCE(transfer_enable, 0) <= COALESCE(u, 0) + COALESCE(d, 0)')
|
||||
->orWhereNull('last_online_at')
|
||||
->orWhere('last_online_at', '<', $threshold);
|
||||
});
|
||||
}
|
||||
|
||||
// Apply sorting rules to the query builder.
|
||||
private function applySorting(Request $request, Builder|QueryBuilder $builder): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user