From 00470fe6cd994dc84b7c14ad1048ac4527666d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Wed, 24 Mar 2021 18:08:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E6=8A=98?= =?UTF-8?q?=E6=89=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/api/auth/Order.php | 15 +++++++++++++++ app/data/view/shop_order/index.html | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/data/controller/api/auth/Order.php b/app/data/controller/api/auth/Order.php index 528166ed2..3665b5145 100644 --- a/app/data/controller/api/auth/Order.php +++ b/app/data/controller/api/auth/Order.php @@ -194,6 +194,21 @@ class Order extends Auth } } + /** + * 获取用户折扣 + */ + public function discount() + { + $data = $this->_vali(['discount_id.require' => '折扣编号不能为空!']); + [$map, $rate] = [['status' => 1, 'deleted' => 0, 'id' => $data['discount_id']], 100.00]; + if ($discount = $this->app->db->name('DataUserDiscount')->where($map)->value('items')) { + foreach (json_decode($discount, true) as $vo) if ($vo['level'] == $this->user['vip_code']) { + $rate = round($vo['discount']); + } + } + $this->success('获取用户折扣', ['rate' => $rate]); + } + /** * 模拟计算订单运费 * @throws \think\db\exception\DataNotFoundException diff --git a/app/data/view/shop_order/index.html b/app/data/view/shop_order/index.html index fb81b5824..c84d9f4f7 100644 --- a/app/data/view/shop_order/index.html +++ b/app/data/view/shop_order/index.html @@ -120,7 +120,7 @@ {if $g.vip_entry > 0 and $g.vip_upgrade > $g.vip_code} [ VIP{$g.vip_code} VIP{$g.vip_upgrade} ] {else} - [ VIP{$g.vip_code} ] + [ VIP{$g.vip_code} ] {/if} {if $g.discount_rate < 100.00} 享{$g.discount_rate+0}%折扣 x