|
@@ -410,7 +410,82 @@ function __construct(){
|
|
|
$post['slpx'] = $matching['wcslpx'];
|
|
|
return $post;
|
|
|
}
|
|
|
-
|
|
|
+ public function getExpressCompany($shop,$info){
|
|
|
+ $url = 'https://open-api.tiktokglobalshop.com';
|
|
|
+ $link = "/fulfillment/202309/orders/".trim($info['orderinfo'])."/shipping_services/query";
|
|
|
+ $time = time();
|
|
|
+ $extra_text = json_decode($info['extra_text'],true);
|
|
|
+ $order_line_item_ids = [];
|
|
|
+ foreach($extra_text['line_items'] as $v)
|
|
|
+ {
|
|
|
+ $order_line_item_ids[] = $v['id'];
|
|
|
+ }
|
|
|
+ $post = [
|
|
|
+ "order_line_item_ids"=>$order_line_item_ids,
|
|
|
+ "weight"=>[
|
|
|
+ "value"=>"400",
|
|
|
+ "unit"=>"GRAM"
|
|
|
+ ],
|
|
|
+ "dimensions"=>[
|
|
|
+ "length"=> "15",
|
|
|
+ "width"=> "10",
|
|
|
+ "height"=> "5",
|
|
|
+ "unit"=> "CM"
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ $queryParams['shop_cipher'] =$shop['shop_cipher'];
|
|
|
+ $queryParams['app_key'] =$shop['app_key'];
|
|
|
+ $queryParams['timestamp'] =$time;
|
|
|
+ $link .= '?'.http_build_query($queryParams);
|
|
|
+ $sign = $this->sign($link,$shop['app_secret'],$post);
|
|
|
+ $url .= $link.'&sign='.$sign;
|
|
|
+ $headers = array('Content-Type: application/json','x-tts-access-token:'.$shop['token']);
|
|
|
+ $res = $this->su_curl($post,$url,$headers);
|
|
|
+ $this->logic_ding->sendToDing($info['number']."获取TT快递服务信息".$res);
|
|
|
+ $res = json_decode($res,true);
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+ //创建运单
|
|
|
+ public function createLabel($info,$shop){
|
|
|
+ $url = 'https://open-api.tiktokglobalshop.com';
|
|
|
+ $link = "/fulfillment/202309/packages";
|
|
|
+ $time = time();
|
|
|
+ $extra_text = json_decode($info['extra_text'],true);
|
|
|
+ //快递服务商
|
|
|
+ $server_info = $extra_text['server_info'];
|
|
|
+ $post = [
|
|
|
+ 'order_id'=>$server_info['order_id'],
|
|
|
+ "order_line_item_ids"=>$server_info['order_line_id'],
|
|
|
+ "dimension"=>$server_info['dimension'],
|
|
|
+ "shipping_service_id"=>$server_info['shipping_services'][0]['shipping_service_id'],
|
|
|
+ "weight"=>$server_info['weight'],
|
|
|
+ ];
|
|
|
+ $queryParams['shop_cipher'] =$shop['shop_cipher'];
|
|
|
+ $queryParams['app_key'] =$shop['app_key'];
|
|
|
+ $queryParams['timestamp'] =$time;
|
|
|
+ $link .= '?'.http_build_query($queryParams);
|
|
|
+ $sign = $this->sign($link,$shop['app_secret'],$post);
|
|
|
+ $url .= $link.'&sign='.$sign;
|
|
|
+ $headers = array('Content-Type: application/json','x-tts-access-token:'.$shop['token']);
|
|
|
+ $res = $this->su_curl($post,$url,$headers);
|
|
|
+ $this->logic_ding->sendToDing($info['number']."获取TT快递服务信息".$res);
|
|
|
+ $res = json_decode($res,true);
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+ //下载快递面单
|
|
|
+ public function downloadLabel($package_id,$shop,$info){
|
|
|
+ $url = 'https://open-api.tiktokglobalshop.com';
|
|
|
+ $link = '/fulfillment/202309/packages/'.$package_id.'/shipping_documents';
|
|
|
+ $time = time();
|
|
|
+ $link .= '?shop_cipher='.$shop['shop_cipher'].'&app_key='.$shop['app_key'].'×tamp='.$time."&document_type=SHIPPING_LABEL";
|
|
|
+ $sign = $this->sign($link,$shop['app_secret'],'');
|
|
|
+ $url .= $link.'&sign='.$sign;
|
|
|
+ $headers = array('Content-Type: application/json','x-tts-access-token:'.$shop['token']);
|
|
|
+ $res = $this->su_curl('',$url,$headers,$date_type='json',$timeout=300,$httptype="GET");
|
|
|
+ $this->logic_ding->sendToDing($info['number']."获取TT快递服务信息".$res);
|
|
|
+ $res = json_decode($res,true);
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
public function sign($url,$appSecret,$body='')
|
|
|
{
|
|
|
// 解析URL获取查询参数
|