|
|
@@ -81,6 +81,7 @@ class OrderService extends BaseService
|
|
|
if (!empty($itIds)) {
|
|
|
$itemInfo = ItemClass::getByIds($itIds, null, 'id');
|
|
|
}
|
|
|
+ $weight = 0;
|
|
|
$goodsPrice = 0;
|
|
|
foreach ($product as $key => $val) {
|
|
|
if (isset($val['property']) == false) {
|
|
|
@@ -91,10 +92,12 @@ class OrderService extends BaseService
|
|
|
$currentId = $val['productId'] ?? 0;
|
|
|
$num = $val['num'] ?? 0;
|
|
|
$unitPrice = 0;
|
|
|
+ $currentWeight = 0;
|
|
|
if ($property == dict::getDict('property', 'goods')) {
|
|
|
$name = $goodsInfo[$currentId]['name'] ?? '';
|
|
|
$cover = $goodsInfo[$currentId]['cover'] ?? '';
|
|
|
$flower = $goodsInfo[$currentId]['flower'] ?? 0;
|
|
|
+ $currentWeight = $goodsInfo[$currentId]['weight'] ?? 0;
|
|
|
if (!empty($groupCover)) {
|
|
|
$groupCover = $cover;
|
|
|
}
|
|
|
@@ -131,6 +134,7 @@ class OrderService extends BaseService
|
|
|
$ratio = $itemInfo[$currentId]['ratio'] ?? 20;
|
|
|
$currentMainId = $itemInfo[$currentId]['mainId'] ?? 0;
|
|
|
$currentPrice = $itemInfo[$currentId]['skPrice'] ?? 0;
|
|
|
+ $currentWeight = $itemInfo[$currentId]['weight'] ?? 0;
|
|
|
if ($currentMainId != $mainId) {
|
|
|
util::fail('不是您的花材' . $mainId . ' ' . $currentMainId);
|
|
|
}
|
|
|
@@ -172,12 +176,32 @@ class OrderService extends BaseService
|
|
|
//库存变化在这里
|
|
|
OrderItemClass::addData($currentItemData, $custom);
|
|
|
}
|
|
|
-
|
|
|
+ $weight = bcadd($weight, $currentWeight, 2);
|
|
|
$goodsPrice = bcadd($goodsPrice, bcmul($unitPrice, $num, 2), 2);
|
|
|
+ }
|
|
|
|
|
|
+ //计算运费
|
|
|
+ $sendDistance = 0;
|
|
|
+ $sendCost = 0;
|
|
|
+ $sendType = $data['sendType'] ?? dict::getDict('sendType', 'thirdSend');
|
|
|
+ if ($sendType == dict::getDict('sendType', 'thirdSend')) {
|
|
|
+ $lat = $data['latitude'] ?? '';
|
|
|
+ $lng = $data['longitude'] ?? '';
|
|
|
+ if (empty($lat) || empty($lng)) {
|
|
|
+ util::fail('请填写收花地址');
|
|
|
+ }
|
|
|
+ $shopLat = $shop->lat ?? '';
|
|
|
+ $shopLong = $shop->long ?? '';
|
|
|
+ if (empty($shopLat) || empty($shopLong)) {
|
|
|
+ util::fail('请完成门店地址');
|
|
|
+ }
|
|
|
+ $disRespond = OrderClass::getDistanceFee($lat, $lng, $shopLat, $shopLong, $weight);
|
|
|
+ $sendCost = $disRespond['fee'] ?? 0;
|
|
|
+ $sendDistance = $disRespond['distance'] ?? 0;
|
|
|
}
|
|
|
+ $post['sendDistance'] = $sendDistance;
|
|
|
+ $post['sendCost'] = $sendCost;
|
|
|
|
|
|
- $sendCost = $data['sendCost'] ?? 0;
|
|
|
$totalPrice = bcadd($goodsPrice, $sendCost, 2);
|
|
|
$modifyPrice = $totalPrice;
|
|
|
if ($modifyPrice > $totalPrice) {
|