LocationLosTraitModel.php 701 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Mead
  5. * Date: 2019/9/4
  6. * Time: 9:36 AM
  7. */
  8. namespace App\Models;
  9. trait LocationLosTraitModel
  10. {
  11. // private static $time_find_order_tagss = 'time_find_order:';
  12. public function byTimeGetOrder($time, $box_no)
  13. {
  14. $where['box_no'] = $box_no;
  15. $where['box_time'] = ['$lt' => $time];
  16. $options['sort'] = ['created_at' => -1];
  17. $options['limit'] = 5;
  18. $logs = $this->mongo->location_logs->find($where, $options);
  19. $log = false;
  20. foreach ($logs as $item) {
  21. if ($item['order_id']) {
  22. $log = $item;
  23. break;
  24. }
  25. }
  26. return $log;
  27. }
  28. }