DispatchService.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <?php
  2. namespace common\components\delivery\services;
  3. use biz\shop\classes\ShopClass;
  4. use bizGhs\express\classes\DeliveryAuthTokenClass;
  5. use bizGhs\order\classes\OrderClass;
  6. use bizGhs\order\classes\OrderItemClass;
  7. use common\components\delivery\helpers\HttpClient;
  8. use common\components\delivery\services\adapter\{ ShansongAdapter, HuolalaAdapter, FengniaoAdapter, ShunfengAdapter}; // MeituanAdapter, DadaAdapter, SFAdapter, UUAdapter,
  9. use common\components\delivery\models\{DeliveryOrder, DeliveryAccount};
  10. use Yii;
  11. /**
  12. * 聚合调度逻辑(平台选择/优先级)
  13. * Class DispatchService
  14. * @package App\Services
  15. */
  16. class DispatchService
  17. {
  18. protected $adapters;
  19. protected $platformName = '';
  20. public function __construct($mainId, $platform='')
  21. {
  22. if ($platform == '') {
  23. $authPlatforms = DeliveryAuthTokenClass::getAllByCondition(['mainId'=>$mainId]);
  24. foreach($authPlatforms as $pt) {
  25. switch ($pt['platform']) {
  26. case 'shansong':
  27. $this->adapters['shansong'] = new ShansongAdapter($pt['accessToken']);
  28. break;
  29. case 'huolala':
  30. $this->adapters['huolala'] = new HuolalaAdapter($pt['accessToken']);
  31. break;
  32. case 'fengniao':
  33. $adapter = new FengniaoAdapter($pt['accessToken']);
  34. $adapter->setMerchantId(14594092); // TODO: 确认是否需要使用动态的商户ID
  35. $this->adapters['fengniao'] = $adapter;
  36. break;
  37. case 'shunfeng':
  38. $this->adapters['shunfeng'] = new ShunfengAdapter($pt['accessToken'], $pt['shopId']);
  39. break;
  40. }
  41. }
  42. } else {
  43. $authPlatform = DeliveryAuthTokenClass::getByCondition(['mainId'=>$mainId, 'platform'=>$platform]);
  44. switch ($platform) {
  45. case 'shansong':
  46. $this->adapters['shansong'] = new ShansongAdapter($authPlatform['accessToken']);
  47. break;
  48. case 'huolala':
  49. $this->adapters['huolala'] = new HuolalaAdapter($authPlatform['accessToken']);
  50. break;
  51. case 'fengniao':
  52. //$this->adapters['fengniao'] = new FengniaoAdapter($authPlatform['accessToken']);
  53. $adapter = new FengniaoAdapter($authPlatform['accessToken']);
  54. $adapter->setMerchantId(14594092); // TODO: 确认是否需要使用动态的商户ID
  55. $this->adapters['fengniao'] = $adapter;
  56. break;
  57. case 'shunfeng':
  58. $this->adapters['shunfeng'] = new ShunfengAdapter($authPlatform['accessToken'], $authPlatform['shopId']);
  59. break;
  60. }
  61. $this->platformName = $platform;
  62. }
  63. //$this->adapters = [
  64. //'meituan' => new MeituanAdapter(),
  65. //'dada' => new DadaAdapter(),
  66. //'sf' => new SFAdapter(),
  67. //'uu' => new UUAdapter(),
  68. //'fengniao' => new FengniaoAdapter(),
  69. //];
  70. }
  71. /**
  72. * 发单调度
  73. */
  74. public function createOrder($order, $shopId, $params)
  75. {
  76. $order = $order->toArray();
  77. $shop = ShopClass::getById($shopId, false, 'id,merchantName,fullAddress,lat,long,city,dist,floor,mobile,merchantName,mobile');
  78. $adapter = $this->getAdapter();
  79. $orderData = $adapter->formatOrderData($order, $shop, $params);
  80. return $adapter->createOrder($orderData);
  81. }
  82. /**
  83. * @param $orderId 平台订单号
  84. * @param string $thirdOrderNo xhGhsOrder.orderSn
  85. */
  86. public function selectOrder($orderId, $thirdOrderNo='')
  87. {
  88. $adapter = $this->getAdapter();
  89. if ($adapter instanceof ShansongAdapter) {
  90. return $adapter->selectOrder($orderId, $thirdOrderNo);
  91. }
  92. return $adapter->selectOrder($orderId);
  93. }
  94. public function cancelOrder($orderId, $reason)
  95. {
  96. $adapter = $this->getAdapter();
  97. return $adapter->cancelOrder($orderId, $reason);
  98. }
  99. public function getCancelReasonList($orderId)
  100. {
  101. $adapter = $this->getAdapter();
  102. return $adapter->getCancelReasonList($orderId);
  103. }
  104. public function getAdapter()
  105. {
  106. return $this->adapters[$this->platformName];
  107. }
  108. /**
  109. * 获取所有平台的最佳报价(使用 Guzzle 并发请求)
  110. *
  111. * 流程说明:
  112. * 1. 同步准备各平台的前置数据(如城市信息、订单商品等)
  113. * 2. 使用 Guzzle Pool 并发发送各平台的报价请求(5秒超时)
  114. * 3. 某个平台失败/超时不影响其他平台,继续等待结果
  115. *
  116. * @param array $order 订单信息
  117. * @param array $shop 店铺信息
  118. * @return array 返回所有平台的报价结果
  119. */
  120. public function getAllPlatformPrice($order, $shop, $orderTime)
  121. {
  122. // 第一步:准备前置数据(同步进行,因为某些平台需要这些数据)
  123. $preparedData = $this->preparePlatformData($order, $shop, $orderTime);
  124. if (empty($preparedData)) {
  125. return ['error' => '所有平台数据准备失败'];
  126. }
  127. // 第二步:并发调用各平台的报价接口
  128. $results = $this->concurrentGetPrices($preparedData, $orderTime);
  129. if (empty($results['success']) && empty($results['failed'])) {
  130. return ['error' => '没有可用的物流平台'];
  131. }
  132. // 格式化返回结果
  133. return [
  134. 'quotes' => array_values($results['success'] ?? []),
  135. 'failed' => $results['failed'] ?? [],
  136. ];
  137. }
  138. /**
  139. * 为各平台准备订单数据(前置数据同步获取)
  140. *
  141. * @param array $order 订单信息
  142. * @param array $shop 店铺信息
  143. * @return array 各平台的订单数据
  144. */
  145. private function preparePlatformData($order, $shop)
  146. {
  147. $preparedData = [];
  148. // 准备 Huolala 数据
  149. if (isset($this->adapters['huolala'])) {
  150. try {
  151. $preparedData['huolala'] = $this->prepareHuolalaData($order, $shop);
  152. } catch (\Exception $e) {
  153. Yii::warning("Huolala 数据准备失败: {$e->getMessage()}");
  154. }
  155. }
  156. // 准备 Fengniao 数据
  157. if (isset($this->adapters['fengniao'])) {
  158. try {
  159. $preparedData['fengniao'] = $this->prepareFengniaoData($order, $shop);
  160. } catch (\Exception $e) {
  161. Yii::warning("Fengniao 数据准备失败: {$e->getMessage()}");
  162. }
  163. }
  164. // 准备 Shansong 数据
  165. if (isset($this->adapters['shansong'])) {
  166. try {
  167. $preparedData['shansong'] = $this->prepareShansongData($order, $shop);
  168. } catch (\Exception $e) {
  169. Yii::warning("Shansong 数据准备失败: {$e->getMessage()}");
  170. }
  171. }
  172. // 准备顺丰订单数据
  173. if (isset($this->adapters['shunfeng'])) {
  174. try {
  175. $preparedData['shunfeng'] = $this->prepareShunfengData($order, $shop);
  176. } catch (\Exception $e) {
  177. Yii::warning("Shunfeng 数据准备失败: {$e->getMessage()}");
  178. }
  179. }
  180. return $preparedData;
  181. }
  182. /**
  183. * 准备货拉拉订单数据
  184. */
  185. private function prepareHuolalaData($order, $shop)
  186. {
  187. $formatCity = rtrim($order['city'], '市');
  188. $cities = include Yii::getAlias('@common/components/delivery/platform/huolala/cities.php');
  189. if (!isset($cities[$formatCity])) {
  190. throw new \Exception('城市编码表中没有找到城市: ' . $formatCity);
  191. }
  192. $cityId = $cities[$formatCity]['city_id'];
  193. $cityVehicleList = $this->adapters['huolala']->getCityVehicleList($cityId); // 产生外部请求 -- TODO 优化成不耗时等待
  194. $cityInfoRevision = $cityVehicleList['city_info_revision'];
  195. // 获取所有车型列表
  196. $vehicleList = $cityVehicleList['vehicle_list'];
  197. if (empty($vehicleList)) {
  198. throw new \Exception('没有找到可选车型');
  199. }
  200. // 解析额外需求
  201. $specReqItem = $cityVehicleList['spec_req_item'] ?? [];
  202. $specReq = [];
  203. foreach ($specReqItem as $item) {
  204. $specReq[] = $item['type'] ?? null;
  205. }
  206. $specReq = array_filter($specReq);
  207. // 构建所有车型数据
  208. $vehicleTypeList = [];
  209. foreach ($vehicleList as $vehicle) {
  210. $vehicleStd = [];
  211. $vehicleStd[] = count($vehicle['vehicle_std_item']) > 0 ? $vehicle['vehicle_std_item'][0]['name'] : '';
  212. $vehicleTypeList[$vehicle['order_vehicle_id']] = [
  213. 'order_vehicle_id' => $vehicle['order_vehicle_id'],
  214. 'city_info_revision' => $cityInfoRevision,
  215. 'order_time' => time() + 600,
  216. 'addr_info' => [
  217. [
  218. 'name' => $shop['merchantName'],
  219. 'addr' => $shop['province'] . $shop['city'] . $shop['dist'] . $shop['address'],
  220. 'city_id' => $cityId,
  221. 'city_name' => $shop['city'],
  222. 'district_name' => $shop['dist'],
  223. 'house_number' => $shop['floor'],
  224. 'contacts_name' => $shop['mobile'],
  225. 'contacts_phone_no' => $shop['mobile'],
  226. 'lat_lon' => ['lat' => (float)$shop['lat'], 'lon' => (float)$shop['long']],
  227. ],
  228. [
  229. 'name' => $order['customName'],
  230. 'addr' => $order['fullAddress'],
  231. 'city_id' => $cityId,
  232. 'city_name' => $order['city'],
  233. 'district_name' => $order['dist'],
  234. 'house_number' => $order['floor'],
  235. 'contacts_name' => $order['customName'],
  236. 'contacts_phone_no' => $order['customMobile'],
  237. 'lat_lon' => ['lat' => (float)$order['lat'], 'lon' => (float)$order['long']],
  238. ]
  239. ],
  240. 'vehicle_std' => $vehicleStd,
  241. 'spec_req' => array_values($specReq),
  242. 'coupon_id' => 123456,
  243. 'invoice_type' => 1,
  244. 'order_service_type' => 1,
  245. '_meta' => [
  246. 'vehicle_type' => $vehicle['vehicle_name'],
  247. 'city_info_revision' => $cityInfoRevision,
  248. ]
  249. ];
  250. }
  251. return [
  252. 'platform' => 'huolala',
  253. 'city_id' => $cityId,
  254. 'vehicle_type_list' => $vehicleTypeList,
  255. ];
  256. }
  257. /**
  258. * 准备蜂鸟订单数据
  259. */
  260. private function prepareFengniaoData($order, $shop)
  261. {
  262. $this->adapters['fengniao']->setMerchantId(14594092); // TODO: 确认是否需要使用动态的商户ID
  263. $itemInfos = OrderItemClass::getAllByCondition(['orderSn' => $order['orderSn']], null, 'id, name, unitPrice, num');
  264. $goodsItemList = [];
  265. foreach ($itemInfos as $item) {
  266. $goodsItemList[] = [
  267. 'item_actual_amount_cent' => (int)($item['unitPrice'] * 100 * $item['num']),
  268. 'item_amount_cent' => (int)($item['unitPrice'] * 100),
  269. 'item_id' => $item['id'],
  270. 'item_name' => $item['name'],
  271. 'item_quantity' => $item['num'],
  272. ];
  273. }
  274. return [
  275. 'platform' => 'fengniao',
  276. 'partner_order_code' => $order['orderSn'],
  277. 'receiver_primary_phone' => $order['customMobile'],
  278. 'receiver_name' => $order['customName'],
  279. 'receiver_latitude' => (float)$order['lat'],
  280. 'receiver_longitude' => (float)$order['long'],
  281. 'receiver_address' => $order['fullAddress'],
  282. 'position_source' => 3,
  283. 'goods_count' => count($goodsItemList),
  284. 'goods_weight' => (float)$order['weight'],
  285. 'goods_total_amount_cent' => (int)($order['prePrice'] * 100),
  286. 'goods_actual_amount_cent' => (int)($order['actPrice'] * 100),
  287. 'goods_item_list' => $goodsItemList,
  288. 'order_type' => 1,
  289. 'chain_store_id' => 467788524,
  290. 'order_remark' => $order['remark'] ?? '',
  291. ];
  292. }
  293. /**
  294. * 准备闪送订单数据
  295. */
  296. private function prepareShansongData($order, $shop)
  297. {
  298. return [
  299. 'platform' => 'shansong',
  300. 'city_name' => $shop['city'],
  301. 'sender' => [
  302. 'from_address' => $shop['address'],
  303. 'from_address_detail' => $shop['floor'],
  304. 'from_sender_name' => $shop['shopName'],
  305. 'from_mobile' => $shop['mobile'],
  306. 'from_latitude' => (float)$shop['lat'],
  307. 'from_longitude' => (float)$shop['long'],
  308. ],
  309. 'receiver_list' => [
  310. [
  311. 'order_no' => $order['orderSn'],
  312. 'to_address' => $order['address'],
  313. 'to_address_detail' => $order['floor'],
  314. 'to_receiver_name' => $order['customName'],
  315. 'to_mobile' => $order['customMobile'],
  316. 'to_latitude' => (float)$order['lat'],
  317. 'to_longitude' => (float)$order['long'],
  318. 'good_type' => 7,
  319. 'weight' => (int)$order['weight'],
  320. 'remarks' => $order['remark'] ?? '',
  321. ]
  322. ],
  323. 'appoint_type' => 0,
  324. 'appointment_date' => '',
  325. 'travel_way' => 0,
  326. 'delivery_type' => 1,
  327. 'expect_start_time' => null,
  328. 'expect_end_time' => null,
  329. ];
  330. }
  331. /**
  332. * 准备顺丰订单数据
  333. */
  334. private function prepareShunfengData($order, $shop)
  335. {
  336. // 获取订单商品信息
  337. $itemInfos = OrderItemClass::getAllByCondition(['orderSn' => $order['orderSn']], null, 'id, name, unitPrice, num, unitWeight');
  338. // 计算商品总重量(单位:克)
  339. $totalWeight = 0;
  340. foreach ($itemInfos as $item) {
  341. $totalWeight += (int)($item['unitWeight'] * $item['num']) * 1000;
  342. }
  343. // 如果没有商品重量,使用订单重量
  344. if ($totalWeight == 0 && isset($order['weight'])) {
  345. $totalWeight = (int)$order['weight'] * 1000;
  346. }
  347. // 默认重量为1000克(1公斤)
  348. if ($totalWeight == 0) {
  349. $totalWeight = 1000;
  350. }
  351. return [
  352. 'platform' => 'shunfeng',
  353. 'user_lng' => (string)$order['long'], // 用户地址经度
  354. 'user_lat' => (string)$order['lat'], // 用户地址纬度
  355. 'user_address' => $order['fullAddress'], // 用户详细地址
  356. 'weight' => $totalWeight, // 物品重量(单位:克)
  357. 'product_type' => 4, // 物品类型(4:鲜花绿植)
  358. 'push_time' => time(), // 推单时间(秒级时间戳)
  359. 'shop' => [ // 发货店铺信息
  360. 'shop_name' => $shop['merchantName'], // 店铺名称
  361. 'shop_address' => $shop['address'], // 店铺地址
  362. 'shop_lng' => (string)$shop['long'], // 店铺经度
  363. 'shop_lat' => (string)$shop['lat'], // 店铺纬度
  364. 'shop_phone' => $shop['mobile'], // 店铺联系电话
  365. ],
  366. //-------------------------- 非必填 -------------------------------
  367. 'city_name' => $order['city'], // 发单城市
  368. //'order_source' => '6', // 订单接入来源(6:京东秒送,可自定义)
  369. 'source_origin_order_id' => $order['orderSn'], // 商流订单号
  370. 'total_price' => (int)($order['actPrice'] * 100), // 用户订单总金额(单位:分)
  371. 'is_appoint' => 0, // 是否预约单(0:非预约单)
  372. 'appoint_type' => 0, // TODO 预约单类型(0:立即单)
  373. 'expect_time' => 0, // TODO 用户期望送达时间
  374. //'expect_pickup_time' => 0, // TODO 用户期望上门时间 -- appoint_type=2时需必传,秒级时间戳
  375. 'shop_expect_time' => 0, // TODO 商家期望送达时间 -- 格式为:{timestamp},
  376. 'lbs_type' => 2, // 坐标类型(2:高德坐标)
  377. 'is_insured' => 0, // 是否保价(0:非保价)
  378. 'is_person_direct' => 0, // 是否专人直送(0:否)
  379. 'vehicle' => 0, // 配送交通工具(0:否)
  380. //'four_wheeler_type' => 0, // 车型 -- 只有vehicle = 2,⻋型字段才有效。
  381. 'declared_value' => 0, // 保价金额(单位:分)
  382. 'gratuity_fee' => 0, // 订单小费(单位:分)
  383. 'rider_pick_method' => 1, // 物流流向(1:从门店取件送至用户)
  384. 'return_flag' => 511, // 返回字段控制标志位(511:全部返回)
  385. 'multi_pickup_info' => [], // 多点取货信息(暂不使用)
  386. ];
  387. }
  388. /**
  389. * 并发获取各平台报价(核心实现)
  390. *
  391. * 使用 HttpClient::postConcurrent 实现真正的并发调用,每个平台请求 5 秒超时。
  392. * 某个平台的超时或失败不会影响其他平台的执行。
  393. *
  394. * @param array $preparedData 准备好的各平台数据
  395. * @param string $orderTime 配送时间
  396. * @return array 包含成功和失败结果
  397. */
  398. private function concurrentGetPrices($preparedData, $orderTime)
  399. {
  400. $results = [
  401. 'success' => [],
  402. 'failed' => [],
  403. ];
  404. // 第一步:收集所有平台的请求信息
  405. $allRequests = [];
  406. $platformMapping = []; // 用于将请求标识映射回平台名称
  407. foreach ($preparedData as $platform => $data) {
  408. try {
  409. if (!isset($this->adapters[$platform])) {
  410. $results['failed'][$platform] = '平台适配器未初始化';
  411. continue;
  412. }
  413. $adapter = $this->adapters[$platform];
  414. // 根据平台类型调用相应的 buildPriceRequest(s) 方法
  415. if ($platform === 'huolala') {
  416. // 货拉拉返回多个请求(一个请求对应一个车型)
  417. $priceRequests = $adapter->buildPriceRequests($data, $orderTime);
  418. foreach ($priceRequests as $requestKey => $requestInfo) {
  419. $allRequests[$requestKey] = $requestInfo;
  420. $platformMapping[$requestKey] = ['platform' => 'huolala', 'data' => $data];
  421. }
  422. } else {
  423. // 其他平台(蜂鸟、闪送)各返回一个请求
  424. $requestInfo = $adapter->buildPriceRequest($data, $orderTime);
  425. $requestKey = "{$platform}_quote";
  426. $allRequests[$requestKey] = $requestInfo;
  427. $platformMapping[$requestKey] = ['platform' => $platform, 'data' => $data];
  428. }
  429. } catch (\Throwable $e) {
  430. $results['failed'][$platform] = "构建请求失败: {$e->getMessage()}";
  431. Yii::error("[DispatchService] {$platform} 构建请求异常: {$e->getMessage()}");
  432. }
  433. }
  434. if (empty($allRequests)) {
  435. return $results;
  436. }
  437. // 第二步:使用 postConcurrent 并发发送所有请求
  438. $startTime = microtime(true);
  439. $concurrentResults = HttpClient::postConcurrent($allRequests, 3);
  440. $totalDuration = microtime(true) - $startTime;
  441. Yii::info("[DispatchService] 所有报价请求完成 (" . round($totalDuration * 1000) . "ms)");
  442. // 第三步:处理并发请求的结果
  443. foreach ($concurrentResults['success'] as $requestKey => $response) {
  444. if (!isset($platformMapping[$requestKey])) {
  445. continue;
  446. }
  447. $mapping = $platformMapping[$requestKey];
  448. $platform = $mapping['platform'];
  449. $data = $mapping['data'];
  450. try {
  451. $adapter = $this->adapters[$platform];
  452. $quote = null;
  453. if ($platform === 'huolala') {
  454. // 货拉拉的响应处理
  455. $quote = $adapter->processPriceResponse($response);
  456. if ($quote && !isset($results['success']['huolala'])) {
  457. // 第一次处理货拉拉的结果,初始化
  458. $results['success']['huolala'] = [
  459. 'platform' => 'huolala',
  460. 'city_id' => $data['city_id'],
  461. 'vehicle_type_list' => $data['vehicle_type_list'],
  462. 'price_info_list' => [],
  463. ];
  464. }
  465. $keyArr = explode('_', $requestKey);
  466. $vehicle_type_list_key = $keyArr[2];
  467. // 将该车型的报价加入到列表中
  468. if ($quote && isset($results['success']['huolala'])) {
  469. $results['success']['huolala']['price_info_list'][] = [
  470. 'calculate_price_info' => isset($quote['calculate_price_info_list']) ? $quote['calculate_price_info_list'][0] : [],
  471. 'vehicle_type' => $data['vehicle_type_list'][$vehicle_type_list_key]
  472. ];
  473. }
  474. } else {
  475. // 蜂鸟和闪送的响应处理
  476. $quote = $adapter->processPriceResponse($response);
  477. if ($quote && !isset($quote['error'])) {
  478. $quote['_duration'] = $totalDuration;
  479. $results['success'][$platform] = $quote;
  480. Yii::info("[DispatchService] {$platform} 报价成功 (" . round($totalDuration * 1000) . "ms)");
  481. } else {
  482. $errorMsg = $quote['error'] ?? '报价返回数据为空';
  483. $results['failed'][$platform] = $errorMsg;
  484. Yii::warning("[DispatchService] {$platform} 报价返回错误: {$errorMsg}");
  485. }
  486. }
  487. } catch (\Throwable $e) {
  488. $platform = $mapping['platform'];
  489. $results['failed'][$platform] = "处理响应失败: {$e->getMessage()}";
  490. Yii::error("[DispatchService] {$platform} 处理响应异常: {$e->getMessage()}");
  491. }
  492. }
  493. // 第四步:处理失败的请求
  494. foreach ($concurrentResults['failed'] as $requestKey => $errorMsg) {
  495. if (!isset($platformMapping[$requestKey])) {
  496. continue;
  497. }
  498. $platform = $platformMapping[$requestKey]['platform'];
  499. // 对于货拉拉,只记录某个车型失败,不影响整体平台状态
  500. if ($platform === 'huolala') {
  501. Yii::warning("[DispatchService] huolala 车型报价失败 ({$requestKey}): {$errorMsg}");
  502. } else {
  503. if (!isset($results['failed'][$platform])) {
  504. $results['failed'][$platform] = $errorMsg;
  505. Yii::error("[DispatchService] {$platform} 报价请求失败: {$errorMsg}");
  506. }
  507. }
  508. }
  509. // 为货拉拉添加元数据
  510. if (isset($results['success']['huolala'])) {
  511. $results['success']['huolala']['_duration'] = $totalDuration;
  512. }
  513. return $results;
  514. }
  515. public function openCitiesLists($platform)
  516. {
  517. $ap = $this->adapters[$platform];
  518. return $ap->cityList();
  519. }
  520. }