Orders.php 965 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. if($config){
  31. $list = Db::name('config_org')
  32. ->where('config_id',$config['id'])
  33. ->where('value',1)
  34. ->column('org_id');
  35. foreach ($list as $k=>$v){
  36. queue_push(json_encode(['org_id'=>$v]),3);
  37. }
  38. }
  39. }
  40. }