$v['order_id'],'state'=>$v['order_status'],'userid'=>$v['buyer_login_id'],'fundstate'=>$fund_status); } } return $data; } } public function get_order($orderid,$code) //详情 { $ch = curl_init(); //$url = 'http://39.100.97.180/start/data'; $url = 'http://39.100.97.180/smt.php'; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); //设置post数据 $post = array(); $post['order_id'] = 1; $post['orderid'] = $orderid; $post['code'] = $code; curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post)); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); if(isset($res)) { return $res; } } public function get_out($whlabel,$all,$orderinfo,$ex,$code) //发货声明 { $ch = curl_init(); //$url = 'http://39.100.97.180/start/out'; $url = 'http://39.100.97.180/smt.php'; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); //设置post数据 $post = array(); $post['order_out'] = 1; $post['whlabel'] = $whlabel; $post['all'] = $all; $post['orderinfo'] = $orderinfo; $post['ex'] = $ex; $post['code'] = $code; curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post)); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); if(isset($res)) { return $res; } } public function get_obtain($orderinfo,$code) //查询声明 { $ch = curl_init(); //$url = 'http://39.100.97.180/start/obtain'; $url = 'http://39.100.97.180/smt.php'; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); //设置post数据 $post = array(); $post['statement'] = 1; $post['orderinfo'] = $orderinfo; $post['code'] = $code; curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post)); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); if(isset($res)) { return $res; } } public function get_editout($oldwhlabel,$whlabel,$all,$orderinfo,$oldex,$ex,$code) //更改声明 { $ch = curl_init(); //$url = 'http://39.100.97.180/start/editout'; $url = 'http://39.100.97.180/smt.php'; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); //设置post数据 $post = array(); $post['editstatement'] = 1; $post['oldwhlabel'] = $oldwhlabel; $post['whlabel'] = $whlabel; $post['all'] = $all; $post['orderinfo'] = $orderinfo; $post['oldex'] = $oldex; $post['ex'] = $ex; $post['code'] = $code; curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post)); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); if(isset($res)) { return $res; } } public function get_msg($shopid,$userid,$content,$code,$order) //发送站内信 { $ch = curl_init(); //$url = 'http://39.100.97.180/start/msg'; $url = 'http://39.100.97.180/smt.php'; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); //设置post数据 $post = array(); $post['shopid'] = $shopid; $post['userid'] = $userid; $post['message_type'] = 'order'; $post['content'] = $content; $post['code'] = $code; $post['order'] = $order; curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post)); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); if(isset($res)) { return $res; } } public function get_commoditylist($page,$size,$code) //获取商品列表 { $ch = curl_init(); //$url = 'http://39.100.97.180/start/commoditylist'; $url = 'http://39.100.97.180/smt.php'; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); //设置post数据 $post = array(); $post['order_commodity_list'] = 1; $post['page'] = $page; $post['size'] = $size;//小于等于100 $post['type'] = 'onSelling';//商品业务状态,目前提供5种,输入参数分别是:上架:onSelling ;下架:offline ;审核中:auditing ;审核不通过:editingRequired;客服删除:service_delete $post['code'] = $code; curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post)); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); if(isset($res)) { return $res; } } public function get_commodityread($data,$code) //商品详情 { $ch = curl_init(); //$url = 'http://39.100.97.180/start/commodityread'; $url = 'http://39.100.97.180/smt.php'; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); //设置post数据 $post = array(); $post['order_commodity_read'] = 1; $post['data'] = $data; $post['code'] = $code; curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post)); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); $sku = array(); if(isset($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku'])) { $gg = array(); if(!isset($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku'][0])) { foreach ($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['aeop_s_k_u_property_list']['aeop_sku_property'] as $vg) { if(isset($vg['property_value_definition_name'])) { $gg[$vg['property_value_id']] = $vg['property_value_definition_name']; } } $code = isset($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['sku_code'])?$res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['sku_code']:''; $sku[$res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['id']] = array('skuid'=>$res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['id'],'code'=>$code); } else { foreach ($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku'] as $vv) { foreach ($vv['aeop_s_k_u_property_list']['aeop_sku_property'] as $vg) { if(isset($vg['property_value_definition_name'])) { $gg[$vg['property_value_id']] = $vg['property_value_definition_name']; } } $code = isset($vv['sku_code'])?$vv['sku_code']:''; $sku[$vv['id']] = array('skuid'=>$vv['id'],'code'=>$code); } } $img = explode(';',$res['image_u_r_ls']); $title = ''; if(isset($res['subject_list']['subject'][14]['value'])) { $title = $res['subject_list']['subject'][14]['value']; } else if(isset($res['subject_list']['subject']['locale'])) { if($res['subject_list']['subject']['locale'] == 'en_US') { $title = $res['subject_list']['subject']['value']; } } else { foreach ($res['subject_list']['subject'] as $rv) { if($rv['locale'] == 'en_US') { $title = $rv['value']; } } } @$mid = array('productid'=>$res['product_id'],'img'=>$img[0],'title'=>$title,'type'=>$res['product_status_type'],'cid'=>$res['category_id'],'sku'=>$sku,'gg'=>$gg); return $mid; } else { $myfile = fopen("./data/errors/txt/".$data.'-'.date('Ymd_His',time()).".txt", "w"); $txt = json_encode($res); fwrite($myfile,$txt); fclose($myfile); return 1;exit; } } public function get_commoditysku($data,$code) //商品类目(sku) { $ch = curl_init(); //$url = 'http://39.100.97.180/start/commoditysku'; $url = 'http://39.100.97.180/smt.php'; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); //设置post数据 $post = array(); $post['order_commodity_sku'] = 1; $post['sku'] = $data; $post['code'] = $code; curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post)); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); if(isset($res)) { return $res; } } public function get_logistics9($data,$orderinfo,$express,$al) //速卖通物流接口 { $ch = curl_init(); //$url = 'http://39.100.97.180/start/logistics'; $url = 'http://39.100.97.180/smt.php'; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); //设置post数据 $post = array(); $post['logistics'] = 1; $post['waybill'] = $waybill; $post['ESCROW'] = 'ESCROW'; $post['orderinfo'] = $orderinfo; $post['express'] = $express; $post['al'] = $al; curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post)); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); if(isset($res)) { return $res; } } public function get_logistics($v) //阿里云云市场 { $host = "https://ali-deliver.showapi.com"; $path = "/showapi_expInfo"; $method = "GET"; $appcode = "008b9815e9fa49c49ba3a95f83f662f6"; $headers = array(); array_push($headers, "Authorization:APPCODE " . $appcode); $waybill = ($v['express'] == 'usps')?str_replace(array('420',$v['zipcode']),array('',''),$v['waybill']):$v['waybill']; $querys = "com=".$v['cxcode']."&nu=".$waybill; $bodys = ""; $url = $host . $path . "?" . $querys; $v['exstate'] = (isset($v['exstate']))?$v['exstate']:'';//非订单查询无此属性 $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //curl_setopt($curl, CURLOPT_HEADER, true); if (1 == strpos("$".$host, "https://")) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); } $read = json_decode(curl_exec($curl),true); if(!isset($read['showapi_res_body']['status'])) { $content = (isset($read['showapi_res_body']['msg']))?date('Y-m-d H',time()).'-'.$read['showapi_res_body']['msg']:date('Y-m-d H',time()).'-'.'查询失败'; $list = array('content'=>$content,'f'=>0);//非正常只更改详情信息 } else if($read['showapi_res_body']['status'] > 1 && $read['showapi_res_body']['status'] != $v['exstate']) { $exstate = $read['showapi_res_body']['status']; $content = $read['showapi_res_body']['data'][0]['time'].' - '.$read['showapi_res_body']['data'][0]['context']; $xq = ''; foreach($read['showapi_res_body']['data'] as $v) { $xq .= $v['time'].' '.$v['context'].'
'; } if($exstate == 2) { $exstate = 3; } else if($exstate == 3) { $exstate = 5; } else if($exstate == 4) { $exstate = 6; } else if($exstate == 9 || $exstate == 5) { $exstate = 1; } $list = array('exstate'=>$exstate,'content'=>$content,'f'=>1,'data'=>$xq);//正常可发送站内信 } else { $content = (isset($read['showapi_res_body']['msg']))?date('Y-m-d H',time()).'-'.$read['showapi_res_body']['msg']:date('Y-m-d H',time()).'-'.'查询失败'; $list = array('content'=>$content,'f'=>0);//非正常只更改详情信息 } return $list; //status : -1 待查询 0 查询异常 1 暂无记录 2 在途中 3 派送中 4 已签收 5 用户拒签 6 疑难件 7 无效单 8 超时单 9 签收失败 10 退回 } public function get_logistics1($data) //快递100 { $key = 'jUQDydMC8647';//客户授权key $customer = '2C11630697BD4A3F260479649ADD9236'; //查询公司编号 $param = array ( 'com' => $data['express'], //快递公司编码 'num' => $data['waybill'], //快递单号 'phone' => '', //手机号 'from' => '', //出发地城市 'to' => '', //目的地城市 'resultv2' => '1' //开启行政区域解析 ); //请求参数 $post_data = array(); $post_data["customer"] = $customer; $post_data["param"] = json_encode($param); $sign = md5($post_data["param"].$key.$post_data["customer"]); $post_data["sign"] = strtoupper($sign); $url = 'http://poll.kuaidi100.com/poll/query.do'; //实时查询请求地址 $params = ""; foreach ($post_data as $k=>$v) { $params .= "$k=".urlencode($v)."&"; //默认UTF-8编码格式 } $post_data = substr($params, 0, -1); $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); $data = str_replace("\"", '"', $result ); return json_decode($data); } //快递鸟查询快递信息开始 public function get_logistics3($data){ $requestData= "{'OrderCode':'','ShipperCode':'".$data['express']."','LogisticCode':'".$data['waybill']."'}"; $datas = array( 'EBusinessID' => '1397054', 'RequestType' => '8001', 'RequestData' => urlencode($requestData) , 'DataType' => '2', ); $datas['DataSign']=$this->_encrypt($requestData,'34aedf94-322e-438e-b6ba-79eea59710bd'); $result=$this->_sendPost('http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx',$datas); return $result; } public function _sendPost($url,$datas) { $temps = array(); foreach ($datas as $key => $value) { $temps[] = sprintf('%s=%s', $key, $value); } $post_data = implode('&', $temps); $url_info = parse_url($url); if(empty($url_info['port'])) { $url_info['port']=80; } $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n"; $httpheader.= "Host:" . $url_info['host'] . "\r\n"; $httpheader.= "Content-Type:application/x-www-form-urlencoded\r\n"; $httpheader.= "Content-Length:" . strlen($post_data) . "\r\n"; $httpheader.= "Connection:close\r\n\r\n"; $httpheader.= $post_data; $fd = fsockopen($url_info['host'], $url_info['port']); fwrite($fd, $httpheader); $gets = ""; $headerFlag = true; while (!feof($fd)) { if (($header = @fgets($fd)) && ($header == "\r\n" || $header == "\n")) { break; } } while (!feof($fd)) { $gets.= fread($fd, 128); } fclose($fd); return $gets; } public function _encrypt($data,$appkey) { return urlencode(base64_encode(md5($data.$appkey))); } //快递鸟查询快递信息结束 } //end class