Droptopool.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\command;
  3. use think\console\Command;
  4. use think\console\Input;
  5. use think\console\Output;
  6. use app\model\Customer;
  7. class Droptopool extends Command
  8. {
  9. protected function configure()
  10. {
  11. $this->setName('droptopool')
  12. ->setDescription('drop to pool everyday night');
  13. }
  14. protected function execute(Input $input, Output $output)
  15. {
  16. $where = [];
  17. $records = Customer::where($where)->select();
  18. foreach($records as $item){
  19. //过滤已签单客户,不掉公
  20. if($item->state == "签单"){
  21. continue;
  22. }
  23. //过滤已到访客户,并掉公
  24. if ($item->state == "已到访") {
  25. $protect_days_num = pubpoolSetting('arrived');
  26. }
  27. //过滤已量房客户,并掉公
  28. if($item->state == "已量房"){
  29. $protect_days_num = pubpoolSetting('measured');
  30. }
  31. //过滤已下定客户,并掉公
  32. if($item->state == "交定"){
  33. $protect_days_num = pubpoolSetting('deposited');
  34. }
  35. //过滤未联系客户,并掉公
  36. if($item->state == "待确认"){
  37. $protect_days_num = pubpoolSetting('notouched');
  38. }
  39. if((int)$protect_days_num > 0){
  40. $time_til = time() + (int)$protect_days_num * 86400;
  41. $enddate = ($item->protected_to)?$item->protected_to:date('Y-m-d H:i:s', $time_til);
  42. if(date('Y-m-d H:i:s', time()) > $enddate){
  43. $org_id = knnPubPool($item->org_id);
  44. Customer::where('id',$item->id)->update(['employee_id'=> NULL, 'org_id'=>$org_id, 'protected_to' => NULL]);
  45. $output->writeln($item->name." 回收至公海");
  46. }
  47. }
  48. }
  49. }
  50. }