| | |
| | | $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]; |
| | | } |
| | | } |
| | |
| | | } |
| | | return $goods; |
| | | } |
| | | |
| | | public function compare_good($content,$common_relation_id,$exclude_tb=0,$exclude_jd=0,$exclude_pdd=0,$exclude_dy=0){ |
| | | //根据传入的内容调用ast方法 |
| | | $goods = $this->ast($content); |
| | | $title = ''; |
| | | $ogoods=[]; |
| | | $newGoods = []; |
| | | //判断goods是否为空 |
| | | if(empty($goods)){ |
| | | $title = $content; |
| | | } |
| | | else{ |
| | | $title = $goods['title']; |
| | | $ogoods=array_merge($ogoods,$goods); |
| | | } |
| | | //根据$title搜索各大平台的商品天猫,淘宝,京东自营,京东POP,拼多多,唯品会,抖音 |
| | | $LogicDingdanxia = new LogicDingdanxia(); |
| | | $LogicJd = new LogicJd(); |
| | | $LogicPdd = new LogicPdd(); |
| | | $LogicHaodanku = new LogicHaodanku(); |
| | | $LogicDataoke=new LogicDataoke(); |
| | | // $c=$exclude_tb+$exclude_jd+$exclude_pdd+$exclude_dy; |
| | | // $pagesize=bcdiv(40,(4-$c)==0?1:(4-$c),0)+1; |
| | | $pagesize=10; |
| | | //根据标题查询天猫商品 |
| | | $taobaoGoods = $LogicDataoke->superSearch($title,1,40,0,1); |
| | | //去除销量为0的商品并按照价格排序 |
| | | $tmGoods = array_filter($taobaoGoods,function($v){ |
| | | return $v['monthSales'] > 0&&strstr($v['shopName'],'旗舰店'); |
| | | unset($v); |
| | | }); |
| | | |
| | | $tmcsGoods=array_filter($taobaoGoods,function($v){ |
| | | return $v['monthSales'] > 0&&strstr($v['shopName'],'天猫超市'); |
| | | unset($v); |
| | | }); |
| | | |
| | | //根据标题查询京东自营商品 |
| | | $jdGoods=$LogicJd->searchGoods($title,'desc','g',0,'match',1,40); |
| | | //去除销量为0的商品并按照价格排序 |
| | | $jdGoods = array_filter($jdGoods,function($v){ |
| | | return $v['monthSales'] > 0; |
| | | }); |
| | | |
| | | $ppdGoodes=[]; |
| | | $common_relation_id='168369887871568'; |
| | | //根据标题查询拼多多商品 |
| | | if(!empty($common_relation_id)){ |
| | | $ppdGoodes=$LogicPdd->searchGoods($title,'',$common_relation_id,'',1,40,0,''); |
| | | //去除销量为0的商品并按照价格排序 |
| | | $ppdGoodes = array_filter($ppdGoodes,function($v){ |
| | | return $v['monthSales'] > 0&&strstr($v['shopName'],'旗舰店'); |
| | | }); |
| | | } |
| | | |
| | | //根据标题查询抖音商品 |
| | | $dyGoods =$LogicHaodanku->getDygoodsList('',$title,0,1,40); |
| | | //去除销量为0的商品并按照价格排序 |
| | | $dyGoods = array_filter($dyGoods,function($v){ |
| | | return $v['monthSales'] > 0; |
| | | }); |
| | | $goodsList=[]; |
| | | $goodscount=count(array_slice($tmGoods,0,$pagesize))+count(array_slice($jdGoods,0,$pagesize))+count(array_slice($ppdGoodes,0,$pagesize))+count(array_slice($dyGoods,0,$pagesize))+count(array_slice($tmcsGoods,0,$pagesize)); |
| | | if($goodscount<40){ |
| | | //如果goodscount不满足20则从天猫商品里补足20 |
| | | $needcount=40-$goodscount+10; |
| | | if($exclude_tb==0){ |
| | | $goodsList =array_merge($goodsList,array_slice($tmGoods,0,$pagesize)); |
| | | $goodsList =array_merge($goodsList,array_slice($tmcsGoods,0,$pagesize)); |
| | | } |
| | | if($exclude_jd==0){ |
| | | $goodsList =array_merge($goodsList,array_slice($jdGoods,0,$pagesize)); |
| | | } |
| | | //按照价格排序 |
| | | if(count($goodsList)>0){ |
| | | $sort1 = array_column($goodsList, 'actualPrice'); |
| | | array_multisort($sort1, SORT_ASC, $goodsList); |
| | | } |
| | | if($exclude_pdd==0){ |
| | | $goodsList =array_merge($goodsList,array_slice($ppdGoodes,0,$pagesize)); |
| | | } |
| | | if($exclude_tb==0){ |
| | | $goodsList =array_merge($goodsList,array_slice($taobaoGoods,0,$needcount)); |
| | | } |
| | | if($exclude_dy==0){ |
| | | $goodsList =array_merge($goodsList,array_slice($dyGoods,0,$pagesize)); |
| | | } |
| | | } |
| | | else{ |
| | | if($exclude_tb==0){ |
| | | $goodsList =array_merge($goodsList,array_slice($tmGoods,0,$pagesize)); |
| | | $goodsList =array_merge($goodsList,array_slice($tmcsGoods,0,$pagesize)); |
| | | } |
| | | if($exclude_jd==0){ |
| | | $goodsList =array_merge($goodsList,array_slice($jdGoods,0,$pagesize)); |
| | | } |
| | | //按照价格排序 |
| | | if(count($goodsList)>0){ |
| | | $sort1 = array_column($goodsList, 'actualPrice'); |
| | | array_multisort($sort1, SORT_ASC, $goodsList); |
| | | } |
| | | if($exclude_pdd==0){ |
| | | $goodsList =array_merge($goodsList,array_slice($ppdGoodes,0,$pagesize)); |
| | | } |
| | | if($exclude_dy==0){ |
| | | $goodsList =array_merge($goodsList,array_slice($dyGoods,0,$pagesize)); |
| | | } |
| | | } |
| | | //如果还是不满足20则从淘宝商品里补足20 |
| | | if(count($goodsList)<40){ |
| | | if($exclude_tb==0){ |
| | | $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); |
| | | $goodsList =array_merge($goodsList,array_slice($tbGoods,0,20)); |
| | | } |
| | | } |
| | | //将$ogoods插入到$goodsList第一行 |
| | | if(!empty($ogoods)){ |
| | | array_unshift($goodsList,$ogoods); |
| | | } |
| | | //取出前20个商品 |
| | | $goodsList = array_slice($goodsList,0,40); |
| | | return $goodsList; |
| | | |
| | | |
| | | } |
| | | |
| | | } |