otc-stock-real-mapper.xml
3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?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>