正在显示
1 个修改的文件
包含
34 行增加
和
25 行删除
| @@ -108,39 +108,48 @@ class InquiryForwardLogic extends BaseLogic | @@ -108,39 +108,48 @@ class InquiryForwardLogic extends BaseLogic | ||
| 108 | 108 | ||
| 109 | //获取发送时间 | 109 | //获取发送时间 |
| 110 | if (isset($this->param['inquiry_date']) && $this->param['inquiry_date']) { | 110 | if (isset($this->param['inquiry_date']) && $this->param['inquiry_date']) { |
| 111 | - //填写了时间 | ||
| 112 | - $date = $this->param['inquiry_date']; | 111 | + //填写了时间,直接使用 |
| 112 | + $start_at = $this->param['inquiry_date']; | ||
| 113 | } else { | 113 | } else { |
| 114 | //未填写时间 | 114 | //未填写时间 |
| 115 | - $hour = date('H'); | ||
| 116 | - if ($hour < 18) { | ||
| 117 | - //当前时间为18点前 | ||
| 118 | - $day = date('Y-m-d'); | ||
| 119 | - $start_hour = $hour < 10 ? 10 : $hour; | 115 | + //1.根据时差获取当地随机10-18点时间 |
| 116 | + $timezoneModel = new AreaTimezone(); | ||
| 117 | + $country_area = $timezoneModel->read(['name' => $info['country']], ['diff']); | ||
| 118 | + $diff = $country_area ? $country_area['diff'] : 0; | ||
| 119 | + if ($diff > 0) { | ||
| 120 | + $area_time = date('Y-m-d H:i:s', strtotime($now . ' +' . $diff . ' hours')); | ||
| 121 | + } elseif ($diff < 0) { | ||
| 122 | + $area_time = date('Y-m-d H:i:s', strtotime($now . ' -' . abs($diff) . ' hours')); | ||
| 120 | } else { | 123 | } else { |
| 121 | - //当前时间为18点后,顺延一天 | ||
| 122 | - $day = date('Y-m-d', strtotime('+1 day')); | ||
| 123 | - $start_hour = 10; | 124 | + $area_time = $now; |
| 124 | } | 125 | } |
| 125 | - $start_time = strtotime($day . ' ' . $start_hour . ':00:00'); | ||
| 126 | - $end_time = strtotime($day . ' 18:00:00'); | 126 | + $area_timestamp = strtotime($area_time); |
| 127 | + $area_hour = date('H', $area_timestamp); | ||
| 128 | + if ($area_hour < 18) { | ||
| 129 | + //当地时间为18点前 | ||
| 130 | + $area_day = date('Y-m-d', $area_timestamp); | ||
| 131 | + $area_start_hour = $area_hour < 10 ? 10 : $area_hour; | ||
| 132 | + } else { | ||
| 133 | + //当地时间为18点后,顺延一天 | ||
| 134 | + $area_day = date('Y-m-d', strtotime($area_time . ' +1 day')); | ||
| 135 | + $area_start_hour = 10; | ||
| 136 | + } | ||
| 137 | + $start_time = strtotime($area_day . ' ' . $area_start_hour . ':00:00'); | ||
| 138 | + $end_time = strtotime($area_day . ' 18:00:00'); | ||
| 127 | $random_timestamp = mt_rand($start_time, $end_time); | 139 | $random_timestamp = mt_rand($start_time, $end_time); |
| 128 | - $date = date('Y-m-d H:i:s', $random_timestamp); | ||
| 129 | - } | 140 | + $area_date = date('Y-m-d H:i:s', $random_timestamp); |
| 130 | 141 | ||
| 131 | - //根据时区换算发送的国内时间 | ||
| 132 | - $timezoneModel = new AreaTimezone(); | ||
| 133 | - $country_area = $timezoneModel->read(['name' => $info['country']], ['diff']); | ||
| 134 | - $diff = $country_area ? $country_area['diff'] : 0; | ||
| 135 | - if ($diff > 0) { | ||
| 136 | - $start_at = date('Y-m-d H:i:s', strtotime($date . ' -' . $diff . ' hours')); | ||
| 137 | - } elseif ($diff < 0) { | ||
| 138 | - $start_at = date('Y-m-d H:i:s', strtotime($date . ' +' . abs($diff) . ' hours')); | ||
| 139 | - } else { | ||
| 140 | - $start_at = $date; | 142 | + //2.再根据时差将随机生成的当地时间换算成国内时间 |
| 143 | + if ($diff > 0) { | ||
| 144 | + $start_at = date('Y-m-d H:i:s', strtotime($area_date . ' -' . $diff . ' hours')); | ||
| 145 | + } elseif ($diff < 0) { | ||
| 146 | + $start_at = date('Y-m-d H:i:s', strtotime($area_date . ' +' . abs($diff) . ' hours')); | ||
| 147 | + } else { | ||
| 148 | + $start_at = $area_date; | ||
| 149 | + } | ||
| 141 | } | 150 | } |
| 142 | 151 | ||
| 143 | - //换算后国内时间小于当前时间,使用当前时间 | 152 | + //换算后的国内时间小于当前时间,使用当前时间 |
| 144 | if ($start_at < $now) { | 153 | if ($start_at < $now) { |
| 145 | $start_at = $now; | 154 | $start_at = $now; |
| 146 | } | 155 | } |
-
请 注册 或 登录 后发表评论