作者 赵彬吉

update

... ... @@ -60,8 +60,8 @@ class InquiryFormData extends Base
unset($data['__amp_source_origin']);
}
$sign = md5(json_encode($sign_data));
//5分钟内是否有重复数据
$is_exist = self::where('sign', $sign)->where('created_at', '>', date('Y-m-d H:i:s', strtotime('-5 minute')))->first();
//30分钟内是否有重复数据
$is_exist = self::where('sign', $sign)->where('created_at', '>', date('Y-m-d H:i:s', strtotime('-30 minute')))->first();
if($is_exist){
return 0;
}
... ...
... ... @@ -17,6 +17,7 @@ use App\Models\SyncSubmitTask\SyncSubmitTask;
use App\Models\Visit\Visit;
use App\Models\Workchat\MessagePush;
use App\Utils\LogUtils;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\URL;
... ... @@ -188,6 +189,22 @@ class SyncSubmitTaskService
*/
public function inquiry($data, $date, $task_id, $traffic = 0)
{
//ip 一分钟请求3次 就半小时内不写入这个ip了
$ip_cache_key = "inquiry_{$data['project_id']}_{$data['ip']}";
$ip_lock_cache_key = "inquiry_{$data['project_id']}_{$data['ip']}_lock";
if (!Cache::get($ip_cache_key)) {
Cache::put($ip_cache_key, 0, 60);
}
$num = Cache::increment($ip_cache_key);
if($num > 2){
//这个ip 锁半个小时
Cache::put($ip_lock_cache_key, 1, 1800);
}
if(Cache::get($ip_lock_cache_key)){
Log::channel('inquiry')->info($task_id . '询盘ip重复锁定', [$data]);
return true;
}
//数组key转为小写
$data['data'] = array_change_key_case($data['data'], CASE_LOWER);
... ...