Prechádzať zdrojové kódy

闪送授权专用接口

shizhongqi 9 mesiacov pred
rodič
commit
bbc4681b57
1 zmenil súbory, kde vykonal 16 pridanie a 29 odobranie
  1. 16 29
      app-ghs/controllers/DeliveryController.php

+ 16 - 29
app-ghs/controllers/DeliveryController.php

@@ -139,31 +139,16 @@ class DeliveryController extends BaseController
     }
 
     /**
-     * 授权回调接口
+     * 闪送授权回调接口
      */
-    public function actionAuthCallback()
+    public function actionShansongAuthCallback()
     {
-        $callbackData = Yii::$app->request->post();
-        if (empty($callbackData)) {
-            $postStr = file_get_contents('php://input');
-            $callbackData = json_decode($postStr, true);
-            if (empty($callbackData)) {
-                util::fail('回调请求的数据为空');
-            }
-        }
-
-        // 从配置中获取安全token
-        // $token = Yii::$app->params['wx_intracity_token'] ?? 'your_token_here';
-        // $result = IntraCityExpress::handleOrderCallback($callbackData, $token);
-        // 记录回调日志
-        Yii::info('聚合配送回调:' . json_encode($callbackData, JSON_UNESCAPED_UNICODE), 'delivery');
-
-        $code = $callbackData['code'];
-        $state = $callbackData['state'];
-        $shopId = $callbackData['shopId'];
-        $isAllStoreAuth = $callbackData['isAllStoreAuth'];
-        $thirdStoreId = $callbackData['thirdStoreId'];
-        $storeId = $callbackData['storeId'];
+        $code = Yii::$app->request->get('code');
+        $state = Yii::$app->request->get('state');
+        $shopId = Yii::$app->request->get('shopId');
+        $isAllStoreAuth = Yii::$app->request->get('isAllStoreAuth');
+        $thirdStoreId = Yii::$app->request->get('thirdStoreId');
+        $storeId = Yii::$app->request->get('storeId');
 
         // 验证state参数(防止CSRF)
         //if ($state != $yourUserId) {
@@ -179,12 +164,14 @@ class DeliveryController extends BaseController
         }
 
         // 保存授权信息到数据库
-        $data['user_id'] = $state;
-        $data['shop_id'] = $shopId;
-        $data['access_token'] = $result['access_token'];
-        $data['refresh_token'] = $result['refresh_token'];
-        $data['expires_at'] = time() + $result['expires_in'];
-        $data['auth_type'] = $isAllStoreAuth ? 'all_store' : 'single_store';
+        $data = [
+            'user_id' => $state,
+            'shop_id' => $shopId,
+            'access_token' => $result['access_token'],
+            'refresh_token' => $result['refresh_token'],
+            'expires_at' => time() + $result['expires_in'],
+            'auth_type' => $isAllStoreAuth ? 'all_store' : 'single_store'
+        ];
 
         if (!$isAllStoreAuth) {
             $data['third_store_id'] = $thirdStoreId;