Przeglądaj źródła

达达订单查询

shish 6 lat temu
rodzic
commit
4e84fe5b32

+ 35 - 7
app/business/controllers/TestController.php

@@ -7,8 +7,9 @@ use common\components\util;
 
 class TestController extends BaseController
 {
-
-	public function actionIndex()
+	
+	//添加订单
+	public function actionAddOrder()
 	{
 		$dada = Yii::getAlias("@vendor/dada/");
 		require_once $dada . 'api/addOrderApi.php';
@@ -16,13 +17,13 @@ class TestController extends BaseController
 		require_once $dada . 'client/dadaResponse.php';
 		require_once $dada . 'config/config.php';
 		require_once $dada . 'model/orderModel.php';
-
+		
 		// isOnline 判断是否是测试环境,会有不同的域名等
 		$isOnline = false;
 		$sourceId = 1000000;
 		// 初始化一个config
 		$config = new \Config($sourceId, $isOnline);
-
+		
 		$orderModel = new \OrderModel();
 		$orderModel->setShopNo('11047059');
 		$orderModel->setOriginId('2018091100000002');
@@ -35,13 +36,40 @@ class TestController extends BaseController
 		$orderModel->setReceiverLng(121.41);
 		$orderModel->setReceiverPhone('18588888888');
 		$orderModel->setCallback('http://api.b.huaml.com/data/request');
-
+		
 		// api主要有2个参数,一个是url, 一个是业务参数
 		$addOrderApi = new \AddOrderApi(json_encode($orderModel));
-
+		
 		$dada_client = new \DadaRequestClient($config, $addOrderApi);
 		$resp = $dada_client->makeRequest();
 		echo json_encode($resp);
 	}
-
+	
+	//订单查询
+	public function actionOrderQuery()
+	{
+		$dada = Yii::getAlias("@vendor/dada/");
+		require_once $dada . 'api/orderStatusQueryApi.php';
+		require_once $dada . 'client/dadaRequestClient.php';
+		require_once $dada . 'client/dadaResponse.php';
+		require_once $dada . 'config/config.php';
+		require_once $dada . 'model/orderModel.php';
+		
+		// isOnline 判断是否是测试环境,会有不同的域名等
+		$isOnline = false;
+		$sourceId = 1000000;
+		// 初始化一个config
+		$config = new \Config($sourceId, $isOnline);
+		
+		$orderModel = new \OrderModel();
+		$orderModel->setOrderId('2018091100000002');
+		
+		// api主要有2个参数,一个是url, 一个是业务参数
+		$addOrderApi = new \OrderQueryApi(json_encode($orderModel));
+		
+		$dada_client = new \DadaRequestClient($config, $addOrderApi);
+		$resp = $dada_client->makeRequest();
+		echo json_encode($resp);
+	}
+	
 }

+ 3 - 3
vendor/dada/api/cityCodeApi.php

@@ -2,9 +2,9 @@
 /**
  * 发单api
  */
-define("BASE_DIR", dirname(__FILE__) . "/");
-require_once BASE_DIR . 'api/baseApi.php';
-require_once BASE_DIR . 'config/urlConfig.php';
+$dada = Yii::getAlias("@vendor/dada/");
+require_once $dada . 'api/baseApi.php';
+require_once $dada . 'config/urlConfig.php';
 
 class CityCodeApi extends BaseApi{
     

+ 14 - 0
vendor/dada/api/orderQueryApi.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ * 添加门店api
+ */
+$dada = Yii::getAlias("@vendor/dada/");
+require_once $dada . 'api/baseApi.php';
+require_once $dada . 'config/urlConfig.php';
+
+class OrderQueryApi extends BaseApi{
+
+    public function __construct($params) {
+        parent::__construct(UrlConfig::ORDER_QUERY_URL, $params);
+    }
+}

+ 4 - 4
vendor/dada/api/shopAddApi.php

@@ -2,11 +2,11 @@
 /**
  * 添加门店api
  */
-define("BASE_DIR", dirname(__FILE__) . "/");
-require_once BASE_DIR . 'api/baseApi.php';
-require_once BASE_DIR . 'config/urlConfig.php';
+$dada = Yii::getAlias("@vendor/dada/");
+require_once $dada . 'api/baseApi.php';
+require_once $dada . 'config/urlConfig.php';
 
-class AddShopApi extends BaseApi{
+class ShopAddApi extends BaseApi{
     
     public function __construct($params) {
         parent::__construct(UrlConfig::SHOP_ADD_URL, $params);

+ 2 - 0
vendor/dada/config/urlConfig.php

@@ -7,4 +7,6 @@ class UrlConfig{
     const SHOP_ADD_URL = "/api/shop/add";
 
     const CITY_ORDER_URL = "/api/cityCode/list";
+    //订单详情查询
+    const ORDER_QUERY_URL = '/api/order/status/query';
 }

+ 143 - 135
vendor/dada/model/orderModel.php

@@ -1,141 +1,149 @@
 <?php
+
 /**
  * http://newopen.imdada.cn/#/development/file/add?_k=5f4vjj
  *
  */
-class OrderModel{
-    
-    public $shop_no;
-    
-    public $origin_id;
-
-    public $city_code;
-
-    public $cargo_price;
-
-    public $is_prepay;
-
-    public $receiver_name;
-
-    public $receiver_address;
-
-    public $receiver_lat;
-
-    public $receiver_lng;
-
-    public $receiver_phone;
-
-    public $callback;
-
-
-    public function setShopNo($shopNo)
-    {
-        !empty($shopNo) ? $this->shop_no = $shopNo : trigger_error('shop_no不能为空', E_USER_ERROR);
-    }
-
-    public function getShopNo()
-    {
-        return $this->shop_no;
-    }
-
-    public function setOriginId($originId)
-    {
-        !empty($originId) ? $this->origin_id = $originId : trigger_error('origin_id不能为空', E_USER_ERROR);
-    }
-
-    public function getOriginId()
-    {
-        return $this->origin_id;
-    }
-
-    public function setCityCode($cityCode)
-    {
-        !empty($cityCode) ? $this->city_code = $cityCode : trigger_error('city_code不能为空', E_USER_ERROR);
-    }
-
-    public function getCityCode()
-    {
-        return $this->city_code;
-    }
-
-    public function setCargoPrice($cargoPrice)
-    {
-        isset($cargoPrice) ? $this->cargo_price = $cargoPrice : trigger_error('cargo_price不能为空', E_USER_ERROR);
-    }
-
-    public function getCargoPrice()
-    {
-        return $this->cargo_price;
-    }
-
-    public function setIsPrepay($isPrepay)
-    {
-        isset($isPrepay) ? $this->is_prepay = $isPrepay : trigger_error('is_prepay不能为空', E_USER_ERROR);
-    }
-
-    public function getIsPrepay()
-    {
-        return $this->is_prepay;
-    }
-
-    public function setReceiverName($receiverName)
-    {
-        !empty($receiverName) ? $this->receiver_name = $receiverName : trigger_error('receiver_name不能为空', E_USER_ERROR);
-    }
-
-    public function getReceiverName()
-    {
-        return $this->receiver_name;
-    }
-
-    public function setReceiverAddress($receiverAddress)
-    {
-        !empty($receiverAddress) ? $this->receiver_address = $receiverAddress : trigger_error('receiver_address不能为空', E_USER_ERROR);
-    }
-
-    public function getReceiverAddress()
-    {
-        return $this->receiver_address;
-    }
-
-    public function setReceiverLat($receiverLat)
-    {
-        isset($receiverLat) ? $this->receiver_lat = $receiverLat : trigger_error('receiver_lat不能为空', E_USER_ERROR);
-    }
-
-    public function getReceiverLat()
-    {
-        return $this->receiver_lat;
-    }
-
-    public function setReceiverLng($receiverLng)
-    {
-        isset($receiverLng) ? $this->receiver_lng = $receiverLng : trigger_error('receiver_lng不能为空', E_USER_ERROR);
-    }
-
-    public function getReceiverLng()
-    {
-        return $this->receiver_lng;
-    }
-
-    public function setReceiverPhone($receiverPhone)
-    {
-        !empty($receiverPhone) ? $this->receiver_phone = $receiverPhone : trigger_error('receiver_phone不能为空', E_USER_ERROR);
-    }
-
-    public function getReceiverPhone()
-    {
-        return $this->receiver_phone;
-    }
-
-    public function setCallback($callback)
-    {
-        !empty($callback) ? $this->callback = $callback : trigger_error('callback不能为空', E_USER_ERROR);
-    }
-
-    public function getCallback()
-    {
-        return $this->callback;
-    }
-
+class OrderModel
+{
+	
+	public $shop_no;
+	
+	public $origin_id;
+	
+	public $city_code;
+	
+	public $cargo_price;
+	
+	public $is_prepay;
+	
+	public $receiver_name;
+	
+	public $receiver_address;
+	
+	public $receiver_lat;
+	
+	public $receiver_lng;
+	
+	public $receiver_phone;
+	
+	public $callback;
+
+	public $order_id;
+	
+	public function setShopNo($shopNo)
+	{
+		!empty($shopNo) ? $this->shop_no = $shopNo : trigger_error('shop_no不能为空', E_USER_ERROR);
+	}
+	
+	public function getShopNo()
+	{
+		return $this->shop_no;
+	}
+	
+	public function setOriginId($originId)
+	{
+		!empty($originId) ? $this->origin_id = $originId : trigger_error('origin_id不能为空', E_USER_ERROR);
+	}
+	
+	public function getOriginId()
+	{
+		return $this->origin_id;
+	}
+	
+	public function setCityCode($cityCode)
+	{
+		!empty($cityCode) ? $this->city_code = $cityCode : trigger_error('city_code不能为空', E_USER_ERROR);
+	}
+	
+	public function getCityCode()
+	{
+		return $this->city_code;
+	}
+	
+	public function setCargoPrice($cargoPrice)
+	{
+		isset($cargoPrice) ? $this->cargo_price = $cargoPrice : trigger_error('cargo_price不能为空', E_USER_ERROR);
+	}
+	
+	public function getCargoPrice()
+	{
+		return $this->cargo_price;
+	}
+	
+	public function setIsPrepay($isPrepay)
+	{
+		isset($isPrepay) ? $this->is_prepay = $isPrepay : trigger_error('is_prepay不能为空', E_USER_ERROR);
+	}
+	
+	public function getIsPrepay()
+	{
+		return $this->is_prepay;
+	}
+	
+	public function setReceiverName($receiverName)
+	{
+		!empty($receiverName) ? $this->receiver_name = $receiverName : trigger_error('receiver_name不能为空', E_USER_ERROR);
+	}
+	
+	public function getReceiverName()
+	{
+		return $this->receiver_name;
+	}
+	
+	public function setReceiverAddress($receiverAddress)
+	{
+		!empty($receiverAddress) ? $this->receiver_address = $receiverAddress : trigger_error('receiver_address不能为空', E_USER_ERROR);
+	}
+	
+	public function getReceiverAddress()
+	{
+		return $this->receiver_address;
+	}
+	
+	public function setReceiverLat($receiverLat)
+	{
+		isset($receiverLat) ? $this->receiver_lat = $receiverLat : trigger_error('receiver_lat不能为空', E_USER_ERROR);
+	}
+	
+	public function getReceiverLat()
+	{
+		return $this->receiver_lat;
+	}
+	
+	public function setReceiverLng($receiverLng)
+	{
+		isset($receiverLng) ? $this->receiver_lng = $receiverLng : trigger_error('receiver_lng不能为空', E_USER_ERROR);
+	}
+	
+	public function getReceiverLng()
+	{
+		return $this->receiver_lng;
+	}
+	
+	public function setReceiverPhone($receiverPhone)
+	{
+		!empty($receiverPhone) ? $this->receiver_phone = $receiverPhone : trigger_error('receiver_phone不能为空', E_USER_ERROR);
+	}
+	
+	public function getReceiverPhone()
+	{
+		return $this->receiver_phone;
+	}
+	
+	public function setCallback($callback)
+	{
+		!empty($callback) ? $this->callback = $callback : trigger_error('callback不能为空', E_USER_ERROR);
+	}
+	
+	public function getCallback()
+	{
+		return $this->callback;
+	}
+	
+	public function setOrderId($id)
+	{
+		return $this->order_id = $id;
+	}
+	
 }