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