Browse Source

Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix

master
Lemon 6 years ago
parent
commit
f9f2e2e893
  1. 6
      app/Controller/v3/GoodsController.php
  2. 4
      app/Service/v3/Implementations/CategoryService.php
  3. 14
      app/Service/v3/Implementations/SearchService.php

6
app/Controller/v3/GoodsController.php

@ -47,6 +47,12 @@ class GoodsController extends BaseController
$res['detail'] = $this->goodsService->detail($params['goods_id']);
$res['banner'] = $this->goodsService->getBanner(1572);
}
//如果没有banner数据,使用商品cover图
if(count($res['banner']) == 0){
$res['banner'] = [$res['detail']['cover_img']];
}
if(isset($params['user_id'])) {
$res['shopcart']['count'] = $this->shopCartService->check(111);
$res['shopcart']['total'] = $this->shopCartService->getTotal();

4
app/Service/v3/Implementations/CategoryService.php

@ -42,8 +42,8 @@ class CategoryService implements CategoryServiceInterface
->groupBy(['category_id'])
->get()->toArray();
return GoodsType::query()
->whereIn('id', array_column($goodsTypeIds, 'category_id'))
return Category::query()
->whereIn('id', array_values(array_column($goodsTypeIds, 'category_id')))
->orderBy('sort', 'DESC')
->orderBy('id', 'DESC')
->get()->toArray();

14
app/Service/v3/Implementations/SearchService.php

@ -44,19 +44,7 @@ class SearchService implements \App\Service\v3\Interfaces\SearchServiceInterface
}
$builder->select(['id', 'store_id', 'cover_img', 'name', 'spec', 'tags', 'original_price', 'price', 'inventory', 'sales as total_sales']);
$goods = $builder->forPage($params['page'], $params['pagesize'])->get()->toArray();
$data = [];
foreach ($goods as $key => &$item) {
$store = (object)$item['store'];
unset($item['store']);
$data[] = [
'goods' => $item,
'store' => $store
];
}
return $data;
return $goods = $builder->forPage($params['page'], $params['pagesize'])->get()->toArray();
}
public function doForStores($params)

Loading…
Cancel
Save