otc-stock-real-mapper.xml 3.46 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 tongxiaochuan -->
<mapper namespace="com.cjs.cms.dao.quota.OtcStockRealDao">

	<select id="queryList" resultType="OtcStockRealInfo"
		parameterType="String">
		select otc_code, fund_account, enable_amount
		from HS_OTC.OTCSTOCKREAL_VIEW 
		where otc_code = #{otcCode}
	</select>

	<select id="queryRealInfo" parameterType="map" resultType="OtcStockRealInfo">
		select otc_code, fund_account, enable_amount
		from HS_OTC.OTCSTOCKREAL_VIEW where otc_code = #{otcCode} 
		and fund_account = #{userId}
	</select>

	<select id="search" resultType="OtcStockRealInfo"
		parameterType="String">
		select otc_code, otc_name, fund_account, enable_amount
		from
		HS_OTC.OTCSTOCKREAL_VIEW where otc_code = #{otcCode} and enable_amount > 0
	</select>
	
	<!-- 根据代码查询持仓 -->
<!-- 	<sql id="searchByCodesSql"> -->
<!-- 	select otc_code, otc_name, fund_account, -->
<!-- 	enable_amount,b.client_name,b.mobile_tel -->
<!-- 	from -->
<!-- 	HS_OTC.OTCSTOCKREAL_VIEW a ,(select c.client_name,d.mobile_tel,c.client_id from HS_ASSET.Client -->
<!-- 	c, -->
<!-- 	HS_ASSET.Clientinfo d where c.client_id=d.client_id(+) -->
<!-- 	)b where a.FUND_ACCOUNT=b.client_id(+) -->

<!-- 	and enable_amount > 0 -->
<!-- 	and a.otc_code in  -->
<!-- 			<foreach collection="otcCodes" item="otcCode" open="(" close=")" -->
<!-- 			separator=","> #{otcCode} </foreach> -->
<!-- 	</sql> -->
<!-- 	<select id="searchByCodes" resultType="map" parameterType="map">  -->
<!-- 		<include refid="common.pageStart" /> -->
<!-- 		<include refid="searchByCodesSql" /> -->
<!-- 		<include refid="common.pageEnd" /> -->
<!-- 	</select> -->
	
<!-- 	<select id="searchByCodeTotal" resultType="java.lang.Integer" parameterType="map"> -->
<!-- 		select count(1) from (<include refid="searchByCodesSql" />) -->
<!-- 	</select> -->
	<!-- 查询没有同意邀约的用户 -->
	<select id="searchAgreeNoUser" resultType="java.lang.String" parameterType="map"> 
		select  fund_account from HS_OTC.OTCSTOCKREAL_VIEW a
		where  otc_code=#{otcCode}
		and fund_account not  in 
		<foreach collection="fundAccounts" item="fundAccount" open="(" close=")" 
			separator=","> #{fundAccount} </foreach>
	</select>
	
	<!-- 用户当前持仓 -->
	<select id="searchCurrentStock" resultType="map">
		SELECT FUND_ACCOUNT,OTC_CODE,ENABLE_AMOUNT FROM HS_OTC.OTCSTOCKREAL_VIEW
	</select>
	
	<!-- 统计用户当前所有持仓(包括委托未卖出的) -->
	<select id="queryUserAmount" parameterType="string" resultType="OtcStockRealInfo">
		SELECT T.OTC_CODE, T.FUND_ACCOUNT, T.ENABLE_AMOUNT + T.ENTRUST_SELL_AMOUNT - T.REAL_SELL_AMOUNT TOTALAMOUNT 
		FROM HS_OTC.OTCSTOCKREAL T 
		WHERE T.OTC_CODE = #{otcCode}
	</select>
	
	<!-- 查询指定用户的指定藏品的持仓(可用+委托尚未卖出) -->
	<select id="queryUserRealAmount" parameterType="string" resultType="OtcStockRealInfo">
		SELECT T.OTC_CODE, T.FUND_ACCOUNT, T.ENABLE_AMOUNT TOTALAMOUNT 
		FROM HS_OTC.OTCSTOCKREAL T 
		WHERE T.OTC_CODE = #{otcCode} AND T.FUND_ACCOUNT = #{fundAccount}
	</select>
	
	<update id="updateSumBuyBalance" parameterType="map">
		UPDATE HS_OTC.OTCSTOCKREAL SET SUM_BUY_BALANCE = SUM_BUY_BALANCE - #{mixBalance} 
		<if test="sumBuyAmount != null and sumBuyAmount != ''">
			, SUM_BUY_AMOUNT = SUM_BUY_AMOUNT + #{sumBuyAmount} 
		</if>
		WHERE OTC_CODE = #{otcCode} AND FUND_ACCOUNT = #{userId}
	</update>
</mapper>