记录网上交易各种SQL语句
<!-- 根据基金账号列表获得最早的投资时间,返回格式是yyyyMMdd,查不到则返回空字符串 -->
<select id="selectHeadMostApdt" resultType="String">
<![CDATA[
SELECT MIN(apdt)
FROM (SELECT t.apdt AS apdt
FROM h_s_acktradeblotter t
WHERE t.retcode = '0000'
AND t.fundacct IN (${fundAcctStrs})
UNION
SELECT to_char(t.apdt, 'yyyymmdd') AS apdt
FROM zd_h_acktradeblotter t
WHERE t.retcode = '0000'
AND t.fundacct IN (${fundAcctStrs}))
]]>
</select>
<!-- 判断指定的日期是不是工作日 -->
<select id="isHoliday" resultType="int">
<![CDATA[
SELECT COUNT(0) as cou
FROM holidays t
WHERE t.hodt = to_date(#{dateStr}, 'yyyy/mm/dd')
]]>
</select>
<!-- 按页查询现金宝每日收益 -->
<select id="selectCashboxDailyIncomeByPage" resultMap="cashboxIncomeMap">
<![CDATA[
SELECT dtstr,
nvl(SUM(accinc), 0) AS accinc,
nvl(SUM(t.income), 0) - nvl(SUM(t.sumreductincome), 0) AS income
FROM V_H_ACCDAILYINC t
WHERE t.FUNDID = #{fundCode}
AND t.DTSTR BETWEEN #{startDate} AND #{endDate}
AND (t.seatno, t.realcustno) IN (${seatNoAndCustNoStrs})
AND t.dtstr <= (SELECT nvl(MAX(workdate), t.dtstr)
FROM fund_sales_dev.clearcheckpoint
WHERE transcd = 'SYJZ'
AND retcode = '0000')
GROUP BY dtstr
ORDER BY dtstr DESC
]]>
</select>
<!-- 按页查询现金宝每日收益 -->
<select id="selectCashboxDailyIncomeByPage" resultMap="cashboxIncomeMap">
<![CDATA[
SELECT dtstr,
nvl(SUM(accinc), 0) AS accinc,
nvl(SUM(t.income), 0) - nvl(SUM(t.sumreductincome), 0) AS income
FROM V_H_ACCDAILYINC t
WHERE t.FUNDID = #{fundCode}
AND t.DTSTR BETWEEN #{startDate} AND #{endDate}
AND (t.seatno, t.realcustno) IN (${seatNoAndCustNoStrs})
AND t.dtstr <= (SELECT nvl(MAX(workdate), t.dtstr)
FROM fund_sales_dev.clearcheckpoint
WHERE transcd = 'SYJZ'
AND retcode = '0000')
GROUP BY dtstr
ORDER BY dtstr DESC
]]>
</select>
<!-- 按时间查询现金宝总收益 -->
<select id="selectCashboxTotalIncome" resultType="String">
<![CDATA[
SELECT nvl(SUM(t.income), 0) - nvl(SUM(t.sumreductincome), 0)
FROM V_H_ACCDAILYINC t
WHERE t.FUNDID = #{fundCode}
AND (t.seatno, t.realcustno) IN (${seatNoAndCustNoStrs})
AND t.dtstr <= (SELECT nvl(MAX(workdate), t.dtstr)
FROM fund_sales_dev.clearcheckpoint
WHERE transcd = 'SYJZ'
AND retcode = '0000')
]]>
<if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
AND t.DTSTR BETWEEN #{startDate} AND #{endDate}
</if>
</select>