From 2591357bf8a96bad8b63eea9e4ec33d99e0651a9 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Fri, 22 Jul 2022 18:25:06 +0800 Subject: [PATCH] add total services. --- beike/Shop/Services/CartService.php | 3 +- beike/Shop/Services/TotalService.php | 36 +++++++++++++++++++ .../TotalServices/ShippingService.php | 15 ++++++++ .../TotalServices/SubtotalService.php | 15 ++++++++ plugins/ServiceCharge/config.json | 12 +++++++ 5 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 beike/Shop/Services/TotalService.php create mode 100644 beike/Shop/Services/TotalServices/ShippingService.php create mode 100644 beike/Shop/Services/TotalServices/SubtotalService.php create mode 100644 plugins/ServiceCharge/config.json diff --git a/beike/Shop/Services/CartService.php b/beike/Shop/Services/CartService.php index d3be7f61..ce6e6a01 100644 --- a/beike/Shop/Services/CartService.php +++ b/beike/Shop/Services/CartService.php @@ -150,7 +150,8 @@ class CartService 'carts' => $carts, 'quantity' => $quantity, 'amount' => $amount, - 'amount_format' => currency_format($amount) + 'amount_format' => currency_format($amount), + 'totals' => TotalService::getTotals(), ]; return $data; } diff --git a/beike/Shop/Services/TotalService.php b/beike/Shop/Services/TotalService.php new file mode 100644 index 00000000..adaefe72 --- /dev/null +++ b/beike/Shop/Services/TotalService.php @@ -0,0 +1,36 @@ + + * @created 2022-07-22 17:11:31 + * @modified 2022-07-22 17:11:31 + */ + +namespace Beike\Shop\Services; + +class TotalService +{ + const TOTAL_CODES = [ + 'subtotal', + 'shipping', + 'total' + ]; + + /** + * @return array + */ + public static function getTotals(): array + { + $totals = []; + foreach (self::TOTAL_CODES as $code) { + $totals[] = 11; + } + + // hook= [subtotal, shipping] + + return []; + } +} diff --git a/beike/Shop/Services/TotalServices/ShippingService.php b/beike/Shop/Services/TotalServices/ShippingService.php new file mode 100644 index 00000000..97571689 --- /dev/null +++ b/beike/Shop/Services/TotalServices/ShippingService.php @@ -0,0 +1,15 @@ + + * @created 2022-07-22 17:58:14 + * @modified 2022-07-22 17:58:14 + */ +class ShippingService +{ + +} diff --git a/beike/Shop/Services/TotalServices/SubtotalService.php b/beike/Shop/Services/TotalServices/SubtotalService.php new file mode 100644 index 00000000..d85b604f --- /dev/null +++ b/beike/Shop/Services/TotalServices/SubtotalService.php @@ -0,0 +1,15 @@ + + * @created 2022-07-22 17:58:25 + * @modified 2022-07-22 17:58:25 + */ +class SubtotalService +{ + +} diff --git a/plugins/ServiceCharge/config.json b/plugins/ServiceCharge/config.json new file mode 100644 index 00000000..9797ce6d --- /dev/null +++ b/plugins/ServiceCharge/config.json @@ -0,0 +1,12 @@ +{ + "code": "service_charge", + "name": "订单手续费", + "description": "订单手续费,采用stripe支付方式或者低总额加收一定费用", + "type": "total", + "version": "v1.0.0", + "icon": "https://via.placeholder.com/100x100.png/112233?text=SERVICE", + "author": { + "name": "成都光大网络科技有限公司", + "email": "yangjin@opencart.cn" + } +}