汇率管理
This commit is contained in:
@@ -37,6 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<!-- 账户余额/外币余额统一取 customer_account 余额表(CNY 为本币,其余为外币),不取 bms_customer 冗余列 -->
|
||||
<!-- 信用额度=总额度+额外额度-已用额度-->
|
||||
<sql id="selectBmsCustomerVo">
|
||||
select c.customer_id, c.customer_code, c.customer_name, c.customer_code_dw, c.credit_code, c.customer_type,
|
||||
c.is_enable, c.sales_user_id, c.sales_user, c.ed, c.zq, c.settlement_user_id, c.settlement_user,
|
||||
@@ -45,7 +46,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where ca.customer_id = c.customer_id and ca.currency = 'CNY' and ca.del_flag = '0') as account_balance,
|
||||
(select coalesce(sum(ca.balance), 0) from customer_account ca
|
||||
where ca.customer_id = c.customer_id and ca.currency != 'CNY' and ca.del_flag = '0') as foreign_currency_balance,
|
||||
c.weight_threshold, c.throw_ratio, c.credit_ed, c.product_ids, c.remark,
|
||||
c.weight_threshold, c.throw_ratio,
|
||||
|
||||
(select coalesce(sum(ca.total_credit+ca.extra_credit-ca.used_credit), 0) from customer_account ca
|
||||
where ca.customer_id = c.customer_id and ca.del_flag = '0') as credit_ed,
|
||||
|
||||
c.product_ids, c.remark,
|
||||
c.create_by, c.create_time, c.update_by, c.update_time, c.del_flag
|
||||
from bms_customer c
|
||||
</sql>
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?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.ruoyi.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>
|
||||
Reference in New Issue
Block a user