Exemplo n.º 1
0
function get_order_info($od_id)
{
    global $g5;
    // 주문정보
    $sql = " select * from {$g5['g5_shop_order_table']} where od_id = '{$od_id}' ";
    $od = sql_fetch($sql);
    if (!$od['od_id']) {
        return false;
    }
    $info = array();
    // 장바구니 주문금액정보
    $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price,\n                    SUM(cp_price) as coupon,\n                    SUM( IF( ct_notax = 0, ( IF(io_type = 1, (io_price * ct_qty), ( (ct_price + io_price) * ct_qty) ) - cp_price ), 0 ) ) as tax_mny,\n                    SUM( IF( ct_notax = 1, ( IF(io_type = 1, (io_price * ct_qty), ( (ct_price + io_price) * ct_qty) ) - cp_price ), 0 ) ) as free_mny\n                from {$g5['g5_shop_cart_table']}\n                where od_id = '{$od_id}'\n                  and ct_status IN ( '주문', '입금', '준비', '배송', '완료' ) ";
    $sum = sql_fetch($sql);
    $cart_price = $sum['price'];
    $cart_coupon = $sum['coupon'];
    // 배송비
    $send_cost = get_sendcost($od_id);
    $od_coupon = $od_send_coupon = 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\n                    from {$g5['g5_shop_coupon_table']} a right join {$g5['g5_shop_coupon_log_table']} b on ( a.cp_id = b.cp_id )\n                    where b.od_id = '{$od_id}'\n                      and b.mb_id = '{$od['mb_id']}'\n                      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;
                $od_coupon = $dc;
            }
        }
        // 배송쿠폰 할인
        $sql = " select a.cp_id, a.cp_type, a.cp_price, a.cp_trunc, a.cp_minimum, a.cp_maximum\n                    from {$g5['g5_shop_coupon_table']} a right join {$g5['g5_shop_coupon_log_table']} b on ( a.cp_id = b.cp_id )\n                    where b.od_id = '{$od_id}'\n                      and b.mb_id = '{$od['mb_id']}'\n                      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;
                }
                $od_send_coupon = $dc;
            }
        }
    }
    // 과세, 비과세 금액정보
    $tax_mny = $sum['tax_mny'];
    $free_mny = $sum['free_mny'];
    if ($od['od_tax_flag']) {
        $tot_tax_mny = $tax_mny + $send_cost + $od['od_send_cost2'] - ($od_coupon + $od_send_coupon + $od['od_receipt_point']);
        if ($tot_tax_mny < 0) {
            $free_mny += $tot_tax_mny;
            $tot_tax_mny = 0;
        }
    } else {
        $tot_tax_mny = $tax_mny + $free_mny + $send_cost + $od['od_send_cost2'] - ($od_coupon + $od_send_coupon + $od['od_receipt_point']);
        $free_mny = 0;
    }
    $od_tax_mny = round($tot_tax_mny / 1.1);
    $od_vat_mny = $tot_tax_mny - $od_tax_mny;
    $od_free_mny = $free_mny;
    // 장바구니 취소금액 정보
    $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price\n                from {$g5['g5_shop_cart_table']}\n                where od_id = '{$od_id}'\n                  and ct_status IN ( '취소', '반품', '품절' ) ";
    $sum = sql_fetch($sql);
    $cancel_price = $sum['price'];
    // 미수금액
    $od_misu = $cart_price + $send_cost + $od['od_send_cost2'] - ($cart_coupon + $od_coupon + $od_send_coupon) - ($od['od_receipt_price'] + $od['od_receipt_point'] - $od['od_refund_price']);
    // 장바구니상품금액
    $od_cart_price = $cart_price + $cancel_price;
    // 결과처리
    $info['od_cart_price'] = $od_cart_price;
    $info['od_send_cost'] = $send_cost;
    $info['od_coupon'] = $od_coupon;
    $info['od_send_coupon'] = $od_send_coupon;
    $info['od_cart_coupon'] = $cart_coupon;
    $info['od_tax_mny'] = $od_tax_mny;
    $info['od_vat_mny'] = $od_vat_mny;
    $info['od_free_mny'] = $od_free_mny;
    $info['od_cancel_price'] = $cancel_price;
    $info['od_misu'] = $od_misu;
    return $info;
}
Exemplo n.º 2
0
</strong></span>
            </div>

        </li>

        <?php 
    $tot_point += $point;
    $tot_sell_price += $sell_price;
}
// for 끝
if ($i == 0) {
    //echo '<tr><td colspan="'.$colspan.'" class="empty_table">장바구니에 담긴 상품이 없습니다.</td></tr>';
    alert('장바구니가 비어 있습니다.', G5_SHOP_URL . '/cart.php');
} else {
    // 배송비 계산
    $send_cost = get_sendcost($s_cart_id);
}
// 복합과세처리
if ($default['de_tax_flag_use']) {
    $comm_tax_mny = round(($tot_tax_mny + $send_cost) / 1.1);
    $comm_vat_mny = $tot_tax_mny + $send_cost - $comm_tax_mny;
}
?>
    </ul>

    <?php 
if ($goods_count) {
    $goods .= ' 외 ' . $goods_count . '건';
}
?>
Exemplo n.º 3
0
                $dc = $cp['cp_maximum'];
            }
            if ($tot_od_price < $dc) {
                die('Order coupon error.');
            }
            $tot_od_cp_price = $dc;
            $tot_od_price -= $tot_od_cp_price;
        }
    }
    $tot_cp_price = $tot_it_cp_price + $tot_od_cp_price;
}
if ((int) ($row['od_price'] - $tot_cp_price) !== $i_price) {
    die("Error.");
}
// 배송비가 상이함
$send_cost = get_sendcost($tmp_cart_id);
$tot_sc_cp_price = 0;
if ($is_member && $send_cost > 0) {
    // 배송쿠폰
    if ($_POST['sc_cp_id']) {
        $sql = " select cp_id, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum\n                    from {$g5['g5_shop_coupon_table']}\n                    where cp_id = '{$_POST['sc_cp_id']}'\n                      and mb_id IN ( '{$member['mb_id']}', '전체회원' )\n                      and cp_start <= '" . G5_TIME_YMD . "'\n                      and cp_end >= '" . G5_TIME_YMD . "'\n                      and cp_method = '3' ";
        $cp = sql_fetch($sql);
        // 사용한 쿠폰인지
        $cp_used = is_used_coupon($member['mb_id'], $cp['cp_id']);
        $dc = 0;
        if (!$cp_used && $cp['cp_id'] && $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'];
            }