作者 赵彬吉

update

@@ -352,7 +352,7 @@ class RelayInquiry extends Command @@ -352,7 +352,7 @@ class RelayInquiry extends Command
352 // 随机访问1-6个页面 352 // 随机访问1-6个页面
353 $deep = rand(1,6); 353 $deep = rand(1,6);
354 if($deep > 2) { 354 if($deep > 2) {
355 - $visit_urls = Arr::random($all_urls, rand(1, count($all_urls) > 3 ? 3 : count($all_urls))); 355 + $visit_urls = Arr::random($all_urls, rand(1, count($all_urls) > 4 ? 4 : count($all_urls)));
356 $urls = array_merge($urls, $visit_urls); 356 $urls = array_merge($urls, $visit_urls);
357 } 357 }
358 if($deep > 1) { 358 if($deep > 1) {
@@ -8,6 +8,7 @@ use App\Models\Inquiry\ReInquiryForm; @@ -8,6 +8,7 @@ use App\Models\Inquiry\ReInquiryForm;
8 use Illuminate\Console\Command; 8 use Illuminate\Console\Command;
9 use Illuminate\Support\Facades\Http; 9 use Illuminate\Support\Facades\Http;
10 use Illuminate\Support\Facades\Log; 10 use Illuminate\Support\Facades\Log;
  11 +use Illuminate\Support\Facades\Redis;
11 12
12 /** 13 /**
13 * Class postInquiry 14 * Class postInquiry
@@ -50,6 +51,18 @@ class postInquiry extends Command @@ -50,6 +51,18 @@ class postInquiry extends Command
50 } 51 }
51 // 询盘数据入库 52 // 询盘数据入库
52 foreach ($list as $key => $val) { 53 foreach ($list as $key => $val) {
  54 + //加个锁 避免重复执行
  55 + $lockKey = 're_inquiry_detail_log_lock_' . $val->id;
  56 + if(!Redis::setnx($lockKey, 1)){
  57 + continue;
  58 + }
  59 + Redis::expire($lockKey, 60);
  60 +
  61 + $log = ReInquiryDetailLog::find($val->id);
  62 + if($log->status != ReInquiryDetailLog::STATUS_INIT){
  63 + continue;
  64 + }
  65 +
53 $this->output('开始执行' . $val->id); 66 $this->output('开始执行' . $val->id);
54 try { 67 try {
55 $detail = ReInquiryDetail::find($val['detail_id']); 68 $detail = ReInquiryDetail::find($val['detail_id']);