public ActionResult Edit(OrderAmountType obj)
        {

            try
            {
                NSession.Update(obj);
                NSession.Flush();
            }
            catch (Exception ee)
            {
                return Json(new { errorMsg = "出错了" });
            }
            return Json(new { IsSuccess = "true" });

        }
        public static void SaveAmount(OrderType order, List<CurrencyType> currencys, ISession NSession)
        {
            NSession.Delete("from OrderAmountType where OId=" + order.Id);
            NSession.Flush();
            CurrencyType currency = currencys.Find(p => p.CurrencyCode.ToUpper() == order.CurrencyCode.ToUpper());

            if (order.Status == "待处理")
                order.Status = OrderStatusEnum.已处理.ToString();
            order.RMB = Math.Round(Convert.ToDouble(currency.CurrencyValue) * order.Amount, 4);
            OrderAmountType orderAmount = new OrderAmountType();
            orderAmount.Account = order.Account;
            orderAmount.OrderNo = order.OrderNo;
            orderAmount.OrderExNo = order.OrderExNo;
            orderAmount.OrderAmount = order.Amount;
            orderAmount.OId = order.Id;
            order.MId = order.MId;
            orderAmount.IsRepeat = order.IsRepeat;
            orderAmount.IsSplit = order.IsSplit;
            orderAmount.ExchangeRate = Convert.ToDouble(currency.CurrencyValue);
            //总成本确认
            object obj = NSession.CreateSQLQuery(
                "select SUM(OP.Qty*p.Price) from OrderProducts OP left join Products  P On OP.SKU=p.SKU where OId=" + order.Id).
                UniqueResult();
            orderAmount.TotalCosts = Convert.ToDouble(obj);

            IList<AccountFeeType> list = NSession.CreateQuery(string.Format("from AccountFeeType where AccountId in (select Id from AccountType where AccountName='{0}' ) and AmountBegin<={1} and AmountEnd>{1} ", order.Account, order.Amount)).List<AccountFeeType>();

            foreach (var feeType in list)
            {

                object d = new DataTable().Compute(feeType.FeeFormula.Replace("T", order.Amount.ToString()), "");
                if (feeType.FeeName == "交易费")
                {
                    if (order.OrderFees > 0)
                    {
                        orderAmount.TransactionFees = order.OrderFees;
                    }
                    else
                    {
                        orderAmount.TransactionFees = Convert.ToDouble(d);
                    }

                }
                if (feeType.FeeName == "手续费")
                {
                    orderAmount.Fee = Convert.ToDouble(d);
                }
                if (feeType.FeeName == "其他费")
                {
                    orderAmount.OtherFees = Convert.ToDouble(d);
                }
            }
            orderAmount.CreateOn = order.CreateOn;
            orderAmount.ScanningOn = order.ScanningOn;
            orderAmount.CurrencyCode = order.CurrencyCode;
            orderAmount.UpdateOn = DateTime.Now;

            orderAmount.Platform = order.Platform;
            orderAmount.Country = order.Country;
            orderAmount.RMB = order.RMB;
            orderAmount.Profit = Math.Round(order.RMB - orderAmount.TotalCosts - orderAmount.OtherFees * Convert.ToDouble(currency.CurrencyValue) - orderAmount.Fee * Convert.ToDouble(currency.CurrencyValue) -
                                 orderAmount.TransactionFees * Convert.ToDouble(currency.CurrencyValue), 5);
            NSession.Save(orderAmount);
            NSession.Flush();
            if (orderAmount.IsRepeat == 1 && orderAmount.MId != 0)
            {
                NSession.CreateQuery("update OrderAmountType set SplitCount=SplitCount+1 where OId=" + orderAmount.MId).ExecuteUpdate();
                NSession.Flush();
            }
            if (orderAmount.IsSplit == 1 && orderAmount.MId != 0)
            {
                NSession.CreateQuery("update OrderAmountType set AgainCount=AgainCount+1 where OId=" + orderAmount.MId).ExecuteUpdate();
                NSession.Flush();
            }
            UpdateAmount(order, NSession);
        }