修改购物车查询

This commit is contained in:
luofei 2024-03-15 11:52:27 +08:00
parent b1aea23f76
commit 5198b95428
4 changed files with 10 additions and 7 deletions

View File

@ -50,11 +50,12 @@ class StoreCartDao extends BaseDao
* @Author:Qinii
* @Date: 2020/6/1
* @param int $uid
* @param int $saleType
* @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([
'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');

View File

@ -73,7 +73,7 @@ class SpuDao extends BaseDao
$query->whereIn('P.mer_id',$where['mer_ids']);
})
->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');
$query->whereIn('P.mer_id', $merIds);
})

View File

@ -46,13 +46,14 @@ class StoreCartRepository extends BaseRepository
}
/**
* @param $uid
* @param $user
* @param int $saleType
* @return array
* @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);
}

View File

@ -56,7 +56,8 @@ class StoreCart extends BaseController
*/
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);
}