MtController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. Yii::info('本框架输出的中文会不会乱码');
  20. $post = Yii::$app->request->post();
  21. if(!empty($post)) {
  22. Yii::warning('newOrder: ' . urldecode(json_encode($post)));
  23. }
  24. $get = Yii::$app->request->get();
  25. if(!empty($get)) {
  26. Yii::warning('newOrder: ' . json_encode($get));
  27. }
  28. return;
  29. $app = new Application($this->config);
  30. $params = ['order_id' => '27061900338318741', 'is_mt_logistics' => 1];
  31. $orderDetail = $app->order->getOrderDetail($params);
  32. print_r(json_decode($orderDetail, true));
  33. // 商品类、活动类接口支持异步队列
  34. $app->goods->async()->create([]);
  35. }
  36. public function actionCancelOrder()
  37. {
  38. $post = Yii::$app->request->post();
  39. if(!empty($post)) {
  40. Yii::warning('cancelOrder: ' . urldecode(json_encode($post)));
  41. }
  42. $get = Yii::$app->request->get();
  43. if(!empty($get)) {
  44. Yii::warning('cancelOrder: ' . json_encode($get));
  45. }
  46. return;
  47. }
  48. }