作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -5,7 +5,7 @@ namespace App\Console\Commands\DayCount;
use App\Helper\Common;
use App\Helper\FormGlobalsoApi;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryOther;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
... ... @@ -102,7 +102,7 @@ class Count extends Command
* @time :2023/6/14 15:40
*/
public function pv_num($yesterday,$domain){
$pv = DB::connection('custom_mysql')->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)->count();
return $pv;
}
... ... @@ -113,7 +113,7 @@ class Count extends Command
* @time :2023/6/14 15:40
*/
public function ip_num($yesterday,$domain){
$ip = DB::connection('custom_mysql')->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)->count();
return $ip;
}
... ... @@ -146,8 +146,8 @@ class Count extends Command
//加上其他询盘
ProjectServer::useProject($project_id);
$arr['inquiry_num'] = InquiryOther::count();
$countryData = InquiryOther::select("country",DB::raw('COUNT(*) as count'))->groupBy('country')->get()->toArray();
$arr['inquiry_num'] += InquiryFormData::getCount();
$countryData = InquiryFormData::getCountryCount();
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']] += $v1['count'];
... ...
... ... @@ -3,7 +3,7 @@
namespace App\Console\Commands;
use App\Helper\FormGlobalsoApi;
use App\Models\Inquiry\InquiryOther;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
... ... @@ -56,7 +56,7 @@ class LastInquiry extends Command
$last_time = $res['data']['data'][0] ?? '';
//其他询盘的最新时间
ProjectServer::useProject($item['id']);
$other_last_time = InquiryOther::orderBy('id', 'desc')->value('submit_time');
$other_last_time = InquiryFormData::orderBy('id', 'desc')->value('submit_at');
$last_inquiry_time = $last_time > $other_last_time ? $last_time : $other_last_time;
... ...
... ... @@ -4,7 +4,7 @@ namespace App\Console\Commands\MonthlyCount;
use App\Helper\FormGlobalsoApi;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryOther;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Carbon\Carbon;
... ... @@ -107,11 +107,9 @@ class InquiryMonthlyCount extends Command
}
//加上其他询盘
ProjectServer::useProject($project_id);
$arr['total'] += InquiryOther::count();
$arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count();
$countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime])
->select("country",DB::raw('COUNT(*) as count'))
->groupBy('country')->get()->toArray();
$arr['total'] += InquiryFormData::count();
$arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]);
$countryData = InquiryFormData::getCountryCount([$startTime, $endTime]);
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']] += $v1['count'];
... ...
... ... @@ -2,30 +2,24 @@
namespace App\Console\Commands;
use App\Http\Logic\Aside\Project\DomainInfoLogic;
use App\Models\Com\UpdateNotify;
use App\Models\Devops\DevopsTask as DevopsTaskModel;
use App\Models\Devops\DevopsTaskLog;
use App\Helper\FormGlobalsoApi;
use App\Models\Domain\DomainInfo;
use App\Models\File\File;
use App\Models\File\Image;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Product;
use App\Models\HomeCount\Count;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use mysql_xdevapi\Exception;
/**
* 测试
* Class Traffic
* Class Test
* @package App\Console\Commands
* @author zbj
* @date 2023/5/18
* @date 2023/4/25
*/
class Test extends Command
{
... ... @@ -41,7 +35,7 @@ class Test extends Command
*
* @var string
*/
protected $description = '测试';
protected $description = '';
/**
* Create a new command instance.
... ... @@ -58,52 +52,70 @@ class Test extends Command
*/
public function handle()
{
$domains = DB::table('gl_customer_visit')->groupBy('domain')->select('domain')->pluck('domain')->toArray();
foreach($domains as $domain){
if(!Str::contains($domain, 'globalso.site')){
$this->sync($domain);
}
$projects = Project::all();
foreach ($projects as $project){
echo "project " . $project->id;
if(!ProjectServer::useProject($project->id)){
echo '未配置数据库' . PHP_EOL;
continue;
}
$test_domain = $project->deploy_build['test_domain'];
$domainInfo = new DomainInfo();
$info = $domainInfo->read(['id'=>$project->deploy_optimize['domain']]);
if($info !== false){
$test_domain = $info['domain'];
}
public function sync($domain){
echo date('Y-m-d H:i:s') . "同步项目{$domain}" . PHP_EOL;
if(!Str::startsWith($domain,'www.')){
$domain = 'www.'.$domain;
try {
$list = Count::where('date', '2023-12-11')->where('project_id', $project->id)->get();
foreach ($list as $v){
$arr = $this->inquiry([],$test_domain, $v['id']);
$v->inquiry_num = $arr['inquiry_num'];
$v->country = $arr['country'];
$v->save();
echo $v['date'] . ':' . $v->pv_num .':'. $v->ip_num . PHP_EOL;
}
$project_id = DomainInfo::where('domain', $domain)->value('project_id');
if(!$project_id){
echo date('Y-m-d H:i:s') . "项目{$domain}不存在" . PHP_EOL;
return true;
}catch (\Exception $e){
echo '保存失败' . $e->getMessage() . PHP_EOL;
}
if(!ProjectServer::useProject($project_id)){
echo date('Y-m-d H:i:s') . "项目{$domain}数据库配置无效" . PHP_EOL;
return true;
}
$visit = 0;
$visit_item = 0;
$list = DB::table('gl_customer_visit')->whereIn('domain', [$domain, str_replace('www.','',$domain)])->get();
foreach ($list as $v){
$v = (array) $v;
$items = DB::table('gl_customer_visit_item')->where('customer_visit_id', $v['id'])->get();
unset($v['id']);
$id = DB::connection('custom_mysql')->table('gl_customer_visit')->insertGetId($v);
$visit++;
echo "finish";
}
$data = [];
foreach ($items as $item){
$item = (array) $item;
unset($item['id']);
$item['customer_visit_id'] = $id;
$data[] = $item;
$visit_item++;
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
if($inquiry_list['status'] == 400){
$arr['inquiry_num'] = 0;
$countryArr = [];
}else{
$arr['inquiry_num'] = $inquiry_list['data']['total'];
//询盘国家统计
$countryData = $inquiry_list['data']['data'];
$countryArr = [];
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']]++;
}else{
$countryArr[$v1['country']] = 1;
}
DB::connection('custom_mysql')->table('gl_customer_visit_item')->insert($data);
}
echo date('Y-m-d H:i:s') . "visit:{$visit};item:{$visit_item}" . PHP_EOL;exit;
}
//加上其他询盘
$arr['inquiry_num'] += InquiryFormData::getCount();
$countryData = InquiryFormData::getCountryCount();
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']] += $v1['count'];
}else{
$countryArr[$v1['country']] = $v1['count'];
}
}
arsort($countryArr);
$top20 = array_slice($countryArr, 0, 20, true);
$arr['country'] = json_encode($top20);
return $arr;
}
}
... ...
... ... @@ -53,14 +53,10 @@ class UpdateRoute extends Command
* @time :2023/11/20 15:13
*/
public function handle(){
$projectModel = new Project();
$lists = $projectModel->list(['is_upgrade'=>0,'type'=>['!=',0]]);
foreach ($lists as $k => $v){
ProjectServer::useProject($v['id']);
$this->getProductKeyword($v['id']);
ProjectServer::useProject(75);
$this->getProductKeyword();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . ' end: 项目id为' . $v['id'] . PHP_EOL;
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
... ... @@ -70,12 +66,32 @@ class UpdateRoute extends Command
* @method :post
* @time :2023/12/8 11:13
*/
public function getProductKeyword($id){
public function getProductKeyword(){
$keywordModel = new Keyword();
$lists = $keywordModel->list(['route'=>['like','%-1-2-%']]);
$lists = $keywordModel->list(['route'=>null]);
if(!empty($lists)){
echo date('Y-m-d H:i:s') . ' 错误id:' . $id . PHP_EOL;
foreach ($lists as $v){
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], 75);
$this->curlDelRoute(['new_route'=>$route]);
$keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
echo date('Y-m-d H:i:s') . 'end :'.$route . PHP_EOL;
}
}
}
/**
* @remark :删除路由通知C端
* @name :curlDelRoute
* @author :lyh
* @method :post
* @time :2023/11/30 14:43
*/
public function curlDelRoute($data){
$data['project_id'] = 75;
$str = http_build_query($data);
$url = 'https://www.zrutong.com/api/delHtml/?'.$str;
curlGet($url);
return true;
}
}
... ...
... ... @@ -33,6 +33,7 @@ use App\Models\Project\RenewLog;
use App\Models\RankData\RankData;
use App\Models\Task\Task;
use App\Models\Visit\Visit;
use App\Models\WebSetting\WebLanguage;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
... ... @@ -541,7 +542,7 @@ class ProjectController extends BaseController
if(isset($this->map['entry_position']) && !empty($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']);
$lists = $hrManagerModel->list($this->map,['sort','id'],['id','manage_id','name','entry_position','is_leader']);
$this->response('success',Code::SUCCESS,$lists);
}
... ... @@ -872,4 +873,17 @@ class ProjectController extends BaseController
}
$this->response('success',Code::SUCCESS,$zone_list);
}
/**
* @remark :获取小语种列表
* @name :lists
* @author :lyh
* @method :post
* @time :2023/11/30 10:59
*/
public function languageLists(){
$webLanguageModel = new WebLanguage();
$lists = $webLanguageModel->list();
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
... ... @@ -65,7 +65,16 @@ class CustomModuleContentController extends BaseController
public function getCategoryList(){
$categoryModel = new CustomModuleCategory();
$list = $categoryModel->list(['project_id'=>$this->user['project_id'],'module_id'=>$this->param['module_id']],['id','name']);
$this->response('success',Code::SUCCESS,$list);
$menu = [];
if(!empty($list)){
foreach ($list as $v){
if($v['pid'] == 0){
$v['sub'] = _get_child($v['id'],$list);
$menu[] = $v;
}
}
}
$this->response('success',Code::SUCCESS,$menu);
}
/**
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Http\Controllers\Bside\CustomModule;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\CustomModule\CustomModuleExtendLogic;
use App\Models\CustomModule\CustomModuleExtend;
... ... @@ -30,7 +31,7 @@ class CustomModuleExtentController extends BaseController
]);
$this->map['project_id'] = $this->user['project_id'];
$filed = ['id','title','status','type','operator_id','project_id','module_id','created_at','updated_at'];
$lists = $customModuleExtend->lists($this->map,$this->page,$this->row,$this->order,$filed);
$lists = $customModuleExtend->list($this->map,$this->order,$filed);
$this->response('success',Code::SUCCESS,$lists);
}
... ... @@ -59,8 +60,8 @@ class CustomModuleExtentController extends BaseController
* @time :2023/12/4 15:45
*/
public function save(CustomModuleExtendLogic $logic){
$logic->extendSave();
$this->response('success');
$info = $logic->extendSave();
$this->response('success',Code::SUCCESS,$info);
}
/**
... ...
... ... @@ -14,8 +14,6 @@ use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\CustomModule\CustomModuleExtend;
use App\Models\CustomModule\CustomModuleExtentContent;
use App\Models\Product\Extend;
use App\Models\Product\ExtendInfo;
use App\Models\RouteMap\RouteMap;
use Illuminate\Support\Facades\DB;
use mysql_xdevapi\Exception;
... ... @@ -248,7 +246,7 @@ class CustomModuleContentLogic extends BaseLogic
*/
public function saveExtendInfo($content_id,$extend){
//先删除以前的数据
$extendInfoModel = new ExtendInfo();
$extendInfoModel = new CustomModuleExtentContent();
$extendInfoModel->del(['content_id'=>$content_id]);
if(empty($extend)) {
return $this->success();
... ... @@ -271,6 +269,7 @@ class CustomModuleContentLogic extends BaseLogic
* @time :2023/12/6 15:11
*/
public function saveHandleExtend(&$v,$content_id){
unset($v['title']);
if($v['type'] == 3){
foreach ($v['values'] as $k1=>$v1){
$v1['url'] = str_replace_url($v1['url']);
... ... @@ -322,8 +321,8 @@ class CustomModuleContentLogic extends BaseLogic
{
RouteMap::delRoute(RouteMap::SOURCE_MODULE, $id, $this->user['project_id']);
//通知
$info = $this->model->read(['id' => $id], ['id', 'url']);
$this->curlDelRoute(['route'=>$info['url']]);
$info = $this->model->read(['id' => $id], ['id', 'route']);
$this->curlDelRoute(['route'=>$info['route']]);
return $this->success();
}
}
... ...
... ... @@ -50,7 +50,7 @@ class CustomModuleExtendLogic extends BaseLogic
}else{
$this->extendAdd();
}
return $this->success();
return $this->success($this->param);
}
/**
... ...
... ... @@ -138,12 +138,17 @@ class CountLogic extends BaseLogic
$customerVisitModel = new Visit();
$data = $customerVisitModel->select('referrer_url', DB::raw('COUNT(*) as count'))
->groupBy('referrer_url')->where(['domain'=>$this->user['domain']])
->orderByDesc('count')->limit(8)->get()->toArray();
->orderByDesc('count')->limit(9)->get()->toArray();
$total = $customerVisitModel->count();
if(!empty($data)){
foreach ($data as $k=>$v){
if(empty($v['referrer_url'])){
unset($data[$k]);
continue;
}
$data[$k]['proportion'] = ($v['count']/$total) * 100;
}
$data = array_values($data);
}
return $this->success($data);
}
... ...
... ... @@ -6,7 +6,7 @@ use App\Helper\FormGlobalsoApi;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\HomeCount\Count;
use App\Models\HomeCount\MonthCount;
use App\Models\Inquiry\InquiryOther;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\DeployOptimize;
use App\Services\ProjectServer;
use Carbon\Carbon;
... ... @@ -86,11 +86,9 @@ class MonthCountLogic extends BaseLogic
}
}
//加上其他询盘
$arr['total'] += InquiryOther::count();
$arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count();
$countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime])
->select("country",DB::raw('COUNT(*) as count'))
->groupBy('country')->get()->toArray();
$arr['total'] += InquiryFormData::getCount();
$arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]);
$countryData = InquiryFormData::getCountryCount([$startTime, $endTime]);
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']] += $v1['count'];
... ...
... ... @@ -126,7 +126,6 @@ class KeywordLogic extends BaseLogic
*/
public function batchAdd(){
try {
$idArr = [];
foreach ($this->param['title'] as $v){
$this->model = new Keyword();
$info = $this->model->read(['title'=>$v]);
... ... @@ -136,15 +135,10 @@ class KeywordLogic extends BaseLogic
$param['updated_at'] = $param['created_at'];
$param['title'] = $v;
$id = $this->model->insertGetId($param);
$idArr[] = ['id'=>$id,'title'=>$v];
}
}
//批量生成路由
foreach ($idArr as $v){
$this->model = new Keyword();
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']);
$route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
$this->curlDelRoute(['new_route'=>$route]);
$this->model->edit(['route'=>$route],['id'=>$v['id']]);
$this->model->edit(['route'=>$route],['id'=>$id]);
}
}
}catch (\Exception $e){
$this->fail('error');
... ...
... ... @@ -13,7 +13,7 @@ use App\Models\Base;
class CustomModuleExtentContent extends Base
{
protected $table = 'gl_custom_module_extent_content';
protected $table = 'gl_custom_module_extend_content';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Models\Inquiry;
use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
/**
* Class InquiryFormData
... ... @@ -26,4 +27,32 @@ class InquiryFormData extends Base
{
return json_decode($value, true);
}
/**
* 非默认表单的数量统计
* @author zbj
* @date 2023/12/12
*/
public static function getCount($submit_at = []){
return self::leftjoin('gl_inquiry_form', 'gl_inquiry_form.id', '=', 'gl_inquiry_form_data.form_id')
->where('gl_inquiry_form.is_default', 0)
->when($submit_at, function ($query, $submit_at) {
$query->whereBetween('submit_at',[$submit_at[0], $submit_at[1]]);
})
->count();
}
/**
* 非默认表单的国家统计
* @author zbj
* @date 2023/12/12
*/
public static function getCountryCount($submit_at = []){
return self::leftjoin('gl_inquiry_form', 'gl_inquiry_form.id', '=', 'gl_inquiry_form_data.form_id')
->where('gl_inquiry_form.is_default', 0)
->when($submit_at, function ($query, $submit_at) {
$query->whereBetween('submit_at',[$submit_at[0], $submit_at[1]]);
})
->select("country",DB::raw('COUNT(*) as count'))->groupBy('country')->get()->toArray();
}
}
... ...
... ... @@ -176,6 +176,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/saveOtherProject', [Aside\Project\ProjectController::class, 'saveOtherProject'])->name('admin.project_saveOtherProject');//其他项目设置
Route::any('/getOtherProject', [Aside\Project\ProjectController::class, 'getOtherProject'])->name('admin.project_getOtherProject');//获取其他项目设置
Route::any('/getChannel', [Aside\Project\ProjectController::class, 'getChannel'])->name('admin.project_getChannel');//其他项目设置
Route::any('/languageLists', [Aside\Project\ProjectController::class, 'languageLists'])->name('admin.project_languageLists');//其他项目设置
//获取关键词前缀和后缀
Route::prefix('keyword')->group(function () {
Route::any('/getKeywordPrefix', [Aside\Project\KeywordPrefixController::class, 'getKeywordPrefix'])->name('admin.keyword_getKeywordPrefix');
... ...