feat(라이브): 방송 창에 Fee·커미션 자동 계산, 광고비·호스트 비용 입력, 방송 장소 뺌
- Fee = 시간 x RM25, 커미션 = 판매금액 x 10% (저장 안 함, 이미지에서 매출을 읽으면 다시 계산) - 광고비·호스트 비용(수기) = 방송마다 저장 (마이그레이션 live_db_006_broadcast_fees.sql) - 달력 날짜 광고비 = 그날 방송 광고비 합, 호스트 비용 = host_fee 합 (날짜별 광고비 입력 버튼·/live/ad-spend 없앰) - 방송 장소는 창·표에서 뺌 (예전 값은 DB 에 그대로) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -135,7 +135,7 @@
|
||||
.lv-total dt { color: #aab3c5; }
|
||||
.lv-total dd { margin: 0; font-variant-numeric: tabular-nums; color: #fbbf72; white-space: nowrap; }
|
||||
.lv-total dd.is-sales { color: #6ee7a8; }
|
||||
.lv-total-edit { padding: 0 2px; border: 0; background: none; color: #cbd5e1; font-size: 9.5px; line-height: 1; cursor: pointer; }
|
||||
.lv-dlg input[readonly] { background: #f1f5f9; color: #475569; }
|
||||
|
||||
.lv-dlg { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--color-subtle-ash, #e5e5e5); border-radius: 12px; }
|
||||
.lv-dlg::backdrop { background: rgba(0, 0, 0, .35); }
|
||||
|
||||
+21
-15
@@ -1,5 +1,5 @@
|
||||
/* 라이브 커머스(2026-11-04) — 스케줄표·달력·호스트 설정 공용: 추가·고치기 창, 저장·지우기(fetch → JSON {ok, message}, 틀려도 입력한 값이 창에 남음).
|
||||
달력: 오른쪽 달력으로 날짜 이동, 카드 끌어 옮기기·맞바꾸기, 날짜별 광고비. 다시 그린 뒤에도 보던 가로 위치 유지. */
|
||||
달력: 오른쪽 달력으로 날짜 이동, 카드 끌어 옮기기·맞바꾸기. 다시 그린 뒤에도 보던 가로 위치 유지. */
|
||||
(function () {
|
||||
"use strict";
|
||||
const calWrap = document.getElementById("lv-cal-wrap");
|
||||
@@ -91,9 +91,28 @@
|
||||
showHosts(editing && row.host_id);
|
||||
if (editing && hostSelect) hostSelect.value = String(row.host_id); // 위에서 보이게 한 뒤 다시 고름
|
||||
showSaved(editing && row.images);
|
||||
recalc();
|
||||
dlg.showModal();
|
||||
}
|
||||
|
||||
// Fee(시간 × 시간당 요금)·커미션(판매금액 × %) 자동 계산 — 보기만(저장 안 함), store.session_pay 와 같게 센트 반올림
|
||||
const feeOut = form.querySelector("[data-fee]");
|
||||
const comOut = form.querySelector("[data-commission]");
|
||||
function money(cents) { return (cents / 100).toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 }); }
|
||||
function minutesOf(v) { const m = /^(\d{1,2}):(\d{2})/.exec(v || ""); return m ? Number(m[1]) * 60 + Number(m[2]) : null; }
|
||||
function recalc() {
|
||||
if (!feeOut || !comOut) return;
|
||||
const s = minutesOf(form.elements.start_time.value), en = minutesOf(form.elements.end_time.value);
|
||||
const mins = s === null || en === null || s === en ? null : (en - s + 1440) % 1440; // 끝이 더 이르면 자정을 넘긴 방송
|
||||
feeOut.value = mins === null ? "" : money(Math.round(mins * Number(feeOut.dataset.fee) * 100 / 60));
|
||||
const sales = Number(String(form.elements.sales_amount.value).replace(/^\s*rm/i, "").replace(/[,\s]/g, ""));
|
||||
const raw = form.elements.sales_amount.value.trim();
|
||||
comOut.value = !raw || !isFinite(sales) || sales < 0 ? "" : money(Math.round(Math.round(sales * 100) * Number(comOut.dataset.commission) / 100));
|
||||
}
|
||||
form.addEventListener("input", function (e) {
|
||||
if (["start_time", "end_time", "sales_amount"].indexOf(e.target.name) >= 0) recalc();
|
||||
});
|
||||
|
||||
const addBtn = document.getElementById("lv-add");
|
||||
if (addBtn) addBtn.addEventListener("click", function () { open(null); });
|
||||
dlg.addEventListener("click", function (e) {
|
||||
@@ -145,7 +164,7 @@
|
||||
if (!r.ok || r.data.amount) break;
|
||||
}
|
||||
save.disabled = false;
|
||||
if (r.ok && r.data.amount) salesInput.value = r.data.amount;
|
||||
if (r.ok && r.data.amount) { salesInput.value = r.data.amount; recalc(); }
|
||||
say(r.message, r.ok);
|
||||
});
|
||||
|
||||
@@ -274,19 +293,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
// ── 달력: 날짜별 광고비 ──
|
||||
document.addEventListener("click", async function (e) {
|
||||
const b = e.target.closest("button[data-spend]");
|
||||
if (!b) return;
|
||||
const value = await window.erpPrompt(tr("{day} 광고비 (RM) — 비우면 지웁니다").replace("{day}", b.dataset.spend), b.dataset.value || "", dialogText());
|
||||
if (value === null || value === undefined) return;
|
||||
const body = new FormData();
|
||||
body.set("day", b.dataset.spend);
|
||||
body.set("amount", value);
|
||||
const r = await post("/live/ad-spend", body);
|
||||
if (r.ok) reload(); else window.erpAlert(r.message, dialogText());
|
||||
});
|
||||
|
||||
// ── 달력: 카드 머리를 끌어 빈 칸으로 옮기기, 다른 카드 위에 놓아 맞바꾸기 ──
|
||||
let dragging = null;
|
||||
calWrap.addEventListener("dragstart", function (e) {
|
||||
|
||||
Reference in New Issue
Block a user