From 1cf1c31ecde7a801a68b2d4589450f97985821ba Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 5 Sep 2020 18:54:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=AE=B6=E8=90=A5=E4=B8=9A=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/StoreController.php | 25 +++++++++++++++ .../Implementations/BusinessHoursService.php | 31 +++++++++++++++++++ .../BusinessHoursServiceInterface.php | 12 +++++++ config/autoload/dependencies.php | 1 + config/routes.php | 2 ++ 5 files changed, 71 insertions(+) create mode 100644 app/Service/v3/Implementations/BusinessHoursService.php create mode 100644 app/Service/v3/Interfaces/BusinessHoursServiceInterface.php diff --git a/app/Controller/v3/StoreController.php b/app/Controller/v3/StoreController.php index 5ace039..aee3b4d 100644 --- a/app/Controller/v3/StoreController.php +++ b/app/Controller/v3/StoreController.php @@ -9,6 +9,7 @@ use App\Service\v3\Interfaces\CollectStoreServiceInterface; 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 { @@ -31,6 +32,12 @@ class StoreController extends BaseController */ protected $collectService; + /** + * @Inject + * @var BusinessHoursServiceInterface + */ + protected $businessHoursService; + /** * 商户详情页 * 1、商户id用来查询的,还要有user_id @@ -48,4 +55,22 @@ class StoreController extends BaseController $data['goods_types'] = $this->categoryService->allForStore($params['store_id']); 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'); + $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,$time1,$time2,$time3,$time4); + return $this->success($res); + } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/BusinessHoursService.php b/app/Service/v3/Implementations/BusinessHoursService.php new file mode 100644 index 0000000..82db352 --- /dev/null +++ b/app/Service/v3/Implementations/BusinessHoursService.php @@ -0,0 +1,31 @@ +find($storeId); + $store->time1 = $time1; + $store->time2 = $time2; + $store->time3 = $time3; + $store->time4 = $time4; + return $store->save(); + } + + public function check($storeId) + { + $res = Store::query()->select('is_rest','time1','time2','time3','time4')->find($storeId); + return $res; + } + + public function undo() + { + // TODO: Implement undo() method. + } +} \ No newline at end of file diff --git a/app/Service/v3/Interfaces/BusinessHoursServiceInterface.php b/app/Service/v3/Interfaces/BusinessHoursServiceInterface.php new file mode 100644 index 0000000..0fd0a53 --- /dev/null +++ b/app/Service/v3/Interfaces/BusinessHoursServiceInterface.php @@ -0,0 +1,12 @@ + \App\Service\v3\Implementations\CouponRecService::class, \App\Service\v3\Interfaces\PaymentServiceInterface::class => \App\Service\v3\Implementations\PaymentService::class, \App\Service\v3\Interfaces\WithdrawalListServiceInterface::class => \App\Service\v3\Implementations\WithdrawalListService::class, + \App\Service\v3\Interfaces\BusinessHoursServiceInterface::class => \App\Service\v3\Implementations\BusinessHoursService::class, ]; diff --git a/config/routes.php b/config/routes.php index 4acfd98..11536d7 100644 --- a/config/routes.php +++ b/config/routes.php @@ -118,4 +118,6 @@ Router::addGroup('/v3/', function () { Router::post('orderOnline/add', 'App\Controller\v3\OrderOnlineController@add'); Router::post('store/storeWithdrawalList', 'App\Controller\v3\BalanceStatementController@getWithdrawalListByStore'); Router::post('payment/wechatpayOnline', 'App\Controller\v3\PaymentController@wechatpayOnline'); + Router::post('store/getBusinessHours', 'App\Controller\v3\StoreController@getBusinessHours'); + Router::post('store/updateBusinessHours', 'App\Controller\v3\StoreController@updateBusinessHours'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]); \ No newline at end of file