break; default: $pp_means = '통장입금'; break; } $list[$i]['pp_means'] = $pp_means; switch ($row['pp_confirm']) { case '1': $pp_confirm = '완료'; break; case '2': $pp_confirm = '취소'; break; default: $pp_confirm = '신청'; break; } $list[$i]['pp_confirm'] = $pp_confirm; $list[$i]['pp_memo'] = conv_content(trim($row['pp_memo']), 0); $list[$i]['pp_memo'] = str_replace("\"", "'", $list[$i]['pp_memo']); $list[$i]['pp_ans'] = conv_content(trim($row['pp_ans']), 0); $list[$i]['pp_ans'] = str_replace("\"", "'", $list[$i]['pp_ans']); list($net, $vat) = apms_vat($row['pp_amount']); $list[$i]['pp_net'] = $net; $list[$i]['pp_vat'] = $vat; } // 페이징 $write_pages = G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages']; $list_page = './?ap=' . $ap . '&page='; $action_url = './payconfirm.php'; @(include_once $skin_path . '/paylist.skin.php');
alert_close('신청금액을 ' . number_format($account['unit']) . '원 단위로 입력해 주세요.'); } // 신청내역 $row = array(); $row['pp_means'] = $pp_means; switch ($pp_means) { case '1': $pp_means = AS_MP . '전환'; break; default: $pp_means = '통장입금'; break; } $row['pp_amount'] = $pp_amount; $row['pp_field'] = $pp_field; list($net, $vat) = apms_vat($pp_amount); $row['pp_net'] = $net; $row['pp_vat'] = $vat; //유형 $row['pp_type'] = $partner['pt_type']; $row['pp_company'] = $partner['pt_company']; //방법 $row['pp_flag'] = $partner['pt_flag']; $pp_flag = apms_pay_flag($partner['pt_flag']); //예상금액 $pp = array(); $pp = apms_pay_amount($row); define('G5_IS_ADMIN', true); $g5['title'] = '신청내역 확인'; include_once G5_PATH . '/head.sub.php'; include_once $skin_path . '/payconfirm.skin.php';
function apms_order($od_id, $od_status, $od_mk = '') { global $g5; if (!$od_id) { return; } $arr_it_id = array(); $arr_no_auto = array(); $account = array(); $now = G5_TIME_YMDHIS; $od_ok = $od_status == "입금" ? true : false; // APMS $mk_id = ''; $mk_brate = 0; if (USE_PARTNER) { $apms = sql_fetch(" select * from {$g5['apms']} ", false); if ($od_mk) { // 추천인 아이디가 있으면 $mk = apms_marketer($od_mk, 'pt_id, pt_benefit'); if ($mk['pt_id']) { $mk_id = $mk['pt_id']; $lvl = isset($mk['pt_level']) && $mk['pt_level'] > 0 ? $mk['pt_level'] : 1; $mk_lvrate = isset($apms['apms_benefit' . $lvl]) && $apms['apms_benefit' . $lvl] > 0 ? $apms['apms_benefit' . $lvl] : 0; $mk_brate = ($mk_lvrate + $mk['pt_benefit']) / 100; } } } // 장바구니에서 내역가져오기 $result = sql_query("select * from {$g5['g5_shop_cart_table']} where od_id = '{$od_id}' and ct_select = '1' order by pt_id, it_id", false); while ($row = sql_fetch_array($result)) { $it = apms_it($row['it_id']); //상품정보 $query = ""; if ($od_ok && in_array($it['pt_it'], $g5['apms_automation'])) { //자동처리 상품일 때 입금상태이면 재고반영, 포인트반영, 결제완료 처리함 //상태변경 $ct_status = '완료'; // 장바구니 업데이트 $query .= ", ct_status = '{$ct_status}'"; // 판매량 반영 $arr_it_id[] = $row['it_id']; // 재고량 반영 if (!$row['ct_stock_use']) { //YC5 관리자용 차용 apms_stock($row['it_id'], $row['ct_qty'], $row['io_id'], $row['io_type']); $query .= ", ct_stock_use = '1'"; } // 포인트 반영 - 컨텐츠 상품은 설정일과 상관없이 반영함 if ($row['mb_id'] && $row['ct_point'] > 0 && !$row['ct_point_use']) { $po_point = $row['ct_point'] * $row['ct_qty']; $po_content = "주문번호 {$od_id} ({$row['it_id']} : {$row['ct_id']}) 결제완료"; insert_point($row['mb_id'], $po_point, $po_content, "@delivery", $row['mb_id'], "{$od_id},{$row['ct_id']}"); $query .= ", ct_point_use = '1'"; } // 정산일 반영 $query .= ", pt_datetime = '{$now}'"; // 히스토리에 남김 - 히스토리에 남길때는 작업|아이디|시간|IP|그리고 나머지 자료 $ct_history = "\n{$ct_status}|automation|{$now}|"; $query .= ", ct_history = CONCAT(ct_history,'{$ct_history}')"; // 멤버쉽 아이템 체크 - 멤버쉽 함수가 있을 때만 작동 if (function_exists('apms_membership_order')) { apms_membership_order($row, $ct_status, $now); } } else { // 자동처리 아닌 상품 $arr_no_auto[] = $row['it_id']; } //커미션, 인센티브 if (USE_PARTNER) { if ($it['pt_id']) { // 판매자 list($commission, $incentive) = apms_pt_rate($apms, $it['pt_it'], $it['pt_id'], $it['pt_commission'], $it['pt_incentive']); $row['pt_commission_rate'] = $commission ? $commission : 0; $row['pt_incentive_rate'] = $incentive ? $incentive : 0; // 가정산 $account = apms_account($row); $query .= " , pt_id = '{$it['pt_id']}'\n\t\t\t\t\t\t\t, pt_commission_rate = '{$row['pt_commission_rate']}'\n\t\t\t\t\t\t\t, pt_incentive_rate = '{$row['pt_incentive_rate']}'\n\t\t\t\t\t\t\t, pt_sale = '{$account['sale']}'\n\t\t\t\t\t\t\t, pt_commission = '{$account['commission']}'\n\t\t\t\t\t\t\t, pt_point = '{$account['point']}'\n\t\t\t\t\t\t\t, pt_incentive = '{$account['incentive']}'\n\t\t\t\t\t\t\t, pt_net = '{$account['net']}' "; } if ($mk_id && isset($it['pt_marketer']) && $it['pt_marketer'] > 0) { // 추천인 $mk_prate = $it['pt_marketer'] / 100; $mk_amount = $row['ct_price'] * $row['ct_qty']; //총금액 if ($row['ct_notax']) { $mk_net = $mk_amount; } else { list($mk_net) = apms_vat($mk_amount); } $mk_profit = floor($mk_net * $mk_prate); if ($mk_profit > 0) { $mk_benefit = floor($mk_profit * $mk_brate); $query .= " , mk_id = '{$mk_id}'\n\t\t\t\t\t\t\t\t, mk_profit = '{$mk_profit}'\n\t\t\t\t\t\t\t\t, mk_benefit = '{$mk_benefit}' "; } } } if ($query) { $sql = " update {$g5['g5_shop_cart_table']} \n\t\t\t\t\t\tset pt_it = '{$it['pt_it']}'\n\t\t\t\t\t\t\t{$query} \n\t\t\t\t\t\twhere od_id = '{$od_id}' and ct_id = '{$row['ct_id']}'\n\t\t\t\t\t"; sql_query($sql); } } // 판매량 일괄반영 if (is_array($arr_it_id) && !empty($arr_it_id)) { $unq_it_id = array_unique($arr_it_id); foreach ($unq_it_id as $it_id) { $row2 = sql_fetch(" select sum(ct_qty) as sum_qty from {$g5['g5_shop_cart_table']} where it_id = '{$it_id}' and ct_status = '완료' "); sql_query(" update {$g5['g5_shop_item_table']} set it_sum_qty = '{$row2['sum_qty']}' where it_id = '{$it_id}' "); } } // 주문서가 자동처리 상품으로 되어 있으면 주문서도 완료처리 $is_sendcost = true; if ($od_ok && is_array($arr_no_auto) && empty($arr_no_auto)) { $info = get_order_info($od_id); if ($info && $info['od_misu'] == 0) { sql_query(" update {$g5['g5_shop_order_table']} set od_status = '완료' where od_id = '{$od_id}' "); $is_sendcost = false; } } // 개별배송비처리 - 무료가 아니고 기본배송비가 있는 경우만 체크 if ($is_sendcost) { $where_sql = !empty($g5['apms_automation']) ? " and pt_it not in (" . implode(', ', $g5['apms_automation']) . ") " : ""; $sql = " select * from {$g5['g5_shop_cart_table']} where od_id = '{$od_id}' and ct_select = '1' {$where_sql} group by it_id order by ct_id "; $result = sql_query($sql); for ($i = 0; $row = sql_fetch_array($result); $i++) { // 합계금액 계산 $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price,\n\t\t\t\t\t\t\tSUM(ct_point * ct_qty) as point,\n\t\t\t\t\t\t\tSUM(ct_qty) as qty\n\t\t\t\t\t\tfrom {$g5['g5_shop_cart_table']}\n\t\t\t\t\t\twhere it_id = '{$row['it_id']}'\n\t\t\t\t\t\t and od_id = '{$od_id}' "; $sum = sql_fetch($sql); // 배송비 $sc_price = 0; switch ($row['ct_send_cost']) { case 1: $sc_type = '착불'; break; case 2: $sc_type = '무료'; break; default: $sc_type = '선불'; $sc_price = $row['it_sc_price']; break; } // 조건부무료 if ($sc_price && $row['it_sc_type'] == 2) { $sc_price = get_item_sendcost($row['it_id'], $sum['price'], $sum['qty'], $od_id); if ($sc_price == 0) { $sc_type = '무료'; } } // 개별배송비 등록 sql_query(" insert into {$g5['apms_sendcost']} set od_id = '{$od_id}', it_id = '{$row['it_id']}', pt_id = '{$row['pt_id']}', sc_price = '{$sc_price}', sc_type = '{$sc_type}', sc_datetime = '" . G5_TIME_YMDHIS . "' ", false); } } return; }
$page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지) $from_record = ($page - 1) * $rows; // 시작 열을 구함 $sql = " select *, SUBSTRING(a.pt_datetime,1,16) as date {$sql_common} order by a.pt_datetime desc, a.ct_id desc limit {$from_record}, {$rows} "; $result = sql_query($sql); for ($i = 0; $row = sql_fetch_array($result); $i++) { $list[$i] = $row; $list[$i]['num'] = $total_count - ($page - 1) * $rows - $i; $list[$i]['href'] = G5_SHOP_URL . '/item.php?it_id=' . $row['it_id']; $list[$i]['sale'] = $row['ct_price'] * $row['ct_qty']; if ($row['ct_notax']) { $net = $list[$i]['sale']; } else { list($net) = apms_vat($list[$i]['sale']); } $list[$i]['net'] = $net; $list[$i]['qty'] = $row['ct_qty']; $list[$i]['profit'] = $row['mk_profit']; $list[$i]['benefit'] = $row['mk_benefit']; $list[$i]['total'] = $row['mk_profit'] + $row['mk_benefit']; $list[$i]['rate'] = $list[$i]['net'] > 0 ? round($list[$i]['total'] / $list[$i]['net'] * 1000) / 10 : 0; $list[$i]['options'] = print_item_options($row['it_id'], $row['od_id'], $row['pt_msg1'], $row['pt_msg2'], $row['pt_msg3']); //구매회원 $list[$i]['buyer'] = '비회원'; if ($row['mb_id']) { $mb = get_member($row['mb_id'], 'mb_nick, mb_email, mb_homepage'); if ($mb['mb_nick']) { $list[$i]['buyer'] = apms_sideview($row['mb_id'], $mb['mb_nick'], $mb['mb_email'], $mb['wr_homepage']); }
$list[$z] = $save; $y = date('w', strtotime($list[$z]['date'] . ' 00:00:01')); $list[$z]['yoil'] = $yoil[$y]; if ($is_week) { $list[$z]['date'] = $list[$z]['date'] . '(' . $list[$z]['yoil'] . ')'; } $z++; unset($save); $save['date'] = $row['sale_date']; } // 매출 $sale = $row['ct_price'] * $row['ct_qty']; if ($row['ct_notax']) { $net = $sale; } else { list($net) = apms_vat($sale); } $save['count']++; $save['sale'] += $sale; $save['net'] += $net; $save['qty'] += $row['ct_qty']; $save['profit'] += $row['mk_profit']; $save['benefit'] += $row['mk_benefit']; $save['total'] += $row['mk_profit'] + $row['mk_benefit']; $tot['count']++; $tot['sale'] += $sale; $tot['net'] += $net; $tot['qty'] += $row['ct_qty']; $tot['profit'] += $row['mk_profit']; $tot['benefit'] += $row['mk_benefit']; $tot['total'] += $row['mk_profit'] + $row['mk_benefit'];
include_once './_common.php'; include_once G5_PATH . '/head.sub.php'; if ($act == 'ok') { // 자료가 많을 경우 대비 설정변경 set_time_limit(0); ini_set('memory_limit', '512M'); // 공급가 수정하기 $result = sql_query(" select * from {$g5['g5_shop_cart_table']} where ct_select = '1' "); for ($i = 0; $row = sql_fetch_array($result); $i++) { $netsale = $row['pt_sale'] - $row['pt_commission'] - $row['pt_point'] + $row['pt_incentive']; if ($row['ct_notax']) { $net = $netsale; $vat = 0; } else { list($net, $vat) = apms_vat($netsale); } sql_query(" update {$g5['g5_shop_cart_table']} set pt_net = '{$net}' where ct_id = '{$row['ct_id']}' "); } ?> <script type='text/javascript'> alert('파트너 자료 업데이트를 완료했습니다.'); self.close(); </script> <?php } else { ?> <form id="defaultform" name="defaultform" method="post" onsubmit="return update_submit(this);"> <input type="hidden" name="act" value="ok"> <div style="padding:10px">