-- ================================================================
-- 대구 동구청 공식 종량제봉투 포장단위 반영 (가격표 묶음·박스 매수)
-- 출처: https://dong.daegu.kr/reserve/contents.do?mid=0302000000
--
-- | 규격 | 묶음(팩)당 | 박스당 | 박스당 팩 수 (=박스÷묶음) |
-- | 3L   | 20        | 3,000  | 150 |
-- | 10L  | 10        | 2,000  | 200 |
-- | 20L  | (표 미기재) | 1,000 | 50매×20팩 추정 |
-- | 50L  | (표 미기재) | 500   | 20매×25팩 추정 |
-- | 75L  | (표 미기재) | 300   | 10매×30팩 추정 |
-- 5L·30L: 동구 표에 묶음/박스 미기재 → 3L·20L·50L와 동일 계열로 20매·박스 3,000/300 유지
--
-- 실행: mysql -u jongryangje -p jongryangje_dev < writable/database/fix_packaging_unit_daegu_donggu_official.sql
-- ================================================================

SET NAMES utf8mb4;

UPDATE `packaging_unit` SET
  `pu_pack_per_sheet` = CASE `pu_bag_code`
    WHEN '10112' THEN 20
    WHEN '10122' THEN 20
    WHEN '10132' THEN 10
    WHEN '10152' THEN 50
    WHEN '10162' THEN 50
    WHEN '10172' THEN 20
    WHEN '10192' THEN 10
    WHEN '10202' THEN 10
    WHEN '20172' THEN 20
    WHEN '40152' THEN 50
    WHEN '40182' THEN 20
    WHEN '40212' THEN 10
    WHEN '50122' THEN 20
    ELSE `pu_pack_per_sheet`
  END,
  `pu_box_per_pack` = CASE `pu_bag_code`
    WHEN '10112' THEN 150
    WHEN '10122' THEN 150
    WHEN '10132' THEN 200
    WHEN '10152' THEN 20
    WHEN '10162' THEN 6
    WHEN '10172' THEN 25
    WHEN '10192' THEN 30
    WHEN '10202' THEN 5
    WHEN '20172' THEN 25
    WHEN '40152' THEN 20
    WHEN '40182' THEN 10
    WHEN '40212' THEN 5
    WHEN '50122' THEN 150
    ELSE `pu_box_per_pack`
  END,
  `pu_total_per_box` = CASE `pu_bag_code`
    WHEN '10112' THEN 3000
    WHEN '10122' THEN 3000
    WHEN '10132' THEN 2000
    WHEN '10152' THEN 1000
    WHEN '10162' THEN 300
    WHEN '10172' THEN 500
    WHEN '10192' THEN 300
    WHEN '10202' THEN 50
    WHEN '20172' THEN 500
    WHEN '40152' THEN 1000
    WHEN '40182' THEN 200
    WHEN '40212' THEN 50
    WHEN '50122' THEN 3000
    ELSE `pu_total_per_box`
  END
WHERE `pu_bag_code` IN (
  '10112','10122','10132','10152','10162','10172','10192','10202',
  '20172','40152','40182','40212','50122'
)
  AND `pu_state` = 1
  AND (`pu_end_date` IS NULL OR `pu_end_date` >= CURDATE());
