作者 赵彬吉
@@ -50,7 +50,7 @@ class GeoQuestionResLogic extends BaseLogic @@ -50,7 +50,7 @@ class GeoQuestionResLogic extends BaseLogic
50 $filed = ['id','project_id','question_id','platform','question','en_question','keywords','url','created_at','updated_at']; 50 $filed = ['id','project_id','question_id','platform','question','en_question','keywords','url','created_at','updated_at'];
51 if(!empty($map['created_at'])){ 51 if(!empty($map['created_at'])){
52 $map['project_id'] = $this->user['project_id']; 52 $map['project_id'] = $this->user['project_id'];
53 - $map['created_at'] = ['between',[$map['created_at'].' 00:00:00',$map['created_at'].'23:59:59']]; 53 + $map['created_at'] = ['between',[$map['created_at'].' 00:00:00',$map['created_at'].' 23:59:59']];
54 $this->model = new GeoQuestionLog(); 54 $this->model = new GeoQuestionLog();
55 } 55 }
56 $query = $this->model->formatQuery($map); 56 $query = $this->model->formatQuery($map);
@@ -83,23 +83,22 @@ class GeoQuestionResLogic extends BaseLogic @@ -83,23 +83,22 @@ class GeoQuestionResLogic extends BaseLogic
83 */ 83 */
84 public function countQuantity(){ 84 public function countQuantity(){
85 $questionModel = new GeoQuestion(); 85 $questionModel = new GeoQuestion();
86 - $list = $questionModel->list(['project_id',$this->user['project_id']],['question','keywords','url']); 86 + $list = $questionModel->list(['project_id'=>$this->user['project_id']],['question','keywords','url']);
87 $questionTotalCount = $urlTotalCount = $keywordsTotalCount = $keywordUrlCount = 0; 87 $questionTotalCount = $urlTotalCount = $keywordsTotalCount = $keywordUrlCount = 0;
88 foreach ($list as $item){ 88 foreach ($list as $item){
89 $questionTotalCount += count($item['question'] ?? []); 89 $questionTotalCount += count($item['question'] ?? []);
90 $keywordsTotalCount += count($item['keywords'] ?? []); 90 $keywordsTotalCount += count($item['keywords'] ?? []);
91 $urlTotalCount += count($item['url'] ?? []); 91 $urlTotalCount += count($item['url'] ?? []);
92 } 92 }
  93 + $keywordUrlCount = 0;
93 $keywordArr = []; 94 $keywordArr = [];
94 - $questionResModel = new GeoQuestionResult();  
95 - $resList = $questionResModel->list(['project_id',$this->user['project_id']],['keywords_num','url_num']); 95 + $questionResModel = new GeoQuestionLog();
  96 + $resList = $questionResModel->list(['project_id'=>$this->user['project_id']],['keywords','url','keywords_num','url_num']);
96 foreach ($resList as $resItem){ 97 foreach ($resList as $resItem){
97 - $keywordsNumArr = json_decode($resItem['keywords_num'] ?? [], true); // 转为 PHP 关联数组  
98 - $keywordUrlCount += array_sum($keywordsNumArr); // 获取值的总和  
99 - $urlNumArr = json_decode($resItem['url'] ?? [],true);  
100 - $keywordUrlCount += array_sum($urlNumArr); // 获取值的总和 98 + $keywordUrlCount += count($resItem['keywords']);
  99 + $keywordUrlCount += count($resItem['url']);
101 foreach ($resItem['keywords_num'] as $key => $value) { 100 foreach ($resItem['keywords_num'] as $key => $value) {
102 - $keywordArr[$key] = ($keywordArr[$key] ?? 0) + $value; 101 + $keywordArr[$key] = ($keywordArr[$key] ?? 0) + (($value != 0) ? 1 : 0);
103 } 102 }
104 } 103 }
105 $data = [ 104 $data = [
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 9
10 namespace App\Models\Geo; 10 namespace App\Models\Geo;
11 11
  12 +use App\Helper\Arr;
12 use App\Models\Base; 13 use App\Models\Base;
13 14
14 /** 15 /**
@@ -21,4 +22,80 @@ use App\Models\Base; @@ -21,4 +22,80 @@ use App\Models\Base;
21 class GeoQuestionLog extends Base 22 class GeoQuestionLog extends Base
22 { 23 {
23 protected $table = 'gl_geo_question_log'; 24 protected $table = 'gl_geo_question_log';
  25 +
  26 + /**
  27 + * @remark :geo提交关键字获取器
  28 + * @name :getUrlAttribute
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2025/7/3 9:53
  32 + */
  33 + public function getKeywordsAttribute($value)
  34 + {
  35 + if($value){
  36 + $value = Arr::s2a($value);
  37 + }
  38 + return $value;
  39 + }
  40 +
  41 + /**
  42 + * @remark :geo提交网址获取器
  43 + * @name :getUrlAttribute
  44 + * @author :lyh
  45 + * @method :post
  46 + * @time :2025/7/3 9:52
  47 + */
  48 + public function getUrlAttribute($value)
  49 + {
  50 + if($value){
  51 + $value = Arr::s2a($value);
  52 + }
  53 + return $value;
  54 + }
  55 +
  56 + /**
  57 + * @remark :geo提交结果获取器
  58 + * @name :getUrlAttribute
  59 + * @author :lyh
  60 + * @method :post
  61 + * @time :2025/7/3 9:52
  62 + */
  63 + public function getTextAttribute($value)
  64 + {
  65 + if($value){
  66 + $value = Arr::s2a($value);
  67 + }
  68 + return $value;
  69 + }
  70 +
  71 + /**
  72 + * @remark :命中的关键词数量
  73 + * @name :getKeywordsNumAttribute
  74 + * @author :lyh
  75 + * @method :post
  76 + * @time :2025/7/21 11:33
  77 + */
  78 + public function getKeywordsNumAttribute($value)
  79 + {
  80 + if($value){
  81 + $value = Arr::s2a($value);
  82 + }
  83 + return $value;
  84 + }
  85 +
  86 + /**
  87 + * @remark :命中的url数量
  88 + * @name :getUrlNumAttribute
  89 + * @author :lyh
  90 + * @method :post
  91 + * @time :2025/7/21 11:34
  92 + */
  93 + public function getUrlNumAttribute($value)
  94 + {
  95 + if($value){
  96 + $value = Arr::s2a($value);
  97 + }
  98 + return $value;
  99 + }
  100 +
24 } 101 }