Ejemplo n.º 1
0
 public bool CreateTrade(FinanceTradeDetail entity)
 {
     try
     {
         financeTradeDetailRepository.Insert(entity);
         return(true);
     }
     catch (Exception ex) {
         Logger.Error(ex.Message);
         return(false);
     }
 }
Ejemplo n.º 2
0
        public async Task <bool> CreateTradeForOrderAsync(decimal amount, string orderNo)
        {
            try {
                FinanceTradeDetail entity = new FinanceTradeDetail();
                entity.Amount           = amount;
                entity.FinanceAccountId = AbpSession.GetFinanceAccountId();
                entity.RefNo            = orderNo;
                entity.SerialNo         = GenerateTradeNo(TradeType.XF);
                entity.UserId           = AbpSession.GetUserId();
                await financeTradeDetailRepository.InsertAsync(entity);

                return(true);
            } catch (Exception ex) {
                Logger.Error(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 3
0
        private bool OperTrade(RechargeInput input, TradeType tradeTyppe)
        {
            var account = _financeAccount.FirstOrDefault(m => m.UserId == input.userId);

            if (account != null)
            {
                if (input.Amount < 0 && account.Blance + input.Amount < 0)
                {
                    throw new UserFriendlyException("账户余额不足, 扣款失败");
                }

                account.Blance = account.Blance + input.Amount;

                FinanceTradeDetail entity = new FinanceTradeDetail();
                entity.UserId           = input.userId;
                entity.Amount           = input.Amount;
                entity.FinanceAccountId = account.Id;
                entity.TradeType        = tradeTyppe.ToString();
                entity.SerialNo         = _tradeManager.GenerateTradeNo(tradeTyppe);
                return(_tradeManager.CreateTrade(entity));
            }
            throw new UserFriendlyException("未找到此账户");
        }