주문취소 시 고객이 사용했던 포인트를 자동으로 반환하기
현재는 고객이 포인트를 사용해서 결제한 후 주문을 취소할 경우 관리자가 포인트 반환을 위해 일일이 수정을 해 줘여 합니다.
고객이 주문 당시 포인트 결제를 사용한 후 주문을 취소할 경우 자동으로 고객이 사용한 포인트가 고객에게 반환되도록 했습니다.
/adm/shop_admin/ordercartupdate.php 파일에서
$qstr = "sort1=$sort1&sort2=$sort2&sel_field=$sel_field&search=$search&page=$page";
요줄 바로 위에 아래내용을 추가하시면 됩니다.
// 포인트결재를 한 후 주문취소를 할 경우 포인트 반환 3월 18일 Harry
$sql1 = " select * from $g4[yc4_cart_table]
where on_uid = '$on_uid'
or (ct_status = '취소'
and on_uid= '$on_uid')";
$result = sql_query($sql1);
for ($i=0; $row=sql_fetch_array($result); $i++) {
$sql1 = " select * from $g4[yc4_cart_table]
where on_uid = '$on_uid'
or (ct_status = '취소'
and on_uid= '$on_uid')";
$result = sql_query($sql1);
for ($i=0; $row=sql_fetch_array($result); $i++) {
// 회원 ID 를 얻는다.
$tmp_row = sql_fetch("select od_id, mb_id, od_temp_point, od_receipt_point from $g4[yc4_order_table] where on_uid = '$row[on_uid]' ");
$tmp_row = sql_fetch("select od_id, mb_id, od_temp_point, od_receipt_point from $g4[yc4_order_table] where on_uid = '$row[on_uid]' ");
// 여러개의 제품을 주문했을 시 취소한 것이 전체인지 일부인지 확인하기 위해
$tmp_cnt1 = sql_fetch("select count(*) as cnt from $g4[yc4_cart_table] where on_uid = '$row[on_uid]' ");
$tmp_cnt2 = sql_fetch("select count(*) as cnt from $g4[yc4_cart_table] where ct_status = '취소' and on_uid = '$row[on_uid]' ");
$tmp_cnt1 = sql_fetch("select count(*) as cnt from $g4[yc4_cart_table] where on_uid = '$row[on_uid]' ");
$tmp_cnt2 = sql_fetch("select count(*) as cnt from $g4[yc4_cart_table] where ct_status = '취소' and on_uid = '$row[on_uid]' ");
// 주문취소 전 제품구입 시 포인트를 사용했다면 포인트 반환, 하지만 일부만 취소할 경우 반환하지 않음
if ($tmp_row[mb_id] && $tmp_row[od_receipt_point] > 0 && ($tmp_cnt1[cnt] == $tmp_cnt2[cnt])) {
$po_point = $tmp_row[od_receipt_point];
$po_content = "주문번호 $tmp_row[od_id] ($row[ct_id]) 주문취소로 포인트 반환";
insert_point($tmp_row[mb_id], $po_point, $po_content, "@return", $tmp_row[mb_id], "$tmp_row[od_id],$row[on_uid],$row[ct_id]");
if ($tmp_row[mb_id] && $tmp_row[od_receipt_point] > 0 && ($tmp_cnt1[cnt] == $tmp_cnt2[cnt])) {
$po_point = $tmp_row[od_receipt_point];
$po_content = "주문번호 $tmp_row[od_id] ($row[ct_id]) 주문취소로 포인트 반환";
insert_point($tmp_row[mb_id], $po_point, $po_content, "@return", $tmp_row[mb_id], "$tmp_row[od_id],$row[on_uid],$row[ct_id]");
sql_query("update $g4[yc4_order_table] set od_receipt_point = '0' where od_receipt_point = '$tmp_row[od_receipt_point]' ");
}
}
}
// 추가사항 끝
// 추가사항 끝
만약 여러제품을 주문했다가 일부만 취소하면 포인트를 반환을 하지않고 고객이 결제한 포인트를 계속 유효화 합니다. (당연히 고객은 그것을 원할테니까..)
이것때문에 위에 select count(*)를 사용해서 비교하는 루틴을 넣었습니다. ㅠㅠ
만약 주문한 모든 제품을 취소하면 그때 포인트가 고객에게 반환됩니다.
가능한 관리자의 수고를 줄이고 고객으로부터의 짠지를 줄이기 위해.......
이전글에 포인트관련 내용 있으니 참고하시기 바랍니다.
|
댓글을 작성하시려면 로그인이 필요합니다.
로그인
댓글 4개
포인트 반환액수, 환불금액 계산 등등 계산할 부분이 많습니다.
지금 거의 다 만들었다고 신나하다가 보니 하나 빼 먹었습니다. ㅠㅠ
만약 배송비가 없다가 일부 주문을 취소한 이유로 배송비가 적용되어져야할 경우, 또는 일부주문 취소로 인해 배송비가 바뀐경우, 환불금액 및 배송비가 자동으로 계산되어져야하는데 배송비 계산을 안넣었습니다.
오늘중으로 되겠지요.....
관리자 페이지보완... 4가지가 크게 남았는데... 작업이 꽤 복잡해지네요. -..-a
우편번호의 db화는 필요하시면 참조하세요.
http://sitereview.co.kr/bbs/board.php?bo_table=yc4_tips_hidden&wr_id=1