Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into master-server
正在显示
5 个修改的文件
包含
160 行增加
和
21 行删除
| @@ -197,7 +197,10 @@ class RelayInquiry extends Command | @@ -197,7 +197,10 @@ class RelayInquiry extends Command | ||
| 197 | continue; | 197 | continue; |
| 198 | } | 198 | } |
| 199 | // 未设置对法对象 | 199 | // 未设置对法对象 |
| 200 | - if (empty($ad_task['target'])) { | 200 | + $target_num_arr = array_map(function ($item) { |
| 201 | + return count($item['target']); | ||
| 202 | + }, $ad_task); | ||
| 203 | + if (!array_sum($target_num_arr)) { | ||
| 201 | $val->status = ReInquiryForm::STATUS_FORGO; | 204 | $val->status = ReInquiryForm::STATUS_FORGO; |
| 202 | $val->remark = '广告任务转发对象为空!'; | 205 | $val->remark = '广告任务转发对象为空!'; |
| 203 | $val->save(); | 206 | $val->save(); |
| @@ -213,7 +216,12 @@ class RelayInquiry extends Command | @@ -213,7 +216,12 @@ class RelayInquiry extends Command | ||
| 213 | } | 216 | } |
| 214 | 217 | ||
| 215 | try { | 218 | try { |
| 216 | - $this->relayDetail($ad_task, $val); | 219 | + $res = false; |
| 220 | + foreach ($ad_task as $task){ | ||
| 221 | + $res += $this->relayDetail($task, $val); | ||
| 222 | + } | ||
| 223 | + $val->status = $res ? ReInquiryForm::STATUS_SUCCESS : ReInquiryForm::STATUS_FORGO; | ||
| 224 | + $val->save(); | ||
| 217 | } catch (\Exception $e) { | 225 | } catch (\Exception $e) { |
| 218 | $this->logChannel()->info('执行询盘错误:' . $e->getMessage()); | 226 | $this->logChannel()->info('执行询盘错误:' . $e->getMessage()); |
| 219 | $this->output('执行询盘错误:' . $e->getMessage()); | 227 | $this->output('执行询盘错误:' . $e->getMessage()); |
| @@ -294,9 +302,7 @@ class RelayInquiry extends Command | @@ -294,9 +302,7 @@ class RelayInquiry extends Command | ||
| 294 | 302 | ||
| 295 | if (empty($random_data)) { | 303 | if (empty($random_data)) { |
| 296 | $this->logChannel()->info('当前任务未发现转发对象!', ['广告任务ID:' . $task['id'], '询盘ID:' . $form->id]); | 304 | $this->logChannel()->info('当前任务未发现转发对象!', ['广告任务ID:' . $task['id'], '询盘ID:' . $form->id]); |
| 297 | - $form->status = ReInquiryForm::STATUS_FORGO; | ||
| 298 | - $form->remark = '当前任务未发现转发对象,广告ID: ' . $form->ad_id . '!'; | ||
| 299 | - $form->save(); | 305 | + $form->remark = $form->remark . '当前任务未发现转发对象,广告ID: ' . $form->ad_id . '!'; |
| 300 | return false; | 306 | return false; |
| 301 | } | 307 | } |
| 302 | 308 | ||
| @@ -352,7 +358,7 @@ class RelayInquiry extends Command | @@ -352,7 +358,7 @@ class RelayInquiry extends Command | ||
| 352 | // 随机访问1-6个页面 | 358 | // 随机访问1-6个页面 |
| 353 | $deep = rand(1,6); | 359 | $deep = rand(1,6); |
| 354 | if($deep > 2) { | 360 | if($deep > 2) { |
| 355 | - $visit_urls = Arr::random($all_urls, rand(1, count($all_urls) > 3 ? 3 : count($all_urls))); | 361 | + $visit_urls = Arr::random($all_urls, rand(1, count($all_urls) > 4 ? 4 : count($all_urls))); |
| 356 | $urls = array_merge($urls, $visit_urls); | 362 | $urls = array_merge($urls, $visit_urls); |
| 357 | } | 363 | } |
| 358 | if($deep > 1) { | 364 | if($deep > 1) { |
| @@ -444,9 +450,6 @@ class RelayInquiry extends Command | @@ -444,9 +450,6 @@ class RelayInquiry extends Command | ||
| 444 | } | 450 | } |
| 445 | } | 451 | } |
| 446 | } | 452 | } |
| 447 | - | ||
| 448 | - $form->status = ReInquiryForm::STATUS_SUCCESS; | ||
| 449 | - $form->save(); | ||
| 450 | return true; | 453 | return true; |
| 451 | } | 454 | } |
| 452 | 455 | ||
| @@ -468,12 +471,15 @@ class RelayInquiry extends Command | @@ -468,12 +471,15 @@ class RelayInquiry extends Command | ||
| 468 | */ | 471 | */ |
| 469 | public function getAdTask($ad_id) | 472 | public function getAdTask($ad_id) |
| 470 | { | 473 | { |
| 471 | - $cache_key = 'inquiry_ads_task'; | 474 | + $cache_key = 'inquiry_ads_tasks'; |
| 472 | $ads = Cache::get($cache_key, function () use ($cache_key) { | 475 | $ads = Cache::get($cache_key, function () use ($cache_key) { |
| 473 | $ads = ReInquiryTask::where(['status' => ReInquiryTask::STATUS_OPEN])->get(['id', 'ad_id', 'num', 'target', 'is_replace_text', 'ai_param']); | 476 | $ads = ReInquiryTask::where(['status' => ReInquiryTask::STATUS_OPEN])->get(['id', 'ad_id', 'num', 'target', 'is_replace_text', 'ai_param']); |
| 474 | $array = []; | 477 | $array = []; |
| 475 | foreach ($ads as $key=>$val) { | 478 | foreach ($ads as $key=>$val) { |
| 476 | - $array[$val->ad_id] = $val; | 479 | + $ad_ids = explode(',', $val['ad_id']); |
| 480 | + foreach ($ad_ids as $ad_id){ | ||
| 481 | + $array[$ad_id][] = $val; | ||
| 482 | + } | ||
| 477 | } | 483 | } |
| 478 | if ($array) | 484 | if ($array) |
| 479 | Cache::put($cache_key, $array, 60); | 485 | Cache::put($cache_key, $array, 60); |
| @@ -8,6 +8,7 @@ use App\Models\Inquiry\ReInquiryForm; | @@ -8,6 +8,7 @@ use App\Models\Inquiry\ReInquiryForm; | ||
| 8 | use Illuminate\Console\Command; | 8 | use Illuminate\Console\Command; |
| 9 | use Illuminate\Support\Facades\Http; | 9 | use Illuminate\Support\Facades\Http; |
| 10 | use Illuminate\Support\Facades\Log; | 10 | use Illuminate\Support\Facades\Log; |
| 11 | +use Illuminate\Support\Facades\Redis; | ||
| 11 | 12 | ||
| 12 | /** | 13 | /** |
| 13 | * Class postInquiry | 14 | * Class postInquiry |
| @@ -50,6 +51,18 @@ class postInquiry extends Command | @@ -50,6 +51,18 @@ class postInquiry extends Command | ||
| 50 | } | 51 | } |
| 51 | // 询盘数据入库 | 52 | // 询盘数据入库 |
| 52 | foreach ($list as $key => $val) { | 53 | foreach ($list as $key => $val) { |
| 54 | + //加个锁 避免重复执行 | ||
| 55 | + $lockKey = 're_inquiry_detail_log_lock_' . $val->id; | ||
| 56 | + if(!Redis::setnx($lockKey, 1)){ | ||
| 57 | + continue; | ||
| 58 | + } | ||
| 59 | + Redis::expire($lockKey, 60); | ||
| 60 | + | ||
| 61 | + $log = ReInquiryDetailLog::find($val->id); | ||
| 62 | + if($log->status != ReInquiryDetailLog::STATUS_INIT){ | ||
| 63 | + continue; | ||
| 64 | + } | ||
| 65 | + | ||
| 53 | $this->output('开始执行' . $val->id); | 66 | $this->output('开始执行' . $val->id); |
| 54 | try { | 67 | try { |
| 55 | $detail = ReInquiryDetail::find($val['detail_id']); | 68 | $detail = ReInquiryDetail::find($val['detail_id']); |
| @@ -7,8 +7,10 @@ use App\Models\Com\Notify; | @@ -7,8 +7,10 @@ use App\Models\Com\Notify; | ||
| 7 | use App\Models\Devops\ServerConfig; | 7 | use App\Models\Devops\ServerConfig; |
| 8 | use App\Models\Devops\ServersIp; | 8 | use App\Models\Devops\ServersIp; |
| 9 | use App\Models\Domain\DomainInfo; | 9 | use App\Models\Domain\DomainInfo; |
| 10 | +use App\Models\Product\Keyword; | ||
| 10 | use App\Models\Project\Project; | 11 | use App\Models\Project\Project; |
| 11 | use App\Services\BatchExportService; | 12 | use App\Services\BatchExportService; |
| 13 | +use App\Services\ProjectServer; | ||
| 12 | use Illuminate\Console\Command; | 14 | use Illuminate\Console\Command; |
| 13 | use Symfony\Component\Process\Process; | 15 | use Symfony\Component\Process\Process; |
| 14 | 16 | ||
| @@ -29,11 +31,86 @@ class Temp extends Command | @@ -29,11 +31,86 @@ class Temp extends Command | ||
| 29 | protected $description = '临时脚本'; | 31 | protected $description = '临时脚本'; |
| 30 | 32 | ||
| 31 | /** | 33 | /** |
| 34 | + * 关键词首字母 | ||
| 35 | + * @author Akun | ||
| 36 | + * @date 2024/10/30 15:37 | ||
| 37 | + */ | ||
| 38 | + public function handle() | ||
| 39 | + { | ||
| 40 | + $projects = Project::where('id', '>', 52)->select(['id'])->orderBy('id', 'asc')->get(); | ||
| 41 | + foreach ($projects as $project) { | ||
| 42 | + ProjectServer::useProject($project->id); | ||
| 43 | + | ||
| 44 | + //处理关键词首字母 | ||
| 45 | + try { | ||
| 46 | + Keyword::select(['id', 'title', 'first_word'])->chunk(1000, function ($query) { | ||
| 47 | + foreach ($query as $item) { | ||
| 48 | + if ($item->first_word === null) { | ||
| 49 | + $item->first_word = $this->getTitleFirstLetter($item->title); | ||
| 50 | + $item->save(); | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | + }); | ||
| 54 | + } catch (\Exception $e) { | ||
| 55 | + $this->output($e->getMessage()); | ||
| 56 | + continue; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + $this->output('ID:' . $project->id . ',success'); | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + protected function getTitleFirstLetter($title) | ||
| 65 | + { | ||
| 66 | + $first = mb_strtolower(mb_substr($title, 0, 1, 'utf-8'), 'utf-8'); | ||
| 67 | + if (in_array($first, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"])) { | ||
| 68 | + $firstLetter = 0; | ||
| 69 | + } else { | ||
| 70 | + if (in_array($first, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'])) { | ||
| 71 | + $rule = [ | ||
| 72 | + "a" => 1, | ||
| 73 | + "b" => 2, | ||
| 74 | + "c" => 3, | ||
| 75 | + "d" => 4, | ||
| 76 | + "e" => 5, | ||
| 77 | + "f" => 6, | ||
| 78 | + "g" => 7, | ||
| 79 | + "h" => 8, | ||
| 80 | + "i" => 9, | ||
| 81 | + "j" => 10, | ||
| 82 | + "k" => 11, | ||
| 83 | + "l" => 12, | ||
| 84 | + "m" => 13, | ||
| 85 | + "n" => 14, | ||
| 86 | + "o" => 15, | ||
| 87 | + "p" => 16, | ||
| 88 | + "q" => 17, | ||
| 89 | + "r" => 18, | ||
| 90 | + "s" => 19, | ||
| 91 | + "t" => 20, | ||
| 92 | + "u" => 21, | ||
| 93 | + "v" => 22, | ||
| 94 | + "w" => 23, | ||
| 95 | + "x" => 24, | ||
| 96 | + "y" => 25, | ||
| 97 | + "z" => 26, | ||
| 98 | + ]; | ||
| 99 | + $firstLetter = $rule[$first]; | ||
| 100 | + } else { | ||
| 101 | + $firstLetter = 27; | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + return $firstLetter; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + | ||
| 108 | + /** | ||
| 32 | * 获取指定服务器所有项目 | 109 | * 获取指定服务器所有项目 |
| 33 | * @author Akun | 110 | * @author Akun |
| 34 | * @date 2024/09/30 17:01 | 111 | * @date 2024/09/30 17:01 |
| 35 | */ | 112 | */ |
| 36 | - public function handle() | 113 | + public function handle3() |
| 37 | { | 114 | { |
| 38 | $server_id = 1; | 115 | $server_id = 1; |
| 39 | 116 | ||
| @@ -79,7 +156,7 @@ class Temp extends Command | @@ -79,7 +156,7 @@ class Temp extends Command | ||
| 79 | * @author Akun | 156 | * @author Akun |
| 80 | * @date 2024/09/26 10:48 | 157 | * @date 2024/09/26 10:48 |
| 81 | */ | 158 | */ |
| 82 | - public function handle1() | 159 | + public function handle2() |
| 83 | { | 160 | { |
| 84 | $server_id = 15; | 161 | $server_id = 15; |
| 85 | 162 | ||
| @@ -131,7 +208,7 @@ class Temp extends Command | @@ -131,7 +208,7 @@ class Temp extends Command | ||
| 131 | * @author Akun | 208 | * @author Akun |
| 132 | * @date 2024/09/26 10:48 | 209 | * @date 2024/09/26 10:48 |
| 133 | */ | 210 | */ |
| 134 | - public function handle2() | 211 | + public function handle1() |
| 135 | { | 212 | { |
| 136 | $notify_model = new Notify(); | 213 | $notify_model = new Notify(); |
| 137 | $project_model = new Project(); | 214 | $project_model = new Project(); |
| @@ -176,6 +176,7 @@ class ProjectUpdate extends Command | @@ -176,6 +176,7 @@ class ProjectUpdate extends Command | ||
| 176 | 'seo_title' => $item['seo_title'] ?? '', | 176 | 'seo_title' => $item['seo_title'] ?? '', |
| 177 | 'seo_keywords' => $item['seo_keywords'] ?? '', | 177 | 'seo_keywords' => $item['seo_keywords'] ?? '', |
| 178 | 'seo_description' => $item['seo_description'] ?? '', | 178 | 'seo_description' => $item['seo_description'] ?? '', |
| 179 | + 'first_word' => $this->getTitleFirstLetter($item['name']), | ||
| 179 | 'is_upgrade' => 1, | 180 | 'is_upgrade' => 1, |
| 180 | 'route' => $route | 181 | 'route' => $route |
| 181 | ]); | 182 | ]); |
| @@ -1225,4 +1226,48 @@ class ProjectUpdate extends Command | @@ -1225,4 +1226,48 @@ class ProjectUpdate extends Command | ||
| 1225 | return false; | 1226 | return false; |
| 1226 | } | 1227 | } |
| 1227 | } | 1228 | } |
| 1229 | + | ||
| 1230 | + //获取关键词首字母对应数字 | ||
| 1231 | + protected function getTitleFirstLetter($title) | ||
| 1232 | + { | ||
| 1233 | + $first = mb_strtolower(mb_substr($title, 0, 1, 'utf-8'), 'utf-8'); | ||
| 1234 | + if (in_array($first, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"])) { | ||
| 1235 | + $firstLetter = 0; | ||
| 1236 | + } else { | ||
| 1237 | + if (in_array($first, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'])) { | ||
| 1238 | + $rule = [ | ||
| 1239 | + "a" => 1, | ||
| 1240 | + "b" => 2, | ||
| 1241 | + "c" => 3, | ||
| 1242 | + "d" => 4, | ||
| 1243 | + "e" => 5, | ||
| 1244 | + "f" => 6, | ||
| 1245 | + "g" => 7, | ||
| 1246 | + "h" => 8, | ||
| 1247 | + "i" => 9, | ||
| 1248 | + "j" => 10, | ||
| 1249 | + "k" => 11, | ||
| 1250 | + "l" => 12, | ||
| 1251 | + "m" => 13, | ||
| 1252 | + "n" => 14, | ||
| 1253 | + "o" => 15, | ||
| 1254 | + "p" => 16, | ||
| 1255 | + "q" => 17, | ||
| 1256 | + "r" => 18, | ||
| 1257 | + "s" => 19, | ||
| 1258 | + "t" => 20, | ||
| 1259 | + "u" => 21, | ||
| 1260 | + "v" => 22, | ||
| 1261 | + "w" => 23, | ||
| 1262 | + "x" => 24, | ||
| 1263 | + "y" => 25, | ||
| 1264 | + "z" => 26, | ||
| 1265 | + ]; | ||
| 1266 | + $firstLetter = $rule[$first]; | ||
| 1267 | + } else { | ||
| 1268 | + $firstLetter = 27; | ||
| 1269 | + } | ||
| 1270 | + } | ||
| 1271 | + return $firstLetter; | ||
| 1272 | + } | ||
| 1228 | } | 1273 | } |
| @@ -62,7 +62,7 @@ class AdsController extends BaseController | @@ -62,7 +62,7 @@ class AdsController extends BaseController | ||
| 62 | foreach ($result as &$item){ | 62 | foreach ($result as &$item){ |
| 63 | $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(); | 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(); | 65 | + $item->form_num = ReInquiryForm::whereIn('ad_id', explode(',', $item->ad_id))->count(); |
| 66 | } | 66 | } |
| 67 | $result = $result->toArray(); | 67 | $result = $result->toArray(); |
| 68 | $result['relay_site_total'] = $relay_site_total; | 68 | $result['relay_site_total'] = $relay_site_total; |
| @@ -169,7 +169,8 @@ class AdsController extends BaseController | @@ -169,7 +169,8 @@ class AdsController extends BaseController | ||
| 169 | if($channel){ | 169 | if($channel){ |
| 170 | $data = [ | 170 | $data = [ |
| 171 | 'is_v6' => 1, | 171 | 'is_v6' => 1, |
| 172 | - 'agent' => trim(explode('-', Channel::getChannelText($channel['user_id']??0))[0]), | 172 | + 'agent' => Channel::getChannelText($channel['user_id']??0), |
| 173 | + 'agent_group' => trim(explode('-', Channel::getChannelText($channel['user_id']??0))[0]), | ||
| 173 | 'domain' => $domain, | 174 | 'domain' => $domain, |
| 174 | ]; | 175 | ]; |
| 175 | return $this->response('success', Code::SUCCESS, $data); | 176 | return $this->response('success', Code::SUCCESS, $data); |
| @@ -180,13 +181,10 @@ class AdsController extends BaseController | @@ -180,13 +181,10 @@ class AdsController extends BaseController | ||
| 180 | return $this->response($res['msg'] ?? '验证失败,请稍后再试!', Code::USER_ERROR, []); | 181 | return $this->response($res['msg'] ?? '验证失败,请稍后再试!', Code::USER_ERROR, []); |
| 181 | } | 182 | } |
| 182 | 183 | ||
| 183 | - $agent = implode(',', array_map(function ($v){ | ||
| 184 | - return trim(explode('-', $v)[0]); | ||
| 185 | - }, explode(',', $res['data'] ?? ''))); | ||
| 186 | - | ||
| 187 | $data = [ | 184 | $data = [ |
| 188 | 'is_v6' => 0, | 185 | 'is_v6' => 0, |
| 189 | - 'agent' => $agent, | 186 | + 'agent' => $res['data'], |
| 187 | + 'agent_group' => trim(explode('-', explode(',', $res['data'] ?? '')[0])[0]), | ||
| 190 | 'domain' => $domain, | 188 | 'domain' => $domain, |
| 191 | ]; | 189 | ]; |
| 192 | return $this->response('success', Code::SUCCESS, $data); | 190 | return $this->response('success', Code::SUCCESS, $data); |
-
请 注册 或 登录 后发表评论