MtController.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace hd\controllers;
  3. use Yii;
  4. use Abbotton\MeituanTakeaway\Application;
  5. class MtController extends PublicController
  6. {
  7. public $guestAccess = [];
  8. private $config = [
  9. 'app_id' => '119094',
  10. 'app_secret' => 'b7e86d768391180f805621b40ec31e33',
  11. 'request_url' => '', // 默认 `https://waimaiopen.meituan.com/api/v1/`
  12. ];
  13. public function actionApi()
  14. {
  15. echo '开发中...';
  16. }
  17. public function actionNewOrder()
  18. {
  19. $post = Yii::$app->request->post();
  20. if(!empty($post)) {
  21. Yii::info('newOrder: ' . json_encode($post));
  22. }
  23. $get = Yii::$app->request->get();
  24. if(!empty($get)) {
  25. Yii::info('newOrder: ' . json_encode($get));
  26. }
  27. return;
  28. $app = new Application($this->config);
  29. $params = ['order_id' => '27061900338318741', 'is_mt_logistics' => 1];
  30. $orderDetail = $app->order->getOrderDetail($params);
  31. print_r(json_decode($orderDetail, true));
  32. // 商品类、活动类接口支持异步队列
  33. $app->goods->async()->create([]);
  34. }
  35. public function actionCancelOrder()
  36. {
  37. $post = Yii::$app->request->post();
  38. if(!empty($post)) {
  39. Yii::info('cancelOrder: ' . json_encode($post));
  40. }
  41. $get = Yii::$app->request->get();
  42. if(!empty($get)) {
  43. Yii::info('cancelOrder: ' . json_encode($get));
  44. }
  45. return;
  46. }
  47. }