| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- @page
- @model Admin.Pages.Store.Coupon.WriteModel
- @using Domain.Entities.Store.ValueObject
- @{
- ViewData["Title"] = "쿠폰 등록";
- }
- <div class="container">
- <h3>@ViewData["Title"]</h3>
- <hr />
- <partial name="_StatusMessage" />
- <div class="alert alert-info">
- 쿠폰 등록 후 <strong>코드 풀</strong> 화면에서 CSV 파일로 실제 코드를 업로드해주세요.<br />
- 쿠폰 상품에만 쿠폰 발급 가능합니다.
- </div>
- <form name="f_admin_write" id="fAdminWrite" method="post" accept-charset="utf-8" autocomplete="off">
- <div class="row mb-2">
- <label asp-for="Input.GameID" class="col-sm-2 col-form-label"><span>*</span> 게임</label>
- <div class="col-sm-10">
- <select asp-for="Input.GameID" asp-items="Model.Games" id="couponGameID" class="form-select" required>
- <option value="">게임을 선택하세요</option>
- </select>
- <span asp-validation-for="Input.GameID" class="text-danger"></span>
- </div>
- </div>
- <div class="row mb-2">
- <label asp-for="Input.ProductID" class="col-sm-2 col-form-label"><span>*</span> 쿠폰 상품</label>
- <div class="col-sm-10">
- <select asp-for="Input.ProductID" id="couponProductID" class="form-select" required>
- <option value="">게임을 먼저 선택하세요</option>
- </select>
- <span asp-validation-for="Input.ProductID" class="text-danger"></span>
- </div>
- </div>
- <div class="row mb-2">
- <label asp-for="Input.Name" class="col-sm-2 col-form-label"><span>*</span> 쿠폰명</label>
- <div class="col-sm-10">
- <input asp-for="Input.Name" class="form-control" required maxlength="200" placeholder="예) LOL RP 충전 쿠폰 1만원권 (200자 이내)" />
- <span asp-validation-for="Input.Name" class="text-danger"></span>
- </div>
- </div>
- <hr />
- <div class="row mb-2">
- <label asp-for="Input.UsagePolicy" class="col-sm-2 col-form-label">사용 정책</label>
- <div class="col-sm-10 align-content-center">
- <div class="form-check-inline">
- <input asp-for="Input.UsagePolicy" type="radio" id="usageSingle" class="form-check-input" value="@CouponUsagePolicy.SingleUse" />
- <label class="form-check-label" for="usageSingle">1회 사용 후 소진</label>
- </div>
- <div class="form-check-inline">
- <input asp-for="Input.UsagePolicy" type="radio" id="usageReusable" class="form-check-input" value="@CouponUsagePolicy.Reusable" />
- <label class="form-check-label" for="usageReusable">재사용 가능</label>
- </div>
- </div>
- </div>
- <div class="row mb-2">
- <label asp-for="Input.ExpiresAt" class="col-sm-2 col-form-label">만료 일시</label>
- <div class="col-sm-10">
- <input asp-for="Input.ExpiresAt" class="form-control w-auto" type="datetime-local" />
- <small class="form-text text-muted">비워두면 만료 없음</small>
- </div>
- </div>
- <div class="row mb-2">
- <label asp-for="Input.LowStockThreshold" class="col-sm-2 col-form-label">재고 알림 임계치</label>
- <div class="col-sm-10">
- <div class="row">
- <div class="col col-md-auto">
- <div class="input-group">
- <input asp-for="Input.LowStockThreshold" class="form-control" type="number" min="0" />
- <span class="input-group-text">개</span>
- </div>
- </div>
- </div>
- <small class="form-text text-muted">잔여 코드 수가 이 값 미만이면 목록에서 빨간색 표시</small>
- <span asp-validation-for="Input.LowStockThreshold" class="text-danger"></span>
- </div>
- </div>
- <hr />
- <div class="d-grid gap-2 text-center d-md-block">
- <button type="submit" class="btn btn-success">등록</button>
- <a href="/Store/Coupon" class="btn btn-secondary">취소</a>
- </div>
- <br />
- </form>
- </div>
- @section Scripts {
- <partial name="_ValidationScriptsPartial" />
- <script>
- var allProducts = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(Model.Products.Select(p => new { id = p.ID, gameID = p.GameID, name = p.Name })));
- function refreshProducts() {
- var gameID = parseInt(document.getElementById("couponGameID").value) || 0;
- var sel = document.getElementById("couponProductID");
- sel.innerHTML = "";
- if (gameID === 0) {
- sel.innerHTML = '<option value="">게임을 먼저 선택하세요</option>';
- return;
- }
- var filtered = allProducts.filter(function(p) { return p.gameID === gameID; });
- if (filtered.length === 0) {
- sel.innerHTML = '<option value="">해당 게임의 쿠폰 상품이 없습니다</option>';
- return;
- }
- sel.innerHTML = '<option value="">상품을 선택하세요</option>';
- filtered.forEach(function(p) {
- var opt = document.createElement("option");
- opt.value = p.id;
- opt.textContent = p.name;
- sel.appendChild(opt);
- });
- }
- document.getElementById("couponGameID").addEventListener("change", refreshProducts);
- refreshProducts();
- </script>
- }
|