| | |
| | | $new_page=1; |
| | | while(count($list)<20){ |
| | | foreach($cids as $key=>$value){ |
| | | $jd_id_list = $LogicPdd->searchGoods('','',$common_relation_id,'',1,5,0,$cids[$key]); |
| | | $jd_id_list = $LogicPdd->searchGoods('','',$common_relation_id,'',1,10,0,$cids[$key]); |
| | | //将多个jd_id_list数组合并成一个数组 |
| | | $list = array_merge($list,$jd_id_list); |
| | | $list = array_merge($list,array_slice($jd_id_list, 0, 5)); |
| | | } |
| | | $new_page=$new_page+1; |
| | | } |
| | |
| | | $this->success('获取成功',['list'=>$list]); |
| | | } |
| | | |
| | | public function compare_good(){ |
| | | $content = request()->param('content',''); |
| | | if (empty($content)) $this->error('内容不能为空'); |
| | | |
| | | $LogicSearch = new LogicSearch(); |
| | | $user = $this->auth->getUser(); |
| | | $common_relation_id = $user['common_relation_id']; |
| | | $info = $LogicSearch->compare_good($content,$common_relation_id); |
| | | $this->success('获取成功',['list'=>$info]); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | return $goods; |
| | | } |
| | | |
| | | public function compare_good($content,$common_relation_id){ |
| | | //根据传入的内容调用ast方法 |
| | | $goods = $this->ast($content); |
| | | $title = ''; |
| | | //判断goods是否为空 |
| | | if(empty($goods)){ |
| | | $title = $content; |
| | | } |
| | | else{ |
| | | $title = $goods['title']; |
| | | } |
| | | //根据$title搜索各大平台的商品天猫,淘宝,京东自营,京东POP,拼多多,唯品会,抖音 |
| | | $LogicDingdanxia = new LogicDingdanxia(); |
| | | $LogicJd = new LogicJd(); |
| | | $LogicPdd = new LogicPdd(); |
| | | $LogicHaodanku = new LogicHaodanku(); |
| | | $LogicDataoke=new LogicDataoke(); |
| | | //根据标题查询天猫商品 |
| | | $newGoods = $LogicDataoke->superSearch($title,1,5,0,1); |
| | | //根据标题查询京东自营商品 |
| | | $newGoods =array_merge($newGoods,$LogicJd->searchGoods($title,'desc','g',0,'match',1,5)); |
| | | //根据标题查询拼多多商品 |
| | | $ppdGoodes=$LogicPdd->searchGoods($title,'',$common_relation_id,'',1,10,0,''); |
| | | $newGoods =array_merge($newGoods,array_slice($ppdGoodes,0,5)); |
| | | //根据标题查询抖音商品 |
| | | $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')); |
| | | } |
| | | //将newGoods按照价格排序 |
| | | $sort1 = array_column($newGoods, 'actualPrice'); |
| | | |
| | | array_multisort($sort1, SORT_ASC, $newGoods); |
| | | log::write("goodsList:".json_encode($newGoods)); |
| | | //取出前20个商品 |
| | | $goodsList = array_slice($newGoods,0,20); |
| | | return $goodsList; |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * @return void |
| | | */ |
| | | public function superSearch($keyWords,$page = 1,$page_size,$sort) |
| | | public function superSearch($keyWords,$page = 1,$page_size,$sort,$tmall=0) |
| | | { |
| | | $params = $this->setParams(['type'=>"0",'keyWords'=>$keyWords,'type'=>0,'pageId'=>$page,'pageSize'=>$page_size,'sort'=>$sort]); |
| | | $params = $this->setParams(['type'=>"0",'keyWords'=>$keyWords,'type'=>0,'pageId'=>$page,'pageSize'=>$page_size,'sort'=>$sort,'tmall'=>$tmall]); |
| | | $result = send_get(self::request_url['super_search_url'],$params); |
| | | if(empty($result) || $result['code'] != 0) return []; |
| | | $list = $result['data']['list']; |
| | |
| | | $params = [ |
| | | 'keyword' => $keyword, |
| | | 'opt_id' => $opt_id, |
| | | 'limit' => $pageSize, |
| | | 'page_size' => $pageSize, |
| | | 'custom_parameters' => '{"uid":"'.$common_relation_id.'"}', |
| | | 'with_coupon' => empty($with_coupon) ? '' : ($with_coupon == 1 ? "true" : "false"), |
| | | 'page' => $page, |