-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /var/www/html/zbk_product.bk.200925/php/order/
File Upload :
Current File : /var/www/html/zbk_product.bk.200925/php/order/step02_save.php

<?
# data checking
	include_once( 'inc/cart.php') ;
	include_once( 'inc/function.order.php') ;

	$cartQuery = '' ;
	switch ( $_POST['ordertype']) {
		case 'CM' : $cartQuery = " ct.Ltype = 'C' and real_no = '{$total[loginno]}' " ; 		break ;
		case 'CN' : $cartQuery = " ct.Ltype = 'C' and ct.cart_id = '{$cart_id}' " ; 				break ;
		case 'DM' :
		case 'DN' :
			if ( empty($_POST['ordercode'])) script_re ( '/' , ' À¯È¿ÇÏÁö ¾ÊÀº Á¢±ÙÀÔ´Ï´Ù. ')  ;
			$cartQuery = " ct.Ltype = 'D' and ct.cart_id = '{$_POST[ordercode]}' " . ( !empty($total['loginno']) ? " and real_no = '{$total[loginno]}' " : "" ) ;
			break ;
		default :
				script_re ( '/' , ' À߸øµÈ Á¢±ÙÀÔ´Ï´Ù. ') ;
	}

	if ( empty($_POST['o_name']) ||
	     empty($_POST['o_tel1']) || empty($_POST['o_tel2']) || empty($_POST['o_tel3']) ||
	     empty($_POST['o_hp1']) || empty($_POST['o_hp2']) || empty($_POST['o_hp3']) ||
	     empty($_POST['o_zip1']) || empty($_POST['o_zip2']) ||
	     empty($_POST['o_addr1']) || empty($_POST['o_addr2']) ||
	     empty($_POST['o_email'])) script_re ( '/' , ' ÁÖ¹®ÀÚ Á¤º¸ ¿À·ù ') ;

	if ( empty($_POST['r_name']) ||
	     empty($_POST['r_tel1']) || empty($_POST['r_tel2']) || empty($_POST['r_tel3']) ||
	     empty($_POST['r_hp1']) || empty($_POST['r_hp2']) || empty($_POST['r_hp3']) ||
	     empty($_POST['r_zip1']) || empty($_POST['r_zip2']) ||
	     empty($_POST['r_addr1']) || empty($_POST['r_addr2']) ||
	     empty($_POST['r_email'])) script_re ( '/' , ' ¹è¼ÛÁö Á¤º¸ ¿À·ù ') ;

	if ( empty($_POST['userSpay']) || ( $_POST['userSpay'] != 'B' && $_POST['userSpay'] != 'C' && $_POST['userSpay'] != 'E' ))
		script_re ( '/' , ' °áÁ¦ Á¤º¸ ¿À·ù ') ;

# get member info
	unset($mem) ;
	$skn_point = '' ;
	if ( !empty($total['loginno'])) {
		$mem = $exe->qry_fetch(" from tbl_{$config[A02][1]} where numid = '{$total[loginno]}' " , " numid , have_point ") ;
		if ( empty($mem['numid'])) script_re ( '/mypage/?mode=logout' , ' ȸ¿ø Á¤º¸¸¦ ãÀ» ¼ö ¾ø½À´Ï´Ù. ') ;

		$use_point = intval($_POST['usepoint']) ;
		if ( $use_point > $mem['have_point'] ) script_re ( '/' , ' »ç¿ëÇÑ Àû¸³±ÝÀÌ ¼ÒÀ¯ÇÑ Àû¸³±Ýº¸´Ù ¸¹½À´Ï´Ù. ') ;
		if ( $use_point < 0  ) script_re ( '/' , ' Àû¸³±Ý »ç¿ëÀÌ À߸øµÇ¾ú½À´Ï´Ù. ') ;
		if ( $use_point > 0 && $use_point < $shop_set['point_use_min']  ) script_re ( '/' , ' Àû¸³±ÝÀº ' . number_format($shop_set['point_use_min']) . 'ÀÌ»ó »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù. ') ;
	} else {  // ºñȸ¿ø
		$use_point = 0 ;
	}

# order goods
	$execute = $exe->qry_one( " from {$tblCart} as ct left outer join tbl_{$total[table]}_item as it on ct.goods_no = it.numid " .
		  " where {$cartQuery} order by ct.write_date asc " ,
		  " it.* , ct.numid as cart_no , ct.file1 as userAttachfile , ct.contents as userComment " .
		  " , ct.totalqry , ct.top_qry , ct.bot_qry , ct.armS , ct.armL , ct.tn_use , ct.tn_text , ct.tn_arch , ct.tn_pos  , ct.cr_opt  " .
		  " , ct.Atype_np , ct.Atype_tnm , ct.Atype_tpos , ct.Atype_memo , ct.Atype_nfont , ct.Atype_arch " .
		  " , ct.file2 as userAttachfile2 , ct.file3 as userAttachfile3 , ct.file4 as userAttachfile4 " .
		  " , ct.MAtype_giftno , ( select numid from tbl_{$config[GFT][1]} where numid = ct.MAtype_giftno ) as gift_noisit , ( select title from tbl_{$config[GFT][1]} where numid = ct.MAtype_giftno ) as gift_title " .
		  " , ct.MAtype_hopedate , ct.MAtype_eventdate , ct.MAtype_payintype , ct.MAtype_payindate " .
		  " , ct.Atype_orderbottype " .
		  " , ct.hoooption_hp , ct.hoooption_schooly , ct.hoooption_classname , ct.hoooption_schoolname , ct.hoooption_teachername , ct.hoooption_teacherhp "  .
		  " , ct.Atype_orderbotoption "  ) ;
	$inOrdergs = array() ;
	$inOKcode = array() ;
	$ordertitle = '' ;
	$goods_count = 0 ;
	$order_point = 0 ;
	$inPosActions = array();
	while ( $rs = $exe->fetch($execute)) {
		unset($tmp_Rs) ;
		if ( $rs['salestate'] != '1' ) continue ;
		if ( $rs['openstate'] != 'Y' ) continue ;
		if ( $rs['formtype'] == 'M' ) $tmp_Rs = M_Order() ;
		if ( $rs['formtype'] == 'T' ) $tmp_Rs = T_Order() ;
		if ( $rs['formtype'] == 'S' ) $tmp_Rs = S_Order() ;
		if ( $rs['formtype'] == 'Q' ) $tmp_Rs = Q_Order() ;
		if ( $rs['formtype'] == 'A' ) $tmp_Rs = A_Order() ;
		if ( $tmp_Rs[0] != 'Y' ) continue ;
		// state normal
		$ordertitle = empty($ordertitle) ? $rs['title'] : $ordertitle ;
		$goods_count++ ;
		$order_point += $rs['g_point'] == 'Y' ? $tmp_Rs[6] : 0 ;
		$inOrdergs[$rs['cart_no']] = array (
			// ±Ý¾× »êÃ⠽à ÇÊ¿äÇÑ Çʼö Á¤º¸
			'goods_no'				=> $rs['numid'] ,
			'old_cart_no'				=> $rs['cart_no'] ,
			'seq'						=> $goods_count ,
			'title'						=> $rs['title'] ,
			'formtype'				=> $rs['formtype'] ,
			'g_price'					=> $rs['g_price'] ,
			'g_point'					=> $rs['g_point'] ,
			'file1'						=> $rs['userAttachfile'] ,
			'file2'						=> $rs['userAttachfile2'] ,
			'file3'						=> $rs['userAttachfile3'] ,
			'file4'						=> $rs['userAttachfile4'] ,
			'contents'				=> $rs['userComment'] ,
			'top_qry'					=> $rs['top_qry'] ,
			'bot_qry'					=> $rs['bot_qry'] ,
			'armS'						=> $rs['armS'] ,
			'armL'						=> $rs['armL'] ,
			'totalqry'					=> $rs['totalqry'] ,
			// type M
			'topprice'				=> $rs['topprice'] ,
			'arm_l_price'			=> $rs['arm_l_price'] ,
			'arm_s_price'			=> $rs['arm_s_price'] ,
			'botprice'				=> $rs['botprice'] ,
			'teamtype'				=> $rs['teamtype'] ,
			'team_o_price'		=> $rs['team_o_price'] ,
			'team_f_price'		=> $rs['team_f_price'] ,
			'team_arch'			=> $rs['team_arch'] ,
			'nfont_p1'				=> $tmp_Rs[1] ,
			'nfont_p2'				=> $tmp_Rs[2] ,
			'nfont_p3'				=> $tmp_Rs[3] ,
			'nfont_gubun'		=> $tmp_Rs[4] ,
			'initial_kr_s'			=> $rs['initial_kr_s'] ,			// TYPE A - ÀÌ´Ï¼È ±Ý¾×
			'initial_kr_c'			=> $rs['initial_kr_c'] ,			// TYPE A - ¹øÈ£¼­Ã¼ ±Ý¾×
			'initial_en_s'			=> $rs['initial_en_s'] ,
			'initial_en_c'			=> $rs['initial_en_c'] ,
			'initial_arch'			=> $rs['initial_arch'] ,
			'stocking_price'		=> $rs['stocking_price'] ,
			// type T
			'tn_use'					=> $rs['tn_use'] ,
			'tn_text'					=> $rs['tn_text'] ,
			'tn_arch'					=> $rs['tn_arch'] ,
			'tn_pos'					=> $rs['tn_pos'] ,
			// type S & Q
			'cr_opt'					=> $rs['cr_opt'] ,
			// type A
			'Atype_np'			=> $rs['Atype_np'] ,
			'Atype_tnm'			=> $rs['Atype_tnm'] ,
			'Atype_tpos'		=> $rs['Atype_tpos'] ,
			'Atype_tpp1'		=> $shop_Atype_tpos1 ,
			'Atype_tpp2'		=> $shop_Atype_tpos2 ,
			'Atype_tpp3'		=> $shop_Atype_tpos3 ,
			'Atype_tpp4'		=> $shop_Atype_tpos4 ,
			'Atype_tpp5'		=> $shop_Atype_tpos5 ,
			'Atype_memo'	=> $rs['Atype_memo'] ,
			'Atype_nfonttype' => $rs['Atype_nfont'] ,
			'Atype_archtype' => $rs['Atype_arch'] ,
			'Atype_nfont1_c' => $rs['nfont1_c'] ,
			'Atype_nfont2_c' => $rs['nfont2_c'] ,
			'Atype_nfont3_c' => $rs['nfont3_c'] ,
			'Atype_initial_c' => $rs['initial_c'] ,
			'Atype_arch_c' => $rs['arch_c'] ,
			'Atype_nfont1_s' => $rs['nfont1_s'] ,
			'Atype_nfont2_s' => $rs['nfont2_s'] ,
			'Atype_nfont3_s' => $rs['nfont3_s'] ,
			'Atype_initial_s' => $rs['initial_s'] ,
			'Atype_arch_s'	=> $rs['arch_s'] ,
			'Atype_orderbottype'		=> $rs['Atype_orderbottype'] ,
			'Atype_orderbotprice'		=> $rs['Atype_botaddprice'] ,
			'Atype_orderbotoption'	=> $rs['Atype_orderbotoption'] ,			// (add) 19.03
			'Atype_nochartype'		=> $rs['Atype_charptype'] ,	// ¹øÈ£ input(ÀÔ·Â) or char(ÀÚ´ç)
			'Atype_inchartype'		=> $rs['Atype_charitype'] ,	// ÀÌ´Ï¼È input(ÀÔ·Â) or char(ÀÚ´ç)
			'Atype_chartype2'		=> $rs['Atype_charptype'] == 'INPUT' && $rs['Atype_charitype'] == 'INPUT' ? 'A' : 'NULL' ,	// (add) 19.06
			'Atype_charsprintprice_c'	=> $rs['charsprintprice_c'] ,
			'Atype_charsprintprice_s'	=> $rs['charsprintprice_s'] ,
			// M or A
			'MAtype_giftno'		=> $rs['MAtype_giftno'] ,
			'MAtype_gifttext'	=> $rs['gift_title'] ,
			'MAtype_hopedate'		=> $rs['MAtype_hopedate'] ,
			'MAtype_eventdate'		=> $rs['MAtype_eventdate'] ,
			'MAtype_payintype'		=> $rs['MAtype_payintype'] ,
			'MAtype_payindate'		=> $rs['MAtype_payindate'] ,
			// hoobul
			'hoooption_hp'				=> $rs['hoooption_hp']  ,
			'hoooption_schooly'			=> $rs['hoooption_schooly']  ,
			'hoooption_classname'		=> $rs['hoooption_classname']  ,
			'hoooption_schoolname'		=> $rs['hoooption_schoolname']  ,
			'hoooption_teachername'	=> $rs['hoooption_teachername']  ,
			'hoooption_teacherhp'		=> $rs['hoooption_teacherhp']
		) ;
		if ( $rs['formtype'] == 'M' ) {
			$inPosActions[$rs['cart_no']] = $tmp_Rs[5] ;
			for ( $i = 1 ; $i <= 14 ; $i++ ) {
				$pos = str_pad( $i , 2 , '0' , STR_PAD_LEFT ) ;
				if ( !is_array($inPosActions[$rs['cart_no']][$pos])) {
					$inPosActions[$rs['cart_no']][$pos] = array(
						'o_code'				=> $rs['p' . $pos] ,
						'p_code'				=> '' ,
						'p_idx'					=> $rs['p' . $pos . '_no'] ,
						'p_arch'				=> '' ,
						'p_tn'					=> '' ,
						'p_price1'			=> '' ,
						'p_price2'			=> '' ,
						'p_price3'			=> '' ,
						'p_gubun'			=> '' ,
						'p_title'				=> '' ,
					) ;
				}
			}
		}
		$inOKcode[] = $rs['cart_no'] ; // ÁÖ¹® °¡´ÉÇÑ ¹øÈ£. ½ºÅ¸Å·, »çÀÌÁî, ¿É¼Ç Àϰý º¹»ç½Ã 'ÁÖ¹®ºÒ°¡´ÉÇÑ »óǰ' °ú 'ÁÖ¹®°¡´ÉÇÑ »óǰ'À» ±¸º°ÇÕ´Ï´Ù.
	}
	// ÁÖ¹®Á¦¸ñ
	$ordertitle .= $goods_count < 2 ? '' : ' ¿Ü ' . ($goods_count-1) ;

	$goods_sumprice += $s_sumprice ;
	if ( $goods_sumprice <= 0 ) script_re ( '/' , ' ÁÖ¹®ÇÒ »óǰÀÌ ¾ø½À´Ï´Ù. ') ;
	$order_sendprice = $goods_sumprice < $shop_set['send_order_min'] && $goods_sumprice > 0 ? $shop_set['send_price']  : 0 ;
	//$goods_sumprice += $order_sendprice ;

# get order secret code
	while ( true ) {
		$orderScode = date('ymd') . str_rand(9 , '1' ) ;
		$tnum = $exe->qry_fetch(" from {$tblOrder} where orderScode = '{$orderScode}' " , " numid ") ;
		if ( empty($tnum['numid'])) break ;
	}

	// {yymmdd}{random number 8}
	if ( $use_point > ($goods_sumprice + $order_sendprice) ) script_re ( '/' , ' Àû¸³±ÝÀº °áÁ¦±Ý¾×º¸´Ù ¸¹ÀÌ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù. ') ;
	$action = array (
		'write_date'					=> $total['now'] ,
		'write_ip'							=> $total['ip'] ,
		'real_id'							=> $total['loginid'] ,
		'real_no'							=> $total['loginno'] ,
		'real_level'						=> $total['loginlevel'] ,
		'orderScode'					=> $orderScode ,
		'order_path'					=> $_POST['ordertype'] ,    // ÁÖ¹®°æ·Î( CM , CN , DM , DN )
		'ordercode'						=> $_POST['ordercode'] , 	// CM, DM , DN ÀÏ °æ¿ì µî·Ï¹øÈ£
		'ordertitle'						=> $ordertitle ,
		'order_qry'						=> $goods_count ,
		// ÁÖ¹®ÀÚÁ¤º¸
		'oname'							=> $_POST['o_name'] ,
		'ozip'								=> $_POST['o_zip1'] . '-' . $_POST['o_zip2'] ,
		'oaddr1'							=> $_POST['o_addr1'] ,
		'oaddr2'							=> $_POST['o_addr2'] ,
		'otel'								=> $_POST['o_tel1'] . '-' . $_POST['o_tel2'] . '-' . $_POST['o_tel3'] ,
		'ohp'								=> $_POST['o_hp1'] . '-' . $_POST['o_hp2'] . '-' . $_POST['o_hp3'] ,
		'oemail'							=> $_POST['o_email'] ,
		// ¹è¼ÛÁöÁ¤º¸
		'rname'							=> $_POST['r_name'] ,
		'rzip'								=> $_POST['r_zip1'] . '-' . $_POST['r_zip2'] ,
		'raddr1'							=> $_POST['r_addr1'] ,
		'raddr2'							=> $_POST['r_addr2'] ,
		'rtel'									=> $_POST['r_tel1'] . '-' . $_POST['r_tel2'] . '-' . $_POST['r_tel3'] ,
		'rhp'								=> $_POST['r_hp1'] . '-' . $_POST['r_hp2'] . '-' . $_POST['r_hp3'] ,
		'remail'							=> $_POST['r_email'] ,
		'rcontents'						=> str_convert($_POST['r_contents']) ,
		// ÁÖ¹®Á¤º¸
		'sum_price'						=> $goods_sumprice ,
		'send_price'					=> $order_sendprice ,
		'use_point'						=> ( $use_point > 0 ? 'Y' : 'N' ) ,
		'point_price'					=> $use_point ,

'result_price'     => ($goods_sumprice + $order_sendprice -  $use_point) , // vat Æ÷ÇÔ

//'result_price'     => ($goods_sumprice + $order_sendprice -  $use_point) + ( $_POST['userSpay'] == 'B' ? 0 : ceil(($goods_sumprice + $order_sendprice -  $use_point)*0.1) ) ,	//vat º°µµ
		'pay_type'						=> $_POST['userSpay'] ,
		'bank_info'						=> ( $_POST['userSpay'] == 'B' ? $_POST['userSpayB'] : 'NULL' ) ,
		'n_state'							=> 'ÀԱݴë±â'  ,
		'order_point'					=> $order_point * 0.01
	) ;
	if ( $action['result_price'] == 0 ) $action['n_state'] = 'ÀԱݿϷá' ;

	$numid = $exe->qry_insert( $action , $tblOrder ) ;
	foreach ( $inOKcode as $cno ) {
		$inOrdergs[$cno]['orderScode'] = $orderScode ;
		$gs_no = $exe->qry_insert( $inOrdergs[$cno] , $tblOrdergs ) ;
		if ( $inOrdergs[$cno]['formtype'] == 'M' ) {
			foreach ( $inPosActions[$cno] as $k => $v ) {
				$v['gs_no']	= $gs_no ;
				$v['pos']	= $k ;
				$exe->qry_insert( $v , $tblOrderpos ) ;
			}
			$exe->qry_query ( " insert into {$tblOrdersize} select '', '{$gs_no}', seq, tsize, bsize, armtype, initialnm, numb, npos1, npos2, npos3 from {$tblCartsize} where cart_no = '{$cno}' ") ;
			$exe->qry_query ( " insert into {$tblOrderStk} select '', '{$gs_no}', nm, qry from {$tblCartStk} where cart_no = '{$cno}' ") ;
		} elseif ( $inOrdergs[$cno]['formtype'] == 'A'  ) {
			$exe->qry_query ( " insert into {$tblOrdersize} select '', '{$gs_no}', seq, tsize, bsize, armtype, initialnm, numb, npos1, npos2, npos3 from {$tblCartsize} where cart_no = '{$cno}' ") ;
			$exe->qry_query ( " insert into {$tblOrderStk} select '', '{$gs_no}', nm, qry from {$tblCartStk} where cart_no = '{$cno}' ") ;
		} elseif ( $inOrdergs[$cno]['formtype'] == 'T' || $inOrdergs[$cno]['formtype'] == 'S' ) {
			$exe->qry_query ( " insert into {$tblOrderStk} select '', '{$gs_no}', nm, qry from {$tblCartStk} where cart_no = '{$cno}' ") ;
		}
	}

	// ¹«ÅëÀåÀÔ±ÝÀÏ ¶§ »ç¿ëÇÑ Àû¸³±ÝÀÌ ÀÖ´Ù¸é ¸ÕÀú Á¦Çϱâ ( ½Å¿ëÄ«µå/¿¡½ºÅ©·Î´Â PG»ç °áÁ¦°á°ú 󏮯äÀÌÁö¿¡¼­ )
	if ( $_POST['userSpay'] == 'B' || $action['result_price'] == 0 ) {
		// use point  - member
		if ( $action['use_point'] == 'Y' && $action['point_price'] > 0 ) {
			$exe->qry_insert ( array (
								'keycode'				=> 'A02' ,
								'write_date'			=> $total['now'] ,
								'ip'							=> $total['ip'] ,
								'real_no'					=> $action['real_no'] ,
								'real_id'					=> $action['real_id'] ,
								'order_no'				=> $numid ,
								'point'						=> '-' . $action['point_price'] ,
								'totalpoint'				=> ($mem['have_point'] - $action['point_price'] ) ,
								'contents'				=> 'ÁÖ¹®½Ã »ç¿ë'
								) , "tbl_{$config[A02][1]}_point" ) ;
			$exe->qry_update(" have_point = have_point - {$action[point_price]} " , "tbl_{$config[A02][1]}" , " numid={$action[real_no]} " ) ;
		}
		if ( $_POST['userSpay'] == 'B' ) {
			orderSendsms_bank($_POST['o_hp1'] . '-' . $_POST['o_hp2'] . '-' . $_POST['o_hp3'],$_POST['userSpayB']);
		}
		script_re( '?mode=orderrst&ordercode=' . $orderScode . '&ordertcode=' . md5($numid)) ;
	} else {
		if ( $paysystem == 'kcp' )
			script_re( '?mode=orderkcp&ordercode=' . $orderScode . '&ordertcode=' . md5($numid)) ;
		else
			script_re( '?mode=orderpay&ordercode=' . $orderScode . '&ordertcode=' . md5($numid)) ;
	}

?>

Copyright © 2017 || Recoded By Mr.Bumblebee