作者 lyh

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6

正在显示 50 个修改的文件 包含 2580 行增加988 行删除

要显示太多修改。

为保证性能只显示 50 of 50+ 个文件。

1 /node_modules 1 /node_modules
2 /public/hot 2 /public/hot
3 /public/storage 3 /public/storage
  4 +/public/.user.ini
4 /storage 5 /storage
5 /vendor 6 /vendor
6 /uploads 7 /uploads
7 -composer.json 8 +composer.lock
8 .env 9 .env
9 .env.backup 10 .env.backup
10 .phpunit.result.cache 11 .phpunit.result.cache
@@ -19,3 +20,6 @@ composer.lock @@ -19,3 +20,6 @@ composer.lock
19 app/Console/Commands/Test/Demo.php 20 app/Console/Commands/Test/Demo.php
20 /public/upload 21 /public/upload
21 /public/runtime 22 /public/runtime
  23 +public/nginx.htaccess
  24 +public/.htaccess
  25 +.gitignore
  1 +<html>
  2 +<head><title>404 Not Found</title></head>
  3 +<body>
  4 +<center><h1>404 Not Found</h1></center>
  5 +<hr><center>nginx</center>
  6 +</body>
  7 +</html>
@@ -66,7 +66,6 @@ class ShareUser extends Command @@ -66,7 +66,6 @@ class ShareUser extends Command
66 //删除用户第三方配置 66 //删除用户第三方配置
67 if(!empty($v['profile_key'])){ 67 if(!empty($v['profile_key'])){
68 $this->del_profiles($v); 68 $this->del_profiles($v);
69 - continue;  
70 } 69 }
71 //更新数据库 70 //更新数据库
72 $this->save_ayr_share($ayr_share_model,$v); 71 $this->save_ayr_share($ayr_share_model,$v);
1 -<?php  
2 -  
3 -namespace App\Console\Commands\Bside\Statistics;  
4 -  
5 -use App\Models\Bside\Statistics\TrafficStatistics;  
6 -use App\Models\CustomerVisit\CustomerVisit;  
7 -use Illuminate\Console\Command;  
8 -use Illuminate\Support\Facades\DB;  
9 -use Throwable;  
10 -  
11 -class Logic  
12 -{  
13 -  
14 - /**  
15 - * @param int $type 统计类型  
16 - * @return array  
17 - */  
18 - public function getMonths(int $type = TrafficStatistics::TYPE_SOURCE)  
19 - {  
20 - $date = getPreviousMonthsDate();  
21 - $TrafficStatistics = new TrafficStatistics();  
22 - $lists = $TrafficStatistics->getMonthsLists($type, $date);  
23 - if (!empty($lists)) {  
24 - $dd = [];  
25 - $lists->map(function ($item) use (&$dd) {  
26 - $dd[] = $item->year . '-' . str_pad($item->month, 2, '0', STR_PAD_LEFT);  
27 - });  
28 - $date = array_diff($date, $dd);  
29 - }  
30 - return $date;  
31 - }  
32 -  
33 - /**  
34 - * @param array $column 统计数据  
35 - * @param int $type 统计类型  
36 - * @param string|null $date 日期 格式:Y-m  
37 - * @param string $message  
38 - * @return array  
39 - * @throws Throwable  
40 - */  
41 - public function save(array $column, int $type = TrafficStatistics::TYPE_SOURCE, string $date = null, $message = '统计当月访问来源数据')  
42 - {  
43 - DB::beginTransaction();  
44 - // 获取当天的IP|PV数量  
45 - $customerVisit = new CustomerVisit();  
46 - $ip_count = $customerVisit->getMonthIPCount($date);  
47 - $pv_count = $customerVisit->getMonthPVCount($date);  
48 - $column['pvnum'] = $pv_count;  
49 - $column['ipnum'] = $ip_count;  
50 - $date = $date ?? date('Y-m');  
51 - // 统计数据并插入到数据库  
52 - $dd = explode('-', $date);  
53 - $year = $dd[0];  
54 - $month = $dd[1];  
55 - $column['year'] = $year;  
56 - $column['month'] = $month;  
57 - $trafficStatistics = new TrafficStatistics();  
58 - $isRes = $trafficStatistics->getMonth($type, $year, $month);  
59 - if ($isRes) {  
60 - $trafficStatistics = $isRes;  
61 - }  
62 - foreach ($column as $key => $value) {  
63 - $trafficStatistics->$key = $value;  
64 - }  
65 - $res = $trafficStatistics->save();  
66 - if ($res) {  
67 - DB::commit();  
68 - $meg = "{$date} - {$message}成功!";  
69 - } else {  
70 - DB::rollBack();  
71 - $meg = "{$date} - {$message}失败!";  
72 - }  
73 - return ['status' => $res, 'msg' => $meg];  
74 - }  
75 -}  
1 -<?php  
2 -  
3 -namespace App\Console\Commands\Bside\Statistics;  
4 -  
5 -use App\Models\Bside\Statistics\TrafficTrends;  
6 -use App\Models\CustomerVisit\CustomerVisit;  
7 -use GuzzleHttp\Exception\GuzzleException;  
8 -use Illuminate\Console\Command;  
9 -use Illuminate\Support\Facades\DB;  
10 -use Throwable;  
11 -  
12 -class StatisticsDayTrend extends Command  
13 -{  
14 - public $error = 0;  
15 - /**  
16 - * The name and signature of the console command.  
17 - *  
18 - * @var string  
19 - */  
20 - protected $signature = 'statistics_day_trend';  
21 -  
22 - /**  
23 - * The console command description.  
24 - *  
25 - * @var string  
26 - */  
27 - protected $description = '统计当天流量趋势数据';  
28 -  
29 - /**  
30 - * @return void  
31 - * @throws GuzzleException  
32 - * @throws Throwable  
33 - */  
34 - public function handle()  
35 - {  
36 - $date = getPreviousDaysDate();  
37 - $trafficTrends = new TrafficTrends();  
38 - $lists = $trafficTrends->getDaysLists($date);  
39 - if (!empty($lists)) {  
40 - $date = array_diff($date, $lists->pluck('day')->all());  
41 - }  
42 - if (!empty($date)) {  
43 - foreach ($date as $value) {  
44 - echo $this->statistics_day_trend($value);  
45 - }  
46 - }  
47 - echo $this->statistics_day_trend();  
48 - }  
49 -  
50 - /**  
51 - * 统计当天流量趋势数据PV|IP数量  
52 - * @return int|mixed  
53 - * @throws GuzzleException|Throwable  
54 - */  
55 - protected function statistics_day_trend($date = null)  
56 - {  
57 - DB::beginTransaction();  
58 - $date = $date ?? date('Y-m-d');  
59 - // 获取当天的IP|PV数量  
60 - $customerVisit = new CustomerVisit();  
61 - $ip_count = $customerVisit->getDayIPCount($date);  
62 - $pv_count = $customerVisit->getDayPVCount($date);  
63 - // 统计数据并插入到数据库  
64 - $trafficTrends = new TrafficTrends();  
65 - $isRes = $trafficTrends->getDay($date);  
66 - if ($isRes) {  
67 - $trafficTrends = $isRes;  
68 - }  
69 - $trafficTrends->day = $date;  
70 - $trafficTrends->pvnum = $pv_count;  
71 - $trafficTrends->ipnum = $ip_count;  
72 - $res = $trafficTrends->save();  
73 - if ($res) {  
74 - DB::commit();  
75 - $this->info($date . ' - 统计当天流量趋势数据PV|IP数量成功');  
76 - } else {  
77 - DB::rollBack();  
78 - $this->error++;  
79 - $this->info($date . ' - 统计当天流量趋势数据PV|IP数量失败');  
80 - }  
81 - return $this->error;  
82 - }  
83 -}  
1 -<?php  
2 -  
3 -namespace App\Console\Commands\Bside\Statistics;  
4 -  
5 -use App\Models\Bside\Statistics\TrafficStatistics;  
6 -use App\Models\CustomerVisit\CustomerVisit;  
7 -use Illuminate\Console\Command;  
8 -use Throwable;  
9 -  
10 -class StatisticsDistribution extends Command  
11 -{  
12 - public $error = 0;  
13 - /**  
14 - * The name and signature of the console command.  
15 - *  
16 - * @var string  
17 - */  
18 - protected $signature = 'statistics_distribution';  
19 -  
20 - /**  
21 - * The console command description.  
22 - *  
23 - * @var string  
24 - */  
25 - protected $description = '统计当月地域分布数据';  
26 -  
27 - public $logic;  
28 -  
29 - public function __construct()  
30 - {  
31 - parent::__construct();  
32 - $this->logic = new Logic();  
33 - }  
34 -  
35 - /**  
36 - * 定时执行  
37 - * @return void  
38 - * @throws Throwable  
39 - */  
40 - public function handle()  
41 - {  
42 - $date = $this->logic->getMonths(TrafficStatistics::TYPE_DISTRIBUTION);  
43 - if (!empty($date)) {  
44 - foreach ($date as $value) {  
45 - echo $this->statistics_distribution($value);  
46 - }  
47 - }  
48 - echo $this->statistics_distribution();  
49 - }  
50 -  
51 - /**  
52 - * 统计当天流量趋势数据PV|IP数量  
53 - * @param string|null $date  
54 - * @return int|mixed  
55 - * @throws Throwable  
56 - */  
57 - protected function statistics_distribution(string $date = null)  
58 - {  
59 - $customerVisit = new CustomerVisit();  
60 - $type = TrafficStatistics::TYPE_DISTRIBUTION;  
61 - $top = json_encode($customerVisit->getCountryCount($date) ?? []);  
62 - $res = $this->logic->save(compact('top', 'type'), $type, $date, '统计当月地域分布数据');  
63 - if (!$res['status']) {  
64 - $this->info($res['msg']);  
65 - $this->error++;  
66 - }  
67 - $this->info($res['msg']);  
68 - return $this->error;  
69 - }  
70 -}  
1 -<?php  
2 -  
3 -namespace App\Console\Commands\Bside\Statistics;  
4 -  
5 -use App\Models\Bside\Statistics\TrafficStatistics;  
6 -use App\Models\CustomerVisit\CustomerVisit;  
7 -use Illuminate\Console\Command;  
8 -use Throwable;  
9 -  
10 -class StatisticsPage extends Command  
11 -{  
12 - public $error = 0;  
13 -  
14 - /**  
15 - * The name and signature of the console command.  
16 - *  
17 - * @var string  
18 - */  
19 - protected $signature = 'statistics_page';  
20 -  
21 - /**  
22 - * The console command description.  
23 - *  
24 - * @var string  
25 - */  
26 - protected $description = '统计当月受访页面数据';  
27 -  
28 - public $logic;  
29 -  
30 - public function __construct()  
31 - {  
32 - parent::__construct();  
33 - $this->logic = new Logic();  
34 - }  
35 -  
36 - /**  
37 - * 定时执行  
38 - * @return void  
39 - */  
40 - public function handle()  
41 - {  
42 - $date = $this->logic->getMonths(TrafficStatistics::TYPE_PAGE);  
43 - if (!empty($date)) {  
44 - foreach ($date as $value) {  
45 - echo $this->statistics_page($value);  
46 - }  
47 - }  
48 - echo $this->statistics_page();  
49 - }  
50 -  
51 - /**  
52 - * 统计当月受访页面数据  
53 - * @param null $date  
54 - * @return int|mixed  
55 - * @throws Throwable  
56 - */  
57 - protected function statistics_page($date = null)  
58 - {  
59 - $customerVisit = new CustomerVisit();  
60 - $top = json_encode($customerVisit->getPageCount($date) ?? []);  
61 - $type = TrafficStatistics::TYPE_PAGE;  
62 - $res = $this->logic->save(compact('top', 'type'), $type, $date, '统计当月受访页面数据');  
63 - if (!$res['status']) {  
64 - $this->info($res['msg']);  
65 - $this->error++;  
66 - }  
67 - $this->info($res['msg']);  
68 - return $this->error;  
69 - }  
70 -}  
1 -<?php  
2 -  
3 -namespace App\Console\Commands\Bside\Statistics;  
4 -  
5 -use App\Models\Bside\Statistics\TrafficStatistics;  
6 -use App\Models\CustomerVisit\CustomerVisit;  
7 -use Illuminate\Console\Command;  
8 -use Throwable;  
9 -  
10 -class StatisticsSource extends Command  
11 -{  
12 - public $error = 0;  
13 - /**  
14 - * The name and signature of the console command.  
15 - *  
16 - * @var string  
17 - */  
18 - protected $signature = 'statistics_source';  
19 -  
20 - /**  
21 - * The console command description.  
22 - *  
23 - * @var string  
24 - */  
25 - protected $description = '统计当月访问来源数据';  
26 -  
27 - public $logic;  
28 -  
29 - public function __construct()  
30 - {  
31 - parent::__construct();  
32 - $this->logic = new Logic();  
33 - }  
34 -  
35 - /**  
36 - * @return void  
37 - * @throws Throwable  
38 - */  
39 - public function handle()  
40 - {  
41 - $date = $this->logic->getMonths();  
42 - if (!empty($date)) {  
43 - foreach ($date as $value) {  
44 - echo $this->statistics_source($value);  
45 - }  
46 - }  
47 - echo $this->statistics_source();  
48 - }  
49 -  
50 - /**  
51 - * 统计当天流量趋势数据  
52 - * @param string|null $date  
53 - * @return int|mixed  
54 - * @throws Throwable  
55 - */  
56 - protected function statistics_source(string $date = null)  
57 - {  
58 - // 获取当天的IP|PV数量  
59 - $customerVisit = new CustomerVisit();  
60 - $top = json_encode($customerVisit->getUrlCount($date) ?? []);  
61 - $type = TrafficStatistics::TYPE_SOURCE;  
62 - $res = $this->logic->save(compact('top', 'type'), $type, $date);  
63 - if (!$res['status']) {  
64 - $this->info($res['msg']);  
65 - $this->error++;  
66 - }  
67 - $this->info($res['msg']);  
68 - return $this->error;  
69 - }  
70 -}  
1 -<?php  
2 -  
3 -namespace App\Console\Commands\Bside\Statistics;  
4 -  
5 -use App\Models\Bside\Statistics\TrafficStatistics;  
6 -use App\Models\CustomerVisit\CustomerVisit;  
7 -use GuzzleHttp\Exception\GuzzleException;  
8 -use Illuminate\Console\Command;  
9 -use Throwable;  
10 -  
11 -class StatisticsTerminal extends Command  
12 -{  
13 - public $error = 0;  
14 -  
15 - /**  
16 - * The name and signature of the console command.  
17 - *  
18 - * @var string  
19 - */  
20 - protected $signature = 'statistics_terminal';  
21 -  
22 - /**  
23 - * The console command description.  
24 - *  
25 - * @var string  
26 - */  
27 - protected $description = '统计当月访问终端数据';  
28 -  
29 - public $logic;  
30 -  
31 - public function __construct()  
32 - {  
33 - parent::__construct();  
34 - $this->logic = new Logic();  
35 - }  
36 -  
37 - /**  
38 - * @return void  
39 - * @throws Throwable  
40 - */  
41 - public function handle()  
42 - {  
43 - $date = $this->logic->getMonths(TrafficStatistics::TYPE_TERMINAL);  
44 - if (!empty($date)) {  
45 - foreach ($date as $value) {  
46 - echo $this->statistics_terminal($value);  
47 - }  
48 - }  
49 - echo $this->statistics_terminal();  
50 - }  
51 -  
52 - /**  
53 - * 统计当月访问终端数据  
54 - * @param string|null $date  
55 - * @return int|mixed  
56 - * @throws Throwable  
57 - */  
58 - protected function statistics_terminal(string $date = null)  
59 - {  
60 - $customerVisit = new CustomerVisit();  
61 - $pcnum = $customerVisit->getTerminalPcCount($date);  
62 - $mbnum = $customerVisit->getTerminalMobileCount($date);  
63 - $top = json_encode($customerVisit->getCountryCount($date) ?? []);  
64 - $type = TrafficStatistics::TYPE_TERMINAL;  
65 - $res = $this->logic->save(compact('top', 'type', 'pcnum', 'mbnum'), $type, $date, '统计当月访问终端数据');  
66 - if (!$res['status']) {  
67 - $this->info($res['msg']);  
68 - $this->error++;  
69 - }  
70 - $this->info($res['msg']);  
71 - return $this->error;  
72 - }  
73 -}  
1 -<?php  
2 -  
3 -namespace App\Console\Commands\Bside\Statistics;  
4 -  
5 -use App\Models\Bside\Statistics\TrafficStatistics;  
6 -use GuzzleHttp\Exception\GuzzleException;  
7 -use Illuminate\Console\Command;  
8 -use Throwable;  
9 -  
10 -class StatisticsTrend extends Command  
11 -{  
12 - public $error = 0;  
13 -  
14 - /**  
15 - * The name and signature of the console command.  
16 - *  
17 - * @var string  
18 - */  
19 - protected $signature = 'statistics_trend';  
20 -  
21 - /**  
22 - * The console command description.  
23 - *  
24 - * @var string  
25 - */  
26 - protected $description = '统计当月流量趋势数据';  
27 -  
28 - public $logic;  
29 -  
30 - public function __construct()  
31 - {  
32 - parent::__construct();  
33 - $this->logic = new Logic();  
34 - }  
35 -  
36 - /**  
37 - * 定时执行  
38 - * @return void  
39 - * @throws GuzzleException|Throwable  
40 - */  
41 - public function handle()  
42 - {  
43 - $date = $this->logic->getMonths(TrafficStatistics::TYPE_TREND);  
44 - if (!empty($date)) {  
45 - foreach ($date as $value) {  
46 - echo $this->statistics_trend($value);  
47 - }  
48 - }  
49 - echo $this->statistics_trend();  
50 - }  
51 -  
52 - /**  
53 - * 统计当天流量趋势数据  
54 - * @param string|null $date  
55 - * @return int|mixed  
56 - * @throws GuzzleException|Throwable  
57 - */  
58 - protected function statistics_trend(string $date = null)  
59 - {  
60 - $domain = request()->getHttpHost(); //'www.wowstainless.com';  
61 - $sta_date = !is_null($date) ? $date . "-01" : date('Y-m-01');  
62 - $inquiry = getInquiryInformation($domain, $sta_date);  
63 - $innum = $inquiry['count'] ?? 0;  
64 - $top = json_encode($inquiry['lists'] ?? []);  
65 - $type = TrafficStatistics::TYPE_TREND;  
66 - $res = $this->logic->save(compact('top', 'type', 'innum'), $type, $date, '统计当月流量趋势数据');  
67 - if (!$res['status']) {  
68 - $this->info($res['msg']);  
69 - $this->error++;  
70 - }  
71 - $this->info($res['msg']);  
72 - return $this->error;  
73 - }  
74 -}  
1 <?php 1 <?php
2 2
3 -namespace App\Console\Commands\YesterdayCount; 3 +namespace App\Console\Commands\DayCount;
4 4
5 use App\Helper\Common; 5 use App\Helper\Common;
6 use App\Helper\FormGlobalsoApi; 6 use App\Helper\FormGlobalsoApi;
7 -use App\Http\Logic\Aside\Project\ProjectLogic;  
8 -use App\Models\CustomerVisit\CustomerVisitItem; 7 +use App\Models\Domain\DomainInfo;
9 use App\Models\Project\DeployBuild; 8 use App\Models\Project\DeployBuild;
  9 +use App\Models\Project\DeployOptimize;
  10 +use App\Models\Project\Project;
  11 +use App\Services\ProjectServer;
10 use Carbon\Carbon; 12 use Carbon\Carbon;
11 use Illuminate\Console\Command; 13 use Illuminate\Console\Command;
12 use Illuminate\Support\Facades\DB; 14 use Illuminate\Support\Facades\DB;
  15 +use Illuminate\Support\Facades\Log;
13 16
14 -class Yesterday extends Command 17 +class Count extends Command
15 { 18 {
16 const STATUS_ERROR = 400; 19 const STATUS_ERROR = 400;
17 public $error = 0; 20 public $error = 0;
@@ -20,7 +23,7 @@ class Yesterday extends Command @@ -20,7 +23,7 @@ class Yesterday extends Command
20 * 23 *
21 * @var string 24 * @var string
22 */ 25 */
23 - protected $signature = 'yesterday_count'; 26 + protected $signature = 'count';
24 27
25 /** 28 /**
26 * The console command description. 29 * The console command description.
@@ -28,6 +31,7 @@ class Yesterday extends Command @@ -28,6 +31,7 @@ class Yesterday extends Command
28 * @var string 31 * @var string
29 */ 32 */
30 protected $description = '统计昨日数据'; 33 protected $description = '统计昨日数据';
  34 +
31 /** 35 /**
32 * @name :(定时执行生成昨日数据统计)handle 36 * @name :(定时执行生成昨日数据统计)handle
33 * @author :lyh 37 * @author :lyh
@@ -36,32 +40,54 @@ class Yesterday extends Command @@ -36,32 +40,54 @@ class Yesterday extends Command
36 */ 40 */
37 public function handle() 41 public function handle()
38 { 42 {
39 - $deployModel = new DeployBuild();  
40 - $list = $deployModel->list();  
41 - $data = [];  
42 - $yesterday = Carbon::yesterday()->toDateString();  
43 - foreach ($list as $v){  
44 - $arr = [];  
45 - //统计时间  
46 - $arr['date'] = $yesterday;  
47 - //pv统计  
48 - $arr['pv_num'] = $this->pv_num($yesterday,$v['test_domain']);  
49 - //ip统计  
50 - $arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']);  
51 - //服务达标天数  
52 - $arr['compliance_day'] = $this->compliance_day($yesterday);  
53 - //剩余服务时常  
54 - $arr['service_day'] = $v['service_duration'] - Common::getDaysToTargetDate($v['created_at']);  
55 - //项目id  
56 - $arr['project_id'] = $v['project_id'];  
57 - $arr['created_at'] = date('Y-m-d H:i:s');  
58 - $arr['updated_at'] = date('Y-m-d H:i:s');  
59 - //询盘统计  
60 - $arr = $this->inquiry($arr,$v['test_domain']);  
61 - $data[] = $arr; 43 + $list = DB::table('gl_project')->where('gl_project.extend_type','!=',5)
  44 + ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
  45 + ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
  46 + ->select($this->selectParam())->get();
  47 + try {
  48 + if(!empty($list)){
  49 + $list = $list->toArray();
  50 + $data = [];
  51 + $yesterday = Carbon::yesterday()->toDateString();
  52 + $domainInfo = new DomainInfo();
  53 + foreach ($list as $v){
  54 + $v = (array)$v;
  55 + if($v['type'] == Project::TYPE_ZERO){
  56 + continue;
  57 + }
  58 + if(!empty($v['domain'])){
  59 + $info = $domainInfo->read(['id'=>$v['domain']]);
  60 + if($info !== false){
  61 + $v['test_domain'] = $info['domain'];
  62 + }
  63 + }
  64 + $arr = [];
  65 + //统计时间
  66 + $arr['date'] = $yesterday;
  67 + ProjectServer::useProject($v['id']);
  68 + //pv统计
  69 + $arr['pv_num'] = $this->pv_num($yesterday,$v['test_domain']);
  70 + //ip统计
  71 + $arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']);
  72 + DB::disconnect('custom_mysql');
  73 + //服务达标天数
  74 + $arr['compliance_day'] = $this->compliance_day($v['id']);
  75 + //剩余服务时常
  76 + $arr['service_day'] = $v['remain_day'];
  77 + //项目id
  78 + $arr['project_id'] = $v['project_id'];
  79 + $arr['created_at'] = date('Y-m-d H:i:s');
  80 + $arr['updated_at'] = date('Y-m-d H:i:s');
  81 + //询盘统计
  82 + $arr = $this->inquiry($arr,$v['test_domain']);
  83 + $data[] = $arr;
  84 + }
  85 + //判断数据是否存在
  86 + DB::table('gl_count')->insert($data);
  87 + }
  88 + }catch (\Exception $e){
  89 + Log::error('同步数据执行失败');
62 } 90 }
63 - //判断数据是否存在  
64 - DB::table('gl_count')->insert($data);  
65 echo $this->error; 91 echo $this->error;
66 } 92 }
67 93
@@ -72,18 +98,18 @@ class Yesterday extends Command @@ -72,18 +98,18 @@ class Yesterday extends Command
72 * @time :2023/6/14 15:40 98 * @time :2023/6/14 15:40
73 */ 99 */
74 public function pv_num($yesterday,$domain){ 100 public function pv_num($yesterday,$domain){
75 - $pv = DB::table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count(); 101 + $pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
76 return $pv; 102 return $pv;
77 } 103 }
78 104
79 /** 105 /**
80 - * @name :(统计pv)pv_num 106 + * @name :(统计ip)ip_num
81 * @author :lyh 107 * @author :lyh
82 * @method :post 108 * @method :post
83 * @time :2023/6/14 15:40 109 * @time :2023/6/14 15:40
84 */ 110 */
85 public function ip_num($yesterday,$domain){ 111 public function ip_num($yesterday,$domain){
86 - $ip = DB::table('gl_customer_visit')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count(); 112 + $ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
87 return $ip; 113 return $ip;
88 } 114 }
89 115
@@ -125,9 +151,9 @@ class Yesterday extends Command @@ -125,9 +151,9 @@ class Yesterday extends Command
125 * @method :post 151 * @method :post
126 * @time :2023/6/14 15:48 152 * @time :2023/6/14 15:48
127 */ 153 */
128 - public function compliance_day($yesterday){ 154 + public function compliance_day($project_id){
129 //服务达标天数 155 //服务达标天数
130 - $rank_info = DB::table('gl_rank_data')->where(['updated_date'=>$yesterday,'lang'=>''])->select(['compliance_day'])->first(); 156 + $rank_info = DB::table('gl_rank_data')->where(['project_id'=>$project_id,'lang'=>''])->select(['compliance_day'])->first();
131 if(empty($rank_info)){ 157 if(empty($rank_info)){
132 $compliance_day = 0; 158 $compliance_day = 0;
133 }else{ 159 }else{
@@ -135,4 +161,25 @@ class Yesterday extends Command @@ -135,4 +161,25 @@ class Yesterday extends Command
135 } 161 }
136 return $compliance_day; 162 return $compliance_day;
137 } 163 }
  164 +
  165 + /**
  166 + * @name :(查询参数设置)selectParam
  167 + * @author :lyh
  168 + * @method :post
  169 + * @time :2023/6/14 15:00
  170 + */
  171 + public function selectParam(){
  172 + $select = [
  173 + 'gl_project.id AS id',
  174 + 'gl_project.type AS type',
  175 + 'gl_project.extend_type AS extend_type',
  176 + 'gl_project.remain_day AS remain_day',
  177 + 'gl_project_deploy_build.test_domain AS test_domain',
  178 + 'gl_project_deploy_optimize.domain AS domain',
  179 + 'gl_project_deploy_build.project_id AS project_id',
  180 + 'gl_project.cooperate_date AS cooperate_date',
  181 + 'gl_project_deploy_build.service_duration AS service_duration',
  182 + ];
  183 + return $select;
  184 + }
138 } 185 }
  1 +<?php
  2 +
  3 +namespace App\Console\Commands\DayCount;
  4 +
  5 +use App\Models\Inquiry\InquiryCount as InquiryCountModel;
  6 +use App\Models\Inquiry\InquiryInfo;
  7 +use Carbon\Carbon;
  8 +use Illuminate\Console\Command;
  9 +
  10 +/**
  11 + * @remark :
  12 + * @class :InquiryCount.php
  13 + * @author :lyh
  14 + * @time :2023/7/14 16:20
  15 + */
  16 +class InquiryCount extends Command
  17 +{
  18 + /**
  19 + * The name and signature of the console command.
  20 + *
  21 + * @var string
  22 + */
  23 + protected $signature = 'inquiry_count';
  24 +
  25 + /**
  26 + * The console command description.
  27 + *
  28 + * @var string
  29 + */
  30 + protected $description = '每天统计询盘数量';
  31 +
  32 + /**
  33 + * @var :根据状态统计
  34 + */
  35 + public $status = [
  36 + 1=>'站群询盘',
  37 + 2=>'ai站群询盘',
  38 + 3=>'amp自建平台',
  39 + 4=>'fb询盘',
  40 + 5=>'fb广告',
  41 + 6=>'广告采集建站',
  42 + 7=>'黄金平台询盘',
  43 + 8=>'内部统计',
  44 + 9=>'GlobalImporter',
  45 + 10=>'whatsapp',
  46 + 11=>'Skype',
  47 + 12=>'建站客户',
  48 + 13=>'ChinaCn',
  49 + 14=>'EC21',
  50 + 15=>'邮件群发'
  51 + ];
  52 +
  53 + /**
  54 + * @remark :统计
  55 + * @name :handle
  56 + * @author :lyh
  57 + * @method :post
  58 + * @time :2023/7/14 16:21
  59 + */
  60 + public function handle(){
  61 + $data = [];
  62 + //获取昨天的时间
  63 + $yesterday = Carbon::yesterday()->toDateString();
  64 + $inquiryInfoModel = new InquiryInfo();
  65 + foreach ($this->status as $k=>$v){
  66 + $total = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']]])->count();
  67 + $untreated = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>1])->count();
  68 + $invalid = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>0])->count();
  69 + $data[] = [
  70 + 'type'=>$k,
  71 + 'day'=>$yesterday,
  72 + 'total'=>$total ?? 0,
  73 + 'untreated'=>$untreated ?? 0,
  74 + 'invalid'=>$invalid ?? 0
  75 + ];
  76 + }
  77 + $inquiryCount = new InquiryCountModel();
  78 + $inquiryCount->insert($data);
  79 + return true;
  80 + }
  81 +}
  1 +<?php
  2 +
  3 +namespace App\Console\Commands\DayCount;
  4 +
  5 +use App\Models\Inquiry\InquiryInfo;
  6 +use Illuminate\Console\Command;
  7 +
  8 +/**
  9 + * @remark :
  10 + * @class :InquiryDelay.php
  11 + * @author :lyh
  12 + * @time :2023/7/14 10:16
  13 + */
  14 +class InquiryDelay extends Command
  15 +{
  16 + /**
  17 + * The name and signature of the console command.
  18 + *
  19 + * @var string
  20 + */
  21 + protected $signature = 'inquiry_delay';
  22 +
  23 + /**
  24 + * The console command description.
  25 + *
  26 + * @var string
  27 + */
  28 + protected $description = '延时询盘转发';
  29 +
  30 + /**
  31 + * @remark :延时询盘转发
  32 + * @name :handle
  33 + * @author :lyh
  34 + * @method :post
  35 + * @time :2023/7/14 10:17
  36 + */
  37 + public function handle()
  38 + {
  39 + $inquiryInfoModel = new InquiryInfo();
  40 + $param = $inquiryInfoModel->formatQuery(['status'=>$inquiryInfoModel::STATUS_FOUR])->orderBy('send_time','asc')->first();
  41 + if(!empty($param)){
  42 + $time = date('Y-m-d H:i:s');
  43 + if($time >= $param['send_time']){
  44 + $data = [];
  45 + //TODO::处理转发的url
  46 + $arr_url = explode(',',$param['forward_url']);
  47 + foreach ($arr_url as $v){
  48 + $data['url'] = $v;
  49 + $this->inquiryForward($data);
  50 + }
  51 + $inquiryInfoModel->edit(['status'=>$inquiryInfoModel::STATUS_THREE],['id'=>$param['id']]);
  52 + }
  53 + }
  54 + return true;
  55 + }
  56 +
  57 + /**
  58 + * @remark :询盘转发
  59 + * @name :inquiryForward
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2023/7/13 14:39
  63 + */
  64 + public function inquiryForward($post_data){
  65 + $url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f';
  66 + $post_data_new = [];
  67 + $post_data_new['refer'] = $post_data['url'];
  68 + $post_data_new['name'] = $post_data['name'];
  69 + $post_data_new['email'] = $post_data['email'];
  70 + $post_data_new['phone'] = $post_data['phone'];
  71 + $post_data_new['ip'] = $post_data['ip'];
  72 + $post_data_new['message'] = $post_data['message'];
  73 + $post_data_new['submit_time'] = date('Y-m-d H:i:s',time()+20);
  74 + $token = md5($post_data_new['refer'].$post_data_new['name'].$post_data_new['ip'].date("Y-m-d",time()));
  75 + $post_data_new['token'] = $token;
  76 + $header = array(
  77 + 'CLIENT-IP: '.$post_data['ip'],
  78 + 'X-FORWARDED-FOR: '.$post_data['ip']
  79 + );
  80 + return http_post($url,$post_data_new,$header);
  81 + }
  82 +
  83 +}
@@ -5,6 +5,7 @@ namespace App\Console\Commands; @@ -5,6 +5,7 @@ namespace App\Console\Commands;
5 5
6 use App\Models\Devops\DevopsTaskLog; 6 use App\Models\Devops\DevopsTaskLog;
7 use App\Models\Project\Project; 7 use App\Models\Project\Project;
  8 +use App\Utils\EncryptUtils;
8 use Illuminate\Console\Command; 9 use Illuminate\Console\Command;
9 use App\Models\Devops\DevopsTask as DevopsTaskModel; 10 use App\Models\Devops\DevopsTask as DevopsTaskModel;
10 11
@@ -45,16 +46,13 @@ class DevopsTask extends Command @@ -45,16 +46,13 @@ class DevopsTask extends Command
45 */ 46 */
46 public function handle() 47 public function handle()
47 { 48 {
48 - while (true){  
49 - $tasks = DevopsTaskModel::where('status', DevopsTaskModel::STATUS_PENDING)->get();  
50 - foreach ($tasks as $task){  
51 - echo "Start task " . $task->id . PHP_EOL;  
52 - if($task->type == DevopsTaskModel::TYPE_MYSQL){  
53 - $this->updateTable($task);  
54 - }  
55 - echo "End task " . $task->id . PHP_EOL; 49 + $tasks = DevopsTaskModel::where('status', DevopsTaskModel::STATUS_PENDING)->get();
  50 + foreach ($tasks as $task){
  51 + echo "Start task " . $task->id;
  52 + if($task->type == DevopsTaskModel::TYPE_MYSQL){
  53 + $this->updateTable($task);
56 } 54 }
57 - sleep(10); 55 + echo "End task " . $task->id . PHP_EOL;
58 } 56 }
59 } 57 }
60 58
@@ -64,6 +62,7 @@ class DevopsTask extends Command @@ -64,6 +62,7 @@ class DevopsTask extends Command
64 echo "project " . $project->id; 62 echo "project " . $project->id;
65 $log = DevopsTaskLog::addLog($task->id, $project->id); 63 $log = DevopsTaskLog::addLog($task->id, $project->id);
66 if($log->status == DevopsTaskModel::STATUS_ACTIVE){ 64 if($log->status == DevopsTaskModel::STATUS_ACTIVE){
  65 + echo 'continue' . PHP_EOL;
67 continue; 66 continue;
68 } 67 }
69 if(!$project->mysqlConfig){ 68 if(!$project->mysqlConfig){
@@ -73,13 +72,21 @@ class DevopsTask extends Command @@ -73,13 +72,21 @@ class DevopsTask extends Command
73 continue; 72 continue;
74 } 73 }
75 //DB类是单例模式,生命周期内修改配置不会生效 74 //DB类是单例模式,生命周期内修改配置不会生效
76 - $conn = new \mysqli(  
77 - $project->mysqlConfig->host,  
78 - $project->mysqlConfig->user,  
79 - $project->mysqlConfig->password,  
80 - $project->databaseName(),  
81 - $project->mysqlConfig->port,  
82 - ); 75 + try {
  76 + $conn = new \mysqli(
  77 + $project->mysqlConfig->host,
  78 + $project->mysqlConfig->user,
  79 + $project->mysqlConfig->password,
  80 + $project->databaseName(),
  81 + $project->mysqlConfig->port,
  82 + );
  83 + }catch (\Exception $e){
  84 + $log->remark = mb_substr('数据库连接失败:' . $e->getMessage(), 0, 500);
  85 + $log->status = DevopsTaskLog::STATUS_ERROR;
  86 + $log->save();
  87 + echo '-->' . $log->remark . PHP_EOL;
  88 + continue;
  89 + }
83 $res = $conn->query($task->sql); 90 $res = $conn->query($task->sql);
84 91
85 $log->status = $res ? DevopsTaskLog::STATUS_ACTIVE : DevopsTaskLog::STATUS_ERROR; 92 $log->status = $res ? DevopsTaskLog::STATUS_ACTIVE : DevopsTaskLog::STATUS_ERROR;
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :DomainInfo.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/11 14:37
  8 + */
  9 +
  10 +namespace App\Console\Commands\Domain;
  11 +
  12 +use Illuminate\Console\Command;
  13 +use App\Models\Domain\DomainInfo as DomainInfoModel;
  14 +
  15 +class DomainInfo extends Command
  16 +{
  17 + /**
  18 + * The name and signature of the console command.
  19 + *
  20 + * @var string
  21 + */
  22 + protected $signature = 'domain_info';
  23 +
  24 + /**
  25 + * The console command description.
  26 + *
  27 + * @var string
  28 + */
  29 + protected $description = '域名相关';
  30 +
  31 + /**
  32 + * @remark :更新证书+证书有效时间
  33 + * @name :handle
  34 + * @author :lyh
  35 + * @method :post
  36 + * @time :2023/9/11 15:09
  37 + */
  38 + public function handle(){
  39 + $domainModel = new DomainInfoModel();
  40 + $map = ['status'=>['!=',2]];
  41 + $list = $domainModel->list($map);
  42 + foreach ($list as $v){
  43 + $ssl = $this->updateDomainSsl($v['domain']);
  44 + $time = $this->updateDomain($v['domain']);
  45 + $data = [
  46 + 'certificate_start_time'=>$ssl['from'],
  47 + 'certificate_end_time'=>$ssl['to'],
  48 + 'domain_start_time'=>$time['start'],
  49 + 'domain_end_time'=>$time['end']
  50 + ];
  51 + $domainModel->edit($data,['id'=>$v['id']]);
  52 + }
  53 + return 1;
  54 + }
  55 +
  56 + /**
  57 + * @remark :更新域名证书
  58 + * @name :updateDomainSsl
  59 + * @author :lyh
  60 + * @method :post
  61 + * @time :2023/9/11 15:07
  62 + */
  63 + public function updateDomainSsl($domain){
  64 + try {
  65 + $context = stream_context_create([
  66 + 'ssl' => [
  67 + 'capture_peer_cert' => true,
  68 + 'capture_peer_cert_chain' => false,
  69 + ],
  70 + ]);
  71 + $stream = stream_socket_client('ssl://'.$domain.':443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
  72 + if(!$stream) {
  73 + die("Failed to connect: $errno - $errstr");
  74 + }
  75 + $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
  76 + if(!$remote_cert) {
  77 + die("Failed to retrieve certificate");
  78 + }
  79 + $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
  80 + $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
  81 + fclose($stream);
  82 + }catch (\Exception $e){
  83 + $valid_from = date('Y-m-d H:i:s');
  84 + $valid_to = date('Y-m-d H:i:s');
  85 + }
  86 + return ['from'=>$valid_from,'to'=>$valid_to];
  87 + }
  88 +
  89 + /**
  90 + * @remark :更新域名有限时间
  91 + * @name :updateDomain
  92 + * @author :lyh
  93 + * @method :post
  94 + * @time :2023/9/11 15:11
  95 + */
  96 + public function updateDomain($domain){
  97 + $url = 'http://openai.waimaoq.com/v1/whois_api?domain='.$domain;
  98 + $response = http_get($url);
  99 + $start = '';
  100 + $end = '';
  101 + if($response['code'] == 200){
  102 + $start = $response['text']['creation_date'];
  103 + $end = $response['text']['expiration_date'];
  104 + }
  105 + return ['start'=>$start,'end'=>$end];
  106 + }
  107 +}
1 -<?php  
2 -  
3 -namespace App\Console\Commands\Domain;  
4 -  
5 -use App\Exceptions\AsideGlobalException;  
6 -use App\Exceptions\BsideGlobalException;  
7 -use App\Http\Logic\Aside\Domain\DomainInfoLogic;  
8 -use GuzzleHttp\Exception\GuzzleException;  
9 -use Illuminate\Console\Command;  
10 -  
11 -class DomainTime extends Command  
12 -{  
13 - public $error = 0;  
14 - /**  
15 - * The name and signature of the console command.  
16 - *  
17 - * @var string  
18 - */  
19 - protected $signature = 'domain_time';  
20 -  
21 - /**  
22 - * The console command description.  
23 - *  
24 - * @var string  
25 - */  
26 - protected $description = '域名定时任务 更新域名|证书到期时间';  
27 -  
28 - /**  
29 - * @name :(定时执行)handle  
30 - * @author :lyh  
31 - * @method :post  
32 - * @time :2023/5/12 14:48  
33 - */  
34 - public function handle()  
35 - {  
36 - echo $this->update_domain_time();  
37 - }  
38 -  
39 - /**  
40 - * 更新域名|证书到期时间  
41 - * @return int|mixed|void  
42 - * @throws AsideGlobalException  
43 - * @throws BsideGlobalException|GuzzleException  
44 - */  
45 - protected function update_domain_time()  
46 - {  
47 - $domainCon = new DomainInfoLogic();  
48 - $all = $domainCon->getAllDomain();  
49 - $all = $all->toArray();  
50 - if ( empty( $all ) ) {  
51 - $this->info( '未获取到数据' );  
52 - return;  
53 - }  
54 - foreach ( $all as $item ) {  
55 - $domain = $item['domain'];  
56 - // 域名到期时间  
57 - $domainT = $domainCon->getDomainTime( $domain );  
58 - if ( $domainT ) {  
59 - $domain_time = $item['domain_end_time'];  
60 - $domainValidFrom = $domainT['validFrom'];  
61 - $domainValidTo = $domainT['validTo'];  
62 - if ( strtotime( $domain_time ) < strtotime( $domainValidTo ) ) {  
63 - $this->info( $domain . '域名到期时间更新成功' );  
64 - $domainCon->updateDomain( $item['id'], [ 'domain_end_time' => $domainValidTo ] );  
65 - }  
66 - } else {  
67 - $this->error++;  
68 - $this->info( $domain . '域名到期时间获取失败' );  
69 - }  
70 - // 证书到期时间  
71 - $certificateT = $domainCon->getDomainCertificateTime( $domain );  
72 - if ( $certificateT ) {  
73 - $certificate_time = $item['certificate_end_time'];  
74 - $certificateValidFrom = $certificateT['validFrom'];  
75 - $certificateValidTo = $certificateT['validTo'];  
76 - if ( strtotime( $certificate_time ) < strtotime( $certificateValidTo ) ) {  
77 - $this->info( $domain . '证书到期时间更新成功' );  
78 - $domainCon->updateDomain( $item['id'], [ 'certificate_end_time' => $certificateValidTo ] );  
79 - }  
80 - } else {  
81 - $this->error++;  
82 - $this->info( $domain . '证书到期时间获取失败' );  
83 - }  
84 - }  
85 - return $this->error;  
86 - }  
87 -}  
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ImportManager.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/8/7 17:47
  8 + */
  9 +
  10 +namespace App\Console\Commands;
  11 +
  12 +use App\Models\Manage\EntryPosition;
  13 +use App\Models\Manage\JobLevel;
  14 +use App\Models\Manage\ManageHr;
  15 +use App\Models\Service\Service;
  16 +use Illuminate\Console\Command;
  17 +use Illuminate\Support\Facades\DB;
  18 +
  19 +class ImportManager extends Command
  20 +{
  21 + /**
  22 + * The name and signature of the console command.
  23 + *
  24 + * @var string
  25 + */
  26 + protected $signature = 'import_manager';
  27 +
  28 + /**
  29 + * The console command description.
  30 + *
  31 + * @var string
  32 + */
  33 + protected $description = '导入数据';
  34 + /**
  35 + * @remark :导入5.0管理员数据
  36 + * @name :handle
  37 + * @author :lyh
  38 + * @method :post
  39 + * @time :2023/8/7 17:49
  40 + */
  41 + public function handle(){
  42 + $model = new Service();
  43 + $info = $model->read(['type'=>5]);
  44 + $values = json_decode($info['values']);
  45 + $values = array_reverse($values);
  46 + $hrModel = new ManageHr();
  47 + foreach ($values as $k => $v){
  48 + $v = (array)$v;
  49 + $info = $hrModel->read(['mobile'=>$v['mobile']]);
  50 + if($info !== false){
  51 + continue;
  52 + }
  53 + $data = [
  54 + 'name'=>$v['name'],
  55 + 'mobile'=>$v['mobile'],
  56 + 'password'=>'$2y$10$ZNHxlIddWiQzQbIIzFgYJOsPlQ4n0cwWl8Sea53qvQvDXtu3WeYMC',
  57 + 'created_at'=>date('Y-m-d H:i:s'),
  58 + 'updated_at'=>date('Y-m-d H:i:s'),
  59 + ];
  60 + $manager_id = DB::table('gl_manage')->insertGetId($data);
  61 + if($v['sex'] == '女'){
  62 + $v['sex'] = 2;
  63 + }else{
  64 + $v['sex'] = 1;
  65 + }
  66 + $education = [
  67 + '专科' => 1,
  68 + '大专' => 1,
  69 + '中专' => 0,
  70 + '本科' => 2,
  71 + '自考本科'=>0,
  72 + '全日制本科'=>2,
  73 + '本科在读'=>2,
  74 + '大学本科'=>2,
  75 + '硕士研究生' => 3,
  76 + '硕士'=>3,
  77 + '其他' => 0,
  78 + ];
  79 + $belong_group = [
  80 + '-' => 0,
  81 + 'KA组' => 1,
  82 + 'A组' => 2,
  83 + 'B组' => 3,
  84 + 'C组'=>4,
  85 + 'D组'=>5,
  86 + 'E组'=>6,
  87 + 'F组'=>7,
  88 + 'G组' => 8,
  89 + 'H组'=>9,
  90 + 'GA组' => 10,
  91 + 'GB组' => 11,
  92 + 'GC组' => 12,
  93 + '前端组' => 13,
  94 + '后端组' => 14,
  95 + '黑格组' => 15,
  96 + '售后组' => 16,
  97 + '其他' => 0,
  98 + ];
  99 + //获取入职岗位
  100 + $entryPositionModel = new EntryPosition();
  101 + $entry_position = $entryPositionModel->read(['name'=>$v['entry_position']]);
  102 + if($entry_position !== false){
  103 + $entry_position = $entry_position['id'];
  104 + }else{
  105 + $entry_position = 0;
  106 + }
  107 + //获取级别
  108 + $jobLevelModel = new JobLevel();
  109 + if(!empty($v['p_level'])){
  110 + $p_level = $jobLevelModel->read(['name'=>$v['p_level']]);
  111 + if($p_level !== false){
  112 + $p_level = $p_level['id'];
  113 + }else{
  114 + $p_level = 0;
  115 + }
  116 + }else{
  117 + $p_level = 0;
  118 + }
  119 + $manager_data = [
  120 + 'manage_id'=>$manager_id,
  121 + 'name'=>$v['name'],
  122 + 'id_card'=>$v['id_card'],
  123 + 'mobile'=>$v['mobile'],
  124 + 'birthday'=>!empty($v['birthday']) ? $v['birthday'] : date('Y-m-d'),
  125 + 'address'=>$v['address'],
  126 + 'sex'=>$v['sex'],
  127 + 'nationality'=>$v['nationality'],
  128 + 'belong_group'=>$belong_group[$v['belong_group']],
  129 + 'education'=>isset($education[$v['education']]) ? $education[$v['education']] : 0,
  130 + 'major'=>$v['major'],
  131 + 'graduate_school'=>$v['graduate_school'],
  132 + 'english_level'=>$v['english_level'],
  133 + 'entry_position'=>$entry_position ?? 0,
  134 + 'p_level'=>$p_level,
  135 + 'residential_address'=>$v['residential_address'],
  136 + 'emergency_contact'=>$v['emergency_contact'],
  137 + 'career_history'=>json_encode((array)$v['career_history']),
  138 + 'learning_history'=>json_encode((array)$v['learning_history']),
  139 + 'bank_card'=>$v['bank_card'],
  140 + 'photo_gallery'=>json_encode((array)$v['photo_gallery']),
  141 + 'id_card_gallery'=>json_encode((array)$v['id_card_gallery']),
  142 + 'certificate_gallery'=>json_encode((array)$v['certificate_gallery']),
  143 + 'dangyuan'=>$v['dangyuan'],
  144 + 'dangzhibu'=>$v['dangzhibu'],
  145 + 'dang_address'=>$v['dang_address'],
  146 + 'join_date'=>!empty($v['join_date']) ? $v['join_date'] : date('Y-m-d'),
  147 + 'status'=> 1,
  148 + 'computer_account'=>$v['computer_account'],
  149 + 'qq_account'=>$v['qq_account']
  150 + ];
  151 + $hrModel->add($manager_data);
  152 + }
  153 + return 1;
  154 + }
  155 +}
  1 +<?php
  2 +
  3 +namespace App\Console\Commands;
  4 +
  5 +use App\Helper\Arr;
  6 +use App\Helper\FormGlobalsoApi;
  7 +use App\Http\Logic\Bside\InquiryLogic;
  8 +use App\Models\Product\Category;
  9 +use App\Models\Product\Product;
  10 +use App\Models\Project\OnlineCheck;
  11 +use App\Models\Project\Project;
  12 +use App\Models\RankData\RankData as GoogleRankModel;
  13 +use App\Models\RouteMap\RouteMap;
  14 +use GuzzleHttp\Client;
  15 +use GuzzleHttp\Promise\Utils;
  16 +use Illuminate\Console\Command;
  17 +use Illuminate\Database\Eloquent\Model;
  18 +use Illuminate\Support\Facades\DB;
  19 +use Illuminate\Support\Str;
  20 +
  21 +/**
  22 + * 最近一次询盘
  23 + * Class InquiryList
  24 + * @package App\Console\Commands
  25 + * @author zbj
  26 + * @date 2023/9/11
  27 + */
  28 +class LastInquiry extends Command
  29 +{
  30 + /**
  31 + * The name and signature of the console command.
  32 + *
  33 + * @var string
  34 + */
  35 + protected $signature = 'last_inquiry';
  36 +
  37 + /**
  38 + * The console command description.
  39 + *
  40 + * @var string
  41 + */
  42 + protected $description = '询盘列表';
  43 +
  44 + /**
  45 + * Create a new command instance.
  46 + *
  47 + * @return void
  48 + */
  49 + public function __construct()
  50 + {
  51 + parent::__construct();
  52 + }
  53 +
  54 + /**
  55 + * @return bool
  56 + */
  57 + public function handle()
  58 + {
  59 + $list = Project::with('deploy_optimize')->whereIn('type', [2,3,4])->get();
  60 + foreach ($list as $item){
  61 + if(empty($item['deploy_optimize']['domain'])){
  62 + continue;
  63 + }
  64 + $api = new FormGlobalsoApi();
  65 + $res = $api->getInquiryList($item['deploy_optimize']['domain']);
  66 + if($res && $res['status'] == 200){
  67 + if(empty($res['data']['data'][0])){
  68 + continue;
  69 + }
  70 + $item->last_inquiry_time = $res['data']['data'][0]['submit_time'];
  71 + $item->save();
  72 + }
  73 + }
  74 + }
  75 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ForwardInquiryCount.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/8/18 9:41
  8 + */
  9 +
  10 +namespace App\Console\Commands\MonthlyCount;
  11 +
  12 +use App\Models\Inquiry\ForwardCount;
  13 +use Carbon\Carbon;
  14 +use Illuminate\Console\Command;
  15 +use Illuminate\Support\Facades\DB;
  16 +
  17 +/**
  18 + * @remark :转发询盘人员统计
  19 + * @name :ForwardInquiryCount
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2023/8/18 9:42
  23 + */
  24 +class ForwardInquiryCount extends Command
  25 +{
  26 + /**
  27 + * The name and signature of the console command.
  28 + *
  29 + * @var string
  30 + */
  31 + protected $signature = 'forward_count';
  32 +
  33 + /**
  34 + * The console command description.
  35 + *
  36 + * @var string
  37 + */
  38 + protected $description = '月转发报告统计';
  39 +
  40 + /**
  41 + * @remark :统计报告
  42 + * @name :handle
  43 + * @author :lyh
  44 + * @method :post
  45 + * @time :2023/8/18 9:52
  46 + */
  47 + public function handle(){
  48 + // 获取上个月的开始时间
  49 + $startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();
  50 + // 获取上个月的结束时间
  51 + $endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();
  52 + $list = DB::table('gl_inquiry_info')->groupBy('user_name')
  53 + ->select("user_name",DB::raw('COUNT(*) as count'))
  54 + ->where('send_time','>=',$startTime.' 00:00:00')
  55 + ->where('send_time','<=',$endTime.' 23:59:59')
  56 + ->get();
  57 + if(!empty($list)){
  58 + $list = $list->toArray();
  59 + $forwardModel = new ForwardCount();
  60 + foreach ($list as $v){
  61 + $data = [
  62 + 'date'=>Carbon::now()->subMonth()->format('Y-m'),
  63 + 'name'=>$v['user_name'],
  64 + 'count'=>$v['count']
  65 + ];
  66 + $forwardModel->add($data);
  67 + }
  68 + }
  69 + return 1;
  70 + }
  71 +}
  1 +<?php
  2 +
  3 +namespace App\Console\Commands\MonthlyCount;
  4 +
  5 +use App\Helper\FormGlobalsoApi;
  6 +use App\Models\Domain\DomainInfo;
  7 +use App\Models\Project\Project;
  8 +use App\Services\ProjectServer;
  9 +use Carbon\Carbon;
  10 +use Illuminate\Console\Command;
  11 +use Illuminate\Support\Facades\DB;
  12 +
  13 +class InquiryMonthlyCount extends Command
  14 +{
  15 + const STATUS_ERROR = 400;
  16 + public $error = 0;
  17 + /**
  18 + * The name and signature of the console command.
  19 + *
  20 + * @var string
  21 + */
  22 + protected $signature = 'month_count';
  23 +
  24 + /**
  25 + * The console command description.
  26 + *
  27 + * @var string
  28 + */
  29 + protected $description = '询盘月报告统计';
  30 +
  31 + /**
  32 + * @remark :询盘月报告
  33 + * @name :handle
  34 + * @author :lyh
  35 + * @method :post
  36 + * @time :2023/6/30 9:32
  37 + */
  38 + public function handle(){
  39 + $list = DB::table('gl_project')->where('gl_project.extend_type','!=',5)
  40 + ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
  41 + ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
  42 + ->select($this->selectParam())->get()->toArray();
  43 + // 获取上个月的开始时间
  44 + $startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();
  45 + // 获取上个月的结束时间
  46 + $endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();
  47 + $domainInfo = new DomainInfo();
  48 + foreach ($list as $value){
  49 + $value = (array)$value;
  50 + if($value['type'] == Project::TYPE_ZERO){
  51 + continue;
  52 + }
  53 + if(!empty($value['domain'])){
  54 + $info = $domainInfo->read(['id'=>$value['domain']]);
  55 + if($info !== false){
  56 + $value['test_domain'] = $value['domain'];
  57 + }
  58 + }
  59 + $arr = [];
  60 + //按月统计询盘记录
  61 + $arr = $this->inquiryCount($arr,$startTime,$endTime,$value['test_domain']);
  62 + $arr = $this->flowCount($arr,$startTime,$endTime,$value['project_id']);
  63 + ProjectServer::useProject($value['project_id']);
  64 + $arr = $this->sourceCount($arr,$value['test_domain'],$startTime,$endTime);
  65 + DB::disconnect('custom_mysql');
  66 + $arr['created_at'] = date('Y-m-d H:i:s');
  67 + $arr['updated_at'] = date('Y-m-d H:i:s');
  68 + $arr['project_id'] = $value['project_id'];
  69 + // 获取当前日期时间
  70 + $arr['month'] = Carbon::now()->subMonth()->format('Y-m');
  71 + DB::table('gl_month_count')->insert($arr);
  72 + }
  73 + return true;
  74 + }
  75 +
  76 + /**
  77 + * @param $domain
  78 + * @param $project_id
  79 + * @remark :询盘按月统计
  80 + * @name :inquiryCount
  81 + * @author :lyh
  82 + * @method :post
  83 + * @time :2023/6/30 14:29
  84 + */
  85 + public function inquiryCount(&$arr,&$startTime,&$endTime,$domain){
  86 + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
  87 + //总数
  88 + $arr['total'] = $inquiry_list['data']['total'] ?? 0;
  89 + //数据详情
  90 + $data = $inquiry_list['data']['data'] ?? 0;
  91 + $arr['month_total'] = 0;
  92 + $countryArr = [];
  93 + $arr['country'] = "";
  94 + if(!empty($data)){
  95 + foreach ($data as $v){
  96 + if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){
  97 + $arr['month_total']++;
  98 + }
  99 + if(isset($countryArr[$v['country']])){
  100 + $countryArr[$v['country']]++;
  101 + }else{
  102 + $countryArr[$v['country']] = 0;
  103 + }
  104 + }
  105 + arsort($countryArr);
  106 + $top20 = array_slice($countryArr, 0, 15, true);
  107 + $arr['country'] = json_encode($top20);
  108 + }
  109 + return $arr;
  110 + }
  111 +
  112 + /**
  113 + * @remark :流量统计
  114 + * @name :flowCount
  115 + * @author :lyh
  116 + * @method :post
  117 + * @time :2023/6/30 14:31
  118 + */
  119 + public function flowCount(&$arr,&$startTime,&$endTime,$project_id){
  120 + $pv_ip = DB::table('gl_count')
  121 + ->where(['project_id'=>$project_id])
  122 + ->where('date','>=',$startTime.' 00:00:00')
  123 + ->where('date','<=',$endTime.' 23:59:59')
  124 + ->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))
  125 + ->first();
  126 + $arr['pv'] = $pv_ip->pv_num;
  127 + $arr['ip'] = $pv_ip->ip_num;
  128 + if($arr['ip'] != 0){
  129 + $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 10,2);
  130 + }
  131 + return $arr;
  132 + }
  133 +
  134 + /**
  135 + * @remark :来源访问前8
  136 + * @name :sourceCount
  137 + * @author :lyh
  138 + * @method :post
  139 + * @time :2023/6/30 16:14
  140 + */
  141 + public function sourceCount(&$arr,$domain,$startTime,$endTime){
  142 + //访问来源前10
  143 + $source = DB::connection('custom_mysql')->table('gl_customer_visit')
  144 + ->select('referrer_url', DB::raw('COUNT(*) as count'))
  145 + ->groupBy('referrer_url')->where(['domain'=>$domain])
  146 + ->whereBetween('updated_date', [$startTime,$endTime])
  147 + ->orderByDesc('count')->limit(10)->get()->toArray();
  148 + $arr['source'] = json_encode($source);
  149 + //访问国家前15
  150 + $source_country = DB::connection('custom_mysql')->table('gl_customer_visit')
  151 + ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
  152 + ->groupBy('country')->where(['domain'=>$domain])
  153 + ->whereBetween('updated_date', [$startTime,$endTime])
  154 + ->orderBy('ip','desc')->limit(15)->get()->toArray();
  155 + $arr['source_country'] = json_encode($source_country);
  156 + //受访界面前15
  157 + $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
  158 + ->select('url',DB::raw('COUNT(*) as num'))
  159 + ->orderBy('num','desc')->where(['domain'=>$domain])
  160 + ->whereBetween('updated_date', [$startTime,$endTime])
  161 + ->groupBy('url')
  162 + ->limit(15)->get()->toArray();
  163 + $arr['referrer_url'] = json_encode($referrer_url);
  164 + //访问端口
  165 + $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
  166 + ->select('device_port',DB::raw('COUNT(*) as num'))
  167 + ->orderBy('num','desc')->where(['domain'=>$domain])
  168 + ->whereBetween('updated_date', [$startTime,$endTime])
  169 + ->groupBy('device_port')
  170 + ->limit(15)->get()->toArray();
  171 + $arr['referrer_port'] = json_encode($referrer_port);
  172 + return $arr;
  173 + }
  174 +
  175 + /**
  176 + * @name :(查询参数设置)selectParam
  177 + * @author :lyh
  178 + * @method :post
  179 + * @time :2023/6/14 15:00
  180 + */
  181 + public function selectParam(){
  182 + $select = [
  183 + 'gl_project.id AS id',
  184 + 'gl_project.type AS type',
  185 + 'gl_project.extend_type AS extend_type',
  186 + 'gl_project_deploy_build.test_domain AS test_domain',
  187 + 'gl_project_deploy_optimize.domain AS domain',
  188 + 'gl_project_deploy_build.project_id AS project_id',
  189 + 'gl_project.cooperate_date AS cooperate_date',
  190 + 'gl_project_deploy_build.service_duration AS service_duration',
  191 + ];
  192 + return $select;
  193 + }
  194 +}
@@ -6,6 +6,7 @@ use App\Helper\Arr; @@ -6,6 +6,7 @@ use App\Helper\Arr;
6 use App\Helper\SemrushApi; 6 use App\Helper\SemrushApi;
7 use App\Models\RankData\ExternalLinks as ExternalLinksModel; 7 use App\Models\RankData\ExternalLinks as ExternalLinksModel;
8 use App\Models\Project\DeployOptimize; 8 use App\Models\Project\DeployOptimize;
  9 +use App\Utils\LogUtils;
9 10
10 /** 11 /**
11 * Class ExternalLinks 12 * Class ExternalLinks
@@ -39,7 +40,7 @@ class ExternalLinks extends BaseCommands @@ -39,7 +40,7 @@ class ExternalLinks extends BaseCommands
39 $semrushApi = new SemrushApi(); 40 $semrushApi = new SemrushApi();
40 //有排名api编号的项目 41 //有排名api编号的项目
41 $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray(); 42 $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
42 - 43 + LogUtils::info('start rank_data_external_links:' . count($list));
43 foreach ($list as $project_id => $domain) { 44 foreach ($list as $project_id => $domain) {
44 if(!$domain){ 45 if(!$domain){
45 continue; 46 continue;
@@ -5,6 +5,7 @@ namespace App\Console\Commands\RankData; @@ -5,6 +5,7 @@ namespace App\Console\Commands\RankData;
5 use App\Helper\QuanqiusouApi; 5 use App\Helper\QuanqiusouApi;
6 use App\Models\Project\DeployOptimize; 6 use App\Models\Project\DeployOptimize;
7 use App\Models\RankData\IndexedPages as IndexedPagesModel; 7 use App\Models\RankData\IndexedPages as IndexedPagesModel;
  8 +use App\Utils\LogUtils;
8 9
9 /** 10 /**
10 * Class IndexedPages 11 * Class IndexedPages
@@ -38,7 +39,7 @@ class IndexedPages extends BaseCommands @@ -38,7 +39,7 @@ class IndexedPages extends BaseCommands
38 $api = new QuanqiusouApi(); 39 $api = new QuanqiusouApi();
39 //有排名api编号的项目 40 //有排名api编号的项目
40 $list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray(); 41 $list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray();
41 - 42 + LogUtils::info('start rank_data_indexed_pages:' . count($list));
42 foreach ($list as $project_id => $api_no) { 43 foreach ($list as $project_id => $api_no) {
43 $model = IndexedPagesModel::where('project_id', $project_id)->first(); 44 $model = IndexedPagesModel::where('project_id', $project_id)->first();
44 if($model && $model->updated_date == getThisWeekStarDate()){ 45 if($model && $model->updated_date == getThisWeekStarDate()){
@@ -6,7 +6,9 @@ use App\Helper\Arr; @@ -6,7 +6,9 @@ use App\Helper\Arr;
6 use App\Helper\QuanqiusouApi; 6 use App\Helper\QuanqiusouApi;
7 use App\Models\Project\DeployBuild; 7 use App\Models\Project\DeployBuild;
8 use App\Models\Project\DeployOptimize; 8 use App\Models\Project\DeployOptimize;
  9 +use App\Models\Project\Project;
9 use App\Models\RankData\RankData as GoogleRankModel; 10 use App\Models\RankData\RankData as GoogleRankModel;
  11 +use App\Utils\LogUtils;
10 12
11 /** 13 /**
12 * Class GoogleRank 14 * Class GoogleRank
@@ -25,6 +27,7 @@ class RankData extends BaseCommands @@ -25,6 +27,7 @@ class RankData extends BaseCommands
25 27
26 /** 28 /**
27 * The console command description. 29 * The console command description.
  30 + * The console command description.
28 * 31 *
29 * @var string 32 * @var string
30 */ 33 */
@@ -40,6 +43,7 @@ class RankData extends BaseCommands @@ -40,6 +43,7 @@ class RankData extends BaseCommands
40 $api = new QuanqiusouApi(); 43 $api = new QuanqiusouApi();
41 //有排名api编号的项目 44 //有排名api编号的项目
42 $list = DeployOptimize::where('api_no', '>' , 0)->select('api_no','minor_languages','project_id')->get(); 45 $list = DeployOptimize::where('api_no', '>' , 0)->select('api_no','minor_languages','project_id')->get();
  46 + LogUtils::info('start rank_data:' . count($list));
43 //当日所有站点谷歌收录数据 47 //当日所有站点谷歌收录数据
44 $site_res = $api->getSiteRes(); 48 $site_res = $api->getSiteRes();
45 if(!$site_res){ 49 if(!$site_res){
@@ -55,10 +59,8 @@ class RankData extends BaseCommands @@ -55,10 +59,8 @@ class RankData extends BaseCommands
55 } 59 }
56 //收录数 60 //收录数
57 $indexed_pages_num = $site_res[$item['api_no']] ?? 0; 61 $indexed_pages_num = $site_res[$item['api_no']] ?? 0;
58 -  
59 $this->save_rank($item['project_id'], $res, $indexed_pages_num); 62 $this->save_rank($item['project_id'], $res, $indexed_pages_num);
60 } 63 }
61 -  
62 //有小语种的 64 //有小语种的
63 $lang_list = $api->getLangList(); 65 $lang_list = $api->getLangList();
64 if(!empty($lang_list[$item['api_no']])){ 66 if(!empty($lang_list[$item['api_no']])){
@@ -142,11 +144,14 @@ class RankData extends BaseCommands @@ -142,11 +144,14 @@ class RankData extends BaseCommands
142 } 144 }
143 145
144 //关键词达标天数 146 //关键词达标天数
  147 + $model->is_compliance = 0;
145 if($model->updated_date != date('Y-m-d')){ 148 if($model->updated_date != date('Y-m-d')){
146 //保证关键词数 149 //保证关键词数
147 $keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num'); 150 $keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
148 - if($first_page_num >= $keyword_num){ 151 + $type = Project::where('id', $project_id)->value('type');
  152 + if($keyword_num && $type == 2 && $first_page_num >= $keyword_num){
149 $model->compliance_day = $model->compliance_day + 1; 153 $model->compliance_day = $model->compliance_day + 1;
  154 + $model->is_compliance = 1;
150 } 155 }
151 } 156 }
152 157
@@ -160,6 +165,7 @@ class RankData extends BaseCommands @@ -160,6 +165,7 @@ class RankData extends BaseCommands
160 $model->lang = $lang; 165 $model->lang = $lang;
161 $model->data = $data; 166 $model->data = $data;
162 $model->updated_date = date('Y-m-d'); 167 $model->updated_date = date('Y-m-d');
  168 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($model, true) . PHP_EOL, FILE_APPEND);
163 $model->save(); 169 $model->save();
164 } 170 }
165 } 171 }
@@ -7,6 +7,7 @@ use App\Helper\Arr; @@ -7,6 +7,7 @@ use App\Helper\Arr;
7 use App\Helper\QuanqiusouApi; 7 use App\Helper\QuanqiusouApi;
8 use App\Models\Project\DeployOptimize; 8 use App\Models\Project\DeployOptimize;
9 use App\Models\RankData\RankWeek as RankWeekModel; 9 use App\Models\RankData\RankWeek as RankWeekModel;
  10 +use App\Utils\LogUtils;
10 11
11 /** 12 /**
12 * Class WeekRank 13 * Class WeekRank
@@ -49,7 +50,7 @@ class RankWeek extends BaseCommands @@ -49,7 +50,7 @@ class RankWeek extends BaseCommands
49 $res = Arr::s2a($res); 50 $res = Arr::s2a($res);
50 //有排名api编号的项目 51 //有排名api编号的项目
51 $list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray(); 52 $list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray();
52 - 53 + LogUtils::info('start rank_data_week:' . count($list));
53 foreach ($list as $project_id => $api_no) { 54 foreach ($list as $project_id => $api_no) {
54 $rank_week = RankWeekModel::where('project_id', $project_id)->first(); 55 $rank_week = RankWeekModel::where('project_id', $project_id)->first();
55 if ($rank_week && $rank_week->updated_date == getThisWeekStarDate()) { 56 if ($rank_week && $rank_week->updated_date == getThisWeekStarDate()) {
@@ -5,6 +5,7 @@ namespace App\Console\Commands\RankData; @@ -5,6 +5,7 @@ namespace App\Console\Commands\RankData;
5 use App\Helper\SemrushApi; 5 use App\Helper\SemrushApi;
6 use App\Models\RankData\RecommDomain as RecommDomainModel; 6 use App\Models\RankData\RecommDomain as RecommDomainModel;
7 use App\Models\Project\DeployOptimize; 7 use App\Models\Project\DeployOptimize;
  8 +use App\Utils\LogUtils;
8 9
9 /** 10 /**
10 * Class RecommDomain 11 * Class RecommDomain
@@ -38,7 +39,7 @@ class RecommDomain extends BaseCommands @@ -38,7 +39,7 @@ class RecommDomain extends BaseCommands
38 $semrushApi = new SemrushApi(); 39 $semrushApi = new SemrushApi();
39 //有排名api编号的项目 40 //有排名api编号的项目
40 $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray(); 41 $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
41 - 42 + LogUtils::info('start rank_data_recomm_domain:' . count($list));
42 foreach ($list as $project_id => $domain) { 43 foreach ($list as $project_id => $domain) {
43 if(!$domain){ 44 if(!$domain){
44 continue; 45 continue;
@@ -6,6 +6,7 @@ use App\Helper\Arr; @@ -6,6 +6,7 @@ use App\Helper\Arr;
6 use App\Helper\GoogleSpeedApi; 6 use App\Helper\GoogleSpeedApi;
7 use App\Models\Project\DeployOptimize; 7 use App\Models\Project\DeployOptimize;
8 use App\Models\RankData\Speed as GoogleSpeedModel; 8 use App\Models\RankData\Speed as GoogleSpeedModel;
  9 +use App\Utils\LogUtils;
9 10
10 /** 11 /**
11 * Class GoogleSpeed 12 * Class GoogleSpeed
@@ -42,7 +43,7 @@ class Speed extends BaseCommands @@ -42,7 +43,7 @@ class Speed extends BaseCommands
42 43
43 //有排名api编号的项目 44 //有排名api编号的项目
44 $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray(); 45 $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
45 - 46 + LogUtils::info('start rank_data_speed:' . count($list));
46 foreach ($list as $project_id => $domain) { 47 foreach ($list as $project_id => $domain) {
47 $model = GoogleSpeedModel::where('project_id', $project_id)->first(); 48 $model = GoogleSpeedModel::where('project_id', $project_id)->first();
48 if ($model && $model->updated_date == getThisWeekStarDate()) { 49 if ($model && $model->updated_date == getThisWeekStarDate()) {
@@ -53,6 +54,7 @@ class Speed extends BaseCommands @@ -53,6 +54,7 @@ class Speed extends BaseCommands
53 $res = $googleSpeedApi->run($domain); 54 $res = $googleSpeedApi->run($domain);
54 if (!$res) { 55 if (!$res) {
55 $error++; 56 $error++;
  57 + continue;
56 } 58 }
57 if (!$model) { 59 if (!$model) {
58 $model = new GoogleSpeedModel; 60 $model = new GoogleSpeedModel;
  1 +<?php
  2 +
  3 +namespace App\Console\Commands;
  4 +
  5 +use App\Helper\Arr;
  6 +use App\Models\Product\Category;
  7 +use App\Models\Product\Product;
  8 +use App\Models\Project\OnlineCheck;
  9 +use App\Models\Project\Project;
  10 +use App\Models\RankData\RankData as GoogleRankModel;
  11 +use App\Models\RouteMap\RouteMap;
  12 +use GuzzleHttp\Client;
  13 +use GuzzleHttp\Promise\Utils;
  14 +use Illuminate\Console\Command;
  15 +use Illuminate\Support\Facades\DB;
  16 +use Illuminate\Support\Str;
  17 +
  18 +/**
  19 + * 剩余服务时长
  20 + * Class Traffic
  21 + * @package App\Console\Commands
  22 + * @author zbj
  23 + * @date 2023/5/18
  24 + */
  25 +class RemainDay extends Command
  26 +{
  27 + /**
  28 + * The name and signature of the console command.
  29 + *
  30 + * @var string
  31 + */
  32 + protected $signature = 'remain_day';
  33 +
  34 + /**
  35 + * The console command description.
  36 + *
  37 + * @var string
  38 + */
  39 + protected $description = '网站服务剩余时长';
  40 +
  41 + /**
  42 + * Create a new command instance.
  43 + *
  44 + * @return void
  45 + */
  46 + public function __construct()
  47 + {
  48 + parent::__construct();
  49 + }
  50 +
  51 + /**
  52 + * @return bool
  53 + */
  54 + public function handle()
  55 + {
  56 + $list = Project::whereIn('type', [2,3,4])->get();
  57 + foreach ($list as $item){
  58 + if($item['type'] == 3){
  59 + //排名达标天数
  60 + $compliance_day = GoogleRankModel::where(['project_id' => $item['id'], 'lang' => ''])->value('compliance_day') ?: 0;
  61 + $remain_day = $item['deploy_build']['service_duration'] - $compliance_day;
  62 + }else{
  63 + //审核上线后开始
  64 + $check_time = OnlineCheck::where('project_id', $item['id'])->where('status', 1)->value('created_at') ?: '';
  65 + if(!$check_time){
  66 + $remain_day = $item['deploy_build']['service_duration'];
  67 + }else{
  68 + $diff = time() - strtotime($check_time);
  69 + $remain_day = floor($diff / (60 * 60 * 24));
  70 + }
  71 + }
  72 + $item->remain_day = $remain_day > 0 ? $remain_day : 0;
  73 + $item->save();
  74 + }
  75 + }
  76 +}
  1 +<?php
  2 +
  3 +namespace App\Console\Commands;
  4 +
  5 +
  6 +use App\Helper\OaGlobalsoApi;
  7 +use App\Models\Channel\Channel;
  8 +use App\Models\Channel\User;
  9 +use App\Models\Channel\Zone;
  10 +use Illuminate\Console\Command;
  11 +
  12 +/**
  13 + * 渠道信息
  14 + * Class ChannelInfo
  15 + * @package App\Console\Commands
  16 + * @author zbj
  17 + * @date 2023/6/27
  18 + */
  19 +class SyncChannel extends Command
  20 +{
  21 + /**
  22 + * The name and signature of the console command.
  23 + *
  24 + * @var string
  25 + */
  26 + protected $signature = 'sync_channel';
  27 +
  28 + /**
  29 + * The console command description.
  30 + *
  31 + * @var string
  32 + */
  33 + protected $description = '更新渠道信息';
  34 +
  35 + /**
  36 + * Create a new command instance.
  37 + *
  38 + * @return void
  39 + */
  40 + public function __construct()
  41 + {
  42 + parent::__construct();
  43 + }
  44 +
  45 + /**
  46 + * @return bool
  47 + */
  48 + public function handle()
  49 + {
  50 + $api = new OaGlobalsoApi();
  51 + $res = $api->agents_lists();
  52 + if($res && !empty($res['data'])){
  53 + foreach ($res['data'] as $item){
  54 + $zone = Zone::sync($item['belong']);
  55 + $channel = Channel::sync($item, $zone->id);
  56 + foreach ($item['users'] as $user){
  57 + User::sync($user, $channel->id);
  58 + }
  59 + }
  60 + }
  61 + return true;
  62 + }
  63 +
  64 +
  65 +}
  1 +<?php
  2 +
  3 +namespace App\Console\Commands;
  4 +
  5 +use App\Helper\Arr;
  6 +use App\Helper\Common;
  7 +use App\Helper\OaGlobalsoApi;
  8 +use App\Models\Channel\Channel;
  9 +use App\Models\Com\NoticeLog;
  10 +use App\Models\Project\After;
  11 +use App\Models\Project\DeployBuild;
  12 +use App\Models\Project\DeployOptimize;
  13 +use App\Models\Project\Payment;
  14 +use App\Models\Project\Project;
  15 +use App\Models\Project\ProjectRenew;
  16 +use App\Utils\LogUtils;
  17 +use Hashids\Hashids;
  18 +use Illuminate\Console\Command;
  19 +use Illuminate\Database\Eloquent\Model;
  20 +use Illuminate\Support\Facades\DB;
  21 +use Illuminate\Support\Facades\Http;
  22 +
  23 +/**
  24 + * 同步项目信息
  25 + * Class ChannelInfo
  26 + * @package App\Console\Commands
  27 + * @author zbj
  28 + * @date 2023/6/27
  29 + */
  30 +class SyncProject extends Command
  31 +{
  32 + /**
  33 + * The name and signature of the console command.
  34 + *
  35 + * @var string
  36 + */
  37 + protected $signature = 'sync_project';
  38 +
  39 + /**
  40 + * The console command description.
  41 + *
  42 + * @var string
  43 + */
  44 + protected $description = '同步项目信息';
  45 +
  46 + /**
  47 + * Create a new command instance.
  48 + *
  49 + * @return void
  50 + */
  51 + public function __construct()
  52 + {
  53 + parent::__construct();
  54 + }
  55 +
  56 + /**
  57 + * @return bool
  58 + */
  59 + public function handle()
  60 + {
  61 + while (true){
  62 + $list = NoticeLog::where('type', NoticeLog::TYPE_PROJECT)->where('status', NoticeLog::STATUS_PENDING)->get();
  63 + foreach ($list as $item){
  64 + try {
  65 + $api = new OaGlobalsoApi();
  66 + $data = $api->order_info($item['data']['order_id']);
  67 + if(!$data || empty($data['data'])){
  68 + LogUtils::error('OaGlobalsoApi order_info error', $data);
  69 + $this->retry($item);
  70 + }
  71 + if($data['data']['order_type'] == '首次'){
  72 + $this->sync($data['data']);
  73 +
  74 + //同步aicc
  75 + if($data['data']['exclusive_aicc']){
  76 + $this->toAicc($data['data']);
  77 + }
  78 + //同步hagro
  79 + if($data['data']['exclusive_hagro']){
  80 + $this->toHagro($data['data']);
  81 + }
  82 + }
  83 + if($data['data']['order_type'] == '续费'){
  84 + $this->renewSync($data['data']);
  85 + }
  86 + $item->status = NoticeLog::STATUS_SUCCESS;
  87 + $item->save();
  88 + }catch (\Exception $e){
  89 + errorLog('项目同步失败', $item, $e);
  90 + $this->retry($item);
  91 + }
  92 + }
  93 + sleep(2);
  94 + }
  95 +
  96 + }
  97 +
  98 + /**
  99 + * @param NoticeLog $log
  100 + */
  101 + public function retry($log){
  102 + if($log->retry >= 3){
  103 + $log->status = NoticeLog::STATUS_FAIL;
  104 + }else{
  105 + $log->retry = $log->retry + 1;
  106 + }
  107 + $log->save();
  108 + }
  109 +
  110 + /**
  111 + * @remark :同步续费记录单
  112 + * @name :renewSync
  113 + * @author :lyh
  114 + * @method :post
  115 + * @time :2023/8/11 15:33
  116 + */
  117 + public function renewSync($param){
  118 + $title = date('Ymd') . '-' . $param['company_name'];;
  119 + $data = [
  120 + 'title' => '【续费单】'.$title,
  121 + 'company' => $param['company_name'],
  122 + 'lead_name' => $param['principal_name'],
  123 + 'mobile' => $param['principal_mobile'],
  124 + 'qq' => $param['customer_qq'],
  125 + 'channel' => json_encode(Channel::getProjectChannel($param['company_id'], $param['username_sales'])),
  126 + 'requirement' => $param['remark'],
  127 + 'cooperate_date' => date('Y-m-d', $param['create_time']),
  128 + 'service_duration' => $param['years'],
  129 + 'plan' => $this->versionData($param['plan_marketing']),
  130 +// 'api_no' => $param['id'], //改手动填
  131 + 'amount' => $param['plan_price'],
  132 + 'contract' => json_encode($param['files']),
  133 + 'bill' => json_encode($param['images']),
  134 + ];
  135 + $renewModel = new ProjectRenew();
  136 + $rs = $renewModel->add($data);
  137 + if($rs === false){
  138 + errorLog('项目续费单同步失败');
  139 + }
  140 + return true;
  141 + }
  142 +
  143 + /**
  144 + * @remark :获取版本
  145 + * @name :versionData
  146 + * @author :lyh
  147 + * @method :post
  148 + * @time :2023/8/9 14:46
  149 + */
  150 + public function versionData($param){
  151 + $data = Project::planMap();
  152 + $data = array_flip($data);
  153 + if(isset($data[$param])){
  154 + return $data[$param];
  155 + }else{
  156 + return 1;
  157 + }
  158 + }
  159 +
  160 + /**
  161 + * @remark :导入数据
  162 + * @name :sync
  163 + * @author :lyh
  164 + * @method :post
  165 + * @time :2023/8/9 15:04
  166 + */
  167 + public function sync($param){
  168 + $title = date('Ymd') . '-' . $param['company_name'];
  169 + $data = [
  170 + 'project'=>[
  171 + 'title' => $title,
  172 + 'company' => $param['company_name'],
  173 + 'lead_name' => $param['principal_name'],
  174 + 'mobile' => $param['principal_mobile'],
  175 + 'mysql_id'=>Project::MYSQL_ID,
  176 + 'qq' => $param['customer_qq'],
  177 + 'channel' => Channel::getProjectChannel($param['company_id'], $param['username_sales']),
  178 + 'requirement' => $param['remark'],
  179 + 'cooperate_date' => date('Y-m-d', $param['create_time']),
  180 + 'from_order_id' => $param['from_order_id'],
  181 + 'aicc' => $param['exclusive_aicc'],
  182 + "exclusive_aicc_day" => $param['exclusive_aicc_day'],
  183 + 'hagro' => $param['exclusive_hagro'],
  184 + "exclusive_hagro_day" => $param['exclusive_hagro_day'],
  185 + 'notice_order_id' => $param['id'],
  186 + ],
  187 + 'deploy_build' => [
  188 + 'service_duration' => $param['years'],
  189 + 'plan' => $this->versionData($param['plan_marketing']),
  190 + 'login_mobile'=>$param['principal_mobile']
  191 + ],
  192 + 'deploy_optimize' => [
  193 + 'api_no' => $param['id']
  194 + ],
  195 + 'project_after' => [],
  196 + 'payment' => [
  197 + 'amount' => $param['plan_price'],
  198 + 'contract'=>$param['files'],
  199 + 'bill'=>$param['images']
  200 + ],
  201 + ];
  202 + DB::beginTransaction();
  203 + try {
  204 + $id = $this->saveProject($data['project']);
  205 + $this->setPostId($data['deploy_build']['plan'],$id);;
  206 + $this->savePayment($data['payment'],$id);
  207 + $this->saveDeployBuild($data['deploy_build'],$id);
  208 + $this->saveDeployOptimize($data['deploy_optimize'],$id);
  209 + $this->saveAfter($data['project_after'],$id);
  210 + DB::commit();
  211 + }catch (\Exception $e){
  212 + DB::rollBack();
  213 + throw new \Exception($e->getMessage());
  214 + }
  215 + }
  216 +
  217 + /**
  218 + * @remark :设置post_id
  219 + * @name :setPostId
  220 + * @author :lyh
  221 + * @method :post
  222 + * @time :2023/8/9 14:47
  223 + */
  224 + public function setPostId($plan,$id){
  225 + $length = strlen((string)$id); // 获取变量的位数
  226 + $paddingLength = Project::TYPE_FIVE - $length; // 计算填充前面的 0 的位数
  227 + $zeros = str_repeat("0", $paddingLength);
  228 + $number = Project::TYPE_SIX.$plan.$zeros.$id;
  229 + $projectModel = new Project();
  230 + $projectModel->edit(['post_id'=>$number],['id'=>$id]);
  231 + return true;
  232 + }
  233 +
  234 + /**
  235 + * @remark :保存项目
  236 + * @name :saveProject
  237 + * @author :lyh
  238 + * @method :post
  239 + * @time :2023/8/30 15:53
  240 + */
  241 + public function saveProject($param){
  242 + if(isset($param['channel']) && !empty($param['channel'])){
  243 + $param['channel'] = Arr::a2s($param['channel']);
  244 + }
  245 + $projectModel = new Project();
  246 + $info = $projectModel->read(['from_order_id'=>$param['from_order_id'],'delete_status'=>0]);
  247 + if($info !== false){
  248 + $projectModel->edit($param, ['id' => $info['id']]);
  249 + return $info['id'];
  250 + }else{
  251 + return $projectModel->addReturnId($param);
  252 + }
  253 + }
  254 +
  255 + /**
  256 + * 保存优化部署
  257 + * @author zbj
  258 + * @date 2023/4/26
  259 + */
  260 + protected function saveAfter($param,$id){
  261 + $param['project_id'] = $id;
  262 + //查询数据是否存在
  263 + $afterModel = new After();
  264 + $info = $afterModel->read(['project_id'=>$id]);
  265 + if($info !== false){
  266 + $afterModel->edit($param,['id'=>$info['id']]);
  267 + }else{
  268 + $afterModel->add($param);
  269 + }
  270 + }
  271 +
  272 + /**
  273 + * @remark :保存付款续费
  274 + * @name :savePayment
  275 + * @author :lyh
  276 + * @method :post
  277 + * @time :2023/8/29 16:19
  278 + */
  279 + protected function savePayment($param,$id){
  280 + $param['project_id'] = $id;
  281 + $paymentModel= new Payment();
  282 +// if(isset($param['contract']) && !empty($param['contract'])){
  283 + $param['contract'] = Arr::a2s($param['contract']);
  284 +// }
  285 +// if(isset($param['bill']) && !empty($param['bill'])){
  286 + $param['bill'] = Arr::a2s($param['bill']);
  287 +// }
  288 + $info = $paymentModel->read(['project_id'=>$id]);
  289 + if($info !== false){
  290 + $paymentModel->edit($param,['id'=>$info['id']]);
  291 + }else{
  292 + $paymentModel->add($param);
  293 + }
  294 + }
  295 +
  296 + /**
  297 + * @remark :保存建站部署
  298 + * @name :saveDeployBuild
  299 + * @author :lyh
  300 + * @method :post
  301 + * @time :2023/8/29 16:19
  302 + */
  303 + protected function saveDeployBuild($param,$id){
  304 + $param['project_id'] = $id;
  305 + $hashids = new Hashids('test_domain', 5, 'abcdefghjkmnpqrstuvwxyz1234567890');
  306 + $code = $hashids->encode($id);
  307 + $param['test_domain'] = 'https://v6-' . $code . '.globalso.site/';
  308 + $deployBuildModel = new DeployBuild();
  309 + $info = $deployBuildModel->read(['project_id'=>$id]);
  310 + if($info !== false){
  311 + $deployBuildModel->edit($param,['id'=>$info['id']]);
  312 + }else{
  313 + $deployBuildModel->add($param);
  314 + }
  315 + }
  316 +
  317 + /**
  318 + * @remark :保存优化信息
  319 + * @name :saveDeployOptimize
  320 + * @author :lyh
  321 + * @method :post
  322 + * @time :2023/8/30 16:11
  323 + */
  324 + protected function saveDeployOptimize($param,$id){
  325 + $param['project_id'] = $id;
  326 + $deployOptimizeModel = new DeployOptimize();
  327 + $info = $deployOptimizeModel->read(['project_id'=>$id]);
  328 + if($info !== false){
  329 + $deployOptimizeModel->edit($param,['id'=>$info['id']]);
  330 + }else{
  331 + $deployOptimizeModel->add($param);
  332 + }
  333 + }
  334 +
  335 + /**
  336 + * 同步到AICC
  337 + * @param $data
  338 + * @author zbj
  339 + * @date 2023/9/1
  340 + */
  341 + protected function toAicc($data){
  342 + $url = 'https://biz.ai.cc/api/sync_company_for_order';
  343 + $param = [
  344 + 'company_name' => $data['company_name'],
  345 + 'company_address' => '',
  346 + 'company_tel' => $data['principal_mobile'],
  347 + 'company_email' => '',
  348 + 'remark' => $data['remark'],
  349 + 'level_id' => 6,
  350 + 'level_day' => $data['exclusive_aicc_day'] ?: 1,
  351 + 'from_order_id' => $data['from_order_id'],
  352 + ];
  353 +
  354 + //sign
  355 + ksort($param);
  356 + $tem = [];
  357 + foreach ($param as $key => $val) {
  358 + $tem[] = $key . '=' . urlencode($val);
  359 + }
  360 + $string = implode('&', $tem);
  361 + $key = md5('quanqiusou.com');
  362 + $param['sign'] = md5($string . $key);
  363 + $res = Http::withoutVerifying()->post($url, $param)->json();
  364 + if(empty($res['status']) || $res['status'] != 200){
  365 + LogUtils::error('ProjectToAicc error', $res);
  366 + }
  367 + }
  368 +
  369 + /**
  370 + * 同步到Hagro
  371 + * @param $data
  372 + * @author zbj
  373 + * @date 2023/9/1
  374 + */
  375 + protected function toHagro($data){
  376 + $url = 'https://admin.hagro.cn/globalso/create_project';
  377 + $param = [
  378 + 'company' => $data['company_name'],
  379 + 'phone' => $data['principal_mobile'],
  380 + 'planday' => $data['exclusive_aicc_day'] ?: 1,
  381 + 'from_order_id' => $data['from_order_id'],
  382 + ];
  383 + $common = new Common();
  384 + $token = $common->encrypt($param);
  385 + $res = Http::withoutVerifying()->get($url, ['token' => $token])->json();
  386 + if(empty($res['code']) || $res['code'] != 200){
  387 + LogUtils::error('ProjectToHagro error', $res);
  388 + }
  389 + }
  390 +}
@@ -7,11 +7,18 @@ @@ -7,11 +7,18 @@
7 */ 7 */
8 namespace App\Console\Commands\Test; 8 namespace App\Console\Commands\Test;
9 9
  10 +use App\Models\Blog\Blog;
10 use App\Models\Devops\ServerConfig; 11 use App\Models\Devops\ServerConfig;
  12 +use App\Models\File\Image;
  13 +use App\Models\Manage\BelongingGroup;
  14 +use App\Models\Manage\Dept;
  15 +use App\Models\Manage\EntryPosition;
  16 +use App\Models\Manage\ManageHr;
11 use App\Services\ProjectServer; 17 use App\Services\ProjectServer;
12 use GuzzleHttp\Client; 18 use GuzzleHttp\Client;
13 use Illuminate\Console\Command; 19 use Illuminate\Console\Command;
14 use Illuminate\Support\Facades\DB; 20 use Illuminate\Support\Facades\DB;
  21 +use Illuminate\Support\Facades\Log;
15 22
16 class Demo extends Command 23 class Demo extends Command
17 { 24 {
@@ -39,11 +46,194 @@ class Demo extends Command @@ -39,11 +46,194 @@ class Demo extends Command
39 parent::__construct(); 46 parent::__construct();
40 } 47 }
41 48
  49 + public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)
  50 + {
  51 +
  52 + $ch = curl_init();
  53 + curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
  54 + curl_setopt($ch, CURLOPT_URL, $url);
  55 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  56 + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  57 + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  58 + if ($data)
  59 + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  60 + curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([
  61 + 'Expect:',
  62 + 'Content-type: application/json',
  63 + 'Accept: application/json',
  64 + ], $header)
  65 + );
  66 + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  67 + $response = curl_exec($ch);
  68 + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  69 + curl_close($ch);
  70 + return [$code, $response];
  71 + }
  72 +
42 /** 73 /**
43 * @return bool 74 * @return bool
44 */ 75 */
45 public function handle() 76 public function handle()
46 { 77 {
  78 + $data = [];
  79 + dd(isset($data['a']['b']));
  80 + $url = 'https://demo.globalso.site/';
  81 + $action = 'api/updateHtmlNotify/';
  82 + $data = [
  83 + 'project_id' => 1,
  84 + 'type' => 1,
  85 + 'route' => 1
  86 + ];;
  87 + $method = 'GET';
  88 + $result = $this->curlRequest($url . $action, $data, $method);
  89 + dd($result);
  90 +
  91 + $context = stream_context_create([
  92 + 'ssl' => [
  93 + 'capture_peer_cert' => true,
  94 + 'capture_peer_cert_chain' => false,
  95 + ],
  96 + ]);
  97 +
  98 + $stream = stream_socket_client('ssl://oa.quanqiusou.cn:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
  99 +
  100 + if(!$stream) {
  101 + die("Failed to connect: $errno - $errstr");
  102 + }
  103 +
  104 + $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
  105 +
  106 + if(!$remote_cert) {
  107 + die("Failed to retrieve certificate");
  108 + }
  109 +
  110 + $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
  111 + $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
  112 +
  113 + fclose($stream);
  114 +
  115 + echo "Certificate Valid From: $valid_from<br>";
  116 + echo "Certificate Valid To: $valid_to<br>";
  117 +
  118 + dd('end');
  119 + $dept_array = [
  120 + '品牌部',
  121 + '综合部',
  122 + '渠道部',
  123 + '广告推广部',
  124 + 'AICC运营部',
  125 + '黑格运营部',
  126 + '直营运营部',
  127 + '直营销售部',
  128 + '深圳跨境部',
  129 + '外贸部',
  130 + '研发部',
  131 + '技术部',
  132 + '售后部',
  133 + ];
  134 + foreach ($dept_array as $v) {
  135 + $dept = Dept::where(['title' => $v])->first();
  136 + if (FALSE == empty($dept))
  137 + continue;
  138 + $dept = new Dept();
  139 + $dept->title = $v;
  140 + $dept->save();
  141 + }
  142 +// dd('dept end');
  143 + $dept_map = Dept::pluck('title', 'id')->toArray();
  144 + $belonging_map = BelongingGroup::pluck('name', 'id')->toArray();
  145 +// dd($belonging_map);
  146 +
  147 + $filename = storage_path('logs/oa_hr.txt');
  148 + $string = file_get_contents($filename);
  149 + $data = explode("\r\n", $string);
  150 + $data = array_filter($data);
  151 + $dept = '';
  152 + foreach ($data as $k=>$v) {
  153 +// var_dump($v) . PHP_EOL;
  154 + if ($k == 1)
  155 + continue;
  156 + $tmp = explode("\t", $v);
  157 + if (count($tmp) == 3) {
  158 + $dept = $tmp[0] ? : $dept;
  159 + $position = $tmp[1];
  160 + $name = $tmp[2];
  161 + } else if (count($tmp) == 2) {
  162 + $position = $tmp[0];
  163 + $name = $tmp[1];
  164 + } else {
  165 + Log::info($v . PHP_EOL);
  166 + continue;
  167 + }
  168 +
  169 +
  170 +// Log::info($dept . '---' . $position . '---' . $name . PHP_EOL);
  171 +// continue;
  172 +
  173 + $dept_id = array_search($dept, $dept_map);
  174 + $belonging_id = 17;
  175 + if (FALSE !== strpos($dept,'技术部')) {
  176 + $belonging_string = str_replace('技术部', '', $dept);
  177 + if ($belonging_string) {
  178 + $belonging_string = $belonging_string . '组';
  179 + $belonging_id = array_search($belonging_string, $belonging_map);
  180 + }
  181 +
  182 + $dept_tmp = '技术部';
  183 + $dept_id = array_search($dept_tmp, $dept_map);
  184 + }
  185 + if (FALSE !== strpos($dept,'售后')) {
  186 + $belonging_string = str_replace('售后', '', $dept);
  187 + if ($belonging_string)
  188 + $belonging_id = array_search($belonging_string, $belonging_map);
  189 + $dept_tmp = '售后部';
  190 + $dept_id = array_search($dept_tmp, $dept_map);
  191 + }
  192 +
  193 + $position_log = EntryPosition::where(['name' => $position])->first();
  194 + if (empty($position_log)) {
  195 + $position_log = new EntryPosition();
  196 + $position_log->name = $position;
  197 + $position_log->save();
  198 + }
  199 + $position_id = $position_log->id;
  200 +
  201 + $hr = ManageHr::where(['name' => $name])->first();
  202 + if (empty($hr)) {
  203 + Log::info($k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id);
  204 + continue;
  205 + }
  206 +
  207 + $hr->belong_group = $belonging_id;
  208 + $hr->dept_id = $dept_id;
  209 + $hr->entry_position = $position_id;
  210 + $hr->save();
  211 + echo $k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id . '-' . '组' . '-' . $belonging_id . PHP_EOL;
  212 +
  213 + }
  214 + dd('end');
  215 + exit;
  216 +
  217 + if (($handle = fopen($filename, 'r')) !== false) {
  218 + while (($data = fgetcsv($handle, 1000, ',')) !== false) {
  219 + // 处理每行数据
  220 + Log::info(var_export($data, true));
  221 + }
  222 + fclose($handle);
  223 + }
  224 + exit;
  225 +
  226 + $group = BelongingGroup::get();
  227 + dd($group->toArray());
  228 + $domain = parse_url('https//:dev.golbalso.site/');
  229 + dd($domain);
  230 + echo time() . PHP_EOL;
  231 + $blogModel = new Image();
  232 + $list = $blogModel->list();
  233 + echo time() . PHP_EOL;
  234 + dd(count($list));
  235 +
  236 + return;
47 preg_match_all("/\@include\(\"([a-z0-9_]+)\"\)/i",' 237 preg_match_all("/\@include\(\"([a-z0-9_]+)\"\)/i",'
48 @include("asdf")@include("")@include("asdtrw2erf") 238 @include("asdf")@include("")@include("asdtrw2erf")
49 ',$include); 239 ',$include);
@@ -5,7 +5,8 @@ namespace App\Console\Commands; @@ -5,7 +5,8 @@ namespace App\Console\Commands;
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Models\Product\Category; 6 use App\Models\Product\Category;
7 use App\Models\Product\Product; 7 use App\Models\Product\Product;
8 -use App\Models\RouteMap; 8 +use App\Models\RouteMap\RouteMap;
  9 +use App\Services\ProjectServer;
9 use GuzzleHttp\Client; 10 use GuzzleHttp\Client;
10 use GuzzleHttp\Promise\Utils; 11 use GuzzleHttp\Promise\Utils;
11 use Illuminate\Console\Command; 12 use Illuminate\Console\Command;
@@ -230,20 +231,26 @@ class WebTraffic extends Command @@ -230,20 +231,26 @@ class WebTraffic extends Command
230 */ 231 */
231 protected function getProductUrls($project_id){ 232 protected function getProductUrls($project_id){
232 //产品分类页面 233 //产品分类页面
233 - $product_cate_ids = Category::where('project_id', $project_id)->where('status', Category::STATUS_ACTIVE)->pluck('id')->toArray();  
234 - $data['urls_cats'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT_CATE)->whereIn('source_id', $product_cate_ids)->get()->toArray(); 234 + ProjectServer::useProject($project_id);
  235 + $product_cate_ids = DB::connection('custom_mysql')->table('gl_product_category')
  236 + ->where('project_id', $project_id)->where('status', 1)->pluck('id')->toArray();
  237 + $data['urls_cats'] = DB::connection('custom_mysql')->table('gl_route_map')
  238 + ->where('project_id', $project_id)->where('source', 'product_category')->whereIn('source_id', $product_cate_ids)->get()->toArray();
235 //单页面 239 //单页面
236 //todo 发布状态的单页面id 240 //todo 发布状态的单页面id
237 - $data['urls_page'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PAGE)->get()->toArray(); 241 + $data['urls_page'] = DB::connection('custom_mysql')->table('gl_route_map')
  242 + ->where('project_id', $project_id)->where('source', 'page')->get()->toArray();
238 //产品详情页 243 //产品详情页
239 - $product_ids = Product::where('project_id', $project_id)->where('status', Product::STATUS_ON)->pluck('id')->toArray();  
240 - $data['urls_details'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT)->whereIn('source_id', $product_ids)->get()->toArray(); 244 + $product_ids = DB::connection('custom_mysql')->table('gl_product_category')
  245 + ->where('project_id', $project_id)->where('status', 1)->pluck('id')->toArray();
  246 + $data['urls_details'] = DB::connection('custom_mysql')->table('gl_route_map')
  247 + ->where('project_id', $project_id)->where('source', 'product')->whereIn('source_id', $product_ids)->get()->toArray();
241 248
242 $data['urls_cats'] = array_merge($data['urls_cats'], $data['urls_page']); 249 $data['urls_cats'] = array_merge($data['urls_cats'], $data['urls_page']);
243 if(empty($data['urls_cats'])){ 250 if(empty($data['urls_cats'])){
244 $data['urls_cats'] = $data['urls_details']; 251 $data['urls_cats'] = $data['urls_details'];
245 } 252 }
246 - 253 + DB::disconnect('custom_mysql');
247 return $data; 254 return $data;
248 } 255 }
249 256
@@ -312,10 +319,10 @@ class WebTraffic extends Command @@ -312,10 +319,10 @@ class WebTraffic extends Command
312 319
313 $url = []; 320 $url = [];
314 if($res_sdzb == 0){//深度一页 321 if($res_sdzb == 0){//深度一页
315 - $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : ''; 322 + $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])->route : '';
316 }elseif($res_sdzb == 1){//深度两页 323 }elseif($res_sdzb == 1){//深度两页
317 $url[] = $project_urls['home']; 324 $url[] = $project_urls['home'];
318 - $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : ''; 325 + $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])->route : '';
319 }elseif($res_sdzb == 2){//深度3-6页 326 }elseif($res_sdzb == 2){//深度3-6页
320 $yms = rand(2,5); //随机页面数 327 $yms = rand(2,5); //随机页面数
321 $url = Arr::pluck(Arr::random($all_url, $yms), 'route'); 328 $url = Arr::pluck(Arr::random($all_url, $yms), 'route');
@@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel @@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
16 protected function schedule(Schedule $schedule) 16 protected function schedule(Schedule $schedule)
17 { 17 {
18 // $schedule->command('inspire')->hourly(); 18 // $schedule->command('inspire')->hourly();
  19 + $schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长
19 $schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次 20 $schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
20 $schedule->command('rank_data_speed')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次 21 $schedule->command('rank_data_speed')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次
21 $schedule->command('rank_data_external_links')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次 22 $schedule->command('rank_data_external_links')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
@@ -23,27 +24,17 @@ class Kernel extends ConsoleKernel @@ -23,27 +24,17 @@ class Kernel extends ConsoleKernel
23 $schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次 24 $schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次
24 $schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次 25 $schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次
25 $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 26 $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
26 - $schedule->command('yesterday_count')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次 27 + $schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
27 $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 28 $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
28 $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 29 $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
29 $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 30 $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
30 -// // 更新域名|证书结束时间,每天凌晨1点执行一次  
31 -// $schedule->command('domain_time')->dailyAt('01:00')->withoutOverlapping(1);  
32 -// // B站 - 网站数据统计  
33 -// // 获取当前月份最后一天  
34 -// $lastDay = date('Y-m-t');  
35 -// // 统计当月访问来源数据,每月最后一天23:59点执行一次  
36 -// $schedule->command('statistics_source')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1);  
37 -// // 统计当月地域分布数据,每月最后一天23:59点执行一次  
38 -// $schedule->command('statistics_distribution')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1);  
39 -// // 统计当月受访页面数据,每月最后一天23:59点执行一次  
40 -// $schedule->command('statistics_page')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1);  
41 -// // 统计当月访问终端数据,每月最后一天23:59点执行一次  
42 -// $schedule->command('statistics_terminal')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1);  
43 -// // 统计当月流量趋势数据,每月最后一天23:59点执行一次  
44 -// $schedule->command('statistics_trend')->monthlyOn($lastDay, '23:59')->withoutOverlapping(1);  
45 -// // 统计当天流量趋势数据,每天23:59点执行一次  
46 -// $schedule->command('statistics_day_trend')->dailyAt('23:59')->withoutOverlapping(1); 31 + $schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次
  32 + $schedule->command('month_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计记录
  33 + $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录
  34 + $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
  35 + $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
  36 + $schedule->command('domain_info')->dailyAt('01:00')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
  37 + $schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
47 } 38 }
48 39
49 /** 40 /**
@@ -18,4 +18,6 @@ final class Common extends Enum @@ -18,4 +18,6 @@ final class Common extends Enum
18 //端 18 //端
19 const A='a'; 19 const A='a';
20 const B='b'; 20 const B='b';
  21 +
  22 + const MANAGE_TOKEN = 'manage_token:';
21 } 23 }
@@ -21,4 +21,5 @@ class AsideGlobalException extends Exception @@ -21,4 +21,5 @@ class AsideGlobalException extends Exception
21 $this->message = Code::fromValue($code)->description; 21 $this->message = Code::fromValue($code)->description;
22 } 22 }
23 } 23 }
  24 +
24 } 25 }
@@ -21,4 +21,5 @@ class BsideGlobalException extends Exception @@ -21,4 +21,5 @@ class BsideGlobalException extends Exception
21 $this->message = Code::fromValue($code)->description; 21 $this->message = Code::fromValue($code)->description;
22 } 22 }
23 } 23 }
  24 +
24 } 25 }
@@ -261,9 +261,6 @@ class AliSms @@ -261,9 +261,6 @@ class AliSms
261 'InvalidSendSms' => '1小时只能请求7次,谢谢', 261 'InvalidSendSms' => '1小时只能请求7次,谢谢',
262 'InvalidDayu.Malformed' => '变量不能是url,可以将变量固化在模板中', 262 'InvalidDayu.Malformed' => '变量不能是url,可以将变量固化在模板中',
263 ); 263 );
264 - if (isset($message[$status])) {  
265 - return $message[$status];  
266 - }  
267 return $status; 264 return $status;
268 } 265 }
269 266
@@ -5,6 +5,7 @@ namespace App\Helper; @@ -5,6 +5,7 @@ namespace App\Helper;
5 use App\Models\Ai\AiCommand as AiCommandModel; 5 use App\Models\Ai\AiCommand as AiCommandModel;
6 use App\Models\User\UserLog as UserLogModel; 6 use App\Models\User\UserLog as UserLogModel;
7 use App\Models\User\UserLogin as UserLoginModel; 7 use App\Models\User\UserLogin as UserLoginModel;
  8 +use Illuminate\Encryption\Encrypter;
8 use Illuminate\Support\Facades\Cache; 9 use Illuminate\Support\Facades\Cache;
9 10
10 /** 11 /**
@@ -12,6 +13,8 @@ use Illuminate\Support\Facades\Cache; @@ -12,6 +13,8 @@ use Illuminate\Support\Facades\Cache;
12 */ 13 */
13 class Common 14 class Common
14 { 15 {
  16 + public $key = '66537a12d4fff992f6d8b67fdda6192f';
  17 + public $method = 'AES-256-CBC';
15 /** 18 /**
16 * @name :生成用户操作日志 19 * @name :生成用户操作日志
17 * @return void 20 * @return void
@@ -37,7 +40,9 @@ class Common @@ -37,7 +40,9 @@ class Common
37 public static function set_user_login($param = []){ 40 public static function set_user_login($param = []){
38 $data = [ 41 $data = [
39 'user_id'=>$param['user_id'], 42 'user_id'=>$param['user_id'],
40 - 'ip'=>$param['ip'] 43 + 'ip'=>$param['ip'],
  44 + 'project_id'=>$param['project_id'] ?: 0,
  45 + 'remark'=>$param['remark'] ?? '',
41 ]; 46 ];
42 $model = new UserLoginModel(); 47 $model = new UserLoginModel();
43 return $model->add($data); 48 return $model->add($data);
@@ -57,12 +62,27 @@ class Common @@ -57,12 +62,27 @@ class Common
57 if($info === false){ 62 if($info === false){
58 response('指令不存在',400); 63 response('指令不存在',400);
59 } 64 }
  65 + if (strpos($param['keywords'], '{') !== false && strpos($param['keywords'], '}') !== false) {
  66 + $pattern = '/\{([^}]+)\}/'; // 匹配大括号及其内容
  67 + if (preg_match($pattern, $param['keywords'], $matches)) {
  68 + $lang = $matches[1]; // 获取捕获的内容
  69 + }
  70 + } else {
  71 + //带原语种翻译
  72 + $result = Translate::translateSl($param['keywords'])->json();
  73 + if (isset($result['texts']['sl']) && isset(Translate::$tls_list[$result['texts']['sl']])) {
  74 + $lang = Translate::$tls_list[$result['texts']['sl']]['text'];
  75 + } else {
  76 + $lang = '中文';
  77 + }
  78 + }
  79 + $str = ',请使用'.$lang.'回答';
60 //替换关键字 80 //替换关键字
61 $content = str_replace('$keyword$', $param['keywords'], $info['ai']); 81 $content = str_replace('$keyword$', $param['keywords'], $info['ai']);
62 $data = [ 82 $data = [
63 'messages'=>[ 83 'messages'=>[
64 ['role'=>'system','content'=>$info['scene']], 84 ['role'=>'system','content'=>$info['scene']],
65 - ['role'=>'assistant','content'=>$content], 85 + ['role'=>'assistant','content'=>$content.$str],
66 ] 86 ]
67 ]; 87 ];
68 return http_post($url,json_encode($data)); 88 return http_post($url,json_encode($data));
@@ -148,4 +168,19 @@ class Common @@ -148,4 +168,19 @@ class Common
148 $days = floor(($currentTimestamp - $targetTimestamp) / (60 * 60 * 24)); 168 $days = floor(($currentTimestamp - $targetTimestamp) / (60 * 60 * 24));
149 return (int)$days; 169 return (int)$days;
150 } 170 }
  171 +
  172 + // 生成授授权码
  173 + public function encrypt($data)
  174 + {
  175 + $crypt = new Encrypter($this->key, $this->method);
  176 + return $crypt->encrypt($data);
  177 + }
  178 +
  179 + // 解密授权码
  180 + public function decrypt($string)
  181 + {
  182 + $crypt = new Encrypter($this->key, $this->method);
  183 + return $crypt->decrypt($string);
  184 + }
  185 +
151 } 186 }
@@ -108,31 +108,30 @@ class GoogleSpeedApi @@ -108,31 +108,30 @@ class GoogleSpeedApi
108 function run($url) 108 function run($url)
109 { 109 {
110 try { 110 try {
111 - $params = [  
112 - 'url' => $url  
113 - ];  
114 - $res = HttpUtils::get('http://45.136.131.72/api.php', $params);  
115 - if ($res) {  
116 - $res = Arr::s2a($res);  
117 - $area_data = Arr::s2a($res['area_data']); 111 + if($url){
  112 + $params = [
  113 + 'url' => $url
  114 + ];
  115 + $res = HttpUtils::get('http://pagespeed.quanqiusou.cn/api.php', $params);
  116 + if ($res) {
  117 + $res = Arr::s2a($res);
  118 + $area_data = Arr::s2a($res['area_data']);
  119 + }
  120 + $numericValue = $area_data[0]['numericValue'] ?? rand(500, 1000);
  121 + foreach ($this->areas as &$area) {
  122 + $start = -$numericValue * 0.5;
  123 + $end = $numericValue * 0.5;
  124 + $numer = rand($start, $end);
  125 + $area["numericValue"] = ceil($numericValue - $numer);
  126 + }
118 } 127 }
119 - $numericValue = $area_data[0]['numericValue'] ?? rand(500, 1000);  
120 - foreach ($this->areas as &$area) {  
121 - $start = -$numericValue * 0.5;  
122 - $end = $numericValue * 0.5;  
123 - $numer = rand($start, $end);  
124 - $area["numericValue"] = ceil($numericValue - $numer);  
125 - }  
126 -  
127 - return [  
128 - "url" => $url,  
129 - "area_data" => $this->areas,  
130 - "created_at" => date("Y-m-d H:i:s")  
131 - ];  
132 -  
133 } catch (\Exception | GuzzleException $e) { 128 } catch (\Exception | GuzzleException $e) {
134 errorLog('测速失败', $params, $e); 129 errorLog('测速失败', $params, $e);
135 - return false;  
136 } 130 }
  131 + return [
  132 + "url" => $url,
  133 + "area_data" => $this->areas,
  134 + "created_at" => date("Y-m-d H:i:s")
  135 + ];
137 } 136 }
138 } 137 }
  1 +<?php
  2 +
  3 +
  4 +namespace App\Helper;
  5 +
  6 +use App\Utils\HttpUtils;
  7 +use GuzzleHttp\Exception\GuzzleException;
  8 +
  9 +
  10 +/**
  11 + * Class OaGlobalsoApi
  12 + * @package App\Helper
  13 + * @author zbj
  14 + * @date 2023/6/27
  15 + */
  16 +class OaGlobalsoApi
  17 +{
  18 +
  19 + //接口地址
  20 + protected $url = 'https://oa.cmer.com';
  21 +
  22 + protected $token = '';
  23 +
  24 +
  25 + public function __construct()
  26 + {
  27 + $this->token = md5('oa' . date('Y-m-d'));
  28 + }
  29 +
  30 + /**
  31 + * 项目信息
  32 + * @author zbj
  33 + * @date 2023/5/17
  34 + */
  35 + public function order_info($order_id)
  36 + {
  37 + $api_url = $this->url . '/api/order_info?token='.$this->token.'&order_id='.$order_id;
  38 + $res = http_get($api_url,["charset" => "UTF-8"]);
  39 + return $res;
  40 + }
  41 +
  42 + /**
  43 + * 渠道信息
  44 + * @author zbj
  45 + * @date 2023/5/17
  46 + */
  47 + public function agents_lists()
  48 + {
  49 + $api_url = $this->url . '/api/agents_lists';
  50 +
  51 + $params = [
  52 + 'token' => $this->token,
  53 + ];
  54 +
  55 + try {
  56 + $res = HttpUtils::get($api_url, $params);
  57 + $res = Arr::s2a($res);
  58 + } catch (\Exception | GuzzleException $e) {
  59 + errorLog('渠道信息', $params, $e);
  60 + return false;
  61 + }
  62 + return $res;
  63 + }
  64 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :Socket.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/8/24 10:43
  8 + */
  9 +
  10 +namespace App\Helper;
  11 +require __DIR__ . '/vendor/autoload.php';
  12 +use WebSocket\Client;
  13 +class Socket
  14 +{
  15 + private $client;
  16 +
  17 + public $serverIp = '127.0.0.1';
  18 +
  19 + public $serverPort = '9555';
  20 +
  21 + public function __construct() {
  22 + $socketUrl = "ws://{$this->serverIp}:{$this->serverPort}";
  23 + $this->client = new Client($socketUrl);
  24 + }
  25 +
  26 + /**
  27 + * @remark :发送消息
  28 + * @name :send
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2023/8/31 10:18
  32 + */
  33 + public function send($data) {
  34 + $this->client->send($data);
  35 + }
  36 +
  37 + public function receive() {
  38 + return $this->client->receive();
  39 + }
  40 +
  41 + /**
  42 + * @remark :关闭连接
  43 + * @name :close
  44 + * @author :lyh
  45 + * @method :post
  46 + * @time :2023/8/31 10:21
  47 + */
  48 + public function close() {
  49 + $this->client->close();
  50 + }
  51 +}
@@ -16,7 +16,8 @@ use Illuminate\Support\Facades\Http; @@ -16,7 +16,8 @@ use Illuminate\Support\Facades\Http;
16 class Translate 16 class Translate
17 { 17 {
18 //接口地址 18 //接口地址
19 - public static $url = 'https://translate.hbb618.cn/translates'; 19 +// public static $url = 'https://translate.hbb618.cn/translates';
  20 + public static $url = 'https://translate.hbbapi.com/';
20 21
21 public static $tls_list = [ 22 public static $tls_list = [
22 'en' => [ 23 'en' => [
@@ -24,659 +25,667 @@ class Translate @@ -24,659 +25,667 @@ class Translate
24 'lang_text' => 'English', 25 'lang_text' => 'English',
25 'con_flag' => 'con_flag/en.jfif', 26 'con_flag' => 'con_flag/en.jfif',
26 'shop_lang' => 'en-gb', 27 'shop_lang' => 'en-gb',
  28 + 'lang_en' => 'English'
27 ], 29 ],
28 'zh' => [ 30 'zh' => [
29 'text' => '中文', 31 'text' => '中文',
30 'lang_text' => '简体中文', 32 'lang_text' => '简体中文',
31 'con_flag' => 'con_flag/zh.jfif', 33 'con_flag' => 'con_flag/zh.jfif',
32 'shop_lang' => 'zh-cn', 34 'shop_lang' => 'zh-cn',
  35 + 'lang_en' => 'Chinese'
33 ], 36 ],
34 'fr' => [ 37 'fr' => [
35 'text' => '法语', 38 'text' => '法语',
36 'lang_text' => 'En français', 39 'lang_text' => 'En français',
37 'con_flag' => '', 40 'con_flag' => '',
38 - 41 + 'lang_en' => 'French'
39 ], 42 ],
40 'de' => [ 43 'de' => [
41 'text' => '德语', 44 'text' => '德语',
42 'lang_text' => 'Das ist Deutsch.', 45 'lang_text' => 'Das ist Deutsch.',
43 'con_flag' => '', 46 'con_flag' => '',
44 - 47 + 'lang_en' => 'German'
45 ], 48 ],
46 'ko' => [ 49 'ko' => [
47 'text' => '韩语', 50 'text' => '韩语',
48 'lang_text' => '', 51 'lang_text' => '',
49 'con_flag' => '', 52 'con_flag' => '',
50 - 53 + 'lang_en' => 'Korean'
51 ], 54 ],
52 'ja' => [ 55 'ja' => [
53 'text' => '日语', 56 'text' => '日语',
54 'lang_text' => '', 57 'lang_text' => '',
55 'con_flag' => '', 58 'con_flag' => '',
56 - 59 + 'lang_en' => 'Japanese'
57 ], 60 ],
58 'es' => [ 61 'es' => [
59 'text' => '西班牙语', 62 'text' => '西班牙语',
60 'lang_text' => 'Español.', 63 'lang_text' => 'Español.',
61 'con_flag' => '', 64 'con_flag' => '',
62 - 65 + 'lang_en' => 'Spanish'
63 ], 66 ],
64 'ar' => [ 67 'ar' => [
65 'text' => '阿拉伯语', 68 'text' => '阿拉伯语',
66 'lang_text' => '', 69 'lang_text' => '',
67 'con_flag' => '', 70 'con_flag' => '',
68 - 71 + 'lang_en' => 'Arabic'
69 ], 72 ],
70 'pt' => [ 73 'pt' => [
71 'text' => '葡萄牙语(葡萄牙、巴西)', 74 'text' => '葡萄牙语(葡萄牙、巴西)',
72 'lang_text' => 'Língua portuguesa', 75 'lang_text' => 'Língua portuguesa',
73 'con_flag' => '', 76 'con_flag' => '',
74 - 77 + 'lang_en' => 'Portuguese'
75 ], 78 ],
76 'ru' => [ 79 'ru' => [
77 'text' => '俄语', 80 'text' => '俄语',
78 'lang_text' => '', 81 'lang_text' => '',
79 'con_flag' => '', 82 'con_flag' => '',
80 - 83 + 'lang_en' => 'Russian'
81 ], 84 ],
82 'af' => [ 85 'af' => [
83 'text' => '南非荷兰语', 86 'text' => '南非荷兰语',
84 'lang_text' => '', 87 'lang_text' => '',
85 'con_flag' => '', 88 'con_flag' => '',
86 - 89 + 'lang_en' => 'Afrikaans'
87 ], 90 ],
88 'sq' => [ 91 'sq' => [
89 'text' => '阿尔巴尼亚语', 92 'text' => '阿尔巴尼亚语',
90 'lang_text' => '', 93 'lang_text' => '',
91 'con_flag' => '', 94 'con_flag' => '',
92 - 95 + 'lang_en' => 'albanian'
93 ], 96 ],
94 'am' => [ 97 'am' => [
95 'text' => '阿姆哈拉语', 98 'text' => '阿姆哈拉语',
96 'lang_text' => '', 99 'lang_text' => '',
97 'con_flag' => '', 100 'con_flag' => '',
98 - 101 + 'lang_en' => 'Amharic'
99 ], 102 ],
100 'hy' => [ 103 'hy' => [
101 'text' => '亚美尼亚语', 104 'text' => '亚美尼亚语',
102 'lang_text' => '', 105 'lang_text' => '',
103 'con_flag' => '', 106 'con_flag' => '',
104 - 107 + 'lang_en' => 'Armenian'
105 ], 108 ],
106 'az' => [ 109 'az' => [
107 'text' => '阿塞拜疆语', 110 'text' => '阿塞拜疆语',
108 'lang_text' => '', 111 'lang_text' => '',
109 'con_flag' => '', 112 'con_flag' => '',
110 - 113 + 'lang_en' => 'Azerbaijani'
111 ], 114 ],
112 'eu' => [ 115 'eu' => [
113 'text' => '巴斯克语', 116 'text' => '巴斯克语',
114 'lang_text' => '', 117 'lang_text' => '',
115 'con_flag' => '', 118 'con_flag' => '',
116 - 119 + 'lang_en' => 'Basque'
117 ], 120 ],
118 'be' => [ 121 'be' => [
119 'text' => '白俄罗斯语', 122 'text' => '白俄罗斯语',
120 'lang_text' => '', 123 'lang_text' => '',
121 'con_flag' => '', 124 'con_flag' => '',
122 - 125 + 'lang_en' => 'belarusian'
123 ], 126 ],
124 'bn' => [ 127 'bn' => [
125 'text' => '孟加拉语', 128 'text' => '孟加拉语',
126 'lang_text' => '', 129 'lang_text' => '',
127 'con_flag' => '', 130 'con_flag' => '',
128 - 131 + 'lang_en' => 'Bengali'
129 ], 132 ],
130 'bs' => [ 133 'bs' => [
131 'text' => '波斯尼亚语', 134 'text' => '波斯尼亚语',
132 'lang_text' => '', 135 'lang_text' => '',
133 'con_flag' => '', 136 'con_flag' => '',
134 - 137 + 'lang_en' => 'Bosnian'
135 ], 138 ],
136 'bg' => [ 139 'bg' => [
137 'text' => '保加利亚语', 140 'text' => '保加利亚语',
138 'lang_text' => '', 141 'lang_text' => '',
139 'con_flag' => '', 142 'con_flag' => '',
140 - 143 + 'lang_en' => 'Bulgarian'
141 ], 144 ],
142 'ca' => [ 145 'ca' => [
143 'text' => '加泰罗尼亚语', 146 'text' => '加泰罗尼亚语',
144 'lang_text' => '', 147 'lang_text' => '',
145 'con_flag' => '', 148 'con_flag' => '',
146 - 149 + 'lang_en' => 'Catalan'
147 ], 150 ],
148 'ceb' => [ 151 'ceb' => [
149 'text' => '宿务语', 152 'text' => '宿务语',
150 'lang_text' => '', 153 'lang_text' => '',
151 'con_flag' => '', 154 'con_flag' => '',
152 - 155 + 'lang_en' => 'Cebuano'
153 ], 156 ],
154 'zh-CN' => [ 157 'zh-CN' => [
155 'text' => '中文(简体)', 158 'text' => '中文(简体)',
156 'lang_text' => '简体中文', 159 'lang_text' => '简体中文',
157 'con_flag' => 'con_flag/zh.jfif', 160 'con_flag' => 'con_flag/zh.jfif',
158 'shop_lang' => 'zh-cn', 161 'shop_lang' => 'zh-cn',
  162 + 'lang_en' => 'Chinese'
159 ], 163 ],
160 'zh-TW' => [ 164 'zh-TW' => [
161 'text' => '中文(繁体)', 165 'text' => '中文(繁体)',
162 'lang_text' => '繁体中文', 166 'lang_text' => '繁体中文',
163 'con_flag' => 'con_flag/zh.jfif', 167 'con_flag' => 'con_flag/zh.jfif',
164 - 168 + 'lang_en' => 'Chinese'
165 ], 169 ],
166 'co' => [ 170 'co' => [
167 'text' => '科西嘉语', 171 'text' => '科西嘉语',
168 'lang_text' => '', 172 'lang_text' => '',
169 'con_flag' => '', 173 'con_flag' => '',
170 - 174 + 'lang_en' => 'corsican'
171 ], 175 ],
172 'hr' => [ 176 'hr' => [
173 'text' => '克罗地亚语', 177 'text' => '克罗地亚语',
174 'lang_text' => '', 178 'lang_text' => '',
175 'con_flag' => '', 179 'con_flag' => '',
176 - 180 + 'lang_en' => 'Croatian'
177 ], 181 ],
178 'cs' => [ 182 'cs' => [
179 'text' => '捷克语', 183 'text' => '捷克语',
180 'lang_text' => '', 184 'lang_text' => '',
181 'con_flag' => '', 185 'con_flag' => '',
182 - 186 + 'lang_en' => 'Czech'
183 ], 187 ],
184 'da' => [ 188 'da' => [
185 'text' => '丹麦语', 189 'text' => '丹麦语',
186 'lang_text' => '', 190 'lang_text' => '',
187 'con_flag' => '', 191 'con_flag' => '',
188 - 192 + 'lang_en' => 'Danish'
189 ], 193 ],
190 'nl' => [ 194 'nl' => [
191 'text' => '荷兰语', 195 'text' => '荷兰语',
192 'lang_text' => '', 196 'lang_text' => '',
193 'con_flag' => '', 197 'con_flag' => '',
194 - 198 + 'lang_en' => 'Dutch'
195 ], 199 ],
196 'eo' => [ 200 'eo' => [
197 'text' => '世界语', 201 'text' => '世界语',
198 'lang_text' => '', 202 'lang_text' => '',
199 'con_flag' => '', 203 'con_flag' => '',
200 - 204 + 'lang_en' => 'Esperanto'
201 ], 205 ],
202 'et' => [ 206 'et' => [
203 'text' => '爱沙尼亚语', 207 'text' => '爱沙尼亚语',
204 'lang_text' => '', 208 'lang_text' => '',
205 'con_flag' => '', 209 'con_flag' => '',
206 - 210 + 'lang_en' => 'Estonian'
207 ], 211 ],
208 'fi' => [ 212 'fi' => [
209 'text' => '芬兰语', 213 'text' => '芬兰语',
210 'lang_text' => '', 214 'lang_text' => '',
211 'con_flag' => '', 215 'con_flag' => '',
212 - 216 + 'lang_en' => 'Finnish'
213 ], 217 ],
214 'fy' => [ 218 'fy' => [
215 'text' => '弗里斯兰语', 219 'text' => '弗里斯兰语',
216 'lang_text' => '', 220 'lang_text' => '',
217 'con_flag' => '', 221 'con_flag' => '',
218 - 222 + 'lang_en' => 'frisian'
219 ], 223 ],
220 'gl' => [ 224 'gl' => [
221 'text' => '加利西亚语', 225 'text' => '加利西亚语',
222 'lang_text' => '', 226 'lang_text' => '',
223 'con_flag' => '', 227 'con_flag' => '',
224 - 228 + 'lang_en' => 'galician'
225 ], 229 ],
226 'ka' => [ 230 'ka' => [
227 'text' => '格鲁吉亚语', 231 'text' => '格鲁吉亚语',
228 'lang_text' => '', 232 'lang_text' => '',
229 'con_flag' => '', 233 'con_flag' => '',
230 - 234 + 'lang_en' => 'Georgian'
231 ], 235 ],
232 'el' => [ 236 'el' => [
233 'text' => '希腊语', 237 'text' => '希腊语',
234 'lang_text' => '', 238 'lang_text' => '',
235 'con_flag' => '', 239 'con_flag' => '',
236 - 240 + 'lang_en' => 'Greek'
237 ], 241 ],
238 'gu' => [ 242 'gu' => [
239 'text' => '古吉拉特语', 243 'text' => '古吉拉特语',
240 'lang_text' => '', 244 'lang_text' => '',
241 'con_flag' => '', 245 'con_flag' => '',
242 - 246 + 'lang_en' => 'Gujarati'
243 ], 247 ],
244 'ht' => [ 248 'ht' => [
245 'text' => '海地克里奥尔语', 249 'text' => '海地克里奥尔语',
246 'lang_text' => '', 250 'lang_text' => '',
247 'con_flag' => '', 251 'con_flag' => '',
248 - 252 + 'lang_en' => 'Haitian Creole'
249 ], 253 ],
250 'ha' => [ 254 'ha' => [
251 'text' => '豪萨语', 255 'text' => '豪萨语',
252 'lang_text' => '', 256 'lang_text' => '',
253 'con_flag' => '', 257 'con_flag' => '',
254 - 258 + 'lang_en' => 'hausa'
255 ], 259 ],
256 'haw' => [ 260 'haw' => [
257 'text' => '夏威夷语', 261 'text' => '夏威夷语',
258 'lang_text' => '', 262 'lang_text' => '',
259 'con_flag' => '', 263 'con_flag' => '',
260 - 264 + 'lang_en' => 'Hawaiian'
261 ], 265 ],
262 'iw' => [ 266 'iw' => [
263 'text' => '希伯来语', 267 'text' => '希伯来语',
264 'lang_text' => '', 268 'lang_text' => '',
265 'con_flag' => '', 269 'con_flag' => '',
266 - 270 + 'lang_en' => 'Hebrew'
267 ], 271 ],
268 'hi' => [ 272 'hi' => [
269 'text' => '印地语', 273 'text' => '印地语',
270 'lang_text' => '', 274 'lang_text' => '',
271 'con_flag' => '', 275 'con_flag' => '',
272 - 276 + 'lang_en' => 'Hindi'
273 ], 277 ],
274 'hmn' => [ 278 'hmn' => [
275 'text' => '苗语', 279 'text' => '苗语',
276 'lang_text' => '', 280 'lang_text' => '',
277 'con_flag' => '', 281 'con_flag' => '',
278 - 282 + 'lang_en' => 'Miao language'
279 ], 283 ],
280 'hu' => [ 284 'hu' => [
281 'text' => '匈牙利语', 285 'text' => '匈牙利语',
282 'lang_text' => '', 286 'lang_text' => '',
283 'con_flag' => '', 287 'con_flag' => '',
284 - 288 + 'lang_en' => 'Hungarian'
285 ], 289 ],
286 'is' => [ 290 'is' => [
287 'text' => '冰岛语', 291 'text' => '冰岛语',
288 'lang_text' => '', 292 'lang_text' => '',
289 'con_flag' => '', 293 'con_flag' => '',
290 - 294 + 'lang_en' => 'Icelandic'
291 ], 295 ],
292 'ig' => [ 296 'ig' => [
293 'text' => '伊博语', 297 'text' => '伊博语',
294 'lang_text' => '', 298 'lang_text' => '',
295 'con_flag' => '', 299 'con_flag' => '',
296 - 300 + 'lang_en' => 'igbo'
297 ], 301 ],
298 'id' => [ 302 'id' => [
299 'text' => '印度尼西亚语', 303 'text' => '印度尼西亚语',
300 'lang_text' => 'Bahasa Indonesia', 304 'lang_text' => 'Bahasa Indonesia',
301 'con_flag' => 'con_flag/id.jfif', 305 'con_flag' => 'con_flag/id.jfif',
302 'shop_lang' => 'id', 306 'shop_lang' => 'id',
  307 + 'lang_en' => 'Indonesian'
303 ], 308 ],
304 'ga' => [ 309 'ga' => [
305 'text' => '爱尔兰语', 310 'text' => '爱尔兰语',
306 'lang_text' => '', 311 'lang_text' => '',
307 'con_flag' => '', 312 'con_flag' => '',
308 - 313 + 'lang_en' => 'irish'
309 ], 314 ],
310 'it' => [ 315 'it' => [
311 'text' => '意大利语', 316 'text' => '意大利语',
312 'lang_text' => 'Lingua italiana', 317 'lang_text' => 'Lingua italiana',
313 'con_flag' => '', 318 'con_flag' => '',
314 - 319 + 'lang_en' => 'Italian'
315 ], 320 ],
316 'jw' => [ 321 'jw' => [
317 'text' => '爪哇语', 322 'text' => '爪哇语',
318 'lang_text' => '', 323 'lang_text' => '',
319 'con_flag' => '', 324 'con_flag' => '',
320 - 325 + 'lang_en' => 'Javanese'
321 ], 326 ],
322 'kn' => [ 327 'kn' => [
323 'text' => '卡纳达语', 328 'text' => '卡纳达语',
324 'lang_text' => '', 329 'lang_text' => '',
325 'con_flag' => '', 330 'con_flag' => '',
326 - 331 + 'lang_en' => 'Kannada'
327 ], 332 ],
328 'kk' => [ 333 'kk' => [
329 'text' => '哈萨克语', 334 'text' => '哈萨克语',
330 'lang_text' => '', 335 'lang_text' => '',
331 'con_flag' => '', 336 'con_flag' => '',
332 - 337 + 'lang_en' => 'Kazakh'
333 ], 338 ],
334 'km' => [ 339 'km' => [
335 'text' => '高棉语', 340 'text' => '高棉语',
336 'lang_text' => '', 341 'lang_text' => '',
337 'con_flag' => '', 342 'con_flag' => '',
338 - 343 + 'lang_en' => 'Khmer'
339 ], 344 ],
340 'rw' => [ 345 'rw' => [
341 'text' => '卢旺达语', 346 'text' => '卢旺达语',
342 'lang_text' => '', 347 'lang_text' => '',
343 'con_flag' => '', 348 'con_flag' => '',
344 - 349 + 'lang_en' => 'Kinyarwanda'
345 ], 350 ],
346 'ku' => [ 351 'ku' => [
347 'text' => '库尔德语', 352 'text' => '库尔德语',
348 'lang_text' => '', 353 'lang_text' => '',
349 'con_flag' => '', 354 'con_flag' => '',
350 - 355 + 'lang_en' => 'Kurdish languages'
351 ], 356 ],
352 'ky' => [ 357 'ky' => [
353 'text' => '吉尔吉斯语', 358 'text' => '吉尔吉斯语',
354 'lang_text' => '', 359 'lang_text' => '',
355 'con_flag' => '', 360 'con_flag' => '',
356 - 361 + 'lang_en' => 'Kyrgyz language'
357 ], 362 ],
358 'lo' => [ 363 'lo' => [
359 'text' => '老挝文', 364 'text' => '老挝文',
360 'lang_text' => '', 365 'lang_text' => '',
361 'con_flag' => '', 366 'con_flag' => '',
362 - 367 + 'lang_en' => 'LAO'
363 ], 368 ],
364 'la' => [ 369 'la' => [
365 'text' => '拉丁文', 370 'text' => '拉丁文',
366 'lang_text' => '', 371 'lang_text' => '',
367 'con_flag' => '', 372 'con_flag' => '',
368 - 373 + 'lang_en' => 'Latin'
369 ], 374 ],
370 'lv' => [ 375 'lv' => [
371 'text' => '拉脱维亚语', 376 'text' => '拉脱维亚语',
372 'lang_text' => '', 377 'lang_text' => '',
373 'con_flag' => '', 378 'con_flag' => '',
374 - 379 + 'lang_en' => 'latvian'
375 ], 380 ],
376 'lt' => [ 381 'lt' => [
377 'text' => '立陶宛语', 382 'text' => '立陶宛语',
378 'lang_text' => '', 383 'lang_text' => '',
379 'con_flag' => '', 384 'con_flag' => '',
380 - 385 + 'lang_en' => 'Lithuanian'
381 ], 386 ],
382 'lb' => [ 387 'lb' => [
383 'text' => '卢森堡语', 388 'text' => '卢森堡语',
384 'lang_text' => '', 389 'lang_text' => '',
385 'con_flag' => '', 390 'con_flag' => '',
386 - 391 + 'lang_en' => 'Luxembourgish'
387 ], 392 ],
388 'mk' => [ 393 'mk' => [
389 'text' => '马其顿语', 394 'text' => '马其顿语',
390 'lang_text' => '', 395 'lang_text' => '',
391 'con_flag' => '', 396 'con_flag' => '',
392 - 397 + 'lang_en' => 'Macedonian language'
393 ], 398 ],
394 'mg' => [ 399 'mg' => [
395 'text' => '马尔加什语', 400 'text' => '马尔加什语',
396 'lang_text' => '', 401 'lang_text' => '',
397 'con_flag' => '', 402 'con_flag' => '',
398 - 403 + 'lang_en' => 'Malagasy'
399 ], 404 ],
400 'ms' => [ 405 'ms' => [
401 'text' => '马来语', 406 'text' => '马来语',
402 'lang_text' => 'Bahasa Melayu', 407 'lang_text' => 'Bahasa Melayu',
403 'con_flag' => 'con_flag/ms.jfif', 408 'con_flag' => 'con_flag/ms.jfif',
404 'shop_lang' => 'ms-my', 409 'shop_lang' => 'ms-my',
  410 + 'lang_en' => 'Malay'
405 ], 411 ],
406 'ml' => [ 412 'ml' => [
407 'text' => '马拉雅拉姆文', 413 'text' => '马拉雅拉姆文',
408 'lang_text' => '', 414 'lang_text' => '',
409 'con_flag' => '', 415 'con_flag' => '',
410 - 416 + 'lang_en' => 'Malayalam script'
411 ], 417 ],
412 'mt' => [ 418 'mt' => [
413 'text' => '马耳他语', 419 'text' => '马耳他语',
414 'lang_text' => '', 420 'lang_text' => '',
415 'con_flag' => '', 421 'con_flag' => '',
416 - 422 + 'lang_en' => 'Maltese'
417 ], 423 ],
418 'mi' => [ 424 'mi' => [
419 'text' => '毛利语', 425 'text' => '毛利语',
420 'lang_text' => '', 426 'lang_text' => '',
421 'con_flag' => '', 427 'con_flag' => '',
422 - 428 + 'lang_en' => 'Maori language'
423 ], 429 ],
424 'mr' => [ 430 'mr' => [
425 'text' => '马拉地语', 431 'text' => '马拉地语',
426 'lang_text' => '', 432 'lang_text' => '',
427 'con_flag' => '', 433 'con_flag' => '',
428 - 434 + 'lang_en' => 'Marathi language'
429 ], 435 ],
430 'mn' => [ 436 'mn' => [
431 'text' => '蒙古文', 437 'text' => '蒙古文',
432 'lang_text' => '', 438 'lang_text' => '',
433 'con_flag' => '', 439 'con_flag' => '',
434 - 440 + 'lang_en' => 'Mongolian'
435 ], 441 ],
436 'my' => [ 442 'my' => [
437 'text' => '缅甸语', 443 'text' => '缅甸语',
438 'lang_text' => '', 444 'lang_text' => '',
439 'con_flag' => '', 445 'con_flag' => '',
440 - 446 + 'lang_en' => 'Burmese'
441 ], 447 ],
442 'ne' => [ 448 'ne' => [
443 'text' => '尼泊尔语', 449 'text' => '尼泊尔语',
444 'lang_text' => '', 450 'lang_text' => '',
445 'con_flag' => '', 451 'con_flag' => '',
446 - 452 + 'lang_en' => 'Nepali'
447 ], 453 ],
448 'no' => [ 454 'no' => [
449 'text' => '挪威语', 455 'text' => '挪威语',
450 'lang_text' => '', 456 'lang_text' => '',
451 'con_flag' => '', 457 'con_flag' => '',
452 - 458 + 'lang_en' => 'Norwegian'
453 ], 459 ],
454 'ny' => [ 460 'ny' => [
455 'text' => '尼杨扎语(齐切瓦语)', 461 'text' => '尼杨扎语(齐切瓦语)',
456 'lang_text' => '', 462 'lang_text' => '',
457 'con_flag' => '', 463 'con_flag' => '',
458 - 464 + 'lang_en' => 'Nyanza language'
459 ], 465 ],
460 'or' => [ 466 'or' => [
461 'text' => '奥里亚语(奥里亚)', 467 'text' => '奥里亚语(奥里亚)',
462 'lang_text' => '', 468 'lang_text' => '',
463 'con_flag' => '', 469 'con_flag' => '',
464 - 470 + 'lang_en' => 'oriya'
465 ], 471 ],
466 'ps' => [ 472 'ps' => [
467 'text' => '普什图语', 473 'text' => '普什图语',
468 'lang_text' => '', 474 'lang_text' => '',
469 'con_flag' => '', 475 'con_flag' => '',
470 - 476 + 'lang_en' => 'Pashto'
471 ], 477 ],
472 'fa' => [ 478 'fa' => [
473 'text' => '波斯语', 479 'text' => '波斯语',
474 'lang_text' => '', 480 'lang_text' => '',
475 'con_flag' => '', 481 'con_flag' => '',
476 - 482 + 'lang_en' => 'farsi'
477 ], 483 ],
478 'pl' => [ 484 'pl' => [
479 'text' => '波兰语', 485 'text' => '波兰语',
480 'lang_text' => '', 486 'lang_text' => '',
481 'con_flag' => '', 487 'con_flag' => '',
482 - 488 + 'lang_en' => 'Polish'
483 ], 489 ],
484 'pa' => [ 490 'pa' => [
485 'text' => '旁遮普语', 491 'text' => '旁遮普语',
486 'lang_text' => '', 492 'lang_text' => '',
487 'con_flag' => '', 493 'con_flag' => '',
488 - 494 + 'lang_en' => 'Punjabi language'
489 ], 495 ],
490 'ro' => [ 496 'ro' => [
491 'text' => '罗马尼亚语', 497 'text' => '罗马尼亚语',
492 'lang_text' => '', 498 'lang_text' => '',
493 'con_flag' => '', 499 'con_flag' => '',
494 - 500 + 'lang_en' => 'Romanian'
495 ], 501 ],
496 'sm' => [ 502 'sm' => [
497 'text' => '萨摩亚语', 503 'text' => '萨摩亚语',
498 'lang_text' => '', 504 'lang_text' => '',
499 'con_flag' => '', 505 'con_flag' => '',
500 - 506 + 'lang_en' => 'Samoan'
501 ], 507 ],
502 'gd' => [ 508 'gd' => [
503 'text' => '苏格兰盖尔语', 509 'text' => '苏格兰盖尔语',
504 'lang_text' => '', 510 'lang_text' => '',
505 'con_flag' => '', 511 'con_flag' => '',
506 - 512 + 'lang_en' => 'GAELIC'
507 ], 513 ],
508 'sr' => [ 514 'sr' => [
509 'text' => '塞尔维亚语', 515 'text' => '塞尔维亚语',
510 'lang_text' => '', 516 'lang_text' => '',
511 'con_flag' => '', 517 'con_flag' => '',
512 - 518 + 'lang_en' => 'Serbian'
513 ], 519 ],
514 'st' => [ 520 'st' => [
515 'text' => '塞索托语', 521 'text' => '塞索托语',
516 'lang_text' => '', 522 'lang_text' => '',
517 'con_flag' => '', 523 'con_flag' => '',
518 - 524 + 'lang_en' => 'sesotho'
519 ], 525 ],
520 'sn' => [ 526 'sn' => [
521 'text' => '修纳语', 527 'text' => '修纳语',
522 'lang_text' => '', 528 'lang_text' => '',
523 'con_flag' => '', 529 'con_flag' => '',
524 - 530 + 'lang_en' => 'Shona'
525 ], 531 ],
526 'sd' => [ 532 'sd' => [
527 'text' => '信德语', 533 'text' => '信德语',
528 'lang_text' => '', 534 'lang_text' => '',
529 'con_flag' => '', 535 'con_flag' => '',
530 - 536 + 'lang_en' => 'Sindhi language'
531 ], 537 ],
532 'si' => [ 538 'si' => [
533 'text' => '僧伽罗语', 539 'text' => '僧伽罗语',
534 'lang_text' => '', 540 'lang_text' => '',
535 'con_flag' => '', 541 'con_flag' => '',
536 - 542 + 'lang_en' => 'Sinhalese'
537 ], 543 ],
538 'sk' => [ 544 'sk' => [
539 'text' => '斯洛伐克语', 545 'text' => '斯洛伐克语',
540 'lang_text' => '', 546 'lang_text' => '',
541 'con_flag' => '', 547 'con_flag' => '',
542 - 548 + 'lang_en' => 'Slovak'
543 ], 549 ],
544 'sl' => [ 550 'sl' => [
545 'text' => '斯洛文尼亚语', 551 'text' => '斯洛文尼亚语',
546 'lang_text' => '', 552 'lang_text' => '',
547 'con_flag' => '', 553 'con_flag' => '',
548 - 554 + 'lang_en' => 'Slovene language'
549 ], 555 ],
550 'so' => [ 556 'so' => [
551 'text' => '索马里语', 557 'text' => '索马里语',
552 'lang_text' => '', 558 'lang_text' => '',
553 'con_flag' => '', 559 'con_flag' => '',
554 - 560 + 'lang_en' => 'Somali'
555 ], 561 ],
556 'su' => [ 562 'su' => [
557 'text' => '巽他语', 563 'text' => '巽他语',
558 'lang_text' => '', 564 'lang_text' => '',
559 'con_flag' => '', 565 'con_flag' => '',
560 - 566 + 'lang_en' => 'Sundanese'
561 ], 567 ],
562 'sw' => [ 568 'sw' => [
563 'text' => '斯瓦希里语', 569 'text' => '斯瓦希里语',
564 'lang_text' => '', 570 'lang_text' => '',
565 'con_flag' => '', 571 'con_flag' => '',
566 - 572 + 'lang_en' => 'Swahili'
567 ], 573 ],
568 'sv' => [ 574 'sv' => [
569 'text' => '瑞典语', 575 'text' => '瑞典语',
570 'lang_text' => '', 576 'lang_text' => '',
571 'con_flag' => '', 577 'con_flag' => '',
572 - 578 + 'lang_en' => 'Swedish'
573 ], 579 ],
574 'tl' => [ 580 'tl' => [
575 'text' => '塔加路语(菲律宾语)', 581 'text' => '塔加路语(菲律宾语)',
576 'lang_text' => 'Pilipino', 582 'lang_text' => 'Pilipino',
577 'con_flag' => 'con_flag/tl.jfif', 583 'con_flag' => 'con_flag/tl.jfif',
578 'shop_lang' => 'tl', 584 'shop_lang' => 'tl',
  585 + 'lang_en' => 'Tagalog'
579 ], 586 ],
580 'tg' => [ 587 'tg' => [
581 'text' => '塔吉克语', 588 'text' => '塔吉克语',
582 'lang_text' => '', 589 'lang_text' => '',
583 'con_flag' => '', 590 'con_flag' => '',
584 - 591 + 'lang_en' => 'Tajik'
585 ], 592 ],
586 'ta' => [ 593 'ta' => [
587 'text' => '泰米尔语', 594 'text' => '泰米尔语',
588 'lang_text' => '', 595 'lang_text' => '',
589 'con_flag' => '', 596 'con_flag' => '',
590 - 597 + 'lang_en' => 'Tamil'
591 ], 598 ],
592 'tt' => [ 599 'tt' => [
593 'text' => '鞑靼语', 600 'text' => '鞑靼语',
594 'lang_text' => '', 601 'lang_text' => '',
595 'con_flag' => '', 602 'con_flag' => '',
596 - 603 + 'lang_en' => 'Tatar language'
597 ], 604 ],
598 'te' => [ 605 'te' => [
599 'text' => '泰卢固语', 606 'text' => '泰卢固语',
600 'lang_text' => '', 607 'lang_text' => '',
601 'con_flag' => '', 608 'con_flag' => '',
602 - 609 + 'lang_en' => 'Telugu language'
603 ], 610 ],
604 'th' => [ 611 'th' => [
605 'text' => '泰文', 612 'text' => '泰文',
606 'lang_text' => 'ไทย', 613 'lang_text' => 'ไทย',
607 'con_flag' => 'con_flag/th.jfif', 614 'con_flag' => 'con_flag/th.jfif',
608 'shop_lang' => 'th', 615 'shop_lang' => 'th',
  616 + 'lang_en' => 'Thai'
609 ], 617 ],
610 'tr' => [ 618 'tr' => [
611 'text' => '土耳其语', 619 'text' => '土耳其语',
612 'lang_text' => '', 620 'lang_text' => '',
613 'con_flag' => '', 621 'con_flag' => '',
614 - 622 + 'lang_en' => 'Turkish'
615 ], 623 ],
616 'tk' => [ 624 'tk' => [
617 'text' => '土库曼语', 625 'text' => '土库曼语',
618 'lang_text' => '', 626 'lang_text' => '',
619 'con_flag' => '', 627 'con_flag' => '',
620 - 628 + 'lang_en' => 'Turkmen language'
621 ], 629 ],
622 'uk' => [ 630 'uk' => [
623 'text' => '乌克兰语', 631 'text' => '乌克兰语',
624 'lang_text' => '', 632 'lang_text' => '',
625 'con_flag' => '', 633 'con_flag' => '',
626 - 634 + 'lang_en' => 'Ukrainian'
627 ], 635 ],
628 'ur' => [ 636 'ur' => [
629 'text' => '乌尔都语', 637 'text' => '乌尔都语',
630 'lang_text' => '', 638 'lang_text' => '',
631 'con_flag' => '', 639 'con_flag' => '',
632 - 640 + 'lang_en' => 'Urdu'
633 ], 641 ],
634 'ug' => [ 642 'ug' => [
635 'text' => '维吾尔语', 643 'text' => '维吾尔语',
636 'lang_text' => '', 644 'lang_text' => '',
637 'con_flag' => '', 645 'con_flag' => '',
638 - 646 + 'lang_en' => 'Uyghur language'
639 ], 647 ],
640 'uz' => [ 648 'uz' => [
641 'text' => '乌兹别克语', 649 'text' => '乌兹别克语',
642 'lang_text' => '', 650 'lang_text' => '',
643 'con_flag' => '', 651 'con_flag' => '',
644 - 652 + 'lang_en' => 'Uzbek language'
645 ], 653 ],
646 'vi' => [ 654 'vi' => [
647 'text' => '越南语', 655 'text' => '越南语',
648 'lang_text' => '', 656 'lang_text' => '',
649 'con_flag' => '', 657 'con_flag' => '',
650 - 658 + 'lang_en' => 'Vietnamese'
651 ], 659 ],
652 'cy' => [ 660 'cy' => [
653 'text' => '威尔士语', 661 'text' => '威尔士语',
654 'lang_text' => '', 662 'lang_text' => '',
655 'con_flag' => '', 663 'con_flag' => '',
656 - 664 + 'lang_en' => 'Welsh'
657 ], 665 ],
658 'xh' => [ 666 'xh' => [
659 'text' => '班图语', 667 'text' => '班图语',
660 'lang_text' => '', 668 'lang_text' => '',
661 'con_flag' => '', 669 'con_flag' => '',
662 - 670 + 'lang_en' => 'Bantu'
663 ], 671 ],
664 'yi' => [ 672 'yi' => [
665 'text' => '意第绪语', 673 'text' => '意第绪语',
666 'lang_text' => '', 674 'lang_text' => '',
667 'con_flag' => '', 675 'con_flag' => '',
668 - 676 + 'lang_en' => 'Yiddish'
669 ], 677 ],
670 'yo' => [ 678 'yo' => [
671 'text' => '约鲁巴语', 679 'text' => '约鲁巴语',
672 'lang_text' => '', 680 'lang_text' => '',
673 'con_flag' => '', 681 'con_flag' => '',
674 - 682 + 'lang_en' => 'Yoruba'
675 ], 683 ],
676 'zu' => [ 684 'zu' => [
677 'text' => '祖鲁语', 685 'text' => '祖鲁语',
678 'lang_text' => '', 686 'lang_text' => '',
679 'con_flag' => '', 687 'con_flag' => '',
  688 + 'lang_en' => 'Zulu'
680 ], 689 ],
681 ]; 690 ];
682 691
@@ -713,6 +722,7 @@ class Translate @@ -713,6 +722,7 @@ class Translate
713 */ 722 */
714 public static function translate($texts, $tls) 723 public static function translate($texts, $tls)
715 { 724 {
  725 + $action = 'translates';
716 if (is_string($texts)) { 726 if (is_string($texts)) {
717 $texts = [$texts]; 727 $texts = [$texts];
718 } 728 }
@@ -724,7 +734,7 @@ class Translate @@ -724,7 +734,7 @@ class Translate
724 'sl' => 'auto', 734 'sl' => 'auto',
725 'tls' => $tls, 735 'tls' => $tls,
726 ]; 736 ];
727 - return Http::post(self::$url, $data); 737 + return Http::post(self::$url.$action, $data);
728 } 738 }
729 739
730 /** 740 /**
@@ -745,6 +755,24 @@ class Translate @@ -745,6 +755,24 @@ class Translate
745 return $retsult[0]['texts'] ?? ''; 755 return $retsult[0]['texts'] ?? '';
746 756
747 } 757 }
748 - 758 + /**
  759 + * 翻译带源语种
  760 + * @param $message
  761 + * @param string $tl
  762 + * @return \Illuminate\Http\Client\Response
  763 + */
  764 + public static function translateSl($message, $tl = 'en')
  765 + {
  766 + $action = 'auto_sl';
  767 + if (is_string($message)) {
  768 + $message = [$message];
  769 + }
  770 + $data = [
  771 + 'texts' => $message,
  772 + 'sl' => 'auto',
  773 + 'tl' => $tl,
  774 + ];
  775 + return Http::post(self::$url . $action, $data);
  776 + }
749 777
750 } 778 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :Wechat.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/8/23 18:18
  8 + */
  9 +
  10 +namespace App\Helper;
  11 +
  12 +use \GuzzleHttp\Client;
  13 +use Illuminate\Support\Facades\Cache;
  14 +
  15 +/**
  16 + * @remark :微信相关
  17 + * @name :Wechat
  18 + * @author :lyh
  19 + * @method :post
  20 + * @time :2023/8/23 18:19
  21 + */
  22 +class Wechat
  23 +{
  24 + public $alias = '_v6';
  25 + public $appid = 'wx8253a38fd7ae78f0';
  26 + public $appSecret = '20981cca3d00c074a8886f115d19548d';
  27 +
  28 + /**
  29 + * @remark :生成access_token
  30 + * @name :getAccessToken
  31 + * @author :lyh
  32 + * @method :post
  33 + * @time :2023/8/23 18:28
  34 + */
  35 + public function getAccessToken()
  36 + {
  37 + $token = file_get_contents("http://wechat.globalso.com/api/accesstoken/v6");
  38 + return $token;
  39 + }
  40 + /**
  41 + * @remark :生成二维码
  42 + * @name :setQrcode
  43 + * @author :lyh
  44 + * @method :post
  45 + * @time :2023/8/23 18:19
  46 + */
  47 + public function setQrcode($type,$accessToken){
  48 + $url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=' . $accessToken;
  49 + $client = new Client();
  50 + $response = $client->post($url, [
  51 + 'json' => [
  52 + 'expire_seconds' => 3600,
  53 + 'action_name' => 'QR_STR_SCENE',
  54 + 'action_info' => [
  55 + 'scene' => [
  56 + 'scene_str' => $type.$this->alias,
  57 + ],
  58 + ],
  59 + ],
  60 + ]);
  61 + $data = json_decode($response->getBody(), true);
  62 + return $data;
  63 + }
  64 +
  65 +}
1 <?php 1 <?php
2 2
  3 +use App\Models\File\Image;
  4 +use App\Services\CosService;
  5 +use App\Utils\EncryptUtils;
3 use App\Utils\LogUtils; 6 use App\Utils\LogUtils;
4 use GuzzleHttp\Client; 7 use GuzzleHttp\Client;
5 use GuzzleHttp\Exception\GuzzleException; 8 use GuzzleHttp\Exception\GuzzleException;
6 use Illuminate\Support\Carbon; 9 use Illuminate\Support\Carbon;
  10 +use App\Models\File\File;
7 11
8 define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/'); 12 define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/');
9 /** 13 /**
@@ -67,13 +71,14 @@ if (!function_exists('http_post')) { @@ -67,13 +71,14 @@ if (!function_exists('http_post')) {
67 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 71 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
68 $res = curl_exec($ch); 72 $res = curl_exec($ch);
69 if (curl_errno($ch)) { 73 if (curl_errno($ch)) {
70 - \Illuminate\Support\Facades\Log::info(print_r(curl_errno($ch), 1), 'debug---1'); 74 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($res, true) . PHP_EOL, FILE_APPEND);
71 } 75 }
72 curl_close($ch); 76 curl_close($ch);
73 return json_decode($res, true); 77 return json_decode($res, true);
74 } 78 }
75 } 79 }
76 80
  81 +
77 if (!function_exists('http_get')) { 82 if (!function_exists('http_get')) {
78 /** 83 /**
79 * 发送http get请求 84 * 发送http get请求
@@ -83,19 +88,20 @@ if (!function_exists('http_get')) { @@ -83,19 +88,20 @@ if (!function_exists('http_get')) {
83 function http_get($url, $header = []) 88 function http_get($url, $header = [])
84 { 89 {
85 if (empty($header)) { 90 if (empty($header)) {
86 - $header[] = "content-type: application/json;  
87 - charset = UTF-8"; 91 + $header[] = "content-type: application/json";
88 } 92 }
89 $ch1 = curl_init(); 93 $ch1 = curl_init();
90 - $timeout = 5; 94 + $timeout = 0;
91 curl_setopt($ch1, CURLOPT_URL, $url); 95 curl_setopt($ch1, CURLOPT_URL, $url);
92 - curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); 96 + curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
  97 + curl_setopt($ch1, CURLOPT_ENCODING, '');
  98 + curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
93 curl_setopt($ch1, CURLOPT_HTTPHEADER, $header); 99 curl_setopt($ch1, CURLOPT_HTTPHEADER, $header);
94 curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout); 100 curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
95 - curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);  
96 - curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, false); 101 + curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
  102 + curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET');
  103 + curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
97 $access_txt = curl_exec($ch1); 104 $access_txt = curl_exec($ch1);
98 - \Illuminate\Support\Facades\Log::info($access_txt);  
99 curl_close($ch1); 105 curl_close($ch1);
100 return json_decode($access_txt, true); 106 return json_decode($access_txt, true);
101 } 107 }
@@ -118,7 +124,7 @@ if (!function_exists('_get_child')) { @@ -118,7 +124,7 @@ if (!function_exists('_get_child')) {
118 $new_arr[] = $v; 124 $new_arr[] = $v;
119 } 125 }
120 } 126 }
121 - return $new_arr ? $new_arr : false; 127 + return $new_arr ? $new_arr : [];
122 } 128 }
123 } 129 }
124 130
@@ -404,3 +410,113 @@ if (!function_exists('getDateArray')) { @@ -404,3 +410,113 @@ if (!function_exists('getDateArray')) {
404 return $days; 410 return $days;
405 } 411 }
406 } 412 }
  413 +
  414 +if (!function_exists('getImageUrl')) {
  415 + /**
  416 + * @remark :获取图片链接
  417 + * @name :getImageUrl
  418 + * @author :lyh
  419 + * @method :post
  420 + * @time :2023/7/20 16:46
  421 + */
  422 + function getImageUrl($path,$location = 1){
  423 + if(empty($path)){
  424 + return '';
  425 + }
  426 + if(is_array($path)){
  427 + foreach ($path as $v){
  428 + $url[] = getImageUrl($v);
  429 + }
  430 + }else{
  431 + if($location == 1){
  432 + $cos = config('filesystems.disks.cos');
  433 + $cosCdn = $cos['cdn'];
  434 + $url = $cosCdn.$path;
  435 + }else{
  436 + $url = url($path);
  437 + }
  438 + }
  439 + return $url;
  440 + }
  441 +}
  442 +if (!function_exists('getFileUrl')) {
  443 + /**
  444 + * @remark :获取文件链接
  445 + * @name :getImageUrl
  446 + * @author :lyh
  447 + * @method :post
  448 + * @time :2023/7/20 16:46
  449 + */
  450 + function getFileUrl($path,$location = 1){
  451 + if(empty($path)){
  452 + return '';
  453 + }
  454 + if(is_array($path)){
  455 + foreach ($path as $v){
  456 + $url[] = getFileUrl($v);
  457 + }
  458 + }else{
  459 + if($location == 1){
  460 + $cos = config('filesystems.disks.cos');
  461 + $cosCdn = $cos['cdn'];
  462 + $url = $cosCdn.$path;
  463 + }else{
  464 + $url = url($path);
  465 + }
  466 + }
  467 + return $url;
  468 + }
  469 +}
  470 +
  471 +/**
  472 + * @remark :字符串截取
  473 + * @name :characterTruncation
  474 + * @author :lyh
  475 + * @method :post
  476 + * @time :2023/6/28 17:39
  477 + */
  478 +function characterTruncation($string,$pattern){
  479 + preg_match($pattern, $string, $matches);
  480 + if (isset($matches[0])) {
  481 + $result = $matches[0];
  482 + return $result; // 输出:这是footer标签的内容
  483 + } else {
  484 + return '';
  485 + }
  486 +}
  487 +if (!function_exists('getAutoLoginCode')) {
  488 + /**
  489 + * @remark :自动登录加密
  490 + * @name :getAutoLoginCode
  491 + * @author :lyh
  492 + * @method :post
  493 + * @time :2023/8/7 9:47
  494 + */
  495 + function getAutoLoginCode($project_id)
  496 + {
  497 + $encrypt = new EncryptUtils();
  498 + return $encrypt->authcode(json_encode(['project_id' => $project_id]), 'ENCODE', 'autologin', 3600);
  499 + }
  500 +}
  501 +
  502 +if (!function_exists('str_replace_url')) {
  503 + /**
  504 + * @remark :截取域名以外的部分
  505 + * @name :str_replace_url
  506 + * @author :lyh
  507 + * @method :post
  508 + * @time :2023/8/31 14:57
  509 + */
  510 + function str_replace_url($url)
  511 + {
  512 + // 使用 parse_url 函数来解析 URL
  513 + $urlParts = parse_url($url);
  514 + // 检查是否存在 host(域名)部分
  515 + if (isset($urlParts['path'])) {
  516 + $urlWithoutDomain = $urlParts['path'];
  517 + return $urlWithoutDomain;
  518 + } else {
  519 + return $url;
  520 + }
  521 + }
  522 +}
@@ -7,19 +7,21 @@ use App\Http\Controllers\Aside\BaseController; @@ -7,19 +7,21 @@ use App\Http\Controllers\Aside\BaseController;
7 use App\Http\Logic\Aside\Ai\AiCommandLogic; 7 use App\Http\Logic\Aside\Ai\AiCommandLogic;
8 use App\Http\Requests\Aside\Ai\AiCommandRequest; 8 use App\Http\Requests\Aside\Ai\AiCommandRequest;
9 use App\Models\Ai\AiCommand as AiCommandModel; 9 use App\Models\Ai\AiCommand as AiCommandModel;
10 -use Illuminate\Http\Request;  
11 -use function App\Helper\send_openai_msg;  
12 10
13 /** 11 /**
14 - * @name:ai指令 12 + * @remark :ai指令
  13 + * @name :AiCommandController
  14 + * @author :lyh
  15 + * @time :2023/6/17 16:27
15 */ 16 */
16 class AiCommandController extends BaseController 17 class AiCommandController extends BaseController
17 { 18 {
18 /** 19 /**
19 - * @name :指令列表  
20 - * @return void  
21 - * @author :liyuhang  
22 - * @method 20 + * @param AiCommandModel $aiCommandModel
  21 + * @name :lists
  22 + * @author :lyh
  23 + * @method :post
  24 + * @time :2023/6/17 16:27
23 */ 25 */
24 public function lists(AiCommandModel $aiCommandModel){ 26 public function lists(AiCommandModel $aiCommandModel){
25 $lists = $aiCommandModel->lists($this->map,$this->page,$this->row,$this->order); 27 $lists = $aiCommandModel->lists($this->map,$this->page,$this->row,$this->order);
@@ -27,10 +29,11 @@ class AiCommandController extends BaseController @@ -27,10 +29,11 @@ class AiCommandController extends BaseController
27 } 29 }
28 30
29 /** 31 /**
30 - * @name :详情  
31 - * @return void  
32 - * @author :liyuhang  
33 - * @method 32 + * @param AiCommandLogic $aiCommandLogic
  33 + * @name :info
  34 + * @author :lyh
  35 + * @method :post
  36 + * @time :2023/6/17 16:27
34 */ 37 */
35 public function info(AiCommandLogic $aiCommandLogic){ 38 public function info(AiCommandLogic $aiCommandLogic){
36 $this->request->validate([ 39 $this->request->validate([
@@ -38,14 +41,17 @@ class AiCommandController extends BaseController @@ -38,14 +41,17 @@ class AiCommandController extends BaseController
38 ],[ 41 ],[
39 'id.required' => 'ID不能为空' 42 'id.required' => 'ID不能为空'
40 ]); 43 ]);
41 - $aiCommandLogic->ai_info();  
42 - $this->response('success'); 44 + $info = $aiCommandLogic->ai_info();
  45 + $this->response('success',Code::SUCCESS,$info);
43 } 46 }
  47 +
44 /** 48 /**
45 - * @name  
46 - * @return void  
47 - * @author :liyuhang  
48 - * @method 49 + * @param AiCommandRequest $request
  50 + * @param AiCommandLogic $aiCommandLogic
  51 + * @name :add
  52 + * @author :lyh
  53 + * @method :post
  54 + * @time :2023/6/17 16:27
49 */ 55 */
50 public function add(AiCommandRequest $request,AiCommandLogic $aiCommandLogic){ 56 public function add(AiCommandRequest $request,AiCommandLogic $aiCommandLogic){
51 $request->validated(); 57 $request->validated();
@@ -54,10 +60,12 @@ class AiCommandController extends BaseController @@ -54,10 +60,12 @@ class AiCommandController extends BaseController
54 } 60 }
55 61
56 /** 62 /**
57 - * @name  
58 - * @return void  
59 - * @author :liyuhang  
60 - * @method 63 + * @param AiCommandRequest $request
  64 + * @param AiCommandLogic $aiCommandLogic
  65 + * @name :edit
  66 + * @author :lyh
  67 + * @method :post
  68 + * @time :2023/6/17 16:28
61 */ 69 */
62 public function edit(AiCommandRequest $request,AiCommandLogic $aiCommandLogic){ 70 public function edit(AiCommandRequest $request,AiCommandLogic $aiCommandLogic){
63 $request->validate([ 71 $request->validate([
@@ -70,16 +78,18 @@ class AiCommandController extends BaseController @@ -70,16 +78,18 @@ class AiCommandController extends BaseController
70 } 78 }
71 79
72 /** 80 /**
73 - * @name  
74 - * @return void  
75 - * @author :liyuhang  
76 - * @method 81 + * @param AiCommandLogic $aiCommandLogic
  82 + * @name :del
  83 + * @author :lyh
  84 + * @method :post
  85 + * @time :2023/6/17 16:27
77 */ 86 */
78 public function del(AiCommandLogic $aiCommandLogic){ 87 public function del(AiCommandLogic $aiCommandLogic){
79 $this->request->validate([ 88 $this->request->validate([
80 - 'id'=>'required' 89 + 'id'=>['required','array'],
81 ],[ 90 ],[
82 - 'id.required' => 'ID不能为空' 91 + 'id.required' => 'ID不能为空',
  92 + 'id.array' => 'ID为数组',
83 ]); 93 ]);
84 $aiCommandLogic->ai_del(); 94 $aiCommandLogic->ai_del();
85 $this->response('success'); 95 $this->response('success');
@@ -5,18 +5,31 @@ namespace App\Http\Controllers\Aside\Ai; @@ -5,18 +5,31 @@ namespace App\Http\Controllers\Aside\Ai;
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
7 use App\Models\Ai\AiLog as AiLogModel; 7 use App\Models\Ai\AiLog as AiLogModel;
  8 +use App\Models\User\User;
8 9
9 - 10 +/**
  11 + * @remark :ai发送记录
  12 + * @name :AiLogController
  13 + * @author :lyh
  14 + * @time :2023/6/17 16:26
  15 + */
10 class AiLogController extends BaseController 16 class AiLogController extends BaseController
11 { 17 {
12 /** 18 /**
13 - * @name :ai日志列表  
14 - * @return void  
15 - * @author :liyuhang  
16 - * @method 19 + * @param AiLogModel $aiLogModel
  20 + * @name :(ai发送日志列表)lists
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2023/6/17 16:25
17 */ 24 */
18 public function lists(AiLogModel $aiLogModel){ 25 public function lists(AiLogModel $aiLogModel){
19 $lists = $aiLogModel->lists($this->map,$this->page,$this->row,$this->order); 26 $lists = $aiLogModel->lists($this->map,$this->page,$this->row,$this->order);
  27 + if(!empty($lists['list'])){
  28 + foreach ($lists['list'] as $k => $v){
  29 + $v['operator_name'] = (new User())->read(['id'=>$v['operator_id']])['name'];
  30 + $lists['list'][$k] = $v;
  31 + }
  32 + }
20 $this->response('success',Code::SUCCESS,$lists); 33 $this->response('success',Code::SUCCESS,$lists);
21 } 34 }
22 } 35 }
@@ -3,12 +3,16 @@ @@ -3,12 +3,16 @@
3 namespace App\Http\Controllers\Aside; 3 namespace App\Http\Controllers\Aside;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
  6 +use App\Enums\Common\Common;
6 use App\Http\Controllers\Controller; 7 use App\Http\Controllers\Controller;
  8 +use App\Models\File\File;
  9 +use App\Models\File\Image;
  10 +use App\Services\CosService;
7 use Illuminate\Http\JsonResponse; 11 use Illuminate\Http\JsonResponse;
8 use Illuminate\Http\Request; 12 use Illuminate\Http\Request;
9 use Illuminate\Http\Exceptions\HttpResponseException; 13 use Illuminate\Http\Exceptions\HttpResponseException;
10 use Illuminate\Support\Facades\Cache; 14 use Illuminate\Support\Facades\Cache;
11 -use Illuminate\Support\Facades\Session; 15 +
12 16
13 class BaseController extends Controller 17 class BaseController extends Controller
14 { 18 {
@@ -21,144 +25,129 @@ class BaseController extends Controller @@ -21,144 +25,129 @@ class BaseController extends Controller
21 protected $order = 'id'; 25 protected $order = 'id';
22 protected $map = [];//处理后的参数 26 protected $map = [];//处理后的参数
23 protected $uid = 0; 27 protected $uid = 0;
24 - protected $user = [];//当前登录用户详情 28 + protected $manage = [];//当前登录用户详情
  29 +
25 /** 30 /**
26 - * 获取所有参数 31 + * @param Request $request
27 */ 32 */
28 public function __construct(Request $request) 33 public function __construct(Request $request)
29 { 34 {
30 $this->request = $request; 35 $this->request = $request;
31 $this->param = $this->request->all(); 36 $this->param = $this->request->all();
32 $this->token = $this->request->header('token'); 37 $this->token = $this->request->header('token');
33 - if(!empty($this->token) && !empty(Cache::get($this->token))){  
34 - $info = Cache::get($this->token);  
35 - $this->user = $info; 38 + $this->getParam();
  39 + $info = Cache::get(Common::MANAGE_TOKEN . $this->token);
  40 + if(!empty($this->token) && !empty($info)){
  41 + $this->manage = $info;
  42 + Cache::put($this->token, $info, 3600 * 6);//更新缓存时间
36 $this->uid = $info['id']; 43 $this->uid = $info['id'];
37 - //参数处理  
38 - $this->get_param();  
39 } 44 }
40 -  
41 } 45 }
42 46
43 47
44 /** 48 /**
45 - * 成功返回  
46 - * @param array $data  
47 - * @param string $code  
48 - * @param bool $objectData  
49 - * @return JsonResponse  
50 - * @throws \Psr\Container\ContainerExceptionInterface  
51 - * @throws \Psr\Container\NotFoundExceptionInterface 49 + * @remark :请求参数处理
  50 + * @name :getParam
  51 + * @author :lyh
  52 + * @method :post
  53 + * @time :2023/6/17 16:34
52 */ 54 */
53 - function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse  
54 - {  
55 - if ($objectData) {  
56 - $data = (object)$data; 55 + public function getParam(){
  56 + foreach ($this->param as $k => $v){
  57 + if(is_array($v)){
  58 + $this->map[$k] = $v;
  59 + }else{
  60 + if(empty($v) && ($v == null)){
  61 + unset($this->param[$k]);
  62 + }
  63 + $this->getMap($k,$v);
  64 + }
57 } 65 }
58 - $code = Code::fromValue($code);  
59 - $response = [  
60 - 'code' => $code->value,  
61 - 'data' => $data,  
62 - 'msg' => $code->description,  
63 - ];  
64 - $this->header['token'] = $this->token;  
65 - return response()->json($response,200,$this->header);  
66 } 66 }
  67 +
67 /** 68 /**
68 - * @name :参数过滤  
69 - * @author :liyuhang  
70 - * @method 69 + * @remark :搜索参数处理
  70 + * @name :getMap
  71 + * @author :lyh
  72 + * @method :post
  73 + * @time :2023/8/28 10:22
71 */ 74 */
72 - public function get_param(){  
73 - $param = $this->param;  
74 - foreach ($param as $k => $v){  
75 - if(is_array($v)){  
76 - continue;  
77 - }  
78 - switch ($k){  
79 - case "order":  
80 - $this->order = $v;  
81 - break;  
82 - case 'page':  
83 - $this->page = $v;  
84 - break;  
85 - case 'row':  
86 - $this->row = $v;  
87 - break;  
88 - case "name":  
89 - $this->map['name'] = ['like','%'.$v.'%'];  
90 - break;  
91 - case "start_at":  
92 - $this->_btw[0] = $v;  
93 - $this->_btw[1] = date('Y-m-d H:i:s',time());  
94 - $this->map['created_at'] = ['between', $this->_btw];  
95 - break;  
96 - case "end_at":  
97 - $this->_btw[1] = $v;  
98 - $this->map['updated_at'] = ['between', $this->_btw];  
99 - break;  
100 - default:  
101 - if (!empty($v)) {  
102 - $this->map[$k] = $v;  
103 - }  
104 - break;  
105 - } 75 + public function getMap($k,$v){
  76 + switch ($k){
  77 + case "order":
  78 + $this->order = $v;
  79 + break;
  80 + case 'page':
  81 + $this->page = $v;
  82 + break;
  83 + case 'row':
  84 + $this->row = $v;
  85 + break;
  86 + case "name":
  87 + $this->map['name'] = ['like','%'.$v.'%'];
  88 + break;
  89 + case "start_at":
  90 + $this->_btw[0] = $v;
  91 + $this->_btw[1] = date('Y-m-d H:i:s',time());
  92 + $this->map['created_at'] = ['between', $this->_btw];
  93 + break;
  94 + case "end_at":
  95 + $this->_btw[1] = $v;
  96 + $this->map['updated_at'] = ['between', $this->_btw];
  97 + break;
  98 + default:
  99 + if ($v != null) {
  100 + $this->map[$k] = $v;
  101 + }
  102 + break;
106 } 103 }
107 } 104 }
108 /** 105 /**
109 - * @name 统一返回参数  
110 - * @return JsonResponse  
111 - * @author :liyuhang  
112 - * @method 106 + * @param $msg
  107 + * @param string $code
  108 + * @param $data
  109 + * @param $result_code
  110 + * @param $type
  111 + * @remark :统一返回
  112 + * @name :response
  113 + * @author :lyh
  114 + * @method :post
  115 + * @time :2023/6/17 16:34
113 */ 116 */
114 public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse 117 public function response($msg = null,string $code = Code::SUCCESS,$data = [],$result_code = 200,$type = 'application/json'): JsonResponse
115 { 118 {
116 $code = Code::fromValue($code); 119 $code = Code::fromValue($code);
117 $result = [ 120 $result = [
118 - 'msg' => $msg == ' ' ? $code->description : $msg, 121 + 'message' => $msg == ' ' ? $code->description : $msg,
119 'code' => $code->value, 122 'code' => $code->value,
120 - 'data' => $this->_extents($data), 123 + 'data' => $data,
121 ]; 124 ];
122 $this->header['Content-Type'] = $type; 125 $this->header['Content-Type'] = $type;
123 $this->header['token'] = $this->token; 126 $this->header['token'] = $this->token;
124 - $response = response($result,$result_code,$this->header);; 127 + $response = response($result,$result_code,$this->header);
125 throw new HttpResponseException($response); 128 throw new HttpResponseException($response);
126 } 129 }
127 130
128 -  
129 /** 131 /**
130 - * @param $data  
131 - * @name :返回参数统一处理  
132 - * @return array|string  
133 - * @author :liyuhang  
134 - * @method 132 + * @remark :返回json
  133 + * @name :success
  134 + * @author :lyh
  135 + * @method :post
  136 + * @time :2023/8/28 10:18
135 */ 137 */
136 - protected function _extents($data) {  
137 -  
138 - if (empty($data) || !is_array($data)) {  
139 - return empty($data) ? is_array($data) ? [] : '' : $data;  
140 - }  
141 - foreach ($data as $k => $v) {  
142 - if (is_array($v)) {  
143 - $data[$k] = $this->_extents($v);  
144 - } else {  
145 - if (is_null($v)) {  
146 - $data[$k] = '';  
147 - continue;  
148 - }  
149 - switch ((string) $k) {  
150 - case 'image':  
151 - $v['image_link'] = url('/a/image/' . $v);  
152 - break;  
153 - }  
154 - } 138 + function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse
  139 + {
  140 + if ($objectData) {
  141 + $data = (object)$data;
155 } 142 }
156 - return $data; 143 + $code = Code::fromValue($code);
  144 + $response = [
  145 + 'code' => $code->value,
  146 + 'data' => $data,
  147 + 'message' => $code->description,
  148 + ];
  149 + $this->header['token'] = $this->token;
  150 + return response()->json($response,200,$this->header);
157 } 151 }
158 152
159 -  
160 -  
161 -  
162 -  
163 -  
164 } 153 }
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside\Com;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Enums\Common\Common;
  7 +use App\Http\Controllers\Aside\BaseController;
  8 +use App\Http\Logic\Aside\Manage\MenuLogic;
  9 +use App\Models\Manage\Manage;
  10 +use Illuminate\Support\Facades\Cache;
  11 +use Illuminate\Support\Facades\Hash;
  12 +
  13 +/**
  14 + * Class IndexController
  15 + * @package App\Http\Controllers\Aside
  16 + * @author zbj
  17 + * @date 2023/4/19
  18 + */
  19 +class IndexController extends BaseController
  20 +{
  21 + /**
  22 + * 用户菜单
  23 + * @param MenuLogic $logic
  24 + * @return \Illuminate\Http\JsonResponse
  25 + * @throws \Psr\Container\ContainerExceptionInterface
  26 + * @throws \Psr\Container\NotFoundExceptionInterface
  27 + * @author zbj
  28 + * @date 2023/6/21
  29 + */
  30 + public function get_menu(MenuLogic $logic)
  31 + {
  32 + if($this->manage['gid'] == 0){ //超级管理员
  33 + $menus = $logic->getAllMenu();
  34 + }else{
  35 + $menus = $logic->getMenuByGroupId($this->manage['gid']);
  36 + }
  37 + $this->response('success',Code::SUCCESS,$menus);
  38 + }
  39 +
  40 + /**
  41 + * @remark :修改密码
  42 + * @name :editPassword
  43 + * @author :lyh
  44 + * @method :post
  45 + * @time :2023/9/11 9:10
  46 + */
  47 + public function editPassword(){
  48 + $this->request->validate([
  49 + 'oldPassword'=>'required',
  50 + 'password' => 'required',
  51 + 'confirm'=>'required',
  52 + ], [
  53 + 'oldPassword.required' => '请输入原密码',
  54 + 'password.required' => '请输入新密码',
  55 + 'confirm.required' => '请再次输入新密码',
  56 + ]);
  57 + //查询员密码是否正确
  58 + $managerModel = new Manage();
  59 + $info = $managerModel->read(['id'=>$this->manage['id']]);
  60 + if(!Hash::check($this->param['oldPassword'], $info['password'])){
  61 + $this->response('原密码错误',Code::USER_REGISTER_ERROE);
  62 + }
  63 + if($this->param['password'] != $this->param['confirm']){
  64 + $this->response('两次密码不一致');
  65 + }
  66 + $rs = $managerModel->edit(['password'=>Hash::make($this->param['password'])],['id'=>$this->manage['id']]);
  67 + if($rs === false){
  68 + $this->response('系统错误',Code::SYSTEM_ERROR);
  69 + }
  70 + Cache::pull(Common::MANAGE_TOKEN . $info['token']);
  71 + $this->response('success');
  72 + }
  73 +
  74 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :UpdateController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/8/19 9:08
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Aside\Com;
  11 +
  12 +use App\Helper\Common;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Services\ProjectServer;
  15 +use Illuminate\Support\Facades\DB;
  16 +
  17 +/**
  18 + * @remark :b端网站更新相关
  19 + * @name :UpdateController
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2023/8/19 9:08
  23 + */
  24 +class UpdateController extends BaseController
  25 +{
  26 + /**
  27 + * @remark :一键更新所有tdk
  28 + * @name :updateSeoTdk
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2023/8/19 9:25
  32 + */
  33 + public function updateSeoTdk(){
  34 + $this->request->validate([
  35 + 'project_id'=>'required',
  36 + ],[
  37 + 'project_id.required' => 'project_id不能为空',
  38 + ]);
  39 + ProjectServer::useProject($this->param['project_id']);
  40 + $this->updateProduct($this->param['project_id']);
  41 + $this->updateBlogs($this->param['project_id']);
  42 + $this->updateNews($this->param['project_id']);
  43 + DB::disconnect('custom_mysql');
  44 + $this->response('success');
  45 + }
  46 +
  47 + /**
  48 + * @remark :更新产品tdk
  49 + * @name :updateProduct
  50 + * @author :lyh
  51 + * @method :post
  52 + * @time :2023/8/19 9:25
  53 + */
  54 + public function updateProduct($project_id){
  55 + $list = DB::connection('custom_mysql')->table('gl_product')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
  56 + if(!empty($list)){
  57 + foreach ($list as $v){
  58 + if(!empty($v['seo_mate'])){
  59 + $seo_arr = $v['seo_mate'];
  60 + //更新seo_title
  61 + if(!isset($seo_arr['title'])){
  62 + //生成seo_title
  63 + $seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']);
  64 + }
  65 + //更新seo_keyword
  66 + if(!isset($seo_arr['keyword'])){
  67 + $seo_arr['keyword'] = $this->ai_send('product_seo_keyword',$v['title']);
  68 + }
  69 + //更新seo_keyword
  70 + if(!isset($seo_arr['description'])){
  71 + $seo_arr['description'] = $this->ai_send('product_seo_description',$v['title']);
  72 + }
  73 + $ser_str = json_encode($seo_arr,true);
  74 + DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update(['seo_mate'=>$ser_str]);
  75 + }
  76 + }
  77 + }
  78 + return true;
  79 + }
  80 +
  81 + /**
  82 + * @remark :更新新闻Tdk
  83 + * @name :updateNews
  84 + * @author :lyh
  85 + * @method :post
  86 + * @time :2023/8/19 10:06
  87 + */
  88 + public function updateNews($project_id){
  89 + $list = DB::connection('custom_mysql')->table('gl_news')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
  90 + if(!empty($list)){
  91 + foreach ($list as $k => $v){
  92 + $data = [];
  93 + if(empty($v['seo_title'])){
  94 + $data['seo_title'] = $this->ai_send('news_seo_title',$v['name']);
  95 + }
  96 + if(empty($v['seo_keywords'])){
  97 + $data['seo_keywords'] = $this->ai_send('news_seo_keyword',$v['name']);
  98 + }
  99 + if(empty($v['seo_description'])){
  100 + $data['seo_description'] = $this->ai_send('news_seo_description',$v['name']);
  101 + }
  102 + DB::connection('custom_mysql')->table('gl_news')->where(['id'=>$v['id']])->update($data);
  103 + }
  104 + }
  105 + return true;
  106 + }
  107 +
  108 + /**
  109 + * @remark :更新blogTdk
  110 + * @name :updateBlogs
  111 + * @author :lyh
  112 + * @method :post
  113 + * @time :2023/8/19 10:07
  114 + */
  115 + public function updateBlogs($project_id){
  116 + $list = DB::connection('custom_mysql')->table('gl_blog')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
  117 + if(!empty($list)){
  118 + foreach ($list as $k => $v){
  119 + $data = [];
  120 + if(empty($v['seo_title'])){
  121 + $data['seo_title'] = $this->ai_send('blog_seo_title',$v['name']);
  122 + }
  123 + if(empty($v['seo_keywords'])){
  124 + $data['seo_keywords'] = $this->ai_send('blog_seo_keyword',$v['name']);
  125 + }
  126 + if(empty($v['seo_description'])){
  127 + $data['seo_description'] = $this->ai_send('blog_seo_description',$v['name']);
  128 + }
  129 + DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update($data);
  130 + }
  131 + }
  132 + return true;
  133 + }
  134 +
  135 + /**
  136 + * @remark :AI发送
  137 + * @name :ai_send
  138 + * @author :lyh
  139 + * @method :post
  140 + * @time :2023/8/19 10:40
  141 + */
  142 + public function ai_send($key,$keywords){
  143 + $chat_url = 'v2/openai_chat';
  144 + $param = [
  145 + 'key'=>$key,
  146 + 'keywords'=>$keywords,
  147 + ];
  148 + $data = Common::send_openai_msg($chat_url,$param);
  149 + return $data['text'];
  150 + }
  151 +}
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace App\Http\Controllers\Aside\Devops; 3 namespace App\Http\Controllers\Aside\Devops;
4 4
  5 +use App\Enums\Common\Code;
5 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
6 7
7 use App\Http\Logic\Aside\Devops\ServerConfigLogic; 8 use App\Http\Logic\Aside\Devops\ServerConfigLogic;
@@ -21,6 +22,41 @@ class ServerConfigController extends BaseController @@ -21,6 +22,41 @@ class ServerConfigController extends BaseController
21 { 22 {
22 23
23 /** 24 /**
  25 + * @remark :服务器列表
  26 + * @name :lists
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2023/8/2 14:48
  30 + */
  31 + public function lists(ServerConfigLogic $logic){
  32 + if(isset($this->map['title']) && !empty($this->map['title'])){
  33 + $this->map['title'] = ['like','%'.$this->map['title'].'%'];
  34 + }
  35 + if(isset($this->map['host']) && !empty($this->map['host'])){
  36 + $this->map['host'] = ['like','%'.$this->map['host'].'%'];
  37 + }
  38 + $lists = $logic->serviceConfigList($this->map,$this->page,$this->row,$this->order);
  39 + $this->response('success',Code::SUCCESS,$lists);
  40 + }
  41 +
  42 + /**
  43 + * @remark :获取数据详情
  44 + * @name :info
  45 + * @author :lyh
  46 + * @method :post
  47 + * @time :2023/8/2 17:52
  48 + */
  49 + public function info(ServerConfigLogic $logic){
  50 + $this->request->validate([
  51 + 'id'=>'required'
  52 + ],[
  53 + 'id.required' => 'ID不能为空'
  54 + ]);
  55 + $info = $logic->getServiceConfig();
  56 + $this->response('success',Code::SUCCESS,$info);
  57 + }
  58 +
  59 + /**
24 * 保存配置 60 * 保存配置
25 * @param ServerConfigRequest $request 61 * @param ServerConfigRequest $request
26 * @param ServerConfigLogic $logic 62 * @param ServerConfigLogic $logic
@@ -28,10 +64,29 @@ class ServerConfigController extends BaseController @@ -28,10 +64,29 @@ class ServerConfigController extends BaseController
28 * @date 2023/4/23 64 * @date 2023/4/23
29 */ 65 */
30 public function save(ServerConfigRequest $request, ServerConfigLogic $logic){ 66 public function save(ServerConfigRequest $request, ServerConfigLogic $logic){
31 - $data = $logic->save($this->param);  
32 - return $this->success($data); 67 + $request->validated();
  68 + $logic->serviceConfigSave();
  69 + $this->response('success');
  70 + }
  71 +
  72 + /**
  73 + * @remark :删除配置
  74 + * @name :del
  75 + * @author :lyh
  76 + * @method :post
  77 + * @time :2023/8/2 15:41
  78 + */
  79 + public function del(ServerConfigLogic $logic){
  80 + $this->request->validate([
  81 + 'id'=>'required'
  82 + ],[
  83 + 'id.required' => 'ID不能为空'
  84 + ]);
  85 + $logic->delServiceConfig();
  86 + return $this->response('success');
33 } 87 }
34 88
  89 +
35 /** 90 /**
36 * 更新表结构 91 * 更新表结构
37 * @param ServerConfigLogic $logic 92 * @param ServerConfigLogic $logic
@@ -63,26 +118,7 @@ class ServerConfigController extends BaseController @@ -63,26 +118,7 @@ class ServerConfigController extends BaseController
63 $data = $logic->updateAllTable($this->param); 118 $data = $logic->updateAllTable($this->param);
64 break; 119 break;
65 } 120 }
66 -  
67 - return $this->success($data); 121 + $this->response('success',Code::SUCCESS,$data);
68 } 122 }
69 123
70 - /**  
71 - * 更新代码  
72 - * @param ServerConfigLogic $logic  
73 - * @author zbj  
74 - * @date 2023/4/24  
75 - */  
76 - public function updateCode(){  
77 - //todo  
78 - //C端  
79 -// $process = new Process(['git', 'pull']);  
80 -// $process->run();  
81 -// dump($process->getExitCodeText());  
82 -// dump($process->getExitCode());  
83 -// dump($process->getErrorOutput());  
84 -// $output = explode(PHP_EOL, $process->getOutput());  
85 -// dump($output);  
86 -// exit;  
87 - }  
88 } 124 }