作者 lyh

gx脚本

@@ -9,9 +9,11 @@ @@ -9,9 +9,11 @@
9 9
10 namespace App\Console\Commands\ProjectWeeklyReport; 10 namespace App\Console\Commands\ProjectWeeklyReport;
11 11
  12 +use App\Helper\FormGlobalsoApi;
12 use App\Models\Blog\Blog; 13 use App\Models\Blog\Blog;
13 use App\Models\Com\Notify; 14 use App\Models\Com\Notify;
14 use App\Models\Com\V6WeeklyReport; 15 use App\Models\Com\V6WeeklyReport;
  16 +use App\Models\Domain\DomainInfo;
15 use App\Models\HomeCount\Count; 17 use App\Models\HomeCount\Count;
16 use App\Models\News\News; 18 use App\Models\News\News;
17 use App\Models\Product\Product; 19 use App\Models\Product\Product;
@@ -53,8 +55,14 @@ class WeekProject extends Command @@ -53,8 +55,14 @@ class WeekProject extends Command
53 public function handle(){ 55 public function handle(){
54 $projectModel = new Project(); 56 $projectModel = new Project();
55 $list = $projectModel->list(['delete_status'=>0,'type'=>['in',[1,2,3,4,6]]],'id',['id','title']); 57 $list = $projectModel->list(['delete_status'=>0,'type'=>['in',[1,2,3,4,6]]],'id',['id','title']);
  58 + $domainModel = new DomainInfo();
56 foreach ($list as $k => $v){ 59 foreach ($list as $k => $v){
57 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 60 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  61 + $domainInfo = $domainModel->read(['project_id'=>$v['id']]);
  62 + if($domainInfo === false){
  63 + continue;
  64 + }
  65 + $v['domain'] = $domainInfo['domain'];
58 ProjectServer::useProject($v['id']); 66 ProjectServer::useProject($v['id']);
59 $this->weekData($v); 67 $this->weekData($v);
60 DB::disconnect('custom_mysql'); 68 DB::disconnect('custom_mysql');
@@ -84,10 +92,11 @@ class WeekProject extends Command @@ -84,10 +92,11 @@ class WeekProject extends Command
84 $data['end_date'] = $endOfLastWeekFormatted = date('Y-m-d', $endOfLastWeek); 92 $data['end_date'] = $endOfLastWeekFormatted = date('Y-m-d', $endOfLastWeek);
85 $countModel = new Count(); 93 $countModel = new Count();
86 $startOfThisWeek = date('Y-m-d', strtotime("monday this week")); 94 $startOfThisWeek = date('Y-m-d', strtotime("monday this week"));
87 - $startOfLastWeekFormattedInfo = $countModel->read(['date'=>$startOfLastWeekFormatted,'project_id'=>$value['id']],['inquiry_num','country']);  
88 $endOfLastWeekFormattedInfo = $countModel->read(['date'=>$startOfThisWeek,'project_id'=>$value['id']],['inquiry_num','country']); 95 $endOfLastWeekFormattedInfo = $countModel->read(['date'=>$startOfThisWeek,'project_id'=>$value['id']],['inquiry_num','country']);
89 $data['inquiry_total'] = $endOfLastWeekFormattedInfo['inquiry_num'] ?? 0;//询盘数量 96 $data['inquiry_total'] = $endOfLastWeekFormattedInfo['inquiry_num'] ?? 0;//询盘数量
90 $data['inquiry_country'] = $endOfLastWeekFormattedInfo['country'] ?? json_encode([]); 97 $data['inquiry_country'] = $endOfLastWeekFormattedInfo['country'] ?? json_encode([]);
  98 + //获取上一周询盘数量
  99 + $result = (new FormGlobalsoApi())->getDateInquiry($value['domain'],$data['start_date'],$data['end_date']);
91 $data['week_inquiry_total'] = ($endOfLastWeekFormattedInfo['inquiry_num'] ?? 0) - ($startOfLastWeekFormattedInfo['inquiry_num'] ?? 0); 100 $data['week_inquiry_total'] = ($endOfLastWeekFormattedInfo['inquiry_num'] ?? 0) - ($startOfLastWeekFormattedInfo['inquiry_num'] ?? 0);
92 $rankDataModel = new RankData(); 101 $rankDataModel = new RankData();
93 $rankInfo = $rankDataModel->read(['project_id'=>$value['id'],'lang'=>''],['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num','indexed_pages_num']); 102 $rankInfo = $rankDataModel->read(['project_id'=>$value['id'],'lang'=>''],['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num','indexed_pages_num']);
@@ -212,4 +212,29 @@ class FormGlobalsoApi @@ -212,4 +212,29 @@ class FormGlobalsoApi
212 echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL; 212 echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
213 return $res; 213 return $res;
214 } 214 }
  215 +
  216 + /**
  217 + * @remark :按时间区间
  218 + * @name :getMonthInquiry
  219 + * @author :lyh
  220 + * @method :post
  221 + * @time :2025/3/1 9:49
  222 + * https://form.globalso.com/api/external-interface/date_count?sta_date=2025-02-26&end_date=2025-02-28&domain=www.ultrasounddawei.com
  223 + */
  224 + public function getDateInquiry($url,$start,$end,$is_upgrade = 0){
  225 + $url = 'https://'.$url.'/';
  226 + $token = md5($url.date("Y-m-d"));
  227 + $data = [
  228 + 'domain' => $url,
  229 + 'token' => $token,
  230 + 'source'=> $is_upgrade ? '1,2,3,4,5' : '1,3,5',
  231 + 'end_date' => $end,
  232 + 'sta_date'=>$start,
  233 + ];
  234 + $queryString = http_build_query($data);
  235 + $url = 'https://www.globalso.site/api/external-interface/date_count?'.$queryString;
  236 + $res = http_get($url,['charset=utf-8']);
  237 + echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
  238 + return $res;
  239 + }
215 } 240 }
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 namespace App\Http\Controllers\Bside; 10 namespace App\Http\Controllers\Bside;
11 11
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
  13 +use App\Helper\FormGlobalsoApi;
13 use App\Helper\PayStripeApi; 14 use App\Helper\PayStripeApi;
14 use App\Http\Logic\Bside\News\NewsLogic; 15 use App\Http\Logic\Bside\News\NewsLogic;
15 use App\Models\Ai\AiBlog; 16 use App\Models\Ai\AiBlog;
@@ -19,6 +20,7 @@ use App\Models\CustomModule\CustomModuleContent; @@ -19,6 +20,7 @@ use App\Models\CustomModule\CustomModuleContent;
19 use App\Models\CustomModule\CustomModuleExtentContent; 20 use App\Models\CustomModule\CustomModuleExtentContent;
20 use App\Models\Domain\DomainInfo; 21 use App\Models\Domain\DomainInfo;
21 use App\Models\ExtentModule\ExtensionModuleValue; 22 use App\Models\ExtentModule\ExtensionModuleValue;
  23 +use App\Models\HomeCount\Count;
22 use App\Models\Manage\ManageHr; 24 use App\Models\Manage\ManageHr;
23 use App\Models\Project\CountAllProject as AllProject; 25 use App\Models\Project\CountAllProject as AllProject;
24 use App\Models\Project\Project; 26 use App\Models\Project\Project;
@@ -38,22 +40,15 @@ class TestController extends BaseController @@ -38,22 +40,15 @@ class TestController extends BaseController
38 * @time :2025/2/13 16:34 40 * @time :2025/2/13 16:34
39 */ 41 */
40 public function ceshi(){ 42 public function ceshi(){
41 - $aiBlogService = new AiBlogService();  
42 - $aiBlogService->mch_id = '100008';  
43 - $aiBlogService->key = '8a9c925bdcca';  
44 - $result = $aiBlogService->createTask('apple');  
45 - if($result['status'] == 200){  
46 - $param = [  
47 - 'keywords'=>'apple',  
48 - 'status'=>$result['data']['status'],  
49 - 'task_id'=>$result['data']['task_id'],  
50 - 'project_id'=>1,  
51 - ];  
52 - ProjectServer::useProject(1);  
53 - $aiBlogModel = new AiBlog();  
54 - $aiBlogModel->add($param);  
55 - DB::disconnect('custom_mysql');  
56 - }  
57 - $this->response('success',Code::SUCCESS,$param); 43 + // 上一周的开始时间(周一 00:00:00)
  44 + $startOfLastWeek = strtotime("last week monday");
  45 + // 上一周的结束时间(周日 23:59:59)
  46 + $endOfLastWeek = strtotime("last week sunday 23:59:59");
  47 + // 格式化为日期时间字符串
  48 + $data['start_date'] = $startOfLastWeekFormatted = date('Y-m-d', $startOfLastWeek);
  49 + $data['end_date'] = $endOfLastWeekFormatted = date('Y-m-d', $endOfLastWeek);
  50 + //获取上一周询盘数量
  51 + $result = (new FormGlobalsoApi())->getDateInquiry('www.rzalubottle.com',$data['start_date'],$data['end_date']);
  52 + $this->response('success',Code::SUCCESS,$result);
58 } 53 }
59 } 54 }