fix: 판매 모달에서 마일리지 표시 오류 수정
- patient_id를 통한 직접 조회로 변경 - /api/patients/search 엔드포인트 추가 - 판매 버튼에 patient_id 데이터 속성 추가 - loadPatientMileage 함수 개선 (patient_id 기반 조회) 이제 박주호 회원의 50,000 마일리지가 판매 모달에서 정상 표시됨 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1380,6 +1380,7 @@ $(document).ready(function() {
|
||||
<button class="btn btn-sm btn-outline-success process-sale" data-id="${compound.compound_id}"
|
||||
data-formula="${compound.formula_name || '직접조제'}"
|
||||
data-patient="${compound.patient_name || '직접조제'}"
|
||||
data-patient-id="${compound.patient_id || ''}"
|
||||
data-cost="${compound.cost_total || 0}"
|
||||
data-price="${compound.sell_price_total || 0}">
|
||||
<i class="bi bi-cash-coin"></i> 판매
|
||||
@@ -1411,10 +1412,11 @@ $(document).ready(function() {
|
||||
const compoundId = $(this).data('id');
|
||||
const formulaName = $(this).data('formula');
|
||||
const patientName = $(this).data('patient');
|
||||
const patientId = $(this).data('patient-id');
|
||||
const costTotal = $(this).data('cost');
|
||||
const priceTotal = $(this).data('price');
|
||||
|
||||
openSalesModal(compoundId, formulaName, patientName, costTotal, priceTotal);
|
||||
openSalesModal(compoundId, formulaName, patientName, patientId, costTotal, priceTotal);
|
||||
});
|
||||
|
||||
// 배송 처리 버튼 이벤트
|
||||
@@ -3553,14 +3555,14 @@ $(document).ready(function() {
|
||||
// ==================== 판매 관리 기능 ====================
|
||||
|
||||
// 판매 모달 열기
|
||||
function openSalesModal(compoundId, formulaName, patientName, costTotal, priceTotal) {
|
||||
function openSalesModal(compoundId, formulaName, patientName, patientId, costTotal, priceTotal) {
|
||||
$('#salesCompoundId').val(compoundId);
|
||||
$('#salesFormulaName').val(formulaName);
|
||||
$('#salesPatientName').val(patientName);
|
||||
$('#salesCostTotal').val(costTotal);
|
||||
|
||||
// 환자 마일리지 조회
|
||||
loadPatientMileage(patientName);
|
||||
// 환자 마일리지 조회 (patient_id로 직접 조회)
|
||||
loadPatientMileage(patientId);
|
||||
|
||||
// 기본 가격 계산 (원가 + 조제료)
|
||||
const dispensingFee = parseFloat($('#salesDispensingFee').val()) || 20000;
|
||||
@@ -3598,11 +3600,12 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
// 환자 마일리지 조회
|
||||
function loadPatientMileage(patientName) {
|
||||
if (patientName && patientName !== '직접조제') {
|
||||
$.get('/api/patients/search', { name: patientName }, function(response) {
|
||||
if (response.success && response.data.length > 0) {
|
||||
const patient = response.data[0];
|
||||
function loadPatientMileage(patientId) {
|
||||
if (patientId) {
|
||||
// patient_id로 직접 조회
|
||||
$.get(`/api/patients/${patientId}`, function(response) {
|
||||
if (response.success && response.data) {
|
||||
const patient = response.data;
|
||||
const mileage = patient.mileage_balance || 0;
|
||||
$('#patientMileageBalance').text(mileage.toLocaleString());
|
||||
$('#salesMileageUse').attr('max', mileage);
|
||||
@@ -3610,8 +3613,13 @@ $(document).ready(function() {
|
||||
$('#patientMileageBalance').text('0');
|
||||
$('#salesMileageUse').attr('max', 0);
|
||||
}
|
||||
}).fail(function() {
|
||||
console.error('Failed to load patient mileage');
|
||||
$('#patientMileageBalance').text('0');
|
||||
$('#salesMileageUse').attr('max', 0);
|
||||
});
|
||||
} else {
|
||||
// 직접조제인 경우
|
||||
$('#patientMileageBalance').text('0');
|
||||
$('#salesMileageUse').attr('max', 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user