作者 刘锟

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

... ... @@ -106,7 +106,7 @@ class Count extends Command
* @method :post
* @time :2023/6/14 15:40
*/
public function pv_num($yesterday,$domain){
public function pv_num($yesterday){
$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->count();
return $pv;
}
... ... @@ -117,7 +117,7 @@ class Count extends Command
* @method :post
* @time :2023/6/14 15:40
*/
public function ip_num($yesterday,$domain){
public function ip_num($yesterday){
$ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->count();
return $ip;
}
... ...
... ... @@ -107,7 +107,7 @@ class CountDate extends Command
* @method :post
* @time :2023/6/14 15:40
*/
public function pv_num($yesterday,$domain){
public function pv_num($yesterday){
$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->count();
return $pv;
}
... ... @@ -118,7 +118,7 @@ class CountDate extends Command
* @method :post
* @time :2023/6/14 15:40
*/
public function ip_num($yesterday,$domain){
public function ip_num($yesterday){
$ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->count();
return $ip;
}
... ...
... ... @@ -179,9 +179,9 @@ class RelayInquiry extends Command
foreach ($inquiry as $key=>$val) {
$this->output('询盘ID:' . $val->id);
//询盘时间超过2小时 就不处理了
if(time() - strtotime($val->inquiry_date) > 7200){
if(time() - strtotime($val->inquiry_date) > 259200){
$val->status = ReInquiryForm::STATUS_FORGO;
$val->remark = '超时2小时未处理!';
$val->remark = '超时72小时未处理!';
$val->save();
continue;
}
... ... @@ -352,10 +352,8 @@ class RelayInquiry extends Command
$country_name = $ip_data->ip_area;
$this->output('转发内容');
// 推送消息 消息内容小于10个字符, 使用内置询盘内容
$message = $form->message;
$message_id = 0;
if (strlen($message) < 10) {
// 通过字符数量区分, 改成完全获取内置询盘内容
$use_ids = ReInquiryDetail::where(['re_website' => $domain])->where('status', '<>', ReInquiryDetail::STATUS_FAIL)->pluck('text_id')->toArray();
$text = ReInquiryText::whereNotIn('id', $use_ids)->where('status', ReInquiryText::STATUS_USABLE)->inRandomOrder()->first();
$message = $text->content;
... ... @@ -363,6 +361,17 @@ class RelayInquiry extends Command
// 获取后,使用次数+1
$text->use_time += 1;
$text->save();
//原内容非英语,转为对应语种
if(is_numeric($form->message)){ //数字会被识别为中文
$lang = 'en';
}else{
$translateSl = Translate::translateSl($form->message);
$lang = $translateSl['texts']['sl'] ?? 'en';
}
if($lang != 'en' || $lang != 'zh-CN'){
$message = Translate::tran($message, $lang);
}
$this->output('获取转发设备信息');
... ...
... ... @@ -175,7 +175,7 @@ class postInquiry extends Command
];
$res = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data)->json();
if(empty($res['data'][0]['code']) || $res['data'][0]['code'] != 200){
if(empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200,300])){
$log->status = ReInquiryDetailLog::STATUS_FAIL;
$log->remark = $res['message'] ?? '';
$log->save();
... ...
... ... @@ -16,6 +16,7 @@ use App\Models\HomeCount\MonthCount;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Models\Visit\Visit;
use App\Models\Visit\VisitItem;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -137,14 +138,12 @@ class MonthAllCount extends Command
* @time :2024/1/8 11:02
*/
public function pv_ip(&$arr,$start,$end,$project_id){
$pv_ip = DB::table('gl_count')
->where(['project_id'=>$project_id])
->where('date','>=',$start.' 00:00:00')
->where('date','<=',$end.' 23:59:59')
->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'),DB::raw('SUM(inquiry_num) as inquiry_num'))
->first();
$arr['pv'] = $pv_ip->pv_num;
$arr['ip'] = $pv_ip->ip_num;
$arr['pv'] = (new VisitItem())
->where('updated_date','>=',$start.' 00:00:00')
->where('updated_date','<=',$end.' 23:59:59')->count();
$arr['ip'] = (new Visit())
->where('updated_date','>=',$start.' 00:00:00')
->where('updated_date','<=',$end.' 23:59:59')->count();
if($arr['ip'] != 0){
$arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2);
}
... ...
... ... @@ -14,6 +14,8 @@ use App\Models\Com\UpdateOldInfo;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Models\Visit\Visit;
use App\Models\Visit\VisitItem;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -159,14 +161,12 @@ class MonthCount extends Command
* @time :2024/1/8 11:02
*/
public function pv_ip(&$arr,$start,$end,$project_id){
$pv_ip = DB::table('gl_count')
->where(['project_id'=>$project_id])
->where('date','>=',$start.' 00:00:00')
->where('date','<=',$end.' 23:59:59')
->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'),DB::raw('SUM(inquiry_num) as inquiry_num'))
->first();
$arr['pv'] = $pv_ip->pv_num;
$arr['ip'] = $pv_ip->ip_num;
$arr['pv'] = (new VisitItem())
->where('updated_date','>=',$start.' 00:00:00')
->where('updated_date','<=',$end.' 23:59:59')->count();
$arr['ip'] = (new Visit())
->where('updated_date','>=',$start.' 00:00:00')
->where('updated_date','<=',$end.' 23:59:59')->count();
if($arr['ip'] != 0){
$arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2);
}
... ...
... ... @@ -14,6 +14,8 @@ use App\Models\Com\UpdateOldInfo;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Models\Visit\Visit;
use App\Models\Visit\VisitItem;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -160,14 +162,12 @@ class MonthCountDate extends Command
* @time :2024/1/8 11:02
*/
public function pv_ip(&$arr,$start,$end,$project_id){
$pv_ip = DB::table('gl_count')
->where(['project_id'=>$project_id])
->where('date','>=',$start.' 00:00:00')
->where('date','<=',$end.' 23:59:59')
->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'),DB::raw('SUM(inquiry_num) as inquiry_num'))
->first();
$arr['pv'] = $pv_ip->pv_num;
$arr['ip'] = $pv_ip->ip_num;
$arr['pv'] = (new VisitItem())
->where('updated_date','>=',$start.' 00:00:00')
->where('updated_date','<=',$end.' 23:59:59')->count();
$arr['ip'] = (new Visit())
->where('updated_date','>=',$start.' 00:00:00')
->where('updated_date','<=',$end.' 23:59:59')->count();
if($arr['ip'] != 0){
$arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2);
}
... ...
... ... @@ -16,6 +16,7 @@ use App\Models\HomeCount\MonthCount;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Models\Visit\Visit;
use App\Models\Visit\VisitItem;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
... ... @@ -133,14 +134,12 @@ class MonthProjectCount extends Command
* @time :2024/1/8 11:02
*/
public function pv_ip(&$arr,$start,$end,$project_id){
$pv_ip = DB::table('gl_count')
->where(['project_id'=>$project_id])
->where('date','>=',$start.' 00:00:00')
->where('date','<=',$end.' 23:59:59')
->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'),DB::raw('SUM(inquiry_num) as inquiry_num'))
->first();
$arr['pv'] = $pv_ip->pv_num;
$arr['ip'] = $pv_ip->ip_num;
$arr['pv'] = (new VisitItem())
->where('updated_date','>=',$start.' 00:00:00')
->where('updated_date','<=',$end.' 23:59:59')->count();
$arr['ip'] = (new Visit())
->where('updated_date','>=',$start.' 00:00:00')
->where('updated_date','<=',$end.' 23:59:59')->count();
if($arr['ip'] != 0){
$arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 10,2);
}
... ...
... ... @@ -2,15 +2,10 @@
namespace App\Console\Commands\RankData;
use App\Helper\QuanqiusouApi;
use App\Http\Logic\Bside\RankData\RankDataLogic;
use App\Models\Domain\DomainInfo;
use App\Models\RankData\RankDataLog as RankDataLogModel;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Models\RankData\RankData as GoogleRankModel;
use App\Utils\LogUtils;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
... ... @@ -35,7 +30,7 @@ class RankData extends BaseCommands
*
* @var string
*/
protected $description = '谷歌排名数据';
protected $description = '分发任务';
/**
* @author zbj
... ... @@ -45,67 +40,31 @@ class RankData extends BaseCommands
{
try {
Log::channel('rank_data')->info('开始-排名数据');
//所有项目 今日是否达标 重置
//有失败会重跑任务,导致达标又被重置 加缓存一天只重置一次
if (!Cache::get('clear_remain_today_' . date('Y-m-d'))) {
Project::where('is_remain_today', 1)->update(['is_remain_today' => 0]);
Cache::set('clear_remain_today_' . date('Y-m-d'), 1, 24 * 3600);
}
$error = 0;
$api = new QuanqiusouApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->select('api_no', 'project_id')->orderBy('project_id', 'asc')->get();
Log::channel('rank_data')->info('开始-排名数据-' . count($list));
//当日所有站点谷歌收录数据
$site_res = $api->getSiteRes();
if (!$site_res) {
Log::channel('rank_data')->error('谷歌收录数据获取失败');
foreach ($list as $item){
RankDataLogModel::addTask($item['project_id'], $item['api_no']);
}
foreach ($list as $item) {
Log::channel('rank_data')->info('项目开始:ID' . $item['project_id'] .' - '. $item['api_no']) . '';
try {
(new RankDataLogic())->syncRankData($item['api_no'], $site_res);
} catch (\Exception $e) {
Log::channel('rank_data')->error('RankData:失败 ' . $item['api_no'] . $e->getMessage());
$error++;
continue;
//小语种
$api = new QuanqiusouApi();
$lang_list = $api->getLangList();
foreach ($list as $item){
$langs = $lang_list[$item['api_no']] ?? [];
foreach ($langs as $lang){
RankDataLogModel::addTask($item['project_id'], $item['api_no'], $lang);
}
}
return !$error;
} catch (\Exception|\Throwable $e) {
Log::channel('rank_data')->error('排名数据任务失败 ' . $e->getMessage());
throw new \Exception($e->getMessage());
}
}
/**
* 同步项目api_no
* @author zbj
* @date 2023/10/16
*/
public function SyncApiNo(){
$deploy_optimizes = DeployOptimize::leftJoin('gl_project', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->whereIn('gl_project.type', [Project::TYPE_TWO,Project::TYPE_THREE])->where('gl_project_deploy_optimize.api_no', 0)
->where('gl_project_deploy_optimize.domain', '>', 0)
->get();
if(!$deploy_optimizes){
return true;
}
$api = new QuanqiusouApi();
$ai_nos = $api->getWebApiNo();
if($ai_nos){
foreach ($deploy_optimizes as $deploy_optimize){
$domain = DomainInfo::where('id', $deploy_optimize['domain'])->value('domain');
if(!$domain){
continue;
}
$api_no = array_search($domain, $ai_nos);
if($api_no){
$deploy_optimize->api_no = $api_no;
$deploy_optimize->save();
}
}
}
}
}
... ...
<?php
namespace App\Console\Commands\RankData;
use App\Helper\Arr;
use App\Helper\QuanqiusouApi;
use App\Http\Logic\Bside\BaseLogic;
use App\Http\Logic\Bside\RankData\RankDataLogic;
use App\Models\RankData\RankDataLog as RankDataLogModel;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
/**
* Class GoogleRank
* @package App\Console\Commands
* @author zbj
* @date 2023/5/6
*/
class RankDataLog extends BaseCommands
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'rank_data_log';
/**
* The console command description.
* The console command description.
*
* @var string
*/
protected $description = '谷歌排名数据';
/**
* @author zbj
* @date 2023/5/6
*/
public function do()
{
while (true) {
$log_id = Redis::rpop('rank_data_task');
echo $log_id . PHP_EOL;
if (!$log_id) {
sleep(10);
continue;
}
$log = RankDataLogModel::where('id', $log_id)->where('status', 0)->first();
if(!$log){
continue;
}
try {
$this->output('项目开始:ID'.$log->project_id . ',APINO' . $log->api_no);
$project = Project::find($log->project_id);
if (!$project) {
$this->output('关联的项目不存在:ID'.$log->project_id . ',APINO' . $log->api_no);
$log->status = 9;
$log->save();
continue;
}
//接口获取数据
$api = new QuanqiusouApi();
$res = $api->getGoogleRank($log->project_id, $log->api_no, $log->lang);
if (!$res) {
$this->output('接口数据获取失败:ID'.$log->project_id . ',APINO' . $log->api_no);
$log->status = 9;
$log->save();
continue;
}
$log->data = Arr::s2a($res);
//保存数据
$this->output('保存排名数据:ID'.$log->project_id . ',APINO' . $log->api_no);
$is_compliance = (new RankDataLogic())->save_rank($log->project_id, $res, null, $log->lang);
$log->is_compliance = $is_compliance;
$log->status = 1;
$log->save();
} catch (\Exception $e) {
$this->output('处理失败:ID'.$log->project_id . ',APINO' . $log->api_no . ':' . $e->getMessage());
}
}
}
public function output($message)
{
$date = date('Y-m-d H:i:s');
$output = $date . ', ' . $message . PHP_EOL;
echo $output;
Log::channel('rank_data')->info($output);
return true;
}
}
... ...
... ... @@ -31,6 +31,7 @@ class SyncSubmitTask extends Command
while (true) {
$task_id = Redis::rpop('sync_submit_task');
if(!$task_id){
sleep(1);
continue;
}
... ...
... ... @@ -44,6 +44,8 @@ class SyncSubmitTaskDistribution extends Command
$this->output('分发:' . $task->id);
}
}
}else{
sleep(1);
}
}catch (\Exception $e){
$this->output('异常:' . $e->getMessage());
... ...
... ... @@ -38,7 +38,7 @@ class WorkchatMessageSend extends Command
$this->output('开始推送消息' . $task->id);
try {
//超过两小时 不推送了
if(time() - $task->send_time > 7200){
if(time() - strtotime($task->send_time) > 7200){
throw new \Exception('超时两小时未推送');
}
ProjectAssociationServices::getInstance()->sendMessage($task->friend_id, $task->content, $task->content_type);
... ...
... ... @@ -107,7 +107,6 @@ class QuanqiusouApi
if($res){
$res = Arr::s2a($res);
Cache::put($key, $res, 2 * 3600);
RankDataLog::addLog($project_id, $api_no, $lang, $endDay, $res);
}
} catch (\Exception | GuzzleException $e) {
errorLog('获取谷歌排名数据失败', [$api_no], $e);
... ...
... ... @@ -38,6 +38,7 @@ class AdsController extends BaseController
$industry = trim($request->input('industry'));
$ad_id = trim($request->input('ad_id'));
$status = $request->input('status', '');
$page_size = intval($request->input('row', '20'));
$result = ReInquiryTask::when($ad_id, function ($query, $ads_id) {
return $query->where('ad_id', 'like', '%' . $ads_id . '%');
})
... ... @@ -53,7 +54,7 @@ class AdsController extends BaseController
}
})
->orderBy('id', 'desc')
->paginate();
->paginate($page_size);
$relay_site_total = 0;
foreach ($result as $item){
... ... @@ -166,6 +167,7 @@ class AdsController extends BaseController
$ad_name = $request->input('ad_name');
$ad_id = $request->input('ad_id');
$country = $request->input('country');
$page_size = intval($request->input('row', '20'));
$result = ReInquiryForm::when($status, function ($query, $status) {
return $query->where('status', $status);
})
... ... @@ -179,7 +181,7 @@ class AdsController extends BaseController
return $query->where('country', 'like', '%' . $country . '%');
})
->orderBy('inquiry_date', 'desc')
->paginate();
->paginate($page_size);
return $this->response('success', Code::SUCCESS, $result);
}
... ...
... ... @@ -36,7 +36,7 @@ class ServersIpLogic extends BaseLogic
public function infoServersIp(){
$info = $this->model->read(['id'=>$this->param['id']]);
$projectModel = new Project();
$info['project_title'] = $projectModel->formatQuery(['serve_id'=>$info['id']])->pluck('title')->toArray();
$info['project_title'] = $projectModel->formatQuery(['serve_id'=>$info['id'],'delete_status'=>0])->pluck('title')->toArray();
return $this->success($info);
}
... ...
... ... @@ -11,6 +11,7 @@ namespace App\Http\Logic\Aside\Manage;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Manage\Manage;
use App\Models\Manage\ManageHr;
use App\Models\Manage\MenuSpecial;
class MenuSpecialLogic extends BaseLogic
... ... @@ -31,11 +32,37 @@ class MenuSpecialLogic extends BaseLogic
*/
public function managerList($map){
$managerModel = new Manage();
$list = $managerModel->list($map,'id',['id','name']);
return $this->success($list);
$query = $managerModel->leftJoin('gl_manage_hr', 'gl_manage.id', '=', 'gl_manage_hr.manage_id');
$query = $this->searchParam($query,$map);
$lists = $query->select($this->selectParam())->get()->toArray();
return $this->success($lists);
}
/**
* @remark :搜索
* @name :searchParam
* @author :lyh
* @method :post
* @time :2024/10/24 11:50
*/
public function searchParam(&$query,$map){
$query = $query->where('gl_manage_hr.status', $map['status'] ?? 1);
return $query;
}
/**
* 需要查询的字段
* @return array
*/
public function selectParam(){
$select = [
'gl_manage.id AS id',
'gl_manage.name AS name',
'gl_manage_hr.status as status'
];
return $select;
}
/**
* @remark :获取详情
* @name :specialInfo
* @author :lyh
... ...
... ... @@ -185,12 +185,12 @@ class CustomTemplateLogic extends BaseLogic
$this->param['html_style'] = "<style id='globalsojs-styles'></style>";
}
}
if($this->param['url'] == 'news' || $this->param['url'] == 'product' || $this->param['url'] == 'blog'){
$this->fail('不允许修改路由为:'.$this->param['url']);
}
$this->param['project_id'] = $this->user['project_id'];
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
if($route == 'news' || $route == 'product' || $route == 'blog'){
$this->fail('不允许修改路由为:'.$this->param['url']);
}
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route);
$this->model->edit(['url'=>$route],['id'=>$id]);
}
... ...
... ... @@ -47,6 +47,9 @@ class RankDataLogic extends BaseLogic
$project = (new ProjectLogic())->getProjectInfo($project_id);
$domain_info = (new DomainInfoLogic)->getDomainInfo($project_id);
$rank = RankData::where('project_id', $project_id)->first();
if(empty($rank) && ($project['deploy_optimize']['api_no'] != 0)){
$data['langs_status'] = 1;
}
$rank_week = RankWeek::where('project_id', $project_id)->first();
$recomm_domain = RecommDomain::where('project_id', $project_id)->first();
$external_links = ExternalLinks::where('project_id', $project_id)->first();
... ... @@ -86,9 +89,6 @@ class RankDataLogic extends BaseLogic
//小语种列表
$quanqiusou_api = new QuanqiusouApi();
$lang_data = $quanqiusou_api->getLangRankData($api_no);
if(empty($lang_data)){
$data['langs_status'] = 1;
}
$lang_data = Arr::setValueToKey($lang_data, 'language');
$data['langs'] = [];
$languageModel = new MinorLanguages();
... ... @@ -447,13 +447,13 @@ class RankDataLogic extends BaseLogic
/**
* @param $project_id
* @param int $indexed_pages_num
* @param $indexed_pages_num
* @param $data
* @param string $lang
* @author zbj
* @date 2023/5/8
*/
public function save_rank($project_id, $data, int $indexed_pages_num = 0, string $lang = ''){
public function save_rank($project_id, $data, $indexed_pages_num = null, string $lang = ''){
$without_project_ids = []; //不用处理排名的项目
$without_extension_project_ids = [658]; //是否达标只统计主词的
$extension_project_ids = [354]; //扩展词也到达标的
... ... @@ -548,11 +548,15 @@ class RankDataLogic extends BaseLogic
$model->first_three_pages_num = $first_three_pages_num;
$model->first_five_pages_num = $first_five_pages_num;
$model->first_ten_pages_num = $first_ten_pages_num;
if($indexed_pages_num !== null){
$model->indexed_pages_num = $indexed_pages_num;
}
$model->lang = $lang;
$model->data = $data;
$model->updated_date = date('Y-m-d');
$model->save();
return $model->is_compliance;
}
/**
... ...
... ... @@ -334,6 +334,9 @@ class TranslateLogic extends BaseLogic
$page = $arr[1];
$route = $arr[0];
}
$routeModel = new RouteMap();
$routeInfo = $routeModel->read(['route'=>$route]);
if($routeInfo === false){
if(in_array($route,['products','news','blog'])){
//固定路由
$data['page'] = $page;
... ... @@ -347,10 +350,6 @@ class TranslateLogic extends BaseLogic
}
return $this->success($data);
}
$routeModel = new RouteMap();
$routeInfo = $routeModel->read(['route'=>$route]);
if($routeInfo === false){
return $data;
}
$data = $this->resultData($routeInfo,$data);
... ...
... ... @@ -120,6 +120,7 @@ class Project extends Base
13 => 'AI站群',
14 => '未达标',
15 => 'AI案例',
16 => '6.0广告'
];
}
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Models\RankData;
use App\Helper\Arr;
use App\Models\Base;
use Illuminate\Support\Facades\Redis;
/**
* Class GoogleRank
... ... @@ -27,22 +28,29 @@ class RankDataLog extends Base
return Arr::s2a($value);
}
public static function addLog($project_id, $api_no, $lang, $date, $res){
$data= [];
foreach ($res as $key=>$item){
$data[$key] = $item[$date];
}
public static function addTask($project_id, $api_no, $lang =''){
$date = date('Y-m-d');
$model = self::where('project_id', $project_id)->where('date', $date)->where('lang', $lang)->first();
if(!$model){
$model = new self();
if($model){
//已达标的
if($model->is_compliance){
return true;
}
//有未执行的
if(!$model->status){
return true;
}
}else{
$model = new self();
$model->project_id = $project_id;
$model->api_no = $api_no;
$model->lang = $lang;
$model->date = $date;
$model->data = $data;
}
$model->status = 0;
$model->save();
Redis::lpush('rank_data_task', $model->id);
return true;
}
... ...
... ... @@ -6,7 +6,9 @@ use App\Models\Base;
use App\Models\Inquiry\InquiryFormData;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Services\ProjectServer;
use App\Utils\LogUtils;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Log;
/**
* Class MessagePush
... ... @@ -40,9 +42,9 @@ class MessagePush extends Base
* @return bool
*/
public static function addInquiryMessage($id, $project_id, $country, $name, $submit_at){
if(!ProjectServer::useProject($project_id)){
return false;
}
// if(!ProjectServer::useProject($project_id)){
// return false;
// }
//项目是否有绑定群
$friend_id = ProjectAssociation::where('project_id', $project_id)
... ... @@ -50,6 +52,7 @@ class MessagePush extends Base
->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)
->value('friend_id');
if(!$friend_id){
Log::channel('inquiry')->info($project_id . '没有绑定企微群', [$id]);
return false;
}
... ... @@ -92,5 +95,7 @@ class MessagePush extends Base
}
}
$model->save();
Log::channel('inquiry')->info($project_id . '通知消息', [$model->id]);
}
}
... ...
... ... @@ -14,6 +14,7 @@ use App\Models\Visit\Visit;
use App\Models\Workchat\MessagePush;
use App\Utils\LogUtils;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
use function Symfony\Component\String\s;
... ... @@ -79,7 +80,7 @@ class SyncSubmitTaskService
}
$handler = new self();
return $handler->$action($data, $date);
return $handler->$action($data, $date, $task['id']);
}
... ... @@ -110,7 +111,7 @@ class SyncSubmitTaskService
* @author zbj
* @date 2024/8/27
*/
public function subscribe($data, $date){
public function subscribe($data, $date, $task_id){
$email = $data['data']['email'];
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$model = new Email();
... ... @@ -129,7 +130,7 @@ class SyncSubmitTaskService
* @author zbj
* @date 2023/12/4
*/
public function inquiry($data, $date)
public function inquiry($data, $date, $task_id)
{
//数组key转为小写
$data['data'] = array_change_key_case($data['data'], CASE_LOWER);
... ... @@ -155,18 +156,22 @@ class SyncSubmitTaskService
$id = InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data']);
//转化询盘
Visit::isInquiry($data['ip']);
//推送企微消息
Log::channel('inquiry')->info($task_id . '询盘结果', [$id]);
if($id){
try {
$name = empty($data['data']['name']) ? '' : ' ' . $data['data']['name'];
MessagePush::addInquiryMessage($id, $data['project_id'], $data['country'], $name, $data['submit_at']);
}catch (\Exception $e){
Log::channel('inquiry')->info($task_id . '询盘失败', [$e->getMessage(), $e->getFile(), $e->getLine()]);
LogUtils::error('询盘消息'.$id.'写入企微消息队列失败' . $e->getMessage());
}
}
Log::channel('inquiry')->info($task_id . '询盘完成' . PHP_EOL);
return true;
}
... ... @@ -179,7 +184,7 @@ class SyncSubmitTaskService
* @author zbj
* @date 2023/12/4
*/
public function visit($data, $date)
public function visit($data, $date, $task_id)
{
$visit_data = $data['data'];
... ...
... ... @@ -179,6 +179,12 @@ return [
'level' => 'debug',
'days' => 14,
],
'inquiry' => [
'driver' => 'daily',
'path' => storage_path('logs/inquiry/laravel.log'),
'level' => 'debug',
'days' => 14,
],
],
//操作日志
'operator_log' =>[
... ...