appkey = self::$appkey; $c->secretKey = self::$secret; $req = new TbkItemInfoGetRequest; $req->setNumIids((string)$params['goods_id']); //$req->setFields("num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url"); $req->setPlatform("2"); $resp = $c->execute($req); if(!isset($resp->code)) { $goods = $resp->results->n_tbk_item[0]; return $goods; }else{ return false; } } catch(Exception $e){ echo $e->getMessage(); return false; } } public static function search($keyword){ try{ $c = new TopClient; $c->appkey = self::$appkey; $c->secretKey = self::$secret; $req = new TbkDgMaterialOptionalRequest; $req->setPageSize("1"); $req->setPageNo("1"); $req->setPlatform("2"); $req->setStartPrice("0"); $req->setQ($keyword); $req->setMaterialId('20564'); $req->setAdzoneId(self::$adzone_id); $resp = $c->execute($req); if(!isset($resp->code)) { $data = $resp->result_list->map_data; return $data[0]; } return false; } catch(Exception $e){ return false; } } public static function syncOrder($page,$stime,$time=120,$tk_status=1,$time_type='create_time',$order_count_type=1,$order_scene=1){ try{ $c = new TopClient; $c->appkey = self::$appkey; $c->secretKey = self::$secret; $req = new TbkOrderGetRequest; $req->setFields("create_time,click_time,item_title,num_iid,seller_nick,seller_shop_title,item_num,price,tk_status,order_type,income_rate,commission_rate,pay_price,pub_share_pre_fee,alipay_total_price,commission,earning_time,total_commission_rate,total_commission_fee,subsidy_rate,subsidy_fee,subsidy_type,terminal_type,tk3rd_type,trade_parent_id,trade_id,auction_category,site_id,site_name,adzone_id,adzone_name,relation_id,special_id"); $req->setStartTime($stime); //开始时间 if($tk_status != 13) $req->setSpan($time);//订单查询时间范围,最小60,最大1200,默认60,仅当查询常规订单,及三方订单时需要设置此参数 $req->setPageNo($page); $req->setPageSize("100"); $req->setTkStatus($tk_status); //订单状态,1: 全部订单,3:订单结算,12:订单付款, 13:订单失效,14:订单成功; $req->setOrderQueryType($time_type); //订单查询类型,创建时间“create_time”,或结算时间“settle_time” $req->setOrderScene($order_scene); //1常规订单包含淘宝客所有的订单数据,含渠道,及会员运营订单,但不包含3方分成,及维权订单 $req->setOrderCountType($order_count_type); //订单数据统计类型,1: 2方订单,2: 3方订单,如果不设置,或者设置为1,表示2方订单 $resp = $c->execute($req); if(isset($resp->results->n_tbk_order) && !empty($resp->results->n_tbk_order)) { $data = $resp->results; $data = json_decode(json_encode($data),true); if(isset($data['n_tbk_order']['trade_id'])){ $data['n_tbk_order'] = [0=>$data['n_tbk_order']]; } return $data['n_tbk_order']; } return false; } catch(Exception $e){ return false; } } /** * 新订单同步, +付款时间拉取 */ public static function syncOrderNew($page, $stime, $etime, $time_type=2, $tk_status, $order_scene=1, $position_index=''){ try{ $c = new TopClient; $c->appkey = self::$appkey; $c->secretKey = self::$secret; $req = new TbkOrderDetailsGetRequest; $req->setQueryType($time_type); //1:按照订单淘客创建时间查询,2:按照订单淘客付款时间查询,3:按照订单淘客结算时间查询 if($position_index) $req->setPositionIndex($position_index); $req->setPageSize("100"); //$req->setMemberType("2"); //2:二方,3:三方,不传,表示所有角色 if($tk_status>0) $req->setTkStatus($tk_status); //12-付款,13-关闭,14-确认收货,15-结算成功;不传,表示所有状态 $req->setEndTime($etime); $req->setStartTime($stime); $req->setJumpType("1"); //-1: 向前翻页,1:向后翻页 $req->setPageNo($page); $req->setOrderScene($order_scene);//1:常规订单,2:渠道订单,3:会员运营订单,默认为1 $resp = $c->execute($req); $result = array(); if(isset($resp->data->results->publisher_order_dto)){ $data = json_decode(json_encode($resp->data), true); $result['position_index'] = $data['position_index']; if(isset($data['results']['publisher_order_dto']['item_id'])){ $result['data'][0] = $data['results']['publisher_order_dto']; }else{ $result['data'] = $data['results']['publisher_order_dto']; } }else{ //echo "\n没数据了~"; } return $result; } catch(Exception $e){ return false; } } public static function syncVqOrder($page, $start_time, $order_count_type=1, $biz_type=1){ try{ $c = new TopClient; $c->appkey = self::$appkey; $c->secretKey = self::$secret; $req = new TbkRelationRefundRequest; $search_option = new TopApiRefundRptOption; $search_option->page_size="100"; $search_option->search_type="3"; //1-维权发起时间,2-订单结算时间(正向订单),3-维权完成时间,4-订单创建时间 $search_option->refund_type=$order_count_type; //1 表示2方,2表示3方 $search_option->start_time=$start_time; $search_option->page_no=$page; $search_option->biz_type=$biz_type; //1代表渠道关系id,2代表会员关系id $req->setSearchOption(json_encode($search_option)); $resp = $c->execute($req); if(isset($resp->result->data->results) && !empty($resp->result->data->results)){ $data = $resp->result->data->results; $data = json_decode(json_encode($data),true); return $data['result']; }else{ return false; } } catch(Exception $e){ return false; } } }