| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace hd\controllers;
- use Yii;
- use Abbotton\MeituanTakeaway\Application;
- use yii\helpers\Json;
- class MtController extends PublicController
- {
- public $guestAccess = [];
- private $config = [
- 'app_id' => '119094',
- 'app_secret' => 'b7e86d768391180f805621b40ec31e33',
- 'request_url' => '', // 默认 `https://waimaiopen.meituan.com/api/v1/`
- ];
- public function actionApi()
- {
- echo '开发中...';
- }
- public function actionNewOrder()
- {
- Yii::info('本框架输出的中文会不会乱码');
- $post = Yii::$app->request->post();
- if(!empty($post)) {
- Yii::warning('newOrder: ' . urldecode(json_encode($post)));
- }
- $get = Yii::$app->request->get();
- if(!empty($get)) {
- Yii::warning('newOrder: ' . json_encode($get));
- }
- return Json::encode(['data' => 'ok']);
- $app = new Application($this->config);
- $params = ['order_id' => '27061900338318741', 'is_mt_logistics' => 1];
- $orderDetail = $app->order->getOrderDetail($params);
- print_r(json_decode($orderDetail, true));
- // 商品类、活动类接口支持异步队列
- $app->goods->async()->create([]);
- }
- public function actionCancelOrder()
- {
- $post = Yii::$app->request->post();
- if(!empty($post)) {
- Yii::warning('cancelOrder: ' . urldecode(json_encode($post)));
- }
- $get = Yii::$app->request->get();
- if(!empty($get)) {
- Yii::warning('cancelOrder: ' . json_encode($get));
- }
- return Json::encode(['data' => 'ok']);
- }
- }
|