From ddfd4b052fa3d4d3039b9292b60244ffc8f3c066 Mon Sep 17 00:00:00 2001 From: chenxi Date: Tue, 29 Sep 2026 17:18:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E5=A4=A7=E5=B0=8F=E5=86=99=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=99=AE=E9=80=9A=E5=95=86=E5=93=81=E8=B5=84?= =?UTF-8?q?=E6=96=99=E4=BB=B7=E6=A0=BC=E6=9C=AA=E5=8C=B9=E9=85=8D=EF=BC=9A?= =?UTF-8?q?=E8=81=9A=E6=B0=B4=E6=BD=AD=E6=88=90=E6=9C=AC=E4=BB=B7/?= =?UTF-8?q?=E5=8F=98=E4=BB=B7=E5=90=8E=E4=BB=B7=E6=A0=BC/=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E5=B9=B3=E5=8F=B0=E4=BB=B7=E6=A0=BC=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=8C=89=E5=A4=A7=E5=86=99=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/ComputeProductMonthlyWeightedAverage.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/ComputeProductMonthlyWeightedAverage.php b/app/Console/Commands/ComputeProductMonthlyWeightedAverage.php index c194624d..d0c1c29b 100644 --- a/app/Console/Commands/ComputeProductMonthlyWeightedAverage.php +++ b/app/Console/Commands/ComputeProductMonthlyWeightedAverage.php @@ -43,7 +43,8 @@ class ComputeProductMonthlyWeightedAverage extends Command $updates = []; foreach ($rows as $row) { - $code = trim((string) $row->product_code); + // 普通商品资料与进销存的商品编码大小写不一致,统一按大写匹配。 + $code = mb_strtoupper(trim((string) $row->product_code)); $costPrice = is_array($cost) ? ($cost[$code] ?? null) : null; $workPrice = is_array($work) ? ($work[$code] ?? null) : null; $changePrice = is_array($change) ? ($change[$code] ?? null) : null; @@ -95,7 +96,7 @@ class ComputeProductMonthlyWeightedAverage extends Command foreach (array_chunk($codes, 2000) as $chunk) { foreach (DB::connection($connection)->table('ops_jst_sku') ->whereIn('sku_id', $chunk)->whereNotNull('cost_price')->get(['sku_id', 'cost_price']) as $row) { - $map[trim((string) $row->sku_id)] = (float) $row->cost_price; + $map[mb_strtoupper(trim((string) $row->sku_id))] = (float) $row->cost_price; } } @@ -119,7 +120,7 @@ class ComputeProductMonthlyWeightedAverage extends Command ->orderBy('effectTime') ->get(['skuCode', 'purchasePrice', 'effectTime']); foreach ($rows as $row) { - $map[trim((string) $row->skuCode)] = [ + $map[mb_strtoupper(trim((string) $row->skuCode))] = [ 'price' => (float) $row->purchasePrice, 'effect' => $row->effectTime === null ? null : (string) $row->effectTime, ]; @@ -142,7 +143,7 @@ class ComputeProductMonthlyWeightedAverage extends Command ->orderBy('effectStartTime') ->get(['skucode', 'afterPrice', 'effectStartTime']); foreach ($rows as $row) { - $map[trim((string) $row->skucode)] = [ + $map[mb_strtoupper(trim((string) $row->skucode))] = [ 'price' => (float) $row->afterPrice, 'time' => $row->effectStartTime === null ? null : (string) $row->effectStartTime, ];