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.

63 lines
1.6 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Service\v3\Implementations;
  3. use App\Model\v3\Market;
  4. use App\Model\v3\Store;
  5. use App\Service\v3\Interfaces\StoreServiceInterface;
  6. class StoreService implements StoreServiceInterface
  7. {
  8. public function do()
  9. {
  10. // TODO: Implement do() method.
  11. }
  12. public function check($storeId)
  13. {
  14. $store = Store::query()->where([
  15. ['id','=',$storeId],
  16. ['is_rest','=',0],
  17. ['status','=',2]
  18. ])
  19. ->select('time1','time2','time3','time4')
  20. ->first();
  21. if(!empty($store)){
  22. $nowTime = time();
  23. $startTime = strtotime(($store->time1));
  24. if(!empty($store->time3) && !empty($store->time4)){
  25. $time4 = strtotime(($store->time4));
  26. $endTime = $time4;
  27. }else{
  28. $time2 = strtotime(($store->time2));
  29. $endTime = $time2;
  30. }
  31. if($nowTime > $startTime && $nowTime < $endTime){
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. public function undo()
  38. {
  39. // TODO: Implement undo() method.
  40. }
  41. public function detail($storeId)
  42. {
  43. return Store::query()
  44. ->with('market')
  45. ->where('id',$storeId)
  46. ->first();
  47. }
  48. public function getList($marketId, $page=1, $pagesize=10)
  49. {
  50. return Market::query()->with(['stores' => function($query) use ($pagesize){
  51. $stores = $query->paginate($pagesize);
  52. return $stores['data'];
  53. }])->where('id',$marketId)->get();
  54. }
  55. }