AutoOrderProfitsharingListen.php 830 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace ln\listens;
  3. use app\common\repositories\store\order\StoreOrderProfitsharingRepository;
  4. use ln\interfaces\ListenerInterface;
  5. use ln\jobs\OrderProfitsharingJob;
  6. use ln\services\TimerService;
  7. use think\facade\Queue;
  8. class AutoOrderProfitsharingListen extends TimerService implements ListenerInterface
  9. {
  10. public function handle($event): void
  11. {
  12. $this->tick(1000 * 60 * 20, function () {
  13. request()->clearCache();
  14. $day = (int)systemConfig('sys_refund_timer') ?: 15;
  15. $time = strtotime('-' . $day . ' day');
  16. $ids = app()->make(StoreOrderProfitsharingRepository::class)->getAutoProfitsharing(date('Y-m-d H:i:s', $time));
  17. foreach ($ids as $id) {
  18. Queue::push(OrderProfitsharingJob::class, $id);
  19. }
  20. });
  21. }
  22. }