Commit deda29e4 by 杨树贤

修复标准品牌问题

parent 668ecc50
......@@ -56,7 +56,7 @@ class StatisticsSkuUploadService
if (empty($brandCountMap)) {
continue;
}
dump("完成供应商$supplierCode".PHP_EOL);
dump("完成供应商$supplierCode" . PHP_EOL);
$redis->hset('half_year_brand_sku_upload_statistics', $supplierCode, json_encode($brandCountMap));
}
}
......@@ -80,7 +80,37 @@ class StatisticsSkuUploadService
}
$data = json_decode($data, true);
arsort($data);
dump($data);
$countByBrandName = [];
foreach ($data as $brandName => $skuCount) {
//然后获取每个品牌的标准品牌
$brandNameAllKey = md5(strtolower($brandName));
$brandId = $redis->hget('brand_name_all', $brandNameAllKey);
//然后找到标准品牌id
$standardBrandId = $redis->hget('standard_brand_mapping', $brandId);
$standardBrand = $redis->hget('standard_brand', $standardBrandId);
$standardBrand = json_decode($standardBrand, true);
$countByBrandName[] = [
'standard_brand_id' => $standardBrandId,
'standard_brand_name' => $standardBrand['brand_name'],
'sku_count' => $skuCount,
];
}
//统计标品的sku数量
$dataByStandardBrandName = collect($countByBrandName)->groupBy('standard_brand_name')->toArray();
$countByStandardBrandName = [];
foreach ($dataByStandardBrandName as $brandName => $standardBrandItem) {
if (empty($brandName)) {
continue;
}
$skuCount = 0;
foreach ($standardBrandItem as $value) {
$skuCount = $value['sku_count'];
}
$countByStandardBrandName[$brandName] = $skuCount;
}
arsort($countByStandardBrandName);
return $data;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment