Esempio n. 1
0
        public override object Do(object obj)
        {
            GetRate bpObj = (GetRate)obj;
            decimal rate  = 0;

            if (bpObj != null)
            {
                rate = GetRates(bpObj);
            }
            return(rate);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取汇率
        /// </summary>
        /// <param name="bpObj"></param>
        /// <returns></returns>
        public Decimal GetRates(GetRate bpObj)
        {
            Decimal rate = 0;

            //原币种,目标币种,汇率类型=买入,已编译=true,开始时间大于等于当前时间,结束时间小于等于当前时间
            ExchangeRateDef.EntityList RateEntityList = ExchangeRateDef.Finder.FindAll("ExchangeRateTable.FromCurrency=@FromCurrency and ExchangeRateTable.ToCurrency=@ToCurrency and ExchangeRateTable.ExchangeRateType=@ExchangeRateType and ExchangeRateTable.Compiled=1 and  FromDate<=@FromDate and ToDate>=@ToDate", new OqlParam(bpObj.OldCurrency), new OqlParam(bpObj.NewCurrency), new OqlParam(UFIDA.U9.Base.Currency.ExchangeRateTypesEnum.Buy.Value), new OqlParam(DateTime.Now.ToString()), new OqlParam(DateTime.Now.ToString()));
            if (RateEntityList.Count > 0)//
            {
                rate = RateEntityList[0].Rate;
            }
            else
            {
                ExchangeRateDef.EntityList RateEntity = ExchangeRateDef.Finder.FindAll("ExchangeRateTable.FromCurrency=@FromCurrency and ExchangeRateTable.ToCurrency=@ToCurrency and ExchangeRateTable.ExchangeRateType=@ExchangeRateType and ExchangeRateTable.Compiled=1  order by FromDate desc", new OqlParam(bpObj.OldCurrency), new OqlParam(bpObj.NewCurrency), new OqlParam(UFIDA.U9.Base.Currency.ExchangeRateTypesEnum.Buy.Value));
                if (RateEntity.Count > 0)
                {
                    //取最近的汇率=》第一条
                    rate = RateEntity[0].Rate;
                }
            }
            return(rate);
        }