106 lines
5.0 KiB
XML
106 lines
5.0 KiB
XML
<?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.bms.system.mapper.BmsExchangeRateMapper">
|
|
|
|
<resultMap type="BmsExchangeRate" id="BmsExchangeRateResult">
|
|
<id property="rateId" column="rate_id" />
|
|
<result property="fromCurrency" column="from_currency" />
|
|
<result property="toCurrency" column="to_currency" />
|
|
<result property="rateType" column="rate_type" />
|
|
<result property="exchangeRate" column="exchange_rate" />
|
|
<result property="effectiveDate" column="effective_date" />
|
|
<result property="expireDate" column="expire_date" />
|
|
<result property="source" column="source" />
|
|
<result property="remark" column="remark" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="delFlag" column="del_flag" />
|
|
</resultMap>
|
|
|
|
<sql id="selectExchangeRateVo">
|
|
select rate_id, from_currency, to_currency, rate_type, exchange_rate, effective_date, expire_date,
|
|
source, remark, create_by, create_time, del_flag
|
|
from sys_exchange_rate
|
|
</sql>
|
|
|
|
<select id="selectExchangeRateList" parameterType="BmsExchangeRate" resultMap="BmsExchangeRateResult">
|
|
<include refid="selectExchangeRateVo"/>
|
|
<where>
|
|
del_flag = '0'
|
|
<if test="fromCurrency != null and fromCurrency != ''"> and from_currency = #{fromCurrency}</if>
|
|
<if test="toCurrency != null and toCurrency != ''"> and to_currency = #{toCurrency}</if>
|
|
<if test="rateType != null and rateType != ''"> and rate_type = #{rateType}</if>
|
|
<if test="source != null and source != ''"> and source like concat('%', #{source}, '%')</if>
|
|
<if test="params != null and params.beginTime != null and params.beginTime != ''">
|
|
and effective_date >= #{params.beginTime}
|
|
</if>
|
|
<if test="params != null and params.endTime != null and params.endTime != ''">
|
|
and effective_date <= #{params.endTime}
|
|
</if>
|
|
</where>
|
|
order by effective_date desc, rate_type asc, rate_id desc
|
|
</select>
|
|
|
|
<select id="selectExchangeRateById" parameterType="Long" resultMap="BmsExchangeRateResult">
|
|
<include refid="selectExchangeRateVo"/>
|
|
where rate_id = #{rateId} and del_flag = '0'
|
|
</select>
|
|
|
|
<select id="selectEffectiveRate" resultMap="BmsExchangeRateResult">
|
|
<include refid="selectExchangeRateVo"/>
|
|
where del_flag = '0'
|
|
and from_currency = #{fromCurrency}
|
|
and to_currency = #{toCurrency}
|
|
<if test="rateType != null and rateType != ''">and rate_type = #{rateType}</if>
|
|
and effective_date <= #{bizDate}
|
|
and (expire_date is null or expire_date >= #{bizDate})
|
|
order by effective_date desc, rate_id desc
|
|
limit 1
|
|
</select>
|
|
|
|
<select id="countDuplicate" resultType="int">
|
|
select count(1) from sys_exchange_rate
|
|
where del_flag = '0'
|
|
and from_currency = #{fromCurrency}
|
|
and to_currency = #{toCurrency}
|
|
and rate_type = #{rateType}
|
|
and effective_date = #{effectiveDate}
|
|
<if test="excludeId != null">and rate_id != #{excludeId}</if>
|
|
</select>
|
|
|
|
<insert id="insertExchangeRate" parameterType="BmsExchangeRate" useGeneratedKeys="true" keyProperty="rateId">
|
|
insert into sys_exchange_rate (
|
|
from_currency, to_currency, rate_type, exchange_rate, effective_date, expire_date,
|
|
source, remark, create_by, create_time, del_flag
|
|
) values (
|
|
#{fromCurrency}, #{toCurrency}, #{rateType}, #{exchangeRate}, #{effectiveDate}, #{expireDate},
|
|
#{source}, #{remark}, #{createBy}, sysdate(), '0'
|
|
)
|
|
</insert>
|
|
|
|
<update id="updateExchangeRate" parameterType="BmsExchangeRate">
|
|
update sys_exchange_rate
|
|
<set>
|
|
<if test="fromCurrency != null and fromCurrency != ''">from_currency = #{fromCurrency},</if>
|
|
<if test="toCurrency != null and toCurrency != ''">to_currency = #{toCurrency},</if>
|
|
<if test="rateType != null and rateType != ''">rate_type = #{rateType},</if>
|
|
<if test="exchangeRate != null">exchange_rate = #{exchangeRate},</if>
|
|
<if test="effectiveDate != null">effective_date = #{effectiveDate},</if>
|
|
expire_date = #{expireDate},
|
|
<if test="source != null">source = #{source},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
</set>
|
|
where rate_id = #{rateId}
|
|
</update>
|
|
|
|
<update id="deleteExchangeRateByIds" parameterType="Long">
|
|
update sys_exchange_rate set del_flag = '1' where rate_id in
|
|
<foreach item="rateId" collection="array" open="(" separator="," close=")">
|
|
#{rateId}
|
|
</foreach>
|
|
</update>
|
|
|
|
</mapper>
|