From 43ef81c3b1636c52cfae7fb07cdce9896da31a8c Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 2 Nov 2022 13:43:33 +0800 Subject: [PATCH] shop add discount --- webapp/controller/ShopController.class.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index d680e9a3..529506d8 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -137,13 +137,18 @@ class ShopController extends BaseAuthedController { $price_array = splitStr1($row['price']); $discount_array = splitStr1($row['discount']); - $discount_begin = $row['discount_begin']; - $discount_end = $row['discount_end']; - $nowTime = $this->_getNowTime(); $need_price = $price_array[$token_pos]; $discount = $discount_array[$token_pos]; + $discount_begin = $row['discount_begin']; + $discount_end = $row['discount_end']; + $nowTime = $this->_getNowTime(); + + if ($nowTime>=$discount_begin && $nowTime<$discount_end) { + $need_price = ceil($need_price * ($discount / 100.0)); + } + $costItemId = $this->getCostItemIdByTokenType($token_type); switch($token_type) {