public ActionResult EditMemberlevel(Guid levelid, int p) { ViewBag.pageNumber = p; Memberlevel level = memberlevelService.GetByID(levelid); return(View(level)); }
public ActionResult DeleteMemberlevel(Guid levelid, int p) { Memberlevel memebrlevel = memberlevelService.GetByID(levelid); memberlevelService.Delete(memebrlevel); memberlevelService.SaveChanges(); return(RedirectToAction("Memberlevel", new { p = p })); }
public ActionResult AddViprecord(Viprecord viprecord, Guid Vipdetailid) { Vipdetail vipdetail = vipdetailService.GetByID(Vipdetailid); Viprecord old_record = viprecordService.Get().Where(a => a.Status == 2).OrderByDescending(o => o.Enddate).FirstOrDefault(a => a.Memberid == viprecord.Memberid); DateTime now = DateTime.Now; if (TryUpdateModel(viprecord, new string[] { "Payway", "Status" }) && ModelState.IsValid) { viprecord.Viprecordid = Guid.NewGuid(); viprecord.Createdate = DateTime.Now; viprecord.Updatedate = DateTime.Now; viprecord.Enddate = DateTime.Now; viprecord.Day = vipdetail.Day; viprecord.Money = vipdetail.Money; viprecord.Depositnumber = DateTime.Now.ToString("yyyyMMddHHmmssfff"); double day = Convert.ToDouble(viprecord.Day); /*** 如果有完成付款,就將開始日期填入今天,填寫付款方式,並且將該會員之層級提升至VIP ***/ if (viprecord.Status == 2) { /** 假設沒有舊資料,就直接新增進去 **/ if (old_record != null) { if (old_record.Enddate > now) { viprecord.Enddate = old_record.Enddate.AddDays(day); viprecord.Startdate = old_record.Enddate; } else { viprecord.Enddate = DateTime.Now.AddDays(day); viprecord.Startdate = DateTime.Now; } } else { viprecord.Enddate = DateTime.Now.AddDays(day); viprecord.Startdate = DateTime.Now; } Members Member = membersService.GetByID(viprecord.Memberid); Memberlevel Memberlevel = memberlevelService.Get().Where(a => a.Levelname == "VIP").FirstOrDefault(); Member.Levelid = Memberlevel.Levelid; membersService.SpecificUpdate(Member, new string[] { "Levelid" }); membersService.SaveChanges(); } viprecordService.Create(viprecord); viprecordService.SaveChanges(); } return(RedirectToAction("Viprecord")); }
public ActionResult EditMemberlevel(Guid levelid, Memberlevel memberlevel, Memberlevelcooldown memberlevelcooldown) { if (TryUpdateModel(memberlevel, new string[] { "Levelname" }) && ModelState.IsValid) { memberlevel.Updatetime = DateTime.Now; memberlevelService.Update(memberlevel); memberlevelService.SaveChanges(); } if (TryUpdateModel(memberlevelcooldown, new string[] { "Cooldowntime" }) && ModelState.IsValid) { memberlevelcooldownService.Update(memberlevelcooldown); memberlevelcooldownService.SaveChanges(); } return(RedirectToAction("Memberlevel")); }
public ActionResult AddMemberlevel(Memberlevel memberlevel, Memberlevelcooldown memberlevelcooldown) { if (TryUpdateModel(memberlevel, new string[] { "Levelname" }) && ModelState.IsValid) { memberlevel.Levelid = Guid.NewGuid(); memberlevel.Isenable = 1; memberlevel.Createdate = DateTime.Now; memberlevel.Updatetime = DateTime.Now; memberlevelService.Create(memberlevel); memberlevelService.SaveChanges(); } if (TryUpdateModel(memberlevelcooldown, new string[] { "Cooldowntime" }) && ModelState.IsValid) { memberlevelcooldown.Levelid = memberlevel.Levelid; memberlevelcooldownService.Create(memberlevelcooldown); memberlevelcooldownService.SaveChanges(); } return(RedirectToAction("Memberlevel")); }
public void DepositReceive(string TradeInfo) { string Receive = Newebpay.DecryptAES256(TradeInfo); var NewebpayRecive = JsonConvert.DeserializeObject <dynamic>(Receive); // 將Newebpay回傳的json格式轉成物件 string DepositNumber = NewebpayRecive.Result.MerchantOrderNo; // 取得儲值編號 Viprecord viprecord = viprecordService.Get().Where(a => a.Depositnumber == DepositNumber).FirstOrDefault(); Returnstatus returnstatus = new Returnstatus(); returnstatus.Text = Receive; returnstatus.Createdate = DateTime.Now; returnstatusService.Create(returnstatus); returnstatusService.SaveChanges(); if (NewebpayRecive.Result.PaymentType == "VACC") { /*** 將付款方式、Newebpay交易編號、開始時間、截止時間 ***/ Viprecord old_data = viprecordService.Get().Where(a => a.Memberid == viprecord.Memberid).OrderByDescending(x => x.Enddate).FirstOrDefault(); viprecord.Paymenttype = NewebpayRecive.Result.PaymentType; viprecord.Status = 2; if (old_data != null) { if (old_data.Enddate < DateTime.Now) { viprecord.Startdate = DateTime.Now; viprecord.Enddate = DateTime.Now.AddDays(Convert.ToDouble(viprecord.Day)); } else { viprecord.Startdate = old_data.Enddate; viprecord.Enddate = old_data.Enddate.AddDays(Convert.ToDouble(viprecord.Day)); } } else { viprecord.Startdate = DateTime.Now; viprecord.Enddate = DateTime.Now.AddDays(Convert.ToDouble(viprecord.Day)); } viprecordService.SpecificUpdate(viprecord, new string[] { "Paymenttype", "Startdate", "Enddate", "Status" }); viprecordService.SaveChanges(); /*** 更新會員層級狀態 ***/ Members member = membersService.GetByID(viprecord.Memberid); Memberlevel memberlevel = memberlevelService.Get().Where(a => a.Levelname == "VIP").FirstOrDefault(); member.Levelid = memberlevel.Levelid; membersService.SpecificUpdate(member, new string[] { "Levelid" }); membersService.SaveChanges(); } else if (NewebpayRecive.Result.PaymentType == "CVS") { /*** 將付款方式、Newebpay交易編號、開始時間、截止時間 ***/ Viprecord old_data = viprecordService.Get().Where(a => a.Memberid == viprecord.Memberid).OrderByDescending(x => x.Enddate).FirstOrDefault(); viprecord.Paymenttype = NewebpayRecive.Result.PaymentType; viprecord.Status = 2; if (old_data != null) { if (old_data.Enddate < DateTime.Now) { viprecord.Startdate = DateTime.Now; viprecord.Enddate = DateTime.Now.AddDays(Convert.ToDouble(viprecord.Day)); } else { viprecord.Startdate = old_data.Enddate; viprecord.Enddate = old_data.Enddate.AddDays(Convert.ToDouble(viprecord.Day)); } } else { viprecord.Startdate = DateTime.Now; viprecord.Enddate = DateTime.Now.AddDays(Convert.ToDouble(viprecord.Day)); } viprecordService.SpecificUpdate(viprecord, new string[] { "Paymenttype", "Startdate", "Enddate", "Status" }); viprecordService.SaveChanges(); /*** 更新會員層級狀態 ***/ Members member = membersService.GetByID(viprecord.Memberid); Memberlevel memberlevel = memberlevelService.Get().Where(a => a.Levelname == "VIP").FirstOrDefault(); member.Levelid = memberlevel.Levelid; membersService.SpecificUpdate(member, new string[] { "Levelid" }); membersService.SaveChanges(); } }
public ActionResult DepositSuccess(string TradeInfo) { string Receive = Newebpay.DecryptAES256(TradeInfo); var NewebpayRecive = JsonConvert.DeserializeObject <dynamic>(Receive); // 將Newebpay回傳的json格式轉成物件 if (NewebpayRecive.Result.PaymentType == "CVS") { string DepositNumber = NewebpayRecive.Result.MerchantOrderNo; // 取得儲值編號 Viprecord viprecord = viprecordService.Get().Where(a => a.Depositnumber == DepositNumber).FirstOrDefault(); ViewBag.Payway = viprecord.Payway; // 付款方式 ViewBag.Amt = NewebpayRecive.Result.Amt; // 付款金額 ViewBag.Day = viprecord.Day; // 購買天數 ViewBag.CodeNo = NewebpayRecive.Result.CodeNo; // 超商編號 ViewBag.DueDate = DateTime.Now.AddDays(7).ToString("yyyy/MM/dd HH:mm:ss"); // 付款期限 /*** 將Newebpay編號、付款方式、超商編號、繳費期限寫入資料庫 ***/ viprecord.Tradenumber = NewebpayRecive.Result.TradeNo; viprecord.Paymenttype = NewebpayRecive.Result.PaymentType; viprecord.Paymentnumber = NewebpayRecive.Result.CodeNo; viprecord.Duedate = DateTime.Now.AddDays(7); viprecordService.SpecificUpdate(viprecord, new string[] { "Tradenumber", "Paymenttype", "Paymentnumber", "Duedate" }); viprecordService.SaveChanges(); } else if (NewebpayRecive.Result.PaymentType == "VACC") { string DepositNumber = NewebpayRecive.Result.MerchantOrderNo; // 取得儲值編號 Viprecord viprecord = viprecordService.Get().Where(a => a.Depositnumber == DepositNumber).FirstOrDefault(); ViewBag.Payway = viprecord.Payway; // 付款方式 ViewBag.Amt = NewebpayRecive.Result.Amt; // 付款金額 ViewBag.Day = viprecord.Day; // 購買天數 ViewBag.CodeNo = NewebpayRecive.Result.CodeNo; // 金融繳費代碼 ViewBag.BankCode = NewebpayRecive.Result.BankCode; // 銀行數字代碼 ViewBag.DueDate = DateTime.Now.AddDays(7).ToString("yyyy/MM/dd HH:mm:ss"); //繳費期限 /*** 將Newebpay編號、付款方式、金融機構代碼、金融繳費代碼、繳費期限寫入資料庫 ****/ viprecord.Tradenumber = NewebpayRecive.Result.TradeNo; viprecord.Paymenttype = NewebpayRecive.Result.PaymentType; viprecord.Bankcode = NewebpayRecive.Result.Bankcode; viprecord.Virtualaccount = NewebpayRecive.Result.CodeNo; viprecord.Duedate = DateTime.Now.AddDays(7); viprecordService.SpecificUpdate(viprecord, new string[] { "Tradenumber", "Paymenttype", "Bankcode", "Virtualaccount", "Duedate" }); viprecordService.SaveChanges(); } else if (NewebpayRecive.Result.PaymentType == "CREDIT") { string DepositNumber = NewebpayRecive.Result.MerchantOrderNo; // 取得儲值編號 Viprecord viprecord = viprecordService.Get().Where(a => a.Depositnumber == DepositNumber).FirstOrDefault(); ViewBag.Payway = viprecord.Payway; // 付款方式 ViewBag.Status = NewebpayRecive.Message; // 付款狀態 ViewBag.Amt = NewebpayRecive.Result.Amt; // 付款金額 ViewBag.Day = viprecord.Day; // 購買天數 ViewBag.OrderDate = NewebpayRecive.Result.PayTime; // 付款日期 /*** 判斷是否授權成功 ***/ if (NewebpayRecive.Message == "授權成功") { /*** 將付款方式、Newebpay交易編號、開始時間、截止時間 ***/ Guid Memberid = Guid.Parse((Session["Memberid"]).ToString()); Viprecord old_data = viprecordService.Get().Where(a => a.Memberid == Memberid).OrderByDescending(x => x.Enddate).FirstOrDefault(); viprecord.Tradenumber = NewebpayRecive.Result.TradNo; viprecord.Paymenttype = NewebpayRecive.Result.PaymentType; viprecord.Status = 2; if (old_data != null) { if (old_data.Enddate < DateTime.Now) { viprecord.Startdate = DateTime.Now; viprecord.Enddate = DateTime.Now.AddDays(Convert.ToDouble(viprecord.Day)); } else { viprecord.Startdate = old_data.Enddate; viprecord.Enddate = old_data.Enddate.AddDays(Convert.ToDouble(viprecord.Day)); } } else { viprecord.Startdate = DateTime.Now; viprecord.Enddate = DateTime.Now.AddDays(Convert.ToDouble(viprecord.Day)); } viprecordService.SpecificUpdate(viprecord, new string[] { "Tradenumber", "Paymenttype", "Startdate", "Enddate", "Status" }); viprecordService.SaveChanges(); /*** 更新會員層級狀態 ***/ Members member = membersService.GetByID(Memberid); Memberlevel memberlevel = memberlevelService.Get().Where(a => a.Levelname == "VIP").FirstOrDefault(); member.Levelid = memberlevel.Levelid; membersService.SpecificUpdate(member, new string[] { "Levelid" }); membersService.SaveChanges(); } } return(View()); }