|
|
@@ -9,24 +9,23 @@ use Yii;
|
|
|
class ShunfengAdapter
|
|
|
{
|
|
|
protected $baseUrl;
|
|
|
- protected $appId;
|
|
|
+ protected $devId;
|
|
|
protected $appSecret;
|
|
|
- protected $merchantId;
|
|
|
protected $shopId;
|
|
|
protected $accessToken;
|
|
|
- protected $apiVersion = '1.0';
|
|
|
+ protected $apiVersion = 19;
|
|
|
|
|
|
public function __construct($accessToken = '', $shopId = 0)
|
|
|
{
|
|
|
// 根据环境设置基础URL
|
|
|
if (getenv('YII_ENV') == 'production') {
|
|
|
$this->baseUrl = 'https://openic.sf-express.com/open/api/external/';
|
|
|
- $this->appId = 1741530942;
|
|
|
+ $this->devId = 1741530942;
|
|
|
$this->appSecret = '07b3f83d19a4a9f89322976c936faf92';
|
|
|
$this->shopId = $shopId;
|
|
|
} else {
|
|
|
$this->baseUrl = 'https://openic.sf-express.com/open/api/external/';
|
|
|
- $this->appId = 1741530942;
|
|
|
+ $this->devId = 1741530942;
|
|
|
$this->appSecret = '07b3f83d19a4a9f89322976c936faf92';
|
|
|
$this->shopId = $shopId;
|
|
|
}
|
|
|
@@ -111,7 +110,7 @@ class ShunfengAdapter
|
|
|
'order_source' => $params['order_source'] ?? '花店系统', // 订单接入来源
|
|
|
'order_time' => $orderTime, // 用户下单时间(秒级时间戳)
|
|
|
'push_time' => time(), // 推单时间(秒级时间戳)
|
|
|
- 'version' => 19, // API版本号
|
|
|
+ 'version' => $this->apiVersion, // API版本号
|
|
|
|
|
|
// 收货人信息
|
|
|
'receive' => [
|
|
|
@@ -247,7 +246,7 @@ class ShunfengAdapter
|
|
|
|
|
|
// 构建签名用的完整payload
|
|
|
$payload = [
|
|
|
- 'dev_id' => $this->appId,
|
|
|
+ 'dev_id' => $this->devId,
|
|
|
'shop_id' => $this->shopId,
|
|
|
'shop_type' => 1, //1:顺丰店铺ID 2:接入方店铺ID
|
|
|
];
|
|
|
@@ -278,7 +277,7 @@ class ShunfengAdapter
|
|
|
{
|
|
|
// 构建参数
|
|
|
$payload = [
|
|
|
- 'dev_id' => $this->appId,
|
|
|
+ 'dev_id' => $this->devId,
|
|
|
'shop_id' => $this->shopId,
|
|
|
'shop_type' => 1, //1:顺丰店铺ID 2:接入方店铺ID
|
|
|
//-------------------------------------------------
|
|
|
@@ -298,7 +297,7 @@ class ShunfengAdapter
|
|
|
public function generateSignature($params)
|
|
|
{
|
|
|
$post_data = json_encode($params);
|
|
|
- $sign_char = $post_data . "&{$this->appId}&{$this->appSecret}";
|
|
|
+ $sign_char = $post_data . "&{$this->devId}&{$this->appSecret}";
|
|
|
$sign = base64_encode(MD5($sign_char)); // 注:md5出来的结果是32位小写16进制字符串,$sign 的最终结果末尾包含等号=
|
|
|
return $sign;
|
|
|
}
|