parent
270623a9ad
commit
399bff4def
|
|
@ -114,7 +114,9 @@ class TotalService
|
||||||
*/
|
*/
|
||||||
private function getTotalClassMaps()
|
private function getTotalClassMaps()
|
||||||
{
|
{
|
||||||
$maps = [];
|
$maps = [
|
||||||
|
'sum_quantity' => "\Beike\\Shop\\Services\\TotalServices\\SumQuantityService"
|
||||||
|
];
|
||||||
foreach (self::TOTAL_CODES as $code) {
|
foreach (self::TOTAL_CODES as $code) {
|
||||||
$serviceName = Str::studly($code) . 'Service';
|
$serviceName = Str::studly($code) . 'Service';
|
||||||
$maps[$code] = "\Beike\\Shop\\Services\\TotalServices\\{$serviceName}";
|
$maps[$code] = "\Beike\\Shop\\Services\\TotalServices\\{$serviceName}";
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ class ShippingService{
|
||||||
if($logisticsId <= 0){
|
if($logisticsId <= 0){
|
||||||
// 获取当前收货地址国家ID
|
// 获取当前收货地址国家ID
|
||||||
$address = $cart->guest_shipping_address ?? $cart->guest_payment_address;
|
$address = $cart->guest_shipping_address ?? $cart->guest_payment_address;
|
||||||
|
if(!$address) return [];
|
||||||
$countryId = $address['country_id'];
|
$countryId = $address['country_id'];
|
||||||
// 获取全部物流 返回第一个物流信息ID
|
// 获取全部物流 返回第一个物流信息ID
|
||||||
$logisticsList = Logistics::getAll($countryId,['type','first_weight','first_weight_fee','continuation_weight_max','add_weight','continuation_weight_fee','num_fee']);
|
$logisticsList = Logistics::getAll($countryId,['type','first_weight','first_weight_fee','continuation_weight_max','add_weight','continuation_weight_fee','num_fee']);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Beike\Shop\Services\TotalServices;
|
||||||
|
|
||||||
|
use Beike\Shop\Services\CheckoutService;
|
||||||
|
|
||||||
|
class SumQuantityService{
|
||||||
|
|
||||||
|
public static function getTotal(CheckoutService $checkout): ?array{
|
||||||
|
$totalService = $checkout->totalService;
|
||||||
|
$sumQuantity = $totalService->countProducts();
|
||||||
|
$totalData = [
|
||||||
|
'code' => 'sum_quantity',
|
||||||
|
'title' => trans('admin/dashboard.product_total'),
|
||||||
|
'amount' => $sumQuantity,
|
||||||
|
'amount_format' => $sumQuantity,
|
||||||
|
];
|
||||||
|
$totalService->totals[] = $totalData;
|
||||||
|
|
||||||
|
return $totalData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -53,13 +53,13 @@ class Bootstrap
|
||||||
$amount = $totalService->amount;
|
$amount = $totalService->amount;
|
||||||
$shippingType = plugin_setting('flat_shipping.type', 'fixed');
|
$shippingType = plugin_setting('flat_shipping.type', 'fixed');
|
||||||
$shippingValue = plugin_setting('flat_shipping.value', 0);
|
$shippingValue = plugin_setting('flat_shipping.value', 0);
|
||||||
if ($shippingType == 'fixed') {
|
$sumQuantity = $totalService->countProducts();
|
||||||
return $shippingValue;
|
if($sumQuantity > 0){
|
||||||
} elseif ($shippingType == 'percent') {
|
if ($shippingType == 'fixed') return $shippingValue;
|
||||||
return $amount * $shippingValue / 100;
|
elseif ($shippingType == 'percent') return $amount * $shippingValue / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,12 @@
|
||||||
</div>
|
</div>
|
||||||
{{-- 购买数量 - 单规格 --}}
|
{{-- 购买数量 - 单规格 --}}
|
||||||
<div class="quantity-wrap mb-4" v-if="Object.keys(source.skus).length <= 1">
|
<div class="quantity-wrap mb-4" v-if="Object.keys(source.skus).length <= 1">
|
||||||
<input type="text" class="form-control" :disabled="!product.quantity" onkeyup="this.value=this.value.replace(/\D/g,'')" v-model="quantity" name="quantity">
|
<input type="text"
|
||||||
|
class="form-control"
|
||||||
|
:disabled="!product.quantity"
|
||||||
|
:value="quantity"
|
||||||
|
@input="singleQuantityChange($event)"
|
||||||
|
name="quantity">
|
||||||
<div class="right" v-if="!isNumSelect">
|
<div class="right" v-if="!isNumSelect">
|
||||||
<i class="bi bi-chevron-up"></i>
|
<i class="bi bi-chevron-up"></i>
|
||||||
<i class="bi bi-chevron-down"></i>
|
<i class="bi bi-chevron-down"></i>
|
||||||
|
|
@ -533,6 +538,7 @@
|
||||||
quantity: function (newval, oldval) {
|
quantity: function (newval, oldval) {
|
||||||
let _this = this;
|
let _this = this;
|
||||||
let list = {};
|
let list = {};
|
||||||
|
// 请求计算运费
|
||||||
list[0] = {
|
list[0] = {
|
||||||
product_id: _this.product_id,
|
product_id: _this.product_id,
|
||||||
product_sku_id: this.product.id,
|
product_sku_id: this.product.id,
|
||||||
|
|
@ -807,12 +813,22 @@
|
||||||
let stock = _this.add_buy_sku[skuIndex].stock || 0;
|
let stock = _this.add_buy_sku[skuIndex].stock || 0;
|
||||||
let quantity = event.target.value || 0;
|
let quantity = event.target.value || 0;
|
||||||
quantity = quantity > stock ? stock : quantity;// 不能超过库存
|
quantity = quantity > stock ? stock : quantity;// 不能超过库存
|
||||||
_this.add_buy_sku[skuIndex].quantity = quantity;
|
_this.add_buy_sku[skuIndex].quantity = typeof quantity != 'number' ? quantity.replace(/\D/g,'') : quantity;
|
||||||
// 处理深度监听失败的问题
|
// 处理深度监听失败的问题
|
||||||
_this.add_buy_sku = Object.assign({}, _this.add_buy_sku);
|
_this.add_buy_sku = Object.assign({}, _this.add_buy_sku);
|
||||||
|
|
||||||
_this.$forceUpdate();
|
_this.$forceUpdate();
|
||||||
},
|
},
|
||||||
|
// 单规格 - 购买数量改变
|
||||||
|
singleQuantityChange(event){
|
||||||
|
let _this = this;
|
||||||
|
let stock = _this.product.quantity || 0;// 库存
|
||||||
|
let quantity = event.target.value || 0;// 购买数量
|
||||||
|
quantity = quantity > stock ? stock : quantity;// 不能超过库存
|
||||||
|
_this.quantity = typeof quantity != 'number' ? quantity.replace(/\D/g,'') : quantity;
|
||||||
|
|
||||||
|
_this.$forceUpdate();
|
||||||
|
},
|
||||||
// 计算当前订单总额
|
// 计算当前订单总额
|
||||||
computeOrderMoney(list){
|
computeOrderMoney(list){
|
||||||
let _this = this;
|
let _this = this;
|
||||||
|
|
@ -825,7 +841,7 @@
|
||||||
_this.$forceUpdate();
|
_this.$forceUpdate();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue