<?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.hzs.activity.declaration.mapper.AcDeclarationGiftDetailMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.activity.declaration.AcDeclarationGiftDetail">
        <id column="PK_ID" property="pkId" />
    <result column="DEL_FLAG" property="delFlag" />
    <result column="CREATION_TIME" property="creationTime" />
    <result column="PK_CREATOR" property="pkCreator" />
    <result column="MODIFIED_TIME" property="modifiedTime" />
    <result column="PK_MODIFIED" property="pkModified" />
    <result column="PK_COUNTRY" property="pkCountry" />
        <result column="PK_RULE_ID" property="pkRuleId" />
        <result column="PK_PRODUCT" property="pkProduct" />
        <result column="SPECS_NAME" property="specsName" />
        <result column="SPECS_NAME_ID" property="specsNameId" />
        <result column="QUANTITY" property="quantity" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        DEL_FLAG,
        CREATION_TIME,
        PK_CREATOR,
        MODIFIED_TIME,
        PK_MODIFIED,
        PK_COUNTRY,
        PK_ID, PK_RULE_ID, PK_PRODUCT, SPECS_NAME, SPECS_NAME_ID, QUANTITY
    </sql>
    <select id="listByPKRuleId" resultType="com.hzs.activity.declaration.param.AcDeclarationProductParam">
        SELECT
            adgd.*,
            bp.PRODUCT_NAME,
            bp.PRODUCT_CODE
        FROM
            AC_DECLARATION_GIFT_DETAIL adgd
                LEFT JOIN BD_PRODUCT bp ON adgd.PK_PRODUCT = bp.PK_ID
        WHERE
            adgd.PK_RULE_ID = #{ pkId }
          AND adgd.DEL_FLAG = 0
    </select>
    <select id="listByPKRuleIds" resultType="com.hzs.activity.declaration.param.AcDeclarationProductParam">
        SELECT
            adgd.*,
            bp.PRODUCT_NAME,
            bp.PRODUCT_CODE
        FROM
            AC_DECLARATION_GIFT_DETAIL adgd
                LEFT JOIN BD_PRODUCT bp ON adgd.PK_PRODUCT = bp.PK_ID
        WHERE
        adgd.PK_RULE_ID in
        <foreach collection="ruleIds" item="items" open="(" close=")" separator=",">
            #{items}
        </foreach>
    </select>

</mapper>
