INSERT INTO mall_store (code, name, city, state, zip, address, phone, timezone, open_time, close_time,
same_day_cutoff, delivery_radius_mi, daily_capacity, lat, lng, active)
VALUES (#{code}, #{name}, #{city}, #{state}, #{zip}, #{address}, #{phone}, COALESCE(#{timezone},'America/New_York'),
COALESCE(#{openTime},'09:00'), COALESCE(#{closeTime},'18:00'), COALESCE(#{sameDayCutoff},'12:00'),
COALESCE(#{deliveryRadiusMi},15.0), COALESCE(#{dailyCapacity},50), #{lat}, #{lng}, COALESCE(#{active},TRUE))
UPDATE mall_store SET name=#{name}, city=#{city}, state=#{state}, zip=#{zip}, address=#{address}, phone=#{phone},
timezone=COALESCE(#{timezone},timezone), open_time=COALESCE(#{openTime},open_time), close_time=COALESCE(#{closeTime},close_time),
same_day_cutoff=COALESCE(#{sameDayCutoff},same_day_cutoff), delivery_radius_mi=COALESCE(#{deliveryRadiusMi},delivery_radius_mi),
daily_capacity=COALESCE(#{dailyCapacity},daily_capacity), lat=COALESCE(#{lat},lat), lng=COALESCE(#{lng},lng)
WHERE id=#{id}
UPDATE mall_store SET active=#{active} WHERE id=#{id}