获取商品数据-分页
This commit is contained in:
@@ -415,4 +415,55 @@ class BasicDataService extends BaseService
|
||||
|
||||
return success($disease_class_detections->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品数据-分页
|
||||
* @return array
|
||||
*/
|
||||
public function getProductPage(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$keyword = $this->request->input('keyword',"");
|
||||
|
||||
$page = $this->request->input('page', 1);
|
||||
$per_page = $this->request->input('per_page', 10);
|
||||
|
||||
$fields = [
|
||||
'product_id',
|
||||
'product_platform_id',
|
||||
'product_name',
|
||||
'product_price',
|
||||
'product_cover_img',
|
||||
'product_spec',
|
||||
'manufacturer',
|
||||
'single_unit',
|
||||
'single_use',
|
||||
'packaging_unit',
|
||||
'frequency_use',
|
||||
'available_days',
|
||||
];
|
||||
|
||||
$params = array();
|
||||
|
||||
|
||||
$product = Product::getWithAmountPage($params, $keyword,$fields, $page, $per_page);
|
||||
if (empty($product['data'])) {
|
||||
return success($product);
|
||||
}
|
||||
|
||||
foreach ($product['data'] as &$item) {
|
||||
$item['product_cover_img'] = addAliyunOssWebsite($item['product_cover_img']);
|
||||
|
||||
$item['product_name'] = $item['product_name'] . ' ' . $item['product_spec'];
|
||||
$item['stock'] = 0;
|
||||
if (!empty($item['ProductPlatformAmount'])){
|
||||
$item['stock'] = $item['ProductPlatformAmount']['stock'];
|
||||
}
|
||||
|
||||
unset($item['ProductPlatformAmount']);
|
||||
}
|
||||
|
||||
return success($product);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user