修改购物车查询
This commit is contained in:
parent
b1aea23f76
commit
5198b95428
@ -50,11 +50,12 @@ class StoreCartDao extends BaseDao
|
|||||||
* @Author:Qinii
|
* @Author:Qinii
|
||||||
* @Date: 2020/6/1
|
* @Date: 2020/6/1
|
||||||
* @param int $uid
|
* @param int $uid
|
||||||
|
* @param int $saleType
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getAll(int $uid)
|
public function getAll(int $uid, int $saleType = 1)
|
||||||
{
|
{
|
||||||
$query = ($this->getModel())::where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0])
|
$query = ($this->getModel())::where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0, 'sale_type' => $saleType])
|
||||||
->with([
|
->with([
|
||||||
'product' => function ($query) {
|
'product' => function ($query) {
|
||||||
$query->field('product_id,image,store_name,is_show,status,is_del,unit_name,price,mer_status,is_used,product_type,once_max_count,once_min_count,pay_limit,mer_svip_status,svip_price_type');
|
$query->field('product_id,image,store_name,is_show,status,is_del,unit_name,price,mer_status,is_used,product_type,once_max_count,once_min_count,pay_limit,mer_svip_status,svip_price_type');
|
||||||
|
@ -73,7 +73,7 @@ class SpuDao extends BaseDao
|
|||||||
$query->whereIn('P.mer_id',$where['mer_ids']);
|
$query->whereIn('P.mer_id',$where['mer_ids']);
|
||||||
})
|
})
|
||||||
->when(isset($where['sale_type']) && $where['sale_type'] !== '',function($query)use($where){
|
->when(isset($where['sale_type']) && $where['sale_type'] !== '',function($query)use($where){
|
||||||
$saleType = $where['sale_type'] == Enum::SALE_TYPE_RETAIL ? [Enum::RETAIL_ONLY, Enum::RETAIL_WHOLESALE] : [Enum::WHOLESALE_ONLY];
|
$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');
|
$merIds = Merchant::whereIn('wholesale', $saleType)->column('mer_id');
|
||||||
$query->whereIn('P.mer_id', $merIds);
|
$query->whereIn('P.mer_id', $merIds);
|
||||||
})
|
})
|
||||||
|
@ -46,13 +46,14 @@ class StoreCartRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $uid
|
* @param $user
|
||||||
|
* @param int $saleType
|
||||||
* @return array
|
* @return array
|
||||||
* @author Qinii
|
* @author Qinii
|
||||||
*/
|
*/
|
||||||
public function getList($user)
|
public function getList($user, int $saleType = 1)
|
||||||
{
|
{
|
||||||
$res = $this->dao->getAll($user->uid)->append(['checkCartProduct', 'UserPayCount', 'ActiveSku','spu']);
|
$res = $this->dao->getAll($user->uid, $saleType)->append(['checkCartProduct', 'UserPayCount', 'ActiveSku','spu']);
|
||||||
return $this->checkCartList($res, $user->uid, $user);
|
return $this->checkCartList($res, $user->uid, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,8 @@ class StoreCart extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function lst()
|
public function lst()
|
||||||
{
|
{
|
||||||
$data = $this->repository->getList($this->request->userInfo());
|
$saleType = $this->request->get('sale_type', 1);
|
||||||
|
$data = $this->repository->getList($this->request->userInfo(), intval($saleType));
|
||||||
return app('json')->success($data);
|
return app('json')->success($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user