Browse Source

商家营业时间

master
Lemon 5 years ago
parent
commit
1cf1c31ecd
  1. 25
      app/Controller/v3/StoreController.php
  2. 31
      app/Service/v3/Implementations/BusinessHoursService.php
  3. 12
      app/Service/v3/Interfaces/BusinessHoursServiceInterface.php
  4. 1
      config/autoload/dependencies.php
  5. 2
      config/routes.php

25
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);
}
}

31
app/Service/v3/Implementations/BusinessHoursService.php

@ -0,0 +1,31 @@
<?php
namespace App\Service\v3\Implementations;
use App\Model\v3\Store;
use \App\Service\v3\Interfaces\BusinessHoursServiceInterface;
class BusinessHoursService implements BusinessHoursServiceInterface
{
public function do($storeId,$time1,$time2,$time3 = '',$time4 = '')
{
$store = Store::query()->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.
}
}

12
app/Service/v3/Interfaces/BusinessHoursServiceInterface.php

@ -0,0 +1,12 @@
<?php
namespace App\Service\v3\Interfaces;
interface BusinessHoursServiceInterface
{
public function do($storeId,$time1,$time2,$time3 = '',$time4 = '');
public function check($storeId);
public function undo();
}

1
config/autoload/dependencies.php

@ -66,4 +66,5 @@ return [
\App\Service\v3\Interfaces\CouponRecServiceInterface::class => \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,
];

2
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]]);
Loading…
Cancel
Save