|
@@ -414,6 +414,27 @@ class GoodsService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 删除购物车商品
|
|
|
+ * @param $userId
|
|
|
+ * @param $params
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function deleteCart($userId, $params)
|
|
|
+ {
|
|
|
+ $ids = isset($params['ids'])? $params['ids'] : [];
|
|
|
+ if(empty($ids)){
|
|
|
+ $this->error = 2923;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ CartsModel::whereIn('id', $ids)->update(['status'=>2,'update_time'=>time()]);
|
|
|
+ $this->error = 1002;
|
|
|
+ RedisService::clear("caches:members:cartCount:{$userId}");
|
|
|
+ RedisService::clear("caches:members:cartList:{$userId}");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 购物车列表
|
|
|
* @param $userId
|
|
|
* @param int $pageSize
|
|
@@ -434,7 +455,7 @@ class GoodsService extends BaseService
|
|
|
->where(['a.status' => 1, 'a.mark' => 1,'b.status'=>1,'b.mark'=>1])
|
|
|
->where('b.cost_price', '>', 0)
|
|
|
->where('a.num', '>', 0)
|
|
|
- ->select(['b.goods_id','b.merch_id','b.goods_name','b.supply_type','b.main_img','b.cost_price','b.retail_price','b.limit_num','b.lowest_num','b.brand_name','a.num','a.sku_id'])
|
|
|
+ ->select(['a.id as cart_id','b.goods_id','b.merch_id','b.goods_name','b.supply_type','b.main_img','b.cost_price','b.retail_price','b.limit_num','b.lowest_num','b.brand_name','a.num','a.sku_id'])
|
|
|
->orderBy('a.create_time','desc')
|
|
|
->limit($pageSize)
|
|
|
->get();
|