|
|
@@ -5,7 +5,6 @@ namespace hd\controllers;
|
|
|
use biz\common\classes\HdNotifyClass;
|
|
|
use Yii;
|
|
|
use biz\ghs\classes\GhsClass;
|
|
|
-use bizGhs\custom\classes\CustomClass;
|
|
|
use bizGhs\express\classes\DeliveryAuthTokenClass;
|
|
|
use bizHd\order\classes\OrderClass;
|
|
|
use bizHd\express\classes\HdDeliveryOrderClass;
|
|
|
@@ -97,6 +96,59 @@ class DeliveryController extends BaseController
|
|
|
util::success($ret, "success");
|
|
|
}
|
|
|
|
|
|
+ // 花店快捷开单时 -- 获取各跑腿平台报价
|
|
|
+ public function actionQuickOrderDeliveryQuotes()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $orderTime = date('Y-m-d H:i:s');
|
|
|
+
|
|
|
+ // --------- $customId ----------
|
|
|
+ $customId = $post['customId'];
|
|
|
+ $custom = \bizHd\custom\classes\CustomClass::getById($customId, true);
|
|
|
+ if (empty($custom)) {
|
|
|
+ util::fail('获取custom数据失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 生成随机订单号,不要跟原来的混起来,跑腿-销售单-
|
|
|
+ $prefix = 'PT-XSD-' . $this->mainId . '-';
|
|
|
+ $orderSn = $prefix . round(microtime(true) * 1000);
|
|
|
+
|
|
|
+ //构建出 Order 数据
|
|
|
+ $order = [
|
|
|
+ 'orderSn' => $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' => $post['weight'] ?? 1,
|
|
|
+ //'remark' => $post['remark'] ?? '',
|
|
|
+ 'prePrice' => floatval($post['totalPrice'] ?? 0),
|
|
|
+ 'actPrice' => floatval($post['totalPrice'] ?? 0),
|
|
|
+ ];
|
|
|
+
|
|
|
+ $shop = ShopClass::getById($this->shopId);
|
|
|
+
|
|
|
+ $ds = new DispatchService($this->mainId);
|
|
|
+ $ds->validateOrder($order); //对 $order 进行验证
|
|
|
+ $platformQuotes = $ds->getAllPlatformPrice($order, $shop, $orderTime);
|
|
|
+ if (isset($platformQuotes['error'])) {
|
|
|
+ util::fail($platformQuotes['error']);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 格式化各平台报价为前端展示格式
|
|
|
+ $deliveryList = $ds->formatPlatformQuotesForDisplay($platformQuotes);
|
|
|
+ // 按 price 从低到高排序
|
|
|
+ ArrayHelper::multisort($deliveryList, 'price', SORT_ASC);
|
|
|
+
|
|
|
+ $ret['deliveryList'] = $deliveryList;
|
|
|
+ util::success($ret, "success");
|
|
|
+ }
|
|
|
+
|
|
|
// 花店向批发买花时 -- 获取各跑腿平台报价
|
|
|
public function actionAllDeliveryQuotes()
|
|
|
{
|
|
|
@@ -112,7 +164,7 @@ class DeliveryController extends BaseController
|
|
|
|
|
|
// --------- $customId
|
|
|
$customId = $ghs->customId ?? 0;
|
|
|
- $custom = CustomClass::getById($customId, true); // 批发的 custom
|
|
|
+ $custom = \bizGhs\custom\classes\CustomClass::getById($customId, true); // 批发的 custom
|
|
|
if (empty($custom)) {
|
|
|
util::fail('获取custom数据失败');
|
|
|
}
|