从 2026-11-01 起,按发货日在报价管理里生效的报价版本(与报价管理「当前生效」同一判断:未作废、 已审核/签署生效、执行期间覆盖发货日,取执行日期最新)逐包裹核算运费,写入 jst_oms_shipping_freight。 - 结算重量:实称>线上>重量;按各快递计泡系数取 max(重量, 长×宽×高÷系数);免抛仓(含「配件」仓)不计泡、不收多件费; 超长费计入,其他附加费不计;城市单独报价、整省「X元/公斤」、洞洞板 9000、个别版本系数等按 10 月逐单核对的口径; - 计算引擎移植自 10 月离线核算脚本,10 月 29.5 万个包裹逐单比对结果一致(仅 x.xx5 边界按正确四舍五入进位); - 发货数据同步完成后核算该窗口;报价版本新增/作废/签署归档后按该快递从执行日期起自动重算; - 新命令 jushuitan:calc-freight --from --to [--carrier]; - 发货数据页面/导出新增「报价核算」列:核算运费、核算-聚水潭运费、报价版本、结算重量依据、核算结算重量、 计费重量、首重、续重/费率、面单、一口价、多件/超长加收、核算公式、核算状态(合并口径每包裹一行,明细只在第一行)。 同时修复发货数据同步 11 月起频繁失败:副本库查发货视图超时后报 20047 DBPROCESS is dead, 原重试只识别 20003/dbnextrow,整次同步失败(11-17 只同步到 62%)。现把 20047 视为可重连重试, 发货视图每批出库单由 300 降到 100。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014nvGZkg27YMEdhry6eiuwf
78 lines
3.2 KiB
PHP
78 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\EcommerceFinance\Providers;
|
|
|
|
use Illuminate\Support\ServiceProvider as Provider;
|
|
use Modules\EcommerceFinance\Console\ExportShengsuanAnomalyOrders;
|
|
use Modules\EcommerceFinance\Console\ImportShengsuanOrderProfitDetails;
|
|
use Modules\EcommerceFinance\Console\ProcessDingRefreshRequests;
|
|
use Modules\EcommerceFinance\Console\DiagnoseJushuitanPackage;
|
|
use Modules\EcommerceFinance\Console\ImportShengsuanOrderProfitRows;
|
|
use Modules\EcommerceFinance\Console\CalcShippingFreight;
|
|
use Modules\EcommerceFinance\Console\SyncJushuitanShipping;
|
|
use Modules\EcommerceFinance\Services\Freight\ShippingFreightService;
|
|
use Modules\EcommerceFinance\Services\JianSunSnapshotRefresher;
|
|
use Modules\EcommerceFinance\Services\OperationsReplicaSnapshotRefresher;
|
|
use Modules\EcommerceFinance\Services\UpstreamSnapshotRefresherRegistry;
|
|
use Modules\EcommerceFinance\Services\UpstreamSourceRegistry;
|
|
|
|
class Main extends Provider
|
|
{
|
|
public function boot(): void
|
|
{
|
|
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'ecommerce-finance');
|
|
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
|
|
|
$this->registerFreightRecalculation();
|
|
|
|
if ($this->app->runningInConsole()) {
|
|
$this->commands([
|
|
SyncJushuitanShipping::class,
|
|
CalcShippingFreight::class,
|
|
ProcessDingRefreshRequests::class,
|
|
DiagnoseJushuitanPackage::class,
|
|
ImportShengsuanOrderProfitRows::class,
|
|
ImportShengsuanOrderProfitDetails::class,
|
|
ExportShengsuanAnomalyOrders::class,
|
|
]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 报价管理里报价版本新增、作废、签署归档后,按该快递从执行日期起自动重算发货数据的报价核算运费
|
|
* (同一请求内合并,请求结束后执行)。
|
|
*/
|
|
private function registerFreightRecalculation(): void
|
|
{
|
|
$queue = static fn ($version) => ShippingFreightService::queueCarrier($version?->company_name, $version?->effective_date);
|
|
\App\Models\Business\CourierQuoteVersion::saved($queue);
|
|
\App\Models\Business\CourierQuoteVersion::deleted($queue);
|
|
$bySignature = static function ($signature) use ($queue): void {
|
|
$version = \App\Models\Business\CourierQuoteVersion::query()->allCompanies()->find($signature->quote_version_id);
|
|
$queue($version);
|
|
};
|
|
\App\Models\Business\CourierQuoteSignature::saved($bySignature);
|
|
}
|
|
|
|
public function register(): void
|
|
{
|
|
$this->app->singleton(UpstreamSnapshotRefresherRegistry::class, function ($app) {
|
|
$registry = new UpstreamSnapshotRefresherRegistry(
|
|
$app->make(UpstreamSourceRegistry::class)
|
|
);
|
|
$registry->register('jiansun', fn () => $app->make(JianSunSnapshotRefresher::class));
|
|
$registry->register('operations_replica', fn () => $app->make(OperationsReplicaSnapshotRefresher::class));
|
|
|
|
return $registry;
|
|
});
|
|
|
|
if (app()->routesAreCached()) {
|
|
return;
|
|
}
|
|
|
|
foreach (['admin.php', 'api.php'] as $route) {
|
|
$this->loadRoutesFrom(__DIR__ . '/../Routes/' . $route);
|
|
}
|
|
}
|
|
}
|