调整商品列表搜索
This commit is contained in:
parent
649f6fbb8e
commit
c9b46e3a81
@ -12,6 +12,7 @@ namespace app\common\dao\store\product;
|
|||||||
|
|
||||||
use app\common\dao\BaseDao;
|
use app\common\dao\BaseDao;
|
||||||
use app\common\Enum;
|
use app\common\Enum;
|
||||||
|
use app\common\model\store\product\ProductAttrValue;
|
||||||
use app\common\model\store\product\ProductCate;
|
use app\common\model\store\product\ProductCate;
|
||||||
use app\common\model\store\product\Spu;
|
use app\common\model\store\product\Spu;
|
||||||
use app\common\model\store\StoreCategory;
|
use app\common\model\store\StoreCategory;
|
||||||
@ -200,6 +201,18 @@ class SpuDao extends BaseDao
|
|||||||
else if ($where['hot_type'] == 'best') $query->where('P.is_best', 1);
|
else if ($where['hot_type'] == 'best') $query->where('P.is_best', 1);
|
||||||
else if ($where['hot_type'] == 'good') $query->where('P.is_benefit', 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){
|
->when(isset($where['svip']) && $where['svip'] !== '',function($query)use($where){
|
||||||
$query->where('svip_price_type','>',0)->where('mer_svip_status',1);
|
$query->where('svip_price_type','>',0)->where('mer_svip_status',1);
|
||||||
})
|
})
|
||||||
|
@ -11,11 +11,13 @@
|
|||||||
namespace app\controller\api\store\product;
|
namespace app\controller\api\store\product;
|
||||||
|
|
||||||
use app\common\model\store\product\ProductLabel;
|
use app\common\model\store\product\ProductLabel;
|
||||||
|
use app\common\model\system\merchant\Merchant;
|
||||||
use app\common\repositories\store\product\ProductRepository;
|
use app\common\repositories\store\product\ProductRepository;
|
||||||
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 app\common\repositories\user\UserHistoryRepository;
|
use app\common\repositories\user\UserHistoryRepository;
|
||||||
use app\common\repositories\user\UserVisitRepository;
|
use app\common\repositories\user\UserVisitRepository;
|
||||||
|
use app\controller\admin\system\merchant\MerchantType;
|
||||||
use crmeb\services\CopyCommand;
|
use crmeb\services\CopyCommand;
|
||||||
use think\App;
|
use think\App;
|
||||||
use crmeb\basic\BaseController;
|
use crmeb\basic\BaseController;
|
||||||
@ -64,6 +66,18 @@ class StoreSpu extends BaseController
|
|||||||
'deduction_rate',
|
'deduction_rate',
|
||||||
'sale_type',
|
'sale_type',
|
||||||
]);
|
]);
|
||||||
|
if ($where['type_id'] || $where['type_code']) {
|
||||||
|
$query = Merchant::where(['status' => 1, 'mer_state' => 1, 'is_del' => 0]);
|
||||||
|
$mer_type_id = MerchantType::where('type_code', $where['type_code'])->value('mer_type_id');
|
||||||
|
if ($mer_type_id && $where['type_code'] == 'PersonalStore') {
|
||||||
|
$where['mer_ids'] = $query->where('type_id', $mer_type_id)->column('mer_id');
|
||||||
|
} else {
|
||||||
|
$where['mer_ids'] = $query->whereIn('type_id', explode(',', $where['type_id']))->column('mer_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($where['category_id'] != '') {
|
||||||
|
$where['mer_ids'] = Merchant::where(['category_id' => $where['category_id'], 'status' => 1, 'is_del' => 0])->column('mer_id');
|
||||||
|
}
|
||||||
$where['is_gift_bag'] = 0;
|
$where['is_gift_bag'] = 0;
|
||||||
$where['product_type'] = 0;
|
$where['product_type'] = 0;
|
||||||
$where['order'] = $where['order'] ?: 'star';
|
$where['order'] = $where['order'] ?: 'star';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user