作者 周海龙

合并分支 'develop' 到 'master'

Develop



查看合并请求 !11
正在显示 65 个修改的文件 包含 2354 行增加638 行删除

要显示太多修改。

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

... ... @@ -4,12 +4,15 @@ namespace App\Console\Commands\DayCount;
use App\Helper\Common;
use App\Helper\FormGlobalsoApi;
use App\Models\Domain\DomainInfo;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class Count extends Command
{
... ... @@ -28,6 +31,7 @@ class Count extends Command
* @var string
*/
protected $description = '统计昨日数据';
/**
* @name :(定时执行生成昨日数据统计)handle
* @author :lyh
... ... @@ -39,25 +43,37 @@ class Count extends Command
$list = DB::table('gl_project')->where('gl_project.extend_type','!=',5)
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->select($this->selectParam())->get()->toArray();
->select($this->selectParam())->get();
try {
if(!empty($list)){
$list = $list->toArray();
$data = [];
$yesterday = Carbon::yesterday()->toDateString();
$domainInfo = new DomainInfo();
foreach ($list as $v){
$v = (array)$v;
if($v['domain'] != ''){
$v['test_domain'] = $v['domain'];
if($v['type'] == Project::TYPE_ZERO){
continue;
}
if(!empty($v['domain'])){
$info = $domainInfo->read(['id'=>$v['domain']]);
if($info !== false){
$v['test_domain'] = $info['domain'];
}
}
$arr = [];
//统计时间
$arr['date'] = $yesterday;
ProjectServer::useProject($v['id']);
//pv统计
$arr['pv_num'] = $this->pv_num($yesterday,$v['test_domain']);
//ip统计
$arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']);
DB::disconnect('custom_mysql');
//服务达标天数
$arr['compliance_day'] = $this->compliance_day($v['test_domain']);
$arr['compliance_day'] = $this->compliance_day($v['id']);
//剩余服务时常
$arr['service_day'] = ((int)$v['service_duration'] - (int)$arr['compliance_day']) > 0 ? ((int)$v['service_duration'] - (int)$arr['compliance_day']) : 0;
$arr['service_day'] = $v['remain_day'];
//项目id
$arr['project_id'] = $v['project_id'];
$arr['created_at'] = date('Y-m-d H:i:s');
... ... @@ -68,6 +84,10 @@ class Count extends Command
}
//判断数据是否存在
DB::table('gl_count')->insert($data);
}
}catch (\Exception $e){
Log::error('同步数据执行失败');
}
echo $this->error;
}
... ... @@ -78,7 +98,7 @@ class Count extends Command
* @time :2023/6/14 15:40
*/
public function pv_num($yesterday,$domain){
$pv = DB::table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
return $pv;
}
... ... @@ -89,7 +109,7 @@ class Count extends Command
* @time :2023/6/14 15:40
*/
public function ip_num($yesterday,$domain){
$ip = DB::table('gl_customer_visit')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
$ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->where('domain',$domain)->count();
return $ip;
}
... ... @@ -150,8 +170,10 @@ class Count extends Command
*/
public function selectParam(){
$select = [
'gl_project.id AS user_id',
'gl_project.id AS id',
'gl_project.type AS type',
'gl_project.extend_type AS extend_type',
'gl_project.remain_day AS remain_day',
'gl_project_deploy_build.test_domain AS test_domain',
'gl_project_deploy_optimize.domain AS domain',
'gl_project_deploy_build.project_id AS project_id',
... ...
... ... @@ -38,7 +38,7 @@ class InquiryDelay extends Command
{
$inquiryInfoModel = new InquiryInfo();
$param = $inquiryInfoModel->formatQuery(['status'=>$inquiryInfoModel::STATUS_FOUR])->orderBy('send_time','asc')->first();
if($param !== false){
if(!empty($param)){
$time = date('Y-m-d H:i:s');
if($time >= $param['send_time']){
$data = [];
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Console\Commands;
use App\Models\Devops\DevopsTaskLog;
use App\Models\Project\Project;
use App\Utils\EncryptUtils;
use Illuminate\Console\Command;
use App\Models\Devops\DevopsTask as DevopsTaskModel;
... ... @@ -45,17 +46,14 @@ class DevopsTask extends Command
*/
public function handle()
{
while (true){
$tasks = DevopsTaskModel::where('status', DevopsTaskModel::STATUS_PENDING)->get();
foreach ($tasks as $task){
echo "Start task " . $task->id . PHP_EOL;
echo "Start task " . $task->id;
if($task->type == DevopsTaskModel::TYPE_MYSQL){
$this->updateTable($task);
}
echo "End task " . $task->id . PHP_EOL;
}
sleep(10);
}
}
public function updateTable($task){
... ... @@ -64,6 +62,7 @@ class DevopsTask extends Command
echo "project " . $project->id;
$log = DevopsTaskLog::addLog($task->id, $project->id);
if($log->status == DevopsTaskModel::STATUS_ACTIVE){
echo 'continue' . PHP_EOL;
continue;
}
if(!$project->mysqlConfig){
... ... @@ -73,6 +72,7 @@ class DevopsTask extends Command
continue;
}
//DB类是单例模式,生命周期内修改配置不会生效
try {
$conn = new \mysqli(
$project->mysqlConfig->host,
$project->mysqlConfig->user,
... ... @@ -80,6 +80,13 @@ class DevopsTask extends Command
$project->databaseName(),
$project->mysqlConfig->port,
);
}catch (\Exception $e){
$log->remark = mb_substr('数据库连接失败:' . $e->getMessage(), 0, 500);
$log->status = DevopsTaskLog::STATUS_ERROR;
$log->save();
echo '-->' . $log->remark . PHP_EOL;
continue;
}
$res = $conn->query($task->sql);
$log->status = $res ? DevopsTaskLog::STATUS_ACTIVE : DevopsTaskLog::STATUS_ERROR;
... ...
<?php
/**
* @remark :
* @name :DomainInfo.php
* @author :lyh
* @method :post
* @time :2023/9/11 14:37
*/
namespace App\Console\Commands\Domain;
use Illuminate\Console\Command;
use App\Models\Domain\DomainInfo as DomainInfoModel;
class DomainInfo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'domain_info';
/**
* The console command description.
*
* @var string
*/
protected $description = '域名相关';
/**
* @remark :更新证书+证书有效时间
* @name :handle
* @author :lyh
* @method :post
* @time :2023/9/11 15:09
*/
public function handle(){
$domainModel = new DomainInfoModel();
$map = ['status'=>['!=',2]];
$list = $domainModel->list($map);
foreach ($list as $v){
$ssl = $this->updateDomainSsl($v['domain']);
$time = $this->updateDomain($v['domain']);
$data = [
'certificate_start_time'=>$ssl['from'],
'certificate_end_time'=>$ssl['to'],
'domain_start_time'=>$time['start'],
'domain_end_time'=>$time['end']
];
$domainModel->edit($data,['id'=>$v['id']]);
}
return 1;
}
/**
* @remark :更新域名证书
* @name :updateDomainSsl
* @author :lyh
* @method :post
* @time :2023/9/11 15:07
*/
public function updateDomainSsl($domain){
try {
$context = stream_context_create([
'ssl' => [
'capture_peer_cert' => true,
'capture_peer_cert_chain' => false,
],
]);
$stream = stream_socket_client('ssl://'.$domain.':443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
if(!$stream) {
die("Failed to connect: $errno - $errstr");
}
$remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
if(!$remote_cert) {
die("Failed to retrieve certificate");
}
$valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
$valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
fclose($stream);
}catch (\Exception $e){
$valid_from = date('Y-m-d H:i:s');
$valid_to = date('Y-m-d H:i:s');
}
return ['from'=>$valid_from,'to'=>$valid_to];
}
/**
* @remark :更新域名有限时间
* @name :updateDomain
* @author :lyh
* @method :post
* @time :2023/9/11 15:11
*/
public function updateDomain($domain){
$url = 'http://openai.waimaoq.com/v1/whois_api?domain='.$domain;
$response = http_get($url);
$start = '';
$end = '';
if($response['code'] == 200){
$start = $response['text']['creation_date'];
$end = $response['text']['expiration_date'];
}
return ['start'=>$start,'end'=>$end];
}
}
... ...
... ... @@ -43,8 +43,13 @@ class ImportManager extends Command
$info = $model->read(['type'=>5]);
$values = json_decode($info['values']);
$values = array_reverse($values);
$hrModel = new ManageHr();
foreach ($values as $k => $v){
$v = (array)$v;
$info = $hrModel->read(['mobile'=>$v['mobile']]);
if($info !== false){
continue;
}
$data = [
'name'=>$v['name'],
'mobile'=>$v['mobile'],
... ... @@ -97,22 +102,26 @@ class ImportManager extends Command
if($entry_position !== false){
$entry_position = $entry_position['id'];
}else{
$entry_position = '';
$entry_position = 0;
}
//获取级别
$jobLevelModel = new JobLevel();
if(!empty($v['p_level'])){
$p_level = $jobLevelModel->read(['name'=>$v['p_level']]);
if($entry_position !== false){
if($p_level !== false){
$p_level = $p_level['id'];
}else{
$p_level = '';
$p_level = 0;
}
}else{
$p_level = 0;
}
$manager_data = [
'manage_id'=>$manager_id ?? '',
'manage_id'=>$manager_id,
'name'=>$v['name'],
'id_card'=>$v['id_card'],
'mobile'=>$v['mobile'],
'birthday'=>$v['birthday'],
'birthday'=>!empty($v['birthday']) ? $v['birthday'] : date('Y-m-d'),
'address'=>$v['address'],
'sex'=>$v['sex'],
'nationality'=>$v['nationality'],
... ... @@ -121,7 +130,7 @@ class ImportManager extends Command
'major'=>$v['major'],
'graduate_school'=>$v['graduate_school'],
'english_level'=>$v['english_level'],
'entry_position'=>$entry_position,
'entry_position'=>$entry_position ?? 0,
'p_level'=>$p_level,
'residential_address'=>$v['residential_address'],
'emergency_contact'=>$v['emergency_contact'],
... ... @@ -134,12 +143,11 @@ class ImportManager extends Command
'dangyuan'=>$v['dangyuan'],
'dangzhibu'=>$v['dangzhibu'],
'dang_address'=>$v['dang_address'],
'join_date'=>$v['join_date'],
'status'=>($v['status'] == '在职') ? 1 : 2,
'join_date'=>!empty($v['join_date']) ? $v['join_date'] : date('Y-m-d'),
'status'=> 1,
'computer_account'=>$v['computer_account'],
'qq_account'=>$v['qq_account']
];
$hrModel = new ManageHr();
$hrModel->add($manager_data);
}
return 1;
... ...
<?php
namespace App\Console\Commands;
use App\Helper\Arr;
use App\Helper\FormGlobalsoApi;
use App\Http\Logic\Bside\InquiryLogic;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Models\RankData\RankData as GoogleRankModel;
use App\Models\RouteMap\RouteMap;
use GuzzleHttp\Client;
use GuzzleHttp\Promise\Utils;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
/**
* 最近一次询盘
* Class InquiryList
* @package App\Console\Commands
* @author zbj
* @date 2023/9/11
*/
class LastInquiry extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'last_inquiry';
/**
* The console command description.
*
* @var string
*/
protected $description = '询盘列表';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @return bool
*/
public function handle()
{
$list = Project::with('deploy_optimize')->whereIn('type', [2,3,4])->get();
foreach ($list as $item){
if(empty($item['deploy_optimize']['domain'])){
continue;
}
$api = new FormGlobalsoApi();
$res = $api->getInquiryList($item['deploy_optimize']['domain']);
if($res && $res['status'] == 200){
if(empty($res['data']['data'][0])){
continue;
}
$item->last_inquiry_time = $res['data']['data'][0]['submit_time'];
$item->save();
}
}
}
}
... ...
... ... @@ -3,6 +3,9 @@
namespace App\Console\Commands\MonthlyCount;
use App\Helper\FormGlobalsoApi;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -41,16 +44,25 @@ class InquiryMonthlyCount extends Command
$startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();
// 获取上个月的结束时间
$endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();
$domainInfo = new DomainInfo();
foreach ($list as $value){
$value = (array)$value;
if($value['domain'] != ''){
if($value['type'] == Project::TYPE_ZERO){
continue;
}
if(!empty($value['domain'])){
$info = $domainInfo->read(['id'=>$value['domain']]);
if($info !== false){
$value['test_domain'] = $value['domain'];
}
}
$arr = [];
//按月统计询盘记录
$arr = $this->inquiryCount($arr,$startTime,$endTime,$value['test_domain']);
$arr = $this->flowCount($arr,$startTime,$endTime,$value['project_id']);
ProjectServer::useProject($value['project_id']);
$arr = $this->sourceCount($arr,$value['test_domain'],$startTime,$endTime);
DB::disconnect('custom_mysql');
$arr['created_at'] = date('Y-m-d H:i:s');
$arr['updated_at'] = date('Y-m-d H:i:s');
$arr['project_id'] = $value['project_id'];
... ... @@ -128,21 +140,21 @@ class InquiryMonthlyCount extends Command
*/
public function sourceCount(&$arr,$domain,$startTime,$endTime){
//访问来源前10
$source = DB::table('gl_customer_visit')
$source = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('referrer_url', DB::raw('COUNT(*) as count'))
->groupBy('referrer_url')->where(['domain'=>$domain])
->whereBetween('updated_date', [$startTime,$endTime])
->orderByDesc('count')->limit(10)->get()->toArray();
$arr['source'] = json_encode($source);
//访问国家前15
$source_country = DB::table('gl_customer_visit')
$source_country = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
->groupBy('country')->where(['domain'=>$domain])
->whereBetween('updated_date', [$startTime,$endTime])
->orderBy('ip','desc')->limit(15)->get()->toArray();
$arr['source_country'] = json_encode($source_country);
//受访界面前15
$referrer_url = DB::table('gl_customer_visit')
$referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('url',DB::raw('COUNT(*) as num'))
->orderBy('num','desc')->where(['domain'=>$domain])
->whereBetween('updated_date', [$startTime,$endTime])
... ... @@ -150,7 +162,7 @@ class InquiryMonthlyCount extends Command
->limit(15)->get()->toArray();
$arr['referrer_url'] = json_encode($referrer_url);
//访问端口
$referrer_port = DB::table('gl_customer_visit')
$referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('device_port',DB::raw('COUNT(*) as num'))
->orderBy('num','desc')->where(['domain'=>$domain])
->whereBetween('updated_date', [$startTime,$endTime])
... ... @@ -168,7 +180,8 @@ class InquiryMonthlyCount extends Command
*/
public function selectParam(){
$select = [
'gl_project.id AS user_id',
'gl_project.id AS id',
'gl_project.type AS type',
'gl_project.extend_type AS extend_type',
'gl_project_deploy_build.test_domain AS test_domain',
'gl_project_deploy_optimize.domain AS domain',
... ...
... ... @@ -6,6 +6,7 @@ use App\Helper\Arr;
use App\Helper\SemrushApi;
use App\Models\RankData\ExternalLinks as ExternalLinksModel;
use App\Models\Project\DeployOptimize;
use App\Utils\LogUtils;
/**
* Class ExternalLinks
... ... @@ -39,7 +40,7 @@ class ExternalLinks extends BaseCommands
$semrushApi = new SemrushApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
LogUtils::info('start rank_data_external_links:' . count($list));
foreach ($list as $project_id => $domain) {
if(!$domain){
continue;
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Console\Commands\RankData;
use App\Helper\QuanqiusouApi;
use App\Models\Project\DeployOptimize;
use App\Models\RankData\IndexedPages as IndexedPagesModel;
use App\Utils\LogUtils;
/**
* Class IndexedPages
... ... @@ -38,7 +39,7 @@ class IndexedPages extends BaseCommands
$api = new QuanqiusouApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray();
LogUtils::info('start rank_data_indexed_pages:' . count($list));
foreach ($list as $project_id => $api_no) {
$model = IndexedPagesModel::where('project_id', $project_id)->first();
if($model && $model->updated_date == getThisWeekStarDate()){
... ...
... ... @@ -6,7 +6,9 @@ use App\Helper\Arr;
use App\Helper\QuanqiusouApi;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Models\RankData\RankData as GoogleRankModel;
use App\Utils\LogUtils;
/**
* Class GoogleRank
... ... @@ -41,6 +43,7 @@ class RankData extends BaseCommands
$api = new QuanqiusouApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>' , 0)->select('api_no','minor_languages','project_id')->get();
LogUtils::info('start rank_data:' . count($list));
//当日所有站点谷歌收录数据
$site_res = $api->getSiteRes();
if(!$site_res){
... ... @@ -141,11 +144,14 @@ class RankData extends BaseCommands
}
//关键词达标天数
$model->is_compliance = 0;
if($model->updated_date != date('Y-m-d')){
//保证关键词数
$keyword_num = DeployBuild::where('project_id', $project_id)->value('keyword_num');
if($first_page_num >= $keyword_num){
$type = Project::where('id', $project_id)->value('type');
if($keyword_num && $type == 2 && $first_page_num >= $keyword_num){
$model->compliance_day = $model->compliance_day + 1;
$model->is_compliance = 1;
}
}
... ...
... ... @@ -7,6 +7,7 @@ use App\Helper\Arr;
use App\Helper\QuanqiusouApi;
use App\Models\Project\DeployOptimize;
use App\Models\RankData\RankWeek as RankWeekModel;
use App\Utils\LogUtils;
/**
* Class WeekRank
... ... @@ -49,7 +50,7 @@ class RankWeek extends BaseCommands
$res = Arr::s2a($res);
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray();
LogUtils::info('start rank_data_week:' . count($list));
foreach ($list as $project_id => $api_no) {
$rank_week = RankWeekModel::where('project_id', $project_id)->first();
if ($rank_week && $rank_week->updated_date == getThisWeekStarDate()) {
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Console\Commands\RankData;
use App\Helper\SemrushApi;
use App\Models\RankData\RecommDomain as RecommDomainModel;
use App\Models\Project\DeployOptimize;
use App\Utils\LogUtils;
/**
* Class RecommDomain
... ... @@ -38,7 +39,7 @@ class RecommDomain extends BaseCommands
$semrushApi = new SemrushApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
LogUtils::info('start rank_data_recomm_domain:' . count($list));
foreach ($list as $project_id => $domain) {
if(!$domain){
continue;
... ...
... ... @@ -6,6 +6,7 @@ use App\Helper\Arr;
use App\Helper\GoogleSpeedApi;
use App\Models\Project\DeployOptimize;
use App\Models\RankData\Speed as GoogleSpeedModel;
use App\Utils\LogUtils;
/**
* Class GoogleSpeed
... ... @@ -42,7 +43,7 @@ class Speed extends BaseCommands
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray();
LogUtils::info('start rank_data_speed:' . count($list));
foreach ($list as $project_id => $domain) {
$model = GoogleSpeedModel::where('project_id', $project_id)->first();
if ($model && $model->updated_date == getThisWeekStarDate()) {
... ...
<?php
namespace App\Console\Commands;
use App\Helper\Arr;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Models\RankData\RankData as GoogleRankModel;
use App\Models\RouteMap\RouteMap;
use GuzzleHttp\Client;
use GuzzleHttp\Promise\Utils;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
/**
* 剩余服务时长
* Class Traffic
* @package App\Console\Commands
* @author zbj
* @date 2023/5/18
*/
class RemainDay extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'remain_day';
/**
* The console command description.
*
* @var string
*/
protected $description = '网站服务剩余时长';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @return bool
*/
public function handle()
{
$list = Project::whereIn('type', [2,3,4])->get();
foreach ($list as $item){
if($item['type'] == 3){
//排名达标天数
$compliance_day = GoogleRankModel::where(['project_id' => $item['id'], 'lang' => ''])->value('compliance_day') ?: 0;
$remain_day = $item['deploy_build']['service_duration'] - $compliance_day;
}else{
//审核上线后开始
$check_time = OnlineCheck::where('project_id', $item['id'])->where('status', 1)->value('created_at') ?: '';
if(!$check_time){
$remain_day = $item['deploy_build']['service_duration'];
}else{
$diff = time() - strtotime($check_time);
$remain_day = floor($diff / (60 * 60 * 24));
}
}
$item->remain_day = $remain_day > 0 ? $remain_day : 0;
$item->save();
}
}
}
... ...
... ... @@ -16,6 +16,7 @@ use App\Models\Project\ProjectRenew;
use App\Utils\LogUtils;
use Hashids\Hashids;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
... ... @@ -57,6 +58,7 @@ class SyncProject extends Command
*/
public function handle()
{
while (true){
$list = NoticeLog::where('type', NoticeLog::TYPE_PROJECT)->where('status', NoticeLog::STATUS_PENDING)->get();
foreach ($list as $item){
try {
... ... @@ -88,6 +90,9 @@ class SyncProject extends Command
$this->retry($item);
}
}
sleep(2);
}
}
/**
... ... @@ -190,14 +195,10 @@ class SyncProject extends Command
'project_after' => [],
'payment' => [
'amount' => $param['plan_price'],
'contract'=>$param['files'],
'bill'=>$param['images']
],
];
if(!empty($param['files'])){
$data['payment']['contract'] = json_encode($param['files']);
}
if(!empty($param['images'])){
$data['payment']['bill'] = json_encode($param['images']);
}
DB::beginTransaction();
try {
$id = $this->saveProject($data['project']);
... ... @@ -209,7 +210,7 @@ class SyncProject extends Command
DB::commit();
}catch (\Exception $e){
DB::rollBack();
errorLog('项目同步失败', $data, $e);
throw new \Exception($e->getMessage());
}
}
... ... @@ -242,8 +243,14 @@ class SyncProject extends Command
$param['channel'] = Arr::a2s($param['channel']);
}
$projectModel = new Project();
$info = $projectModel->read(['from_order_id'=>$param['from_order_id'],'delete_status'=>0]);
if($info !== false){
$projectModel->edit($param, ['id' => $info['id']]);
return $info['id'];
}else{
return $projectModel->addReturnId($param);
}
}
/**
* 保存优化部署
... ... @@ -254,7 +261,12 @@ class SyncProject extends Command
$param['project_id'] = $id;
//查询数据是否存在
$afterModel = new After();
return $afterModel->add($param);
$info = $afterModel->read(['project_id'=>$id]);
if($info !== false){
$afterModel->edit($param,['id'=>$info['id']]);
}else{
$afterModel->add($param);
}
}
/**
... ... @@ -267,13 +279,18 @@ class SyncProject extends Command
protected function savePayment($param,$id){
$param['project_id'] = $id;
$paymentModel= new Payment();
if(isset($param['contract']) && !empty($param['contract'])){
// if(isset($param['contract']) && !empty($param['contract'])){
$param['contract'] = Arr::a2s($param['contract']);
}
if(isset($param['bill']) && !empty($param['bill'])){
// }
// if(isset($param['bill']) && !empty($param['bill'])){
$param['bill'] = Arr::a2s($param['bill']);
// }
$info = $paymentModel->read(['project_id'=>$id]);
if($info !== false){
$paymentModel->edit($param,['id'=>$info['id']]);
}else{
$paymentModel->add($param);
}
return $paymentModel->add($param);
}
/**
... ... @@ -289,7 +306,12 @@ class SyncProject extends Command
$code = $hashids->encode($id);
$param['test_domain'] = 'https://v6-' . $code . '.globalso.site/';
$deployBuildModel = new DeployBuild();
return $deployBuildModel->add($param);
$info = $deployBuildModel->read(['project_id'=>$id]);
if($info !== false){
$deployBuildModel->edit($param,['id'=>$info['id']]);
}else{
$deployBuildModel->add($param);
}
}
/**
... ... @@ -302,7 +324,12 @@ class SyncProject extends Command
protected function saveDeployOptimize($param,$id){
$param['project_id'] = $id;
$deployOptimizeModel = new DeployOptimize();
return $deployOptimizeModel->add($param);
$info = $deployOptimizeModel->read(['project_id'=>$id]);
if($info !== false){
$deployOptimizeModel->edit($param,['id'=>$info['id']]);
}else{
$deployOptimizeModel->add($param);
}
}
/**
... ... @@ -346,7 +373,7 @@ class SyncProject extends Command
* @date 2023/9/1
*/
protected function toHagro($data){
$url = 'https://beta.hagro.cn/globalso/create_project';
$url = 'https://admin.hagro.cn/globalso/create_project';
$param = [
'company' => $data['company_name'],
'phone' => $data['principal_mobile'],
... ...
... ... @@ -10,10 +10,15 @@ namespace App\Console\Commands\Test;
use App\Models\Blog\Blog;
use App\Models\Devops\ServerConfig;
use App\Models\File\Image;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\Dept;
use App\Models\Manage\EntryPosition;
use App\Models\Manage\ManageHr;
use App\Services\ProjectServer;
use GuzzleHttp\Client;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class Demo extends Command
{
... ... @@ -41,11 +46,187 @@ class Demo extends Command
parent::__construct();
}
public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
if ($data)
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([
'Expect:',
'Content-type: application/json',
'Accept: application/json',
], $header)
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [$code, $response];
}
/**
* @return bool
*/
public function handle()
{
$data = [];
dd(isset($data['a']['b']));
$url = 'https://demo.globalso.site/';
$action = 'api/updateHtmlNotify/';
$data = [
'project_id' => 1,
'type' => 1,
'route' => 1
];;
$method = 'GET';
$result = $this->curlRequest($url . $action, $data, $method);
dd($result);
$context = stream_context_create([
'ssl' => [
'capture_peer_cert' => true,
'capture_peer_cert_chain' => false,
],
]);
$stream = stream_socket_client('ssl://oa.quanqiusou.cn:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
if(!$stream) {
die("Failed to connect: $errno - $errstr");
}
$remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
if(!$remote_cert) {
die("Failed to retrieve certificate");
}
$valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
$valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
fclose($stream);
echo "Certificate Valid From: $valid_from<br>";
echo "Certificate Valid To: $valid_to<br>";
dd('end');
$dept_array = [
'品牌部',
'综合部',
'渠道部',
'广告推广部',
'AICC运营部',
'黑格运营部',
'直营运营部',
'直营销售部',
'深圳跨境部',
'外贸部',
'研发部',
'技术部',
'售后部',
];
foreach ($dept_array as $v) {
$dept = Dept::where(['title' => $v])->first();
if (FALSE == empty($dept))
continue;
$dept = new Dept();
$dept->title = $v;
$dept->save();
}
// dd('dept end');
$dept_map = Dept::pluck('title', 'id')->toArray();
$belonging_map = BelongingGroup::pluck('name', 'id')->toArray();
// dd($belonging_map);
$filename = storage_path('logs/oa_hr.txt');
$string = file_get_contents($filename);
$data = explode("\r\n", $string);
$data = array_filter($data);
$dept = '';
foreach ($data as $k=>$v) {
// var_dump($v) . PHP_EOL;
if ($k == 1)
continue;
$tmp = explode("\t", $v);
if (count($tmp) == 3) {
$dept = $tmp[0] ? : $dept;
$position = $tmp[1];
$name = $tmp[2];
} else if (count($tmp) == 2) {
$position = $tmp[0];
$name = $tmp[1];
} else {
Log::info($v . PHP_EOL);
continue;
}
// Log::info($dept . '---' . $position . '---' . $name . PHP_EOL);
// continue;
$dept_id = array_search($dept, $dept_map);
$belonging_id = 17;
if (FALSE !== strpos($dept,'技术部')) {
$belonging_string = str_replace('技术部', '', $dept);
if ($belonging_string) {
$belonging_string = $belonging_string . '组';
$belonging_id = array_search($belonging_string, $belonging_map);
}
$dept_tmp = '技术部';
$dept_id = array_search($dept_tmp, $dept_map);
}
if (FALSE !== strpos($dept,'售后')) {
$belonging_string = str_replace('售后', '', $dept);
if ($belonging_string)
$belonging_id = array_search($belonging_string, $belonging_map);
$dept_tmp = '售后部';
$dept_id = array_search($dept_tmp, $dept_map);
}
$position_log = EntryPosition::where(['name' => $position])->first();
if (empty($position_log)) {
$position_log = new EntryPosition();
$position_log->name = $position;
$position_log->save();
}
$position_id = $position_log->id;
$hr = ManageHr::where(['name' => $name])->first();
if (empty($hr)) {
Log::info($k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id);
continue;
}
$hr->belong_group = $belonging_id;
$hr->dept_id = $dept_id;
$hr->entry_position = $position_id;
$hr->save();
echo $k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id . '-' . '组' . '-' . $belonging_id . PHP_EOL;
}
dd('end');
exit;
if (($handle = fopen($filename, 'r')) !== false) {
while (($data = fgetcsv($handle, 1000, ',')) !== false) {
// 处理每行数据
Log::info(var_export($data, true));
}
fclose($handle);
}
exit;
$group = BelongingGroup::get();
dd($group->toArray());
$domain = parse_url('https//:dev.golbalso.site/');
dd($domain);
echo time() . PHP_EOL;
$blogModel = new Image();
$list = $blogModel->list();
... ...
... ... @@ -6,6 +6,7 @@ use App\Helper\Arr;
use App\Models\Product\Category;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use App\Services\ProjectServer;
use GuzzleHttp\Client;
use GuzzleHttp\Promise\Utils;
use Illuminate\Console\Command;
... ... @@ -230,20 +231,26 @@ class WebTraffic extends Command
*/
protected function getProductUrls($project_id){
//产品分类页面
$product_cate_ids = Category::where('project_id', $project_id)->where('status', Category::STATUS_ACTIVE)->pluck('id')->toArray();
$data['urls_cats'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT_CATE)->whereIn('source_id', $product_cate_ids)->get()->toArray();
ProjectServer::useProject($project_id);
$product_cate_ids = DB::connection('custom_mysql')->table('gl_product_category')
->where('project_id', $project_id)->where('status', 1)->pluck('id')->toArray();
$data['urls_cats'] = DB::connection('custom_mysql')->table('gl_route_map')
->where('project_id', $project_id)->where('source', 'product_category')->whereIn('source_id', $product_cate_ids)->get()->toArray();
//单页面
//todo 发布状态的单页面id
$data['urls_page'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PAGE)->get()->toArray();
$data['urls_page'] = DB::connection('custom_mysql')->table('gl_route_map')
->where('project_id', $project_id)->where('source', 'page')->get()->toArray();
//产品详情页
$product_ids = Product::where('project_id', $project_id)->where('status', Product::STATUS_ON)->pluck('id')->toArray();
$data['urls_details'] = RouteMap::where('project_id', $project_id)->where('source', RouteMap::SOURCE_PRODUCT)->whereIn('source_id', $product_ids)->get()->toArray();
$product_ids = DB::connection('custom_mysql')->table('gl_product_category')
->where('project_id', $project_id)->where('status', 1)->pluck('id')->toArray();
$data['urls_details'] = DB::connection('custom_mysql')->table('gl_route_map')
->where('project_id', $project_id)->where('source', 'product')->whereIn('source_id', $product_ids)->get()->toArray();
$data['urls_cats'] = array_merge($data['urls_cats'], $data['urls_page']);
if(empty($data['urls_cats'])){
$data['urls_cats'] = $data['urls_details'];
}
DB::disconnect('custom_mysql');
return $data;
}
... ... @@ -312,10 +319,10 @@ class WebTraffic extends Command
$url = [];
if($res_sdzb == 0){//深度一页
$url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : '';
$url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])->route : '';
}elseif($res_sdzb == 1){//深度两页
$url[] = $project_urls['home'];
$url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])['route'] : '';
$url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb])->route : '';
}elseif($res_sdzb == 2){//深度3-6页
$yms = rand(2,5); //随机页面数
$url = Arr::pluck(Arr::random($all_url, $yms), 'route');
... ...
... ... @@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长
$schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
$schedule->command('rank_data_speed')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次
$schedule->command('rank_data_external_links')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
... ... @@ -27,14 +28,13 @@ class Kernel extends ConsoleKernel
$schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
$schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
$schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
$schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每周执行一次
$schedule->command('sync_project')->everyMinute()->withoutOverlapping(1); //同步项目
$schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次
$schedule->command('month_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计记录
$schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录
$schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次
$schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
// // 更新域名|证书结束时间,每天凌晨1点执行一次
// $schedule->command('domain_time')->dailyAt('01:00')->withoutOverlapping(1);
$schedule->command('domain_info')->dailyAt('01:00')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
$schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
}
/**
... ...
... ... @@ -88,16 +88,16 @@ if (!function_exists('http_get')) {
function http_get($url, $header = [])
{
if (empty($header)) {
$header[] = "content-type: application/json;
charset = UTF-8";
$header[] = "content-type: application/json";
}
$ch1 = curl_init();
$timeout = 0;
curl_setopt($ch1, CURLOPT_URL, $url);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_ENCODING, '');
curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch1, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
... ... @@ -419,28 +419,21 @@ if (!function_exists('getImageUrl')) {
* @method :post
* @time :2023/7/20 16:46
*/
function getImageUrl($hash){
if(is_array($hash)){
foreach ($hash as $v){
function getImageUrl($path,$location = 1){
if(empty($path)){
return '';
}
if(is_array($path)){
foreach ($path as $v){
$url[] = getImageUrl($v);
}
}else{
$imageModel = new Image();
if (strpos($hash, '.') !== false) {
$info = $imageModel->read(['path'=>['like','%'.$hash.'%']]);
}else{
$info = $imageModel->read(['hash'=>$hash]);
}
if(!empty($info)){
if($info['is_cos'] == 1){
if($location == 1){
$cos = config('filesystems.disks.cos');
$cosCdn = $cos['cdn'];
$url = $cosCdn.$info['path'];
$url = $cosCdn.$path;
}else{
$url = url($info['path']);
}
}else{
$url = $hash;
$url = url($path);
}
}
return $url;
... ... @@ -454,33 +447,27 @@ if (!function_exists('getFileUrl')) {
* @method :post
* @time :2023/7/20 16:46
*/
function getFileUrl($hash){
if(is_array($hash)){
foreach ($hash as $v){
function getFileUrl($path,$location = 1){
if(empty($path)){
return '';
}
if(is_array($path)){
foreach ($path as $v){
$url[] = getFileUrl($v);
}
}else{
$fileModel = new File();
if (strpos($hash, '.') !== false) {
$info = $fileModel->read(['path'=>['like','%'.$hash.'%']]);
}else{
$info = $fileModel->read(['hash'=>$hash]);
}
if(!empty($info)){
if($info['is_cos'] == 1){
if($location == 1){
$cos = config('filesystems.disks.cos');
$cosCdn = $cos['cdn'];
$url = $cosCdn.'/upload'.$info['path'];
$url = $cosCdn.$path;
}else{
$url = url('upload'.$info['path']);
}
}else{
$url = $hash;
$url = url($path);
}
}
return $url;
}
}
/**
* @remark :字符串截取
* @name :characterTruncation
... ...
... ... @@ -7,8 +7,6 @@ use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Ai\AiCommandLogic;
use App\Http\Requests\Aside\Ai\AiCommandRequest;
use App\Models\Ai\AiCommand as AiCommandModel;
use Illuminate\Http\Request;
use function App\Helper\send_openai_msg;
/**
* @remark :ai指令
... ...
... ... @@ -39,6 +39,7 @@ class BaseController extends Controller
$info = Cache::get(Common::MANAGE_TOKEN . $this->token);
if(!empty($this->token) && !empty($info)){
$this->manage = $info;
Cache::put($this->token, $info, 3600 * 6);//更新缓存时间
$this->uid = $info['id'];
}
}
... ... @@ -54,7 +55,7 @@ class BaseController extends Controller
public function getParam(){
foreach ($this->param as $k => $v){
if(is_array($v)){
continue;
$this->map[$k] = $v;
}else{
if(empty($v) && ($v == null)){
unset($this->param[$k]);
... ...
... ... @@ -3,8 +3,12 @@
namespace App\Http\Controllers\Aside\Com;
use App\Enums\Common\Code;
use App\Enums\Common\Common;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\MenuLogic;
use App\Models\Manage\Manage;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
/**
* Class IndexController
... ... @@ -33,4 +37,38 @@ class IndexController extends BaseController
$this->response('success',Code::SUCCESS,$menus);
}
/**
* @remark :修改密码
* @name :editPassword
* @author :lyh
* @method :post
* @time :2023/9/11 9:10
*/
public function editPassword(){
$this->request->validate([
'oldPassword'=>'required',
'password' => 'required',
'confirm'=>'required',
], [
'oldPassword.required' => '请输入原密码',
'password.required' => '请输入新密码',
'confirm.required' => '请再次输入新密码',
]);
//查询员密码是否正确
$managerModel = new Manage();
$info = $managerModel->read(['id'=>$this->manage['id']]);
if(!Hash::check($this->param['oldPassword'], $info['password'])){
$this->response('原密码错误',Code::USER_REGISTER_ERROE);
}
if($this->param['password'] != $this->param['confirm']){
$this->response('两次密码不一致');
}
$rs = $managerModel->edit(['password'=>Hash::make($this->param['password'])],['id'=>$this->manage['id']]);
if($rs === false){
$this->response('系统错误',Code::SYSTEM_ERROR);
}
Cache::pull(Common::MANAGE_TOKEN . $info['token']);
$this->response('success');
}
}
... ...
... ... @@ -31,15 +31,6 @@ class DomainInfoController extends BaseController
$this->map['domain'] = ['like','%'.$this->map['domain'],'%'];
}
$lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order);
$projectModel = new Project();
if(!empty($lists)){
foreach ($lists['list'] as $k => $v){
if(!empty($info['project_id'])){
$v['company'] = $projectModel->read(['id'=>$info['project_id']],['title'])['title'];
}
$lists['list'][$k] = $v;
}
}
return $this->response('success', Code::SUCCESS, $lists);
}
... ...
... ... @@ -41,6 +41,13 @@ class LoginController extends BaseController
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :退出登录
* @name :logout
* @author :lyh
* @method :post
* @time :2023/9/7 16:29
*/
public function logout(LoginLogic $logic)
{
$logic->logout();
... ... @@ -91,4 +98,5 @@ class LoginController extends BaseController
SmsLog::createLog($mobile, $code['code'],SmsLog::TYPE_MANAGER_LOGIN);
$this->response('success');
}
}
... ...
... ... @@ -3,6 +3,8 @@
namespace App\Http\Controllers\Aside\Manage;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Manage\ManageHr;
use App\Models\Manage\Menu;
use Illuminate\Http\Request;
use App\Http\Logic\Aside\Manage\HrLogic;
... ... @@ -15,10 +17,10 @@ class HrController extends BaseController
* @method :post
* @time :2023/7/24 11:56
*/
public function list(HrLogic $logic)
public function list(ManageHr $manageHr)
{
$lists = $logic->getHrList($this->map,$this->page,$this->row,$this->order);
if(!empty($lists['list'])){
$lists = $manageHr->lists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['photo_gallery_link'] = json_decode($v['photo_gallery']);
$v['id_card_gallery_link'] = json_decode($v['id_card_gallery']);
... ... @@ -29,8 +31,15 @@ class HrController extends BaseController
return $this->response('success', Code::SUCCESS, $lists);
}
public function info(Request $request, HrLogic $logic){
$request->validate([
/**
* @remark :获取详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/9/6 10:04
*/
public function info(HrLogic $logic){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
... ... @@ -42,6 +51,13 @@ class HrController extends BaseController
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/9/6 10:05
*/
public function save(HrLogic $logic){
$logic->hrSave();
return $this->response('success');
... ... @@ -59,4 +75,26 @@ class HrController extends BaseController
$this->response('success',Code::SUCCESS,$list);
}
/**
* @param HrLogic $hrLogic
* @return \Illuminate\Http\JsonResponse
*/
public function getHrList(HrLogic $hrLogic)
{
$page_size = intval(request()->input('page_size', 15));
$list = $hrLogic->getHrListForV5($page_size);
$result = [];
foreach ($list as $v) {
$result[] = [
'name' => $v->name,
'id_card' => $v->id_card,
'mobile' => $v->mobile,
'dept_title' => $v->dept_title = $v->dept ? $v->dept->title : '',
'position_title' => $v->position = $v->position ? $v->position->name : '',
'status' => $v->status,
];
}
return $this->response('success',Code::SUCCESS, $result);
}
}
... ...
... ... @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\ManageLogic;
use App\Http\Requests\Aside\Manage\ManageRequest;
use App\Models\Manage\Manage;
use App\Models\Manage\MenuSpecial;
use App\Models\User\ProjectRole;
use App\Rules\Ids;
... ... @@ -28,19 +29,10 @@ class ManageController extends BaseController
* @method :post
* @time :2023/8/28 10:04
*/
public function list(Request $request, ManageLogic $logic)
public function list()
{
$map = [];
if(!empty($this->param['search'])){
$map[] = ['name|mobile', 'like', "%{$this->param['search']}%"];
}
if(!empty($this->param['dept_id'])){
$map[] = ['dept_id', $this->param['dept_id']];
}
if(!empty($this->param['gid'])){
$map[] = ['gid', $this->param['gid']];
}
$list = $logic->getList($map,['sort' => 'desc'],['*'],$this->row);
$managerModel = new Manage();
$list = $managerModel->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$list);
}
... ... @@ -90,8 +82,8 @@ class ManageController extends BaseController
],[
'ids.required' => 'ID不能为空'
]);
$logic->delete($this->param['ids']);
$this->response('success');
$logic->managerDelete();
$this->response('删除成功');
}
/**
... ... @@ -104,8 +96,10 @@ class ManageController extends BaseController
public function setSort(ManageLogic $logic){
$this->request->validate([
'id'=>'required',
'sort'=>'required',
],[
'id.required' => 'ID不能为空',
'sort.required' => 'sort不能为空',
]);
$logic->setParamStatus();
$this->response('success');
... ...
<?php
/**
* @remark :
* @name :ManagerLogController.php
* @author :lyh
* @method :post
* @time :2023/9/5 16:09
*/
namespace App\Http\Controllers\Aside\Manage;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Manage\LoginLog;
use App\Models\Manage\Manage;
class ManagerLogController extends BaseController
{
/**
* @remark :管理员日志列表
* @name :lists
* @author :lyh
* @method :post
* @time :2023/9/5 16:10
*/
public function lists(LoginLog $manageLogin){
$map = $this->searchParam();
$lists = $manageLogin->lists($map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
$managerModel = new Manage();
foreach ($lists['list'] as $k => $v){
$info = $managerModel->read(['id'=>$v['manage_id']]);
$v['mobile'] = $info['mobile'] ?? '';
$v['name'] = $info['name'] ?? '';
$v['type'] = (isset($v['type']) && $v['type'] == 1) ? '账号密码登录' : '验证码登录';
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :搜索参数
* @name :searchParam
* @author :lyh
* @method :post
* @time :2023/9/5 16:56
*/
public function searchParam(){
$map = [];
$managerModel = new Manage();
if(isset($this->map['mobile']) && !empty($this->map['mobile'])){
$ids = $managerModel->where('mobile', 'like', '%' . $this->map['mobile'] . '%')->pluck('id')->toArray();
$map['manage_id'] = ['in',$ids];
}elseif (isset($this->map['name']) && !empty($this->map['name'])){
$ids = $managerModel->where('name', 'like', '%' . $this->param['name'] . '%')->pluck('id')->toArray();
$map['manage_id'] = ['in',$ids];
}
if(isset($this->map['created_at'])){
$map['created_at'] = $this->map['created_at'];
}
return $map;
}
}
... ...
... ... @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Aside\Manage;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\MenuSpecialLogic;
use App\Models\Manage\MenuSpecial;
/**
* @remark :特殊模块设置
... ... @@ -29,8 +30,11 @@ class MenuSpecialController extends BaseController
* @method :post
* @time :2023/8/7 11:52
*/
public function lists(MenuSpecialLogic $logic){
$lists = $logic->specialLists($this->map,$this->page,$this->row,$this->order);
public function lists(MenuSpecial $menuSpecial){
if(isset($this->map['remark']) && !empty($this->map['remark'])){
$this->map['remark'] = ['like','%'.$this->map['remark'].'%'];
}
$lists = $menuSpecial->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
... ... @@ -73,11 +77,11 @@ class MenuSpecialController extends BaseController
public function save(MenuSpecialLogic $logic){
$this->request->validate([
'name'=>'required',
'user_list'=>'required',
// 'user_list'=>'required',
'remark'=>'required'
],[
'name.required' => 'name不能为空',
'user_list.required' => 'user_list不能为空',
// 'user_list.required' => 'user_list不能为空',
'remark.required' => 'remark不能为空'
]);
$logic->specialSave();
... ...
<?php
/**
* @remark :
* @name :KeywordsController.php
* @author :lyh
* @method :post
* @time :2023/9/4 10:12
*/
namespace App\Http\Controllers\Aside\Optimize;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
class KeywordsController extends BaseController
{
/**
* @remark :关键字查案例
* @name :lists
* @author :lyh
* @method :post
* @time :2023/9/4 10:13
*/
public function lists(){
$projectDeployOptimizeModel = new DeployOptimize();
$ids = $projectDeployOptimizeModel->where('customer_keywords','like','%'.$this->map['search'].'%')
->orWhere('main_keywords', 'like' , '%'.$this->map['search'].'%')->pluck('project_id')->toArray();
$projectModel = new Project();
$lists = $projectModel->formatQuery(['id'=>['in',$ids]])->with('payment')->with('deploy_build')
->with('deploy_optimize')->get()->toArray();
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
... ... @@ -95,7 +95,9 @@ class OnlineController extends BaseController
* @time :2023/8/18 14:44
*/
public function handleParam(&$item){
if($item['type'] != Project::TYPE_ZERO){
$data = APublicModel::getNumByProjectId($item['id']);
}
$manageModel = new Manage();
$item['channel'] = Channel::getChannelText($item['channel']['user_id'] ?? 0);
$item['build_leader'] = $manageModel->getName($item['leader_mid']);
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Aside\Optimize;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Optimize\OptimizeLogic;
use App\Models\Domain\DomainInfo;
use App\Models\Manage\Manage;
use App\Models\Project\Project;
use Illuminate\Support\Facades\DB;
... ... @@ -32,11 +33,13 @@ class OptimizeController extends BaseController
$lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray();
if(!empty($lists['list'])){
$manager = new Manage();
$domainModel = new DomainInfo();
foreach ($lists['list'] as $k => $v){
$v['plan'] = $project::planMap()[$v['plan']];
$v['optimist_mid_name'] = $manager->getName($v['optimist_mid']);
$v['tech_mid_name'] = $manager->getName($v['tech_mid']);
$v['autologin_code'] = getAutoLoginCode($v['id']);
$v['domain'] = $domainModel->getDomain($v['domain']);
$lists['list'][$k] = $v;
}
}
... ...
... ... @@ -11,6 +11,7 @@ namespace App\Http\Controllers\Aside\Project;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Project\KeywordPrefixLogic;
use App\Models\Project\KeywordPrefix;
class KeywordPrefixController extends BaseController
... ... @@ -27,4 +28,23 @@ class KeywordPrefixController extends BaseController
$list = $keywordPrefixModel->list($this->map);
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :保存关键字
* @name :save
* @author :lyh
* @method :post
* @time :2023/9/6 14:47
*/
public function save(KeywordPrefixLogic $keywordPrefixLogic){
$this->request->validate([
'keyword'=>'required',
'type'=>'required'
],[
'keyword.required' => 'keyword不能为空',
'type.required' => 'type不能为空',
]);
$keywordPrefixLogic->prefixSave();
$this->response('success');
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Aside\Project;
use App\Enums\Common\Code;
use App\Helper\QuanqiusouApi;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\ManageLogic;
use App\Http\Logic\Aside\Project\OnlineCheckLogic;
... ... @@ -15,6 +16,7 @@ use App\Models\Channel\Channel;
use App\Models\Com\City;
use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
use App\Models\HomeCount\Count;
use App\Models\Inquiry\InquirySet;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\Manage;
... ... @@ -25,6 +27,7 @@ use App\Models\Project\Payment;
use App\Models\Project\Project;
use App\Models\RankData\RankData;
use App\Models\Task\Task;
use App\Models\Visit\Visit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
... ... @@ -47,144 +50,239 @@ class ProjectController extends BaseController
* @time :2023/8/30 10:11
*/
public function lists(Project $project){
$map = [];
//搜索参数处理
$map = $this->searchParam($map,$this->map);
//类型
if(isset($this->map['type'])){
$map['type'] = $this->searchType($this->map['type']);
$map['extend_type'] = 0;//排除未续费项目
}
$filed = ['id', 'title', 'mysql_id' ,'channel','cooperate_date' ,'type', 'created_at'];
$lists = $project->formatQuery($map)->select($filed)->with('payment')->with('deploy_build')
->with('deploy_optimize')->with('online_check')->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
$lists = $lists->toArray();
foreach ($lists['list'] as $k=>$item){
$item = $this->handleParam($item);
$lists['list'][$k] = $item;
$query = $project->leftJoin('gl_project_payment', 'gl_project.id', '=', 'gl_project_payment.project_id')
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id');
$query = $this->searchParam($query);
$lists = $query->orderBy('gl_project.id', 'desc')->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray();
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v = $this->handleParam($v);
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :返回参数过滤
* @name :returnParamItem
* @remark :搜索参数处理
* @name :searchParam
* @author :lyh
* @method :post
* @time :2023/8/30 11:07
* @time :2023/8/18 10:58
*/
public function handleParam(&$item){
$manageModel = new Manage();
if($item['mysql_id'] != 0 && $item['type'] != 0){
$data = APublicModel::getNumByProjectId($item['id']);
}
$item = [
'id' => $item['id'],
'title' => $item['title'],
'channel' => Channel::getChannelText($item['channel']['user_id'] ?? 0),
'key' => $item['deploy_build']['keyword_num'] ?? 0,
'day' => $item['deploy_build']['service_duration'] ?? 0,
'amount' => $item['payment']['amount'] ?? 0,
'build_leader' => $manageModel->getName($item['deploy_build']['leader_mid']), //组长
'build_manager' => $manageModel->getName($item['deploy_build']['manager_mid']), //项目经理
'build_designer' => $manageModel->getName($item['deploy_build']['designer_mid']), //设计师
'build_tech' => $manageModel->getName($item['deploy_build']['tech_mid']), //技术助理
'optimize_manager' => $manageModel->getName($item['deploy_optimize']['manager_mid']), //优化服务经理
'optimize_optimist' => $manageModel->getName($item['deploy_optimize']['optimist_mid']), //优化师
'optimize_assist' => $manageModel->getName($item['deploy_optimize']['assist_mid']), //优化助理
'optimize_tech' => $manageModel->getName($item['deploy_optimize']['tech_mid']), //售后技术
'type' => $item['type'],
'test_domain' => $item['deploy_build']['test_domain'] ?? 0,
'plan' =>Project::planMap()[$item['deploy_build']['plan']],
'domain' => $item['deploy_optimize']['domain'] ?? 0,
'created_at' => date('Y年m月d日', strtotime($item['created_at'])),
'product_num' => $data['product'] ?? 0,
'keyword_num' => $item['deploy_build']['keyword_num'] ?? 0,
'article_num' => ($data['blog'] ?? 0) + ($data['news'] ?? 0),
'task_finish_num' => Task::getNumByProjectId($item['id'], Task::STATUS_DOWN),
'task_pending_num' => Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]),
'optimist_status'=>$item['online_check']['optimist_status'] ?? 0,
'qa_status'=>$item['online_check']['qa_status'] ?? 0,
'service_day'=>$item['deploy_build']['service_duration'] - $this->compliance_day($item['id']),
];
return $item;
public function searchParam(&$query){
//参数type
$query = $this->searchType($query);
//根据查看权限获取项目搜索条件(必带)
$query = $this->getManagerRole($query);
//搜索技术组
$query = $this->searchDept($query);
//搜索技术人员
$query = $this->searchManager($query);
//按类型搜索
$query = $this->searchContent($query);
return $query;
}
/**
* @param $yesterday
* @name :(服务达标天数)compliance_day
* @remark :type类型
* @name :searchType
* @author :lyh
* @method :post
* @time :2023/6/14 15:48
* @time :2023/8/30 10:14
*/
public function compliance_day($project_id){
//服务达标天数
$rankDataModel = new RankData();
$rank_info = $rankDataModel->where(['project_id'=>$project_id,'lang'=>''])->select(['compliance_day'])->first();
if(empty($rank_info)){
$compliance_day = 0;
public function searchType(&$query){
$query->where('gl_project.delete_status',Project::TYPE_ZERO);
if(!isset($this->map['type'])){
$this->map['type'] = Project::TYPE_ZERO;
}
if($this->map['type'] == Project::TYPE_ZERO){
$query->where('gl_project.type',Project::TYPE_ZERO);
}elseif ($this->map['type'] == Project::TYPE_ONE){
$query->where('gl_project.type',Project::TYPE_ONE);
}elseif ($this->map['type'] == Project::TYPE_TWO){
$query->whereIn('gl_project.type', [Project::TYPE_TWO,Project::TYPE_THREE]);
}else{
$compliance_day = $rank_info->compliance_day;
$query->whereIn('gl_project.type', [Project::TYPE_FOUR,Project::TYPE_SIX]);
}
return $compliance_day;
return $query;
}
/**
* @remark :type类型
* @name :searchType
* @remark :查询字段处理
* @name :selectParam
* @author :lyh
* @method :post
* @time :2023/8/30 10:14
* @time :2023/8/18 10:59
*/
public function searchType($type){
//初始项目
if($type == Project::TYPE_ZERO){
$type = Project::TYPE_ZERO;
public function selectParam(){
$select = [
'gl_project.id AS id',
'gl_project.title AS title',
'gl_project.channel AS channel',
'gl_project.company AS company',
'gl_project.type AS type',
'gl_project.created_at AS created_at',
'gl_project.cooperate_date AS cooperate_date',
'gl_project_online_check.id AS online_check_id',
'gl_project_online_check.question AS question',
'gl_project_online_check.optimist_status AS optimist_status',
'gl_project_online_check.qa_status AS qa_status',
'gl_project_payment.amount AS amount',
'gl_project_deploy_build.dept_id AS dept_id',
'gl_project_deploy_build.keyword_num AS key',
'gl_project_deploy_build.service_duration AS day',
'gl_project_deploy_build.leader_mid AS leader_mid',
'gl_project_deploy_build.manager_mid AS manager_mid',
'gl_project_deploy_build.designer_mid AS designer_mid',
'gl_project_deploy_build.tech_mid AS tech_mid',
'gl_project_deploy_build.test_domain AS test_domain',
'gl_project_deploy_build.plan AS plan',
'gl_project_deploy_optimize.dept_id AS optimize_dept_id',
'gl_project_deploy_optimize.manager_mid AS optimize_manager_mid',
'gl_project_deploy_optimize.optimist_mid AS optimize_optimist_mid',
'gl_project_deploy_optimize.assist_mid AS optimize_assist_mid',
'gl_project_deploy_optimize.tech_mid AS optimize_tech_mid',
'gl_project_deploy_optimize.design_mid AS design_mid',
'gl_project_deploy_optimize.tech_leader AS tech_leader',
'gl_project_deploy_optimize.domain AS domain',
'gl_project_deploy_optimize.quality_mid AS quality_mid',
'gl_project_deploy_optimize.design_mid AS design_mid',
'gl_project_payment.amount AS amount',
];
return $select;
}
//建站中
if($type == Project::TYPE_ONE){
$type = Project::TYPE_ONE;
/**
* @remark :按需搜索
* @name :searchDomainTitle
* @author :lyh
* @method :post
* @time :2023/9/7 18:39
*/
public function searchContent(&$query){
if(!empty($this->map['search']) && !empty($this->map['search_type'])){
//搜索域名
$query->where(function ($subQuery) {
$subQuery->orwhere('gl_project_deploy_optimize.domain','like','%'.$this->map['search'].'%')
->orwhere('gl_project.company','like','%'.$this->map['search'].'%')
->orwhere('gl_project.title','like','%'.$this->map['search'].'%');
});
}
//建站完成
if($type == Project::TYPE_TWO){
$type = ['in',[Project::TYPE_TWO,Project::TYPE_THREE]];
return $query;
}
if($this->param['type'] == Project::TYPE_THREE){
$type = ['in',[Project::TYPE_FOUR,Project::TYPE_SIX]];
/**
* @remark :搜索技术组
* @name :searchDept
* @author :lyh
* @method :post
* @time :2023/9/7 18:40
*/
public function searchDept(&$query){
if(!empty($this->map['dept_id'])){
$query->where(function ($subQuery) {
$subQuery->orwhere('gl_project_deploy_build.dept_id',$this->map['dept_id'])
->orwhere('gl_project_deploy_optimize.dept_id',$this->map['dept_id']);
});
}
return $type;
return $query;
}
/**
* @remark :搜索参数处理
* @name :searchParam
* @remark :访问权限
* @name :getManagerRole
* @author :lyh
* @method :post
* @time :2023/8/30 10:30
* @time :2023/9/7 17:28
*/
public function searchParam(&$map,$param){
//搜索技术组
if(!empty($param['dep_id'])){
$map['id'] = ['in', DeployBuild::where('dept_id', $param['dep_id'])->pluck('project_id')->toArray()];
}
//搜索技术人员
if(!empty($param['manage_id'])){
$map['id'] = ['in', DeployBuild::where('leader_mid', $param['manage_id'])
->orwhere('manager_mid', $param['manage_id'])->orwhere('designer_mid', $param['manage_id'])
->orwhere('tech_mid', $param['manage_id'])->pluck('project_id')->toArray()];
public function getManagerRole(&$query){
if($this->manage['role'] != 1){//1代表查看所有
//获取用户所在组
$managerHr = new ManageHr();
$info = $managerHr->read(['manage_id'=>$this->manage['id']]);
//获取当前用户自己的项目
$query->where(function ($subQuery) use ($info) {
$subQuery->where('gl_project_deploy_build.leader_mid', $this->manage['id'])
->orWhere('gl_project_deploy_build.manager_mid', $this->manage['id'])
->orWhere('gl_project_deploy_build.designer_mid', $this->manage['id'])
->orWhere('gl_project_deploy_build.tech_mid', $this->manage['id'])
->orWhere('gl_project_deploy_optimize.manager_mid', $this->manage['id'])
->orWhere('gl_project_deploy_optimize.optimist_mid', $this->manage['id'])
->orWhere('gl_project_deploy_optimize.assist_mid', $this->manage['id'])
->orWhere('gl_project_deploy_optimize.tech_mid', $this->manage['id'])
->orWhere('gl_project_deploy_optimize.tech_leader', $this->manage['id'])
->orWhere('gl_project_deploy_optimize.quality_mid', $this->manage['id'])
->orWhere('gl_project_deploy_optimize.design_mid', $this->manage['id'])
->orWhere('gl_project_deploy_build.dept_id', $info['belong_group'])
->orWhere('gl_project_deploy_optimize.dept_id', $info['belong_group']);
});
}
return $query;
}
//按类型搜索
if(!empty($param['search']) && !empty($param['search_type'])){
if($this->param['search_type'] == 'domain'){
//搜索域名
$map['id'] = ['id', 'in', DeployOptimize::where('domain', 'like', "%{$this->param['search']}%")->pluck('project_id')->toArray()];
}else{
$map[$param['search_type']] = ['like', "%{$param['search']}%"];
/**
* @remark :搜索技术人员
* @name :searchManager
* @author :lyh
* @method :post
* @time :2023/9/7 17:16
*/
public function searchManager(&$query)
{
if (!empty($this->map['manage_id'])) {
$query->where(function ($subQuery) {
$subQuery->orWhere('gl_project_deploy_build.leader_mid', $this->map['manage_id'])
->orWhere('gl_project_deploy_build.manager_mid', $this->map['manage_id'])
->orWhere('gl_project_deploy_build.designer_mid', $this->map['manage_id'])
->orWhere('gl_project_deploy_build.tech_mid', $this->map['manage_id'])
->orWhere('gl_project_deploy_optimize.manager_mid', $this->map['manage_id'])
->orWhere('gl_project_deploy_optimize.optimist_mid', $this->map['manage_id'])
->orWhere('gl_project_deploy_optimize.assist_mid', $this->map['manage_id'])
->orWhere('gl_project_deploy_optimize.tech_mid', $this->map['manage_id'])
->orWhere('gl_project_deploy_optimize.tech_leader', $this->map['manage_id'])
->orWhere('gl_project_deploy_optimize.quality_mid', $this->map['manage_id'])
->orWhere('gl_project_deploy_optimize.design_mid', $this->map['manage_id']);
});
}
return $query;
}
/**
* @remark :参数处理
* @name :handleParam
* @author :lyh
* @method :post
* @time :2023/8/18 14:44
*/
public function handleParam(&$item){
if($item['type'] != Project::TYPE_ZERO){
$data = APublicModel::getNumByProjectId($item['id']);
}
return $map;
$manageModel = new Manage();
$item['channel'] = Channel::getChannelText($item['channel']['user_id'] ?? 0);
$item['build_leader'] = $manageModel->getName($item['leader_mid']);
$item['build_manager'] = $manageModel->getName($item['manager_mid']);
$item['build_designer'] = $manageModel->getName($item['designer_mid']);
$item['build_tech'] = $manageModel->getName($item['tech_mid']);
$item['optimize_manager'] = $manageModel->getName($item['optimize_manager_mid']);
$item['optimize_optimist'] = $manageModel->getName($item['optimize_optimist_mid']);
$item['optimize_assist'] = $manageModel->getName($item['optimize_assist_mid']);
$item['optimize_tech'] = $manageModel->getName($item['optimize_tech_mid']);
$item['plan'] = Project::planMap()[$item['plan']];
$item['created_at'] = date('Y年m月d日', strtotime($item['cooperate_date']));
$item['autologin_code'] = getAutoLoginCode($item['id']);
$domainModel = new DomainInfo();
$item['domain'] = !empty($item['domain']) ? $domainModel->getDomain($item['domain']) : '';
$item['product_num'] = $data['product'] ?? 0;
$item['keyword_num'] = $item['key'] ?? 0;
$item['autologin_code'] = getAutoLoginCode($item['id']);
$item['article_num'] = ($data['blog'] ?? 0) + ($data['news'] ?? 0);
$item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN);
$item['task_pending_num'] = Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]);
return $item;
}
/**
... ... @@ -354,8 +452,8 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/30 19:01
*/
public function online_check(Request $request, OnlineCheckLogic $logic){
$request->validate([
public function online_check(OnlineCheckLogic $logic){
$this->request->validate([
'id'=>'required',
'type'=>'required|in:optimist,qa',
'status'=>'required|in:0,1'
... ... @@ -384,7 +482,7 @@ class ProjectController extends BaseController
'type.required' => '请选择审核类型'
]);
$belongGroupModel = new BelongingGroup();
$lists = $belongGroupModel->list($this->map);
$lists = $belongGroupModel->list($this->map,'name',['id','name','type'],'asc');
$this->response('success',Code::SUCCESS,$lists);
}
... ... @@ -397,6 +495,10 @@ class ProjectController extends BaseController
*/
public function getManagerList(){
$hrManagerModel = new ManageHr();
$this->map['status'] = $hrManagerModel::STATUS_ONE;
if(isset($this->map['entry_position']) && is_array($this->map['entry_position'])){
$this->map['entry_position'] = ['in',$this->map['entry_position']];
}
$lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']);
$this->response('success',Code::SUCCESS,$lists);
}
... ... @@ -410,7 +512,7 @@ class ProjectController extends BaseController
*/
public function getServiceConfig(){
$serviceConfigModel = new ServerConfig();
$list = $serviceConfigModel->list($this->param);
$list = $serviceConfigModel->list($this->param,'id',['id','type','title']);
$this->response('success',Code::SUCCESS,$list);
}
... ... @@ -422,8 +524,112 @@ class ProjectController extends BaseController
* @time :2023/8/14 10:29
*/
public function getDomain(){
$this->request->validate([
'project_id'=>'required',
],[
'project_id.required' => 'project_id不能为空',
]);
$domainModel = new DomainInfo();
$list = $domainModel->list(['status'=>0]);
$list = $domainModel->list(['status'=>0,'project_id'=>['or',$this->param['project_id']]]);
$this->response('success',Code::SUCCESS,$list);
}
/**
* 通过企业名称查询项目是否在服务中, 有项目并且在服务中的返回1, 其他的返回0
* @author zbj
* @date 2023/9/4
*/
public function getProjectInService(){
$company = $this->param['company'];
if(!$company){
$this->response('企业名称必传',Code::SYSTEM_ERROR);
}
$project = Project::where('company', $company)->first();
if($project && ($project['remain_day'] > 0 || in_array($project['type'], [0, 1,6]))){
$in_service = 1;
}else{
$in_service = 0;
}
$this->response('success',Code::SUCCESS, ['in_service' => $in_service]);
}
/**
* @remark :逻辑删除项目
* @name :del
* @author :lyh
* @method :post
* @time :2023/9/8 15:21
*/
public function del(ProjectLogic $logic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'id不能为空',
]);
$logic->projectDel();
$this->response('success');
}
/**
* 根据渠道商查询项目
* @author zbj
* @date 2023/9/11
*/
public function getProjectByChannel(){
$source_id = $this->param['channel_id']; //原系统渠道id
$size = $this->param['page_size'] ?? 20;
$type = $this->param['type'] ?? '';
$company = $this->param['company'] ?? '';
$channel = Channel::where('source_id', $source_id)->first();
if(!$channel){
$this->response('渠道不存在',Code::SYSTEM_ERROR);
}
$data = Project::with(['deploy_build', 'deploy_optimize', 'online_check'])->where('channel->channel_id', $channel->id)->where(function ($query) use ($type, $company){
if ($type) {
$query->where('type', $type);
}
if ($company) {
$query->where('company', 'like', '%' . $company . '%');
}
})->orderBy('id', 'desc')->paginate($size)->toArray();
$list = [];
foreach ($data['list'] as $item){
$param = [
"id" => $item['id'],
"title" => $item['title'],
"company" => $item['company'],
"type" => $item['type'],
"type_text" => Project::typeMap()[$item['type']] ?? '',
"channel" => $item['channel'],
"created_at" => $item['created_at'],
"updated_at" => $item['updated_at'],
"post_id" => $item['post_id'],
"from_order_id" => $item['from_order_id'],
"remain_day" => $item['remain_day'],
"last_inquiry_time" => $item['last_inquiry_time'],
"plan" => $item['deploy_build']['plan'] ?: 0,
"plan_text" => Project::planMap()[$item['deploy_build']['plan']] ?? '',
"start_date" => $item['deploy_optimize']['start_date'] ?? '',
"domain" => $item['deploy_optimize']['domain'] ?? '',
"test_domain" => $item['deploy_build']['test_domain'] ?? '',
"online_time" => $item['online_check']['qa_check_time'] ?? '',
"cooperate_date" => $item['cooperate_date'],
];
if ($item['type'] == 3) {
$param['is_compliance'] = RankData::where('project_id', $item['id'])->where('lang', '')->value('is_compliance') ?: 0;
} else {
$param['is_compliance'] = 1;
}
$yesterday_count = Count::where('project_id', $item['id'])->where('date', date('Y-m-d', strtotime('-1 day')))->first();
$today_count = Count::where('project_id', $item['id'])->where('date', date('Y-m-d'))->first();
$param['yesterday_ip_count'] = $yesterday_count['ip_num'] ?? 0;
$param['today_ip_count'] = $today_count['ip_num'] ?? 0;
$param['inquiry_num'] = $today_count['inquiry_num'] ?? 0;
$list[] = $param;
}
$data['list'] = $list;
$this->response('success',Code::SUCCESS, $data);
}
}
... ...
... ... @@ -16,6 +16,7 @@ use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Http\Logic\Aside\Project\RenewLogic;
use App\Models\ASide\APublicModel;
use App\Models\Channel\Channel;
use App\Models\Domain\DomainInfo;
use App\Models\HomeCount\Count;
use App\Models\Manage\Manage;
use App\Models\Project\DeployBuild;
... ... @@ -34,43 +35,22 @@ class RenewProjectController extends BaseController
* @time :2023/8/11 10:22
*/
public function lists(Project $project){
$arr = $this->getLessThanFifteenProjectId();
$map = [];
$this->searchParam($map,$this->map,$arr);
//按类型搜索
$map['id'] = ['in', $arr];
$filed = ['id', 'title', 'mysql_id' ,'channel','cooperate_date' ,'type', 'created_at'];
$map = $this->searchParam($this->map);
$filed = ['id', 'title', 'type' ,'mysql_id' ,'channel','cooperate_date' ,'type', 'remain_day' ,'created_at','delete_status'];
$lists = $project->formatQuery($map)->select($filed)->with('payment')->with('deploy_build')
->with('deploy_optimize')->with('online_check')->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
$lists = $lists->toArray();
$manageModel = new Manage();
$domainModel = new DomainInfo();
foreach ($lists['list'] as $k=>$item){
$item = $this->handleParam($item);
$item = $this->handleParam($item,$manageModel,$domainModel);
$lists['list'][$k] = $item;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :获取小于15天的项目id
* @name :getlessThanFifteenProjectId
* @author :lyh
* @method :post
* @time :2023/8/30 11:49
*/
public function getLessThanFifteenProjectId(){
$count = new Count();
$yesterday = Carbon::yesterday()->toDateString();
$count_list = $count->list(['date'=>$yesterday,'service_day'=>['<=',15]],'id',['project_id']);
$arr = [];
if(!empty($count_list)){
foreach ($count_list as $v){
$arr[] = $v['project_id'];
}
}
return $arr;
}
/**
* @remark :搜索参数处理
... ... @@ -79,16 +59,16 @@ class RenewProjectController extends BaseController
* @method :post
* @time :2023/8/30 10:30
*/
public function searchParam(&$map,$param,&$arr){
public function searchParam($param){
$map = [];
//按类型搜索
if(!empty($param['search']) && !empty($param['search_type'])){
if($this->param['search_type'] == 'domain'){
//搜索域名
$map['id'] = ['id', 'in', DeployOptimize::where('domain', 'like', "%{$param['search']}%")->where('id','in',$arr)->pluck('project_id')->toArray()];
}else{
$map[$this->param['search_type']] = ['like', "%{$this->param['search']}%"];
}
}
//按类型搜索
$map['delete_status'] = 0;
$map['type'] = ['in',[2,3,4]];
$map['remain_day'] = ['<=',15];
return $map;
}
... ... @@ -138,8 +118,10 @@ class RenewProjectController extends BaseController
->with('project_after')->paginate($this->row, ['*'], 'page', $this->page);
if(!empty($lists)){
$lists = $lists->toArray();
$manageModel = new Manage();
$domainModel = new DomainInfo();
foreach ($lists['list'] as $k=>$item){
$item = $this->handleParam($item);
$item = $this->handleParam($item,$manageModel,$domainModel);
$lists['list'][$k] = $item;
}
}
... ... @@ -153,9 +135,10 @@ class RenewProjectController extends BaseController
* @method :post
* @time :2023/8/18 14:44
*/
public function handleParam(&$item){
$manageModel = new Manage();
public function handleParam(&$item,&$manageModel,&$domainModel){
if($item['type'] != Project::TYPE_ZERO){
$data = APublicModel::getNumByProjectId($item['id']);
}
$item = [
'id' => $item['id'],
'title' => $item['title'],
... ... @@ -174,7 +157,7 @@ class RenewProjectController extends BaseController
'type' => $item['type'],
'test_domain' => $item['deploy_build']['test_domain'] ?? 0,
'plan' =>Project::planMap()[$item['deploy_build']['plan']],
'domain' => $item['deploy_optimize']['domain'] ?? 0,
'domain' => !empty($item['deploy_optimize']['domain']) ? $domainModel->getDomain($item['deploy_optimize']['domain']) : '',
'created_at' => date('Y年m月d日', strtotime($item['created_at'])),
'autologin_code' => getAutoLoginCode($item['id']),
'product_num' => $data['product'] ?? 0,
... ... @@ -184,6 +167,7 @@ class RenewProjectController extends BaseController
'task_pending_num' => Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]),
'optimist_status'=>$item['online_check']['optimist_status'] ?? 0,
'qa_status'=>$item['online_check']['qa_status'] ?? 0,
'service_day'=>$item['remain_day'] ?? 0,
];
return $item;
}
... ...
... ... @@ -44,6 +44,7 @@ class TaskController extends BaseController
$map = $this->searchParam($task,$taskOwnerModel);
$manager_list = $taskOwnerModel->formatQuery($map)->select('manage_id', DB::raw('COUNT(*) as count'))
->groupBy('manage_id')->get()->toArray();
$managerModel = new Manage();
foreach ($manager_list as $k => $v){
$ids = $taskOwnerModel->where('manage_id', $v['manage_id'])->pluck('task_id')->toArray();
... ... @@ -74,20 +75,24 @@ class TaskController extends BaseController
$map['manage_id'] = $this->map['manage_id'];
}
}
}elseif (isset($this->map['content']) && !empty($this->map['content'])){
$ids = $task->where('content', 'like','%'.$this->map['content'].'%')->pluck('id')->toArray();
$manage_ids = $taskOwnerModel->formatQuery(['task_id'=>['in',$ids]])->pluck('manage_id')->toArray();
$map['manage_id'] = ['in',$manage_ids];
}elseif (isset($this->map['search_type']) && !empty($this->map['search_type'])){
if(isset($this->map['search']) && !empty($this->map['search'])) {
$projectModel = new Project();
if($this->map['search_type'] == 'project'){
$ids = $projectModel->where('title', 'like', '%' . $this->map['search'] . '%')->pluck('id')->toArray();
$manage_ids = $taskOwnerModel->formatQuery(['project'=>['in',$ids]])->pluck('manage_id')->toArray();
$map['manage_id'] = ['in',$manage_ids];
}else{
$ids = $task->where('content', 'like','%'.$this->map['search'].'%')->pluck('id')->toArray();
$manage_ids = $taskOwnerModel->formatQuery(['task_id'=>['in',$ids]])->pluck('manage_id')->toArray();
$map['manage_id'] = ['in',$manage_ids];
}
}
}else{
if(isset($this->map['search_type']) && !empty($this->map['search_type'])){
$map['manage_id'] = $this->map['manage_id'];
}
}
return $map;
}
... ... @@ -210,10 +215,11 @@ class TaskController extends BaseController
*/
public function getUserTaskList(){
$taskOwnerModel = new TaskOwner();
$this->map['manage_id'] = $this->manage['id'];
$lists = $taskOwnerModel->lists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
$taskModel = new Task();
$map = $this->searchUserParam($taskOwnerModel,$taskModel);
$lists = $taskOwnerModel->lists($map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
$managerModel = new Manage();
foreach ($lists['list'] as $k => $v){
$taskInfo = $taskModel->read(['id'=>$v['task_id']]);
... ... @@ -225,4 +231,34 @@ class TaskController extends BaseController
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :我的任务搜索参数
* @name :searchUserParam
* @author :lyh
* @method :post
* @time :2023/9/5 15:00
*/
public function searchUserParam(&$taskOwnerModel,&$taskModel){
$map = [];
if (isset($this->map['search_type']) && !empty($this->map['search_type'])){
if(isset($this->map['search']) && !empty($this->map['search'])) {
$projectModel = new Project();
if($this->map['search_type'] == 'project'){
$ids = $projectModel->where('title', 'like', '%' . $this->map['search'] . '%')->pluck('id')->toArray();
$manage_ids = $taskOwnerModel->formatQuery(['project'=>['in',$ids],'manage_id'=>$this->manage['id']])->pluck('manage_id')->toArray();
$map['manage_id'] = ['in',$manage_ids];
}else{
$ids = $taskModel->where('content', 'like','%'.$this->map['search'].'%')->pluck('id')->toArray();
$manage_ids = $taskOwnerModel->formatQuery(['task_id'=>['in',$ids],'manage_id'=>$this->manage['id']])->pluck('manage_id')->toArray();
$map['manage_id'] = ['in',$manage_ids];
}
}else{
$map['manage_id'] = $this->manage['id'];
}
}else{
$map['manage_id'] = $this->manage['id'];
}
return $map;
}
}
... ...
... ... @@ -36,13 +36,6 @@ class ATemplateModuleController extends BaseController
* @time :2023/6/28 16:55
*/
public function save(ATemplateModuleRequest $ATemplateModuleRequest,ATemplateModuleLogic $ATemplateModuleLogic){
if(isset($this->param['id'])){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
}
$ATemplateModuleRequest->validated();
$ATemplateModuleLogic->aTemplateModuleSave();
$this->response('success');
... ...
... ... @@ -30,6 +30,7 @@ class ProjectMenuController extends BaseController
* @time :2023/6/21 17:24
*/
public function lists(ProjectMenuLogic $projectMenuLogic){
$lists = $projectMenuLogic->MenuList($this->map);
$this->response('success',Code::SUCCESS,$lists);
}
... ... @@ -137,4 +138,21 @@ class ProjectMenuController extends BaseController
$list = $projectMenuLogic->roleMenuInfo();
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :排序
* @name :setSort
* @author :lyh
* @method :post
* @time :2023/8/10 16:40
*/
public function sort(ProjectMenuLogic $projectMenuLogic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'ID不能为空',
]);
$projectMenuLogic->setParamStatus();
$this->response('success');
}
}
... ...
... ... @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\User\UserLogic;
use App\Http\Requests\Aside\User\UserRequest;
use App\Models\Project\Project;
use App\Models\User\ProjectRole;
use App\Models\User\User;
use App\Models\User\User as UserModel;
... ... @@ -145,4 +146,33 @@ class ProjectUserController extends BaseController
$list = $roleModel->list($this->map);
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :排序
* @name :setSort
* @author :lyh
* @method :post
* @time :2023/8/10 16:40
*/
public function sort(UserLogic $userLogic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'ID不能为空',
]);
$userLogic->setParamStatus();
$this->response('success');
}
/**
* @remark :保存用户获取项目列表
* @name :getProjectList
* @author :lyh
* @method :post
* @time :2023/9/6 9:06
*/
public function getProjectList(Project $project){
$lists = $project->list(['type'=>['!=',$project::TYPE_ZERO]],'id',['id','title']);
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
<?php
/**
* @remark :
* @name :UserLogController.php
* @author :lyh
* @method :post
* @time :2023/9/5 16:07
*/
namespace App\Http\Controllers\Aside\User;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Manage\Manage;
use App\Models\User\User;
use App\Models\User\UserLogin;
class UserLogController extends BaseController
{
/**
* @remark :用户日志
* @name :lists
* @author :lyh
* @method :post
* @time :2023/9/5 16:10
*/
public function lists(UserLogin $user){
$userModel = new User();
$map = $this->searchParam($userModel);
$lists = $user->lists($map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$info = $userModel->read(['id'=>$v['user_id']]);
$v['mobile'] = $info['mobile'] ?? '';
$v['name'] = $info['name'] ?? '';
$v['type'] = ($v['type'] == 0) ? '用户登录' : '管理员登录';
if(!empty($v['remark'])){
$v['remark'] = $this->handleRemark($userModel,$v['remark']);
}
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :搜索参数
* @name :searchParam
* @author :lyh
* @method :post
* @time :2023/9/5 16:56
*/
public function searchParam(&$userModel){
$map = [];
if(isset($this->map['mobile']) && !empty($this->map['mobile'])){
$ids = $userModel->where('mobile', 'like', '%' . $this->map['mobile'] . '%')->pluck('id')->toArray();
$map['user_id'] = ['in',$ids];
}elseif (isset($this->map['name']) && !empty($this->map['name'])){
$ids = $userModel->where('name', 'like', '%' . $this->param['name'] . '%')->pluck('id')->toArray();
$map['user_id'] = ['in',$ids];
}
if(isset($this->map['created_at'])){
$map['created_at'] = $this->map['created_at'];
}
return $map;
}
/**
* @remark :处理备注
* @name :handleRemark
* @author :lyh
* @method :post
* @time :2023/9/5 17:21
*/
public function handleRemark(&$managerModel,$remark){
$arr = explode(':',$remark);
$managerInfo = $managerModel->read(['id'=>$arr[1]]);
if($managerInfo !== false){
$remark = $arr[0].':'.$managerInfo['name'];
}
return $remark;
}
}
... ...
<?php
/**
* @remark :
* @name :CNoticeController.php
* @author :lyh
* @method :post
* @time :2023/9/12 10:04
*/
namespace App\Http\Controllers\Bside\BCom;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingLogic;
use App\Models\Com\UpdateNotify;
use App\Models\Com\UpdateProgress;
use App\Models\Project\Country as CountryModel;
use App\Models\RouteMap\RouteMap;
use App\Models\WebSetting\WebSettingCountry;
use Illuminate\Http\Request;
/**
* @remark :通知C端
* @name :CNoticeController
* @author :lyh
* @method :post
* @time :2023/9/12 10:38
*/
class CNoticeController extends BaseController
{
/**
* 更新通知C端
* @param Request $request
* @param WebSettingLogic $webSettingLogic
*/
public function sendNotify(){
$updateProgressModel = new UpdateProgress();
$progressInfo = $updateProgressModel->formatQuery(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']])->orderBy('id','desc')->first();
if((!empty($progressInfo))){
$progressInfo = $progressInfo->toArray();
if(($progressInfo['total_num'] > $progressInfo['current_num'])){
$this->response('当前页面正在生成了,请完成后再点击',Code::SUCCESS,$progressInfo);
}
}
//通知更新
if($this->param['type'] == UpdateNotify::TYPE_MASTER){
$this->updateMaster();
}else{
$this->updateMinorLanguages();
}
$urlStr = $this->getString($this->param['type'],$this->param['page']);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($urlStr, true) . PHP_EOL, FILE_APPEND);
$this->curlGet($urlStr);
$this->response('更新成功');
}
/**
* @remark :主站通知
* @name :updateMaster
* @author :lyh
* @method :post
* @time :2023/9/12 14:46
*/
public function updateMaster(){
try {
$updateNotifyModel = new UpdateNotify();
if($this->param['page'] == UpdateNotify::PAGE_ALL){
//如果是更新所有
$routeMapModel = new RouteMap();
$count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count();
$updateNotifyModel->edit(['status' => 1], ['project_id' => $this->user['project_id'], 'status' => 0]);
$this->addProgress($count,$this->param['type'],$this->param['page']);
}elseif($this->param['page'] == UpdateNotify::PAGE_SINGLE){
//更新所有已修改的更新
$count = $updateNotifyModel->formatQuery(['project_id' => $this->user['project_id'], 'status' => 0])->count();
$updateNotifyModel->edit(['status' => 1], ['project_id' => $this->user['project_id'], 'status' => 0]);
$this->addProgress($count,$this->param['type'],$this->param['page']);
}else{
//根据传递的参数更新
$count = count($this->param['url']);
$extent = json_encode(['url'=>$this->param['url']]);
$this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
}
}catch (\Exception $e){
$this->response('error',Code::USER_ERROR);
}
return true;
}
/**
* @remark :更新小语种
* @name :updateMinorLanguages
* @author :lyh
* @method :post
* @time :2023/9/12 14:48
*/
public function updateMinorLanguages(){
$updateNotifyModel = new UpdateNotify();
try {
if($this->param['page'] == UpdateNotify::PAGE_ALL){
//如果是更新所有
$routeMapModel = new RouteMap();
$count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count();
$updateNotifyModel->edit(['minor_languages_status' => 1], ['project_id' => $this->user['project_id'], 'minor_languages_status' => 0]);
$extent = json_encode(['language'=>$this->param['language']]);
$this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
}else{
//根据传递的参数更新
$count = count($this->param['url']);
$extent = json_encode(['url'=>$this->param['url'],'language'=>$this->param['language']]);
$this->addProgress($count,$this->param['type'],$this->param['page'],$extent);
}
}catch (\Exception $e){
$this->response('error',Code::USER_ERROR);
}
return true;
}
/**
* @remark :curl请求
* @name :curlGet
* @author :lyh
* @method :post
* @time :2023/9/12 10:10
*/
public function curlGet($url){
$ch1 = curl_init();
$timeout = 0;
curl_setopt($ch1, CURLOPT_URL, $url);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_ENCODING, '');
curl_setopt($ch1, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch1, CURLOPT_HTTPHEADER, array());
curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
$access_txt = curl_exec($ch1);
curl_close($ch1);
return json_decode($access_txt, true);
}
/**
* @remark :生成一条更新记录
* @name :addProgress
* @author :lyh
* @method :post
* @time :2023/9/6 17:01
*/
public function addProgress($count,$type,$page,$extend = ''){
$data = [
'total_num'=>$count,
'current_num'=>0,
'type'=>$type,
'page'=>$page,
'extends'=>!empty($extend) ? $extend : json_encode([]),
'project_id'=>$this->user['project_id'],
'created_at'=>date('Y-m-d H;i:s')
];
$updateProgressModel = new UpdateProgress();
return $updateProgressModel->insert($data);
}
/**
* @remark :通知参数处理
* @name :getString
* @author :lyh
* @method :post
* @time :2023/9/6 17:03
*/
public function getString($type,$page){
$param = [
'project_id' => $this->user['project_id'],
'type' => $type,
'route' => $page
];
$string = http_build_query($param);
return $this->user['domain'].'api/updateHtmlNotify/?' . $string;
}
/**
* @remark :获取当前项目选中的语种
* @name :getCountry
* @author :lyh
* @method :post
* @time :2023/9/12 15:20
*/
public function getCountry(){
$countryModel = new CountryModel();
$info = $countryModel->read(['project_id'=>$this->user['project_id']],['id','country_lists']);
$ids = [];
if($info !== false){
$ids = explode(',',$info['country_lists']);
}
$webSettingCountryModel = new WebSettingCountry();
$lists = $webSettingCountryModel->list(['id'=>['in',$ids]],'id',['id','name','country_img']);
if (!empty($lists)){
foreach ($lists as $k => $v){
$lists[$k]['image_link'] = url('upload/country/' . $v['country_img']);
}
}
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
... ... @@ -3,9 +3,11 @@
namespace App\Http\Controllers\Bside\BCom;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\User\UserLogic;
use App\Models\Project\DeployBuild;
use App\Models\Project\Project;
use App\Models\User\ProjectMenu as ProjectMenuModel;
use App\Models\User\ProjectRole as ProjectRoleModel;
... ... @@ -26,14 +28,11 @@ class ComController extends BaseController
//根据当前登录用户角色返回用户菜单列表
$projectMenuModel = new ProjectMenuModel();
if($this->user['role_id'] != 0){
$projectRoleModel = new ProjectRoleModel();
$info = $projectRoleModel->read(['id'=>$this->user['role_id']]);
$info['role_menu'] = trim($info['role_menu'],',');
$lists = $projectMenuModel->where(['status'=>0,'is_role'=>0])->whereIn('id',explode(',',$info['role_menu']))->get();
$this->map = $this->getNoAdminMenuCondition();
}else{
$lists = $projectMenuModel->where(['is_role'=>0])->get();
$this->map = $this->getAdminMenuCondition();
}
$lists = $lists->toArray();
$lists = $projectMenuModel->list($this->map,'sort');
$menu = array();
foreach ($lists as $k => $v){
$v = (array)$v;
... ... @@ -45,6 +44,7 @@ class ComController extends BaseController
$this->response('当前用户菜单列表',Code::SUCCESS,$menu);
}
/**
* @name :获取当前项目详情
* @author :liyuhang
... ... @@ -59,22 +59,96 @@ class ComController extends BaseController
}
/**
* @remark :非超级管理员菜单列表
* @name :getRoleMenuLis
* @author :lyh
* @method :post
* @time :2023/9/6 11:47
*/
public function getNoAdminMenuCondition(){
$code = $this->getIsHome();
$projectRoleModel = new ProjectRoleModel();
$info = $projectRoleModel->read(['id'=>$this->user['role_id']]);
if($code != 1){
$info['role_menu'] = trim(str_replace(',11,',',',','.$info['role_menu'].','),',');
}
$this->map = [
'status'=>0,
'is_role'=>0,
'id'=>['in',explode(',',$info['role_menu'])]
];
return $this->map;
}
/**
* @remark :超级管理员菜单列表
* @name :getAdminMenuCondition
* @author :lyh
* @method :post
* @time :2023/9/6 13:53
*/
public function getAdminMenuCondition(){
$this->map['status'] = 0;
$code = $this->getIsHome();
if($code != 1){
$this->map['id'] = ['!=',11];//排除菜单网站装修
}
return $this->map;
}
/**
* @remark :查看是否显示网站装饰
* @name :getIsHome
* @author :lyh
* @method :post
* @time :2023/9/6 11:30
*/
public function getIsHome(){
if(isset($this->user['manager_id'])){
return 1;
}
$deployBuild = new DeployBuild();
$info = $deployBuild->read(['project_id'=>$this->user['project_id']]);
if(!empty($info['configuration'])){
$configuration = Arr::s2a($info['configuration']);
if(isset($configuration['is_home']) && ((int)$configuration['is_home'] != 0)){
return 1;
}
}
return 0;
}
/**
* @name :登录用户编辑资料/修改密码
* @author :liyuhang
* @method
*/
public function edit_info(){
$this->request->validate([
'password'=>['required'],
'name'=>['required'],
],[
'password.required'=>'密码必须填写',
'name.required'=>'名称必须填写',
'oldPassword'=>'required',
'password' => 'required',
'confirm'=>'required',
], [
'oldPassword.required' => '请输入原密码',
'password.required' => '请输入新密码',
'confirm.required' => '请再次输入新密码',
]);
$userLogic = new UserLogic();
$this->param['id'] = $this->uid;
$userLogic->edits($this->param);
$this->response('编辑成功');
//查询员密码是否正确
$userModel = new User();
$info = $userModel->read(['id'=>$this->user['id']]);
if($info['password'] != base64_encode(md5($this->param['oldPassword']))){
$this->response('原密码错误',Code::USER_ERROR);
}
if($this->param['password'] != $this->param['confirm']){
$this->response('两次密码不一致');
}
$rs = $userModel->edit(['password'=>base64_encode(md5($this->param['password']))],['id'=>$this->user['id']]);
if($rs === false){
$this->response('系统错误',Code::SYSTEM_ERROR);
}
Cache::pull($info['token']);
$this->response('success');
}
/**
... ...
... ... @@ -5,12 +5,7 @@ namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Http\Controllers\Controller;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Http\Requests\Scene;
use App\Models\File\File;
use App\Models\File\Image;
use App\Models\User\User as UserModel;
use App\Services\CosService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Exceptions\HttpResponseException;
... ... @@ -58,7 +53,7 @@ class BaseController extends Controller
public function getParam(){
foreach ($this->param as $k => $v){
if(is_array($v)){
continue;
$this->map[$k] = $v;
}else{
if(empty($v) && ($v == null)){
unset($this->param[$k]);
... ... @@ -96,7 +91,7 @@ class BaseController extends Controller
break;
case "end_at":
$this->_btw[1] = $v;
$this->map['updated_at'] = ['between', $this->_btw];
$this->map['created_at'] = ['between', $this->_btw];
break;
default:
if (!empty($v) || $v == 0) {
... ...
... ... @@ -58,36 +58,23 @@ class BlogCategoryController extends BaseController
'id.required' => 'ID不能为空'
]);
$info = $blogCategoryLogic->info_blog_category();
$info['alias'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG_CATE, $info['id'], $this->user['project_id']);
$info['url'] = $this->user['domain'] . RouteMap::PATH_BLOG_CATE . '/' . $info['alias'];
$info['url'] = $this->user['domain'] . $info['alias'];
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name :添加分类
* @author :liyuhang
* @method
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/9/7 14:04
*/
public function add(BlogCategoryRequest $request,BlogCategoryLogic $blogCategoryLogic){
public function save(BlogCategoryRequest $request,BlogCategoryLogic $blogCategoryLogic){
$request->validated();
//添加时,验证分类上级分类是否有,有则更新到当前分类中,没有时直接添加
$blogCategoryLogic->add_blog_category();
$blogCategoryLogic->categorySave();
$this->response('success');
}
/**
* @name :编辑分类
* @author :liyuhang
* @method
*/
public function edit(BlogCategoryRequest $request,BlogCategoryLogic $blogCategoryLogic){
$request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$blogCategoryLogic->edit_blog_category();
$this->response('success');
}
/**
* @name :编辑状态/与排序
... ... @@ -116,7 +103,7 @@ class BlogCategoryController extends BaseController
'id.required' => 'ID不能为空',
'id.array' => 'ID为数组',
]);
$blogCategoryLogic->del_blog_category();
$blogCategoryLogic->delBlogCategory();
//TODO::写入操作日志
$this->response('success');
}
... ...
... ... @@ -9,33 +9,32 @@ use App\Http\Logic\Bside\Blog\BlogLabelLogic;
use App\Http\Logic\Bside\Blog\BlogLogic;
use App\Http\Requests\Bside\Blog\BlogRequest;
use App\Models\Blog\Blog as BlogModel;
use App\Models\Blog\BlogCategory;
use App\Models\RouteMap\RouteMap;
use App\Models\User\User;
class BlogController extends BaseController
{
//通知别名
public $updateModelView = 'blog';
/**
* @name :博客列表
* @author :liyuhang
* @method
* @remark :博客列表
* @name :lists
* @author :lyh
* @method :post
* @time :2023/9/14 10:45
*/
public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic,BlogLabelLogic $blogLabelLogic){
//搜索条件
$this->map['project_id'] = $this->user['project_id'];
$lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order = 'sort',
['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']);
if(!empty($lists['list'])){
$this->map = $this->searchParam();
$lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order = 'sort', ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']);
if(!empty($lists) && !empty($lists['list'])){
//获取当前项目的所有分类
$data = $this->getCategoryList();
$user = new User();
foreach ($lists['list'] as $k => $v){
//获取分类名称
$v = $blogCategoryLogic->get_category_name($v);
//获取标签名称
$v = $blogLabelLogic->get_label_name($v);
$v['url'] = $this->user['domain'] . RouteMap::getRoute(RouteMap::SOURCE_BLOG, $v['id'], $this->user['project_id']);
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'] .$v['url'];
$v['image_link'] = getImageUrl($v['image']);
$v['operator_name'] = (new User())->getName($v['operator_id']);
$v['operator_name'] = $user->getName($v['operator_id']);
$lists['list'][$k] = $v;
}
}
... ... @@ -43,6 +42,61 @@ class BlogController extends BaseController
}
/**
* @remark :处理列表返回参数
* @name :handleReturnParam
* @author :lyh
* @method :post
* @time :2023/9/14 10:01
*/
public function searchParam(){
$this->map['project_id'] = $this->user['project_id'];
if(isset($this->map['category_id']) && !empty($this->map['category_id'])){
$this->map['category_id'] = ['like','%,'.$this->map['category_id'].',%'];
}
return $this->map;
}
/**
* @remark :获取所有分类
* @name :getCategoryList
* @author :lyh
* @method :post
* @time :2023/9/14 13:56
*/
public function getCategoryList(){
$categoryModel = new BlogCategory();
$data = [];
$cateList = $categoryModel->list(['project_id'=>$this->user['project_id']],['id','name']);
if(!empty($cateList)){
foreach ($cateList as $value){
$data[$value['id']] = $value['name'];
}
}
return $data;
}
/**
* @remark :获取分类名称
* @name :categoryName
* @author :lyh
* @method :post
* @time :2023/9/14 13:58
*/
public function categoryName($category_id,$data){
$category_name = '';
if(!empty($category_id) && !empty($data)){
$arr = explode(',',trim($category_id,','));
foreach ($arr as $v){
if(isset($data[$v])){
$category_name .= $data[$v].',';
}
}
$category_name = trim($category_name,',');
}
return $category_name;
}
/**
* @remark :根据状态数量
* @name :getStatusNumber
* @author :lyh
... ... @@ -76,34 +130,20 @@ class BlogController extends BaseController
],[
'id.required' => 'ID不能为空'
]);
$info = $blogLogic->blog_info();
$info = $blogLogic->blogInfo();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name :添加博客
* @author :liyuhang
* @method
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/9/7 13:40
*/
public function add(BlogRequest $request,BlogLogic $blogLogic){
public function save(BlogRequest $request,BlogLogic $blogLogic){
$request->validated();
$blogLogic->blogAdd();
$this->response('success');
}
/**
* @name :编辑博客
* @author :liyuhang
* @method
*/
public function edit(BlogRequest $request,BlogLogic $blogLogic){
$request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$blogLogic->blogEdit();
$blogLogic->blogSave();
$this->response('success');
}
... ... @@ -140,7 +180,7 @@ class BlogController extends BaseController
'id.required' => 'ID不能为空',
'id.array' => 'ID为数组',
]);
$blogLogic->blog_status();
$blogLogic->blogStatus();
//TODO::写入日志
$this->response('success');
}
... ... @@ -157,7 +197,7 @@ class BlogController extends BaseController
'id.required' => 'ID不能为空',
'id.array' => 'ID为数组',
]);
$blogLogic->blog_del();
$blogLogic->blogDel();
$this->response('success');
}
... ...
... ... @@ -23,6 +23,8 @@ use App\Models\Service\Service;
use App\Models\Sms\SmsLog;
use App\Models\Template\Template;
use App\Models\Template\TemplateModule;
use App\Models\User\DeptUser;
use App\Models\User\ProjectRole;
use App\Models\User\User;
use App\Models\User\User as UserModel;
use App\Utils\EncryptUtils;
... ... @@ -182,7 +184,8 @@ class LoginController extends BaseController
$message = simplexml_load_string($message, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOERROR);
$jsonData = json_encode($message);
$arrayData = json_decode($jsonData, true);
$data = $this->setWechat($arrayData['ToUserName'],$arrayData['EventKey']);
//gh_27174ac5c9d8,gh_27174ac5c9d8
$data = $this->setWechat($arrayData['FromUserName'],$arrayData['EventKey']);
if($data['code'] == 0){//登录失败,请先绑定
$resMessage = $data['message'];
}elseif($data['code'] == 1){
... ... @@ -228,22 +231,32 @@ class LoginController extends BaseController
*/
public function globalSo_v6_login(UserLoginLogic $logic){
$common = new Common();
$arr = $common->decrypt($this->param['token']);
$arr = $common->decrypt(urldecode($this->param['token']));
if(empty($arr)){
$this->response('登录失败',Code::USER_ERROR);
$this->response('非法请求!',Code::USER_ERROR);
}
if (empty($arr['timestamp']) || time() - $arr['timestamp'] > 60) {
$this->response('授权已过期,请重新获取授权码!',Code::USER_ERROR);
}
//没有from_order_id的项目 进入演示版 运营中心
$arr['from_order_id'] = 0;
$arr['from_order_id'] = $arr['from_order_id'] ?? 0;
if(!$arr['from_order_id']){
//有账号就直接登录, 没有账号创建账号登录
$user = (new User())->where('project_id', Project::DEMO_PROJECT_ID)->where('mobile', $arr['phone'])->first();
if(!$user){
$user = new User();
$user->project_id = Project::DEMO_PROJECT_ID;
$user->role_id = ProjectRole::OPERATION_CENTER_ID;
$user->mobile = $arr['phone'];
$user->password = base64_encode(md5('v6.' . substr($arr['phone'], -6)));
$user->name = $arr['phone'];
$user->name = $arr['name'] ?? $arr['phone'];
$user->save();
//运营中心组织
$dept_user = new DeptUser();
$dept_user->dept_id = DeptUser::OPERATION_CENTER_ID;
$dept_user->project_id = Project::DEMO_PROJECT_ID;
$dept_user->user_id = $user->id;
$dept_user->save();
}
$data = [
'user_id'=>$user['id'],
... ... @@ -287,21 +300,4 @@ class LoginController extends BaseController
return $data;
}
public function ceshi(){
$templateModel = new TemplateModule();
$list = $templateModel->list();
$imageModel = new ImageModel();
foreach ($list as $k=>$v){
if (strpos($v['image'], '.') !== false) {
$v['image'] = '/upload'.$v['image'];
}else{
$info = $imageModel->read(['hash'=>$v['image']]);
if($info !== false){
$v['image'] = $info['path'];
}
}
$templateModel->edit(['image'=>$v['image']],['id'=>$v['id']]);
}
$this->response('success');
}
}
... ...
... ... @@ -82,28 +82,14 @@ class NavController extends BaseController
*/
public function urls(){
// todo::需要配合 c端来
return $this->success([
[
'url' => 'index',
'name' => '首页'
],
[
'url' => 'news',
'name' => '新闻'
],
[
'url' => 'products',
'name' => '产品'
],
[
'url' => 'search',
'name' => '搜索页'
],
[
'url' => 'blog',
'name' => '博客'
]
]);
$data = [
['url'=>'index', 'name'=>'首页'],
['url'=>'news', 'name'=>'新闻'],
['url'=>'products', 'name'=>'产品'],
['url'=>'search', 'name'=>'搜索页'],
['url'=>'blog', 'name'=>'博客']
];
$this->response('success',Code::SUCCESS,$data);
}
/**
... ...
... ... @@ -58,34 +58,20 @@ class NewsCategoryController extends BaseController
'id.required' => 'ID不能为空'
]);
$info = $newsCategoryLogic->info_news_category();
$info['alias'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS_CATE, $info['id'], $this->user['project_id']);
$info['url'] = $this->user['domain'] . RouteMap::PATH_NEWS_CATE . '/' . $info['alias'];
$info['url'] = $this->user['domain'] . $info['alias'];
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name :添加分类
* @author :liyuhang
* @method
*/
public function add(NewsCategoryRequest $request,NewsCategoryLogic $newsCategoryLogic){
$request->validated();
//添加时,验证分类上级分类是否有,有则更新到当前分类中,没有时直接添加
$newsCategoryLogic->add_news_category();
$this->response('success');
}
/**
* @name :编辑分类
* @author :liyuhang
* @method
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/9/7 14:51
*/
public function edit(NewsCategoryRequest $request,NewsCategoryLogic $newsCategoryLogic){
$request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$newsCategoryLogic->edit_news_category();
public function save(NewsCategoryRequest $request,NewsCategoryLogic $newsCategoryLogic){
$request->validated();
$newsCategoryLogic->newsCategorySave();
$this->response('success');
}
... ...
... ... @@ -8,6 +8,7 @@ use App\Http\Logic\Bside\News\NewsCategoryLogic;
use App\Http\Logic\Bside\News\NewsLogic;
use App\Http\Requests\Bside\News\NewsRequest;
use App\Models\News\News as NewsModel;
use App\Models\News\NewsCategory;
use App\Models\RouteMap\RouteMap;
use App\Models\User\User;
... ... @@ -24,21 +25,18 @@ class NewsController extends BaseController
* @method
*/
public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){
$this->map['project_id'] = $this->user['project_id'];
$this->map = $this->searchParam();
$lists = $news->lists($this->map,$this->page,$this->row,$this->order = 'sort',
['id','category_id','operator_id','status','created_at','updated_at','image','name','sort','url']);
if(!empty($lists['list'])){
if(!empty($lists) && !empty($lists['list'])){
//获取当前项目的所有分类
$data = $this->getCategoryList();
$user = new User();
foreach ($lists['list'] as $k => $v){
if(!empty($v['category_id'])){
$v = $newsCategoryLogic->get_category_name($v);
}
$v['url'] = $this->user['domain'] . RouteMap::getRoute(RouteMap::SOURCE_NEWS, $v['id'], $this->user['project_id']);
if(!empty($v['image'])){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'] . $v['url'];
$v['image_link'] = getImageUrl($v['image']);
}
if(!empty($v['operator_id'])){
$v['operator_name'] = (new User())->getName($v['operator_id']);
}
$v['operator_name'] = $user->getName($v['operator_id']);
$lists['list'][$k] = $v;
}
}
... ... @@ -46,6 +44,61 @@ class NewsController extends BaseController
}
/**
* @remark :处理列表返回参数
* @name :handleReturnParam
* @author :lyh
* @method :post
* @time :2023/9/14 10:01
*/
public function searchParam(){
$this->map['project_id'] = $this->user['project_id'];
if(isset($this->map['category_id']) && !empty($this->map['category_id'])){
$this->map['category_id'] = ['like','%,'.$this->map['category_id'].',%'];
}
return $this->map;
}
/**
* @remark :获取所有分类
* @name :getCategoryList
* @author :lyh
* @method :post
* @time :2023/9/14 13:56
*/
public function getCategoryList(){
$categoryModel = new NewsCategory();
$data = [];
$cateList = $categoryModel->list(['project_id'=>$this->user['project_id']],['id','name']);
if(!empty($cateList)){
foreach ($cateList as $value){
$data[$value['id']] = $value['name'];
}
}
return $data;
}
/**
* @remark :获取分类名称
* @name :categoryName
* @author :lyh
* @method :post
* @time :2023/9/14 13:58
*/
public function categoryName($category_id,$data){
$category_name = '';
if(!empty($category_id) && !empty($data)){
$arr = explode(',',trim($category_id,','));
foreach ($arr as $v){
if(isset($data[$v])){
$category_name .= $data[$v].',';
}
}
$category_name = trim($category_name,',');
}
return $category_name;
}
/**
* @remark :根据状态数量
* @name :getStatusNumber
* @author :lyh
... ... @@ -78,38 +131,24 @@ class NewsController extends BaseController
],[
'id.required' => 'ID不能为空',
]);
$info = $newsLogic->news_info();
$info['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $info['id'], $this->user['project_id']);
$info['url'] = $this->user['domain'] . $info['route'];
$info['image_link'] = getImageUrl($info['image']);
$info = $newsLogic->newsInfo();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name :添加新闻
* @return json
* @author :liyuhang
* @method
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/9/7 11:22
*/
public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){
public function save(NewsRequest $newsRequest,NewsLogic $newsLogic){
$newsRequest->validated();
$newsLogic->news_add();
$newsLogic->newsSave();
$this->response('success');
}
/**
* @name :编辑
* @author :liyuhang
* @method
*/
public function edit(NewsRequest $newsRequest,NewsLogic $newsLogic){
$newsRequest->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$newsLogic->news_edit();
$this->response('success');
}
/**
* @name :编辑新闻seo
... ... @@ -160,8 +199,7 @@ class NewsController extends BaseController
'id.required' => 'ID不能为空',
'id.array' => 'ID为数组',
]);
$newsLogic->news_del();
//TODO::清空相关资源/写入日志
$newsLogic->newsDel();
$this->response('success');
}
... ...
... ... @@ -31,16 +31,15 @@ class CategoryController extends BaseController
*/
public function index(Category $category)
{
if(!empty($this->map['title'])){
$this->map['title'] = ['like','%'.$this->map['title'].'%'];
}
$this->map['project_id'] = $this->user['project_id'];
$this->map = $this->searchParam();
$filed = ['id', 'project_id', 'pid', 'title', 'image', 'route','keywords', 'describe', 'status','created_at'];
$list = $category->list($this->map,'id',$filed);
$data = [];
if(!empty($list)){
foreach ($list as $k =>$v){
$v = $this->handleParam($v);
$v['url'] = $this->user['domain'] . $v['route'];
$v['product_num'] = Product::where('category_id','like' ,'%,'.$v['id'].',%')->count();;
$v['image_link'] = getImageUrl($v['image']);
$list[$k] = $v;
}
$data = $this->getListSon($list);
... ... @@ -49,17 +48,18 @@ class CategoryController extends BaseController
}
/**
* @remark :分类处理参数
* @name :handleParam
* @remark :搜索参数处理
* @name :searchParam
* @author :lyh
* @method :post
* @time :2023/8/17 11:10
* @time :2023/9/14 14:57
*/
public function handleParam($v){
$v['url'] = $this->user['domain'] . RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_CATE, $v['id'], $v['project_id']);
$v['product_num'] = Product::where('category_id','like' ,'%,'.$v['id'].',%')->count();;
$v['image_link'] = getImageUrl($v['image']);
return $v;
public function searchParam(){
if(!empty($this->map['title'])){
$this->map['title'] = ['like','%'.$this->map['title'].'%'];
}
$this->map['project_id'] = $this->user['project_id'];
return $this->map;
}
/**
... ... @@ -126,7 +126,6 @@ class CategoryController extends BaseController
],[
'ids.required' => 'ID不能为空'
]);
$data = $logic->categoryDelete();
return $this->success($data);
}
... ...
... ... @@ -36,13 +36,13 @@ class KeywordController extends BaseController
$this->map['title'] = ['like','%'.$this->map['title'].'%'];
}
$this->map['project_id'] = $this->user['project_id'];
$filed = ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at'];
$filed = ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at','route'];
$data = $keyword->lists($this->map,$this->page,$this->row,$this->order,$filed);
if(!empty($data)){
foreach ($data['list'] as &$v){
$v['product_num'] = Product::where('keyword_id','like' ,'%,'.$v['id'].',%')->count();
$v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']);
$v['url'] = $this->user['domain'] . RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
$v['url'] = $this->user['domain'] . $v['route'];
}
}
return $this->response('success',Code::SUCCESS,$data);
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Product;
use App\Enums\Common\Code;
use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Product\ProductLogic;
use App\Http\Requests\Bside\Product\ProductRequest;
... ... @@ -13,9 +14,12 @@ use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\Template\BSetting;
use App\Models\Template\BTemplate;
use App\Models\User\User;
use App\Rules\Ids;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
/**
... ... @@ -36,7 +40,36 @@ class ProductController extends BaseController
*/
public function index(Product $product)
{
$this->order = 'sort';
$this->map = $this->searchParam();
$filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' ,
'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at'];
$lists = $product->lists($this->map,$this->page,$this->row,$this->order = ['sort','id'],$filed);
if(!empty($lists) && !empty($lists['list'])){
$cate_data = $this->getCategoryList();//分类
$key_data = $this->getKeywordsList();//关键字
//获取当前用户选择的模版
$templateSettingModel = new BSetting();
$info = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
$userModel = new User();
foreach ($lists['list'] as $k=>$v){
$v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
$v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
$v['created_uid_text'] = $userModel->getName($v['created_uid']);
$v['is_renovation'] = $this->getProductIsRenovation($info,$v['id']);
$lists['list'][$k] = $v;
}
}
return $this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :搜索参数处理
* @name :searchParam
* @author :lyh
* @method :post
* @time :2023/9/14 14:32
*/
public function searchParam(){
if(isset($this->map['title']) && !empty($this->map['title'])){
$this->map['title'] = ['like','%'.$this->map['title'].'%'];
}
... ... @@ -44,17 +77,135 @@ class ProductController extends BaseController
$this->map['category_id'] = ['like','%'.$this->map['category_id'].'%'];
}
$this->map['project_id'] = $this->user['project_id'];
$filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' ,
'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at'];
$lists = $product->lists($this->map,$this->page,$this->row,$this->order,$filed);
if(!empty($lists['list'])){
foreach ($lists['list'] as $k=>$v){
//处理参数
$v = $this->handleParam($v);
$lists['list'][$k] = $v;
return $this->map;
}
/**
* @remark :查看产品是否已装修
* @name :getProductIsRenovation
* @author :lyh
* @method :post
* @time :2023/9/13 14:02
*/
public function getProductIsRenovation($info,$id){
if($info !== false){
$webTemplateModel = new BTemplate();
$param = [
'source'=>2,
'project_id'=>$this->user['project_id'],
'source_id'=>$id,
'template_id'=>$info['template_id']
];
$templateInfo = $webTemplateModel->read($param);
if($templateInfo !== false){
return 1;
}
}
return $this->response('success',Code::SUCCESS,$lists);
return 0;
}
/**
* @remark :获取所有分类
* @name :getCategoryList
* @author :lyh
* @method :post
* @time :2023/9/14 13:56
*/
public function getCategoryList(){
$data = Common::get_user_cache('product_category',$this->user['project_id']);
if(empty($data)){
$categoryModel = new Category();
$data = [];
$cateList = $categoryModel->list(['project_id'=>$this->user['project_id']],['id','title']);
if(!empty($cateList)){
foreach ($cateList as $value){
$data[$value['id']] = $value['title'];
}
}
Common::set_user_cache($data,'product_category',$this->user['project_id']);
}
return $data;
}
/**
* @remark :获取所有关键词
* @name :getCategoryList
* @author :lyh
* @method :post
* @time :2023/9/14 13:56
*/
public function getKeywordsList(){
$data = Common::get_user_cache('product_keyword',$this->user['project_id']);
if(empty($data)) {
$keywordModel = new Keyword();
$data = [];
$cateList = $keywordModel->list(['project_id' => $this->user['project_id']], ['id', 'title']);
if (!empty($cateList)) {
foreach ($cateList as $value) {
$data[$value['id']] = $value['title'];
}
}
Common::set_user_cache($data,'product_keyword',$this->user['project_id']);
}
return $data;
}
/**
* @remark :获取分类名称
* @name :categoryName
* @author :lyh
* @method :post
* @time :2023/9/14 13:58
*/
public function categoryName($category_id,$data){
$category_name = '';
if(!empty($category_id) && !empty($data)){
foreach ($category_id as $v){
if(isset($data[$v])){
$category_name .= $data[$v].',';
}
}
$category_name = trim($category_name,',');
}
return $category_name;
}
/**
* @remark :获取关键词名称
* @name :categoryName
* @author :lyh
* @method :post
* @time :2023/9/14 13:58
*/
public function keywordName($keyword_id,$data){
$keyword_name = '';
if(!empty($keyword_id) && !empty($data)){
foreach ($keyword_id as $v){
if(isset($data[$v])){
$keyword_name .= $data[$v].',';
}
}
$keyword_name = trim($keyword_name,',');
}
return $keyword_name;
}
/**
* @remark :详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/8/21 18:12
*/
public function info(Product $product){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$info = $product->read(['id'=>$this->param['id']]);
$info = $this->handleParam($info);
return $this->response('success',Code::SUCCESS,$info);
}
/**
... ... @@ -84,28 +235,13 @@ class ProductController extends BaseController
$v['keyword_id_text'] = trim($v['keyword_id_text'],',');
}
$v['status_text'] = Product::statusMap()[$v['status']] ?? '';
$v['created_uid_text'] = (new User())->read(['id'=>$v['created_uid']])['name'] ?? '';
//获取当前用户选择的模版
$templateSettingModel = new BSetting();
$templateInfo = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
$v['is_renovation'] = $this->getProductIsRenovation($templateInfo,$v['id']);
$v['url'] = $this->user['domain'].$v['route'];
return $v;
}
/**
* @remark :详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/8/21 18:12
*/
public function info(Product $product){
$this->request->validate([
'id'=>'required'
],[
'id.required' => 'ID不能为空'
]);
$info = $product->read(['id'=>$this->param['id']]);
$info = $this->handleParam($info);
return $this->response('success',Code::SUCCESS,$info);
}
/**
... ... @@ -118,8 +254,8 @@ class ProductController extends BaseController
public function save(ProductRequest $request, ProductLogic $logic)
{
$request->validated();
$data = $logic->productSave();
return $this->success($data);
$logic->productSave();
$this->response('success');
}
/**
... ...
... ... @@ -35,20 +35,4 @@ class WebSettingController extends BaseController
$this->response('success');
}
/**
* 更新通知C端
* @param Request $request
* @param WebSettingLogic $webSettingLogic
*/
public function sendNotify(Request $request, WebSettingLogic $webSettingLogic){
$type = $request->input('type', UpdateNotify::TYPE_MASTER);
if (FALSE == in_array($type, [UpdateNotify::TYPE_MASTER, UpdateNotify::TYPE_MINOR]))
$this->response('非法参数!', Code::USER_ERROR);
$list = $webSettingLogic->sendNotifyMessage($type);
if(!empty($list)){
$this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$list);
}
$this->response('success');
}
}
... ...
<?php
/**
* @remark :
* @name :WebSettingSeoController.php
* @author :lyh
* @method :post
* @time :2023/9/11 16:31
*/
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\WebSettingSeoLogic;
class WebSettingSeoController extends BaseController
{
/**
* @remark :获取当前项目seo详情
* @name :info
* @author :lyh
* @method :post
* @time :2023/9/11 16:31
*/
public function info(WebSettingSeoLogic $logic){
$info = $logic->seoInfo();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/9/11 16:32
*/
public function save(WebSettingSeoLogic $logic){
$logic->seoSave();
$this->response('success');
}
}
... ...
... ... @@ -71,6 +71,10 @@ class BTemplateController extends BaseController
* @time :2023/6/29 10:02
*/
public function save(TemplateRequest $templateRequest,BTemplateLogic $BTemplateLogic){
//演示项目,不允许其他号码编辑$this->user['mobile'] != '15928018676' ||
if(($this->user['project_id'] == 1) && ($this->user['mobile'] != '15680871314') && ($this->param['source'] == 1)){
$this->response('演示项目仅支持演示功能,无法更改首页',Code::USER_ERROR);
}
$templateRequest->validated();
$BTemplateLogic->templateSave();
$this->response('success');
... ... @@ -87,4 +91,36 @@ class BTemplateController extends BaseController
$list = $BTemplateLogic->getModuleType();
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :公共主题设置公共head
* @name :setHead
* @author :lyh
* @method :post
* @time :2023/7/10 15:30
*/
public function setHeadFooter(BTemplateLogic $BTemplateLogic){
$this->request->validate([
'head'=>'required',
'footer'=>'required'
],[
'head.required' => 'head不能为空',
'footer.required' => 'footer不能为空'
]);
$BTemplateLogic->setHeadFooterSave();
$this->response('success');
}
/**
* @remark :获取公共主题head
* @name :getHead
* @author :lyh
* @method :post
* @time :2023/7/10 15:30
*/
public function getHeadFooter(BTemplateLogic $BTemplateLogic){
$info = $BTemplateLogic->getHeadFooterList();
$this->response('success',Code::SUCCESS,$info);
}
}
... ...
... ... @@ -54,7 +54,7 @@ class UserController extends BaseController
* @author :liyuhang
* @method
*/
public function edit(UserRequest $request,UserLogic $userLogic){
public function edit(Request $request,UserLogic $userLogic){
$request->validate([
'id'=>['required']
],[
... ...
... ... @@ -35,6 +35,9 @@ class FileController
$this->param = $this->request->all();
$this->config = config('filesystems.disks.upload');
$this->uploads = config('upload.default_file');
//获取当前登录用户详情
$this->token = $this->request->header('token');
$this->cache = Cache::get($this->token);
}
/**
... ... @@ -94,7 +97,7 @@ class FileController
$size = $files->getSize();
$file_type = $files->getClientOriginalExtension();
$mime = $files->getMimeType();
return $this->single($files,$size,$file_type,$mime);
return $this->single($files);
}
}
... ... @@ -105,7 +108,7 @@ class FileController
* @method :post
* @time :2023/6/17 16:32
*/
public function single(&$files,$size,$file_type,$mime = ''){
public function single(&$files){
$hash = hash_file('md5', $files->getPathname());
//查看文件是否存在
$fileModel = new File();
... ... @@ -114,7 +117,7 @@ class FileController
return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path']));
}
$url = $this->config['root'].$this->path;
$fileName = uniqid().rand(10000,99999).'.'.$file_type;
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
//同步数据到cos
if($this->upload_location == 1){
$cosService = new CosService();
... ... @@ -125,7 +128,7 @@ class FileController
return $this->response($files->getError(), Code::USER_ERROR);
}
}
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime);
$this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType());
return $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName));
}
... ... @@ -222,11 +225,10 @@ class FileController
*/
public function downLoad(){
$file_model = new File();
$info = $file_model->read(['path' => $this->param['path']]);
$info = $file_model->read(['path' => str_replace_url($this->param['path'])]);
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
}
if($info['is_cos'] == 1){
$cos = new CosService();
$fileUrl = $cos->getImageUrl($info['path']);
... ... @@ -257,9 +259,6 @@ class FileController
if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
$this->path = $this->uploads['path_a'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m');
}else{
//获取当前登录用户详情
$this->token = $this->request->header('token');
$this->cache = Cache::get($this->token);
//B端上传,upload_method 为 1时 强制上传到本地
if(!isset($this->param['upload_method'])) {
//根据项目上传标识区分上传到cos/本地
... ... @@ -281,10 +280,14 @@ class FileController
* @time :2023/6/29 11:48
*/
public function getFileList(){
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
$this->map['project_id'] = $this->cache['project_id'];
}
$this->map['refer'] = 1;
$fileModel = new File();
$lists = $fileModel->list(['refer'=>1],$order = 'id',['id','hash','type','path','created_at']);
$lists = $fileModel->list($this->map,'id',['id','hash','type','path','created_at']);
foreach ($lists as $k => $v){
$v['file_link'] = getFileUrl($v['hash']);
$v['file_link'] = getFileUrl($v['path']);
$lists[$k] = $v;
}
$this->response('success',Code::SUCCESS,$lists);
... ... @@ -300,7 +303,7 @@ class FileController
public function responseData($path){
$data = [
'file'=>$path,
'file_link'=>getFileUrl($path),
'file_link'=>getFileUrl($path,$this->upload_location),
];
return $data;
}
... ... @@ -314,11 +317,11 @@ class FileController
*/
public function getDownloadUrl(){
$fileModel = new File();
$info = $fileModel->read(['path' => $this->param['path']]);
$info = $fileModel->read(['path' => str_replace_url($this->param['path'])]);
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
}
$data = ['file_download'=>url('a/downLoad/files?path='.$this->param['path'])];
$data = ['file_download'=>url('a/download_files?path='.$info['path'])];
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -16,7 +16,7 @@ use Intervention\Image\Facades\Image;
class ImageController extends Controller
{
public $path = '/upload';//路径
public $path = '';//路径
public $config = '';//存储默认配置
... ... @@ -35,6 +35,7 @@ class ImageController extends Controller
public $map = [];
public $upload_location = 1;//是否同步到cos
//上传图片类型
public $image_type = [
... ... @@ -53,6 +54,9 @@ class ImageController extends Controller
$this->config = config('filesystems.disks.upload');
$this->uploads = config('upload.default_image');
$this->get_param();
//获取当前登录用户详情
$this->token = $this->request->header('token');
$this->cache = Cache::get($this->token);
}
/**
... ... @@ -105,8 +109,13 @@ class ImageController extends Controller
if ($info === false) {
$this->response('指定图片不存在!', Code::USER_ERROR);
}
if($info['is_cos'] == 1){
$filename = getImageUrl($info['path']);
$content = file_get_contents($filename);
$header['Content-Length'] = strlen($content);
}else{
//查看缩略图是否存在
$filename = $this->config['root'] . '/' .$info['path'] . '_' . $w . '_' . $h;
$filename = $this->config['root'] . $info['path'] . '_' . $w . '_' . $h;
if(is_file($filename)){
$content = file_get_contents($filename);
$header['Content-Length'] = strlen($content);
... ... @@ -114,6 +123,7 @@ class ImageController extends Controller
$content = $this->readImageContent($info,$w,$h);
$header['Content-Length'] = strlen($content);
}
}
$header['Content-Type'] = $info['mime'];
return response($content,200,$header);
}
... ... @@ -127,15 +137,11 @@ class ImageController extends Controller
*/
public function readImageContent($info,$w,$h)
{
$path = $this->config['root'] . '/' . $info['path'];
if (!is_file($path)) {
$this->response('指定图片已被系统删除!', Code::USER_ERROR);
}
if ($w > 0 && $h > 0) {
$path = $this->cacheImage($info, $w, $h);
$content = file_get_contents($path);
} else {
$content = file_get_contents($path);
$content = file_get_contents($this->config['root'] . $info['path']);
}
return $content;
}
... ... @@ -160,10 +166,7 @@ class ImageController extends Controller
if ($type == 'multi') {
return $this->multi($files);
}else{
$size = $files->getSize();
$image_type = $files->getClientOriginalExtension();
$mime = $files->getMimeType();
return $this->single($files,$size,$image_type,$mime);
return $this->single($files);
}
}
... ... @@ -175,27 +178,31 @@ class ImageController extends Controller
* @method :post
* @time :2023/6/17 16:30
*/
public function single(&$files,$size,$image_type,$mime){
public function single(&$files){
$hash = hash_file('md5', $files->getPathname());
//查看文件是否存在
$imageModel = new ImageModel();
$image_hash = $imageModel->read(['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0]);
//查看图片是否已上传
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
$param['project_id'] = $this->cache['project_id'];
}
$image_hash = $imageModel->read($param);
if($image_hash !== false){
return $this->response('图片资源',Code::SUCCESS,$this->responseData($image_hash['path']));
}
//保存路径
$url = $this->config['root'].$this->path;
$image_type = $files->getClientOriginalExtension();
$fileName = uniqid().rand(10000,99999).'.'.$image_type;
//上传到cos
if($this->upload_location == 1){
$cosService = new CosService();
$cosService->uploadFile($files,$this->path,$fileName);
}else{
$res = $files->move($url,$fileName);
if ($res === false) {
return $this->response($files->getError(), Code::USER_ERROR);
}
$files->move($url,$fileName);
}
$this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location,$mime);
$this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType());
return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName));
}
... ... @@ -224,10 +231,8 @@ class ImageController extends Controller
}
return true;
}
/**
* @param $info
* @param $w
* @param $h
* @remark :生成缩略图
* @name :cacheImage
* @author :lyh
... ... @@ -242,7 +247,6 @@ class ImageController extends Controller
}
/**
* @param $files
* @remark :多图片上传
* @name :multi
* @author :lyh
... ... @@ -252,30 +256,30 @@ class ImageController extends Controller
private function multi(&$files) {
$data = [];
foreach ($files as $file) {
$size = $file->getSize();
$image_type = $file->getClientOriginalExtension();
$mime = $file->getMimeType();
$imageModel = new ImageModel();
$hash = hash_file('md5', $file->getPathname());
$image_hash = $imageModel->read(['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0]);
//查看图片是否已上传
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
$param['project_id'] = $this->cache['project_id'];
}
$image_hash = $imageModel->read($param);
if($image_hash !== false){
$data[] = $this->responseData($image_hash['path']);
continue;
}
$url = $this->config['root'].$this->path;
$fileName = uniqid().rand(10000,99999).'.'.$file->getClientOriginalExtension();
$image_type = $file->getClientOriginalExtension();
$fileName = uniqid().rand(10000,99999).'.'.$image_type;
//同步数据到cos
if($this->upload_location == 1){
$cosService = new CosService();
$cosService->uploadFile($file,$this->path,$fileName);
}else{
$res = $file->move($url,$fileName);
if ($res === false) {
$this->response($file->getError(), Code::USER_ERROR);
}
$file->move($url,$fileName);
}
//批量存储
$this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location,$mime);
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType());
$data[] = $this->responseData($this->path.'/'.$fileName);
}
$this->response('图片资源',Code::SUCCESS,$data);
... ... @@ -291,7 +295,8 @@ class ImageController extends Controller
*/
public function download(){
$imageModel = new ImageModel();
$info = $imageModel->read(['path' => $this->param['path']]);
;
$info = $imageModel->read(['path' => str_replace_url($this->param['path'])]);
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
}
... ... @@ -342,11 +347,14 @@ class ImageController extends Controller
* @time :2023/6/29 11:48
*/
public function getImageList(){
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
$this->map['project_id'] = $this->cache['project_id'];
}
$imageModel = new ImageModel();
$lists = $imageModel->lists($this->map,$this->page,$this->row);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['image_link'] = getImageUrl($v['hash']);
$v['image_link'] = getImageUrl($v['path']);
$lists['list'][$k] = $v;
}
}
... ... @@ -365,9 +373,6 @@ class ImageController extends Controller
if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
$this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
}else{
//B端上传
$this->token = $this->request->header('token');
$this->cache = Cache::get($this->token);
if(!isset($this->param['upload_method'])){
//根据项目上传标识区分上传到cos/本地
$projectModel = new Project();
... ... @@ -404,11 +409,11 @@ class ImageController extends Controller
*/
public function getDownloadUrl(){
$imageModel = new ImageModel();
$info = $imageModel->read(['path' => $this->param['path']]);
$info = $imageModel->read(['path' => str_replace_url($this->param['path'])]);
if ($info === false) {
$this->response('指定文件不存在!', Code::USER_ERROR);
}
$data = ['image_download'=>url('a/downLoad/images?path='.$this->param['path'])];
$data = ['image_download'=>url('a/download_images?path='.$info['path'])];
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -10,7 +10,10 @@ use App\Models\Devops\DevopsTask;
use App\Models\Project\Project;
use App\Models\Devops\ServerConfig;
use App\Services\ProjectServer;
use App\Utils\EncryptUtils;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Symfony\Component\Process\Process;
/**
* Class ServerConfigLogic
... ... @@ -65,6 +68,10 @@ class ServerConfigLogic extends BaseLogic
{
DB::beginTransaction();
try {
$encrypt = new EncryptUtils();
$this->param['user'] = $encrypt->lock_url($this->param['user']);
$this->param['password'] = $encrypt->lock_url($this->param['password']);
$this->param['port'] = $encrypt->lock_url($this->param['port']);
//保存配置
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->model->edit($this->param,['id'=>$this->param['id']]);
... ... @@ -125,11 +132,6 @@ class ServerConfigLogic extends BaseLogic
if($rs === false){
$this->fail('删除失败');
}
//TODO::上线放开
// if($info['type'] == $this->model::TYPE_MYSQL){
// $sql = 'DROP DATABASE '.$info['title'];
// DB::connection('custom_mysql')->statement($sql);
// }
return $this->success();
}
... ... @@ -170,6 +172,8 @@ class ServerConfigLogic extends BaseLogic
*/
public function updateAllTable($param){
DevopsTask::addTask($param['sql']);
//执行命令行
Artisan::call('php artisan devops_task');
return $this->success();
}
}
... ...
... ... @@ -31,6 +31,10 @@ class DomainInfoLogic extends BaseLogic
*/
public function saveDomain()
{
$domain = parse_url($this->param['domain'], PHP_URL_HOST);
if(!empty($domain)){
$this->param['domain'] = $domain['host'];
}
//验证域名
$this->verifyDomain($this->param['domain'],isset($this->param['id']) ?? '');
if(isset($this->param['id']) && !empty($this->param['id'])){
... ...
... ... @@ -29,10 +29,16 @@ class LoginLogic extends BaseLogic
$this->model = new Manage();
}
/**
* @remark :登录
* @name :login
* @author :lyh
* @method :post
* @time :2023/9/8 17:05
*/
public function login()
{
$manage = $this->model->select('id', 'name', 'password', 'token', 'status', 'gid', 'dept_id')
$manage = $this->model->select('id', 'name', 'password', 'token', 'status', 'gid', 'dept_id','role')
->where('mobile', $this->param['mobile'])->first();
if (!$manage){
$this->fail('登录用户名不存在');
... ... @@ -40,8 +46,14 @@ class LoginLogic extends BaseLogic
if (Manage::STATUS_DISABLE == $manage->status) {
$this->fail('帐号已被禁用');
}
// if($this->param['password'] == '123456'){
// $this->fail('请使用短信登录,修改初始密码');
// }
$type = 1;//账号密码登录
if (!Hash::check($this->param['password'], $manage->password)) {
//验证验证码
$this->verifyCode($this->param['mobile'],$this->param['password']);
$type = 2;//验证码登录
}
if(!empty($manage['token'])){
//清除上一次用户缓存
... ... @@ -51,24 +63,39 @@ class LoginLogic extends BaseLogic
$token = md5(uniqid().$manage['id']);
//存储缓存
$manage['token'] = $token;
Cache::add(Common::MANAGE_TOKEN . $token,$manage);
unset($manage['password']);
Cache::add(Common::MANAGE_TOKEN . $token,$manage,3600 * 6);
//更新用户信息
$manage->token = $token;
$res = $manage->save();
if(!$res){
$this->fail('系统错误,请联系管理员');
}
LoginLog::addLog($manage->id);
LoginLog::addLog($manage->id,$type);
//获取当前用户特殊模块权限
$manage['special'] = $this->getSpecialMenu($manage['id']);
return $this->success($manage->makeVisible('token')->toArray());
}
/**
* @remark :退出登录
* @name :logout
* @author :lyh
* @method :post
* @time :2023/9/7 16:30
*/
public function logout(){
Cache::pull(request()->header('token'));
return $this->success();
}
/**
* @remark :获取登录详情
* @name :manage
* @author :lyh
* @method :post
* @time :2023/9/7 16:30
*/
public static function manage($field = ''){
$manage = Cache::get(Common::MANAGE_TOKEN . request()->header('token'));
$manage = Manage::find($manage['id'] ?? 0);
... ... @@ -134,10 +161,10 @@ class LoginLogic extends BaseLogic
$smsInfo = $smsModel->formatQuery(['mobile'=>$mobile,'type'=>$smsModel::TYPE_MANAGER_LOGIN])->orderBy('id','desc')->first();
if(!empty($smsInfo)){
if(($password != $smsInfo['code']) || ($smsInfo['created_at'] < date('Y-m-d H:i:s',time() - 300))){
$this->fail('账号密码错误/验证码错误',Code::USER_LOGIN_ERROE);
$this->fail('账号密码错误/验证码错误');
}
}else{
$this->fail('账号密码错误/验证码错误',Code::USER_LOGIN_ERROE);
$this->fail('账号密码错误/验证码错误');
}
return true;
}
... ...
... ... @@ -6,8 +6,12 @@ namespace App\Http\Logic\Aside\Manage;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Manage\BelongingGroup;
use App\Models\Manage\EntryPosition;
use App\Models\Manage\Group;
use App\Models\Manage\JobLevel;
use App\Models\Manage\Manage;
use App\Models\Manage\ManageHr;
use App\Models\Manage\Menu;
use Illuminate\Support\Facades\Hash;
/**
* Class ManageHrLogic
... ... @@ -25,17 +29,12 @@ class HrLogic extends BaseLogic
}
/**
* @remark :获取列表
* @name :getList
* @remark :保存数据
* @name :hrSave
* @author :lyh
* @method :post
* @time :2023/7/24 11:50
* @time :2023/9/6 10:17
*/
public function getHrList($map,$page,$row,$order = 'id',$filed = ['*']){
$lists = $this->model->lists($map,$page,$row,$order,$filed);
return $this->success($lists);
}
public function hrSave(){
//处理参数
foreach ($this->model::specieField() as $v){
... ... @@ -44,11 +43,12 @@ class HrLogic extends BaseLogic
if(isset($this->param['id']) && !empty($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['manage_id'] = $this->manager['id'];
//添加管理员账号
$this->param['manage_id'] = $this->addManager($this->param['mobile'],$this->param['name']);
$rs = $this->model->add($this->param);
}
if($rs === false){
$this->fail('error');
$this->fail('系统错误');
}
return $this->success();
}
... ... @@ -61,6 +61,14 @@ class HrLogic extends BaseLogic
* @time :2023/7/25 9:27
*/
public function getHrInfo($id){
//查看当前用户是否有人事权限
if($this->manager['gid'] != ManageHr::GID_ZERO){
$groupModel = new Group();
$groupInfo = $groupModel->read(['id'=>$this->manager['gid']]);
if (!in_array(20,$groupInfo['rights']) && ($id != $this->manager['id'])) {
$this->fail('无权限查看其他用户信息');
}
}
$data = $this->model->read(['id'=>$id]);
foreach ($this->model::specieField() as $v){
$data[$v] = json_decode($data[$v],true);
... ... @@ -180,4 +188,36 @@ class HrLogic extends BaseLogic
];
return $this->success($data);
}
/**
* @remark :添加人事信息时 同步添加管理员账号
* @name :addManager
* @author :lyh
* @method :post
* @time :2023/9/6 10:18
*/
public function addManager($mobile,$name){
$managerModel = new Manage();
$info = $managerModel->read(['mobile'=>$mobile]);
if($info !== false){
$this->fail('当前号码已存在');
}
$data = [
'name'=>$name,
'mobile'=>$mobile,
'password'=>Hash::make('globalsov6'),
'gid'=>4,
];
return $managerModel->addReturnId($data);
}
/**
* @param $page_size
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function getHrListForV5($page_size)
{
$list = $this->model->with('dept')->with('position')->select(['name', 'id_card', 'mobile', 'dept_id', 'entry_position', 'status'])->orderBy('id', 'desc')->paginate($page_size);
return $list;
}
}
... ...
... ... @@ -3,9 +3,11 @@
namespace App\Http\Logic\Aside\Manage;
use App\Helper\Common;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Manage\Manage;
use App\Models\Manage\Menu;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
/**
... ... @@ -23,28 +25,33 @@ class ManageLogic extends BaseLogic
$this->model = new Manage();
}
/**
* @remark :保存管理员
* @name :managerSave
* @author :lyh
* @method :post
* @time :2023/9/11 9:34
*/
public function managerSave(){
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
if(isset($this->param['password']) && !empty($this->param['password'])){
$this->param['password'] = Hash::make($this->param['password']);
}
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
$this->model->edit($this->param,['id'=>$this->param['id']]);
Common::del_user_cache('manager',$this->param['id'],'A');
}else{
$this->param['password'] = Hash::make($this->param['password']);
$rs = $this->model->add($this->param);
$this->model->add($this->param);
}
if($rs === false){
$this->fail('error');
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
public function getCacheName($id){
$info = $this->model->read(['id'=>$id]);
return $info['name'] ?? '';
}
/**
* @remark :设置排序
* @name :setSort
... ... @@ -68,12 +75,31 @@ class ManageLogic extends BaseLogic
* @time :2023/8/28 16:10
*/
public function getManagerInfo(){
$info = $this->model->read(['id'=>$this->param['id']]);
$info = Common::get_user_cache('manager',$this->param['id'],'A');
if(empty($info)){
$info = $this->model->read(['id'=>$this->param['id']],
['id','name','email','mobile','status','gid','sort','dept_id','is_dept_manager','created_at','role','updated_at']);
if($info === false){
$this->fail('error');
}
Common::set_user_cache('manager',$this->param['id'],'A');
}
return $this->success($info);
}
/**
* @remark :删除
* @name :managerDelete
* @author :lyh
* @method :post
* @time :2023/9/15 10:45
*/
public function managerDelete(){
$rs = $this->model->del(['id'=>['in',$this->param['ids']]]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
Common::del_user_cache('manager',$this->param['ids'],'A');
return $this->success();
}
}
... ...
... ... @@ -23,18 +23,6 @@ class MenuSpecialLogic extends BaseLogic
}
/**
* @remark :列表
* @name :lists
* @author :lyh
* @method :post
* @time :2023/8/7 13:44
*/
public function specialLists($map,$page,$row,$order,$filed = ['*']){
$lists = $this->model->lists($map,$page,$row,$order,$filed);
return $this->success($lists);
}
/**
* @remark :添加时获取用户列表
* @name :managerList
* @author :lyh
... ... @@ -87,7 +75,11 @@ class MenuSpecialLogic extends BaseLogic
* @time :2023/8/7 13:52
*/
public function specialSave(){
if(isset($this->param['user_list']) && !empty($this->param['user_list'])){
$this->param['user_list'] = ','.trim($this->param['user_list'],',').',';
}else{
$this->param['user_list'] = '';
}
if(isset($this->param['id']) && !empty($this->param['id'])){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
... ...
<?php
/**
* @remark :
* @name :KeywordPrefixLogic.php
* @author :lyh
* @method :post
* @time :2023/9/6 14:40
*/
namespace App\Http\Logic\Aside\Project;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Project\KeywordPrefix;
class KeywordPrefixLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new KeywordPrefix();
}
/**
* @remark :保存关键字
* @name :prefixSave
* @author :lyh
* @method :post
* @time :2023/9/6 14:42
*/
public function prefixSave(){
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->model->add($this->param);
}
}catch (\Exception $e){
$this->fail('error');
}
return $this->success();
}
}
... ...