合并分支 'zhl' 到 'master'
修改部分流程 查看合并请求 !1120
正在显示
1 个修改的文件
包含
26 行增加
和
7 行删除
| @@ -71,31 +71,50 @@ class SyncInquiryRelay extends Command | @@ -71,31 +71,50 @@ class SyncInquiryRelay extends Command | ||
| 71 | */ | 71 | */ |
| 72 | public function getInquirySzcm() | 72 | public function getInquirySzcm() |
| 73 | { | 73 | { |
| 74 | - $max_origin_key = InquiryInfo::where('type', 4)->orderBy('origin_key', 'desc')->value('origin_key'); | 74 | + $max_origin_key = InquiryInfo::where('type', InquiryInfo::TYPE_SPIDER)->orderBy('origin_key', 'desc')->value('origin_key'); |
| 75 | if ($max_origin_key) { | 75 | if ($max_origin_key) { |
| 76 | $start_id = $max_origin_key + 1; | 76 | $start_id = $max_origin_key + 1; |
| 77 | } else { | 77 | } else { |
| 78 | $start_id = 65029; | 78 | $start_id = 65029; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | + // TODO 由于该渠道数据不规则, 可能某个ID获取不到数据, 无法判断是因为已经没有数据了, 还是因为解析问题导致, 所以当未获取到数据时, 多向后取几次数据, 连续几次没有数据, 就认为已经获取到最大数据。 | ||
| 81 | $service = new InquiryRelayService(); | 82 | $service = new InquiryRelayService(); |
| 83 | + $pre = 0; | ||
| 82 | while ($start_id > 0) { | 84 | while ($start_id > 0) { |
| 83 | $result = $service->getInquirySzcm($start_id); | 85 | $result = $service->getInquirySzcm($start_id); |
| 86 | + if (empty($result) && $pre <= 3) { | ||
| 87 | + $start_id++; | ||
| 88 | + $pre++; | ||
| 89 | + continue; | ||
| 90 | + } | ||
| 91 | + | ||
| 84 | if ($result) { | 92 | if ($result) { |
| 85 | - $this->saveDate($result, 4); | ||
| 86 | - $start_id += 1; | ||
| 87 | - } else { | ||
| 88 | - $start_id = 0; | 93 | + $this->saveDate($result, InquiryInfo::TYPE_SPIDER); |
| 94 | + $start_id++; | ||
| 95 | + $pre = 0; | ||
| 89 | } | 96 | } |
| 97 | + | ||
| 98 | + if ($pre > 3) | ||
| 99 | + break; | ||
| 90 | } | 100 | } |
| 101 | + return true; | ||
| 91 | } | 102 | } |
| 92 | 103 | ||
| 104 | + /** | ||
| 105 | + * 询盘数据入库 | ||
| 106 | + * @param $data | ||
| 107 | + * @param $type | ||
| 108 | + * @return bool | ||
| 109 | + */ | ||
| 93 | public function saveDate($data, $type) | 110 | public function saveDate($data, $type) |
| 94 | { | 111 | { |
| 95 | $model = new InquiryInfo(); | 112 | $model = new InquiryInfo(); |
| 96 | $message_sign = md5($data['name'] . $data['email'] . $data['phone'] . $data['ip'] . $data['time']); | 113 | $message_sign = md5($data['name'] . $data['email'] . $data['phone'] . $data['ip'] . $data['time']); |
| 97 | $inquiry_info = $model->where('message_sign', $message_sign)->first(); | 114 | $inquiry_info = $model->where('message_sign', $message_sign)->first(); |
| 98 | - if (!$inquiry_info) { | 115 | + if ($inquiry_info) |
| 116 | + return true; | ||
| 117 | + | ||
| 99 | //没有IP,根据submit_country获取 | 118 | //没有IP,根据submit_country获取 |
| 100 | if (empty($data['ip']) && isset($data['submit_country']) && $data['submit_country']) { | 119 | if (empty($data['ip']) && isset($data['submit_country']) && $data['submit_country']) { |
| 101 | $chinese_name = DB::table('gl_world_country_city')->where('pid', 0)->where('iso2', $data['submit_country'])->value('chinese_name'); | 120 | $chinese_name = DB::table('gl_world_country_city')->where('pid', 0)->where('iso2', $data['submit_country'])->value('chinese_name'); |
| @@ -140,7 +159,7 @@ class SyncInquiryRelay extends Command | @@ -140,7 +159,7 @@ class SyncInquiryRelay extends Command | ||
| 140 | } | 159 | } |
| 141 | 160 | ||
| 142 | $model->createInquiry($data['name'], $data['phone'], $data['email'], $data['ip'], $country, $data['message'], $message_cn, $type, $data['time'], $data['refer'], $data['title'], $keywords, $message_sign, $data['origin_key'], $data['image']); | 161 | $model->createInquiry($data['name'], $data['phone'], $data['email'], $data['ip'], $country, $data['message'], $message_cn, $type, $data['time'], $data['refer'], $data['title'], $keywords, $message_sign, $data['origin_key'], $data['image']); |
| 143 | - } | 162 | + return true; |
| 144 | } | 163 | } |
| 145 | 164 | ||
| 146 | /** | 165 | /** |
-
请 注册 或 登录 后发表评论