商品价格更改列表添加走势图
This commit is contained in:
parent
ef95b1989f
commit
ca1570abb2
@ -108,4 +108,11 @@ class StoreProductPriceController extends BaseAdminController
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
|
||||
public function chart()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$data = StoreProductPriceLogic::chart($params);
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
}
|
@ -243,4 +243,26 @@ class StoreProductPriceLogic extends BaseLogic
|
||||
return (new StoreProductPriceXlsx())->export($data);
|
||||
}
|
||||
|
||||
public static function chart($params)
|
||||
{
|
||||
$list = StoreProductPrice::where('product_id', $params['product_id'])
|
||||
->field('id,purchase_price,purchase,create_time')
|
||||
->order('id desc')->limit(30)
|
||||
->select()->toArray();
|
||||
foreach ($list as &$item) {
|
||||
$item['date'] = date('m-d', strtotime($item['create_time']));
|
||||
if ($params['type'] == 1) {
|
||||
$item['price'] = $item['purchase_price'];
|
||||
} else {
|
||||
$item['price'] = $item['purchase'];
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'name' => '价格趋势',
|
||||
'series' => [['name' => '价格', 'value' => array_column($list, 'price')]],
|
||||
'x' => array_column($list, 'date'),
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user