Merge remote-tracking branch 'origin/master' into akun
正在显示
20 个修改的文件
包含
498 行增加
和
82 行删除
| @@ -169,7 +169,6 @@ class RelayInquiry extends Command | @@ -169,7 +169,6 @@ class RelayInquiry extends Command | ||
| 169 | while (true) { | 169 | while (true) { |
| 170 | $inquiry = $this->getInquiry(); | 170 | $inquiry = $this->getInquiry(); |
| 171 | if ($inquiry->isEmpty()){ | 171 | if ($inquiry->isEmpty()){ |
| 172 | - $this->logChannel()->info('未发现待处理询盘!'); | ||
| 173 | $this->output('未发现待处理询盘!'); | 172 | $this->output('未发现待处理询盘!'); |
| 174 | sleep(60); | 173 | sleep(60); |
| 175 | continue; | 174 | continue; |
| @@ -272,10 +271,25 @@ class RelayInquiry extends Command | @@ -272,10 +271,25 @@ class RelayInquiry extends Command | ||
| 272 | public function relayDetail($task, $form) | 271 | public function relayDetail($task, $form) |
| 273 | { | 272 | { |
| 274 | $this->output('获取转发对象'); | 273 | $this->output('获取转发对象'); |
| 274 | + | ||
| 275 | + //是否有必选的 | ||
| 276 | + $require_data = []; | ||
| 277 | + foreach ($task['target'] as $item){ | ||
| 278 | + if(!empty($item['is_require'])){ | ||
| 279 | + $require_data[] = $item; | ||
| 280 | + } | ||
| 281 | + } | ||
| 282 | + //代理商组 一个组只发一个 | ||
| 283 | + $agent_group = collect($task['target'])->whereNotIn('agent_group', array_column($require_data, 'agent_group'))->groupBy('agent_group'); | ||
| 275 | // 获取转发对象 重置num数量, array_rand数量不足会报错 | 284 | // 获取转发对象 重置num数量, array_rand数量不足会报错 |
| 276 | - $task['num'] = $task['num'] > count($task['target']) ? count($task['target']) : $task['num']; | ||
| 277 | - $relay_target_key = array_rand($task['target'], $task['num']); | ||
| 278 | - if (empty($relay_target_key)) { | 285 | + $task['num'] = $task['num'] - count($require_data); |
| 286 | + $num = $task['num'] > count($agent_group) ? count($agent_group) : $task['num']; | ||
| 287 | + $random_data = $agent_group->keys()->random($num)->map(function ($group) use ($agent_group) { | ||
| 288 | + return $agent_group[$group]->random(); | ||
| 289 | + })->all(); | ||
| 290 | + $random_data = array_merge($require_data, $random_data); | ||
| 291 | + | ||
| 292 | + if (empty($random_data)) { | ||
| 279 | $this->logChannel()->info('当前任务未发现转发对象!', ['广告任务ID:' . $task['id'], '询盘ID:' . $form->id]); | 293 | $this->logChannel()->info('当前任务未发现转发对象!', ['广告任务ID:' . $task['id'], '询盘ID:' . $form->id]); |
| 280 | $form->status = ReInquiryForm::STATUS_FORGO; | 294 | $form->status = ReInquiryForm::STATUS_FORGO; |
| 281 | $form->remark = '当前任务未发现转发对象,广告ID: ' . $form->ad_id . '!'; | 295 | $form->remark = '当前任务未发现转发对象,广告ID: ' . $form->ad_id . '!'; |
| @@ -283,10 +297,10 @@ class RelayInquiry extends Command | @@ -283,10 +297,10 @@ class RelayInquiry extends Command | ||
| 283 | return false; | 297 | return false; |
| 284 | } | 298 | } |
| 285 | 299 | ||
| 286 | - foreach ($relay_target_key as $key) { | 300 | + foreach ($random_data as $item) { |
| 287 | // 推送站点 | 301 | // 推送站点 |
| 288 | - $domain = $task['target'][$key]['url']; | ||
| 289 | - $is_v6 = $task['target'][$key]['is_v6']; | 302 | + $domain = $item['url']; |
| 303 | + $is_v6 = $item['is_v6']; | ||
| 290 | $re_website = 'https://' . $domain . '/'; | 304 | $re_website = 'https://' . $domain . '/'; |
| 291 | 305 | ||
| 292 | $this->output('转发对象:' . $domain); | 306 | $this->output('转发对象:' . $domain); |
| @@ -320,18 +334,29 @@ class RelayInquiry extends Command | @@ -320,18 +334,29 @@ class RelayInquiry extends Command | ||
| 320 | $page_url = [$re_website . 'contact-us/']; | 334 | $page_url = [$re_website . 'contact-us/']; |
| 321 | } | 335 | } |
| 322 | } | 336 | } |
| 337 | + | ||
| 323 | // 所有可用url | 338 | // 所有可用url |
| 324 | $urls = $inquiry_urls = []; | 339 | $urls = $inquiry_urls = []; |
| 325 | - $urls[] = $inquiry_urls[] = $re_website; | 340 | + //入口url 首页30%,单页10%,聚合页60% |
| 341 | + $type = getRandByRatio([30,10,60]); | ||
| 342 | + $inlet = $re_website; | ||
| 343 | + $type == 1 && $inlet = $page_url ? Arr::random($page_url) : $re_website; | ||
| 344 | + $type == 2 && $inlet = $keywords_url ? Arr::random($keywords_url) : $re_website; | ||
| 345 | + $urls[] = $inquiry_urls[] = $inlet; | ||
| 326 | $all_urls = array_merge($urls, $product_url, $product_cate_url, $keywords_url, $page_url); | 346 | $all_urls = array_merge($urls, $product_url, $product_cate_url, $keywords_url, $page_url); |
| 327 | $inquiry_urls = array_merge($urls, $product_cate_url, $keywords_url, $page_url); | 347 | $inquiry_urls = array_merge($urls, $product_cate_url, $keywords_url, $page_url); |
| 328 | 348 | ||
| 329 | - // 随机访问1-3个页面 | ||
| 330 | - $visit_urls = Arr::random($all_urls, rand(1, count($all_urls) > 3 ? 3 : count($all_urls))); | ||
| 331 | - $urls = array_merge($urls, $visit_urls); | ||
| 332 | - // 推送着落页只能是 首页、产品分类、单页面、聚合页 | ||
| 333 | - if(!in_array(end($urls), $inquiry_urls)){ | ||
| 334 | - $urls[] = Arr::random($inquiry_urls); | 349 | + // 随机访问1-6个页面 |
| 350 | + $deep = rand(1,6); | ||
| 351 | + if($deep > 2) { | ||
| 352 | + $visit_urls = Arr::random($all_urls, rand(1, count($all_urls) > 3 ? 3 : count($all_urls))); | ||
| 353 | + $urls = array_merge($urls, $visit_urls); | ||
| 354 | + } | ||
| 355 | + if($deep > 1) { | ||
| 356 | + // 推送着落页只能是 首页、产品分类、单页面、聚合页 | ||
| 357 | + if (!in_array(end($urls), $inquiry_urls)) { | ||
| 358 | + $urls[] = Arr::random($inquiry_urls); | ||
| 359 | + } | ||
| 335 | } | 360 | } |
| 336 | 361 | ||
| 337 | $this->output('获取转发ip'); | 362 | $this->output('获取转发ip'); |
| @@ -352,26 +377,29 @@ class RelayInquiry extends Command | @@ -352,26 +377,29 @@ class RelayInquiry extends Command | ||
| 352 | $country_name = $ip_data->ip_area; | 377 | $country_name = $ip_data->ip_area; |
| 353 | 378 | ||
| 354 | $this->output('转发内容'); | 379 | $this->output('转发内容'); |
| 380 | + $message = $form->message; | ||
| 381 | + $message_id = 0; | ||
| 382 | + //开启文案替换 配置替换或者字符少于4个,直接替换文案 | ||
| 383 | + if($task['is_replace_text'] || strlen($message) <= 4) { | ||
| 384 | + $use_ids = ReInquiryDetail::where(['re_website' => $domain])->where('status', '<>', ReInquiryDetail::STATUS_FAIL)->pluck('text_id')->toArray(); | ||
| 385 | + $text = ReInquiryText::whereNotIn('id', $use_ids)->where('status', ReInquiryText::STATUS_USABLE)->inRandomOrder()->first(); | ||
| 386 | + $message = $text->content; | ||
| 387 | + $message_id = $text->id; | ||
| 388 | + // 获取后,使用次数+1 | ||
| 389 | + $text->use_time += 1; | ||
| 390 | + $text->save(); | ||
| 391 | + | ||
| 392 | + //原内容非英语,转为对应语种 | ||
| 393 | + if (is_numeric($form->message)) { //数字会被识别为中文 | ||
| 394 | + $lang = 'en'; | ||
| 395 | + } else { | ||
| 396 | + $translateSl = Translate::translateSl($form->message); | ||
| 397 | + $lang = $translateSl['texts']['sl'] ?? 'en'; | ||
| 398 | + } | ||
| 355 | 399 | ||
| 356 | - // 通过字符数量区分, 改成完全获取内置询盘内容 | ||
| 357 | - $use_ids = ReInquiryDetail::where(['re_website' => $domain])->where('status', '<>', ReInquiryDetail::STATUS_FAIL)->pluck('text_id')->toArray(); | ||
| 358 | - $text = ReInquiryText::whereNotIn('id', $use_ids)->where('status', ReInquiryText::STATUS_USABLE)->inRandomOrder()->first(); | ||
| 359 | - $message = $text->content; | ||
| 360 | - $message_id = $text->id; | ||
| 361 | - // 获取后,使用次数+1 | ||
| 362 | - $text->use_time += 1; | ||
| 363 | - $text->save(); | ||
| 364 | - | ||
| 365 | - //原内容非英语,转为对应语种 | ||
| 366 | - if(is_numeric($form->message)){ //数字会被识别为中文 | ||
| 367 | - $lang = 'en'; | ||
| 368 | - }else{ | ||
| 369 | - $translateSl = Translate::translateSl($form->message); | ||
| 370 | - $lang = $translateSl['texts']['sl'] ?? 'en'; | ||
| 371 | - } | ||
| 372 | - | ||
| 373 | - if($lang != 'en' || $lang != 'zh-CN'){ | ||
| 374 | - $message = Translate::tran($message, $lang); | 400 | + if ($lang != 'en' && Str::contains($lang, 'zh')) { |
| 401 | + $message = Translate::tran($message, $lang); | ||
| 402 | + } | ||
| 375 | } | 403 | } |
| 376 | 404 | ||
| 377 | $this->output('获取转发设备信息'); | 405 | $this->output('获取转发设备信息'); |
| @@ -430,7 +458,7 @@ class RelayInquiry extends Command | @@ -430,7 +458,7 @@ class RelayInquiry extends Command | ||
| 430 | { | 458 | { |
| 431 | $cache_key = 'inquiry_ads_task'; | 459 | $cache_key = 'inquiry_ads_task'; |
| 432 | $ads = Cache::get($cache_key, function () use ($cache_key) { | 460 | $ads = Cache::get($cache_key, function () use ($cache_key) { |
| 433 | - $ads = ReInquiryTask::where(['status' => ReInquiryTask::STATUS_OPEN])->get(['id', 'ad_id', 'num', 'target']); | 461 | + $ads = ReInquiryTask::where(['status' => ReInquiryTask::STATUS_OPEN])->get(['id', 'ad_id', 'num', 'target', 'is_replace_text']); |
| 434 | $array = []; | 462 | $array = []; |
| 435 | foreach ($ads as $key=>$val) { | 463 | foreach ($ads as $key=>$val) { |
| 436 | $array[$val->ad_id] = $val; | 464 | $array[$val->ad_id] = $val; |
| 1 | <?php | 1 | <?php |
| 2 | namespace App\Console\Commands\Inquiry; | 2 | namespace App\Console\Commands\Inquiry; |
| 3 | 3 | ||
| 4 | +use App\Models\Inquiry\ReInquiryCount; | ||
| 4 | use App\Models\Inquiry\ReInquiryDetail; | 5 | use App\Models\Inquiry\ReInquiryDetail; |
| 5 | use App\Models\Inquiry\ReInquiryDetailLog; | 6 | use App\Models\Inquiry\ReInquiryDetailLog; |
| 6 | use App\Models\Inquiry\ReInquiryForm; | 7 | use App\Models\Inquiry\ReInquiryForm; |
| @@ -66,6 +67,7 @@ class postInquiry extends Command | @@ -66,6 +67,7 @@ class postInquiry extends Command | ||
| 66 | $form = ReInquiryForm::find($detail['form_id']); | 67 | $form = ReInquiryForm::find($detail['form_id']); |
| 67 | $form->success_num = $form->success_num + 1; | 68 | $form->success_num = $form->success_num + 1; |
| 68 | $form->save(); | 69 | $form->save(); |
| 70 | + Log::channel('inquiry_relay')->info('询盘成功:',[$detail['form_id'], $val->id, getmypid()]); | ||
| 69 | } | 71 | } |
| 70 | } | 72 | } |
| 71 | }catch (\Exception $e){ | 73 | }catch (\Exception $e){ |
| @@ -175,6 +177,10 @@ class postInquiry extends Command | @@ -175,6 +177,10 @@ class postInquiry extends Command | ||
| 175 | ]; | 177 | ]; |
| 176 | 178 | ||
| 177 | $res = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data)->json(); | 179 | $res = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data)->json(); |
| 180 | + //兼容接口返回格式 | ||
| 181 | + if(!empty($res['data'][0]['status'])){ | ||
| 182 | + $res['data'][0]['code'] = $res['data'][0]['status'] == 'success' ? 200 : 400; | ||
| 183 | + } | ||
| 178 | if(empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200,300])){ | 184 | if(empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200,300])){ |
| 179 | $log->status = ReInquiryDetailLog::STATUS_FAIL; | 185 | $log->status = ReInquiryDetailLog::STATUS_FAIL; |
| 180 | $log->remark = $res['message'] ?? ''; | 186 | $log->remark = $res['message'] ?? ''; |
| @@ -186,6 +192,10 @@ class postInquiry extends Command | @@ -186,6 +192,10 @@ class postInquiry extends Command | ||
| 186 | } | 192 | } |
| 187 | $log->status = ReInquiryDetailLog::STATUS_SUCCESS; | 193 | $log->status = ReInquiryDetailLog::STATUS_SUCCESS; |
| 188 | $log->save(); | 194 | $log->save(); |
| 195 | + | ||
| 196 | + //统计 | ||
| 197 | + ReInquiryCount::addInquiryNum($detail['id'], $detail['re_website']); | ||
| 198 | + | ||
| 189 | return true; | 199 | return true; |
| 190 | } | 200 | } |
| 191 | 201 |
| @@ -56,21 +56,56 @@ class UpdateRoute extends Command | @@ -56,21 +56,56 @@ class UpdateRoute extends Command | ||
| 56 | */ | 56 | */ |
| 57 | public function handle(){ | 57 | public function handle(){ |
| 58 | $projectModel = new Project(); | 58 | $projectModel = new Project(); |
| 59 | - $list = $projectModel->list(['id'=>['in',[1148]]]); | 59 | + $list = $projectModel->list(['id'=>['in',[1750]]]); |
| 60 | $data = []; | 60 | $data = []; |
| 61 | foreach ($list as $v){ | 61 | foreach ($list as $v){ |
| 62 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | 62 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; |
| 63 | ProjectServer::useProject($v['id']); | 63 | ProjectServer::useProject($v['id']); |
| 64 | // $this->getProduct(); | 64 | // $this->getProduct(); |
| 65 | - $this->setProductKeyword(); | 65 | +// $this->setProductKeyword(); |
| 66 | // $this->getBlog(); | 66 | // $this->getBlog(); |
| 67 | // $this->setCustomRoute($v['id']); | 67 | // $this->setCustomRoute($v['id']); |
| 68 | // $this->editProductAlt(); | 68 | // $this->editProductAlt(); |
| 69 | + $this->custom_to_blogs(); | ||
| 69 | DB::disconnect('custom_mysql'); | 70 | DB::disconnect('custom_mysql'); |
| 70 | } | 71 | } |
| 71 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | 72 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; |
| 72 | } | 73 | } |
| 73 | 74 | ||
| 75 | + /** | ||
| 76 | + * @remark :同步擴展模塊數據到blogs | ||
| 77 | + * @name :custom_to_blogs | ||
| 78 | + * @author :lyh | ||
| 79 | + * @method :post | ||
| 80 | + * @time :2024/10/28 15:45 | ||
| 81 | + */ | ||
| 82 | + public function custom_to_blogs(){ | ||
| 83 | + $customContentModel = new CustomModuleContent(); | ||
| 84 | + $lists = $customContentModel->list(['module_id'=>9]); | ||
| 85 | + foreach ($lists as $k => $v){ | ||
| 86 | + $data = [ | ||
| 87 | + 'name'=>$v['name'], | ||
| 88 | + 'category_id'=>',1,', | ||
| 89 | + 'remark'=>$v['remark'], | ||
| 90 | + 'text'=>$v['content'], | ||
| 91 | + 'url'=>$v['route'], | ||
| 92 | + 'image'=>$v['image'], | ||
| 93 | + 'seo_title'=>$v['seo_title'], | ||
| 94 | + 'seo_description'=>$v['seo_description'], | ||
| 95 | + 'seo_keywords'=>$v['seo_keywords'], | ||
| 96 | + 'project_id'=>1750, | ||
| 97 | + 'operator_id'=>$v['operator_id'], | ||
| 98 | + 'create_id'=>$v['operator_id'], | ||
| 99 | + 'created_at'=>$v['created_at'], | ||
| 100 | + 'updated_at'=>$v['updated_at'], | ||
| 101 | + 'release_at'=>$v['release_at'] | ||
| 102 | + ]; | ||
| 103 | + $blogModel = new Blog(); | ||
| 104 | + $id = $blogModel->insertGetId($data); | ||
| 105 | + RouteMap::setRoute($v['route'], RouteMap::SOURCE_BLOG, $id, 1750); | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + | ||
| 74 | public function editProductAlt(){ | 109 | public function editProductAlt(){ |
| 75 | $productModel = new Product(); | 110 | $productModel = new Product(); |
| 76 | $lists = $productModel->list(['status'=>1],'id',['id','route','thumb','gallery']); | 111 | $lists = $productModel->list(['status'=>1],'id',['id','route','thumb','gallery']); |
| @@ -242,18 +277,20 @@ class UpdateRoute extends Command | @@ -242,18 +277,20 @@ class UpdateRoute extends Command | ||
| 242 | if(!empty($lists)){ | 277 | if(!empty($lists)){ |
| 243 | foreach ($lists as $v){ | 278 | foreach ($lists as $v){ |
| 244 | if(!empty($v['route'])){ | 279 | if(!empty($v['route'])){ |
| 245 | - $tag = "-product"; | ||
| 246 | - if (!(substr($v['route'], -strlen($tag)) === $tag)) { | ||
| 247 | - echo date('Y-m-d H:i:s') . '拼接'.$tag . PHP_EOL; | ||
| 248 | - $route = $v['route'].$tag; | ||
| 249 | - // 如果不是以 '-product' 结尾,则拼接上 '-product' | ||
| 250 | - $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | ||
| 251 | - $productModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 252 | - }else{ | ||
| 253 | - echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; | ||
| 254 | - $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | ||
| 255 | - $productModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 256 | - } | 280 | +// $tag = "-product"; |
| 281 | +// if (!(substr($v['route'], -strlen($tag)) === $tag)) { | ||
| 282 | +// echo date('Y-m-d H:i:s') . '拼接'.$tag . PHP_EOL; | ||
| 283 | +// $route = $v['route'].$tag; | ||
| 284 | +// // 如果不是以 '-product' 结尾,则拼接上 '-product' | ||
| 285 | +// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | ||
| 286 | +// $productModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 287 | +// }else{ | ||
| 288 | +// echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; | ||
| 289 | +// $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | ||
| 290 | +// $productModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 291 | +// } | ||
| 292 | + $route = RouteMap::setRoute($v['route'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | ||
| 293 | + $productModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 257 | continue; | 294 | continue; |
| 258 | }else{ | 295 | }else{ |
| 259 | echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; | 296 | echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; |
| @@ -266,5 +266,25 @@ class QuanqiusouApi | @@ -266,5 +266,25 @@ class QuanqiusouApi | ||
| 266 | return $res; | 266 | return $res; |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | + /** | ||
| 270 | + * 获取代理信息 | ||
| 271 | + * @param $domain | ||
| 272 | + * @return array|mixed | ||
| 273 | + * @author zbj | ||
| 274 | + * @date 2024/10/26 | ||
| 275 | + */ | ||
| 276 | + public function getV5Agent($domain){ | ||
| 277 | + $token = md5($domain.'qqs'); | ||
| 278 | + try { | ||
| 279 | + $client = new \GuzzleHttp\Client(); | ||
| 280 | + $res = $client->request('GET', 'https://quanqiusou.cn/extend_api/api/get_agent_by_domain.php?'.http_build_query(['token' => $token, 'domain' => $domain]), [ | ||
| 281 | + 'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号 | ||
| 282 | + ])->getBody()->getContents(); | ||
| 283 | + return Arr::s2a($res); | ||
| 284 | + } catch (\Exception | GuzzleException $e) { | ||
| 285 | + errorLog('获取代理失败', [$domain], $e); | ||
| 286 | + return []; | ||
| 287 | + } | ||
| 288 | + } | ||
| 269 | 289 | ||
| 270 | } | 290 | } |
| @@ -989,6 +989,41 @@ if (!function_exists('check_domain_record')) { | @@ -989,6 +989,41 @@ if (!function_exists('check_domain_record')) { | ||
| 989 | } | 989 | } |
| 990 | } | 990 | } |
| 991 | 991 | ||
| 992 | +/** | ||
| 993 | + * 邮箱脱敏 | ||
| 994 | + * @author zbj | ||
| 995 | + * @date 2024/10/25 | ||
| 996 | + */ | ||
| 997 | +function email_desensitize($email){ | ||
| 998 | + $parts = explode('@', $email); | ||
| 999 | + $username = $parts[0]; | ||
| 1000 | + $domain = $parts[1]; | ||
| 1001 | + $maskedUsername = substr($username, 0, -4) . '****'; | ||
| 1002 | + $maskedDomain = '****.' . substr($domain, -5); | ||
| 1003 | + return $maskedUsername . '@' . $maskedDomain; | ||
| 1004 | +} | ||
| 1005 | + | ||
| 1006 | +/** | ||
| 1007 | + * 按比例取值 [10,30,60] | ||
| 1008 | + * @author zbj | ||
| 1009 | + * @date 2024/10/25 | ||
| 1010 | + */ | ||
| 1011 | +function getRandByRatio($proArr){ | ||
| 1012 | + $result = ''; | ||
| 1013 | + $proSum = array_sum($proArr); | ||
| 1014 | + foreach ($proArr as $key => $proCur) { | ||
| 1015 | + $randNum = mt_rand(1, $proSum); | ||
| 1016 | + if ($randNum <= $proCur) { | ||
| 1017 | + $result = $key; | ||
| 1018 | + break; | ||
| 1019 | + } else { | ||
| 1020 | + $proSum -= $proCur; | ||
| 1021 | + } | ||
| 1022 | + } | ||
| 1023 | + unset ($proArr); | ||
| 1024 | + return $result; | ||
| 1025 | +} | ||
| 1026 | + | ||
| 992 | 1027 | ||
| 993 | 1028 | ||
| 994 | 1029 |
| @@ -95,6 +95,7 @@ class ProjectController extends BaseController | @@ -95,6 +95,7 @@ class ProjectController extends BaseController | ||
| 95 | 'gl_project_deploy_build.dept_id AS dept_id', | 95 | 'gl_project_deploy_build.dept_id AS dept_id', |
| 96 | 'gl_project_deploy_build.keyword_num AS key', | 96 | 'gl_project_deploy_build.keyword_num AS key', |
| 97 | 'gl_project_deploy_build.service_duration AS day', | 97 | 'gl_project_deploy_build.service_duration AS day', |
| 98 | + 'gl_project_deploy_build.is_comment AS is_comment', | ||
| 98 | 'gl_project_deploy_build.leader_mid AS leader_mid', | 99 | 'gl_project_deploy_build.leader_mid AS leader_mid', |
| 99 | 'gl_project_deploy_build.manager_mid AS manager_mid', | 100 | 'gl_project_deploy_build.manager_mid AS manager_mid', |
| 100 | 'gl_project_deploy_build.designer_mid AS designer_mid', | 101 | 'gl_project_deploy_build.designer_mid AS designer_mid', |
| @@ -9,9 +9,11 @@ namespace App\Http\Controllers\Aside\Task; | @@ -9,9 +9,11 @@ namespace App\Http\Controllers\Aside\Task; | ||
| 9 | 9 | ||
| 10 | use App\Enums\Common\Code; | 10 | use App\Enums\Common\Code; |
| 11 | use App\Helper\Arr; | 11 | use App\Helper\Arr; |
| 12 | +use App\Helper\QuanqiusouApi; | ||
| 12 | use App\Http\Controllers\Aside\BaseController; | 13 | use App\Http\Controllers\Aside\BaseController; |
| 13 | use App\Models\Channel\Channel; | 14 | use App\Models\Channel\Channel; |
| 14 | use App\Models\Domain\DomainInfo; | 15 | use App\Models\Domain\DomainInfo; |
| 16 | +use App\Models\Inquiry\ReInquiryCount; | ||
| 15 | use App\Models\Inquiry\ReInquiryDetail; | 17 | use App\Models\Inquiry\ReInquiryDetail; |
| 16 | use App\Models\Inquiry\ReInquiryForm; | 18 | use App\Models\Inquiry\ReInquiryForm; |
| 17 | use App\Models\Inquiry\ReInquiryTask; | 19 | use App\Models\Inquiry\ReInquiryTask; |
| @@ -57,11 +59,14 @@ class AdsController extends BaseController | @@ -57,11 +59,14 @@ class AdsController extends BaseController | ||
| 57 | ->paginate($page_size); | 59 | ->paginate($page_size); |
| 58 | 60 | ||
| 59 | $relay_site_total = 0; | 61 | $relay_site_total = 0; |
| 60 | - foreach ($result as $item){ | 62 | + foreach ($result as &$item){ |
| 61 | $relay_site_total += count($item->target); | 63 | $relay_site_total += count($item->target); |
| 64 | + $item->requiry_num = ReInquiryDetail::where('task_id', $item->id)->where('status', ReInquiryDetail::STATUS_SUCCESS)->count(); | ||
| 65 | + $item->form_num = ReInquiryForm::where('ad_id', $item->ad_id)->count(); | ||
| 62 | } | 66 | } |
| 63 | $result = $result->toArray(); | 67 | $result = $result->toArray(); |
| 64 | $result['relay_site_total'] = $relay_site_total; | 68 | $result['relay_site_total'] = $relay_site_total; |
| 69 | + $result['default_ai_param'] = ReInquiryTask::DEFAULT_AI_PARAM; | ||
| 65 | 70 | ||
| 66 | return $this->response('success', Code::SUCCESS, $result); | 71 | return $this->response('success', Code::SUCCESS, $result); |
| 67 | } | 72 | } |
| @@ -81,10 +86,27 @@ class AdsController extends BaseController | @@ -81,10 +86,27 @@ class AdsController extends BaseController | ||
| 81 | $ad_img = trim($request->input('ad_img')); | 86 | $ad_img = trim($request->input('ad_img')); |
| 82 | $num = intval($request->input('num')); | 87 | $num = intval($request->input('num')); |
| 83 | $status = intval($request->input('status')); | 88 | $status = intval($request->input('status')); |
| 89 | + $is_replace_text = intval($request->input('is_replace_text')); | ||
| 90 | + $ai_param = $request->input('ai_param'); | ||
| 84 | if (empty($title) || empty($ad_id)) | 91 | if (empty($title) || empty($ad_id)) |
| 85 | return $this->response('请填写完整信息!', Code::USER_ERROR, []); | 92 | return $this->response('请填写完整信息!', Code::USER_ERROR, []); |
| 86 | 93 | ||
| 87 | - ReInquiryTask::createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status); | 94 | + //AI生成 |
| 95 | + if($is_replace_text == 2){ | ||
| 96 | + if(empty($ai_param['mkeywords'])){ | ||
| 97 | + return $this->response('工厂关键词不能为空!', Code::USER_ERROR, []); | ||
| 98 | + } | ||
| 99 | + if(empty($ai_param['characters'])){ | ||
| 100 | + return $this->response('随机字符数不能为空!', Code::USER_ERROR, []); | ||
| 101 | + } | ||
| 102 | + if(empty($ai_param['inkeywords'])){ | ||
| 103 | + return $this->response('询盘内容关键词不能为空!', Code::USER_ERROR, []); | ||
| 104 | + } | ||
| 105 | + if(empty($ai_param['suoxie'])){ | ||
| 106 | + return $this->response('英文缩写参考不能为空!', Code::USER_ERROR, []); | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + ReInquiryTask::createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status, $is_replace_text, $ai_param); | ||
| 88 | return $this->response('success', Code::SUCCESS, []); | 110 | return $this->response('success', Code::SUCCESS, []); |
| 89 | } | 111 | } |
| 90 | 112 | ||
| @@ -104,6 +126,7 @@ class AdsController extends BaseController | @@ -104,6 +126,7 @@ class AdsController extends BaseController | ||
| 104 | if(empty($target)){ | 126 | if(empty($target)){ |
| 105 | return $this->response('请添加关联网站!', Code::USER_ERROR, []); | 127 | return $this->response('请添加关联网站!', Code::USER_ERROR, []); |
| 106 | } | 128 | } |
| 129 | + $is_require_num = 0; | ||
| 107 | foreach ($target as &$item){ | 130 | foreach ($target as &$item){ |
| 108 | if(empty($item['url'])){ | 131 | if(empty($item['url'])){ |
| 109 | return $this->response('网站域名不能为空!', Code::USER_ERROR, []); | 132 | return $this->response('网站域名不能为空!', Code::USER_ERROR, []); |
| @@ -111,7 +134,20 @@ class AdsController extends BaseController | @@ -111,7 +134,20 @@ class AdsController extends BaseController | ||
| 111 | if(empty($item['agent'])){ | 134 | if(empty($item['agent'])){ |
| 112 | return $this->response('代理不能为空!', Code::USER_ERROR, []); | 135 | return $this->response('代理不能为空!', Code::USER_ERROR, []); |
| 113 | } | 136 | } |
| 137 | + if(empty($item['agent_group'])){ | ||
| 138 | + return $this->response('代理商分组不能为空!', Code::USER_ERROR, []); | ||
| 139 | + } | ||
| 114 | $item['url'] = trim(str_replace(['http://', 'https://'], '', $item['url']), '/'); | 140 | $item['url'] = trim(str_replace(['http://', 'https://'], '', $item['url']), '/'); |
| 141 | + if(!empty($item['is_require'])){ | ||
| 142 | + $is_require_num++; | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + if($is_require_num > $task->num){ | ||
| 146 | + return $this->response('必选渠道不能大于转发数量!', Code::USER_ERROR, []); | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + foreach ($target as $v){ | ||
| 150 | + ReInquiryCount::addInquiryNum($id, $v['url'], 0); | ||
| 115 | } | 151 | } |
| 116 | $task->target = json_encode($target); | 152 | $task->target = json_encode($target); |
| 117 | $task->save(); | 153 | $task->save(); |
| @@ -129,28 +165,28 @@ class AdsController extends BaseController | @@ -129,28 +165,28 @@ class AdsController extends BaseController | ||
| 129 | //是否v6 | 165 | //是否v6 |
| 130 | $domain_info = DomainInfo::where('domain', $domain)->first(); | 166 | $domain_info = DomainInfo::where('domain', $domain)->first(); |
| 131 | if($domain_info){ | 167 | if($domain_info){ |
| 132 | - $channel = Project::where('id', $domain_info['project_id'])->value('channel'); | ||
| 133 | - $data = [ | ||
| 134 | - 'is_v6' => 1, | ||
| 135 | - 'agent' => Channel::getChannelText($channel['user_id']??0), | ||
| 136 | - 'domain' => $domain, | ||
| 137 | - ]; | ||
| 138 | - return $this->response('success', Code::SUCCESS, $data); | ||
| 139 | - } | ||
| 140 | - | ||
| 141 | - $token = md5($domain.'qqs'); | ||
| 142 | - try { | ||
| 143 | - $res = HttpUtils::get('https://quanqiusou.cn/extend_api/api/get_agent_by_domain.php', ['token' => $token, 'domain' => $domain]); | ||
| 144 | - $res = Arr::s2a($res); | ||
| 145 | - } catch (\Exception | GuzzleException $e) { | ||
| 146 | - return $this->response('验证失败,请稍后再试!', Code::USER_ERROR, []); | 168 | + $channel = Project::where('id', $domain_info['project_id'])->where('delete_status', 0)->value('channel'); |
| 169 | + if($channel){ | ||
| 170 | + $data = [ | ||
| 171 | + 'is_v6' => 1, | ||
| 172 | + 'agent' => trim(explode('-', Channel::getChannelText($channel['user_id']??0))[0]), | ||
| 173 | + 'domain' => $domain, | ||
| 174 | + ]; | ||
| 175 | + return $this->response('success', Code::SUCCESS, $data); | ||
| 176 | + } | ||
| 147 | } | 177 | } |
| 178 | + $res = (new QuanqiusouApi())->getV5Agent($domain); | ||
| 148 | if(empty($res['status']) || $res['status'] != 200){ | 179 | if(empty($res['status']) || $res['status'] != 200){ |
| 149 | - return $this->response($res['msg'], Code::USER_ERROR, []); | 180 | + return $this->response($res['msg'] ?? '验证失败,请稍后再试!', Code::USER_ERROR, []); |
| 150 | } | 181 | } |
| 182 | + | ||
| 183 | + $agent = implode(',', array_map(function ($v){ | ||
| 184 | + return trim(explode('-', $v)[0]); | ||
| 185 | + }, explode(',', $res['data'] ?? ''))); | ||
| 186 | + | ||
| 151 | $data = [ | 187 | $data = [ |
| 152 | 'is_v6' => 0, | 188 | 'is_v6' => 0, |
| 153 | - 'agent' => $res['data'], | 189 | + 'agent' => $agent, |
| 154 | 'domain' => $domain, | 190 | 'domain' => $domain, |
| 155 | ]; | 191 | ]; |
| 156 | return $this->response('success', Code::SUCCESS, $data); | 192 | return $this->response('success', Code::SUCCESS, $data); |
| @@ -214,4 +250,34 @@ class AdsController extends BaseController | @@ -214,4 +250,34 @@ class AdsController extends BaseController | ||
| 214 | ->paginate(); | 250 | ->paginate(); |
| 215 | return $this->response('success', Code::SUCCESS, $result); | 251 | return $this->response('success', Code::SUCCESS, $result); |
| 216 | } | 252 | } |
| 253 | + | ||
| 254 | + public function fbRelayCount(Request $request){ | ||
| 255 | + $task_id = intval($request->input('task_id')); | ||
| 256 | + $domain = trim($request->input('domain')); | ||
| 257 | + $company = trim($request->input('company')); | ||
| 258 | + $operator = trim($request->input('operator')); | ||
| 259 | + $num = intval($request->input('num')); | ||
| 260 | + $row = intval($request->input('row', 20)); | ||
| 261 | + | ||
| 262 | + $result = ReInquiryCount::when($task_id, function ($query, $task_id) { | ||
| 263 | + return $query->WhereRaw("FIND_IN_SET({$task_id}, `task_ids`)"); | ||
| 264 | + }) | ||
| 265 | + ->when($domain, function ($query, $domain) { | ||
| 266 | + return $query->where('domain', 'like', '%'.$domain.'%'); | ||
| 267 | + }) | ||
| 268 | + ->when($company, function ($query, $company) { | ||
| 269 | + return $query->where('company', 'like', '%'.$company.'%'); | ||
| 270 | + }) | ||
| 271 | + ->when($num, function ($query) use($num, $operator) { | ||
| 272 | + return $query->where('num', $operator?:'=', $num); | ||
| 273 | + }) | ||
| 274 | + ->orderBy('num', 'desc') | ||
| 275 | + ->paginate($row); | ||
| 276 | + | ||
| 277 | + foreach ($result as $item){ | ||
| 278 | + $item->tasks = $item->tasks; //调用访问器 | ||
| 279 | + } | ||
| 280 | + | ||
| 281 | + return $this->response('success', Code::SUCCESS, $result); | ||
| 282 | + } | ||
| 217 | } | 283 | } |
| @@ -15,6 +15,7 @@ use App\Models\RouteMap\RouteMap; | @@ -15,6 +15,7 @@ use App\Models\RouteMap\RouteMap; | ||
| 15 | use App\Models\User\ProjectMenu as ProjectMenuModel; | 15 | use App\Models\User\ProjectMenu as ProjectMenuModel; |
| 16 | use App\Models\User\ProjectRole as ProjectRoleModel; | 16 | use App\Models\User\ProjectRole as ProjectRoleModel; |
| 17 | use App\Models\User\User; | 17 | use App\Models\User\User; |
| 18 | +use Illuminate\Support\Facades\Artisan; | ||
| 18 | use Illuminate\Support\Facades\Cache; | 19 | use Illuminate\Support\Facades\Cache; |
| 19 | 20 | ||
| 20 | /*** | 21 | /*** |
| @@ -114,7 +115,7 @@ class ComController extends BaseController | @@ -114,7 +115,7 @@ class ComController extends BaseController | ||
| 114 | $info['role_menu'] = trim(str_replace(',52,',',',','.$info['role_menu'].','),','); | 115 | $info['role_menu'] = trim(str_replace(',52,',',',','.$info['role_menu'].','),','); |
| 115 | } | 116 | } |
| 116 | $is_comment = $this->getIsComment(); | 117 | $is_comment = $this->getIsComment(); |
| 117 | - if(!$is_comment){ | 118 | + if($is_comment != 1){ |
| 118 | $info['role_menu'] = trim(str_replace(',55,',',',','.$info['role_menu'].','),','); | 119 | $info['role_menu'] = trim(str_replace(',55,',',',','.$info['role_menu'].','),','); |
| 119 | } | 120 | } |
| 120 | $this->map = [ | 121 | $this->map = [ |
| @@ -161,7 +162,7 @@ class ComController extends BaseController | @@ -161,7 +162,7 @@ class ComController extends BaseController | ||
| 161 | $data[] = 52; | 162 | $data[] = 52; |
| 162 | } | 163 | } |
| 163 | $is_comment = $this->getIsComment(); | 164 | $is_comment = $this->getIsComment(); |
| 164 | - if(!$is_comment){ | 165 | + if($is_comment != 1){ |
| 165 | $data[] = 55; | 166 | $data[] = 55; |
| 166 | } | 167 | } |
| 167 | if(!empty($data)){ | 168 | if(!empty($data)){ |
| @@ -246,7 +247,7 @@ class ComController extends BaseController | @@ -246,7 +247,7 @@ class ComController extends BaseController | ||
| 246 | * @time :2024/9/14 13:32 | 247 | * @time :2024/9/14 13:32 |
| 247 | */ | 248 | */ |
| 248 | public function getIsComment(){ | 249 | public function getIsComment(){ |
| 249 | - return $this->user['is_subscribe'] ?? 0; | 250 | + return $this->user['is_comment'] ?? 0; |
| 250 | } | 251 | } |
| 251 | 252 | ||
| 252 | /** | 253 | /** |
| @@ -398,4 +399,15 @@ class ComController extends BaseController | @@ -398,4 +399,15 @@ class ComController extends BaseController | ||
| 398 | $this->response('success',Code::SUCCESS,$lists); | 399 | $this->response('success',Code::SUCCESS,$lists); |
| 399 | } | 400 | } |
| 400 | 401 | ||
| 402 | + /** | ||
| 403 | + * @remark : | ||
| 404 | + * @name :month_count | ||
| 405 | + * @author :lyh | ||
| 406 | + * @method :post | ||
| 407 | + * @time :2024/10/28 11:51 | ||
| 408 | + */ | ||
| 409 | + public function month_count(){ | ||
| 410 | + Artisan::call('month_project '.$this->user['project_id']); | ||
| 411 | + $this->response('重新刷新中,请稍后刷新查询'); | ||
| 412 | + } | ||
| 401 | } | 413 | } |
| @@ -167,6 +167,13 @@ class InquiryController extends BaseController | @@ -167,6 +167,13 @@ class InquiryController extends BaseController | ||
| 167 | 167 | ||
| 168 | $data = $data['list'] ?? []; | 168 | $data = $data['list'] ?? []; |
| 169 | foreach ($data as &$item){ | 169 | foreach ($data as &$item){ |
| 170 | + //非正常登录的 | ||
| 171 | + if($this->param['login_source'] != 2){ | ||
| 172 | + //脱敏 | ||
| 173 | + $item['email'] = email_desensitize($item['email']); | ||
| 174 | + $item['phone'] = substr($item['phone'], 0, -4) . '****'; | ||
| 175 | + } | ||
| 176 | + | ||
| 170 | $item['ip_address'] = "{$item['country']}({$item['ip']})"; | 177 | $item['ip_address'] = "{$item['country']}({$item['ip']})"; |
| 171 | 178 | ||
| 172 | if(!empty($this->param['form_id'])){ | 179 | if(!empty($this->param['form_id'])){ |
| @@ -23,7 +23,7 @@ class MailController extends BaseController | @@ -23,7 +23,7 @@ class MailController extends BaseController | ||
| 23 | $lists = $mailModel->where('status',0)->where($this->map) | 23 | $lists = $mailModel->where('status',0)->where($this->map) |
| 24 | ->where('user_list','like','%,'.$this->uid.',%') | 24 | ->where('user_list','like','%,'.$this->uid.',%') |
| 25 | ->orWhere('user_list', '') | 25 | ->orWhere('user_list', '') |
| 26 | - ->select(['*'])->orderBy($this->order,'desc') | 26 | + ->orderBy($this->order,'desc') |
| 27 | ->paginate($this->row, ['*'], 'page', $this->page); | 27 | ->paginate($this->row, ['*'], 'page', $this->page); |
| 28 | if(!empty($lists)){ | 28 | if(!empty($lists)){ |
| 29 | $lists = $lists->toArray(); | 29 | $lists = $lists->toArray(); |
| @@ -206,7 +206,11 @@ class ProductController extends BaseController | @@ -206,7 +206,11 @@ class ProductController extends BaseController | ||
| 206 | $query = $query->where('created_uid',$this->map['created_uid']); | 206 | $query = $query->where('created_uid',$this->map['created_uid']); |
| 207 | } | 207 | } |
| 208 | if(!empty($this->param['start_at']) && !empty($this->param['end_at'])){ | 208 | if(!empty($this->param['start_at']) && !empty($this->param['end_at'])){ |
| 209 | - $query->where('created_at', '>=' ,$this->param['start_at'].' 00:00:00')->where('created_at', '<=' ,$this->param['end_at'].' 59:59:59'); | 209 | + if($this->user['project_id'] == 2059){ |
| 210 | + $query->where('send_time', '>=' ,$this->param['start_at'].' 00:00:00')->where('send_time', '<=' ,$this->param['end_at'].' 59:59:59'); | ||
| 211 | + }else{ | ||
| 212 | + $query->where('created_at', '>=' ,$this->param['start_at'].' 00:00:00')->where('created_at', '<=' ,$this->param['end_at'].' 59:59:59'); | ||
| 213 | + } | ||
| 210 | } | 214 | } |
| 211 | $this->param['featured_status'] = $this->param['featured_status'] ?? 0; | 215 | $this->param['featured_status'] = $this->param['featured_status'] ?? 0; |
| 212 | if($this->param['featured_status'] != Category::STATUS_ACTIVE) { | 216 | if($this->param['featured_status'] != Category::STATUS_ACTIVE) { |
| @@ -46,7 +46,7 @@ class MenuSpecialLogic extends BaseLogic | @@ -46,7 +46,7 @@ class MenuSpecialLogic extends BaseLogic | ||
| 46 | * @time :2024/10/24 11:50 | 46 | * @time :2024/10/24 11:50 |
| 47 | */ | 47 | */ |
| 48 | public function searchParam(&$query,$map){ | 48 | public function searchParam(&$query,$map){ |
| 49 | - $query = $query->where('gl_manage_hr.status', $map['status'] ?? 1); | 49 | + $query = $query->where('gl_manage_hr.status', null)->orWhere('gl_manage_hr.status', $map['status'] ?? 1); |
| 50 | return $query; | 50 | return $query; |
| 51 | } | 51 | } |
| 52 | 52 |
| @@ -179,7 +179,7 @@ class CountLogic extends BaseLogic | @@ -179,7 +179,7 @@ class CountLogic extends BaseLogic | ||
| 179 | $result =array(); | 179 | $result =array(); |
| 180 | if(!empty($data)){ | 180 | if(!empty($data)){ |
| 181 | foreach ($data as $k => $v){ | 181 | foreach ($data as $k => $v){ |
| 182 | - if(($this->project['is_record_china_visit'] != 1) && ($v['country'] == '中国')){ | 182 | + if(isset($v['country']) && isset($this->project['is_record_china_visit']) && ($this->project['is_record_china_visit'] != 1) && ($v['country'] == '中国')){ |
| 183 | continue; | 183 | continue; |
| 184 | }else{ | 184 | }else{ |
| 185 | $v['pv'] = (int)$v['pv']; | 185 | $v['pv'] = (int)$v['pv']; |
| @@ -128,10 +128,31 @@ class KeywordLogic extends BaseLogic | @@ -128,10 +128,31 @@ class KeywordLogic extends BaseLogic | ||
| 128 | if(!isset($param['is_video_keyword']) || $param['is_video_keyword'] == null){ | 128 | if(!isset($param['is_video_keyword']) || $param['is_video_keyword'] == null){ |
| 129 | $param['is_video_keyword'] = 0; | 129 | $param['is_video_keyword'] = 0; |
| 130 | } | 130 | } |
| 131 | + $param['first_word'] = $this->first_word($param['title']); | ||
| 131 | return $param; | 132 | return $param; |
| 132 | } | 133 | } |
| 133 | 134 | ||
| 134 | /** | 135 | /** |
| 136 | + * @remark :获取字符串首字符 | ||
| 137 | + * @name :first_word | ||
| 138 | + * @author :lyh | ||
| 139 | + * @method :post | ||
| 140 | + * @time :2024/10/28 10:47 | ||
| 141 | + */ | ||
| 142 | + public function first_word($title){ | ||
| 143 | + $first_title = mb_substr($title, 0, 1); | ||
| 144 | + //返回对应的键 | ||
| 145 | + $keywordModel = new Keyword(); | ||
| 146 | + $firstNumWord = $keywordModel->firstNumWord; | ||
| 147 | + foreach($firstNumWord as $k => $v){ | ||
| 148 | + if(strtolower($v) == strtolower($first_title)){ | ||
| 149 | + return $k; | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + return 27; | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + /** | ||
| 135 | * @remark :批量添加关键词任务, 异步处理 | 156 | * @remark :批量添加关键词任务, 异步处理 |
| 136 | * @name :batchAdd | 157 | * @name :batchAdd |
| 137 | * @author :lyh | 158 | * @author :lyh |
| @@ -151,6 +172,7 @@ class KeywordLogic extends BaseLogic | @@ -151,6 +172,7 @@ class KeywordLogic extends BaseLogic | ||
| 151 | $param['created_at'] = date('Y-m-d H:i:s'); | 172 | $param['created_at'] = date('Y-m-d H:i:s'); |
| 152 | $param['updated_at'] = $param['created_at']; | 173 | $param['updated_at'] = $param['created_at']; |
| 153 | $param['title'] = $v; | 174 | $param['title'] = $v; |
| 175 | + $param['first_word'] = $this->first_word($param['title']); | ||
| 154 | $this->model->insertGetId($param); | 176 | $this->model->insertGetId($param); |
| 155 | } | 177 | } |
| 156 | } | 178 | } |
| @@ -224,7 +246,7 @@ class KeywordLogic extends BaseLogic | @@ -224,7 +246,7 @@ class KeywordLogic extends BaseLogic | ||
| 224 | if($v){ | 246 | if($v){ |
| 225 | $keyword_info = $this->model->read(['title'=>$v]); | 247 | $keyword_info = $this->model->read(['title'=>$v]); |
| 226 | if(!$keyword_info){ | 248 | if(!$keyword_info){ |
| 227 | - $k_id = $this->model->addReturnId(['title'=>$v,'project_id'=>$project_id]); | 249 | + $k_id = $this->model->addReturnId(['title'=>$v,'first_word' => $this->first_word($v),'project_id'=>$project_id]); |
| 228 | $route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $k_id, $project_id); | 250 | $route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $k_id, $project_id); |
| 229 | $this->model->edit(['route'=>$route],['id'=>$k_id]); | 251 | $this->model->edit(['route'=>$route],['id'=>$k_id]); |
| 230 | }else{ | 252 | }else{ |
| @@ -56,7 +56,9 @@ class ProductLogic extends BaseLogic | @@ -56,7 +56,9 @@ class ProductLogic extends BaseLogic | ||
| 56 | $id = $this->param['id']; | 56 | $id = $this->param['id']; |
| 57 | }else{ | 57 | }else{ |
| 58 | $this->param = $this->addHandleParam($this->param); | 58 | $this->param = $this->addHandleParam($this->param); |
| 59 | - $this->param['sort'] = $this->setNewsSort(); | 59 | + if($this->user['project_id'] != 2059){//2059项目不处理排序 |
| 60 | + $this->param['sort'] = $this->setProductSort(); | ||
| 61 | + } | ||
| 60 | $id = $this->model->addReturnId($this->param); | 62 | $id = $this->model->addReturnId($this->param); |
| 61 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); | 63 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); |
| 62 | $this->model->edit(['route'=>$route],['id'=>$id]); | 64 | $this->model->edit(['route'=>$route],['id'=>$id]); |
| @@ -81,7 +83,7 @@ class ProductLogic extends BaseLogic | @@ -81,7 +83,7 @@ class ProductLogic extends BaseLogic | ||
| 81 | * @method :post | 83 | * @method :post |
| 82 | * @time :2023/12/25 9:27 | 84 | * @time :2023/12/25 9:27 |
| 83 | */ | 85 | */ |
| 84 | - public function setNewsSort(){ | 86 | + public function setProductSort(){ |
| 85 | $info = $this->model->orderBy('sort','desc')->first(); | 87 | $info = $this->model->orderBy('sort','desc')->first(); |
| 86 | if(empty($info)){ | 88 | if(empty($info)){ |
| 87 | return 1; | 89 | return 1; |
| @@ -948,8 +950,18 @@ class ProductLogic extends BaseLogic | @@ -948,8 +950,18 @@ class ProductLogic extends BaseLogic | ||
| 948 | * @time :2024/9/20 16:48 | 950 | * @time :2024/9/20 16:48 |
| 949 | */ | 951 | */ |
| 950 | public function batchSetKeyword(){ | 952 | public function batchSetKeyword(){ |
| 951 | - $this->param['keyword_id'] = ','.implode(',',$this->param['keyword_id']).','; | ||
| 952 | - $this->edit(['keyword_id'=>$this->param['keyword_id']],['id'=>['in',$this->param['id']]]); | 953 | + if(isset($this->param['is_cover']) && $this->param['is_cover'] == 1){//覆盖 |
| 954 | + $this->param['keyword_id'] = ','.implode(',',$this->param['keyword_id']).','; | ||
| 955 | + $this->edit(['keyword_id'=>$this->param['keyword_id']],['id'=>['in',$this->param['id']]]); | ||
| 956 | + }else{ | ||
| 957 | + foreach ($this->param['id'] as $id){ | ||
| 958 | + //获取当前产品的分类 | ||
| 959 | + $productInfo = $this->model->read(['id'=>$id],['id','keyword_id']); | ||
| 960 | + $keyword_ids_arr = array_values(array_unique(array_merge($productInfo['keyword_id'],$this->param['keyword_id']))); | ||
| 961 | + $keyword_ids = ','.implode(',',$keyword_ids_arr).','; | ||
| 962 | + $this->model->edit(['keyword_id'=>$keyword_ids],['id'=>$id]); | ||
| 963 | + } | ||
| 964 | + } | ||
| 953 | return $this->success(); | 965 | return $this->success(); |
| 954 | } | 966 | } |
| 955 | } | 967 | } |
| @@ -38,7 +38,7 @@ class Base extends Model | @@ -38,7 +38,7 @@ class Base extends Model | ||
| 38 | { | 38 | { |
| 39 | $query = $this->formatQuery($map); | 39 | $query = $this->formatQuery($map); |
| 40 | $query = $this->sortOrder($query,$order,$sort); | 40 | $query = $this->sortOrder($query,$order,$sort); |
| 41 | - $lists = $query->select($fields)->paginate($row, ['*'], 'page', $page); | 41 | + $lists = $query->select($fields)->paginate($row, $fields, 'page', $page); |
| 42 | if (empty($lists)) { | 42 | if (empty($lists)) { |
| 43 | return []; | 43 | return []; |
| 44 | } | 44 | } |
app/Models/Inquiry/ReInquiryCount.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Inquiry; | ||
| 4 | + | ||
| 5 | +use App\Helper\Arr; | ||
| 6 | +use App\Helper\QuanqiusouApi; | ||
| 7 | +use App\Models\Domain\DomainInfo; | ||
| 8 | +use App\Models\Project\Project; | ||
| 9 | +use App\Models\Task\TaskOwner; | ||
| 10 | +use Illuminate\Database\Eloquent\Model; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Class ReInquiryCount | ||
| 14 | + * @package App\Models\Inquiry | ||
| 15 | + * @author zbj | ||
| 16 | + * @date 2024/10/25 | ||
| 17 | + */ | ||
| 18 | +class ReInquiryCount extends Model | ||
| 19 | +{ | ||
| 20 | + /** | ||
| 21 | + * @var string | ||
| 22 | + */ | ||
| 23 | + protected $table = 'gl_re_inquiry_count'; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * @param $task_id | ||
| 27 | + * @param $domain | ||
| 28 | + * @param int $num | ||
| 29 | + * @author zbj | ||
| 30 | + * @date 2024/10/26 | ||
| 31 | + */ | ||
| 32 | + public static function addInquiryNum($task_id, $domain, $num = 1) | ||
| 33 | + { | ||
| 34 | + $model = self::where('domain', $domain)->first(); | ||
| 35 | + | ||
| 36 | + if (!$model) { | ||
| 37 | + //新增时获取公司名 | ||
| 38 | + $company = ''; | ||
| 39 | + $domain_info = DomainInfo::where('domain', $domain)->first(); | ||
| 40 | + if ($domain_info) { | ||
| 41 | + $company = Project::where('id', $domain_info['project_id'])->value('company'); | ||
| 42 | + } else { | ||
| 43 | + $res = (new QuanqiusouApi())->getV5Agent($domain); | ||
| 44 | + if (!empty($res['status']) && $res['status'] == 200) { | ||
| 45 | + $company = $res['company_name']; | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + $model = new self(); | ||
| 50 | + $model->domain = $domain; | ||
| 51 | + $model->company = $company; | ||
| 52 | + } | ||
| 53 | + $model->task_ids = $model->task_ids + [$task_id]; | ||
| 54 | + $model->num = $model->num + $num; | ||
| 55 | + $model->save(); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public function setTaskIdsAttribute($value) | ||
| 59 | + { | ||
| 60 | + $this->attributes['task_ids'] = Arr::arrToSet($value); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public function getTaskIdsAttribute($value) | ||
| 64 | + { | ||
| 65 | + return Arr::setToArr($value); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public function getTasksAttribute(){ | ||
| 69 | + $tasks = ReInquiryTask::whereIn('id', $this->task_ids)->select(['title', 'industry','target'])->get()->toArray(); | ||
| 70 | + foreach ($tasks as &$task){ | ||
| 71 | + $target = collect($task['target'])->where('url', $this->domain)->first(); | ||
| 72 | + $task['agent'] = $target['agent'] ?? ''; | ||
| 73 | + $task['is_v6'] = $target['is_v6'] ?? ''; | ||
| 74 | + $task['agent_group'] = $target['agent_group'] ?? ''; | ||
| 75 | + unset($task['target']); | ||
| 76 | + } | ||
| 77 | + return $tasks; | ||
| 78 | + } | ||
| 79 | +} |
| @@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
| 7 | */ | 7 | */ |
| 8 | namespace App\Models\Inquiry; | 8 | namespace App\Models\Inquiry; |
| 9 | 9 | ||
| 10 | +use App\Helper\Arr; | ||
| 10 | use App\Models\Base; | 11 | use App\Models\Base; |
| 11 | use Illuminate\Database\Eloquent\Model; | 12 | use Illuminate\Database\Eloquent\Model; |
| 12 | 13 | ||
| @@ -28,6 +29,36 @@ class ReInquiryTask extends Base | @@ -28,6 +29,36 @@ class ReInquiryTask extends Base | ||
| 28 | const STATUS_OPEN = 1; | 29 | const STATUS_OPEN = 1; |
| 29 | const STATUS_CLOSE = 0; | 30 | const STATUS_CLOSE = 0; |
| 30 | 31 | ||
| 32 | + const DEFAULT_AI_PARAM = [ | ||
| 33 | + 'mkeywords' => '', | ||
| 34 | + 'characters' => '30 | ||
| 35 | +40 | ||
| 36 | +50 | ||
| 37 | +60 | ||
| 38 | +70 | ||
| 39 | +80 | ||
| 40 | +90 | ||
| 41 | +100 | ||
| 42 | +120 | ||
| 43 | +150', | ||
| 44 | + 'inkeywords' => 'OEM/ODM价格 | ||
| 45 | +FOB价格多少 | ||
| 46 | +最小起订量 | ||
| 47 | +批发价格多少 | ||
| 48 | +批发价格及价格梯度 | ||
| 49 | +本地是否招商 | ||
| 50 | +支持的支付方式 | ||
| 51 | +产品画册及类别 | ||
| 52 | +公司详细资质 | ||
| 53 | +能否WhatsApp直接联系 | ||
| 54 | +是否需求本地合作伙伴', | ||
| 55 | + 'suoxie' => 'Thanks 写成 Tks | ||
| 56 | +Please 写成 Pls | ||
| 57 | +As Soon As Possible 写成 ASAP | ||
| 58 | +For Your Information 写成 FYI | ||
| 59 | +How Much 写成 HM', | ||
| 60 | + ]; | ||
| 61 | + | ||
| 31 | /** | 62 | /** |
| 32 | * 创建询盘任务 | 63 | * 创建询盘任务 |
| 33 | * @param $id | 64 | * @param $id |
| @@ -40,7 +71,7 @@ class ReInquiryTask extends Base | @@ -40,7 +71,7 @@ class ReInquiryTask extends Base | ||
| 40 | * @param int $status | 71 | * @param int $status |
| 41 | * @return ReInquiryTask | 72 | * @return ReInquiryTask |
| 42 | */ | 73 | */ |
| 43 | - public static function createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status = self::STATUS_OPEN) | 74 | + public static function createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status, $is_replace_text, $ai_param) |
| 44 | { | 75 | { |
| 45 | $self = self::where(['id' => $id])->first(); | 76 | $self = self::where(['id' => $id])->first(); |
| 46 | if (empty($self)) | 77 | if (empty($self)) |
| @@ -52,6 +83,8 @@ class ReInquiryTask extends Base | @@ -52,6 +83,8 @@ class ReInquiryTask extends Base | ||
| 52 | $self->ad_img = $ad_img; | 83 | $self->ad_img = $ad_img; |
| 53 | $self->num = $num; | 84 | $self->num = $num; |
| 54 | $self->status = $status; | 85 | $self->status = $status; |
| 86 | + $self->is_replace_text = $is_replace_text; | ||
| 87 | + $self->ai_param = $ai_param; | ||
| 55 | $self->save(); | 88 | $self->save(); |
| 56 | return $self; | 89 | return $self; |
| 57 | } | 90 | } |
| @@ -62,6 +95,23 @@ class ReInquiryTask extends Base | @@ -62,6 +95,23 @@ class ReInquiryTask extends Base | ||
| 62 | */ | 95 | */ |
| 63 | public function getTargetAttribute($value) | 96 | public function getTargetAttribute($value) |
| 64 | { | 97 | { |
| 65 | - return $value ? json_decode($value, true) : []; | 98 | + $value = $value ? json_decode($value, true) : []; |
| 99 | + foreach ($value as &$item){ | ||
| 100 | + $item['url'] = $item['url'] ?? ''; | ||
| 101 | + $item['agent'] = $item['agent'] ?? ''; | ||
| 102 | + $item['agent_group'] = $item['agent_group'] ?? ''; | ||
| 103 | + $item['is_require'] = $item['is_require'] ?? 0; | ||
| 104 | + } | ||
| 105 | + return $value; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public function setAiParamAttribute($value) | ||
| 109 | + { | ||
| 110 | + $this->attributes['ai_param'] = Arr::a2s($value); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public function getAiParamAttribute($value) | ||
| 114 | + { | ||
| 115 | + return Arr::s2a($value) ?: self::DEFAULT_AI_PARAM; | ||
| 66 | } | 116 | } |
| 67 | } | 117 | } |
| @@ -17,6 +17,38 @@ class Keyword extends Base | @@ -17,6 +17,38 @@ class Keyword extends Base | ||
| 17 | protected $connection = 'custom_mysql'; | 17 | protected $connection = 'custom_mysql'; |
| 18 | 18 | ||
| 19 | const STATUS_ACTIVE = 1; | 19 | const STATUS_ACTIVE = 1; |
| 20 | + //获取字母对应数字 | ||
| 21 | + public $firstNumWord = [ | ||
| 22 | + 0=>"0", | ||
| 23 | + 1=>"a", | ||
| 24 | + 2=>"b", | ||
| 25 | + 3=>"c", | ||
| 26 | + 4=>"d", | ||
| 27 | + 5=>"e", | ||
| 28 | + 6=>"f", | ||
| 29 | + 7=>"g", | ||
| 30 | + 8=>"h", | ||
| 31 | + 9=>"i", | ||
| 32 | + 10=>"j", | ||
| 33 | + 11=>"k", | ||
| 34 | + 12=>"l", | ||
| 35 | + 13=>"m", | ||
| 36 | + 14=>"n", | ||
| 37 | + 15=>"o", | ||
| 38 | + 16=>"p", | ||
| 39 | + 17=>"q", | ||
| 40 | + 18=>"r", | ||
| 41 | + 19=>"s", | ||
| 42 | + 20=>"t", | ||
| 43 | + 21=>"u", | ||
| 44 | + 22=>"v", | ||
| 45 | + 23=>"w", | ||
| 46 | + 24=>"x", | ||
| 47 | + 25=>"y", | ||
| 48 | + 26=>"z", | ||
| 49 | + 27=>"all", | ||
| 50 | + ]; | ||
| 51 | + | ||
| 20 | /** | 52 | /** |
| 21 | * @remark :视频 | 53 | * @remark :视频 |
| 22 | * @name :getKeywordVideoAttribute | 54 | * @name :getKeywordVideoAttribute |
| @@ -490,6 +490,7 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -490,6 +490,7 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 490 | Route::any('/fb_check_domain', [Aside\Task\AdsController::class, 'checkDomain'])->name('admin.fb_check_domain'); | 490 | Route::any('/fb_check_domain', [Aside\Task\AdsController::class, 'checkDomain'])->name('admin.fb_check_domain'); |
| 491 | Route::any('/fb_inquiry_list', [Aside\Task\AdsController::class, 'fbInquiryList'])->name('admin.fb_ads_inquiry_list'); | 491 | Route::any('/fb_inquiry_list', [Aside\Task\AdsController::class, 'fbInquiryList'])->name('admin.fb_ads_inquiry_list'); |
| 492 | Route::any('/fb_relay_detail_list', [Aside\Task\AdsController::class, 'fbRelayDetail'])->name('admin.fb_ads_relay_detail_list'); | 492 | Route::any('/fb_relay_detail_list', [Aside\Task\AdsController::class, 'fbRelayDetail'])->name('admin.fb_ads_relay_detail_list'); |
| 493 | + Route::any('/fb_relay_count', [Aside\Task\AdsController::class, 'fbRelayCount'])->name('admin.fb_relay_count'); | ||
| 493 | }); | 494 | }); |
| 494 | }); | 495 | }); |
| 495 | 496 |
-
请 注册 或 登录 后发表评论