From 166226e8ba606155da3d020742d557de1def3d01 Mon Sep 17 00:00:00 2001
From: heyuntao <heyuntao@LAPTOP-MP4HD5NS>
Date: 星期一, 17 七月 2023 10:19:01 +0800
Subject: [PATCH] no message

---
 application/api/logic/taoke/Search.php |  104 +++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 86 insertions(+), 18 deletions(-)

diff --git a/application/api/logic/taoke/Search.php b/application/api/logic/taoke/Search.php
index 31be576..4cc50d0 100644
--- a/application/api/logic/taoke/Search.php
+++ b/application/api/logic/taoke/Search.php
@@ -123,7 +123,7 @@
                     $user = $ModelUser->get(USERID);
                     $info = $LogicPdd->universal($user['common_relation_id'],$uri);
                     if($info){
-                        $goods = $LogicPdd->searchGoods($info,'',$user['common_relation_id'],true,1,1);
+                        $goods = $LogicPdd->searchGoods($info,'',$user['common_relation_id'],true,1,10);
                         if($goods !== false && isset($goods[0]))$goods = $goods[0];
                     }
                 }  
@@ -143,9 +143,11 @@
         //鏍规嵁浼犲叆鐨勫唴瀹硅皟鐢╝st鏂规硶
         $goods = $this->ast($content);
         $title = '';
+        $newGoods = [];
         //鍒ゆ柇goods鏄惁涓虹┖
         if(empty($goods)){
             $title = $content;
+            $newGoods=array_merge($newGoods,$goods);
         }
         else{
             $title = $goods['title'];
@@ -157,30 +159,96 @@
         $LogicHaodanku = new LogicHaodanku();
         $LogicDataoke=new LogicDataoke();
         //鏍规嵁鏍囬鏌ヨ澶╃尗鍟嗗搧
-        $newGoods = $LogicDataoke->superSearch($title,1,5,0,1);
+        $taobaoGoods = $LogicDataoke->superSearch($title,1,40,0,1);
+        //鍘婚櫎閿�閲忎负0鐨勫晢鍝佸苟鎸夌収浠锋牸鎺掑簭
+        $tmGoods = array_filter($taobaoGoods,function($v){
+            return $v['monthSales'] > 0&&strstr($v['shopName'],'鏃楄埌搴�');
+            unset($v);
+        });
+        //鎸夌収浠锋牸鎺掑簭
+        $sort1 = array_column($tmGoods, 'actualPrice');
+        array_multisort($sort1, SORT_ASC, $tmGoods);
+
+        $tmcsGoods=array_filter($taobaoGoods,function($v){
+            return $v['monthSales'] > 0&&strstr($v['shopName'],'澶╃尗瓒呭競');
+            unset($v);
+        });
+        //鎸夌収浠锋牸鎺掑簭
+        $sort1 = array_column($tmcsGoods, 'actualPrice');
+        array_multisort($sort1, SORT_ASC, $tmcsGoods);
+
         //鏍规嵁鏍囬鏌ヨ浜笢鑷惀鍟嗗搧
-        $newGoods =array_merge($newGoods,$LogicJd->searchGoods($title,'desc','g',0,'match',1,5));
+        $jdGoods=$LogicJd->searchGoods($title,'desc','g',0,'match',1,20);
+        //鍘婚櫎閿�閲忎负0鐨勫晢鍝佸苟鎸夌収浠锋牸鎺掑簭
+        $jdGoods = array_filter($jdGoods,function($v){
+            return $v['monthSales'] > 0;
+        });
+        //鎸夌収浠锋牸鎺掑簭
+        $sort1 = array_column($jdGoods, 'actualPrice');
+        array_multisort($sort1, SORT_ASC, $jdGoods);
+
+        $ppdGoodes=[];
+        $common_relation_id='168369887871568';
         //鏍规嵁鏍囬鏌ヨ鎷煎澶氬晢鍝�
         if(!empty($common_relation_id)){
-            $ppdGoodes=$LogicPdd->searchGoods($title,'',$common_relation_id,'',1,10,0,'');
-            $newGoods =array_merge($newGoods,array_slice($ppdGoodes,0,5));
+            $ppdGoodes=$LogicPdd->searchGoods($title,'',$common_relation_id,'',1,20,0,'');
+            //鍘婚櫎閿�閲忎负0鐨勫晢鍝佸苟鎸夌収浠锋牸鎺掑簭
+            $ppdGoodes = array_filter($ppdGoodes,function($v){
+                return $v['monthSales'] > 0;
+            });
+            //鎸夌収浠锋牸鎺掑簭
+            $sort1 = array_column($ppdGoodes, 'actualPrice');
+            array_multisort($sort1, SORT_ASC, $ppdGoodes);
         }
         
         //鏍规嵁鏍囬鏌ヨ鎶栭煶鍟嗗搧
-        $newGoods =array_merge($newGoods,$LogicHaodanku->getDygoodsList('',$title,0,1,5));
-        if(count($newGoods)<20){
-         //鏍规嵁鏍囬鏌ヨ娣樺疂鍟嗗搧
-        // $newGoods =array_merge($newGoods,$LogicDataoke->superSearch($title,1,5,0,0));
-         //鏍规嵁鏍囬鏌ヨ浜笢POP鍟嗗搧
-        // $newGoods =array_merge($newGoods,$LogicJd->searchGoods($title,'desc','p',0,'match',1,5));
-         //鏍规嵁鏍囬鏌ヨ鍞搧浼氬晢鍝�
-        // $newGoods =array_merge($newGoods,$LogicDingdanxia->superSearch($goods['title'],'wph','t'));
-        }
-        //灏唍ewGoods鎸夌収浠锋牸鎺掑簭
-        $sort1 = array_column($newGoods, 'actualPrice');
+        $dyGoods =$LogicHaodanku->getDygoodsList('',$title,0,1,20);
+        //鍘婚櫎閿�閲忎负0鐨勫晢鍝佸苟鎸夌収浠锋牸鎺掑簭
+        $dyGoods = array_filter($dyGoods,function($v){
+            return $v['monthSales'] > 0;
+        });
+        //鎸夌収浠锋牸鎺掑簭
+        $sort1 = array_column($dyGoods, 'actualPrice');
+        array_multisort($sort1, SORT_ASC, $dyGoods);
 
-        array_multisort($sort1, SORT_ASC, $newGoods);
-        log::write("goodsList:".json_encode($newGoods));
+        $goodscount=count(array_slice($tmGoods,0,5))+count(array_slice($jdGoods,0,5))+count(array_slice($ppdGoodes,0,5))+count(array_slice($dyGoods,0,5))+count(array_slice($tmcsGoods,0,5));
+        if($goodscount<20){
+            //濡傛灉goodscount涓嶆弧瓒�20鍒欎粠澶╃尗鍟嗗搧閲岃ˉ瓒�20
+            $needcount=20-$goodscount+5;
+            $newGoods =array_merge($newGoods,array_slice($tmGoods,0,5));
+            $newGoods =array_merge($newGoods,array_slice($tmcsGoods,0,5));
+            $newGoods =array_merge($newGoods,array_slice($jdGoods,0,5));
+            //鎸夌収浠锋牸鎺掑簭
+            $sort1 = array_column($newGoods, 'actualPrice');
+            array_multisort($sort1, SORT_ASC, $newGoods);
+            $newGoods =array_merge($newGoods,array_slice($taobaoGoods,0,$needcount));
+            $newGoods =array_merge($newGoods,array_slice($ppdGoodes,0,5));
+            $newGoods =array_merge($newGoods,array_slice($dyGoods,0,5));
+
+        }
+        else{
+            $newGoods =array_merge($newGoods,array_slice($tmGoods,0,5));
+            $newGoods =array_merge($newGoods,array_slice($tmcsGoods,0,5));
+            $newGoods =array_merge($newGoods,array_slice($jdGoods,0,5));
+            //鎸夌収浠锋牸鎺掑簭
+            $sort1 = array_column($newGoods, 'actualPrice');
+            array_multisort($sort1, SORT_ASC, $newGoods);
+            $newGoods =array_merge($newGoods,array_slice($ppdGoodes,0,5));
+            $newGoods =array_merge($newGoods,array_slice($dyGoods,0,5));
+        }
+        //濡傛灉杩樻槸涓嶆弧瓒�20鍒欎粠娣樺疂鍟嗗搧閲岃ˉ瓒�20
+        if(count($newGoods)<20){
+            $tbGoods = $LogicDataoke->superSearch($title,1,20,0,0);
+            //鍘婚櫎閿�閲忎负0鐨勫晢鍝佸苟鎸夌収浠锋牸鎺掑簭
+            $tbGoods = array_filter($tbGoods,function($v){
+                return $v['monthSales'] > 0&&$v['shopType']=='娣樺疂';
+            });
+            //鎸夌収浠锋牸鎺掑簭
+            $sort1 = array_column($tbGoods, 'actualPrice');
+            array_multisort($sort1, SORT_ASC, $tbGoods);
+            $newGoods =array_merge($newGoods,array_slice($tbGoods,0,20));
+        }
+
         //鍙栧嚭鍓�20涓晢鍝�
         $goodsList = array_slice($newGoods,0,20);
         return $goodsList;

--
Gitblit v1.9.3