fix: 회원 상세 - transaction_id로 POS 품목 조회 연동
- 마일리지 적립 시 저장된 transaction_id로 SALE_SUB 조회 - 적립 내역에 구매 품목 표시 (품명, 수량, 가격) - 구매 이력 탭: QR 적립된 구매만 품목과 함께 표시 - 기존 전화번호→고객코드 매핑 로직 제거 (불필요)
This commit is contained in:
@@ -906,6 +906,25 @@
|
||||
month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit'
|
||||
}) : '';
|
||||
|
||||
// 품목 렌더링
|
||||
let itemsHtml = '';
|
||||
if (tx.items && tx.items.length > 0) {
|
||||
itemsHtml = `
|
||||
<div class="tx-items">
|
||||
${tx.items.map(item => `
|
||||
<div class="tx-item">
|
||||
<span class="tx-item-name">${escapeHtml(item.name)}</span>
|
||||
<span class="tx-item-qty">x${item.quantity}</span>
|
||||
<span class="tx-item-price">${item.price.toLocaleString()}원</span>
|
||||
</div>
|
||||
`).join('')}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// 금액 표시
|
||||
const amountText = tx.total_amount ? ` (${tx.total_amount.toLocaleString()}원 구매)` : '';
|
||||
|
||||
return `
|
||||
<div class="tx-card ${isPositive ? '' : 'negative'}">
|
||||
<div class="tx-header">
|
||||
@@ -914,26 +933,34 @@
|
||||
${isPositive ? '+' : ''}${tx.points.toLocaleString()}P
|
||||
</div>
|
||||
</div>
|
||||
<div class="tx-desc">${escapeHtml(tx.description || tx.reason || '')}</div>
|
||||
<div class="tx-desc">${escapeHtml(tx.description || tx.reason || '')}${amountText}</div>
|
||||
${itemsHtml}
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function renderPurchaseTab(container) {
|
||||
if (!detailData.purchases || detailData.purchases.length === 0) {
|
||||
container.innerHTML = '<div class="detail-empty">📭 구매 이력이 없습니다<br><small style="color:#94a3b8;">최근 30일 내역만 표시됩니다</small></div>';
|
||||
// 적립 내역 중 품목이 있는 것들만 추출
|
||||
if (!detailData.mileage || !detailData.mileage.transactions) {
|
||||
container.innerHTML = '<div class="detail-empty">📭 구매 이력이 없습니다</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
const purchases = detailData.mileage.transactions.filter(tx =>
|
||||
tx.items && tx.items.length > 0 && tx.points > 0
|
||||
);
|
||||
|
||||
if (purchases.length === 0) {
|
||||
container.innerHTML = '<div class="detail-empty">📭 QR 적립된 구매 이력이 없습니다</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
const purchases = detailData.purchases;
|
||||
container.innerHTML = purchases.map(p => {
|
||||
// 날짜 포맷
|
||||
const dateStr = p.date || '';
|
||||
let formattedDate = dateStr;
|
||||
if (dateStr.length === 8) {
|
||||
formattedDate = `${dateStr.slice(0,4)}-${dateStr.slice(4,6)}-${dateStr.slice(6,8)}`;
|
||||
}
|
||||
const date = p.created_at ? new Date(p.created_at).toLocaleString('ko-KR', {
|
||||
year: 'numeric', month: 'short', day: 'numeric'
|
||||
}) : '';
|
||||
|
||||
// 품목 렌더링
|
||||
const itemsHtml = (p.items || []).map(item => `
|
||||
@@ -947,9 +974,10 @@
|
||||
return `
|
||||
<div class="purchase-card">
|
||||
<div class="purchase-header">
|
||||
<span class="purchase-date">📅 ${formattedDate}</span>
|
||||
<span class="purchase-total">${p.total.toLocaleString()}원</span>
|
||||
<span class="purchase-date">📅 ${date}</span>
|
||||
<span class="purchase-total">${(p.total_amount || 0).toLocaleString()}원</span>
|
||||
</div>
|
||||
<div style="font-size:12px;color:#10b981;margin-bottom:8px;">+${p.points.toLocaleString()}P 적립</div>
|
||||
${p.items && p.items.length > 0 ? `
|
||||
<div class="purchase-items">${itemsHtml}</div>
|
||||
` : ''}
|
||||
|
||||
Reference in New Issue
Block a user