|
|
@@ -21,7 +21,10 @@ class Apiexpress extends Start_Controller {
|
|
|
if($arg == 'search')
|
|
|
{
|
|
|
$this->search();
|
|
|
- }else{
|
|
|
+ }elseif($arg == 'cxddcs'){
|
|
|
+ $this->searchcs();
|
|
|
+ }
|
|
|
+ else{
|
|
|
$this->_a();
|
|
|
}
|
|
|
}
|
|
|
@@ -246,5 +249,309 @@ class Apiexpress extends Start_Controller {
|
|
|
die($this->logic_tools->ret_json(1,"success",$ret_arr));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /* 搜索订单状态和快递信息接口
|
|
|
+ * @param $arg_array[0] string 请求店铺
|
|
|
+ * @param $arg_array[1] string 请求单号
|
|
|
+ */
|
|
|
+ public function searchcs(){
|
|
|
+ $data = file_get_contents('PHP://input');
|
|
|
+ $data = json_decode($data, true);
|
|
|
+ $shop = isset($data['shop'])?$data['shop']:"";
|
|
|
+ $order_no = isset($data['order_no'])?$data['order_no']:"";
|
|
|
+ $type = isset($data['type'])?$data['type']:"";
|
|
|
+ $apply_time = isset($data['time'])?$data['time']:0;
|
|
|
+
|
|
|
+ $jiami_str = isset($data['key'])?$data['key']:"";
|
|
|
+
|
|
|
+ $now_time = time();
|
|
|
+ if(strlen( $apply_time."") != 10){
|
|
|
+ die($this->logic_tools->ret_json(-1,"参数异常"));
|
|
|
+ }
|
|
|
+ if(empty($shop)){
|
|
|
+ die($this->logic_tools->ret_json(-1,"请求店铺异常"));
|
|
|
+ }
|
|
|
+ $shop_key = $this->logic_tools->getshopname($shop);
|
|
|
+ if(empty($jiami_str)){
|
|
|
+ die($this->logic_tools->ret_json(-1,"秘钥信息不存在"));
|
|
|
+ }
|
|
|
+ $jiemi_str = $this->logic_tools->toolsjiemi($jiami_str,$this->key,$this->iv);
|
|
|
+ if(empty($shop_key)){
|
|
|
+ die($this->logic_tools->ret_json(-1,"该店铺的秘钥不存在"));
|
|
|
+ }
|
|
|
+ $jiemi_arr = explode("+",$jiemi_str);
|
|
|
+ $jiemi_key = isset($jiemi_arr[0])?$jiemi_arr[0]:"";
|
|
|
+ $jiemi_time = isset($jiemi_arr[1])?$jiemi_arr[1]:"";
|
|
|
+ // if((int)$jiemi_time != (int)$apply_time){
|
|
|
+ // die($this->logic_tools->ret_json(-1,"请求超时"));
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if( $now_time - $apply_time > 100){
|
|
|
+ // die($this->logic_tools->ret_json(-1,"请求已超时"));
|
|
|
+ // }
|
|
|
+ if($jiemi_key != $shop_key){
|
|
|
+ die($this->logic_tools->ret_json(-1,"该店铺的秘钥不正确"));
|
|
|
+ }
|
|
|
+ if(empty($order_no) ){
|
|
|
+ die($this->logic_tools->ret_json(-1,"请求查询的单号不能为空"));
|
|
|
+ }
|
|
|
+ $table_name = $this->logic_tools->getOrderTable($shop);
|
|
|
+ if(empty($table_name)){
|
|
|
+ die($this->logic_tools->ret_json(-1,"店铺未开通此功能!!!"));
|
|
|
+ }
|
|
|
+ // $type == 2 为运单号
|
|
|
+ if($type == 2){
|
|
|
+ $info = $this->logic_order->getInfoByTableName($table_name,"waybill = '".$order_no. "' and shop = ".$shop,"id,number,orderinfo,express,excontent,expressstate,waybill,dtime,printtime,client,name,country,province,city,address,address2,street,phone,zipcode,dlzemailtime");
|
|
|
+ //当检索不到运单号时,返回订单已经备货了
|
|
|
+ if(empty($info)){
|
|
|
+ die($this->logic_tools->ret_json(1,"success",[
|
|
|
+ "order_no"=>"",
|
|
|
+ 'icon'=>"",
|
|
|
+ "express_name"=>"" ,
|
|
|
+ "waybill"=>$order_no,
|
|
|
+ "preparing"=>[
|
|
|
+ "desc"=>"The Order Has Been Created And TheMerchant lspreparing Your Order.",
|
|
|
+ "status"=>1,
|
|
|
+ "date"=>"",
|
|
|
+ ],//店家处理
|
|
|
+ "shipped"=>[
|
|
|
+ "desc"=>"",
|
|
|
+ "status"=>0,
|
|
|
+ "date"=>"",
|
|
|
+ ],//工厂处理
|
|
|
+ "in_transit"=> [
|
|
|
+ "desc"=>"",
|
|
|
+ "status"=>0,
|
|
|
+ "date"=>"",
|
|
|
+ ],//快递发货
|
|
|
+ "delivered"=>[
|
|
|
+ "desc"=>"",
|
|
|
+ "status"=>0,
|
|
|
+ "date"=>"",
|
|
|
+ ],//客户收货
|
|
|
+ "express_trace"=>[],//快递跟踪信息
|
|
|
+ "address_info"=>[
|
|
|
+ "client"=>"",//客户姓名
|
|
|
+ "name"=>"",//收件人姓名
|
|
|
+ "country"=>"",//国家
|
|
|
+ "province"=>"",//省份
|
|
|
+ "city"=>"",//城市
|
|
|
+ "address"=>"",//地址
|
|
|
+ "address2"=>"",//地址
|
|
|
+ "street"=>"",//街道
|
|
|
+ "phone"=>"",//电话
|
|
|
+ "zipcode"=>"",//邮编
|
|
|
+ ]
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $info = $this->logic_order->getInfoByTableName($table_name,"orderinfo = '".$shop.$order_no. "' and shop = ".$shop,"id,number,orderinfo,express,excontent,expressstate,waybill,dtime,printtime,client,name,country,province,city,address,address2,street,phone,zipcode,dlzemailtime,library,librarytime,printtime");
|
|
|
+ if(empty($info)){
|
|
|
+ die($this->logic_tools->ret_json(-1,"未查询到相关快递信息"));
|
|
|
+ }
|
|
|
+ if(empty($info['waybill']) && ($info['printtime'])){
|
|
|
+ //如果没有运单号,则返回订单已经备货了
|
|
|
+ die($this->logic_tools->ret_json(1,"success",[
|
|
|
+ "order_no"=>$info['number'],
|
|
|
+ 'icon'=>"",
|
|
|
+ "express_name"=>"" ,
|
|
|
+ "waybill"=>"",
|
|
|
+ "preparing"=>[
|
|
|
+ "desc"=>"The Order Has Been Created And TheMerchant lspreparing Your Order.",
|
|
|
+ "status"=>1,
|
|
|
+ "date"=>"",
|
|
|
+ ],//店家处理
|
|
|
+ "shipped"=>[
|
|
|
+ "desc"=>"",
|
|
|
+ "status"=>0,
|
|
|
+ "date"=>"",
|
|
|
+ ],//工厂处理
|
|
|
+ "in_transit"=> [
|
|
|
+ "desc"=>"",
|
|
|
+ "status"=>0,
|
|
|
+ "date"=>"",
|
|
|
+ ],//快递发货
|
|
|
+ "delivered"=>[
|
|
|
+ "desc"=>"",
|
|
|
+ "status"=>0,
|
|
|
+ "date"=>"",
|
|
|
+ ],//客户收货
|
|
|
+ "express_trace"=>[],//快递跟踪信息
|
|
|
+ "address_info"=>[
|
|
|
+ "client"=>$info['client'],//客户姓名
|
|
|
+ "name"=>$info['name'],//收件人姓名
|
|
|
+ "country"=>$info['country'],//国家
|
|
|
+ "province"=>$info['province'],//省份
|
|
|
+ "city"=>$info['city'],//城市
|
|
|
+ "address"=>$info['address'],//地址
|
|
|
+ "address2"=>$info['address2'],//地址
|
|
|
+ "street"=>$info['street'],//街道
|
|
|
+ "phone"=>$info['phone'],//电话
|
|
|
+ "zipcode"=>$info['zipcode'],//邮编
|
|
|
+ ]
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $receive_time = "";//客户签到时间
|
|
|
+ $shipping_time = "";//快递接受发货时间
|
|
|
+ $express_trace = [];
|
|
|
+ $express_info = $this->express->read($info['express']);
|
|
|
+
|
|
|
+ if(!empty($info['excontent'])){
|
|
|
+ $tmp_arr = explode("<br />",$info['excontent']);
|
|
|
+ if(!empty($tmp_arr)){
|
|
|
+ $tc_tmp_str = array_pop($tmp_arr);
|
|
|
+ if(empty($tmp_arr)){
|
|
|
+ $express_trace = [
|
|
|
+ $tc_tmp_str,
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ $re_arr = array_reverse($tmp_arr);
|
|
|
+ if(!isset($re_arr[0])){
|
|
|
+ $this->logic_ding->sendToDing("Apiexpress接口95行异常".json_encode($info,JSON_UNESCAPED_UNICODE));
|
|
|
+ }
|
|
|
+ if(strpos($re_arr[0],"[") !== false){
|
|
|
+ $shipping_time_arr = explode("[",$re_arr[0] ) ;
|
|
|
+ $shipping_time = $shipping_time_arr[0];
|
|
|
+ if($info['expressstate'] == 6){
|
|
|
+ $receive_tmp_arr = explode("[",$tmp_arr[0] ) ;
|
|
|
+ $receive_time = $receive_tmp_arr[0];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $shipping_time = date("Y-m-d H:i:s",$info['dlzemailtime']);
|
|
|
+ if($info['expressstate'] == 6){
|
|
|
+
|
|
|
+ $receive_time = -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $express_trace = $re_arr;
|
|
|
+ }
|
|
|
+
|
|
|
+ ob_clean();
|
|
|
+ }else{
|
|
|
+ die($this->logic_tools->ret_json(-1,"物流信息存储异常"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }else{
|
|
|
+ die($this->logic_tools->ret_json(-1,"运单时间太久,暂无法查询"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(empty($info['librarytime'])){
|
|
|
+ $shipped = [
|
|
|
+ "desc"=>"",
|
|
|
+ "status"=>0,
|
|
|
+ "date"=>"",
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ $shipped = [
|
|
|
+ "desc"=>"Courier company picked up the package",
|
|
|
+ "status"=>1,
|
|
|
+ "date"=>date("Y-m-d H:i:s",$info['librarytime']),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $in_transit = [
|
|
|
+ "desc"=>"",
|
|
|
+ "status"=>0,
|
|
|
+ "date"=>"",
|
|
|
+ ];
|
|
|
+ //在途 没有签收 并且 出库了
|
|
|
+ if(empty($receive_time) && $info['librarytime'] > 0){
|
|
|
+ $in_transit = [
|
|
|
+ "desc"=>"",
|
|
|
+ "status"=>1,
|
|
|
+ "date"=>"",
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($receive_time)){
|
|
|
+ $received = [
|
|
|
+ "desc"=>"",
|
|
|
+ "status"=>0,
|
|
|
+ "date"=>"",
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ if($receive_time < 0){
|
|
|
+ $received = [
|
|
|
+ "desc"=>"Order signed for successfully",
|
|
|
+ "status"=>1,
|
|
|
+ "date"=>0,
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ $received = [
|
|
|
+ "desc"=>"Order signed for successfully",
|
|
|
+ "status"=>1,
|
|
|
+ "date"=>$receive_time,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $icon = 7;
|
|
|
+ $final_express_name = $express_name = strtolower($express_info['iscode']);
|
|
|
+ if(strpos($express_name,"usps") !== false){
|
|
|
+ $icon = 1;
|
|
|
+ $final_express_name = "usps";
|
|
|
+ }
|
|
|
+ if(strpos($express_name,"dhl") !== false){
|
|
|
+ $icon = 2;
|
|
|
+ $final_express_name = "dhl";
|
|
|
+ }
|
|
|
+ if(strpos($express_name,"ups") !== false){
|
|
|
+ $icon = 3;
|
|
|
+ $final_express_name = "ups";
|
|
|
+ }
|
|
|
+ if(strpos($express_name,"fedex") !== false){
|
|
|
+ $icon = 4;
|
|
|
+ $final_express_name = "fedex";
|
|
|
+ }
|
|
|
+ if(strpos($express_name,"aramex") !== false){
|
|
|
+ $icon = 5;
|
|
|
+ $final_express_name = "aramex";
|
|
|
+ }
|
|
|
+ if(strpos($express_name,"ges") !== false){
|
|
|
+ $icon = 6;
|
|
|
+ $final_express_name = "ges";
|
|
|
+ }
|
|
|
+
|
|
|
+ $ret_arr = [
|
|
|
+ "order_no"=>$order_no,
|
|
|
+ 'icon'=>$icon,
|
|
|
+ "express_name"=>strtoupper($final_express_name) ,
|
|
|
+ "waybill"=>$info['waybill'],
|
|
|
+ "preparing"=>[
|
|
|
+ "desc"=>"The Order Has Been Created And TheMerchant lspreparing Your Order.",
|
|
|
+ "status"=>1,
|
|
|
+ "date"=>"",
|
|
|
+ ],//店家处理
|
|
|
+ "shipped"=>$shipped,//工厂处理
|
|
|
+ "in_transit"=> $in_transit,//快递发货
|
|
|
+ "delivered"=>$received,//客户收货
|
|
|
+ "express_trace"=>$express_trace,//快递跟踪信息
|
|
|
+ "address_info"=>[
|
|
|
+ "client"=>$info['client'],//客户姓名
|
|
|
+ "name"=>$info['name'],//收件人姓名
|
|
|
+ "country"=>$info['country'],//国家
|
|
|
+ "province"=>$info['province'],//省份
|
|
|
+ "city"=>$info['city'],//城市
|
|
|
+ "address"=>$info['address'],//地址
|
|
|
+ "address2"=>$info['address2'],//地址
|
|
|
+ "street"=>$info['street'],//街道
|
|
|
+ "phone"=>$info['phone'],//电话
|
|
|
+ "zipcode"=>$info['zipcode'],//邮编
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ die($this->logic_tools->ret_json(1,"success",$ret_arr));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|