public ActionResult _FishPay(int id) { aJaxDto ajd = new aJaxDto(); try { if (User.Identity.GetUserId() == null) { //ajd.ErrorMsg = "下注前須先登入\n請先至會員登入中心進行登入註冊,謝謝"; ajd.isTrue = false; throw new Exception("error"); } Product product = new MallRepository().Get(id); List <Product> productAll = new MallRepository().getAll(); cfgUnit unit = new UnitsRepository().getValid(product.unitSn); ProductApiModel pm = new ProductApiModel(); pm.unit = unit; pm.product = product; pm.producList = productAll.Where(x => x.unitSn == 3 && x.type == 3).ToList(); return(View(pm)); } catch { return(Json(ajd)); } }
public ActionResult _ProductRecord() { var pdrlist = new MallRepository().GetProductRecord(User.Identity.GetUserId()); List <ProductApiModel> pml = new List <ProductApiModel>(); foreach (var p in pdrlist.Where(x => x.type != -3)) { ProductApiModel pm = new ProductApiModel(); pm.productRecord = p; pm.product = new MallRepository().Get((int)p.ProductId); if (pm.product != null) { pm.unit = new UnitsRepository().getValid(pm.product.unitSn); if (pm.product.unitSn == 2 && pm.product.type == 3) { DateTime start = Convert.ToDateTime("2019/10/16 12:00:00"); DateTime end = Convert.ToDateTime(pm.productRecord.inpdate); DateTime dtNow = DateTime.Today; pm.product.ProductName = "兌換魚骨幣 " + p.assets; if ((DateTime.Compare(end, dtNow) >= 0) && (DateTime.Compare(start, dtNow) >= 0)) { pm.product.Price = p.assets / pm.product.Price; } else { pm.product.Price = p.assets; } } else if (pm.productRecord.unitSn == 1 && pm.productRecord.type == 5) { pm.product.ProductName = "首儲贈送"; pm.product.Price = p.assets; pm.unit = new UnitsRepository().getValid(1); } pml.Add(pm); } } return(View(pml.OrderByDescending(x => x.productRecord.inpdate))); }
public ActionResult ChangeRecord() { var pdrlist = new MallRepository().GetAllProductRecord(); var crm = new List <ProductRecordModel>(); pdrlist = pdrlist.Where(x => x.unitSn == 2 && x.type != -3).ToList(); foreach (var pd in pdrlist) { var cr = new ProductRecordModel(); var user = UserManager.FindById(pd.UserID); cr.change_name = user.UserName; cr.change_email = user.Email; cr.productRecord = pd; cr.produc = new MallRepository().Get((int)pd.ProductId); crm.Add(cr); } return(View(crm)); }
public ActionResult _ProductRecord() { var pdrlist = new MallRepository().GetProductRecord(User.Identity.GetUserId()); List <ProductApiModel> pml = new List <ProductApiModel>(); foreach (var p in pdrlist.Where(x => x.type != -3)) { ProductApiModel pm = new ProductApiModel(); pm.productRecord = p; pm.product = new MallRepository().Get((int)p.ProductId); pm.unit = new UnitsRepository().getValid(pm.product.unitSn); if (pm.product.unitSn == 2 && pm.product.type == 3) { pm.product.ProductName = "兌換魚骨幣 " + p.assets; pm.product.Price = p.assets; } pml.Add(pm); } return(View(pml.OrderByDescending(x => x.productRecord.inpdate))); }
public ActionResult ChangeRecord() { var pdrlist = new MallRepository().GetAllProductRecord(); var crm = new List <ProductRecordModel>(); pdrlist = pdrlist.Where(x => x.unitSn == 2 && x.type != -3).ToList(); foreach (var pd in pdrlist) { var cr = new ProductRecordModel(); var user = UserManager.FindById(pd.UserID); cr.change_name = user.UserName; cr.change_email = user.Email; cr.productRecord = pd; cr.change_address = pd.address; cr.produc = new MallRepository().Get((int)pd.ProductId); cr.change_phone = pd.phone; cr.change_recipient = pd.recipient; cr.pay = 0; var record = new MallRepository().GetProductRecord(pd.UserID).Where(x => x.type == 1); foreach (var r in record) { cr.pay += (float)new MallRepository().Get((int)r.ProductId).Price; } if (cr.produc != null) { crm.Add(cr); } } var pdListDy = crm.OrderByDescending(x => x.productRecord.inpdate); return(View(pdListDy)); }
public ActionResult _FishPay(int id) { aJaxDto ajd = new aJaxDto(); try { if (User.Identity.GetUserId() == null) { ajd.ErrorMsg = "登入後才可以購買"; ajd.Title = "未登入!"; ajd.isTrue = true; throw new Exception("error"); } var user = UserManager.FindById(User.Identity.GetUserId()); if (!user.EmailConfirmed) { ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝"; ajd.Title = "Email尚未驗證!"; ajd.isTrue = false; throw new Exception("error"); } if (!user.PhoneNumberConfirmed) { ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝"; ajd.Title = "手機尚未驗證!"; ajd.isTrue = false; throw new Exception("error"); } //var pr = new PreferentialRepository().getPRecords(User.Identity.GetUserId()); //普通首儲 /*if (pr == null) * { * var prm = new PreferentialRecords { * UserId = User.Identity.GetUserId(), * Count = 1, * inpdate = DateTime.Now, * PreferentialID = 1 * }; * * new PreferentialRepository().PRecordsCreate(prm); * pr = new PreferentialRepository().getPRecords(User.Identity.GetUserId()); * }*/ var pr = new PreferentialRepository().getPRecordsAll(User.Identity.GetUserId()).Where(x => x.PreferentialID == 5); //2倍首儲 if (pr.Count() == 0) { var m = new MallRepository().getAll().Where(x => x.unitSn == 3 && x.type == 3).ToList(); foreach (var md in m) { var prm = new PreferentialRecords { UserId = User.Identity.GetUserId(), Count = 1, inpdate = DateTime.Now, PreferentialID = 5, productID = md.id }; new PreferentialRepository().PRecordsCreate(prm); //pr = new PreferentialRepository().getPRecords(User.Identity.GetUserId()); } } pr = new PreferentialRepository().getPRecordsAll(User.Identity.GetUserId()).Where(x => x.PreferentialID == 5); Product product = new MallRepository().Get(id); List <Product> productAll = new MallRepository().getAll(); cfgUnit unit = new UnitsRepository().getValid(product.unitSn); ProductApiModel pm = new ProductApiModel(); pm.unit = unit; pm.product = product; pm.producList = productAll.Where(x => x.unitSn == 3 && x.type == 3).ToList(); List <int> fta = new List <int>(); foreach (var p in pr) { if (p.Count != 0) { fta.Add(1); } else { fta.Add(0); } } pm.firstTypeArray = fta; if (pr.Where(x => x.Count != 0).Count() != 0) { pm.firstType = 1; } else { pm.firstType = 0; } //pm.firstType = (pr.Count != 0) ? 1 : 0; pm.preferential = new PreferentialRepository().getpreferential(1); return(View(pm)); } catch { return(Json(ajd, JsonRequestBehavior.AllowGet)); } }