获取用户折扣

This commit is contained in:
邹景立 2021-03-24 18:08:52 +08:00
parent e186a8dcfa
commit 00470fe6cd
2 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -120,7 +120,7 @@
{if $g.vip_entry > 0 and $g.vip_upgrade > $g.vip_code}
[ <b class="color-red">VIP{$g.vip_code}</b> <span class="layui-icon font-s10 color-blue">&#xe602;</span> <b class="color-red">VIP{$g.vip_upgrade}</b> ]
{else}
[ <b class="color-blue">VIP{$g.vip_code}</b> ]
[ <b class="color-text">VIP{$g.vip_code}</b> ]
{/if}
{if $g.discount_rate < 100.00}
<b class="color-blue">{$g.discount_rate+0}%折扣</b><span class="color-red"> x </span>