|
|
@@ -105,7 +105,19 @@ class PurchaseController extends BaseController
|
|
|
$ghsInfo['miniKilo'] = $ghsShopInfo->miniKilo ?? 0;
|
|
|
|
|
|
$post['product'] = $productList;
|
|
|
- $post['sendCost'] = isset($post['sendCost']) && is_numeric($post['sendCost']) ? $post['sendCost'] : 0;
|
|
|
+
|
|
|
+ $sendType = $post['sendType'] ?? 1;
|
|
|
+ $sendCost = 0;
|
|
|
+ if ($sendType == 3) {
|
|
|
+ $weight = 0;
|
|
|
+ foreach ($productList as $itemData) {
|
|
|
+ $currentWeight = $itemData['weight'] ?? 0;
|
|
|
+ $weight = bcadd($currentWeight, $weight, 2);
|
|
|
+ }
|
|
|
+ $result = PurchaseClass::getDistanceFee($this->shop, $ghsShopInfo, $weight);
|
|
|
+ $sendCost = $result['fee'] ?? 0;
|
|
|
+ }
|
|
|
+ $post['sendCost'] = $sendCost;
|
|
|
|
|
|
$respond = PurchaseService::createPurchase($post, $ghsInfo);
|
|
|
$transaction->commit();
|