public ActionResult ClearingInvestment(string investmentGuid, string endTime, double gains, string accountingTime)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.AssertHasContent(investmentGuid, "Investment guid不能为空");
                CommUtils.AssertHasContent(endTime, "[到期时间]不能为空");
                CommUtils.AssertHasContent(accountingTime, "[到账时间]不能为空");
                CommUtils.Assert(gains <= 1000000000000, "[收益金额]不能大于10,000亿元");
                CommUtils.Assert(gains >= -1000000000000, "[收益金额]不能小于-10,000亿元");

                var valEndTime = DateTime.Parse(endTime);
                var valAccountingTime = DateTime.Parse(accountingTime);
                CommUtils.Assert(DateTime.Compare(valAccountingTime, valEndTime) >= 0, "[到账时间]不能小于[到期时间]");

                var investment = m_dbAdapter.Investment.GetInvestment(investmentGuid);
                CommUtils.Assert(DateTime.Compare(valEndTime, investment.StartTime) > 0, "[到期时间]必须大于[开始时间]");
                CommUtils.Assert(!(gains <0 && System.Math.Abs(gains)> investment.Money), "[收益金额]不能亏损超过[投资金额]");

                investment.Gains = gains;
                investment.EndTime = valEndTime;
                investment.AccountingTime = valAccountingTime;
                investment.Yield = InterestRateUtils.CalculateYield(investment.Gains.Value, investment.Money, investment.EndTime, investment.StartTime);
                var result = m_dbAdapter.Investment.UpdateInvestment(investment);

                return ActionUtils.Success(result);
            }));
        }
        public ActionResult ModifyInvestment(string investmentGuid, string name, string description,
                                             double money, string yieldDue, double?gains, string startTime, string endTime, string accountingTime)
        {
            return(ActionUtils.Json(() =>
            {
                ValidateUtils.Name(name, "投资标的");
                CommUtils.AssertHasContent(startTime, "[开始时间]不能为空");
                CommUtils.AssertHasContent(endTime, "[到期时间]不能为空");
                CommUtils.Assert(money <= 1000000000000, "[投资金额]不能大于10,000亿元");
                CommUtils.Assert(money > 0, "[投资金额]必须大于0元");

                var valStartTime = DateTime.Parse(startTime);
                var valEndTime = DateTime.Parse(endTime);
                CommUtils.Assert(DateTime.Compare(valEndTime, valStartTime) > 0, "[到期时间]必须大于[开始时间]");

                var investment = m_dbAdapter.Investment.GetInvestment(investmentGuid);
                investment.Name = name;
                investment.Description = description;
                investment.Money = money;
                investment.StartTime = valStartTime;
                investment.EndTime = valEndTime;
                investment.YieldDue = null;

                if (investment.Gains.HasValue)
                {
                    CommUtils.AssertNotNull(gains, "[收益金额]不能为空");
                    CommUtils.AssertHasContent(accountingTime, "[到账时间]不能为空");
                    CommUtils.Assert(gains <= 1000000000000, "[收益金额]不能大于10,000亿元");
                    CommUtils.Assert(gains >= -1000000000000, "[收益金额]不能小于-10,000亿元");
                    CommUtils.Assert(!(gains <0 && System.Math.Abs(gains.Value)> investment.Money), "[收益金额]不能亏损超过[投资金额]");

                    var valAccountingTime = DateTime.Parse(accountingTime);
                    CommUtils.Assert(DateTime.Compare(valAccountingTime, valEndTime) >= 0, "[到账时间]不能小于[到期时间]");

                    investment.AccountingTime = valAccountingTime;
                    investment.Gains = gains;
                    investment.Yield = InterestRateUtils.CalculateYield(investment.Gains.Value, investment.Money, investment.EndTime, investment.StartTime);
                }

                if (!string.IsNullOrWhiteSpace(yieldDue) && yieldDue != "-")
                {
                    var percentValue = 0.0;
                    if (yieldDue.Contains('%'))
                    {
                        CommUtils.Assert(double.TryParse(yieldDue.Substring(0, yieldDue.Length - 1), out percentValue), "预计收益率必须为数字");
                    }
                    else
                    {
                        CommUtils.Assert(double.TryParse(yieldDue, out percentValue), "预计收益率必须为数字");
                    }
                    CommUtils.Assert(percentValue >= 365.00 * (-1) / (valEndTime - valStartTime).TotalDays, "预计收益率过低,请重新填写");
                    investment.YieldDue = percentValue / 100;
                }

                var result = m_dbAdapter.Investment.UpdateInvestment(investment);
                return ActionUtils.Success(result);
            }));
        }