0
0

Orders.php 906 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\cron;
  3. use app\common\model\Config;
  4. use app\common\model\Orders as OrderModel;
  5. use think\Db;
  6. use yunwuxin\cron\Task;
  7. //订单自动派单
  8. class Orders extends Task
  9. {
  10. public function configure()
  11. {
  12. $this->everyMinute(); //每分钟执行一次
  13. }
  14. /**
  15. * 执行任务
  16. * @return mixed
  17. */
  18. protected function execute()
  19. {
  20. try{
  21. $this->autoSend();
  22. }catch (\Exception $e){
  23. trace($e->getMessage());
  24. }
  25. }
  26. public function autoSend(){
  27. $config = Db::name('config')
  28. ->where('name','org_auto_send')
  29. ->find();
  30. $list = Db::name('config_org')
  31. ->where('config_id',$config['id'])
  32. ->where('value',1)
  33. ->column('org_id');
  34. foreach ($list as $k=>$v){
  35. queue_push(json_encode(['org_id'=>$v]),3);
  36. }
  37. }
  38. }