|
|
|
@ -181,40 +181,43 @@ class Goods extends BaseModel |
|
|
|
|
|
|
|
|
|
$query = $this->getQueryFilter($param); |
|
|
|
|
// 设置显示的销量 goods_sales |
|
|
|
|
$query->field(['(sales_initial + sales_actual) as goods_sales']); |
|
|
|
|
$query->field(['(sales_initial + sales_actual) as goods_sales', '(line_price_max - goods_price_min) as discount']); |
|
|
|
|
// 排序条件 |
|
|
|
|
$sort = $this->setQuerySort($param); |
|
|
|
|
$order = request()->get()['order'] ?? ''; |
|
|
|
|
|
|
|
|
|
if (!empty($order)) { |
|
|
|
|
if ($order == 1) { |
|
|
|
|
$sort['goods_price_min'] = 'asc'; |
|
|
|
|
$sort = ['goods_price_min' => 'asc']; |
|
|
|
|
} |
|
|
|
|
if ($order == 2) { |
|
|
|
|
$sort['goods_price_min'] = 'desc'; |
|
|
|
|
$sort = ['goods_price_min' => 'desc']; |
|
|
|
|
} |
|
|
|
|
//todo wmc |
|
|
|
|
|
|
|
|
|
if ($order == 3) { |
|
|
|
|
$sort['goods_price_min'] = 'asc'; |
|
|
|
|
$sort = ['discount' => 'asc']; |
|
|
|
|
} |
|
|
|
|
if ($order == 4) { |
|
|
|
|
$sort['goods_price_min'] = 'desc'; |
|
|
|
|
$sort = ['discount' => 'desc']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($order == 5) { |
|
|
|
|
$sort['goods_sales'] = 'asc'; |
|
|
|
|
$sort = ['goods_sales' => 'asc']; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if ($order == 6) { |
|
|
|
|
$sort['goods_sales'] = 'desc'; |
|
|
|
|
$sort = ['goods_sales' => 'desc']; |
|
|
|
|
} |
|
|
|
|
//todo wmc |
|
|
|
|
|
|
|
|
|
if ($order == 7) { |
|
|
|
|
$sort['goods_sales'] = 'asc'; |
|
|
|
|
$sort = ['goods_sales' => 'asc']; |
|
|
|
|
} |
|
|
|
|
if ($order == 8) { |
|
|
|
|
$sort['goods_sales'] = 'desc'; |
|
|
|
|
$sort = ['goods_sales' => 'desc']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$field = $this->getAliasFields($this->name, ['content']); |
|
|
|
|
$field[] = 'selling_point'; |
|
|
|
|
// 执行查询 |
|
|
|
|