Merge remote-tracking branch 'origin/master' into akun
正在显示
28 个修改的文件
包含
816 行增加
和
48 行删除
| @@ -80,7 +80,7 @@ class TemplateLog extends Command | @@ -80,7 +80,7 @@ class TemplateLog extends Command | ||
| 80 | * @time :2024/11/13 16:19 | 80 | * @time :2024/11/13 16:19 |
| 81 | */ | 81 | */ |
| 82 | public function deleteUserLog(){ | 82 | public function deleteUserLog(){ |
| 83 | - $date = date('Y-m-d H:i:s', strtotime('-30 days')); | 83 | + $date = date('Y-m-d H:i:s', strtotime('-60 days')); |
| 84 | $userLogModel = new UserLog(); | 84 | $userLogModel = new UserLog(); |
| 85 | return $userLogModel->del(['created_at'=>['<=',$date]]); | 85 | return $userLogModel->del(['created_at'=>['<=',$date]]); |
| 86 | } | 86 | } |
| @@ -338,7 +338,7 @@ class RelayInquiry extends Command | @@ -338,7 +338,7 @@ class RelayInquiry extends Command | ||
| 338 | $re_website = 'https://' . $domain . '/'; | 338 | $re_website = 'https://' . $domain . '/'; |
| 339 | 339 | ||
| 340 | //urls | 340 | //urls |
| 341 | - list($urls, $lang) = $this->getUrls($is_v6, $domain, $re_website, $form, $task); | 341 | + list($urls, $lang, $inquiry_product_url) = $this->getUrls($is_v6, $domain, $re_website, $form, $task); |
| 342 | if(!$urls){ | 342 | if(!$urls){ |
| 343 | continue; | 343 | continue; |
| 344 | } | 344 | } |
| @@ -349,7 +349,7 @@ class RelayInquiry extends Command | @@ -349,7 +349,7 @@ class RelayInquiry extends Command | ||
| 349 | $country_name = $ip_data->ip_area; | 349 | $country_name = $ip_data->ip_area; |
| 350 | 350 | ||
| 351 | //message | 351 | //message |
| 352 | - list($message, $message_id, $msg_lang) = $this->getMessage($task, $form->message, $domain); | 352 | + list($message, $message_id, $msg_lang) = $this->getMessage($task, $form->message, $domain, $inquiry_product_url); |
| 353 | $lang = $lang ?: $msg_lang; | 353 | $lang = $lang ?: $msg_lang; |
| 354 | 354 | ||
| 355 | $this->output('获取转发设备信息'); | 355 | $this->output('获取转发设备信息'); |
| @@ -406,6 +406,7 @@ class RelayInquiry extends Command | @@ -406,6 +406,7 @@ class RelayInquiry extends Command | ||
| 406 | $ip_data = $this->getIpData($form->country_name); | 406 | $ip_data = $this->getIpData($form->country_name); |
| 407 | $ip = $ip_data->ip; | 407 | $ip = $ip_data->ip; |
| 408 | $country_name = $ip_data->ip_area; | 408 | $country_name = $ip_data->ip_area; |
| 409 | + | ||
| 409 | //message | 410 | //message |
| 410 | list($message, $message_id, $lang) = $this->getMessage($task, $form->message, $domain); | 411 | list($message, $message_id, $lang) = $this->getMessage($task, $form->message, $domain); |
| 411 | 412 | ||
| @@ -477,7 +478,7 @@ class RelayInquiry extends Command | @@ -477,7 +478,7 @@ class RelayInquiry extends Command | ||
| 477 | return $ip_data; | 478 | return $ip_data; |
| 478 | } | 479 | } |
| 479 | 480 | ||
| 480 | - public function getMessage($task, $message, $domain){ | 481 | + public function getMessage($task, $message, $domain, $inquiry_product_url = ''){ |
| 481 | $this->output('转发内容'); | 482 | $this->output('转发内容'); |
| 482 | $form_message = $message; | 483 | $form_message = $message; |
| 483 | $message_id = 0; | 484 | $message_id = 0; |
| @@ -486,7 +487,7 @@ class RelayInquiry extends Command | @@ -486,7 +487,7 @@ class RelayInquiry extends Command | ||
| 486 | //AI生成 | 487 | //AI生成 |
| 487 | $error = 0; | 488 | $error = 0; |
| 488 | while ($error<3){ | 489 | while ($error<3){ |
| 489 | - $message = $this->ai_send($task['ai_param'], $message); | 490 | + $message = $this->ai_send($task['ai_param'], $message, $inquiry_product_url); |
| 490 | if(!$message){ | 491 | if(!$message){ |
| 491 | $this->output('AI文案生成失败'); | 492 | $this->output('AI文案生成失败'); |
| 492 | $error++; | 493 | $error++; |
| @@ -580,7 +581,13 @@ class RelayInquiry extends Command | @@ -580,7 +581,13 @@ class RelayInquiry extends Command | ||
| 580 | $urls[] = Arr::random($inquiry_urls); | 581 | $urls[] = Arr::random($inquiry_urls); |
| 581 | } | 582 | } |
| 582 | } | 583 | } |
| 583 | - return [$urls, $lang]; | 584 | + //着陆页是否是产品页面或产品列表页 |
| 585 | + $inquiry_product_url = ''; | ||
| 586 | + if(in_array(Arr::last($urls), $product_url) || in_array(Arr::last($urls), $product_cate_url)){ | ||
| 587 | + $inquiry_product_url = Arr::last($urls); | ||
| 588 | + } | ||
| 589 | + | ||
| 590 | + return [$urls, $lang, $inquiry_product_url]; | ||
| 584 | } | 591 | } |
| 585 | /** | 592 | /** |
| 586 | * 获取待处理询盘表单 | 593 | * 获取待处理询盘表单 |
| @@ -693,7 +700,7 @@ class RelayInquiry extends Command | @@ -693,7 +700,7 @@ class RelayInquiry extends Command | ||
| 693 | } | 700 | } |
| 694 | } | 701 | } |
| 695 | 702 | ||
| 696 | - public function ai_send($ai_param, $incontent) | 703 | + public function ai_send($ai_param, $incontent, $inquiry_product_url) |
| 697 | { | 704 | { |
| 698 | $ai_command = AiCommand::where('key', 'fb_inquiry_text')->value('ai'); | 705 | $ai_command = AiCommand::where('key', 'fb_inquiry_text')->value('ai'); |
| 699 | if (!$ai_command) { | 706 | if (!$ai_command) { |
| @@ -707,6 +714,16 @@ class RelayInquiry extends Command | @@ -707,6 +714,16 @@ class RelayInquiry extends Command | ||
| 707 | }else{ | 714 | }else{ |
| 708 | $language = Translate::getTls($lang); | 715 | $language = Translate::getTls($lang); |
| 709 | } | 716 | } |
| 717 | + | ||
| 718 | + | ||
| 719 | + | ||
| 720 | + //着陆页是否是产品页面或产品列表页 | ||
| 721 | + if($inquiry_product_url){ | ||
| 722 | + $title = Common::getUrlTitle($inquiry_product_url); | ||
| 723 | + if($title){ | ||
| 724 | + $ai_command = str_replace('{mkeywords}', $title, $ai_command); | ||
| 725 | + } | ||
| 726 | + } | ||
| 710 | $ai_command = str_replace('{mkeywords}', Arr::random(explode("\r\n", $ai_param['mkeywords'])), $ai_command); | 727 | $ai_command = str_replace('{mkeywords}', Arr::random(explode("\r\n", $ai_param['mkeywords'])), $ai_command); |
| 711 | $ai_command = str_replace('{incontent}', Arr::random(explode("\r\n", $incontent)), $ai_command); | 728 | $ai_command = str_replace('{incontent}', Arr::random(explode("\r\n", $incontent)), $ai_command); |
| 712 | $ai_command = str_replace('{characters}', Arr::random(explode("\r\n", $ai_param['characters'])), $ai_command); | 729 | $ai_command = str_replace('{characters}', Arr::random(explode("\r\n", $ai_param['characters'])), $ai_command); |
| @@ -219,7 +219,7 @@ class postInquiry extends Command | @@ -219,7 +219,7 @@ class postInquiry extends Command | ||
| 219 | } else { | 219 | } else { |
| 220 | $data['__amp_source_origin'] = trim($website, '/'); | 220 | $data['__amp_source_origin'] = trim($website, '/'); |
| 221 | } | 221 | } |
| 222 | - $res = Http::withoutVerifying()->timeout(10)->withHeaders(['User-Agent' => $detail['user_agent']])->post($website . 'api/inquiryQd/', $data)->json(); | 222 | + $res = Http::withoutVerifying()->timeout(10)->withHeaders(['User-Agent' => $detail['user_agent']])->post($website . 'api/inquiryQd?source=5', $data)->json(); |
| 223 | if (empty($res['code']) || $res['code'] != 200) { | 223 | if (empty($res['code']) || $res['code'] != 200) { |
| 224 | $log->status = ReInquiryDetailLog::STATUS_FAIL; | 224 | $log->status = ReInquiryDetailLog::STATUS_FAIL; |
| 225 | $log->remark = mb_substr($res['message'] ?? '', 0, 200); | 225 | $log->remark = mb_substr($res['message'] ?? '', 0, 200); |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :CreateProject.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/1/6 10:34 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\Project; | ||
| 11 | + | ||
| 12 | +use App\Helper\Arr; | ||
| 13 | +use App\Models\Channel\Channel; | ||
| 14 | +use App\Models\Com\UpdateLog; | ||
| 15 | +use App\Models\Com\UpdateVisit; | ||
| 16 | +use App\Models\Devops\Servers; | ||
| 17 | +use App\Models\Devops\ServersIp; | ||
| 18 | +use App\Models\Manage\Mobile; | ||
| 19 | +use App\Models\Project\After; | ||
| 20 | +use App\Models\Project\DeployBuild; | ||
| 21 | +use App\Models\Project\DeployOptimize; | ||
| 22 | +use App\Models\Project\Payment; | ||
| 23 | +use App\Models\Project\Project; | ||
| 24 | +use App\Models\User\User as UserModel; | ||
| 25 | +use App\Services\ProjectServer; | ||
| 26 | +use Hashids\Hashids; | ||
| 27 | +use Illuminate\Console\Command; | ||
| 28 | +use Illuminate\Support\Facades\DB; | ||
| 29 | + | ||
| 30 | +class CreateProject extends Command | ||
| 31 | +{ | ||
| 32 | + protected $signature = 'create_project'; | ||
| 33 | + protected $description = '创建项目'; | ||
| 34 | + | ||
| 35 | + public function handle(){ | ||
| 36 | + return $this->sync(); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public function sync($is_update = 0){ | ||
| 40 | + $title = date('Ymd') . '-广东威美建材科技有限公司'; | ||
| 41 | + $data = [ | ||
| 42 | + 'project'=>[ | ||
| 43 | + 'title' => $title, | ||
| 44 | + 'company' => '广东威美建材科技有限公司', | ||
| 45 | + 'lead_name' => '蔡伟文', | ||
| 46 | + 'mobile' => '13929953235', | ||
| 47 | + 'mysql_id'=>Project::MYSQL_ID, | ||
| 48 | + 'serve_id'=>9, | ||
| 49 | + 'qq' => '', | ||
| 50 | + 'channel' => '{"user_id": "53", "zone_id": "4", "channel_id": "4"}', | ||
| 51 | + 'requirement' => '', | ||
| 52 | + 'cooperate_date' => '2019-04-01', | ||
| 53 | + 'from_order_id' => '', | ||
| 54 | + 'type' => $is_update, | ||
| 55 | + 'is_upgrade'=>$is_update, | ||
| 56 | + ], | ||
| 57 | + 'deploy_build' => [ | ||
| 58 | + 'service_duration' => 0, | ||
| 59 | + 'plan' => $this->versionData('标准版'), | ||
| 60 | + 'login_mobile'=>'13929953235' | ||
| 61 | + ], | ||
| 62 | + 'deploy_optimize' => [ | ||
| 63 | +// 'api_no' => 0 | ||
| 64 | + ], | ||
| 65 | + 'project_after' => [], | ||
| 66 | + 'payment' => [ | ||
| 67 | + 'amount' => 0, | ||
| 68 | + 'contract'=>[], | ||
| 69 | + 'bill'=>[] | ||
| 70 | + ], | ||
| 71 | + ]; | ||
| 72 | + DB::beginTransaction(); | ||
| 73 | + try { | ||
| 74 | + $id = $this->saveProject($data['project']); | ||
| 75 | + $this->setPostId($data['deploy_build']['plan'],$id); | ||
| 76 | + $this->savePayment($data['payment'],$id); | ||
| 77 | + $this->saveDeployBuild($data['deploy_build'],$id); | ||
| 78 | + $this->saveDeployOptimize($data['deploy_optimize'],$id); | ||
| 79 | + $this->saveAfter($data['project_after'],$id); | ||
| 80 | + $serversIpModel = new ServersIp(); | ||
| 81 | + $serversModel = new Servers(); | ||
| 82 | + $serversIpModel->where(['id'=>9])->increment('total',1); | ||
| 83 | + $serversModel->where(['id'=>7])->increment('being_number',1); | ||
| 84 | + if($is_update == 1){ | ||
| 85 | + //4.0或5.0更新到6.0 | ||
| 86 | + //初始化数据库 | ||
| 87 | + $this->initializationMysql($id); | ||
| 88 | + //初始账号 | ||
| 89 | + $this->createUser($data['project']['mobile'],$id,$data['project']['lead_name']); | ||
| 90 | + } | ||
| 91 | + DB::commit(); | ||
| 92 | + }catch (\Exception $e){ | ||
| 93 | + DB::rollBack(); | ||
| 94 | + throw new \Exception($e->getMessage()); | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + /** | ||
| 99 | + * @remark :获取版本 | ||
| 100 | + * @name :versionData | ||
| 101 | + * @author :lyh | ||
| 102 | + * @method :post | ||
| 103 | + * @time :2023/8/9 14:46 | ||
| 104 | + */ | ||
| 105 | + public function versionData($param){ | ||
| 106 | + $data = Project::planMap(); | ||
| 107 | + $data = array_flip($data); | ||
| 108 | + if(isset($data[$param])){ | ||
| 109 | + return $data[$param]; | ||
| 110 | + }else{ | ||
| 111 | + return 1; | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + /** | ||
| 116 | + * @remark :保存项目 | ||
| 117 | + * @name :saveProject | ||
| 118 | + * @author :lyh | ||
| 119 | + * @method :post | ||
| 120 | + * @time :2023/8/30 15:53 | ||
| 121 | + */ | ||
| 122 | + public function saveProject($param){ | ||
| 123 | + $projectModel = new Project(); | ||
| 124 | + return $projectModel->addReturnId($param); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * @remark :设置post_id | ||
| 129 | + * @name :setPostId | ||
| 130 | + * @author :lyh | ||
| 131 | + * @method :post | ||
| 132 | + * @time :2023/8/9 14:47 | ||
| 133 | + */ | ||
| 134 | + public function setPostId($plan,$id){ | ||
| 135 | + $length = strlen((string)$id); // 获取变量的位数 | ||
| 136 | + $paddingLength = Project::TYPE_FIVE - $length; // 计算填充前面的 0 的位数 | ||
| 137 | + $zeros = str_repeat("0", $paddingLength); | ||
| 138 | + $number = Project::TYPE_SIX.$plan.$zeros.$id; | ||
| 139 | + $projectModel = new Project(); | ||
| 140 | + $projectModel->edit(['post_id'=>$number],['id'=>$id]); | ||
| 141 | + return true; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + /** | ||
| 145 | + * 保存优化部署 | ||
| 146 | + * @author zbj | ||
| 147 | + * @date 2023/4/26 | ||
| 148 | + */ | ||
| 149 | + protected function saveAfter($param,$id){ | ||
| 150 | + $param['project_id'] = $id; | ||
| 151 | + //查询数据是否存在 | ||
| 152 | + $afterModel = new After(); | ||
| 153 | + $info = $afterModel->read(['project_id'=>$id]); | ||
| 154 | + if($info !== false){ | ||
| 155 | + $afterModel->edit($param,['id'=>$info['id']]); | ||
| 156 | + }else{ | ||
| 157 | + $afterModel->add($param); | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + /** | ||
| 162 | + * @remark :保存付款续费 | ||
| 163 | + * @name :savePayment | ||
| 164 | + * @author :lyh | ||
| 165 | + * @method :post | ||
| 166 | + * @time :2023/8/29 16:19 | ||
| 167 | + */ | ||
| 168 | + protected function savePayment($param,$id){ | ||
| 169 | + $param['project_id'] = $id; | ||
| 170 | + $paymentModel= new Payment(); | ||
| 171 | + $param['contract'] = Arr::a2s($param['contract']); | ||
| 172 | + $param['bill'] = Arr::a2s($param['bill']); | ||
| 173 | + if(!isset($param['renewal_record'])){ | ||
| 174 | + $param['renewal_record'] = Arr::a2s([["amount"=> null, "remark"=> null, "expire_at"=> null]]); | ||
| 175 | + } | ||
| 176 | + $info = $paymentModel->read(['project_id'=>$id]); | ||
| 177 | + if($info !== false){ | ||
| 178 | + $paymentModel->edit($param,['id'=>$info['id']]); | ||
| 179 | + }else{ | ||
| 180 | + $paymentModel->add($param); | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + /** | ||
| 185 | + * @remark :保存建站部署 | ||
| 186 | + * @name :saveDeployBuild | ||
| 187 | + * @author :lyh | ||
| 188 | + * @method :post | ||
| 189 | + * @time :2023/8/29 16:19 | ||
| 190 | + */ | ||
| 191 | + protected function saveDeployBuild($param,$id){ | ||
| 192 | + $param['project_id'] = $id; | ||
| 193 | + $hashids = new Hashids('test_domain', 5, 'abcdefghjkmnpqrstuvwxyz1234567890'); | ||
| 194 | + $code = $hashids->encode($id); | ||
| 195 | + $param['test_domain'] = 'https://v6-' . $code . '.globalso.site/'; | ||
| 196 | + $deployBuildModel = new DeployBuild(); | ||
| 197 | + $info = $deployBuildModel->read(['project_id'=>$id]); | ||
| 198 | + if($info !== false){ | ||
| 199 | + $deployBuildModel->edit($param,['id'=>$info['id']]); | ||
| 200 | + }else{ | ||
| 201 | + $deployBuildModel->add($param); | ||
| 202 | + } | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + /** | ||
| 206 | + * @remark :保存优化信息 | ||
| 207 | + * @name :saveDeployOptimize | ||
| 208 | + * @author :lyh | ||
| 209 | + * @method :post | ||
| 210 | + * @time :2023/8/30 16:11 | ||
| 211 | + */ | ||
| 212 | + protected function saveDeployOptimize($param,$id){ | ||
| 213 | + $param['project_id'] = $id; | ||
| 214 | + $deployOptimizeModel = new DeployOptimize(); | ||
| 215 | + $info = $deployOptimizeModel->read(['project_id'=>$id]); | ||
| 216 | + if($info !== false){ | ||
| 217 | + //存在就不处理了 | ||
| 218 | +// $deployOptimizeModel->edit($param,['id'=>$info['id']]); | ||
| 219 | + }else{ | ||
| 220 | + $deployOptimizeModel->add($param); | ||
| 221 | + } | ||
| 222 | + } | ||
| 223 | + /** | ||
| 224 | + * 初始化数据库 | ||
| 225 | + * @param $project_id | ||
| 226 | + * @author Akun | ||
| 227 | + * @date 2023/09/19 15:12 | ||
| 228 | + */ | ||
| 229 | + public function initializationMysql($project_id){ | ||
| 230 | + //切换数据库配置 | ||
| 231 | + $project = ProjectServer::useProject($project_id); | ||
| 232 | + //创建数据库 | ||
| 233 | + ProjectServer::createDatabase($project); | ||
| 234 | + //创建表 | ||
| 235 | + ProjectServer::initTable(); | ||
| 236 | + //初始数据 | ||
| 237 | + ProjectServer::saveInitParam($project_id); | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + /** | ||
| 241 | + * 创建用户 | ||
| 242 | + * @param $mobile | ||
| 243 | + * @param $project_id | ||
| 244 | + * @param $lead_name | ||
| 245 | + * @author Akun | ||
| 246 | + * @date 2023/09/19 15:12 | ||
| 247 | + */ | ||
| 248 | + public function createUser($mobile,$project_id,$lead_name){ | ||
| 249 | + $userModel = new UserModel(); | ||
| 250 | + //查看当前项目是否存在号码库中 | ||
| 251 | + $mobileModel = new Mobile(); | ||
| 252 | + $mobileInfo = $mobileModel->read(['mobile'=>$mobile]); | ||
| 253 | + if($mobileInfo === false){ | ||
| 254 | + //查看当前用户是否存在 | ||
| 255 | + $info = $userModel->read(['mobile'=>$mobile,'project_id'=>$project_id]); | ||
| 256 | + if($info === false){ | ||
| 257 | + $data = [ | ||
| 258 | + 'mobile'=>$mobile, | ||
| 259 | + 'password'=>base64_encode(md5('123456')), | ||
| 260 | + 'project_id'=>$project_id, | ||
| 261 | + 'name'=>$lead_name, | ||
| 262 | + 'type'=>UserModel::TYPE_ONE | ||
| 263 | + ]; | ||
| 264 | + $userModel->add($data); | ||
| 265 | + } | ||
| 266 | + } | ||
| 267 | + return true; | ||
| 268 | + } | ||
| 269 | +} |
| @@ -9,6 +9,7 @@ use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel; | @@ -9,6 +9,7 @@ use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel; | ||
| 9 | use App\Services\SyncSubmitTaskService; | 9 | use App\Services\SyncSubmitTaskService; |
| 10 | use Illuminate\Console\Command; | 10 | use Illuminate\Console\Command; |
| 11 | use Illuminate\Support\Facades\DB; | 11 | use Illuminate\Support\Facades\DB; |
| 12 | +use Illuminate\Support\Facades\Log; | ||
| 12 | use Illuminate\Support\Facades\Redis; | 13 | use Illuminate\Support\Facades\Redis; |
| 13 | use Illuminate\Support\Facades\Schema; | 14 | use Illuminate\Support\Facades\Schema; |
| 14 | use Illuminate\Support\Str; | 15 | use Illuminate\Support\Str; |
| @@ -68,6 +69,7 @@ class SyncSubmitTask extends Command | @@ -68,6 +69,7 @@ class SyncSubmitTask extends Command | ||
| 68 | 69 | ||
| 69 | $this->output('任务完成'); | 70 | $this->output('任务完成'); |
| 70 | } catch (\Exception $e) { | 71 | } catch (\Exception $e) { |
| 72 | + | ||
| 71 | $task_info->retry = $task_info->retry + 1; | 73 | $task_info->retry = $task_info->retry + 1; |
| 72 | if ($task_info->retry >= 3) { | 74 | if ($task_info->retry >= 3) { |
| 73 | $task_info->status = 2; | 75 | $task_info->status = 2; |
| @@ -76,7 +78,7 @@ class SyncSubmitTask extends Command | @@ -76,7 +78,7 @@ class SyncSubmitTask extends Command | ||
| 76 | Redis::lpush('sync_submit_task', $task_id); | 78 | Redis::lpush('sync_submit_task', $task_id); |
| 77 | } | 79 | } |
| 78 | $task_info->save(); | 80 | $task_info->save(); |
| 79 | - | 81 | + Log::channel('inquiry')->error($task_id . '处理失败', [$e->getMessage(), $e->getFile(), $e->getLine()]); |
| 80 | $this->output('任务失败:' . $e->getMessage()); | 82 | $this->output('任务失败:' . $e->getMessage()); |
| 81 | } | 83 | } |
| 82 | 84 |
app/Console/Commands/Task/SendAutoEmail.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :SendAutoEmail.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/12/30 15:39 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\Task; | ||
| 11 | + | ||
| 12 | +use App\Mail\TextMail; | ||
| 13 | +use App\Models\Project\AutoEmailLog; | ||
| 14 | +use App\Models\Subscribe\Smtp; | ||
| 15 | +use Illuminate\Console\Command; | ||
| 16 | +use Illuminate\Support\Facades\Config; | ||
| 17 | +use Illuminate\Support\Facades\Mail; | ||
| 18 | +class SendAutoEmail extends Command | ||
| 19 | +{ | ||
| 20 | + protected $signature = 'send_auto_email'; | ||
| 21 | + protected $description = '自动发送回复邮件'; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * @remark :脚本 | ||
| 25 | + * @name :handle | ||
| 26 | + * @author :lyh | ||
| 27 | + * @method :post | ||
| 28 | + * @time :2024/12/30 15:43 | ||
| 29 | + */ | ||
| 30 | + public function handle() | ||
| 31 | + { | ||
| 32 | + $autoEmailLogModel = new AutoEmailLog(); | ||
| 33 | + $list = $autoEmailLogModel->list(['status'=>AutoEmailLog::STATUS_PENDING],'id',['*'],'asc',100); | ||
| 34 | + if(!empty($list)){ | ||
| 35 | + $ids = array_column($list,'id'); | ||
| 36 | + $autoEmailLogModel->edit(['status'=>AutoEmailLog::STATUS_ON],['id'=>['in',$ids]]); | ||
| 37 | + foreach ($list as $value) { | ||
| 38 | + $this->output('开始执行任务:' . $value['id']); | ||
| 39 | + $smtpModel = new Smtp(); | ||
| 40 | + $smtpInfo = $smtpModel->read(['project_id'=>$value['project_id']]); | ||
| 41 | + if($smtpInfo === false){ | ||
| 42 | + $status = AutoEmailLog::STATUS_ERROR; | ||
| 43 | + $this->output('任务:' . $smtpInfo['id'] . '失败,未配置SMTP'); | ||
| 44 | + }else{ | ||
| 45 | + $status = $this->toQueue($value,$smtpInfo); | ||
| 46 | + } | ||
| 47 | + $autoEmailLogModel = new AutoEmailLog(); | ||
| 48 | + $rs = $autoEmailLogModel->edit(['status'=>$status],['id'=>$value['id']]); | ||
| 49 | + $this->output('保存状态:' . $rs . 'status=>'.$status); | ||
| 50 | + } | ||
| 51 | + } | ||
| 52 | + return true; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * @remark :发送邮件 | ||
| 57 | + * @name :toQueue | ||
| 58 | + * @author :lyh | ||
| 59 | + * @method :post | ||
| 60 | + * @time :2024/12/30 15:43 | ||
| 61 | + */ | ||
| 62 | + public function toQueue($info,$smtpInfo){ | ||
| 63 | + Config::set('mail.mailers.smtp.host', $smtpInfo['host']); | ||
| 64 | + Config::set('mail.mailers.smtp.username', $smtpInfo['email']); | ||
| 65 | + Config::set('mail.mailers.smtp.password', $smtpInfo['password']); | ||
| 66 | + Config::set('mail.from.address', $smtpInfo['email']); | ||
| 67 | + Config::set('mail.from.name', $smtpInfo['from_name']); | ||
| 68 | + try { | ||
| 69 | + $status = AutoEmailLog::STATUS_SUCCESS; | ||
| 70 | + Mail::to([$info['email']])->send(new TextMail(['subject' => $info['title'], 'text' => $info['content']])); | ||
| 71 | + } catch (\Exception $e) { | ||
| 72 | + $status = AutoEmailLog::STATUS_ERROR; | ||
| 73 | + $this->output('任务:' . $info['id'] . ' 邮箱' . $info['email'] . '发送失败,' . $e->getMessage()); | ||
| 74 | + } | ||
| 75 | + return $status; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * 输出处理日志 | ||
| 80 | + */ | ||
| 81 | + public function output($message): bool | ||
| 82 | + { | ||
| 83 | + echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; | ||
| 84 | + return true; | ||
| 85 | + } | ||
| 86 | +} |
| @@ -59,11 +59,11 @@ class UpdateRoute extends Command | @@ -59,11 +59,11 @@ class UpdateRoute extends Command | ||
| 59 | */ | 59 | */ |
| 60 | public function handle(){ | 60 | public function handle(){ |
| 61 | $projectModel = new Project(); | 61 | $projectModel = new Project(); |
| 62 | - $list = $projectModel->list(['delete_status'=>['=',0],'id'=>874]); | 62 | + $list = $projectModel->list(['delete_status'=>['=',0],'id'=>2902]); |
| 63 | foreach ($list as $v){ | 63 | foreach ($list as $v){ |
| 64 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | 64 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; |
| 65 | ProjectServer::useProject($v['id']); | 65 | ProjectServer::useProject($v['id']); |
| 66 | - $this->setProductKeyword(); | 66 | + $this->getProduct(); |
| 67 | DB::disconnect('custom_mysql'); | 67 | DB::disconnect('custom_mysql'); |
| 68 | } | 68 | } |
| 69 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | 69 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; |
| @@ -291,7 +291,7 @@ class UpdateRoute extends Command | @@ -291,7 +291,7 @@ class UpdateRoute extends Command | ||
| 291 | 291 | ||
| 292 | public function getProduct(){ | 292 | public function getProduct(){ |
| 293 | $productModel = new Product(); | 293 | $productModel = new Product(); |
| 294 | - $lists = $productModel->list(['status'=>['!=',2]]); | 294 | + $lists = $productModel->list(); |
| 295 | if(!empty($lists)){ | 295 | if(!empty($lists)){ |
| 296 | foreach ($lists as $v){ | 296 | foreach ($lists as $v){ |
| 297 | if(!empty($v['route'])){ | 297 | if(!empty($v['route'])){ |
| @@ -313,7 +313,7 @@ class UpdateRoute extends Command | @@ -313,7 +313,7 @@ class UpdateRoute extends Command | ||
| 313 | }else{ | 313 | }else{ |
| 314 | echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; | 314 | echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; |
| 315 | $v['title'] = Translate::tran($v['title'], 'en'); | 315 | $v['title'] = Translate::tran($v['title'], 'en'); |
| 316 | - $v['title'] = str_replace('.','',$v['title']).'-product'; | 316 | + $v['title'] = str_replace('.','',$v['title']); |
| 317 | $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | 317 | $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); |
| 318 | $productModel->edit(['route'=>$route],['id'=>$v['id']]); | 318 | $productModel->edit(['route'=>$route],['id'=>$v['id']]); |
| 319 | } | 319 | } |
| @@ -8,6 +8,7 @@ use App\Models\User\UserLog as UserLogModel; | @@ -8,6 +8,7 @@ use App\Models\User\UserLog as UserLogModel; | ||
| 8 | use App\Models\User\UserLogin as UserLoginModel; | 8 | use App\Models\User\UserLogin as UserLoginModel; |
| 9 | use Illuminate\Encryption\Encrypter; | 9 | use Illuminate\Encryption\Encrypter; |
| 10 | use Illuminate\Support\Facades\Cache; | 10 | use Illuminate\Support\Facades\Cache; |
| 11 | +use Illuminate\Support\Facades\Http; | ||
| 11 | 12 | ||
| 12 | /** | 13 | /** |
| 13 | * @name: | 14 | * @name: |
| @@ -225,4 +226,24 @@ class Common | @@ -225,4 +226,24 @@ class Common | ||
| 225 | public static function deal_str($str){ | 226 | public static function deal_str($str){ |
| 226 | return str_replace(['{','}','”','“','"'],'',$str); | 227 | return str_replace(['{','}','”','“','"'],'',$str); |
| 227 | } | 228 | } |
| 229 | + | ||
| 230 | + /** | ||
| 231 | + * 获取网页 title | ||
| 232 | + * @param $url | ||
| 233 | + * @author zbj | ||
| 234 | + * @date 2024/12/31 | ||
| 235 | + */ | ||
| 236 | + public static function getUrlTitle($url) | ||
| 237 | + { | ||
| 238 | + try { | ||
| 239 | + $response = Http::withoutVerifying()->get($url); | ||
| 240 | + $html = $response->body(); | ||
| 241 | + $dom = new \DOMDocument(); | ||
| 242 | + @$dom->loadHTML($html); // 加载 HTML | ||
| 243 | + $title = $dom->getElementsByTagName('title')->item(0); // 获取 <title> 标签 | ||
| 244 | + return $title->nodeValue; | ||
| 245 | + } catch (\Exception $e) { | ||
| 246 | + return ''; | ||
| 247 | + } | ||
| 248 | + } | ||
| 228 | } | 249 | } |
| @@ -140,7 +140,7 @@ class FormGlobalsoApi | @@ -140,7 +140,7 @@ class FormGlobalsoApi | ||
| 140 | * @author zbj | 140 | * @author zbj |
| 141 | * @date 2024/1/20 | 141 | * @date 2024/1/20 |
| 142 | */ | 142 | */ |
| 143 | - public function submitInquiry($ip, $referer, $submit_at, $data) | 143 | + public function submitInquiry($ip, $referer, $submit_at, $data, $traffic = 0) |
| 144 | { | 144 | { |
| 145 | $api_url = $this->url . '/api/external-interface/add/fa043f9cbec6b38f'; | 145 | $api_url = $this->url . '/api/external-interface/add/fa043f9cbec6b38f'; |
| 146 | 146 | ||
| @@ -148,7 +148,7 @@ class FormGlobalsoApi | @@ -148,7 +148,7 @@ class FormGlobalsoApi | ||
| 148 | $data['token'] = md5($referer . $data['name'] . $ip . date("Y-m-d")); | 148 | $data['token'] = md5($referer . $data['name'] . $ip . date("Y-m-d")); |
| 149 | $data['refer'] = $referer; | 149 | $data['refer'] = $referer; |
| 150 | $data['submit_time'] = date('Y-m-d H:i:s', strtotime($submit_at)); | 150 | $data['submit_time'] = date('Y-m-d H:i:s', strtotime($submit_at)); |
| 151 | - $data['source'] = 1; //固定 | 151 | + $data['source'] = $traffic ? 5 : 1; //1 固定 5 FB广告 |
| 152 | 152 | ||
| 153 | try { | 153 | try { |
| 154 | $res = HttpUtils::post($api_url, $data); | 154 | $res = HttpUtils::post($api_url, $data); |
| @@ -41,7 +41,8 @@ class PayStripeApi | @@ -41,7 +41,8 @@ class PayStripeApi | ||
| 41 | // 构造函数设置密钥 | 41 | // 构造函数设置密钥 |
| 42 | public function __construct() | 42 | public function __construct() |
| 43 | { | 43 | { |
| 44 | - $this->secretKey = 'sk_test_51MyseXIWCYVeLww1tbPZzRe1Qk4lS5d2VLiDjpju7G0ToiX1RJcFinQXNlftq9eCjZE0n2gjaz1mfy1g0mxTusdf00m636Gv62'; | 44 | +// $this->secretKey = 'sk_test_51MyseXIWCYVeLww1tbPZzRe1Qk4lS5d2VLiDjpju7G0ToiX1RJcFinQXNlftq9eCjZE0n2gjaz1mfy1g0mxTusdf00m636Gv62'; |
| 45 | + $this->secretKey = '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'; | ||
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | /** | 48 | /** |
| @@ -89,7 +90,8 @@ class PayStripeApi | @@ -89,7 +90,8 @@ class PayStripeApi | ||
| 89 | $data = [ | 90 | $data = [ |
| 90 | 'amount' => $amount, | 91 | 'amount' => $amount, |
| 91 | 'currency' => $currency, | 92 | 'currency' => $currency, |
| 92 | - 'automatic_payment_methods[enabled]' => 'true', | 93 | + 'payment_method_types' => $this->currency_types[$currency], |
| 94 | +// 'automatic_payment_methods[enabled]' => 'true', | ||
| 93 | ]; | 95 | ]; |
| 94 | return $this->sendRequest($url, 'POST', $data); | 96 | return $this->sendRequest($url, 'POST', $data); |
| 95 | } | 97 | } |
| @@ -148,7 +150,8 @@ class PayStripeApi | @@ -148,7 +150,8 @@ class PayStripeApi | ||
| 148 | { | 150 | { |
| 149 | try { | 151 | try { |
| 150 | // Webhook 签名密钥(从 Stripe 仪表盘获取) | 152 | // Webhook 签名密钥(从 Stripe 仪表盘获取) |
| 151 | - $endpointSecret = 'whsec_garhW2TrCIrduyM3rve9mFS2sn69B9Yt'; | 153 | +// $endpointSecret = 'whsec_garhW2TrCIrduyM3rve9mFS2sn69B9Yt'; |
| 154 | + $endpointSecret = 'whsec_YPuQn3XPuJ0xyiN6XFoF0ZLaxfRM3wnS'; | ||
| 152 | // 获取原始请求内容 | 155 | // 获取原始请求内容 |
| 153 | $payload = request()->getContent(); | 156 | $payload = request()->getContent(); |
| 154 | // 获取 Stripe 签名头 | 157 | // 获取 Stripe 签名头 |
| @@ -289,7 +289,7 @@ class AdsController extends BaseController | @@ -289,7 +289,7 @@ class AdsController extends BaseController | ||
| 289 | */ | 289 | */ |
| 290 | public function fbInquiryChart(Request $request) | 290 | public function fbInquiryChart(Request $request) |
| 291 | { | 291 | { |
| 292 | - $start_date = $request->input('start_date', date('Y-m-d', strtotime('-1 month'))); | 292 | + $start_date = $request->input('start_date', date('Y-m-d', strtotime('-3 month'))); |
| 293 | $end_date = $request->input('end_date', date('Y-m-d')); | 293 | $end_date = $request->input('end_date', date('Y-m-d')); |
| 294 | $result = ReInquiryForm::select(DB::raw('DATE(inquiry_date) as date'), DB::raw('COUNT(*) as count')) | 294 | $result = ReInquiryForm::select(DB::raw('DATE(inquiry_date) as date'), DB::raw('COUNT(*) as count')) |
| 295 | ->whereBetween('inquiry_date', [$start_date, date('Y-m-d', strtotime($end_date . ' +1 day'))]) | 295 | ->whereBetween('inquiry_date', [$start_date, date('Y-m-d', strtotime($end_date . ' +1 day'))]) |
| @@ -297,7 +297,7 @@ class AdsController extends BaseController | @@ -297,7 +297,7 @@ class AdsController extends BaseController | ||
| 297 | ->pluck('count', 'date')->toArray(); | 297 | ->pluck('count', 'date')->toArray(); |
| 298 | $data = []; | 298 | $data = []; |
| 299 | while ($start_date <= $end_date) { | 299 | while ($start_date <= $end_date) { |
| 300 | - $data[$start_date] = $result[$start_date]??0; | 300 | + $data[$start_date] = ($result[$start_date]??0) * 3 ; |
| 301 | $start_date = date('Y-m-d', strtotime($start_date . ' + 1 day')); | 301 | $start_date = date('Y-m-d', strtotime($start_date . ' + 1 day')); |
| 302 | } | 302 | } |
| 303 | 303 |
| @@ -13,16 +13,27 @@ use App\Enums\Common\Code; | @@ -13,16 +13,27 @@ use App\Enums\Common\Code; | ||
| 13 | use App\Helper\Arr; | 13 | use App\Helper\Arr; |
| 14 | use App\Http\Controllers\Bside\BaseController; | 14 | use App\Http\Controllers\Bside\BaseController; |
| 15 | use App\Jobs\UpdatePageJob; | 15 | use App\Jobs\UpdatePageJob; |
| 16 | +use App\Models\Blog\Blog; | ||
| 17 | +use App\Models\Blog\BlogCategory; | ||
| 16 | use App\Models\Com\Notify; | 18 | use App\Models\Com\Notify; |
| 17 | use App\Models\Com\UpdateLog; | 19 | use App\Models\Com\UpdateLog; |
| 18 | use App\Models\Com\UpdateNotify; | 20 | use App\Models\Com\UpdateNotify; |
| 19 | use App\Models\Com\UpdateProgress; | 21 | use App\Models\Com\UpdateProgress; |
| 22 | +use App\Models\CustomModule\CustomModuleCategory; | ||
| 23 | +use App\Models\CustomModule\CustomModuleContent; | ||
| 20 | use App\Models\Devops\ServerConfig; | 24 | use App\Models\Devops\ServerConfig; |
| 21 | use App\Models\Devops\ServersIp; | 25 | use App\Models\Devops\ServersIp; |
| 22 | use App\Models\Domain\DomainInfo; | 26 | use App\Models\Domain\DomainInfo; |
| 27 | +use App\Models\News\News; | ||
| 28 | +use App\Models\News\NewsCategory; | ||
| 29 | +use App\Models\Product\Category; | ||
| 30 | +use App\Models\Product\CategoryRelated; | ||
| 31 | +use App\Models\Product\Keyword; | ||
| 32 | +use App\Models\Product\Product; | ||
| 23 | use App\Models\Project\Country as CountryModel; | 33 | use App\Models\Project\Country as CountryModel; |
| 24 | use App\Models\Project\Project; | 34 | use App\Models\Project\Project; |
| 25 | use App\Models\RouteMap\RouteMap; | 35 | use App\Models\RouteMap\RouteMap; |
| 36 | +use App\Models\WebSetting\SettingNum; | ||
| 26 | use App\Models\WebSetting\WebLanguage; | 37 | use App\Models\WebSetting\WebLanguage; |
| 27 | use Illuminate\Http\Request; | 38 | use Illuminate\Http\Request; |
| 28 | use Illuminate\Support\Facades\DB; | 39 | use Illuminate\Support\Facades\DB; |
| @@ -38,6 +49,157 @@ use Illuminate\Support\Facades\DB; | @@ -38,6 +49,157 @@ use Illuminate\Support\Facades\DB; | ||
| 38 | class CNoticeController extends BaseController | 49 | class CNoticeController extends BaseController |
| 39 | { | 50 | { |
| 40 | /** | 51 | /** |
| 52 | + * @remark :统计所有小语种 | ||
| 53 | + * @name :countLanguagePage | ||
| 54 | + * @author :lyh | ||
| 55 | + * @method :post | ||
| 56 | + * @time :2025/1/4 10:13 | ||
| 57 | + */ | ||
| 58 | + public function countLanguagePage(){ | ||
| 59 | + $this->request->validate([ | ||
| 60 | + 'language'=>'required', | ||
| 61 | + ],[ | ||
| 62 | + 'language.required' => 'language不能为空', | ||
| 63 | + ]); | ||
| 64 | + $lang_num = count($this->param['language']); | ||
| 65 | + $keyword_num = (new Keyword())->counts(['route'=>['!=',null]]); | ||
| 66 | + $data_num = $this->productNum() + $this->CustomNum() + $this->newsNum() + $this->blogNum(); | ||
| 67 | + $number = $keyword_num * 18 + $lang_num * $data_num; | ||
| 68 | + if($number >= 450000){ | ||
| 69 | + $this->response('success',Code::SUCCESS,['msg'=>'翻译数量过多, 大概页面数量:'.$number.', 磁盘空间占用可能会超过40G,请联系管理员操作!']); | ||
| 70 | + } | ||
| 71 | + $this->response('success'); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * @remark :产品分类页面数量 | ||
| 76 | + * @name :productCateNum | ||
| 77 | + * @author :lyh | ||
| 78 | + * @method :post | ||
| 79 | + * @time :2025/1/4 10:43 | ||
| 80 | + */ | ||
| 81 | + public function productNum(){ | ||
| 82 | + $number = (new Product())->counts(['status'=>1]); | ||
| 83 | + $settingModel = new SettingNum(); | ||
| 84 | + $info = $settingModel->read(['type'=>1]); | ||
| 85 | + if($info === false){ | ||
| 86 | + $product_page_number = 15; | ||
| 87 | + }else{ | ||
| 88 | + $product_page_number = $info['num']; | ||
| 89 | + } | ||
| 90 | + $productCateModel = new Category(); | ||
| 91 | + $productCateList = $productCateModel->list(['status'=>1]); | ||
| 92 | + if(!empty($productCateList)){ | ||
| 93 | + $cateReModel = new CategoryRelated(); | ||
| 94 | + foreach ($productCateList as $v){ | ||
| 95 | + $cate_num = $cateReModel->counts(['cate_id'=>$v['id']]); | ||
| 96 | + if($cate_num == 0){ | ||
| 97 | + $number += 1; | ||
| 98 | + }else{ | ||
| 99 | + $number += ceil($cate_num / $product_page_number); | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + return $number; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + /** | ||
| 107 | + * @remark :新闻数量 | ||
| 108 | + * @name :newsNum | ||
| 109 | + * @author :lyh | ||
| 110 | + * @method :post | ||
| 111 | + * @time :2025/1/4 11:21 | ||
| 112 | + */ | ||
| 113 | + public function newsNum(){ | ||
| 114 | + $newsModel = new News(); | ||
| 115 | + $number = $newsModel->counts(['status'=>1]); | ||
| 116 | + $settingModel = new SettingNum(); | ||
| 117 | + $info = $settingModel->read(['type'=>2]); | ||
| 118 | + if($info === false){ | ||
| 119 | + $news_page_number = 10; | ||
| 120 | + }else{ | ||
| 121 | + $news_page_number = $info['num']; | ||
| 122 | + } | ||
| 123 | + $newsCateModel = new NewsCategory(); | ||
| 124 | + $newsCateList = $newsCateModel->list(['status'=>0]); | ||
| 125 | + if(!empty($newsCateList)){ | ||
| 126 | + foreach ($newsCateList as $v){ | ||
| 127 | + $cate_num = $newsModel->counts(['category_id'=>['like',','.$v['id'].',']]); | ||
| 128 | + if($cate_num == 0){ | ||
| 129 | + $number += 1; | ||
| 130 | + }else{ | ||
| 131 | + $number += ceil($cate_num / $news_page_number); | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + } | ||
| 135 | + return $number; | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + /** | ||
| 139 | + * @remark :博客数量 | ||
| 140 | + * @name :blogNum | ||
| 141 | + * @author :lyh | ||
| 142 | + * @method :post | ||
| 143 | + * @time :2025/1/4 11:21 | ||
| 144 | + */ | ||
| 145 | + public function blogNum(){ | ||
| 146 | + $blogModel = new Blog(); | ||
| 147 | + $number = $blogModel->counts(['status'=>1]); | ||
| 148 | + $settingModel = new SettingNum(); | ||
| 149 | + $info = $settingModel->read(['type'=>3]); | ||
| 150 | + if($info === false){ | ||
| 151 | + $news_page_number = 10; | ||
| 152 | + }else{ | ||
| 153 | + $news_page_number = $info['num']; | ||
| 154 | + } | ||
| 155 | + $blogCateModel = new BlogCategory(); | ||
| 156 | + $blogCateList = $blogCateModel->list(['status'=>0]); | ||
| 157 | + if(!empty($blogCateList)){ | ||
| 158 | + foreach ($blogCateList as $v){ | ||
| 159 | + $cate_num = $blogModel->counts(['category_id'=>['like',','.$v['id'].',']]); | ||
| 160 | + if($cate_num == 0){ | ||
| 161 | + $number += 1; | ||
| 162 | + }else{ | ||
| 163 | + $number += ceil($cate_num / $news_page_number); | ||
| 164 | + } | ||
| 165 | + } | ||
| 166 | + } | ||
| 167 | + return $number; | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + /** | ||
| 171 | + * @remark :扩展模块数量 | ||
| 172 | + * @name :blogNum | ||
| 173 | + * @author :lyh | ||
| 174 | + * @method :post | ||
| 175 | + * @time :2025/1/4 11:21 | ||
| 176 | + */ | ||
| 177 | + public function CustomNum(){ | ||
| 178 | + $contentModel = new CustomModuleContent(); | ||
| 179 | + $number = $contentModel->counts(['status'=>0]); | ||
| 180 | + $settingModel = new SettingNum(); | ||
| 181 | + $info = $settingModel->read(['type'=>2]); | ||
| 182 | + if($info === false){ | ||
| 183 | + $news_page_number = 10; | ||
| 184 | + }else{ | ||
| 185 | + $news_page_number = $info['num']; | ||
| 186 | + } | ||
| 187 | + $cateModel = new CustomModuleCategory(); | ||
| 188 | + $cateList = $cateModel->list(['status'=>0]); | ||
| 189 | + if(!empty($cateList)){ | ||
| 190 | + foreach ($cateList as $v){ | ||
| 191 | + $cate_num = $contentModel->counts(['category_id'=>['like',','.$v['id'].',']]); | ||
| 192 | + if($cate_num == 0){ | ||
| 193 | + $number += 1; | ||
| 194 | + }else{ | ||
| 195 | + $number += ceil($cate_num / $news_page_number); | ||
| 196 | + } | ||
| 197 | + } | ||
| 198 | + } | ||
| 199 | + return $number; | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + /** | ||
| 41 | * 更新通知C端 | 203 | * 更新通知C端 |
| 42 | * @param Request $request | 204 | * @param Request $request |
| 43 | * @return \Illuminate\Http\JsonResponse | 205 | * @return \Illuminate\Http\JsonResponse |
| @@ -23,6 +23,7 @@ class BaseController extends Controller | @@ -23,6 +23,7 @@ class BaseController extends Controller | ||
| 23 | protected $row = 20;//每页条数 | 23 | protected $row = 20;//每页条数 |
| 24 | protected $header = [];//设置请求头参数 | 24 | protected $header = [];//设置请求头参数 |
| 25 | protected $order = 'created_at'; | 25 | protected $order = 'created_at'; |
| 26 | + protected $order_type = 'desc'; | ||
| 26 | protected $map = [];//处理后的参数 | 27 | protected $map = [];//处理后的参数 |
| 27 | protected $uid = 0; | 28 | protected $uid = 0; |
| 28 | protected $user = [];//当前登录用户详情 | 29 | protected $user = [];//当前登录用户详情 |
| @@ -79,6 +80,9 @@ class BaseController extends Controller | @@ -79,6 +80,9 @@ class BaseController extends Controller | ||
| 79 | case "order": | 80 | case "order": |
| 80 | $this->order = $v; | 81 | $this->order = $v; |
| 81 | break; | 82 | break; |
| 83 | + case "order_type": | ||
| 84 | + $this->order_type = $v; | ||
| 85 | + break; | ||
| 82 | case 'page': | 86 | case 'page': |
| 83 | $this->page = $v; | 87 | $this->page = $v; |
| 84 | break; | 88 | break; |
| @@ -168,12 +172,15 @@ class BaseController extends Controller | @@ -168,12 +172,15 @@ class BaseController extends Controller | ||
| 168 | 172 | ||
| 169 | 173 | ||
| 170 | /** | 174 | /** |
| 171 | - * 是否post请求 | ||
| 172 | - * @return bool | 175 | + * @remark :是否是post请求 |
| 176 | + * @name :isPost | ||
| 177 | + * @author :lyh | ||
| 178 | + * @method :post | ||
| 179 | + * @time :2024/12/30 14:17 | ||
| 173 | */ | 180 | */ |
| 174 | protected final function isPost() | 181 | protected final function isPost() |
| 175 | { | 182 | { |
| 176 | - return \Illuminate\Support\Facades\Request::isMethod('post'); | 183 | + return Request::isMethod('post'); |
| 177 | } | 184 | } |
| 178 | 185 | ||
| 179 | 186 |
| @@ -62,25 +62,49 @@ class FileManageController extends BaseController | @@ -62,25 +62,49 @@ class FileManageController extends BaseController | ||
| 62 | * @method :post | 62 | * @method :post |
| 63 | * @time :2023/12/28 17:18 | 63 | * @time :2023/12/28 17:18 |
| 64 | */ | 64 | */ |
| 65 | - public function downLoad(){ | ||
| 66 | - if(!isset($this->param['path']) || empty($this->param['path'])){ | ||
| 67 | - $this->response('参数错误',Code::SYSTEM_ERROR); | 65 | + public function downLoad() |
| 66 | + { | ||
| 67 | + // 检查参数 | ||
| 68 | + if (!isset($this->param['path']) || empty($this->param['path'])) { | ||
| 69 | + $this->response('参数错误', Code::SYSTEM_ERROR); | ||
| 68 | } | 70 | } |
| 69 | $username = basename($this->param['path']); | 71 | $username = basename($this->param['path']); |
| 70 | $parsed_url = parse_url($this->param['path']); | 72 | $parsed_url = parse_url($this->param['path']); |
| 71 | - if(isset($parsed_url['scheme'])){ | ||
| 72 | - $fileUrl = $this->param['path']; | ||
| 73 | - } else { | ||
| 74 | - $fileUrl = 'https://file.globalso.com'.$this->param['path']; | 73 | + // 构造文件 URL |
| 74 | + $fileUrl = isset($parsed_url['scheme']) | ||
| 75 | + ? $this->param['path'] | ||
| 76 | + : 'https://file.globalso.com' . $this->param['path']; | ||
| 77 | + // 初始化 curl | ||
| 78 | + $ch = curl_init(); | ||
| 79 | + curl_setopt($ch, CURLOPT_URL, $fileUrl); | ||
| 80 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
| 81 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | ||
| 82 | + curl_setopt($ch, CURLOPT_HEADER, false); | ||
| 83 | + // 跳过 SSL 验证 | ||
| 84 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
| 85 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | ||
| 86 | + // 执行 curl 请求 | ||
| 87 | + $fileContent = curl_exec($ch); | ||
| 88 | + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | ||
| 89 | + $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); | ||
| 90 | + $curlError = curl_error($ch); | ||
| 91 | + curl_close($ch); | ||
| 92 | + // 检查 curl 错误或 HTTP 状态码 | ||
| 93 | + if ($fileContent === false || $httpCode != 200) { | ||
| 94 | + $errorMsg = $fileContent === false ? "Curl Error: $curlError" : "HTTP Error: $httpCode"; | ||
| 95 | + $this->response("文件下载失败 - $errorMsg", Code::SYSTEM_ERROR); | ||
| 75 | } | 96 | } |
| 76 | // 设置响应头 | 97 | // 设置响应头 |
| 77 | header('Content-Description: File Transfer'); | 98 | header('Content-Description: File Transfer'); |
| 78 | - header('Content-Type: application/octet-stream'); | 99 | + header('Content-Type: ' . ($contentType ?: 'application/octet-stream')); |
| 79 | header('Content-Disposition: attachment; filename="' . $username . '"'); | 100 | header('Content-Disposition: attachment; filename="' . $username . '"'); |
| 80 | - // 下载文件 | ||
| 81 | - readfile($fileUrl); | 101 | + header('Content-Length: ' . strlen($fileContent)); |
| 102 | + // 输出文件内容 | ||
| 103 | + echo $fileContent; | ||
| 104 | + exit; | ||
| 82 | } | 105 | } |
| 83 | 106 | ||
| 107 | + | ||
| 84 | public function upload(Request $request, FileManage $fileManage){ | 108 | public function upload(Request $request, FileManage $fileManage){ |
| 85 | $request->validate([ | 109 | $request->validate([ |
| 86 | 'file'=>['required'], | 110 | 'file'=>['required'], |
| @@ -49,8 +49,8 @@ class ProductController extends BaseController | @@ -49,8 +49,8 @@ class ProductController extends BaseController | ||
| 49 | { | 49 | { |
| 50 | $filed = ['id', 'project_id', 'title', 'sort' ,'thumb' ,'product_type' , 'route' , | 50 | $filed = ['id', 'project_id', 'title', 'sort' ,'thumb' ,'product_type' , 'route' , |
| 51 | 'category_id', 'keyword_id', 'status', 'created_uid', 'is_upgrade' ,'created_at', 'updated_at','six_read']; | 51 | 'category_id', 'keyword_id', 'status', 'created_uid', 'is_upgrade' ,'created_at', 'updated_at','six_read']; |
| 52 | - $this->order = 'sort'; | ||
| 53 | - $query = $product->orderBy($this->order ,'desc')->orderBy('id','desc'); | 52 | + $this->order = $this->order ?? 'sort'; |
| 53 | + $query = $product->orderBy($this->order ,$this->order_type)->orderBy('id','desc'); | ||
| 54 | $query = $this->searchParam($query); | 54 | $query = $this->searchParam($query); |
| 55 | $lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page); | 55 | $lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page); |
| 56 | if(!empty($lists)){ | 56 | if(!empty($lists)){ |
| @@ -68,9 +68,12 @@ class ProductController extends BaseController | @@ -68,9 +68,12 @@ class ProductController extends BaseController | ||
| 68 | $v = $this->getHandleFileImage($v); | 68 | $v = $this->getHandleFileImage($v); |
| 69 | $lists['list'][$k] = $v; | 69 | $lists['list'][$k] = $v; |
| 70 | } | 70 | } |
| 71 | + $lists['order_type'] = $this->order_type; | ||
| 72 | + $lists['order'] = $this->order; | ||
| 71 | } | 73 | } |
| 72 | $this->response('success',Code::SUCCESS,$lists); | 74 | $this->response('success',Code::SUCCESS,$lists); |
| 73 | } | 75 | } |
| 76 | + | ||
| 74 | /** | 77 | /** |
| 75 | * @remark :列表 | 78 | * @remark :列表 |
| 76 | * @name :index | 79 | * @name :index |
| @@ -105,6 +105,8 @@ class TranslateController extends BaseController | @@ -105,6 +105,8 @@ class TranslateController extends BaseController | ||
| 105 | $translate_data[$value] = ''; | 105 | $translate_data[$value] = ''; |
| 106 | } | 106 | } |
| 107 | } | 107 | } |
| 108 | + }else{ | ||
| 109 | + $translate_data = json_decode($values['translate_data']['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); | ||
| 108 | } | 110 | } |
| 109 | $resData['data'] = $translate_data ?? []; | 111 | $resData['data'] = $translate_data ?? []; |
| 110 | $res_data[] = $resData; | 112 | $res_data[] = $resData; |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AutoEmailContentController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/12/30 14:09 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Bside\Subscribe; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Http\Controllers\Bside\BaseController; | ||
| 14 | +use App\Models\Project\AutoEmail; | ||
| 15 | +use App\Models\Subscribe\Smtp; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * @remark :项目设置自动回复邮件内容 | ||
| 19 | + * @name :AutoEmailContentController | ||
| 20 | + * @author :lyh | ||
| 21 | + * @method :post | ||
| 22 | + * @time :2024/12/30 14:09 | ||
| 23 | + */ | ||
| 24 | +class AutoEmailContentController extends BaseController | ||
| 25 | +{ | ||
| 26 | + /** | ||
| 27 | + * @remark :获取 | ||
| 28 | + * @name :getInfo | ||
| 29 | + * @author :lyh | ||
| 30 | + * @method :post | ||
| 31 | + * @time :2024/12/30 14:10 | ||
| 32 | + */ | ||
| 33 | + public function getContent(){ | ||
| 34 | + $autoEmailModel = new AutoEmail(); | ||
| 35 | + $lists = $autoEmailModel->list(['project_id'=>$this->user['project_id']]); | ||
| 36 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * @remark :保存详情 | ||
| 41 | + * @name :saveContent | ||
| 42 | + * @author :lyh | ||
| 43 | + * @method :post | ||
| 44 | + * @time :2024/12/30 14:11 | ||
| 45 | + */ | ||
| 46 | + public function saveContent(){ | ||
| 47 | + $this->request->validate([ | ||
| 48 | + 'content' => ['required'], | ||
| 49 | + ], [ | ||
| 50 | + 'content.required' => '内容不能为空', | ||
| 51 | + ]); | ||
| 52 | + $smtpModel = new Smtp(); | ||
| 53 | + $smtpInfo = $smtpModel->read(['project_id' => $this->user['project_id']]); | ||
| 54 | + if($smtpInfo === false){ | ||
| 55 | + $this->fail('请先设置SMTP',Code::USER_ERROR); | ||
| 56 | + } | ||
| 57 | + $autoEmailModel = new AutoEmail(); | ||
| 58 | + $info = $autoEmailModel->read(['project_id'=>$this->user['project_id']]); | ||
| 59 | + if($info === false){ | ||
| 60 | + //执行新增 | ||
| 61 | + $data = ['project_id'=>$this->user['project_id'],'title'=>$this->param['title'],'content'=>$this->param['content']]; | ||
| 62 | + $id = $autoEmailModel->addReturnId($data); | ||
| 63 | + }else{ | ||
| 64 | + $id = $info['id']; | ||
| 65 | + $autoEmailModel->edit(['title'=>$this->param['title'],'content'=>$this->param['content']],['project_id'=>$this->user['project_id']]); | ||
| 66 | + } | ||
| 67 | + $this->response('success',Code::SUCCESS,['id'=>$id]); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + | ||
| 71 | +} |
| @@ -17,6 +17,8 @@ use App\Models\WebSetting\TranslateData; | @@ -17,6 +17,8 @@ use App\Models\WebSetting\TranslateData; | ||
| 17 | use App\Models\WebSetting\WebLanguage; | 17 | use App\Models\WebSetting\WebLanguage; |
| 18 | use App\Helper\Translate; | 18 | use App\Helper\Translate; |
| 19 | use Illuminate\Support\Facades\DB; | 19 | use Illuminate\Support\Facades\DB; |
| 20 | +use Illuminate\Support\Str; | ||
| 21 | + | ||
| 20 | class TranslateLogic extends BaseLogic | 22 | class TranslateLogic extends BaseLogic |
| 21 | { | 23 | { |
| 22 | public function __construct() | 24 | public function __construct() |
| @@ -75,6 +77,7 @@ class TranslateLogic extends BaseLogic | @@ -75,6 +77,7 @@ class TranslateLogic extends BaseLogic | ||
| 75 | if($val == ' ' || $val == ''){ | 77 | if($val == ' ' || $val == ''){ |
| 76 | continue; | 78 | continue; |
| 77 | } | 79 | } |
| 80 | + $val = trim(trim($val,' ')); | ||
| 78 | if (FALSE == in_array(trim(urldecode($val),' '), $old_key)){ | 81 | if (FALSE == in_array(trim(urldecode($val),' '), $old_key)){ |
| 79 | $arr2[] = $val; | 82 | $arr2[] = $val; |
| 80 | } | 83 | } |
| @@ -25,7 +25,7 @@ class WebSettingTextLogic extends BaseLogic | @@ -25,7 +25,7 @@ class WebSettingTextLogic extends BaseLogic | ||
| 25 | */ | 25 | */ |
| 26 | public function setting_read(){ | 26 | public function setting_read(){ |
| 27 | $web_setting = new WebSetting(); | 27 | $web_setting = new WebSetting(); |
| 28 | - $setting_info = $web_setting->read(['project_id'=>$this->user['project_id']],['anchor_setting','anchor_is_enable','anchor_num']); | 28 | + $setting_info = $web_setting->read(['project_id'=>$this->user['project_id']],['anchor_setting','anchor_is_enable','anchor_num','anchor_page_num']); |
| 29 | if($setting_info === false){ | 29 | if($setting_info === false){ |
| 30 | $setting_info = []; | 30 | $setting_info = []; |
| 31 | } | 31 | } |
| @@ -63,7 +63,8 @@ class WebSettingTextLogic extends BaseLogic | @@ -63,7 +63,8 @@ class WebSettingTextLogic extends BaseLogic | ||
| 63 | $data = [ | 63 | $data = [ |
| 64 | 'anchor_setting'=>$this->param['anchor_setting'], | 64 | 'anchor_setting'=>$this->param['anchor_setting'], |
| 65 | 'anchor_is_enable'=>$this->param['anchor_is_enable'], | 65 | 'anchor_is_enable'=>$this->param['anchor_is_enable'], |
| 66 | - 'anchor_num'=>$this->param['anchor_num'] | 66 | + 'anchor_num'=>$this->param['anchor_num'] ?? 0, |
| 67 | + 'anchor_page_num'=>$this->param['anchor_page_num'] ?? 0 | ||
| 67 | ]; | 68 | ]; |
| 68 | $web_setting->edit($data,['project_id'=>$this->user['project_id']]); | 69 | $web_setting->edit($data,['project_id'=>$this->user['project_id']]); |
| 69 | $this->model->del(['project_id'=>$this->user['project_id']]); | 70 | $this->model->del(['project_id'=>$this->user['project_id']]); |
| @@ -31,6 +31,7 @@ class TextMail extends Mailable | @@ -31,6 +31,7 @@ class TextMail extends Mailable | ||
| 31 | */ | 31 | */ |
| 32 | public function build() | 32 | public function build() |
| 33 | { | 33 | { |
| 34 | - return $this->subject($this->subject)->view('mail.text', ['text' => $this->text]); | 34 | + return $this->subject($this->subject)->text('mail.text', ['text' => $this->text])->view('mail.html', ['text' => $this->text]); |
| 35 | } | 35 | } |
| 36 | + | ||
| 36 | } | 37 | } |
| @@ -41,7 +41,7 @@ class InquiryFormData extends Base | @@ -41,7 +41,7 @@ class InquiryFormData extends Base | ||
| 41 | * @author zbj | 41 | * @author zbj |
| 42 | * @date 2023/12/4 | 42 | * @date 2023/12/4 |
| 43 | */ | 43 | */ |
| 44 | - public static function saveData($form_id, $domain, $ip, $country, $referer, $user_agent, $submit_at, $data){ | 44 | + public static function saveData($form_id, $domain, $ip, $country, $referer, $user_agent, $submit_at, $data, $traffic = 0){ |
| 45 | if(!empty($data['email'])){ | 45 | if(!empty($data['email'])){ |
| 46 | $data['email'] = str_replace(' ', '', $data['email']); | 46 | $data['email'] = str_replace(' ', '', $data['email']); |
| 47 | } | 47 | } |
| @@ -100,7 +100,7 @@ class InquiryFormData extends Base | @@ -100,7 +100,7 @@ class InquiryFormData extends Base | ||
| 100 | } | 100 | } |
| 101 | } | 101 | } |
| 102 | if(!$has_file) { | 102 | if(!$has_file) { |
| 103 | - $res = (new FormGlobalsoApi())->submitInquiry($ip, $referer, $submit_at, $data); | 103 | + $res = (new FormGlobalsoApi())->submitInquiry($ip, $referer, $submit_at, $data, $traffic); |
| 104 | Log::channel('inquiry')->info('询盘发送邮件', [$data, $res]); | 104 | Log::channel('inquiry')->info('询盘发送邮件', [$data, $res]); |
| 105 | } | 105 | } |
| 106 | } | 106 | } |
app/Models/Project/AutoEmail.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AutoEmail.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/12/30 14:03 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Project; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class AutoEmail extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_auto_email_content'; | ||
| 17 | +} |
app/Models/Project/AutoEmailLog.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AutoEmailLog.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/12/30 15:31 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Project; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class AutoEmailLog extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_auto_email_content_log'; | ||
| 17 | + | ||
| 18 | + const STATUS_PENDING = 0;//待发送 | ||
| 19 | + const STATUS_ON = 1;//执行中 | ||
| 20 | + const STATUS_SUCCESS = 2;//执行结束 | ||
| 21 | + const STATUS_ERROR = 3;//执行失败 | ||
| 22 | +} |
| @@ -18,6 +18,7 @@ class WebSettingText extends Base | @@ -18,6 +18,7 @@ class WebSettingText extends Base | ||
| 18 | const TYPE_KEYWORD = 3; | 18 | const TYPE_KEYWORD = 3; |
| 19 | const TYPE_NEWS = 4; | 19 | const TYPE_NEWS = 4; |
| 20 | const TYPE_BLOG = 5; | 20 | const TYPE_BLOG = 5; |
| 21 | + const TYPE_OTHER = 6; | ||
| 21 | /** | 22 | /** |
| 22 | * @var :描文本设置 | 23 | * @var :描文本设置 |
| 23 | */ | 24 | */ |
| @@ -27,6 +28,7 @@ class WebSettingText extends Base | @@ -27,6 +28,7 @@ class WebSettingText extends Base | ||
| 27 | self::TYPE_KEYWORD=>'关键词页', | 28 | self::TYPE_KEYWORD=>'关键词页', |
| 28 | self::TYPE_NEWS=>'新闻页', | 29 | self::TYPE_NEWS=>'新闻页', |
| 29 | self::TYPE_BLOG=>'博客页', | 30 | self::TYPE_BLOG=>'博客页', |
| 31 | + self::TYPE_OTHER=>'其他页', | ||
| 30 | ]; | 32 | ]; |
| 31 | 33 | ||
| 32 | /** | 34 | /** |
| @@ -4,8 +4,12 @@ | @@ -4,8 +4,12 @@ | ||
| 4 | namespace App\Services; | 4 | namespace App\Services; |
| 5 | 5 | ||
| 6 | use App\Exceptions\InquiryFilterException; | 6 | use App\Exceptions\InquiryFilterException; |
| 7 | +use App\Models\Domain\CountryCode; | ||
| 8 | +use App\Models\Domain\DomainInfo; | ||
| 7 | use App\Models\Inquiry\InquiryForm; | 9 | use App\Models\Inquiry\InquiryForm; |
| 8 | use App\Models\Inquiry\InquiryFormData; | 10 | use App\Models\Inquiry\InquiryFormData; |
| 11 | +use App\Models\Project\AutoEmail; | ||
| 12 | +use App\Models\Project\AutoEmailLog; | ||
| 9 | use App\Models\Project\InquiryFilterConfig; | 13 | use App\Models\Project\InquiryFilterConfig; |
| 10 | use App\Models\Project\Project; | 14 | use App\Models\Project\Project; |
| 11 | use App\Models\Subscribe\Email; | 15 | use App\Models\Subscribe\Email; |
| @@ -61,14 +65,28 @@ class SyncSubmitTaskService | @@ -61,14 +65,28 @@ class SyncSubmitTaskService | ||
| 61 | 65 | ||
| 62 | // 项目ID:448, 过滤被刷访问 | 66 | // 项目ID:448, 过滤被刷访问 |
| 63 | if ($project['id'] == 448 && $task['type'] == 'visit') { | 67 | if ($project['id'] == 448 && $task['type'] == 'visit') { |
| 64 | - if ($data['country'] == '约旦' && empty($data['referrer_url'])) { | ||
| 65 | - $url_array = parse_url($data['url']); | 68 | + if ($data['country'] == '约旦' && empty($data['data']['referrer_url'])) { |
| 69 | + $url_array = parse_url($data['data']['url']); | ||
| 66 | $path_array = explode('/', $url_array['path']); | 70 | $path_array = explode('/', $url_array['path']); |
| 67 | if (FALSE == empty($path_array[1]) && strlen($path_array[1]) <= 3) | 71 | if (FALSE == empty($path_array[1]) && strlen($path_array[1]) <= 3) |
| 68 | return false; | 72 | return false; |
| 69 | } | 73 | } |
| 70 | } | 74 | } |
| 71 | 75 | ||
| 76 | + //域名 过滤国家或ip | ||
| 77 | + $domain_info = DomainInfo::where('project_id', $project['id'])->first(); | ||
| 78 | + if(!empty($domain_info['not_allow_country'])){ | ||
| 79 | + $not_allow_countries = CountryCode::whereIn('id', $domain_info['not_allow_country'])->pluck('c_name')->toArray(); | ||
| 80 | + if(in_array($data['country'], $not_allow_countries)){ | ||
| 81 | + return false; | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + if(!empty($domain_info['not_allow_ip'])){ | ||
| 85 | + if(in_array($data['ip'], $domain_info['not_allow_ip'])){ | ||
| 86 | + return false; | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + | ||
| 72 | if(!ProjectServer::useProject($project['id'])){ | 90 | if(!ProjectServer::useProject($project['id'])){ |
| 73 | return false; | 91 | return false; |
| 74 | } | 92 | } |
| @@ -89,7 +107,7 @@ class SyncSubmitTaskService | @@ -89,7 +107,7 @@ class SyncSubmitTaskService | ||
| 89 | } | 107 | } |
| 90 | 108 | ||
| 91 | $handler = new self(); | 109 | $handler = new self(); |
| 92 | - return $handler->$action($data, $date, $task['id']); | 110 | + return $handler->$action($data, $date, $task['id'], $task['traffic']); |
| 93 | } | 111 | } |
| 94 | 112 | ||
| 95 | 113 | ||
| @@ -120,21 +138,47 @@ class SyncSubmitTaskService | @@ -120,21 +138,47 @@ class SyncSubmitTaskService | ||
| 120 | * @author zbj | 138 | * @author zbj |
| 121 | * @date 2024/8/27 | 139 | * @date 2024/8/27 |
| 122 | */ | 140 | */ |
| 123 | - public function subscribe($data, $date, $task_id){ | 141 | + public function subscribe($data, $date, $task_id, $traffic = 0){ |
| 124 | $email = $data['data']['email']; | 142 | $email = $data['data']['email']; |
| 125 | if (filter_var($email, FILTER_VALIDATE_EMAIL)) { | 143 | if (filter_var($email, FILTER_VALIDATE_EMAIL)) { |
| 126 | $model = Email::where('email', $email)->first(); | 144 | $model = Email::where('email', $email)->first(); |
| 127 | if($model){ | 145 | if($model){ |
| 128 | return true; | 146 | return true; |
| 129 | } | 147 | } |
| 148 | + $model = new Email(); | ||
| 130 | $model->email = $email; | 149 | $model->email = $email; |
| 131 | $model->save(); | 150 | $model->save(); |
| 151 | + //查询当前项目是否开启自动回复邮件 | ||
| 152 | + $this->saveEmailLog($data['project_id'],$email); | ||
| 132 | }else{ | 153 | }else{ |
| 133 | throw new InquiryFilterException( '邮箱格式异常:' . $email); | 154 | throw new InquiryFilterException( '邮箱格式异常:' . $email); |
| 134 | } | 155 | } |
| 135 | } | 156 | } |
| 136 | 157 | ||
| 137 | /** | 158 | /** |
| 159 | + * @remark :保存自动发送邮件 | ||
| 160 | + * @name :saveEmailLog | ||
| 161 | + * @author :lyh | ||
| 162 | + * @method :post | ||
| 163 | + * @time :2024/12/30 15:36 | ||
| 164 | + */ | ||
| 165 | + public function saveEmailLog($project_id,$email){ | ||
| 166 | + $autoEmailModel = new AutoEmail(); | ||
| 167 | + $info = $autoEmailModel->read(['project_id'=>$project_id]); | ||
| 168 | + if($info !== false){ | ||
| 169 | + $paramData = [ | ||
| 170 | + 'project_id'=>$project_id, | ||
| 171 | + 'title'=>$info['title'], | ||
| 172 | + 'content'=>$info['content'], | ||
| 173 | + 'email'=>$email, | ||
| 174 | + ]; | ||
| 175 | + $autoEmailLogModel = new AutoEmailLog(); | ||
| 176 | + $autoEmailLogModel->addReturnId($paramData); | ||
| 177 | + } | ||
| 178 | + return true; | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + /** | ||
| 138 | * 询盘 | 182 | * 询盘 |
| 139 | * @param $data | 183 | * @param $data |
| 140 | * @return bool | 184 | * @return bool |
| @@ -142,7 +186,7 @@ class SyncSubmitTaskService | @@ -142,7 +186,7 @@ class SyncSubmitTaskService | ||
| 142 | * @author zbj | 186 | * @author zbj |
| 143 | * @date 2023/12/4 | 187 | * @date 2023/12/4 |
| 144 | */ | 188 | */ |
| 145 | - public function inquiry($data, $date, $task_id) | 189 | + public function inquiry($data, $date, $task_id, $traffic = 0) |
| 146 | { | 190 | { |
| 147 | //数组key转为小写 | 191 | //数组key转为小写 |
| 148 | $data['data'] = array_change_key_case($data['data'], CASE_LOWER); | 192 | $data['data'] = array_change_key_case($data['data'], CASE_LOWER); |
| @@ -166,7 +210,7 @@ class SyncSubmitTaskService | @@ -166,7 +210,7 @@ class SyncSubmitTaskService | ||
| 166 | 210 | ||
| 167 | $data['referer'] = $this->handle_referer($data['referer']); | 211 | $data['referer'] = $this->handle_referer($data['referer']); |
| 168 | 212 | ||
| 169 | - $id = InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data']); | 213 | + $id = InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data'], $traffic); |
| 170 | 214 | ||
| 171 | 215 | ||
| 172 | //转化询盘 | 216 | //转化询盘 |
| @@ -196,7 +240,7 @@ class SyncSubmitTaskService | @@ -196,7 +240,7 @@ class SyncSubmitTaskService | ||
| 196 | * @author zbj | 240 | * @author zbj |
| 197 | * @date 2023/12/4 | 241 | * @date 2023/12/4 |
| 198 | */ | 242 | */ |
| 199 | - public function visit($data, $date, $task_id) | 243 | + public function visit($data, $date, $task_id, $traffic = 0) |
| 200 | { | 244 | { |
| 201 | 245 | ||
| 202 | $visit_data = $data['data']; | 246 | $visit_data = $data['data']; |
| @@ -295,7 +339,6 @@ class SyncSubmitTaskService | @@ -295,7 +339,6 @@ class SyncSubmitTaskService | ||
| 295 | if(empty($data['referer']) || empty($data['user_agent']) || empty($data['data'])){ | 339 | if(empty($data['referer']) || empty($data['user_agent']) || empty($data['data'])){ |
| 296 | throw new InquiryFilterException( '数据异常:' . $data['country']); | 340 | throw new InquiryFilterException( '数据异常:' . $data['country']); |
| 297 | } | 341 | } |
| 298 | - | ||
| 299 | $config = InquiryFilterConfig::getCacheInfoByProjectId($project_id); | 342 | $config = InquiryFilterConfig::getCacheInfoByProjectId($project_id); |
| 300 | //没配置 则默认开启且使用全局 | 343 | //没配置 则默认开启且使用全局 |
| 301 | if(!$config){ | 344 | if(!$config){ |
resources/views/mail/html.blade.php
0 → 100644
| @@ -166,6 +166,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -166,6 +166,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 166 | Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'save'])->name('web_setting_save'); | 166 | Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'save'])->name('web_setting_save'); |
| 167 | //通知 | 167 | //通知 |
| 168 | Route::any('/sendNotify', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'sendNotify'])->name('web_setting_sendNotify'); | 168 | Route::any('/sendNotify', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'sendNotify'])->name('web_setting_sendNotify'); |
| 169 | + Route::any('/countLanguagePage', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'countLanguagePage'])->name('web_setting_countLanguagePage'); | ||
| 169 | //已选择的国家 | 170 | //已选择的国家 |
| 170 | Route::any('/getCountry', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'getCountry'])->name('web_setting_getCountry'); | 171 | Route::any('/getCountry', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'getCountry'])->name('web_setting_getCountry'); |
| 171 | //第三方代码获取与设置 | 172 | //第三方代码获取与设置 |
| @@ -641,6 +642,13 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -641,6 +642,13 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 641 | Route::any('/info', [\App\Http\Controllers\Bside\Comment\CommentController::class, 'info'])->name('comment_info'); | 642 | Route::any('/info', [\App\Http\Controllers\Bside\Comment\CommentController::class, 'info'])->name('comment_info'); |
| 642 | Route::any('/status', [\App\Http\Controllers\Bside\Comment\CommentController::class, 'status'])->name('comment_status'); | 643 | Route::any('/status', [\App\Http\Controllers\Bside\Comment\CommentController::class, 'status'])->name('comment_status'); |
| 643 | }); | 644 | }); |
| 645 | + | ||
| 646 | + //自动邮件设置 | ||
| 647 | + Route::prefix('auto_email_content')->group(function () { | ||
| 648 | + Route::any('/getContent', [\App\Http\Controllers\Bside\Subscribe\AutoEmailContentController::class, 'getContent'])->name('auto_email_content_getContent'); | ||
| 649 | + Route::any('/saveContent', [\App\Http\Controllers\Bside\Subscribe\AutoEmailContentController::class, 'saveContent'])->name('auto_email_content_saveContent'); | ||
| 650 | + | ||
| 651 | + }); | ||
| 644 | }); | 652 | }); |
| 645 | //无需登录验证的路由组 | 653 | //无需登录验证的路由组 |
| 646 | Route::group([], function () { | 654 | Route::group([], function () { |
-
请 注册 或 登录 后发表评论