Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
15 个修改的文件
包含
795 行增加
和
12 行删除
app/Console/Commands/AiBlog/AiBlogTask.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AiBlogTask.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/2/14 11:14 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\AiBlog; | ||
| 11 | + | ||
| 12 | +use App\Models\Ai\AiBlog; | ||
| 13 | +use App\Models\Project\ProjectAiSetting; | ||
| 14 | +use App\Services\AiBlogService; | ||
| 15 | +use App\Services\ProjectServer; | ||
| 16 | +use Illuminate\Console\Command; | ||
| 17 | +use App\Models\Project\AiBlogTask as AiBlogTaskModel; | ||
| 18 | +use Illuminate\Support\Facades\Cache; | ||
| 19 | +use Illuminate\Support\Facades\DB; | ||
| 20 | +use function Symfony\Component\String\s; | ||
| 21 | + | ||
| 22 | +class AiBlogTask extends Command | ||
| 23 | +{ | ||
| 24 | + /** | ||
| 25 | + * The name and signature of the console command. | ||
| 26 | + * | ||
| 27 | + * @var string | ||
| 28 | + */ | ||
| 29 | + protected $signature = 'save_ai_blog'; | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * The console command description. | ||
| 33 | + * | ||
| 34 | + * @var string | ||
| 35 | + */ | ||
| 36 | + protected $description = '查询ai_blog是否已经生成'; | ||
| 37 | + | ||
| 38 | + public function handle(){ | ||
| 39 | + $aiBlogTaskModel = new AiBlogTaskModel(); | ||
| 40 | + while (true){ | ||
| 41 | + $info = $aiBlogTaskModel->where('status',1)->orderBy('id','asc')->first(); | ||
| 42 | + if($info === false){ | ||
| 43 | + sleep(20); | ||
| 44 | + continue; | ||
| 45 | + } | ||
| 46 | + $info = $info->toArray(); | ||
| 47 | + echo '开始->任务id:' . $info['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); | ||
| 48 | + //获取配置 | ||
| 49 | + $aiSettingInfo = $this->getSetting($info['project_id']); | ||
| 50 | + $aiBlogService = new AiBlogService(); | ||
| 51 | + $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 52 | + $aiBlogService->key = $aiSettingInfo['key']; | ||
| 53 | + $aiBlogService->task_id = $info['task_id']; | ||
| 54 | + $result = $aiBlogService->getDetail(); | ||
| 55 | + if($result['status'] != 200){ | ||
| 56 | + sleep(10); | ||
| 57 | + continue; | ||
| 58 | + } | ||
| 59 | + //修改任务状态 | ||
| 60 | + $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]); | ||
| 61 | + //保存当前项目ai_blog数据 | ||
| 62 | + ProjectServer::useProject($info['project_id']); | ||
| 63 | + $aiBlogModel = new AiBlog(); | ||
| 64 | + $aiBlogModel->edit(['new_title'=>$result['data']['title'] ?? '','text'=>$result['data']['text'] ?? '','status'=>2],['task_id'=>$info['task_id']]); | ||
| 65 | + DB::disconnect('custom_mysql'); | ||
| 66 | + echo '结束->任务id:' . $info['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); | ||
| 67 | + } | ||
| 68 | + return true; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * @remark :获取项目配置 | ||
| 73 | + * @name :getSetting | ||
| 74 | + * @author :lyh | ||
| 75 | + * @method :post | ||
| 76 | + * @time :2025/2/14 11:27 | ||
| 77 | + */ | ||
| 78 | + public function getSetting($project_id){ | ||
| 79 | + $ai_cache = Cache::get('ai_blog_'.$project_id); | ||
| 80 | + if($ai_cache){ | ||
| 81 | + return $ai_cache; | ||
| 82 | + } | ||
| 83 | + $projectAiSettingModel = new ProjectAiSetting(); | ||
| 84 | + $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$project_id]); | ||
| 85 | + Cache::put('ai_blog_'.$project_id,$aiSettingInfo,3600); | ||
| 86 | + return $aiSettingInfo; | ||
| 87 | + } | ||
| 88 | +} |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2025/2/13 | ||
| 6 | + * Time: 16:45 | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +namespace App\Console\Commands\Inquiry; | ||
| 10 | + | ||
| 11 | +use App\Helper\Translate; | ||
| 12 | +use App\Models\Inquiry\InquiryInfo; | ||
| 13 | +use App\Services\InquiryRelayService; | ||
| 14 | +use Illuminate\Console\Command; | ||
| 15 | +use Illuminate\Support\Facades\DB; | ||
| 16 | + | ||
| 17 | +class SyncInquiryRelay extends Command | ||
| 18 | +{ | ||
| 19 | + /** | ||
| 20 | + * The name and signature of the console command. | ||
| 21 | + * | ||
| 22 | + * @var string | ||
| 23 | + */ | ||
| 24 | + protected $signature = 'sync_inquiry_relay'; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * The console command description. | ||
| 28 | + * | ||
| 29 | + * @var string | ||
| 30 | + */ | ||
| 31 | + protected $description = '同步询盘信息:站群询盘,'; | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * Create a new command instance. | ||
| 35 | + * | ||
| 36 | + * @return void | ||
| 37 | + */ | ||
| 38 | + public function __construct() | ||
| 39 | + { | ||
| 40 | + parent::__construct(); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + | ||
| 44 | + public function handle() | ||
| 45 | + { | ||
| 46 | + $this->getInquiryForm(); | ||
| 47 | + $this->getInquirySzcm(); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 获取表单系统中询盘信息 | ||
| 52 | + * message_sign唯一值:md5(name+email+phone+ip+time) | ||
| 53 | + */ | ||
| 54 | + public function getInquiryForm() | ||
| 55 | + { | ||
| 56 | + $service = new InquiryRelayService(); | ||
| 57 | + $result = $service->getInquiryRelay(); | ||
| 58 | + if (isset($result['status']) && $result['status'] == 200) { | ||
| 59 | + $data = $result['data'] ?? []; | ||
| 60 | + foreach ($data as $item) { | ||
| 61 | + $this->saveDate($item, $item['source_type']); | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * 获取秋哥asp采集询盘信息 | ||
| 68 | + * type固定4 | ||
| 69 | + * message_sign唯一值:md5(name+email+phone+ip+time) | ||
| 70 | + * 先查数据库最大origin_key,再获取数据 | ||
| 71 | + */ | ||
| 72 | + public function getInquirySzcm() | ||
| 73 | + { | ||
| 74 | + $max_origin_key = InquiryInfo::where('type', 4)->orderBy('origin_key', 'desc')->value('origin_key'); | ||
| 75 | + if ($max_origin_key) { | ||
| 76 | + $start_id = $max_origin_key + 1; | ||
| 77 | + } else { | ||
| 78 | + $start_id = 65029; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + $service = new InquiryRelayService(); | ||
| 82 | + while ($start_id > 0) { | ||
| 83 | + $result = $service->getInquirySzcm($start_id); | ||
| 84 | + if ($result) { | ||
| 85 | + $this->saveDate($result, 4); | ||
| 86 | + $start_id += 1; | ||
| 87 | + } else { | ||
| 88 | + $start_id = 0; | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public function saveDate($data, $type) | ||
| 94 | + { | ||
| 95 | + $model = new InquiryInfo(); | ||
| 96 | + $message_sign = md5($data['name'] . $data['email'] . $data['phone'] . $data['ip'] . $data['time']); | ||
| 97 | + $inquiry_info = $model->where('message_sign', $message_sign)->first(); | ||
| 98 | + if (!$inquiry_info) { | ||
| 99 | + //没有IP,根据submit_country获取 | ||
| 100 | + if (empty($data['ip']) && isset($data['submit_country']) && $data['submit_country']) { | ||
| 101 | + $chinese_name = DB::table('gl_world_country_city')->where('pid', 0)->where('iso2', $data['submit_country'])->value('chinese_name'); | ||
| 102 | + $data['ip'] = $this->getIpData($chinese_name); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + //获取country | ||
| 106 | + $country = ''; | ||
| 107 | + if ($data['ip']) { | ||
| 108 | + $country = file_get_contents("http://ip.globalso.com?ip=" . $data['ip']); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + //翻译message | ||
| 112 | + $message_cn = ''; | ||
| 113 | + $re_message_trans = Translate::translate($data['message'], 'zh'); | ||
| 114 | + if (isset($re_message_trans[0]['code']) && $re_message_trans[0]['code'] == 200) { | ||
| 115 | + $message_cn = $re_message_trans[0]['texts']; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + //获取页面上title和keywords | ||
| 119 | + $html = curl_c($data['refer'], false); | ||
| 120 | + | ||
| 121 | + if (empty($data['title'])) { | ||
| 122 | + preg_match_all('/<title>([\w\W]*?)<\/title>/', $html, $matches); | ||
| 123 | + if (!empty($matches[1])) { | ||
| 124 | + $data['title'] = substr($matches[1][0], 0, 255); | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + $keywords = ''; | ||
| 129 | + preg_match_all('/<meta\s+[^>]*?name=[\'|\"]keywords[\'|\"]\s+[^>]*?content=[\'|\"]([\w\W]*?)[\'|\"]/', $html, $matches); | ||
| 130 | + if (!empty($matches[1])) { | ||
| 131 | + $keywords = substr($matches[1][0], 0, 255); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + if (empty($data['origin_key'])) { | ||
| 135 | + $data['origin_key'] = 0; | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + if (empty($data['image'])) { | ||
| 139 | + $data['image'] = ''; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + $model->createInquiry($data['name'], $data['phone'], $data['email'], $data['ip'], $country, $data['message'], $message_cn, $type, $data['time'], $data['refer'], $data['title'], $keywords, $message_sign, $data['origin_key'], $data['image']); | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + /** | ||
| 147 | + * 获取国家随机ip | ||
| 148 | + * @param $country_name | ||
| 149 | + * @return mixed|string | ||
| 150 | + * @author Akun | ||
| 151 | + * @date 2025/02/14 14:19 | ||
| 152 | + */ | ||
| 153 | + public function getIpData($country_name) | ||
| 154 | + { | ||
| 155 | + // 有国家 通过国家查询, 如果没有获取到就随机获取 | ||
| 156 | + $where = []; | ||
| 157 | + $country_name && $where['ip_area'] = $country_name; | ||
| 158 | + $ip = DB::table('gl_xunpan_ipdata')->where($where)->inRandomOrder()->value('ip'); | ||
| 159 | + if (empty($ip_data)) { | ||
| 160 | + $ip = DB::table('gl_xunpan_ipdata')->inRandomOrder()->value('ip'); | ||
| 161 | + } | ||
| 162 | + return $ip; | ||
| 163 | + } | ||
| 164 | +} |
| @@ -2,9 +2,14 @@ | @@ -2,9 +2,14 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers\Bside\Ai; | 3 | namespace App\Http\Controllers\Bside\Ai; |
| 4 | 4 | ||
| 5 | +use App\Enums\Common\Code; | ||
| 5 | use App\Http\Controllers\Bside\BaseController; | 6 | use App\Http\Controllers\Bside\BaseController; |
| 6 | use App\Http\Logic\Bside\Ai\AiBlogLogic; | 7 | use App\Http\Logic\Bside\Ai\AiBlogLogic; |
| 7 | use App\Http\Requests\Bside\Ai\AiBlogRequest; | 8 | use App\Http\Requests\Bside\Ai\AiBlogRequest; |
| 9 | +use App\Models\Ai\AiBlog; | ||
| 10 | +use App\Services\AiBlogService; | ||
| 11 | +use App\Services\ProjectServer; | ||
| 12 | +use Illuminate\Support\Facades\DB; | ||
| 8 | 13 | ||
| 9 | class AiBlogController extends BaseController | 14 | class AiBlogController extends BaseController |
| 10 | { | 15 | { |
| @@ -20,4 +25,36 @@ class AiBlogController extends BaseController | @@ -20,4 +25,36 @@ class AiBlogController extends BaseController | ||
| 20 | $aiBlogLogic->blogSave(); | 25 | $aiBlogLogic->blogSave(); |
| 21 | $this->response('success'); | 26 | $this->response('success'); |
| 22 | } | 27 | } |
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * @remark :获取ai博客列表 | ||
| 31 | + * @name :getAiBlog | ||
| 32 | + * @author :lyh | ||
| 33 | + * @method :post | ||
| 34 | + * @time :2025/2/14 13:59 | ||
| 35 | + */ | ||
| 36 | + public function getAiBlog(AiBlog $aiBlog){ | ||
| 37 | + $lists = $aiBlog->lists($this->map,$this->page,$this->row,'id',['id','new_title','task_id','status','created_at','updated_at']); | ||
| 38 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * @remark :发布任务 | ||
| 43 | + * @name :sendTask | ||
| 44 | + * @author :lyh | ||
| 45 | + * @method :post | ||
| 46 | + * @time :2025/2/14 10:25 | ||
| 47 | + */ | ||
| 48 | + public function sendTask(AiBlogLogic $aiBlogLogic){ | ||
| 49 | + $this->request->validate([ | ||
| 50 | + 'keyword'=>['required'], | ||
| 51 | + 'type'=>['required'] | ||
| 52 | + ],[ | ||
| 53 | + 'keyword.required' => '关键字不能为空', | ||
| 54 | + 'type.required' => '场景不能为空', | ||
| 55 | + ]); | ||
| 56 | + //获取当前项目的ai_blog设置 | ||
| 57 | + $result = $aiBlogLogic->sendTask(); | ||
| 58 | + $this->response('success',Code::SUCCESS,$result); | ||
| 59 | + } | ||
| 23 | } | 60 | } |
| @@ -662,7 +662,7 @@ class ProductController extends BaseController | @@ -662,7 +662,7 @@ class ProductController extends BaseController | ||
| 662 | 'product_id.required' => 'product_id不能为空', | 662 | 'product_id.required' => 'product_id不能为空', |
| 663 | ]); | 663 | ]); |
| 664 | $productInfo = $product->read(['id' => $this->param['product_id']]); | 664 | $productInfo = $product->read(['id' => $this->param['product_id']]); |
| 665 | - if (empty($productInfo)) { | 665 | + if ($productInfo == false) { |
| 666 | $this->fail('请选择有效产品信息!'); | 666 | $this->fail('请选择有效产品信息!'); |
| 667 | } | 667 | } |
| 668 | $productInfo = $this->handleParam($productInfo); | 668 | $productInfo = $this->handleParam($productInfo); |
| @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside; | @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside; | ||
| 12 | use App\Enums\Common\Code; | 12 | use App\Enums\Common\Code; |
| 13 | use App\Helper\PayStripeApi; | 13 | use App\Helper\PayStripeApi; |
| 14 | use App\Http\Logic\Bside\News\NewsLogic; | 14 | use App\Http\Logic\Bside\News\NewsLogic; |
| 15 | +use App\Models\Ai\AiBlog; | ||
| 15 | use App\Models\Channel\Channel; | 16 | use App\Models\Channel\Channel; |
| 16 | use App\Models\CustomModule\CustomModuleCategory; | 17 | use App\Models\CustomModule\CustomModuleCategory; |
| 17 | use App\Models\CustomModule\CustomModuleContent; | 18 | use App\Models\CustomModule\CustomModuleContent; |
| @@ -21,24 +22,38 @@ use App\Models\ExtentModule\ExtensionModuleValue; | @@ -21,24 +22,38 @@ use App\Models\ExtentModule\ExtensionModuleValue; | ||
| 21 | use App\Models\Manage\ManageHr; | 22 | use App\Models\Manage\ManageHr; |
| 22 | use App\Models\Project\CountAllProject as AllProject; | 23 | use App\Models\Project\CountAllProject as AllProject; |
| 23 | use App\Models\Project\Project; | 24 | use App\Models\Project\Project; |
| 25 | +use App\Models\Project\ProjectAiSetting; | ||
| 24 | use App\Models\RouteMap\RouteMap; | 26 | use App\Models\RouteMap\RouteMap; |
| 27 | +use App\Services\AiBlogService; | ||
| 25 | use App\Services\ProjectServer; | 28 | use App\Services\ProjectServer; |
| 26 | use Illuminate\Support\Facades\DB; | 29 | use Illuminate\Support\Facades\DB; |
| 27 | 30 | ||
| 28 | class TestController extends BaseController | 31 | class TestController extends BaseController |
| 29 | { | 32 | { |
| 30 | /** | 33 | /** |
| 31 | - * @remark :非6.0拉取数据 | ||
| 32 | - * @name :NoSixProject | 34 | + * @remark :创建项目 |
| 35 | + * @name :createProject | ||
| 33 | * @author :lyh | 36 | * @author :lyh |
| 34 | * @method :post | 37 | * @method :post |
| 35 | - * @time :2024/11/11 14:51 | 38 | + * @time :2025/2/13 16:34 |
| 36 | */ | 39 | */ |
| 37 | public function ceshi(){ | 40 | public function ceshi(){ |
| 38 | - $pay = new PayStripeApi(); | ||
| 39 | - $data = $pay->createPaymentIntent(5000,'cny'); | ||
| 40 | - $this->response('success',Code::SUCCESS,$data); | 41 | + $aiBlogService = new AiBlogService(); |
| 42 | + $aiBlogService->mch_id = '100008'; | ||
| 43 | + $aiBlogService->key = '8a9c925bdcca'; | ||
| 44 | + $result = $aiBlogService->createTask('apple'); | ||
| 45 | + if($result['status'] == 200){ | ||
| 46 | + $param = [ | ||
| 47 | + 'keywords'=>'apple', | ||
| 48 | + 'status'=>$result['data']['status'], | ||
| 49 | + 'task_id'=>$result['data']['task_id'], | ||
| 50 | + 'project_id'=>1, | ||
| 51 | + ]; | ||
| 52 | + ProjectServer::useProject(1); | ||
| 53 | + $aiBlogModel = new AiBlog(); | ||
| 54 | + $aiBlogModel->add($param); | ||
| 55 | + DB::disconnect('custom_mysql'); | ||
| 56 | + } | ||
| 57 | + $this->response('success',Code::SUCCESS,$param); | ||
| 41 | } | 58 | } |
| 42 | - | ||
| 43 | - | ||
| 44 | } | 59 | } |
| @@ -30,6 +30,7 @@ use App\Models\Project\InquiryFilterConfig; | @@ -30,6 +30,7 @@ use App\Models\Project\InquiryFilterConfig; | ||
| 30 | use App\Models\Project\MinorLanguages; | 30 | use App\Models\Project\MinorLanguages; |
| 31 | use App\Models\Project\Payment; | 31 | use App\Models\Project\Payment; |
| 32 | use App\Models\Project\Project; | 32 | use App\Models\Project\Project; |
| 33 | +use App\Models\Project\ProjectAiSetting; | ||
| 33 | use App\Models\Project\ProjectKeyword; | 34 | use App\Models\Project\ProjectKeyword; |
| 34 | use App\Models\Project\ProjectRenew; | 35 | use App\Models\Project\ProjectRenew; |
| 35 | use App\Models\Project\WebTrafficConfig; | 36 | use App\Models\Project\WebTrafficConfig; |
| @@ -43,6 +44,7 @@ use App\Models\User\ProjectMenu; | @@ -43,6 +44,7 @@ use App\Models\User\ProjectMenu; | ||
| 43 | use App\Models\User\ProjectRole; | 44 | use App\Models\User\ProjectRole; |
| 44 | use App\Models\User\User as UserModel; | 45 | use App\Models\User\User as UserModel; |
| 45 | use App\Models\WebSetting\WebLanguage; | 46 | use App\Models\WebSetting\WebLanguage; |
| 47 | +use App\Services\AiBlogService; | ||
| 46 | use App\Services\ProjectServer; | 48 | use App\Services\ProjectServer; |
| 47 | use App\Services\SyncService; | 49 | use App\Services\SyncService; |
| 48 | use App\Utils\LogUtils; | 50 | use App\Utils\LogUtils; |
| @@ -158,6 +160,8 @@ class ProjectLogic extends BaseLogic | @@ -158,6 +160,8 @@ class ProjectLogic extends BaseLogic | ||
| 158 | $this->setServers($this->param['serve_id'],$this->param['id']); | 160 | $this->setServers($this->param['serve_id'],$this->param['id']); |
| 159 | //保存项目信息 | 161 | //保存项目信息 |
| 160 | $this->saveProject($this->param); | 162 | $this->saveProject($this->param); |
| 163 | + //ai_blog | ||
| 164 | + $this->setAiBlog($this->param['id'],$this->param['main_lang_id'],$this->param['is_ai_blog'],$this->param['title']); | ||
| 161 | //保存建站部署信息 | 165 | //保存建站部署信息 |
| 162 | $this->saveProjectDeployBuild($this->param['deploy_build']); | 166 | $this->saveProjectDeployBuild($this->param['deploy_build']); |
| 163 | //保存付费信息 | 167 | //保存付费信息 |
| @@ -184,6 +188,59 @@ class ProjectLogic extends BaseLogic | @@ -184,6 +188,59 @@ class ProjectLogic extends BaseLogic | ||
| 184 | } | 188 | } |
| 185 | 189 | ||
| 186 | /** | 190 | /** |
| 191 | + * @remark :开启AI博客后 | ||
| 192 | + * @name :setAiBlog | ||
| 193 | + * @author :lyh | ||
| 194 | + * @method :post | ||
| 195 | + * @time :2025/2/13 16:02 | ||
| 196 | + */ | ||
| 197 | + public function setAiBlog($project_id,$main_lang_id,$is_ai_blog,$title){ | ||
| 198 | + if(empty($main_lang_id) || empty($is_ai_blog)){ | ||
| 199 | + return true; | ||
| 200 | + } | ||
| 201 | + $projectModel = new Project(); | ||
| 202 | + $projectInfo = $projectModel->read(['id'=>$project_id],['is_ai_blog','main_lang_id']); | ||
| 203 | + //获取项目主语种 | ||
| 204 | + $languageModel = new WebLanguage(); | ||
| 205 | + $languageInfo = $languageModel->read(['id'=>$main_lang_id],['short']); | ||
| 206 | + if($languageInfo == false){ | ||
| 207 | + return true; | ||
| 208 | + } | ||
| 209 | + $aiSettingModel = new ProjectAiSetting(); | ||
| 210 | + $aiSettingInfo = $aiSettingModel->read(['project_id'=>$project_id]); | ||
| 211 | + if($aiSettingInfo === false){ | ||
| 212 | + $aiBlogService = new AiBlogService(); | ||
| 213 | + $result = $aiBlogService->createProject($title,$languageInfo['short'],$projectInfo['company']); | ||
| 214 | + if($result['status'] == 200){ | ||
| 215 | + //查看当前项目是否已有记录 | ||
| 216 | + $resData = [ | ||
| 217 | + 'project_id'=>$project_id, | ||
| 218 | + 'mch_id'=>$result['data']['mch_id'], | ||
| 219 | + 'key'=>$result['data']['key'], | ||
| 220 | + ]; | ||
| 221 | + $aiSettingModel->add($resData); | ||
| 222 | + } | ||
| 223 | + }else{ | ||
| 224 | + //有信息更新 | ||
| 225 | + if(($projectInfo['title'] != $title) || ($projectInfo['main_lang_id'] != $main_lang_id)){ | ||
| 226 | + $aiBlogService = new AiBlogService(); | ||
| 227 | + $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 228 | + $aiBlogService->key = $aiSettingInfo['key']; | ||
| 229 | + $result = $aiBlogService->updatedProject($title,$languageInfo['short']); | ||
| 230 | + if($result['status'] == 200){ | ||
| 231 | + $resData = [ | ||
| 232 | + 'mch_id'=>$result['data']['mch_id'], | ||
| 233 | + 'key'=>$result['data']['key'], | ||
| 234 | + ]; | ||
| 235 | + $aiSettingModel = new ProjectAiSetting(); | ||
| 236 | + $aiSettingModel->edit($resData,['project_id'=>$project_id]); | ||
| 237 | + } | ||
| 238 | + } | ||
| 239 | + } | ||
| 240 | + return true; | ||
| 241 | + } | ||
| 242 | + | ||
| 243 | + /** | ||
| 187 | * @remark :选择服务器后双向绑定 | 244 | * @remark :选择服务器后双向绑定 |
| 188 | * @name :setServers | 245 | * @name :setServers |
| 189 | * @author :lyh | 246 | * @author :lyh |
| @@ -4,6 +4,10 @@ namespace App\Http\Logic\Bside\Ai; | @@ -4,6 +4,10 @@ namespace App\Http\Logic\Bside\Ai; | ||
| 4 | 4 | ||
| 5 | use App\Http\Logic\Bside\BaseLogic; | 5 | use App\Http\Logic\Bside\BaseLogic; |
| 6 | use App\Models\Ai\AiBlog; | 6 | use App\Models\Ai\AiBlog; |
| 7 | +use App\Models\Project\AiBlogTask; | ||
| 8 | +use App\Models\Project\Project; | ||
| 9 | +use App\Models\Project\ProjectAiSetting; | ||
| 10 | +use App\Services\AiBlogService; | ||
| 7 | 11 | ||
| 8 | class AiBlogLogic extends BaseLogic | 12 | class AiBlogLogic extends BaseLogic |
| 9 | { | 13 | { |
| @@ -29,4 +33,35 @@ class AiBlogLogic extends BaseLogic | @@ -29,4 +33,35 @@ class AiBlogLogic extends BaseLogic | ||
| 29 | } | 33 | } |
| 30 | return $this->success(); | 34 | return $this->success(); |
| 31 | } | 35 | } |
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * @remark :发布任务 | ||
| 39 | + * @name :sendTask | ||
| 40 | + * @author :lyh | ||
| 41 | + * @method :post | ||
| 42 | + * @time :2025/2/14 10:28 | ||
| 43 | + */ | ||
| 44 | + public function sendTask(){ | ||
| 45 | + $projectAiSettingModel = new ProjectAiSetting(); | ||
| 46 | + $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 47 | + if($aiSettingInfo === false){ | ||
| 48 | + $this->fail('请先联系管理员开启Ai博客'); | ||
| 49 | + } | ||
| 50 | + $aiBlogService = new AiBlogService(); | ||
| 51 | + $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 52 | + $aiBlogService->key = $aiSettingInfo['key']; | ||
| 53 | + $result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']); | ||
| 54 | + if($result['status'] == 200){ | ||
| 55 | + try { | ||
| 56 | + $aiBlogTaskModel = new AiBlogTask(); | ||
| 57 | + $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'task_id'=>$result['data']['task_id'],'status'=>$result['data']['status']]); | ||
| 58 | + $aiBlogModel = new AiBlog(); | ||
| 59 | + $aiBlogModel->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>$result['data']['status'], 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'], | ||
| 60 | + ]); | ||
| 61 | + }catch (\Exception $e){ | ||
| 62 | + $this->fail('请求ai_blog失败,请联系管理员'); | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + return $this->success(); | ||
| 66 | + } | ||
| 32 | } | 67 | } |
| @@ -34,6 +34,9 @@ class AiCommandLogic extends BaseLogic | @@ -34,6 +34,9 @@ class AiCommandLogic extends BaseLogic | ||
| 34 | if(strpos($prompt, '{keyword}') !== false) { | 34 | if(strpos($prompt, '{keyword}') !== false) { |
| 35 | $prompt = str_replace('{keyword}', $this->param['keywords'], $prompt); | 35 | $prompt = str_replace('{keyword}', $this->param['keywords'], $prompt); |
| 36 | } | 36 | } |
| 37 | + if(strpos($prompt, '{topic}') !== false) { | ||
| 38 | + $prompt = str_replace('{topic}', $this->param['keywords'], $prompt); | ||
| 39 | + } | ||
| 37 | if(strpos($prompt, '{company introduction}') !== false) { | 40 | if(strpos($prompt, '{company introduction}') !== false) { |
| 38 | $company_introduction = $this->getDeployOptimize('company_en_description'); | 41 | $company_introduction = $this->getDeployOptimize('company_en_description'); |
| 39 | $prompt = str_replace('{company introduction}', $company_introduction, $prompt); | 42 | $prompt = str_replace('{company introduction}', $company_introduction, $prompt); |
| @@ -46,10 +46,10 @@ class CustomTemplateLogic extends BaseLogic | @@ -46,10 +46,10 @@ class CustomTemplateLogic extends BaseLogic | ||
| 46 | */ | 46 | */ |
| 47 | public function customTemplateInfo(){ | 47 | public function customTemplateInfo(){ |
| 48 | $info = $this->model->read(['id'=>$this->param['id']]); | 48 | $info = $this->model->read(['id'=>$this->param['id']]); |
| 49 | - $info['image'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']); | ||
| 50 | if($info === false){ | 49 | if($info === false){ |
| 51 | $this->fail('当前数据不存在'); | 50 | $this->fail('当前数据不存在'); |
| 52 | } | 51 | } |
| 52 | + $info['image'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']); | ||
| 53 | if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){ | 53 | if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){ |
| 54 | $template_id = $this->getTemplateId(); | 54 | $template_id = $this->getTemplateId(); |
| 55 | $html = $this->getTemplateComHtml($info['html'],$info['html_style'],$template_id); | 55 | $html = $this->getTemplateComHtml($info['html'],$info['html_style'],$template_id); |
| @@ -12,6 +12,12 @@ use App\Models\Base; | @@ -12,6 +12,12 @@ use App\Models\Base; | ||
| 12 | */ | 12 | */ |
| 13 | class InquiryInfo extends Base | 13 | class InquiryInfo extends Base |
| 14 | { | 14 | { |
| 15 | + /** | ||
| 16 | + * @var string 数据表 | ||
| 17 | + */ | ||
| 18 | + protected $table = 'gl_inquiry_info'; | ||
| 19 | + | ||
| 20 | + // TODO 之前的状态, 留下可以找到之前的程序 | ||
| 15 | const STATUS_ZERO = 0;//未转发 | 21 | const STATUS_ZERO = 0;//未转发 |
| 16 | const STATUS_ONE = 1;//无效 | 22 | const STATUS_ONE = 1;//无效 |
| 17 | 23 | ||
| @@ -21,5 +27,87 @@ class InquiryInfo extends Base | @@ -21,5 +27,87 @@ class InquiryInfo extends Base | ||
| 21 | 27 | ||
| 22 | const STATUS_FOUR = 4;//延时转发中 | 28 | const STATUS_FOUR = 4;//延时转发中 |
| 23 | 29 | ||
| 24 | - protected $table = 'gl_inquiry_info'; | 30 | + const STATUS_INIT = 0; |
| 31 | + const STATUS_FINISH = 1; | ||
| 32 | + const STATUS_INVALID = 2; | ||
| 33 | + const STATUS_FAIL = 9; | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + const TYPE_SITE_GROUP = 1; | ||
| 37 | + const TYPE_ADS = 2; | ||
| 38 | + const TYPE_AI_SITE_GROUP = 3; | ||
| 39 | + const TYPE_SPIDER = 4; | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 状态映射 | ||
| 43 | + * @return array | ||
| 44 | + */ | ||
| 45 | + public function statusMap() | ||
| 46 | + { | ||
| 47 | + return [ | ||
| 48 | + self::STATUS_INIT => '未处理', | ||
| 49 | + self::STATUS_FINISH => '已处理', | ||
| 50 | + self::STATUS_INVALID => '无效数据', | ||
| 51 | + self::STATUS_FAIL => '失败数据', | ||
| 52 | + ]; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * 类型映射 | ||
| 57 | + * @return array | ||
| 58 | + */ | ||
| 59 | + public function typeMap() | ||
| 60 | + { | ||
| 61 | + return [ | ||
| 62 | + self::TYPE_SITE_GROUP => '站群询盘', | ||
| 63 | + self::TYPE_ADS => 'ads采集站询盘', | ||
| 64 | + self::TYPE_AI_SITE_GROUP => 'AI站群询盘', | ||
| 65 | + self::TYPE_SPIDER => '蜘蛛询盘', | ||
| 66 | + ]; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * 创建新盘信息 | ||
| 71 | + * @param $name | ||
| 72 | + * @param $phone | ||
| 73 | + * @param $email | ||
| 74 | + * @param $ip | ||
| 75 | + * @param $country | ||
| 76 | + * @param $message | ||
| 77 | + * @param $message_cn | ||
| 78 | + * @param $type | ||
| 79 | + * @param $inquiry_date | ||
| 80 | + * @param $url | ||
| 81 | + * @param $url_title | ||
| 82 | + * @param $url_keyword | ||
| 83 | + * @param $message_sign | ||
| 84 | + * @param $origin_key | ||
| 85 | + * @param string $image | ||
| 86 | + * @return bool | ||
| 87 | + */ | ||
| 88 | + public function createInquiry($name, $phone, $email, $ip, $country, $message, $message_cn, $type, $inquiry_date, $url, $url_title, $url_keyword, $message_sign, $origin_key, $image = '') | ||
| 89 | + { | ||
| 90 | + try { | ||
| 91 | + $self = new self(); | ||
| 92 | + $self->name = $name; | ||
| 93 | + $self->phone = $phone; | ||
| 94 | + $self->email = $email; | ||
| 95 | + $self->ip = $ip; | ||
| 96 | + $self->country = $country; | ||
| 97 | + $self->message = $message; | ||
| 98 | + $self->message_cn = $message_cn; | ||
| 99 | + $self->type = $type; | ||
| 100 | + $self->inquiry_date = $inquiry_date; | ||
| 101 | + $self->url = $url; | ||
| 102 | + $self->url_title = $url_title; | ||
| 103 | + $self->url_keyword = $url_keyword; | ||
| 104 | + $self->image = $image; | ||
| 105 | + $self->origin_key = $origin_key; | ||
| 106 | + $self->message_sign = $message_sign; | ||
| 107 | + $self->save(); | ||
| 108 | + return true; | ||
| 109 | + } catch (\Exception $e) { | ||
| 110 | + return false; | ||
| 111 | + } | ||
| 112 | + } | ||
| 25 | } | 113 | } |
app/Models/Project/AiBlogTask.php
0 → 100644
app/Models/Project/ProjectAiSetting.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :ProjectAiSetting.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/2/13 16:53 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Project; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * @remark :项目ai_blog设置 | ||
| 16 | + * @name :ProjectAiSetting | ||
| 17 | + * @author :lyh | ||
| 18 | + * @method :post | ||
| 19 | + * @time :2025/2/13 16:53 | ||
| 20 | + */ | ||
| 21 | +class ProjectAiSetting extends Base | ||
| 22 | +{ | ||
| 23 | + protected $table = 'gl_project_ai_setting'; | ||
| 24 | +} |
app/Services/AiBlogService.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AiBlogService.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/2/13 14:15 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Services; | ||
| 11 | + | ||
| 12 | +class AiBlogService | ||
| 13 | +{ | ||
| 14 | + public $url = 'https://ai-extend.ai.cc/'; | ||
| 15 | + | ||
| 16 | + public $mch_id = 1;//默认配置 | ||
| 17 | + public $sign = '';//签名 | ||
| 18 | + public $key = 'b3e4c722b821';//默认key | ||
| 19 | + | ||
| 20 | + public $webhook = 'https://develop.globalso.com/api/ai_webhook';//回调地址 | ||
| 21 | + | ||
| 22 | + public $task_id = '';//任务id | ||
| 23 | + /** | ||
| 24 | + * @remark :创建项目 | ||
| 25 | + * @name :createProject | ||
| 26 | + * @author :lyh | ||
| 27 | + * @method :post | ||
| 28 | + * @time :2025/2/13 14:28 | ||
| 29 | + */ | ||
| 30 | + public function createProject($project_name,$language = 'en',$profile){ | ||
| 31 | + $request_url = $this->url.'api/project/create'; | ||
| 32 | + $param = [ | ||
| 33 | + 'mch_id'=>$this->mch_id, | ||
| 34 | + 'title'=>$project_name, | ||
| 35 | + 'language'=>$language, | ||
| 36 | + 'profile'=>$profile | ||
| 37 | + ]; | ||
| 38 | + $this->sign = $this->generateSign($param,$this->key); | ||
| 39 | + $param['sign'] = $this->sign; | ||
| 40 | + $result = http_post($request_url,json_encode($param,true)); | ||
| 41 | + return $result; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * @remark :更新项目 | ||
| 46 | + * @name :updatedProject | ||
| 47 | + * @author :lyh | ||
| 48 | + * @method :post | ||
| 49 | + * @time :2025/2/13 14:35 | ||
| 50 | + */ | ||
| 51 | + public function updatedProject($project_name,$language = 'en'){ | ||
| 52 | + $request_url = $this->url.'api/project/save'; | ||
| 53 | + $param = [ | ||
| 54 | + 'mch_id'=>$this->mch_id, | ||
| 55 | + 'title'=>$project_name, | ||
| 56 | + 'language'=>$language | ||
| 57 | + ]; | ||
| 58 | + $this->sign = $this->generateSign($param,$this->key); | ||
| 59 | + $param['sign'] = $this->sign; | ||
| 60 | + $result = http_post($request_url,json_encode($param,true)); | ||
| 61 | + return $result; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * @remark :创建任务 | ||
| 66 | + * @name :createTask | ||
| 67 | + * @author :lyh | ||
| 68 | + * @method :post | ||
| 69 | + * @time :2025/2/13 14:39 | ||
| 70 | + * @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url | ||
| 71 | + */ | ||
| 72 | + public function createTask($keyword,$type = 1,$subtype = 'Blog',$template_id = 1){ | ||
| 73 | + $request_url = $this->url.'api/task/create'; | ||
| 74 | + $param = [ | ||
| 75 | + 'mch_id'=>$this->mch_id, | ||
| 76 | + 'keyword'=>$keyword, | ||
| 77 | + 'type'=>$type, | ||
| 78 | + 'subtype'=>$subtype, | ||
| 79 | + 'url'=>$this->webhook, | ||
| 80 | + 'template_id'=>$template_id | ||
| 81 | + ]; | ||
| 82 | + $this->sign = $this->generateSign($param,$this->key); | ||
| 83 | + $param['sign'] = $this->sign; | ||
| 84 | + $result = http_post($request_url,json_encode($param,true)); | ||
| 85 | + return $result; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * @remark :创建作者 | ||
| 90 | + * @name :createAuthor | ||
| 91 | + * @author :lyh | ||
| 92 | + * @method :post | ||
| 93 | + * @time :2025/2/13 14:43 | ||
| 94 | + */ | ||
| 95 | + public function createAuthor(){ | ||
| 96 | + $request_url = $this->url.'api/author/create'; | ||
| 97 | + $param = [ | ||
| 98 | + 'mch_id'=>$this->mch_id, | ||
| 99 | + 'sign'=>$this->sign, | ||
| 100 | + ]; | ||
| 101 | + $result = http_post($request_url,json_encode($param,true)); | ||
| 102 | + return $result; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * @remark :计算签名 | ||
| 107 | + * @name :generateSign | ||
| 108 | + * @author :lyh | ||
| 109 | + * @method :post | ||
| 110 | + * @time :2025/2/13 15:07 | ||
| 111 | + */ | ||
| 112 | + public function generateSign($params, $key) | ||
| 113 | + { | ||
| 114 | + // 去除数组中所有值为空的项 | ||
| 115 | + array_filter($params); | ||
| 116 | + // 按照key值的ASCII码从小到大排序 | ||
| 117 | + ksort($params); | ||
| 118 | + // 生成URL的查询字符串 | ||
| 119 | + $string = http_build_query($params); | ||
| 120 | + // 生成签名 | ||
| 121 | + $sign = md5($string . $key); | ||
| 122 | + // 转换成大写 | ||
| 123 | + $sign = strtoupper($sign); | ||
| 124 | + return $sign; | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * @remark :获取文章详情 | ||
| 129 | + * @name :getDetail | ||
| 130 | + * @author :lyh | ||
| 131 | + * @method :post | ||
| 132 | + * @time :2025/2/14 11:23 | ||
| 133 | + */ | ||
| 134 | + public function getDetail(){ | ||
| 135 | + $request_url = $this->url.'api/result/detail'; | ||
| 136 | + $param = [ | ||
| 137 | + 'mch_id'=>$this->mch_id, | ||
| 138 | + 'task_id'=>$this->task_id, | ||
| 139 | + ]; | ||
| 140 | + $this->sign = $this->generateSign($param,$this->key); | ||
| 141 | + $param['sign'] = $this->sign; | ||
| 142 | + $result = http_post($request_url,json_encode($param,true)); | ||
| 143 | + return $result; | ||
| 144 | + } | ||
| 145 | +} |
app/Services/InquiryRelayService.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: zhl | ||
| 5 | + * Date: 2025/2/13 | ||
| 6 | + * Time: 11:01 | ||
| 7 | + */ | ||
| 8 | +namespace App\Services; | ||
| 9 | + | ||
| 10 | +use Illuminate\Support\Facades\Log; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Class InquiryRelayService | ||
| 14 | + * @package App\Services | ||
| 15 | + */ | ||
| 16 | +class InquiryRelayService | ||
| 17 | +{ | ||
| 18 | + /** | ||
| 19 | + * 获取询盘 | ||
| 20 | + * @return mixed|string | ||
| 21 | + */ | ||
| 22 | + public function getInquiryRelay() | ||
| 23 | + { | ||
| 24 | + $date = date('Y-m-d'); | ||
| 25 | + $token = md5($date . 'qqs'); | ||
| 26 | + $url = 'https://form.globalso.com/api/external-interface/echo_inquriy/d1483a8e57cb485a?date=' . $date . '&token=' . $token . '&type=2'; | ||
| 27 | + $result = http_get($url); | ||
| 28 | + return $result; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 获取询盘 | ||
| 33 | + * @param $id | ||
| 34 | + * @return array|bool | ||
| 35 | + */ | ||
| 36 | + public function getInquirySzcm($id) | ||
| 37 | + { | ||
| 38 | + try { | ||
| 39 | + // 获取数据 | ||
| 40 | + $url = "https://api.szcmapi.com/get_inquiry.aspx?id=".$id; | ||
| 41 | + $json = $this->szcmCurl($url); | ||
| 42 | + // 兼容过去到的数据, 比较乱 | ||
| 43 | + $json = trim(str_replace("\r\n", '\n', (string) $json)); | ||
| 44 | + $json = str_replace('3/4"','3/4',$json); | ||
| 45 | + $json = str_replace('"Steklopribor"','Steklopribor',$json); | ||
| 46 | + $json = str_replace('"Net30 days"','Net30 days',$json); | ||
| 47 | + $json = trim($json); | ||
| 48 | + $json = str_replace("\n",'',$json); | ||
| 49 | + $array = json_decode($json,true); | ||
| 50 | + | ||
| 51 | + if (empty($array)) | ||
| 52 | + return false; | ||
| 53 | + | ||
| 54 | + // 整合最终数据 | ||
| 55 | + $title = base64_decode($array['title']); | ||
| 56 | + $title = str_replace("'",'',$title); | ||
| 57 | + $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8'); | ||
| 58 | + $title = str_replace("'",'',$title); | ||
| 59 | + $message = html_entity_decode(addslashes(base64_decode($array['Message'])), ENT_QUOTES, 'UTF-8'); | ||
| 60 | + $message = str_replace("'",'',$message); | ||
| 61 | + $email = trim($array['Email']); | ||
| 62 | + $name = html_entity_decode($array['Name'], ENT_QUOTES, 'UTF-8'); | ||
| 63 | + $name = str_replace("'",'',$name); | ||
| 64 | + | ||
| 65 | + $result = [ | ||
| 66 | + 'image' => $array['image'] ?: '', | ||
| 67 | + 'time' => $array['submit_time'] ?: date('Y-m-d H:i:s'), | ||
| 68 | + 'name' => $name, | ||
| 69 | + 'email' => $email, | ||
| 70 | + 'phone' => $array['Phone'] ?: '', | ||
| 71 | + 'refer' => $array['refer'] ?: '', | ||
| 72 | + 'message' => $message, | ||
| 73 | + 'ip' => $array['submit_ip'] ?: '', | ||
| 74 | + 'source_address' => 'api.szcmapi.com', | ||
| 75 | + 'title' => $title, | ||
| 76 | + 'submit_country' => $array['submit_country'] ?: '', | ||
| 77 | + 'origin_key' => $array['Id'], | ||
| 78 | + ]; | ||
| 79 | + return $result; | ||
| 80 | + } catch (\Exception $e) { | ||
| 81 | + Log::error('获取询盘: getInquirySzcm : ' . $id . ', error: ' . $e->getMessage()); | ||
| 82 | + return false; | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * @param $url | ||
| 88 | + * @return bool|string | ||
| 89 | + */ | ||
| 90 | + public function szcmCurl($url) | ||
| 91 | + { | ||
| 92 | + $agent = 'ChuangMao_API_Bot'; | ||
| 93 | + $ch = curl_init($url); | ||
| 94 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
| 95 | + curl_setopt($ch, CURLOPT_HEADER, false); | ||
| 96 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | ||
| 97 | + curl_setopt($ch, CURLOPT_USERAGENT, $agent); | ||
| 98 | + curl_setopt($ch, CURLOPT_AUTOREFERER, true); | ||
| 99 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); | ||
| 100 | + curl_setopt($ch, CURLOPT_TIMEOUT, 120); | ||
| 101 | + curl_setopt($ch, CURLOPT_MAXREDIRS, 10); | ||
| 102 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
| 103 | + curl_setopt($ch, CURLOPT_SSLVERSION, 'all'); | ||
| 104 | + $result = curl_exec($ch); | ||
| 105 | + curl_close($ch); | ||
| 106 | + return $result; | ||
| 107 | + } | ||
| 108 | +} |
| @@ -153,7 +153,9 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -153,7 +153,9 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 153 | Route::prefix('ai')->group(function () { | 153 | Route::prefix('ai')->group(function () { |
| 154 | //ai | 154 | //ai |
| 155 | Route::any('/news/', [\App\Http\Controllers\Bside\Ai\AiNewsController::class, 'save'])->name('ai_news_save'); | 155 | Route::any('/news/', [\App\Http\Controllers\Bside\Ai\AiNewsController::class, 'save'])->name('ai_news_save'); |
| 156 | - Route::any('/blog/', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'save'])->name('ai_blog_save'); | 156 | + Route::any('/blog/getAiBlog', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'getAiBlog'])->name('ai_blog_getAiBlog'); |
| 157 | + Route::any('/blog/save', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'save'])->name('ai_blog_save'); | ||
| 158 | + Route::any('/blog/sendTask', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'sendTask'])->name('ai_blog_sendTask'); | ||
| 157 | Route::any('/product/', [\App\Http\Controllers\Bside\Ai\AiProductController::class, 'save'])->name('ai_product_save'); | 159 | Route::any('/product/', [\App\Http\Controllers\Bside\Ai\AiProductController::class, 'save'])->name('ai_product_save'); |
| 158 | Route::any('/product/productList', [\App\Http\Controllers\Bside\Ai\AiProductController::class, 'productList'])->name('ai_product_productList'); | 160 | Route::any('/product/productList', [\App\Http\Controllers\Bside\Ai\AiProductController::class, 'productList'])->name('ai_product_productList'); |
| 159 | Route::any('/product/productCateList', [\App\Http\Controllers\Bside\Ai\AiProductController::class, 'productCateList'])->name('ai_product_productCateList'); | 161 | Route::any('/product/productCateList', [\App\Http\Controllers\Bside\Ai\AiProductController::class, 'productCateList'])->name('ai_product_productCateList'); |
-
请 注册 或 登录 后发表评论