public ActionResult EditFBOrder(Guid FBOrderid) { FBOrder fborder = fborderService.GetByID(FBOrderid); if (TryUpdateModel(fborder, new string[] { "Url", "Count", "Productid", "FBOrderStatus", "Categoryid", "Istest" }) && ModelState.IsValid) { if (fborder.FBOrderStatus == 2 || fborder.FBOrderStatus == 3) { /*** 將完成名單的會員Docker關閉 ****/ IEnumerable <FBMembers> FBMembers = fbmembersService.Get().Where(a => a.Isdocker == 1); foreach (FBMembers FBMember in FBMembers) { if (FBMember.FBOrderlist.Where(a => a.FBOrderid == FBOrderid) != null) { FBMember.Isdocker = 0; fbmembersService.SpecificUpdate(FBMember, new string[] { "Isdocker" }); } } fbmembersService.SaveChanges(); } fborderService.Update(fborder); fborderService.SaveChanges(); } return(RedirectToAction("FBOrder")); }
public ActionResult DeleteFBOrder(Guid FBOrderid) { FBOrder fborder = fborderService.GetByID(FBOrderid); fborderService.Delete(fborder); fborderService.SaveChanges(); return(RedirectToAction("FBOrder")); }
public ActionResult FBOrderregain(Guid FBOrderid, int p, Guid Productid) { FBOrder fborder = fborderService.GetByID(FBOrderid); fborder.FBOrderStatus = 4; //將訂單改為等待收回 fborderService.SpecificUpdate(fborder, new string[] { "FBOrderStatus" }); fborderService.SaveChanges(); return(RedirectToAction("FBOrder", new { p = p })); }
public ActionResult EditFBOrder(Guid FBOrderid, int p) { ViewBag.pageNumber = p; FBOrder fborder = fborderService.GetByID(FBOrderid); /**** FB產品選單 ****/ FBProductDropDownList(fborder); /***** 留言類別選單 ***/ CategoryMessageDropDownList(fborder); return(View(fborder)); }
public JsonResult AjaxUpdateCheckedCost(Guid[] FBOrderid) { foreach (Guid Orderid in FBOrderid) { FBOrder fborder = fborderService.GetByID(Orderid); IEnumerable <FBOrderlist> fborderlist = fborderlistService.Get().Where(a => a.FBOrderid == Orderid); fborder.Cost = (fborder.CostRun + fborder.CostAccount) - ((fborder.CostRun + fborder.CostAccount) * (20d / 100d)); // 訂單成本為實際成本(運行+帳號) - 20%(預估死亡率) fborder.FinishCount = fborderlist.Where(c => c.FBMembers.Isenable == 1).Where(a => a.FBMembers.FBMembersLoginlog.FirstOrDefault().Status != 2).Count(); fborder.DeathCount = fborderlist.Where(c => c.FBMembers.Isenable == 1).Where(a => a.FBMembers.FBMembersLoginlog.FirstOrDefault().Status == 2).Count(); /*** 假設訂單完成 ***/ if (fborder.FBOrderStatus == 2) { fborder.ReplenishCount += Convert.ToInt32(fborder.Count - fborder.FinishCount); // 補充人數為訂單數量 - 成功數量 } fborderService.SpecificUpdate(fborder, new string[] { "Cost", "FinishCount", "DeathCount", "ReplenishCount" }); } fborderService.SaveChanges(); return(this.Json("Success")); }
public ActionResult FBOrderreplenish(Guid FBOrderid, int p) { FBOrder fborder = fborderService.GetByID(FBOrderid); fborder.FBOrderStatus = 0; // 將訂單改為等待中 /*** 補充數量為 下單數量-完成數量 ****/ fborder.Remains = fborder.Count - fborderlistService.Get().Where(a => a.FBOrderid == FBOrderid).Where(x => x.FBMembers.FBMembersLoginlog.FirstOrDefault().Status != 2).Count(); /*** 將完成名單的會員Docker關閉 ****/ IEnumerable <FBMembers> FBMembers = fbmembersService.Get().Where(a => a.Isdocker == 1); foreach (FBMembers FBMember in FBMembers) { if (FBMember.FBOrderlist.Where(a => a.FBOrderid == FBOrderid) != null) { FBMember.Isdocker = 0; fbmembersService.SpecificUpdate(FBMember, new string[] { "Isdocker" }); } } fbmembersService.SaveChanges(); fborderService.SpecificUpdate(fborder, new string[] { "FBOrderStatus", "Remains" }); fborderService.SaveChanges(); return(RedirectToAction("FBOrder", new { p = p })); }
public ActionResult AddFBOrder(FBOrder fborder) { if (TryUpdateModel(fborder, new string[] { "Url", "Count", "Productid", "Categoryid", "Istest" }) && ModelState.IsValid) { fborder.FBOrderid = Guid.NewGuid(); fborder.Createdate = dt_tw(); fborder.Updatedate = dt_tw(); fborder.Remains = fborder.Count; // 剩餘數量 fborder.ProductCost = 1; Product product = productService.GetByID(fborder.Productid); if (fborder.Istest == false) { fborder.Price = Convert.ToDouble(product.Price * fborder.Count); // 售價 } fborder.ProductCost = Convert.ToDouble(product.Cost); // 產品成本是當前的產品成本 fborder.Cost = Convert.ToDouble(fborder.Count * product.Cost); // 訂單成本先預估是數量x當前產品成本 fborder.FBOrdernumber = "FBOrder" + dt_tw().ToString("yyyyMMddHHmmssfff"); fborder.IsResourceGroup = true; fborderService.Create(fborder); fborderService.SaveChanges(); } return(RedirectToAction("FBOrder")); }
public JsonResult AjaxCalcCheckedCost() { double Cost = 0.0; //成本 double Price = 0.0; //售價 double Count = 0.0; //筆數 string[] OrdernumberList = Session["OrderStatistics"].ToString().Split(';'); foreach (string ordernumber in OrdernumberList) { if (ordernumber != "") { if (ordernumber.IndexOf("FB") != -1) { FBOrder fborder = fborderService.Get().Where(a => a.FBOrdernumber == ordernumber).FirstOrDefault(); Product product = productService.GetByID(fborder.Productid); if (fborder.Istest == true) { Cost += 0.0; Price += 0.0; } else { Cost += Convert.ToInt32(product.Cost * fborder.Count); Price += Convert.ToInt32(product.Price * fborder.Count); } } else if (ordernumber.IndexOf("IG") != -1) { IGOrder igorder = igorderService.Get().Where(a => a.IGOrdernumber == ordernumber).FirstOrDefault(); Product product = productService.GetByID(igorder.Productid); if (igorder.Istest == true) { Cost += 0.0; Price += 0.0; } else { Cost += Convert.ToInt32(product.Cost * igorder.Count); Price += Convert.ToInt32(product.Price * igorder.Count); } } else if (ordernumber.IndexOf("YT") != -1) { YTOrder ytorder = ytorderService.Get().Where(a => a.YTOrdernumber == ordernumber).FirstOrDefault(); Product product = productService.GetByID(ytorder.Productid); if (ytorder.Istest == true) { Cost += 0.0; Price += 0.0; } else { Cost += Convert.ToInt32(product.Cost * ytorder.Count); Price += Convert.ToInt32(product.Price * ytorder.Count); } } Count++; } } Session.Remove("OrderStatistics"); // 清除Session的訂單編號 return(this.Json(Cost + ";" + Price + ";" + (Price - Cost) + ";" + Count)); }