Merge remote-tracking branch 'origin/master' into zhl
正在显示
27 个修改的文件
包含
571 行增加
和
202 行删除
| @@ -5,6 +5,7 @@ namespace App\Console\Commands\DayCount; | @@ -5,6 +5,7 @@ namespace App\Console\Commands\DayCount; | ||
| 5 | use App\Helper\Common; | 5 | use App\Helper\Common; |
| 6 | use App\Helper\FormGlobalsoApi; | 6 | use App\Helper\FormGlobalsoApi; |
| 7 | use App\Models\Domain\DomainInfo; | 7 | use App\Models\Domain\DomainInfo; |
| 8 | +use App\Models\Inquiry\InquiryForm; | ||
| 8 | use App\Models\Inquiry\InquiryFormData; | 9 | use App\Models\Inquiry\InquiryFormData; |
| 9 | use App\Models\Project\DeployBuild; | 10 | use App\Models\Project\DeployBuild; |
| 10 | use App\Models\Project\DeployOptimize; | 11 | use App\Models\Project\DeployOptimize; |
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * @remark : | 3 | * @remark : |
| 4 | - * @name :UpgradeProjectCount.php | 4 | + * @name :CountProject.php |
| 5 | * @author :lyh | 5 | * @author :lyh |
| 6 | * @method :post | 6 | * @method :post |
| 7 | * @time :2024/1/8 9:03 | 7 | * @time :2024/1/8 9:03 |
| @@ -9,6 +9,8 @@ | @@ -9,6 +9,8 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Console\Commands\DayCount; | 10 | namespace App\Console\Commands\DayCount; |
| 11 | 11 | ||
| 12 | +use App\Helper\FormGlobalsoApi; | ||
| 13 | +use App\Models\Inquiry\InquiryFormData; | ||
| 12 | use App\Models\Project\Project; | 14 | use App\Models\Project\Project; |
| 13 | use App\Models\Visit\Visit; | 15 | use App\Models\Visit\Visit; |
| 14 | use App\Services\ProjectServer; | 16 | use App\Services\ProjectServer; |
| @@ -16,14 +18,16 @@ use Illuminate\Console\Command; | @@ -16,14 +18,16 @@ use Illuminate\Console\Command; | ||
| 16 | use Illuminate\Support\Facades\DB; | 18 | use Illuminate\Support\Facades\DB; |
| 17 | use App\Models\HomeCount\Count; | 19 | use App\Models\HomeCount\Count; |
| 18 | 20 | ||
| 19 | -class UpgradeCount extends Command | 21 | +class CountAll extends Command |
| 20 | { | 22 | { |
| 23 | + const STATUS_ERROR = 400; | ||
| 24 | + public $error = 0; | ||
| 21 | /** | 25 | /** |
| 22 | * The name and signature of the console command. | 26 | * The name and signature of the console command. |
| 23 | * | 27 | * |
| 24 | * @var string | 28 | * @var string |
| 25 | */ | 29 | */ |
| 26 | - protected $signature = 'upgrade_counts'; | 30 | + protected $signature = 'count_all'; |
| 27 | 31 | ||
| 28 | /** | 32 | /** |
| 29 | * The console command description. | 33 | * The console command description. |
| @@ -34,7 +38,7 @@ class UpgradeCount extends Command | @@ -34,7 +38,7 @@ class UpgradeCount extends Command | ||
| 34 | 38 | ||
| 35 | public function handle(){ | 39 | public function handle(){ |
| 36 | $projectModel = new Project(); | 40 | $projectModel = new Project(); |
| 37 | - $list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0]); | 41 | + $list = $projectModel->list(['delete_status'=>0]); |
| 38 | foreach ($list as $v) { | 42 | foreach ($list as $v) { |
| 39 | echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL; | 43 | echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL; |
| 40 | ProjectServer::useProject($v['id']); | 44 | ProjectServer::useProject($v['id']); |
| @@ -90,6 +94,52 @@ class UpgradeCount extends Command | @@ -90,6 +94,52 @@ class UpgradeCount extends Command | ||
| 90 | } | 94 | } |
| 91 | 95 | ||
| 92 | /** | 96 | /** |
| 97 | + * @param $arr | ||
| 98 | + * @param $domain | ||
| 99 | + * @name :(询盘统计)inquiry | ||
| 100 | + * @author :lyh | ||
| 101 | + * @method :post | ||
| 102 | + * @time :2023/6/14 15:44 | ||
| 103 | + */ | ||
| 104 | + public function inquiry($arr,$domain,$project_id){ | ||
| 105 | + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000); | ||
| 106 | + if($inquiry_list == false){ | ||
| 107 | + return false; | ||
| 108 | + } | ||
| 109 | + if($inquiry_list['status'] == self::STATUS_ERROR){ | ||
| 110 | + $arr['inquiry_num'] = 0; | ||
| 111 | + $countryArr = []; | ||
| 112 | + }else{ | ||
| 113 | + $arr['inquiry_num'] = $inquiry_list['data']['total']; | ||
| 114 | + //询盘国家统计 | ||
| 115 | + $countryData = $inquiry_list['data']['data']; | ||
| 116 | + $countryArr = []; | ||
| 117 | + foreach ($countryData as $v1){ | ||
| 118 | + if(isset($countryArr[$v1['country']])){ | ||
| 119 | + $countryArr[$v1['country']]++; | ||
| 120 | + }else{ | ||
| 121 | + $countryArr[$v1['country']] = 1; | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + } | ||
| 125 | + //加上其他询盘 | ||
| 126 | + ProjectServer::useProject($project_id); | ||
| 127 | + $arr['inquiry_num'] += InquiryFormData::getCount(); | ||
| 128 | + $countryData = InquiryFormData::getCountryCount(); | ||
| 129 | + foreach ($countryData as $v1){ | ||
| 130 | + if(isset($countryArr[$v1['country']])){ | ||
| 131 | + $countryArr[$v1['country']] += $v1['count']; | ||
| 132 | + }else{ | ||
| 133 | + $countryArr[$v1['country']] = $v1['count']; | ||
| 134 | + } | ||
| 135 | + } | ||
| 136 | + arsort($countryArr); | ||
| 137 | + $top20 = array_slice($countryArr, 0, 20, true); | ||
| 138 | + $arr['country'] = json_encode($top20); | ||
| 139 | + return $arr; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + /** | ||
| 93 | * @remark :询盘数量 | 143 | * @remark :询盘数量 |
| 94 | * @name :inquiry_num | 144 | * @name :inquiry_num |
| 95 | * @author :lyh | 145 | * @author :lyh |
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * @remark : | 3 | * @remark : |
| 4 | - * @name :UpgradeProjectCount.php | 4 | + * @name :CountProject.php |
| 5 | * @author :lyh | 5 | * @author :lyh |
| 6 | * @method :post | 6 | * @method :post |
| 7 | * @time :2024/1/8 9:03 | 7 | * @time :2024/1/8 9:03 |
| @@ -9,6 +9,10 @@ | @@ -9,6 +9,10 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Console\Commands\DayCount; | 10 | namespace App\Console\Commands\DayCount; |
| 11 | 11 | ||
| 12 | +use App\Helper\FormGlobalsoApi; | ||
| 13 | +use App\Models\Domain\DomainInfo; | ||
| 14 | +use App\Models\Inquiry\InquiryFormData; | ||
| 15 | +use App\Models\Project\DeployOptimize; | ||
| 12 | use App\Models\Project\Project; | 16 | use App\Models\Project\Project; |
| 13 | use App\Models\Visit\Visit; | 17 | use App\Models\Visit\Visit; |
| 14 | use App\Services\ProjectServer; | 18 | use App\Services\ProjectServer; |
| @@ -16,14 +20,16 @@ use Illuminate\Console\Command; | @@ -16,14 +20,16 @@ use Illuminate\Console\Command; | ||
| 16 | use Illuminate\Support\Facades\DB; | 20 | use Illuminate\Support\Facades\DB; |
| 17 | use App\Models\HomeCount\Count; | 21 | use App\Models\HomeCount\Count; |
| 18 | 22 | ||
| 19 | -class UpgradeProjectCount extends Command | 23 | +class CountProject extends Command |
| 20 | { | 24 | { |
| 25 | + const STATUS_ERROR = 400; | ||
| 26 | + public $error = 0; | ||
| 21 | /** | 27 | /** |
| 22 | * The name and signature of the console command. | 28 | * The name and signature of the console command. |
| 23 | * | 29 | * |
| 24 | * @var string | 30 | * @var string |
| 25 | */ | 31 | */ |
| 26 | - protected $signature = 'upgrade_count {project_id}'; | 32 | + protected $signature = 'count_project {project_id}'; |
| 27 | 33 | ||
| 28 | /** | 34 | /** |
| 29 | * The console command description. | 35 | * The console command description. |
| @@ -51,6 +57,19 @@ class UpgradeProjectCount extends Command | @@ -51,6 +57,19 @@ class UpgradeProjectCount extends Command | ||
| 51 | ->groupBy('updated_date')->get()->toArray(); | 57 | ->groupBy('updated_date')->get()->toArray(); |
| 52 | $project = new Project(); | 58 | $project = new Project(); |
| 53 | $projectInfo = $project->read(['id'=>$project_id]); | 59 | $projectInfo = $project->read(['id'=>$project_id]); |
| 60 | + $projectOptimizeModel = new DeployOptimize(); | ||
| 61 | + $optimizeInfo = $projectOptimizeModel->read(['project_id'=>$project_id]); | ||
| 62 | + $domain = ''; | ||
| 63 | + if(!empty($optimizeInfo['domain'])){ | ||
| 64 | + $domainInfoModel = new DomainInfo(); | ||
| 65 | + $domainInfo = $domainInfoModel->read(['id'=>$optimizeInfo['domain']]); | ||
| 66 | + if($domainInfo !== false){ | ||
| 67 | + $domain = $domainInfo['domain']; | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + if(empty($domain)){ | ||
| 71 | + return false; | ||
| 72 | + } | ||
| 54 | if(!empty($list)){ | 73 | if(!empty($list)){ |
| 55 | $arr = []; | 74 | $arr = []; |
| 56 | foreach ($list as $k=>$v){ | 75 | foreach ($list as $k=>$v){ |
| @@ -64,12 +83,11 @@ class UpgradeProjectCount extends Command | @@ -64,12 +83,11 @@ class UpgradeProjectCount extends Command | ||
| 64 | $arr['date'] = $v['updated_date']; | 83 | $arr['date'] = $v['updated_date']; |
| 65 | $arr['pv_num'] = $this->pv_num($v['updated_date']); | 84 | $arr['pv_num'] = $this->pv_num($v['updated_date']); |
| 66 | $arr['ip_num'] = $this->ip_num($v['updated_date']); | 85 | $arr['ip_num'] = $this->ip_num($v['updated_date']); |
| 67 | - $arr['inquiry_num'] = $this->inquiry_num($v['updated_date']); | ||
| 68 | //服务达标天数 | 86 | //服务达标天数 |
| 69 | $arr['compliance_day'] = $projectInfo['finish_remain_day']; | 87 | $arr['compliance_day'] = $projectInfo['finish_remain_day']; |
| 70 | //剩余服务时常 | 88 | //剩余服务时常 |
| 71 | $arr['service_day'] = $projectInfo['remain_day']; | 89 | $arr['service_day'] = $projectInfo['remain_day']; |
| 72 | - $arr['country'] = json_encode([]); | 90 | + $arr = $this->inquiry($arr,$domain, $project_id); |
| 73 | //查询当天数据是否存在 存在则更新 | 91 | //查询当天数据是否存在 存在则更新 |
| 74 | $info = $count->read(['date'=>$v['updated_date'],'project_id'=>$project_id]); | 92 | $info = $count->read(['date'=>$v['updated_date'],'project_id'=>$project_id]); |
| 75 | if($info === false){ | 93 | if($info === false){ |
| @@ -103,7 +121,6 @@ class UpgradeProjectCount extends Command | @@ -103,7 +121,6 @@ class UpgradeProjectCount extends Command | ||
| 103 | * @time :2023/6/14 15:40 | 121 | * @time :2023/6/14 15:40 |
| 104 | */ | 122 | */ |
| 105 | public function pv_num($day){ | 123 | public function pv_num($day){ |
| 106 | - //$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $day)->count(); | ||
| 107 | $pv = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->sum('depth'); | 124 | $pv = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->sum('depth'); |
| 108 | return $pv; | 125 | return $pv; |
| 109 | } | 126 | } |
| @@ -119,6 +136,50 @@ class UpgradeProjectCount extends Command | @@ -119,6 +136,50 @@ class UpgradeProjectCount extends Command | ||
| 119 | return $ip; | 136 | return $ip; |
| 120 | } | 137 | } |
| 121 | 138 | ||
| 122 | - | 139 | + /** |
| 140 | + * @param $arr | ||
| 141 | + * @param $domain | ||
| 142 | + * @name :(询盘统计)inquiry | ||
| 143 | + * @author :lyh | ||
| 144 | + * @method :post | ||
| 145 | + * @time :2023/6/14 15:44 | ||
| 146 | + */ | ||
| 147 | + public function inquiry($arr,$domain,$project_id){ | ||
| 148 | + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000); | ||
| 149 | + if($inquiry_list == false){ | ||
| 150 | + return false; | ||
| 151 | + } | ||
| 152 | + if($inquiry_list['status'] == self::STATUS_ERROR){ | ||
| 153 | + $arr['inquiry_num'] = 0; | ||
| 154 | + $countryArr = []; | ||
| 155 | + }else{ | ||
| 156 | + $arr['inquiry_num'] = $inquiry_list['data']['total']; | ||
| 157 | + //询盘国家统计 | ||
| 158 | + $countryData = $inquiry_list['data']['data']; | ||
| 159 | + $countryArr = []; | ||
| 160 | + foreach ($countryData as $v1){ | ||
| 161 | + if(isset($countryArr[$v1['country']])){ | ||
| 162 | + $countryArr[$v1['country']]++; | ||
| 163 | + }else{ | ||
| 164 | + $countryArr[$v1['country']] = 1; | ||
| 165 | + } | ||
| 166 | + } | ||
| 167 | + } | ||
| 168 | + //加上其他询盘 | ||
| 169 | + ProjectServer::useProject($project_id); | ||
| 170 | + $arr['inquiry_num'] += InquiryFormData::getCount(); | ||
| 171 | + $countryData = InquiryFormData::getCountryCount(); | ||
| 172 | + foreach ($countryData as $v1){ | ||
| 173 | + if(isset($countryArr[$v1['country']])){ | ||
| 174 | + $countryArr[$v1['country']] += $v1['count']; | ||
| 175 | + }else{ | ||
| 176 | + $countryArr[$v1['country']] = $v1['count']; | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + arsort($countryArr); | ||
| 180 | + $top20 = array_slice($countryArr, 0, 20, true); | ||
| 181 | + $arr['country'] = json_encode($top20); | ||
| 182 | + return $arr; | ||
| 183 | + } | ||
| 123 | 184 | ||
| 124 | } | 185 | } |
| @@ -10,6 +10,7 @@ | @@ -10,6 +10,7 @@ | ||
| 10 | namespace App\Console\Commands\Domain; | 10 | namespace App\Console\Commands\Domain; |
| 11 | 11 | ||
| 12 | use App\Models\Devops\ServerConfig; | 12 | use App\Models\Devops\ServerConfig; |
| 13 | +use App\Models\Devops\ServersIp; | ||
| 13 | use App\Models\Project\CountryCustom; | 14 | use App\Models\Project\CountryCustom; |
| 14 | use App\Models\Project\Project; | 15 | use App\Models\Project\Project; |
| 15 | use Illuminate\Console\Command; | 16 | use Illuminate\Console\Command; |
| @@ -98,13 +99,18 @@ class DomainInfo extends Command | @@ -98,13 +99,18 @@ class DomainInfo extends Command | ||
| 98 | $ssl['to'] && $data['certificate_end_time'] = $ssl['to']; | 99 | $ssl['to'] && $data['certificate_end_time'] = $ssl['to']; |
| 99 | 100 | ||
| 100 | $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']); | 101 | $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']); |
| 101 | - if ($v['type'] == 1 && $ssl['to'] < $end_day && $project_info && $project_info['serve_id'] != ServerConfig::SELF_SITE_ID) { | ||
| 102 | - //非自建站项目,申请免费证书 | ||
| 103 | - $this->updatePrivate($v); | 102 | + if ($v['type'] == 1 && $ssl['to'] < $end_day && $project_info) { |
| 103 | + $serverIpModel = new ServersIp(); | ||
| 104 | + $servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id']); | ||
| 105 | + if ($servers_ip_info && $servers_ip_info['servers_id'] != ServerConfig::SELF_SITE_ID) { | ||
| 106 | + //非自建站项目,申请免费证书 | ||
| 107 | + $this->updatePrivate($v); | ||
| 108 | + | ||
| 109 | + $ssl_new = $this->updateDomainSsl($v['domain']); | ||
| 110 | + $ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from']; | ||
| 111 | + $ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to']; | ||
| 112 | + } | ||
| 104 | 113 | ||
| 105 | - $ssl_new = $this->updateDomainSsl($v['domain']); | ||
| 106 | - $ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from']; | ||
| 107 | - $ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to']; | ||
| 108 | } | 114 | } |
| 109 | 115 | ||
| 110 | $domainModel->edit($data, ['id' => $v['id']]); | 116 | $domainModel->edit($data, ['id' => $v['id']]); |
| @@ -142,13 +148,17 @@ class DomainInfo extends Command | @@ -142,13 +148,17 @@ class DomainInfo extends Command | ||
| 142 | $ssl['to'] && $data['amp_certificate_end_time'] = $ssl['to']; | 148 | $ssl['to'] && $data['amp_certificate_end_time'] = $ssl['to']; |
| 143 | 149 | ||
| 144 | $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']); | 150 | $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']); |
| 145 | - if ($v['amp_type'] == 1 && $ssl['to'] < $end_day && $project_info && $project_info['serve_id'] != ServerConfig::SELF_SITE_ID) { | ||
| 146 | - //非自建站项目,申请免费证书 | ||
| 147 | - $this->updateAmpPrivate($v['domain']); | 151 | + if ($v['amp_type'] == 1 && $ssl['to'] < $end_day && $project_info) { |
| 152 | + $serverIpModel = new ServersIp(); | ||
| 153 | + $servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id']); | ||
| 154 | + if ($servers_ip_info && $servers_ip_info['servers_id'] != ServerConfig::SELF_SITE_ID) { | ||
| 155 | + //非自建站项目,申请免费证书 | ||
| 156 | + $this->updateAmpPrivate($v['domain']); | ||
| 148 | 157 | ||
| 149 | - $ssl_new = $this->updateDomainSsl($v['domain']); | ||
| 150 | - $ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from']; | ||
| 151 | - $ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to']; | 158 | + $ssl_new = $this->updateDomainSsl($v['domain']); |
| 159 | + $ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from']; | ||
| 160 | + $ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to']; | ||
| 161 | + } | ||
| 152 | } | 162 | } |
| 153 | 163 | ||
| 154 | $domainModel->edit($data, ['id' => $v['id']]); | 164 | $domainModel->edit($data, ['id' => $v['id']]); |
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * @remark : | 3 | * @remark : |
| 4 | - * @name :UpgradeProjectCount.php | 4 | + * @name :CountProject.php |
| 5 | * @author :lyh | 5 | * @author :lyh |
| 6 | * @method :post | 6 | * @method :post |
| 7 | * @time :2024/1/8 9:03 | 7 | * @time :2024/1/8 9:03 |
| @@ -13,6 +13,7 @@ use App\Helper\FormGlobalsoApi; | @@ -13,6 +13,7 @@ use App\Helper\FormGlobalsoApi; | ||
| 13 | use App\Models\Com\UpdateOldInfo; | 13 | use App\Models\Com\UpdateOldInfo; |
| 14 | use App\Models\Domain\DomainInfo; | 14 | use App\Models\Domain\DomainInfo; |
| 15 | use App\Models\HomeCount\MonthCount; | 15 | use App\Models\HomeCount\MonthCount; |
| 16 | +use App\Models\Inquiry\InquiryFormData; | ||
| 16 | use App\Models\Project\Project; | 17 | use App\Models\Project\Project; |
| 17 | use App\Models\Visit\Visit; | 18 | use App\Models\Visit\Visit; |
| 18 | use App\Services\ProjectServer; | 19 | use App\Services\ProjectServer; |
| @@ -20,14 +21,14 @@ use Illuminate\Console\Command; | @@ -20,14 +21,14 @@ use Illuminate\Console\Command; | ||
| 20 | use Illuminate\Support\Facades\DB; | 21 | use Illuminate\Support\Facades\DB; |
| 21 | use App\Models\HomeCount\Count; | 22 | use App\Models\HomeCount\Count; |
| 22 | 23 | ||
| 23 | -class UpgradeCount extends Command | 24 | +class MonthAllCount extends Command |
| 24 | { | 25 | { |
| 25 | /** | 26 | /** |
| 26 | * The name and signature of the console command. | 27 | * The name and signature of the console command. |
| 27 | * | 28 | * |
| 28 | * @var string | 29 | * @var string |
| 29 | */ | 30 | */ |
| 30 | - protected $signature = 'upgrade_month_counts'; | 31 | + protected $signature = 'month_all'; |
| 31 | 32 | ||
| 32 | /** | 33 | /** |
| 33 | * The console command description. | 34 | * The console command description. |
| @@ -38,14 +39,23 @@ class UpgradeCount extends Command | @@ -38,14 +39,23 @@ class UpgradeCount extends Command | ||
| 38 | 39 | ||
| 39 | public function handle(){ | 40 | public function handle(){ |
| 40 | $projectModel = new Project(); | 41 | $projectModel = new Project(); |
| 41 | - $list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0]); | 42 | + $list = $projectModel->list(['delete_status'=>0]); |
| 42 | foreach ($list as $v) { | 43 | foreach ($list as $v) { |
| 43 | - $oldModel = new UpdateOldInfo(); | ||
| 44 | - $info = $oldModel->read(['project_id' => $v['id']]); | ||
| 45 | - if ($info !== false) { | ||
| 46 | - $url = $info['old_domain_online']; | 44 | + if($v['is_upgrade'] == 1){ |
| 45 | + $oldModel = new UpdateOldInfo(); | ||
| 46 | + $info = $oldModel->read(['project_id' => $v['id']]); | ||
| 47 | + if ($info !== false) { | ||
| 48 | + $url = $info['old_domain_online']; | ||
| 49 | + }else{ | ||
| 50 | + continue; | ||
| 51 | + } | ||
| 47 | }else{ | 52 | }else{ |
| 48 | - continue; | 53 | + $domainModel = new DomainInfo(); |
| 54 | + $info = $domainModel->read(['project_id'=>$v['id']]); | ||
| 55 | + if($info === false){ | ||
| 56 | + continue; | ||
| 57 | + } | ||
| 58 | + $url = $info['domain']; | ||
| 49 | } | 59 | } |
| 50 | ProjectServer::useProject($v['id']); | 60 | ProjectServer::useProject($v['id']); |
| 51 | echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL; | 61 | echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL; |
| @@ -67,9 +77,7 @@ class UpgradeCount extends Command | @@ -67,9 +77,7 @@ class UpgradeCount extends Command | ||
| 67 | ->groupBy('month')->get()->toArray(); | 77 | ->groupBy('month')->get()->toArray(); |
| 68 | foreach ($list as $k=>$v){ | 78 | foreach ($list as $k=>$v){ |
| 69 | $v = (array)$v; | 79 | $v = (array)$v; |
| 70 | - if($v['month'] == date('Y-m')){ | ||
| 71 | - continue; | ||
| 72 | - } | 80 | + $arr = []; |
| 73 | $monthCountModel = new MonthCount(); | 81 | $monthCountModel = new MonthCount(); |
| 74 | $info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]); | 82 | $info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]); |
| 75 | // 获取当月开始时间 | 83 | // 获取当月开始时间 |
| @@ -78,7 +86,7 @@ class UpgradeCount extends Command | @@ -78,7 +86,7 @@ class UpgradeCount extends Command | ||
| 78 | $end = date('Y-m-t', strtotime($v['month'])); | 86 | $end = date('Y-m-t', strtotime($v['month'])); |
| 79 | $arr['project_id'] = $project_id; | 87 | $arr['project_id'] = $project_id; |
| 80 | $res = $this->inquiry($url,$v['month']); | 88 | $res = $this->inquiry($url,$v['month']); |
| 81 | -// $arr['month_total'] = 0; | 89 | + $arr['total'] = $arr['month_total'] = 0; |
| 82 | if(isset($res['data']['count'])){ | 90 | if(isset($res['data']['count'])){ |
| 83 | echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL; | 91 | echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL; |
| 84 | $arr['month_total'] = $res['data']['count']; | 92 | $arr['month_total'] = $res['data']['count']; |
| @@ -91,9 +99,21 @@ class UpgradeCount extends Command | @@ -91,9 +99,21 @@ class UpgradeCount extends Command | ||
| 91 | $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0); | 99 | $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0); |
| 92 | } | 100 | } |
| 93 | } | 101 | } |
| 102 | + //获取当月的其他询盘 | ||
| 103 | + $arr['total'] += InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']); | ||
| 104 | + $country = []; | ||
| 94 | if(isset($res['data']['data'])){ | 105 | if(isset($res['data']['data'])){ |
| 95 | - $arr['country'] = json_encode($res['data']['data']); | 106 | + $country = $res['data']['data']; |
| 107 | + } | ||
| 108 | + $countryData = InquiryFormData::getCountryCount([$start.' 00:00:00',$end.' 00:00:00']); | ||
| 109 | + foreach ($countryData as $v1){ | ||
| 110 | + if(isset($country[$v1['country']])){ | ||
| 111 | + $country[$v1['country']] += $v1['count']; | ||
| 112 | + }else{ | ||
| 113 | + $country[$v1['country']] = $v1['count']; | ||
| 114 | + } | ||
| 96 | } | 115 | } |
| 116 | + $arr['country'] = json_encode($country); | ||
| 97 | $arr['month'] = $v['month']; | 117 | $arr['month'] = $v['month']; |
| 98 | $arr = $this->pv_ip($arr,$start,$end,$project_id); | 118 | $arr = $this->pv_ip($arr,$start,$end,$project_id); |
| 99 | $arr = $this->sourceCount($arr,$start,$end); | 119 | $arr = $this->sourceCount($arr,$start,$end); |
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * @remark : | 3 | * @remark : |
| 4 | - * @name :UpgradeProjectCount.php | 4 | + * @name :CountProject.php |
| 5 | * @author :lyh | 5 | * @author :lyh |
| 6 | * @method :post | 6 | * @method :post |
| 7 | * @time :2024/1/8 9:03 | 7 | * @time :2024/1/8 9:03 |
| @@ -11,6 +11,7 @@ namespace App\Console\Commands\MonthlyCount; | @@ -11,6 +11,7 @@ namespace App\Console\Commands\MonthlyCount; | ||
| 11 | 11 | ||
| 12 | use App\Models\Com\UpdateOldInfo; | 12 | use App\Models\Com\UpdateOldInfo; |
| 13 | use App\Models\Domain\DomainInfo; | 13 | use App\Models\Domain\DomainInfo; |
| 14 | +use App\Models\Inquiry\InquiryFormData; | ||
| 14 | use App\Models\Project\Project; | 15 | use App\Models\Project\Project; |
| 15 | use App\Services\ProjectServer; | 16 | use App\Services\ProjectServer; |
| 16 | use Illuminate\Console\Command; | 17 | use Illuminate\Console\Command; |
| @@ -98,44 +99,57 @@ class MonthCount extends Command | @@ -98,44 +99,57 @@ class MonthCount extends Command | ||
| 98 | * @time :2024/1/8 9:05 | 99 | * @time :2024/1/8 9:05 |
| 99 | */ | 100 | */ |
| 100 | public function count($project_id,$url){ | 101 | public function count($project_id,$url){ |
| 101 | - $v = ['month'=>date('Y-m')]; | ||
| 102 | - $monthCountModel = new MonthCountModel(); | ||
| 103 | - $info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]); | ||
| 104 | - // 获取当月开始时间 | ||
| 105 | - $start = date('Y-m-01', strtotime($v['month'])); | ||
| 106 | - // 获取当月结束时间 | ||
| 107 | - $end = date('Y-m-t', strtotime($v['month'])); | ||
| 108 | - $arr['project_id'] = $project_id; | ||
| 109 | - $res = $this->inquiry($url,$v['month']); | ||
| 110 | -// $arr['month_total'] = 0; | ||
| 111 | - if(isset($res['data']['count'])){ | ||
| 112 | - echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL; | ||
| 113 | - $arr['month_total'] = $res['data']['count']; | ||
| 114 | - //获取上一个的count | ||
| 115 | - $previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month')); | ||
| 116 | - $previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]); | ||
| 117 | - if($previousInfo === false){ | ||
| 118 | - $arr['total'] = $arr['month_total']; | ||
| 119 | - }else{ | ||
| 120 | - $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0); | ||
| 121 | - } | ||
| 122 | - } | ||
| 123 | - if(isset($res['data']['data'])){ | ||
| 124 | - $arr['country'] = json_encode($res['data']['data']); | 102 | + $arr = []; |
| 103 | + $v = ['month'=>date('Y-m')]; | ||
| 104 | + $monthCountModel = new MonthCountModel(); | ||
| 105 | + $info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]); | ||
| 106 | + // 获取当月开始时间 | ||
| 107 | + $start = date('Y-m-01', strtotime($v['month'])); | ||
| 108 | + // 获取当月结束时间 | ||
| 109 | + $end = date('Y-m-t', strtotime($v['month'])); | ||
| 110 | + $arr['project_id'] = $project_id; | ||
| 111 | + $res = $this->inquiry($url,$v['month']); | ||
| 112 | + $arr['total'] = $arr['month_total'] = 0; | ||
| 113 | + if(isset($res['data']['count'])){ | ||
| 114 | + echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL; | ||
| 115 | + $arr['month_total'] = $res['data']['count']; | ||
| 116 | + //获取上一个的count | ||
| 117 | + $previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month')); | ||
| 118 | + $previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]); | ||
| 119 | + if($previousInfo === false){ | ||
| 120 | + $arr['total'] = $arr['month_total']; | ||
| 121 | + }else{ | ||
| 122 | + $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0); | ||
| 125 | } | 123 | } |
| 126 | - $arr['month'] = $v['month']; | ||
| 127 | - $arr = $this->pv_ip($arr,$start,$end,$project_id); | ||
| 128 | - $arr = $this->sourceCount($arr,$start,$end); | ||
| 129 | - if($info === false){ | ||
| 130 | - $selectedDate = $start; | ||
| 131 | - $firstDayOfNextMonth = date('Y-m-01 01:00:00', strtotime("$selectedDate +1 month")); | ||
| 132 | - $arr['created_at'] = $firstDayOfNextMonth; | ||
| 133 | - $arr['updated_at'] = $firstDayOfNextMonth; | ||
| 134 | -// echo date('Y-m-d H:i:s') . '数据:'.json_encode($arr) . PHP_EOL; | ||
| 135 | - $monthCountModel->insert($arr); | 124 | + } |
| 125 | + //获取当月的其他询盘 | ||
| 126 | + $arr['total'] += InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']); | ||
| 127 | + $country = []; | ||
| 128 | + if(isset($res['data']['data'])){ | ||
| 129 | + $country = $res['data']['data']; | ||
| 130 | + } | ||
| 131 | + $countryData = InquiryFormData::getCountryCount([$start.' 00:00:00',$end.' 00:00:00']); | ||
| 132 | + foreach ($countryData as $v1){ | ||
| 133 | + if(isset($country[$v1['country']])){ | ||
| 134 | + $country[$v1['country']] += $v1['count']; | ||
| 136 | }else{ | 135 | }else{ |
| 137 | - $monthCountModel->edit($arr,['id'=>$info['id']]); | 136 | + $country[$v1['country']] = $v1['count']; |
| 138 | } | 137 | } |
| 138 | + } | ||
| 139 | + $arr['country'] = json_encode($country); | ||
| 140 | + $arr['month'] = $v['month']; | ||
| 141 | + $arr = $this->pv_ip($arr,$start,$end,$project_id); | ||
| 142 | + $arr = $this->sourceCount($arr,$start,$end); | ||
| 143 | + if($info === false){ | ||
| 144 | + $selectedDate = $start; | ||
| 145 | + $firstDayOfNextMonth = date('Y-m-01 01:00:00', strtotime("$selectedDate +1 month")); | ||
| 146 | + $arr['created_at'] = $firstDayOfNextMonth; | ||
| 147 | + $arr['updated_at'] = $firstDayOfNextMonth; | ||
| 148 | +// echo date('Y-m-d H:i:s') . '数据:'.json_encode($arr) . PHP_EOL; | ||
| 149 | + $monthCountModel->insert($arr); | ||
| 150 | + }else{ | ||
| 151 | + $monthCountModel->edit($arr,['id'=>$info['id']]); | ||
| 152 | + } | ||
| 139 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | 153 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; |
| 140 | } | 154 | } |
| 141 | 155 |
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * @remark : | 3 | * @remark : |
| 4 | - * @name :UpgradeProjectCount.php | 4 | + * @name :CountProject.php |
| 5 | * @author :lyh | 5 | * @author :lyh |
| 6 | * @method :post | 6 | * @method :post |
| 7 | * @time :2024/1/8 9:03 | 7 | * @time :2024/1/8 9:03 |
| @@ -13,6 +13,7 @@ use App\Helper\FormGlobalsoApi; | @@ -13,6 +13,7 @@ use App\Helper\FormGlobalsoApi; | ||
| 13 | use App\Models\Com\UpdateOldInfo; | 13 | use App\Models\Com\UpdateOldInfo; |
| 14 | use App\Models\Domain\DomainInfo; | 14 | use App\Models\Domain\DomainInfo; |
| 15 | use App\Models\HomeCount\MonthCount; | 15 | use App\Models\HomeCount\MonthCount; |
| 16 | +use App\Models\Inquiry\InquiryFormData; | ||
| 16 | use App\Models\Project\Project; | 17 | use App\Models\Project\Project; |
| 17 | use App\Models\Visit\Visit; | 18 | use App\Models\Visit\Visit; |
| 18 | use App\Services\ProjectServer; | 19 | use App\Services\ProjectServer; |
| @@ -20,14 +21,14 @@ use Illuminate\Console\Command; | @@ -20,14 +21,14 @@ use Illuminate\Console\Command; | ||
| 20 | use Illuminate\Support\Facades\DB; | 21 | use Illuminate\Support\Facades\DB; |
| 21 | use App\Models\HomeCount\Count; | 22 | use App\Models\HomeCount\Count; |
| 22 | 23 | ||
| 23 | -class UpgradeProjectCount extends Command | 24 | +class MonthProjectCount extends Command |
| 24 | { | 25 | { |
| 25 | /** | 26 | /** |
| 26 | * The name and signature of the console command. | 27 | * The name and signature of the console command. |
| 27 | * | 28 | * |
| 28 | * @var string | 29 | * @var string |
| 29 | */ | 30 | */ |
| 30 | - protected $signature = 'upgrade_month_count {project_id}'; | 31 | + protected $signature = 'month_project {project_id}'; |
| 31 | 32 | ||
| 32 | /** | 33 | /** |
| 33 | * The console command description. | 34 | * The console command description. |
| @@ -64,10 +65,8 @@ class UpgradeProjectCount extends Command | @@ -64,10 +65,8 @@ class UpgradeProjectCount extends Command | ||
| 64 | ->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month')) | 65 | ->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month')) |
| 65 | ->groupBy('month')->get()->toArray(); | 66 | ->groupBy('month')->get()->toArray(); |
| 66 | foreach ($list as $k=>$v){ | 67 | foreach ($list as $k=>$v){ |
| 68 | + $arr = []; | ||
| 67 | $v = (array)$v; | 69 | $v = (array)$v; |
| 68 | - if($v['month'] == date('Y-m')){ | ||
| 69 | - continue; | ||
| 70 | - } | ||
| 71 | $monthCountModel = new MonthCount(); | 70 | $monthCountModel = new MonthCount(); |
| 72 | $info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]); | 71 | $info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]); |
| 73 | // 获取当月开始时间 | 72 | // 获取当月开始时间 |
| @@ -76,7 +75,7 @@ class UpgradeProjectCount extends Command | @@ -76,7 +75,7 @@ class UpgradeProjectCount extends Command | ||
| 76 | $end = date('Y-m-t', strtotime($v['month'])); | 75 | $end = date('Y-m-t', strtotime($v['month'])); |
| 77 | $arr['project_id'] = $project_id; | 76 | $arr['project_id'] = $project_id; |
| 78 | $res = $this->inquiry($url,$v['month']); | 77 | $res = $this->inquiry($url,$v['month']); |
| 79 | -// $arr['month_total'] = 0; | 78 | + $arr['total'] = $arr['month_total'] = 0; |
| 80 | if(isset($res['data']['count'])){ | 79 | if(isset($res['data']['count'])){ |
| 81 | echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL; | 80 | echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL; |
| 82 | $arr['month_total'] = $res['data']['count']; | 81 | $arr['month_total'] = $res['data']['count']; |
| @@ -89,9 +88,21 @@ class UpgradeProjectCount extends Command | @@ -89,9 +88,21 @@ class UpgradeProjectCount extends Command | ||
| 89 | $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0); | 88 | $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0); |
| 90 | } | 89 | } |
| 91 | } | 90 | } |
| 91 | + //获取当月的其他询盘 | ||
| 92 | + $arr['total'] += InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']); | ||
| 93 | + $country = []; | ||
| 92 | if(isset($res['data']['data'])){ | 94 | if(isset($res['data']['data'])){ |
| 93 | - $arr['country'] = json_encode($res['data']['data']); | 95 | + $country = $res['data']['data']; |
| 96 | + } | ||
| 97 | + $countryData = InquiryFormData::getCountryCount([$start.' 00:00:00',$end.' 00:00:00']); | ||
| 98 | + foreach ($countryData as $v1){ | ||
| 99 | + if(isset($country[$v1['country']])){ | ||
| 100 | + $country[$v1['country']] += $v1['count']; | ||
| 101 | + }else{ | ||
| 102 | + $country[$v1['country']] = $v1['count']; | ||
| 103 | + } | ||
| 94 | } | 104 | } |
| 105 | + $arr['country'] = json_encode($country); | ||
| 95 | $arr['month'] = $v['month']; | 106 | $arr['month'] = $v['month']; |
| 96 | $arr = $this->pv_ip($arr,$start,$end,$project_id); | 107 | $arr = $this->pv_ip($arr,$start,$end,$project_id); |
| 97 | $arr = $this->sourceCount($arr,$start,$end); | 108 | $arr = $this->sourceCount($arr,$start,$end); |
| @@ -13,6 +13,7 @@ use App\Models\Com\KeywordVideoTaskLog; | @@ -13,6 +13,7 @@ use App\Models\Com\KeywordVideoTaskLog; | ||
| 13 | use App\Models\Domain\DomainInfo; | 13 | use App\Models\Domain\DomainInfo; |
| 14 | use Illuminate\Console\Command; | 14 | use Illuminate\Console\Command; |
| 15 | use Illuminate\Support\Facades\DB; | 15 | use Illuminate\Support\Facades\DB; |
| 16 | +use Illuminate\Support\Facades\Log; | ||
| 16 | 17 | ||
| 17 | /** | 18 | /** |
| 18 | * @remark :通知C端生成界面 | 19 | * @remark :通知C端生成界面 |
| @@ -65,6 +66,7 @@ class Notice extends Command | @@ -65,6 +66,7 @@ class Notice extends Command | ||
| 65 | } | 66 | } |
| 66 | foreach ($domainList as $v1){ | 67 | foreach ($domainList as $v1){ |
| 67 | //TODO::通知C端 | 68 | //TODO::通知C端 |
| 69 | + @file_put_contents(storage_path('logs/notice_c_'.date('Y-m-d').'.log'), var_export($v1['domain'], true) . PHP_EOL, FILE_APPEND); | ||
| 68 | $this->curlDelRoute($v1['domain'],$v1['project_id']); | 70 | $this->curlDelRoute($v1['domain'],$v1['project_id']); |
| 69 | } | 71 | } |
| 70 | return true; | 72 | return true; |
| @@ -51,19 +51,12 @@ class RecommendedSuppliers extends Command | @@ -51,19 +51,12 @@ class RecommendedSuppliers extends Command | ||
| 51 | { | 51 | { |
| 52 | $projectModel = new DeployBuild(); | 52 | $projectModel = new DeployBuild(); |
| 53 | $project_list = $projectModel->list(['is_supplier'=>1]);//TODO::已开启推荐供应商 | 53 | $project_list = $projectModel->list(['is_supplier'=>1]);//TODO::已开启推荐供应商 |
| 54 | - foreach ($project_list as $k => $v){ | 54 | + foreach ($project_list as $v){ |
| 55 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['project_id'] . PHP_EOL; | 55 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['project_id'] . PHP_EOL; |
| 56 | ProjectServer::useProject($v['project_id']); | 56 | ProjectServer::useProject($v['project_id']); |
| 57 | - $info = Keyword::inRandomOrder()->first(); | ||
| 58 | - if(empty($info)){ | ||
| 59 | - continue; | ||
| 60 | - } | ||
| 61 | - $keywordInfo = $this->getPurchaser($info->title,$v['project_id']); | ||
| 62 | - if($keywordInfo !== false){ | ||
| 63 | - continue; | ||
| 64 | - } | 57 | + $title = $this->getKeywords($v['project_id']); |
| 65 | echo date('Y-m-d H:i:s') . '开始:'.$v['project_id'] . PHP_EOL; | 58 | echo date('Y-m-d H:i:s') . '开始:'.$v['project_id'] . PHP_EOL; |
| 66 | - $this->savePurchaser($v['project_id'],$info->title); | 59 | + $this->savePurchaser($v['project_id'],$title); |
| 67 | DB::disconnect('custom_mysql'); | 60 | DB::disconnect('custom_mysql'); |
| 68 | } | 61 | } |
| 69 | return true; | 62 | return true; |
| @@ -122,6 +115,8 @@ class RecommendedSuppliers extends Command | @@ -122,6 +115,8 @@ class RecommendedSuppliers extends Command | ||
| 122 | * @time :2024/7/1 18:07 | 115 | * @time :2024/7/1 18:07 |
| 123 | */ | 116 | */ |
| 124 | public function getKeywords($project_id){ | 117 | public function getKeywords($project_id){ |
| 118 | + $keywordModel = new Keyword(); | ||
| 119 | + $keywordModel-> | ||
| 125 | $info = Keyword::inRandomOrder()->first(); | 120 | $info = Keyword::inRandomOrder()->first(); |
| 126 | $keywordInfo = $this->getPurchaser($info->title,$project_id); | 121 | $keywordInfo = $this->getPurchaser($info->title,$project_id); |
| 127 | if($keywordInfo !== false){ | 122 | if($keywordInfo !== false){ |
| @@ -28,23 +28,15 @@ class SyncSubmitTask extends Command | @@ -28,23 +28,15 @@ class SyncSubmitTask extends Command | ||
| 28 | 28 | ||
| 29 | public function handle() | 29 | public function handle() |
| 30 | { | 30 | { |
| 31 | - $backup = false; | ||
| 32 | while (true) { | 31 | while (true) { |
| 33 | - $task_id = $this->getTaskId(); | ||
| 34 | - if ($task_id > 2000000) { | ||
| 35 | - $backup = true; | ||
| 36 | - } | ||
| 37 | - if (empty($task_id)) { | ||
| 38 | - if ($backup) { | ||
| 39 | - $this->backup(); | ||
| 40 | - $backup = false; | ||
| 41 | - } | ||
| 42 | - sleep(5); | 32 | + $task_id = Redis::rpop('sync_submit_task'); |
| 33 | + if(!$task_id){ | ||
| 34 | + sleep(3); | ||
| 43 | continue; | 35 | continue; |
| 44 | } | 36 | } |
| 45 | $this->output('任务' . $task_id . '开始'); | 37 | $this->output('任务' . $task_id . '开始'); |
| 46 | $task_info = SyncSubmitTaskModel::find($task_id); | 38 | $task_info = SyncSubmitTaskModel::find($task_id); |
| 47 | - if (empty($task_info) || $task_info->status) { | 39 | + if (empty($task_info) || $task_info->status !=3) { |
| 48 | $this->output('任务不存在或者已执行'); | 40 | $this->output('任务不存在或者已执行'); |
| 49 | continue; | 41 | continue; |
| 50 | } | 42 | } |
| @@ -79,29 +71,6 @@ class SyncSubmitTask extends Command | @@ -79,29 +71,6 @@ class SyncSubmitTask extends Command | ||
| 79 | } | 71 | } |
| 80 | } | 72 | } |
| 81 | 73 | ||
| 82 | - public function getTaskId() | ||
| 83 | - { | ||
| 84 | - $task_id = Redis::rpop('sync_submit_task'); | ||
| 85 | - $lockKey = 'lock_sync_submit_task'; | ||
| 86 | - if (empty($task_id)) { | ||
| 87 | - // 获取锁 | ||
| 88 | - if (Redis::setnx($lockKey, 1)) { | ||
| 89 | - // 设置锁的过期时间,防止死锁 | ||
| 90 | - Redis::expire($lockKey, 10); | ||
| 91 | - $ids = SyncSubmitTaskModel::where('status', 0)->limit(100)->pluck('id'); | ||
| 92 | - foreach ($ids as $id) { | ||
| 93 | - Redis::lpush('sync_submit_task', $id); | ||
| 94 | - } | ||
| 95 | - $task_id = Redis::rpop('sync_submit_task'); | ||
| 96 | - Redis::del($lockKey); | ||
| 97 | - } else { | ||
| 98 | - // 未获取到锁 | ||
| 99 | - return ''; | ||
| 100 | - } | ||
| 101 | - } | ||
| 102 | - return $task_id; | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | /** | 74 | /** |
| 106 | * 输出处理日志 | 75 | * 输出处理日志 |
| 107 | */ | 76 | */ |
| @@ -110,31 +79,4 @@ class SyncSubmitTask extends Command | @@ -110,31 +79,4 @@ class SyncSubmitTask extends Command | ||
| 110 | echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; | 79 | echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; |
| 111 | return true; | 80 | return true; |
| 112 | } | 81 | } |
| 113 | - | ||
| 114 | - /** | ||
| 115 | - * 备份数据 | ||
| 116 | - * @author zbj | ||
| 117 | - * @date 2024/1/23 | ||
| 118 | - */ | ||
| 119 | - public function backup() | ||
| 120 | - { | ||
| 121 | - DB::beginTransaction(); | ||
| 122 | - try { | ||
| 123 | - $table = (new SyncSubmitTaskModel())->getTable(); | ||
| 124 | - $new_table = $table . '_backup_' . date('Ymd'); | ||
| 125 | - | ||
| 126 | - //重命名当前表 | ||
| 127 | - Schema::rename($table, $new_table); | ||
| 128 | - //克隆表数据 | ||
| 129 | - DB::statement('CREATE TABLE ' . $table . ' LIKE ' . $new_table); | ||
| 130 | - | ||
| 131 | - DB::commit(); | ||
| 132 | - | ||
| 133 | - $this->output('数据备份成功'); | ||
| 134 | - } catch (\Exception $e) { | ||
| 135 | - $this->output('数据备份失败' . $e->getMessage()); | ||
| 136 | - DB::rollBack(); | ||
| 137 | - } | ||
| 138 | - return true; | ||
| 139 | - } | ||
| 140 | } | 82 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\Sync; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Exceptions\InquiryFilterException; | ||
| 7 | +use App\Models\Project\Project; | ||
| 8 | +use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel; | ||
| 9 | +use App\Services\SyncSubmitTaskService; | ||
| 10 | +use Illuminate\Console\Command; | ||
| 11 | +use Illuminate\Support\Facades\Cache; | ||
| 12 | +use Illuminate\Support\Facades\DB; | ||
| 13 | +use Illuminate\Support\Facades\Redis; | ||
| 14 | +use Illuminate\Support\Facades\Schema; | ||
| 15 | +use Illuminate\Support\Str; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * | ||
| 19 | + * Class SyncSubmitTask | ||
| 20 | + * @package App\Console\Commands | ||
| 21 | + * @author zbj | ||
| 22 | + * @date 2023/11/28 | ||
| 23 | + */ | ||
| 24 | +class SyncSubmitTaskDistribution extends Command | ||
| 25 | +{ | ||
| 26 | + | ||
| 27 | + protected $signature = 'sync_submit_task_distribution'; | ||
| 28 | + protected $description = '询盘、访问异步任务分发'; | ||
| 29 | + | ||
| 30 | + public function handle() | ||
| 31 | + { | ||
| 32 | + while (true) { | ||
| 33 | + $len = Redis::llen('sync_submit_task'); | ||
| 34 | + if (!$len) { | ||
| 35 | + $max_id = SyncSubmitTaskModel::orderBy('id', 'desc')->value('id'); | ||
| 36 | + if ($max_id > 2000000) { | ||
| 37 | + $this->backup(); | ||
| 38 | + } else { | ||
| 39 | + $tasks = SyncSubmitTaskModel::where('status', 0)->limit(100)->get(); | ||
| 40 | + foreach ($tasks as $task) { | ||
| 41 | + $task->status = 3; | ||
| 42 | + $task->save(); | ||
| 43 | + Redis::lpush('sync_submit_task', $task->id); | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + sleep(3); | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 输出处理日志 | ||
| 53 | + */ | ||
| 54 | + public function output($message): bool | ||
| 55 | + { | ||
| 56 | + echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; | ||
| 57 | + return true; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * 备份数据 | ||
| 62 | + * @author zbj | ||
| 63 | + * @date 2024/1/23 | ||
| 64 | + */ | ||
| 65 | + public function backup() | ||
| 66 | + { | ||
| 67 | + DB::beginTransaction(); | ||
| 68 | + try { | ||
| 69 | + $table = (new SyncSubmitTaskModel())->getTable(); | ||
| 70 | + $new_table = $table . '_backup_' . date('Ymd'); | ||
| 71 | + | ||
| 72 | + //重命名当前表 | ||
| 73 | + Schema::rename($table, $new_table); | ||
| 74 | + //克隆表数据 | ||
| 75 | + DB::statement('CREATE TABLE ' . $table . ' LIKE ' . $new_table); | ||
| 76 | + | ||
| 77 | + //未入队的写到新表 | ||
| 78 | + $list = DB::table($new_table)->where('status', 0)->get(); | ||
| 79 | + $data = []; | ||
| 80 | + foreach ($list as $task) { | ||
| 81 | + $data[] = [ | ||
| 82 | + 'type' => $task->type, | ||
| 83 | + 'data' => json_encode($task->data), | ||
| 84 | + 'created_at' => $task['created_at'], | ||
| 85 | + 'updated_at' => $task['updated_at'], | ||
| 86 | + ]; | ||
| 87 | + } | ||
| 88 | + $data && SyncSubmitTaskModel::insert($data); | ||
| 89 | + | ||
| 90 | + DB::commit(); | ||
| 91 | + | ||
| 92 | + $this->output('数据备份成功'); | ||
| 93 | + } catch (\Exception $e) { | ||
| 94 | + $this->output('数据备份失败' . $e->getMessage()); | ||
| 95 | + DB::rollBack(); | ||
| 96 | + } | ||
| 97 | + return $new_table ?? ''; | ||
| 98 | + } | ||
| 99 | +} |
| @@ -54,12 +54,13 @@ class UpdateRoute extends Command | @@ -54,12 +54,13 @@ class UpdateRoute extends Command | ||
| 54 | */ | 54 | */ |
| 55 | public function handle(){ | 55 | public function handle(){ |
| 56 | $projectModel = new Project(); | 56 | $projectModel = new Project(); |
| 57 | - $list = $projectModel->list(['id'=>['in',[1085]]]); | 57 | + $list = $projectModel->list(['id'=>['in',[664]]]); |
| 58 | $data = []; | 58 | $data = []; |
| 59 | foreach ($list as $v){ | 59 | foreach ($list as $v){ |
| 60 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | 60 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; |
| 61 | ProjectServer::useProject($v['id']); | 61 | ProjectServer::useProject($v['id']); |
| 62 | $this->getProduct(); | 62 | $this->getProduct(); |
| 63 | +// $this->setProductKeyword(); | ||
| 63 | DB::disconnect('custom_mysql'); | 64 | DB::disconnect('custom_mysql'); |
| 64 | } | 65 | } |
| 65 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | 66 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; |
| @@ -106,19 +107,8 @@ class UpdateRoute extends Command | @@ -106,19 +107,8 @@ class UpdateRoute extends Command | ||
| 106 | if(!empty($lists)){ | 107 | if(!empty($lists)){ |
| 107 | foreach ($lists as $v){ | 108 | foreach ($lists as $v){ |
| 108 | if(!empty($v['route'])){ | 109 | if(!empty($v['route'])){ |
| 109 | -// $tag = "-tag"; | ||
| 110 | -// if ((substr($v['route'], -strlen($tag)) === $tag)) { | ||
| 111 | -// echo date('Y-m-d H:i:s') . '拼接 :'.$v['id'] . PHP_EOL; | ||
| 112 | -// $route = Translate::tran($v['route'], 'en').$tag; | ||
| 113 | -// // 如果不是以 '-tag' 结尾,则拼接上 '-tag' | ||
| 114 | -// $route = trim($v['route'],'-tag'); | ||
| 115 | -// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']); | ||
| 116 | -// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 117 | -// }else{ | ||
| 118 | -// $route = Translate::tran($v['title'], 'en').$tag; | ||
| 119 | -// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']); | ||
| 120 | -// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]); | ||
| 121 | -// } | 110 | + echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL; |
| 111 | + continue; | ||
| 122 | }else{ | 112 | }else{ |
| 123 | echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL; | 113 | echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL; |
| 124 | $route = Translate::tran($v['title'], 'en'); | 114 | $route = Translate::tran($v['title'], 'en'); |
| @@ -128,7 +118,6 @@ class UpdateRoute extends Command | @@ -128,7 +118,6 @@ class UpdateRoute extends Command | ||
| 128 | $keywordModel->edit(['route'=>$route],['id'=>$v['id']]); | 118 | $keywordModel->edit(['route'=>$route],['id'=>$v['id']]); |
| 129 | } | 119 | } |
| 130 | } | 120 | } |
| 131 | - echo date('Y-m-d H:i:s') . 'end :' . PHP_EOL; | ||
| 132 | } | 121 | } |
| 133 | } | 122 | } |
| 134 | } | 123 | } |
| @@ -224,7 +213,7 @@ class UpdateRoute extends Command | @@ -224,7 +213,7 @@ class UpdateRoute extends Command | ||
| 224 | 213 | ||
| 225 | public function getProduct(){ | 214 | public function getProduct(){ |
| 226 | $productModel = new Product(); | 215 | $productModel = new Product(); |
| 227 | - $lists = $productModel->list(['status'=>1]); | 216 | + $lists = $productModel->list(['status'=>1,'id'=>['<=',501]]); |
| 228 | if(!empty($lists)){ | 217 | if(!empty($lists)){ |
| 229 | foreach ($lists as $v){ | 218 | foreach ($lists as $v){ |
| 230 | if(!empty($v['route'])){ | 219 | if(!empty($v['route'])){ |
| @@ -240,9 +229,10 @@ class UpdateRoute extends Command | @@ -240,9 +229,10 @@ class UpdateRoute extends Command | ||
| 240 | // $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | 229 | // $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); |
| 241 | // $productModel->edit(['route'=>$route],['id'=>$v['id']]); | 230 | // $productModel->edit(['route'=>$route],['id'=>$v['id']]); |
| 242 | } | 231 | } |
| 232 | + continue; | ||
| 243 | }else{ | 233 | }else{ |
| 244 | echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; | 234 | echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; |
| 245 | -// $v['title'] = Translate::tran($v['title'], 'en'); | 235 | + $v['title'] = Translate::tran($v['title'], 'en'); |
| 246 | $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); | 236 | $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); |
| 247 | $productModel->edit(['route'=>$route],['id'=>$v['id']]); | 237 | $productModel->edit(['route'=>$route],['id'=>$v['id']]); |
| 248 | } | 238 | } |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :UpdateKeyword.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/7/3 9:23 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\Update; | ||
| 11 | + | ||
| 12 | +use App\Models\Domain\DomainInfo; | ||
| 13 | +use App\Models\Product\Keyword; | ||
| 14 | +use App\Models\Product\KeywordPage; | ||
| 15 | +use App\Services\ProjectServer; | ||
| 16 | +use Illuminate\Console\Command; | ||
| 17 | +use Illuminate\Support\Facades\DB; | ||
| 18 | + | ||
| 19 | +class UpdateKeyword extends Command | ||
| 20 | +{ | ||
| 21 | + /** | ||
| 22 | + * The name and signature of the console command. | ||
| 23 | + * | ||
| 24 | + * @var string | ||
| 25 | + */ | ||
| 26 | + protected $signature = 'update_keyword_content'; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * The console command description. | ||
| 30 | + * | ||
| 31 | + * @var string | ||
| 32 | + */ | ||
| 33 | + protected $description = '批量更新关键词内容'; | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + public function handle(){ | ||
| 37 | + while (true){ | ||
| 38 | + $keywordPageModel = new KeywordPage(); | ||
| 39 | + $lists = $keywordPageModel->list(['status'=>0]); | ||
| 40 | + if(empty($lists)){ | ||
| 41 | + sleep(100); | ||
| 42 | + continue; | ||
| 43 | + } | ||
| 44 | + $domainModel = new DomainInfo(); | ||
| 45 | + foreach ($lists as $v){ | ||
| 46 | + ProjectServer::useProject($v['project_id']); | ||
| 47 | + $this->saveKeywordContent($v); | ||
| 48 | + DB::disconnect('custom_mysql'); | ||
| 49 | + //获取当前项目的域名 | ||
| 50 | + $domainInfo = $domainModel->read(['project_id'=>$v['project_id']]); | ||
| 51 | + if($domainInfo !== false){ | ||
| 52 | + $this->curlDelRoute($domainInfo['domain'],$v['project_id']); | ||
| 53 | + } | ||
| 54 | + $keywordPageModel->edit(['status'=>1],['id'=>$v['id']]); | ||
| 55 | + } | ||
| 56 | + sleep(10); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * @remark :更新关键词内容 | ||
| 63 | + * @name :saveKeywordContent | ||
| 64 | + * @author :lyh | ||
| 65 | + * @method :post | ||
| 66 | + * @time :2024/7/3 10:25 | ||
| 67 | + */ | ||
| 68 | + public function saveKeywordContent($info){ | ||
| 69 | + $keywordModel = new Keyword(); | ||
| 70 | + $updateObject = json_decode($info['update_object'],true); | ||
| 71 | + $text = json_decode($info['text'],true); | ||
| 72 | + if(empty($text)){ | ||
| 73 | + return false; | ||
| 74 | + } | ||
| 75 | + $number = count($text); | ||
| 76 | + $randomNumber = rand(0, $number - 1); | ||
| 77 | + if($updateObject['type'] == 0){//更新所有关键字 | ||
| 78 | + $keywordModel->edit(['keyword_content'=>$text[$randomNumber]],['status'=>1]); | ||
| 79 | + }else{ | ||
| 80 | + //按传递的关键字更新 | ||
| 81 | + if(!empty($updateObject['keyword'])){ | ||
| 82 | + $updateObject['keyword'] = (array)$updateObject['keyword']; | ||
| 83 | + $keywordModel->edit(['keyword_content'=>$text[$randomNumber]],['title'=>['in',$updateObject['keyword']]]); | ||
| 84 | + } | ||
| 85 | + //按给定的数量更新 | ||
| 86 | + if(!empty($updateObject['number']) && ($updateObject['number'] != 0)){ | ||
| 87 | + $keywordIdArr = $keywordModel->where("status",1)->inRandomOrder()->take($updateObject['number'])->pluck('id')->toArray(); | ||
| 88 | + $keywordModel->edit(['keyword_content'=>$text[$randomNumber]],['id'=>['in',$keywordIdArr]]); | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + return true; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * @remark :删除路由通知C端 | ||
| 96 | + * @name :curlDelRoute | ||
| 97 | + * @author :lyh | ||
| 98 | + * @method :post | ||
| 99 | + * @time :2023/11/30 14:43 | ||
| 100 | + */ | ||
| 101 | + public function curlDelRoute($domain,$project_id){ | ||
| 102 | + if (strpos($domain, 'https://') === false) { | ||
| 103 | + $domain = 'https://' . $domain . '/'; | ||
| 104 | + } | ||
| 105 | + $url = $domain.'api/update_page/?project_id='.$project_id.'&route=4'; | ||
| 106 | + shell_exec('curl -k "'.$url.'"'); | ||
| 107 | + return true; | ||
| 108 | + } | ||
| 109 | +} |
| @@ -48,6 +48,8 @@ class Kernel extends ConsoleKernel | @@ -48,6 +48,8 @@ class Kernel extends ConsoleKernel | ||
| 48 | $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次 | 48 | $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次 |
| 49 | $schedule->command('update_keyword_route')->dailyAt('01:00')->withoutOverlapping(1); //升级项目--清除路由相同的关键字 | 49 | $schedule->command('update_keyword_route')->dailyAt('01:00')->withoutOverlapping(1); //升级项目--清除路由相同的关键字 |
| 50 | $schedule->command('recommended_suppliers')->dailyAt('03:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商 | 50 | $schedule->command('recommended_suppliers')->dailyAt('03:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商 |
| 51 | + | ||
| 52 | + $schedule->command('update_keyword_content')->hourly()->withoutOverlapping(1); | ||
| 51 | // 每日推送视频任务 | 53 | // 每日推送视频任务 |
| 52 | $schedule->command('video_task')->hourly()->withoutOverlapping(1); | 54 | $schedule->command('video_task')->hourly()->withoutOverlapping(1); |
| 53 | // 每日推送已完成视频任务项目生成对应界面 | 55 | // 每日推送已完成视频任务项目生成对应界面 |
| @@ -42,7 +42,7 @@ class AutoTaskController extends BaseController | @@ -42,7 +42,7 @@ class AutoTaskController extends BaseController | ||
| 42 | $where['status'] = $status - 1; | 42 | $where['status'] = $status - 1; |
| 43 | $result = Notify::select(['id','project_id', 'type', 'data', 'status', 'route', 'num', 'updated_at', 'created_at']) | 43 | $result = Notify::select(['id','project_id', 'type', 'data', 'status', 'route', 'num', 'updated_at', 'created_at']) |
| 44 | ->where('id', '>', 84000) // 查询有效数据 | 44 | ->where('id', '>', 84000) // 查询有效数据 |
| 45 | - ->where('server_id', '<>', 9) // 过滤测试环境数据 | 45 | + ->where('server_id', '<>', 7) // 过滤测试环境数据 |
| 46 | ->where('server_id', '>', 0) // 过滤测试环境数据 | 46 | ->where('server_id', '>', 0) // 过滤测试环境数据 |
| 47 | ->where($where) | 47 | ->where($where) |
| 48 | ->orderBy('id', 'desc') | 48 | ->orderBy('id', 'desc') |
| @@ -99,4 +99,4 @@ class AutoTaskController extends BaseController | @@ -99,4 +99,4 @@ class AutoTaskController extends BaseController | ||
| 99 | ]; | 99 | ]; |
| 100 | return $this->response('success', Code::SUCCESS, $result); | 100 | return $this->response('success', Code::SUCCESS, $result); |
| 101 | } | 101 | } |
| 102 | -} | ||
| 102 | +} |
| @@ -16,6 +16,7 @@ use App\Models\Com\Notify; | @@ -16,6 +16,7 @@ use App\Models\Com\Notify; | ||
| 16 | use App\Models\Com\UpdateNotify; | 16 | use App\Models\Com\UpdateNotify; |
| 17 | use App\Models\Com\UpdateProgress; | 17 | use App\Models\Com\UpdateProgress; |
| 18 | use App\Models\Devops\ServerConfig; | 18 | use App\Models\Devops\ServerConfig; |
| 19 | +use App\Models\Devops\ServersIp; | ||
| 19 | use App\Models\Domain\DomainInfo; | 20 | use App\Models\Domain\DomainInfo; |
| 20 | use App\Models\Project\Country as CountryModel; | 21 | use App\Models\Project\Country as CountryModel; |
| 21 | use App\Models\Project\Project; | 22 | use App\Models\Project\Project; |
| @@ -51,8 +52,14 @@ class CNoticeController extends BaseController | @@ -51,8 +52,14 @@ class CNoticeController extends BaseController | ||
| 51 | //获取项目所在服务器 | 52 | //获取项目所在服务器 |
| 52 | $project_model = new Project(); | 53 | $project_model = new Project(); |
| 53 | $project_info = $project_model->read(['id'=>$project_id],['serve_id']); | 54 | $project_info = $project_model->read(['id'=>$project_id],['serve_id']); |
| 55 | + if(!$project_info){ | ||
| 56 | + $this->fail('未查询到项目数据'); | ||
| 57 | + } | ||
| 58 | + $serve_ip_model = new ServersIp(); | ||
| 59 | + $serve_ip_info = $serve_ip_model->read(['id'=>$project_info['serve_id']],['servers_id']); | ||
| 60 | + $servers_id = $serve_ip_info ? $serve_ip_info['servers_id'] : 0; | ||
| 54 | 61 | ||
| 55 | - if($project_info && $project_info['serve_id'] == ServerConfig::SELF_SITE_ID){ | 62 | + if($servers_id == ServerConfig::SELF_SITE_ID){ |
| 56 | //自建站服务器:如果项目已经上线,不请求C端接口,数据直接入库 | 63 | //自建站服务器:如果项目已经上线,不请求C端接口,数据直接入库 |
| 57 | $domain_model = new DomainInfo(); | 64 | $domain_model = new DomainInfo(); |
| 58 | $domain_info = $domain_model->read(['project_id'=>$this->user['project_id']],['domain']); | 65 | $domain_info = $domain_model->read(['project_id'=>$this->user['project_id']],['domain']); |
| @@ -312,13 +312,13 @@ class ComController extends BaseController | @@ -312,13 +312,13 @@ class ComController extends BaseController | ||
| 312 | public function getMobileProject(){ | 312 | public function getMobileProject(){ |
| 313 | $data = []; | 313 | $data = []; |
| 314 | $userModel = new User(); | 314 | $userModel = new User(); |
| 315 | - $list = $userModel->list(['mobile'=>$this->user['mobile'],'project_id'=>['!=',$this->user['project_id']]],'id',['id','project_id']); | ||
| 316 | - if(!empty($list)){ | 315 | + $project_id = $userModel->formatQuery(['mobile'=>$this->user['mobile'],'project_id'=>['!=',$this->user['project_id']]])->pluck('project_id')->toArray(); |
| 316 | + if(!empty($project_id)){ | ||
| 317 | $projectModel = new Project(); | 317 | $projectModel = new Project(); |
| 318 | - foreach ($list as $k => $v){ | ||
| 319 | - $projectInfo = $projectModel->read(['id'=>$v['project_id']],['id','company']); | 318 | + $list = $projectModel->list(['id'=>['in',$project_id],'delete_status'=>0],'id',['id','company']); |
| 319 | + foreach ($list as $v){ | ||
| 320 | //获取当前项目详情 | 320 | //获取当前项目详情 |
| 321 | - $data[] = ['project_id'=>$projectInfo['id'],'company'=>$projectInfo['company']]; | 321 | + $data[] = ['project_id'=>$v['id'],'company'=>$v['company']]; |
| 322 | } | 322 | } |
| 323 | } | 323 | } |
| 324 | //登录选择项目的有效时间 | 324 | //登录选择项目的有效时间 |
| @@ -7,7 +7,9 @@ use App\Helper\Arr; | @@ -7,7 +7,9 @@ use App\Helper\Arr; | ||
| 7 | use App\Http\Controllers\Bside\BaseController; | 7 | use App\Http\Controllers\Bside\BaseController; |
| 8 | use App\Http\Logic\Bside\Product\KeywordLogic; | 8 | use App\Http\Logic\Bside\Product\KeywordLogic; |
| 9 | use App\Http\Requests\Bside\Product\KeywordRequest; | 9 | use App\Http\Requests\Bside\Product\KeywordRequest; |
| 10 | +use App\Models\Com\NoticeLog; | ||
| 10 | use App\Models\Product\Keyword; | 11 | use App\Models\Product\Keyword; |
| 12 | +use App\Models\Product\KeywordPage; | ||
| 11 | use App\Models\Product\KeywordRelated; | 13 | use App\Models\Product\KeywordRelated; |
| 12 | use App\Models\Product\Product; | 14 | use App\Models\Product\Product; |
| 13 | use App\Models\RouteMap\RouteMap; | 15 | use App\Models\RouteMap\RouteMap; |
| @@ -232,4 +234,30 @@ class KeywordController extends BaseController | @@ -232,4 +234,30 @@ class KeywordController extends BaseController | ||
| 232 | } | 234 | } |
| 233 | $this->response('success'); | 235 | $this->response('success'); |
| 234 | } | 236 | } |
| 237 | + | ||
| 238 | + /** | ||
| 239 | + * @remark :批量提交更新关键词 | ||
| 240 | + * @name :batchUpdateKeyword | ||
| 241 | + * @author :lyh | ||
| 242 | + * @method :post | ||
| 243 | + * @time :2024/7/2 10:14 | ||
| 244 | + */ | ||
| 245 | + public function batchUpdateKeyword(){ | ||
| 246 | + $this->request->validate([ | ||
| 247 | + 'text'=>'required|array', | ||
| 248 | + 'update_object'=>'required|array', | ||
| 249 | + 'update_method'=>'required' | ||
| 250 | + ],[ | ||
| 251 | + 'text.required' => '文件内容不能为空', | ||
| 252 | + 'update_object.required' => '更新对象不为空', | ||
| 253 | + 'update_object.array' => '更新对象为数组', | ||
| 254 | + 'update_method.required' => '请求方式不为空' | ||
| 255 | + ]); | ||
| 256 | + $keywordPageModel = new KeywordPage(); | ||
| 257 | + $this->param['text'] = json_encode($this->param['text']); | ||
| 258 | + $this->param['update_object'] = json_encode($this->param['update_object']); | ||
| 259 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 260 | + $id = $keywordPageModel->addReturnId($this->param); | ||
| 261 | + $this->response('success',Code::SUCCESS,['id'=>$id]); | ||
| 262 | + } | ||
| 235 | } | 263 | } |
| @@ -268,10 +268,10 @@ class DomainInfoLogic extends BaseLogic | @@ -268,10 +268,10 @@ class DomainInfoLogic extends BaseLogic | ||
| 268 | $serverModel = new Servers(); | 268 | $serverModel = new Servers(); |
| 269 | $serverInfo = $serverModel->read(['id'=>$serversIpInfo['servers_id']],['init_domain']); | 269 | $serverInfo = $serverModel->read(['id'=>$serversIpInfo['servers_id']],['init_domain']); |
| 270 | $server_info = ['domain'=>$serverInfo['init_domain'],'ip'=>$serversIpInfo['ip']]; | 270 | $server_info = ['domain'=>$serverInfo['init_domain'],'ip'=>$serversIpInfo['ip']]; |
| 271 | - if($project_info['serve_id'] == 9){ | 271 | + if($serversIpInfo['servers_id'] == 7){ |
| 272 | $this->fail('请切换服务器,生成站点不能使用测试服务器'); | 272 | $this->fail('请切换服务器,生成站点不能使用测试服务器'); |
| 273 | } | 273 | } |
| 274 | - if($project_info['serve_id'] == ServerConfig::SELF_SITE_ID){ | 274 | + if($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID){ |
| 275 | $this->model->edit(['amp_status' => $this->param['amp_status'] ?? 0,],['id'=>$this->param['id']]); | 275 | $this->model->edit(['amp_status' => $this->param['amp_status'] ?? 0,],['id'=>$this->param['id']]); |
| 276 | $this->fail('自建站服务器无法生成站点'); | 276 | $this->fail('自建站服务器无法生成站点'); |
| 277 | } | 277 | } |
| @@ -303,8 +303,8 @@ class DomainInfoLogic extends BaseLogic | @@ -303,8 +303,8 @@ class DomainInfoLogic extends BaseLogic | ||
| 303 | 303 | ||
| 304 | //保存301跳转数据+其他域名 | 304 | //保存301跳转数据+其他域名 |
| 305 | $data = [ | 305 | $data = [ |
| 306 | - 'other_domain'=>json_encode($this->param['other_domain'] ?? []), | ||
| 307 | - 'extend_config'=>json_encode($this->param['extend_config'] ?? []), | 306 | + 'other_domain'=>json_encode(array_filter($this->param['other_domain'] ?? [])), |
| 307 | + 'extend_config'=>json_encode(array_filter($this->param['extend_config'] ?? [])), | ||
| 308 | 'type'=>$this->param['type'], | 308 | 'type'=>$this->param['type'], |
| 309 | 'private_key' => $this->param['key'] ?? '', | 309 | 'private_key' => $this->param['key'] ?? '', |
| 310 | 'private_cert' => $this->param['cert'] ?? '', | 310 | 'private_cert' => $this->param['cert'] ?? '', |
| @@ -313,8 +313,8 @@ class DomainInfoLogic extends BaseLogic | @@ -313,8 +313,8 @@ class DomainInfoLogic extends BaseLogic | ||
| 313 | 'amp_type' => $this->param['amp_type'] ?? 0, | 313 | 'amp_type' => $this->param['amp_type'] ?? 0, |
| 314 | 'amp_private_key' => $this->param['amp_key'] ?? '', | 314 | 'amp_private_key' => $this->param['amp_key'] ?? '', |
| 315 | 'amp_private_cert' => $this->param['amp_cert'] ?? '', | 315 | 'amp_private_cert' => $this->param['amp_cert'] ?? '', |
| 316 | - 'not_allow_country'=>json_encode($this->param['not_allow_country'] ?? []), | ||
| 317 | - 'not_allow_ip'=>json_encode($this->param['not_allow_ip'] ?? []), | 316 | + 'not_allow_country'=>json_encode(array_filter($this->param['not_allow_country'] ?? [])), |
| 317 | + 'not_allow_ip'=>json_encode(array_filter($this->param['not_allow_ip'] ?? [])), | ||
| 318 | ]; | 318 | ]; |
| 319 | $this->model->edit($data,['id'=>$this->param['id']]); | 319 | $this->model->edit($data,['id'=>$this->param['id']]); |
| 320 | //主站生成证书 | 320 | //主站生成证书 |
| @@ -391,6 +391,12 @@ class DomainInfoLogic extends BaseLogic | @@ -391,6 +391,12 @@ class DomainInfoLogic extends BaseLogic | ||
| 391 | $serverModel = new Servers(); | 391 | $serverModel = new Servers(); |
| 392 | $serverInfo = $serverModel->read(['id'=>$serversIpInfo['servers_id']],['init_domain']); | 392 | $serverInfo = $serverModel->read(['id'=>$serversIpInfo['servers_id']],['init_domain']); |
| 393 | $server_info = ['domain'=>$serverInfo['init_domain'],'ip'=>$serversIpInfo['ip']]; | 393 | $server_info = ['domain'=>$serverInfo['init_domain'],'ip'=>$serversIpInfo['ip']]; |
| 394 | + if($serversIpInfo['servers_id'] == 7){ | ||
| 395 | + $this->fail('请切换服务器,生成站点不能使用测试服务器'); | ||
| 396 | + } | ||
| 397 | + if($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID){ | ||
| 398 | + $this->fail('自建站服务器无法生成站点'); | ||
| 399 | + } | ||
| 394 | //域名是否都已经解析 | 400 | //域名是否都已经解析 |
| 395 | if(strpos($this->param['custom_domain'],'//') === false){ | 401 | if(strpos($this->param['custom_domain'],'//') === false){ |
| 396 | $this->param['custom_domain'] = '//'.$this->param['custom_domain']; | 402 | $this->param['custom_domain'] = '//'.$this->param['custom_domain']; |
| @@ -148,7 +148,7 @@ class ProjectLogic extends BaseLogic | @@ -148,7 +148,7 @@ class ProjectLogic extends BaseLogic | ||
| 148 | //初始化项目 | 148 | //初始化项目 |
| 149 | $this->createProjectData($this->param); | 149 | $this->createProjectData($this->param); |
| 150 | //双向绑定服务器,需放到保存项目的上方 | 150 | //双向绑定服务器,需放到保存项目的上方 |
| 151 | - $this->setServers($this->param['serve_id'],$this->param['id']); | 151 | + $this->setServers($this->param['serve_id'] ?? 0,$this->param['id']); |
| 152 | //保存项目信息 | 152 | //保存项目信息 |
| 153 | $this->saveProject($this->param); | 153 | $this->saveProject($this->param); |
| 154 | //保存建站部署信息 | 154 | //保存建站部署信息 |
| @@ -192,6 +192,9 @@ class ProjectLogic extends BaseLogic | @@ -192,6 +192,9 @@ class ProjectLogic extends BaseLogic | ||
| 192 | $serversModel->where(['id'=>$oldServerIpInfo['servers_id']])->decrement('being_number',1); | 192 | $serversModel->where(['id'=>$oldServerIpInfo['servers_id']])->decrement('being_number',1); |
| 193 | } | 193 | } |
| 194 | } | 194 | } |
| 195 | + if(empty($servers_id)){ | ||
| 196 | + return $this->success(); | ||
| 197 | + } | ||
| 195 | $serversIpInfo = $serversIpModel->read(['id'=>$servers_id]); | 198 | $serversIpInfo = $serversIpModel->read(['id'=>$servers_id]); |
| 196 | $serversInfo = $serversModel->read(['id'=>$serversIpInfo['servers_id']]); | 199 | $serversInfo = $serversModel->read(['id'=>$serversIpInfo['servers_id']]); |
| 197 | if($serversIpInfo['total'] >= $serversInfo['ip_total']){ | 200 | if($serversIpInfo['total'] >= $serversInfo['ip_total']){ |
| @@ -124,11 +124,11 @@ class ATemplateLogic extends BaseLogic | @@ -124,11 +124,11 @@ class ATemplateLogic extends BaseLogic | ||
| 124 | if(!empty($info['image'])){ | 124 | if(!empty($info['image'])){ |
| 125 | $info['image_link'] = getImageUrl($info['image']); | 125 | $info['image_link'] = getImageUrl($info['image']); |
| 126 | } | 126 | } |
| 127 | - if(!empty($info['design_manager'])){ | ||
| 128 | - $info['design_manager'] = (new Manage())->getName($info['design_manager']); | 127 | + if(!empty($info['design_msg'])){ |
| 128 | + $info['design_msg'] = json_decode($info['design_msg']); | ||
| 129 | } | 129 | } |
| 130 | - if(!empty($info['front_manager'])){ | ||
| 131 | - $info['front_manager'] = (new Manage())->getName($info['front_manager']); | 130 | + if(!empty($info['front_msg'])){ |
| 131 | + $info['front_msg'] = json_decode($info['front_msg']); | ||
| 132 | } | 132 | } |
| 133 | return $this->success($info); | 133 | return $this->success($info); |
| 134 | } | 134 | } |
| @@ -261,15 +261,11 @@ class ATemplateLogic extends BaseLogic | @@ -261,15 +261,11 @@ class ATemplateLogic extends BaseLogic | ||
| 261 | */ | 261 | */ |
| 262 | public function auditingStatus(){ | 262 | public function auditingStatus(){ |
| 263 | //获取当前数据详情 | 263 | //获取当前数据详情 |
| 264 | - $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 265 | - if(isset($this->param['front_status']) && $this->param['front_status'] == 1){ | ||
| 266 | - if($info['design_status'] == 0){ | ||
| 267 | - $this->fail('请先提交设计审核'); | ||
| 268 | - } | ||
| 269 | - $this->param['design_manager'] = $this->manager['id']; | ||
| 270 | - $this->param['test_model'] = 0; | ||
| 271 | - }else{ | ||
| 272 | - $this->param['front_manager'] = $this->manager['id']; | 264 | + if(isset($this->param['design_msg']) && !empty($this->param['design_msg'])){ |
| 265 | + $this->param['design_msg'] = json_encode($this->param['design_msg']); | ||
| 266 | + } | ||
| 267 | + if(isset($this->param['front_msg']) && !empty($this->param['front_msg'])){ | ||
| 268 | + $this->param['front_msg'] = json_encode($this->param['front_msg']); | ||
| 273 | } | 269 | } |
| 274 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 270 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 275 | if($rs === false){ | 271 | if($rs === false){ |
| @@ -8,6 +8,7 @@ use App\Exceptions\BsideGlobalException; | @@ -8,6 +8,7 @@ use App\Exceptions\BsideGlobalException; | ||
| 8 | use App\Http\Logic\Logic; | 8 | use App\Http\Logic\Logic; |
| 9 | use App\Models\Com\UpdateNotify; | 9 | use App\Models\Com\UpdateNotify; |
| 10 | use App\Models\Devops\ServerConfig; | 10 | use App\Models\Devops\ServerConfig; |
| 11 | +use App\Models\Devops\ServersIp; | ||
| 11 | use App\Models\Project\Project; | 12 | use App\Models\Project\Project; |
| 12 | use App\Models\RouteMap\RouteDelete; | 13 | use App\Models\RouteMap\RouteDelete; |
| 13 | use App\Models\Service\Service; | 14 | use App\Models\Service\Service; |
| @@ -175,11 +176,13 @@ class BaseLogic extends Logic | @@ -175,11 +176,13 @@ class BaseLogic extends Logic | ||
| 175 | $data['project_id'] = $this->user['project_id']; | 176 | $data['project_id'] = $this->user['project_id']; |
| 176 | $str = http_build_query($data); | 177 | $str = http_build_query($data); |
| 177 | $url = $this->user['domain'].'api/delHtml/?'.$str; | 178 | $url = $this->user['domain'].'api/delHtml/?'.$str; |
| 178 | - if(isset($this->project['serve_id']) && ($this->project['serve_id'] == ServerConfig::SELF_SITE_ID)){ | 179 | + $serverIpModel = new ServersIp(); |
| 180 | + $serversIpInfo = $serverIpModel->read(['id'=>$this->project['serve_id']],['servers_id']); | ||
| 181 | + if($serversIpInfo && ($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID)){ | ||
| 179 | //自建站服务器直接返回 | 182 | //自建站服务器直接返回 |
| 180 | return $this->success(); | 183 | return $this->success(); |
| 181 | } | 184 | } |
| 182 | - if(isset($this->project['serve_id']) && ($this->project['serve_id'] != 1)){//TODO::当前项目通知不过 ,跳过自动更新 | 185 | + if($serversIpInfo && ($serversIpInfo['servers_id'] != 1)){//TODO::当前项目通知不过 ,跳过自动更新 |
| 183 | exec('curl -k "'.$url.'" > /dev/null 2>&1 &'); | 186 | exec('curl -k "'.$url.'" > /dev/null 2>&1 &'); |
| 184 | }else{ | 187 | }else{ |
| 185 | shell_exec('curl -k "'.$url.'"'); | 188 | shell_exec('curl -k "'.$url.'"'); |
| @@ -34,7 +34,7 @@ class ServerConfig extends Base | @@ -34,7 +34,7 @@ class ServerConfig extends Base | ||
| 34 | 34 | ||
| 35 | const STATUS_ONE = 1; | 35 | const STATUS_ONE = 1; |
| 36 | 36 | ||
| 37 | - const SELF_SITE_ID = 8;//自建站服务器ID | 37 | + const SELF_SITE_ID = 6;//自建站服务器ID |
| 38 | 38 | ||
| 39 | /** | 39 | /** |
| 40 | * @remark :获取数据用户名解密 | 40 | * @remark :获取数据用户名解密 |
| @@ -15,7 +15,6 @@ use App\Utils\EncryptUtils; | @@ -15,7 +15,6 @@ use App\Utils\EncryptUtils; | ||
| 15 | class Servers extends Base | 15 | class Servers extends Base |
| 16 | { | 16 | { |
| 17 | protected $table = 'gl_servers'; | 17 | protected $table = 'gl_servers'; |
| 18 | - const SELF_SITE_ID = 8;//自建站服务器ID | ||
| 19 | 18 | ||
| 20 | /** | 19 | /** |
| 21 | * @remark :获取数据用户名解密 | 20 | * @remark :获取数据用户名解密 |
app/Models/Product/KeywordPage.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :KeywordPage.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/7/2 15:26 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Product; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class KeywordPage extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_product_keyword_page'; | ||
| 17 | +} |
| @@ -133,6 +133,9 @@ class SyncSubmitTaskService | @@ -133,6 +133,9 @@ class SyncSubmitTaskService | ||
| 133 | $visit_data['updated_date'] = $data['submit_at']->toDateString(); | 133 | $visit_data['updated_date'] = $data['submit_at']->toDateString(); |
| 134 | $visit_data['created_at'] = $data['submit_at']; | 134 | $visit_data['created_at'] = $data['submit_at']; |
| 135 | $visit_data['user_agent'] = $data['user_agent']; | 135 | $visit_data['user_agent'] = $data['user_agent']; |
| 136 | + if(!empty($data['is_cf'])){ | ||
| 137 | + $visit_data['is_inquiry'] = 1; | ||
| 138 | + } | ||
| 136 | Visit::saveData($visit_data, $date); | 139 | Visit::saveData($visit_data, $date); |
| 137 | 140 | ||
| 138 | return true; | 141 | return true; |
| @@ -271,6 +271,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -271,6 +271,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 271 | Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd'); | 271 | Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd'); |
| 272 | Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel'); | 272 | Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel'); |
| 273 | Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete'); | 273 | Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete'); |
| 274 | + Route::any('keyword/batchUpdateKeyword', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchUpdateKeyword'])->name('product_keyword_batchUpdateKeyword'); | ||
| 274 | Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo'); | 275 | Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo'); |
| 275 | Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled'); | 276 | Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled'); |
| 276 | //产品参数 | 277 | //产品参数 |
-
请 注册 或 登录 后发表评论