接入店铺台账负责人字段 #663
@ -6,6 +6,7 @@ use Illuminate\Database\DatabaseManager;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Modules\EcommerceFinance\Repositories\BusinessInformationMirrorRepository;
|
||||
use Modules\EcommerceFinance\Repositories\JushuitanShopBalanceRepository;
|
||||
use Modules\EcommerceFinance\Repositories\StoreAccountMirrorRepository;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@ -20,6 +21,7 @@ class FinanceLedgerShopDirectory
|
||||
public function __construct(
|
||||
private readonly BusinessInformationMirrorRepository $storeInformation,
|
||||
private readonly StoreReportPeriodBuilder $periods,
|
||||
private readonly StoreAccountMirrorRepository $storeAccounts,
|
||||
private readonly DatabaseManager $databases,
|
||||
) {
|
||||
}
|
||||
@ -34,6 +36,8 @@ class FinanceLedgerShopDirectory
|
||||
* company_name:?string,
|
||||
* account_short:?string,
|
||||
* status:string,
|
||||
* store_manager:?string,
|
||||
* department_manager:?string,
|
||||
* payout_account:?string,
|
||||
* shop_balance:float,
|
||||
* shop_balance_date:?string,
|
||||
@ -72,6 +76,7 @@ class FinanceLedgerShopDirectory
|
||||
|
||||
$financeShops = $this->financeShops();
|
||||
$accountMaster = $this->accountMaster();
|
||||
$ownership = $this->storeOwnership();
|
||||
$rows = [];
|
||||
foreach ($openStores as $store) {
|
||||
$erpStoreName = trim((string) ($store['erp_store_name'] ?? ''));
|
||||
@ -95,6 +100,17 @@ class FinanceLedgerShopDirectory
|
||||
$this->nullableString($financeShop->account_short ?? null),
|
||||
$accountMaster,
|
||||
);
|
||||
$storeManager = $this->nullableString($store['store_manager'] ?? null);
|
||||
$departmentManager = $this->nullableString($store['department_manager'] ?? null);
|
||||
$ownershipMatch = $ownership[StoreAccountMirrorRepository::storeNameKey($erpStoreName)] ?? null;
|
||||
if ($ownershipMatch !== null) {
|
||||
if (trim((string) ($ownershipMatch['operation_owner'] ?? '')) !== '') {
|
||||
$storeManager = trim((string) $ownershipMatch['operation_owner']);
|
||||
}
|
||||
if (trim((string) ($ownershipMatch['operation_department_head'] ?? '')) !== '') {
|
||||
$departmentManager = trim((string) $ownershipMatch['operation_department_head']);
|
||||
}
|
||||
}
|
||||
$rows[] = [
|
||||
'id' => (int) ($store['id'] ?? 0),
|
||||
'account_match_key' => $this->normalizeAccountValue($storePayoutAccount ?? $financePayoutAccount),
|
||||
@ -103,6 +119,8 @@ class FinanceLedgerShopDirectory
|
||||
'company_name' => $companyName,
|
||||
'account_short' => $account['account_short'] ?? null,
|
||||
'status' => '在营',
|
||||
'store_manager' => $storeManager,
|
||||
'department_manager' => $departmentManager,
|
||||
'payout_account' => $this->nullableString($account['account_no'] ?? null),
|
||||
'shop_balance' => round((float) ($financeShop->shop_balance ?? 0), 2),
|
||||
'shop_balance_date' => $this->nullableString($financeShop->shop_balance_date ?? null),
|
||||
@ -113,6 +131,20 @@ class FinanceLedgerShopDirectory
|
||||
return $this->propagateAccountLinks($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* 与店铺维度报表一致:店铺账号镜像有值时覆盖店铺资料中的负责人字段。
|
||||
*
|
||||
* @return array<string,array{operation_owner:string,operation_department_head:string,operation_director:string,profit_center:string}>
|
||||
*/
|
||||
private function storeOwnership(): array
|
||||
{
|
||||
try {
|
||||
return $this->storeAccounts->ownershipByStoreName();
|
||||
} catch (Throwable) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/** @return array{exact:array<string,object>,normalized:array<string,object>} */
|
||||
private function financeShops(): array
|
||||
{
|
||||
|
||||
@ -848,6 +848,8 @@ class FinanceLedgerPageData
|
||||
'company_name' => ['sort' => 'company_name', 'type' => 'text'],
|
||||
'account_short' => ['sort' => 'account_short', 'type' => 'text'],
|
||||
'status' => ['sort' => 'status', 'type' => 'text'],
|
||||
'store_manager' => ['sort' => 'shop_name', 'type' => 'text'],
|
||||
'department_manager' => ['sort' => 'shop_name', 'type' => 'text'],
|
||||
'payout_account' => ['sort' => 'payout_account', 'type' => 'text'],
|
||||
'shop_balance' => ['sort' => 'shop_balance', 'type' => 'number'],
|
||||
'remark' => ['sort' => 'remark', 'type' => 'text'],
|
||||
|
||||
@ -115,6 +115,8 @@
|
||||
['company_name', '店铺主体', 'text'],
|
||||
['account_short', '账户简称', 'text'],
|
||||
['status', '店铺状态', 'text'],
|
||||
['store_manager', '店铺负责人', 'text'],
|
||||
['department_manager', '部门负责人', 'text'],
|
||||
['payout_account', '回款账户', 'text'],
|
||||
['shop_balance', '店铺余额', 'number', ['headerClass' => 'num', 'align' => 'end']],
|
||||
['remark', '备注', 'text'],
|
||||
@ -801,7 +803,7 @@
|
||||
@endif
|
||||
<div class="ledger-summary"><div class="ledger-summary__item"><span>店铺数</span><b>{{ number_format((int) ($ledgerShopSummary['count'] ?? 0)) }}</b></div><div class="ledger-summary__item"><span>店铺余额合计</span><b>{{ $money($ledgerShopSummary['balance'] ?? 0) }}</b></div><div class="ledger-summary__item"><span>余额口径</span><b>{{ $shopBalanceDate ? '上一晚店铺余额(' . $shopBalanceDate . ')' : '尚未同步' }}</b></div></div>
|
||||
<div class="ledger-table-wrap">
|
||||
<table class="ledger-table" style="min-width:56rem"><thead><tr>
|
||||
<table class="ledger-table" style="min-width:66rem"><thead><tr>
|
||||
@foreach ($ledgerTableHeaders['shops'] as $header)
|
||||
@include('business.pages.financial-ledger.partials.table-header', [
|
||||
'column' => $header[0],
|
||||
@ -815,7 +817,7 @@
|
||||
])
|
||||
@endforeach
|
||||
</tr></thead>
|
||||
<tbody>@forelse ($ledgerShops as $row)<tr><td>{{ $row->platform }}</td><td>{{ $row->shop_name }}</td><td>{{ $row->company_name }}</td><td>{{ $row->account_short }}</td><td><span class="{{ $row->status === '在营' ? 'success' : 'muted' }}">{{ $row->status }}</span></td><td>{{ $row->payout_account }}</td><td class="num" @if ($row->shop_balance_date ?? null) title="余额日期:{{ $row->shop_balance_date }}" @endif>{{ $money($row->shop_balance) }}</td><td>{{ $row->remark }}</td></tr>@empty<tr><td colspan="8"><div class="ledger-empty">没有匹配的店铺数据。</div></td></tr>@endforelse</tbody>
|
||||
<tbody>@forelse ($ledgerShops as $row)<tr><td>{{ $row->platform }}</td><td>{{ $row->shop_name }}</td><td>{{ $row->company_name }}</td><td>{{ $row->account_short }}</td><td><span class="{{ $row->status === '在营' ? 'success' : 'muted' }}">{{ $row->status }}</span></td><td>{{ $row->store_manager ?? '' }}</td><td>{{ $row->department_manager ?? '' }}</td><td>{{ $row->payout_account }}</td><td class="num" @if ($row->shop_balance_date ?? null) title="余额日期:{{ $row->shop_balance_date }}" @endif>{{ $money($row->shop_balance) }}</td><td>{{ $row->remark }}</td></tr>@empty<tr><td colspan="{{ count($ledgerTableHeaders['shops']) }}"><div class="ledger-empty">没有匹配的店铺数据。</div></td></tr>@endforelse</tbody>
|
||||
</table>
|
||||
@include('business.pages.financial-ledger.partials.pagination', [
|
||||
'rows' => $ledgerShops,
|
||||
|
||||
@ -130,8 +130,8 @@ class FinanceLedgerHeaderControlsTest extends FeatureTestCase
|
||||
$response = $this->loginAs()->get($this->pageUrl());
|
||||
$html = $response->assertOk()->getContent();
|
||||
|
||||
$this->assertSame(63, preg_match_all('/<details\b[^>]*data-ledger-header-details/', $html));
|
||||
$this->assertSame(63, preg_match_all('/<span\b[^>]*data-ledger-header-label/', $html));
|
||||
$this->assertSame(65, preg_match_all('/<details\b[^>]*data-ledger-header-details/', $html));
|
||||
$this->assertSame(65, preg_match_all('/<span\b[^>]*data-ledger-header-label/', $html));
|
||||
$this->assertSame(2, preg_match_all('/<select name="transactions_filter_value"/', $html));
|
||||
$this->assertSame(1, preg_match_all('/<input\b[^>]*name="transactions_filter_value"[^>]*list="ledger-header-options-transactions-effective_account_short"/', $html));
|
||||
$this->assertStringContainsString(
|
||||
@ -168,6 +168,8 @@ class FinanceLedgerHeaderControlsTest extends FeatureTestCase
|
||||
$this->assertStringContainsString('data-ledger-header-label>平台</span>', $headerHtml);
|
||||
$this->assertStringContainsString('data-ledger-header-label>ERP系统店铺名称</span>', $headerHtml);
|
||||
$this->assertStringContainsString('data-ledger-header-label>店铺主体</span>', $headerHtml);
|
||||
$this->assertStringContainsString('data-ledger-header-label>店铺负责人</span>', $headerHtml);
|
||||
$this->assertStringContainsString('data-ledger-header-label>部门负责人</span>', $headerHtml);
|
||||
$this->assertStringNotContainsString('data-ledger-header-label>店铺名称</span>', $headerHtml);
|
||||
$this->assertStringNotContainsString('data-ledger-header-label>所属公司</span>', $headerHtml);
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ namespace Tests\Feature\Business;
|
||||
use App\Models\Auth\Permission;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\EcommerceFinance\Repositories\BusinessInformationMirrorRepository;
|
||||
use Modules\EcommerceFinance\Repositories\StoreAccountMirrorRepository;
|
||||
use Modules\EcommerceFinance\Services\StoreReportPeriodBuilder;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
@ -86,6 +87,8 @@ class FinanceLedgerShopDirectoryTest extends FeatureTestCase
|
||||
'erp_store_name' => '天猫-报表测试店',
|
||||
'company_name' => '历史主体',
|
||||
'store_status' => '0',
|
||||
'store_manager' => '原店铺负责人',
|
||||
'department_manager' => '原部门负责人',
|
||||
'withdrawal_account' => 'ABC-1234',
|
||||
];
|
||||
$closedStore = [
|
||||
@ -102,6 +105,8 @@ class FinanceLedgerShopDirectoryTest extends FeatureTestCase
|
||||
'erp_store_name' => '淘宝-无主体店',
|
||||
'company_name' => null,
|
||||
'store_status' => '0',
|
||||
'store_manager' => '无主体店铺负责人',
|
||||
'department_manager' => '无主体部门负责人',
|
||||
'withdrawal_account' => 'PAY-8888',
|
||||
];
|
||||
$openStoreWithExcludedBank = [
|
||||
@ -110,6 +115,8 @@ class FinanceLedgerShopDirectoryTest extends FeatureTestCase
|
||||
'erp_store_name' => '拼多多-网商店',
|
||||
'company_name' => null,
|
||||
'store_status' => '0',
|
||||
'store_manager' => '网商店铺负责人',
|
||||
'department_manager' => '网商部门负责人',
|
||||
'withdrawal_account' => 'NET-7777',
|
||||
];
|
||||
$openStoreWithKnownSharedPayout = [
|
||||
@ -118,6 +125,8 @@ class FinanceLedgerShopDirectoryTest extends FeatureTestCase
|
||||
'erp_store_name' => '天猫-同账户甲',
|
||||
'company_name' => null,
|
||||
'store_status' => '0',
|
||||
'store_manager' => '同账户甲负责人',
|
||||
'department_manager' => '同账户甲部门负责人',
|
||||
'withdrawal_account' => 'LEGACY-5555',
|
||||
];
|
||||
$openStoreWithUnknownSharedPayout = [
|
||||
@ -126,6 +135,8 @@ class FinanceLedgerShopDirectoryTest extends FeatureTestCase
|
||||
'erp_store_name' => '淘宝-同账户乙',
|
||||
'company_name' => null,
|
||||
'store_status' => '0',
|
||||
'store_manager' => '同账户乙负责人',
|
||||
'department_manager' => '同账户乙部门负责人',
|
||||
'withdrawal_account' => 'LEGACY5555',
|
||||
];
|
||||
|
||||
@ -166,6 +177,17 @@ class FinanceLedgerShopDirectoryTest extends FeatureTestCase
|
||||
],
|
||||
],
|
||||
]);
|
||||
$this->mock(StoreAccountMirrorRepository::class)
|
||||
->shouldReceive('ownershipByStoreName')
|
||||
->once()
|
||||
->andReturn([
|
||||
'天猫-报表测试店' => [
|
||||
'operation_owner' => '运营负责人',
|
||||
'operation_department_head' => '运营部门负责人',
|
||||
'operation_director' => '运营总监',
|
||||
'profit_center' => '运营中心',
|
||||
],
|
||||
]);
|
||||
|
||||
$html = $this->loginAs()->get($this->pageUrl())->assertOk()->getContent();
|
||||
$panelStart = strpos($html, 'id="ledger-panel-shops"');
|
||||
@ -177,6 +199,10 @@ class FinanceLedgerShopDirectoryTest extends FeatureTestCase
|
||||
$this->assertStringContainsString('天猫', $shopHtml);
|
||||
$this->assertStringContainsString('天猫-报表测试店', $shopHtml);
|
||||
$this->assertStringContainsString('当前存续主体', $shopHtml);
|
||||
$this->assertStringContainsString('运营负责人', $shopHtml);
|
||||
$this->assertStringContainsString('运营部门负责人', $shopHtml);
|
||||
$this->assertStringContainsString('无主体店铺负责人', $shopHtml);
|
||||
$this->assertStringContainsString('无主体部门负责人', $shopHtml);
|
||||
$this->assertStringContainsString('淘宝-无主体店', $shopHtml);
|
||||
$this->assertStringContainsString('拼多多-网商店', $shopHtml);
|
||||
$this->assertStringContainsString('天猫-同账户甲', $shopHtml);
|
||||
@ -189,6 +215,8 @@ class FinanceLedgerShopDirectoryTest extends FeatureTestCase
|
||||
$this->assertGreaterThanOrEqual(2, substr_count($shopHtml, '>MASTER-OTHER</td>'));
|
||||
$this->assertStringNotContainsString('京东-已关店', $shopHtml);
|
||||
$this->assertStringNotContainsString('历史主体', $shopHtml);
|
||||
$this->assertStringNotContainsString('原店铺负责人', $shopHtml);
|
||||
$this->assertStringNotContainsString('原部门负责人', $shopHtml);
|
||||
$this->assertStringNotContainsString('测试公司', $shopHtml);
|
||||
$this->assertStringNotContainsString('支付宝账户', $shopHtml);
|
||||
$this->assertStringNotContainsString('网商银行账户', $shopHtml);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user