|
|
<?php
namespace App\Controller\v3;
use App\Constants\v3\ErrorCode;use App\Exception\ErrorCodeException;use App\Controller\BaseController;use App\Model\v3\Employees;use App\Model\v3\ServicePersonnel;use App\Request\v3\StoreIndexRequest;use App\Service\v3\Interfaces\CategoryServiceInterface;use App\Service\v3\Interfaces\CollectStoreServiceInterface;use App\Service\v3\Interfaces\GoodsServiceInterface;use App\Service\v3\Interfaces\StoreServiceInterface;use Hyperf\Di\Annotation\Inject;use Psr\Http\Message\ResponseInterface;use \App\Service\v3\Interfaces\BusinessHoursServiceInterface;
class StoreController extends BaseController{
/** * @Inject * @var StoreServiceInterface */ protected $storeService;
/** * @Inject * @var CategoryServiceInterface */ protected $categoryService;
/** * @Inject * @var CollectStoreServiceInterface */ protected $collectService;
/** * @Inject * @var BusinessHoursServiceInterface */ protected $businessHoursService;
/** * @Inject * @var GoodsServiceInterface */ protected $goodsService;
/** * 商户详情页 * 1、商户id用来查询的,还要有user_id * 2、返回数据,id、logo、name、收藏状态、简介、地址、营业状态、营业时间、联系电话 * 3、返回数据,商品推荐的分类,需要经过商户商品反查 * 4、分类下的商品,则复用商品搜索接口 * @param StoreIndexRequest $request * @return ResponseInterface */ public function index(StoreIndexRequest $request) { $params = $this->request->all(); $data = $this->storeService->detail($params['store_id']); if(empty($data)){ $msg = ['plat'=>'/v3/store/index/',"data"=>$params]; throw new ErrorCodeException(ErrorCode::STORE_NOT_AVAILABLE,'',$msg); } $data['is_collected'] = (bool)$this->collectService->check($params['user_id'],$params['store_id']); $data['goods_types'] = $this->categoryService->allForStore($params['store_id']); $data['in_business'] = $this->storeService->check($params['store_id']); if($data['in_business'] === true) { $data['in_business_text'] = '营业中'; }else{ $data['in_business_text'] = '休息中'; } return $this->success(['store' => $data]); }
public function getBusinessHours() { $storeId = $this->request->input('store_id'); $res = $this->businessHoursService->check($storeId); return $this->success($res); }
public function updateBusinessHours() { $storeId = $this->request->input('store_id'); $isRest = $this->request->input('is_rest',''); $time1 = $this->request->input('time1',''); $time2 = $this->request->input('time2',''); $time3 = $this->request->input('time3',''); $time4 = $this->request->input('time4',''); $res = $this->businessHoursService->do($storeId,$isRest,$time1,$time2,$time3,$time4); return $this->success($res); }
public function getGoodsByType() { $storeId = $this->request->input('store_id'); $typeId = $this->request->input('type_id',''); $goods = $this->goodsService->getByType($storeId,$typeId); return $this->success($goods); }
public function getList() { $userId = $this->request->input('user_id'); $page = $this->request->input('page',1); $pagesize = $this->request->input('pagesize',10); $employees = Employees::query() ->where('user_id',$userId) ->whereJsonContains('position', '30') ->first(); if(empty($employees)){ return $this->success(['personnel' => false]); } $res = $this->storeService->getList($employees->market_id,$page,$pagesize); return $this->success($res); }
public function getCategory() { $storeId = $this->request->input('store_id'); $res = $data['goods_types'] = $this->categoryService->allForStoreIncludeOff($storeId); return $this->success(['goods_types' => $res]); }
public function getListByMarketId() { $marketId = $this->request->input('market_id'); $page = $this->request->input('page',1); $pagesize = $this->request->input('pagesize',10); $res = $this->storeService->getListByMarketId($marketId,$page,$pagesize); return $this->success($res); }
public function updateIsRest() { $storeId = $this->request->input('store_id'); $res = $this->storeService->updateIsRest($storeId); return $this->success($res); }}
|