|
@@ -13,6 +13,7 @@ use common\components\dada\config\config;
|
|
|
use common\components\dada\protocol\requestClient;
|
|
use common\components\dada\protocol\requestClient;
|
|
|
use common\components\util;
|
|
use common\components\util;
|
|
|
use Yii;
|
|
use Yii;
|
|
|
|
|
+
|
|
|
//达达快递
|
|
//达达快递
|
|
|
class dada
|
|
class dada
|
|
|
{
|
|
{
|
|
@@ -22,7 +23,7 @@ class dada
|
|
|
{
|
|
{
|
|
|
$config = self::getConfig($sourceId);
|
|
$config = self::getConfig($sourceId);
|
|
|
$api = new cityCodeApi('');
|
|
$api = new cityCodeApi('');
|
|
|
- $client = new requestClient($config,$api);
|
|
|
|
|
|
|
+ $client = new requestClient($config, $api);
|
|
|
$resp = $client->makeRequest();
|
|
$resp = $client->makeRequest();
|
|
|
return self::handleResp($resp);
|
|
return self::handleResp($resp);
|
|
|
}
|
|
}
|
|
@@ -65,7 +66,7 @@ class dada
|
|
|
{
|
|
{
|
|
|
$config = self::getConfig($sourceId);
|
|
$config = self::getConfig($sourceId);
|
|
|
$api = new reasonsApi('');
|
|
$api = new reasonsApi('');
|
|
|
- $client = new requestClient($config,$api);
|
|
|
|
|
|
|
+ $client = new requestClient($config, $api);
|
|
|
$resp = $client->makeRequest();
|
|
$resp = $client->makeRequest();
|
|
|
return self::handleResp($resp);
|
|
return self::handleResp($resp);
|
|
|
}
|
|
}
|
|
@@ -118,36 +119,36 @@ class dada
|
|
|
"msg": "成功"
|
|
"msg": "成功"
|
|
|
}
|
|
}
|
|
|
*/
|
|
*/
|
|
|
- public static function addOrder($sourceId,$params)
|
|
|
|
|
|
|
+ public static function addOrder($sourceId, $params)
|
|
|
{
|
|
{
|
|
|
$config = self::getConfig($sourceId);
|
|
$config = self::getConfig($sourceId);
|
|
|
$api = new orderApi();
|
|
$api = new orderApi();
|
|
|
//body内容
|
|
//body内容
|
|
|
$api->addOrder($params);
|
|
$api->addOrder($params);
|
|
|
- $client = new requestClient($config,$api);
|
|
|
|
|
|
|
+ $client = new requestClient($config, $api);
|
|
|
$resp = $client->makeRequest();
|
|
$resp = $client->makeRequest();
|
|
|
return self::handleResp($resp);
|
|
return self::handleResp($resp);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
//运费查询(参数跟新增订单一致)
|
|
//运费查询(参数跟新增订单一致)
|
|
|
- public static function queryDeliverFee($sourceId,$params)
|
|
|
|
|
|
|
+ public static function queryDeliverFee($sourceId, $params)
|
|
|
{
|
|
{
|
|
|
$config = self::getConfig($sourceId);
|
|
$config = self::getConfig($sourceId);
|
|
|
$api = new orderApi();
|
|
$api = new orderApi();
|
|
|
$api->queryDeliverFee($params);
|
|
$api->queryDeliverFee($params);
|
|
|
- $client = new requestClient($config,$api);
|
|
|
|
|
|
|
+ $client = new requestClient($config, $api);
|
|
|
$resp = $client->makeRequest();
|
|
$resp = $client->makeRequest();
|
|
|
return self::handleResp($resp);
|
|
return self::handleResp($resp);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//订单重发(参数跟新增订单一致)
|
|
//订单重发(参数跟新增订单一致)
|
|
|
- public static function reAddOrder($sourceId,$params)
|
|
|
|
|
|
|
+ public static function reAddOrder($sourceId, $params)
|
|
|
{
|
|
{
|
|
|
$config = self::getConfig($sourceId);
|
|
$config = self::getConfig($sourceId);
|
|
|
$api = new orderApi();
|
|
$api = new orderApi();
|
|
|
$api->reAddOrder($params);
|
|
$api->reAddOrder($params);
|
|
|
- $client = new requestClient($config,$api);
|
|
|
|
|
|
|
+ $client = new requestClient($config, $api);
|
|
|
$resp = $client->makeRequest();
|
|
$resp = $client->makeRequest();
|
|
|
return self::handleResp($resp);
|
|
return self::handleResp($resp);
|
|
|
|
|
|
|
@@ -159,50 +160,50 @@ class dada
|
|
|
cancel_reason_id Integer 是 取消原因ID(取消原因列表)
|
|
cancel_reason_id Integer 是 取消原因ID(取消原因列表)
|
|
|
cancel_reason String 否 取消原因(当取消原因ID为其他时,此字段必填)
|
|
cancel_reason String 否 取消原因(当取消原因ID为其他时,此字段必填)
|
|
|
*/
|
|
*/
|
|
|
- public static function formalCancel($sourceId,$orderSn,$reasonId,$reason='')
|
|
|
|
|
|
|
+ public static function formalCancel($sourceId, $orderSn, $reasonId, $reason = '')
|
|
|
{
|
|
{
|
|
|
$config = self::getConfig($sourceId);
|
|
$config = self::getConfig($sourceId);
|
|
|
$api = new orderApi();
|
|
$api = new orderApi();
|
|
|
$params = [
|
|
$params = [
|
|
|
- 'order_id'=>$orderSn,
|
|
|
|
|
- 'cancel_reason_id'=>$reasonId,
|
|
|
|
|
|
|
+ 'order_id' => $orderSn,
|
|
|
|
|
+ 'cancel_reason_id' => $reasonId,
|
|
|
];
|
|
];
|
|
|
- if($reasonId==10000){
|
|
|
|
|
|
|
+ if ($reasonId == 10000) {
|
|
|
$params['cancel_reason'] = $reason;
|
|
$params['cancel_reason'] = $reason;
|
|
|
}
|
|
}
|
|
|
$api->formalCancel($params);
|
|
$api->formalCancel($params);
|
|
|
- $client = new requestClient($config,$api);
|
|
|
|
|
|
|
+ $client = new requestClient($config, $api);
|
|
|
$resp = $client->makeRequest();
|
|
$resp = $client->makeRequest();
|
|
|
return self::handleResp($resp);
|
|
return self::handleResp($resp);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//订单状态查询
|
|
//订单状态查询
|
|
|
- public static function statusQuery($sourceId,$orderSn)
|
|
|
|
|
|
|
+ public static function statusQuery($sourceId, $orderSn)
|
|
|
{
|
|
{
|
|
|
$config = self::getConfig($sourceId);
|
|
$config = self::getConfig($sourceId);
|
|
|
$api = new orderApi();
|
|
$api = new orderApi();
|
|
|
$params = [
|
|
$params = [
|
|
|
- 'order_id'=>$orderSn,
|
|
|
|
|
|
|
+ 'order_id' => $orderSn,
|
|
|
];
|
|
];
|
|
|
$api->queryOrderStatus($params);
|
|
$api->queryOrderStatus($params);
|
|
|
- $client = new requestClient($config,$api);
|
|
|
|
|
|
|
+ $client = new requestClient($config, $api);
|
|
|
$resp = $client->makeRequest();
|
|
$resp = $client->makeRequest();
|
|
|
return self::handleResp($resp);
|
|
return self::handleResp($resp);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static function getConfig($sourceId)
|
|
public static function getConfig($sourceId)
|
|
|
{
|
|
{
|
|
|
- if(empty($sourceId)){
|
|
|
|
|
|
|
+ if (empty($sourceId)) {
|
|
|
util::fail("暂不支持配送,请绑定达达或联系客服");
|
|
util::fail("暂不支持配送,请绑定达达或联系客服");
|
|
|
}
|
|
}
|
|
|
$config = new config();
|
|
$config = new config();
|
|
|
- $online = Yii::$app->params['dadaOnline'];
|
|
|
|
|
|
|
+ //$online = Yii::$app->params['dadaOnline'];
|
|
|
$appKey = Yii::$app->params['dadaAppKey'];
|
|
$appKey = Yii::$app->params['dadaAppKey'];
|
|
|
$appSecret = Yii::$app->params['dadaAppSecret'];
|
|
$appSecret = Yii::$app->params['dadaAppSecret'];
|
|
|
- if($online){
|
|
|
|
|
|
|
+ if (getenv('YII_ENV', 'local') == 'production') {
|
|
|
$config->setSourceId($sourceId);
|
|
$config->setSourceId($sourceId);
|
|
|
$config->setHost('https://newopen.imdada.cn');
|
|
$config->setHost('https://newopen.imdada.cn');
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
//测试 :商户id: 73753 门店id: 11047059
|
|
//测试 :商户id: 73753 门店id: 11047059
|
|
|
$config->setSourceId(73753);
|
|
$config->setSourceId(73753);
|
|
|
$config->setHost("http://newopen.qa.imdada.cn");
|
|
$config->setHost("http://newopen.qa.imdada.cn");
|
|
@@ -214,7 +215,7 @@ class dada
|
|
|
|
|
|
|
|
public static function handleResp($resp)
|
|
public static function handleResp($resp)
|
|
|
{
|
|
{
|
|
|
- if($resp->getStatus()!='success'){
|
|
|
|
|
|
|
+ if ($resp->getStatus() != 'success') {
|
|
|
util::fail($resp->getMsg());
|
|
util::fail($resp->getMsg());
|
|
|
}
|
|
}
|
|
|
return $resp->getResult();
|
|
return $resp->getResult();
|