AND category_id = #{categoryId} AND (name ILIKE '%' || #{keyword} || '%' OR brand ILIKE '%' || #{keyword} || '%' OR description ILIKE '%' || #{keyword} || '%') AND status = #{status} AND occasion = #{occasion} AND flower_type = #{flowerType} AND COALESCE(sale_price, price) <= #{maxPrice} INSERT INTO mall_product (category_id, sku, name, brand, description, price, sale_price, status, stock, thumbnail, occasion, flower_type, shelf_life_days) VALUES (#{categoryId}, #{sku}, #{name}, #{brand}, #{description}, #{price}, #{salePrice}, COALESCE(#{status},'ON_SALE'), COALESCE(#{stock},0), #{thumbnail}, #{occasion}, #{flowerType}, COALESCE(#{shelfLifeDays},5)) UPDATE mall_product SET category_id=#{categoryId}, name=#{name}, brand=#{brand}, description=#{description}, price=#{price}, sale_price=#{salePrice}, status=COALESCE(#{status},status), stock=COALESCE(#{stock},stock), thumbnail=#{thumbnail}, occasion=COALESCE(#{occasion},occasion), flower_type=COALESCE(#{flowerType},flower_type), shelf_life_days=COALESCE(#{shelfLifeDays},shelf_life_days) WHERE id=#{id} UPDATE mall_product SET status=#{status} WHERE id=#{id} UPDATE mall_product SET sales_count = COALESCE(sales_count,0) + #{qty}, stock = GREATEST(COALESCE(stock,0) - #{qty}, 0) WHERE id=#{id} DELETE FROM mall_product WHERE id=#{id} INSERT INTO mall_product_option (product_id, option_name, option_value, extra_price, stock, sku_suffix, option_type) VALUES (#{productId}, #{optionName}, #{optionValue}, COALESCE(#{extraPrice},0), COALESCE(#{stock},0), #{skuSuffix}, #{optionType}) DELETE FROM mall_product_option WHERE product_id = #{productId} INSERT INTO mall_product_size (product_id, size_code, label, price, stem_count, sort_order) VALUES (#{productId}, #{sizeCode}, #{label}, #{price}, #{stemCount}, COALESCE(#{sortOrder},0)) DELETE FROM mall_product_size WHERE product_id = #{productId} INSERT INTO mall_product_image (product_id, url, sort_order, is_main) VALUES (#{productId}, #{url}, COALESCE(#{sortOrder},0), COALESCE(#{isMain},FALSE)) DELETE FROM mall_product_image WHERE product_id = #{productId}