购物车添加查询字段
This commit is contained in:
parent
5198b95428
commit
fab06892d4
@ -134,9 +134,9 @@ class StoreCartDao extends BaseDao
|
||||
* @return mixed
|
||||
* @author Qinii
|
||||
*/
|
||||
public function getCartCount(int $uid)
|
||||
public function getCartCount(int $uid, int $saleType)
|
||||
{
|
||||
$data = ($this->getModel()::getDB())->where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0])->field('SUM(cart_num) as count')->select();
|
||||
$data = ($this->getModel()::getDB())->where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0, 'sale_type' => $saleType])->field('SUM(cart_num) as count')->select();
|
||||
$data[0]['count'] = $data[0]['count'] ? $data[0]['count'] : 0;
|
||||
return $data;
|
||||
}
|
||||
|
@ -76,6 +76,9 @@ class SpuDao extends BaseDao
|
||||
$saleType = $where['sale_type'] == Enum::SALE_TYPE_RETAIL ? [Enum::RETAIL_ONLY, Enum::RETAIL_WHOLESALE] : [Enum::WHOLESALE_ONLY, Enum::RETAIL_WHOLESALE];
|
||||
$merIds = Merchant::whereIn('wholesale', $saleType)->column('mer_id');
|
||||
$query->whereIn('P.mer_id', $merIds);
|
||||
if ($where['sale_type'] == Enum::SALE_TYPE_WHOLESALE) {
|
||||
$query->join('StoreProductAttrValue PAV','S.product_id = PAV.product_id', 'left')->where('PAV.wholesale_price', '>', 0);
|
||||
}
|
||||
})
|
||||
->when(isset($where['product_ids']) && $where['product_ids'] !== '',function($query)use($where){
|
||||
$query->whereIn('P.product_id',$where['product_ids']);
|
||||
@ -112,6 +115,14 @@ class SpuDao extends BaseDao
|
||||
|
||||
$query->whereIn('P.mer_id',$merId);
|
||||
})
|
||||
->when(isset($where['mer_type']) && $where['mer_type'] !== '',function($query)use($where){
|
||||
$merId = Merchant::where('type_id', 22)->value('mer_id');
|
||||
if ($where['mer_type'] == 1) {
|
||||
$query->where('P.mer_id', $merId);
|
||||
} elseif ($where['mer_type'] == 2) {
|
||||
$query->where('P.mer_id', '<>', $merId);
|
||||
}
|
||||
})
|
||||
->when(isset($where['cate_pid']) && $where['cate_pid'], function ($query) use ($where) {
|
||||
$storeCategoryRepository = app()->make(StoreCategoryRepository::class);
|
||||
if (is_array($where['cate_pid'])) {
|
||||
|
@ -34,7 +34,7 @@ class SpuRepository extends BaseRepository
|
||||
{
|
||||
public $dao;
|
||||
public $merchantFiled = 'mer_id,mer_name,mer_avatar,is_trader,mer_info,mer_keyword,type_id';
|
||||
public $productFiled = 'P.product_id,S.store_name,S.image,activity_id,S.keyword,S.price,S.mer_id,spu_id,S.status,store_info,brand_id,cate_id,unit_name,S.star,S.rank,S.sort,sales,S.product_type,rate,reply_count,extension_type,S.sys_labels,S.mer_labels,P.delivery_way,P.delivery_free,S.ot_price,svip_price_type,stock,mer_svip_status';
|
||||
public $productFiled = 'P.product_id,S.store_name,S.image,activity_id,S.keyword,S.price,S.mer_id,spu_id,S.status,store_info,brand_id,cate_id,unit_name,S.star,S.rank,S.sort,P.sales,S.product_type,rate,reply_count,extension_type,S.sys_labels,S.mer_labels,P.delivery_way,P.delivery_free,S.ot_price,svip_price_type,P.stock,mer_svip_status';
|
||||
public function __construct(SpuDao $dao)
|
||||
{
|
||||
$this->dao = $dao;
|
||||
|
@ -173,7 +173,8 @@ class StoreCart extends BaseController
|
||||
*/
|
||||
public function cartCount()
|
||||
{
|
||||
return app('json')->success($this->repository->getCartCount($this->request->uid()));
|
||||
$saleType = $this->request->get('sale_type', 1);
|
||||
return app('json')->success($this->repository->getCartCount($this->request->uid()), intval($saleType));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,6 +67,7 @@ class StoreSpu extends BaseController
|
||||
'type_code',
|
||||
'category_id',
|
||||
'label_name',
|
||||
'mer_type',
|
||||
]);
|
||||
if ($where['type_id'] || $where['type_code']) {
|
||||
$query = Merchant::where(['status' => 1, 'mer_state' => 1, 'is_del' => 0]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user