会员组折扣功能

客户组编辑释放出折扣率

会员组折扣

客户组折扣

wip

会员组折扣

会员组折扣
This commit is contained in:
TL 2023-02-08 15:05:03 +08:00 committed by Edward Yang
parent 27bfe41623
commit 1276d0a98b
5 changed files with 56 additions and 0 deletions

View File

@ -21,6 +21,7 @@ class TotalService
'subtotal',
'tax',
'shipping',
'customer_discount',
'order_total',
];

View File

@ -0,0 +1,47 @@
<?php
/**
* CustomerDiscountService.php
*
* @copyright 2023 beikeshop.com - All Rights Reserved
* @link https://beikeshop.com
* @author TL <mengwb@guangda.work>
* @created 2023-02-07 18:49:15
* @modified 2023-02-07 18:49:15
*/
namespace Beike\Shop\Services\TotalServices;
use Beike\Shop\Services\CheckoutService;
class CustomerDiscountService
{
/**
* @param CheckoutService $checkout
* @return array
*/
public static function getTotal(CheckoutService $checkout)
{
$totalService = $checkout->totalService;
$discountFactor = current_customer()->customerGroup->discount_factor;
if ($discountFactor <= 0) {
return;
}
if ($discountFactor > 1) {
$discountFactor = 1;
}
$amount = $totalService->getSubTotal() * $discountFactor / 100;
$totalData = [
'code' => 'customer_discount',
'title' => trans('shop/carts.customer_discount'),
'amount' => -$amount,
'amount_format' => currency_format(-$amount),
];
$totalService->amount += $totalData['amount'];
$totalService->totals[] = $totalData;
return $totalData;
}
}

View File

@ -62,6 +62,12 @@
</el-form-item>
</el-form-item>
<el-form-item label="{{ __('admin/customer_group.discount_rate') }}">
<el-input class="mb-0" type="number" v-model="dialog.form.discount_factor" placeholder="{{ __('admin/customer_group.discount_rate') }}">
<template slot="append">%</template>
</el-input>
</el-form-item>
@if (0)
<el-form-item label="{{ __('customer_group.level') }}">
<el-input class="mb-0" v-model="dialog.form.level" placeholder="{{ __('customer_group.level') }}"></el-input>

View File

@ -17,6 +17,7 @@ return [
'quantity' => 'Quantity',
'subtotal' => 'Subtotal',
'product_total' => 'Product Total',
'customer_discount' => 'Customer Discount',
'order_total' => 'Order Total',
'shipping_fee' => 'Shipping Fee',
'all' => 'All',

View File

@ -17,6 +17,7 @@ return [
'quantity' => '数量',
'subtotal' => '小计',
'product_total' => '商品总计',
'customer_discount' => '会员优惠',
'order_total' => '应付总金额',
'shipping_fee' => '运费',
'all' => '全部',