order_calc.php
| 1 | <?php |
| 2 | // 주문 금액 계산 (결제 페이지, 모바일 주문서 공용) |
| 3 | // 사용: php order_calc.php order.json |
| 4 | include "inc/config.php"; |
| 5 | include "inc/member.php"; |
| 6 | include "inc/util.php"; |
| 7 | |
| 8 | $order = json_decode(file_get_contents($argv[1]), true); |
| 9 | $NOW = isset($order['now']) ? strtotime($order['now']) : time(); |
| 10 | $GLOBALS['NOW'] = $NOW; |
| 11 | $mem = $order['member']; |
| 12 | |
| 13 | // 모바일 주문은 무료배송 기준을 낮춤 (2013 모바일 프로모션, 박과장 요청) |
| 14 | if ($order['channel'] == 'mobile') $CFG['free_ship'] = 30000; |
| 15 | |
| 16 | $goods_total = 0; // 정가 합계 |
| 17 | $sale_total = 0; // 할인 후 합계 |
| 18 | foreach ($order['items'] as $it) { |
| 19 | $line = $it['price'] * $it['qty']; |
| 20 | $goods_total += $line; |
| 21 | $rate = 0; |
| 22 | // 세일 상품은 등급 할인 제외 |
| 23 | if (!$it['is_sale']) { |
| 24 | $rate = get_grade_rate($mem['grade']); |
| 25 | // VIP 생일 달 추가 할인 |
| 26 | if ($mem['grade'] == 'VIP' && is_birth_month($mem['birth'])) $rate += 2; |
| 27 | } |
| 28 | // 같은 상품 10개 이상 대량 구매 5% 추가 할인 |
| 29 | if ($it['qty'] > 10) $rate += 5; |
| 30 | $line = $line - floor10($line * $rate / 100); |
| 31 | $sale_total += $line; |
| 32 | } |
| 33 | |
| 34 | // 2012 창립 이벤트 10% (이벤트 기간에만) |
| 35 | if ($CFG['EVENT_2012'] && date('Y', $NOW) == '2012') { |
| 36 | $sale_total = $sale_total - floor10($sale_total * 0.1); |
| 37 | } |
| 38 | |
| 39 | // 쿠폰 (정액) |
| 40 | $coupon = 0; |
| 41 | if (isset($order['coupon']) && $order['coupon'] > 0) { |
| 42 | if ($sale_total >= $CFG['coupon_min']) $coupon = $order['coupon']; |
| 43 | } |
| 44 | $pay = $sale_total - $coupon; |
| 45 | if ($pay < 0) $pay = 0; |
| 46 | |
| 47 | // 배송비: 무료배송 판단은 정가 합계 기준 |
| 48 | $ship = ($goods_total >= $CFG['free_ship']) ? 0 : $CFG['ship_fee']; |
| 49 | $ship += ship_extra($order['zip']); |
| 50 | |
| 51 | // 적립금 사용 |
| 52 | $use_point = 0; |
| 53 | if ($mem['point'] >= $CFG['point_min'] && $order['use_point'] > 0) { |
| 54 | $max = floor100($pay * $CFG['point_max_rate']); |
| 55 | $use_point = min($order['use_point'], $mem['point'], $max); |
| 56 | $use_point = floor100($use_point); |
| 57 | } |
| 58 | $pay = $pay - $use_point; |
| 59 | |
| 60 | $final = floor10($pay + $ship); |
| 61 | |
| 62 | // 적립 예정: 적립금 쓴 만큼 뺀 상품 결제액 기준, 배송비 제외 |
| 63 | $save = floor10(($pay) * point_save_rate($mem['grade']) / 100); |
| 64 | |
| 65 | echo json_encode(array( |
| 66 | 'goods_total' => $goods_total, |
| 67 | 'sale_total' => $sale_total, |
| 68 | 'coupon' => $coupon, |
| 69 | 'ship' => $ship, |
| 70 | 'use_point' => $use_point, |
| 71 | 'final' => $final, |
| 72 | 'save_point' => $save, |
| 73 | 'ship_date' => ship_date($NOW), |
| 74 | ), JSON_UNESCAPED_UNICODE) . "\n"; |
| 75 | ?> |
inc/config.php
| 1 | <?php |
| 2 | // 쇼핑몰 설정 (2009.03 김대리 작성, 2013.07 수정) |
| 3 | $CFG = array(); |
| 4 | $CFG['ship_fee'] = 2500; // 기본 배송비 |
| 5 | $CFG['free_ship'] = 50000; // 무료배송 기준 금액 |
| 6 | $CFG['jeju_fee'] = 3000; // 제주 추가 배송비 |
| 7 | $CFG['island_fee'] = 5000; // 도서산간 추가 배송비 |
| 8 | $CFG['coupon_min'] = 30000; // 쿠폰 사용 최소 주문금액 |
| 9 | $CFG['point_min'] = 3000; // 적립금 최소 보유액 |
| 10 | $CFG['point_max_rate']= 0.3; // 적립금 1회 최대 사용 비율 |
| 11 | $CFG['EVENT_2012'] = true; // 2012 창립 이벤트 |
| 12 | |
| 13 | // 도서산간 우편번호 앞자리 (택배사 목록 2011년 기준) |
| 14 | $ISLAND_ZIP = array('23100','23101','23102','40200','52570','59100','59101'); |
| 15 | ?> |
inc/member.php
| 1 | <?php |
| 2 | // 회원 등급 관련 |
| 3 | function get_grade_rate($grade) { |
| 4 | if ($grade == 'VIP') return 5; |
| 5 | else if ($grade == 'GOLD') return 3; |
| 6 | return 0; |
| 7 | } |
| 8 | |
| 9 | function is_birth_month($birth) { |
| 10 | // birth: YYYY-MM-DD |
| 11 | if (!$birth) return false; |
| 12 | return substr($birth, 5, 2) == date('m', $GLOBALS['NOW']); |
| 13 | } |
| 14 | |
| 15 | function point_save_rate($grade) { |
| 16 | if ($grade == 'VIP') return 2; |
| 17 | return 1; |
| 18 | } |
| 19 | ?> |
inc/util.php
| 1 | <?php |
| 2 | function floor10($n) { return floor($n / 10) * 10; } |
| 3 | function floor100($n) { return floor($n / 100) * 100; } |
| 4 | |
| 5 | function ship_extra($zip) { |
| 6 | global $CFG, $ISLAND_ZIP; |
| 7 | $z = intval($zip); |
| 8 | if ($z >= 63000 && $z <= 63644) return $CFG['jeju_fee']; |
| 9 | foreach ($ISLAND_ZIP as $p) { |
| 10 | if (substr($zip, 0, 5) == $p) return $CFG['island_fee']; |
| 11 | } |
| 12 | return 0; |
| 13 | } |
| 14 | |
| 15 | // 출고일: 토요일·일요일 주문은 월요일, 평일 15시 이후 주문은 다음날 |
| 16 | function ship_date($ts) { |
| 17 | $w = date('w', $ts); |
| 18 | if ($w == 6) return date('Y-m-d', $ts + 86400 * 2); |
| 19 | if ($w == 0) return date('Y-m-d', $ts + 86400); |
| 20 | if (date('H', $ts) >= 15) { |
| 21 | if ($w == 5) return date('Y-m-d', $ts + 86400 * 3); |
| 22 | return date('Y-m-d', $ts + 86400); |
| 23 | } |
| 24 | return date('Y-m-d', $ts); |
| 25 | } |
| 26 | ?> |
쇼핑몰 주문 금액 계산 — 업무 규칙 명세
대상: legacy/shop/ (order_calc.php, inc/config.php, inc/member.php, inc/util.php, sample-order.json)
목적: 이 문서만으로 동일 동작의 시스템을 재구현할 수 있도록 한다.
검증: 아래 모든 수치·예시는 원본 코드를 PHP 8로 직접 실행한 결과다. 원본은 수정하지 않았다.
1. 개요
CLI 스크립트(php order_calc.php order.json) 하나가 주문 JSON을 읽어 결제 금액을 계산해 JSON 한 줄로 출력한다.
주석상 결제 페이지와 모바일 주문서가 공용으로 쓴다. DB·세션 없이 입력 JSON과 설정값만으로 결정되는 순수 계산이다.
2. 입력 / 출력
입력 (order.json)
| 필드 | 의미 |
|---|---|
now |
(선택) 기준 시각 문자열. 없으면 서버 현재 시각. 테스트·재현용 |
channel |
"mobile" 이면 모바일, 그 외(web 등)는 일반 |
zip |
배송지 우편번호(5자리 문자열) |
member.grade |
VIP / GOLD / 그 외(일반) |
member.birth |
YYYY-MM-DD, 없거나 빈 값 가능 |
member.point |
보유 적립금 |
items[] |
price(단가), qty(수량), is_sale(세일 상품 여부), name(계산에 안 쓰임) |
coupon |
(선택) 정액 쿠폰 금액 |
use_point |
사용하려는 적립금 |
출력 (JSON 한 줄, 한글 이스케이프 안 함)
goods_total, sale_total, coupon, ship, use_point, final, save_point, ship_date
3. 설정 상수 (inc/config.php)
| 키 | 값 | 의미 |
|---|---|---|
| ship_fee | 2,500 | 기본 배송비 |
| free_ship | 50,000 | 무료배송 기준(웹). 모바일은 30,000으로 덮어씀 |
| jeju_fee | 3,000 | 제주 추가 배송비 |
| island_fee | 5,000 | 도서산간 추가 배송비 |
| coupon_min | 30,000 | 쿠폰 사용 최소 금액 |
| point_min | 3,000 | 적립금 사용 가능 최소 보유액 |
| point_max_rate | 0.3 | 1회 적립금 최대 사용 비율 |
| EVENT_2012 | true | 2012 창립 이벤트 활성 플래그 |
| ISLAND_ZIP | 23100, 23101, 23102, 40200, 52570, 59100, 59101 | 도서산간 우편번호(택배사 2011년 목록) |
4. 공통 함수
floor10(n)= floor(n/10)*10 (10원 단위 내림)floor100(n)= floor(n/100)*100 (100원 단위 내림)
5. 계산 순서와 규칙
5.1 기준 시각
now 가 있으면 그 시각, 없으면 현재 시각. 이후 생일 달 판정, 2012 이벤트 판정, 출고일 계산 모두 이 값을 쓴다.
시간대는 코드에 지정이 없고 PHP 기본 시간대에 따른다(재구현 시 시간대를 명시해야 함. §8 참조).
5.2 상품 라인별 계산 (items 순회)
line = price × qty;goods_total += line(정가 합계)- 할인율
rate(%) 결정: - 세일 상품(
is_sale)이 아니면: 등급 할인율 적용- VIP 5, GOLD 3, 그 외 0
- VIP이면서 생일 달이면 +2 (VIP 합계 7). 생일 달 =
birth의 월(문자 6~7번째)이 기준 시각의 월과 같음.birth가 비어 있으면 아님. 연도·일은 무관.
- 세일 상품이면 등급 할인·생일 할인 모두 없음(0).
- 수량
qty > 10(11개부터)이면 +5. 세일 상품에도 적용된다. 할인율은 가산(합산)이다. line = line − floor10(line × rate / 100)— 할인액을 10원 단위로 내림하므로 고객이 약간 더 낸다.sale_total += line
예) VIP·생일 달·일반 상품 qty 12 → rate = 5+2+5 = 12%.
예) 세일 상품 qty 11, 일반 회원 → rate 5% (대량만 적용): 11,000 → 10,450.
5.3 2012 창립 이벤트
EVENT_2012가 true이고 기준 시각의 연도가 2012이면 sale_total에서 10% 추가 할인: sale_total −= floor10(sale_total × 0.1).
기준 시각이 2012년이 아니면 적용되지 않는다. 즉 실서비스에서 오늘 날짜 기준으로는 사실상 죽은 규칙이며, now를 2012년으로 주는 경우에만 동작한다.
(예: 정가 100,000, 일반 → 90,000)
5.4 쿠폰 (정액)
coupon > 0이고 이벤트 반영 후sale_total ≥ 30,000이면 쿠폰 적용(coupon = 입력값), 아니면 0.pay = sale_total − coupon, 음수면 0.- 쿠폰 금액 상한 검사 없음:
sale_total보다 큰 쿠폰도 그대로coupon으로 출력되고pay만 0으로 보정된다.
(예: 30,000원에 쿠폰 40,000 → 출력 coupon=40000, pay=0) - 29,990원 주문에 쿠폰 5,000 → 미적용(coupon=0).
5.5 배송비
- 무료배송 판단 기준은 할인 전 정가 합계(
goods_total). 할인·쿠폰 후 금액이 아님. goods_total ≥ free_ship→ 0원, 아니면 2,500원free_ship: 웹 50,000 / 모바일(channel == "mobile") 30,000 (2013 모바일 프로모션, 박과장 요청이라는 주석이 있음. 종료일 정의 없음)- 추가 배송비(위 기본 배송비에 가산, 무료배송이어도 부과):
- 우편번호 정수값이 63000 ~ 63644 → 제주 3,000
- 아니면 우편번호 앞 5자리가 도서산간 목록과 일치 → 5,000
- 그 외 0
- 제주 판정이 먼저이며 둘 중 하나만 적용(중복 가산 없음)
- 예) 정가 60,000, 우편번호 63644 → ship 3,000 / 63645 → 0 / 23100 → 5,000
5.6 적립금 사용
조건: member.point ≥ 3,000 그리고 use_point > 0. 아니면 사용 0.
조건 충족 시:
1. max = floor100(pay × 0.3) — pay는 쿠폰 적용 후, 적립금 차감 전 금액(배송비 제외)
2. use_point = min(요청값, 보유 적립금, max)
3. use_point = floor100(use_point) (100원 단위 내림)
- 보유 2,990이면 사용 불가(→ 0). 3,000 이상이어야 함.
pay가 0이면 max=0이라 사용 0.pay −= use_point
5.7 최종 결제액
final = floor10(pay + ship) — 배송비는 쿠폰·적립금 대상이 아니며 마지막에 더한 뒤 10원 단위 내림.
5.8 적립 예정 포인트
save_point = floor10(pay × 적립률 / 100)
- pay는 적립금 사용 후, 배송비 제외 금액(쿠폰도 이미 차감된 값)
- 적립률: VIP 2%, 그 외(GOLD 포함) 1%
5.9 출고 예정일 (ship_date)
기준 시각 요일·시간으로 결정:
| 조건 | 출고일 |
|---|---|
| 토요일 | +2일 (월요일) |
| 일요일 | +1일 (월요일) |
| 평일(월~목) 15:00 이후 | +1일 |
| 금요일 15:00 이후 | +3일 (월요일) |
| 그 외(평일 15시 전) | 당일 |
- 15시 판정은 시(hour) ≥ 15, 즉 15:00:00 정확히부터 다음 영업일. 14:59는 당일.
- 토·일은 시각 무관. 공휴일 처리 없음. 월요일이 공휴일이어도 월요일로 계산.
- 날짜 계산이
+86400초방식이라 서머타임 시간대에서는 오차 가능(한국 시간대는 해당 없음).
6. 출력 필드 정의 요약
| 필드 | 값 |
|---|---|
| goods_total | Σ(price×qty), 할인 전 |
| sale_total | 상품별 할인 + (2012 이벤트) 반영 합계, 쿠폰 전 |
| coupon | 적용된 쿠폰(검증 통과 시 입력값 그대로, 아니면 0) |
| ship | 기본(0/2,500) + 지역 추가 |
| use_point | 실제 사용 적립금 |
| final | floor10(쿠폰·적립금 차감 후 금액 + ship) |
| save_point | 적립 예정 포인트 |
| ship_date | 출고 예정일 YYYY-MM-DD |
7. 검증된 예시
7.1 sample-order.json (실행 결과)
입력: 2026-10-31(토) 16:20, web, 우편 63100(제주), VIP 생일 10월, 보유 12,000, 사용 요청 10,000, 쿠폰 3,000
- 쿠키 24,000: VIP 5 + 생일 2 = 7% → 24,000 − 1,680 = 22,320
- 커피 18,000(세일, qty 12): 등급 없음, 대량 5% → 18,000 − 900 = 17,100
- goods_total 42,000 / sale_total 39,420
- 쿠폰 3,000 → pay 36,420
- 배송: 42,000 < 50,000 → 2,500 + 제주 3,000 = 5,500
- 적립금: max = floor100(10,926) = 10,900 → min(10,000, 12,000, 10,900) = 10,000 → pay 26,420
- final = floor10(26,420 + 5,500) = 31,920
- save = floor10(26,420 × 2 / 100 = 528.4) = 520
- ship_date: 토요일 → 2026-11-02
{"goods_total":42000,"sale_total":39420,"coupon":3000,"ship":5500,"use_point":10000,"final":31920,"save_point":520,"ship_date":"2026-11-02"}
7.2 추가 경계 케이스 (실행으로 확인)
| 케이스 | 결과 |
|---|---|
| 일반 상품 qty 10 / 세일 상품 qty 11 (단가 1,000) | 10,000(할인 없음) / 10,450(5%) |
| 일반회원 정가 30,000 웹 vs 모바일 | 웹 ship 2,500 / 모바일 ship 0 |
| 2012-03-05, 정가 100,000 | sale_total 90,000 |
| 쿠폰 5,000, 금액 29,990 | coupon 0 |
| 금액 30,000, 쿠폰 40,000, 적립금 5,000 요청 | coupon 40,000 출력, pay 0, use_point 0, final 2,500(배송비만) |
| 보유 적립금 2,990, 사용 2,990 요청 | use_point 0 |
| VIP·10월 생일, 세일 1,000×11 + 일반 1,000×1 | 10,450 + 930 = 11,380 |
| 출고일: 금 14:59 / 금 15:00 / 토 09:00 / 일 20:00 / 월 15:00 (2026-10-30~11-02) | 10-30 / 11-02 / 11-02 / 11-02 / 11-03 |
8. 코드 주석과 실제 동작이 다른 곳 및 재구현 시 결정 사항
원본의 의도가 불명확한 부분이다. 동일 결과를 내려면 현재 동작을 따르고, 바꾸려면 기획 확인이 필요하다.
- 대량 구매 기준: 주석은 "10개 이상"인데 코드는
qty > 10(11개 이상). 현재 동작은 11개부터. - 대량 할인이 세일 상품에도 적용: "세일 상품은 등급 할인 제외" 주석과 달리 대량 할인은 세일 상품에도 붙는다. 의도인지 누락인지 불명.
- 2012 이벤트는 기준 연도가 2012일 때만 동작하므로 현재는 사실상 비활성. 새 시스템에서는 제거 후보. 단, 과거 주문 재계산이 필요하면 유지.
- 모바일 무료배송 30,000은 2013 프로모션용이고 종료 조건이 없어 계속 적용 중. 유지 여부 확인 필요.
- 도서산간 우편번호 목록은 2011년 택배사 기준이며 낡았을 수 있음. 우편번호 체계(2015년 5자리 개편 등) 변화 반영 여부 확인 필요. 제주 범위 63000~63644도 동일.
- 쿠폰이 주문 금액을 초과해도 출력
coupon은 입력값 그대로이고 실제 차감은 sale_total까지만. 정산·표시용으로 쓰면 실제 차감액과 불일치. 새 구현에서는 min(coupon, sale_total)로 보정할지 결정 필요. - 쿠폰 최소금액은 이벤트 할인 후
sale_total기준(정가 아님), 무료배송은 정가 기준. 기준이 서로 다르다. - 적립금 최대 사용 한도는 쿠폰 차감 후 상품 금액의 30%(배송비 제외), 적립 예정은 적립금 차감 후 금액 기준.
- 음수·비정상 입력 검증 없음: qty·price 음수,
coupon문자열,use_point누락(PHP notice),zip누락,member누락 등에 대한 방어가 없다. 입력 검증은 새로 정의해야 한다. - 시간대: 코드에
date_default_timezone_set없음. 생일 달·출고일·2012 판정 모두 서버 시간대에 의존. 한국 서비스라면Asia/Seoul을 명시할 것. - 금액 타입: PHP
floor()는 float을 반환. 재구현 시 정수 연산(원 단위)으로 하되,pay × 0.3,× rate / 100같은 곱셈의 반올림 오차(부동소수) 영향이 없는지 확인(원본은 float 계산 후 내림이라 경계값에서 1원 단위 차이가 날 수 있음). - 등급:
VIP,GOLD외 모든 값(오타·소문자 포함)은 일반 취급. 대소문자 구분. - 공휴일·재고·상품별 배송비·부가세 등은 이 코드에 없다.
9. 재구현용 의사코드
free_ship = (channel == "mobile") ? 30000 : 50000
goods_total = 0; sale_total = 0
for item in items:
line = price * qty
goods_total += line
rate = 0
if not item.is_sale:
rate = {VIP:5, GOLD:3}.get(grade, 0)
if grade == "VIP" and birth_month(birth) == month(now): rate += 2
if qty > 10: rate += 5
sale_total += line - floor10(line * rate / 100)
if year(now) == 2012: # EVENT_2012 = true
sale_total -= floor10(sale_total * 0.1)
coupon = (coupon_in > 0 and sale_total >= 30000) ? coupon_in : 0
pay = max(sale_total - coupon, 0)
ship = (goods_total >= free_ship) ? 0 : 2500
if 63000 <= int(zip) <= 63644: ship += 3000
elif zip[:5] in ISLAND_ZIP: ship += 5000
use_point = 0
if member.point >= 3000 and use_point_in > 0:
cap = floor100(pay * 0.3)
use_point = floor100(min(use_point_in, member.point, cap))
pay -= use_point
final = floor10(pay + ship)
save_point = floor10(pay * (2 if grade == "VIP" else 1) / 100)
ship_date = per §5.9
쇼핑몰 주문 금액 계산 — 업무 규칙 명세 (legacy/shop 역분석)
대상: legacy/shop/order_calc.php, inc/config.php, inc/member.php, inc/util.php, sample-order.json
방법: 소스 전체 정독 + PHP 8.5로 실제 실행하여 모든 규칙·경계값 검증 (원본은 수정하지 않음).
목적: 이 문서만 보고 동일하게 동작하는 계산 모듈을 새로 만들 수 있게 한다.
표기: [코드] = 코드가 실제로 하는 일, [주석] = 주석에 적힌 의도, ⚠ = 코드와 주석(또는 상식)이 어긋나거나 확인이 필요한 지점.
새로 만들 때 "기존과 100% 동일 결과"가 목표인지, "의도대로 고치기"가 목표인지 먼저 결정해야 하는 항목은 12장에 모았다.
1. 입출력
1.1 입력 (JSON)
| 필드 | 타입 | 필수 | 설명 |
|---|---|---|---|
now |
문자열 YYYY-MM-DD HH:MM:SS |
선택 | 주문 시각. 없으면 서버 현재 시각. 테스트용으로 시각 주입 가능 |
channel |
"web" / "mobile" |
필수 | "mobile"이면 무료배송 기준 변경 (3.1) |
zip |
문자열 | 필수 | 배송지 우편번호(5자리 문자열 기준) |
member.grade |
"VIP" / "GOLD" / 그 외 |
필수 | 회원 등급 |
member.birth |
YYYY-MM-DD 또는 빈 값 |
필수 | 생일 (빈 값이면 생일 아님) |
member.point |
정수 | 필수 | 보유 적립금(원) |
items[] |
배열 | 필수 | 주문 상품들 |
items[].price |
정수 | 필수 | 단가(원) |
items[].qty |
정수 | 필수 | 수량 |
items[].is_sale |
boolean | 필수 | 세일 상품 여부 |
items[].name |
문자열 | 무관 | 계산에 쓰이지 않음 |
coupon |
정수(원) | 선택 | 정액 쿠폰 금액. 없으면 0 취급 |
use_point |
정수(원) | 사실상 필수 | 사용하려는 적립금. (코드는 키 존재를 확인하지 않음 → 누락 시 PHP 경고, 값은 0 취급) |
1.2 출력 (JSON 한 줄, 한글 이스케이프 없음)
| 필드 | 의미 |
|---|---|
goods_total |
정가 합계 (Σ price×qty) |
sale_total |
할인 적용 후 상품 합계 (이벤트 할인까지 반영, 쿠폰 전) |
coupon |
실제 적용된 쿠폰 금액 (미적용이면 0) |
ship |
배송비 (기본 + 지역 추가) |
use_point |
실제 사용된 적립금 |
final |
최종 결제 금액 |
save_point |
적립 예정 포인트 |
ship_date |
출고 예정일 YYYY-MM-DD |
2. 설정값 (config.php)
| 키 | 값 | 의미 |
|---|---|---|
ship_fee |
2,500 | 기본 배송비 |
free_ship |
50,000 | 무료배송 기준(정가 합계) |
jeju_fee |
3,000 | 제주 추가 배송비 |
island_fee |
5,000 | 도서산간 추가 배송비 |
coupon_min |
30,000 | 쿠폰 사용 최소 금액 |
point_min |
3,000 | 적립금 사용 가능 최소 보유액 |
point_max_rate |
0.3 | 1회 최대 사용 비율(30%) |
EVENT_2012 |
true | 2012 창립 이벤트 활성 플래그 |
ISLAND_ZIP |
23100, 23101, 23102, 40200, 52570, 59100, 59101 |
도서산간 우편번호 (택배사 목록 2011년 기준) |
새 구현에서는 위 값을 하드코딩하지 말고 설정으로 분리할 것.
2.1 공통 유틸
floor10(n)=floor(n/10)*10(10원 단위 내림)floor100(n)=floor(n/100)*100(100원 단위 내림)- 모든 금액은 원 단위 정수. 반올림은 어디에도 없고 전부 내림이다.
3. 계산 순서 (전체 흐름)
1) 채널 보정 (mobile → 무료배송 기준 30,000)
2) 상품별 줄 계산: 정가합계 누적, 줄 할인율 결정 → 줄 금액 = 줄정가 - floor10(줄정가×율/100)
3) sale_total = 줄 금액 합
4) 2012 이벤트: (활성 && 주문연도==2012) → sale_total -= floor10(sale_total×0.1)
5) 쿠폰: sale_total ≥ 30,000 이면 쿠폰 적용, pay = max(0, sale_total - coupon)
6) 배송비: goods_total(정가) ≥ 무료배송기준 ? 0 : 2,500, 그 뒤 지역 추가비 가산
7) 적립금 사용: 조건 충족 시 min(요청, 보유, floor100(pay×0.3)) 을 100원 단위 내림
8) pay -= use_point
9) final = floor10(pay + ship)
10) save_point = floor10(pay × 등급적립률 / 100) ← 7·8 이후의 pay, 배송비 제외
11) ship_date 계산
순서가 결과를 바꾼다(예: 이벤트 → 쿠폰 최소금액 판정, 쿠폰 → 적립금 한도). 순서를 바꾸지 말 것.
4. 상품 줄(line) 할인 규칙
각 상품마다:
line = price × qty
goods_total += line
rate = 0 # 단위: %
if (is_sale == false):
rate = 등급할인율(grade) # VIP 5, GOLD 3, 그 외 0
if grade == "VIP" and 생일달(birth): rate += 2
if qty > 10: rate += 5 # 세일 여부와 무관하게 적용
line_after = line - floor10(line × rate / 100)
sale_total += line_after
| 규칙 | 내용 |
|---|---|
| 등급 할인 | VIP 5%, GOLD 3%, 그 외 0%. 세일 상품(is_sale=true)은 등급 할인 제외 |
| VIP 생일달 추가 | VIP이고 생일의 월이 주문 시각(now)의 월과 같으면 +2%p. 세일 상품은 제외(등급 할인 블록 안에 있음). 일(日)은 보지 않음. 생일 값이 비어 있으면 해당 없음 |
| 대량 구매 | 수량이 10 초과(11개 이상) 이면 +5%p. 세일 상품에도 적용, 등급과 무관 |
| 합산 | 위 비율은 더한 뒤 한 번에 적용 (복리 아님). 최대 VIP 5+2+5 = 12% |
| 반올림 | 할인액을 줄 단위로 floor10 (할인액이 10원 단위로 내림 → 고객에게는 불리) |
| 수량 기준 | 같은 상품 한 줄(line)의 qty 기준. 상품이 여러 줄로 쪼개져 들어오면 합산하지 않음 |
⚠ 주석은 "10개 이상"이라고 쓰여 있으나 코드는 > 10(11개부터). 검증: qty=10 → 대량할인 없음, qty=11 → 5% 적용. 현재 동작은 "11개 이상"이다.
생일 판정: substr(birth, 5, 2) == date('m', now) — YYYY-MM-DD 형식 전제, 문자열의 6~7번째 글자(월 두 자리, 0-index 5부터 2글자)를 주문 월과 문자열로 비교. 시각은 서버 현재 시각이 아닌 주문 now 를 사용한다.
5. 2012 창립 이벤트
if EVENT_2012 플래그 == true and 주문연도(now) == 2012:
sale_total -= floor10(sale_total × 0.1)
- 상품 줄 할인 이후 합계 전체에 추가 10% (할인액 floor10).
- 연도 조건 때문에 현재 시각(2026년 등)에서는 절대 발동하지 않는 죽은 규칙. 단
now에 2012년을 넣으면 발동한다(검증: GOLD, 10,000×3 → 등급 3% 적용 29,100 → 이벤트 10% 차감 2,910 → sale_total 26,190). - 새 구현에서는 폐기 후보 (12장 참조).
6. 쿠폰
coupon = 0
if coupon 필드 존재 and coupon > 0 and sale_total ≥ 30,000:
coupon = 입력값 그대로
pay = max(0, sale_total - coupon)
- 정액 쿠폰만 지원(정률 없음). 1장만.
- 최소 금액 판정은 할인·이벤트가 모두 끝난
sale_total기준(정가 아님). 30,000 이상이면 가능(29,999 불가, 검증됨). - 쿠폰 금액을 상한으로 자르지 않는다: sale_total 60,000, 쿠폰 100,000 → 출력
coupon은 100,000 그대로,pay만 0으로 바닥 처리. (출력 coupon이 실제 차감액보다 클 수 있음 ⚠) - 쿠폰은 상품금액에만 적용, 배송비는 쿠폰으로 못 깎음.
7. 배송비
ship = (goods_total ≥ 무료배송기준) ? 0 : 2,500
ship += 지역추가비(zip)
7.1 무료배송 기준
- 정가 합계(goods_total) 로 판단. 할인·쿠폰 후 금액이 아니다. (예: 정가 60,000 → 할인 후 49,000이어도 무료)
- 기본 50,000 이상이면 무료 (49,999는 유료, 검증됨).
channel == "mobile"이면 기준이 30,000으로 낮아짐 (2013 모바일 프로모션, 박과장 요청이라는 주석). 프로모션 종료 기한 없이 영구 코드로 남아 있음 ⚠. 채널 문자열은 정확히"mobile"만 해당(그 외 전부 웹 취급).
7.2 지역 추가 배송비 (무료배송이어도 별도로 항상 가산)
판정 순서(먼저 걸리는 것 하나만):
1. intval(zip)이 63000 ~ 63644 (양끝 포함) → 제주 +3,000
2. zip 앞 5글자가 ISLAND_ZIP 목록 중 하나와 일치 → 도서산간 +5,000
3. 그 외 → 0
- 검증: 63644 → 제주(+3,000), 63645 → 일반, 52570 → 도서산간(+5,000), 정가 60,000이고 zip 23100 → ship=5,000 (무료배송 + 도서추가).
- 도서산간 목록의 항목이 모두 5자리이므로 사실상 우편번호 5자리 완전 일치이다(주석은 "앞자리"라 되어 있음). 목록은 2011년 기준으로 낡았음 ⚠.
- 제주+도서산간 중복 가산은 없다(제주 우선, 단일).
- 제주/도서 추가비는 쿠폰·포인트 대상이 아니며
final에 그대로 더해진다.
8. 적립금 사용
use_point = 0
if member.point ≥ 3,000 and use_point_요청 > 0:
max = floor100(pay × 0.3) # pay = 쿠폰 차감 후 상품금액 (배송비 제외)
use_point = min(요청, 보유, max)
use_point = floor100(use_point)
pay = pay - use_point
- 보유 적립금이 3,000 이상이어야 사용 가능 (2,999 → 사용 0, 검증됨). 3,000 이상이면 요청 금액만큼 쓰되 보유액 초과 불가.
- 1회 한도 = 쿠폰 차감 후 상품 결제액의 30% 를 100원 단위 내림. 배송비는 한도 계산·포인트 결제 대상 모두에서 제외(포인트로 배송비를 낼 수 없음).
- 최종 사용액은 100원 단위 내림 (요청 9,950 → 9,900 이하).
- 예: pay=10,000, 보유 9,000, 요청 9,000 → 한도 3,000 → 사용 3,000.
9. 최종 결제 금액
final = floor10(pay + ship) # pay: 포인트 차감 후
- 배송비를 더한 합계를 10원 단위 내림. (ship은 현재 항상 500의 배수라 영향 없으나 pay가 10원 단위가 아닐 때 영향.)
- 쿠폰/포인트가 상품금액을 초과해도
pay는 0 이하로 내려가지 않고, 배송비는 항상final에 남는다 (예: 쿠폰 100,000 → final = 배송비 5,000만 결제).
10. 적립 예정 포인트
save_point = floor10(pay × rate / 100)
rate = 2 (VIP), 그 외(GOLD 포함) 1
- 기준액
pay= 쿠폰·사용한 적립금을 모두 뺀 상품 결제액. 배송비 제외. (주석: "적립금 쓴 만큼 뺀 상품 결제액 기준, 배송비 제외") - 등급 구분은 VIP만 2%, GOLD도 1%.
- 적립 시점/유효기간 등은 이 코드에 없음.
11. 출고 예정일 (ship_date)
주문 시각 now 기준 (서버 타임존 사용 — PHP date() 기본 타임존):
| 주문 요일/시각 | 출고일 |
|---|---|
| 토요일(어느 시각이든) | +2일 (월요일) |
| 일요일(어느 시각이든) | +1일 (월요일) |
| 금요일 15시 이후 | +3일 (월요일) |
| 월~목 15시 이후 | +1일 |
| 평일 15시 이전(00:00~14:59) | 당일 |
- 15시 판정: 시(hour) ≥ 15 (15:00:00부터 다음 영업일). 검증: 2026-03-06(금) 15:00 → 03-09(월), 2026-03-05(목) 15:00 → 03-06.
- 공휴일/휴무일은 고려하지 않는다(주말만). 금요일 15시 전 주문은 당일 출고.
- 날짜 계산을
+86400초로 하므로 DST 있는 타임존에서는 하루 오차가 날 수 있음(한국 타임존은 DST 없어 무해). 새 구현은 날짜 연산으로 대체 권장. - 시각만 쓰고
ship_date는 날짜 문자열만 반환.
12. 숨은 규칙·불일치·판단 필요 항목 (인수인계 핵심)
| # | 항목 | 현재 동작 | 비고 |
|---|---|---|---|
| 1 | 대량 구매 경계 | 11개부터 (>10) |
주석은 "10개 이상". 어느 쪽이 의도인지 기획 확인 필요 |
| 2 | 대량 구매는 세일 상품에도 적용 | 적용됨 | 세일 제외 규칙과 비일관. 의도 확인 필요 |
| 3 | 무료배송 판단이 정가 기준 | 정가 합계 | 할인으로 5만원 미만이 돼도 무료. 의도적 정책인지 확인 |
| 4 | 모바일 무료배송 30,000 | 영구 적용 | 2013 프로모션. 종료 여부 확인 |
| 5 | 2012 이벤트 | now가 2012년일 때만 |
현실적으로 죽은 코드. 폐기 가능 여부 확인 |
| 6 | 쿠폰 > 상품금액 | 출력 coupon이 초과액 그대로 |
실제 차감액으로 자를지 결정 |
| 7 | 도서산간 목록 2011년 기준 | 7개 우편번호 하드코딩 | 최신 택배사 목록으로 교체 필요. 5자리 완전일치임에 유의 |
| 8 | 제주 범위 63000–63644 | 하드코딩 | 현행 제주 우편번호 체계 확인 |
| 9 | 입력 검증 없음 | 필드 누락 시 PHP Notice, 음수·문자열도 그대로 계산 | 새 구현에서는 검증 필요. use_point, zip, channel 누락 시 경고 후 0/빈값 취급 |
| 10 | 가격 정수 가정 | 실수 연산 후 floor |
새 구현은 정수 연산(또는 Decimal)으로 하되 결과 동일해야 함. 할인액만 내림, 내림 단위는 줄 10원 → 합계 10원 → 포인트 100원 |
| 11 | 타임존 | 서버 설정 의존 | 한국 시간(Asia/Seoul)을 명시할 것 |
| 12 | 공휴일 미반영 | 주말만 | 필요하면 휴일 캘린더 추가 |
| 13 | GOLD 생일 혜택 없음 | VIP만 | 코드대로 |
| 14 | 알 수 없는 등급 | 할인 0%, 적립 1% | BASIC 등 기본값 취급 |
| 15 | 쿠폰 최소금액은 쿠폰 입력 시에만 검사 | 미달 시 조용히 무시 (오류 없음) | UI에서 안내 필요 여부 확인 |
13. 검증 데이터 (실제 실행 결과 — 새 구현의 회귀 테스트로 사용)
모든 경우 channel=web, 별도 언급 없으면 zip=10000, 등급 BASIC, 생일 없음, now=2026-03-04 10:00:00(수).
13.1 샘플 주문 (sample-order.json)
입력: now 2026-10-31 16:20(토), web, zip 63100, VIP, 생일 1985-10-02, 보유 12,000,
상품 ① 12,000×2 일반 ② 1,500×12 세일, 쿠폰 3,000, 사용 10,000
① 24,000 → VIP 5% + 생일(10월) 2% = 7% → 할인 1,680 → 22,320
② 18,000 → 세일이라 등급/생일 제외, qty 12>10 → 5% → 할인 900 → 17,100
sale_total = 39,420 (goods_total = 42,000)
쿠폰: 39,420 ≥ 30,000 → 3,000 → pay 36,420
배송: 42,000 < 50,000 → 2,500 + 제주(63100) 3,000 = 5,500
포인트: 한도 floor100(36,420×0.3=10,926)=10,900, min(10,000, 12,000, 10,900)=10,000 → pay 26,420
final = floor10(26,420 + 5,500) = 31,920
save = floor10(26,420 × 2/100 = 528.4) = 520
ship_date: 2026-10-31은 토요일 → 2026-11-02
기대 출력:
{"goods_total":42000,"sale_total":39420,"coupon":3000,"ship":5500,"use_point":10000,"final":31920,"save_point":520,"ship_date":"2026-11-02"}
13.2 경계값 케이스
| 케이스 | 입력 요약 | 기대 출력 |
|---|---|---|
| 2012 이벤트 | now 2012-05-10 10:00, GOLD, 10,000×3 | goods 30,000 / sale 26,190 / ship 2,500 / final 28,690 / save 260 / 출고 2012-05-10 |
| 모바일 무료배송 | channel mobile, 30,000×1 | ship 0 / final 30,000 / save 300 |
| 웹 49,999 | 49,999×1 | ship 2,500 / final 52,490 / save 490 |
| 무료배송+도서+초과쿠폰 | zip 23100, 60,000×1, coupon 100,000 | ship 5,000 / coupon 100,000 / final 5,000 / save 0 |
| 금요일 15:00, qty 11, zip 63645 | now 2026-03-06 15:00, 10,000×11 | sale 104,500 / ship 0 / save 1,040 / 출고 2026-03-09 |
| 보유 2,999, qty 10, VIP 생일 3월 | zip 63000, 10,000×10, use_point 5,000 | sale 93,000(7%) / use_point 0 / ship 3,000 / final 96,000 / save 1,860 |
| 일요일, 포인트 한도 | now 2026-03-08 23:00, 10,000×1, 보유 9,000, 사용 9,000 | use_point 3,000 / ship 2,500 / final 9,500 / save 70 / 출고 2026-03-09 |
| 쿠폰 최소 미달 | 29,999×1, coupon 1,000 | coupon 0 / final 32,490 |
| 세일+qty 11+VIP 생일 | 1,000×11 세일 | sale 10,450 (대량 5%만, 등급·생일 제외) |
| 목요일 15:00 | now 2026-03-05 15:00, 1,000×1 | 출고 2026-03-06 |
| 제주 끝 | zip 63644 | ship 5,500 |
| 도서산간 | zip 52570 | ship 7,500 |
14. 재구현 시 권장 구조 (참고)
- 설정(2장)을 외부 설정으로 분리, 계산 함수는
now·설정을 인자로 받는 순수 함수로 작성. - 3장의 단계 순서를 그대로 유지하고 단계별 중간값(
sale_total,pay등)을 단위 테스트로 고정. - 13장의 케이스를 회귀 테스트로 먼저 넣어 기존과 동일 결과임을 확인한 뒤, 12장의 항목을 기획 결정에 따라 하나씩 의도적으로 변경.
플러그인이 만든 영어 문서 그대로입니다. 한 장짜리 보고서: REPORT.html 열기
Business Rules — shop
At extraction: 19 confirmed rules (6 P0); later steps may add or correct rules below. Each citation was checked by a second agent that read the cited lines; 0 candidate rules were refuted and left out.
| ID | Name | Category | Priority | Source | Confidence |
|---|---|---|---|---|---|
| RULE-001 | Line item discount (grade, birthday, bulk) | Calculation | P0 | order_calc.php:18-32 |
Medium |
| RULE-002 | Shipping fee and surcharge | Calculation | P0 | order_calc.php:47-49 |
High |
| RULE-003 | Final payment amount | Calculation | P0 | order_calc.php:60 |
High |
| RULE-004 | Final payment and earned points | Calculation | P0 | order_calc.php:60-63 |
High |
| RULE-005 | Remote-area shipping surcharge | Calculation | P1 | inc/util.php:5-13 |
Medium |
| RULE-006 | Bulk discount threshold is more than 10 units (comment says 10 or more) | Calculation | P1 | order_calc.php:28-30 |
Medium |
| RULE-007 | Earned points exclude shipping and used points; tier rate | Calculation | P1 | order_calc.php:58-63 |
Medium |
| RULE-008 | Final amount and earn rounding to 10 won | Calculation | P1 | order_calc.php:60-63 |
High |
| RULE-009 | Fixed coupon eligibility | Validation | P0 | order_calc.php:39-45 |
High |
| RULE-010 | Loyalty point redemption limits | Validation | P0 | order_calc.php:51-58 |
High |
| RULE-011 | Jeju zip range and island zip prefix matching | Validation | P1 | inc/util.php:5-13 |
Medium |
| RULE-012 | Birth month determination | Validation | P2 | inc/member.php:9-13 |
High |
| RULE-013 | Event active only when flag and year both match | Lifecycle | P2 | order_calc.php:34-37 |
High |
| RULE-014 | Grade discount and point-save rate tables | Policy | P1 | inc/member.php:3-18 |
High |
| RULE-015 | Ship date cutoff | Policy | P1 | inc/util.php:15-25 |
High |
| RULE-016 | Free shipping judged on pre-discount total | Policy | P1 | order_calc.php:47-49 |
Medium |
| RULE-017 | Mobile free-shipping threshold | Policy | P2 | order_calc.php:13-14 |
Medium |
| RULE-018 | Birthday bonus is VIP only and excluded for sale items | Policy | P2 | order_calc.php:23-27 |
High |
| RULE-019 | Founding event 10% discount (2012 only) | Policy | P2 | order_calc.php:34-37 |
High |
Calculation
RULE-001: Line item discount (grade, birthday, bulk)
Category: Calculation
Priority: P0
Source: order_calc.php:18-32
Also cited: order_calc.php:18-32; order_calc.php:18-32
Plain English: Each line gets a percentage discount: grade rate (VIP 5, GOLD 3) plus 2 for VIP in birth month, only for non-sale items; plus 5 for qty over 10 on any item; discount floored to 10 won.
Specification:
Given VIP member born in October, ordering in October; item 12,000 x 2, not on sale
When line is priced
Then rate = 5+2 = 7%; line 24,000 - floor10(1,680)=1,680 = 22,320. A sale item 1,500 x 12 gets only 5% bulk: 18,000 - 900 = 17,100
Parameters: VIP 5%, GOLD 3%, birthday +2% (VIP only), bulk +5% when qty > 10, floor to 10 won
Edge cases handled: Sale items skip grade and birthday discount but still get bulk; Bulk threshold is qty > 10 although comment says 10 or more, so qty 10 gets no discount; Other grades get 0%; Discount stacks additively not multiplicatively
Suspected defect: Comment says 10 or more; code requires >10.
Confidence: Medium — Is bulk meant to apply at 10 or more (comment) or strictly more than 10 (code)?
RULE-002: Shipping fee and surcharge
Category: Calculation
Priority: P0
Source: order_calc.php:47-49
Also cited: order_calc.php:13-14,47-49
Plain English: Base shipping 2,500 is waived when pre-discount goods total reaches the free-shipping threshold (50,000, or 30,000 for mobile); regional surcharge is always added.
Specification:
Given web order, goods_total 42,000, zip 63100
When shipping computed
Then 2,500 + 3,000 Jeju = 5,500
Parameters: ship_fee 2500, free_ship 50000, mobile 30000
Edge cases handled: Threshold uses list price, not discounted; Surcharge applies even when shipping is free; Mobile channel lowers threshold
Confidence: High
RULE-003: Final payment amount
Category: Calculation
Priority: P0
Source: order_calc.php:60
Also cited: order_calc.php:58-60
Plain English: Final charge is payment after coupon and points plus shipping, floored to 10 won.
Specification:
Given pay 26,420, ship 5,500
When final computed
Then 31,920
Parameters: floor to 10 won
Edge cases handled: Rounds down in customer favor
Confidence: High
RULE-004: Final payment and earned points
Category: Calculation
Priority: P0
Source: order_calc.php:60-63
Plain English: Final charge is pay plus shipping floored to 10 won; earned points are 2% (VIP) or 1% of pay after points, excluding shipping, floored to 10.
Specification:
Given VIP, pay after points 26420, ship 3000
When order is finalized
Then final=floor10(29420)=29420; save=floor10(264202/100=528.4)=520
Parameters: VIP 2%, others 1% (member.php:15-18)
Edge cases handled: Earn base excludes shipping and redeemed points
Confidence:* High
RULE-005: Remote-area shipping surcharge
Category: Calculation
Priority: P1
Source: inc/util.php:5-13
Also cited: inc/util.php:5-13; inc/util.php:5-13
Plain English: Zip codes 63000-63644 (Jeju) add 3000; listed island zip prefixes add 5000.
Specification:
Given zip 63100
When surcharge computed
Then 3000 added. Zip 23100 gives 5000, others 0
Parameters: jeju_fee=3000, island_fee=5000, Jeju range 63000-63644, island list 23100,23101,23102,40200,52570,59100,59101 (2011 carrier list)
Edge cases handled: Island match is first 5 chars of the zip string; Island list is dated 2011
Confidence: Medium — Is the 2011 island zip list still current with the carrier?
RULE-006: Bulk discount threshold is more than 10 units (comment says 10 or more)
Category: Calculation
Priority: P1
Source: order_calc.php:28-30
Also cited: order_calc.php:23-30; order_calc.php:28-30
Plain English: A line with quantity strictly greater than 10 gets an extra 5% discount. This applies even to sale items and non-members, and it stacks with the grade discount.
Specification:
Given A line of price 10,000 with qty 10, and another with qty 11, as a non-member, not on sale
When The order is calculated
Then qty 10: no discount (100,000). qty 11: 5% off, so 110,000 - floor10(5,500) = 104,500
Parameters: qty > 10; +5 percentage points
Edge cases handled: Sale items skip the grade discount but still get the bulk discount; Discount is floored to 10 won per line
Suspected defect: The comment says '10개 이상' (10 or more), but the code uses > 10, so qty 10 gets nothing. | Comment says '10 or more' but code uses > 10, so qty 10 is excluded. | Comment says 10 or more; code requires 11 or more.
Confidence: Medium — Should the bulk discount start at 10 units (as the comment says) or 11 units (as the code does)? / Should bulk discount start at 10 units (per comment) or 11 (per code)? / Does bulk discount start at 10 units or 11?
RULE-007: Earned points exclude shipping and used points; tier rate
Category: Calculation
Priority: P1
Source: order_calc.php:58-63
Also cited: (calls point_save_rate defined at inc/member.php:15-18); order_calc.php:62-63; order_calc.php:62-63; order_calc.php:62-63
Plain English: VIP earns 2% and everyone else 1%, based on pay after coupon and points, rounded down to 10.
Specification:
Given VIP, pay after points 50,000
When Points are earned
Then Save is 1,000. A GOLD member earns 1%, which gives 500.
Parameters: VIP 2%, others 1%
Edge cases handled: GOLD earns the same as a basic member
Confidence: Medium — Citation was corrected by referee (The behavior exists, but the cited lines only hold part of it. inc/member.php:15-18 defines point_save_rate(), which returns 2 for VIP and 1 for every other grade. That matches the tier rate parameters. It does not exclude shipping or used points, and it does not round down to 10. Those parts are in order_calc.php. Line 58 computes $pay = $pay - $use_point. Line…
RULE-008: Final amount and earn rounding to 10 won
Category: Calculation
Priority: P1
Source: order_calc.php:60-63
Plain English: The final payment is the goods pay after points plus shipping, floored to 10 won. Earned points are the goods pay after points times the grade earn rate, floored to 10.
Specification:
Given Pay after points 28,000, ship 2,500, VIP
When Final and earn are computed
Then final = floor10(30,500) = 30,500. save = floor10(28,0002/100) = 560
Parameters: floor to 10 won
Edge cases handled: Coupons reduce the earn base; Shipping is excluded from the earn base
Confidence:* High
Validation
RULE-009: Fixed coupon eligibility
Category: Validation
Priority: P0
Source: order_calc.php:39-45
Also cited: order_calc.php:39-45; order_calc.php:39-45; order_calc.php:39-45; order_calc.php:39-45
Plain English: A fixed-amount coupon is honored only if discounted subtotal is at least 30,000; payment is floored at 0.
Specification:
Given sale_total 39,420 and coupon 3,000
When coupon applied
Then coupon=3,000, pay=36,420. If sale_total were 29,999 coupon=0
Parameters: coupon_min=30000
Edge cases handled: Coupon larger than subtotal gives pay 0; Minimum checked on post-discount total
Confidence: High
RULE-010: Loyalty point redemption limits
Category: Validation
Priority: P0
Source: order_calc.php:51-58
Also cited: order_calc.php:51-58; order_calc.php:51-58; order_calc.php:51-58; order_calc.php:51-57
Plain English: Points can be used only if the member holds at least 3,000; use is capped at 30% of payable amount, the member's balance and the request, in 100-won units.
Specification:
Given point 12000, use_point 10000, pay 40000
When points applied
Then max=floor100(12000)=12000; use=10000; pay=30000
Parameters: point_min=3000; point_max_rate=0.3; unit 100
Edge cases handled: Balance <3000 means zero use; Cap computed on pay after coupon, before shipping; Shipping is never paid by points
Confidence: High
RULE-011: Jeju zip range and island zip prefix matching
Category: Validation
Priority: P1
Source: inc/util.php:5-13
Also cited: inc/util.php:5-13
Plain English: Jeju is identified by a numeric zip between 63000 and 63644. Island areas are identified by a 5-character zip prefix match against a 2011 carrier list.
Specification:
Given Zip 63100, zip 23101, or zip 06000
When The surcharge is determined
Then 63100 gives 3,000 (Jeju). 23101 gives 5,000 (island). 06000 gives 0
Parameters: Jeju range 63000-63644; island list 23100, 23101, 23102, 40200, 52570, 59100, 59101 (carrier list from 2011)
Edge cases handled: Jeju is checked before island, so Jeju wins; The island list is stale (2011) and any zip outside it gets no surcharge; Non-numeric zip becomes 0 via intval and gets no Jeju surcharge; Zip must have at least 5 chars to match the island list
Confidence: Medium — Is the 2011 island zip list and the Jeju range 63000-63644 still current with the carrier? / Is the 2011 island zip list still current?
RULE-012: Birth month determination
Category: Validation
Priority: P2
Source: inc/member.php:9-13
Plain English: A member's birthday month matches when the MM of birth date equals the month of the order time.
Specification:
Given birth 1985-10-02 and order time in October
When checked
Then true; empty birth gives false
Parameters: birth format YYYY-MM-DD
Edge cases handled: Uses order 'now' override, not real clock
Confidence: High
Lifecycle
RULE-013: Event active only when flag and year both match
Category: Lifecycle
Priority: P2
Source: order_calc.php:34-37
Plain English: The founding event discount is time-boxed by the order's year (2012) and a config flag. The order's own 'now' value can override the clock.
Specification:
Given Order now=2012-12-31 and flag true
When Priced
Then 10% off the subtotal, floored to 10. In 2013, no discount.
Parameters: EVENT_2012=true; year 2012
Edge cases handled: The now field in input determines eligibility
Confidence: High
Policy
RULE-014: Grade discount and point-save rate tables
Category: Policy
Priority: P1
Source: inc/member.php:3-18
Plain English: VIP members get 5% grade discount and 2% point earn; GOLD gets 3% discount and 1% earn; everyone else gets 0% discount and 1% earn.
Specification:
Given A member with grade VIP, GOLD, or other
When Discount and earn rates are looked up
Then VIP: discount 5, earn 2; GOLD: discount 3, earn 1; other (incl. unknown or lowercase grade): discount 0, earn 1
Parameters: VIP 5%/2%, GOLD 3%/1%, default 0%/1%
Edge cases handled: Match is case-sensitive; 'vip' gets no discount; Only VIP earns the higher point rate
Confidence: High
RULE-015: Ship date cutoff
Category: Policy
Priority: P1
Source: inc/util.php:15-25
Also cited: inc/util.php:15-25; inc/util.php:15-25; inc/util.php:16-25
Plain English: Orders on Saturday ship Monday, Sunday ship Monday, weekdays after 15:00 ship next day (Friday after 15:00 ships Monday), otherwise same day.
Specification:
Given Saturday 2026-10-31 16:20
When ship date computed
Then 2026-11-02
Parameters: cutoff hour 15; Sat +2 days; Sun +1; Fri late +3
Edge cases handled: No holiday handling; Exactly 15:00 counts as late
Confidence: High
RULE-016: Free shipping judged on pre-discount total
Category: Policy
Priority: P1
Source: order_calc.php:47-49
Also cited: order_calc.php:47-49; order_calc.php:47-49
Plain English: Free shipping depends on the list-price total, not the amount actually paid, and regional surcharge is always added.
Specification:
Given List total 52,000, discounted to 40,000, zip on Jeju
When Shipping computed
Then Base fee 0 but Jeju surcharge 3,000 still charged, so ship is 3,000.
Parameters: free_ship=50000 (30000 mobile)
Edge cases handled: Coupons and points do not affect eligibility
Confidence: Medium — Is free shipping intended to use list price rather than the discounted amount?
RULE-017: Mobile free-shipping threshold
Category: Policy
Priority: P2
Source: order_calc.php:13-14
Plain English: Mobile channel orders get free shipping from 30,000 instead of 50,000 (2013 promotion, never removed).
Specification:
Given channel mobile, goods_total 35,000
When shipping computed
Then base fee 0
Parameters: 30000
Edge cases handled: Originally a promotion, may be stale
Confidence: Medium — Is the mobile promotion still active?
RULE-018: Birthday bonus is VIP only and excluded for sale items
Category: Policy
Priority: P2
Source: order_calc.php:23-27
Plain English: The 2% birthday-month bonus applies only to VIP members on non-sale items.
Specification:
Given A GOLD member in birth month buying a non-sale item
When Rate is computed
Then Rate is 3% with no birthday bonus. A VIP gets 5+2=7%.
Parameters: VIP 5, GOLD 3, birthday +2
Edge cases handled: Missing birth date yields no bonus; Sale item gets neither grade nor birthday discount
Confidence: High
RULE-019: Founding event 10% discount (2012 only)
Category: Policy
Priority: P2
Source: order_calc.php:34-37
Also cited: order_calc.php:34-37; order_calc.php:34-37
Plain English: While the event flag is on and the order year is 2012, 10% is taken off the discounted subtotal.
Specification:
Given EVENT_2012 true, order date in 2012, sale_total 100000
When totals computed
Then sale_total = 90000 (10% truncated to 10 won)
Parameters: EVENT_2012=true; year 2012; 10%
Edge cases handled: Dead for any other year; Flag still true in config
Confidence: High
Rules requiring SME confirmation
- RULE-001 (Medium): Is bulk meant to apply at 10 or more (comment) or strictly more than 10 (code)?
- RULE-005 (Medium): Is the 2011 island zip list still current with the carrier?
- RULE-006 (Medium): Should the bulk discount start at 10 units (as the comment says) or 11 units (as the code does)? / Should bulk discount start at 10 units (per comment) or 11 (per code)? / Does bulk discount start at 10 units or 11?
- RULE-007 (Medium): Citation was corrected by referee (The behavior exists, but the cited lines only hold part of it. inc/member.php:15-18 defines point_save_rate(), which returns 2 for VIP and 1 for every other grade. That matches the tier rate parameters. It does not exclude shipping or used points, and it does not round down to 10. Those parts are in order_calc.php. Line 58 computes $pay = $pay - $use_point. Line…
- RULE-011 (Medium): Is the 2011 island zip list and the Jeju range 63000-63644 still current with the carrier? / Is the 2011 island zip list still current?
- RULE-016 (Medium): Is free shipping intended to use list price rather than the discounted amount?
- RULE-017 (Medium): Is the mobile promotion still active?
Rules folded into another
These rules described the same behavior as another rule in a different place, so they were merged into it (the kept rule lists their locations under "Also cited"):
- Bulk discount applies to sale items and needs more than 10 units (order_calc.php:23-30) into Bulk discount threshold is more than 10 units (comment says 10 or more)
- Bulk discount threshold (more than 10 units, applies to sale items) (order_calc.php:28-30) into Bulk discount threshold is more than 10 units (comment says 10 or more)
- Earned points based on payment after point use, excluding shipping (order_calc.php:62-63) into Earned points exclude shipping and used points; tier rate
- Earned points on purchase (order_calc.php:62-63) into Earned points exclude shipping and used points; tier rate
- Point earn on purchase (order_calc.php:62-63) into Earned points exclude shipping and used points; tier rate
- Final payable amount (order_calc.php:58-60) into Final payment amount
- Line discount: grade, birthday and bulk (order_calc.php:18-32) into Line item discount (grade, birthday, bulk)
- Per-line discount rate (grade, birthday, bulk) (order_calc.php:18-32) into Line item discount (grade, birthday, bulk)
- Event discount ordering and year gate (order_calc.php:34-37) into Founding event 10% discount (2012 only)
- 2012 founding event discount (order_calc.php:34-37) into Founding event 10% discount (2012 only)
- Free shipping is judged on pre-discount list price (order_calc.php:47-49) into Free shipping judged on pre-discount total
- Free-shipping test uses pre-discount goods total (order_calc.php:47-49) into Free shipping judged on pre-discount total
- Shipping fee and free-shipping threshold (order_calc.php:13-14,47-49) into Shipping fee and surcharge
- Regional shipping surcharge (inc/util.php:5-13) into Remote-area shipping surcharge
- Regional shipping surcharge by zip (inc/util.php:5-13) into Remote-area shipping surcharge
- Island zip matching and Jeju range (inc/util.php:5-13) into Jeju zip range and island zip prefix matching
- Ship-out date cutoff (inc/util.php:15-25) into Ship date cutoff
- Ship date: weekend and Friday-after-cutoff push to Monday (inc/util.php:15-25) into Ship date cutoff
- Ship-out date rule for Friday evening and weekends (inc/util.php:16-25) into Ship date cutoff
- Coupon eligibility and cap (order_calc.php:39-45) into Fixed coupon eligibility
- Coupon eligibility is tested on discounted subtotal and payment floored at zero (order_calc.php:39-45) into Fixed coupon eligibility
- Coupon eligibility measured after discounts and event; pay floored at zero (order_calc.php:39-45) into Fixed coupon eligibility
- Coupon threshold is judged after discounts, and the pay amount is floored at zero (order_calc.php:39-45) into Fixed coupon eligibility
- Point redemption limits (order_calc.php:51-58) into Loyalty point redemption limits
- Point usage rounding and base on coupon-adjusted pay (excludes shipping) (order_calc.php:51-58) into Loyalty point redemption limits
- Point usage gating and cap on pre-point payable (order_calc.php:51-58) into Loyalty point redemption limits
- Point usage requires minimum balance and caps at 30% of post-coupon pay (order_calc.php:51-57) into Loyalty point redemption limits
플러그인이 만든 영어 문서 그대로입니다. 한 장짜리 보고서: REPORT.html 열기
Business Rules — shop
At extraction: 19 confirmed rules (6 P0); later steps may add or correct rules below. Each citation was checked by a second agent that read the cited lines; 1 candidate rules were refuted and left out.
| ID | Name | Category | Priority | Source | Confidence |
|---|---|---|---|---|---|
| RULE-001 | Line-item discount (grade, birthday, bulk) | Calculation | P0 | order_calc.php:18-32 |
High |
| RULE-002 | Shipping fee, free-shipping threshold and region surcharge | Calculation | P0 | order_calc.php:47-49 |
High |
| RULE-003 | Point redemption limits | Calculation | P0 | order_calc.php:51-58 |
High |
| RULE-004 | Final payment amount | Calculation | P0 | order_calc.php:60 |
High |
| RULE-005 | Final charge and earned points | Calculation | P0 | order_calc.php:60-63 |
High |
| RULE-006 | Remote-area surcharge by zip code | Calculation | P1 | inc/util.php:5-13 |
High |
| RULE-007 | Bulk discount threshold applies strictly above 10 and stacks | Calculation | P1 | order_calc.php:28-30 |
Medium |
| RULE-008 | Rounding of payable amounts | Calculation | P1 | order_calc.php:54-60 |
High |
| RULE-009 | Earned points on purchase | Calculation | P1 | order_calc.php:62-63 |
High |
| RULE-010 | Point save rate by grade | Calculation | P2 | inc/member.php:15-18 |
High |
| RULE-011 | Fixed coupon eligibility and payable floor | Validation | P0 | order_calc.php:39-45 |
High |
| RULE-012 | Birth-month test | Validation | P2 | inc/member.php:9-13 |
High |
| RULE-013 | Grade-based discount and point-save rates | Policy | P1 | inc/member.php:3-18 |
High |
| RULE-014 | Shipment date cutoff | Policy | P1 | inc/util.php:15-25 |
Medium |
| RULE-015 | Mobile channel lowers free-shipping threshold | Policy | P1 | order_calc.php:13-14 |
Medium |
| RULE-016 | Sale items excluded from grade and birthday discount but not from bulk | Policy | P1 | order_calc.php:21-29 |
Medium |
| RULE-017 | Sale items excluded from grade and birthday discount; birthday bonus VIP-only | Policy | P1 | order_calc.php:22-27 |
High |
| RULE-018 | 2012 founding event discount | Policy | P1 | order_calc.php:34-37 |
Medium |
| RULE-019 | Free-shipping test uses list price before discounts | Policy | P1 | order_calc.php:47-48 |
Medium |
Calculation
RULE-001: Line-item discount (grade, birthday, bulk)
Category: Calculation
Priority: P0
Source: order_calc.php:18-32
Also cited: order_calc.php:18-32; order_calc.php:18-32
Plain English: Each line gets a grade discount (VIP 5%, GOLD 3%) unless the item is on sale, plus VIP birth-month +2%, plus 5% bulk if qty>10; discount floored to 10 won.
Specification:
Given VIP member born in the current month, non-sale item price 20,000 qty 11
When order is calculated
Then rate=5+2+5=12%; line=220,000; discount=floor10(26,400)=26,400; line total 193,600
Parameters: VIP 5, GOLD 3, other 0; birthday +2 (VIP only); bulk +5 when qty>10; floor to 10 won
Edge cases handled: Sale items skip grade and birthday discount but still get the bulk 5%; Comment says '10 or more' but code is qty>10, so exactly 10 gets no bulk discount; Birth month compared to order 'now' month
Suspected defect: Comment says 10 or more; code requires more than 10. | Comment says 10 or more but code requires more than 10 (qty > 10).
Confidence: High
RULE-002: Shipping fee, free-shipping threshold and region surcharge
Category: Calculation
Priority: P0
Source: order_calc.php:47-49
Also cited: order_calc.php:47-49
Plain English: Shipping is 2,500 unless the pre-discount goods total reaches the free-shipping threshold (50,000; 30,000 for mobile); remote-area surcharges are always added.
Specification:
Given web order, goods_total 45,000, Jeju zip 63100
When shipping computed
Then ship=2500+3000=5500
Parameters: ship_fee 2500; free_ship 50000 (mobile 30000, order_calc.php:14); jeju_fee 3000 for zip 63000-63644; island_fee 5000 for zips prefixed 23100,23101,23102,40200,52570,59100,59101 (util.php:5-13)
Edge cases handled: Threshold uses list price total, not discounted; Surcharge applies even when shipping is free; Jeju check wins before island list; Mobile threshold comes from a 2013 promotion hack
Confidence: High
RULE-003: Point redemption limits
Category: Calculation
Priority: P0
Source: order_calc.php:51-58
Plain English: Points can be used only if the member holds at least 3,000; usage is capped at 30% of payment after coupon, at the member's balance and at the request, in 100-won units.
Specification:
Given Points 12,000, request 10,000, pay 36,420
When points are applied
Then max = floor100(10,926)=10,900; use = min(10,000,12,000,10,900)=10,000; pay = 26,420
Parameters: point_min=3000, point_max_rate=0.3, unit 100 won
Edge cases handled: Balance under 3,000 means no use; Cap is computed on pay after coupon, before shipping; Result is floored to 100
Confidence: High
RULE-004: Final payment amount
Category: Calculation
Priority: P0
Source: order_calc.php:60
Plain English: The final amount is the payment after points plus shipping, floored to 10 won.
Specification:
Given pay 26,420 and ship 5,500
When final is computed
Then final = floor10(31,920) = 31,920
Parameters: floor to 10 won
Edge cases handled: Shipping is excluded from the point cap but included in the final amount
Confidence: High
RULE-005: Final charge and earned points
Category: Calculation
Priority: P0
Source: order_calc.php:60-63
Plain English: Final amount = (pay after points + shipping) floored to 10 won; earned points are 2% (VIP) or 1% of pay after points, excluding shipping.
Specification:
Given VIP, pay after points 14,000, ship 2,500
When calculated
Then final 16,500; save_point floor10(280)=280
Parameters: VIP 2%, others 1%; floor 10 won (util.php floor10; member.php:15-18)
Edge cases handled: GOLD earns only 1%
Confidence: High
RULE-006: Remote-area surcharge by zip code
Category: Calculation
Priority: P1
Source: inc/util.php:5-13
Also cited: inc/util.php:5-13; inc/util.php:5-13
Plain English: Jeju zip codes 63000-63644 add 3,000; listed island zip prefixes add 5,000; otherwise none.
Specification:
Given Zip 63100 (Jeju), 23101 (island) or 06000 (other)
When Extra shipping is computed
Then Surcharge is 3,000, 5,000 and 0 respectively; jeju is checked first
Parameters: jeju range 63000-63644 fee 3000; island prefixes 23100,23101,23102,40200,52570,59100,59101 fee 5000 (carrier list from 2011)
Edge cases handled: Island match uses the first 5 characters of the zip string; Jeju uses integer conversion, so non-numeric zips become 0 and are not Jeju; Surcharge applies even when base shipping is free; Island list is dated 2011
Confidence: High
RULE-007: Bulk discount threshold applies strictly above 10 and stacks
Category: Calculation
Priority: P1
Source: order_calc.php:28-30
Also cited: order_calc.php:28-30
Plain English: Quantity over 10 of one item adds 5% discount, even to sale items which otherwise get no grade discount.
Specification:
Given VIP, sale item, qty 11, price 1000
When line discount computed
Then rate 5 -> 11000 - floor10(550) = 10450; qty exactly 10 gets no bulk discount
Parameters: qty > 10; 5%
Edge cases handled: Comment says '10 or more' but code uses > 10; Sale items still get bulk discount
Suspected defect: Comment says 10+ but code requires more than 10. | Comment says '10개 이상' (10 or more) but code uses > 10.
Confidence: Medium — Should bulk discount start at 10 units (comment) or 11 (code)? / Should the bulk bonus start at 10 or at 11?
RULE-008: Rounding of payable amounts
Category: Calculation
Priority: P1
Source: order_calc.php:54-60
Plain English: Point usage is truncated to 100 won, and the final charge and savings to 10 won, always rounding down in the customer's favor for discounts but down on the charge.
Specification:
Given pay 45,678, ship 2,500, points allowed
When Totals are computed
Then Max points = floor100(456780.3)=13,700; final = floor10(pay after points + ship)
Parameters: floor100 for points, floor10 for final and save
Edge cases handled: Max point cap is computed on pay after coupon, excluding shipping; Final truncation may drop up to 9 won from the shipping-inclusive total
Confidence:* High
RULE-009: Earned points on purchase
Category: Calculation
Priority: P1
Source: order_calc.php:62-63
Plain English: Earned points are 2% (VIP) or 1% (others) of the product payment after coupon and points, excluding shipping, floored to 10 won.
Specification:
Given VIP, pay 26,420
When earn is computed
Then floor10(26,4202/100=528.4)=520
Parameters: VIP 2%, others 1% (member.php:15-18)
Edge cases handled: GOLD earns only 1%, the same as the base rate
Confidence:* High
RULE-010: Point save rate by grade
Category: Calculation
Priority: P2
Source: inc/member.php:15-18
Plain English: VIP earns 2% points; everyone else 1%.
Specification:
Given VIP, pay 100000
When points earned
Then 2000 points; non-VIP 1000
Parameters: VIP 2%, default 1%
Edge cases handled: GOLD earns only the base 1%
Confidence: High
Validation
RULE-011: Fixed coupon eligibility and payable floor
Category: Validation
Priority: P0
Source: order_calc.php:39-45
Also cited: order_calc.php:39-45
Plain English: A fixed-amount coupon applies only if the discounted subtotal is at least 30,000; payment cannot go below zero.
Specification:
Given sale_total 33,000 and coupon 3,000
When coupon is applied
Then coupon=3,000, pay=30,000. If sale_total were 29,990 the coupon would be 0.
Parameters: coupon_min=30000
Edge cases handled: Coupon <=0 or missing ignored; Coupon larger than subtotal gives pay 0; Minimum is tested against the post-discount subtotal, before the coupon
Confidence: High
RULE-012: Birth-month test
Category: Validation
Priority: P2
Source: inc/member.php:9-13
Also cited: inc/member.php:9-13
Plain English: A member is in birth month when characters 6-7 of the YYYY-MM-DD birth date equal the order month.
Specification:
Given Birth 1980-05-12 and order time in May
When Birth month is checked
Then True; empty birth is false
Parameters: substr(birth,5,2) vs month of order 'now'
Edge cases handled: Month comes from the order's now field or the system clock; No format validation of the birth string
Confidence: High
Policy
RULE-013: Grade-based discount and point-save rates
Category: Policy
Priority: P1
Source: inc/member.php:3-18
Also cited: inc/member.php:3-18
Plain English: VIP gets 5% discount and 2% point accrual, GOLD gets 3% discount and 1% accrual, everyone else gets 0% discount and 1% accrual.
Specification:
Given A GOLD member
When Rates are looked up
Then Discount 3%, point accrual 1%; VIP is 5% and 2%; any other grade is 0% and 1%
Parameters: VIP 5/2, GOLD 3/1, default 0/1
Edge cases handled: Grade comparison is exact and case-sensitive; Unknown or missing grade silently falls to the default
Confidence: High
RULE-014: Shipment date cutoff
Category: Policy
Priority: P1
Source: inc/util.php:15-25
Also cited: inc/util.php:15-25
Plain English: Weekend orders ship Monday; weekday orders at or after 15:00 ship next day, Friday after 15:00 ships Monday.
Specification:
Given Saturday order 2026-10-31 16:20
When ship date computed
Then ship date is Monday 2026-11-02
Parameters: cutoff hour 15; Sat +2 days, Sun +1, Fri after cutoff +3
Edge cases handled: Holidays not considered; Before 15:00 on weekdays ships same day
Confidence: Medium — Should public holidays shift the ship date?
RULE-015: Mobile channel lowers free-shipping threshold
Category: Policy
Priority: P1
Source: order_calc.php:13-14
Plain English: Orders from the mobile channel get free shipping from 30,000 instead of 50,000 (list-price total).
Specification:
Given A mobile order with list-price total 35,000 and a domestic non-remote zip
When Shipping is calculated
Then Base shipping is 0 (threshold 30,000 instead of 50,000); the same order on web pays 2,500
Parameters: mobile free_ship=30000; default free_ship=50000; base fee 2500
Edge cases handled: Only the exact string 'mobile' triggers it; other or missing channels use 50,000; Regional surcharge is still added; Comment calls it a 2013 promotion but there is no end date in code
Confidence: Medium — Is the mobile promotion still active or should it expire?
RULE-016: Sale items excluded from grade and birthday discount but not from bulk
Category: Policy
Priority: P1
Source: order_calc.php:21-29
Plain English: Items flagged as sale never receive the grade or birthday discount, but the bulk discount still applies to them.
Specification:
Given A VIP with a sale item at price 10,000 and quantity 11
When The line discount is computed
Then Rate is 5% (bulk only), so the discount is floor10(110,0005/100)=5,500
Parameters: Bulk bonus 5%
Edge cases handled: Bulk applies when qty is more than 10 (qty 11 and above), although the comment says 10 or more; Rates stack additively, and the discount is floored to 10 KRW per line
Suspected defect: Code uses qty > 10, comment says 10 or more.
Confidence:* Medium — Should bulk discount start at 10 units (as the comment says) or 11 (as the code does)?
RULE-017: Sale items excluded from grade and birthday discount; birthday bonus VIP-only
Category: Policy
Priority: P1
Source: order_calc.php:22-27
Plain English: Grade discounts (VIP 5, GOLD 3) apply only to non-sale items; VIP in birth month gets extra 2%.
Specification:
Given VIP member born in current month, non-sale item
When line rate computed
Then rate 7%; sale item 0%; GOLD birthday stays 3%
Parameters: VIP 5, GOLD 3 (member.php:3-7); birthday +2; birth month from chars 6-7 of YYYY-MM-DD (member.php:9-13)
Edge cases handled: Empty birth date means no birthday; Month compared against order time, not real clock
Confidence: High
RULE-018: 2012 founding event discount
Category: Policy
Priority: P1
Source: order_calc.php:34-37
Also cited: order_calc.php:34-37; order_calc.php:34-37
Plain English: A 10% discount on the discounted subtotal applies only when the event flag is on and the order year is 2012.
Specification:
Given Event flag true and order dated in 2012, subtotal 100,000
When order is calculated
Then subtotal becomes 100,000 - floor10(10,000) = 90,000
Parameters: EVENT_2012=true, rate 10%, year '2012'
Edge cases handled: Orders in any other year are unaffected, so it is dead for current dates
Confidence: Medium — Can this expired event code be removed? / Is the 2012 event long over, so this rule can be dropped rather than migrated?
RULE-019: Free-shipping test uses list price before discounts
Category: Policy
Priority: P1
Source: order_calc.php:47-48
Plain English: Free shipping depends on the pre-discount goods total, not the amount actually paid.
Specification:
Given Items list-price total 52,000 discounted to 45,000, web channel
When Shipping is computed
Then Base shipping is 0 because 52,000 >= 50,000
Parameters: threshold 50000 (web), 30000 (mobile)
Edge cases handled: Comparison is >=, so exactly 50,000 ships free; Coupon and point use do not affect it
Confidence: Medium — Is using the pre-discount total intentional?
Rules requiring SME confirmation
- RULE-007 (Medium): Should bulk discount start at 10 units (comment) or 11 (code)? / Should the bulk bonus start at 10 or at 11?
- RULE-014 (Medium): Should public holidays shift the ship date?
- RULE-015 (Medium): Is the mobile promotion still active or should it expire?
- RULE-016 (Medium): Should bulk discount start at 10 units (as the comment says) or 11 (as the code does)?
- RULE-018 (Medium): Can this expired event code be removed? / Is the 2012 event long over, so this rule can be dropped rather than migrated?
- RULE-019 (Medium): Is using the pre-discount total intentional?
Rules folded into another
These rules described the same behavior as another rule in a different place, so they were merged into it (the kept rule lists their locations under "Also cited"):
- Line discount by grade, birthday and bulk (order_calc.php:18-32) into Line-item discount (grade, birthday, bulk)
- Line-item discount rate (grade, birthday, bulk) (order_calc.php:18-32) into Line-item discount (grade, birthday, bulk)
- Bulk bonus applies to sale items and stacks with other rates (order_calc.php:28-30) into Bulk discount threshold applies strictly above 10 and stacks
- Founding event applies only in calendar year 2012 (order_calc.php:34-37) into 2012 founding event discount
- Founding event 10% discount (order_calc.php:34-37) into 2012 founding event discount
- Shipping fee and regional surcharge (order_calc.php:47-49) into Shipping fee, free-shipping threshold and region surcharge
- Jeju and island regional surcharge zip classification (inc/util.php:5-13) into Remote-area surcharge by zip code
- Regional surcharge by postal code (inc/util.php:5-13) into Remote-area surcharge by zip code
- Ship-out date (inc/util.php:15-25) into Shipment date cutoff
- Birth-month detection for VIP bonus (inc/member.php:9-13) into Birth-month test
- Fixed coupon eligibility (order_calc.php:39-45) into Fixed coupon eligibility and payable floor
- Grade-based discount and point-save rate tables (inc/member.php:3-18) into Grade-based discount and point-save rates