|
@@ -24,7 +24,7 @@ class GoodsController extends webApp
|
|
|
try {
|
|
|
$params = request()->post();
|
|
|
$pageSize = request()->post('pageSize', 0);
|
|
|
- $datas = GoodsService::make()->getDataList($params, $pageSize,'', $this->userId);
|
|
|
+ $datas = GoodsService::make()->getApiDataList($params, $pageSize,'', $this->userId);
|
|
|
return showJson(1010, true, $datas);
|
|
|
} catch (\Exception $exception){
|
|
|
RedisService::set("caches:request:error_goods_index", ['trace'=>$exception->getTrace()], 7200);
|
|
@@ -33,23 +33,6 @@ class GoodsController extends webApp
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 列表
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function list()
|
|
|
- {
|
|
|
- try {
|
|
|
- $params = request()->post();
|
|
|
- $pageSize = request()->post('pageSize', 0);
|
|
|
- $datas = GoodsService::make()->getDataList($params, $pageSize,'lev_a.*,lev_c.name as merch_name', $this->userId);
|
|
|
- return showJson(1010, true, $datas);
|
|
|
- } catch (\Exception $exception){
|
|
|
- RedisService::set("caches:request:error_goods_index", ['trace'=>$exception->getTrace()], 7200);
|
|
|
- return showJson(1018, false, ['error'=>env('APP_DEBUG')? $exception->getTrace() : '']);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 分类
|
|
|
* @return array
|
|
|
*/
|
|
@@ -68,78 +51,8 @@ class GoodsController extends webApp
|
|
|
public function info()
|
|
|
{
|
|
|
$id = request()->post('id', 0);
|
|
|
- $info = GoodsService::make()->getInfo($id, $this->userId);
|
|
|
+ $info = GoodsService::make()->getApiInfo($id);
|
|
|
return showJson(1010, true, $info);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 推荐
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function recommend()
|
|
|
- {
|
|
|
- try {
|
|
|
- $params = request()->post();
|
|
|
- $pageSize = request()->post('pageSize', 0);
|
|
|
- $lng = isset($params['lng'])? $params['lng'] : '';
|
|
|
- $lat = isset($params['lat'])? $params['lat'] : '';
|
|
|
- $params = [
|
|
|
- 'lat'=> $lat? $lat : (isset($this->userInfo['lat'])? $this->userInfo['lat'] : ''),
|
|
|
- 'lng'=> $lng? $lng : (isset($this->userInfo['lng'])? $this->userInfo['lng'] : ''),
|
|
|
- 'sort_type'=> 1,
|
|
|
- 'is_recommend'=> 1,
|
|
|
- 'type'=> isset($params['type'])? intval($params['type']) : 2,
|
|
|
- 'status'=> 2,
|
|
|
- ];
|
|
|
- $datas = GoodsService::make()->getDataList($params, $pageSize);
|
|
|
- return showJson(1010, true, $datas);
|
|
|
- } catch (\Exception $exception){
|
|
|
- RedisService::set("caches:request:error_goods_recommend", ['trace'=>$exception->getTrace()], 7200);
|
|
|
- return showJson(1018, false, ['error'=>env('APP_DEBUG')? $exception->getMessage() : '']);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 发布
|
|
|
- * @param GoodsValidator $validator
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function submit(GoodsValidator $validator)
|
|
|
- {
|
|
|
- $params = request()->all();
|
|
|
- $params = $validator->check($params, 'submit');
|
|
|
- if (!is_array($params)) {
|
|
|
- return showJson($params, false);
|
|
|
- }
|
|
|
-
|
|
|
- if(!$result = GoodsService::make()->submit($this->userId, $params)){
|
|
|
- return showJson(GoodsService::make()->getError(), false);
|
|
|
- }else{
|
|
|
- return showJson(GoodsService::make()->getError(), true, $result);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 状态/上下架
|
|
|
- * @return array|mixed
|
|
|
- */
|
|
|
- public function status()
|
|
|
- {
|
|
|
- if(!$result = GoodsService::make()->status()){
|
|
|
- return showJson(GoodsService::make()->getError(), false);
|
|
|
- }else{
|
|
|
- return showJson(GoodsService::make()->getError(), true, $result);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除
|
|
|
- * @return array|mixed
|
|
|
- */
|
|
|
- public function delete()
|
|
|
- {
|
|
|
- return GoodsService::make()->delete();
|
|
|
- }
|
|
|
-
|
|
|
}
|