feat(실적): 틱톡 탭 삭제 + [말레이시아 실적] 모듈 추가

- 실적 틱톡 탭·tiktok_ads 광고 API·테스트 삭제, 틱톡 데이터 삭제 SQL(performance_db 012)
- 말레이시아 실적: 실적 라우터·화면을 /malaysia/performance 에 한 번 더 마운트,
  차이는 performance/variant.py(KR·MY) 한 곳 — 저장소·권한키·주소·광고 채널·통화
- 틱톡·쇼피·라자다 그룹(쇼핑몰 + 라이브커머스 하위, 그룹 열 = 합계), 광고비 채널 3개
- 금액 RM 소수 2자리 = 센 정수 저장(입력·엑셀 scale, 화면 num/money, JS money)
- malaysia_performance_db = performance_db 구조 복사 + seed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 16:03:18 +09:00
parent e9f57b6ff6
commit 62cc5e2778
34 changed files with 790 additions and 892 deletions
-5
View File
@@ -43,7 +43,6 @@
.perf-tab.is-active { color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.perf-tab-sales.is-active, .perf-tab-sales.is-active:hover { background: var(--color-deep-black, #1e1f21); }
.perf-tab-ads.is-active, .perf-tab-ads.is-active:hover { background: var(--perf-ad, #d9480f); }
.perf-tab-tiktok.is-active, .perf-tab-tiktok.is-active:hover { background: var(--perf-tiktok, #e11d48); }
a.perf-tab.is-active:link, a.perf-tab.is-active:visited { color: #fff; }
.perf-tab-gear {
margin-left: auto; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
@@ -60,10 +59,6 @@ a.perf-tab.is-active:link, a.perf-tab.is-active:visited { color: #fff; }
.perf-ads td.is-upload .v-gross { color: var(--perf-ad); }
/* 광고 API(구글 광고 등)로 가져온 칸 — 초록 숫자 */
.perf-ads td.is-api .v-gross { color: #1e8e3e; }
/* 틱톡 화면 — 광고비 화면 틀에 색만 바꿈 */
.perf, .perf-modal { --perf-tiktok: #e11d48; }
.perf-tiktok .perf-quick .perf-seg.is-active { background: var(--perf-tiktok); }
.perf-tiktok .perf-chart .bar { fill: var(--perf-tiktok); }
.perf-ad-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* 광고 API 설정 창 — 서비스 계정 JSON 같은 여러 줄 항목 */
.perf-cred-multi { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12px; resize: vertical; }
+56 -46
View File
@@ -1,6 +1,8 @@
/* 실적(쇼핑몰 통합 매출) — 대시보드 / 설정 화면 동작.
*
* 쇼핑몰 API 는 브라우저에서 직접 부르지 않는다. 모든 요청은 우리 서버(/performance/api/…)로만.
* 쇼핑몰 API 는 브라우저에서 직접 부르지 않는다. 모든 요청은 우리 서버(BASE/api/…)로만.
* 같은 화면이 [실적](/performance)과 [말레이시아 실적](/malaysia/performance, 2026-11-20)에 쓰인다 — 주소는 .perf data-base,
* 말레이시아는 data-cents(금액 = 센 정수, 화면 = RM 소수 2자리).
* 인증정보 창은 저장된 비밀값을 받지 않는다(서버가 "저장됨" 여부만 준다).
*/
(function () {
@@ -22,17 +24,26 @@
return { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c];
});
}
const PERF_ROOT = document.querySelector(".perf");
const BASE = (PERF_ROOT && PERF_ROOT.dataset.base) || "/performance";
const CENTS = !!(PERF_ROOT && PERF_ROOT.dataset.cents); // 말레이시아 실적 — 금액 = 센(0.01 RM) 정수
const CUR = CENTS ? "RM" : "원";
function fmt(n) { return Number(n || 0).toLocaleString("ko-KR"); }
function won(n) { return n ? fmt(n) : '<span class="perf-zero">–</span>'; }
// 금액(저장 단위) → 글자. 원 = 정수, 센 = RM 소수 2자리(서버 variant.num_text 와 같음)
function money(n) {
return CENTS ? (Number(n || 0) / 100).toLocaleString("ko-KR", { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : fmt(n);
}
function won(n) { return n ? money(n) : '<span class="perf-zero">–</span>'; }
// 매출 단위(실적 설정 "공통 보기 설정", 모든 사용자 같음) — 서버 dashboard.amount_text 와 같은 표기(천원 정수, 백만원 소수 한 자리)
function unitWon(n, unit) {
if (!n) return won(0);
if (unit === "thousand") return Math.round(n / 1000).toLocaleString("ko-KR");
if (unit === "million") return (Math.round(n / 100000) / 10).toLocaleString("ko-KR", { minimumFractionDigits: 1, maximumFractionDigits: 1 });
return fmt(n);
return money(n);
}
// 축 눈금용 짧은 금액(1.2억 / 350만)
function short(n) {
if (CENTS) n = Math.round(n / 100);
const a = Math.abs(n), s = n < 0 ? "-" : "";
if (a >= 100000000) return s + (a / 100000000).toFixed(a >= 1000000000 ? 0 : 1).replace(/\.0$/, "") + "억";
if (a >= 10000) return s + Math.round(a / 10000).toLocaleString("ko-KR") + "만";
@@ -179,7 +190,7 @@
b.disabled = true;
b.textContent = "중지하는 중…";
try {
const r = await api("POST", "/performance/api/sync/jobs/" + encodeURIComponent(jobId) + "/shops/" +
const r = await api("POST", BASE + "/api/sync/jobs/" + encodeURIComponent(jobId) + "/shops/" +
encodeURIComponent(b.dataset.stop) + "/stop");
last = r.job;
renderSyncJob(m.body, r.job, false);
@@ -197,7 +208,7 @@
cancelBtn.disabled = true;
cancelBtn.textContent = "취소하는 중…";
try {
const r = await api("POST", "/performance/api/sync/jobs/" + encodeURIComponent(jobId) + "/cancel");
const r = await api("POST", BASE + "/api/sync/jobs/" + encodeURIComponent(jobId) + "/cancel");
last = r.job;
renderSyncJob(m.body, r.job, false);
} catch (err) {
@@ -207,7 +218,7 @@
}
});
(existing ? Promise.resolve({ job: existing, joined: true })
: api("POST", startUrl || "/performance/api/sync", Object.assign({ background: true }, payload))).then(function (res) {
: api("POST", startUrl || BASE + "/api/sync", Object.assign({ background: true }, payload))).then(function (res) {
last = res.job;
jobId = res.job.id;
const joined = res.joined;
@@ -217,7 +228,7 @@
async function poll() {
if (closed) return;
try {
const r = await api("GET", "/performance/api/sync/jobs/" + encodeURIComponent(res.job.id));
const r = await api("GET", BASE + "/api/sync/jobs/" + encodeURIComponent(res.job.id));
last = r.job;
renderSyncJob(m.body, r.job, joined);
if (r.job.finished) {
@@ -399,7 +410,7 @@
if (colw) colw.apply();
folded = folded.filter(function (c) { return c !== col; });
if (fold) folded.push(col);
api("PUT", "/performance/api/my-col-fold", { kind: table.dataset.cfoldKind, cols: folded })
api("PUT", BASE + "/api/my-col-fold", { kind: table.dataset.cfoldKind, cols: folded })
.catch(function (err) { alertMsg("접은 열을 저장하지 못했습니다: " + err.message); });
});
}
@@ -408,7 +419,7 @@
const data = JSON.parse((document.getElementById("perf-data") || {}).textContent || "{}");
const METRIC_NAMES = { gross: "총매출", commission: "수수료", net: "수수료 차감 매출" };
const FIXED_METRIC = root.dataset.fixedMetric || ""; // 광고비 화면 = 금액 하나(gross)뿐
const MANUAL_API = data.manual_api || "/performance/api/manual-sales/";
const MANUAL_API = data.manual_api || BASE + "/api/manual-sales/";
const MANUAL_WORD = data.manual_word || "총매출";
const EMPTY_TEXT = data.empty_text || "기간 내 매출이 없습니다.";
@@ -421,7 +432,6 @@
b.classList.toggle("is-active", b.dataset.metric === m);
});
drawDaily(m, "perf-chart-daily", data.daily);
drawDaily(m, "perf-chart-daily2", data.daily2); // 틱톡 탭 — 매출·광고비 두 그래프
drawShare(m);
root.querySelectorAll(".perf-metric-name").forEach(function (n) { n.textContent = METRIC_NAMES[m]; });
}
@@ -498,7 +508,7 @@
'<p class="perf-muted" style="margin:0 0 8px">1열에 <b>날짜</b>, 2열부터 <b>쇼핑몰 이름</b>을 머리글로 적고 그날 <b>총매출</b>을 넣습니다. ' +
"값이 있는 칸만 반영되고(같은 날 값은 덮어씀) 빈 칸은 기존 값 그대로입니다.</p>" +
'<p class="perf-muted" style="margin:0 0 10px">입력 가능한 쇼핑몰: ' + (shops || "없음") + "</p>" +
'<p style="margin:0 0 12px"><a class="erp-btn erp-btn-outline erp-btn-sm" href="/performance/api/manual-sales/sample.xlsx" download>' +
'<p style="margin:0 0 12px"><a class="erp-btn erp-btn-outline erp-btn-sm" href="' + BASE + '/api/manual-sales/sample.xlsx" download>' +
"샘플 파일 받기</a></p>" +
'<input type="file" class="erp-input perf-upload-file" accept=".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" aria-label="엑셀 파일" />' +
'<div class="perf-upload-result"></div>';
@@ -518,7 +528,7 @@
fd.append("file", f);
let res, body = null;
try {
res = await fetch("/performance/api/manual-sales/upload", { method: "POST", credentials: "same-origin", body: fd });
res = await fetch(BASE + "/api/manual-sales/upload", { method: "POST", credentials: "same-origin", body: fd });
try { body = await res.json(); } catch (_) { body = null; }
} catch (err) {
out.innerHTML = '<p class="perf-notice is-warn">업로드 실패: ' + esc(err.message) + "</p>";
@@ -588,7 +598,7 @@
});
let res, body = null;
try {
res = await fetch("/performance/api/ad-spend/upload?channel=" + encodeURIComponent(sel.value),
res = await fetch(BASE + "/api/ad-spend/upload?channel=" + encodeURIComponent(sel.value),
{ method: "POST", credentials: "same-origin", body: fd });
try { body = await res.json(); } catch (_) { body = null; }
} catch (err) {
@@ -624,7 +634,7 @@
let running = false;
try {
let cur = null;
try { cur = (await api("GET", "/performance/api/ad-sync/current")).job; } catch (_) { cur = null; }
try { cur = (await api("GET", BASE + "/api/ad-sync/current")).job; } catch (_) { cur = null; }
let job;
if (cur && !cur.finished) {
job = await runSyncWithProgress(null, "광고비 업데이트 진행 상황 " + (cur.from || "") + " ~ " + (cur.to || ""), cur);
@@ -632,7 +642,7 @@
const from = data.period_start, to = data.period_end < data.today ? data.period_end : data.today;
if (from > data.today) throw new Error("앞으로의 기간은 가져올 수 없습니다.");
job = await runSyncWithProgress({ from: from, to: to }, "광고비 업데이트 " + from + " ~ " + to, null,
"/performance/api/ad-sync");
BASE + "/api/ad-sync");
}
running = !!(job && !job.finished);
const ok = [], bad = [], other = [];
@@ -681,7 +691,7 @@
const m = openModal(name + " 광고 보고서 · " + (data.period_label || ""), { wide: true });
m.body.innerHTML = '<p class="perf-muted">불러오는 중…</p>';
try {
const res = await api("GET", "/performance/api/ad-spend/" + encodeURIComponent(code) + "/details?from=" +
const res = await api("GET", BASE + "/api/ad-spend/" + encodeURIComponent(code) + "/details?from=" +
encodeURIComponent(data.period_start) + "&to=" + encodeURIComponent(data.period_end));
if (!res.rows || !res.rows.length) { m.body.innerHTML = '<p class="perf-muted">이 기간 보고서 자료가 없습니다(파일 업로드 또는 광고 API 불러오기).</p>'; return; }
const cols = res.columns || [];
@@ -770,7 +780,7 @@
try {
// 이미 돌고 있는 업데이트(다른 사람·자동 업데이트 포함)가 있으면 새로 시작하지 않고 그 진행 창을 다시 연다
let cur = null;
try { cur = (await api("GET", "/performance/api/sync/current")).job; } catch (_) { cur = null; }
try { cur = (await api("GET", BASE + "/api/sync/current")).job; } catch (_) { cur = null; }
let job;
if (cur && !cur.finished) {
job = await runSyncWithProgress(null, "매출 업데이트 진행 상황 " + (cur.from || "") + " ~ " + (cur.to || ""), cur);
@@ -855,7 +865,7 @@
}, 120);
}
function saveManual(td, text) {
const raw = String(text || "").replace(/[,\s원]/g, "").replace(/^=/, "");
const raw = String(text || "").replace(/[,\s원]|RM/gi, "").replace(/^=/, "");
if (raw !== "" && !/^[-+*/().\d×÷xX]+$/.test(raw)) {
return Promise.reject(new Error("숫자 또는 1000+2000 같은 계산식만 입력하세요."));
}
@@ -864,7 +874,7 @@
return api("PUT", MANUAL_API + encodeURIComponent(td.dataset.manualCode) + "/" +
encodeURIComponent(td.dataset.date), { amount: raw === "" ? null : raw });
}).then(function (res) {
const manual = res.manual == null ? "" : String(res.manual);
const manual = res.manual == null ? "" : CENTS ? (res.manual / 100).toFixed(2) : String(res.manual);
td.dataset.manualValue = manual;
if (res.formula) td.dataset.formula = res.formula; else delete td.dataset.formula;
td.classList.toggle("is-manual", manual !== "");
@@ -960,7 +970,7 @@
td.classList.toggle("has-memo", !!memo);
}
async function saveMemo(td, memo) {
const res = await api("PUT", "/performance/api/cell-memos/" + encodeURIComponent(MEMO_KIND) + "/" +
const res = await api("PUT", BASE + "/api/cell-memos/" + encodeURIComponent(MEMO_KIND) + "/" +
encodeURIComponent(td.dataset.memoCode) + "/" + encodeURIComponent(td.dataset.date), { memo: memo });
setCellMemo(td, res.memo || "");
}
@@ -1037,7 +1047,7 @@
const m = openModal(title, { wide: true }); // 넓은 창 + 상품명 줄바꿈 → 가로 스크롤 없이
m.body.innerHTML = '<p class="perf-muted">불러오는 중…</p>';
try {
const res = await api("GET", "/performance/api/events?code=" + encodeURIComponent(code) +
const res = await api("GET", BASE + "/api/events?code=" + encodeURIComponent(code) +
"&from=" + encodeURIComponent(from) + "&to=" + encodeURIComponent(to));
const rows = res.rows || [];
if (!rows.length) { m.body.innerHTML = '<p class="perf-muted">내역이 없습니다.</p>'; return; }
@@ -1135,7 +1145,7 @@
const x = L + i * bw + bw * 0.15, w = Math.max(1, bw * 0.7);
const y0 = y(0), y1 = y(v);
g += '<rect class="bar' + (v < 0 ? " is-neg" : "") + '" x="' + x + '" y="' + Math.min(y0, y1) +
'" width="' + w + '" height="' + Math.max(0.5, Math.abs(y1 - y0)) + '"><title>' + esc(p.label) + " " + fmt(v) + "원</title></rect>";
'" width="' + w + '" height="' + Math.max(0.5, Math.abs(y1 - y0)) + '"><title>' + esc(p.label) + " " + money(v) + " " + CUR + "</title></rect>";
if (i % every === 0) g += '<text x="' + (L + i * bw + bw / 2) + '" y="' + (H - 8) + '" text-anchor="middle">' + esc(p.label) + "</text>";
});
g += '<line class="axis" x1="' + L + '" x2="' + (W - R) + '" y1="' + y(0) + '" y2="' + y(0) + '"/>';
@@ -1155,8 +1165,8 @@
const w = Math.max(0, (W - L - R) * Math.max(0, v) / maxV);
const pct = total > 0 ? (Math.max(0, v) / total * 100).toFixed(1) : "0.0";
g += '<text x="' + (L - 8) + '" y="' + (y + 14) + '" text-anchor="end">' + esc(r.name) + "</text>" +
'<rect class="bar" x="' + L + '" y="' + (y + 4) + '" width="' + w + '" height="13"><title>' + esc(r.name) + " " + fmt(v) + "원</title></rect>" +
'<text x="' + (L + w + 6) + '" y="' + (y + 14) + '">' + fmt(v) + " (" + pct + "%)</text>";
'<rect class="bar" x="' + L + '" y="' + (y + 4) + '" width="' + w + '" height="13"><title>' + esc(r.name) + " " + money(v) + " " + CUR + "</title></rect>" +
'<text x="' + (L + w + 6) + '" y="' + (y + 14) + '">' + money(v) + " (" + pct + "%)</text>";
});
box.innerHTML = svg(W, H, g);
}
@@ -1201,7 +1211,7 @@
if (pending || asking || document.hidden) return;
asking = true;
try {
const st = await api("GET", "/performance/api/update-status?kind=" + encodeURIComponent(w.kind));
const st = await api("GET", BASE + "/api/update-status?kind=" + encodeURIComponent(w.kind));
if (st.done && st.done !== seen && !st.running) { pending = true; reloadWhenFree(); }
} catch (_) { /* 잠깐 끊김·로그아웃 — 다음 차례에 */ } finally { asking = false; }
}
@@ -1340,7 +1350,7 @@
}
save.disabled = true;
try {
const res = await api("PUT", "/performance/api/auto-sync-schedule", payload);
const res = await api("PUT", BASE + "/api/auto-sync-schedule", payload);
rows.forEach(function (row) {
const r = res[row.dataset.kind];
if (!r) return;
@@ -1362,7 +1372,7 @@
b.addEventListener("click", async function () {
const u = b.dataset.unit;
try {
await api("PUT", "/performance/api/display-unit", { unit: u });
await api("PUT", BASE + "/api/display-unit", { unit: u });
} catch (err) {
alertMsg("저장 실패: " + err.message);
return;
@@ -1384,7 +1394,7 @@
root.querySelectorAll("#perf-view-opts [data-colw]").forEach(function (b) {
b.addEventListener("click", function () {
const v = b.dataset.colw;
document.cookie = "perf_colw=" + v + "; path=/performance; max-age=31536000; SameSite=Lax";
document.cookie = "perf_colw=" + v + "; path=" + BASE + "; max-age=31536000; SameSite=Lax";
root.querySelectorAll("#perf-view-opts [data-colw]").forEach(function (x) {
x.classList.toggle("is-active", x === b);
x.setAttribute("aria-checked", x === b ? "true" : "false");
@@ -1407,7 +1417,7 @@
c.addEventListener("change", function () {
const codes = hideBoxes.filter(function (x) { return x.checked; }).map(function (x) { return x.dataset.hide; });
hideSave = hideSave.then(function () {
return api("PUT", "/performance/api/hidden-marketplaces", { codes: codes });
return api("PUT", BASE + "/api/hidden-marketplaces", { codes: codes });
}).catch(function (err) {
c.checked = !c.checked;
alertMsg("저장 실패: " + err.message);
@@ -1424,7 +1434,7 @@
payload[box.dataset.field] = box.checked;
box.disabled = true;
try {
await api("PUT", "/performance/api/marketplaces/" + tr.dataset.code, payload);
await api("PUT", BASE + "/api/marketplaces/" + tr.dataset.code, payload);
} catch (err) {
box.checked = !box.checked;
alertMsg("저장 실패: " + err.message);
@@ -1438,12 +1448,12 @@
const tr = btn.closest("tr");
const code = tr.dataset.code, name = tr.dataset.name;
// 광고 API 연동 줄(data-api="ad-sources")은 /performance/api/ad-sources/…, 나머지는 쇼핑몰
const base = "/performance/api/" + (tr.dataset.api || "marketplaces") + "/";
const base = BASE + "/api/" + (tr.dataset.api || "marketplaces") + "/";
if (btn.dataset.act === "rate") openRate(code, name, btn.dataset.hasHistory === "1");
else if (btn.dataset.act === "creds") openCreds(code, name, base);
else if (btn.dataset.act === "test") runTest(code, name, btn, base);
else if (btn.dataset.act === "rename") openName(tr.dataset.group ? "그룹 이름 변경" : "쇼핑몰 이름 변경", name, function (v) {
return api("PUT", "/performance/api/marketplaces/" + code, { name: v });
return api("PUT", BASE + "/api/marketplaces/" + code, { name: v });
});
else if (btn.dataset.act === "delete") deleteCustom(code, name, !!tr.dataset.group);
});
@@ -1471,22 +1481,22 @@
}
const addShop = document.getElementById("perf-add-shop");
if (addShop) addShop.addEventListener("click", function () {
openName("쇼핑몰 추가(수동 입력)", "", function (v) { return api("POST", "/performance/api/marketplaces", { kind: "shop", name: v }); });
openName("쇼핑몰 추가(수동 입력)", "", function (v) { return api("POST", BASE + "/api/marketplaces", { kind: "shop", name: v }); });
});
const addGroup = document.getElementById("perf-add-group");
if (addGroup) addGroup.addEventListener("click", function () {
openName("그룹 추가", "", function (v) { return api("POST", "/performance/api/marketplaces", { kind: "group", name: v }); });
openName("그룹 추가", "", function (v) { return api("POST", BASE + "/api/marketplaces", { kind: "group", name: v }); });
});
async function deleteCustom(code, name, isGroup) {
let msg;
if (isGroup) msg = "그룹 [" + name + "]을 삭제할까요? 하위 쇼핑몰은 지워지지 않고 그룹 없음이 됩니다.";
else {
let days = 0;
try { days = (await api("GET", "/performance/api/marketplaces/" + code + "/manual-days")).days || 0; } catch (_) { /* 확인 문구만 */ }
try { days = (await api("GET", BASE + "/api/marketplaces/" + code + "/manual-days")).days || 0; } catch (_) { /* 확인 문구만 */ }
msg = "쇼핑몰 [" + name + "]을 삭제할까요?" + (days ? " 입력해 둔 매출 " + fmt(days) + "일치와 수수료율도 함께 지워지며 되돌릴 수 없습니다." : "");
}
if (!(await confirmMsg(msg))) return;
try { await api("DELETE", "/performance/api/marketplaces/" + code); location.reload(); }
try { await api("DELETE", BASE + "/api/marketplaces/" + code); location.reload(); }
catch (err) { alertMsg("삭제 실패: " + err.message); }
}
root.querySelectorAll("select[data-act-group]").forEach(function (sel) {
@@ -1494,7 +1504,7 @@
sel.addEventListener("change", async function () {
sel.disabled = true;
try {
await api("PUT", "/performance/api/marketplaces/" + sel.closest("tr").dataset.code, { parent_code: sel.value });
await api("PUT", BASE + "/api/marketplaces/" + sel.closest("tr").dataset.code, { parent_code: sel.value });
location.reload(); // 행이 그룹 아래로(또는 밖으로) 옮겨 그려진다
} catch (err) { sel.value = before; sel.disabled = false; alertMsg("저장 실패: " + err.message); }
});
@@ -1532,7 +1542,7 @@
document.body.classList.remove("perf-dragging");
const order = currentOrder();
if (order.join(",") === start) return;
try { await api("PUT", "/performance/api/marketplace-order", { codes: order }); }
try { await api("PUT", BASE + "/api/marketplace-order", { codes: order }); }
catch (err) { await alertMsg("순서 저장 실패: " + err.message); location.reload(); }
}
document.addEventListener("pointermove", move);
@@ -1577,7 +1587,7 @@
'</td><td><button type="button" class="erp-btn erp-btn-ghost erp-btn-sm" data-del="' + r.id + '">삭제</button></td></tr>';
}).join("") + "</tbody></table>";
}
try { renderHist((await api("GET", "/performance/api/marketplaces/" + code + "/rates")).rates || []); }
try { renderHist((await api("GET", BASE + "/api/marketplaces/" + code + "/rates")).rates || []); }
catch (err) { m.body.querySelector("#perf-rate-hist").textContent = err.message; }
m.body.addEventListener("click", async function (e) {
@@ -1585,7 +1595,7 @@
if (!b) return;
if (!(await confirmMsg("이 수수료 이력을 삭제할까요? 해당 기간 실적의 수수료가 다시 계산됩니다."))) return;
try {
renderHist((await api("DELETE", "/performance/api/marketplaces/" + code + "/rates/" + b.dataset.del)).rates || []);
renderHist((await api("DELETE", BASE + "/api/marketplaces/" + code + "/rates/" + b.dataset.del)).rates || []);
m.changed = true;
} catch (err) { alertMsg(err.message); }
});
@@ -1593,7 +1603,7 @@
const rate = m.body.querySelector("#perf-rate-in").value.trim();
if (!rate) { m.body.querySelector("#perf-rate-in").focus(); return; }
try {
const res = await api("POST", "/performance/api/marketplaces/" + code + "/rates", {
const res = await api("POST", BASE + "/api/marketplaces/" + code + "/rates", {
rate_percent: rate, effective_from: all.checked ? "2000-01-01" : from.value,
memo: m.body.querySelector("#perf-rate-memo").value,
});
@@ -1609,7 +1619,7 @@
// ── API 인증정보 ──
async function openCreds(code, name, base) {
base = base || "/performance/api/marketplaces/";
base = base || BASE + "/api/marketplaces/";
const m = openModal(name + " API 설정", { narrow: true, onClose: function () { if (m.changed) location.reload(); } });
m.body.innerHTML = '<p class="perf-muted">불러오는 중…</p>';
let info;
@@ -1709,7 +1719,7 @@
const label = btn.textContent;
btn.textContent = "확인 중…";
try {
const res = await api("POST", (base || "/performance/api/marketplaces/") + code + "/test", {});
const res = await api("POST", (base || BASE + "/api/marketplaces/") + code + "/test", {});
await alertMsg(name + " — " + (res.ok ? "정상 연결\n" : res.label + "\n") + res.message, res.ok ? { tone: "ok" } : undefined);
location.reload();
} catch (err) {
@@ -1765,7 +1775,7 @@
if (gen) gen.addEventListener("click", async function () {
gen.disabled = true;
try {
const res = await api("POST", "/performance/api/sample-data", {
const res = await api("POST", BASE + "/api/sample-data", {
action: "generate", from: document.getElementById("perf-sample-from").value,
to: document.getElementById("perf-sample-to").value,
});
@@ -1777,7 +1787,7 @@
if (del) del.addEventListener("click", async function () {
if (!(await confirmMsg("테스트 데이터만 모두 삭제합니다. 실제 수집한 매출은 지우지 않습니다. 계속할까요?"))) return;
try {
const res = await api("POST", "/performance/api/sample-data", { action: "delete" });
const res = await api("POST", BASE + "/api/sample-data", { action: "delete" });
await alertMsg("테스트 데이터 " + fmt(res.deleted) + "건을 삭제했습니다.");
location.reload();
} catch (err) { alertMsg(err.message); }
@@ -1786,7 +1796,7 @@
if (rekey) rekey.addEventListener("click", async function () {
if (!(await confirmMsg("예전 키로 암호화된 인증정보를 현재 키로 다시 암호화합니다. 계속할까요?"))) return;
try {
const res = await api("POST", "/performance/api/rekey");
const res = await api("POST", BASE + "/api/rekey");
await alertMsg("다시 암호화 " + res.reencrypted + "건" + (res.failed ? ", 실패 " + res.failed + "건(다시 입력 필요)" : ""));
location.reload();
} catch (err) { alertMsg(err.message); }