'application/x-www-form-urlencoded;charset=utf-8', "Accept" => "application/json" ]; $body = $this->formatWaybillData($waybill); try { $response = httpPost(config('api_logistic.DB.prod.uri')['create_order'], $body, $header); if (!$response["result"]) { return null; } return $response ?? ''; }catch (\Exception $e){ $this->push(__METHOD__."->".__LINE__,"德邦接口请求失败",$e->getMessage() . ' | '.json_encode($response ?? '')); return null; } } /** * 根据 德邦运单号 获取 订单物流轨迹 * @param array $params * @return array */ public function getOrderStatus(array $params = []):array { if ( ($params['mailNo']??'') == '') return ['code' => 0 , 'msg' => '德邦运单号不能为空']; $header = [ 'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8', "Accept" => "application/json" ]; $data = [ 'mailNo' => $params['mailNo']??'' ]; $param = json_encode($data, 1); $dd["params"] = $param; $dd["timestamp"] = (integer)getMillisecond(); $dd["digest"] = base64_encode(md5($param . config('api_logistic.DB.prod.app_key') . $dd['timestamp'])); $dd["companyCode"] = config('api_logistic.DB.prod.company_code'); $return = httpPost(config('api_logistic.DB.prod.uri')['order_locus'], $dd, $header); if (array_key_exists('result', $return) && $return['result'] == 'true' && array_key_exists('resultCode', $return) && $return['resultCode'] == '1000'){ return ['code'=> 1, 'msg'=> '正在加载中。。。', 'data' => $return['responseParam']]; } return ['code' => 0, 'msg' => '暂无物流信息']; } /** * @param Model|\stdClass $waybill */ private function formatWaybillData($waybill):array { $waybill->loadMissing([ "order.shop","owner","order.warehouse.province","order.warehouse.city","order.warehouse.county" ]); $date = date('Y-m-d H:i:s', $waybill->deliver_at ? strtotime($waybill->deliver_at) : now()->getTimestamp()); $data = [ 'logisticID' => config('api_logistic.DB.prod.sign').date("YmdHis").mt_rand(1000, 9999).$waybill->order->id, 'custOrderNo' => $waybill->order->client_code ?? '', 'needTraceInfo' => config('api_logistic.DB.prod.needTraceInfo'), 'companyCode' => config('api_logistic.DB.prod.company_code'), 'orderType' => $waybill->order_type, 'transportType' => $waybill->transport_type, 'customerCode' => config('api_logistic.DB.prod.customer_Code'), 'sender' => [ 'companyName' => '宝时物流', 'businessNetworkNo' => '', 'name' => '宝时物流', 'mobile' => '', 'phone' => '021-6316561', 'province' => $waybill->order->warehouse->province->name ?? '', 'city' => $waybill->order->warehouse->city->name ?? '', 'country' => $waybill->order->warehouse->county->name ?? '', 'town' => '', 'address' => $waybill->order->warehouse->address ?? '', ], 'receiver' => [ 'toNetworkNo' => '', 'name' => $waybill->order->consignee_name ?? '', 'phone' => $waybill->order->consignee_phone ?? '', 'mobile' => $waybill->order->consignee_phone ?? '', 'province' => $waybill->order->province ?? '', 'city' => $waybill->order->city ?? "", 'county' => $waybill->order->district ?? '', 'town' => '', 'address' => $waybill->order->address ?? '', 'companyName' => '' ], 'packageInfo' => [ 'cargoName' => $waybill->cargo_name ?? '', 'totalNumber' => $waybill->total_number ?? '', 'totalWeight' => $waybill->total_weight ?? '', 'totalVolume' => '', 'packageService' => $waybill->package_service ?? '', 'deliveryType' => $waybill->deliveryType_id, ], 'gmtCommit' => $date, 'payType' => $waybill->pay_type, 'addServices' => [ 'insuranceValue' => '', 'codType' => '', 'reciveLoanAccount' => '', 'accountName' => '', 'codValue' => '', 'backSignBill' => $waybill->back_sign_bill ], 'smsNotify' => config('api_logistic.DB.prod.smsNotify'), 'sendStartTime' => $date, 'sendEndTime' => date('Y-m-d ', $waybill->deliver_at ? strtotime($waybill->deliver_at) : now()->getTimestamp()).'23:59:59', 'originalWaybillNumber' => $waybill->wms_bill_number ?? '', 'remark' => $waybill->dispatch_remark ?? '', 'isOut' => 'N', 'passwordSigning' => config('api_logistic.DB.prod.passwordSigning'), 'isdispatched' => '', 'ispresaleorder'=> '', 'isCenterDelivery' => '', // 'orderExtendFields' => [ // 'value' => '', // 'key' => '' // ] ]; $param = json_encode($data); $timestamp = (integer)getMillisecond(); return ["params"=>$param,"timestamp"=>$timestamp, "digest"=>base64_encode(md5($param.config('api_logistic.DB.prod.app_key').$timestamp)), "companyCode" => config('api_logistic.DB.prod.company_code')]; } }