'119094', 'app_secret' => 'b7e86d768391180f805621b40ec31e33', 'request_url' => '', // 默认 `https://waimaiopen.meituan.com/api/v1/` ]; public function actionApi() { echo '开发中...'; } public function actionNewOrder() { $post = Yii::$app->request->post(); if(empty($post)) { // 无数据过来时,是美团对接口进行存活试探,请保留此段代码,好让请求在此被中断返回 return Json::encode(['data' => 'ok']); } // 美团传入的订单数据,中文是 URL_encode 的,执行下解密 foreach($post as $k => $val) { $post[$k] = urldecode($val); } $data = arrayUtil::humpUnderlineConversion($post, 1); $orderId = $data['orderId']; $mtOrder = MtOrderClass::getByCondition(['orderId' => $orderId]); if (!empty($mtOrder)) { Yii::warning('订单号已存在:' . $orderId); return Json::encode(['data' => 'ok']); } $mtOrder = MtOrderClass::add($data); $picArr = []; $app = new Application($this->config); $items = explode(trim($data['detail'], '[]'), ','); foreach($items as $item){ $item = json_decode($item, true); $appSpuCode = $item['app_spu_code']; $params = ['app_poi_code' => $data['app_poi_code'], 'app_spu_code' => $appSpuCode]; $retailDetail = $app->retail->getDetail($params); $pic[$appSpuCode] = $retailDetail['picture']; } Yii::info('picture: ' . json_encode($pic)); return Json::encode(['data' => 'ok']); } public function actionCancelOrder() { $post = Yii::$app->request->post(); if(!empty($post)) { Yii::warning('cancelOrder: ' . urldecode(json_encode($post))); } return Json::encode(['data' => 'ok']); } public function demo() { $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([]); } }