|
|
@@ -1,10 +1,10 @@
|
|
|
<?php
|
|
|
namespace mall\controllers;
|
|
|
|
|
|
+use Yii;
|
|
|
use bizMall\shop\classes\ShopClass;
|
|
|
use common\components\delivery\services\DispatchService;
|
|
|
use common\components\util;
|
|
|
-use Yii;
|
|
|
use yii\helpers\ArrayHelper;
|
|
|
|
|
|
class DeliveryController extends BaseController
|
|
|
@@ -27,18 +27,20 @@ class DeliveryController extends BaseController
|
|
|
if (empty($mainId)) {
|
|
|
util::fail('商户不存在');
|
|
|
}
|
|
|
- $weight = $post['weight'] ?? 1;
|
|
|
- $buyType = $post['buyType'] ?? 'huaCai';
|
|
|
+ $buyType = $post['buyType'] ?? 'huaCai'; //订单类型
|
|
|
|
|
|
$order = $this->generateOrderData($buyType, $user, $post);
|
|
|
$ghsShop = ShopClass::getById($ghsShopId);
|
|
|
+ if (empty($ghsShop)) {
|
|
|
+ util::fail('店铺信息不存在');
|
|
|
+ }
|
|
|
+
|
|
|
$ds = new DispatchService($mainId);
|
|
|
$platformQuotes = $ds->getAllPlatformPrice($order, $ghsShop, $orderTime);
|
|
|
if(isset($platformQuotes['error'])){
|
|
|
util::fail($platformQuotes['error']);
|
|
|
}
|
|
|
|
|
|
- $deliveryList = [];
|
|
|
// 格式化各平台报价为前端展示格式
|
|
|
$deliveryList = $ds->formatPlatformQuotesForDisplay($platformQuotes);
|
|
|
// 按 price 从低到高排序
|
|
|
@@ -55,7 +57,7 @@ class DeliveryController extends BaseController
|
|
|
$orderSn = $prefix . round(microtime(true) * 1000);
|
|
|
|
|
|
//构建出 Order 数据
|
|
|
- if($buyType == 'huaCai'){//花材
|
|
|
+ if($buyType == 'huaCai'){//订单类型是:花材
|
|
|
$order = [
|
|
|
'orderSn' => $orderSn,
|
|
|
'customName' => $user['name'],
|
|
|
@@ -72,7 +74,7 @@ class DeliveryController extends BaseController
|
|
|
'prePrice' => floatval($post['totalPrice'] ?? 0),
|
|
|
'actPrice' => floatval($post['totalPrice'] ?? 0),
|
|
|
];
|
|
|
- }elseif($buyType == 'huaShu'){//花束
|
|
|
+ }elseif($buyType == 'huaShu'){//订单类型是:花束
|
|
|
$order = [
|
|
|
'orderSn' => $orderSn,
|
|
|
'customName' => $post['receiveUserName'],
|
|
|
@@ -80,8 +82,8 @@ class DeliveryController extends BaseController
|
|
|
'fullAddress' => $post['address'],
|
|
|
'floor' => $post['floor'] ?? '',
|
|
|
'dist' => $post['dist'] ?? '',
|
|
|
- 'lat' => $post['region']['latitude'],// TODO
|
|
|
- 'long' => $post['region']['longitude'],// TODO
|
|
|
+ 'lat' => $post['region']['latitude'],
|
|
|
+ 'long' => $post['region']['longitude'],
|
|
|
'address' => $post['address'], //'toAddress' => $order['address'],
|
|
|
'city' => $post['city'],
|
|
|
'weight' => $post['weight'] ?? 1,
|