fundreal-mapper.xml 2.49 KB
<?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">

<!-- 客户资金查询 @author 仝玉甫 -->
<mapper namespace="com.cjs.site.dao.user.fund.FundRealDao">

	<!-- 查询指定客户资金 -->
	<select id="queryByUserId" parameterType="string" resultType="map">
		SELECT F.FUND_ACCOUNT, F.CURRENT_BALANCE, F.ENABLE_BALANCE, 
			F.CASH_BALANCE, F.FROZEN_BALANCE, F.UNFROZEN_BALANCE
		FROM HS_FUND.FUNDREAL F
		WHERE F.FUND_ACCOUNT = #{value}
	</select>
	
	<!-- 查询资金流水 -->
	<select id="queryFundRecord" parameterType="map" resultType="map">
		<include refid="common.pageStart" />
		SELECT A.FUND_ACCOUNT,A.BUSINESS_FLAG,A.OCCUR_BALANCE,A.POST_BALANCE,A.INIT_DATE,A.CURR_TIME,A.REMARK 
		FROM 
		(SELECT T.FUND_ACCOUNT,T.BUSINESS_FLAG,T.OCCUR_BALANCE,T.POST_BALANCE,
		T.INIT_DATE,T.CURR_TIME,T.REMARK FROM HS_ASSET.FUNDJOUR T 
		UNION 
		SELECT R.FUND_ACCOUNT,R.BUSINESS_FLAG,R.OCCUR_BALANCE,R.POST_BALANCE,
		R.INIT_DATE,R.CURR_TIME,R.REMARK FROM HS_HIS.HIS_FUNDJOUR R) A 
		WHERE A.INIT_DATE BETWEEN #{start_date} AND #{end_date} 
		AND A.FUND_ACCOUNT = #{fundAccount} 
		<if test="en_business_flag != null and en_business_flag != ''">
		AND A.BUSINESS_FLAG = #{en_business_flag} 
		</if>
		<if test="remark != null and remark != ''">
			AND INSTR(remark, #{remark}) > 0 
		</if>
		ORDER BY A.INIT_DATE,A.CURR_TIME DESC 
		<include refid="common.pageEnd" />
	</select>
	
	<select id="queryFundRecordTotal" parameterType="map" resultType="int">
		SELECT COUNT(1) FROM 
		(SELECT T.FUND_ACCOUNT,T.BUSINESS_FLAG,T.OCCUR_BALANCE,T.POST_BALANCE,
		T.INIT_DATE,T.CURR_TIME,T.REMARK FROM HS_ASSET.FUNDJOUR T 
		UNION 
		SELECT R.FUND_ACCOUNT,R.BUSINESS_FLAG,R.OCCUR_BALANCE,R.POST_BALANCE,
		R.INIT_DATE,R.CURR_TIME,R.REMARK FROM HS_HIS.HIS_FUNDJOUR R) A 
		WHERE A.INIT_DATE BETWEEN #{start_date} AND #{end_date} 
		AND A.FUND_ACCOUNT = #{fundAccount} 
		<if test="en_business_flag != null and en_business_flag != ''">
		AND A.BUSINESS_FLAG = #{en_business_flag} 
		</if>
		<if test="remark != null and remark != ''">
			AND INSTR(remark, #{remark}) > 0 
		</if>
	</select>
	
		
	<select id="getUserBalance" resultType="java.util.HashMap">
		select current_balance  from hs_fund.fundreal a where a.client_id =#{userId}
	</select>
	
	<update id="freezeAmount">
		update  hs_fund.fundreal set current_balance =current_balance-#{amount},enable_balance=enable_balance-#{amount} ,frozen_balance=#{amount} where client_id = #{userId}
	</update>
</mapper>