kamal
2019-03-11 10:42:45 +08:00
SELECT
b.secu_id AS f_secu_id,
b.fund_code AS trd_code,
b.fundfullname AS chi_name,
b.fundname AS secu_sht,
b.companyid AS fmc_com_id,
b.companyname AS fmc_com_name,
b.f_info_custodianbank AS cust_com_name,
IF (
f_pchredm_pchstartdate IS NULL
OR f_pchredm_pchstartdate > Date_format(Now(), '%Y%m%d')
OR Locate('633001001', pur_st_temp) > 0,
'暂停申购',
IF(
Locate('633001002', pur_st_temp) > 0,
'暂停大额申购',
IF(
Locate('633001003', pur_st_temp) > 0,
'暂停定期定额申购',
IF(
Locate('633001004', pur_st_temp) > 0,
'暂停大额定期定额申购',
'开放申购'
)
)
)
) AS pur_st,
IF (
f_info_redmstartdate IS NULL
OR f_info_redmstartdate > Date_format(Now(), '%Y%m%d')
OR Locate('633001005', redem_st_temp) > 0,
'暂停赎回',
IF(
Locate('633001006', pur_st_temp) > 0,
'暂停实时赎回',
'开放赎回'
)
) AS redem_st,
b.isqdii AS is_qdii,
b.fundtype AS inv_typ_com,
(
CASE
b.fundtype
WHEN '10100' THEN '股票型'
WHEN '10200' THEN '债券型'
WHEN '10300' THEN '货币型'
WHEN '10400' THEN '混合型'
WHEN '10600' THEN 'FOF'
WHEN '10700' THEN '保本型'
WHEN '10800' THEN '理财型'
WHEN '10901' THEN 'QDII'
WHEN '10905' THEN '指数型'
ELSE '专户'
end
) AS inv_typ_com_desc,
Date_format(c.trade_dt, '%Y-%m-%d') AS trd_dt,
nav.f_nav_unit AS unit_nav,
c.f_avgreturn_day AS chg_rat_1d,
c.f_avgreturn_week AS chg_rat_1w,
c.f_avgreturn_month AS chg_rat_1m,
c.f_avgreturn_quarter AS chg_rat_3m,
c.f_avgreturn_halfyear AS chg_rat_6m,
c.f_avgreturn_year AS chg_rat_1y,
c.f_avgreturn_twoyea AS chg_rat_2y,
c.f_avgreturn_threeyear AS chg_rat_3y,
c.f_avgreturn_fiveyear AS chg_rat_5y,
'' AS chg_rat_10y,
c.f_avgreturn_sincefound AS chg_rat_bgn,
c.f_sfrank_day AS chg_rat_1d_rk,
c.f_sfrank_recentweek AS chg_rat_1w_rk,
c.f_sfrank_recentmonth AS chg_rat_1m_rk,
c.f_sfrank_recentquarter AS chg_rat_3m_rk,
c.f_sfrank_recenthalfyear AS chg_rat_6m_rk,
c.f_sfrank_recentyear AS chg_rat_1y_rk,
c.f_sfrank_recenttwoyear AS chg_rat_2y_rk,
c.f_sfrank_recentthreeyear AS chg_rat_3y_rk,
c.f_sfrank_recentfiveyear AS chg_rat_5y_rk,
'' AS chg_rat_10y_rk,
c.f_sfrank_sincefound AS chg_rat_bgn_rk,
d.f_income_per_million AS unit_yld,
d.f_info_yearlyroe AS ann_yld_rat
FROM
(
SELECT
base.*,
redm.pur_st_temp,
redm.redem_st_temp
FROM
(
SELECT
CASE
wb.fundtype
WHEN '10901' THEN '1'
ELSE '0'
end AS isqdii,
f_info_custodianbank,
f_pchredm_pchstartdate,
f_info_redmstartdate,
wb.companyid,
wb.companyname,
wb.fundfullname,
wb.fundname,
wb.fundtype,
wb.fund_code,
wb.secu_id
FROM
wb_fundinfo wb,
wind_db.chinamutualfunddescription cmfd
WHERE
cmfd.f_info_windcode = wb.secu_id
) base
LEFT JOIN (
SELECT
s_info_windcode,
Group_concat(DISTINCT f_info_suspchtype) AS pur_st_temp,
Group_concat(DISTINCT f_info_suspchtype) AS redem_st_temp
FROM
wind_db.chinamutualfundsuspendpchredm
WHERE
s_info_windcode = #{trdcode}
AND (
(
f_info_suspchstartdt <= date_format(now(), '%Y%m%d')
AND f_info_repchdt IS NULL
)
OR (
f_info_suspchstartdt <= date_format(now(), '%Y%m%d')
AND f_info_repchdt > date_format(now(), '%Y%m%d')
)
)
GROUP BY
s_info_windcode
) redm ON base.secu_id = redm.s_info_windcode
) b
LEFT JOIN wind_db.chinamfperformance_new c ON b.secu_id = c.s_info_windcode
LEFT JOIN (
SELECT
f_nav_unit,
f_info_windcode,
ann_date,
price_date
FROM
wind_db.chinamutualfundnav_new cmfnav
) nav ON b.secu_id = nav.f_info_windcode
LEFT JOIN wind_db.cmoneymarketdailyfincome d ON b.secu_id = d.s_info_windcode
AND d.f_info_enddate = nav.price_date
WHERE
b.fund_code = #{trdcode}