作者 周海龙

合并分支 'develop' 到 'master'

Develop



查看合并请求 !11
正在显示 124 个修改的文件 包含 3436 行增加1110 行删除
... ... @@ -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();
}
}
... ...
... ... @@ -2,6 +2,10 @@
namespace App\Http\Logic\Aside\Project;
use App\Models\Devops\ServerConfig;
use App\Models\Project\ProjectRenew;
use App\Models\User\ProjectMenu;
use App\Models\User\ProjectRole;
use Illuminate\Support\Arr as SupArr;
use App\Helper\Arr;
use App\Helper\Common;
... ... @@ -23,6 +27,7 @@ use App\Services\ProjectServer;
use Hashids\Hashids;
use App\Models\User\User as UserModel;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
/**
* Class ProjectLogic
... ... @@ -47,14 +52,11 @@ class ProjectLogic extends BaseLogic
* @time :2023/7/28 17:11
*/
public function getProjectInfo($id){
// $info = Common::get_user_cache($this->model->getTable(),$id);
// if(empty($info)){
$info = $this->model->with('payment')->with('deploy_build')->with('deploy_optimize')->with('online_check')
->with('project_after')->where(['id'=>$id])->first()->toArray();
if(!empty($info['online_check']['created_manage_id'])){
$info['online_check']['name'] = (new Manage())->read(['id'=>$info['online_check']['created_manage_id']])['name'] ?? '';
}
if(isset($info['deploy_optimize']['minor_keywords']) && !empty($info['deploy_optimize']['minor_keywords'])){
$info['deploy_optimize']['minor_keywords'] = json_decode($info['deploy_optimize']['minor_keywords']) ?? '';
}else{
... ... @@ -63,8 +65,6 @@ class ProjectLogic extends BaseLogic
if($info['extend_type'] != 0){
$info['type'] = $info['extend_type'];
}
// Common::set_user_cache($info,$this->model->getTable(),$id);
// }
return $this->success($info);
}
... ... @@ -76,8 +76,14 @@ class ProjectLogic extends BaseLogic
* @time :2023/8/30 11:57
*/
public function projectSave(){
DB::beginTransaction();
try {
if($this->param['type'] == Project::TYPE_SEVEN){
//错误单直接返回,单独处理
$this->setTypeSevenEdit($this->param);
}else{
//初始化项目
$this->createProjectData($this->param);
//保存项目信息
$this->saveProject($this->param);
... ... @@ -89,6 +95,7 @@ class ProjectLogic extends BaseLogic
$this->saveProjectDeployOptimize($this->param['deploy_optimize']);
//保存售后信息
$this->saveProjectAfter($this->param['project_after']);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -164,6 +171,9 @@ class ProjectLogic extends BaseLogic
*/
protected function saveProjectDeployBuild($deploy_build){
$deployBuildModel = new DeployBuild();
if(isset($deploy_build['configuration']) && !empty($deploy_build['configuration'])){
$deploy_build['configuration'] = Arr::a2s($deploy_build['configuration']);
}
$deployBuildModel->edit($deploy_build,['id'=>$deploy_build['id']]);
return $this->success();
}
... ... @@ -178,8 +188,9 @@ class ProjectLogic extends BaseLogic
protected function saveProjectDeployOptimize($deploy_optimize){
$deployOptimizeModel = new DeployOptimize();
if(isset($deploy_optimize['domain']) && !empty($deploy_optimize['domain'])){
if (!preg_match('/http/', $deploy_optimize['domain'])) {
$deploy_optimize['domain'] = 'https://'.trim($deploy_optimize['domain'],'/').'/';
//更改域名
if(isset($deploy_optimize['domain']) && !empty($deploy_optimize['domain'])){
$this->editDomainStatus($deploy_optimize['domain'],$deploy_optimize['project_id']);
}
}
if(isset($deploy_optimize['minor_languages']) && !empty($deploy_optimize['minor_languages'])){
... ... @@ -214,12 +225,20 @@ class ProjectLogic extends BaseLogic
* @time :2023/8/30 14:30
*/
public function createProjectData($param){
//查看当前项目状态是否为初始项目
$info = $this->model->read(['id'=>$param['id']]);
//项目为初始项目时,只能选择建站中
if($info['type'] == Project::TYPE_ZERO){
$param['type'] = Project::TYPE_ONE;
}
//创建默认数据库
if($param['type'] == Project::TYPE_ONE){
//初始化数据库
if(isset($param['mysql_id']) && !empty($param['mysql_id'])){
$this->initializationMysql($param['id']);
}
//创建初始角色
// $this->createdRole($param['id']);
//初始账号
if(isset($param['mobile']) && !empty($param['mobile'])){
$this->createUser($param['mobile'],$param['id'],$param['lead_name']);
... ... @@ -232,6 +251,39 @@ class ProjectLogic extends BaseLogic
return $this->success();
}
/**
* @remark :根据类型状态设置
* @name :setTypeStatusEdit
* @author :lyh
* @method :post
* @time :2023/9/12 11:20
*/
public function setTypeSevenEdit($param){
$info = $this->model->read(['id'=>$param['id']]);
if($info['delete_status'] == 0){
//删除原始项目
$this->edit(['delete_status' => 1], ['id' => $param['id']]);
//添加到续费单
$data = [
'title' => '【续费单】' . $param['title'],
'company' => $param['company'],
'lead_name' => $param['lead_name'],
'mobile' => $param['mobile'],
'qq' => $param['qq'],
'channel' => json_encode($param['channel']),
'requirement' => $param['requirement'],
'cooperate_date' => $param['cooperate_date'],
'service_duration' => $param['deploy_build']['service_duration'],
'plan' => $param['deploy_build']['plan'],
'amount' => $param['payment']['amount'],
'contract' => json_encode($param['payment']['contract']),
'bill' => json_encode($param['payment']['bill']),
];
$renewModel = new ProjectRenew();
$renewModel->add($data);
}
return $this->success();
}
/**
* @remark :初始化数据库
... ... @@ -250,6 +302,7 @@ class ProjectLogic extends BaseLogic
return $this->success();
}
/**
* @remark :更新服务器为已使用
* @name :updateServe
... ... @@ -258,8 +311,8 @@ class ProjectLogic extends BaseLogic
* @time :2023/8/28 10:50
*/
public function updateServe($serve_id){
$domainModel = new DomainInfo();
$domainModel->edit(['status'=>$domainModel::STATUS_ONE],['id'=>$serve_id]);
$serverModel = new ServerConfig();
$serverModel->edit(['status'=>$serverModel::STATUS_ONE],['id'=>$serve_id]);
return $this->success();
}
... ... @@ -291,7 +344,32 @@ class ProjectLogic extends BaseLogic
return $this->success();
}
/**
* @remark :创建角色
* @name :createdRole
* @author :lyh
* @method :post
* @time :2023/9/6 11:16
*/
public function createdRole($project_id){
$roleModel = new ProjectRole();
//查看当前用户是否存在
$info = $roleModel->read(['project_id'=>$project_id]);
if($info === false){
$menuModel = new ProjectMenu();
$ids = $menuModel->where(['status'=>0])->pluck('id')->toArray();
$data = [
'name'=>'超级管理员',
'role_menu'=>implode(',',$ids),
'project_id'=>$project_id,
'type'=>1,
'operator_id'=>$this->manager['id'],
'create_id'=>$this->manager['id'],
];
$roleModel->add($data);
}
return $this->success();
}
public function clearCache($id)
{
... ... @@ -355,8 +433,38 @@ class ProjectLogic extends BaseLogic
}
/**
* @remark :修改域名时,同时更改其状态
* @name :domainStatus
* @author :lyh
* @method :post
* @time :2023/9/4 14:29
*/
public function editDomainStatus($domain,$project_id){
$domainModel = new DomainInfo();
//先清空上一次所绑定的域名
$info = $domainModel->read(['project_id'=>$project_id]);
if($info !== false){
$domainModel->edit(['project_id'=>0,'status'=>DomainInfo::STATUS_ZERO],['id'=>$info['id']]);
}
//重新设置域名
$domainModel->edit(['status'=>DomainInfo::STATUS_ONE,'project_id'=>$project_id],['id'=>$domain]);
return $this->success();
}
/**
* @remark :删除
* @name :projectDel
* @author :lyh
* @method :post
* @time :2023/9/8 15:23
*/
public function projectDel(){
$rs = $this->edit(['delete_status'=>1],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
}
... ...
... ... @@ -25,7 +25,7 @@ class ATemplateLogic extends BaseLogic
* @method :post
* @time :2023/6/28 17:03
*/
public function aTemplateList($map,$page,$row,$order = ['created_at'],$filed = ['id','name','url','status','deleted_status','sort','image']){
public function aTemplateList($map,$page,$row,$order = ['created_at'],$filed = ['*']){
$map['deleted_status'] = 0;
$map['status'] = 0;
$lists = $this->model->lists($map,$page,$row,$order,$filed);
... ...
... ... @@ -115,4 +115,19 @@ class ProjectMenuLogic extends BaseLogic
$list = $this->model->list(['pid'=>$this->param['id'], 'is_role'=>1]);
return $this->success($list);
}
/**
* @remark :设置排序
* @name :setSort
* @author :lyh
* @method :post
* @time :2023/8/10 16:42
*/
public function setParamStatus(){
$rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('修改失败');
}
return $this->success();
}
}
... ...
... ... @@ -159,4 +159,19 @@ class UserLogic extends BaseLogic
Common::del_user_cache($this->model, $ids, 'A');
return $this->success();
}
/**
* @remark :设置排序
* @name :setSort
* @author :lyh
* @method :post
* @time :2023/8/10 16:42
*/
public function setParamStatus(){
$rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('修改失败');
}
return $this->success();
}
}
... ...
... ... @@ -14,6 +14,7 @@ use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateLog;
use App\Models\Template\Template;
use Illuminate\Support\Facades\DB;
use mysql_xdevapi\Exception;
/**
* @remark :b端模块
... ... @@ -316,6 +317,43 @@ class BTemplateLogic extends BaseLogic
return $info['values'];
}
/**
* @remark :设置主题公共head
* @name :setHeadInfo
* @author :lyh
* @method :post
* @time :2023/7/10 15:32
*/
public function setHeadFooterSave(){
$serviceSettingModel = new ServiceSettingModel();
DB::beginTransaction();
try {
$serviceSettingModel->del(['type'=>2]);
$data = [
['type'=>2,'key'=>'head','values'=>$this->param['head'],'created_at'=>date('Y-m-d H:i:s'),'updated_at'=>date('Y-m-d H:i:s')],
['type'=>2,'key'=>'footer','values'=>$this->param['footer'],'created_at'=>date('Y-m-d H:i:s'),'updated_at'=>date('Y-m-d H:i:s')]
];
$serviceSettingModel->insert($data);
DB::commit();
}catch (Exception $e){
DB::rollBack();
$this->fail('error');
}
}
/**
* @remark :获取主题公共head
* @name :getHeadInfo
* @author :lyh
* @method :post
* @time :2023/7/10 15:33
*/
public function getHeadFooterList(){
$serviceSettingModel = new ServiceSettingModel();
$list = $serviceSettingModel->list(['type'=>2],'created_at');
return $this->success($list);
}
/**
* @remark :获取类型
... ...
... ... @@ -77,12 +77,12 @@ class CustomTemplateLogic extends BaseLogic
}
//路由映射
if(isset($this->param['url']) && !empty($this->param['url'])){
RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
//TODO::通知网站更新
$data = [
'project_id'=>$this->user['project_id'],
'type'=>RouteMap::SOURCE_PAGE,
'route'=>$this->param['url'],
'route'=>$route,
];
$this->updateNotify($data);
}
... ... @@ -122,6 +122,8 @@ class CustomTemplateLogic extends BaseLogic
'project_id'=>$this->user['project_id'],
'source'=>1//首页
]);
$html = '';
if($TemplateInfo !== false){
if(empty($preg_html)){
$preg_html = "<main></main>";
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $TemplateInfo['html']);
... ... @@ -130,6 +132,7 @@ class CustomTemplateLogic extends BaseLogic
}
//内容
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $preg_html, $html);
}
return $html;
}
... ...
... ... @@ -8,6 +8,7 @@ use App\Exceptions\BsideGlobalException;
use App\Http\Logic\Logic;
use App\Models\Com\UpdateNotify;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteDelete;
use Illuminate\Support\Facades\Cache;
/**
... ... @@ -159,4 +160,23 @@ class BaseLogic extends Logic
}
return $this->success();
}
/**
* @remark :删除和编辑路由时生成一条记录
* @name :setRouteDeleteSave
* @author :lyh
* @method :post
* @time :2023/9/7 9:38
*/
public function setRouteDeleteSave($param){
$routeDeleteModel = new RouteDelete();
$data = [
'project_id'=>$this->user['project_id'],
'source'=>$param['source'],
'created_at'=>date('Y-m-d H:i:s'),
'route'=>$param['route'],
];
$routeDeleteModel->insert($data);
return $this->success();
}
}
... ...
... ... @@ -35,23 +35,36 @@ class BlogCategoryLogic extends BaseLogic
$v['category_name'] = trim($str,',');
return $this->success($v);
}
/**
* @name :添加时验证上级分类是否有商品,有则替换带当前分类下
* @return void
* @author :liyuhang
* @method
* @remark :保存数据
* @name :categorySave
* @author :lyh
* @method :post
* @time :2023/9/7 13:42
*/
public function add_blog_category(){
public function categorySave(){
//验证名称是否存在
$this->verifyParamName($this->param['name']);
//拼接参数
$this->param = $this->addParamProcessing($this->param);
DB::beginTransaction();
try {
$cate_id = $this->model->insertGetId($this->param);
if(isset($this->param['id']) && !empty($this->param['id'])){
//验证参数是否可编辑
$this->verifyParamEdit($this->param['id'],$this->param['pid']);
//查看路由是否更新
$id = $this->editCategoryRoute($this->param['id'],$this->param['alias']);
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
//拼接参数
$this->param = $this->addParamProcessing($this->param);
$id = $this->model->addReturnId($this->param);
//处理子集
$this->addProcessingSon($cate_id);
$route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $cate_id, $this->user['project_id']);
$this->addProcessingSon($id);
}
$route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],
RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
$this->edit(['alias'=>$route],['id'=>$id]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -63,24 +76,26 @@ class BlogCategoryLogic extends BaseLogic
}
/**
* @name :编辑分类
* @return void
* @author :liyuhang
* @method
* @remark :编辑路由时生成路由记录
* @name :editCategoryRoute
* @author :lyh
* @method :post
* @time :2023/9/7 10:51
*/
public function edit_blog_category(){
//验证名称是否存在
$this->verifyParamName($this->param['name'],$this->param['id']);
//验证参数是否可编辑
$this->verifyParamEdit($this->param['id'],$this->param['pid']);
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$this->param['id']]);
$route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']);
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]);
public function editCategoryRoute($id,$route){
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','alias']);
if($info['alias'] != $route){
$data = [
'source'=>RouteMap::SOURCE_NEWS_CATE,
'route'=>$info['alias'],
];
$this->setRouteDeleteSave($data);
}
return $this->success();
}
/**
* @remark :查看参数是否可编辑
* @name :verifyParamEdit
... ... @@ -115,7 +130,7 @@ class BlogCategoryLogic extends BaseLogic
* @method
*/
public function info_blog_category(){
$info = $this->info($this->param);
$info = $this->model->read($this->param);
return $this->success($info);
}
... ... @@ -139,24 +154,35 @@ class BlogCategoryLogic extends BaseLogic
* @author :liyuhang
* @method
*/
public function del_blog_category(){
$ids = $this->param['id'];
foreach ($ids as $v){
public function delBlogCategory(){
foreach ($this->param['id'] as $id){
$this->verifyIsDelete($id);
//删除路由
$this->delRoute($id);
$this->model->del(['id'=>$id]);
}
return $this->success();
}
/**
* @remark :验证是否可删除
* @name :VerifyIsDelete
* @author :lyh
* @method :post
* @time :2023/9/7 14:40
*/
public function verifyIsDelete($id){
//查询是否有子分类
$rs = $this->model->read(['pid'=>$v],['id']);
$rs = $this->model->read(['pid'=>$id],['id']);
if($rs !== false){
$this->response('当前分类拥有子分类不允许删除');
}
//查看当前分内下是否有博客
$blogModel = new BlogModel();
$rs = $blogModel->read(['category_id'=>$v],['id']);
$rs = $blogModel->read(['category_id'=>$id],['id']);
if($rs !== false){
$this->response('当前分类拥有博客,不允许删除');
}
RouteMap::delRoute(RouteMap::SOURCE_BLOG_CATE, $v, $this->user['project_id']);
}
$this->param['id'] = ['in',$this->param['id']];
$this->del($this->param,$ids);
return $this->success();
}
... ... @@ -186,8 +212,6 @@ class BlogCategoryLogic extends BaseLogic
$param['project_id'] = $this->user['project_id'];
$param['operator_id'] = $this->user['id'];
$param['create_id'] = $this->user['id'];
$param['created_at'] = date('Y-m-d H:i:s');
$param['updated_at'] = date('Y-m-d H:i:s');
return $this->success($param);
}
... ... @@ -197,16 +221,14 @@ class BlogCategoryLogic extends BaseLogic
* @method :post
* @time :2023/6/13 11:41
*/
public function verifyParamName($name,$id = ''){
if(isset($id) && !empty($id)){
public function verifyParamName($name){
if(isset($this->param['id']) && !empty($this->param['id'])){
$condition = [
'id'=>['!=',$id],
'id'=>['!=',$this->param['id']],
'name'=>$name,
];
}else{
$condition = [
'name'=>$name
];
$condition = ['name'=>$name];
}
$info = $this->model->read($condition);
if($info !== false){
... ... @@ -246,4 +268,23 @@ class BlogCategoryLogic extends BaseLogic
return $this->success();
}
/**
* @remark :删除路由
* @name :delRoute
* @author :lyh
* @method :post
* @time :2023/9/7 10:50
*/
public function delRoute($id){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','alias']);
$data = [
'source'=>RouteMap::SOURCE_BLOG_CATE,
'route'=>$info['alias'],
];
$this->setRouteDeleteSave($data);
return $this->success();
}
}
... ...
... ... @@ -47,20 +47,28 @@ class BlogLogic extends BaseLogic
}
return $this->success($list);
}
/**
* @name :添加博客
* @return void
* @author :liyuhang
* @method
* @remark :保存数据
* @name :blogSave
* @author :lyh
* @method :post
* @time :2023/9/7 11:49
*/
public function blogAdd(){
public function blogSave(){
//拼接参数
DB::beginTransaction();
try {
$this->param = $this->paramProcessing($this->param);
$rs = $this->model->insertGetId($this->param);
$route = $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'],
RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']);
if(isset($this->param['id']) && !empty($this->param['id'])){
//是否更新路由
$id = $this->editNewsRoute($this->param['id'],$this->param['url']);
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
$id = $this->model->addReturnId($this->param);
}
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
$this->edit(['url'=>$route],['id'=>$id]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -72,28 +80,25 @@ class BlogLogic extends BaseLogic
}
/**
* @name : 编辑博客
* @return void
* @author :liyuhang
* @method
* @remark :查看是否编辑路由
* @name :editCategoryRoute
* @author :lyh
* @method :post
* @time :2023/9/7 11:05
*/
public function blogEdit(){
//拼接参数
$this->param = $this->paramProcessing($this->param);
DB::beginTransaction();
try {
$route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'],
RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']);
$this->edit($this->param,['id'=>$this->param['id']]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
public function editNewsRoute($id,$route){
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','url']);
if($info['url'] != $route){
$data = [
'source'=>RouteMap::SOURCE_BLOG,
'route'=>$info['url'],
];
$this->setRouteDeleteSave($data);
}
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG, 'route'=>$route]);
return $this->success();
return $id;
}
/**
* @name :编辑seo
* @return void
... ... @@ -108,13 +113,15 @@ class BlogLogic extends BaseLogic
}
return $this->success();
}
/**
* @name :获取数据详情
* @return array
* @author :liyuhang
* @method
*/
public function blog_info(){
public function blogInfo(){
//读取缓存
$info = Common::get_user_cache($this->model->getTable(),$this->param['id']);
if(empty($info)){
... ... @@ -128,8 +135,6 @@ class BlogLogic extends BaseLogic
//获取标签名称
$blogLabelLogic = new BlogLabelLogic();
$info = $blogLabelLogic->get_label_name($info);
$info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']);
$info['url'] = $this->user['domain'] . $info['route'];
$info['image_link'] = getImageUrl($info['image']);
//写入缓存
Common::set_user_cache($info,$this->model->getTable(),$this->param['id']);
... ... @@ -144,7 +149,7 @@ class BlogLogic extends BaseLogic
* @author :liyuhang
* @method
*/
public function blog_status(){
public function blogStatus(){
$this->param['operator_id'] = $this->user['id'];
$rs = $this->model->edit($this->param,['id'=>['in',$this->param['id']]]);
if($rs === false){
... ... @@ -159,14 +164,12 @@ class BlogLogic extends BaseLogic
* @author :liyuhang
* @method
*/
public function blog_del(){
$ids = $this->param['id'];
public function blogDel(){
DB::beginTransaction();
try {
$this->param['id'] = ['in',$this->param['id']];
$this->del($this->param,$ids);
foreach ($ids as $id){
RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
foreach ($this->param['id'] as $id){
$this->delRoute($id);
$this->model->del(['id'=>$id]);
}
DB::commit();
}catch (Exception $e){
... ... @@ -176,6 +179,25 @@ class BlogLogic extends BaseLogic
return $this->success();
}
/**
* @remark :删除路由
* @name :delRoute
* @author :lyh
* @method :post
* @time :2023/9/7 10:50
*/
public function delRoute($id){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','url']);
$data = [
'source'=>RouteMap::SOURCE_BLOG,
'route'=>$info['url'],
];
$this->setRouteDeleteSave($data);
return $this->success();
}
/**
* @name :(参数处理)paramProcessing
... ... @@ -186,15 +208,17 @@ class BlogLogic extends BaseLogic
public function paramProcessing($param){
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = ','.trim($param['category_id'],',').',';
}
}else{
$param['create_id'] = $this->user['id'];
$param['operator_id'] = $this->user['id'];
$param['project_id'] = $this->user['project_id'];
$param['created_at'] = date('Y-m-d H:i:s',time());
$param['updated_at'] = date('Y-m-d H:i:s',time());
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = ','.$param['category_id'].',';
}
}
return $this->success($param);
}
... ...
... ... @@ -22,7 +22,7 @@ class MailLogic extends BaseLogic
* @author :liyuhang
*/
public function mail_info(){
$info = $this->info($this->param);
$info = $this->model->read($this->param);
//生成一条阅读记录
$mailUserModel = new MailUserModel();
$data = [
... ...
... ... @@ -5,6 +5,8 @@ namespace App\Http\Logic\Bside\Nav;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Nav\BNav;
use App\Models\RouteMap\RouteMap;
use Illuminate\Support\Facades\DB;
/**
... ... @@ -32,7 +34,33 @@ class NavLogic extends BaseLogic
*/
public function navSave()
{
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->handleEditParam();//验证是否可编辑分类
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$this->model->add($this->param);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
}
//编辑菜单后,通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NAV, 'route'=>'all']);
return $this->success();
}
/**
* @remark :验证是否可编辑
* @name :handleEditParam
* @author :lyh
* @method :post
* @time :2023/9/7 14:36
*/
public function handleEditParam(){
$info = $this->model->read(['id'=>$this->param['id']]);
if($this->param['pid'] == $info['id']){
$this->fail('不允许成为自己的上级');
... ... @@ -41,14 +69,6 @@ class NavLogic extends BaseLogic
if(($pid_info !== false) && $this->param['pid'] != $info['pid']){
$this->fail('当前菜单拥有子集不允许修改上级');
}
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$rs = $this->model->add($this->param);
}
if($rs === false){
$this->fail('error');
}
return $this->success();
}
... ... @@ -70,6 +90,8 @@ class NavLogic extends BaseLogic
if($rs === false){
$this->fail('error');
}
//编辑菜单后,通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NAV, 'route'=>'all']);
return $this->success();
}
... ...
... ... @@ -25,6 +25,7 @@ class NewsCategoryLogic extends BaseLogic
* @method
*/
public function get_category_name($v){
if(!empty($v['category_id'])){
//获取用户已读还是未读
$category_info = $this->model->list([
'id'=>['in',explode(',',trim($v['category_id'],','))]],'id',['name']);
... ... @@ -33,6 +34,7 @@ class NewsCategoryLogic extends BaseLogic
$str .= $v1['name'].',';
}
$v['category_name'] = trim($str,',');
}
return $this->success($v);
}
... ... @@ -44,57 +46,66 @@ class NewsCategoryLogic extends BaseLogic
* @method
*/
public function info_news_category(){
$info = $this->info($this->param);
$info = $this->model->read($this->param);
return $this->success($info);
}
/**
* @name :添加时验证上级分类是否有商品,有则替换带当前分类下
* @return void
* @author :liyuhang
* @method
* @remark :保存数据
* @name :newsCategorySave
* @author :lyh
* @method :post
* @time :2023/9/7 14:53
*/
public function add_news_category(){
public function newsCategorySave(){
//验证名称是否存在
$this->verifyParamName($this->param['name']);
//参数处理
// DB::beginTransaction();
// try {
if(isset($this->param['id']) && !empty($this->param['id'])){
//验证是否可编辑
$this->verifyEditParam($this->param['id'],$this->param['pid']);
$this->param['operator_id'] = $this->user['id'];
//查看路由是否更新
$id = $this->editCategoryRoute($this->param['id'],$this->param['alias']);
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param = $this->addParamProcessing($this->param);
DB::beginTransaction();
try {
$cate_id = $this->model->insertGetId($this->param);
//当父级分类拥有产品时,处理产品
$this->addProcessingSon($cate_id);
RouteMap::setRoute($this->param['alias'] ?: $this->param['name'],
RouteMap::SOURCE_NEWS_CATE, $cate_id, $this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
}
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'],
'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$this->param['alias']]);
$id = $this->model->addReturnId($this->param);
//当父级分类拥有产品时,处理子集
$this->addProcessingSon($id);
}
$route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$this->model->edit(['alias'=>$route],['id'=>$id]);
// DB::commit();
// }catch (\Exception $e){
// DB::rollBack();
// $this->fail('error');
// }
//更新通知记录表
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]);
return $this->success();
}
/**
* @name :编辑分类
* @return void
* @author :liyuhang
* @method
* @remark :编辑路由时生成路由记录
* @name :editCategoryRoute
* @author :lyh
* @method :post
* @time :2023/9/7 10:51
*/
public function edit_news_category(){
//验证名称是否存在
$this->verifyParamName($this->param['name'],$this->param['id']);
//验证是否可编辑
$this->verifyEditParam($this->param['id'],$this->param['pid']);
$this->param['operator_id'] = $this->user['id'];
$this->param['alias'] = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'],
RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']);
$this->edit($this->param,['id'=>$this->param['id']]);
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'],
'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$this->param['alias']]);
return $this->success();
public function editCategoryRoute($id,$route){
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','alias']);
if($info['alias'] != $route){
$data = [
'source'=>RouteMap::SOURCE_NEWS_CATE,
'route'=>$info['alias'],
];
$this->setRouteDeleteSave($data);
}
return $id;
}
/**
... ... @@ -144,23 +155,21 @@ class NewsCategoryLogic extends BaseLogic
* @method
*/
public function del_news_category(){
$ids = $this->param['id'];
foreach ($this->param['id'] as $v){
foreach ($this->param['id'] as $id){
//查询是否有子分类
$rs = $this->model->read(['pid'=>$v],['id']);
$rs = $this->model->read(['pid'=>$id],['id']);
if($rs !== false){
$this->fail('当前分类拥有子分类不允许删除');
}
//查看当前分内下是否有商品
$newsModel = new NewsModel();
$rs = $newsModel->read(['category_id'=>$v],['id']);
$rs = $newsModel->read(['category_id'=>$id],['id']);
if($rs !== false){
$this->fail('当前分类拥有商品');
}
RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $v, $this->user['project_id']);
$this->delRoute($id);
$this->model->del(['id'=>$id]);
}
$this->param['id'] = ['in',$this->param['id']];
$this->del($this->param,$ids);
return $this->success();
}
... ... @@ -186,16 +195,11 @@ class NewsCategoryLogic extends BaseLogic
* @method :post
* @time :2023/6/13 11:41
*/
public function verifyParamName($name,$id = ''){
if(isset($id) && !empty($id)){
$condition = [
'id'=>['!=',$id],
'name'=>$name,
];
public function verifyParamName($name){
if(isset($this->param['id']) && !empty($this->param['id'])){
$condition = ['id'=>['!=',$this->param['id']], 'name'=>$name];
}else{
$condition = [
'name'=>$name
];
$condition = ['name'=>$name];
}
$info = $this->model->read($condition);
if($info !== false){
... ... @@ -214,8 +218,6 @@ class NewsCategoryLogic extends BaseLogic
$param['project_id'] = $this->user['project_id'];
$param['operator_id'] = $this->user['id'];
$param['create_id'] = $this->user['id'];
$param['created_at'] = date('Y-m-d H:i:s');
$param['updated_at'] = date('Y-m-d H:i:s');
return $this->success($param);
}
... ... @@ -248,4 +250,24 @@ class NewsCategoryLogic extends BaseLogic
}
return $this->success();
}
/**
* @remark :删除路由
* @name :delRoute
* @author :lyh
* @method :post
* @time :2023/9/7 10:50
*/
public function delRoute($id){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','alias']);
$data = [
'source'=>RouteMap::SOURCE_NEWS_CATE,
'route'=>$info['alias'],
];
$this->setRouteDeleteSave($data);
return $this->success();
}
}
... ...
... ... @@ -48,18 +48,27 @@ class NewsLogic extends BaseLogic
}
/**
* @name :添加博客
* @return void
* @author :liyuhang
* @method
* @remark :保存数据
* @name :newsSave
* @author :lyh
* @method :post
* @time :2023/9/7 11:02
*/
public function news_add(){
public function newsSave(){
//拼接参数
DB::beginTransaction();
try {
$this->param = $this->paramProcessing($this->param);
$rs = $this->model->insertGetId($this->param);
$route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']);
if(isset($this->param['id']) && !empty($this->param['id'])){
//是否更新路由
$id = $this->editNewsRoute($this->param['id'],$this->param['url']);
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
$id = $this->model->addReturnId($this->param);
}
//更新路由
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
$this->edit(['url'=>$route],['id'=>$id]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -71,29 +80,26 @@ class NewsLogic extends BaseLogic
}
/**
* @name :编辑
* @return void
* @author :liyuhang
* @method
* @remark :查看是否编辑路由
* @name :editCategoryRoute
* @author :lyh
* @method :post
* @time :2023/9/7 11:05
*/
public function news_edit(){
//拼接参数
$this->param = $this->paramProcessing($this->param);
DB::beginTransaction();
try {
//设置路由
$route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']);
$this->edit($this->param,['id'=>$this->param['id']]);
DB::commit();
}catch (\exception $e){
DB::rollBack();
$this->fail('参数错误或其他服务器原因,编辑失败');
}
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS, 'route'=>$route]);
return $this->success();
public function editNewsRoute($id,$route){
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','url']);
if($info['url'] != $route){
$data = [
'source'=>RouteMap::SOURCE_NEWS,
'route'=>$info['url'],
];
$this->setRouteDeleteSave($data);
}
return $id;
}
/**
* @name :编辑seo
* @return void
... ... @@ -132,16 +138,11 @@ class NewsLogic extends BaseLogic
* @author :liyuhang
* @method
*/
public function news_info(){
//读取缓存
$info = Common::get_user_cache($this->model->getTable(),$this->param['id']);
if(empty($info)){
public function newsInfo(){
$info = $this->model->read($this->param);
$info['image_link'] = getImageUrl($info['image']);
$newsCategoryLogic = new NewsCategoryLogic();
$info = $newsCategoryLogic->get_category_name($info);
//写入缓存
Common::set_user_cache($info,$this->model->getTable(),$this->param['id']);
}
return $this->success($info);
}
... ... @@ -151,19 +152,17 @@ class NewsLogic extends BaseLogic
* @author :liyuhang
* @method
*/
public function news_del(){
$ids = $this->param['id'];
public function newsDel(){
DB::beginTransaction();
try {
$this->param['id'] = ['in',$this->param['id']];
$this->del($this->param,$ids);
foreach ($ids as $id){
RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
foreach ($this->param['id'] as $id){
$this->delRoute($id);
$this->model->del(['id'=>$id]);
}
DB::commit();
}catch (Exception $e){
DB::rollBack();
$this->fail('当前数据不存在');
$this->fail('error');
}
return $this->success();
}
... ... @@ -177,15 +176,17 @@ class NewsLogic extends BaseLogic
public function paramProcessing($param){
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = ','.trim($param['category_id'],',').',';
}
}else{
$param['create_id'] = $this->user['id'];
$param['operator_id'] = $this->user['id'];
$param['project_id'] = $this->user['project_id'];
$param['created_at'] = date('Y-m-d H:i:s',time());
$param['updated_at'] = date('Y-m-d H:i:s',time());
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = ','.$param['category_id'].',';
}
}
return $this->success($param);
}
... ... @@ -223,4 +224,24 @@ class NewsLogic extends BaseLogic
}
return $this->success();
}
/**
* @remark :删除路由
* @name :delRoute
* @author :lyh
* @method :post
* @time :2023/9/7 10:50
*/
public function delRoute($id){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','url']);
$data = [
'source'=>RouteMap::SOURCE_NEWS,
'route'=>$info['url'],
];
$this->setRouteDeleteSave($data);
return $this->success();
}
}
... ...
... ... @@ -2,11 +2,10 @@
namespace App\Http\Logic\Bside\Product;
use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use Illuminate\Support\Facades\DB;
... ... @@ -69,7 +68,8 @@ class CategoryLogic extends BaseLogic
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->handleEditParam($this->param);
$id = $this->param['id'];
//是否编辑路由
$id = $this->editCategoryRoute($this->param['id'],$this->param['route']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
... ... @@ -77,17 +77,45 @@ class CategoryLogic extends BaseLogic
}
//路由映射
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
$this->edit(['route'=>$route],['id'=>$id]);
//清除缓存
Common::del_user_cache('product_category',$this->user['project_id']);
DB::commit();
} catch (\Exception $e){
DB::rollBack();
$this->fail('保存失败');
}
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT_CATE, 'route'=>$route]);
$notifyData = [
'project_id'=>$this->user['project_id'],
'type'=>RouteMap::SOURCE_PRODUCT_CATE,
'route'=>$route
];
$this->updateNotify($notifyData);
return $this->success();
}
/**
* @remark :编辑路由时生成路由记录
* @name :editCategoryRoute
* @author :lyh
* @method :post
* @time :2023/9/7 10:51
*/
public function editCategoryRoute($id,$route){
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
if($info['route'] != $route){
$data = [
'source'=>RouteMap::SOURCE_PRODUCT_CATE,
'route'=>$info['route'],
];
$this->setRouteDeleteSave($data);
}
return $id;
}
/**
* @remark :验证编辑时是否可修改pid
* @name :handleEditParam
* @author :lyh
... ... @@ -108,7 +136,7 @@ class CategoryLogic extends BaseLogic
if(($product_info !== false) && ($info['pid'] != $param['pid'])){
$this->fail('当前产品分类拥有产品不允许编辑上级分类');
}
return true;
return $this->success();
}
... ... @@ -129,10 +157,12 @@ class CategoryLogic extends BaseLogic
if($product_info !== false){
$this->fail('当前分类拥有产品不允许删除');
}
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
//删除路由
$this->delRoute($id);
$this->model->del(['id'=>$id]);
}
$this->model->del(['id'=>['in',$ids]]);
//清除缓存
Common::del_user_cache('product_category',$this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -141,4 +171,23 @@ class CategoryLogic extends BaseLogic
return $this->success();
}
/**
* @remark :删除路由
* @name :delRoute
* @author :lyh
* @method :post
* @time :2023/9/7 10:50
*/
public function delRoute($id){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
$data = [
'source'=>RouteMap::SOURCE_PRODUCT_CATE,
'route'=>$info['route'],
];
$this->setRouteDeleteSave($data);
return $this->success();
}
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\Product;
use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
... ... @@ -51,16 +52,20 @@ class KeywordLogic extends BaseLogic
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $this->param['id'], $this->user['project_id']);
$id = $this->editCategoryRoute($this->param['id'],$route);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$this->param['created_at'] = date('Y-m-d H:i:s');
$this->param['updated_at'] = $this->param['created_at'];
$id = $this->model->insertGetId($this->param);
}
//路由映射
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
}
$this->model->edit(['route'=>$route],['id'=>$id]);
//清除缓存
Common::del_user_cache('product_keyword',$this->user['project_id']);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -72,6 +77,26 @@ class KeywordLogic extends BaseLogic
}
/**
* @remark :编辑路由时生成路由记录
* @name :editCategoryRoute
* @author :lyh
* @method :post
* @time :2023/9/7 10:51
*/
public function editCategoryRoute($id,$route){
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
if($info['route'] != $route){
$data = [
'source'=>RouteMap::SOURCE_PRODUCT_KEYWORD,
'route'=>$info['route'],
];
$this->setRouteDeleteSave($data);
}
return $id;
}
/**
* @remark :批量添加数据
* @name :batchAdd
* @author :lyh
... ... @@ -107,10 +132,31 @@ class KeywordLogic extends BaseLogic
if($product_info !== false){
$this->fail('当前关键词拥有产品不允许删除');
}
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
$this->delRoute($id);
$this->model->del(['id'=>$id]);
}
$this->model->del(['id'=>['in',$ids]]);
//清除缓存
Common::del_user_cache('product_keyword',$this->user['project_id']);
return $this->success();
}
/**
* @remark :删除路由
* @name :delRoute
* @author :lyh
* @method :post
* @time :2023/9/7 10:50
*/
public function delRoute($id){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
$data = [
'source'=>RouteMap::SOURCE_PRODUCT_KEYWORD,
'route'=>$info['route'],
];
$this->setRouteDeleteSave($data);
return $this->success();
}
}
... ...
... ... @@ -33,20 +33,24 @@ class ProductLogic extends BaseLogic
* @time :2023/8/21 18:35
*/
public function productSave(){
//参数处理
$this->param = $this->handleSaveParam($this->param);
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
//查看路由是否更新
$id = $this->editProductRoute($this->param['id'],$this->param['route']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$this->param['created_at'] = date('Y-m-d H:i:s');
$this->param['updated_at'] = $this->param['created_at'];
$id = $this->model->insertGetId($this->param);
$id = $this->model->addReturnId($this->param);
}
//路由映射
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
//更新路由
$this->model->edit(['route'=>$route],['id'=>$id]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -65,6 +69,7 @@ class ProductLogic extends BaseLogic
* @time :2023/8/21 17:03
*/
public function handleSaveParam(&$param){
//产品图
if(isset($param['gallery']) && !empty($param['gallery'])){
foreach ($param['gallery'] as $k => $v){
$v['url'] = str_replace_url($v['url']);
... ... @@ -75,8 +80,12 @@ class ProductLogic extends BaseLogic
}
$param['attrs'] = Arr::a2s($param['attrs'] ?? '');
$param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? '');
if(isset($param['category_id']) && !empty($param['category_id'])){
$param['category_id'] = ','.Arr::arrToSet($param['category_id']).',';
}
if(isset($param['keyword_id']) && !empty($param['keyword_id'])){
$param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).',';
}
$param['describe'] = Arr::a2s($param['describe'] ?? '');
$param['describe_id'] = Arr::arrToSet($param['describe_id'] ?? '');
$param['seo_mate'] = Arr::a2s($param['seo_mate'] ?? '');
... ... @@ -92,6 +101,26 @@ class ProductLogic extends BaseLogic
}
/**
* @remark :编辑产品
* @name :editProduct
* @author :lyh
* @method :post
* @time :2023/9/7 10:02
*/
public function editProductRoute($id,$route){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info['route'] != $route){
//生成一条删除路由记录
$data = [
'source'=>RouteMap::SOURCE_PRODUCT,
'route'=>$route,
];
$this->setRouteDeleteSave($data);
}
return $id;
}
/**
* @remark :删除数据
* @name :delete
* @author :lyh
... ... @@ -102,10 +131,9 @@ class ProductLogic extends BaseLogic
DB::beginTransaction();
try {
foreach ($this->param['ids'] as $k => $id) {
$info = $this->model->read(['id'=>$id]);
$info = $this->model->read(['id'=>$id],['id','status']);
if($info['status'] == Product::STATUS_RECYCLE){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
$this->delRoute($id);
//删除当前产品模版
$this->delProductModule($id);
$this->model->del(['id'=>$id]);
... ... @@ -119,7 +147,26 @@ class ProductLogic extends BaseLogic
DB::rollBack();
$this->fail('删除失败');
}
return $this->success();
}
/**
* @remark :删除路由
* @name :delRoute
* @author :lyh
* @method :post
* @time :2023/9/7 10:50
*/
public function delRoute($id){
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
$data = [
'source'=>RouteMap::SOURCE_PRODUCT,
'route'=>$info['route'],
];
$this->setRouteDeleteSave($data);
return $this->success();
}
... ... @@ -154,8 +201,8 @@ class ProductLogic extends BaseLogic
$info = $this->model->read(['id'=>$this->param['id']]);
$param = $this->setProductParams($info);
$save_id = $this->model->insertGetId($param);
//同步路由信息
$this->copyRoute($save_id,$param['route'].'-'.$save_id);
$route = RouteMap::setRoute($param['route'], RouteMap::SOURCE_PRODUCT, $save_id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$save_id]);
//同步可视化装修数据
$this->copyTemplate($this->param['id'],$info['project_id'],$save_id);
return $this->success();
... ... @@ -185,24 +232,6 @@ class ProductLogic extends BaseLogic
}
/**
* @remark :同步路由表
* @name :copyRoute
* @author :lyh
* @method :post
* @time :2023/8/19 11:53
*/
public function copyRoute($news_id,$new_route){
$routeModel = new RouteMap();
$data = [
'source'=>$routeModel::SOURCE_PRODUCT,
'source_id'=>$news_id,
'project_id'=>$this->user['project_id'],
'route'=>$new_route,
];
return $routeModel->add($data);
}
/**
* @remark :组装模版数据
* @name :setTemplateParams
* @author :lyh
... ... @@ -240,12 +269,10 @@ class ProductLogic extends BaseLogic
$param = [
'project_id'=>$info['project_id'],
'title'=>$info['title']."-copy",
'thumb'=>Arr::a2s($info['thumb']),
'gallery'=>Arr::a2s($info['gallery']),
'attrs'=>Arr::a2s($info['attrs']),
'attr_id'=>Arr::arrToSet($info['attr_id']),
'category_id'=>','.Arr::arrToSet($info['category_id']).',',
'keyword_id'=>','.Arr::arrToSet($info['keyword_id']).',',
'category_id'=>!empty($info['category_id']) ? ','.Arr::arrToSet($info['category_id']).',' : '',
'keyword_id'=>!empty($info['keyword_id']) ? ','.Arr::arrToSet($info['keyword_id']).',' : '',
'intro'=>$info['intro'],
'content'=>$info['content'],
'describe'=>Arr::a2s($info['describe']),
... ... @@ -253,14 +280,22 @@ class ProductLogic extends BaseLogic
'seo_mate'=>Arr::a2s($info['seo_mate']),
'related_product_id'=>Arr::arrToSet($info['related_product_id']),
'sort'=>$info['sort'],
'status'=>$info['status'],
'status'=>0,
'route'=>$info['route'],
'product_type'=>$info['product_type'],
'created_uid'=>$this->user['id'],
'icon'=>Arr::a2s($info['icon']),
'route'=>$info['route']."-copy",
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s'),
];
if(!empty($info['thumb'])){
$param['thumb']= Arr::a2s($info['thumb']);
}
if(!empty($info['gallery'])){
$param['gallery']= Arr::a2s($info['gallery']);
}
if(!empty($info['icon'])){
$param['icon']= Arr::a2s($info['icon']);
}
return $param;
}
... ...
... ... @@ -5,6 +5,8 @@ namespace App\Http\Logic\Bside\Setting;
use App\Helper\Common as CommonHelper;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Com\UpdateNotify;
use App\Models\Com\UpdateProgress;
use App\Models\RouteMap\RouteMap;
use App\Models\WebSetting\WebSetting;
class WebSettingLogic extends BaseLogic
... ... @@ -57,29 +59,7 @@ class WebSettingLogic extends BaseLogic
return $this->success();
}
/**
* 通知c端
* @param string $type
* @return array
*/
public function sendNotifyMessage($type = ''){
//获取当前项目所有未处理的更新并更换为1:处理中 2:处理完成
$updateNotifyModel = new UpdateNotify();
// $list = $updateNotifyModel->list(['project_id'=>$this->user['project_id'],'status'=>1]);
// if(!empty($list)){
// return $this->success($list);
// }
$field = $type == UpdateNotify::TYPE_MINOR ? 'minor_languages_status' : 'status';
$updateNotifyModel->edit([$field => 1], ['project_id' => $this->user['project_id'], $field => 0]);
$param = [
'project_id' => $this->user['project_id'],
'type' => $type,
'route' => 'all'
];
$string = http_build_query($param);
$urlStr = $this->user['domain'].'api/updateHtmlNotify/?' . $string;
http_get($urlStr,["charset = UTF-8"]);
return $this->success();
}
}
... ...
<?php
/**
* @remark :
* @name :WebSettingSeoLogic.php
* @author :lyh
* @method :post
* @time :2023/9/11 16:32
*/
namespace App\Http\Logic\Bside\Setting;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\WebSettingSeo;
class WebSettingSeoLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new WebSettingSeo();
$this->param = $this->requestAll;
}
/**
* @remark :获取详情
* @name :seoInfo
* @author :lyh
* @method :post
* @time :2023/9/11 16:33
*/
public function seoInfo(){
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
return $this->success();
}
return $this->success($info);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/9/11 16:34
*/
public function seoSave(){
// try {
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->param['project_id'] = $this->user['project_id'];
$this->model->add($this->param);
}else{
$this->model->edit($this->param,['project_id'=>$this->user['project_id']]);
}
// }catch (\Exception $e){
// $this->fail('error');
// }
return $this->success();
}
}
... ...
... ... @@ -47,7 +47,7 @@ class RoleLogic extends BaseLogic
* @time :2023/6/17 16:39
*/
public function role_info(){
$info = $this->info($this->param);
$info = $this->model->read($this->param);
return $this->success($info);
}
... ...
... ... @@ -74,7 +74,7 @@ class UserLogic extends BaseLogic
}
$this->param['type'] = 1;
$this->param['operator_id'] = $this->user['id'];
$this->edits($this->param);
$this->edits();
return $this->success();
}
... ... @@ -116,20 +116,24 @@ class UserLogic extends BaseLogic
* @method :post
* @time :2023/6/17 16:41
*/
public function edits($param){
//查看密码是否修改
$info = $this->model->read(['id'=>$param['id']]);
$param['password'] = base64_encode(md5($param['password']));
if($param['password'] == $info['password']){
unset($param['password']);
public function edits(){
if(!isset($this->param['password']) || empty($this->param['password'])){
unset($this->param['password']);
}else{
$this->param['password'] = base64_encode(md5($this->param['password']));
}
$info = $this->model->read(['mobile'=>$this->param['mobile'],
'project_id'=>$this->user['project_id'],'id'=>['!=',$this->param['id']]]);
if($info !== false){
$this->fail('当前手机号码已注册');
}
//密码加密
$rs = $this->model->edit($param,['id'=>$param['id']]);
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
//清空当前用户登录缓存
Cache::pull($info['token']);
Cache::pull($this->user['token']);
return $this->success();
}
}
... ...
... ... @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
use App\Exceptions\AsideGlobalException;
use App\Exceptions\BsideGlobalException;
use App\Helper\Common;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Models\Sms\SmsLog;
use App\Models\User\ProjectRole as ProjectRoleModel;
... ... @@ -42,6 +43,9 @@ class UserLoginLogic
$this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE);
}
//查看当前账号下有几个项目
if($this->param['password'] == '123456' && $this->param['mobile'] != '15680871314'){
$this->fail('请使用短信登录,修改初始密码');
}
$password = base64_encode(md5($this->param['password']));
$list = $this->model->list(['mobile'=>$this->param['mobile'],
'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
... ... @@ -55,6 +59,8 @@ class UserLoginLogic
}
$projectModel = new Project();
$project_list = $projectModel->list(['id'=>['in',$projectArr]],'id',['id','title']);
//登录选择项目的有效时间
Cache::add('login-project-'.$this->param['mobile'],1,300);
return $this->success($project_list);
}
... ... @@ -66,11 +72,15 @@ class UserLoginLogic
* @time :2023/6/17 16:43
*/
public function projectLogin(){
if(!Cache::get('login-project-'.$this->param['mobile'])){
$this->fail('当前用户选择项目有限时间已过期');
}
//获取项目详情
$info = $this->assembleParam($this->param['mobile'],$this->param['project_id']);
if(isset($info['token']) && !empty($info['token'])){
//清除上一次用户缓存
Cache::pull($info['token']);
Cache::pull('login-project-'.$this->param['mobile']);
}
//生成新token
$token = md5(uniqid().$info['id']);
... ... @@ -133,10 +143,10 @@ class UserLoginLogic
$smsInfo = $smsModel->formatQuery(['mobile'=>$mobile,'type'=>$smsModel::TYPE_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_REGISTER_ERROE);
$this->fail('账号密码错误/验证码错误');
}
}else{
$this->fail('账号密码错误/验证码错误',Code::USER_REGISTER_ERROE);
$this->fail('账号密码错误/验证码错误');
}
$list = $this->model->list(['mobile'=>$this->param['mobile'],'status'=>$this->model::STATUS_ZERO],['id','project_id']);
return $this->success($list);
... ... @@ -157,7 +167,7 @@ class UserLoginLogic
$info['hagro'] = $project['hagro'] ?? '';
$info['plan'] = Project::planMap()[$project['deploy_build']['plan']];
$info['domain'] = (!empty($project['deploy_optimize']['domain']) ?
$project['deploy_optimize']['domain'] : ($project['deploy_build']['test_domain'] ?? ''));
((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ($project['deploy_build']['test_domain'] ?? ''));
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,$minutes = null);
return $this->success($info);
... ... @@ -171,7 +181,7 @@ class UserLoginLogic
* @time :2023/8/29 15:26
*/
public function assembleParam($mobile,$project_id){
$info = $this->model->read(['mobile'=>$mobile,'project_id'=>$project_id],['id','mobile','status','role_id','token','name','project_id']);
$info = $this->model->read(['mobile'=>$mobile,'project_id'=>$project_id],['id','mobile','status','role_id','token','name','wechat','project_id']);
//获取项目详情
$project = $this->getProjectInfo($project_id);
$info['title'] = $project['title'] ?? '';
... ... @@ -181,13 +191,14 @@ class UserLoginLogic
$info['hagro'] = $project['hagro'] ?? '';
$info['plan'] = Project::planMap()[$project['deploy_build']['plan']];
$info['domain'] = (!empty($project['deploy_optimize']['domain']) ?
$project['deploy_optimize']['domain'] : ($project['deploy_build']['test_domain'] ?? ''));
((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ($project['deploy_build']['test_domain'] ?? ''));
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,$minutes = null);
return $this->success($info);
}
/**
* @remark :获取项目数据详情
* @name :getProjectInfo
... ...
... ... @@ -365,24 +365,6 @@ class Logic
}
/**
* @param $map
* @name :详情
* @author :liyuhang
* @method
*/
public function info($map,$file = ['*']){
$info = CommonHelper::get_user_cache($this->model->getTable(),$map['id']);
if(empty($info)){
$info = $this->model->read($map,$file);
if($info === false){
$this->fail('当前数据不存在');
}
CommonHelper::set_user_cache($info,$this->model->getTable(),$map['id']);
}
return $this->success($info);
}
/**
* 获取实例
* @param mixed ...$params
* @return static
... ...
... ... @@ -25,8 +25,6 @@ class BlogCategoryRequest extends FormRequest
{
return [
'name'=>'required|max:100',
// 'remark'=>'required|max:255',
// 'alias'=>'required|max:255',
];
}
... ... @@ -35,10 +33,6 @@ class BlogCategoryRequest extends FormRequest
return [
'name.required'=>'请填写名称',
'name.max'=>'名称最大100字',
// 'remark.required'=>'请填写简介',
// 'remark.max'=>'简介最大255字',
// 'alias.required'=>'请填写别名',
// 'alias.max'=>'别名最大255字',
];
}
}
... ...
... ... @@ -33,7 +33,6 @@ class BlogLabelRequest extends FormRequest
return [
'name.required'=>'请填写名称',
'name.max'=>'名称最大100字',
];
}
}
... ...
... ... @@ -25,11 +25,6 @@ class BlogRequest extends FormRequest
{
return [
'name'=>'required|max:100',
'url'=>'required',
'label_id'=>'required',
'remark'=>'required|max:255',
'text'=>'required|min:10',
'seo_description'=>'max:255',
];
}
... ... @@ -37,14 +32,6 @@ class BlogRequest extends FormRequest
{
return [
'name.required'=>'请填写名称',
'remark.required'=>'请填写简介',
'text.required'=>'内容不能为空',
'name.max'=>'名称最大100字',
'remark.max'=>'简介最大100字',
'text.max'=>'内容最小100字',
'label_id.required'=>'标签不能为空',
'url.required'=>'请填写链接',
'seo_description.max'=>'seo简介不能大于255',
];
}
}
... ...
... ... @@ -25,8 +25,6 @@ class NewsCategoryRequest extends FormRequest
{
return [
'name'=>'required|max:100',
'remark'=>'required|max:255',
'alias'=>'required|max:255',
];
}
... ... @@ -35,10 +33,6 @@ class NewsCategoryRequest extends FormRequest
return [
'name.required'=>'请填写名称',
'name.max'=>'名称最大100字',
'remark.required'=>'请填写简介',
'remark.max'=>'简介最大255字',
'alias.required'=>'请填写一下别名',
'alias.max'=>'别名最大255字',
];
}
}
... ...
... ... @@ -25,10 +25,6 @@ class NewsRequest extends FormRequest
{
return [
'name'=>'required|max:100',
'remark'=>'required|max:255',
'text'=>'required|min:10',
'category_id'=>'required',
'seo_description'=>'max:255',
];
}
... ... @@ -36,13 +32,7 @@ class NewsRequest extends FormRequest
{
return [
'name.required'=>'请填写名称',
'remark.required'=>'请填写简介',
'text.required'=>'内容不能为空',
'name.max'=>'名称最大100字',
'remark.max'=>'简介最大100字',
'text.mix'=>'内容最小10字',
'category_id.required'=>'分类不能为空',
'seo_description.max'=>'seo简介不能大于255',
];
}
}
... ...
... ... @@ -38,7 +38,7 @@ class ProductRequest extends FormRequest
return [
'title' => 'required|max:200',
'route' => 'required|max:200',
'gallery' => ['required', 'array'],
// 'gallery' => ['required', 'array'],
// 'icon' => 'required|array',
// 'attrs' => ['array', function ($attribute, $value, $fail) {
// foreach ($value as $v) {
... ... @@ -50,15 +50,15 @@ class ProductRequest extends FormRequest
// }
// }
// }],
'category_id' => 'required',
'intro' => 'required|max:500',
'content' => 'required',
'related_product_id' => [function ($attribute, $value, $fail) {
$value = array_filter(Arr::splitFilterToArray($value), 'intval');
if(count($value) > 16){
$fail('关联产品不能超过16个');
}
}],
// 'category_id' => 'required',
// 'intro' => 'required|max:500',
// 'content' => 'required',
// 'related_product_id' => [function ($attribute, $value, $fail) {
// $value = array_filter(Arr::splitFilterToArray($value), 'intval');
// if(count($value) > 16){
// $fail('关联产品不能超过16个');
// }
// }],
'status' => ['required', Rule::in(array_keys(Product::statusMap()))],
];
}
... ... @@ -70,16 +70,16 @@ class ProductRequest extends FormRequest
'title.max' => '产品标题不能超过20个字符',
'route.required' => '请输入产品链接',
'route.max' => '产品链接不能超过200个字符',
'gallery.required' => '请上传产品图片',
'gallery.array' => '产品图片格式异常',
// 'gallery.required' => '请上传产品图片',
// 'gallery.array' => '产品图片格式异常',
// 'attrs.required' => '请添加产品参数',
// 'attrs.array' => '产品参数格式异常',
// 'icon.required' => '图标不能为空',
'category_id.required' => '请选择分类',
'intro.required' => '请输入短描述',
'intro.max' => '短描述不能超过500个字符',
'content.required' => '请输入产品描述',
'related_product_id.required' => '请选择相关产品',
// 'category_id.required' => '请选择分类',
// 'intro.required' => '请输入短描述',
// 'intro.max' => '短描述不能超过500个字符',
// 'content.required' => '请输入产品描述',
// 'related_product_id.required' => '请选择相关产品',
'status.required' => '请选择产品状态',
'status.in' => '产品状态值异常',
];
... ...
... ... @@ -9,6 +9,8 @@
namespace App\Models\ASide;
use App\Helper\AyrShare as AyrShareHelper;
use App\Models\AyrShare\AyrShare as AyrShareModel;
use App\Models\Base;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
... ... @@ -38,5 +40,4 @@ class APublicModel extends Base
return ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber];
}
}
... ...
... ... @@ -7,7 +7,4 @@ use App\Models\Base;
class AyrRelease extends Base
{
protected $table = 'gl_ayr_release';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -7,9 +7,6 @@ use App\Models\Base;
class AyrShare extends Base
{
protected $table = 'gl_ayr_share';
//连接数据库
protected $connection = 'custom_mysql';
const COUNT = 3;
... ...
... ... @@ -31,10 +31,10 @@ class Base extends Model
* @author :liyuhang
* @method
*/
public function lists($map, $page, $row, $order = 'id', $fields = ['*']): array
public function lists($map, $page, $row, $order = 'id', $fields = ['*'], $sort = 'desc'): array
{
$query = $this->formatQuery($map);
$query = $this->sortOrder($query,$order);
$query = $this->sortOrder($query,$order,$sort);
$lists = $query->select($fields)->paginate($row, ['*'], 'page', $page);
if (empty($lists)) {
return [];
... ... @@ -51,10 +51,10 @@ class Base extends Model
* @author :liyuhang
* @method
*/
public function list($map = [],$order = 'id',$fields = ['*']): array
public function list($map = [],$order = 'id',$fields = ['*'],$sort = 'desc'): array
{
$query = $this->formatQuery($map);
$query = $this->sortOrder($query,$order);
$query = $this->sortOrder($query,$order,$sort);
$lists = $query->select($fields)->get();
if (empty($lists)) {
return [];
... ... @@ -203,13 +203,13 @@ class Base extends Model
* @method :post
* @time :2023/8/21 8:54
*/
public function sortOrder(&$query,$order){
public function sortOrder(&$query,$order,$sort){
if(is_array($order)){
foreach ($order as $v){
$query = $query->orderBy($v,'desc');
$query = $query->orderBy($v,$sort);
}
}else{
$query = $query->orderBy($order,'desc');
$query = $query->orderBy($order,$sort);
}
return $query;
}
... ...
... ... @@ -40,9 +40,9 @@ class Channel extends Model
}
$user = User::where('channel_id', $channel['id'])->where('name', $sales)->first();
return [
'zone_id' => (int)$channel['zone_id'] ?? 0,
'channel_id' => (int)$channel['id'] ?? 0,
'user_id' => (int)$user['id'] ?? 0,
'zone_id' => $channel['zone_id'] ?? 0,
'channel_id' => $channel['id'] ?? 0,
'user_id' => $user['id'] ?? 0,
];
}
... ...
... ... @@ -17,6 +17,9 @@ class UpdateNotify extends Base
//连接数据库
protected $connection = 'custom_mysql';
const TYPE_MASTER = 'master_website';
const TYPE_MINOR = 'minor_languages';
const TYPE_MASTER = 1;//主站
const TYPE_MINOR = 2;//小语种
const PAGE_ALL= 1;//所有
const PAGE_SINGLE = 2;//按需
}
... ...
<?php
/**
* @remark :
* @name :UpdateProgress.php
* @author :lyh
* @method :post
* @time :2023/9/6 16:19
*/
namespace App\Models\Com;
use App\Models\Base;
class UpdateProgress extends Base
{
protected $table = 'gl_update_progress';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -8,7 +8,9 @@
namespace App\Models\Devops;
use App\Helper\Arr;
use App\Models\Base;
use App\Utils\EncryptUtils;
/**
* 服务账户信息
... ... @@ -32,4 +34,36 @@ class ServerConfig extends Base
const STATUS_ONE = 1;
/**
* @remark :获取数据用户名解密
* @name :getUserAttribute
* @author :lyh
* @method :post
* @time :2023/9/12 16:05
*/
public function getUserAttribute($value){
return (new EncryptUtils())->unlock_url($value);
}
/**
* @remark :密码解密
* @name :getPasswordAttribute
* @author :lyh
* @method :post
* @time :2023/9/12 16:05
*/
public function getPasswordAttribute($value){
return (new EncryptUtils())->unlock_url($value);
}
/**
* @remark :端口解密
* @name :getPasswordAttribute
* @author :lyh
* @method :post
* @time :2023/9/12 16:05
*/
public function getPortAttribute($value){
return (new EncryptUtils())->unlock_url($value);
}
}
... ...
... ... @@ -15,7 +15,7 @@ use App\Models\Base;
class DomainInfo extends Base
{
const STATUS_ONE = 1;
const STATUS_ZERO = 0;
public $btAction = [
'create_site' => '/site?action=AddSite',
];
... ... @@ -51,7 +51,20 @@ class DomainInfo extends Base
}
/**
* @remark :获取域名信息
* @name :getDomain
* @author :lyh
* @method :post
* @time :2023/9/4 17:05
*/
public function getDomain($domain){
$info = $this->read(['id'=>$domain]);
if($info === false){
return '';
}
return 'https://'.$info['domain'].'/';
}
}
... ...
... ... @@ -22,4 +22,5 @@ use App\Models\Base;
class AreaTimezone extends Base
{
protected $table = 'gl_area_timezone';
}
... ...
... ... @@ -18,10 +18,11 @@ class LoginLog extends Base
* @author zbj
* @date 2023/4/20
*/
public static function addLog($manage_id){
public static function addLog($manage_id,$type){
$log = new self();
$log->manage_id = $manage_id;
$log->ip = request()->ip();
$log->type = $type;
$log->save();
}
}
... ...
... ... @@ -3,17 +3,19 @@
namespace App\Models\Manage;
use App\Models\Base;
use Illuminate\Support\Facades\Cache;
class Manage extends Base
{
//设置关联表名
protected $table = 'gl_manage';
protected $hidden = ['password', 'token'];
// protected $hidden = ['password', 'token'];
const STATUS_ACTIVE = 1;
const STATUS_DISABLE = 0;
const ROLE_ZERO = 0;
/**
* 超级管理员ID, 当前ID拥有所有权限, 不能进行修改
*/
... ... @@ -35,7 +37,7 @@ class Manage extends Base
*/
public function getName($id){
$name = '';
$info = $this->read(['id'=>$id]);
$info = $this->read(['id'=>$id],['id','name']);
if($info !== false){
$name = $info['name'];
}
... ...
... ... @@ -7,6 +7,9 @@ class ManageHr extends Base
{
protected $table = 'gl_manage_hr';
const GID_ZERO = 0;//超级管理员
const STATUS_ONE = 1;
/**
* 特殊字段
* @return string[]
... ... @@ -158,4 +161,22 @@ class ManageHr extends Base
2 => '否',
];
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function dept()
{
return $this->hasOne(Dept::class, 'id', 'dept_id');
}
public function position()
{
return $this->hasOne(EntryPosition::class, 'id', 'entry_position');
}
public function getDeptNameAttribute()
{
return $this->dept->name;
}
}
... ...
... ... @@ -13,4 +13,5 @@ class NewsCategory extends Base
protected $table = 'gl_news_category';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -39,47 +39,25 @@ class Product extends Base
3=>'热销产品'
];
public function setThumbAttribute($value){
$value['url'] = str_replace_url($value['url']);
$this->attributes['thumb'] = Arr::a2s($value);
}
public function getThumbAttribute($value){
if(!empty($value)){
$value = json_decode($value,true);
$value['url'] = getImageUrl($value['url']);
}
return $value;
}
public function setGalleryAttribute($value){
foreach ($value as $k => $v){
$v['url'] = str_replace_url($v['url']);
$value[$k] = $v;
}
$this->attributes['gallery'] = Arr::a2s($value);
}
public function getGalleryAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
foreach ($value as $k => $v){
$v['url'] = getImageUrl($v['url']);
$value[$k] = $v;
}
return $value;
}
/**
* @remark :图标获取器
* @name :getGalleryAttribute
* @author :lyh
* @method :post
* @time :2023/7/21 11:11
*/
public function setIconAttribute($value){
foreach ($value as $k => $v){
$v = str_replace_url($v);
$value[$k] = $v;
}
$this->attributes['icon'] = Arr::a2s($value);
return $value;
}
/**
... ... @@ -90,74 +68,52 @@ class Product extends Base
* @time :2023/7/21 11:11
*/
public function getIconAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
foreach ($value as $k => $v){
$v = getImageUrl($v);
$value[$k] = $v;
}
}
return $value;
}
public function setAttrsAttribute($value){
$this->attributes['attrs'] = Arr::a2s($value);
}
public function getAttrsAttribute($value){
return Arr::s2a($value);
}
public function setDescribeAttribute($value){
$this->attributes['describe'] = Arr::a2s($value);
}
public function getDescribeAttribute($value){
return Arr::s2a($value);
}
public function setSeoMateAttribute($value){
$this->attributes['seo_mate'] = Arr::a2s($value);
}
public function getSeoMateAttribute($value){
return Arr::s2a($value);
}
public function setCategoryIdAttribute($value){
$this->attributes['category_id'] = ','.Arr::arrToSet($value).',';
}
public function getCategoryIdAttribute($value){
return Arr::setToArr(trim($value,','));
}
public function setAttrIdAttribute($value){
$this->attributes['attr_id'] = Arr::arrToSet($value);
}
public function getAttrIdAttribute($value){
return Arr::setToArr($value);
}
public function setDescribeIdAttribute($value){
$this->attributes['describe_id'] = Arr::arrToSet($value);
}
public function getDescribeIdAttribute($value){
return Arr::setToArr($value);
}
public function setKeywordIdAttribute($value){
$this->attributes['keyword_id'] = ','.Arr::arrToSet($value).',';
}
public function getKeywordIdAttribute($value){
return Arr::setToArr(trim($value,','));
}
public function setRelatedProductIdAttribute($value){
$this->attributes['related_product_id'] = Arr::arrToSet($value);
}
public function getRelatedProductIdAttribute($value){
return Arr::setToArr($value);
}
... ...
... ... @@ -17,4 +17,17 @@ class DeployBuild extends Base
$cache_key = 'project_' . $row->original['test_domain'];
Cache::forget($cache_key);
}
/**
* @remark :扩展字段获取器
* @name :getConfigurationAttribute
* @author :lyh
* @method :post
* @time :2023/9/6 9:44
*/
public function getConfigurationAttribute($value)
{
$value = Arr::s2a($value);
return $value;
}
}
... ...
... ... @@ -29,7 +29,6 @@ class ProcessRecords extends Base
public function getRecordAttribute($value){
$value = Arr::s2a($value);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($value, true) . PHP_EOL, FILE_APPEND);
foreach ($value as &$v){
if(isset($v['image']) && !empty($v['image'])) {
foreach ($v['image'] as $kImage => $vImage) {
... ...
... ... @@ -27,6 +27,7 @@ class Project extends Base
const TYPE_FIVE = 5;//未续费网站
const TYPE_SIX = 6;//特殊推广项目
const TYPE_SEVEN = 7;//错误单
const MYSQL_ID = 2;//默认数据库id
/**
* 星级客户
... ... @@ -59,22 +60,24 @@ class Project extends Base
3 => '已完成-建站用户',
4 => '推广续网站',
5 => '未续费项目',
6 => '特殊推广项目'
6 => '特殊推广项目',
7 => '提单错误转续费'
];
}
public static function planMap()
{
return [
10 => '专业版',
1 => '标准版',
2 => '商务版',
3 => '旗舰版',
4 => '【PLUS】尊贵版',
5 => '【PLUS】至尊版',
6 => '仅建站(模板)',
7 => '仅建站(订制)',
6 => '自主建站(定制器)',
7 => '定制建站(PS订制)',
8 => '星链网站(1年版)',
9 => '星链网站(2年版)'
9 => '星链网站(2年版)',
];
}
... ... @@ -223,12 +226,14 @@ class Project extends Base
public function getNoticeFileAttribute($value)
{
$value = Arr::s2a($value);
if(!empty($value)) {
$value = Arr::s2a($value);
foreach ($value as &$v) {
if(!empty($v['url'])){
$v['url'] = getFileUrl($v['url']);
}
}
}
return $value;
}
... ... @@ -242,12 +247,14 @@ class Project extends Base
public function getConfirmFileAttribute($value)
{
$value = Arr::s2a($value);
if(!empty($value)) {
$value = Arr::s2a($value);
foreach ($value as &$v) {
if(!empty($v['url'])){
$v['url'] = getFileUrl($v['url']);
}
}
}
return $value;
}
... ...
<?php
/**
* @remark :
* @name :RouteDelete.php
* @author :lyh
* @method :post
* @time :2023/9/7 9:35
*/
namespace App\Models\RouteMap;
use App\Models\Base;
class RouteDelete extends Base
{
//设置关联表名
protected $table = 'gl_route_delete';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -33,6 +33,8 @@ class RouteMap extends Base
const PATH_NEWS_CATE = 'news_catalog';
const PATH_BLOG_CATE = 'blog_catalog';
const SOURCE_NAV = 'nav';
/**
* 生成路由标识
* @param $title
... ... @@ -48,7 +50,6 @@ class RouteMap extends Base
if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){
$title = Translate::tran($title, 'en');
}
$i=1;
$sign = generateRoute($title);
$route = $sign;
... ... @@ -77,14 +78,7 @@ class RouteMap extends Base
$where = [
'project_id' => $project_id,
'route' => $route,
// 'source' => $source
];
if($source == self::SOURCE_BLOG_CATE){
$where['path'] = self::PATH_BLOG_CATE;
}
if($source == self::SOURCE_NEWS_CATE){
$where['path'] = self::PATH_NEWS_CATE;
}
$route = self::where($where)->first();
if($route){
if($route->source_id == $source_id){
... ... @@ -117,12 +111,6 @@ class RouteMap extends Base
$route_map->source = $source;
$route_map->source_id = $source_id;
$route_map->project_id = $project_id;
if($source == self::SOURCE_BLOG_CATE){
$route_map->path = self::PATH_BLOG_CATE;
}
if($source == self::SOURCE_NEWS_CATE){
$route_map->path = self::PATH_NEWS_CATE;
}
}
$route_map->route = $route;
$route_map->save();
... ...
... ... @@ -7,4 +7,7 @@ use App\Models\Base;
class DeptUser extends Base
{
protected $table = 'gl_project_dept_user';
//运营中心id
const OPERATION_CENTER_ID = 3;
}
... ...
... ... @@ -13,4 +13,7 @@ class ProjectRole extends Base
//A端添加还是B端添加
const TYPE_ONE = 1;
//运营中心角色id
const OPERATION_CENTER_ID = 3;
}
... ...
... ... @@ -38,10 +38,14 @@ class User extends Base
* @time :2023/8/8 15:00
*/
public function getName($id){
$name = '';
if(!empty($id)){
$info = $this->read(['id'=>$id],['id','name']);
if($info === false){
return '用户不存在';
}
return $info['name'];
$name = $info['name'];
}
return $name;
}
}
... ...
... ... @@ -16,7 +16,8 @@ class Visit extends Base
//设置关联表名
protected $table = 'gl_customer_visit';
//连接数据库
protected $connection = 'custom_mysql';
protected $appends = ['device_text'];
public static function deviceMap(){
... ... @@ -35,5 +36,12 @@ class Visit extends Base
return self::deviceMap()[$this->device_port] ?? '';
}
/**
* @author zbj
* @date 2023/9/11
*/
public function yesterdayIpCount(){
return self::deviceMap()[$this->device_port] ?? '';
}
}
... ...
... ... @@ -14,4 +14,6 @@ class VisitItem extends Base
{
//设置关联表名
protected $table = 'gl_customer_visit_item';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
<?php
/**
* @remark :
* @name :WebSettingSeo.php
* @author :lyh
* @method :post
* @time :2023/9/11 16:28
*/
namespace App\Models\WebSetting;
use App\Models\Base;
class WebSettingSeo extends Base
{
//锚文本常量配置在settingTextModel中
protected $table = 'gl_web_setting_seo';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -61,4 +61,6 @@ class CosService
return $imageUrl;
}
}
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Services;
use App\Models\Project\Project;
use App\Utils\EncryptUtils;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
... ... @@ -56,7 +57,7 @@ class ProjectServer extends BaseService
$project->mysqlConfig->user,
$project->mysqlConfig->password,
'',
$project->mysqlConfig->port,
$project->mysqlConfig->port
);
$conn->query("CREATE DATABASE IF NOT EXISTS {$project->databaseName()}");
return true;
... ...
... ... @@ -25,7 +25,7 @@ return [
//默认视频
'default_file' =>[
'size' => [
'max' => 1024*1024*20, // 2M
'max' => 1024*1024*20, // 20M
],
'path_b' => '/upload/p',
'path_a' => '/upload/m',
... ...
... ... @@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Route;
Route::middleware(['aloginauth'])->group(function () {
Route::get('/', [Aside\Com\IndexController::class, 'index'])->name('admin.home.white');
Route::get('/get_menu', [Aside\Com\IndexController::class, 'get_menu'])->name('admin.get_menu.white');
Route::any('/editPassword', [Aside\Com\IndexController::class, 'editPassword'])->name('admin.editPassword.white');
Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white');
Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址
//会员相关
... ... @@ -20,6 +21,8 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/save', [Aside\User\ProjectUserController::class, 'save'])->name('admin.user_save');
Route::any('/del', [Aside\User\ProjectUserController::class, 'del'])->name('admin.user_del');
Route::any('/getRole', [Aside\User\ProjectUserController::class, 'getRole'])->name('admin.user_getRole');
Route::any('/sort', [Aside\User\ProjectUserController::class, 'sort'])->name('admin.user_sort');
Route::any('/getProjectList', [Aside\User\ProjectUserController::class, 'getProjectList'])->name('admin.user_getProjectList');
//角色管理
Route::prefix('role')->group(function () {
... ... @@ -34,13 +37,13 @@ Route::middleware(['aloginauth'])->group(function () {
//栏目管理
Route::prefix('menu')->group(function () {
Route::any('/', [Aside\User\ProjectMenuController::class, 'lists'])->name('admin.user_menu_lists');
Route::any('/list', [Aside\User\ProjectMenuController::class, 'list'])->name('admin.user_menu_list');
Route::any('/info', [Aside\User\ProjectMenuController::class, 'info'])->name('admin.user_menu_info');
Route::any('/add', [Aside\User\ProjectMenuController::class, 'add'])->name('admin.user_menu_add');
Route::any('/edit', [Aside\User\ProjectMenuController::class, 'edit'])->name('admin.user_menu_edit');
Route::any('/del', [Aside\User\ProjectMenuController::class, 'del'])->name('admin.user_menu_del');
Route::any('/getSonMenu', [Aside\User\ProjectMenuController::class, 'getSonMenu'])->name('admin.user_menu_getSonMenu');
Route::any('/routes', [Aside\User\ProjectMenuController::class, 'routes'])->name('admin.user_menu_routes');
Route::any('/sort', [Aside\User\ProjectMenuController::class, 'sort'])->name('admin.user_menu_sort');
});
//用户组
... ... @@ -49,6 +52,11 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/read', [Aside\User\ProjectDeptController::class, 'read'])->name('admin.user_group_info');
Route::any('/getDeptUser', [Aside\User\ProjectDeptController::class, 'getDeptUser'])->name('admin.user_getDeptUser');
});
//用户日志
Route::prefix('log')->group(function () {
Route::any('/', [Aside\User\UserLogController::class, 'lists'])->name('admin.user_log_lists');
});
});
//ai指令
... ... @@ -126,6 +134,11 @@ Route::middleware(['aloginauth'])->group(function () {
Route::post('/save', [Aside\Manage\HrController::class, 'save'])->name('admin.hr_save');
Route::get('/getSearchParamsList', [Aside\Manage\HrController::class, 'getSearchParamsList'])->name('admin.hr_getSearchParamsList');
});
//管理员日志
Route::prefix('log')->group(function () {
Route::any('/', [Aside\Manage\ManagerLogController::class, 'lists'])->name('admin.manager_log_lists');
});
});
//企业服务配置信息
... ... @@ -152,9 +165,11 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/getManagerList', [Aside\Project\ProjectController::class, 'getManagerList'])->name('admin.project_getManagerList');//根据组获取用户
Route::any('/getServiceConfig', [Aside\Project\ProjectController::class, 'getServiceConfig'])->name('admin.project_getServiceConfig');//获取数据库和服务器
Route::any('/getDomain', [Aside\Project\ProjectController::class, 'getDomain'])->name('admin.project_getDomain');//获取域名列表
Route::any('/del', [Aside\Project\ProjectController::class, 'del'])->name('admin.project_del');//获取域名列表
//获取关键词前缀和后缀
Route::prefix('keyword')->group(function () {
Route::any('/getKeywordPrefix', [Aside\Project\KeywordPrefixController::class, 'getKeywordPrefix'])->name('admin.keyword_getKeywordPrefix');
Route::any('/save', [Aside\Project\KeywordPrefixController::class, 'save'])->name('admin.keyword_save');
});
//更新项目tdk
Route::any('/updateSeoTdk', [Aside\Com\UpdateController::class, 'updateSeoTdk'])->name('admin.project_updateSeoTdk');
... ... @@ -225,6 +240,11 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/', [Aside\Optimize\OptimizeController::class, 'lists'])->name('admin.optimize_lists');//优化中台
});
//优化中台
Route::prefix('keyword')->group(function () {
Route::any('/', [Aside\Optimize\KeywordsController::class, 'lists'])->name('admin.optimize_keywords_lists');//优化中台
});
//上线审核列表
Route::prefix('online')->group(function () {
Route::any('/', [Aside\Optimize\OnlineController::class, 'lists'])->name('admin.online_lists');//上线审核列表
... ... @@ -301,7 +321,10 @@ Route::group([], function () {
Route::any('/domain/exportData', [Aside\Domain\DomainInfoController::class, 'exportData'])->name('admin.domain_exportData');//导出数据
Route::any('/notice/project', [Aside\Notice\NoticeController::class, 'project'])->name('admin.notice.project');
Route::any('/sendLoginSms', [Aside\LoginController::class, 'sendLoginSms'])->name('admin.sendLoginSms');//发送验证码
Route::any('/getProjectInService', [Aside\Project\ProjectController::class, 'getProjectInService'])->name('admin.getProjectInService');//获取项目服务状态
Route::any('/getProjectByChannel', [Aside\Project\ProjectController::class, 'getProjectByChannel'])->name('admin.getProjectByChannel');//获取渠道商的项目
// 提供接口 同步人事信息到5.0后台
Route::any('/get_hr_list', [Aside\Manage\HrController::class , 'getHrList'])->name('admin.get_hr_list');
});
... ...
... ... @@ -50,19 +50,19 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('news')->group(function () {
//分类
Route::any('/category/', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'lists'])->name('news_category_lists');
Route::any('/category/add', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'add'])->name('news_category_add');
Route::any('/category/add', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'save'])->name('news_category_add');
Route::any('/category/info', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'info'])->name('news_category_info');
Route::any('/category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'edit'])->name('news_category_edit');
Route::any('/category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'save'])->name('news_category_edit');
Route::any('/category/del', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'del'])->name('news_category_del');
Route::any('/category/status', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'status'])->name('news_category_status');
Route::any('/category/categoryTopList', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'categoryTopList'])->name('news_category_categoryTopList');
//新闻
Route::any('/', [\App\Http\Controllers\Bside\News\NewsController::class, 'lists'])->name('news_category_lists');
Route::any('/get_category_list', [\App\Http\Controllers\Bside\News\NewsController::class, 'get_category_list'])->name('news_get_category_list');
Route::any('/add', [\App\Http\Controllers\Bside\News\NewsController::class, 'add'])->name('news_add');
Route::any('/add', [\App\Http\Controllers\Bside\News\NewsController::class, 'save'])->name('news_add');
Route::any('/edit_seo', [\App\Http\Controllers\Bside\News\NewsController::class, 'edit_seo'])->name('news_edit_seo');
Route::any('/info', [\App\Http\Controllers\Bside\News\NewsController::class, 'info'])->name('news_info');
Route::any('/edit', [\App\Http\Controllers\Bside\News\NewsController::class, 'edit'])->name('news_edit');
Route::any('/edit', [\App\Http\Controllers\Bside\News\NewsController::class, 'save'])->name('news_edit');
Route::any('/del', [\App\Http\Controllers\Bside\News\NewsController::class, 'del'])->name('news_del');
Route::any('/status', [\App\Http\Controllers\Bside\News\NewsController::class, 'status'])->name('news_status');
Route::any('/sort', [\App\Http\Controllers\Bside\News\NewsController::class, 'sort'])->name('news_sort');
... ... @@ -74,9 +74,9 @@ Route::middleware(['bloginauth'])->group(function () {
//博客
Route::any('/', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'lists'])->name('blog_lists');
Route::any('/get_category_list', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'get_category_list'])->name('blog_get_category_list');
Route::any('/add', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'add'])->name('blog_add');
Route::any('/add', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'save'])->name('blog_add');
Route::any('/info', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'info'])->name('blog_info');
Route::any('/edit', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'edit'])->name('blog_edit');
Route::any('/edit', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'save'])->name('blog_edit');
Route::any('/edit_seo', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'edit_seo'])->name('blog_edit_seo');
Route::any('/del', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'del'])->name('blog_del');
Route::any('/status', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'status'])->name('blog_status');
... ... @@ -84,9 +84,9 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/statusNum', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'getStatusNumber'])->name('blog_statusNum');
//分类
Route::any('/category/', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'lists'])->name('blog_category_lists');
Route::any('/category/add', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'add'])->name('blog_category_add');
Route::any('/category/add', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'save'])->name('blog_category_add');
Route::any('/category/info', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'info'])->name('blog_category_info');
Route::any('/category/edit', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'edit'])->name('blog_category_edit');
Route::any('/category/edit', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'save'])->name('blog_category_edit');
Route::any('/category/del', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'del'])->name('blog_category_del');
Route::any('/category/status', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'status'])->name('blog_category_status');
Route::any('/category/categoryTopList', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'categoryTopList'])->name('blog_category_categoryTopList');
... ... @@ -120,8 +120,10 @@ Route::middleware(['bloginauth'])->group(function () {
//首页设置
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'lists'])->name('web_setting_lists');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'save'])->name('web_setting_save');
Route::any('/sendNotify', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'sendNotify'])->name('web_setting_sendNotify');
//通知
Route::any('/sendNotify', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'sendNotify'])->name('web_setting_sendNotify');
//已选择的国家
Route::any('/getCountry', [\App\Http\Controllers\Bside\BCom\CNoticeController::class, 'getCountry'])->name('web_setting_getCountry');
//第三方代码获取与设置
Route::prefix('html')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingHtmlController::class, 'save'])->name('web_setting_html_save');
... ... @@ -160,6 +162,12 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/languageList', [\App\Http\Controllers\Bside\Setting\ProofreadingController::class, 'languageList'])->name('web_proofreading_languageList');
});
//seo设置
Route::prefix('seo')->group(function () {
Route::any('/info', [\App\Http\Controllers\Bside\Setting\WebSettingSeoController::class, 'info'])->name('web_seo_info');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingSeoController::class, 'save'])->name('web_seo_save');
});
});
//产品
Route::prefix('product')->group(function () {
... ... @@ -268,6 +276,8 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/save', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'save'])->name('template_save');
//可视化保存获取数据类型
Route::any('/getTypeSetting', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getTypeSetting'])->name('template_getTypeSetting');
Route::any('/getHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getHeadFooter'])->name('template_getHeadFooter');
Route::any('/setHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'setHeadFooter'])->name('template_setHeadFooter');
// 模板
Route::prefix('module')->group(function () {
//获取所有左侧模版
... ...