/*$publickeyData = "-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCAVBWerYFCgDqECD2HCJibijI5SCB9GmsgSUlx sTL083+nh979eJCH/U4QmV4i0rSnor0nghoZLNkg5oDCfEb5RZSleQmiPAe/YOl+vW27uR/tAXl0 bUADcm6rXp814d9ZWzcVnhxLCgQ+0hU0RvxTwWmkuUlxGgeKmuuHI5DDFQIDAQAB -----END PUBLIC KEY----- "; $privatekeyData = "-----BEGIN PRIVATE KEY----- MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAOC8riDCsH0TB8Y7BEIwQfcAVzN 1AmxCG7HFAhawXrhM/2YM4eSH+di6995domSUTMDY6V1sXxn0z3yydoRNtDs7W/UBPaeBXXtyPQ Dv8w7W5UwmGEE9FCK7wsQhxOrLlZG1tuS7M/mZQg1ml9n8Z6ltAUNANAfpxV0+TpgWLka9AgMBA AECgYEAi2DZSV4VYOydhLZzVK1jK9IdQr+NyiBR1rWNLw8hH4I5X0wcCMTAEkcalOFTZreGxo+A Y71jWdC3oel4kWMzo+LPF8XpbeOutgjqVPy8cj1vWnz/ugWSRTR8fbCPJnECpU3diqQ5pus/ps3 zofTocNjij/Swn+vhR9HitwlfV6ECQQD53c+GS98du2QRePQ+JsU/JZyPMeTE613SKK0q/Wt0c+ gTWCu+LW+/D2dfElxz8/Ll4MM/9QOe7ZuhwQtxNjK1AkEA5kD0E0VaCJd+Kh/jQbVRNVT6bns+W S6DyCpZF0laMO/tncrBq0nzIzy7ZWwOzzMpbzpk1Y7Yeiyd9hnKeCWg6QJBAKMUiFvorSjko31b 6l2eRGLgk3xKXjvAOq3t6ogCet24wKHPjE1FroeO8DL28uyjLcenmQfnTIOwJUG/k05Cx3kCQQC ExON40T6vQZuwcp66XvEqzYtydYJoLlgy7ahdsyBco5zipe2y9XtL0FNGkl6fv6Kezo8iTbIqEN ws8oY7bYcxAkEA33JtnwlDEydtgO4R2qt64KxZVlE+lE8C22RHoizQA8BH3pAAGB+QvvY6ybV4F q1mTb5ciqaifmqhSWcgYZow3w== -----END PRIVATE KEY----- "; $accessKey = '_1AtDG8-VY_utm6eOgfOfxahyc9e0wTSPwdDXJekkR0='; */ $jdStatusInfo = array( '1' => '新单', '13' => '自提退货', '2' => '等待支付', '14' => '确认自提', '3' => '等待支付确认', '16' => '等待确认收货', '4' => '延迟付款确认', '17' => '配送退货', '5' => '订单暂停', '18' => '货到付款确认', '6' => '店长最终审核', '19' => '已完成', '7' => '等待打印', '21' => '收款确认', '8' => '等待出库', '22' => '锁定', '9' => '等待打包', '29' => '等待三方出库', '10' => '等待发货', '30' => '等待三方发货', '11' => '自提途中', '31' => '等待三方发货完成', '12' => '上门提货' ); function jd_add_log($url, $post, $rs) { global $db; if(is_array($post)) $post = json_encode($post); $db->query("insert into tb_jd_api_log set url = '".addslashes($url)."', post = '".addslashes($post)."', rs = '".addslashes($rs)."', addtime = now() ", 'SILENT'); } function jd_encrypt($s) { global $publickey, $publickeyData; if(!$publickey) $publickey = openssl_get_publickey($publickeyData); openssl_public_encrypt($s, $s2, $publickey); $s2 = base64_encode($s2); return $s2; } function jd_decrypt($s) { global $privatekey, $privatekeyData, $accessKey; if(!$privatekey) $privatekey = openssl_get_privatekey($privatekeyData); $s = base64_decode($s); openssl_private_decrypt($s, $s2, $privatekey); return $s2; } function jd_decrypt_public($s) { global $publickey, $publickeyData; if(!$publickey) $publickey = openssl_get_publickey($publickeyData); $s = base64_decode($s); openssl_public_decrypt($s, $s2, $publickey); return $s2; } function jd_sign($data, $isLogin = false) { global $privatekey, $privatekeyData, $accessKey; if(!$privatekey) $privatekey = openssl_get_privatekey($privatekeyData); $data['accessKey'] = $accessKey; $time = time(); if(!$isLogin) $time = $time*1000; $data['timestamp'] = $time; $s = ''; ksort($data); foreach($data as $key => $value) { if($s != '') $s .= "&"; $s .= $key."=".$value; } //echo $s."\n"; $sha = hash("sha256", $s); openssl_private_encrypt($sha, $sign, $privatekey); $sign = base64_encode($sign); if($isLogin) { foreach($data as $key => $value) { $data[$key] = jd_encrypt($value); } } $data['sign'] = $sign; return $data; } function jd_verify($data) { global $privatekey, $privatekeyData, $accessKey; if(!$privatekey) $privatekey = openssl_get_privatekey($privatekeyData); if(!$data['sign']) return false; foreach($data as $key => $value) { if(($value."") === "") { unset($data[$key]); } else { if($key != 'sign') $data[$key] = jd_decrypt($value); } } //foreach($data as $key => $value) { // if($key != 'sign') $data[$key] = jd_decrypt($value); //} $sha_jd = jd_decrypt_public($data['sign']); unset($data['sign']); $s = ''; ksort($data); foreach($data as $key => $value) { if($s != '') $s .= "&"; $s .= $key."=".$value; } //echo $s."\n"; $sha = hash("sha256", $s); if($sha != $sha_jd) return false; return $data; } function gotoJd($uid, $returnUrl = '/index') { global $accessKey; $timestamp = time(); //$jd_url = "https://mes.jd.com/{$accessKey}/autoLogin"; //$returnUrl = "https://mes.jd.com/{$accessKey}".$returnUrl; //$jd_url = "https://jxi-fuli-login.jd.com/autoLogin?appTarget=5&loginCode={$accessKey}"; //$returnUrl = "https://jfd-m.jd.com/fuli_page_wegoIndex"; $jd_url = "https://jxi-fuli-login.jd.com/autoLogin?appTarget=5&loginCode={$accessKey}"; $returnUrl = "https://jxi-fuli-m.jd.com/fuli_page_index"; //echo $uid;exit; $uid = "yzmsdc_".$uid; $data = array( 'returnUrl' => $returnUrl, 'uid' => $uid ); $data = jd_sign($data, true); $html = '