|
|
@@ -12,6 +12,7 @@ use bizHd\saas\services\RegionService;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\dateUtil;
|
|
|
+use common\components\freight;
|
|
|
use common\components\httpUtil;
|
|
|
use Yii;
|
|
|
use common\components\util;
|
|
|
@@ -281,11 +282,50 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
$orderId = $get['id'] ?? 0; //订单ID
|
|
|
$customId = $get['customId'] ?? 0;
|
|
|
- if (!empty($customId)) {
|
|
|
- util::success(['sedCost' => 27]);
|
|
|
- }
|
|
|
+
|
|
|
if (empty($orderId)) {
|
|
|
- util::success(['sedCost' => 10]);
|
|
|
+ //自定义运费
|
|
|
+ //freight::getCost();
|
|
|
+ if (empty($customId)) {
|
|
|
+ util::fail("请选择客户");
|
|
|
+ }
|
|
|
+ $customInfo = CustomClass::getById($customId);
|
|
|
+ if (empty($customInfo)) {
|
|
|
+ util::fail('没有找到客户');
|
|
|
+ }
|
|
|
+ $shop = $this->shop;
|
|
|
+
|
|
|
+ //花材信息
|
|
|
+ $productJson = $post['product'] ?? '';
|
|
|
+ // $productJson = '[{"productId":31993,"bigNum":1,"smallNum":0}]';
|
|
|
+ if (empty($productJson)) {
|
|
|
+ util::fail('请选择花材');
|
|
|
+ }
|
|
|
+ $productList = json_decode($productJson, true);
|
|
|
+ if (empty($productList)) {
|
|
|
+ util::fail('请选择花材');
|
|
|
+ }
|
|
|
+
|
|
|
+ $productList = ProductClass::mergeItemInfo($productList);
|
|
|
+ $weight = 0;
|
|
|
+ $price = 0;
|
|
|
+ $productData = ProductClass::getProductMapData($productList);
|
|
|
+ $bigNum = 0;
|
|
|
+ foreach ($productList as $key => $val) {
|
|
|
+ $productId = $val['productId'];
|
|
|
+ $w = ProductClass::getWeight($val['productId'], $val['bigNum'], $val['smallNum']);
|
|
|
+ $bigNum += $val['bigNum'];
|
|
|
+ $weight = bcadd($w, $weight, 2);
|
|
|
+ $ratio = $productData[$productId]['ratio'] ?? 0;
|
|
|
+ //大小数量合并多少扎
|
|
|
+ $itemNum = ProductClass::mergeItemNum($val['bigNum'], $val['smallNum'], $ratio);
|
|
|
+ //售卖价格
|
|
|
+ $itemPrice = $productData[$productId]['price'] ?? 0;
|
|
|
+ //合计价格
|
|
|
+ $price = bcadd($price,bcmul($itemNum, $itemPrice, 2),2);
|
|
|
+ }
|
|
|
+ $cost = freight::getCost($shop->lat,$shop->long,$customInfo['lat'],$customInfo['long'],$weight);
|
|
|
+ util::success(['sedCost' => $cost]);
|
|
|
}
|
|
|
$province = $get['province'] ?? '';
|
|
|
$city = $get['city'] ?? '';
|
|
|
@@ -402,4 +442,4 @@ class OrderController extends BaseController
|
|
|
util::success($respond);
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+}
|