| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Http\Validator\StoreValidator;
- use App\Services\Api\StoreService;
- /**
- * 商家
- * @package App\Http\Controllers\Api
- */
- class StoreController extends webApp
- {
- /**
- * 列表
- * @return array
- */
- public function index()
- {
- $params =request()->post();
- $pageSize = request()->post('pageSize', 15);
- $datas = StoreService::make()->getDataList($params, $pageSize);
- return showJson(1010, true, $datas);
- }
- /**
- * 主页店铺商品
- * @return array
- */
- public function goods()
- {
- $params =request()->post();
- try {
- $params['user_id'] = $this->userId;
- $datas = StoreService::make()->getGoodsList($params);
- return showJson(StoreService::make()->getError(), true, $datas);
- }catch (\Exception $exception) {
- $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
- return showJson(1046, false, $error);
- }
- }
- /**
- * 行业分类
- * @return array
- */
- public function categorys()
- {
- $datas = StoreService::make()->getCategoryList();
- return showJson(1010, true, $datas);
- }
- /**
- * 详情
- * @return array
- */
- public function info()
- {
- $params = request()->all();
- $id = isset($params['id'])? $params['id'] : 0;
- try {
- if(!$result = StoreService::make()->getInfo($id)){
- return showJson(1009, false);
- }else{
- return showJson(1010, true, $result);
- }
- } catch (\Exception $exception) {
- $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
- return showJson(1046, false, $error);
- }
- }
- /**
- * 详情
- * @return array
- */
- public function applyInfo()
- {
- $params = request()->all();
- $uid = isset($params['uid'])? $params['uid'] : 0;
- $uid = $uid? $uid : $this->userId;
- try {
- if(!$result = StoreService::make()->getApplyInfo($uid)){
- return showJson(1009, false);
- }else{
- return showJson(1010, true, $result);
- }
- } catch (\Exception $exception) {
- $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
- return showJson(1046, false, $error);
- }
- }
- /**
- * 添加
- * @param StoreValidator $validator
- * @return array
- */
- public function apply(StoreValidator $validator)
- {
- $params = request()->all();
- $params = $validator->check($params, 'apply');
- if (!is_array($params)) {
- return showJson($params, false);
- }
- try {
- if(!$result = StoreService::make()->apply($this->userId, $params)){
- return showJson(StoreService::make()->getError(), false);
- }else{
- return showJson(StoreService::make()->getError(), true, $result);
- }
- } catch (\Exception $exception) {
- $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
- return showJson(1046, false, $error);
- }
- }
- /**
- * 删除
- * @return array|mixed
- */
- public function delete()
- {
- if(!StoreService::make()->delete()){
- return showJson(StoreService::make()->getError(), false);
- }else{
- return showJson(StoreService::make()->getError(), true);
- }
- }
- }
|