修复商品编码大小写不一致导致普通商品资料价格未匹配:聚水潭成本价/变价后价格/工作平台价格统一按大写匹配
This commit is contained in:
parent
af1a98e1a1
commit
ddfd4b052f
@ -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,
|
||||
];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user