MtController.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace hd\controllers;
  3. use Yii;
  4. use Abbotton\MeituanTakeaway\Application;
  5. class MtController extends BaseController
  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. if(!empty($_POST)) {
  28. Yii::info('newOrder: ' . json_encode($_POST));
  29. }
  30. return;
  31. $app = new Application($this->config);
  32. $params = ['order_id' => '27061900338318741', 'is_mt_logistics' => 1];
  33. $orderDetail = $app->order->getOrderDetail($params);
  34. print_r(json_decode($orderDetail, true));
  35. // 商品类、活动类接口支持异步队列
  36. $app->goods->async()->create([]);
  37. }
  38. public function actionCancelOrder()
  39. {
  40. $post = Yii::$app->request->post();
  41. if(!empty($post)) {
  42. Yii::info('cancelOrder: ' . json_encode($post));
  43. }
  44. $get = Yii::$app->request->get();
  45. if(!empty($get)) {
  46. Yii::info('cancelOrder: ' . json_encode($get));
  47. }
  48. if(!empty($_POST)) {
  49. Yii::info('cancelOrder: ' . json_encode($_POST));
  50. }
  51. return;
  52. }
  53. }