Merge remote-tracking branch 'origin/master' into akun
正在显示
25 个修改的文件
包含
275 行增加
和
152 行删除
| @@ -106,7 +106,7 @@ class Count extends Command | @@ -106,7 +106,7 @@ class Count extends Command | ||
| 106 | * @method :post | 106 | * @method :post |
| 107 | * @time :2023/6/14 15:40 | 107 | * @time :2023/6/14 15:40 |
| 108 | */ | 108 | */ |
| 109 | - public function pv_num($yesterday,$domain){ | 109 | + public function pv_num($yesterday){ |
| 110 | $pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->count(); | 110 | $pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->count(); |
| 111 | return $pv; | 111 | return $pv; |
| 112 | } | 112 | } |
| @@ -117,7 +117,7 @@ class Count extends Command | @@ -117,7 +117,7 @@ class Count extends Command | ||
| 117 | * @method :post | 117 | * @method :post |
| 118 | * @time :2023/6/14 15:40 | 118 | * @time :2023/6/14 15:40 |
| 119 | */ | 119 | */ |
| 120 | - public function ip_num($yesterday,$domain){ | 120 | + public function ip_num($yesterday){ |
| 121 | $ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->count(); | 121 | $ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->count(); |
| 122 | return $ip; | 122 | return $ip; |
| 123 | } | 123 | } |
| @@ -107,7 +107,7 @@ class CountDate extends Command | @@ -107,7 +107,7 @@ class CountDate extends Command | ||
| 107 | * @method :post | 107 | * @method :post |
| 108 | * @time :2023/6/14 15:40 | 108 | * @time :2023/6/14 15:40 |
| 109 | */ | 109 | */ |
| 110 | - public function pv_num($yesterday,$domain){ | 110 | + public function pv_num($yesterday){ |
| 111 | $pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->count(); | 111 | $pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->count(); |
| 112 | return $pv; | 112 | return $pv; |
| 113 | } | 113 | } |
| @@ -118,7 +118,7 @@ class CountDate extends Command | @@ -118,7 +118,7 @@ class CountDate extends Command | ||
| 118 | * @method :post | 118 | * @method :post |
| 119 | * @time :2023/6/14 15:40 | 119 | * @time :2023/6/14 15:40 |
| 120 | */ | 120 | */ |
| 121 | - public function ip_num($yesterday,$domain){ | 121 | + public function ip_num($yesterday){ |
| 122 | $ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->count(); | 122 | $ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->count(); |
| 123 | return $ip; | 123 | return $ip; |
| 124 | } | 124 | } |
| @@ -179,9 +179,9 @@ class RelayInquiry extends Command | @@ -179,9 +179,9 @@ class RelayInquiry extends Command | ||
| 179 | foreach ($inquiry as $key=>$val) { | 179 | foreach ($inquiry as $key=>$val) { |
| 180 | $this->output('询盘ID:' . $val->id); | 180 | $this->output('询盘ID:' . $val->id); |
| 181 | //询盘时间超过2小时 就不处理了 | 181 | //询盘时间超过2小时 就不处理了 |
| 182 | - if(time() - strtotime($val->inquiry_date) > 7200){ | 182 | + if(time() - strtotime($val->inquiry_date) > 259200){ |
| 183 | $val->status = ReInquiryForm::STATUS_FORGO; | 183 | $val->status = ReInquiryForm::STATUS_FORGO; |
| 184 | - $val->remark = '超时2小时未处理!'; | 184 | + $val->remark = '超时72小时未处理!'; |
| 185 | $val->save(); | 185 | $val->save(); |
| 186 | continue; | 186 | continue; |
| 187 | } | 187 | } |
| @@ -352,17 +352,26 @@ class RelayInquiry extends Command | @@ -352,17 +352,26 @@ class RelayInquiry extends Command | ||
| 352 | $country_name = $ip_data->ip_area; | 352 | $country_name = $ip_data->ip_area; |
| 353 | 353 | ||
| 354 | $this->output('转发内容'); | 354 | $this->output('转发内容'); |
| 355 | - // 推送消息 消息内容小于10个字符, 使用内置询盘内容 | ||
| 356 | - $message = $form->message; | ||
| 357 | - $message_id = 0; | ||
| 358 | - if (strlen($message) < 10) { | ||
| 359 | - $use_ids = ReInquiryDetail::where(['re_website' => $domain])->where('status', '<>', ReInquiryDetail::STATUS_FAIL)->pluck('text_id')->toArray(); | ||
| 360 | - $text = ReInquiryText::whereNotIn('id', $use_ids)->where('status', ReInquiryText::STATUS_USABLE)->inRandomOrder()->first(); | ||
| 361 | - $message = $text->content; | ||
| 362 | - $message_id = $text->id; | ||
| 363 | - // 获取后,使用次数+1 | ||
| 364 | - $text->use_time += 1; | ||
| 365 | - $text->save(); | 355 | + |
| 356 | + // 通过字符数量区分, 改成完全获取内置询盘内容 | ||
| 357 | + $use_ids = ReInquiryDetail::where(['re_website' => $domain])->where('status', '<>', ReInquiryDetail::STATUS_FAIL)->pluck('text_id')->toArray(); | ||
| 358 | + $text = ReInquiryText::whereNotIn('id', $use_ids)->where('status', ReInquiryText::STATUS_USABLE)->inRandomOrder()->first(); | ||
| 359 | + $message = $text->content; | ||
| 360 | + $message_id = $text->id; | ||
| 361 | + // 获取后,使用次数+1 | ||
| 362 | + $text->use_time += 1; | ||
| 363 | + $text->save(); | ||
| 364 | + | ||
| 365 | + //原内容非英语,转为对应语种 | ||
| 366 | + if(is_numeric($form->message)){ //数字会被识别为中文 | ||
| 367 | + $lang = 'en'; | ||
| 368 | + }else{ | ||
| 369 | + $translateSl = Translate::translateSl($form->message); | ||
| 370 | + $lang = $translateSl['texts']['sl'] ?? 'en'; | ||
| 371 | + } | ||
| 372 | + | ||
| 373 | + if($lang != 'en' || $lang != 'zh-CN'){ | ||
| 374 | + $message = Translate::tran($message, $lang); | ||
| 366 | } | 375 | } |
| 367 | 376 | ||
| 368 | $this->output('获取转发设备信息'); | 377 | $this->output('获取转发设备信息'); |
| @@ -175,7 +175,7 @@ class postInquiry extends Command | @@ -175,7 +175,7 @@ class postInquiry extends Command | ||
| 175 | ]; | 175 | ]; |
| 176 | 176 | ||
| 177 | $res = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data)->json(); | 177 | $res = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data)->json(); |
| 178 | - if(empty($res['data'][0]['code']) || $res['data'][0]['code'] != 200){ | 178 | + if(empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200,300])){ |
| 179 | $log->status = ReInquiryDetailLog::STATUS_FAIL; | 179 | $log->status = ReInquiryDetailLog::STATUS_FAIL; |
| 180 | $log->remark = $res['message'] ?? ''; | 180 | $log->remark = $res['message'] ?? ''; |
| 181 | $log->save(); | 181 | $log->save(); |
| @@ -16,6 +16,7 @@ use App\Models\HomeCount\MonthCount; | @@ -16,6 +16,7 @@ use App\Models\HomeCount\MonthCount; | ||
| 16 | use App\Models\Inquiry\InquiryFormData; | 16 | use App\Models\Inquiry\InquiryFormData; |
| 17 | use App\Models\Project\Project; | 17 | use App\Models\Project\Project; |
| 18 | use App\Models\Visit\Visit; | 18 | use App\Models\Visit\Visit; |
| 19 | +use App\Models\Visit\VisitItem; | ||
| 19 | use App\Services\ProjectServer; | 20 | use App\Services\ProjectServer; |
| 20 | use Illuminate\Console\Command; | 21 | use Illuminate\Console\Command; |
| 21 | use Illuminate\Support\Facades\DB; | 22 | use Illuminate\Support\Facades\DB; |
| @@ -137,14 +138,12 @@ class MonthAllCount extends Command | @@ -137,14 +138,12 @@ class MonthAllCount extends Command | ||
| 137 | * @time :2024/1/8 11:02 | 138 | * @time :2024/1/8 11:02 |
| 138 | */ | 139 | */ |
| 139 | public function pv_ip(&$arr,$start,$end,$project_id){ | 140 | public function pv_ip(&$arr,$start,$end,$project_id){ |
| 140 | - $pv_ip = DB::table('gl_count') | ||
| 141 | - ->where(['project_id'=>$project_id]) | ||
| 142 | - ->where('date','>=',$start.' 00:00:00') | ||
| 143 | - ->where('date','<=',$end.' 23:59:59') | ||
| 144 | - ->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')) | ||
| 145 | - ->first(); | ||
| 146 | - $arr['pv'] = $pv_ip->pv_num; | ||
| 147 | - $arr['ip'] = $pv_ip->ip_num; | 141 | + $arr['pv'] = (new VisitItem()) |
| 142 | + ->where('updated_date','>=',$start.' 00:00:00') | ||
| 143 | + ->where('updated_date','<=',$end.' 23:59:59')->count(); | ||
| 144 | + $arr['ip'] = (new Visit()) | ||
| 145 | + ->where('updated_date','>=',$start.' 00:00:00') | ||
| 146 | + ->where('updated_date','<=',$end.' 23:59:59')->count(); | ||
| 148 | if($arr['ip'] != 0){ | 147 | if($arr['ip'] != 0){ |
| 149 | $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2); | 148 | $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2); |
| 150 | } | 149 | } |
| @@ -14,6 +14,8 @@ use App\Models\Com\UpdateOldInfo; | @@ -14,6 +14,8 @@ use App\Models\Com\UpdateOldInfo; | ||
| 14 | use App\Models\Domain\DomainInfo; | 14 | use App\Models\Domain\DomainInfo; |
| 15 | use App\Models\Inquiry\InquiryFormData; | 15 | use App\Models\Inquiry\InquiryFormData; |
| 16 | use App\Models\Project\Project; | 16 | use App\Models\Project\Project; |
| 17 | +use App\Models\Visit\Visit; | ||
| 18 | +use App\Models\Visit\VisitItem; | ||
| 17 | use App\Services\ProjectServer; | 19 | use App\Services\ProjectServer; |
| 18 | use Illuminate\Console\Command; | 20 | use Illuminate\Console\Command; |
| 19 | use Illuminate\Support\Facades\DB; | 21 | use Illuminate\Support\Facades\DB; |
| @@ -159,14 +161,12 @@ class MonthCount extends Command | @@ -159,14 +161,12 @@ class MonthCount extends Command | ||
| 159 | * @time :2024/1/8 11:02 | 161 | * @time :2024/1/8 11:02 |
| 160 | */ | 162 | */ |
| 161 | public function pv_ip(&$arr,$start,$end,$project_id){ | 163 | public function pv_ip(&$arr,$start,$end,$project_id){ |
| 162 | - $pv_ip = DB::table('gl_count') | ||
| 163 | - ->where(['project_id'=>$project_id]) | ||
| 164 | - ->where('date','>=',$start.' 00:00:00') | ||
| 165 | - ->where('date','<=',$end.' 23:59:59') | ||
| 166 | - ->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')) | ||
| 167 | - ->first(); | ||
| 168 | - $arr['pv'] = $pv_ip->pv_num; | ||
| 169 | - $arr['ip'] = $pv_ip->ip_num; | 164 | + $arr['pv'] = (new VisitItem()) |
| 165 | + ->where('updated_date','>=',$start.' 00:00:00') | ||
| 166 | + ->where('updated_date','<=',$end.' 23:59:59')->count(); | ||
| 167 | + $arr['ip'] = (new Visit()) | ||
| 168 | + ->where('updated_date','>=',$start.' 00:00:00') | ||
| 169 | + ->where('updated_date','<=',$end.' 23:59:59')->count(); | ||
| 170 | if($arr['ip'] != 0){ | 170 | if($arr['ip'] != 0){ |
| 171 | $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2); | 171 | $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2); |
| 172 | } | 172 | } |
| @@ -14,6 +14,8 @@ use App\Models\Com\UpdateOldInfo; | @@ -14,6 +14,8 @@ use App\Models\Com\UpdateOldInfo; | ||
| 14 | use App\Models\Domain\DomainInfo; | 14 | use App\Models\Domain\DomainInfo; |
| 15 | use App\Models\Inquiry\InquiryFormData; | 15 | use App\Models\Inquiry\InquiryFormData; |
| 16 | use App\Models\Project\Project; | 16 | use App\Models\Project\Project; |
| 17 | +use App\Models\Visit\Visit; | ||
| 18 | +use App\Models\Visit\VisitItem; | ||
| 17 | use App\Services\ProjectServer; | 19 | use App\Services\ProjectServer; |
| 18 | use Illuminate\Console\Command; | 20 | use Illuminate\Console\Command; |
| 19 | use Illuminate\Support\Facades\DB; | 21 | use Illuminate\Support\Facades\DB; |
| @@ -160,14 +162,12 @@ class MonthCountDate extends Command | @@ -160,14 +162,12 @@ class MonthCountDate extends Command | ||
| 160 | * @time :2024/1/8 11:02 | 162 | * @time :2024/1/8 11:02 |
| 161 | */ | 163 | */ |
| 162 | public function pv_ip(&$arr,$start,$end,$project_id){ | 164 | public function pv_ip(&$arr,$start,$end,$project_id){ |
| 163 | - $pv_ip = DB::table('gl_count') | ||
| 164 | - ->where(['project_id'=>$project_id]) | ||
| 165 | - ->where('date','>=',$start.' 00:00:00') | ||
| 166 | - ->where('date','<=',$end.' 23:59:59') | ||
| 167 | - ->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')) | ||
| 168 | - ->first(); | ||
| 169 | - $arr['pv'] = $pv_ip->pv_num; | ||
| 170 | - $arr['ip'] = $pv_ip->ip_num; | 165 | + $arr['pv'] = (new VisitItem()) |
| 166 | + ->where('updated_date','>=',$start.' 00:00:00') | ||
| 167 | + ->where('updated_date','<=',$end.' 23:59:59')->count(); | ||
| 168 | + $arr['ip'] = (new Visit()) | ||
| 169 | + ->where('updated_date','>=',$start.' 00:00:00') | ||
| 170 | + ->where('updated_date','<=',$end.' 23:59:59')->count(); | ||
| 171 | if($arr['ip'] != 0){ | 171 | if($arr['ip'] != 0){ |
| 172 | $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2); | 172 | $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2); |
| 173 | } | 173 | } |
| @@ -16,6 +16,7 @@ use App\Models\HomeCount\MonthCount; | @@ -16,6 +16,7 @@ use App\Models\HomeCount\MonthCount; | ||
| 16 | use App\Models\Inquiry\InquiryFormData; | 16 | use App\Models\Inquiry\InquiryFormData; |
| 17 | use App\Models\Project\Project; | 17 | use App\Models\Project\Project; |
| 18 | use App\Models\Visit\Visit; | 18 | use App\Models\Visit\Visit; |
| 19 | +use App\Models\Visit\VisitItem; | ||
| 19 | use App\Services\ProjectServer; | 20 | use App\Services\ProjectServer; |
| 20 | use Illuminate\Console\Command; | 21 | use Illuminate\Console\Command; |
| 21 | use Illuminate\Support\Carbon; | 22 | use Illuminate\Support\Carbon; |
| @@ -133,14 +134,12 @@ class MonthProjectCount extends Command | @@ -133,14 +134,12 @@ class MonthProjectCount extends Command | ||
| 133 | * @time :2024/1/8 11:02 | 134 | * @time :2024/1/8 11:02 |
| 134 | */ | 135 | */ |
| 135 | public function pv_ip(&$arr,$start,$end,$project_id){ | 136 | public function pv_ip(&$arr,$start,$end,$project_id){ |
| 136 | - $pv_ip = DB::table('gl_count') | ||
| 137 | - ->where(['project_id'=>$project_id]) | ||
| 138 | - ->where('date','>=',$start.' 00:00:00') | ||
| 139 | - ->where('date','<=',$end.' 23:59:59') | ||
| 140 | - ->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')) | ||
| 141 | - ->first(); | ||
| 142 | - $arr['pv'] = $pv_ip->pv_num; | ||
| 143 | - $arr['ip'] = $pv_ip->ip_num; | 137 | + $arr['pv'] = (new VisitItem()) |
| 138 | + ->where('updated_date','>=',$start.' 00:00:00') | ||
| 139 | + ->where('updated_date','<=',$end.' 23:59:59')->count(); | ||
| 140 | + $arr['ip'] = (new Visit()) | ||
| 141 | + ->where('updated_date','>=',$start.' 00:00:00') | ||
| 142 | + ->where('updated_date','<=',$end.' 23:59:59')->count(); | ||
| 144 | if($arr['ip'] != 0){ | 143 | if($arr['ip'] != 0){ |
| 145 | $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 10,2); | 144 | $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 10,2); |
| 146 | } | 145 | } |
| @@ -2,15 +2,10 @@ | @@ -2,15 +2,10 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Console\Commands\RankData; | 3 | namespace App\Console\Commands\RankData; |
| 4 | 4 | ||
| 5 | - | ||
| 6 | use App\Helper\QuanqiusouApi; | 5 | use App\Helper\QuanqiusouApi; |
| 7 | -use App\Http\Logic\Bside\RankData\RankDataLogic; | ||
| 8 | -use App\Models\Domain\DomainInfo; | 6 | +use App\Models\RankData\RankDataLog as RankDataLogModel; |
| 9 | use App\Models\Project\DeployOptimize; | 7 | use App\Models\Project\DeployOptimize; |
| 10 | use App\Models\Project\Project; | 8 | use App\Models\Project\Project; |
| 11 | -use App\Models\RankData\RankData as GoogleRankModel; | ||
| 12 | -use App\Utils\LogUtils; | ||
| 13 | -use Illuminate\Database\Eloquent\Model; | ||
| 14 | use Illuminate\Support\Facades\Cache; | 9 | use Illuminate\Support\Facades\Cache; |
| 15 | use Illuminate\Support\Facades\Log; | 10 | use Illuminate\Support\Facades\Log; |
| 16 | 11 | ||
| @@ -35,7 +30,7 @@ class RankData extends BaseCommands | @@ -35,7 +30,7 @@ class RankData extends BaseCommands | ||
| 35 | * | 30 | * |
| 36 | * @var string | 31 | * @var string |
| 37 | */ | 32 | */ |
| 38 | - protected $description = '谷歌排名数据'; | 33 | + protected $description = '分发任务'; |
| 39 | 34 | ||
| 40 | /** | 35 | /** |
| 41 | * @author zbj | 36 | * @author zbj |
| @@ -45,67 +40,31 @@ class RankData extends BaseCommands | @@ -45,67 +40,31 @@ class RankData extends BaseCommands | ||
| 45 | { | 40 | { |
| 46 | try { | 41 | try { |
| 47 | Log::channel('rank_data')->info('开始-排名数据'); | 42 | Log::channel('rank_data')->info('开始-排名数据'); |
| 43 | + | ||
| 48 | //所有项目 今日是否达标 重置 | 44 | //所有项目 今日是否达标 重置 |
| 49 | //有失败会重跑任务,导致达标又被重置 加缓存一天只重置一次 | 45 | //有失败会重跑任务,导致达标又被重置 加缓存一天只重置一次 |
| 50 | if (!Cache::get('clear_remain_today_' . date('Y-m-d'))) { | 46 | if (!Cache::get('clear_remain_today_' . date('Y-m-d'))) { |
| 51 | Project::where('is_remain_today', 1)->update(['is_remain_today' => 0]); | 47 | Project::where('is_remain_today', 1)->update(['is_remain_today' => 0]); |
| 52 | Cache::set('clear_remain_today_' . date('Y-m-d'), 1, 24 * 3600); | 48 | Cache::set('clear_remain_today_' . date('Y-m-d'), 1, 24 * 3600); |
| 53 | } | 49 | } |
| 54 | - $error = 0; | ||
| 55 | - $api = new QuanqiusouApi(); | ||
| 56 | //有排名api编号的项目 | 50 | //有排名api编号的项目 |
| 57 | $list = DeployOptimize::where('api_no', '>', 0)->select('api_no', 'project_id')->orderBy('project_id', 'asc')->get(); | 51 | $list = DeployOptimize::where('api_no', '>', 0)->select('api_no', 'project_id')->orderBy('project_id', 'asc')->get(); |
| 58 | Log::channel('rank_data')->info('开始-排名数据-' . count($list)); | 52 | Log::channel('rank_data')->info('开始-排名数据-' . count($list)); |
| 59 | - //当日所有站点谷歌收录数据 | ||
| 60 | - $site_res = $api->getSiteRes(); | ||
| 61 | - if (!$site_res) { | ||
| 62 | - Log::channel('rank_data')->error('谷歌收录数据获取失败'); | 53 | + foreach ($list as $item){ |
| 54 | + RankDataLogModel::addTask($item['project_id'], $item['api_no']); | ||
| 63 | } | 55 | } |
| 64 | - foreach ($list as $item) { | ||
| 65 | - Log::channel('rank_data')->info('项目开始:ID' . $item['project_id'] .' - '. $item['api_no']) . ''; | ||
| 66 | - try { | ||
| 67 | - (new RankDataLogic())->syncRankData($item['api_no'], $site_res); | ||
| 68 | - } catch (\Exception $e) { | ||
| 69 | - Log::channel('rank_data')->error('RankData:失败 ' . $item['api_no'] . $e->getMessage()); | ||
| 70 | - $error++; | ||
| 71 | - continue; | 56 | + //小语种 |
| 57 | + $api = new QuanqiusouApi(); | ||
| 58 | + $lang_list = $api->getLangList(); | ||
| 59 | + foreach ($list as $item){ | ||
| 60 | + $langs = $lang_list[$item['api_no']] ?? []; | ||
| 61 | + foreach ($langs as $lang){ | ||
| 62 | + RankDataLogModel::addTask($item['project_id'], $item['api_no'], $lang); | ||
| 72 | } | 63 | } |
| 73 | } | 64 | } |
| 74 | - return !$error; | ||
| 75 | } catch (\Exception|\Throwable $e) { | 65 | } catch (\Exception|\Throwable $e) { |
| 76 | Log::channel('rank_data')->error('排名数据任务失败 ' . $e->getMessage()); | 66 | Log::channel('rank_data')->error('排名数据任务失败 ' . $e->getMessage()); |
| 77 | - throw new \Exception($e->getMessage()); | ||
| 78 | } | 67 | } |
| 68 | + return true; | ||
| 79 | } | 69 | } |
| 80 | - | ||
| 81 | - /** | ||
| 82 | - * 同步项目api_no | ||
| 83 | - * @author zbj | ||
| 84 | - * @date 2023/10/16 | ||
| 85 | - */ | ||
| 86 | - public function SyncApiNo(){ | ||
| 87 | - $deploy_optimizes = DeployOptimize::leftJoin('gl_project', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') | ||
| 88 | - ->whereIn('gl_project.type', [Project::TYPE_TWO,Project::TYPE_THREE])->where('gl_project_deploy_optimize.api_no', 0) | ||
| 89 | - ->where('gl_project_deploy_optimize.domain', '>', 0) | ||
| 90 | - ->get(); | ||
| 91 | - if(!$deploy_optimizes){ | ||
| 92 | - return true; | ||
| 93 | - } | ||
| 94 | - $api = new QuanqiusouApi(); | ||
| 95 | - $ai_nos = $api->getWebApiNo(); | ||
| 96 | - if($ai_nos){ | ||
| 97 | - foreach ($deploy_optimizes as $deploy_optimize){ | ||
| 98 | - $domain = DomainInfo::where('id', $deploy_optimize['domain'])->value('domain'); | ||
| 99 | - if(!$domain){ | ||
| 100 | - continue; | ||
| 101 | - } | ||
| 102 | - $api_no = array_search($domain, $ai_nos); | ||
| 103 | - if($api_no){ | ||
| 104 | - $deploy_optimize->api_no = $api_no; | ||
| 105 | - $deploy_optimize->save(); | ||
| 106 | - } | ||
| 107 | - } | ||
| 108 | - } | ||
| 109 | - } | ||
| 110 | - | ||
| 111 | } | 70 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\RankData; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Helper\Arr; | ||
| 7 | +use App\Helper\QuanqiusouApi; | ||
| 8 | +use App\Http\Logic\Bside\BaseLogic; | ||
| 9 | +use App\Http\Logic\Bside\RankData\RankDataLogic; | ||
| 10 | +use App\Models\RankData\RankDataLog as RankDataLogModel; | ||
| 11 | +use App\Models\Project\DeployOptimize; | ||
| 12 | +use App\Models\Project\Project; | ||
| 13 | +use Illuminate\Support\Facades\Cache; | ||
| 14 | +use Illuminate\Support\Facades\Log; | ||
| 15 | +use Illuminate\Support\Facades\Redis; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Class GoogleRank | ||
| 19 | + * @package App\Console\Commands | ||
| 20 | + * @author zbj | ||
| 21 | + * @date 2023/5/6 | ||
| 22 | + */ | ||
| 23 | +class RankDataLog extends BaseCommands | ||
| 24 | +{ | ||
| 25 | + /** | ||
| 26 | + * The name and signature of the console command. | ||
| 27 | + * | ||
| 28 | + * @var string | ||
| 29 | + */ | ||
| 30 | + protected $signature = 'rank_data_log'; | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * The console command description. | ||
| 34 | + * The console command description. | ||
| 35 | + * | ||
| 36 | + * @var string | ||
| 37 | + */ | ||
| 38 | + protected $description = '谷歌排名数据'; | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * @author zbj | ||
| 42 | + * @date 2023/5/6 | ||
| 43 | + */ | ||
| 44 | + public function do() | ||
| 45 | + { | ||
| 46 | + while (true) { | ||
| 47 | + $log_id = Redis::rpop('rank_data_task'); | ||
| 48 | + echo $log_id . PHP_EOL; | ||
| 49 | + if (!$log_id) { | ||
| 50 | + sleep(10); | ||
| 51 | + continue; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + $log = RankDataLogModel::where('id', $log_id)->where('status', 0)->first(); | ||
| 55 | + if(!$log){ | ||
| 56 | + continue; | ||
| 57 | + } | ||
| 58 | + try { | ||
| 59 | + $this->output('项目开始:ID'.$log->project_id . ',APINO' . $log->api_no); | ||
| 60 | + $project = Project::find($log->project_id); | ||
| 61 | + if (!$project) { | ||
| 62 | + $this->output('关联的项目不存在:ID'.$log->project_id . ',APINO' . $log->api_no); | ||
| 63 | + $log->status = 9; | ||
| 64 | + $log->save(); | ||
| 65 | + continue; | ||
| 66 | + } | ||
| 67 | + //接口获取数据 | ||
| 68 | + $api = new QuanqiusouApi(); | ||
| 69 | + $res = $api->getGoogleRank($log->project_id, $log->api_no, $log->lang); | ||
| 70 | + if (!$res) { | ||
| 71 | + $this->output('接口数据获取失败:ID'.$log->project_id . ',APINO' . $log->api_no); | ||
| 72 | + $log->status = 9; | ||
| 73 | + $log->save(); | ||
| 74 | + continue; | ||
| 75 | + } | ||
| 76 | + $log->data = Arr::s2a($res); | ||
| 77 | + //保存数据 | ||
| 78 | + $this->output('保存排名数据:ID'.$log->project_id . ',APINO' . $log->api_no); | ||
| 79 | + $is_compliance = (new RankDataLogic())->save_rank($log->project_id, $res, null, $log->lang); | ||
| 80 | + $log->is_compliance = $is_compliance; | ||
| 81 | + $log->status = 1; | ||
| 82 | + $log->save(); | ||
| 83 | + | ||
| 84 | + } catch (\Exception $e) { | ||
| 85 | + $this->output('处理失败:ID'.$log->project_id . ',APINO' . $log->api_no . ':' . $e->getMessage()); | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + public function output($message) | ||
| 91 | + { | ||
| 92 | + $date = date('Y-m-d H:i:s'); | ||
| 93 | + $output = $date . ', ' . $message . PHP_EOL; | ||
| 94 | + echo $output; | ||
| 95 | + Log::channel('rank_data')->info($output); | ||
| 96 | + return true; | ||
| 97 | + } | ||
| 98 | +} |
| @@ -31,6 +31,7 @@ class SyncSubmitTask extends Command | @@ -31,6 +31,7 @@ class SyncSubmitTask extends Command | ||
| 31 | while (true) { | 31 | while (true) { |
| 32 | $task_id = Redis::rpop('sync_submit_task'); | 32 | $task_id = Redis::rpop('sync_submit_task'); |
| 33 | if(!$task_id){ | 33 | if(!$task_id){ |
| 34 | + sleep(1); | ||
| 34 | continue; | 35 | continue; |
| 35 | } | 36 | } |
| 36 | 37 |
| @@ -44,6 +44,8 @@ class SyncSubmitTaskDistribution extends Command | @@ -44,6 +44,8 @@ class SyncSubmitTaskDistribution extends Command | ||
| 44 | $this->output('分发:' . $task->id); | 44 | $this->output('分发:' . $task->id); |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | + }else{ | ||
| 48 | + sleep(1); | ||
| 47 | } | 49 | } |
| 48 | }catch (\Exception $e){ | 50 | }catch (\Exception $e){ |
| 49 | $this->output('异常:' . $e->getMessage()); | 51 | $this->output('异常:' . $e->getMessage()); |
| @@ -38,7 +38,7 @@ class WorkchatMessageSend extends Command | @@ -38,7 +38,7 @@ class WorkchatMessageSend extends Command | ||
| 38 | $this->output('开始推送消息' . $task->id); | 38 | $this->output('开始推送消息' . $task->id); |
| 39 | try { | 39 | try { |
| 40 | //超过两小时 不推送了 | 40 | //超过两小时 不推送了 |
| 41 | - if(time() - $task->send_time > 7200){ | 41 | + if(time() - strtotime($task->send_time) > 7200){ |
| 42 | throw new \Exception('超时两小时未推送'); | 42 | throw new \Exception('超时两小时未推送'); |
| 43 | } | 43 | } |
| 44 | ProjectAssociationServices::getInstance()->sendMessage($task->friend_id, $task->content, $task->content_type); | 44 | ProjectAssociationServices::getInstance()->sendMessage($task->friend_id, $task->content, $task->content_type); |
| @@ -107,7 +107,6 @@ class QuanqiusouApi | @@ -107,7 +107,6 @@ class QuanqiusouApi | ||
| 107 | if($res){ | 107 | if($res){ |
| 108 | $res = Arr::s2a($res); | 108 | $res = Arr::s2a($res); |
| 109 | Cache::put($key, $res, 2 * 3600); | 109 | Cache::put($key, $res, 2 * 3600); |
| 110 | - RankDataLog::addLog($project_id, $api_no, $lang, $endDay, $res); | ||
| 111 | } | 110 | } |
| 112 | } catch (\Exception | GuzzleException $e) { | 111 | } catch (\Exception | GuzzleException $e) { |
| 113 | errorLog('获取谷歌排名数据失败', [$api_no], $e); | 112 | errorLog('获取谷歌排名数据失败', [$api_no], $e); |
| @@ -38,6 +38,7 @@ class AdsController extends BaseController | @@ -38,6 +38,7 @@ class AdsController extends BaseController | ||
| 38 | $industry = trim($request->input('industry')); | 38 | $industry = trim($request->input('industry')); |
| 39 | $ad_id = trim($request->input('ad_id')); | 39 | $ad_id = trim($request->input('ad_id')); |
| 40 | $status = $request->input('status', ''); | 40 | $status = $request->input('status', ''); |
| 41 | + $page_size = intval($request->input('row', '20')); | ||
| 41 | $result = ReInquiryTask::when($ad_id, function ($query, $ads_id) { | 42 | $result = ReInquiryTask::when($ad_id, function ($query, $ads_id) { |
| 42 | return $query->where('ad_id', 'like', '%' . $ads_id . '%'); | 43 | return $query->where('ad_id', 'like', '%' . $ads_id . '%'); |
| 43 | }) | 44 | }) |
| @@ -53,7 +54,7 @@ class AdsController extends BaseController | @@ -53,7 +54,7 @@ class AdsController extends BaseController | ||
| 53 | } | 54 | } |
| 54 | }) | 55 | }) |
| 55 | ->orderBy('id', 'desc') | 56 | ->orderBy('id', 'desc') |
| 56 | - ->paginate(); | 57 | + ->paginate($page_size); |
| 57 | 58 | ||
| 58 | $relay_site_total = 0; | 59 | $relay_site_total = 0; |
| 59 | foreach ($result as $item){ | 60 | foreach ($result as $item){ |
| @@ -166,6 +167,7 @@ class AdsController extends BaseController | @@ -166,6 +167,7 @@ class AdsController extends BaseController | ||
| 166 | $ad_name = $request->input('ad_name'); | 167 | $ad_name = $request->input('ad_name'); |
| 167 | $ad_id = $request->input('ad_id'); | 168 | $ad_id = $request->input('ad_id'); |
| 168 | $country = $request->input('country'); | 169 | $country = $request->input('country'); |
| 170 | + $page_size = intval($request->input('row', '20')); | ||
| 169 | $result = ReInquiryForm::when($status, function ($query, $status) { | 171 | $result = ReInquiryForm::when($status, function ($query, $status) { |
| 170 | return $query->where('status', $status); | 172 | return $query->where('status', $status); |
| 171 | }) | 173 | }) |
| @@ -179,7 +181,7 @@ class AdsController extends BaseController | @@ -179,7 +181,7 @@ class AdsController extends BaseController | ||
| 179 | return $query->where('country', 'like', '%' . $country . '%'); | 181 | return $query->where('country', 'like', '%' . $country . '%'); |
| 180 | }) | 182 | }) |
| 181 | ->orderBy('inquiry_date', 'desc') | 183 | ->orderBy('inquiry_date', 'desc') |
| 182 | - ->paginate(); | 184 | + ->paginate($page_size); |
| 183 | return $this->response('success', Code::SUCCESS, $result); | 185 | return $this->response('success', Code::SUCCESS, $result); |
| 184 | } | 186 | } |
| 185 | 187 |
| @@ -36,7 +36,7 @@ class ServersIpLogic extends BaseLogic | @@ -36,7 +36,7 @@ class ServersIpLogic extends BaseLogic | ||
| 36 | public function infoServersIp(){ | 36 | public function infoServersIp(){ |
| 37 | $info = $this->model->read(['id'=>$this->param['id']]); | 37 | $info = $this->model->read(['id'=>$this->param['id']]); |
| 38 | $projectModel = new Project(); | 38 | $projectModel = new Project(); |
| 39 | - $info['project_title'] = $projectModel->formatQuery(['serve_id'=>$info['id']])->pluck('title')->toArray(); | 39 | + $info['project_title'] = $projectModel->formatQuery(['serve_id'=>$info['id'],'delete_status'=>0])->pluck('title')->toArray(); |
| 40 | return $this->success($info); | 40 | return $this->success($info); |
| 41 | } | 41 | } |
| 42 | 42 |
| @@ -11,6 +11,7 @@ namespace App\Http\Logic\Aside\Manage; | @@ -11,6 +11,7 @@ namespace App\Http\Logic\Aside\Manage; | ||
| 11 | 11 | ||
| 12 | use App\Http\Logic\Aside\BaseLogic; | 12 | use App\Http\Logic\Aside\BaseLogic; |
| 13 | use App\Models\Manage\Manage; | 13 | use App\Models\Manage\Manage; |
| 14 | +use App\Models\Manage\ManageHr; | ||
| 14 | use App\Models\Manage\MenuSpecial; | 15 | use App\Models\Manage\MenuSpecial; |
| 15 | 16 | ||
| 16 | class MenuSpecialLogic extends BaseLogic | 17 | class MenuSpecialLogic extends BaseLogic |
| @@ -31,11 +32,37 @@ class MenuSpecialLogic extends BaseLogic | @@ -31,11 +32,37 @@ class MenuSpecialLogic extends BaseLogic | ||
| 31 | */ | 32 | */ |
| 32 | public function managerList($map){ | 33 | public function managerList($map){ |
| 33 | $managerModel = new Manage(); | 34 | $managerModel = new Manage(); |
| 34 | - $list = $managerModel->list($map,'id',['id','name']); | ||
| 35 | - return $this->success($list); | 35 | + $query = $managerModel->leftJoin('gl_manage_hr', 'gl_manage.id', '=', 'gl_manage_hr.manage_id'); |
| 36 | + $query = $this->searchParam($query,$map); | ||
| 37 | + $lists = $query->select($this->selectParam())->get()->toArray(); | ||
| 38 | + return $this->success($lists); | ||
| 36 | } | 39 | } |
| 37 | 40 | ||
| 38 | /** | 41 | /** |
| 42 | + * @remark :搜索 | ||
| 43 | + * @name :searchParam | ||
| 44 | + * @author :lyh | ||
| 45 | + * @method :post | ||
| 46 | + * @time :2024/10/24 11:50 | ||
| 47 | + */ | ||
| 48 | + public function searchParam(&$query,$map){ | ||
| 49 | + $query = $query->where('gl_manage_hr.status', $map['status'] ?? 1); | ||
| 50 | + return $query; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * 需要查询的字段 | ||
| 55 | + * @return array | ||
| 56 | + */ | ||
| 57 | + public function selectParam(){ | ||
| 58 | + $select = [ | ||
| 59 | + 'gl_manage.id AS id', | ||
| 60 | + 'gl_manage.name AS name', | ||
| 61 | + 'gl_manage_hr.status as status' | ||
| 62 | + ]; | ||
| 63 | + return $select; | ||
| 64 | + } | ||
| 65 | + /** | ||
| 39 | * @remark :获取详情 | 66 | * @remark :获取详情 |
| 40 | * @name :specialInfo | 67 | * @name :specialInfo |
| 41 | * @author :lyh | 68 | * @author :lyh |
| @@ -185,12 +185,12 @@ class CustomTemplateLogic extends BaseLogic | @@ -185,12 +185,12 @@ class CustomTemplateLogic extends BaseLogic | ||
| 185 | $this->param['html_style'] = "<style id='globalsojs-styles'></style>"; | 185 | $this->param['html_style'] = "<style id='globalsojs-styles'></style>"; |
| 186 | } | 186 | } |
| 187 | } | 187 | } |
| 188 | + if($this->param['url'] == 'news' || $this->param['url'] == 'product' || $this->param['url'] == 'blog'){ | ||
| 189 | + $this->fail('不允许修改路由为:'.$this->param['url']); | ||
| 190 | + } | ||
| 188 | $this->param['project_id'] = $this->user['project_id']; | 191 | $this->param['project_id'] = $this->user['project_id']; |
| 189 | $id = $this->model->addReturnId($this->param); | 192 | $id = $this->model->addReturnId($this->param); |
| 190 | $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']); | 193 | $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']); |
| 191 | - if($route == 'news' || $route == 'product' || $route == 'blog'){ | ||
| 192 | - $this->fail('不允许修改路由为:'.$this->param['url']); | ||
| 193 | - } | ||
| 194 | $this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route); | 194 | $this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route); |
| 195 | $this->model->edit(['url'=>$route],['id'=>$id]); | 195 | $this->model->edit(['url'=>$route],['id'=>$id]); |
| 196 | } | 196 | } |
| @@ -47,6 +47,9 @@ class RankDataLogic extends BaseLogic | @@ -47,6 +47,9 @@ class RankDataLogic extends BaseLogic | ||
| 47 | $project = (new ProjectLogic())->getProjectInfo($project_id); | 47 | $project = (new ProjectLogic())->getProjectInfo($project_id); |
| 48 | $domain_info = (new DomainInfoLogic)->getDomainInfo($project_id); | 48 | $domain_info = (new DomainInfoLogic)->getDomainInfo($project_id); |
| 49 | $rank = RankData::where('project_id', $project_id)->first(); | 49 | $rank = RankData::where('project_id', $project_id)->first(); |
| 50 | + if(empty($rank) && ($project['deploy_optimize']['api_no'] != 0)){ | ||
| 51 | + $data['langs_status'] = 1; | ||
| 52 | + } | ||
| 50 | $rank_week = RankWeek::where('project_id', $project_id)->first(); | 53 | $rank_week = RankWeek::where('project_id', $project_id)->first(); |
| 51 | $recomm_domain = RecommDomain::where('project_id', $project_id)->first(); | 54 | $recomm_domain = RecommDomain::where('project_id', $project_id)->first(); |
| 52 | $external_links = ExternalLinks::where('project_id', $project_id)->first(); | 55 | $external_links = ExternalLinks::where('project_id', $project_id)->first(); |
| @@ -86,9 +89,6 @@ class RankDataLogic extends BaseLogic | @@ -86,9 +89,6 @@ class RankDataLogic extends BaseLogic | ||
| 86 | //小语种列表 | 89 | //小语种列表 |
| 87 | $quanqiusou_api = new QuanqiusouApi(); | 90 | $quanqiusou_api = new QuanqiusouApi(); |
| 88 | $lang_data = $quanqiusou_api->getLangRankData($api_no); | 91 | $lang_data = $quanqiusou_api->getLangRankData($api_no); |
| 89 | - if(empty($lang_data)){ | ||
| 90 | - $data['langs_status'] = 1; | ||
| 91 | - } | ||
| 92 | $lang_data = Arr::setValueToKey($lang_data, 'language'); | 92 | $lang_data = Arr::setValueToKey($lang_data, 'language'); |
| 93 | $data['langs'] = []; | 93 | $data['langs'] = []; |
| 94 | $languageModel = new MinorLanguages(); | 94 | $languageModel = new MinorLanguages(); |
| @@ -447,13 +447,13 @@ class RankDataLogic extends BaseLogic | @@ -447,13 +447,13 @@ class RankDataLogic extends BaseLogic | ||
| 447 | 447 | ||
| 448 | /** | 448 | /** |
| 449 | * @param $project_id | 449 | * @param $project_id |
| 450 | - * @param int $indexed_pages_num | 450 | + * @param $indexed_pages_num |
| 451 | * @param $data | 451 | * @param $data |
| 452 | * @param string $lang | 452 | * @param string $lang |
| 453 | * @author zbj | 453 | * @author zbj |
| 454 | * @date 2023/5/8 | 454 | * @date 2023/5/8 |
| 455 | */ | 455 | */ |
| 456 | - public function save_rank($project_id, $data, int $indexed_pages_num = 0, string $lang = ''){ | 456 | + public function save_rank($project_id, $data, $indexed_pages_num = null, string $lang = ''){ |
| 457 | $without_project_ids = []; //不用处理排名的项目 | 457 | $without_project_ids = []; //不用处理排名的项目 |
| 458 | $without_extension_project_ids = [658]; //是否达标只统计主词的 | 458 | $without_extension_project_ids = [658]; //是否达标只统计主词的 |
| 459 | $extension_project_ids = [354]; //扩展词也到达标的 | 459 | $extension_project_ids = [354]; //扩展词也到达标的 |
| @@ -548,11 +548,15 @@ class RankDataLogic extends BaseLogic | @@ -548,11 +548,15 @@ class RankDataLogic extends BaseLogic | ||
| 548 | $model->first_three_pages_num = $first_three_pages_num; | 548 | $model->first_three_pages_num = $first_three_pages_num; |
| 549 | $model->first_five_pages_num = $first_five_pages_num; | 549 | $model->first_five_pages_num = $first_five_pages_num; |
| 550 | $model->first_ten_pages_num = $first_ten_pages_num; | 550 | $model->first_ten_pages_num = $first_ten_pages_num; |
| 551 | - $model->indexed_pages_num = $indexed_pages_num; | 551 | + if($indexed_pages_num !== null){ |
| 552 | + $model->indexed_pages_num = $indexed_pages_num; | ||
| 553 | + } | ||
| 552 | $model->lang = $lang; | 554 | $model->lang = $lang; |
| 553 | $model->data = $data; | 555 | $model->data = $data; |
| 554 | $model->updated_date = date('Y-m-d'); | 556 | $model->updated_date = date('Y-m-d'); |
| 555 | $model->save(); | 557 | $model->save(); |
| 558 | + | ||
| 559 | + return $model->is_compliance; | ||
| 556 | } | 560 | } |
| 557 | 561 | ||
| 558 | /** | 562 | /** |
| @@ -334,23 +334,22 @@ class TranslateLogic extends BaseLogic | @@ -334,23 +334,22 @@ class TranslateLogic extends BaseLogic | ||
| 334 | $page = $arr[1]; | 334 | $page = $arr[1]; |
| 335 | $route = $arr[0]; | 335 | $route = $arr[0]; |
| 336 | } | 336 | } |
| 337 | - if(in_array($route,['products','news','blog'])){ | ||
| 338 | - //固定路由 | ||
| 339 | - $data['page'] = $page; | ||
| 340 | - $data['is_list'] = 1; | ||
| 341 | - if($route == 'products'){ | ||
| 342 | - $data['source'] = 2; | ||
| 343 | - }elseif ($route == 'news'){ | ||
| 344 | - $data['source'] = 4; | ||
| 345 | - }else{ | ||
| 346 | - $data['source'] = 3; | ||
| 347 | - } | ||
| 348 | - return $this->success($data); | ||
| 349 | - } | ||
| 350 | - | ||
| 351 | $routeModel = new RouteMap(); | 337 | $routeModel = new RouteMap(); |
| 352 | $routeInfo = $routeModel->read(['route'=>$route]); | 338 | $routeInfo = $routeModel->read(['route'=>$route]); |
| 353 | if($routeInfo === false){ | 339 | if($routeInfo === false){ |
| 340 | + if(in_array($route,['products','news','blog'])){ | ||
| 341 | + //固定路由 | ||
| 342 | + $data['page'] = $page; | ||
| 343 | + $data['is_list'] = 1; | ||
| 344 | + if($route == 'products'){ | ||
| 345 | + $data['source'] = 2; | ||
| 346 | + }elseif ($route == 'news'){ | ||
| 347 | + $data['source'] = 4; | ||
| 348 | + }else{ | ||
| 349 | + $data['source'] = 3; | ||
| 350 | + } | ||
| 351 | + return $this->success($data); | ||
| 352 | + } | ||
| 354 | return $data; | 353 | return $data; |
| 355 | } | 354 | } |
| 356 | $data = $this->resultData($routeInfo,$data); | 355 | $data = $this->resultData($routeInfo,$data); |
| @@ -5,6 +5,7 @@ namespace App\Models\RankData; | @@ -5,6 +5,7 @@ namespace App\Models\RankData; | ||
| 5 | 5 | ||
| 6 | use App\Helper\Arr; | 6 | use App\Helper\Arr; |
| 7 | use App\Models\Base; | 7 | use App\Models\Base; |
| 8 | +use Illuminate\Support\Facades\Redis; | ||
| 8 | 9 | ||
| 9 | /** | 10 | /** |
| 10 | * Class GoogleRank | 11 | * Class GoogleRank |
| @@ -27,22 +28,29 @@ class RankDataLog extends Base | @@ -27,22 +28,29 @@ class RankDataLog extends Base | ||
| 27 | return Arr::s2a($value); | 28 | return Arr::s2a($value); |
| 28 | } | 29 | } |
| 29 | 30 | ||
| 30 | - public static function addLog($project_id, $api_no, $lang, $date, $res){ | ||
| 31 | - $data= []; | ||
| 32 | - foreach ($res as $key=>$item){ | ||
| 33 | - $data[$key] = $item[$date]; | ||
| 34 | - } | 31 | + public static function addTask($project_id, $api_no, $lang =''){ |
| 32 | + $date = date('Y-m-d'); | ||
| 35 | $model = self::where('project_id', $project_id)->where('date', $date)->where('lang', $lang)->first(); | 33 | $model = self::where('project_id', $project_id)->where('date', $date)->where('lang', $lang)->first(); |
| 36 | - if(!$model){ | 34 | + if($model){ |
| 35 | + //已达标的 | ||
| 36 | + if($model->is_compliance){ | ||
| 37 | + return true; | ||
| 38 | + } | ||
| 39 | + //有未执行的 | ||
| 40 | + if(!$model->status){ | ||
| 41 | + return true; | ||
| 42 | + } | ||
| 43 | + }else{ | ||
| 37 | $model = new self(); | 44 | $model = new self(); |
| 45 | + $model->project_id = $project_id; | ||
| 46 | + $model->api_no = $api_no; | ||
| 47 | + $model->lang = $lang; | ||
| 48 | + $model->date = $date; | ||
| 38 | } | 49 | } |
| 39 | - $model->project_id = $project_id; | ||
| 40 | - $model->api_no = $api_no; | ||
| 41 | - $model->lang = $lang; | ||
| 42 | - $model->date = $date; | ||
| 43 | - $model->data = $data; | 50 | + $model->status = 0; |
| 44 | $model->save(); | 51 | $model->save(); |
| 45 | 52 | ||
| 53 | + Redis::lpush('rank_data_task', $model->id); | ||
| 46 | return true; | 54 | return true; |
| 47 | } | 55 | } |
| 48 | 56 |
| @@ -6,7 +6,9 @@ use App\Models\Base; | @@ -6,7 +6,9 @@ use App\Models\Base; | ||
| 6 | use App\Models\Inquiry\InquiryFormData; | 6 | use App\Models\Inquiry\InquiryFormData; |
| 7 | use App\Models\ProjectAssociation\ProjectAssociation; | 7 | use App\Models\ProjectAssociation\ProjectAssociation; |
| 8 | use App\Services\ProjectServer; | 8 | use App\Services\ProjectServer; |
| 9 | +use App\Utils\LogUtils; | ||
| 9 | use Illuminate\Database\Eloquent\SoftDeletes; | 10 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 11 | +use Illuminate\Support\Facades\Log; | ||
| 10 | 12 | ||
| 11 | /** | 13 | /** |
| 12 | * Class MessagePush | 14 | * Class MessagePush |
| @@ -40,9 +42,9 @@ class MessagePush extends Base | @@ -40,9 +42,9 @@ class MessagePush extends Base | ||
| 40 | * @return bool | 42 | * @return bool |
| 41 | */ | 43 | */ |
| 42 | public static function addInquiryMessage($id, $project_id, $country, $name, $submit_at){ | 44 | public static function addInquiryMessage($id, $project_id, $country, $name, $submit_at){ |
| 43 | - if(!ProjectServer::useProject($project_id)){ | ||
| 44 | - return false; | ||
| 45 | - } | 45 | +// if(!ProjectServer::useProject($project_id)){ |
| 46 | +// return false; | ||
| 47 | +// } | ||
| 46 | 48 | ||
| 47 | //项目是否有绑定群 | 49 | //项目是否有绑定群 |
| 48 | $friend_id = ProjectAssociation::where('project_id', $project_id) | 50 | $friend_id = ProjectAssociation::where('project_id', $project_id) |
| @@ -50,6 +52,7 @@ class MessagePush extends Base | @@ -50,6 +52,7 @@ class MessagePush extends Base | ||
| 50 | ->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT) | 52 | ->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT) |
| 51 | ->value('friend_id'); | 53 | ->value('friend_id'); |
| 52 | if(!$friend_id){ | 54 | if(!$friend_id){ |
| 55 | + Log::channel('inquiry')->info($project_id . '没有绑定企微群', [$id]); | ||
| 53 | return false; | 56 | return false; |
| 54 | } | 57 | } |
| 55 | 58 | ||
| @@ -92,5 +95,7 @@ class MessagePush extends Base | @@ -92,5 +95,7 @@ class MessagePush extends Base | ||
| 92 | } | 95 | } |
| 93 | } | 96 | } |
| 94 | $model->save(); | 97 | $model->save(); |
| 98 | + | ||
| 99 | + Log::channel('inquiry')->info($project_id . '通知消息', [$model->id]); | ||
| 95 | } | 100 | } |
| 96 | } | 101 | } |
| @@ -14,6 +14,7 @@ use App\Models\Visit\Visit; | @@ -14,6 +14,7 @@ use App\Models\Visit\Visit; | ||
| 14 | use App\Models\Workchat\MessagePush; | 14 | use App\Models\Workchat\MessagePush; |
| 15 | use App\Utils\LogUtils; | 15 | use App\Utils\LogUtils; |
| 16 | use Illuminate\Support\Facades\Http; | 16 | use Illuminate\Support\Facades\Http; |
| 17 | +use Illuminate\Support\Facades\Log; | ||
| 17 | use Illuminate\Support\Facades\URL; | 18 | use Illuminate\Support\Facades\URL; |
| 18 | use Illuminate\Support\Str; | 19 | use Illuminate\Support\Str; |
| 19 | use function Symfony\Component\String\s; | 20 | use function Symfony\Component\String\s; |
| @@ -79,7 +80,7 @@ class SyncSubmitTaskService | @@ -79,7 +80,7 @@ class SyncSubmitTaskService | ||
| 79 | } | 80 | } |
| 80 | 81 | ||
| 81 | $handler = new self(); | 82 | $handler = new self(); |
| 82 | - return $handler->$action($data, $date); | 83 | + return $handler->$action($data, $date, $task['id']); |
| 83 | } | 84 | } |
| 84 | 85 | ||
| 85 | 86 | ||
| @@ -110,7 +111,7 @@ class SyncSubmitTaskService | @@ -110,7 +111,7 @@ class SyncSubmitTaskService | ||
| 110 | * @author zbj | 111 | * @author zbj |
| 111 | * @date 2024/8/27 | 112 | * @date 2024/8/27 |
| 112 | */ | 113 | */ |
| 113 | - public function subscribe($data, $date){ | 114 | + public function subscribe($data, $date, $task_id){ |
| 114 | $email = $data['data']['email']; | 115 | $email = $data['data']['email']; |
| 115 | if (filter_var($email, FILTER_VALIDATE_EMAIL)) { | 116 | if (filter_var($email, FILTER_VALIDATE_EMAIL)) { |
| 116 | $model = new Email(); | 117 | $model = new Email(); |
| @@ -129,7 +130,7 @@ class SyncSubmitTaskService | @@ -129,7 +130,7 @@ class SyncSubmitTaskService | ||
| 129 | * @author zbj | 130 | * @author zbj |
| 130 | * @date 2023/12/4 | 131 | * @date 2023/12/4 |
| 131 | */ | 132 | */ |
| 132 | - public function inquiry($data, $date) | 133 | + public function inquiry($data, $date, $task_id) |
| 133 | { | 134 | { |
| 134 | //数组key转为小写 | 135 | //数组key转为小写 |
| 135 | $data['data'] = array_change_key_case($data['data'], CASE_LOWER); | 136 | $data['data'] = array_change_key_case($data['data'], CASE_LOWER); |
| @@ -155,18 +156,22 @@ class SyncSubmitTaskService | @@ -155,18 +156,22 @@ class SyncSubmitTaskService | ||
| 155 | 156 | ||
| 156 | $id = InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data']); | 157 | $id = InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data']); |
| 157 | 158 | ||
| 159 | + | ||
| 158 | //转化询盘 | 160 | //转化询盘 |
| 159 | Visit::isInquiry($data['ip']); | 161 | Visit::isInquiry($data['ip']); |
| 160 | 162 | ||
| 161 | //推送企微消息 | 163 | //推送企微消息 |
| 164 | + Log::channel('inquiry')->info($task_id . '询盘结果', [$id]); | ||
| 162 | if($id){ | 165 | if($id){ |
| 163 | try { | 166 | try { |
| 164 | $name = empty($data['data']['name']) ? '' : ' ' . $data['data']['name']; | 167 | $name = empty($data['data']['name']) ? '' : ' ' . $data['data']['name']; |
| 165 | MessagePush::addInquiryMessage($id, $data['project_id'], $data['country'], $name, $data['submit_at']); | 168 | MessagePush::addInquiryMessage($id, $data['project_id'], $data['country'], $name, $data['submit_at']); |
| 166 | }catch (\Exception $e){ | 169 | }catch (\Exception $e){ |
| 170 | + Log::channel('inquiry')->info($task_id . '询盘失败', [$e->getMessage(), $e->getFile(), $e->getLine()]); | ||
| 167 | LogUtils::error('询盘消息'.$id.'写入企微消息队列失败' . $e->getMessage()); | 171 | LogUtils::error('询盘消息'.$id.'写入企微消息队列失败' . $e->getMessage()); |
| 168 | } | 172 | } |
| 169 | } | 173 | } |
| 174 | + Log::channel('inquiry')->info($task_id . '询盘完成' . PHP_EOL); | ||
| 170 | 175 | ||
| 171 | return true; | 176 | return true; |
| 172 | } | 177 | } |
| @@ -179,7 +184,7 @@ class SyncSubmitTaskService | @@ -179,7 +184,7 @@ class SyncSubmitTaskService | ||
| 179 | * @author zbj | 184 | * @author zbj |
| 180 | * @date 2023/12/4 | 185 | * @date 2023/12/4 |
| 181 | */ | 186 | */ |
| 182 | - public function visit($data, $date) | 187 | + public function visit($data, $date, $task_id) |
| 183 | { | 188 | { |
| 184 | 189 | ||
| 185 | $visit_data = $data['data']; | 190 | $visit_data = $data['data']; |
| @@ -179,6 +179,12 @@ return [ | @@ -179,6 +179,12 @@ return [ | ||
| 179 | 'level' => 'debug', | 179 | 'level' => 'debug', |
| 180 | 'days' => 14, | 180 | 'days' => 14, |
| 181 | ], | 181 | ], |
| 182 | + 'inquiry' => [ | ||
| 183 | + 'driver' => 'daily', | ||
| 184 | + 'path' => storage_path('logs/inquiry/laravel.log'), | ||
| 185 | + 'level' => 'debug', | ||
| 186 | + 'days' => 14, | ||
| 187 | + ], | ||
| 182 | ], | 188 | ], |
| 183 | //操作日志 | 189 | //操作日志 |
| 184 | 'operator_log' =>[ | 190 | 'operator_log' =>[ |
-
请 注册 或 登录 后发表评论