From 86613909c1be520ac6f994b4fa6f01b428b85bca Mon Sep 17 00:00:00 2001
From: heyuntao <heyuntao@LAPTOP-MP4HD5NS>
Date: 星期一, 17 七月 2023 09:54:21 +0800
Subject: [PATCH] no message

---
 application/api/logic/taoke/Search.php |  141 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 138 insertions(+), 3 deletions(-)

diff --git a/application/api/logic/taoke/Search.php b/application/api/logic/taoke/Search.php
index 5e91370..ea8b6e0 100644
--- a/application/api/logic/taoke/Search.php
+++ b/application/api/logic/taoke/Search.php
@@ -9,7 +9,8 @@
 use app\api\logic\taoke\device\Pdd as LogicPdd;
 use app\common\model\User as ModelUser;
 use app\api\logic\taoke\device\Haodanku as LogicHaodanku;
-
+use app\api\logic\taoke\device\Dataoke as LogicDataoke;
+use think\log;
 
 
 class Search extends BasicLogic
@@ -76,11 +77,28 @@
         $LogicPdd = new LogicPdd();
         $LogicZhetaoke = new LogicZhetaoke();
         $LogicHaodanku = new LogicHaodanku();
+        $LogicDataoke=new LogicDataoke();
         $goods = [];
         switch($this->provider){
             case 'tb':  //娣樺疂
                 $info = $LogicZhetaoke->zhuanlian($uri,'');
-                if($info) $goods = $info;
+                if(empty($info)&&isset($parse_url['host'])&&strstr($parse_url['host'],'item.taobao.com')){
+                    $info = $LogicDataoke->zhuanlian($uri,'');
+                    //鏍规嵁瀹濊礉鏍囬鎼滅储瀹濊礉
+                    $item_name=$info["title"];
+                    $goods["goodsId"]="";
+                    $goods["title"]=$item_name;
+                }
+                else if(empty($info)){
+                    $goods = [];
+                }
+                else{
+                    $goods_id=$info["tao_id"];
+                    $info = $LogicDataoke->getGoodsDetail($goods_id);
+                    if(empty($info)) return [];
+                    if($info) $goods = $info;
+                  
+                }
                 break;
             case 'tm': 
                     $info = $LogicDingdanxia->superSearch($uri,'tm','t');
@@ -105,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];
                     }
                 }  
@@ -120,5 +138,122 @@
         }
         return $goods;
     }
+
+    public function compare_good($content,$common_relation_id){
+        //鏍规嵁浼犲叆鐨勫唴瀹硅皟鐢╝st鏂规硶
+        $goods = $this->ast($content);
+        $title = '';
+        $newGoods = [];
+        //鍒ゆ柇goods鏄惁涓虹┖
+        if(empty($goods)){
+            $title = $content;
+            $newGoods=array_merge($newGoods,$goods);
+        }
+        else{
+            $title = $goods['title'];
+        }
+        //鏍规嵁$title鎼滅储鍚勫ぇ骞冲彴鐨勫晢鍝佸ぉ鐚紝娣樺疂锛屼含涓滆嚜钀ワ紝浜笢POP锛屾嫾澶氬锛屽敮鍝佷細锛屾姈闊�
+        $LogicDingdanxia = new LogicDingdanxia();
+        $LogicJd = new LogicJd();
+        $LogicPdd = new LogicPdd();
+        $LogicHaodanku = new LogicHaodanku();
+        $LogicDataoke=new LogicDataoke();
+        //鏍规嵁鏍囬鏌ヨ澶╃尗鍟嗗搧
+        $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);
+
+        //鏍规嵁鏍囬鏌ヨ浜笢鑷惀鍟嗗搧
+        $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=[];
+        //鏍规嵁鏍囬鏌ヨ鎷煎澶氬晢鍝�
+        if(!empty($common_relation_id)){
+            $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);
+        }
+        
+        //鏍规嵁鏍囬鏌ヨ鎶栭煶鍟嗗搧
+        $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);
+
+        $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