更新云商品sku查询
This commit is contained in:
parent
e366e6f14b
commit
72a2d569d5
@ -203,16 +203,42 @@ class SpuRepository extends BaseRepository
|
||||
'merchant' => function ($query) {
|
||||
$query->field($this->merchantFiled)->with(['type_name']);
|
||||
},
|
||||
'issetCoupon',
|
||||
'issetCoupon'
|
||||
]);
|
||||
$list = $query->setOption('field', [])->field($this->productFiled)->page($page)->limit($limit)->select();
|
||||
$append = ['stop_time','svip_price','show_svip_info','is_svip_price'];
|
||||
|
||||
$list->append($append);
|
||||
$list = $this->getBorderList($list);
|
||||
$productIdArray = $productSkuArray = [];
|
||||
foreach ($list as &$item) {
|
||||
$productIdArray[] = $item->product_id;
|
||||
$item['referer'] = AesUtils::encrypt($entryMerId . '|' . rand(1, 100), env('app_key'));
|
||||
}
|
||||
$productAttrList = Db::name('store_product_attr_value')->whereIn('product_id', $productIdArray)->field(['product_id', 'sku', 'price', 'stock', 'image', 'weight', 'volume', 'sales', 'unique', 'bar_code', 'ot_price', 'svip_price'])->select();
|
||||
foreach($productAttrList as $prod) {
|
||||
$productSkuArray[$prod['product_id']][] = [
|
||||
$prod['sku'] => [
|
||||
"sku" => $prod['sku'],
|
||||
"price" => $prod['price'],
|
||||
"stock" => $prod['stock'],
|
||||
"image" => $prod['image'],
|
||||
"weight" => $prod['weight'],
|
||||
"volume" => $prod['volume'],
|
||||
"sales" => $prod['sales'],
|
||||
"unique" => $prod['unique'],
|
||||
"bar_code" => $prod['bar_code'],
|
||||
"ot_price" => $prod['ot_price'],
|
||||
"svip_price" => $prod['svip_price']
|
||||
]
|
||||
];
|
||||
}
|
||||
foreach ($list as &$item) {
|
||||
$item['sku'] = (object)[];
|
||||
if (!empty($productSkuArray[$item['product_id']])) {
|
||||
$item['sku'] = $productSkuArray[$item['product_id']];
|
||||
}
|
||||
}
|
||||
unset($item);
|
||||
return compact('count', 'list');
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user