Merge remote-tracking branch 'origin/fix/sumu-product-prices' into fix/WuYongJie-product-prices-review

This commit is contained in:
WuYongJie 2026-07-30 18:39:55 +08:00
commit 78f38ad19c
27 changed files with 1127 additions and 209 deletions

View File

@ -7,11 +7,14 @@ use App\Models\StoreReceivables\StoreZhongcaiReconciliation;
use App\Utilities\SidebarPermissions;
use Illuminate\Routing\Controller;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Collection;
use Modules\EcommerceFinance\Repositories\EdgeBandingRepository;
use Modules\EcommerceFinance\Repositories\InventoryRepository;
use Modules\EcommerceFinance\Repositories\PinduoduoSpreadBillRepository;
use Modules\EcommerceFinance\Repositories\ProductPriceRepository;
use Modules\EcommerceFinance\Repositories\RawBoardPayablesRepository;
use Modules\EcommerceFinance\Repositories\SupplierPayableReportRepository;
use Modules\EcommerceFinance\Repositories\TmallTaobaoSpreadBillRepository;
use Modules\EcommerceFinance\Services\UpstreamQueryCacheFactory;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
@ -28,7 +31,9 @@ class Pages extends Controller
public function __construct(
private readonly EdgeBandingRepository $edgeBanding,
private readonly InventoryRepository $inventory,
private readonly ProductPriceRepository $productPrices,
private readonly RawBoardPayablesRepository $rawBoardPayables,
private readonly SupplierPayableReportRepository $supplierPayableReports,
private readonly UpstreamQueryCacheFactory $upstreamCaches,
) {
}
@ -146,10 +151,178 @@ class Pages extends Controller
return match ($page) {
'marketing-account-bills' => $this->contentForMarketingAccountBills($tab),
'zhongcai-reconciliation' => $this->contentForZhongcaiReconciliation(),
'product-prices' => $this->contentForProductPrices(),
'board-deductions' => $this->contentForBoardDeductions(),
'supplier-payables-report' => $this->contentForSupplierPayablesReport(),
default => null,
};
}
protected function contentForBoardDeductions(): array
{
$filters = [
'stock_in_date' => $this->dateFilter(request('stock_in_date')),
'stock_out_date' => $this->dateFilter(request('stock_out_date')),
'furniture_factory' => mb_substr(trim((string) request('furniture_factory', '')), 0, 191),
'lamination_factory' => mb_substr(trim((string) request('lamination_factory', '')), 0, 191),
'deduction_type' => mb_substr(trim((string) request('deduction_type', '')), 0, 191),
'material_name' => mb_substr(trim((string) request('material_name', '')), 0, 191),
'claim_number' => mb_substr(trim((string) request('claim_number', '')), 0, 191),
];
$page = max((int) request('page', 1), 1);
$limit = min(max((int) setting('default.list_limit', 25), 1), 100);
$cache = $this->upstreamCaches->forSource('jiansun');
try {
$result = $cache->remember(
'supplier-payables.board-deductions.list',
['filters' => $filters, 'page' => $page, 'limit' => $limit],
fn () => $this->supplierPayableReports->boardDeductions($filters, $page, $limit),
);
return [
'boardDeductions' => $this->supplierPayablePaginator((array) ($result['rows'] ?? []), $limit, $page),
'boardDeductionFilters' => $filters,
'boardDeductionStatus' => $cache->responseHeaders(),
'boardDeductionError' => null,
];
} catch (ServiceUnavailableHttpException $exception) {
return [
'boardDeductions' => $this->supplierPayablePaginator([], $limit, $page),
'boardDeductionFilters' => $filters,
'boardDeductionStatus' => [],
'boardDeductionError' => $exception->getMessage(),
];
} catch (Throwable $exception) {
report($exception);
return [
'boardDeductions' => $this->supplierPayablePaginator([], $limit, $page),
'boardDeductionFilters' => $filters,
'boardDeductionStatus' => [],
'boardDeductionError' => '板材扣款数据暂时无法读取,请稍后重试。',
];
}
}
protected function contentForSupplierPayablesReport(): array
{
$month = trim((string) request('month', ''));
$filters = [
'month' => preg_match('/^\d{4}-\d{2}$/', $month) === 1 ? $month : '',
'supplier' => mb_substr(trim((string) request('supplier', '')), 0, 191),
'checker' => mb_substr(trim((string) request('checker', '')), 0, 191),
'settlement_method' => mb_substr(trim((string) request('settlement_method', '')), 0, 191),
];
$page = max((int) request('page', 1), 1);
$limit = min(max((int) setting('default.list_limit', 25), 1), 100);
$cache = $this->upstreamCaches->forSource('jiansun');
try {
$result = $cache->remember(
'supplier-payables.report.list',
['filters' => $filters, 'page' => $page, 'limit' => $limit],
fn () => $this->supplierPayableReports->supplierPayables($filters, $page, $limit),
);
return [
'supplierPayables' => $this->supplierPayablePaginator((array) ($result['rows'] ?? []), $limit, $page),
'supplierPayableFilters' => $filters,
'supplierPayableStatus' => $cache->responseHeaders(),
'supplierPayableError' => null,
];
} catch (ServiceUnavailableHttpException $exception) {
return [
'supplierPayables' => $this->supplierPayablePaginator([], $limit, $page),
'supplierPayableFilters' => $filters,
'supplierPayableStatus' => [],
'supplierPayableError' => $exception->getMessage(),
];
} catch (Throwable $exception) {
report($exception);
return [
'supplierPayables' => $this->supplierPayablePaginator([], $limit, $page),
'supplierPayableFilters' => $filters,
'supplierPayableStatus' => [],
'supplierPayableError' => '供应商应付数据暂时无法读取,请稍后重试。',
];
}
}
private function supplierPayablePaginator(array $rows, int $limit, int $page): Paginator
{
return new Paginator(
Collection::make($rows)->map(static fn (array $row): object => (object) $row),
$limit,
$page,
[
'path' => request()->url(),
'query' => request()->except('page'),
],
);
}
protected function contentForProductPrices(): array
{
$priceType = trim((string) request('price_type', ''));
$costReduction = trim((string) request('cost_reduction', ''));
$filters = [
'barcode' => mb_substr(trim((string) request('barcode', '')), 0, 191),
'price_type' => in_array($priceType, ['pricing', 'repricing'], true) ? $priceType : '',
'cost_reduction' => in_array($costReduction, ['yes', 'no'], true) ? $costReduction : '',
'effective_from' => $this->dateFilter(request('effective_from')),
'effective_to' => $this->dateFilter(request('effective_to')),
];
$page = max((int) request('page', 1), 1);
$limit = min(max((int) setting('default.list_limit', 25), 1), 100);
$cache = $this->upstreamCaches->forSource('jiansun');
try {
$result = $cache->remember(
'supplier-payables.product-prices.list',
['filters' => $filters, 'page' => $page, 'limit' => $limit],
fn () => $this->productPrices->paginate($filters, $page, $limit),
);
return [
'productPrices' => $this->productPricePaginator((array) ($result['rows'] ?? []), $limit, $page),
'productPriceFilters' => $filters,
'productPriceStatus' => $cache->responseHeaders(),
'productPriceError' => null,
];
} catch (ServiceUnavailableHttpException $exception) {
return [
'productPrices' => $this->productPricePaginator([], $limit, $page),
'productPriceFilters' => $filters,
'productPriceStatus' => [],
'productPriceError' => $exception->getMessage(),
];
} catch (Throwable $exception) {
report($exception);
return [
'productPrices' => $this->productPricePaginator([], $limit, $page),
'productPriceFilters' => $filters,
'productPriceStatus' => [],
'productPriceError' => '商品价格暂时无法读取,请稍后重试。',
];
}
}
private function productPricePaginator(array $rows, int $limit, int $page): Paginator
{
return new Paginator(
Collection::make($rows)->map(static fn (array $row): object => (object) $row),
$limit,
$page,
[
'path' => request()->url(),
'query' => request()->except('page'),
],
);
}
/**
* 封边条页面只读取上游快照;未启用或无快照时将错误交给页面显示,
* 避免工作台因上游暂不可用直接返回 500。

View File

@ -157,6 +157,7 @@ class Kernel extends HttpKernel
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'business.page' => \App\Http\Middleware\EnsureBusinessPageAccess::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'cookies.encrypt' => \App\Http\Middleware\EncryptCookies::class,

View File

@ -0,0 +1,23 @@
<?php
namespace App\Http\Middleware;
use App\Utilities\SidebarPermissions;
use Closure;
use Illuminate\Http\Request;
class EnsureBusinessPageAccess
{
public function handle(Request $request, Closure $next, string $section, string $page): mixed
{
$sectionConfig = collect(SidebarPermissions::navigationFor(user()))->firstWhere('slug', $section);
$pages = collect($sectionConfig['pages'] ?? [])->flatMap(static fn (array $configuredPage): array => [
$configuredPage,
...($configuredPage['children'] ?? []),
]);
abort_unless($pages->contains('slug', $page), 403, '当前账号没有该页面权限。');
return $next($request);
}
}

View File

@ -208,9 +208,9 @@ class GoodsReconciliationRepository
ISNULL(s.spo, '') AS purchaseNo,
FORMAT(ISNULL(s.created, s.createTime), 'yyyy-MM-dd HH:mm:ss') AS sendTime,
ISNULL(s.scmname, '') AS supplier,
ISNULL(s.skuoid, '') AS goodsNo,
ISNULL(s.skuoid, '') AS skuCode,
ISNULL(s.procode, '') AS productCode,
ISNULL(s.skuname, '') AS specName,
ISNULL(s.skuname, '') AS skuName,
ISNULL(s.settlementStock, 0) AS qty,
ISNULL(s.singlePrice, 0) AS unitPrice,
ISNULL(s.settlementPrice, 0) AS amount,
@ -218,7 +218,7 @@ class GoodsReconciliationRepository
ISNULL(s.settlementStock * ISNULL(a.price, 0), 0) AS guessAmount,
'' AS supplierGoodsCode,
ISNULL(s.remark, '') AS remark,
ISNULL(s.whname, '') AS warehouseName,
ISNULL(s.whname, '') AS warehouse,
FORMAT(s.createTime, 'yyyy-MM-dd HH:mm:ss') AS createTime,
'' AS expressName,
'' AS expressNo,
@ -259,9 +259,9 @@ class GoodsReconciliationRepository
'' AS purchaseNo,
FORMAT(s.sendTime, 'yyyy-MM-dd HH:mm:ss') AS sendTime,
ISNULL(s.supplier, '') AS supplier,
ISNULL(s.skucode, '') AS goodsNo,
ISNULL(s.skucode, '') AS skuCode,
ISNULL(s.procode, '') AS productCode,
ISNULL(s.skuname, '') AS specName,
ISNULL(s.skuname, '') AS skuName,
ISNULL(s.settlementStock, 0) AS qty,
ISNULL(s.singlePrice, 0) AS unitPrice,
ISNULL(s.settlementPrice, 0) AS amount,
@ -269,7 +269,7 @@ class GoodsReconciliationRepository
ISNULL(s.settlementStock * ISNULL(a.price, 0), 0) AS guessAmount,
'' AS supplierGoodsCode,
ISNULL(s.remark, '') AS remark,
ISNULL(s.whName, '') AS warehouseName,
ISNULL(s.whName, '') AS warehouse,
FORMAT(s.createTime, 'yyyy-MM-dd HH:mm:ss') AS createTime,
ISNULL(s.expressName, '') AS expressName,
ISNULL(s.expressNo, '') AS expressNo,

View File

@ -0,0 +1,110 @@
<?php
namespace Modules\EcommerceFinance\Repositories;
use Modules\EcommerceFinance\Services\UpstreamReadOnlyQuery;
use Modules\EcommerceFinance\Services\UpstreamReadOnlyQueryFactory;
/**
* Supplier product pricing and repricing records from JianSun.
*/
class ProductPriceRepository
{
private const SOURCE = 'jiansun';
private const TABLE = '[dbo].[aaronprice]';
private const PRICE_TYPES = [
'pricing' => '定价',
'repricing' => '变价',
];
private const COST_REDUCTION = [
'yes' => '是',
'no' => '否',
];
private readonly UpstreamReadOnlyQuery $query;
public function __construct(UpstreamReadOnlyQueryFactory $queries)
{
$this->query = $queries->forSource(self::SOURCE);
}
/** @return array{rows:array<int,array<string,mixed>>} */
public function paginate(array $filters, int $page, int $limit): array
{
$page = max($page, 1);
$limit = min(max($limit, 1), 100);
$where = [];
$bindings = [];
if (($filters['barcode'] ?? '') !== '') {
$where[] = "[条形码] LIKE ? ESCAPE '\\'";
$bindings[] = $this->contains((string) $filters['barcode']);
}
$priceType = self::PRICE_TYPES[(string) ($filters['price_type'] ?? '')] ?? null;
if ($priceType !== null) {
$where[] = '[价格类型] = ?';
$bindings[] = $priceType;
}
$costReduction = self::COST_REDUCTION[(string) ($filters['cost_reduction'] ?? '')] ?? null;
if ($costReduction !== null) {
$where[] = '[是否采购降本] = ?';
$bindings[] = $costReduction;
}
if (($filters['effective_from'] ?? '') !== '') {
$where[] = 'TRY_CONVERT(date, [生效开始时间]) >= ?';
$bindings[] = (string) $filters['effective_from'];
}
if (($filters['effective_to'] ?? '') !== '') {
$where[] = 'TRY_CONVERT(date, [生效开始时间]) <= ?';
$bindings[] = (string) $filters['effective_to'];
}
$whereSql = $where === [] ? '' : ' WHERE ' . implode(' AND ', $where);
$offset = ($page - 1) * $limit;
$fetch = $limit + 1;
$sql = 'SELECT '
. '[条形码] AS barcode, '
. '[价格类型] AS price_type, '
. '[变价类型] AS change_type, '
. '[是否采购降本] AS cost_reduction, '
. 'TRY_CONVERT(decimal(18,2), NULLIF([变价前价格], \'\')) AS price_before, '
. 'TRY_CONVERT(decimal(18,2), NULLIF([变价后价格], \'\')) AS price_after, '
. 'TRY_CONVERT(decimal(18,2), NULLIF([差价], \'\')) AS price_diff, '
. '[申请人] AS applicant, '
. '[备注] AS remark, '
. 'CONVERT(varchar(19), TRY_CONVERT(datetime2, [生效开始时间]), 120) AS effective_start, '
. 'CONVERT(varchar(19), TRY_CONVERT(datetime2, [生效结束时间]), 120) AS effective_end, '
. 'CONVERT(varchar(19), TRY_CONVERT(datetime2, [流程完成时间]), 120) AS completed_at '
. 'FROM ' . self::TABLE
. $whereSql
. ' ORDER BY TRY_CONVERT(datetime2, [流程完成时间]) DESC, [条形码] ASC'
. " OFFSET {$offset} ROWS FETCH NEXT {$fetch} ROWS ONLY";
return ['rows' => array_map([$this, 'normalize'], $this->query->select($sql, $bindings))];
}
private function contains(string $value): string
{
return '%' . str_replace(['\\', '%', '_'], ['\\\\', '\\%', '\\_'], trim($value)) . '%';
}
/** @param array<string,mixed> $row */
private function normalize(array $row): array
{
foreach (['price_before', 'price_after', 'price_diff'] as $field) {
$row[$field] = $row[$field] === null || $row[$field] === ''
? null
: (float) $row[$field];
}
return $row;
}
}

View File

@ -0,0 +1,207 @@
<?php
namespace Modules\EcommerceFinance\Repositories;
use Modules\EcommerceFinance\Services\UpstreamReadOnlyQuery;
use Modules\EcommerceFinance\Services\UpstreamReadOnlyQueryFactory;
class SupplierPayableReportRepository
{
private const SOURCE = 'jiansun';
private readonly UpstreamReadOnlyQuery $query;
public function __construct(UpstreamReadOnlyQueryFactory $queries)
{
$this->query = $queries->forSource(self::SOURCE);
}
/** @return array{rows:array<int,array<string,mixed>>} */
public function boardDeductions(array $filters, int $page, int $limit): array
{
[$whereSql, $bindings] = $this->boardWhere($filters);
[$offset, $fetch] = $this->pageWindow($page, $limit);
$sql = 'SELECT '
. '[id] AS id, '
. 'CONVERT(varchar(10), [inDate], 23) AS stock_in_date, '
. 'CONVERT(varchar(10), [deliveryDate], 23) AS stock_out_date, '
. '[giveSupplier] AS furniture_factory, '
. '[arrSupplier] AS lamination_factory, '
. '[name] AS deduction_type, '
. '[number] AS specification, '
. '[plainName] AS material_name, '
. '[inCount] AS received_quantity, '
. '[priceA] AS unit_price, '
. '[moneyA] AS amount, '
. 'CAST(NULL AS varchar(10)) AS unit, '
. 'CONVERT(varchar(10), [date], 23) AS batch_date, '
. '[deliveryNo] AS stock_out_number, '
. '[deliveryRemarks] AS stock_out_remark, '
. '[applyNo] AS claim_number, '
. '[numberType] AS number_type, '
. '[sendNo] AS delivery_number '
. 'FROM [dbo].[finance_boardDeduction]'
. $whereSql
. ' ORDER BY [inDate] DESC, [id] DESC'
. " OFFSET {$offset} ROWS FETCH NEXT {$fetch} ROWS ONLY";
return ['rows' => array_map([$this, 'normalizeBoardRow'], $this->query->select($sql, $bindings))];
}
/** @return array{rows:array<int,array<string,mixed>>} */
public function supplierPayables(array $filters, int $page, int $limit): array
{
[$whereSql, $bindings] = $this->payablesWhere($filters);
[$offset, $fetch] = $this->pageWindow($page, $limit);
$sql = 'SELECT '
. '[id] AS id, '
. '[company] AS company, '
. '[supplier] AS supplier, '
. '[checker] AS checker, '
. '[settleway] AS settlement_method, '
. '[ExpFieght] AS express_freight, '
. '[bginMonthPay] AS beginning_payable, '
. '[unpriced] AS unpriced, '
. '[advloan] AS advance_loan, '
. '[loan] AS loan, '
. '[refund] AS refund, '
. '[procurement] AS procurement, '
. '[invoiceDct] AS invoice_deduction, '
. '[boardDct] AS board_deduction, '
. '[specimenDct] AS sample_deduction, '
. '[Totalindemnity] AS total_compensation, '
. '[other] AS other_adjustment, '
. '[supplySup] AS supplier_supplement, '
. '[billRemaining] AS supplier_balance, '
. '[ShouldPay] AS should_pay, '
. '[guessPrice] AS estimated_price, '
. '[toCorporate] AS to_corporate, '
. '[toPrivate] AS to_private, '
. '[factPay] AS actual_pay, '
. '[remarks] AS remarks, '
. '[reason] AS private_reason, '
. '[mark] AS negative_reason, '
. '[Month] AS month, '
. '[depositMoney] AS deposit, '
. '[cashierbypaid] AS cashier_paid, '
. '[isPayment] AS is_payment, '
. 'CONVERT(varchar(19), [createTime], 120) AS created_at, '
. 'CONVERT(varchar(19), [modifiedTime], 120) AS modified_at '
. 'FROM [dbo].[fys_supplierPaymentSummary]'
. $whereSql
. ' ORDER BY [id] DESC'
. " OFFSET {$offset} ROWS FETCH NEXT {$fetch} ROWS ONLY";
return ['rows' => array_map([$this, 'normalizePayableRow'], $this->query->select($sql, $bindings))];
}
/** @return array{0:string,1:array<int,string>} */
private function boardWhere(array $filters): array
{
$where = [];
$bindings = [];
foreach ([
'stock_in_date' => 'inDate',
'stock_out_date' => 'deliveryDate',
] as $filter => $column) {
if (($filters[$filter] ?? '') === '') {
continue;
}
$where[] = "CAST([{$column}] AS date) = ?";
$bindings[] = (string) $filters[$filter];
}
foreach ([
'furniture_factory' => 'giveSupplier',
'lamination_factory' => 'arrSupplier',
'deduction_type' => 'name',
'material_name' => 'plainName',
'claim_number' => 'applyNo',
] as $filter => $column) {
if (($filters[$filter] ?? '') === '') {
continue;
}
$where[] = "[{$column}] LIKE ? ESCAPE '\\'";
$bindings[] = $this->contains((string) $filters[$filter]);
}
return [$where === [] ? '' : ' WHERE ' . implode(' AND ', $where), $bindings];
}
/** @return array{0:string,1:array<int,string>} */
private function payablesWhere(array $filters): array
{
$where = [];
$bindings = [];
if (($filters['month'] ?? '') !== '') {
$where[] = '[Month] = ?';
$bindings[] = (string) $filters['month'];
}
foreach ([
'supplier' => 'supplier',
'checker' => 'checker',
'settlement_method' => 'settleway',
] as $filter => $column) {
if (($filters[$filter] ?? '') === '') {
continue;
}
$where[] = "[{$column}] LIKE ? ESCAPE '\\'";
$bindings[] = $this->contains((string) $filters[$filter]);
}
return [$where === [] ? '' : ' WHERE ' . implode(' AND ', $where), $bindings];
}
/** @return array{0:int,1:int} */
private function pageWindow(int $page, int $limit): array
{
$page = max($page, 1);
$limit = min(max($limit, 1), 100);
return [($page - 1) * $limit, $limit + 1];
}
private function contains(string $value): string
{
return '%' . str_replace(['\\', '%', '_'], ['\\\\', '\\%', '\\_'], trim($value)) . '%';
}
/** @param array<string,mixed> $row */
private function normalizeBoardRow(array $row): array
{
foreach (['received_quantity', 'unit_price', 'amount'] as $field) {
$row[$field] = $this->number($row[$field] ?? null);
}
return $row;
}
/** @param array<string,mixed> $row */
private function normalizePayableRow(array $row): array
{
foreach ([
'express_freight', 'beginning_payable', 'unpriced', 'advance_loan', 'loan',
'refund', 'procurement', 'invoice_deduction', 'board_deduction',
'sample_deduction', 'total_compensation', 'other_adjustment',
'supplier_supplement', 'supplier_balance', 'should_pay', 'estimated_price',
'to_corporate', 'to_private', 'actual_pay', 'deposit', 'cashier_paid',
] as $field) {
$row[$field] = $this->number($row[$field] ?? null);
}
$row['is_payment'] = (bool) ($row['is_payment'] ?? false);
return $row;
}
private function number(mixed $value): ?float
{
return $value === null || $value === '' ? null : (float) $value;
}
}

View File

@ -8,8 +8,10 @@ use Modules\EcommerceFinance\Repositories\EdgeBandingRepository;
use Modules\EcommerceFinance\Repositories\GoodsReconciliationRepository;
use Modules\EcommerceFinance\Repositories\InventoryRepository;
use Modules\EcommerceFinance\Repositories\PinduoduoSpreadBillRepository;
use Modules\EcommerceFinance\Repositories\ProductPriceRepository;
use Modules\EcommerceFinance\Repositories\RawBoardPayablesRepository;
use Modules\EcommerceFinance\Repositories\SupplierPayableRepository;
use Modules\EcommerceFinance\Repositories\SupplierPayableReportRepository;
use Modules\EcommerceFinance\Repositories\TmallTaobaoSpreadBillRepository;
/**
@ -23,9 +25,11 @@ class JianSunSnapshotRefresher implements UpstreamSnapshotRefresher
private readonly GoodsReconciliationRepository $goods,
private readonly InventoryRepository $inventory,
private readonly PinduoduoSpreadBillRepository $pinduoduo,
private readonly ProductPriceRepository $productPrices,
private readonly RawBoardPayablesRepository $rawBoardPayables,
private readonly TmallTaobaoSpreadBillRepository $taobaoAlipay,
private readonly SupplierPayableRepository $supplier,
private readonly SupplierPayableReportRepository $supplierPayableReports,
) {
}
@ -103,6 +107,22 @@ class JianSunSnapshotRefresher implements UpstreamSnapshotRefresher
),
'taobao-alipay-bills.options' => $this->taobaoAlipay->storeOptions(),
'supplier-payables.product-prices.list' => $this->productPrices->paginate(
$filters,
$page,
$limit,
),
'supplier-payables.board-deductions.list' => $this->supplierPayableReports->boardDeductions(
$filters,
$page,
$limit,
),
'supplier-payables.report.list' => $this->supplierPayableReports->supplierPayables(
$filters,
$page,
$limit,
),
'return-reconciliations.list' => $this->supplier->returnReconciliations($filters, $page, $limit),
'return-reconciliations.summary' => $this->supplier->returnReconciliationSummary($filters),
'return-reconciliations.options' => $this->supplier->filterOptionsForReturn(),

2
public/css/app.css vendored

File diff suppressed because one or more lines are too long

View File

@ -25,7 +25,7 @@ const app = new Vue({
data() {
return {
baseUrl: url + '/api/ecommerce-finance/supplier-payables/advance-details',
baseUrl: url + '/workspace-data/supplier-payables/advance-details',
loading: false,
tableData: [],
total: 0,

View File

@ -25,7 +25,7 @@ const app = new Vue({
data() {
return {
baseUrl: url + '/api/ecommerce-finance/supplier-payables/compensation-details',
baseUrl: url + '/workspace-data/supplier-payables/compensation-details',
loading: false,
tableData: [],
total: 0,

View File

@ -27,7 +27,7 @@ const app = new Vue({
data() {
return {
baseUrl: url + '/api/ecommerce-finance/supplier-payables/delivery-unpriced',
baseUrl: url + '/workspace-data/supplier-payables/delivery-unpriced',
loading: false,
tableData: [],
total: 0,

View File

@ -27,7 +27,7 @@ const app = new Vue({
data() {
return {
baseUrl: url + '/api/ecommerce-finance/supplier-payables/dropshipping-express',
baseUrl: url + '/workspace-data/supplier-payables/dropshipping-express',
loading: false,
tableData: [],
total: 0,

View File

@ -28,7 +28,7 @@ const app = new Vue({
data() {
return {
baseUrl: url + '/api/ecommerce-finance/goods-reconciliations',
baseUrl: url + '/workspace-data/supplier-payables/payment-reconciliation',
loading: false,
tableData: [],
total: 0,

View File

@ -25,7 +25,7 @@ const app = new Vue({
data() {
return {
baseUrl: url + '/api/ecommerce-finance/supplier-payables/invoice-deductions',
baseUrl: url + '/workspace-data/supplier-payables/invoice-deductions',
loading: false,
tableData: [],
total: 0,

View File

@ -25,7 +25,7 @@ const app = new Vue({
data() {
return {
baseUrl: url + '/api/ecommerce-finance/supplier-payables/other-adjustments',
baseUrl: url + '/workspace-data/supplier-payables/other-adjustments',
loading: false,
tableData: [],
total: 0,

View File

@ -36,7 +36,7 @@ const app = new Vue({
data() {
return {
baseUrl: url + '/api/ecommerce-finance/supplier-payables/return-reconciliations',
baseUrl: url + '/workspace-data/supplier-payables/return-reconciliation',
loading: false,
tableData: [],
total: 0,

View File

@ -27,7 +27,7 @@ const app = new Vue({
data() {
return {
baseUrl: url + '/api/ecommerce-finance/supplier-payables/return-unpriced',
baseUrl: url + '/workspace-data/supplier-payables/return-unpriced',
loading: false,
tableData: [],
total: 0,

View File

@ -25,7 +25,7 @@ const app = new Vue({
data() {
return {
baseUrl: url + '/api/ecommerce-finance/supplier-payables/sample-deductions',
baseUrl: url + '/workspace-data/supplier-payables/sample-deductions',
loading: false,
tableData: [],
total: 0,

View File

@ -1,3 +1,10 @@
@php
$boardDeductions = $content['boardDeductions'] ?? null;
$boardDeductionFilters = $content['boardDeductionFilters'] ?? [];
$boardDeductionError = $content['boardDeductionError'] ?? null;
$boardDeductionStatus = data_get($content, 'boardDeductionStatus.X-Caiwu-Data-Status');
@endphp
<div class="supplier-board-page">
<style>
.supplier-board-toolbar {
@ -44,6 +51,43 @@
box-shadow: 0 0 0 2px rgba(197, 160, 74, 0.14);
}
.supplier-board-actions {
display: flex;
gap: 0.5rem;
}
.supplier-board-button {
display: inline-flex;
height: 2.25rem;
align-items: center;
justify-content: center;
gap: 0.35rem;
padding: 0 0.85rem;
border: 1px solid #d1d5db;
border-radius: 0.375rem;
background: #ffffff;
color: #374151;
font-size: 0.8125rem;
font-weight: 600;
white-space: nowrap;
}
.supplier-board-button.is-primary {
border-color: var(--vip-content-accent-dark, #856632);
background: var(--vip-content-accent-dark, #856632);
color: #ffffff;
}
.supplier-board-alert {
margin-bottom: 1rem;
padding: 0.75rem 1rem;
border: 1px solid #f2c8c8;
border-radius: 0.375rem;
background: #fff5f5;
color: #9b2c2c;
font-size: 0.8125rem;
}
.supplier-board-table-card {
overflow: hidden;
border: 1px solid #e5e7eb;
@ -116,40 +160,50 @@
}
</style>
<div class="supplier-board-toolbar" aria-label="板材扣款筛选">
<form method="GET" class="supplier-board-toolbar" aria-label="板材扣款筛选">
<div class="supplier-board-field">
<label for="board-deduction-stock-in-date">入库日期</label>
<input id="board-deduction-stock-in-date" type="date">
<input id="board-deduction-stock-in-date" name="stock_in_date" type="date" value="{{ $boardDeductionFilters['stock_in_date'] ?? '' }}">
</div>
<div class="supplier-board-field">
<label for="board-deduction-stock-out-date">出库日期</label>
<input id="board-deduction-stock-out-date" type="date">
<input id="board-deduction-stock-out-date" name="stock_out_date" type="date" value="{{ $boardDeductionFilters['stock_out_date'] ?? '' }}">
</div>
<div class="supplier-board-field">
<label for="board-deduction-furniture-factory">家具厂</label>
<input id="board-deduction-furniture-factory" type="text" placeholder="请输入家具厂">
<input id="board-deduction-furniture-factory" name="furniture_factory" type="text" value="{{ $boardDeductionFilters['furniture_factory'] ?? '' }}" placeholder="请输入家具厂">
</div>
<div class="supplier-board-field">
<label for="board-deduction-lamination-factory">压贴厂</label>
<input id="board-deduction-lamination-factory" type="text" placeholder="请输入压贴厂">
<input id="board-deduction-lamination-factory" name="lamination_factory" type="text" value="{{ $boardDeductionFilters['lamination_factory'] ?? '' }}" placeholder="请输入压贴厂">
</div>
<div class="supplier-board-field">
<label for="board-deduction-type">类型</label>
<select id="board-deduction-type">
<option>全部类型</option>
<option>正常扣款</option>
<option>调整扣款</option>
</select>
<input id="board-deduction-type" name="deduction_type" type="text" value="{{ $boardDeductionFilters['deduction_type'] ?? '' }}" placeholder="请输入类型">
</div>
<div class="supplier-board-field">
<label for="board-deduction-material">原料名称</label>
<input id="board-deduction-material" type="text" placeholder="请输入原料名称">
<input id="board-deduction-material" name="material_name" type="text" value="{{ $boardDeductionFilters['material_name'] ?? '' }}" placeholder="请输入原料名称">
</div>
<div class="supplier-board-field">
<label for="board-deduction-claim-number">申领单号</label>
<input id="board-deduction-claim-number" type="text" placeholder="请输入申领单号">
<input id="board-deduction-claim-number" name="claim_number" type="text" value="{{ $boardDeductionFilters['claim_number'] ?? '' }}" placeholder="请输入申领单号">
</div>
</div>
<div class="supplier-board-actions">
<button type="submit" class="supplier-board-button is-primary">
<span class="material-icons-outlined" aria-hidden="true">search</span>
<span>查询</span>
</button>
<a href="{{ route('business.pages.show', ['section' => $section['slug'], 'page' => $page['slug']]) }}" class="supplier-board-button">
<span class="material-icons-outlined" aria-hidden="true">refresh</span>
<span>重置</span>
</a>
</div>
</form>
@if ($boardDeductionError)
<div class="supplier-board-alert" role="alert">{{ $boardDeductionError }}</div>
@endif
<div class="supplier-board-table-card">
<div class="supplier-board-table-scroll">
@ -176,15 +230,50 @@
</tr>
</thead>
<tbody>
<tr class="is-empty">
<td colspan="17">暂无数据</td>
</tr>
@forelse ($boardDeductions ?? [] as $row)
<tr>
<td>{{ $row->stock_in_date ?: '-' }}</td>
<td>{{ $row->stock_out_date ?: '-' }}</td>
<td>{{ $row->furniture_factory ?: '-' }}</td>
<td>{{ $row->lamination_factory ?: '-' }}</td>
<td>{{ $row->deduction_type ?: '-' }}</td>
<td>{{ $row->specification ?: '-' }}</td>
<td>{{ $row->material_name ?: '-' }}</td>
<td class="is-number">{{ $row->received_quantity === null ? '-' : number_format($row->received_quantity, 0) }}</td>
<td class="is-number">{{ $row->unit_price === null ? '-' : number_format($row->unit_price, 2) }}</td>
<td class="is-number">{{ $row->amount === null ? '-' : number_format($row->amount, 2) }}</td>
<td>{{ $row->unit ?: '-' }}</td>
<td>{{ $row->batch_date ?: '-' }}</td>
<td>{{ $row->stock_out_number ?: '-' }}</td>
<td>{{ $row->stock_out_remark ?: '-' }}</td>
<td>{{ $row->claim_number ?: '-' }}</td>
<td>{{ $row->number_type ?: '-' }}</td>
<td>{{ $row->delivery_number ?: '-' }}</td>
</tr>
@empty
<tr class="is-empty">
<td colspan="17">{{ $boardDeductionError ? '数据读取失败,请稍后重试。' : '暂无数据' }}</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="supplier-board-pagination">
<span>共 0 条记录</span>
<span>第 1 / 1 页</span>
<span>
当前页 {{ $boardDeductions?->count() ?? 0 }} 条
@if ($boardDeductionStatus)
· {{ strtoupper($boardDeductionStatus) }}
@endif
</span>
<span>
@if ($boardDeductions && !$boardDeductions->onFirstPage())
<a href="{{ $boardDeductions->previousPageUrl() }}">上一页</a>
@endif
第 {{ $boardDeductions?->currentPage() ?? 1 }} 页
@if ($boardDeductions?->hasMorePages())
<a href="{{ $boardDeductions->nextPageUrl() }}">下一页</a>
@endif
</span>
</div>
</div>
</div>

View File

@ -1,150 +1,166 @@
@php
$productPrices = $content['productPrices'] ?? null;
$productPriceFilters = $content['productPriceFilters'] ?? [];
$productPriceError = $content['productPriceError'] ?? null;
@endphp
<style>
#main-body > .container {
max-width: none;
width: auto;
margin-left: 1.5rem;
margin-right: 1.5rem;
}
.product-prices-filter-bar {
display: flex;
flex-wrap: wrap;
display: grid;
grid-template-columns: minmax(180px, 1.4fr) repeat(4, minmax(140px, 1fr)) auto;
align-items: flex-end;
gap: 1rem;
padding: 1.25rem 1.5rem;
border: 1px solid #e5e7eb;
border-radius: 0.75rem;
gap: 16px;
padding: 16px;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: 12px;
background: #ffffff;
box-shadow: 0 4px 12px rgba(31, 41, 55, 0.04);
margin-bottom: 1.25rem;
box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
margin-bottom: 16px;
}
.product-prices-filter-bar .filter-group {
display: flex;
flex-direction: column;
gap: 0.35rem;
gap: 4px;
}
.product-prices-filter-bar .filter-label {
font-size: 0.8rem;
font-weight: 600;
color: #6b7280;
text-transform: uppercase;
letter-spacing: 0.025em;
color: #595959;
font-size: 0.75rem;
font-weight: 500;
letter-spacing: 0;
}
.product-prices-filter-bar input,
.product-prices-filter-bar select {
height: 2.5rem;
padding: 0 0.75rem;
border: 1px solid #d1d5db;
border-radius: 0.5rem;
font-size: 0.875rem;
color: #1f2937;
background: #f9fafb;
width: 100%;
min-width: 0;
height: 34px;
padding: 0 10px;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: 8px;
color: #171717;
background: #ffffff;
font-size: 0.8125rem;
transition: border-color 150ms, box-shadow 150ms;
min-width: 10rem;
}
.product-prices-filter-bar input:focus,
.product-prices-filter-bar select:focus {
outline: none;
border-color: #4f46e5;
box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
background: #ffffff;
border-color: var(--vip-content-accent-dark, #856632);
box-shadow: 0 0 0 3px rgba(133, 102, 50, 0.20);
}
.btn-filter {
display: inline-flex;
align-items: center;
gap: 0.4rem;
height: 2.5rem;
padding: 0 1.25rem;
border-radius: 0.5rem;
font-size: 0.875rem;
font-weight: 600;
border: none;
gap: 6px;
height: 34px;
padding: 0 14px;
border: 1px solid transparent;
border-radius: 8px;
font-size: 0.8125rem;
font-weight: 500;
cursor: pointer;
transition: background 150ms;
transition: background 150ms, border-color 150ms, color 150ms;
white-space: nowrap;
}
.btn-filter-primary {
background: #4f46e5;
background: var(--vip-content-accent-dark, #856632);
color: #ffffff;
}
.btn-filter-primary:hover {
background: #4338ca;
background: #6A5129;
}
.btn-filter-secondary {
background: #f3f4f6;
color: #374151;
border-color: var(--vip-border, #D8D2C7);
background: #ffffff;
color: #171717;
}
.btn-filter-secondary:hover {
background: #e5e7eb;
background: var(--vip-content-accent-soft, #F7F0DE);
border-color: var(--vip-content-accent-dark, #856632);
}
.price-tag {
display: inline-block;
padding: 0.15rem 0.65rem;
padding: 2px 8px;
border-radius: 999px;
font-size: 0.75rem;
font-weight: 600;
font-weight: 500;
line-height: 1.5;
}
.price-tag.dingjia {
background: #e0e7ff;
color: #3730a3;
.price-tag.dingjia,
.price-tag.bianjia {
background: var(--vip-content-accent-soft, #F7F0DE);
color: var(--vip-content-accent-dark, #856632);
}
.price-tag.bianjia {
background: #fef3c7;
color: #92400e;
}
.price-tag.bianjia { box-shadow: inset 0 0 0 1px var(--vip-content-accent, #B9954F); }
.price-diff-positive {
color: #16a34a;
color: var(--vip-success, #53793E);
font-weight: 600;
}
.price-diff-negative {
color: #dc2626;
color: var(--vip-danger, #B80000);
font-weight: 600;
}
.price-diff-zero {
color: #9ca3af;
color: #595959;
}
.cost-reduction-icon.is-yes { color: var(--vip-success, #53793E); }
.cost-reduction-icon.is-no { color: var(--vip-danger, #B80000); }
.product-price-error {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 16px;
padding: 12px 16px;
border: 1px solid var(--vip-danger, #B80000);
border-radius: 8px;
background: rgba(184, 0, 0, 0.05);
color: var(--vip-danger, #B80000);
font-size: 0.8125rem;
}
.data-table-wrapper {
border: 1px solid #e5e7eb;
border-radius: 0.75rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: 12px;
background: #ffffff;
overflow: hidden;
box-shadow: 0 4px 12px rgba(31, 41, 55, 0.04);
overflow-x: auto;
box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.data-table {
width: 100%;
min-width: 1380px;
border-collapse: collapse;
font-size: 0.875rem;
font-size: 0.78125rem;
}
.data-table thead {
background: #f9fafb;
border-bottom: 2px solid #e5e7eb;
background: var(--vip-content-accent-soft, #F7F0DE);
border-bottom: 1px solid var(--vip-border, #D8D2C7);
}
.data-table thead th {
padding: 0.85rem 1rem;
padding: 10px 12px;
text-align: left;
font-weight: 700;
color: #374151;
font-size: 0.8rem;
text-transform: uppercase;
letter-spacing: 0.025em;
color: #595959;
font-size: 0.75rem;
font-weight: 600;
letter-spacing: 0;
white-space: nowrap;
}
@ -153,17 +169,17 @@
}
.data-table tbody tr {
border-bottom: 1px solid #f3f4f6;
border-bottom: 1px solid var(--vip-border, #D8D2C7);
transition: background 120ms;
}
.data-table tbody tr:hover {
background: #f9fafb;
background: var(--vip-content-accent-soft, #F7F0DE);
}
.data-table tbody td {
padding: 0.75rem 1rem;
color: #4b5563;
padding: 10px 12px;
color: #171717;
vertical-align: middle;
}
@ -173,28 +189,29 @@
}
.data-table tbody td.mono {
font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
font-size: 0.8rem;
color: #1f2937;
font-variant-numeric: tabular-nums;
color: #171717;
}
.summary-bar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.85rem 1.5rem;
background: #f9fafb;
border-top: 1px solid #e5e7eb;
font-size: 0.85rem;
color: #6b7280;
min-width: 1380px;
padding: 10px 12px;
background: #ffffff;
border-top: 1px solid var(--vip-border, #D8D2C7);
color: #595959;
font-size: 0.78125rem;
}
.summary-bar strong {
color: #1f2937;
color: #171717;
}
.pagination-wrapper {
padding: 1rem 1.5rem;
min-width: 1380px;
padding: 12px;
display: flex;
justify-content: center;
}
@ -203,79 +220,74 @@
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 2.25rem;
height: 2.25rem;
padding: 0 0.6rem;
border: 1px solid #d1d5db;
border-radius: 0.4rem;
font-size: 0.85rem;
color: #374151;
min-width: 34px;
height: 34px;
padding: 0 10px;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: 8px;
color: #171717;
background: #ffffff;
font-size: 0.8125rem;
cursor: pointer;
transition: all 120ms;
}
.pagination-btn:hover {
border-color: #4f46e5;
color: #4f46e5;
border-color: var(--vip-content-accent-dark, #856632);
background: var(--vip-content-accent-soft, #F7F0DE);
color: var(--vip-content-accent-dark, #856632);
}
.pagination-btn.active {
background: #4f46e5;
border-color: #4f46e5;
background: var(--vip-content-accent-dark, #856632);
border-color: var(--vip-content-accent-dark, #856632);
color: #ffffff;
}
@media (max-width: 1200px) {
.product-prices-filter-bar {
grid-template-columns: repeat(3, minmax(160px, 1fr));
}
}
@media (max-width: 720px) {
.product-prices-filter-bar {
grid-template-columns: 1fr;
}
}
</style>
<div class="my-6">
{{-- Page header --}}
<div class="flex items-center justify-between mb-5">
<div>
<h1 class="text-xl font-bold text-gray-900">
{{ $page['title'] ?? '商品价格' }}
</h1>
<p class="text-sm text-gray-500 mt-1">
管理供应商商品的定价与变价记录
</p>
</div>
<div class="flex items-center gap-3">
<button class="btn-filter btn-filter-secondary">
<span class="material-icons-outlined text-base">file_download</span>
导出
</button>
</div>
</div>
{{-- Filter bar --}}
<form method="GET" class="product-prices-filter-bar">
<div class="filter-group">
<label class="filter-label">条形码</label>
<input type="text" name="barcode" placeholder="输入条形码搜索..."
value="{{ request('barcode') }}">
value="{{ $productPriceFilters['barcode'] ?? '' }}">
</div>
<div class="filter-group">
<label class="filter-label">价格类型</label>
<select name="price_type">
<option value="">全部</option>
<option value="0" {{ request('price_type') === '0' ? 'selected' : '' }}>定价</option>
<option value="1" {{ request('price_type') === '1' ? 'selected' : '' }}>变价</option>
<option value="pricing" {{ ($productPriceFilters['price_type'] ?? '') === 'pricing' ? 'selected' : '' }}>定价</option>
<option value="repricing" {{ ($productPriceFilters['price_type'] ?? '') === 'repricing' ? 'selected' : '' }}>变价</option>
</select>
</div>
<div class="filter-group">
<label class="filter-label">是否采购降本</label>
<select name="cost_reduction">
<option value="">全部</option>
<option value="1" {{ request('cost_reduction') === '1' ? 'selected' : '' }}>是</option>
<option value="0" {{ request('cost_reduction') === '0' ? 'selected' : '' }}>否</option>
<option value="yes" {{ ($productPriceFilters['cost_reduction'] ?? '') === 'yes' ? 'selected' : '' }}>是</option>
<option value="no" {{ ($productPriceFilters['cost_reduction'] ?? '') === 'no' ? 'selected' : '' }}>否</option>
</select>
</div>
<div class="filter-group">
<label class="filter-label">生效日期起</label>
<input type="date" name="effective_from" value="{{ request('effective_from') }}">
<input type="date" name="effective_from" value="{{ $productPriceFilters['effective_from'] ?? '' }}">
</div>
<div class="filter-group">
<label class="filter-label">生效日期止</label>
<input type="date" name="effective_to" value="{{ request('effective_to') }}">
<input type="date" name="effective_to" value="{{ $productPriceFilters['effective_to'] ?? '' }}">
</div>
<div class="filter-group">
<label class="filter-label">&nbsp;</label>
@ -293,6 +305,13 @@
</div>
</form>
@if ($productPriceError)
<div class="product-price-error" role="alert">
<span class="material-icons-outlined" aria-hidden="true">error_outline</span>
<span>{{ $productPriceError }}</span>
</div>
@endif
{{-- Data table --}}
<div class="data-table-wrapper">
<table class="data-table">
@ -316,7 +335,7 @@
<tbody>
@forelse ($productPrices ?? [] as $index => $item)
@php
$priceTypeLabel = ($item->price_type ?? '') === '1' ? '变价' : '定价';
$priceTypeLabel = $item->price_type ?: '-';
@endphp
<tr>
<td class="mono">{{ ($productPrices->currentPage() - 1) * $productPrices->perPage() + $index + 1 }}</td>
@ -328,12 +347,12 @@
</td>
<td>{{ $item->change_type ?? '-' }}</td>
<td>
@if (($item->cost_reduction ?? '') === '1')
<span class="material-icons-outlined text-green-600 text-lg">check_circle</span>
@elseif (($item->cost_reduction ?? '') === '0')
<span class="material-icons-outlined text-red-400 text-lg">cancel</span>
@if (($item->cost_reduction ?? '') === '是')
<span class="material-icons-outlined cost-reduction-icon is-yes" title="是">check_circle</span>
@elseif (($item->cost_reduction ?? '') === '否')
<span class="material-icons-outlined cost-reduction-icon is-no" title="否">cancel</span>
@else
<span class="text-gray-300">-</span>
<span>-</span>
@endif
</td>
<td class="right">{{ isset($item->price_before) && $item->price_before !== null ? number_format((float) $item->price_before, 2) : '-' }}</td>
@ -366,9 +385,15 @@
</tr>
@empty
<tr>
<td colspan="13" class="text-center py-12 text-gray-400">
<td colspan="13" class="text-center py-12">
<span class="material-icons-outlined text-4xl mb-2 block">inventory_2</span>
暂无商品价格数据
@if ($productPriceError)
数据读取失败,请稍后重试。
@elseif (array_filter($productPriceFilters))
没有符合当前筛选条件的商品价格数据,请调整条件后重新查询。
@else
暂无商品价格数据。
@endif
</td>
</tr>
@endforelse
@ -376,13 +401,13 @@
</table>
{{-- Summary bar --}}
@if (!empty($productPrices) && method_exists($productPrices, 'total'))
@if ($productPrices && $productPrices->count() > 0)
<div class="summary-bar">
<span>
共 <strong>{{ $productPrices->total() }}</strong> 条记录
当前页 <strong>{{ $productPrices->count() }}</strong> 条记录
</span>
<span>
当前第 <strong>{{ $productPrices->currentPage() }}</strong> / <strong>{{ $productPrices->lastPage() }}</strong> 页
第 <strong>{{ $productPrices->currentPage() }}</strong> 页
</span>
</div>
@ -401,33 +426,9 @@
</a>
@endif
{{-- Page numbers --}}
@php
$current = $productPrices->currentPage();
$last = $productPrices->lastPage();
$start = max(1, $current - 2);
$end = min($last, $current + 2);
@endphp
@if ($start > 1)
<a href="{{ $productPrices->url(1) }}" class="pagination-btn">1</a>
@if ($start > 2)
<span class="pagination-btn opacity-50 cursor-default">...</span>
@endif
@endif
@for ($i = $start; $i <= $end; $i++)
<a href="{{ $productPrices->url($i) }}" class="pagination-btn {{ $i === $current ? 'active' : '' }}">
{{ $i }}
</a>
@endfor
@if ($end < $last)
@if ($end < $last - 1)
<span class="pagination-btn opacity-50 cursor-default">...</span>
@endif
<a href="{{ $productPrices->url($last) }}" class="pagination-btn">{{ $last }}</a>
@endif
<span class="pagination-btn active" aria-current="page">
{{ $productPrices->currentPage() }}
</span>
{{-- Next --}}
@if ($productPrices->hasMorePages())

View File

@ -1,3 +1,11 @@
@php
$supplierPayables = $content['supplierPayables'] ?? null;
$supplierPayableFilters = $content['supplierPayableFilters'] ?? [];
$supplierPayableError = $content['supplierPayableError'] ?? null;
$supplierPayableStatus = data_get($content, 'supplierPayableStatus.X-Caiwu-Data-Status');
$money = static fn (mixed $value): string => $value === null ? '-' : number_format((float) $value, 2);
@endphp
<div class="supplier-payables-report-page">
<style>
.supplier-payables-report-toolbar {
@ -75,6 +83,16 @@
font-size: 1rem;
}
.supplier-payables-report-alert {
margin-bottom: 1rem;
padding: 0.75rem 1rem;
border: 1px solid #f2c8c8;
border-radius: 0.375rem;
background: #fff5f5;
color: #9b2c2c;
font-size: 0.8125rem;
}
.supplier-payables-report-table-card {
overflow: hidden;
border: 1px solid #e5e7eb;
@ -181,24 +199,19 @@
<form method="GET" class="supplier-payables-report-toolbar" aria-label="供应商应付表筛选">
<div class="supplier-payables-report-field">
<label for="supplier-payables-report-month">账单月份</label>
<input id="supplier-payables-report-month" name="month" type="month" value="{{ request('month') }}">
<input id="supplier-payables-report-month" name="month" type="month" value="{{ $supplierPayableFilters['month'] ?? '' }}">
</div>
<div class="supplier-payables-report-field">
<label for="supplier-payables-report-supplier">供应商</label>
<input id="supplier-payables-report-supplier" name="supplier" type="text" value="{{ request('supplier') }}" placeholder="供应商名称或简称">
<input id="supplier-payables-report-supplier" name="supplier" type="text" value="{{ $supplierPayableFilters['supplier'] ?? '' }}" placeholder="供应商名称或简称">
</div>
<div class="supplier-payables-report-field">
<label for="supplier-payables-report-reconciler">对账人</label>
<input id="supplier-payables-report-reconciler" name="reconciler" type="text" value="{{ request('reconciler') }}" placeholder="请输入对账人">
<input id="supplier-payables-report-reconciler" name="checker" type="text" value="{{ $supplierPayableFilters['checker'] ?? '' }}" placeholder="请输入对账人">
</div>
<div class="supplier-payables-report-field">
<label for="supplier-payables-report-status">合作状态</label>
<select id="supplier-payables-report-status" name="cooperation_status">
<option value="">全部状态</option>
<option value="cooperating" @selected(request('cooperation_status') === 'cooperating')>合作中</option>
<option value="stopped" @selected(request('cooperation_status') === 'stopped')>已停止合作</option>
<option value="resumed" @selected(request('cooperation_status') === 'resumed')>重新启用</option>
</select>
<label for="supplier-payables-report-status">结算方式</label>
<input id="supplier-payables-report-status" name="settlement_method" type="text" value="{{ $supplierPayableFilters['settlement_method'] ?? '' }}" placeholder="请输入结算方式">
</div>
<div class="supplier-payables-report-actions">
<button type="submit" class="supplier-payables-report-button is-primary">
@ -215,6 +228,10 @@
</div>
</form>
@if ($supplierPayableError)
<div class="supplier-payables-report-alert" role="alert">{{ $supplierPayableError }}</div>
@endif
<div class="supplier-payables-report-table-card">
<div class="supplier-payables-report-table-scroll">
<table class="supplier-payables-report-table">
@ -281,7 +298,7 @@
</tr>
<tr>
<th class="group-closed">对账人</th>
<th class="group-closed">合作状态</th>
<th class="group-closed">结算方式</th>
<th class="group-purchase">货款金额</th>
<th class="group-purchase">减:退货金额</th>
<th class="group-purchase">小计</th>
@ -300,15 +317,67 @@
</tr>
</thead>
<tbody>
<tr class="is-empty">
<td colspan="34">暂无供应商应付数据</td>
</tr>
@forelse ($supplierPayables ?? [] as $index => $row)
<tr>
<td>{{ $row->checker ?: '-' }}</td>
<td>{{ $row->settlement_method ?: '-' }}</td>
<td>{{ ($supplierPayables->currentPage() - 1) * $supplierPayables->perPage() + $index + 1 }}</td>
<td>{{ $row->company ?: '-' }}</td>
<td>{{ $row->supplier ?: '-' }}</td>
<td>{{ $money($row->express_freight) }}</td>
<td>{{ $money($row->beginning_payable) }}</td>
<td>{{ $money($row->unpriced) }}</td>
<td>{{ $money($row->advance_loan) }}</td>
<td>{{ $money($row->loan) }}</td>
<td>{{ $money($row->refund) }}</td>
<td>{{ $money($row->procurement) }}</td>
<td>{{ $money($row->invoice_deduction) }}</td>
<td>{{ $money($row->board_deduction) }}</td>
<td>{{ $money($row->sample_deduction) }}</td>
<td>{{ $money($row->total_compensation) }}</td>
<td>{{ $money($row->other_adjustment) }}</td>
<td>{{ $money($row->supplier_supplement) }}</td>
<td>{{ $money($row->supplier_balance) }}</td>
<td>{{ $money($row->should_pay) }}</td>
<td>{{ $money($row->estimated_price) }}</td>
<td>{{ $money($row->to_corporate) }}</td>
<td>{{ $money($row->to_private) }}</td>
<td>{{ $money($row->cashier_paid) }}</td>
<td>{{ $row->remarks ?: '-' }}</td>
<td>{{ (float) ($row->to_private ?? 0) !== 0.0 ? '是' : '否' }}</td>
<td>{{ $row->private_reason ?: '-' }}</td>
<td>-</td>
<td>{{ $money($row->deposit) }}</td>
<td>-</td>
<td>{{ $row->modified_at ?: '-' }}</td>
<td>-</td>
<td>-</td>
<td>{{ $row->negative_reason ?: '-' }}</td>
</tr>
@empty
<tr class="is-empty">
<td colspan="34">{{ $supplierPayableError ? '数据读取失败,请稍后重试。' : '暂无供应商应付数据' }}</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="supplier-payables-report-pagination">
<span>共 0 条记录</span>
<span>第 1 / 1 页</span>
<span>
当前页 {{ $supplierPayables?->count() ?? 0 }} 条
@if ($supplierPayableStatus)
· {{ strtoupper($supplierPayableStatus) }}
@endif
</span>
<span>
@if ($supplierPayables && !$supplierPayables->onFirstPage())
<a href="{{ $supplierPayables->previousPageUrl() }}">上一页</a>
@endif
第 {{ $supplierPayables?->currentPage() ?? 1 }} 页
@if ($supplierPayables?->hasMorePages())
<a href="{{ $supplierPayables->nextPageUrl() }}">下一页</a>
@endif
</span>
</div>
</div>
</div>

View File

@ -3,6 +3,8 @@
use Illuminate\Support\Facades\Route;
use Modules\EcommerceFinance\Http\Controllers\AccountBills;
use Modules\EcommerceFinance\Http\Controllers\AlipayBills;
use Modules\EcommerceFinance\Http\Controllers\Api\GoodsReconciliations;
use Modules\EcommerceFinance\Http\Controllers\Api\SupplierPayables;
Route::get('ecommerce-finance/alipay-bills', [AlipayBills::class, 'index'])
->name('ecommerce-finance.alipay-bills.index');
@ -14,6 +16,44 @@ Route::get('ecommerce-finance/account-bills/type/{bill_type}', [AccountBills::cl
Route::get('ecommerce-finance/account-bills/{bill}', [AccountBills::class, 'show'])
->name('ecommerce-finance.account-bills.show');
Route::prefix('workspace-data/supplier-payables')
->name('workspace-data.supplier-payables.')
->group(function () {
Route::get('payment-reconciliation', [GoodsReconciliations::class, 'index'])
->middleware('business.page:supplier-payables,payment-reconciliation')
->name('payment-reconciliation.index');
Route::get('payment-reconciliation/summary', [GoodsReconciliations::class, 'summary'])
->middleware('business.page:supplier-payables,payment-reconciliation')
->name('payment-reconciliation.summary');
Route::get('payment-reconciliation/options', [GoodsReconciliations::class, 'options'])
->middleware('business.page:supplier-payables,payment-reconciliation')
->name('payment-reconciliation.options');
$pages = [
'return-reconciliation' => 'returnReconciliations',
'invoice-deductions' => 'invoiceDeductions',
'compensation-details' => 'compensationDetails',
'advance-details' => 'advanceDetails',
'delivery-unpriced' => 'deliveryUnpriced',
'return-unpriced' => 'returnUnpriced',
'sample-deductions' => 'sampleDeductions',
'other-adjustments' => 'otherAdjustments',
'dropshipping-express' => 'dropshippingExpress',
];
foreach ($pages as $slug => $action) {
Route::get($slug, [SupplierPayables::class, $action . 'Index'])
->middleware('business.page:supplier-payables,' . $slug)
->name($slug . '.index');
Route::get($slug . '/summary', [SupplierPayables::class, $action . 'Summary'])
->middleware('business.page:supplier-payables,' . $slug)
->name($slug . '.summary');
Route::get($slug . '/options', [SupplierPayables::class, $action . 'Options'])
->middleware('business.page:supplier-payables,' . $slug)
->name($slug . '.options');
}
});
/**
* 'admin' middleware applied to all routes
*

View File

@ -139,7 +139,7 @@ class PagesTest extends FeatureTestCase
);
$pages = [
['supplier-payables', 'product-prices', '暂无商品价格数据'],
['supplier-payables', 'product-prices', '数据读取失败,请稍后重试。'],
['courier-payables', 'freight-reconciliation', '快递单号'],
['courier-payables', 'bookkeeping-details', '暂无记账明细'],
['courier-payables', 'compensation-details', '暂无赔偿明细'],

View File

@ -3,6 +3,7 @@
namespace Tests\Feature\Business;
use App\Models\Auth\Permission;
use Modules\EcommerceFinance\Services\JianSunQueryCache;
use Tests\Feature\FeatureTestCase;
class SupplierPayablePagesTest extends FeatureTestCase
@ -103,4 +104,40 @@ class SupplierPayablePagesTest extends FeatureTestCase
$this->assertCount(34, $columns[0]);
}
public function testDataBackedSupplierPayableListRoutesAreAvailableToWorkspaceAjaxRequests()
{
$this->grantAdminPermission();
$cache = \Mockery::mock(JianSunQueryCache::class);
$cache->shouldReceive('remember')->times(10)->andReturnUsing(
static fn (string $scope): array => [
'data' => [['scope' => $scope]],
'total' => 1,
],
);
$cache->shouldReceive('responseHeaders')->times(10)->andReturn([]);
$this->app->instance(JianSunQueryCache::class, $cache);
$routes = [
'workspace-data.supplier-payables.payment-reconciliation.index',
'workspace-data.supplier-payables.return-reconciliation.index',
'workspace-data.supplier-payables.invoice-deductions.index',
'workspace-data.supplier-payables.compensation-details.index',
'workspace-data.supplier-payables.advance-details.index',
'workspace-data.supplier-payables.delivery-unpriced.index',
'workspace-data.supplier-payables.return-unpriced.index',
'workspace-data.supplier-payables.sample-deductions.index',
'workspace-data.supplier-payables.other-adjustments.index',
'workspace-data.supplier-payables.dropshipping-express.index',
];
foreach ($routes as $routeName) {
$this->loginAs()
->withHeader('X-Requested-With', 'XMLHttpRequest')
->get(route($routeName))
->assertOk()
->assertJsonPath('total', 1);
}
}
}

View File

@ -7,8 +7,10 @@ use Modules\EcommerceFinance\Repositories\EdgeBandingRepository;
use Modules\EcommerceFinance\Repositories\GoodsReconciliationRepository;
use Modules\EcommerceFinance\Repositories\InventoryRepository;
use Modules\EcommerceFinance\Repositories\PinduoduoSpreadBillRepository;
use Modules\EcommerceFinance\Repositories\ProductPriceRepository;
use Modules\EcommerceFinance\Repositories\RawBoardPayablesRepository;
use Modules\EcommerceFinance\Repositories\SupplierPayableRepository;
use Modules\EcommerceFinance\Repositories\SupplierPayableReportRepository;
use Modules\EcommerceFinance\Repositories\TmallTaobaoSpreadBillRepository;
use Modules\EcommerceFinance\Services\JianSunQueryCache;
use Modules\EcommerceFinance\Services\JianSunSnapshotRefresher;
@ -172,8 +174,10 @@ class JianSunSnapshotRefresherTest extends TestCase
private function refresher(
?InventoryRepository $inventory = null,
?PinduoduoSpreadBillRepository $pinduoduo = null,
?ProductPriceRepository $productPrices = null,
?RawBoardPayablesRepository $rawBoardPayables = null,
?TmallTaobaoSpreadBillRepository $taobaoAlipay = null,
?SupplierPayableReportRepository $supplierPayableReports = null,
): JianSunSnapshotRefresher {
return new JianSunSnapshotRefresher(
new class extends JianSunQueryCache {
@ -194,9 +198,11 @@ class JianSunSnapshotRefresherTest extends TestCase
$this->placeholder(GoodsReconciliationRepository::class),
$inventory ?? $this->placeholder(InventoryRepository::class),
$pinduoduo ?? $this->placeholder(PinduoduoSpreadBillRepository::class),
$productPrices ?? $this->placeholder(ProductPriceRepository::class),
$rawBoardPayables ?? $this->placeholder(RawBoardPayablesRepository::class),
$taobaoAlipay ?? $this->placeholder(TmallTaobaoSpreadBillRepository::class),
$this->placeholder(SupplierPayableRepository::class),
$supplierPayableReports ?? $this->placeholder(SupplierPayableReportRepository::class),
);
}

View File

@ -0,0 +1,51 @@
<?php
namespace Tests\Unit\EcommerceFinance;
use Modules\EcommerceFinance\Repositories\ProductPriceRepository;
use Modules\EcommerceFinance\Services\UpstreamReadOnlyQuery;
use Modules\EcommerceFinance\Services\UpstreamReadOnlyQueryFactory;
use PHPUnit\Framework\TestCase;
class ProductPriceRepositoryTest extends TestCase
{
public function test_filters_are_parameterized_and_page_queries_overfetch_one_row(): void
{
$query = $this->createMock(UpstreamReadOnlyQuery::class);
$query->expects($this->once())->method('select')->willReturnCallback(
function (string $sql, array $bindings): array {
UpstreamReadOnlyQuery::assertReadOnlySql($sql);
$this->assertStringContainsString('[dbo].[aaronprice]', $sql);
$this->assertStringContainsString('[条形码] LIKE ?', $sql);
$this->assertStringContainsString('OFFSET 2 ROWS FETCH NEXT 3 ROWS ONLY', $sql);
$this->assertSame(
['%ABC\\%\\_%', '定价', '是', '2026-07-01', '2026-07-31'],
$bindings,
);
return [
['barcode' => 'A', 'price_before' => '10.00', 'price_after' => '11.50', 'price_diff' => '1.50'],
['barcode' => 'B', 'price_before' => '', 'price_after' => null, 'price_diff' => '0.00'],
['barcode' => 'C', 'price_before' => '3.00', 'price_after' => '4.00', 'price_diff' => '1.00'],
];
},
);
$factory = $this->createMock(UpstreamReadOnlyQueryFactory::class);
$factory->expects($this->once())->method('forSource')->with('jiansun')->willReturn($query);
$result = (new ProductPriceRepository($factory))->paginate([
'barcode' => 'ABC%_',
'price_type' => 'pricing',
'cost_reduction' => 'yes',
'effective_from' => '2026-07-01',
'effective_to' => '2026-07-31',
], 2, 2);
$this->assertCount(3, $result['rows']);
$this->assertSame(10.0, $result['rows'][0]['price_before']);
$this->assertSame(11.5, $result['rows'][0]['price_after']);
$this->assertNull($result['rows'][1]['price_before']);
$this->assertSame(0.0, $result['rows'][1]['price_diff']);
}
}

View File

@ -0,0 +1,91 @@
<?php
namespace Tests\Unit\EcommerceFinance;
use Modules\EcommerceFinance\Repositories\SupplierPayableReportRepository;
use Modules\EcommerceFinance\Services\UpstreamReadOnlyQuery;
use Modules\EcommerceFinance\Services\UpstreamReadOnlyQueryFactory;
use PHPUnit\Framework\TestCase;
class SupplierPayableReportRepositoryTest extends TestCase
{
public function test_board_deductions_use_parameterized_filters_and_overfetch_pagination(): void
{
$query = $this->createMock(UpstreamReadOnlyQuery::class);
$query->expects($this->once())->method('select')->willReturnCallback(
function (string $sql, array $bindings): array {
UpstreamReadOnlyQuery::assertReadOnlySql($sql);
$this->assertStringContainsString('[dbo].[finance_boardDeduction]', $sql);
$this->assertStringContainsString('OFFSET 2 ROWS FETCH NEXT 3 ROWS ONLY', $sql);
$this->assertSame([
'2026-07-01',
'2026-07-02',
'%Factory\\%\\_%',
'%Press%',
'%Normal%',
'%Board%',
'%AP-1%',
], $bindings);
return [[
'received_quantity' => '2',
'unit_price' => '10.50',
'amount' => '',
]];
},
);
$result = $this->repository($query)->boardDeductions([
'stock_in_date' => '2026-07-01',
'stock_out_date' => '2026-07-02',
'furniture_factory' => 'Factory%_',
'lamination_factory' => 'Press',
'deduction_type' => 'Normal',
'material_name' => 'Board',
'claim_number' => 'AP-1',
], 2, 2);
$this->assertSame(2.0, $result['rows'][0]['received_quantity']);
$this->assertSame(10.5, $result['rows'][0]['unit_price']);
$this->assertNull($result['rows'][0]['amount']);
}
public function test_supplier_payables_use_fixed_fields_and_parameterized_filters(): void
{
$query = $this->createMock(UpstreamReadOnlyQuery::class);
$query->expects($this->once())->method('select')->willReturnCallback(
function (string $sql, array $bindings): array {
UpstreamReadOnlyQuery::assertReadOnlySql($sql);
$this->assertStringContainsString('[dbo].[fys_supplierPaymentSummary]', $sql);
$this->assertStringContainsString('[billRemaining] AS supplier_balance', $sql);
$this->assertStringContainsString('OFFSET 2 ROWS FETCH NEXT 3 ROWS ONLY', $sql);
$this->assertSame(['2026-07', '%Supplier%', '%Checker%', '%Monthly%'], $bindings);
return [[
'should_pay' => '100.00',
'supplier_balance' => null,
'is_payment' => 1,
]];
},
);
$result = $this->repository($query)->supplierPayables([
'month' => '2026-07',
'supplier' => 'Supplier',
'checker' => 'Checker',
'settlement_method' => 'Monthly',
], 2, 2);
$this->assertSame(100.0, $result['rows'][0]['should_pay']);
$this->assertNull($result['rows'][0]['supplier_balance']);
$this->assertTrue($result['rows'][0]['is_payment']);
}
private function repository(UpstreamReadOnlyQuery $query): SupplierPayableReportRepository
{
$factory = $this->createMock(UpstreamReadOnlyQueryFactory::class);
$factory->expects($this->once())->method('forSource')->with('jiansun')->willReturn($query);
return new SupplierPayableReportRepository($factory);
}
}