<?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="org.springblade.audit.mapper.CwFactIncomeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="cwFactIncomeResultMap" type="org.springblade.audit.entity.CwFactIncome">
        <result column="THEMONTH" property="themonth"/>
        <result column="PROVINCE_NO" property="provinceNo"/>
        <result column="PROVINCE" property="province"/>
        <result column="SPCODE" property="spcode"/>
        <result column="SERVICETYPE" property="servicetype"/>
        <result column="SERVICEID" property="serviceid"/>
        <result column="SERVICENAME" property="servicename"/>
        <result column="VACPRODUCTID" property="vacproductid"/>
        <result column="SPID" property="spid"/>
        <result column="SPNAME" property="spname"/>
        <result column="FACT_INCOME" property="factIncome"/>
        <result column="ORDERS" property="orders"/>
    </resultMap>


    <update id="giveSpidSoul">
        update CW_FACT_INCOME a
        set spid=(select max(spid) from dim_product_category b where a.VACPRODUCTID=b.VACPRODUCTID)
        where spid is null and themonth = #{theMonth}
    </update>

    <update id="giveSpidSoulTwo">
        update CW_FACT_INCOME a
        set spid=(select max(spid) from dim_product_category b where a.spname=b.spname)
        where spid is null and themonth = #{theMonth}
    </update>

    <update id="giveSpidSoulThree">
        update CW_FACT_INCOME a
        set spid= (select max(spid) from DIM_CS_PRM_SPNAME b where a.spname=b.PRM_SPNAME)
        where themonth = #{theMonth} and spid is null
    </update>


</mapper>
