<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.erp.product.sku.repository.PlatformSkuBindingRepository">
    
    <!-- 查询生效的绑定 -->
    <select id="findActiveByPlatformSkuId" resultType="com.erp.product.sku.entity.PlatformSkuBinding">
        SELECT * FROM platform_sku_bindings 
        WHERE platform_sku_id = #{platformSkuId} AND is_active = true
    </select>
    
    <!-- 解绑指定平台SKU的所有绑定 -->
    <update id="deactivateByPlatformSkuId">
        UPDATE platform_sku_bindings 
        SET is_active = false, unbound_at = NOW() 
        WHERE platform_sku_id = #{platformSkuId} AND is_active = true
    </update>
    
</mapper>
