load->_model("Model_apitt","apitt"); } public function getData($info,$type = 'CBT'){ if(empty($info)){ return $g = [ 'x'=>0, 'Description'=>'订单信息不存在', ]; } $shop_info = $this->db->from('shop')->where('id', $info['shop'])->get()->result_array(); if(empty($shop_info)){ return [ 'x'=>0, 'Description'=>'该商铺不存在', ]; } if($type == 'CBT'){ //获取快递服务信息 $res = $this->getExpressCompany($info,$shop_info[0]); if($res['x'] == 0){ return $res; } $res1 = $this->createExpressLabel($res['data'],$shop_info[0]); if($res1['x'] == 0){ return $res1; } $res2 = $this->downloadExpressLabel($res['data'],$shop_info[0]); if($res2['x'] == 0){ return $res2; } return [ 'x'=>1, 'msg'=>'获取成功', 'data'=>$info ]; }else if($type == 'FBT'){ $res = $this->apitt->get_data([$info['orderinfo']],$shop_info[0]); echo "
";
print_r($res);
die;
}else{
return [
'x'=>0,
'Description'=>'暂不支持该快递类型',
];
}
}
private function getOrderDetail($info,$shop_info){
}
//获取订单承运的快递商
private function getExpressCompany($info,$shop_info){
$res = $this->apitt->getExpressCompany($info,$shop_info);
if($res['code'] != 0){
return [
'x'=>0,
'Description'=>$res['message'],
];
}
$extra_info = json_decode($info['extra_info'],true);
$extra_info['server_info'] = $res['data'];
$info['extra_info'] = json_encode($extra_info,JSON_UNESCAPED_UNICODE);
$this->db->update('fullordertt', [
'extra_info' => $info['extra_info']
], ['id' => $info['id']]) ;
return [
'x'=>1,
'msg'=>'获取成功',
'data'=>$info
];
}
//创建发货单和运单标签
private function createExpressLabel($info,$shop_info){
$res = $this->apitt->createExpressLabel($info,$shop_info);
if($res['code'] != 0){
return [
'x'=>0,
'Description'=>$res['message'],
];
}
$extra_info = json_decode($info['extra_info'],true);
$extra_info['label_info'] = $res['data'];
$info['extra_info'] = json_encode($extra_info,JSON_UNESCAPED_UNICODE);
$this->db->update('fullordertt', [
'extra_info' => $info['extra_info']
], ['id' => $info['id']]) ;
return [
'x'=>1,
'msg'=>'获取成功',
'data'=>$info
];
}
//下载快递面单
private function downloadExpressLabel($info,$shop){
$extra_info = json_decode($info['extra_info'],true);
$packageid = $extra_info['label_info']['packageid'];
$res = $this->apitt->downloadLabel($packageid,$shop,$info);
if($res['code'] != 0){
return [
'x'=>0,
'Description'=>$res['message'],
];
}
$extra_info = json_decode($info['extra_info'],true);
$extra_info['express_info'] = $res['data'];
$info['extra_info'] = json_encode($extra_info,JSON_UNESCAPED_UNICODE);
$this->db->update('fullordertt', [
'extra_info' => $info['extra_info']
], ['id' => $info['id']]) ;
return [
'x'=>1,
'msg'=>'获取成功',
'waybill'=>$res['data']['tracking_number'],
'label'=>$res['data']['doc_url'],
];
}
}