作者 周海龙

合并分支 'zhl' 到 'master'

修改部分流程



查看合并请求 !1120
... ... @@ -71,31 +71,50 @@ class SyncInquiryRelay extends Command
*/
public function getInquirySzcm()
{
$max_origin_key = InquiryInfo::where('type', 4)->orderBy('origin_key', 'desc')->value('origin_key');
$max_origin_key = InquiryInfo::where('type', InquiryInfo::TYPE_SPIDER)->orderBy('origin_key', 'desc')->value('origin_key');
if ($max_origin_key) {
$start_id = $max_origin_key + 1;
} else {
$start_id = 65029;
}
// TODO 由于该渠道数据不规则, 可能某个ID获取不到数据, 无法判断是因为已经没有数据了, 还是因为解析问题导致, 所以当未获取到数据时, 多向后取几次数据, 连续几次没有数据, 就认为已经获取到最大数据。
$service = new InquiryRelayService();
$pre = 0;
while ($start_id > 0) {
$result = $service->getInquirySzcm($start_id);
if (empty($result) && $pre <= 3) {
$start_id++;
$pre++;
continue;
}
if ($result) {
$this->saveDate($result, 4);
$start_id += 1;
} else {
$start_id = 0;
$this->saveDate($result, InquiryInfo::TYPE_SPIDER);
$start_id++;
$pre = 0;
}
if ($pre > 3)
break;
}
return true;
}
/**
* 询盘数据入库
* @param $data
* @param $type
* @return bool
*/
public function saveDate($data, $type)
{
$model = new InquiryInfo();
$message_sign = md5($data['name'] . $data['email'] . $data['phone'] . $data['ip'] . $data['time']);
$inquiry_info = $model->where('message_sign', $message_sign)->first();
if (!$inquiry_info) {
if ($inquiry_info)
return true;
//没有IP,根据submit_country获取
if (empty($data['ip']) && isset($data['submit_country']) && $data['submit_country']) {
$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
}
$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']);
}
return true;
}
/**
... ...