You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

64 lines
1.6 KiB

<?php
namespace App\Service\v3\Implementations;
use App\Model\v3\Market;
use App\Model\v3\Store;
use App\Service\v3\Interfaces\StoreServiceInterface;
class StoreService implements StoreServiceInterface
{
public function do()
{
// TODO: Implement do() method.
}
public function check($storeId)
{
$store = Store::query()->where([
['id','=',$storeId],
['is_rest','=',0],
['status','=',2]
])
->select('time1','time2','time3','time4')
->first();
if(!empty($store)){
$nowTime = time();
$startTime = strtotime(($store->time1));
if(!empty($store->time3) && !empty($store->time4)){
$time4 = strtotime(($store->time4));
$endTime = $time4;
}else{
$time2 = strtotime(($store->time2));
$endTime = $time2;
}
if($nowTime > $startTime && $nowTime < $endTime){
return true;
}
}
return false;
}
public function undo()
{
// TODO: Implement undo() method.
}
public function detail($storeId)
{
return Store::query()
->with('market')
->where('id',$storeId)
->first();
}
public function getList($marketId, $page=1, $pagesize=10)
{
return Market::query()->with(['stores' => function($query) use ($pagesize){
$stores = $query->paginate($pagesize);
return $stores['data'];
}])->where('id',$marketId)->get();
}
}