/// <summary>
        /// 冻结交易取消
        /// </summary>
        /// <param name="sourceTradeType">原始订单交易类型</param>
        /// <param name="targetTradeType">目标订单交易类型</param>
        /// <param name="orderId"></param>
        internal void TradeFrozeCancel(OrderTradeType sourceTradeType, OrderTradeType targetTradeType, long orderId, string remark)
        {
            lock (LocalThreadLock.GetLockKeyName(LockKeyNames.LOCK_WALLET, this._studentId.ToString()))
            {
                TblCashWalletForzenDetail detail = this.ProcessFrozeBalanceComplete(sourceTradeType, orderId, BalanceFrozeStatus.Cancel);

                decimal transAmount = detail.Amount * (-1);

                //2、增加交易记录
                TblCashWallet tblCashWallet   = this.TblCashWallet;
                decimal       transBefBalance = tblCashWallet.Balance + transAmount; //交易前余额,同下
                decimal       transAftBalance = tblCashWallet.Balance;               //交易后余额,冻结交易,余额早已扣除,所以该余额即交易后余额
                //余额交易明细
                TblCashWalletTrade walletTrade = new TblCashWalletTrade()
                {
                    WalletTradeId   = IdGenerator.NextId(),
                    OrderId         = orderId,
                    StudentId       = this._studentId,
                    SchoolId        = this._schoolId,
                    TradeType       = (int)targetTradeType,
                    TransBefBalance = transBefBalance,
                    TransAftBalance = transAftBalance,
                    TransAmount     = transAmount,
                    TransDate       = DateTime.Now,
                    Remark          = remark
                };
                //写入数据
                _walletTradeRepository.Value.Add(walletTrade);
            }
        }
        /// <summary>
        /// 钱包交易金额冻结
        /// </summary>
        /// <param name="transType"></param>
        /// <param name="transAmount"></param>
        /// <param name="unitOfWork">事务工作单元</param>
        internal void TradeFroze(OrderTradeType transType, long orderId, decimal transAmount, string remark)
        {
            if (transAmount == 0)
            {
                return;
            }
            //TODO 以后应用分布式锁
            lock (LocalThreadLock.GetLockKeyName(LockKeyNames.LOCK_WALLET, this._studentId.ToString()))
            {
                //1、钱包余额冻结金额
                TblCashWallet tblCashWallet   = this.TblCashWallet;
                decimal       transBefBalance = tblCashWallet.Balance;               //交易前余额
                decimal       transAftBalance = tblCashWallet.Balance + transAmount; //交易后余额
                tblCashWallet.Balance      = transAftBalance;
                tblCashWallet.FrozenAmount = transAmount;
                tblCashWallet.UpdateTime   = DateTime.Now;

                //2、冻结明细记录
                TblCashWalletForzenDetail detail = new TblCashWalletForzenDetail()
                {
                    BusinessId           = orderId,
                    BusinessType         = (int)transType,
                    SchoolId             = this._schoolId,
                    Status               = 1,
                    Amount               = transAmount,
                    StudentId            = this._studentId,
                    WalletForzenDetailId = IdGenerator.NextId(),
                    CreateTime           = DateTime.Now
                };

                //3、余额交易明细
                TblCashWalletTrade walletTrade = new TblCashWalletTrade()
                {
                    WalletTradeId   = IdGenerator.NextId(),
                    OrderId         = orderId,
                    StudentId       = this._studentId,
                    SchoolId        = this._schoolId,
                    TradeType       = (int)transType,
                    TransBefBalance = transBefBalance,
                    TransAftBalance = transAftBalance,
                    TransAmount     = transAmount,
                    TransDate       = DateTime.Now,
                    Remark          = remark
                };

                //4、写入数据

                _walletTradeRepository.Value.Add(walletTrade);
                _repository.Value.Update(tblCashWallet);  //更新用户钱包余额
                _forzenRepository.Value.Add(detail);      //写入冻结明细
            }
        }
        /// <summary>
        /// 余额交易
        /// 余额交易分两种
        /// </summary>
        /// <param name="transType">交易类型</param>
        /// <param name="transAmount">交易的金额</param>
        public void Trade(OrderTradeType transType, long orderId, decimal transAmount, string remark)
        {
            if (transAmount == 0)
            {
                return;
            }

            //TODO 以后应用分布式锁
            lock (LocalThreadLock.GetLockKeyName(LockKeyNames.LOCK_WALLET, this._studentId.ToString()))
            {
                //钱包汇总
                TblCashWallet tblCashWallet   = this.TblCashWallet;
                decimal       transBefBalance = tblCashWallet.Balance;               //交易前余额
                decimal       transAftBalance = tblCashWallet.Balance + transAmount; //交易后余额
                tblCashWallet.Balance    = transAftBalance;
                tblCashWallet.UpdateTime = DateTime.Now;


                //余额交易明细
                TblCashWalletTrade walletTrade = new TblCashWalletTrade()
                {
                    WalletTradeId   = IdGenerator.NextId(),
                    OrderId         = orderId,
                    StudentId       = this._studentId,
                    SchoolId        = this._schoolId,
                    TradeType       = (int)transType,
                    TransBefBalance = transBefBalance,
                    TransAftBalance = transAftBalance,
                    TransAmount     = transAmount,
                    TransDate       = DateTime.Now,
                    Remark          = remark
                };
                //写入数据
                _walletTradeRepository.Value.Add(walletTrade);
                _repository.Value.Update(tblCashWallet);
            }
        }