public async Task <ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model) { if (new UserRepository().checkPhoneNumber(model.PhoneNumber)) { ViewBag.StatusMessage = "此手機號碼已經綁定"; } if (!ModelState.IsValid) { return(View(model)); } var result = await UserManager.ChangePhoneNumberAsync(User.Identity.GetUserId(), model.PhoneNumber, model.Code); if (result.Succeeded) { var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (user != null) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); } //驗證成功直接贈送5000魚骨 AssetsRecord ar = new AssetsRecord(); ar.assets = 5000; ar.unitSn = 1; ar.UserId = user.Id; new AssetsRepository().AddAssetsByAssets(ar); return(RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess })); } // 如果執行到這裡,發生某項失敗,則重新顯示表單 ModelState.AddModelError("", "無法驗證號碼"); return(View(model)); }
public void BrickUserData() { var u = new H5GameRepository().Usercount(User.Identity.GetUserId()).Where(x => x.gameModel == 4).FirstOrDefault(); new H5GameRepository().DaycountRemove(u); H5Bets h5b = new H5Bets(); var game = new H5GameRepository().H5GetAll(4).Where(x => x.gameStatus == 1).FirstOrDefault(); h5b.gameBets = new GameBets { userId = User.Identity.GetUserId(), GameSn = game.id, unitSn = 1, money = 200, Odds = 0, valid = 1, gameModel = game.gameModel, createDate = DateTime.Now, modiDate = DateTime.Now }; new H5GameRepository().GameBets(h5b); AssetsRecord assr = new AssetsRecord { UserId = h5b.gameBets.userId, unitSn = 1, gameSn = h5b.gameBets.GameSn, assets = -200, type = -1, }; new AssetsRepository().Addh5gameByAssets(assr); }
public bool SetMissionFinsh(string UserID, int userMissionSn) { List <MissionNoteModel> mnList = GetMissionCode(UserID).ToList(); MissionNoteModel mn = mnList.Where(p => p.userMissionSn == userMissionSn).FirstOrDefault(); if (mn == null) { return(false); } if (mn.isFinsh) { foreach (MissionAssets ma in mn.maList) { AssetsRecord ar = new AssetsRecord { type = 3, unitSn = ma.unitSn, assets = ma.assets, UserId = UserID, inpdate = DateTime.Now }; new AssetsRepository().AddAssetsByAssets(ar); UserMissions um = db.UserMissions.Where(p => p.sn == userMissionSn && p.userID == UserID).FirstOrDefault(); um.valid = 2; db.SaveChanges(); } return(true); } else { return(false); } }
public int LottoBets(int[] Number) { List <AssetsViewModel> avList = new List <AssetsViewModel>(); avList = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId()); int b = 1; //玩家扣錢記錄 if (avList.Where(x => x.unitSn == 1).FirstOrDefault().Asset >= 10000) { H5LottoBets h5b = new H5LottoBets(); var game = new H5GameRepository().H5GetAll(2).Where(x => x.gameStatus == 1).FirstOrDefault(); h5b.gameBets = new GameBets { userId = User.Identity.GetUserId(), GameSn = game.id, unitSn = 1, money = 10000, Odds = 12, valid = 1, gameModel = game.gameModel, createDate = DateTime.Now, modiDate = DateTime.Now }; List <PlayerNumber> pnvm = new List <PlayerNumber>(); foreach (var n in Number) { var pn = new PlayerNumber { Number = n }; pnvm.Add(pn); } h5b.playnumber = pnvm; new H5GameRepository().LottoBets(h5b); AssetsRecord assr = new AssetsRecord { UserId = h5b.gameBets.userId, unitSn = 1, gameSn = h5b.gameBets.GameSn, assets = -10000, type = -15, h5forValue = game.gameModel }; new AssetsRepository().Addh5gameByAssets(assr); } else { b = 0; } return(b); //return Json(akm, JsonRequestBehavior.AllowGet); }
public ActionResult DeleteConfirmed(int id) { AssetsRecord assetsRecord = db.AssetsRecord.Find(id); db.AssetsRecord.Remove(assetsRecord); db.SaveChanges(); return(RedirectToAction("Index")); }
public JsonResult SlottoUserData(float money, int id, int win) { SlotVewModel slotvm = new SlotVewModel(); var u = new H5GameRepository().Usercount(User.Identity.GetUserId()).Where(x => x.gameModel == 5).FirstOrDefault(); H5Bets h5b = new H5Bets(); var game = new H5GameRepository().H5GetAll(5).Where(x => x.gameStatus == 1).FirstOrDefault(); h5b.gameBets = new GameBets { userId = User.Identity.GetUserId(), GameSn = game.id, unitSn = 1, money = money, Odds = 0, valid = 1, gameModel = game.gameModel, createDate = DateTime.Now, modiDate = DateTime.Now }; new H5GameRepository().GameBets(h5b); AssetsRecord assr = new AssetsRecord { UserId = h5b.gameBets.userId, unitSn = 1, gameSn = h5b.gameBets.GameSn, assets = -(money - win), type = -1, }; if ((money - win) != 0) { new AssetsRepository().Addh5gameByAssets(assr); } slotvm.slotm = new H5GameRepository().GetSlotCash(id); slotvm.slotm.slot_cash += (money - win); slotvm.slotm.baseCash = (slotvm.slotm.slot_cash >= 11000) ? slotvm.slotm.slot_cash : 11000; var slom = new cfgSlotCash { id = id, slot_cash = slotvm.slotm.slot_cash, baseCash = slotvm.slotm.baseCash }; new H5GameRepository().SlotCashCreate(slom); return(Json(slotvm, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit([Bind(Include = "sn,UserId,unitSn,gameSn,assets,type,inpdate")] AssetsRecord assetsRecord) { if (ModelState.IsValid) { db.Entry(assetsRecord).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(assetsRecord)); }
public void RatScoretoMoney(float money) { //H5Bets h5b = new H5Bets(); var game = new H5GameRepository().H5GetAll(3).Where(x => x.gameStatus == 1).FirstOrDefault(); /*H5payouts h5p = new H5payouts * { * gameSn = h5.id, * userId = User.Identity.GetUserId(), * betSn = p.id, * Odds = p.Odds, * money = p.money, * readlMoney = p.money * p.Odds * (100 - h5.rake) / 100, * createDate = DateTime.Now, * modiDate = DateTime.Now, * rake = 0 * * }; * this.Payouts(h5p);*/ //玩家加錢和記錄 AssetsRecord assr = new AssetsRecord { UserId = User.Identity.GetUserId(), unitSn = 1, gameSn = game.id, assets = (double)money, type = 1, }; new AssetsRepository().Addh5gameByAssets(assr); //int b = 1; List <AssetsViewModel> avList = new List <AssetsViewModel>(); // avList = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId()); //玩家扣錢記錄 /* AssetsRecord assr = new AssetsRecord * { * UserId = User.Identity.GetUserId(), * unitSn = 1, * gameSn = h5b.gameBets.GameSn, * assets = (double)money, * type = -1, * * * }; * * new AssetsRepository().Addh5gameByAssets(assr);*/ //return b; //return Json(akm, JsonRequestBehavior.AllowGet); }
// GET: AssetsRecords/Create public ActionResult Create(string userId, int?unitSn) { userId = (string.IsNullOrEmpty(userId) ? User.Identity.GetUserId() : userId); AssetsRecord ar = new AssetsRecord(); ar.UserId = userId; if (unitSn.HasValue) { ar.unitSn = unitSn.Value; } return(View(ar)); }
public ActionResult Create(AssetsRecord assetsRecord) { if (ModelState.IsValid) { //string userID = User.Identity.GetUserId(); //assetsRecord.unitSn = 1; //assetsRecord.UserId = userID; new AssetsRepository().AddAssetsByAssets(assetsRecord); return(RedirectToAction("Index", "game")); } return(View(assetsRecord)); }
// GET: AssetsRecords/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AssetsRecord assetsRecord = db.AssetsRecord.Find(id); if (assetsRecord == null) { return(HttpNotFound()); } return(View(assetsRecord)); }
public void BrickScoretoMoney(float money) { var game = new H5GameRepository().H5GetAll(4).Where(x => x.gameStatus == 1).FirstOrDefault(); AssetsRecord assr = new AssetsRecord { UserId = User.Identity.GetUserId(), unitSn = 1, gameSn = game.id, assets = (double)money, type = 1, }; new AssetsRepository().Addh5gameByAssets(assr); }
public int AKBets(float money, int Number) { H5Bets h5b = new H5Bets(); var game = new H5GameRepository().H5GetAll(1).Where(x => x.gameStatus == 1).FirstOrDefault(); h5b.gameBets = new GameBets { userId = User.Identity.GetUserId(), GameSn = game.id, unitSn = 1, money = money, Odds = 12, valid = 1, gameModel = game.gameModel, createDate = DateTime.Now, modiDate = DateTime.Now }; h5b.playnumber = new PlayerNumber { Number = Number }; new H5GameRepository().AkBets(h5b); int b = 1; List <AssetsViewModel> avList = new List <AssetsViewModel>(); avList = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId()); //玩家扣錢記錄 if (avList.Where(x => x.unitSn == 1).FirstOrDefault().Asset >= money) { AssetsRecord assr = new AssetsRecord { UserId = h5b.gameBets.userId, unitSn = 1, gameSn = h5b.gameBets.GameSn, assets = -(double)money, type = -15, h5forValue = game.gameModel }; new AssetsRepository().Addh5gameByAssets(assr); } else { b = 0; } return(b); //return Json(akm, JsonRequestBehavior.AllowGet); }
public ActionResult Login(string returnUrl, string message, int?log) { if (string.IsNullOrEmpty(User.Identity.GetUserId())) { ViewBag.ReturnUrl = returnUrl; if (message != "") { ViewData["Message"] = message; } if (log == 1) { ViewBag.log = log; } return(View()); } else { PreferentialRecords pr = new PreferentialRepository().getPRecordsType(User.Identity.GetUserId(), 100); if (log == 1) { ViewBag.log = log; } if (pr == null && log == 1) { var prm = new PreferentialRecords { UserId = User.Identity.GetUserId(), Count = 0, inpdate = DateTime.Now, PreferentialID = 100 }; new PreferentialRepository().PRecordsCreate(prm); var ar = new AssetsRecord { UserId = User.Identity.GetUserId(), unitSn = 1, assets = 5000, type = 2, inpdate = DateTime.Now }; new AssetsRepository().AddAssetsByAssets(ar); return(RedirectToAction("Index", "Manage", new { Log = "已贈送5000魚骨幣至您的帳戶" })); } return(RedirectToAction("Index", "Manage")); } }
/// <summary> /// h5遊戲派彩給予金錢&&下注扣錢 /// </summary> /// <param name="ar"></param> /// <returns></returns> public bool Addh5gameByAssets(AssetsRecord ar) { Assets assDb = db.Assets.Where(p => p.UserId == ar.UserId && p.unitSn == ar.unitSn).FirstOrDefault(); double fAssets = (assDb == null ? 0 : assDb.assets); if (assDb == null) { assDb = new Assets { UserId = ar.UserId, unitSn = ar.unitSn, assets = fAssets + ar.assets }; db.Assets.Add(assDb); } else { assDb.assets += ar.assets; } try { db.SaveChanges(); } catch (Exception ex) { throw; } AssetsRecord assr = new AssetsRecord { UserId = ar.UserId, unitSn = ar.unitSn, assets = ar.assets, gameSn = ar.gameSn, inpdate = DateTime.Now, type = ar.type, h5forValue = ar.h5forValue, h5score = ar.h5score }; db.AssetsRecord.Add(assr); db.SaveChanges(); return(true); }
public void RatScoretoMoney(float money, float score) { //H5Bets h5b = new H5Bets(); var game = new H5GameRepository().H5GetAll(3).Where(x => x.gameStatus == 1).FirstOrDefault(); //玩家加錢和記錄 AssetsRecord assr = new AssetsRecord { UserId = User.Identity.GetUserId(), unitSn = 1, gameSn = game.id, assets = (double)money, type = 15, h5forValue = game.gameModel, h5score = score }; new AssetsRepository().Addh5gameByAssets(assr); }
/// <summary> /// 下注 /// </summary> /// <param name="bet">下注資料</param> /// <returns></returns> public bool AddAssetsByBet(betDto bet) { Assets assDb = db.Assets.Where(p => p.UserId == bet.userId && p.unitSn == bet.unitSn).FirstOrDefault(); double fAssets = (assDb == null ? 0 : assDb.assets); if (assDb == null) { assDb = new Assets { UserId = bet.userId, unitSn = bet.unitSn.Value, assets = fAssets + bet.money.Value * -1 }; db.Assets.Add(assDb); } else { assDb.assets += bet.money.Value * -1; } db.SaveChanges(); AssetsRecord assr = new AssetsRecord { UserId = bet.userId, unitSn = bet.unitSn.Value, assets = bet.money.Value * -1, gameSn = bet.gameSn, topicSn = bet.topicSn, choiceSn = bet.choiceSn, inpdate = DateTime.Now, type = -1 }; db.AssetsRecord.Add(assr); db.SaveChanges(); return(true); }
//ak自動派彩 public void akAutoPay(H5Games h5) { string url = "https://api.random.org/json-rpc/2/invoke"; Random r = new Random(); int id = r.Next(0, 100); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ContentType = "application/json"; request.Method = "POST"; using (var streamWriter = new StreamWriter(request.GetRequestStream())) { string json = "{\"jsonrpc\":\"2.0\"," + "\"method\":\"generateIntegers\"," + "\"params\":{" + "\"apiKey\":\"3d80c333-78f2-4ed1-b4e1-80e07eb9f041\"," + "\"n\":1," + "\"min\":1," + "\"max\":13," + "\"replacement\":true}," + "\"id\":" + id + "}" ; streamWriter.Write(json); streamWriter.Flush(); streamWriter.Close(); } var httpResponse = (HttpWebResponse)request.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); RandomObject ro = JsonConvert.DeserializeObject <RandomObject>(result); //1:A-K 2:樂透 GameNumberRecord gnr = new GameNumberRecord { gameSn = h5.id, number = ro.result.random.data[0], inpdate = DateTime.Now, }; //寫入牌記錄 this.GNCreate(gnr); //派彩 var player = this.PlayerGetAll(h5.id); foreach (var p in player) { var number = this.NumberGetAll(p.id); foreach (var n in number) { //確認正解 p.valid = 2; this.betsUpdate(p); if (gnr.number == n.Number) { //派彩記錄 H5payouts h5p = new H5payouts { gameSn = h5.id, userId = p.userId, betSn = p.id, Odds = p.Odds, money = p.money, readlMoney = p.money * p.Odds * (100 - h5.rake) / 100, createDate = DateTime.Now, modiDate = DateTime.Now, rake = h5.rake }; this.Payouts(h5p); //玩家加錢和記錄 AssetsRecord assr = new AssetsRecord { UserId = h5p.userId, unitSn = 1, gameSn = h5.id, assets = (double)h5p.readlMoney, type = 15, h5forValue = h5.gameModel }; new AssetsRepository().Addh5gameByAssets(assr); } } } //開盤資料更新 h5.gameStatus = 0; h5.payDate = DateTime.Now; this.H5GameUpdate(h5); } }
public void UpdateAssetsRecord(AssetsRecord item) { _assetsRecordRep.Update(item); }
public void AddToAssetsRecord(AssetsRecord item) { _assetsRecordRep.Add(item); }
//ak無派彩自動派彩 public void WaitakAutoPay(H5Games h5) { try { if (h5 == null) { throw new Exception("error"); } //亂數產生 int[] randomArray = new int[5]; Random rnd = new Random(); //產生亂數初始值 for (int i = 0; i < 5; i++) { randomArray[i] = rnd.Next(1, 14); //亂數產生,亂數產生的範圍是1~9 for (int j = 0; j < i; j++) { while (randomArray[j] == randomArray[i]) //檢查是否與前面產生的數值發生重複,如果有就重新產生 { j = 0; //如有重複,將變數j設為0,再次檢查 (因為還是有重複的可能) randomArray[i] = rnd.Next(1, 14); //重新產生,存回陣列,亂數產生的範圍是1~9 } } } //1:A-K 2:樂透 GameNumberRecord gnr = new GameNumberRecord { gameSn = h5.id, number = randomArray[0], inpdate = DateTime.Now, }; //寫入牌記錄 this.GNCreate(gnr); //派彩 var player = this.PlayerGetAll(h5.id); foreach (var p in player) { var number = this.NumberGetAll(p.id); foreach (var n in number) { //確認正解 p.valid = 2; this.betsUpdate(p); if (gnr.number == n.Number) { //派彩記錄 H5payouts h5p = new H5payouts { gameSn = h5.id, userId = p.userId, betSn = p.id, Odds = p.Odds, money = p.money, readlMoney = p.money * p.Odds * (100 - h5.rake) / 100, createDate = DateTime.Now, modiDate = DateTime.Now, rake = h5.rake }; this.Payouts(h5p); //玩家加錢和記錄 AssetsRecord assr = new AssetsRecord { UserId = h5p.userId, unitSn = 1, gameSn = h5.id, assets = (double)h5p.readlMoney, type = 15, h5forValue = h5.gameModel }; new AssetsRepository().Addh5gameByAssets(assr); } } } //開盤資料更新 h5.gameStatus = 0; h5.payDate = DateTime.Now; this.H5GameUpdate(h5); var ak = this.H5GetAll(1).Where(x => x.gameStatus == 1).ToList(); if (ak.Count == 0) { double m = DateTime.Now.Minute; DateTime dtn = DateTime.Now; m += 10; string md = ""; md = m.ToString().Substring(0, 1); md = md + "0"; string dt = dtn.Year + "-" + dtn.Month + "-" + dtn.Day + " " + dtn.Hour + ":" + md + ":" + dtn.Second; H5Games h5g = new H5Games { title = "A-K選牌", gameModel = 1, gameStatus = 1, valid = 1, rake = 5, createDate = DateTime.Now, endTime = Convert.ToDateTime(dt) }; new H5GameRepository().GameCreate(h5g); } } catch { } }
//樂透自動派彩 public double ballAutoPay(H5Games h5) { double b = 0; /*try * { * string url = "https://api.random.org/json-rpc/2/invoke"; * Random r = new Random(); * int id = r.Next(0, 100); * * * HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); * request.ContentType = "application/json"; * request.Method = "POST"; * using (var streamWriter = new StreamWriter(request.GetRequestStream())) * { * string json = "{\"jsonrpc\":\"2.0\"," + * "\"method\":\"generateIntegers\"," + * "\"params\":{" + * "\"apiKey\":\"3d80c333-78f2-4ed1-b4e1-80e07eb9f041\"," + * "\"n\":5," + * "\"min\":0," + * "\"max\":35," + * "\"replacement\":false}," + * "\"id\":" + id + "}" * * ; * * streamWriter.Write(json); * streamWriter.Flush(); * streamWriter.Close(); * } * var httpResponse = (HttpWebResponse)request.GetResponse(); * * using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) * { * var result = streamReader.ReadToEnd(); * RandomObject ro = JsonConvert.DeserializeObject<RandomObject>(result); * * //1:A-K 2:樂透 * foreach (var rd in ro.result.random.data) * { * GameNumberRecord gnr = new GameNumberRecord * { * gameSn = h5.id, * number = rd, * inpdate = DateTime.Now, * }; * //寫入牌記錄 * this.GNCreate(gnr); * * } * * //派彩 * var player = this.PlayerGetAll(h5.id); * int[] ary = new int[] { 0, 0, 0, 0 }; * var ucm = new List<BallGameModel>(); * //確認多少中獎 * foreach (var p in player) * { * var number = this.NumberGetAll(p.id); * int count = 0; * var uc = new BallGameModel(); * * foreach (var n in number) * { * * foreach (var rd in ro.result.random.data) * { * if (rd == n.Number) * { * count += 1; * } * * } * * } * if (count >= 2) * { * ary[count - 2] += 1; * uc.gamebets = p; * uc.count = count; * ucm.Add(uc); * } * //確認正解 * p.valid = 2; * this.betsUpdate(p); * * * * * } * double total = (h5.totallottery != null) ? (double)h5.totallottery : 0; * double ball = 500000 + total; * double totalbets = this.PlayerGetAll(h5.id).Sum(x => (double)x.money); * * double deduction = 0; * * foreach (var c in ucm) * { * double? rm = (c.count != 5) ? (totalbets * 25 / 100) / ary[c.count - 2] : ball + (totalbets * 25 / 100) / ary[c.count - 2]; * * * if (c.count == 5) * { * h5.bingo = 1; * deduction += total + (totalbets * 25 / 100) / ary[c.count - 2]; * } * else * { * deduction += (double)rm; * } * * * //派彩記錄 * H5payouts h5p = new H5payouts * { * gameSn = h5.id, * userId = c.gamebets.userId, * betSn = c.gamebets.id, * Odds = c.gamebets.Odds, * money = c.gamebets.money, * readlMoney = rm * (100 - h5.rake) / 100, * createDate = DateTime.Now, * modiDate = DateTime.Now, * rake = h5.rake * * }; * * this.Payouts(h5p); * //玩家加錢和記錄 * AssetsRecord assr = new AssetsRecord * { * UserId = h5p.userId, * unitSn = 1, * gameSn = h5.id, * assets = (double)h5p.readlMoney, * type = 15, * h5forValue = h5.gameModel * * * }; * * new AssetsRepository().Addh5gameByAssets(assr); * * } * * * * * * * //開盤資料更新 * h5.gameStatus = 0; * h5.payDate = DateTime.Now; * this.H5GameUpdate(h5); * * * b = totalbets + total - deduction; * H5Games h5g = new H5Games * { * title = "樂透", * gameModel = 2, * gameStatus = 1, * valid = 1, * rake = 20, * createDate = DateTime.Now, * totallottery = b, * endTime = DateTime.Now.AddMinutes(30) * }; * //h5g.totallottery = 500; * new H5GameRepository().GameCreate(h5g); * //new H5GameRepository().akAutoPay(ak.LastOrDefault()); * * * * } * * } * catch { * var ak = this.H5GetAll(2).Where(x => x.gameStatus == 1).ToList(); * if (ak.Count == 1) * b = ballAutoPay(h5); * * }*/ try { if (h5 == null) { throw new Exception("error"); } //亂數產生 int[] randomArray = new int[5]; Random rnd = new Random(); //產生亂數初始值 for (int i = 0; i < 5; i++) { randomArray[i] = rnd.Next(1, 37); //亂數產生,亂數產生的範圍是1~9 for (int j = 0; j < i; j++) { while (randomArray[j] == randomArray[i]) //檢查是否與前面產生的數值發生重複,如果有就重新產生 { j = 0; //如有重複,將變數j設為0,再次檢查 (因為還是有重複的可能) randomArray[i] = rnd.Next(1, 37); //重新產生,存回陣列,亂數產生的範圍是1~9 } } } //1:A-K 2:樂透 foreach (var rd in randomArray) { GameNumberRecord gnr = new GameNumberRecord { gameSn = h5.id, number = rd, inpdate = DateTime.Now, }; //寫入牌記錄 this.GNCreate(gnr); } //派彩 var player = this.PlayerGetAll(h5.id); int[] ary = new int[] { 0, 0, 0, 0 }; int[] bonus = new int[] { 50, 30, 20, 70 }; var ucm = new List <BallGameModel>(); //確認多少中獎 foreach (var p in player) { var number = this.NumberGetAll(p.id); int count = 0; var uc = new BallGameModel(); foreach (var n in number) { foreach (var rd in randomArray) { if (rd == n.Number) { count += 1; } } } if (count >= 2) { ary[count - 2] += 1; uc.gamebets = p; uc.count = count; ucm.Add(uc); } //確認正解 p.valid = 2; this.betsUpdate(p); } double total = (h5.totallottery != null) ? (double)h5.totallottery : 0; double ball = 18326000 + total; double totalbets = this.PlayerGetAll(h5.id).Sum(x => (double)x.money); double deduction = 0; foreach (var c in ucm) { double?rm = (c.count != 5) ? (totalbets * bonus[c.count - 2] / 100) / ary[c.count - 2] : ball + (totalbets * bonus[c.count - 2] / 100) / ary[c.count - 2]; if (c.count == 5) { h5.bingo = 1; deduction = totalbets + total; //deduction += total + (totalbets * 25 / 100) / ary[c.count - 2]; } else { deduction = totalbets; } //派彩記錄 H5payouts h5p = new H5payouts { gameSn = h5.id, userId = c.gamebets.userId, betSn = c.gamebets.id, Odds = c.gamebets.Odds, money = c.gamebets.money, readlMoney = rm * (100 - h5.rake) / 100, createDate = DateTime.Now, modiDate = DateTime.Now, rake = h5.rake }; this.Payouts(h5p); //玩家加錢和記錄 AssetsRecord assr = new AssetsRecord { UserId = h5p.userId, unitSn = 1, gameSn = h5.id, assets = (double)h5p.readlMoney, type = 15, h5forValue = h5.gameModel }; new AssetsRepository().Addh5gameByAssets(assr); } //開盤資料更新 h5.gameStatus = 0; h5.payDate = DateTime.Now; this.H5GameUpdate(h5); b = totalbets + total - deduction; H5Games h5g = new H5Games { title = "樂透", gameModel = 2, gameStatus = 1, valid = 1, rake = 20, createDate = DateTime.Now, totallottery = b, endTime = DateTime.Now.AddMinutes(30) }; //h5g.totallottery = 500; new H5GameRepository().GameCreate(h5g); //new H5GameRepository().akAutoPay(ak.LastOrDefault()); } catch { var ak = this.H5GetAll(2).Where(x => x.gameStatus == 1).ToList(); if (ak.Count == 1) { b = ballAutoPay(h5); } } return(b); }
//樂透無派彩自動派彩 public double WaitballAutoPay(H5Games h5) { double b = 0; try { if (h5 == null) { throw new Exception("error"); } //亂數產生 int[] randomArray = new int[5]; Random rnd = new Random(); //產生亂數初始值 for (int i = 0; i < 5; i++) { randomArray[i] = rnd.Next(1, 37); //亂數產生,亂數產生的範圍是1~9 for (int j = 0; j < i; j++) { while (randomArray[j] == randomArray[i]) //檢查是否與前面產生的數值發生重複,如果有就重新產生 { j = 0; //如有重複,將變數j設為0,再次檢查 (因為還是有重複的可能) randomArray[i] = rnd.Next(1, 37); //重新產生,存回陣列,亂數產生的範圍是1~9 } } } //1:A-K 2:樂透 foreach (var rd in randomArray) { GameNumberRecord gnr = new GameNumberRecord { gameSn = h5.id, number = rd, inpdate = DateTime.Now, }; //寫入牌記錄 this.GNCreate(gnr); } //派彩 var player = this.PlayerGetAll(h5.id); int[] ary = new int[] { 0, 0, 0, 0 }; int[] bonus = new int[] { 50, 30, 20, 70 }; var ucm = new List <BallGameModel>(); //確認多少中獎 foreach (var p in player) { var number = this.NumberGetAll(p.id); int count = 0; var uc = new BallGameModel(); foreach (var n in number) { foreach (var rd in randomArray) { if (rd == n.Number) { count += 1; } } } if (count >= 2) { ary[count - 2] += 1; uc.gamebets = p; uc.count = count; ucm.Add(uc); } //確認正解 p.valid = 2; this.betsUpdate(p); } double total = (h5.totallottery != null) ? (double)h5.totallottery : 0; double ball = 18326000 + total; double totalbets = this.PlayerGetAll(h5.id).Sum(x => (double)x.money); double deduction = 0; foreach (var c in ucm) { double?rm = (c.count != 5) ? (totalbets * bonus[c.count - 2] / 100) / ary[c.count - 2] : ball + (totalbets * bonus[c.count - 2] / 100) / ary[c.count - 2]; if (c.count == 5) { h5.bingo = 1; deduction = totalbets + total; //deduction += total + (totalbets * 25 / 100) / ary[c.count - 2]; } else { deduction = totalbets; } //派彩記錄 H5payouts h5p = new H5payouts { gameSn = h5.id, userId = c.gamebets.userId, betSn = c.gamebets.id, Odds = c.gamebets.Odds, money = c.gamebets.money, readlMoney = rm * (100 - h5.rake) / 100, createDate = DateTime.Now, modiDate = DateTime.Now, rake = h5.rake }; this.Payouts(h5p); //玩家加錢和記錄 AssetsRecord assr = new AssetsRecord { UserId = h5p.userId, unitSn = 1, gameSn = h5.id, assets = (double)h5p.readlMoney, type = 15, h5forValue = h5.gameModel }; new AssetsRepository().Addh5gameByAssets(assr); } //開盤資料更新 h5.gameStatus = 0; h5.payDate = DateTime.Now; this.H5GameUpdate(h5); var ak = this.H5GetAll(2).Where(x => x.gameStatus == 1).ToList(); if (ak.Count == 0) { double m = DateTime.Now.Minute; double h = DateTime.Now.Hour; DateTime dtn = DateTime.Now; double md = (m < 30) ? 30 : 00; double hd = (m < 30) ? h : h + 1; int result = 0; result = Convert.ToInt16(Math.Floor(m / 3)) + 10; string dt = dtn.Year + "-" + dtn.Month + "-" + dtn.Day + " " + hd + ":" + md + ":" + dtn.Second; b = totalbets + total - deduction; H5Games h5g = new H5Games { title = "樂透", gameModel = 2, gameStatus = 1, valid = 1, rake = 20, createDate = DateTime.Now, totallottery = b, endTime = Convert.ToDateTime(dt) }; //h5g.totallottery = 500; new H5GameRepository().GameCreate(h5g); } } catch { } return(b); }
//轉帳系統功能 public bool AddAssetsByTransfer(TransferRecords tr) { //轉出方增加 Assets assDb = db.Assets.Where(p => p.UserId == tr.Transfer && p.unitSn == tr.unitSn).FirstOrDefault(); double fAssets = (assDb == null ? 0 : assDb.assets); if (assDb == null) { assDb = new Assets { UserId = tr.Transfer, unitSn = tr.unitSn, assets = fAssets + tr.credit * (100 - (double)tr.rake) / 100 }; db.Assets.Add(assDb); } else { assDb.assets += tr.credit * (100 - (double)tr.rake) / 100; } try { db.SaveChanges(); } catch (Exception ex) { throw; } //支出方扣除 assDb = db.Assets.Where(p => p.UserId == tr.UserId && p.unitSn == tr.unitSn).FirstOrDefault(); fAssets = (assDb == null ? 0 : assDb.assets); assDb.assets -= tr.credit; try { db.SaveChanges(); } catch (Exception ex) { throw; } TransferRecords assr = new TransferRecords { UserId = tr.UserId, Transfer = tr.Transfer, unitSn = tr.unitSn, credit = tr.credit, type = tr.type, createDate = DateTime.Now, rake = tr.rake }; db.TransferRecords.Add(assr); db.SaveChanges(); AssetsRecord assru = new AssetsRecord { UserId = tr.UserId, unitSn = tr.unitSn, assets = tr.credit, inpdate = DateTime.Now, type = -12 }; db.AssetsRecord.Add(assru); db.SaveChanges(); AssetsRecord assrt = new AssetsRecord { UserId = tr.Transfer, unitSn = tr.unitSn, assets = tr.credit, inpdate = DateTime.Now, type = 12 }; db.AssetsRecord.Add(assrt); db.SaveChanges(); return(true); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid && new reCAPTCHAHelper().Validate(Request["g-recaptcha-response"])) { var user = new ApplicationUser { UserName = model.Name, Email = model.Email, Name = model.Name, RegistrationDate = DateTime.Now }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // 傳送包含此連結的電子郵件 //string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); //var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); //await UserManager.SendEmailAsync(user.Id, "熊i猜Email驗證信", "請按此連結確認您的帳戶 <a href=\"" + callbackUrl + "\">驗證</a>"); await new AccountModel().RegisterFinsh(user); //寄送驗證信件 string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); string emailBody = EmailTemplatesService.GetVerifyEmailHTML(callbackUrl); await UserManager.SendEmailAsync(user.Id, "熊i猜Email驗證信", emailBody); if (model.Code != "") { var r = new UserRepository().getRecommend(); foreach (var re in r) { var v = new UserRepository().getRecommendStart((int)re.ReId); if (v.edate > DateTime.Now) { if (model.Code == re.code) { AssetsRecord ar = new AssetsRecord(); ar.assets = (double)v.money; ar.unitSn = 1; ar.UserId = user.Id; new AssetsRepository().AddAssetsByAssets(ar); } } } } if (model.Assets > 5000) { model.Assets = 5000; } if (model.Assets != 0) { AssetsRecord ar2 = new AssetsRecord(); ar2.assets = (double)model.Assets; ar2.unitSn = 1; ar2.UserId = user.Id; new AssetsRepository().AddAssetsByAssets(ar2); } var prm = new PreferentialRecords { UserId = user.Id, Count = 0, inpdate = DateTime.Now, PreferentialID = 100 }; new PreferentialRepository().PRecordsCreate(prm); return(RedirectToAction("Index", "Manage", new { RM = "溫馨提醒:Email以及手機驗證,才可以參與所有競猜活動!!" })); } AddErrors(result); } // 如果執行到這裡,發生某項失敗,則重新顯示表單 return(View(model)); }
//樂透自動派彩 public double ballAutoPay(H5Games h5) { string url = "https://api.random.org/json-rpc/2/invoke"; Random r = new Random(); int id = r.Next(0, 100); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ContentType = "application/json"; request.Method = "POST"; using (var streamWriter = new StreamWriter(request.GetRequestStream())) { string json = "{\"jsonrpc\":\"2.0\"," + "\"method\":\"generateIntegers\"," + "\"params\":{" + "\"apiKey\":\"3d80c333-78f2-4ed1-b4e1-80e07eb9f041\"," + "\"n\":5," + "\"min\":0," + "\"max\":35," + "\"replacement\":false}," + "\"id\":" + id + "}" ; streamWriter.Write(json); streamWriter.Flush(); streamWriter.Close(); } var httpResponse = (HttpWebResponse)request.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); RandomObject ro = JsonConvert.DeserializeObject <RandomObject>(result); //1:A-K 2:樂透 foreach (var rd in ro.result.random.data) { GameNumberRecord gnr = new GameNumberRecord { gameSn = h5.id, number = rd, inpdate = DateTime.Now, }; //寫入牌記錄 this.GNCreate(gnr); } //派彩 var player = this.PlayerGetAll(h5.id); int[] ary = new int[] { 0, 0, 0, 0 }; var ucm = new List <BallGameModel>(); //確認多少中獎 foreach (var p in player) { var number = this.NumberGetAll(p.id); int count = 0; var uc = new BallGameModel(); foreach (var n in number) { foreach (var rd in ro.result.random.data) { if (rd == n.Number) { count += 1; } } } if (count >= 2) { ary[count - 2] += 1; uc.gamebets = p; uc.count = count; ucm.Add(uc); } //確認正解 p.valid = 2; this.betsUpdate(p); } double total = (h5.totallottery != null) ? (double)h5.totallottery:0; double ball = 500000 + total; double totalbets = this.PlayerGetAll(h5.id).Sum(x => (double)x.money); double deduction = 0; foreach (var c in ucm) { double?rm = (c.count != 5)?(totalbets * 25 / 100) / ary[c.count - 2]: ball + (totalbets * 25 / 100) / ary[c.count - 2]; if (c.count == 5) { h5.bingo = 1; deduction += total + (totalbets * 25 / 100) / ary[c.count - 2]; } else { deduction += (double)rm; } //派彩記錄 H5payouts h5p = new H5payouts { gameSn = h5.id, userId = c.gamebets.userId, betSn = c.gamebets.id, Odds = c.gamebets.Odds, money = c.gamebets.money, readlMoney = rm * (100 - h5.rake) / 100, createDate = DateTime.Now, modiDate = DateTime.Now, rake = h5.rake }; this.Payouts(h5p); //玩家加錢和記錄 AssetsRecord assr = new AssetsRecord { UserId = h5p.userId, unitSn = 1, gameSn = h5.id, assets = (double)h5p.readlMoney, type = 15, h5forValue = h5.gameModel }; new AssetsRepository().Addh5gameByAssets(assr); } //開盤資料更新 h5.gameStatus = 0; h5.payDate = DateTime.Now; this.H5GameUpdate(h5); return(totalbets + total - deduction); } }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl, int?log) { if (!ModelState.IsValid || !new reCAPTCHAHelper().Validate(Request["g-recaptcha-response"])) { ViewData["Message"] = "驗證有誤,請重新登入"; return(View(model)); } // 這不會計算為帳戶鎖定的登入失敗 // 若要啟用密碼失敗來觸發帳戶鎖定,請變更為 shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.Name, model.Password, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: var live = new UserRepository().getlive(); var user = UserManager.FindByName(model.Name); foreach (var l in live) { if (l.username == user.Id) { if (l.valid != 0) { ViewData["Message"] = "此為直播主帳號,無法登入。"; return(View(model)); } else { ViewData["Message"] = "此帳號還在申請審核中。"; return(View(model)); } } } string vClientIP = GetIPAddress(); new UserRepository().CreateIP(user.Id, vClientIP); PreferentialRecords pr = new PreferentialRepository().getPRecordsType(user.Id, 100); Session["Assets"] = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId()); //Session["levelExp"] = new AssetsRepository().getExpByUserID(User.Identity.GetUserId()); if (returnUrl != null) { Response.Redirect(returnUrl); } if (pr == null && log == 1) { var prm = new PreferentialRecords { UserId = user.Id, Count = 0, inpdate = DateTime.Now, PreferentialID = 100 }; new PreferentialRepository().PRecordsCreate(prm); var ar = new AssetsRecord { UserId = user.Id, unitSn = 1, assets = 5000, type = 2, inpdate = DateTime.Now }; new AssetsRepository().AddAssetsByAssets(ar); return(RedirectToAction("Index", "Manage", new { Log = "已贈送5000魚骨幣至您的帳戶" })); } return(RedirectToAction("Index", "Home")); //return RedirectToLocal(returnUrl); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: //ModelState.AddModelError("", "登入嘗試失試。"); ViewData["Message"] = "登入嘗試失試。"; return(View(model)); } }
//ak自動派彩 public void akAutoPay(H5Games h5) { try { if (h5 == null) { throw new Exception("error"); } //亂數產生 int[] randomArray = new int[5]; Random rnd = new Random(); //產生亂數初始值 for (int i = 0; i < 5; i++) { randomArray[i] = rnd.Next(1, 14); //亂數產生,亂數產生的範圍是1~9 for (int j = 0; j < i; j++) { while (randomArray[j] == randomArray[i]) //檢查是否與前面產生的數值發生重複,如果有就重新產生 { j = 0; //如有重複,將變數j設為0,再次檢查 (因為還是有重複的可能) randomArray[i] = rnd.Next(1, 14); //重新產生,存回陣列,亂數產生的範圍是1~9 } } } //1:A-K 2:樂透 GameNumberRecord gnr = new GameNumberRecord { gameSn = h5.id, number = randomArray[0], inpdate = DateTime.Now, }; //寫入牌記錄 this.GNCreate(gnr); //派彩 var player = this.PlayerGetAll(h5.id); foreach (var p in player) { var number = this.NumberGetAll(p.id); foreach (var n in number) { //確認正解 p.valid = 2; this.betsUpdate(p); if (gnr.number == n.Number) { //派彩記錄 H5payouts h5p = new H5payouts { gameSn = h5.id, userId = p.userId, betSn = p.id, Odds = p.Odds, money = p.money, readlMoney = p.money * p.Odds * (100 - h5.rake) / 100, createDate = DateTime.Now, modiDate = DateTime.Now, rake = h5.rake }; this.Payouts(h5p); //玩家加錢和記錄 AssetsRecord assr = new AssetsRecord { UserId = h5p.userId, unitSn = 1, gameSn = h5.id, assets = (double)h5p.readlMoney, type = 15, h5forValue = h5.gameModel }; new AssetsRepository().Addh5gameByAssets(assr); } } } //開盤資料更新 h5.gameStatus = 0; h5.payDate = DateTime.Now; this.H5GameUpdate(h5); var ak = this.H5GetAll(1).Where(x => x.gameStatus == 1).ToList(); if (ak.Count != 1) { H5Games h5g = new H5Games { title = "A-K選牌", gameModel = 1, gameStatus = 1, valid = 1, rake = 5, createDate = DateTime.Now, endTime = DateTime.Now.AddMinutes(10) }; new H5GameRepository().GameCreate(h5g); } else { //開盤資料更新 h5.gameStatus = 0; h5.payDate = DateTime.Now; this.H5GameUpdate(h5); H5Games h5g = new H5Games { title = "A-K選牌", gameModel = 1, gameStatus = 1, valid = 1, rake = 5, createDate = DateTime.Now, endTime = DateTime.Now.AddMinutes(10) }; new H5GameRepository().GameCreate(h5g); } }catch { var ak = this.H5GetAll(1).Where(x => x.gameStatus == 1).ToList(); if (ak.Count == 1) { akAutoPay(h5); } } /* try * { * string url = "https://api.random.org/json-rpc/2/invoke"; * Random r = new Random(); * int id = r.Next(0, 100); * * * HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); * request.ContentType = "application/json"; * request.Method = "POST"; * using (var streamWriter = new StreamWriter(request.GetRequestStream())) * { * string json = "{\"jsonrpc\":\"2.0\"," + * "\"method\":\"generateIntegers\"," + * "\"params\":{" + * "\"apiKey\":\"3d80c333-78f2-4ed1-b4e1-80e07eb9f041\"," + * "\"n\":1," + * "\"min\":1," + * "\"max\":13," + * "\"replacement\":true}," + * "\"id\":" + id + "}" * * ; * * streamWriter.Write(json); * streamWriter.Flush(); * streamWriter.Close(); * } * var httpResponse = (HttpWebResponse)request.GetResponse(); * * using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) * { * var result = streamReader.ReadToEnd(); * RandomObject ro = JsonConvert.DeserializeObject<RandomObject>(result); * * //1:A-K 2:樂透 * GameNumberRecord gnr = new GameNumberRecord * { * gameSn = h5.id, * number = ro.result.random.data[0], * inpdate = DateTime.Now, * }; * //寫入牌記錄 * this.GNCreate(gnr); * //派彩 * var player = this.PlayerGetAll(h5.id); * foreach (var p in player) * { * var number = this.NumberGetAll(p.id); * foreach (var n in number) * { * //確認正解 * p.valid = 2; * this.betsUpdate(p); * * if (gnr.number == n.Number) * { * //派彩記錄 * H5payouts h5p = new H5payouts * { * gameSn = h5.id, * userId = p.userId, * betSn = p.id, * Odds = p.Odds, * money = p.money, * readlMoney = p.money * p.Odds * (100 - h5.rake) / 100, * createDate = DateTime.Now, * modiDate = DateTime.Now, * rake = h5.rake * * }; * this.Payouts(h5p); * //玩家加錢和記錄 * AssetsRecord assr = new AssetsRecord * { * UserId = h5p.userId, * unitSn = 1, * gameSn = h5.id, * assets = (double)h5p.readlMoney, * type = 15, * h5forValue = h5.gameModel * * * }; * * new AssetsRepository().Addh5gameByAssets(assr); * * * } * } * } * * * //開盤資料更新 * h5.gameStatus = 0; * h5.payDate = DateTime.Now; * this.H5GameUpdate(h5); * * H5Games h5g = new H5Games * { * title = "A-K選牌", * gameModel = 1, * gameStatus = 1, * valid = 1, * rake = 5, * createDate = DateTime.Now, * endTime = DateTime.Now.AddMinutes(10) * }; * new H5GameRepository().GameCreate(h5g); * } * * } * catch { * var ak = this.H5GetAll(1).Where(x => x.gameStatus == 1).ToList(); * if(ak.Count == 1) * akAutoPay(h5); * }*/ }