功能:增加淘系支付宝账户筛选

This commit is contained in:
WuYongJie 2026-07-23 20:49:07 +08:00
parent 4b56c9cd07
commit cd8eb1fe41
3 changed files with 127 additions and 52 deletions

View File

@ -23,10 +23,44 @@ class MarketingTaobaoAlipayBills extends Controller
*/
public function index()
{
$storeName = trim((string) request()->query('store_name'));
$fromDate = trim((string) request()->query('from'));
$toDate = trim((string) request()->query('to'));
$query = MarketingTaobaoAlipayBill::query();
if ($storeName !== '') {
$query->where('store_name', $storeName);
}
if ($fromDate !== '' && preg_match('/^\d{4}-\d{2}-\d{2}$/', $fromDate)) {
$query->where('transaction_date', '>=', $fromDate);
}
if ($toDate !== '' && preg_match('/^\d{4}-\d{2}-\d{2}$/', $toDate)) {
$query->where('transaction_date', '<=', $toDate);
}
$storeOptions = MarketingTaobaoAlipayBill::select('store_name')
->whereNotNull('store_name')
->distinct()
->orderBy('store_name')
->pluck('store_name')
->toArray();
return view('banking.marketing_taobao_alipay_bills.index', [
'bills' => MarketingTaobaoAlipayBill::orderBy('transaction_date', 'desc')
'bills' => $query->orderBy('transaction_date', 'desc')
->orderBy('id', 'desc')
->paginate(setting('default.list_limit', 25)),
->paginate(setting('default.list_limit', 25))
->appends([
'store_name' => $storeName,
'from' => $fromDate,
'to' => $toDate,
]),
'filters' => [
'store_name' => $storeName,
'from' => $fromDate,
'to' => $toDate,
'store_options' => $storeOptions,
],
]);
}

View File

@ -148,11 +148,47 @@ class Pages extends Controller
// 淘系支付宝 - 使用独立的流水账单表(8字段)
if ($tab === 'taobao-alipay') {
$request = request();
$storeName = trim((string) $request->query('store_name'));
$fromDate = trim((string) $request->query('from'));
$toDate = trim((string) $request->query('to'));
$query = MarketingTaobaoAlipayBill::query();
if ($storeName !== '') {
$query->where('store_name', $storeName);
}
if ($fromDate !== '' && preg_match('/^\d{4}-\d{2}-\d{2}$/', $fromDate)) {
$query->where('transaction_date', '>=', $fromDate);
}
if ($toDate !== '' && preg_match('/^\d{4}-\d{2}-\d{2}$/', $toDate)) {
$query->where('transaction_date', '<=', $toDate);
}
// 筛选项下拉用的店铺列表(去重)
$storeOptions = MarketingTaobaoAlipayBill::select('store_name')
->whereNotNull('store_name')
->distinct()
->orderBy('store_name')
->pluck('store_name')
->toArray();
return [
'view' => 'banking.marketing_taobao_alipay_bills.partials.embedded-table',
'bills' => MarketingTaobaoAlipayBill::orderBy('transaction_date', 'desc')
'bills' => $query->orderBy('transaction_date', 'desc')
->orderBy('id', 'desc')
->paginate(setting('default.list_limit', 25)),
->paginate(setting('default.list_limit', 25))
->appends([
'store_name' => $storeName,
'from' => $fromDate,
'to' => $toDate,
]),
'filters' => [
'store_name' => $storeName,
'from' => $fromDate,
'to' => $toDate,
'store_options' => $storeOptions,
],
];
}

View File

@ -18,37 +18,7 @@
{{-- 操作工具栏 --}}
<div class="mb-4 flex flex-wrap items-end justify-between gap-3 border-b border-gray-200 pb-4">
@can('create-banking-accounts')
<div class="flex flex-wrap items-end gap-3">
<a href="{{ route('marketing-taobao-alipay-bills.create') }}"
class="inline-flex h-10 items-center gap-2 rounded-lg bg-green px-4 text-sm text-white hover:bg-green-700">
<span class="material-icons text-base" aria-hidden="true">add</span>
{{ trans('marketing_taobao_alipay_bills.add_bill') }}
</a>
<form method="POST" action="{{ route('marketing-taobao-alipay-bills.import') }}"
enctype="multipart/form-data" class="flex flex-wrap items-end gap-3">
@csrf
<div>
<label for="bills-import-embedded" class="mb-1 block text-xs font-medium text-gray-600">
{{ trans('marketing_taobao_alipay_bills.choose_file') }}
</label>
<input id="bills-import-embedded" type="file" name="import"
accept=".xlsx,.xls,.csv" required
class="block max-w-xs text-sm text-gray-600" />
</div>
<button type="submit"
class="inline-flex h-10 items-center gap-2 rounded-lg bg-green px-4 text-sm text-white hover:bg-green-700">
<span class="material-icons text-base" aria-hidden="true">upload_file</span>
{{ trans('marketing_taobao_alipay_bills.bulk_upload') }}
</button>
</form>
<a href="{{ route('marketing-taobao-alipay-bills.template') }}"
class="inline-flex h-10 items-center gap-2 rounded-lg border border-gray-300 bg-white px-4 text-sm text-gray-700 hover:bg-gray-50">
<span class="material-icons text-base" aria-hidden="true">file_download</span>
{{ trans('marketing_taobao_alipay_bills.download_template') }}
</a>
</div>
@endcan
<div></div>
<div class="flex items-center gap-3">
@can('update-banking-accounts')
<button type="submit" form="marketing-taobao-alipay-bills-export-form"
@ -68,6 +38,57 @@
</div>
@endif
{{-- 筛选器:按店铺 + 日期范围 --}}
@php
$filters = $filters ?? ['store_name' => '', 'from' => '', 'to' => '', 'store_options' => []];
$storeOptions = is_array($filters['store_options'] ?? null) ? $filters['store_options'] : [];
$currentStore = (string) ($filters['store_name'] ?? '');
$currentFrom = (string) ($filters['from'] ?? '');
$currentTo = (string) ($filters['to'] ?? '');
@endphp
<form method="GET" action="{{ request()->url() }}"
class="mb-4 rounded-lg border border-gray-200 bg-gray-50 px-4 py-3">
<div class="flex flex-wrap items-end gap-4">
<div>
<label for="filter-store" class="mb-1 block text-xs font-medium text-gray-600">店铺名称</label>
<select id="filter-store" name="store_name"
class="h-10 min-w-[200px] rounded-md border border-gray-300 bg-white px-3 text-sm">
<option value="">全部店铺</option>
@foreach ($storeOptions as $opt)
<option value="{{ $opt }}" @selected($opt === $currentStore)>{{ $opt }}</option>
@endforeach
</select>
</div>
<div>
<label for="filter-from" class="mb-1 block text-xs font-medium text-gray-600">交易日期 起</label>
<input id="filter-from" type="date" name="from" value="{{ $currentFrom }}"
class="h-10 rounded-md border border-gray-300 bg-white px-3 text-sm" />
</div>
<div>
<label for="filter-to" class="mb-1 block text-xs font-medium text-gray-600">交易日期 止</label>
<input id="filter-to" type="date" name="to" value="{{ $currentTo }}"
class="h-10 rounded-md border border-gray-300 bg-white px-3 text-sm" />
</div>
<div class="flex items-end gap-2">
<button type="submit"
class="inline-flex h-10 items-center gap-2 rounded-md bg-[#856632] px-4 text-sm text-white hover:opacity-90">
<span class="material-icons text-base" aria-hidden="true">search</span>
筛选
</button>
<a href="{{ request()->url() }}"
class="inline-flex h-10 items-center gap-2 rounded-md border border-gray-300 bg-white px-4 text-sm text-gray-700 hover:bg-gray-100">
<span class="material-icons text-base" aria-hidden="true">clear</span>
清除
</a>
</div>
@if ($currentStore !== '' || $currentFrom !== '' || $currentTo !== '')
<div class="ml-auto self-center text-xs text-gray-500">
共匹配 {{ $bills->total() }} 条
</div>
@endif
</div>
</form>
{{-- 8列数据表格 --}}
<div class="bill-table-wrapper">
<table class="bill-table divide-y divide-gray-200">
@ -89,13 +110,12 @@
<th class="text-right">{{ trans('marketing_taobao_alipay_bills.operation_amount') }}</th>
<th class="text-right">{{ trans('marketing_taobao_alipay_bills.balance_after') }}</th>
<th>{{ trans('marketing_taobao_alipay_bills.notes') }}</th>
<th class="text-right">{{ trans('general.actions') }}</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100 bg-white">
@if ($bills->isEmpty())
<tr>
<td colspan="10" class="px-5 py-10 text-center text-gray-400">
<td colspan="9" class="px-5 py-10 text-center text-gray-400">
{{ trans('marketing_taobao_alipay_bills.no_records') }}
</td>
</tr>
@ -125,21 +145,6 @@
<td class="max-w-xs truncate" title="{{ $bill->notes }}">
{{ \Illuminate\Support\Str::limit($bill->notes, 20) }}
</td>
<td class="text-right whitespace-nowrap">
@can('update-banking-accounts')
<a href="{{ route('marketing-taobao-alipay-bills.edit', $bill) }}"
class="text-purple hover:underline mr-3">{{ trans('general.edit') }}</a>
@endcan
@can('delete-banking-accounts')
<form action="{{ route('marketing-taobao-alipay-bills.destroy', $bill) }}"
method="POST" class="inline"
onsubmit="return confirm('{{ trans('general.delete_confirm') }}')">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:underline">{{ trans('general.delete') }}</button>
</form>
@endcan
</td>
</tr>
@endforeach
@endif