merge: 同步最新 main
This commit is contained in:
commit
e0b091bf8e
182
app/Business/BusinessSummaryCards.php
Normal file
182
app/Business/BusinessSummaryCards.php
Normal file
@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace App\Business;
|
||||
|
||||
/**
|
||||
* 经营报表页面顶部的小格子指标。
|
||||
*
|
||||
* 汇总卡片只描述当前表本身,不把其他目录的数据拼成跨表大看板。
|
||||
*/
|
||||
class BusinessSummaryCards
|
||||
{
|
||||
/**
|
||||
* @param array<string,mixed> $summary
|
||||
* @return list<array{label:string,value:mixed,hint:string,format:string,query:array<string,mixed>,tone:string}>
|
||||
*/
|
||||
public function forPage(string $key, array $summary = []): array
|
||||
{
|
||||
return match ($key) {
|
||||
'store-management/store-report' => $summary === [] ? [] : $this->storeReportCards($summary),
|
||||
'company-management/subject-operating-report' => $summary === [] ? [] : $this->subjectOperatingReportCards($summary),
|
||||
'store-management/internal-flow-report' => $summary === [] ? [] : $this->internalFlowReportCards($summary),
|
||||
'company-management/company-cost-arrangement' => $this->companyCostArrangementCards(),
|
||||
'company-management/tax-forecast' => $this->taxForecastCards(),
|
||||
'company-management/personnel-inventory' => $this->personnelInventoryCards(),
|
||||
default => [],
|
||||
};
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $summary */
|
||||
private function subjectOperatingReportCards(array $summary): array
|
||||
{
|
||||
$ready = (bool) ($summary['company_status_ready'] ?? false);
|
||||
$previousLabel = (string) ($summary['previous_month_label'] ?? '上月');
|
||||
$currentLabel = (string) ($summary['current_month_label'] ?? '当月');
|
||||
$previousStores = (int) ($summary['previous_income_entities'] ?? 0);
|
||||
$currentStores = (int) ($summary['current_income_entities'] ?? 0);
|
||||
|
||||
if (! $ready) {
|
||||
return [
|
||||
$this->card('正常存续主体', '—', '公司资料镜像未就绪,暂时无法剔除注销主体', [], 'text', 'warning'),
|
||||
$this->card('上月收入', '—', '公司资料镜像未就绪', [], 'text', 'warning'),
|
||||
$this->card('当月收入', '—', '公司资料镜像未就绪', [], 'text', 'warning'),
|
||||
$this->card('小规模纳税人', '—', '公司资料镜像未就绪', [], 'text'),
|
||||
$this->card('一般纳税人', '—', '公司资料镜像未就绪', [], 'text'),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
$this->card('正常存续主体', $summary['normal'] ?? 0, '只统计公司台账标签为保留的主体', ['company_status' => '正常'], 'integer', 'accent'),
|
||||
$this->card($previousLabel . '收入', $summary['previous_income'] ?? 0, $previousStores . ' 个存续主体有收入', [
|
||||
'company_status' => '正常',
|
||||
'sort' => $summary['previous_month_key'] ?? null,
|
||||
'direction' => 'desc',
|
||||
], 'amount', 'success'),
|
||||
$this->card($currentLabel . '收入', $summary['current_month_income'] ?? 0, $currentStores . ' 个存续主体有收入', [
|
||||
'company_status' => '正常',
|
||||
'sort' => $summary['current_month_key'] ?? null,
|
||||
'direction' => 'desc',
|
||||
], 'amount', 'warning'),
|
||||
$this->card('小规模纳税人', $summary['small_taxpayer'] ?? 0, '正常存续主体中的小规模纳税人', [
|
||||
'company_status' => '正常',
|
||||
'tax_type' => '小规模纳税人',
|
||||
]),
|
||||
$this->card('一般纳税人', $summary['general_taxpayer'] ?? 0, '正常存续主体中的一般纳税人', [
|
||||
'company_status' => '正常',
|
||||
'tax_type' => '一般纳税人',
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $summary */
|
||||
private function storeReportCards(array $summary): array
|
||||
{
|
||||
$previousLabel = (string) ($summary['previous_month_label'] ?? '上月');
|
||||
$currentLabel = (string) ($summary['current_month_label'] ?? '当月');
|
||||
$normalStores = (int) ($summary['normal_stores'] ?? 0);
|
||||
$previousStores = (int) ($summary['previous_month_stores'] ?? 0);
|
||||
$currentStores = (int) ($summary['current_month_stores'] ?? 0);
|
||||
$previousShare = $normalStores > 0
|
||||
? number_format($previousStores / $normalStores * 100, 1) . '%'
|
||||
: '0.0%';
|
||||
|
||||
return [
|
||||
$this->card('正常存续店铺', $normalStores, '只统计开店中店铺,不含关店和已注销', ['status' => '0'], 'integer', 'accent'),
|
||||
$this->card($previousLabel . '销量', $summary['previous_month_sales'] ?? 0, $previousStores . ' 家存续店铺有销量', [
|
||||
'status' => '0',
|
||||
'sort' => $summary['previous_month_key'] ?? null,
|
||||
'direction' => 'desc',
|
||||
], 'amount', 'success'),
|
||||
$this->card($currentLabel . '销量', $summary['current_month_sales'] ?? 0, $currentStores . ' 家存续店铺有销量', [
|
||||
'status' => '0',
|
||||
'sort' => $summary['current_month_key'] ?? null,
|
||||
'direction' => 'desc',
|
||||
], 'amount', 'warning'),
|
||||
$this->card($previousLabel . '有销量店铺', $previousStores, '占正常存续店铺 ' . $previousShare, [
|
||||
'status' => '0',
|
||||
'sort' => $summary['previous_month_key'] ?? null,
|
||||
'direction' => 'desc',
|
||||
]),
|
||||
$this->card($currentLabel . '有销量店铺', $currentStores, $currentStores === 0 ? '当前还未同步当月销量' : '正常存续店铺中当月已有销量', [
|
||||
'status' => '0',
|
||||
'sort' => $summary['current_month_key'] ?? null,
|
||||
'direction' => 'desc',
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $summary */
|
||||
private function internalFlowReportCards(array $summary): array
|
||||
{
|
||||
return [
|
||||
$this->card('公司数', $summary['companies'] ?? 0, '当前筛选内内部流转公司', [], 'integer', 'accent'),
|
||||
$this->card('预计销量合计', $summary['projected_sales'] ?? 0, '当前筛选内预计销量合计', [
|
||||
'sort' => 'projected_sales',
|
||||
'direction' => 'desc',
|
||||
], 'amount'),
|
||||
$this->card('已收票合计', $summary['receipt_total'] ?? 0, '供应商、关联公司与内部流转收票合计', [
|
||||
'sort' => 'receipt_total',
|
||||
'direction' => 'desc',
|
||||
], 'amount', 'success'),
|
||||
$this->card('剩余缺口合计', $summary['remaining_gap'] ?? 0, '金额越大越应优先处理', [
|
||||
'sort' => 'remaining_gap',
|
||||
'direction' => 'desc',
|
||||
], 'amount', 'warning'),
|
||||
$this->card('平均开票比例', $summary['average_invoicing_ratio'] ?? 0, '按有比例的公司简单平均', [], 'percent'),
|
||||
];
|
||||
}
|
||||
|
||||
private function companyCostArrangementCards(): array
|
||||
{
|
||||
return [
|
||||
$this->card('数据状态', '待接入', '当前表尚无业务数据', [], 'text', 'warning'),
|
||||
$this->card('完整表头', '11 列', '包含序号,收入、成本、税金、人工等字段全部保留', [], 'text'),
|
||||
$this->card('核心结果', '预计结余 / 缺口', '当月收入预测减去成本与费用', [], 'text'),
|
||||
$this->card('缺口提示', '负值标红', '成本或费用未覆盖收入时提醒', [], 'text', 'danger'),
|
||||
$this->card('配平提示', '零或正结余标绿', '表示当月预算已覆盖', [], 'text', 'success'),
|
||||
];
|
||||
}
|
||||
|
||||
private function taxForecastCards(): array
|
||||
{
|
||||
return [
|
||||
$this->card('数据状态', '待取数', '规则已定义,业务数据尚未接入', [], 'text', 'warning'),
|
||||
$this->card('完整表头', '22 列', '包含序号、征管口径、收入、税额与备注', [], 'text'),
|
||||
$this->card('计算税种', '4 类', '增值税、附加税、印花税、所得税', [], 'text'),
|
||||
$this->card('必补口径', '2 项', '工商类型与征收方式', [], 'text', 'warning'),
|
||||
$this->card('当前记录', '0 条', '数据接入后按完整字段展示', [], 'text'),
|
||||
];
|
||||
}
|
||||
|
||||
private function personnelInventoryCards(): array
|
||||
{
|
||||
return [
|
||||
$this->card('数据状态', '待接入', '当前表尚无人员数据', [], 'text', 'warning'),
|
||||
$this->card('完整表头', '17 列', '包含序号和全部人员、容量字段', [], 'text'),
|
||||
$this->card('敏感字段', '4 项', '密码、身份证、实名手机和身份证地址只显示维护状态', [], 'text', 'danger'),
|
||||
$this->card('容量规则', '3 档', '可担任公司数量按风险档位提示', [], 'text'),
|
||||
$this->card('当前记录', '0 条', '接入后按正常在职人员汇总', [], 'text'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{label:string,value:mixed,hint:string,format:string,query:array<string,mixed>,tone:string}
|
||||
*/
|
||||
private function card(
|
||||
string $label,
|
||||
mixed $value,
|
||||
string $hint,
|
||||
array $query = [],
|
||||
string $format = 'integer',
|
||||
string $tone = 'neutral',
|
||||
): array {
|
||||
return [
|
||||
'label' => $label,
|
||||
'value' => $value,
|
||||
'hint' => $hint,
|
||||
'format' => $format,
|
||||
'query' => ['page' => null, ...$query],
|
||||
'tone' => $tone,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -45,7 +45,7 @@ class UpstreamBusinessInformation
|
||||
};
|
||||
request()->attributes->set(
|
||||
'business-page-summary-cards',
|
||||
$this->businessSummaryCards($key, $payload['summary'] ?? []),
|
||||
app(BusinessSummaryCards::class)->forPage($key, $payload['summary'] ?? []),
|
||||
);
|
||||
|
||||
return new LengthAwarePaginator(
|
||||
@ -60,97 +60,6 @@ class UpstreamBusinessInformation
|
||||
);
|
||||
}
|
||||
|
||||
private function businessSummaryCards(string $key, array $summary): array
|
||||
{
|
||||
if ($summary === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return match ($key) {
|
||||
'store-management/store-report' => [
|
||||
$this->summaryCard('店铺总数', $summary['stores'] ?? 0, '当前筛选内唯一店铺,明细按期间拆分'),
|
||||
$this->summaryCard('正常店铺', $summary['normal'] ?? 0, '店铺状态为正常(开店中)', ['status' => '0']),
|
||||
$this->summaryCard('关店中', $summary['closing'] ?? 0, '店铺状态为关闭中', ['status' => '3']),
|
||||
$this->summaryCard('已关闭', $summary['closed'] ?? 0, '店铺状态为已关闭', ['status' => '6']),
|
||||
$this->summaryCard('期间销量', $summary['period_sales'] ?? 0, '收入 + 优惠 + 冲减 + 退款', [
|
||||
'sort' => 'period_sales',
|
||||
'direction' => 'desc',
|
||||
], 'money'),
|
||||
],
|
||||
'company-management/subject-operating-report' => [
|
||||
$this->summaryCard('主体总数', $summary['total'] ?? 0, '当前筛选内唯一主体'),
|
||||
($summary['company_status_ready'] ?? false)
|
||||
? $this->summaryCard('有效主体', $summary['normal'] ?? 0, '经营状态为正常', ['company_status' => '正常'])
|
||||
: $this->summaryCard('有效主体', '—', '公司资料镜像未就绪', [], 'text'),
|
||||
($summary['company_status_ready'] ?? false)
|
||||
? $this->summaryCard('已注销主体', $summary['deregistered'] ?? 0, '最新公司资料状态为已注销', ['company_status' => '已注销'])
|
||||
: $this->summaryCard('已注销主体', '—', '公司资料镜像未就绪', [], 'text'),
|
||||
$this->summaryCard('最近12个月收入', $summary['rolling_income'] ?? 0, '最近 12 个完整月账单收入', [
|
||||
'sort' => 'rolling_12m_income',
|
||||
'direction' => 'desc',
|
||||
], 'money'),
|
||||
$this->summaryCard('本月收入', $summary['current_month_income'] ?? 0, (string) ($summary['current_month_label'] ?? '本月') . '账单收入', [
|
||||
'sort' => 'income_' . ($summary['current_month_number'] ?? now()->format('m')),
|
||||
'direction' => 'desc',
|
||||
], 'money'),
|
||||
],
|
||||
'store-management/basic-information' => [
|
||||
$this->summaryCard('店铺总数', $summary['total'] ?? 0, '当前筛选内店铺档案'),
|
||||
$this->summaryCard('正常店铺', $summary['normal'] ?? 0, '店铺状态为正常', ['store_status' => '正常']),
|
||||
$this->summaryCard('关闭中', $summary['closing'] ?? 0, '店铺状态为关闭中', ['store_status' => '关闭中']),
|
||||
$this->summaryCard('已关闭', $summary['closed'] ?? 0, '店铺状态为已关闭', ['store_status' => '已关闭']),
|
||||
$this->summaryCard('平台数', $summary['platforms'] ?? 0, '按店铺档案平台去重', [
|
||||
'sort' => 'platform',
|
||||
'direction' => 'asc',
|
||||
]),
|
||||
],
|
||||
'store-management/store-accounts' => [
|
||||
$this->summaryCard('账号总数', $summary['total'] ?? 0, '当前筛选内账号记录'),
|
||||
$this->summaryCard('主账号', $summary['main_accounts'] ?? 0, '账号类型为 MAIN', ['account_type' => '主账号']),
|
||||
$this->summaryCard('子账号', $summary['sub_accounts'] ?? 0, '账号类型为 SUB', ['account_type' => '子账号']),
|
||||
$this->summaryCard('密码已设置', $summary['password_set'] ?? 0, '仅统计是否设置,不展示密码', ['password_configured' => '已设置']),
|
||||
$this->summaryCard('密码未设置', $summary['password_missing'] ?? 0, '需店铺负责人补充', ['password_configured' => '未设置']),
|
||||
],
|
||||
'company-management/basic-information' => [
|
||||
$this->summaryCard('公司总数', $summary['total'] ?? 0, '当前筛选内公司档案'),
|
||||
$this->summaryCard('正常公司', $summary['normal'] ?? 0, '公司状态为正常', ['company_status' => '正常']),
|
||||
$this->summaryCard('已注销公司', $summary['deregistered'] ?? 0, '公司状态为已注销', ['company_status' => '已注销']),
|
||||
$this->summaryCard('一般纳税人', $summary['general_taxpayer'] ?? 0, '纳税人类型为一般纳税人', ['taxpayer_type' => '一般纳税人']),
|
||||
$this->summaryCard('小规模纳税人', $summary['small_taxpayer'] ?? 0, '纳税人类型为小规模纳税人', ['taxpayer_type' => '小规模纳税人']),
|
||||
],
|
||||
'trademark-management/information' => [
|
||||
$this->summaryCard('商标总数', $summary['total'] ?? 0, '当前筛选内商标档案'),
|
||||
$this->summaryCard('有效商标', $summary['enabled'] ?? 0, '商标状态为有效', ['trademark_status' => '有效']),
|
||||
$this->summaryCard('未启用', $summary['disabled'] ?? 0, '商标状态为未启用', ['trademark_status' => '未启用']),
|
||||
$this->summaryCard('最终持有人', $summary['holders'] ?? 0, '按非空最终持有人去重', [
|
||||
'sort' => 'final_holder',
|
||||
'direction' => 'asc',
|
||||
]),
|
||||
$this->summaryCard('保管部门', $summary['departments'] ?? 0, '按非空保管部门去重', [
|
||||
'sort' => 'custody_department',
|
||||
'direction' => 'asc',
|
||||
]),
|
||||
],
|
||||
default => [],
|
||||
};
|
||||
}
|
||||
|
||||
private function summaryCard(
|
||||
string $label,
|
||||
mixed $value,
|
||||
string $hint,
|
||||
array $query = [],
|
||||
string $format = 'integer',
|
||||
): array {
|
||||
return [
|
||||
'label' => $label,
|
||||
'value' => $value,
|
||||
'hint' => $hint,
|
||||
'format' => $format,
|
||||
'query' => ['page' => null, ...$query],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 财务经营风险管控 › 流程统计:店铺申请流程(开店 / 变更 / 关店)只读镜像。
|
||||
*
|
||||
@ -410,12 +319,6 @@ SQL);
|
||||
$filters = StoreReportRepository::requestFilters();
|
||||
$rows = $this->storeReportRows($filters);
|
||||
|
||||
// 所有店铺该月都没有业绩的月份列默认隐藏;「筛选字段」中仍保留勾选项,可手动选出来。
|
||||
request()->attributes->set(
|
||||
'store-report.default_hidden_columns',
|
||||
$this->columnsWithoutData($rows, 'sales_', zeroCountsAsData: false),
|
||||
);
|
||||
|
||||
$offset = ($page - 1) * $perPage;
|
||||
|
||||
return [
|
||||
@ -428,9 +331,21 @@ SQL);
|
||||
/** @param list<array<string,mixed>> $rows */
|
||||
private function storeReportSummary(array $rows): array
|
||||
{
|
||||
$stores = [];
|
||||
$periodSales = 0.0;
|
||||
$normalStores = [];
|
||||
$previousMonth = now()->startOfMonth()->subMonthNoOverflow();
|
||||
$currentMonth = now()->startOfMonth();
|
||||
$previousMonthKey = 'sales_' . $previousMonth->format('m');
|
||||
$currentMonthKey = 'sales_' . $currentMonth->format('m');
|
||||
$previousSales = 0.0;
|
||||
$currentSales = 0.0;
|
||||
$previousStores = [];
|
||||
$currentStores = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if (trim((string) ($row['status'] ?? '')) !== '开店中') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = trim((string) ($row['erp_store_name'] ?? ''));
|
||||
if ($key === '') {
|
||||
$key = trim((string) ($row['store_id'] ?? $row['id'] ?? ''));
|
||||
@ -438,18 +353,32 @@ SQL);
|
||||
if ($key === '') {
|
||||
continue;
|
||||
}
|
||||
$stores[$key] = (string) ($row['status'] ?? '');
|
||||
$periodSales += (float) ($row['period_sales'] ?? 0);
|
||||
|
||||
$normalStores[$key] = true;
|
||||
$previousValue = (float) ($row[$previousMonthKey] ?? 0);
|
||||
$currentValue = (float) ($row[$currentMonthKey] ?? 0);
|
||||
$previousSales += $previousValue;
|
||||
$currentSales += $currentValue;
|
||||
if ($previousValue > 0) {
|
||||
$previousStores[$key] = true;
|
||||
}
|
||||
if ($currentValue > 0) {
|
||||
$currentStores[$key] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$statusCounts = array_count_values($stores);
|
||||
|
||||
return [
|
||||
'stores' => count($stores),
|
||||
'normal' => (int) ($statusCounts['开店中'] ?? 0),
|
||||
'closing' => (int) ($statusCounts['关店中'] ?? 0),
|
||||
'closed' => (int) ($statusCounts['关店'] ?? 0),
|
||||
'period_sales' => round($periodSales, 2),
|
||||
'normal_stores' => count($normalStores),
|
||||
'previous_month_sales' => round($previousSales, 2),
|
||||
'current_month_sales' => round($currentSales, 2),
|
||||
'previous_month_stores' => count($previousStores),
|
||||
'current_month_stores' => count($currentStores),
|
||||
'previous_month_key' => $previousMonthKey,
|
||||
'current_month_key' => $currentMonthKey,
|
||||
'previous_month_label' => $previousMonth->isSameYear($currentMonth)
|
||||
? '上月(' . $previousMonth->format('n月') . ')'
|
||||
: '上月(' . $previousMonth->format('Y年n月') . ')',
|
||||
'current_month_label' => '当月(' . $currentMonth->format('n月') . ')',
|
||||
];
|
||||
}
|
||||
|
||||
@ -601,21 +530,26 @@ SQL);
|
||||
$row['city'] = $this->cityFromDetails($row['company_details']);
|
||||
$row['company_status'] = $row['company_details'][0]['company_status'] ?? null;
|
||||
$classification = $classifications[$row['entity']] ?? [];
|
||||
$row['tax_type'] = $classification['tax_type']
|
||||
$taxType = $classification['tax_type']
|
||||
?? $row['company_details'][0]['taxpayer_category']
|
||||
?? null;
|
||||
$row['business_registration_type'] = $classification['business_registration_type']
|
||||
$businessType = $classification['business_registration_type']
|
||||
?? $row['company_details'][0]['business_registration_type']
|
||||
?? null;
|
||||
$classificationStatus = trim((string) ($classification['status'] ?? ''));
|
||||
$retained = $classificationStatus !== ''
|
||||
? $classificationStatus === '保留'
|
||||
: $row['company_status'] === '正常';
|
||||
$row['company_status'] = $retained ? '正常' : '已注销';
|
||||
$row['tax_type'] = $retained
|
||||
? ($this->normalizeTaxType($taxType) ?? '待维护')
|
||||
: '/';
|
||||
$row['business_registration_type'] = $retained
|
||||
? (trim((string) $businessType) !== '' ? trim((string) $businessType) : '待维护')
|
||||
: '/';
|
||||
}
|
||||
unset($row);
|
||||
|
||||
// 所有主体该月收入均为空时,该月份列在页面上默认隐藏;「筛选字段」中仍保留勾选项,可手动选出来。
|
||||
request()->attributes->set(
|
||||
'subject-operating-report.default_hidden_columns',
|
||||
$this->columnsWithoutData($rows, 'income_', zeroCountsAsData: true),
|
||||
);
|
||||
|
||||
$rows = array_values(array_filter($rows, fn (array $row): bool => $this->subjectMatchesFilters($row, $filters)));
|
||||
$summary = $this->subjectSummary($rows, $companyStatusReady);
|
||||
$this->sortSubjectRows($rows, $filters);
|
||||
@ -630,9 +564,17 @@ SQL);
|
||||
{
|
||||
$normal = 0;
|
||||
$deregistered = 0;
|
||||
$rollingIncome = 0.0;
|
||||
$currentMonthKey = 'income_' . now()->format('m');
|
||||
$smallTaxpayers = 0;
|
||||
$generalTaxpayers = 0;
|
||||
$previousMonth = now()->startOfMonth()->subMonthNoOverflow();
|
||||
$currentMonth = now()->startOfMonth();
|
||||
$previousMonthKey = 'income_' . $previousMonth->format('m');
|
||||
$currentMonthKey = 'income_' . $currentMonth->format('m');
|
||||
$previousIncome = 0.0;
|
||||
$currentMonthIncome = 0.0;
|
||||
$previousIncomeEntities = 0;
|
||||
$currentIncomeEntities = 0;
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$status = trim((string) ($row['company_status'] ?? ''));
|
||||
if ($status === '正常') {
|
||||
@ -640,11 +582,28 @@ SQL);
|
||||
} elseif ($status === '已注销') {
|
||||
$deregistered++;
|
||||
}
|
||||
if (($row['rolling_12m_income'] ?? null) !== null) {
|
||||
$rollingIncome += (float) $row['rolling_12m_income'];
|
||||
|
||||
if ($status !== '正常') {
|
||||
continue;
|
||||
}
|
||||
if (($row[$currentMonthKey] ?? null) !== null) {
|
||||
$currentMonthIncome += (float) $row[$currentMonthKey];
|
||||
|
||||
$taxType = (string) ($row['tax_type'] ?? '');
|
||||
if (str_contains($taxType, '小规模')) {
|
||||
$smallTaxpayers++;
|
||||
}
|
||||
if (str_contains($taxType, '一般纳税人')) {
|
||||
$generalTaxpayers++;
|
||||
}
|
||||
|
||||
$previousValue = (float) ($row[$previousMonthKey] ?? 0);
|
||||
$currentValue = (float) ($row[$currentMonthKey] ?? 0);
|
||||
$previousIncome += $previousValue;
|
||||
$currentMonthIncome += $currentValue;
|
||||
if ($previousValue > 0) {
|
||||
$previousIncomeEntities++;
|
||||
}
|
||||
if ($currentValue > 0) {
|
||||
$currentIncomeEntities++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -652,45 +611,34 @@ SQL);
|
||||
'total' => count($rows),
|
||||
'normal' => $normal,
|
||||
'deregistered' => $deregistered,
|
||||
'rolling_income' => round($rollingIncome, 2),
|
||||
'small_taxpayer' => $smallTaxpayers,
|
||||
'general_taxpayer' => $generalTaxpayers,
|
||||
'previous_income' => round($previousIncome, 2),
|
||||
'current_month_income' => round($currentMonthIncome, 2),
|
||||
'current_month_number' => now()->format('m'),
|
||||
'current_month_label' => now()->format('Y年n月'),
|
||||
'previous_income_entities' => $previousIncomeEntities,
|
||||
'current_income_entities' => $currentIncomeEntities,
|
||||
'previous_month_key' => $previousMonthKey,
|
||||
'current_month_key' => $currentMonthKey,
|
||||
'previous_month_label' => $previousMonth->isSameYear($currentMonth)
|
||||
? '上月(' . $previousMonth->format('n月') . ')'
|
||||
: '上月(' . $previousMonth->format('Y年n月') . ')',
|
||||
'current_month_label' => '当月(' . $currentMonth->format('n月') . ')',
|
||||
'company_status_ready' => $companyStatusReady,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 没有数据的月份列:所有行该月都没有数值时返回该列名,页面据此默认隐藏。
|
||||
*
|
||||
* 收入(income_)以 null/空字符串表示无账单,金额 0 也算有账单;
|
||||
* 销量(sales_)没有空值标记,数值 0 视为当月没有业绩。
|
||||
*
|
||||
* @param array<int,array<string,mixed>> $rows
|
||||
* @return array<int,string>
|
||||
*/
|
||||
private function columnsWithoutData(array $rows, string $prefix, bool $zeroCountsAsData): array
|
||||
private function normalizeTaxType(mixed $value): ?string
|
||||
{
|
||||
$columns = [];
|
||||
|
||||
for ($month = 1; $month <= 12; $month++) {
|
||||
$key = sprintf('%s%02d', $prefix, $month);
|
||||
foreach ($rows as $row) {
|
||||
$value = $row[$key] ?? null;
|
||||
if ($value === null || $value === '') {
|
||||
continue;
|
||||
}
|
||||
if (! $zeroCountsAsData && (float) $value === 0.0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
continue 2;
|
||||
}
|
||||
|
||||
$columns[] = $key;
|
||||
$taxType = trim((string) $value);
|
||||
if ($taxType === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $columns;
|
||||
return match ($taxType) {
|
||||
'小规模' => '小规模纳税人',
|
||||
'一般纳税人', '小规模纳税人', '个体工商户', '无税务登记' => $taxType,
|
||||
default => $taxType,
|
||||
};
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $row @param array<string,string> $filters */
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Business;
|
||||
|
||||
use App\Business\BusinessTableImporter;
|
||||
use App\Business\BusinessSummaryCards;
|
||||
use App\Business\InventoryInboundDetailImporter;
|
||||
use App\Business\InventoryWarehouseNameMappingWorkbookImporter;
|
||||
use App\Business\InventoryWarehouseShortNames;
|
||||
@ -3768,9 +3769,25 @@ class Pages extends Controller
|
||||
$agreementCourierContractParties = $this->agreementCourierContractParties($page['slug'] ?? null, $agreementCourierNames);
|
||||
$agreementSupplierOptions = $this->agreementSupplierOptions($page['slug'] ?? null);
|
||||
|
||||
$staticSummaryKey = (string) ($section['slug'] ?? '') . '/' . (string) ($page['slug'] ?? '');
|
||||
if (in_array($staticSummaryKey, [
|
||||
'company-management/company-cost-arrangement',
|
||||
'company-management/tax-forecast',
|
||||
'company-management/personnel-inventory',
|
||||
], true)) {
|
||||
request()->attributes->set(
|
||||
'business-page-summary-cards',
|
||||
app(BusinessSummaryCards::class)->forPage($staticSummaryKey),
|
||||
);
|
||||
}
|
||||
|
||||
// 内部流转报表读取共享业务镜像中由工作簿导入的数据集,不走上游只读查询。
|
||||
if ($page && $content === null && $this->isInternalFlowReportPage($section, $page)) {
|
||||
[$rows, $upstreamError] = $this->internalFlowReportRows();
|
||||
[$rows, $upstreamError, $flowSummary] = $this->internalFlowReportRows();
|
||||
request()->attributes->set(
|
||||
'business-page-summary-cards',
|
||||
app(BusinessSummaryCards::class)->forPage('store-management/internal-flow-report', $flowSummary),
|
||||
);
|
||||
}
|
||||
|
||||
if (($section['slug'] ?? null) === 'product-inventory' && ($page['slug'] ?? null) === 'inventory-report') {
|
||||
@ -4220,7 +4237,7 @@ class Pages extends Controller
|
||||
* 内部流转报表明细。数据来自共享业务镜像中按工作簿整份替换的导入结果,
|
||||
* 尚未导入时保留空页面并说明原因,不把“未导入”当成业务数据为 0。
|
||||
*
|
||||
* @return array{0: LengthAwarePaginator, 1: ?string}
|
||||
* @return array{0: LengthAwarePaginator, 1: ?string, 2: array<string,int|float>}
|
||||
*/
|
||||
private function internalFlowReportRows(): array
|
||||
{
|
||||
@ -4240,6 +4257,7 @@ class Pages extends Controller
|
||||
return [
|
||||
$paginate([], 0),
|
||||
'内部流转数据尚未导入。导入《一般纳税人内部流转》工作簿后,本页会显示明细。',
|
||||
[],
|
||||
];
|
||||
}
|
||||
|
||||
@ -4254,7 +4272,11 @@ class Pages extends Controller
|
||||
(string) request('direction', 'asc'),
|
||||
);
|
||||
|
||||
return [$paginate($payload['data'], $payload['total']), null];
|
||||
return [
|
||||
$paginate($payload['data'], $payload['total']),
|
||||
null,
|
||||
(array) ($payload['summary'] ?? []),
|
||||
];
|
||||
}
|
||||
|
||||
private function storeReceivingAccountRows(?string $tab): LengthAwarePaginator
|
||||
|
||||
@ -17,9 +17,16 @@ $navigation = [
|
||||
'fields' => [
|
||||
['name' => 'city', 'label' => '市'],
|
||||
['name' => 'entity', 'label' => '主体'],
|
||||
['name' => 'company_type', 'label' => '公司类型'],
|
||||
['name' => 'tax_type', 'label' => '税务类型'],
|
||||
['name' => 'business_registration_type', 'label' => '工商类型'],
|
||||
['name' => 'company_type', 'label' => '公司类型', 'kind' => 'badge'],
|
||||
['name' => 'tax_type', 'label' => '税务类型', 'kind' => 'badge', 'tones' => [
|
||||
'小规模纳税人' => 'info',
|
||||
'一般纳税人' => 'accent',
|
||||
'个体工商户' => 'success',
|
||||
'无税务登记' => 'warning',
|
||||
'待维护' => 'warning',
|
||||
'/' => 'muted',
|
||||
]],
|
||||
['name' => 'business_registration_type', 'label' => '工商类型', 'kind' => 'badge'],
|
||||
['name' => 'rolling_12m_income', 'label' => '最近12个月累计收入', 'kind' => 'number'],
|
||||
...array_map(static fn (int $month): array => ['name' => sprintf('income_%02d', $month), 'label' => $month . '月收入', 'kind' => 'number'], range(1, 12)),
|
||||
['name' => 'can_change_entity', 'label' => '能否变更主体'],
|
||||
@ -38,8 +45,11 @@ $navigation = [
|
||||
'empty' => '公司成本安排尚未同步数据。',
|
||||
'fields' => [
|
||||
['name' => 'company', 'label' => '公司'],
|
||||
['name' => 'company_type', 'label' => '公司类型'],
|
||||
['name' => 'invoice_type', 'label' => '发票类型'],
|
||||
['name' => 'company_type', 'label' => '公司类型', 'kind' => 'badge'],
|
||||
['name' => 'invoice_type', 'label' => '发票类型', 'kind' => 'badge', 'tones' => [
|
||||
'专票' => 'accent',
|
||||
'普票' => 'info',
|
||||
]],
|
||||
['name' => 'current_month_income_forecast', 'label' => '当月收入预测', 'kind' => 'number'],
|
||||
['name' => 'historical_cost_gap', 'label' => '往期成本缺口', 'kind' => 'number'],
|
||||
['name' => 'supplier_cost_arrangement', 'label' => '供应商成本安排', 'kind' => 'number'],
|
||||
@ -61,9 +71,21 @@ $navigation = [
|
||||
'empty' => '税金预测表尚未接入取数:工商类型、征收方式(查账征收/核定征收)确认并补齐数据来源后开始计算。',
|
||||
'fields' => [
|
||||
['name' => 'company_name', 'label' => '公司名称'],
|
||||
['name' => 'taxpayer_type', 'label' => '公司税务类型'],
|
||||
['name' => 'business_registration_type', 'label' => '工商类型'],
|
||||
['name' => 'collection_method', 'label' => '征收方式'],
|
||||
['name' => 'taxpayer_type', 'label' => '公司税务类型', 'kind' => 'badge', 'tones' => [
|
||||
'小规模纳税人' => 'info',
|
||||
'一般纳税人' => 'accent',
|
||||
'个体工商户' => 'success',
|
||||
'无税务登记' => 'warning',
|
||||
'待维护' => 'warning',
|
||||
'/' => 'muted',
|
||||
]],
|
||||
['name' => 'business_registration_type', 'label' => '工商类型', 'kind' => 'badge'],
|
||||
['name' => 'collection_method', 'label' => '征收方式', 'kind' => 'badge', 'tones' => [
|
||||
'查账征收' => 'info',
|
||||
'核定征收' => 'accent',
|
||||
'待维护' => 'warning',
|
||||
'/' => 'muted',
|
||||
]],
|
||||
['name' => 'assessed_income_rate', 'label' => '核定应税所得率(%)', 'kind' => 'number'],
|
||||
['name' => 'forecast_month', 'label' => '预测月份'],
|
||||
['name' => 'revenue_incl_tax', 'label' => '当月含税收入预测', 'kind' => 'number'],
|
||||
@ -95,9 +117,16 @@ $navigation = [
|
||||
'fields' => [
|
||||
['name' => 'unified_social_credit_code', 'label' => '统一社会信用代码'],
|
||||
['name' => 'company_name', 'label' => '公司名称'],
|
||||
['name' => 'taxpayer_type', 'label' => '税务类型', 'source' => 'taxpayer_category'],
|
||||
['name' => 'business_registration_type', 'label' => '工商类型'],
|
||||
['name' => 'company_status', 'label' => '公司状态'],
|
||||
['name' => 'taxpayer_type', 'label' => '税务类型', 'source' => 'taxpayer_category', 'kind' => 'badge', 'tones' => [
|
||||
'小规模纳税人' => 'info',
|
||||
'一般纳税人' => 'accent',
|
||||
'个体工商户' => 'success',
|
||||
'无税务登记' => 'warning',
|
||||
'待维护' => 'warning',
|
||||
'/' => 'muted',
|
||||
]],
|
||||
['name' => 'business_registration_type', 'label' => '工商类型', 'kind' => 'badge'],
|
||||
['name' => 'company_status', 'label' => '公司状态', 'kind' => 'badge'],
|
||||
['name' => 'subscribed_capital', 'label' => '认缴注册资本(万元)', 'kind' => 'number'],
|
||||
['name' => 'registered_at', 'label' => '注册时间', 'kind' => 'date', 'source' => 'establishment_date'],
|
||||
['name' => 'legal_representative', 'label' => '法人'],
|
||||
@ -123,8 +152,8 @@ $navigation = [
|
||||
'fields' => [
|
||||
['name' => 'person_name', 'label' => '人员名称'],
|
||||
['name' => 'alias', 'label' => '花名'],
|
||||
['name' => 'position', 'label' => '职位'],
|
||||
['name' => 'tag', 'label' => '标签'],
|
||||
['name' => 'position', 'label' => '职位', 'kind' => 'badge'],
|
||||
['name' => 'tag', 'label' => '标签', 'kind' => 'badge'],
|
||||
['name' => 'tax_account', 'label' => '税务局账号'],
|
||||
['name' => 'tax_password', 'label' => '税务局密码', 'kind' => 'secret'],
|
||||
['name' => 'department', 'label' => '部门'],
|
||||
@ -133,7 +162,7 @@ $navigation = [
|
||||
['name' => 'verified_mobile', 'label' => '实名手机号', 'kind' => 'secret'],
|
||||
['name' => 'sim_card_keeper', 'label' => '电话卡保管人'],
|
||||
['name' => 'id_address', 'label' => '身份证地址', 'kind' => 'secret'],
|
||||
['name' => 'company_type', 'label' => '公司类型'],
|
||||
['name' => 'company_type', 'label' => '公司类型', 'kind' => 'badge'],
|
||||
['name' => 'total_company_count', 'label' => '合计担任公司数量', 'kind' => 'number'],
|
||||
['name' => 'retained_company_count', 'label' => '保留担任公司数量', 'kind' => 'number'],
|
||||
['name' => 'available_company_count', 'label' => '可担任公司数量', 'kind' => 'number'],
|
||||
@ -169,7 +198,7 @@ $navigation = [
|
||||
'fields' => [
|
||||
['name' => 'trademark_name', 'label' => '商标名称'],
|
||||
['name' => 'trademark_number', 'label' => '商标号'],
|
||||
['name' => 'trademark_status', 'label' => '商标状态'],
|
||||
['name' => 'trademark_status', 'label' => '商标状态', 'kind' => 'badge'],
|
||||
['name' => 'registration_date', 'label' => '注册时间', 'kind' => 'date'],
|
||||
['name' => 'expiry_date', 'label' => '有效期', 'kind' => 'date'],
|
||||
['name' => 'international_classification', 'label' => '国际分类', 'source' => 'trademark_type'],
|
||||
@ -265,10 +294,10 @@ $navigation = [
|
||||
['name' => 'store_manager', 'label' => '店铺负责人'],
|
||||
['name' => 'department_manager', 'label' => '部门负责人'],
|
||||
['name' => 'opened_at', 'label' => '开店时间', 'kind' => 'date'],
|
||||
['name' => 'status', 'label' => '状态'],
|
||||
['name' => 'status', 'label' => '状态', 'kind' => 'badge'],
|
||||
['name' => 'can_change', 'label' => '能否变更'],
|
||||
['name' => 'entity', 'label' => '主体'],
|
||||
['name' => 'company_type', 'label' => '公司类型'],
|
||||
['name' => 'company_type', 'label' => '公司类型', 'kind' => 'badge'],
|
||||
['name' => 'effective_at', 'label' => '生效时间', 'kind' => 'date'],
|
||||
['name' => 'invalid_at', 'label' => '失效时间', 'kind' => 'date'],
|
||||
['name' => 'period_sales', 'label' => '期间销量', 'kind' => 'number'],
|
||||
@ -290,7 +319,11 @@ $navigation = [
|
||||
'empty' => '内部流转数据尚未导入。导入工作簿后这里会显示明细。',
|
||||
'fields' => [
|
||||
['name' => 'company_name', 'label' => '抬头'],
|
||||
['name' => 'tag', 'label' => '标签'],
|
||||
['name' => 'tag', 'label' => '标签', 'kind' => 'badge', 'tones' => [
|
||||
'1' => 'accent',
|
||||
'2' => 'warning',
|
||||
'3' => 'info',
|
||||
]],
|
||||
['name' => 'projected_sales', 'label' => '预计9月销量', 'kind' => 'number'],
|
||||
['name' => 'invoiced_to_buyer', 'label' => '开票-给买家开票', 'kind' => 'number'],
|
||||
['name' => 'internal_invoiced', 'label' => '开票-内部开票', 'kind' => 'number'],
|
||||
@ -316,11 +349,11 @@ $navigation = [
|
||||
'description' => '优先读取共享业务镜像中的店铺资料、店铺 ID 和续签时间;提现账户仅显示配置状态。',
|
||||
'empty' => '尚未读取到店铺基础资料。请检查共享镜像或上游同步状态。',
|
||||
'fields' => [
|
||||
['name' => 'platform', 'label' => '平台'],
|
||||
['name' => 'platform', 'label' => '平台', 'kind' => 'badge'],
|
||||
['name' => 'store_id', 'label' => '店铺ID'],
|
||||
['name' => 'store_name', 'label' => '店铺名称', 'source' => 'erp_store_name'],
|
||||
['name' => 'store_entity', 'label' => '店铺主体', 'source' => 'company_name'],
|
||||
['name' => 'store_status', 'label' => '店铺状态'],
|
||||
['name' => 'store_status', 'label' => '店铺状态', 'kind' => 'badge'],
|
||||
['name' => 'trademark', 'label' => '商标', 'source' => 'trademark_name'],
|
||||
['name' => 'trademark_number', 'label' => '商标号'],
|
||||
['name' => 'business_department', 'label' => '业务部门', 'source' => 'profit_center'],
|
||||
@ -346,16 +379,32 @@ $navigation = [
|
||||
['name' => 'operation_department_head', 'label' => '店铺运营部门负责人'],
|
||||
['name' => 'operation_director', 'label' => '店铺运营总监'],
|
||||
['name' => 'profit_center', 'label' => '店铺所属利润中心'],
|
||||
['name' => 'account_type', 'label' => '账号类型'],
|
||||
['name' => 'account_type', 'label' => '账号类型', 'kind' => 'badge', 'tones' => [
|
||||
'主账号' => 'accent',
|
||||
'子账号' => 'info',
|
||||
]],
|
||||
['name' => 'account', 'label' => '账号'],
|
||||
['name' => 'password_configured', 'label' => '密码', 'kind' => 'secret_status'],
|
||||
['name' => 'bound_phone', 'label' => '绑定手机号'],
|
||||
['name' => 'verification_contact', 'label' => '手机号验证码对接人'],
|
||||
['name' => 'account_group_name', 'label' => '账号分组名称'],
|
||||
['name' => 'authorization_status', 'label' => '授权状态'],
|
||||
['name' => 'store_status', 'label' => '店铺状态'],
|
||||
['name' => 'flow_type', 'label' => '流程类型'],
|
||||
['name' => 'approval_status', 'label' => '审批状态'],
|
||||
['name' => 'authorization_status', 'label' => '授权状态', 'kind' => 'badge', 'tones' => [
|
||||
'已授权' => 'success',
|
||||
'已过期' => 'warning',
|
||||
'未授权' => 'danger',
|
||||
]],
|
||||
['name' => 'store_status', 'label' => '店铺状态', 'kind' => 'badge'],
|
||||
['name' => 'flow_type', 'label' => '流程类型', 'kind' => 'badge'],
|
||||
['name' => 'approval_status', 'label' => '审批状态', 'kind' => 'badge', 'tones' => [
|
||||
'完成' => 'success',
|
||||
'已签署' => 'success',
|
||||
'拒绝' => 'danger',
|
||||
'撤回' => 'muted',
|
||||
'流程中' => 'info',
|
||||
'待审批' => 'warning',
|
||||
'暂存' => 'warning',
|
||||
'待签署' => 'warning',
|
||||
]],
|
||||
['name' => 'created_at', 'label' => '店铺创建时间', 'kind' => 'date'],
|
||||
['name' => 'updated_at', 'label' => '店铺修改时间', 'kind' => 'date'],
|
||||
],
|
||||
|
||||
@ -175,7 +175,7 @@ SQL)
|
||||
->all();
|
||||
}
|
||||
|
||||
/** @return array<string,array{tax_type:?string,business_registration_type:?string}> */
|
||||
/** @return array<string,array{status:?string,tax_type:?string,business_registration_type:?string}> */
|
||||
public function companyClassificationsByNames(array $names): array
|
||||
{
|
||||
$names = array_values(array_unique(array_filter(array_map('trim', $names))));
|
||||
@ -184,13 +184,15 @@ SQL)
|
||||
}
|
||||
|
||||
return $this->connection->table('fin_companies')
|
||||
->select(['name', 'tax_type', 'business_type'])
|
||||
->select(['name', 'status', 'tax_type', 'business_type'])
|
||||
->whereIn('name', $names)
|
||||
->get()
|
||||
->mapWithKeys(static function (object $row): array {
|
||||
$businessType = trim((string) ($row->business_type ?? ''));
|
||||
$status = trim((string) ($row->status ?? ''));
|
||||
|
||||
return [trim((string) $row->name) => [
|
||||
'status' => $status !== '' ? $status : null,
|
||||
'tax_type' => trim((string) ($row->tax_type ?? '')) ?: null,
|
||||
'business_registration_type' => in_array($businessType, ['', '/'], true) ? null : $businessType,
|
||||
]];
|
||||
|
||||
@ -47,12 +47,22 @@ class InternalFlowReportRepository
|
||||
|
||||
/**
|
||||
* @param array{company_name?:string,tag?:string} $filters
|
||||
* @return array{data: list<array<string,mixed>>, total: int}
|
||||
* @return array{data: list<array<string,mixed>>, total: int, summary: array<string,int|float>}
|
||||
*/
|
||||
public function paginate(int $page, int $perPage, array $filters = [], ?string $sort = null, string $direction = 'asc'): array
|
||||
{
|
||||
if (! $this->ready()) {
|
||||
return ['data' => [], 'total' => 0];
|
||||
return [
|
||||
'data' => [],
|
||||
'total' => 0,
|
||||
'summary' => [
|
||||
'companies' => 0,
|
||||
'projected_sales' => 0.0,
|
||||
'receipt_total' => 0.0,
|
||||
'remaining_gap' => 0.0,
|
||||
'average_invoicing_ratio' => 0.0,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$query = $this->connection->table(self::TABLE);
|
||||
@ -68,6 +78,30 @@ class InternalFlowReportRepository
|
||||
}
|
||||
|
||||
$total = (clone $query)->count();
|
||||
$totals = (clone $query)->selectRaw(
|
||||
'COUNT(*) AS companies, '
|
||||
. 'COALESCE(SUM(projected_sales), 0) AS projected_sales, '
|
||||
. 'COALESCE(SUM(receipt_total), 0) AS receipt_total, '
|
||||
. 'COALESCE(SUM(remaining_gap), 0) AS remaining_gap',
|
||||
)->first();
|
||||
$ratios = (clone $query)
|
||||
->whereNotNull('invoicing_ratio')
|
||||
->pluck('invoicing_ratio')
|
||||
->map(static function (mixed $value): ?float {
|
||||
$text = str_replace([',', ' ', '%'], '', trim((string) $value));
|
||||
if ($text === '' || $text === '/' || ! is_numeric($text)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$ratio = (float) $text;
|
||||
if (str_contains((string) $value, '%') || $ratio > 1) {
|
||||
$ratio /= 100;
|
||||
}
|
||||
|
||||
return $ratio >= 0 ? $ratio : null;
|
||||
})
|
||||
->filter(static fn (?float $value): bool => $value !== null)
|
||||
->values();
|
||||
|
||||
$column = in_array($sort, self::SORTABLE, true) ? $sort : null;
|
||||
$direction = strtolower($direction) === 'desc' ? 'desc' : 'asc';
|
||||
@ -84,6 +118,16 @@ class InternalFlowReportRepository
|
||||
->map(static fn (object $row): array => (array) $row)
|
||||
->all();
|
||||
|
||||
return ['data' => $rows, 'total' => $total];
|
||||
return [
|
||||
'data' => $rows,
|
||||
'total' => $total,
|
||||
'summary' => [
|
||||
'companies' => (int) ($totals->companies ?? $total),
|
||||
'projected_sales' => round((float) ($totals->projected_sales ?? 0), 2),
|
||||
'receipt_total' => round((float) ($totals->receipt_total ?? 0), 2),
|
||||
'remaining_gap' => round((float) ($totals->remaining_gap ?? 0), 2),
|
||||
'average_invoicing_ratio' => round((float) ($ratios->avg() ?? 0) * 100, 2),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,49 @@
|
||||
background: #fbf7ec;
|
||||
}
|
||||
|
||||
.business-summary-card[data-tone="accent"] {
|
||||
border-color: #cdb985;
|
||||
background: #fbf7ec;
|
||||
}
|
||||
|
||||
.business-summary-card[data-tone="success"] {
|
||||
border-color: #b9c9ad;
|
||||
background: #f3f8ef;
|
||||
}
|
||||
|
||||
.business-summary-card[data-tone="warning"] {
|
||||
border-color: #ddc79e;
|
||||
background: #fff8ea;
|
||||
}
|
||||
|
||||
.business-summary-card[data-tone="danger"] {
|
||||
border-color: #dfbbbb;
|
||||
background: #fff4f4;
|
||||
}
|
||||
|
||||
.business-summary-card[data-tone]::before {
|
||||
position: absolute;
|
||||
top: 0.7rem;
|
||||
bottom: 0.7rem;
|
||||
left: 0;
|
||||
width: 3px;
|
||||
border-radius: 0 999px 999px 0;
|
||||
background: var(--vip-content-accent-dark, #856632);
|
||||
content: "";
|
||||
}
|
||||
|
||||
.business-summary-card[data-tone="success"]::before {
|
||||
background: #53793e;
|
||||
}
|
||||
|
||||
.business-summary-card[data-tone="warning"]::before {
|
||||
background: #935f07;
|
||||
}
|
||||
|
||||
.business-summary-card[data-tone="danger"]::before {
|
||||
background: #b80000;
|
||||
}
|
||||
|
||||
.business-summary-card:hover,
|
||||
.business-summary-card:focus-visible,
|
||||
.business-summary-card[aria-current="true"] {
|
||||
@ -107,23 +150,28 @@
|
||||
$format = $card['format'] ?? 'integer';
|
||||
$formattedValue = match ($format) {
|
||||
'money' => '¥' . number_format((float) ($card['value'] ?? 0), 2),
|
||||
'amount' => number_format((float) ($card['value'] ?? 0), 2),
|
||||
'percent' => number_format((float) ($card['value'] ?? 0), 2) . '%',
|
||||
'text' => (string) ($card['value'] ?? '—'),
|
||||
default => number_format((int) ($card['value'] ?? 0)),
|
||||
};
|
||||
$tone = (string) ($card['tone'] ?? 'neutral');
|
||||
$isAmount = in_array($format, ['money', 'amount'], true);
|
||||
$activeQuery = collect($query)
|
||||
->filter(fn ($value, string $key): bool => $key !== 'page' && $value !== null && $value !== '');
|
||||
$isActive = $activeQuery->isNotEmpty()
|
||||
&& $activeQuery->every(fn ($value, string $key): bool => (string) request($key) === (string) $value);
|
||||
@endphp
|
||||
<a
|
||||
class="business-summary-card{{ $format === 'money' ? ' business-summary-card--money' : '' }}"
|
||||
class="business-summary-card{{ $isAmount ? ' business-summary-card--money' : '' }}"
|
||||
href="{{ rtrim(request()->fullUrlWithQuery($query), '?') }}"
|
||||
data-business-summary-card="{{ $card['label'] ?? '' }}"
|
||||
data-tone="{{ $tone }}"
|
||||
aria-label="{{ $card['label'] ?? '' }}:{{ $formattedValue }},查看明细"
|
||||
@if ($isActive) aria-current="true" @endif
|
||||
>
|
||||
<span class="business-summary-card__label">{{ $card['label'] ?? '' }}</span>
|
||||
<strong class="business-summary-card__value{{ $format === 'money' ? ' business-summary-card__value--money' : '' }}">{{ $formattedValue }}</strong>
|
||||
<strong class="business-summary-card__value{{ $isAmount ? ' business-summary-card__value--money' : '' }}">{{ $formattedValue }}</strong>
|
||||
<span class="business-summary-card__hint" title="{{ $card['hint'] ?? '' }}">{{ $card['hint'] ?? '' }}</span>
|
||||
<span class="material-icons-outlined business-summary-card__open" aria-hidden="true">arrow_outward</span>
|
||||
</a>
|
||||
|
||||
@ -584,6 +584,61 @@
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.directory-value-badge {
|
||||
display: inline-flex;
|
||||
max-width: 12rem;
|
||||
min-height: 1.45rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0.15rem 0.48rem;
|
||||
border: 1px solid #d8d2c7;
|
||||
border-radius: 999px;
|
||||
background: #f4f1eb;
|
||||
color: #595959;
|
||||
font-size: 0.6875rem;
|
||||
line-height: 1.2;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: middle;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.directory-value-badge[data-tone="accent"] {
|
||||
border-color: #dcc99d;
|
||||
background: #f7f0de;
|
||||
color: #6a5129;
|
||||
}
|
||||
|
||||
.directory-value-badge[data-tone="success"] {
|
||||
border-color: #bfd1b3;
|
||||
background: #f1f7ed;
|
||||
color: #53793e;
|
||||
}
|
||||
|
||||
.directory-value-badge[data-tone="warning"] {
|
||||
border-color: #e1ca9c;
|
||||
background: #fff7e7;
|
||||
color: #935f07;
|
||||
}
|
||||
|
||||
.directory-value-badge[data-tone="danger"] {
|
||||
border-color: #e5bcbc;
|
||||
background: #fff1f1;
|
||||
color: #b80000;
|
||||
}
|
||||
|
||||
.directory-value-badge[data-tone="info"] {
|
||||
border-color: #b7ceda;
|
||||
background: #eef5f8;
|
||||
color: #006395;
|
||||
}
|
||||
|
||||
.directory-value-badge[data-tone="muted"] {
|
||||
border-color: #ddd7ce;
|
||||
background: #f3f1ed;
|
||||
color: #68635c;
|
||||
}
|
||||
|
||||
/* 快递运费:这几列是从来源表/快递应付带出来的金额与计算列,按业务要求表头和数值都靠左展示。 */
|
||||
.directory-table-page .directory-table th.is-number[data-column-key="freight_amount"],
|
||||
.directory-table-page .directory-table td.is-number[data-column-key="freight_amount"],
|
||||
@ -1367,6 +1422,12 @@
|
||||
>
|
||||
@if ($directoryUsesFieldQuery)
|
||||
<span class="sr-only" data-directory-status>{{ $directory['status'] ?? '尚未同步' }}</span>
|
||||
<div class="directory-query-page-head">
|
||||
<div>
|
||||
<strong>{{ $page['title'] ?? $section['title'] }}</strong>
|
||||
<p>{{ $directoryQueryPageDescriptions[$directoryPageKey] ?? '按当前字段查询、筛选并导出业务数据' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@if (!empty($upstreamError))
|
||||
<div class="directory-table-notice" role="alert">
|
||||
<span class="material-icons-outlined" aria-hidden="true">error_outline</span>
|
||||
@ -2733,7 +2794,7 @@
|
||||
<span class="directory-field-picker__hint">{{ $directoryHasGroupedHeader ? '两层合并表头按固定列顺序渲染,仅可切换显示字段。' : '拖动字段调整顺序;固定序号列不可隐藏。' }}</span>
|
||||
@foreach ($directoryFields as $field)
|
||||
<label class="directory-field-picker__option" draggable="true" data-directory-field-option>
|
||||
<input type="checkbox" value="{{ $field['name'] }}" data-directory-field-check @checked(!in_array($field['name'], ['sales_01', 'sales_02', 'sales_03', 'sales_04', 'sales_05', 'sales_06'], true))>
|
||||
<input type="checkbox" value="{{ $field['name'] }}" data-directory-field-check @checked(in_array($field['name'], $visibleDirectoryColumns, true))>
|
||||
<span>{{ $field['label'] }}</span>
|
||||
</label>
|
||||
@endforeach
|
||||
@ -2865,6 +2926,20 @@
|
||||
} elseif ($kind === 'boolean' && $value !== null && $value !== '') {
|
||||
$display = in_array($value, [true, 1, '1', '是', '✔'], true) ? '是' : '否';
|
||||
}
|
||||
$badgeTone = null;
|
||||
if ($kind === 'badge') {
|
||||
$badgeText = trim((string) ($display ?? ''));
|
||||
$badgeTone = (string) (($field['tones'] ?? [])[$badgeText] ?? 'neutral');
|
||||
if ($badgeTone === 'neutral') {
|
||||
$badgeTone = match (true) {
|
||||
in_array($badgeText, ['正常', '开店中', '存续中', '有效', '已完成', '已通过', '是'], true) => 'success',
|
||||
in_array($badgeText, ['已注销', '已关闭', '关店', '拒绝', '已拒绝'], true) => 'danger',
|
||||
in_array($badgeText, ['待维护', '关店中', '关闭中', '未启用', '未设置', '待处理', '待审批', '暂存'], true) => 'warning',
|
||||
in_array($badgeText, ['/'], true) => 'muted',
|
||||
default => 'neutral',
|
||||
};
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
<td data-column-key="{{ $field['name'] }}" class="{{ in_array($kind, ['number', 'integer'], true) ? 'is-number' : '' }} {{ !in_array($field['name'], $visibleDirectoryColumns, true) ? 'is-column-hidden' : '' }}"@if (($page['slug'] ?? '') === 'courier-freight' && in_array($field['name'], ['transaction_no', 'express_no', 'barcode', 'shop_name'], true) && filled($display)) title="{{ $display }}"@endif>
|
||||
@if (($page['slug'] ?? '') === 'store-accounts' && $field['name'] === 'password_configured')
|
||||
@ -2882,7 +2957,11 @@
|
||||
</span>
|
||||
@endif
|
||||
@else
|
||||
{{ filled($display) ? $display : ($isInventoryReportPage && $field['name'] === 'warehouse_short_name' ? '' : '—') }}
|
||||
@if ($kind === 'badge' && filled($display))
|
||||
<span class="directory-value-badge" data-tone="{{ $badgeTone }}">{{ $display }}</span>
|
||||
@else
|
||||
{{ filled($display) ? $display : ($isInventoryReportPage && $field['name'] === 'warehouse_short_name' ? '' : '—') }}
|
||||
@endif
|
||||
@endif
|
||||
</td>
|
||||
@endforeach
|
||||
|
||||
@ -521,10 +521,10 @@
|
||||
|
||||
var rate = Number(changeRate);
|
||||
if (rate > 0) {
|
||||
trend.textContent = '↑' + Math.abs(rate).toLocaleString('zh-CN', { maximumFractionDigits: 1 }) + '%';
|
||||
trend.textContent = '↑' + Math.abs(rate).toLocaleString('zh-CN', { minimumFractionDigits: 1, maximumFractionDigits: 1 }) + '%';
|
||||
trend.classList.add('is-up');
|
||||
} else if (rate < 0) {
|
||||
trend.textContent = '↓' + Math.abs(rate).toLocaleString('zh-CN', { maximumFractionDigits: 1 }) + '%';
|
||||
trend.textContent = '↓' + Math.abs(rate).toLocaleString('zh-CN', { minimumFractionDigits: 1, maximumFractionDigits: 1 }) + '%';
|
||||
trend.classList.add('is-down');
|
||||
} else {
|
||||
trend.textContent = '持平';
|
||||
|
||||
@ -33,6 +33,13 @@ class InternalFlowReportPageTest extends FeatureTestCase
|
||||
'invoicing_ratio' => '1',
|
||||
]],
|
||||
'total' => 1,
|
||||
'summary' => [
|
||||
'companies' => 1,
|
||||
'projected_sales' => 1200000.0,
|
||||
'receipt_total' => 0.0,
|
||||
'remaining_gap' => 0.0,
|
||||
'average_invoicing_ratio' => 100.0,
|
||||
],
|
||||
]);
|
||||
$this->app->instance(InternalFlowReportRepository::class, $repository);
|
||||
|
||||
@ -49,6 +56,11 @@ class InternalFlowReportPageTest extends FeatureTestCase
|
||||
->assertSeeText('收票-内部流转(来源)1')
|
||||
->assertSeeText('剩余缺口')
|
||||
->assertSeeText('开票比例')
|
||||
->assertSeeText('公司数')
|
||||
->assertSeeText('预计销量合计')
|
||||
->assertSeeText('已收票合计')
|
||||
->assertSeeText('剩余缺口合计')
|
||||
->assertSeeText('平均开票比例')
|
||||
->assertSee('data-directory-query-picker', false)
|
||||
->assertSee('data-directory-query-export', false)
|
||||
->assertSee('data-directory-query-field="company_name"', false)
|
||||
|
||||
@ -46,11 +46,13 @@ class PrototypePageTest extends FeatureTestCase
|
||||
->assertSeeText('主账号')
|
||||
->assertSeeText('已设置')
|
||||
->assertSeeText('13800000000')
|
||||
->assertSee('directory-value-badge', false)
|
||||
->assertSee('data-tone="accent"', false)
|
||||
->assertDontSeeText('MAIN')
|
||||
->assertDontSeeText('共享镜像中暂未读取到店铺账号数据');
|
||||
}
|
||||
|
||||
public function testSharedBusinessPagesRenderClickableSummaryCards(): void
|
||||
public function testBaseInformationPagesDoNotRenderSummaryCards(): void
|
||||
{
|
||||
$rows = new LengthAwarePaginator([(object) [
|
||||
'id' => 'account-summary',
|
||||
@ -64,15 +66,7 @@ class PrototypePageTest extends FeatureTestCase
|
||||
->shouldReceive('paginate')
|
||||
->once()
|
||||
->with('store-management', 'store-accounts', 50)
|
||||
->andReturnUsing(function () use ($rows): LengthAwarePaginator {
|
||||
request()->attributes->set('business-page-summary-cards', [
|
||||
['label' => '账号总数', 'value' => 958, 'hint' => '当前筛选内账号记录', 'format' => 'integer', 'query' => ['page' => null]],
|
||||
['label' => '主账号', 'value' => 640, 'hint' => '账号类型为 MAIN', 'format' => 'integer', 'query' => ['page' => null, 'account_type' => '主账号']],
|
||||
['label' => '子账号', 'value' => 318, 'hint' => '账号类型为 SUB', 'format' => 'integer', 'query' => ['page' => null, 'account_type' => '子账号']],
|
||||
]);
|
||||
|
||||
return $rows;
|
||||
});
|
||||
->andReturn($rows);
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('business.pages.show', [
|
||||
@ -81,16 +75,56 @@ class PrototypePageTest extends FeatureTestCase
|
||||
'account_type' => '主账号',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertSee('data-business-summary-cards', false)
|
||||
->assertSee('data-business-summary-card="账号总数"', false)
|
||||
->assertSee('data-business-summary-card="主账号"', false)
|
||||
->assertSee('data-business-summary-card="子账号"', false)
|
||||
->assertSee('account_type=', false)
|
||||
->assertSee('aria-current="true"', false)
|
||||
->assertSeeText('958')
|
||||
->assertSeeText('640')
|
||||
->assertSeeText('318')
|
||||
->assertSee('查看明细', false);
|
||||
->assertDontSee('data-business-summary-cards', false);
|
||||
}
|
||||
|
||||
public function testOperatingReportPagesRenderTableSpecificSummaryCards(): void
|
||||
{
|
||||
$pages = [
|
||||
['company-cost-arrangement', ['数据状态', '完整表头', '11 列', '核心结果', '缺口提示', '配平提示']],
|
||||
['tax-forecast', ['数据状态', '完整表头', '22 列', '计算税种', '必补口径', '当前记录']],
|
||||
['personnel-inventory', ['数据状态', '完整表头', '17 列', '敏感字段', '容量规则', '当前记录']],
|
||||
];
|
||||
|
||||
foreach ($pages as [$page, $labels]) {
|
||||
$response = $this->loginAs()->get(route('business.pages.show', [
|
||||
'section' => 'company-management',
|
||||
'page' => $page,
|
||||
]));
|
||||
|
||||
$response->assertOk()->assertSee('data-business-summary-cards', false);
|
||||
foreach ($labels as $label) {
|
||||
$response->assertSeeText($label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testOperatingReportFieldContractsKeepAllOriginalHeaders(): void
|
||||
{
|
||||
$navigation = require config_path('business_navigation.php');
|
||||
$pages = collect($navigation)
|
||||
->flatMap(static fn (array $section) => collect($section['pages'] ?? [])
|
||||
->map(static fn (array $page): array => [
|
||||
'key' => $section['slug'] . '/' . $page['slug'],
|
||||
'fields' => $page['directory']['fields'] ?? [],
|
||||
]))
|
||||
->keyBy('key');
|
||||
$expectedFieldCounts = [
|
||||
'company-management/subject-operating-report' => 21,
|
||||
'company-management/company-cost-arrangement' => 10,
|
||||
'company-management/tax-forecast' => 21,
|
||||
'company-management/personnel-inventory' => 16,
|
||||
'store-management/store-report' => 26,
|
||||
'store-management/internal-flow-report' => 15,
|
||||
];
|
||||
|
||||
foreach ($expectedFieldCounts as $key => $count) {
|
||||
$fields = $pages[$key]['fields'];
|
||||
$names = array_column($fields, 'name');
|
||||
|
||||
$this->assertCount($count, $fields, $key . ' 的字段数量不应减少');
|
||||
$this->assertCount($count, array_unique($names), $key . ' 的字段名不应重复');
|
||||
}
|
||||
}
|
||||
|
||||
public function testNavigationUsesConfiguredPermissionsAndTitles(): void
|
||||
@ -150,6 +184,8 @@ class PrototypePageTest extends FeatureTestCase
|
||||
->assertSeeText('测试主体')
|
||||
->assertSeeText('小规模纳税人')
|
||||
->assertSeeText('个人独资企业')
|
||||
->assertSee('directory-value-badge', false)
|
||||
->assertSee('data-tone="info"', false)
|
||||
->assertSeeText('共 1 条')
|
||||
->assertSeeText('已从共享业务镜像读取')
|
||||
->assertDontSee('<div class="directory-table-tools" data-directory-tools>', false)
|
||||
@ -191,16 +227,11 @@ class PrototypePageTest extends FeatureTestCase
|
||||
->assertSeeTextInOrder(['最近12个月累计收入', '1月收入', '12月收入']);
|
||||
}
|
||||
|
||||
public function testSubjectOperatingReportHidesMonthsWithoutDataAndKeepsThemSelectable(): void
|
||||
public function testSubjectOperatingReportShowsAllMonthsByDefaultAndStillSupportsColumnSelection(): void
|
||||
{
|
||||
$service = Mockery::mock(UpstreamBusinessInformation::class);
|
||||
$service->shouldReceive('paginate')->with('company-management', 'subject-operating-report', 50)
|
||||
->andReturnUsing(function (): LengthAwarePaginator {
|
||||
request()->attributes->set(
|
||||
'subject-operating-report.default_hidden_columns',
|
||||
['income_01', 'income_02'],
|
||||
);
|
||||
|
||||
return new LengthAwarePaginator([(object) [
|
||||
'entity' => '测试主体',
|
||||
'city' => '常州市',
|
||||
@ -224,14 +255,13 @@ class PrototypePageTest extends FeatureTestCase
|
||||
$response->assertOk();
|
||||
$html = $response->getContent();
|
||||
|
||||
// 没有数据的月份默认隐藏,但表头和「筛选字段」勾选项仍在页面中。
|
||||
$this->assertMatchesRegularExpression('/<th[^>]*data-column-key="income_01"[^>]*is-column-hidden/', $html);
|
||||
$this->assertMatchesRegularExpression('/<th[^>]*data-column-key="income_02"[^>]*is-column-hidden/', $html);
|
||||
// 所有原始月份表头默认显示,避免新增汇总卡后缩减原表字段。
|
||||
$this->assertDoesNotMatchRegularExpression('/<th[^>]*data-column-key="income_01"[^>]*is-column-hidden/', $html);
|
||||
$this->assertDoesNotMatchRegularExpression('/<th[^>]*data-column-key="income_02"[^>]*is-column-hidden/', $html);
|
||||
$this->assertDoesNotMatchRegularExpression('/<th[^>]*data-column-key="income_03"[^>]*is-column-hidden/', $html);
|
||||
$this->assertStringContainsString('value="income_01" data-directory-query-column', $html);
|
||||
$this->assertStringNotContainsString('value="income_01" data-directory-query-column checked', $html);
|
||||
$this->assertStringContainsString('value="income_01" data-directory-query-column checked', $html);
|
||||
$this->assertStringContainsString('value="income_03" data-directory-query-column checked', $html);
|
||||
$this->assertStringContainsString('筛选字段 19/21', $html);
|
||||
|
||||
// 手动勾选(columns 参数)后,对应月份列恢复显示。
|
||||
$restored = $this->get(route('business.pages.show', [
|
||||
@ -247,16 +277,11 @@ class PrototypePageTest extends FeatureTestCase
|
||||
$this->assertMatchesRegularExpression('/<th[^>]*data-column-key="income_04"[^>]*is-column-hidden/', $restoredHtml);
|
||||
}
|
||||
|
||||
public function testStoreReportHidesSalesMonthsWithoutDataAndKeepsThemSelectable(): void
|
||||
public function testStoreReportShowsAllMonthsByDefaultAndStillSupportsColumnSelection(): void
|
||||
{
|
||||
$service = Mockery::mock(UpstreamBusinessInformation::class);
|
||||
$service->shouldReceive('paginate')->with('store-management', 'store-report', 50)
|
||||
->andReturnUsing(function (): LengthAwarePaginator {
|
||||
request()->attributes->set(
|
||||
'store-report.default_hidden_columns',
|
||||
['sales_01', 'sales_08'],
|
||||
);
|
||||
|
||||
return new LengthAwarePaginator([(object) [
|
||||
'erp_store_name' => 'ERP测试店铺',
|
||||
'store_name' => '前台测试店铺',
|
||||
@ -280,14 +305,13 @@ class PrototypePageTest extends FeatureTestCase
|
||||
$response->assertOk();
|
||||
$html = $response->getContent();
|
||||
|
||||
// 没有业绩的月份默认隐藏,但表头和「筛选字段」勾选项仍在页面中。
|
||||
$this->assertMatchesRegularExpression('/<th[^>]*data-column-key="sales_01"[^>]*is-column-hidden/', $html);
|
||||
$this->assertMatchesRegularExpression('/<th[^>]*data-column-key="sales_08"[^>]*is-column-hidden/', $html);
|
||||
// 所有原始月份表头默认显示,避免新增汇总卡后缩减原表字段。
|
||||
$this->assertDoesNotMatchRegularExpression('/<th[^>]*data-column-key="sales_01"[^>]*is-column-hidden/', $html);
|
||||
$this->assertDoesNotMatchRegularExpression('/<th[^>]*data-column-key="sales_08"[^>]*is-column-hidden/', $html);
|
||||
$this->assertDoesNotMatchRegularExpression('/<th[^>]*data-column-key="sales_07"[^>]*is-column-hidden/', $html);
|
||||
$this->assertStringContainsString('value="sales_01" data-directory-query-column', $html);
|
||||
$this->assertStringNotContainsString('value="sales_01" data-directory-query-column checked', $html);
|
||||
$this->assertStringContainsString('value="sales_01" data-directory-query-column checked', $html);
|
||||
$this->assertStringContainsString('value="sales_07" data-directory-query-column checked', $html);
|
||||
$this->assertStringContainsString('筛选字段 24/26', $html);
|
||||
|
||||
// 手动勾选(columns 参数)后,对应月份列恢复显示。
|
||||
$restored = $this->get(route('business.pages.show', [
|
||||
|
||||
@ -117,6 +117,11 @@ class InternalFlowReportImportTest extends TestCase
|
||||
$all = $repository->paginate(1, 50);
|
||||
$this->assertSame(3, $all['total']);
|
||||
$this->assertSame('示例甲供应链有限公司', $all['data'][0]['company_name']);
|
||||
$this->assertSame(3, $all['summary']['companies']);
|
||||
$this->assertSame(3669135.68, $all['summary']['projected_sales']);
|
||||
$this->assertSame(1420000.61, $all['summary']['receipt_total']);
|
||||
$this->assertEqualsWithDelta(1401086.9311, $all['summary']['remaining_gap'], 0.005);
|
||||
$this->assertEqualsWithDelta(71.0, $all['summary']['average_invoicing_ratio'], 0.000001);
|
||||
|
||||
$filtered = $repository->paginate(1, 50, ['company_name' => '示例乙']);
|
||||
$this->assertSame(1, $filtered['total']);
|
||||
|
||||
@ -136,6 +136,8 @@ class BusinessInformationMirrorRepositoryTest extends TestCase
|
||||
$this->assertSame(1, $businessTypedCompany['total']);
|
||||
$this->assertSame('个人独资企业', $businessTypedCompany['data'][0]['business_registration_type']);
|
||||
$this->assertSame(1, $cityCompany['total']);
|
||||
$this->assertSame('保留', $companyClassifications['新公司']['status']);
|
||||
$this->assertSame('待注销', $companyClassifications['其他公司']['status']);
|
||||
$this->assertSame('小规模纳税人', $companyClassifications['新公司']['tax_type']);
|
||||
$this->assertSame('个人独资企业', $companyClassifications['新公司']['business_registration_type']);
|
||||
$this->assertNull($companyClassifications['旧公司']['business_registration_type']);
|
||||
|
||||
@ -256,6 +256,7 @@ class StoreReportRepositoryTest extends TestCase
|
||||
|
||||
public function test_upstream_business_information_exposes_shared_store_report_rows(): void
|
||||
{
|
||||
Carbon::setTestNow('2026-07-15 10:00:00');
|
||||
$this->insertBill('店铺A', '2026-07-05', 60);
|
||||
$mirror = Mockery::mock(BusinessInformationMirrorRepository::class);
|
||||
$mirror->shouldReceive('ready')->with('store-information.read')->andReturnTrue();
|
||||
@ -287,14 +288,14 @@ class StoreReportRepositoryTest extends TestCase
|
||||
$this->assertSame('部门负责人', $paginator->items()[0]->department_manager);
|
||||
$this->assertSame('运营中心A', $paginator->items()[0]->profit_center);
|
||||
$summaryCards = collect($this->app['request']->attributes->get('business-page-summary-cards'))->keyBy('label');
|
||||
$this->assertSame(1, $summaryCards['店铺总数']['value']);
|
||||
$this->assertSame(1, $summaryCards['正常店铺']['value']);
|
||||
$this->assertSame(0, $summaryCards['关店中']['value']);
|
||||
$this->assertSame(0, $summaryCards['已关闭']['value']);
|
||||
$this->assertSame(60.0, (float) $summaryCards['期间销量']['value']);
|
||||
$this->assertSame(1, $summaryCards['正常存续店铺']['value']);
|
||||
$this->assertSame(0.0, (float) $summaryCards['上月(6月)销量']['value']);
|
||||
$this->assertSame(60.0, (float) $summaryCards['当月(7月)销量']['value']);
|
||||
$this->assertSame(0, $summaryCards['上月(6月)有销量店铺']['value']);
|
||||
$this->assertSame(1, $summaryCards['当月(7月)有销量店铺']['value']);
|
||||
}
|
||||
|
||||
public function test_store_report_hides_sales_months_without_data_by_default(): void
|
||||
public function test_store_report_keeps_all_sales_months_visible_by_default(): void
|
||||
{
|
||||
Carbon::setTestNow('2026-09-15 10:00:00');
|
||||
$this->insertBill('店铺A', '2026-07-05', 60);
|
||||
@ -314,15 +315,44 @@ class StoreReportRepositoryTest extends TestCase
|
||||
|
||||
$paginator = $service->paginate('store-management', 'store-report', 50);
|
||||
|
||||
// 只有 7 月有业绩,其余月份列默认隐藏。
|
||||
$this->assertSame(
|
||||
['sales_01', 'sales_02', 'sales_03', 'sales_04', 'sales_05', 'sales_06', 'sales_08', 'sales_09', 'sales_10', 'sales_11', 'sales_12'],
|
||||
$this->assertNull(
|
||||
$this->app['request']->attributes->get('store-report.default_hidden_columns'),
|
||||
);
|
||||
$this->assertSame(1, $paginator->total());
|
||||
$this->assertSame(60.0, (float) $paginator->items()[0]->sales_07);
|
||||
}
|
||||
|
||||
public function test_store_cards_exclude_closed_store_but_keep_its_detail_row(): void
|
||||
{
|
||||
Carbon::setTestNow('2026-07-15 10:00:00');
|
||||
$this->insertBill('正常店铺', '2026-07-05', 10);
|
||||
$this->insertBill('已关店铺', '2026-07-06', 90);
|
||||
|
||||
$mirror = Mockery::mock(BusinessInformationMirrorRepository::class);
|
||||
$mirror->shouldReceive('ready')->with('store-information.read')->andReturnTrue();
|
||||
$mirror->shouldReceive('allStores')->andReturn([
|
||||
['erp_store_name' => '正常店铺', 'company_name' => '主体甲', 'store_status' => '0'],
|
||||
['erp_store_name' => '已关店铺', 'company_name' => '主体乙', 'store_status' => '6'],
|
||||
]);
|
||||
$accounts = Mockery::mock(StoreAccountMirrorRepository::class);
|
||||
$accounts->shouldReceive('ownershipByStoreName')->andReturn([]);
|
||||
$service = new UpstreamBusinessInformation(
|
||||
Mockery::mock(UpstreamQueryCacheFactory::class),
|
||||
$mirror,
|
||||
$this->repository,
|
||||
$accounts,
|
||||
);
|
||||
|
||||
$paginator = $service->paginate('store-management', 'store-report', 50);
|
||||
$summaryCards = collect($this->app['request']->attributes->get('business-page-summary-cards'))->keyBy('label');
|
||||
|
||||
// 已关店铺明细继续保留,只从“正常存续”汇总卡中剔除。
|
||||
$this->assertSame(2, $paginator->total());
|
||||
$this->assertSame(1, $summaryCards['正常存续店铺']['value']);
|
||||
$this->assertSame(10.0, (float) $summaryCards['当月(7月)销量']['value']);
|
||||
$this->assertSame(1, $summaryCards['当月(7月)有销量店铺']['value']);
|
||||
}
|
||||
|
||||
public function test_subject_operating_report_aggregates_income_by_entity(): void
|
||||
{
|
||||
Carbon::setTestNow('2026-09-01 10:00:00');
|
||||
@ -371,10 +401,12 @@ class StoreReportRepositoryTest extends TestCase
|
||||
$this->assertSame('小规模纳税人', $rows[0]->tax_type);
|
||||
$this->assertSame('个人独资企业', $rows[0]->business_registration_type);
|
||||
$summaryCards = collect($this->app['request']->attributes->get('business-page-summary-cards'))->keyBy('label');
|
||||
$this->assertSame(1, $summaryCards['主体总数']['value']);
|
||||
$this->assertSame(1, $summaryCards['有效主体']['value']);
|
||||
$this->assertSame(0, $summaryCards['已注销主体']['value']);
|
||||
$this->assertSame(90.0, (float) $summaryCards['最近12个月收入']['value']);
|
||||
$this->assertSame(1, $summaryCards['正常存续主体']['value']);
|
||||
$this->assertSame(70.0, (float) $summaryCards['上月(8月)收入']['value']);
|
||||
$this->assertSame(0.0, (float) $summaryCards['当月(9月)收入']['value']);
|
||||
$this->assertSame(1, $summaryCards['小规模纳税人']['value']);
|
||||
$this->assertSame(0, $summaryCards['一般纳税人']['value']);
|
||||
$this->assertArrayNotHasKey('最近12个月收入', $summaryCards);
|
||||
|
||||
request()->merge(['income_08' => '70.00']);
|
||||
$this->assertSame(1, $service->paginate('company-management', 'subject-operating-report', 50)->total());
|
||||
@ -392,6 +424,110 @@ class StoreReportRepositoryTest extends TestCase
|
||||
$this->assertSame(0, $service->paginate('company-management', 'subject-operating-report', 50)->total());
|
||||
}
|
||||
|
||||
public function test_subject_cards_exclude_deregistered_entities_and_show_slash_for_their_types(): void
|
||||
{
|
||||
Carbon::setTestNow('2026-09-15 10:00:00');
|
||||
$this->insertBill('店铺正常', '2026-08-05', 30);
|
||||
$this->insertBill('店铺注销', '2026-08-06', 70);
|
||||
|
||||
$mirror = Mockery::mock(BusinessInformationMirrorRepository::class);
|
||||
$mirror->shouldReceive('ready')->with('store-information.read')->andReturnTrue();
|
||||
$mirror->shouldReceive('ready')->with('company-information.read')->andReturnTrue();
|
||||
$mirror->shouldReceive('allStores')->andReturn([
|
||||
['erp_store_name' => '店铺正常', 'company_name' => '存续主体', 'store_status' => '0'],
|
||||
['erp_store_name' => '店铺注销', 'company_name' => '注销主体', 'store_status' => '0'],
|
||||
]);
|
||||
$mirror->shouldReceive('companiesByNames')->andReturn([
|
||||
'存续主体' => [[
|
||||
'Id' => 2,
|
||||
'businessLicenseName' => '存续主体',
|
||||
'companyStatus' => '0',
|
||||
'taxCategoryAndType' => '小规模',
|
||||
'business_registration_type' => null,
|
||||
]],
|
||||
'注销主体' => [[
|
||||
'Id' => 1,
|
||||
'businessLicenseName' => '注销主体',
|
||||
'companyStatus' => '1',
|
||||
'taxCategoryAndType' => '一般纳税人',
|
||||
'business_registration_type' => '有限公司',
|
||||
]],
|
||||
]);
|
||||
$mirror->shouldReceive('companyClassificationsByNames')->andReturn([]);
|
||||
$accounts = Mockery::mock(StoreAccountMirrorRepository::class);
|
||||
$accounts->shouldReceive('ownershipByStoreName')->andReturn([]);
|
||||
$service = new UpstreamBusinessInformation(
|
||||
Mockery::mock(UpstreamQueryCacheFactory::class),
|
||||
$mirror,
|
||||
$this->repository,
|
||||
$accounts,
|
||||
);
|
||||
|
||||
$rows = collect($service->paginate('company-management', 'subject-operating-report', 50)->items())->keyBy('entity');
|
||||
$summaryCards = collect($this->app['request']->attributes->get('business-page-summary-cards'))->keyBy('label');
|
||||
|
||||
$this->assertSame('小规模纳税人', $rows['存续主体']->tax_type);
|
||||
$this->assertSame('待维护', $rows['存续主体']->business_registration_type);
|
||||
$this->assertSame('/', $rows['注销主体']->tax_type);
|
||||
$this->assertSame('/', $rows['注销主体']->business_registration_type);
|
||||
$this->assertSame(1, $summaryCards['正常存续主体']['value']);
|
||||
$this->assertSame(30.0, (float) $summaryCards['上月(8月)收入']['value']);
|
||||
$this->assertSame(1, $summaryCards['小规模纳税人']['value']);
|
||||
$this->assertSame(0, $summaryCards['一般纳税人']['value']);
|
||||
}
|
||||
|
||||
public function test_subject_uses_company_ledger_retained_tag_for_operating_population(): void
|
||||
{
|
||||
Carbon::setTestNow('2026-09-15 10:00:00');
|
||||
$this->insertBill('保留店铺', '2026-08-05', 30);
|
||||
$this->insertBill('待注销店铺', '2026-08-06', 70);
|
||||
|
||||
$mirror = Mockery::mock(BusinessInformationMirrorRepository::class);
|
||||
$mirror->shouldReceive('ready')->with('store-information.read')->andReturnTrue();
|
||||
$mirror->shouldReceive('ready')->with('company-information.read')->andReturnTrue();
|
||||
$mirror->shouldReceive('allStores')->andReturn([
|
||||
['erp_store_name' => '保留店铺', 'company_name' => '保留主体', 'store_status' => '0'],
|
||||
['erp_store_name' => '待注销店铺', 'company_name' => '待注销主体', 'store_status' => '0'],
|
||||
]);
|
||||
$mirror->shouldReceive('companiesByNames')->andReturn([
|
||||
'保留主体' => [[
|
||||
'Id' => 1,
|
||||
'businessLicenseName' => '保留主体',
|
||||
'companyStatus' => '0',
|
||||
'taxCategoryAndType' => '小规模纳税人',
|
||||
'business_registration_type' => '/',
|
||||
]],
|
||||
'待注销主体' => [[
|
||||
'Id' => 2,
|
||||
'businessLicenseName' => '待注销主体',
|
||||
'companyStatus' => '0',
|
||||
'taxCategoryAndType' => '一般纳税人',
|
||||
'business_registration_type' => '核定',
|
||||
]],
|
||||
]);
|
||||
$mirror->shouldReceive('companyClassificationsByNames')->andReturn([
|
||||
'保留主体' => ['status' => '保留', 'tax_type' => '小规模纳税人', 'business_registration_type' => null],
|
||||
'待注销主体' => ['status' => '待注销', 'tax_type' => '一般纳税人', 'business_registration_type' => '核定'],
|
||||
]);
|
||||
$accounts = Mockery::mock(StoreAccountMirrorRepository::class);
|
||||
$accounts->shouldReceive('ownershipByStoreName')->andReturn([]);
|
||||
$service = new UpstreamBusinessInformation(
|
||||
Mockery::mock(UpstreamQueryCacheFactory::class),
|
||||
$mirror,
|
||||
$this->repository,
|
||||
$accounts,
|
||||
);
|
||||
|
||||
$rows = collect($service->paginate('company-management', 'subject-operating-report', 50)->items())->keyBy('entity');
|
||||
$summaryCards = collect($this->app['request']->attributes->get('business-page-summary-cards'))->keyBy('label');
|
||||
|
||||
$this->assertSame('待维护', $rows['保留主体']->business_registration_type);
|
||||
$this->assertSame('/', $rows['待注销主体']->tax_type);
|
||||
$this->assertSame('/', $rows['待注销主体']->business_registration_type);
|
||||
$this->assertSame(1, $summaryCards['正常存续主体']['value']);
|
||||
$this->assertSame(30.0, (float) $summaryCards['上月(8月)收入']['value']);
|
||||
}
|
||||
|
||||
private function insertBill(string $store, string $occurredOn, float $income): void
|
||||
{
|
||||
$this->insertIncome($store, $occurredOn, $income);
|
||||
|
||||
@ -160,14 +160,10 @@ class UpstreamBusinessInformationTest extends TestCase
|
||||
$this->assertNotSame('运营总监', $paginator->items()[0]->department_manager);
|
||||
$this->assertSame('正常', $paginator->items()[0]->store_status);
|
||||
$summaryCards = collect($this->app['request']->attributes->get('business-page-summary-cards'))->keyBy('label');
|
||||
$this->assertSame(1, $summaryCards['店铺总数']['value']);
|
||||
$this->assertSame(1, $summaryCards['正常店铺']['value']);
|
||||
$this->assertSame(0, $summaryCards['关闭中']['value']);
|
||||
$this->assertSame(0, $summaryCards['已关闭']['value']);
|
||||
$this->assertSame(1, $summaryCards['平台数']['value']);
|
||||
$this->assertSame([], $summaryCards->all());
|
||||
}
|
||||
|
||||
public function test_company_and_trademark_mirror_summaries_become_clickable_cards(): void
|
||||
public function test_base_information_pages_do_not_render_summary_cards(): void
|
||||
{
|
||||
$mirror = Mockery::mock(BusinessInformationMirrorRepository::class);
|
||||
$mirror->shouldReceive('ready')->times(2)->andReturnUsing(
|
||||
@ -203,16 +199,11 @@ class UpstreamBusinessInformationTest extends TestCase
|
||||
);
|
||||
$information->paginate('company-management', 'basic-information', 50);
|
||||
$companyCards = collect($this->app['request']->attributes->get('business-page-summary-cards'))->keyBy('label');
|
||||
$this->assertSame(818, $companyCards['公司总数']['value']);
|
||||
$this->assertSame(['page' => null, 'company_status' => '正常'], $companyCards['正常公司']['query']);
|
||||
$this->assertSame(['page' => null, 'taxpayer_type' => '一般纳税人'], $companyCards['一般纳税人']['query']);
|
||||
$this->assertSame([], $companyCards->all());
|
||||
|
||||
$information->paginate('trademark-management', 'information', 50);
|
||||
$trademarkCards = collect($this->app['request']->attributes->get('business-page-summary-cards'))->keyBy('label');
|
||||
$this->assertSame(593, $trademarkCards['商标总数']['value']);
|
||||
$this->assertSame(45, $trademarkCards['未启用']['value']);
|
||||
$this->assertSame(['page' => null, 'trademark_status' => '有效'], $trademarkCards['有效商标']['query']);
|
||||
$this->assertSame('final_holder', $trademarkCards['最终持有人']['query']['sort']);
|
||||
$this->assertSame([], $trademarkCards->all());
|
||||
}
|
||||
|
||||
public function test_bootstrap_without_mirror_explains_shared_connection_instead_of_requesting_upstream_credentials(): void
|
||||
@ -228,7 +219,7 @@ class UpstreamBusinessInformationTest extends TestCase
|
||||
->paginate('store-management', 'basic-information');
|
||||
}
|
||||
|
||||
public function test_subject_operating_report_hides_income_months_without_data_by_default(): void
|
||||
public function test_subject_operating_report_keeps_all_income_months_visible_by_default(): void
|
||||
{
|
||||
$mirror = Mockery::mock(BusinessInformationMirrorRepository::class);
|
||||
$mirror->shouldReceive('ready')->with('store-information.read')->andReturnTrue();
|
||||
@ -267,9 +258,7 @@ class UpstreamBusinessInformationTest extends TestCase
|
||||
|
||||
$paginator = $information->paginate('company-management', 'subject-operating-report', 50);
|
||||
|
||||
// income_02 有金额、income_03 为 0 都算有数据,其余空月份默认隐藏。
|
||||
$this->assertSame(
|
||||
['income_01', 'income_04', 'income_05', 'income_06', 'income_07', 'income_08', 'income_09', 'income_10', 'income_11', 'income_12'],
|
||||
$this->assertNull(
|
||||
$this->app['request']->attributes->get('subject-operating-report.default_hidden_columns'),
|
||||
);
|
||||
$this->assertSame(1, $paginator->total());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user