|
|
@@ -0,0 +1,155 @@
|
|
|
+<?php
|
|
|
+namespace hd\controllers;
|
|
|
+
|
|
|
+use biz\ghs\classes\GhsClass;
|
|
|
+use bizGhs\custom\classes\CustomClass;
|
|
|
+use Yii;
|
|
|
+use biz\shop\classes\ShopClass;
|
|
|
+use common\components\delivery\services\DispatchService;
|
|
|
+use common\components\util;
|
|
|
+use ghs\controllers\BaseController;
|
|
|
+
|
|
|
+class DeliveryController extends BaseController
|
|
|
+{
|
|
|
+ // 获取多个平台报价
|
|
|
+ public function actionAllDeliveryQuotes()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $orderTime = date('Y-m-d H:i:s');
|
|
|
+ // --------- $ghsShopId ----------
|
|
|
+ $ghsId = $post['ghsId'] ?? 0;
|
|
|
+ $ghs = GhsClass::getById($ghsId, true);
|
|
|
+ if (empty($ghs)) {
|
|
|
+ util::fail('获取批发商失败');
|
|
|
+ }
|
|
|
+ $ghsShopId = $ghs->shopId ?? 0;
|
|
|
+ //$ghsShopId = $post['shopId'];
|
|
|
+
|
|
|
+ // --------- $customId
|
|
|
+ $customId = $ghs->customId ?? 0;
|
|
|
+ $custom = CustomClass::getById($customId, true);
|
|
|
+ if (empty($custom)) {
|
|
|
+ util::fail('获取custom数据失败');
|
|
|
+ }
|
|
|
+ $weight = $post['weight'] ?? 1;
|
|
|
+
|
|
|
+ //$orderId = intval($post['orderId']);
|
|
|
+ //$order = OrderClass::getById($orderId);
|
|
|
+ //构建出 Order 数据
|
|
|
+ $order = [
|
|
|
+ 'orderSn' => '',
|
|
|
+ 'customName' => $custom['name'],
|
|
|
+ 'customMobile' => $custom['mobile'],
|
|
|
+ 'fullAddress' => $custom['fullAddress'],
|
|
|
+ 'floor' => $custom['floor'],
|
|
|
+ 'dist' => $custom['dist'],
|
|
|
+ 'lat' => $custom['lat'],
|
|
|
+ 'long' => $custom['long'],
|
|
|
+ 'address' => $custom['address'], //'toAddress' => $order['address'],
|
|
|
+ 'city' => $custom['city'],
|
|
|
+ 'weight' => $weight,
|
|
|
+ 'remark' => '',
|
|
|
+ 'prePrice' => 10,
|
|
|
+ 'actPrice' => 10,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $arr2 = [
|
|
|
+ //'goods_count' => count($goodsItemList), // 这个应该是通过 orderSn 查询出来的,如果 orderSn 是假的怎么办? -- 提供临时的
|
|
|
+ ];
|
|
|
+
|
|
|
+ $ghsShop = ShopClass::getById($ghsShopId);
|
|
|
+
|
|
|
+ $ghsMainId = $ghs->mainId;
|
|
|
+ $ds = new DispatchService($ghsMainId);
|
|
|
+ $platformQuotes = $ds->getAllPlatformPrice($order, $ghsShop, $orderTime);
|
|
|
+
|
|
|
+ $deliveryList = [];
|
|
|
+ foreach ($platformQuotes['quotes'] as $item) {
|
|
|
+ switch ($item['platform']) {
|
|
|
+ case 'shunfeng':
|
|
|
+ $deliveryList[] = [
|
|
|
+ 'name' => '顺丰',
|
|
|
+ 'en_name' => 'shunfeng',
|
|
|
+ 'price' => $item['real_pay_money'],
|
|
|
+ 'distance' => $item['distance'],
|
|
|
+ 'type' => '',
|
|
|
+ 'isAble' => true
|
|
|
+ ];
|
|
|
+ break;
|
|
|
+ case 'shansong':
|
|
|
+ $deliveryList[] = [
|
|
|
+ 'name' => '闪送',
|
|
|
+ 'en_name' => 'shansong',
|
|
|
+ 'price' => $item['total_amount'],
|
|
|
+ 'distance' => $item['total_distance'],
|
|
|
+ 'type' => '',
|
|
|
+ 'issOrderNo' => $item['order_number'],
|
|
|
+ 'isAble' => true
|
|
|
+ ];
|
|
|
+ break;
|
|
|
+ case 'fengniao':
|
|
|
+ // 循环遍历 goods_infos 数组,提取有效项的信息
|
|
|
+ $validGoods = [];
|
|
|
+ if (!empty($item['goods_infos']) && is_array($item['goods_infos'])) {
|
|
|
+ foreach ($item['goods_infos'] as $good) {
|
|
|
+ if (!empty($good['is_valid']) && $good['is_valid'] == 1) {
|
|
|
+ $validGoods[] = [
|
|
|
+ 'actual_delivery_amount_cent' => $good['actual_delivery_amount_cent'] ?? 0,
|
|
|
+ 'service_goods_id' => $good['service_goods_id'] ?? ''
|
|
|
+ ];
|
|
|
+
|
|
|
+ $deliveryList[] = [
|
|
|
+ 'name' => '蜂鸟'. ' (' .$good['base_goods_id'] . ')',
|
|
|
+ 'en_name' => 'fengniao',
|
|
|
+ 'price' => $good['actual_delivery_amount_cent'],
|
|
|
+ 'distance' => $item['distance'],
|
|
|
+ 'valid_goods' => $validGoods,
|
|
|
+ 'type' => $good['slogan'],
|
|
|
+ 'isAble' => true
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ $deliveryList[] = [
|
|
|
+ 'name' => '蜂鸟'. ' (' .$good['base_goods_id'] . ')',
|
|
|
+ 'en_name' => 'fengniao',
|
|
|
+ 'price' => 0,
|
|
|
+ 'distance' => $item['distance'],
|
|
|
+ 'valid_goods' => $good,
|
|
|
+ 'type' => $good['disable_reason'],
|
|
|
+ 'isAble' => false
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'huolala':
|
|
|
+ foreach($item['price_info_list'] as $arr) {
|
|
|
+ $priceInfo = $arr['calculate_price_info'];
|
|
|
+ $vehicleType = $arr['vehicle_type'];
|
|
|
+ $deliveryList[] = [
|
|
|
+ 'name' => '货拉拉' . ' (' . $vehicleType['_meta']['vehicle_type'] . ')',
|
|
|
+ 'en_name' => 'huolala',
|
|
|
+ 'price' => $priceInfo['price_conditions'][0]['price_info']['total_price'],
|
|
|
+ 'distance' => $priceInfo['distance_info']['distance_total'],
|
|
|
+ 'type' => $vehicleType['_meta']['vehicle_type'],
|
|
|
+ 'isAble' => true,
|
|
|
+ // ---------------------------------------------
|
|
|
+ 'order_vehicle_id' => $vehicleType['order_vehicle_id'],
|
|
|
+ 'city_id' => $item['city_id'],
|
|
|
+ 'city_info_revision' => $vehicleType['city_info_revision'],
|
|
|
+ // // 下单需要透传的数据
|
|
|
+ 'vehicle_std' => $vehicleType['vehicle_std'],
|
|
|
+ 'spec_req' => $vehicleType['spec_req'],
|
|
|
+ 'price_calculate_id' => $priceInfo['price_calculate_id'],
|
|
|
+ 'price_item_encryption' => $priceInfo['price_conditions'][0]['price_item_encryption'],
|
|
|
+ 'vehicle_attr' => $priceInfo['vehicle_info']['vehicle_attr'],
|
|
|
+ 'commodity_info' => $priceInfo['price_conditions'][0]['commodity_item'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $ret['deliveryList'] = $deliveryList;
|
|
|
+ util::success($ret, "success");
|
|
|
+ }
|
|
|
+}
|