作者 刘锟

update

... ... @@ -108,39 +108,48 @@ class InquiryForwardLogic extends BaseLogic
//获取发送时间
if (isset($this->param['inquiry_date']) && $this->param['inquiry_date']) {
//填写了时间
$date = $this->param['inquiry_date'];
//填写了时间,直接使用
$start_at = $this->param['inquiry_date'];
} else {
//未填写时间
$hour = date('H');
if ($hour < 18) {
//当前时间为18点前
$day = date('Y-m-d');
$start_hour = $hour < 10 ? 10 : $hour;
//1.根据时差获取当地随机10-18点时间
$timezoneModel = new AreaTimezone();
$country_area = $timezoneModel->read(['name' => $info['country']], ['diff']);
$diff = $country_area ? $country_area['diff'] : 0;
if ($diff > 0) {
$area_time = date('Y-m-d H:i:s', strtotime($now . ' +' . $diff . ' hours'));
} elseif ($diff < 0) {
$area_time = date('Y-m-d H:i:s', strtotime($now . ' -' . abs($diff) . ' hours'));
} else {
$area_time = $now;
}
$area_timestamp = strtotime($area_time);
$area_hour = date('H', $area_timestamp);
if ($area_hour < 18) {
//当地时间为18点前
$area_day = date('Y-m-d', $area_timestamp);
$area_start_hour = $area_hour < 10 ? 10 : $area_hour;
} else {
//当前时间为18点后,顺延一天
$day = date('Y-m-d', strtotime('+1 day'));
$start_hour = 10;
//当地时间为18点后,顺延一天
$area_day = date('Y-m-d', strtotime($area_time . ' +1 day'));
$area_start_hour = 10;
}
$start_time = strtotime($day . ' ' . $start_hour . ':00:00');
$end_time = strtotime($day . ' 18:00:00');
$start_time = strtotime($area_day . ' ' . $area_start_hour . ':00:00');
$end_time = strtotime($area_day . ' 18:00:00');
$random_timestamp = mt_rand($start_time, $end_time);
$date = date('Y-m-d H:i:s', $random_timestamp);
}
$area_date = date('Y-m-d H:i:s', $random_timestamp);
//根据时区换算发送的国内时间
$timezoneModel = new AreaTimezone();
$country_area = $timezoneModel->read(['name' => $info['country']], ['diff']);
$diff = $country_area ? $country_area['diff'] : 0;
//2.再根据时差将随机生成的当地时间换算成国内时间
if ($diff > 0) {
$start_at = date('Y-m-d H:i:s', strtotime($date . ' -' . $diff . ' hours'));
$start_at = date('Y-m-d H:i:s', strtotime($area_date . ' -' . $diff . ' hours'));
} elseif ($diff < 0) {
$start_at = date('Y-m-d H:i:s', strtotime($date . ' +' . abs($diff) . ' hours'));
$start_at = date('Y-m-d H:i:s', strtotime($area_date . ' +' . abs($diff) . ' hours'));
} else {
$start_at = $date;
$start_at = $area_date;
}
}
//换算后国内时间小于当前时间,使用当前时间
//换算后国内时间小于当前时间,使用当前时间
if ($start_at < $now) {
$start_at = $now;
}
... ...