@ -83,21 +83,38 @@ class Store extends AuthController
*/
*/
public function getCategory()
public function getCategory()
{
{
$parentCategory = StoreCategory::pidByCategory(0, 'id,cate_name');
$cateogry = StoreCategory::with('children')->where(['is_show' => 1])->order('sort desc,id desc')->where('pid', 0)->select();
$parentCategory = count($parentCategory) > 0 ? $parentCategory->toArray() : [];
return JsonService::successful($cateogry->toArray());
return JsonService::successful($parentCategory);
}
}
/**商品列表
/**商品列表
* @param string $keyword
* @param int $page
* @param int $limit
* @param int $cId
* @param int $cId
* @param int $first
* @param string $keyword
* @return null
*/
public function getProductList($page = 1, $limit = 8, $cId = 0, $keyword = '')
{
if (!empty($keyword)) $keyword = base64_decode(htmlspecialchars($keyword));
$model = StoreProduct::validWhere();
if (!empty($cId)) $model = $model->where('cate_id', $cId);
if (!empty($keyword)) $model->where('keyword|store_name', 'LIKE', "%$keyword%");
$model->order('sort DESC, add_time DESC');
$list = $model->page((int)$page, (int)$limit)->field('id,mer_id,store_name,image,sales,price,stock,IFNULL(sales,0) + IFNULL(ficti,0) as sales,keyword')->select();
$list = count($list) > 0 ? $list->toArray() : [];
return JsonService::successful($list);
}
/**商品推荐列表
* @param int $page
* @param int $limit
* @param int $limit
* @throws \think\db\exception\DataNotFoundException
* @param int $cId
* @throws \think\db\exception\ModelNotFoundException
* @param string $keyword
* @throws \think\exception\DbException
* @return null
*/
*/
public function getProductList($page = 1, $limit = 8, $cId = 0)
public function getRecommend ProductList($page = 1, $limit = 8, $cId = 0, $keyword = '' )
{
{
if (!empty($keyword)) $keyword = base64_decode(htmlspecialchars($keyword));
if (!empty($keyword)) $keyword = base64_decode(htmlspecialchars($keyword));
$model = StoreProduct::validWhere();
$model = StoreProduct::validWhere();