Просмотр исходного кода

修改一号通接口适配v2.0

liaofei 2 лет назад
Родитель
Сommit
2f13a58b20

+ 6 - 6
crmeb/crmeb/services/AccessTokenServeService.php

@@ -61,12 +61,12 @@ class AccessTokenServeService extends HttpService
      * 沙盒模式
      * @var bool
      */
-    protected $sandBox = false;
+    protected $sandBox = true;
 
     /**
      * 登录接口
      */
-    const USER_LOGIN = "user/login";
+    const USER_LOGIN = "v2/user/login";
 
 
     /**
@@ -105,11 +105,11 @@ class AccessTokenServeService extends HttpService
      */
     public function getToken()
     {
-        $accessTokenKey = md5($this->account . '_' . $this->secret . $this->cacheTokenPrefix);
+        $accessTokenKey = md5($this->account . '_v2_' . $this->secret . $this->cacheTokenPrefix);
         $cacheToken = $this->cache->get($accessTokenKey);
         if (!$cacheToken) {
             $getToken = $this->getTokenFromServer();
-            $this->cache->set($accessTokenKey, $getToken['access_token'], 300);
+            $this->cache->set($accessTokenKey, $getToken['access_token'], $getToken['expires_in'] - 60);
             $cacheToken = $getToken['access_token'];
         }
         $this->accessToken = $cacheToken;
@@ -125,8 +125,8 @@ class AccessTokenServeService extends HttpService
     public function getTokenFromServer()
     {
         $params = [
-            'account' => $this->account,
-            'secret' => $this->secret,
+            'access_key' => $this->account,
+            'secret_key' => $this->secret,
         ];
         $response = $this->postRequest($this->get(self::USER_LOGIN), $params);
         $response = json_decode($response, true);

+ 14 - 10
crmeb/crmeb/services/express/storage/Express.php

@@ -24,36 +24,36 @@ class Express extends BaseExpress
     /**
      * 注册服务
      */
-    const EXPRESS_OPEN = 'expr/open';
+    const EXPRESS_OPEN = 'v2/expr/open';
 
     /**
      * 电子面单模版
      */
-    const EXPRESS_TEMP = 'expr/temp';
+    const EXPRESS_TEMP = 'v2/expr/temp';
 
     /**
      * 快递公司
      */
-    const EXPRESS_LIST = 'expr/express';
+    const EXPRESS_LIST = 'v2/expr/express';
 
     /**
      * 快递查询
      */
-    const EXPRESS_QUERY = 'expr/query';
+    const EXPRESS_QUERY = 'v2/expr/query';
 
     /**
      * 面单打印
      */
-    const EXPRESS_DUMP = 'expr/dump';
+    const EXPRESS_DUMP = 'v2/expr/dump';
 
     //获取物流公司信息
-    const SHIPMENT_KUAIDI_NUMS = 'shipment/get_kuaidi_coms';
+    const SHIPMENT_KUAIDI_NUMS = 'v2/shipment/get_kuaidi_coms';
     //创建商家寄件订单
-    const SHIPMENT_CREATE_ORDER = 'shipment/create_order';
+    const SHIPMENT_CREATE_ORDER = 'v2/v2/shipment/create_order';
     //取消商家寄件
-    const SHIPMENT_CANCEL_ORDER = 'shipment/cancel_order';
+    const SHIPMENT_CANCEL_ORDER = 'v2/shipment/cancel_order';
     //获取商家寄件订单列表
-    const SHIPMENT_INDEX = 'shipment/index';
+    const SHIPMENT_INDEX = 'v2/shipment/index';
 
     /** 初始化
      * @param array $config
@@ -260,7 +260,11 @@ class Express extends BaseExpress
         if (!$data['siid']) {
             $param['print_type'] = 'IMAGE';
         }
-        return $this->accessToken->httpRequest(self::EXPRESS_DUMP, $param, 'POST', true, ['version:v1.1']);
+        $header = [];
+        if (!sys_config('config_export_siid')) {
+            $header = ['version:v1.1'];
+        }
+        return $this->accessToken->httpRequest(self::EXPRESS_DUMP, $param, 'POST', true, $header);
     }
 
 }

+ 9 - 9
crmeb/crmeb/services/sms/storage/Yihaotong.php

@@ -26,47 +26,47 @@ class Yihaotong extends BaseSms
     /**
      * 开通
      */
-    const SMS_OPEN = 'sms_v2/open';
+    const SMS_OPEN = 'v2/sms_v2/open';
 
     /**
      * 修改签名
      */
-    const SMS_MODIFY = 'sms_v2/modify';
+    const SMS_MODIFY = 'v2/sms_v2/modify';
 
     /**
      * 用户信息
      */
-    const SMS_INFO = 'sms_v2/info';
+    const SMS_INFO = 'v2/sms_v2/info';
 
     /**
      * 发送短信
      */
-    const SMS_SEND = 'sms_v2/send';
+    const SMS_SEND = 'v2/sms_v2/send';
 
     /**
      * 短信模板
      */
-    const SMS_TEMPS = 'sms_v2/temps';
+    const SMS_TEMPS = 'v2/sms_v2/temps';
 
     /**
      * 申请模板
      */
-    const SMS_APPLY = 'sms_v2/apply';
+    const SMS_APPLY = 'v2/sms_v2/apply';
 
     /**
      * 模板记录
      */
-    const SMS_APPLYS = 'sms_v2/applys';
+    const SMS_APPLYS = 'v2/sms_v2/applys';
 
     /**
      * 发送记录
      */
-    const SMS_RECORD = 'sms_v2/record';
+    const SMS_RECORD = 'v2/sms_v2/record';
 
     /**
      * 获取短信发送状态
      */
-    const SMS_STSTUS = 'sms/status';
+    const SMS_STSTUS = 'v2/sms/status';
 
     /**
      * 短信签名