|
@@ -6,69 +6,27 @@
|
|
|
* Time: 上午10:27
|
|
|
*/
|
|
|
|
|
|
-define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
|
|
|
+defined('BASE_ROOT_PATH') or define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
|
|
|
|
|
|
require_once(BASE_ROOT_PATH . '/fooder.php');
|
|
|
-require_once (BASE_CORE_PATH . "/framework/function/http.php");
|
|
|
-use Log;
|
|
|
+require_once(BASE_ROOT_PATH . '/helper/kdn_helper.php');
|
|
|
|
|
|
-class kdn_helper
|
|
|
+class TestKdniao extends PHPUnit_Framework_TestCase
|
|
|
{
|
|
|
- const EBusinessID = 1366783;
|
|
|
- const AppKey = "e62955d6-4871-4740-9ec9-62068a544ab5";
|
|
|
- const ReqURL = "http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx";
|
|
|
- const TRACEAPI = "http://api.kdniao.cc/api/dis";
|
|
|
-
|
|
|
- public static function cur_businessid()
|
|
|
- {
|
|
|
- return self::EBusinessID;
|
|
|
- }
|
|
|
-
|
|
|
- public static function onCallback($data)
|
|
|
- {
|
|
|
- $order_sn = $data['CallBack'];
|
|
|
- if(empty($order_sn)) return;
|
|
|
-
|
|
|
- $e_code = $data['ShipperCode'];
|
|
|
- $shipping_code = $data['LogisticCode'];
|
|
|
- $key = "express_{$e_code}_{$shipping_code}";
|
|
|
-
|
|
|
- Log::record("kdn_helper::onCallback: key === {$key}, full data ===".json_encode($data));
|
|
|
- }
|
|
|
-
|
|
|
- public static function req_subscribe($e_code, $logisticCode, $order_sn)
|
|
|
+ public static function setUpBeforeClass()
|
|
|
{
|
|
|
- $datas = [
|
|
|
- 'ShipperCode' => $e_code,
|
|
|
- 'LogisticCode' => $logisticCode,
|
|
|
- 'Callback' => $order_sn
|
|
|
- ];
|
|
|
-
|
|
|
- $requestData = json_encode($datas);
|
|
|
-
|
|
|
- $datas = array(
|
|
|
- 'EBusinessID' => self::EBusinessID,
|
|
|
- 'RequestType' => '8008',
|
|
|
- 'RequestData' => urlencode($requestData),
|
|
|
- 'DataType' => '2',
|
|
|
- 'DataSign' => self::encrypt($requestData, self::AppKey)
|
|
|
- );
|
|
|
- $result = http_post_data(self::ReqURL, $datas);
|
|
|
- return $result;
|
|
|
+ Base::run_util();
|
|
|
}
|
|
|
|
|
|
- private static function encrypt($data, $appkey)
|
|
|
+ public function testQuery()
|
|
|
{
|
|
|
- return urlencode(base64_encode(md5($data . $appkey)));
|
|
|
- }
|
|
|
-}
|
|
|
+ //$order_sn = "9000000002470048";
|
|
|
+ $e_code = "YTO";
|
|
|
+ $logisticCode = "886670260037510426";
|
|
|
|
|
|
+ $ret = kdn_helper_new::query($e_code, $logisticCode);
|
|
|
|
|
|
-class TestKdniao extends PHPUnit_Framework_TestCase
|
|
|
-{
|
|
|
- public static function setUpBeforeClass()
|
|
|
- {
|
|
|
- Base::run_util();
|
|
|
+ var_dump($ret);
|
|
|
}
|
|
|
|
|
|
public function testSubscribe()
|
|
@@ -77,7 +35,7 @@ class TestKdniao extends PHPUnit_Framework_TestCase
|
|
|
$e_code = "YTO";
|
|
|
$logisticCode = "886670260037510426";
|
|
|
|
|
|
- $subs = kdn_helper::req_subscribe($e_code, $logisticCode, $order_sn);
|
|
|
+ $subs = kdn_helper_new::req_subscribe($e_code, $logisticCode, $order_sn);
|
|
|
|
|
|
var_dump($subs);
|
|
|
}
|