public ActionResult Withdraw() { var model = new UserWithdrawViewModel(); model.User = CurrentUser; model.Withdraws = ur.GetWithdrawHistoryByUser(CurrentUser.Id); return(View(model)); }
public ActionResult Withdraw(UserWithdraw withdraw, string mcode) { if (!new SmsRepository().CheckSms(CurrentUser.Phone, mcode, "WITHDRAW")) { ModelState.AddModelError("Withdraw", "请确认短信验证码"); var model = new UserWithdrawViewModel(); model.User = CurrentUser; model.Withdraws = ur.GetWithdrawHistoryByUser(CurrentUser.Id); return(View(model)); } decimal chargeFee = 0M; if (withdraw.Amount >= 100 && withdraw.Amount < 200) { chargeFee = withdraw.Amount * 0.03M; } else if (withdraw.Amount >= 200 && withdraw.Amount < 500) { chargeFee = withdraw.Amount * 0.029M; } else if (withdraw.Amount >= 500 && withdraw.Amount < 1000) { chargeFee = withdraw.Amount * 0.025M; } else if (withdraw.Amount >= 1000) { chargeFee = withdraw.Amount * 0.02M; } withdraw.ChargeFee = chargeFee; withdraw.UserId = CurrentUser.Id; withdraw.Status = 0; withdraw.CreateTime = DateTime.Now; var bank = ur.GetBankAccount(CurrentUser.Id); if (bank != null) { withdraw.Bank = bank.Bank; withdraw.AccountName = bank.AccountName; withdraw.AccountNum = bank.AccountNum; new UserWithdrawRepository().Create(withdraw); var score = new UserScore { UserId = CurrentUser.Id, TypeId = (int)ScoreType.提现, Status = 0, ChargeFee = chargeFee, Score = withdraw.Amount, CreateTime = DateTime.Now }; new UserScoreRepository().Create(score); } return(RedirectToAction("Withdraw")); }