2025-03-10 08:35:19 +08:00

118 lines
3.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% extends "base.html" %}
{% block title %}优惠券管理{% endblock %}
{% block content %}
<div class="container mt-4">
<h2>优惠券管理</h2>
<div class="card mb-4">
<div class="card-header">创建新优惠券</div>
<div class="card-body">
<form method="post" action="{{ url_for('coupons.create_coupon') }}">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>优惠码</label>
<input type="text" name="coupon_code" class="form-control" required>
</div>
</div>
<!-- 新增折扣类型 -->
<div class="col-md-2">
<div class="form-group">
<label>折扣类型</label>
<select name="discount_type" class="form-control" required>
<option value="fixed">满减</option>
<option value="percentage">打折</option>
</select>
</div>
</div>
<!-- 新增折扣值 -->
<div class="col-md-2">
<div class="form-group">
<label>折扣值(打折类型优惠券打 95折直接输入 95</label>
<input type="number" name="discount_amount" class="form-control"
min="0" step="0.01" required>
</div>
</div>
<!-- 新增最低消费 -->
<div class="col-md-2">
<div class="form-group">
<label>最低消费</label>
<input type="number" name="min_order_amount" class="form-control"
min="0" step="0.01">
</div>
</div>
<!-- 新增有效期 -->
<div class="col-md-3">
<div class="form-group">
<label>有效期开始</label>
<input type="datetime-local" name="valid_from"
class="form-control" step="1" required>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>有效期结束</label>
<input type="datetime-local" name="valid_to"
class="form-control" step="1" required>
</div>
</div>
<!-- 现有库存字段 -->
<div class="col-md-2">
<div class="form-group">
<label>库存数量</label>
<input type="number" name="quantity" class="form-control"
min="1" value="1" required>
</div>
</div>
<div class="col-md-2 align-self-end">
<button type="submit" class="btn btn-primary">提交</button>
</div>
</div>
</form>
</div>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>优惠券ID</th>
<th>优惠码</th>
<th>折扣类型</th>
<th>折扣值</th>
<th>最低消费</th>
<th>有效期</th>
<th>库存</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for coupon in coupons %}
<tr>
<td>{{ coupon.coupon_id }}</td>
<td>{{ coupon.coupon_code }}</td>
<td>{{ coupon.discount_type }}</td>
<td>{{ coupon.discount_amount }}</td>
<td>{{ coupon.min_order_amount or '无限制' }}</td>
<td>{{ coupon.valid_from }} 至 {{ coupon.valid_to }}</td>
<td>{{ coupon.quantity }}</td>
<td>
<form action="{{ url_for('coupons.delete_coupon', coupon_id=coupon.coupon_id) }}" method="post">
<button type="submit" class="btn btn-danger btn-sm"
onclick="return confirm('确定删除该优惠券吗?')">
删除
</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}