优化代码

main
home.fengxinyhyl 6 months ago
parent 870d817f40
commit 806a9172c1
  1. 4
      app/common/dao/store/product/SpuDao.php
  2. 2
      app/controller/api/store/product/StoreSpu.php

@ -17,6 +17,7 @@ use app\common\model\store\StoreCategory;
use app\common\repositories\store\StoreCategoryRepository; use app\common\repositories\store\StoreCategoryRepository;
use app\common\repositories\system\merchant\MerchantRepository; use app\common\repositories\system\merchant\MerchantRepository;
use crmeb\services\VicWordService; use crmeb\services\VicWordService;
use think\facade\Log;
class SpuDao extends BaseDao class SpuDao extends BaseDao
{ {
@ -39,10 +40,13 @@ class SpuDao extends BaseDao
} }
}elseif($where['order'] == 'star'){ }elseif($where['order'] == 'star'){
$order = 'S.star DESC,S.rank DESC'; $order = 'S.star DESC,S.rank DESC';
}elseif($where['order'] == 'product_id'){
$order = 'S.product_id ASC';
}else{ }else{
$order = 'S.'. (($where['order'] !== '') ?$where['order']: 'star' ).' DESC'; $order = 'S.'. (($where['order'] !== '') ?$where['order']: 'star' ).' DESC';
} }
} }
Log::info("Order is ". $order);
$order .= ',S.create_time DESC'; $order .= ',S.create_time DESC';
if(isset($where['order']) && $where['order'] === 'none'){ if(isset($where['order']) && $where['order'] === 'none'){

@ -67,7 +67,7 @@ class StoreSpu extends BaseController
$limit = 10; $limit = 10;
$where['is_good'] = 1; $where['is_good'] = 1;
} }
$where['order'] = $where['order'] ?: 'star'; $where['order'] = $where['order'] ?: 'product_id';
if ($where['is_trader'] != 1) unset($where['is_trader']); if ($where['is_trader'] != 1) unset($where['is_trader']);
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo); $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
return app('json')->success($data); return app('json')->success($data);

Loading…
Cancel
Save