shish 4 ani în urmă
părinte
comite
be646e7bab
1 a modificat fișierele cu 21 adăugiri și 7 ștergeri
  1. 21 7
      app-hd/controllers/MtController.php

+ 21 - 7
app-hd/controllers/MtController.php

@@ -24,15 +24,26 @@ class MtController extends PublicController
         echo '开发中...';
         echo '开发中...';
     }
     }
 
 
+    //已确认订单通知
+    public function actionConfirmOrder()
+    {
+        $post = Yii::$app->request->post();
+        if (empty($post)) { // 无数据过来时,是美团对接口进行存活试探,请保留此段代码,好让请求在此被中断返回
+            return Json::encode(['data' => 'ok']);
+        }
+        $data = arrayUtil::humpUnderlineConversion($post, 1);
+        Yii::warning('confirmOrder: ' . urldecode(json_encode($data))); // 想要知道美团请求中带过来哪些参数,查看此日志输出
+    }
+
     public function actionNewOrder()
     public function actionNewOrder()
     {
     {
         $post = Yii::$app->request->post();
         $post = Yii::$app->request->post();
-        if(empty($post)) { // 无数据过来时,是美团对接口进行存活试探,请保留此段代码,好让请求在此被中断返回
+        if (empty($post)) { // 无数据过来时,是美团对接口进行存活试探,请保留此段代码,好让请求在此被中断返回
             return Json::encode(['data' => 'ok']);
             return Json::encode(['data' => 'ok']);
         }
         }
 
 
         // 美团传入的订单数据,中文是 URL_encode 的,执行下解密
         // 美团传入的订单数据,中文是 URL_encode 的,执行下解密
-        foreach($post as $k => $val) {
+        foreach ($post as $k => $val) {
             $post[$k] = urldecode($val);
             $post[$k] = urldecode($val);
         }
         }
 
 
@@ -54,7 +65,7 @@ class MtController extends PublicController
         $app = new Application($this->config);
         $app = new Application($this->config);
         $detail = $data['detail'];
         $detail = $data['detail'];
         $items = json_decode($detail, true);
         $items = json_decode($detail, true);
-        foreach($items as $item){
+        foreach ($items as $item) {
             $appSpuCode = $item['app_spu_code'];
             $appSpuCode = $item['app_spu_code'];
 
 
             // access_token 是商家授权后,获取到的
             // access_token 是商家授权后,获取到的
@@ -62,7 +73,7 @@ class MtController extends PublicController
             $retailDetail = $app->retail->getDetail($params);
             $retailDetail = $app->retail->getDetail($params);
             $retailDetail = json_decode($retailDetail, true);
             $retailDetail = json_decode($retailDetail, true);
             if (isset($retailDetail['error'])) {
             if (isset($retailDetail['error'])) {
-                 Yii::error('get retail fail:' . json_encode($params));
+                Yii::error('get retail fail:' . json_encode($params));
             } else {
             } else {
                 $picArr[$appSpuCode] = $retailDetail['data']['picture'];
                 $picArr[$appSpuCode] = $retailDetail['data']['picture'];
             }
             }
@@ -76,14 +87,17 @@ class MtController extends PublicController
     public function actionCancelOrder()
     public function actionCancelOrder()
     {
     {
         $post = Yii::$app->request->post();
         $post = Yii::$app->request->post();
-        if(!empty($post)) {
-            Yii::warning('cancelOrder: ' . urldecode(json_encode($post)));
+        if (empty($post)) {
+            return Json::encode(['data' => 'ok']);
         }
         }
 
 
+        Yii::warning('cancelOrder: ' . urldecode(json_encode($post)));
+
         return Json::encode(['data' => 'ok']);
         return Json::encode(['data' => 'ok']);
     }
     }
 
 
-    public function demo() {
+    public function demo()
+    {
         $app = new Application($this->config);
         $app = new Application($this->config);
 
 
         $params = ['order_id' => '27061900338318741', 'is_mt_logistics' => 1];
         $params = ['order_id' => '27061900338318741', 'is_mt_logistics' => 1];