상품판매 수량 반영 코드 수정

This commit is contained in:
chicpro
2014-07-16 15:22:50 +09:00
parent 82296af20c
commit 8d6d1276b5
2 changed files with 30 additions and 0 deletions

View File

@ -19,6 +19,8 @@ if (in_array($_POST['ct_status'], $status_normal) || in_array($_POST['ct_status'
$mod_history = '';
$cnt = count($_POST['ct_id']);
$arr_it_id = array();
for ($i=0; $i<$cnt; $i++)
{
$k = $_POST['ct_chk'][$i];
@ -139,6 +141,23 @@ for ($i=0; $i<$cnt; $i++)
where od_id = '$od_id'
and ct_id = '$ct_id' ";
sql_query($sql);
// it_id를 배열에 저장
if($ct_status == '주문' || $ct_status == '취소' || $ct_status == '반품' || $ct_status == '품절' || $ct_status == '완료')
$arr_it_id[] = $ct['it_id'];
}
// 상품 판매수량 반영
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) {
$sql2 = " select sum(ct_qty) as sum_qty from {$g5['g5_shop_cart_table']} where it_id = '$it_id' and ct_status = '완료' ";
$row2 = sql_fetch($sql2);
$sql3 = " update {$g5['g5_shop_item_table']} set it_sum_qty = '{$row2['sum_qty']}' where it_id = '$it_id' ";
sql_query($sql3);
}
}
// 장바구니 상품 모두 취소일 경우 주문상태 변경

View File

@ -112,12 +112,23 @@ for ($i=0; $i<count($_POST['chk']); $i++)
change_status($od_id, '배송', '완료');
// 완료인 경우에만 상품구입 합계수량을 상품테이블에 저장한다.
$sql2 = " select it_id from {$g5['g5_shop_cart_table']} where od_id = '$od_id' and ct_status = '완료' group by it_id ";
$result2 = sql_query($sql2);
for ($k=0; $row2=sql_fetch_array($result2); $k++) {
$sql3 = " select sum(ct_qty) as sum_qty from {$g5['g5_shop_cart_table']} where it_id = '{$row2['it_id']}' and ct_status = '완료' ";
$row3 = sql_fetch($sql3);
$sql4 = " update {$g5['g5_shop_item_table']} set it_sum_qty = '{$row3['sum_qty']}' where it_id = '{$row2['it_id']}' ";
sql_query($sql4);
}
/*
$sql2 = " select it_id, sum(ct_qty) as sum_qty from {$g5['g5_shop_cart_table']} where od_id = '$od_id' and ct_status = '완료' group by it_id ";
$result2 = sql_query($sql2);
for ($k=0; $row2=sql_fetch_array($result2); $k++) {
$sql3 = " update {$g5['g5_shop_item_table']} set it_sum_qty = it_sum_qty + '{$row2['sum_qty']}' where it_id = '{$row2['it_id']}' ";
sql_query($sql3);
}
*/
break;
} // switch end