public ActionResult Deposit(CardsViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } var info = new RequestInfo { //Merchant site id Merchant_id = _merchantId, //Email tài khoản nhận tiền khi nạp Merchant_acount = _merchantEmail, //Mật khẩu giao tiếp khi đăng ký merchant site Merchant_password = _merchantPassword, //Nhà mạng CardType = viewModel.CardType, Pincard = viewModel.PinCard, //Mã đơn hàng Refcode = (new Random().Next(0, 10000)).ToString(), SerialCard = viewModel.SerialCard }; var result = NLCardLib.CardChage(info); string html = ""; var applyResult = new CardsViewModel(); if (result.Errorcode.Equals("00")) { html += "<div>" + result.Message + "</div>"; html += "<div>Số tiền nạp : <b>" + result.Card_amount + "</b> đ</div>"; html += "<div>Mã giao dịch : <b>" + result.TransactionID + "</b></div>"; html += "<div>Mã đơn hàng : <b>" + result.Refcode + "</b></div>"; applyResult.Result.Message = html; applyResult.Result.Result = true; var coin = int.Parse(result.Card_amount); coin = (coin / 1000 * 8) / 10; _applicationUserService.UpdateCoin(User.Identity.GetUserId(), coin); _applicationUserService.SaveChanges(); var transactionHistory = new TransactionHistory { CardOwner = User.Identity.GetUserId(), Description = $"Mã thẻ: {info.Pincard} | Seri thẻ: { info.SerialCard }", Money = Decimal.Parse(result.Card_amount), MoneyInSite = coin }; this.transactionHistoryService.AddTransactionHistory(transactionHistory); _applicationUserService.SaveChanges(); return(View("Deposit", applyResult)); } html += "<div>Nạp thẻ không thành công</div>"; html += "<div>" + result.Message + "</div>"; applyResult.Result.Message = html; applyResult.Result.Result = false; return(View("Deposit", applyResult)); }
public ActionResult CardDonate(CardDonateView model) { var user = DBHelper.GetUser(User.Identity.GetUserId()); RequestInfo info = new RequestInfo(); //Merchant site id info.Merchant_id = "54442"; //Email tài khoản nhận tiền khi nạp info.Merchant_acount = "*****@*****.**"; //Mật khẩu giao tiếp khi đăng ký merchant site info.Merchant_password = "******"; //Nhà mạng switch (model.Type) { case CardType.VMS: info.CardType = "VMS"; break; case CardType.VNP: info.CardType = "VNP"; break; case CardType.VIETTEL: info.CardType = "VIETTEL"; break; case CardType.GATE: info.CardType = "GATE"; break; default: break; } info.Pincard = model.PIN; //Mã đơn hàng info.Refcode = user.Email; info.SerialCard = model.Serial; ResponseInfo result = NLCardLib.CardChage(info); if (result.Errorcode == "00") { int gainCIF = 0; switch (result.Card_amount) { case "20000": gainCIF = 1000; break; case "50000": gainCIF = 2500; break; case "100000": gainCIF = 6000; break; case "200000": gainCIF = 15000; break; case "500000": gainCIF = 55000; break; default: break; } DBHelper.AddUserCIF(user.Id, gainCIF); } TempData["Message"] = result.Message; return(RedirectToAction("Donate", "Home")); }
public ActionResult Napthe(FormCollection collection) { if (Session["login"] == null) { HttpContext.Application["_controler"] = "Service"; HttpContext.Application["_action"] = "Napthe"; return(RedirectToAction("Index", "Account")); //return RedirectToAction("Index", HttpContext.Application["_controler"] as string); } if (collection["seri"].ToString() == "" || collection["pin"].ToString() == "") { TempData["errorcard"] = "Vui lòng nhập đầy đủ thông tin thẻ cào."; TempData["successcard"] = null; _9d_percen p = accountContext._9d_percens.FirstOrDefault(); TempData["status"] = p.status; return(View()); } try { _9d_percen p = accountContext._9d_percens.FirstOrDefault(); TempData["status"] = p.status; RequestInfo info = new RequestInfo(); info.Merchant_id = "36680"; info.Merchant_acount = "*****@*****.**"; info.Merchant_password = "******"; //Nhà mạng info.CardType = collection["MovieType"].ToString(); info.Pincard = collection["pin"].ToString(); //Mã đơn hàng info.Refcode = (new Random().Next(0, 10000)).ToString(); info.SerialCard = collection["seri"].ToString(); ResponseInfo resutl = NLCardLib.CardChage(info); if (resutl.Errorcode.Equals("00")) { _9d_user user = accountContext._9d_users.Where(c => c.user_name == Session["login"].ToString() && c.delete_flag == false).FirstOrDefault(); int coutncar = (Convert.ToInt32(resutl.Card_amount) * p.percen) / 100; user.balance = user.balance + coutncar; accountContext.SubmitChanges(); User_History addhistory = new User_History(); addhistory.user_name = Session["login"].ToString(); addhistory.time_into = DateTime.Now; addhistory.car_info = coutncar.ToString(); addhistory.car_type = collection["MovieType"].ToString(); accountContext.User_Histories.InsertOnSubmit(addhistory); accountContext.SubmitChanges(); _9d_user u = common.getUserInfo(Session["login"].ToString()); ViewBag.balance = u != null?u.balance.ToString() : "0"; TempData["errorcard"] = null; TempData["successcard"] = "Chúc mừng, bạn đã nạp thành công thẻ mệnh giá " + coutncar.ToString() + "."; } else { TempData["errorcard"] = resutl.Message.ToString(); TempData["successcard"] = null; } return(View()); } catch (Exception) { throw; } }