상태 변경에 따른 미수금 계산 코드 추가
This commit is contained in:
@ -164,67 +164,101 @@ $od = sql_fetch($sql);
|
||||
|
||||
// 주문 합계
|
||||
$sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price,
|
||||
SUM(cp_price) as coupon
|
||||
SUM(cp_price) as coupon,
|
||||
COUNT(distinct it_id) as cnt
|
||||
from {$g4['shop_cart_table']}
|
||||
where od_id = '$od_id'
|
||||
and ct_status IN ( '주문', '준비', '배송', '완료' ) ";
|
||||
$sum = sql_fetch($sql);
|
||||
$cart_price = $sum['price'];
|
||||
$cart_coupon = $sum['coupon'];
|
||||
|
||||
// 주문할인 쿠폰
|
||||
$sql = " select cp_id, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum
|
||||
from {$g4['shop_coupon_table']}
|
||||
where od_id = '$od_id'
|
||||
and cp_method = '2' ";
|
||||
$cp = sql_fetch($sql);
|
||||
|
||||
if($cp['cp_id']) {
|
||||
$dc = 0;
|
||||
$tot_od_price = $cart_price - $cart_coupon;
|
||||
|
||||
if($cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_price)) {
|
||||
if($cp['cp_type']) {
|
||||
$dc = floor(($tot_od_price * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
|
||||
} else {
|
||||
$dc = $cp['cp_price'];
|
||||
}
|
||||
|
||||
if($cp['cp_maximum'] && $dc > $cp['cp_maximum'])
|
||||
$dc = $cp['cp_maximum'];
|
||||
|
||||
if($tot_od_price < $dc)
|
||||
$dc = $tot_od_price;
|
||||
}
|
||||
}
|
||||
$cart_count = $sum['cnt'];
|
||||
|
||||
// 배송비
|
||||
$send_cost = get_sendcost($cart_price, $od_id);
|
||||
|
||||
$tot_od_cp_price = $tot_sc_cp_price = 0;
|
||||
|
||||
if($od['mb_id']) {
|
||||
// 주문할인 쿠폰
|
||||
$sql = " select a.cp_id, a.cp_type, a.cp_price, a.cp_trunc, a.cp_minimum, a.cp_maximum
|
||||
from {$g4['shop_coupon_table']} a right join {$g4['shop_coupon_log_table']} b on ( a.cp_id = b.cp_id )
|
||||
where b.od_id = '$od_id'
|
||||
and b.mb_id = '{$od['mb_id']}'
|
||||
and a.cp_method = '2' ";
|
||||
$cp = sql_fetch($sql);
|
||||
|
||||
$tot_od_price = $cart_price - $cart_coupon;
|
||||
|
||||
if($cp['cp_id']) {
|
||||
$dc = 0;
|
||||
|
||||
if($cp['cp_minimum'] <= $tot_od_price) {
|
||||
if($cp['cp_type']) {
|
||||
$dc = floor(($tot_od_price * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
|
||||
} else {
|
||||
$dc = $cp['cp_price'];
|
||||
}
|
||||
|
||||
if($cp['cp_maximum'] && $dc > $cp['cp_maximum'])
|
||||
$dc = $cp['cp_maximum'];
|
||||
|
||||
if($tot_od_price < $dc)
|
||||
$dc = $tot_od_price;
|
||||
|
||||
$tot_od_price -= $dc;
|
||||
$tot_od_cp_price = $dc;
|
||||
}
|
||||
}
|
||||
|
||||
// 배송쿠폰 할인
|
||||
$sql = " select a.cp_id, a.cp_type, a.cp_price, a.cp_trunc, a.cp_minimum, a.cp_maximum
|
||||
from {$g4['shop_coupon_table']} a right join {$g4['shop_coupon_log_table']} b on ( a.cp_id = b.cp_id )
|
||||
where b.od_id = '$od_id'
|
||||
and b.mb_id = '{$od['mb_id']}'
|
||||
and a.cp_method = '3' ";
|
||||
$cp = sql_fetch($sql);
|
||||
|
||||
if($cp['cp_id']) {
|
||||
$dc = 0;
|
||||
if($cp['cp_minimum'] <= $tot_od_price) {
|
||||
if($cp['cp_type']) {
|
||||
$dc = floor(($send_cost * ($cp['cp_price'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
|
||||
} else {
|
||||
$dc = $cp['cp_price'];
|
||||
}
|
||||
|
||||
if($cp['cp_maximum'] && $dc > $cp['cp_maximum'])
|
||||
$dc = $cp['cp_maximum'];
|
||||
|
||||
if($dc > $send_cost)
|
||||
$dc = $send_cost;
|
||||
|
||||
$tot_sc_cp_price = $dc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 취소 합계
|
||||
$sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price,
|
||||
SUM(cp_price) as coupon
|
||||
$sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price
|
||||
from {$g4['shop_cart_table']}
|
||||
where od_id = '$od_id'
|
||||
and ct_status IN ( '취소', '반품', '품절' ) ";
|
||||
$sum = sql_fetch($sql);
|
||||
$cancel_price = $sum['price'];
|
||||
$cancel_coupon = $sum['coupon'];
|
||||
|
||||
// 배송비가 배송비 쿠폰보다 작다면 쿠폰금액으로 설정
|
||||
if($send_cost < $od['od_send_coupon'])
|
||||
$send_cost = $od['od_send_coupon'];
|
||||
|
||||
// 미수
|
||||
$od_misu = $od['od_cart_price'] + $send_cost + $od['od_send_cost2']
|
||||
- ($od['od_cart_coupon'] + $od['od_coupon'] + $od['od_send_coupon'])
|
||||
- ($od['od_receipt_price'] + $od['od_receipt_point'])
|
||||
+ $cancel_coupon
|
||||
+ ($od['od_coupon'] - $dc);
|
||||
$od_misu = ( $cart_price + $send_cost + $od['od_send_cost2'] )
|
||||
- ( $cart_coupon + $tot_od_cp_price + $tot_sc_cp_price )
|
||||
- ( $od['od_receipt_price'] + $od['od_receipt_point'] - $od['od_refund_price'] );
|
||||
|
||||
// 주문정보 반영
|
||||
$sql = " update {$g4['shop_order_table']}
|
||||
set od_cancel_price = '$cancel_price',
|
||||
set od_cart_price = '$cart_price',
|
||||
od_cart_coupon = '$cart_coupon',
|
||||
od_coupon = '$tot_od_cp_price',
|
||||
od_send_coupon = '$tot_sc_cp_price',
|
||||
od_cancel_price = '$cancel_price',
|
||||
od_send_cost = '$send_cost',
|
||||
od_misu = '$od_misu'
|
||||
where od_id = '$od_id' ";
|
||||
|
||||
@ -251,7 +251,7 @@ $pg_anchor = '<ul class="anchor">
|
||||
$amount['취소'] = $od['od_cancel_price'];
|
||||
|
||||
// 미수금 = 주문금액 - 취소금액 - 입금금액 - 쿠폰금액
|
||||
$amount['미수'] = $amount['주문'] - $amount['입금'] - $amount['쿠폰'];
|
||||
//$amount['미수'] = $amount['주문'] - $amount['입금'] - $amount['쿠폰'];
|
||||
|
||||
// 결제방법
|
||||
$s_receipt_way = $od['od_settle_case'];
|
||||
@ -260,7 +260,7 @@ $pg_anchor = '<ul class="anchor">
|
||||
$s_receipt_way .= "+포인트";
|
||||
?>
|
||||
|
||||
<strong class="sodr_nonpay">미수금 <?php echo display_price($amount['미수']); ?></strong>
|
||||
<strong class="sodr_nonpay">미수금 <?php echo display_price($od['od_misu']); ?></strong>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
@ -394,8 +394,8 @@ $pg_anchor = '<ul class="anchor">
|
||||
<td><?php echo display_point($od['od_receipt_point']); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">취소/환불액</th>
|
||||
<td><?php echo display_price($od['od_cancel_price']); ?></td>
|
||||
<th scope="row">결제취소/환불액</th>
|
||||
<td><?php echo display_price($od['od_refund_price']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$sql = " select dl_company, dl_url, dl_tel from {$g4['shop_delivery_table']} where dl_id = '{$od['dl_id']}' ";
|
||||
@ -585,9 +585,9 @@ $pg_anchor = '<ul class="anchor">
|
||||
<td><input type="text" name="od_receipt_point" value="<?php echo $od['od_receipt_point']; ?>" id="od_receipt_point" class="frm_input" size="10"> 점</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="od_cancel_price">취소/환불 금액</label></th>
|
||||
<th scope="row"><label for="od_refund_price">결제취소/환불 금액</label></th>
|
||||
<td>
|
||||
<input type="text" name="od_cancel_price" value="<?php echo $od['od_cancel_price']; ?>" class="frm_input" size="10"> 원
|
||||
<input type="text" name="od_refund_price" value="<?php echo $od['od_refund_price']; ?>" class="frm_input" size="10"> 원
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -640,7 +640,7 @@ $pg_anchor = '<ul class="anchor">
|
||||
|
||||
<div class="btn_confirm">
|
||||
<input type="submit" value="결제/배송내역 수정" class="btn_submit">
|
||||
<?php if($amount['미수'] > 0) { ?>
|
||||
<?php if($od['od_misu'] > 0) { ?>
|
||||
<a href="./personalpayform.php?popup=yes&od_id=<?php echo $od_id; ?>" id="personalpay_add">개인결제추가</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
@ -6,27 +6,37 @@ include_once(G4_LIB_PATH.'/icode.sms.lib.php');
|
||||
|
||||
auth_check($auth[$sub_menu], "w");
|
||||
|
||||
$sql = " select * from {$g4['shop_order_table']} where od_id = '$od_id' ";
|
||||
$od = sql_fetch($sql);
|
||||
|
||||
if(!$od['od_id'])
|
||||
alert('주문자료가 존재하지 않습니다.');
|
||||
|
||||
if ($od_receipt_time)
|
||||
{
|
||||
if (check_datetime($od_receipt_time) == false)
|
||||
alert('결제일시 오류입니다.');
|
||||
}
|
||||
|
||||
// 미수
|
||||
$od_misu = ( $od['od_cart_price'] + $od_send_cost + $od_send_cost2 )
|
||||
- ( $od['od_cart_coupon'] + $od['od_coupon'] + $od['od_send_coupon'] )
|
||||
- ( $od_receipt_price + $od_receipt_point - $od_refund_price );
|
||||
|
||||
$sql = " update {$g4['shop_order_table']}
|
||||
set od_deposit_name = '$od_deposit_name',
|
||||
od_bank_account = '$od_bank_account',
|
||||
od_receipt_time = '$od_receipt_time',
|
||||
od_receipt_price = '$od_receipt_price',
|
||||
od_receipt_point = '$od_receipt_point',
|
||||
od_cancel_price = '$od_cancel_price',
|
||||
od_refund_price = '$od_refund_price',
|
||||
od_misu = '$od_misu',
|
||||
dl_id = '$dl_id',
|
||||
od_invoice = '$od_invoice',
|
||||
od_invoice_time = '$od_invoice_time' ";
|
||||
if (isset($od_send_cost))
|
||||
$sql .= " , od_send_cost = '$od_send_cost' ";
|
||||
if (isset($od_send_cost2))
|
||||
$sql .= " , od_send_cost2 = '$od_send_cost2' ";
|
||||
$sql .= " where od_id = '$od_id' ";
|
||||
od_invoice_time = '$od_invoice_time',
|
||||
od_send_cost = '$od_send_cost',
|
||||
od_send_cost2 = '$od_send_cost2'
|
||||
where od_id = '$od_id' ";
|
||||
sql_query($sql);
|
||||
|
||||
|
||||
|
||||
@ -514,7 +514,7 @@ if(!sql_query(" select od_misu from {$g4['shop_order_table']} limit 1 ", false))
|
||||
ADD `od_misu` int(11) NOT NULL DEFAULT '0' AFTER `od_coupon` ", true);
|
||||
}
|
||||
|
||||
// 쿠폰 history 테이블추가
|
||||
// 쿠폰로그 테이블추가
|
||||
if(!isset($g4['shop_coupon_log_table']))
|
||||
die_utf8('dbconfig.php 파일에 $g4[\'shop_coupon_log_table\'] = SHOP_TABLE_PREFIX.\'coupon_log\'; // 쿠폰정보 테이블 추가해주세요.');
|
||||
if(!sql_query(" DESCRIBE `{$g4['shop_coupon_log_table']}` ", false)) {
|
||||
@ -534,4 +534,10 @@ if(!sql_query(" DESCRIBE `{$g4['shop_coupon_log_table']}` ", false)) {
|
||||
DROP `cp_used_time`,
|
||||
DROP `cp_used` ", true);
|
||||
}
|
||||
|
||||
// 환불필드 추가
|
||||
if(!sql_query(" select od_refund_price from {$g4['shop_order_table']} limit 1 ", false)) {
|
||||
sql_query(" ALTER TABLE `{$g4['shop_order_table']}`
|
||||
ADD `od_refund_price` int(11) NOT NULL DEFAULT '0' AFTER `od_receipt_point` ", true);
|
||||
}
|
||||
?>
|
||||
|
||||
@ -597,6 +597,7 @@ CREATE TABLE IF NOT EXISTS `shop_order` (
|
||||
`od_receipt_price` int(11) NOT NULL DEFAULT '0',
|
||||
`od_cancel_price` int(11) NOT NULL DEFAULT '0',
|
||||
`od_receipt_point` int(11) NOT NULL DEFAULT '0',
|
||||
`od_refund_price` int(11) NOT NULL DEFAULT '0',
|
||||
`od_bank_account` varchar(255) NOT NULL DEFAULT '',
|
||||
`od_receipt_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`od_coupon` int(11) NOT NULL DEFAULT '0',
|
||||
|
||||
Reference in New Issue
Block a user