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.

56 lines
1.6 KiB

5 years ago
5 years ago
  1. <?php
  2. namespace App\Service\v3\Implementations;
  3. use App\Model\v3\ShoppingCart;
  4. use App\Model\v3\Store;
  5. use App\Service\v3\Interfaces\AppointmentTimeServiceInterface;
  6. use phpDocumentor\Reflection\Types\Object_;
  7. class AppointmentTimeService implements AppointmentTimeServiceInterface
  8. {
  9. public function do()
  10. {
  11. return [
  12. '尽快送达',
  13. '08:30 - 09:00',
  14. '09:00 - 09:30',
  15. '09:30 - 10:00',
  16. '10:00 - 10:30'
  17. ];
  18. }
  19. public function check()
  20. {
  21. // TODO: Implement check() method.
  22. }
  23. public function undo()
  24. {
  25. // TODO: Implement undo() method.
  26. }
  27. public function get($shopcartIds)
  28. {
  29. $shopcartIds = explode(',',$shopcartIds);
  30. $sotreIds = ShoppingCart::query()->whereIn('id',$shopcartIds)->pluck('store_id');
  31. $stores = Store::query()->whereIn('id',$sotreIds)->get()->toArray();
  32. // return $stores;
  33. $time1 = array_values(array_column($stores,'time1'));
  34. $time2 = array_values(array_column($stores,'time2'));
  35. $time3 = array_values(array_column($stores,'time3'));
  36. $time4 = array_values(array_column($stores,'time4'));
  37. $startTimeArr = array_merge($time1,$time3);
  38. $endTimeArr = array_merge($time2,$time4);
  39. array_filter($startTimeArr);
  40. array_filter($endTimeArr);
  41. $startTime = max($startTimeArr);
  42. $endTime = min($endTimeArr);
  43. // foreach ($stores as $store){
  44. //
  45. // }
  46. return [
  47. 'start_time' => $startTimeArr,
  48. 'end_time' => $endTimeArr
  49. ];
  50. }
  51. }