|
|
@@ -132,11 +132,15 @@ class GoodsService extends BaseService
|
|
|
$where['status'] = $status;
|
|
|
}
|
|
|
|
|
|
- // 多商户支持:如果当前登录用户关联了stores表,则只查询该商家的商品
|
|
|
+ // 企业支持:如果当前登录用户关联了企业信息,则只查询该企业的商品
|
|
|
if (isset($params['store_id']) && $params['store_id'] > 0) {
|
|
|
$where['store_id'] = $params['store_id'];
|
|
|
}
|
|
|
|
|
|
+ if (isset($params['is_recommend']) && $params['is_recommend'] > 0) {
|
|
|
+ $where['is_recommend'] = $params['is_recommend'];
|
|
|
+ }
|
|
|
+
|
|
|
// 分类筛选
|
|
|
$categoryId = isset($params['category_id']) ? intval($params['category_id']) : 0;
|
|
|
if ($categoryId > 0) {
|
|
|
@@ -153,7 +157,7 @@ class GoodsService extends BaseService
|
|
|
$query->where('goods_name', 'like', "%{$goodsName}%");
|
|
|
}
|
|
|
|
|
|
- // 商家名称搜索(通过关联stores表)
|
|
|
+ // 企业名称搜索(通过关联stores表)
|
|
|
$storeName = isset($params['store_name']) ? trim($params['store_name']) : '';
|
|
|
if ($storeName) {
|
|
|
$query->whereHas('store', function ($q) use ($storeName) {
|
|
|
@@ -596,6 +600,36 @@ class GoodsService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 设置推荐
|
|
|
+ */
|
|
|
+ public function recommend()
|
|
|
+ {
|
|
|
+ $params = request()->all();
|
|
|
+ $id = isset($params['id']) ? intval($params['id']) : 0;
|
|
|
+ $isRecommend = isset($params['is_recommend']) ? intval($params['is_recommend']) : 0;
|
|
|
+
|
|
|
+ if (!$id) {
|
|
|
+ return ['code' => 1, 'msg' => '商品ID不能为空'];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$isRecommend || ($isRecommend != 1 && $isRecommend != 2)) {
|
|
|
+ return ['code' => 1, 'msg' => '参数错误'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $info = $this->model->where(['id' => $id, 'mark' => 1])->first();
|
|
|
+ if (!$info) {
|
|
|
+ return ['code' => 1, 'msg' => '商品信息不存在'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->model->where('id', $id)->update([
|
|
|
+ 'is_recommend' => $isRecommend,
|
|
|
+ 'update_time' => time()
|
|
|
+ ]);
|
|
|
+
|
|
|
+ return ['code' => 0, 'msg' => $isRecommend==1?'设置推荐成功':'取消推荐成功'];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取商品详情(重写父类方法)
|
|
|
* @param int $storeId 商家ID,用于数据隔离(0表示超级管理员,>0表示商户用户)
|
|
|
* @return array
|