using MMoneyCoderSharp.Data.Request;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static MMoneyCoderSharp.DBDefine;

namespace MMoneyCoderSharp.DB
{
    /// <summary>
    /// </summary>
    internal class Stick12 : ADataObject
    {
     

        public Stick12(국내시장종류 recvMarketType)
        {
            this.mMarketType = recvMarketType;
        }

        private 국내시장종류 mMarketType;

        /// <summary>
        /// 금일 데이터 쿼리
        /// </summary>
         string queryKOSPI = @"select 
                decode(f_invest_code,'8000','개인','9000','외국인','9001','외국인','기관') invest_name, 
                round((sum(F_SELL_turnover) - sum(F_BUY_turnover)) / 100000000)  amt 
            from t_invest 
            where F_PART_CODE = '001' 
                and F_INVEST_CODE in('1000', '2000', '3000', '3100', '4000', '5000', '6000', '7000', '8000', '9000', '9001') 
            group by decode(f_invest_code, '8000', '개인', '9000', '외국인', '9001', '외국인', '기관')";


        string queryKOSDAQ = @"select 
                decode(f_invest_code,'8000','개인','9000','외국인','9001','외국인','기관') invest_name, 
                round((sum(F_SELL_turnover) - sum(F_BUY_turnover)) / 100000000)  amt 
            from t_kosdaq_invest 
            where F_PART_CODE = '001' 
                and F_INVEST_CODE in('1000', '2000', '3000', '3100', '4000', '5000', '6000', '7000', '8000', '9000', '9001') 
            group by decode(f_invest_code, '8000', '개인', '9000', '외국인', '9001', '외국인', '기관')";

        public override IDataRequest buildData()
        {

            string bufQuery = "";

            switch (this.mMarketType)
            {
                case 국내시장종류.KOSPI:
                    bufQuery = queryKOSPI;
                    break;
                case 국내시장종류.KOSDAQ:
                    bufQuery = queryKOSDAQ;
                    break;
            }

            mRequestQuery.Add("", bufQuery);

            return this;
        }
    }
}
