调整商品列表搜索
This commit is contained in:
parent
d787726c86
commit
a436f7227c
@ -11,6 +11,7 @@
|
||||
namespace app\common\dao\store\product;
|
||||
|
||||
use app\common\dao\BaseDao;
|
||||
use app\common\model\store\product\ProductAttrValue;
|
||||
use app\common\model\store\product\ProductCate;
|
||||
use app\common\model\store\product\Spu;
|
||||
use app\common\model\store\StoreCategory;
|
||||
@ -187,6 +188,18 @@ class SpuDao extends BaseDao
|
||||
else if ($where['hot_type'] == 'best') $query->where('P.is_best', 1);
|
||||
else if ($where['hot_type'] == 'good') $query->where('P.is_benefit', 1);
|
||||
})
|
||||
->when(isset($where['deduction_rate']) && $where['deduction_rate'] !== '', function($query) use ($where) {
|
||||
$maxRate = $where['deduction_rate'] == 25 ? 100 : $where['deduction_rate'] + 5;
|
||||
$productIds = ProductAttrValue::when(isset($where['mer_id']) && $where['mer_id'] !== '', function($query) use ($where) {
|
||||
$query->where('mer_id', $where['mer_id']);
|
||||
})->where('profit_rate', '>=', $where['deduction_rate'])
|
||||
->where('profit_rate', '<', $maxRate)
|
||||
->column('product_id');
|
||||
if (empty($productIds)) {
|
||||
$productIds = [0];
|
||||
}
|
||||
$query->whereIn('S.product_id', $productIds);
|
||||
})
|
||||
->when(isset($where['svip']) && $where['svip'] !== '',function($query)use($where){
|
||||
$query->where('svip_price_type','>',0)->where('mer_svip_status',1);
|
||||
})->when($order, function ($query) use ($where, $order) {
|
||||
|
@ -582,6 +582,7 @@ class SpuRepository extends BaseRepository
|
||||
];
|
||||
break;
|
||||
case 2:
|
||||
/** @var ProductPresellRepository $_make */
|
||||
$_make = app()->make(ProductPresellRepository::class);
|
||||
$res = $_make->getWhere([$_make->getPk() => $id]);
|
||||
$where = [
|
||||
|
@ -14,6 +14,7 @@
|
||||
namespace app\common\repositories\system\merchant;
|
||||
|
||||
|
||||
use app\common\dao\store\StoreCategoryDao;
|
||||
use app\common\dao\system\financial\FinancialDao;
|
||||
use app\common\dao\system\merchant\MerchantDao;
|
||||
use app\common\dao\system\serve\ServeOrderDao;
|
||||
@ -410,12 +411,17 @@ class MerchantRepository extends BaseRepository
|
||||
/**
|
||||
* @Author:Qinii
|
||||
* @Date: 2020/5/30
|
||||
* @param int $id
|
||||
* @param int $merId
|
||||
* @param int $pid
|
||||
* @return mixed
|
||||
*/
|
||||
public function categoryList(int $id)
|
||||
public function categoryList(int $merId, int $pid = 0)
|
||||
{
|
||||
return app()->make(StoreCategoryRepository::class)->getApiFormatList($id, 1);
|
||||
if ($pid == 0) {
|
||||
return app()->make(StoreCategoryRepository::class)->getApiFormatList($merId, 1);
|
||||
} else {
|
||||
return app()->make(StoreCategoryDao::class)->children($pid, $merId);
|
||||
}
|
||||
}
|
||||
|
||||
public function wxQrcode($merId)
|
||||
|
@ -128,9 +128,10 @@ class Merchant extends BaseController
|
||||
*/
|
||||
public function categoryList($id)
|
||||
{
|
||||
$pid = $this->request->get('pid', 0);
|
||||
if (!$this->repository->merExists((int)$id))
|
||||
return app('json')->fail('店铺已打烊');
|
||||
return app('json')->success($this->repository->categoryList($id));
|
||||
return app('json')->success($this->repository->categoryList($id, $pid));
|
||||
}
|
||||
|
||||
public function qrcode($id)
|
||||
|
@ -12,6 +12,7 @@ namespace app\controller\api\store\product;
|
||||
|
||||
use app\common\dao\store\CityAreaDao;
|
||||
use app\common\dao\system\merchant\MerchantDao;
|
||||
use app\common\model\store\product\ProductLabel;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\repositories\store\StoreCategoryRepository;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
@ -64,17 +65,19 @@ class StoreSpu extends BaseController
|
||||
'category_id',
|
||||
'type_code',
|
||||
'village_id',
|
||||
'location'
|
||||
'location',
|
||||
'sys_labels',
|
||||
'deduction_rate'
|
||||
]);
|
||||
if (isset($where['type_code']) && $where['type_code'] == 'PersonalStore') {
|
||||
$where['long'] = '';
|
||||
$where['lat'] = '';
|
||||
$where['type_id'] = 21;
|
||||
} else {
|
||||
[$lat, $lng] = (new CityAreaDao())->getLngAndLat($where['location'], $where['street_id']);
|
||||
$where['long'] = $lng;
|
||||
$where['lat'] = $lat;
|
||||
}
|
||||
// if (isset($where['type_code']) && $where['type_code'] == 'PersonalStore') {
|
||||
// $where['long'] = '';
|
||||
// $where['lat'] = '';
|
||||
// $where['type_id'] = 21;
|
||||
// } else {
|
||||
// [$lat, $lng] = (new CityAreaDao())->getLngAndLat($where['location'], $where['street_id']);
|
||||
// $where['long'] = $lng;
|
||||
// $where['lat'] = $lat;
|
||||
// }
|
||||
if ($where['type_id'] || $where['type_code']) {
|
||||
$arr = ['status' => 1, 'mer_state' => 1, 'is_del' => 0];
|
||||
$query = Merchant::where($arr);
|
||||
@ -161,7 +164,7 @@ class StoreSpu extends BaseController
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$where = $this->request->params([
|
||||
'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common'
|
||||
'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common', 'deduction_rate'
|
||||
]);
|
||||
if ($where['action']) unset($where['product_type']);
|
||||
$where['mer_id'] = $id;
|
||||
@ -416,4 +419,12 @@ class StoreSpu extends BaseController
|
||||
}
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
public function storeLabel()
|
||||
{
|
||||
$merId = $this->request->get('mer_id');
|
||||
$list = ProductLabel::where('mer_id', $merId)->select()->toArray();
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -578,6 +578,8 @@ Route::group('api/', function () {
|
||||
Route::get('/active/category/:type', 'StoreSpu/activeCategory');
|
||||
//标签获取数据
|
||||
Route::get('/labels', 'StoreSpu/labelsLst');
|
||||
//店铺商品标签列表
|
||||
Route::get('/storeLabel', 'StoreSpu/storeLabel');
|
||||
//本地生活商品
|
||||
Route::get('/local/:id', 'StoreSpu/local');
|
||||
//复制口令
|
||||
|
Loading…
x
Reference in New Issue
Block a user