Преглед изворни кода

滴滴授权成功后返回可观页面

shizhongqi пре 8 месеци
родитељ
комит
d7880abda7
1 измењених фајлова са 21 додато и 0 уклоњено
  1. 21 0
      app-ghs/controllers/DeliveryController.php

+ 21 - 0
app-ghs/controllers/DeliveryController.php

@@ -950,7 +950,28 @@ class DeliveryController extends BaseController
                 'platform' => 'didi'
             ];
             DeliveryAuthTokenClass::add($data);
+
+            $templatePath = Yii::getAlias('@common/components/delivery/html/auth-success-template.html');
+            $template = '';
+            if (is_file($templatePath) && is_readable($templatePath)) {
+                $template = file_get_contents($templatePath);
+            }
+            if ($template === false || $template === '') {
+                $template = '<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>{{title}}</title></head><body><h1>{{heading}}</h1><p>{{message}}</p></body></html>';
+            }
+
+            $content = strtr($template, [
+                '{{title}}' => '授权成功',
+                '{{heading}}' => '授权成功',
+                '{{message}}' => '您的滴滴账号已成功完成授权,现在可以返回使用聚合配送服务。',
+            ]);
+
+            $response = Yii::$app->response;
+            $response->format = Response::FORMAT_HTML;
+            $response->content = $content;
             Yii::info('滴滴授权回调保存成功', 'didi');
+
+            return $response;
         } catch (\Exception $e) {
             Yii::error('滴滴授权回调保存失败' . $e->getMessage(), 'didi');
         }