|
|
@@ -22,13 +22,19 @@ class Product extends Model
|
|
|
}else{
|
|
|
$model = self::where('is_best', 1);
|
|
|
}
|
|
|
- $model->order('sort DESC, add_time DESC');
|
|
|
- $list = $model->page((int)$page, (int)$limit)->field('id,store_name,image,price,cost,ot_price,IFNULL(sales,0) + IFNULL(ficti,0) as sales')->select();
|
|
|
+ if($data['sort'] == 'sales'){
|
|
|
+ $model->orderRaw('sales+ficti desc');
|
|
|
+ }else if($data['sort'] == 'commission'){
|
|
|
+ $model->orderRaw('price-ot_price desc');
|
|
|
+ }else{
|
|
|
+ $model->order('sort DESC, add_time DESC');
|
|
|
+ }
|
|
|
+ $list = $model->page((int)$page, (int)$limit)->field('id,store_name,image,price,cost,ot_price,(price-ot_price) as commission,IFNULL(sales,0) + IFNULL(ficti,0) as sales')->select();
|
|
|
$list = count($list) ? $list->toArray() : [];
|
|
|
return $list;
|
|
|
}
|
|
|
|
|
|
- public static function getValidProduct($productId, $field = 'add_time,browse,cate_id,code_path,cost,ficti,id,image,is_sub,is_best,is_del,is_hot,is_show,keyword,ot_price,postage,price,sales,slider_image,sort,stock,store_info,store_name,unit_name,vip_price,spec_type,IFNULL(sales,0) + IFNULL(ficti,0) as fsales,video_link,description')
|
|
|
+ public static function getValidProduct($productId, $field = 'add_time,browse,cate_id,code_path,cost,ficti,id,image,is_sub,is_best,is_del,is_hot,is_show,keyword,ot_price,postage,price,(price-ot_price) as commission,sales,slider_image,sort,stock,store_info,store_name,unit_name,vip_price,spec_type,IFNULL(sales,0) + IFNULL(ficti,0) as fsales,video_link,description')
|
|
|
{
|
|
|
$Product = self::where('is_del', 0)->where('is_show', 1)->where('id', $productId)->field($field)->find();
|
|
|
if ($Product) return $Product->toArray();
|