lqmac 6 months ago
parent 354715505a
commit 45408a5a70
  1. 15
      app/api/controller/Goods.php
  2. 37
      app/api/service/Goods.php
  3. 2
      app/common/model/Goods.php
  4. 5
      app/store/model/Store.php

@ -306,7 +306,20 @@ class Goods extends Controller
//Cache::set($cache_key, $goodsList, 60*60); //Cache::set($cache_key, $goodsList, 60*60);
return $this->renderSuccess(compact('goodsList')); return $this->renderSuccess(compact('goodsList'));
} }
/**
* 推荐的商品列表
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function recommendedNew(): Json
{
$service = new GoodsService;
$goodsList = $service->recommendedNew();
return $this->renderSuccess(compact('goodsList'));
}
/** /**
* 商品大牌和新品 * 商品大牌和新品
* @return Json * @return Json

@ -170,7 +170,42 @@ class Goods extends GoodsService
} }
return $this->formatGoodsList($goodsList); return $this->formatGoodsList($goodsList);
} }
/**
* 推荐的商品列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function recommendedNew(): array
{
// 获取商品推荐数据
$setting = $this->getRecommendedSetting();
// 获取商品数据
$model = new GoodsModel;
if ($setting['params']['source'] === 'choice') {
// 数据来源:手动
// if (empty($setting['params']['goodsIds'])) return [];
// $goodsList = $model->getListByIdsFromApi($setting['params']['goodsIds']);
// 数据来源:自动
$goodsList = $model->getList([
'status' => 10,
'goodsIds' => implode(",",$setting['params']['goodsIds']),
'sortType' => "all",
], 10);
} else {
// 数据来源:自动
$goodsList = $model->getList([
'status' => 10,
'categoryId' => $setting['params']['auto']['category'],
'sortType' => $setting['params']['auto']['goodsSort'],
], 10);
}
return $this->formatGoodsList($goodsList);
}
//大牌正品列表 //大牌正品列表
public function brandList(): array public function brandList(): array
{ {

@ -312,6 +312,7 @@ class Goods extends BaseModel
$query = $query->whereRaw('goods_name like ? or goods_no like ?', ["%{$val}%", "%{$val}%"]); $query = $query->whereRaw('goods_name like ? or goods_no like ?', ["%{$val}%", "%{$val}%"]);
} }
} }
//数据渠道过滤特殊处理
if (isset($param['fliter_condition']) && $param['fliter_condition']) { if (isset($param['fliter_condition']) && $param['fliter_condition']) {
$fliter_condition = json_decode($param['fliter_condition'], true); $fliter_condition = json_decode($param['fliter_condition'], true);
@ -571,7 +572,6 @@ class Goods extends BaseModel
if (isset($param['is_jd_remove']) && $param['is_jd_remove'] !== '') { if (isset($param['is_jd_remove']) && $param['is_jd_remove'] !== '') {
$filter[] = ['goods.is_jd_remove', '=', $params['is_jd_remove']]; $filter[] = ['goods.is_jd_remove', '=', $params['is_jd_remove']];
} }
// 实例化新查询对象 // 实例化新查询对象
return $query->where($filter); return $query->where($filter);
} }

@ -30,7 +30,10 @@ class Store extends StoreModel
{ {
// 是否删除图片 // 是否删除图片
!isset($data['logo_image_id']) && $data['logo_image_id'] = 0; !isset($data['logo_image_id']) && $data['logo_image_id'] = 0;
$data['fliter_condition'] = isset($data['fliter_condition']) ? json_encode($data['fliter_condition'], JSON_UNESCAPED_UNICODE) : ""; if (isset($data['fliter_condition'])) {
$data['fliter_condition'] = json_encode($data['fliter_condition'], JSON_UNESCAPED_UNICODE);
}
return $this->save($data) !== false; return $this->save($data) !== false;
} }
} }

Loading…
Cancel
Save