public ActionResult FbList() { LivePostsRepository livePost_repo = new LivePostsRepository(); ViewData.Model = livePost_repo.GetAllLivePosts(); return(View()); }
public static int Select(string livePageID) { LivePostsRepository livepost_repo = new LivePostsRepository(); var liveID = livepost_repo.Select(livePageID); return(liveID); }
public static List <LivePostViewModel> ListLivePosts() { var live_repo = new LivePostsRepository(); var current_liveposts = live_repo.Select(); return(current_liveposts); }
public void SendMsgByButton(string livePageID) { var live_repo = new LivePostsRepository(); int liveid = live_repo.Select(livePageID); var order_repo = new OrderRepositories(); //List<string> ids = new List<string> { "3032519476788720", "2762673820474754" }; List <MsgTextViewModel> ordersinfo = order_repo.SelectAllOrdersInfo(liveid); //string token = (string)Session["token"]; string userid = User.Identity.GetUserId(); string token = FanPageService.GetToken(userid); var orders = new List <OrderList>(); foreach (var orderinfo in ordersinfo) { var order = new OrderList(); order.CustomerID = orderinfo.CustomerID; order.CustomerName = orderinfo.CustomerName; order.OrderID = orderinfo.OrderID; order.Product = new ProductViewModel { Salepage_id = orderinfo.ProductPageID, SkuId = orderinfo.ProductID, ProductName = orderinfo.ProductName }; order.Quantity = orderinfo.Quantity; orders.Add(order); FBSendMsgService.SuccessOrderToSendMsg(livePageID, order, token); } }
public ActionResult FbOrderChart(int liveId) { LivePostsRepository livePost_repo = new LivePostsRepository(); var time = livePost_repo.GetLivePost(liveId); OrderRepositories order_repo = new OrderRepositories(); var orders = order_repo.GetOrders(liveId); var post = time.postTime.Minute; TimeSpan interval = time.endTime - time.postTime; var minutes = Math.Round(Convert.ToDouble(interval.TotalMinutes)); var intervalOrders = new List <CommentOrderLIstViewModel>(); var sum = new List <int>(); var datetime = new List <string>(); var chartData = new { datetime, sum }; for (var i = 0; i <= minutes; i++) { intervalOrders = orders.Where((x) => post + i <= x.OrderDateTime.Minute && x.OrderDateTime.Minute < post + i + 1).ToList(); var qty = 0; foreach (var item in intervalOrders) { qty += item.Quantity; } datetime.Add(time.postTime.AddMinutes(i).ToString("HH:mm")); sum.Add(qty); } return(Json(chartData)); }
public ActionResult ROIOrderList(int liveId) { LivePostsRepository livePost_repo = new LivePostsRepository(); ViewData.Model = livePost_repo.GetLivePost(liveId); var SaleOrder = livePost_repo.SaleOrder(liveId); ViewData["SaleOrder"] = SaleOrder; return(View()); }
public ActionResult CommentsOrderList(int liveId) { LivePostsRepository livePost_repo = new LivePostsRepository(); ViewData["LivePost"] = livePost_repo.GetLivePost(liveId); OrderRepositories order_repo = new OrderRepositories(); List <CommentOrderLIstViewModel> orders = order_repo.GetOrders(liveId); ViewData.Model = orders; return(View()); }
public ActionResult SetPostEndtime(string livePageID) { OrderRepositories o_repo = new OrderRepositories(); decimal Amount = o_repo.GetAmount(livePageID); int QtyOfOrders = o_repo.GetQtyOfOrders(livePageID); var live_repo = new LivePostsRepository(); int views = (int)Session["views"]; live_repo.UpdatePost(livePageID, QtyOfOrders, Amount, DateTime.UtcNow.AddHours(8), views); Session.Abandon(); return(RedirectToAction("Index", "Report")); }
public static List <OrderList> KeywordFilter(List <ProductViewModel> products, List <Datum> datas, string livePageID, string keywordPattern) { var resultOrderList = new List <OrderList>(); var cust_repo = new CustomerRepository(); //List<Datum> resultDatum = new List<Datum>(); if (keywordPattern == null) { keywordPattern = "+1"; } foreach (var data in datas) { foreach (var item in products) { string completeKeyword = item.Keyword + keywordPattern; if (data.message == completeKeyword) { //resultDatum.Add(data); if (data.from.name == null) { break; } var name = UTF8ConvertToString(data.from.name); if (!cust_repo.SelectCustomer(data.from.id)) { var customer = new Customer { CustomerID = data.from.id, CustomerName = name }; cust_repo.InsertCustomer(customer); } var live_repo = new LivePostsRepository(); var order = new OrderList(); order.CustomerID = data.from.id; order.CustomerName = name; order.Keyword = data.message; order.Product = new ProductViewModel { Salepage_id = item.Salepage_id, SkuId = item.SkuId, ProductName = item.ProductName, UnitPrice = item.UnitPrice }; order.LiveID = live_repo.Select(livePageID); order.OrderDateTime = data.created_time.ToUniversalTime().AddHours(8); order.Quantity = 1; //因為目前只有+1,所以暫時寫死 resultOrderList.Add(order); break; } } } return(resultOrderList); }
public static List <OrderList> KeywordCheck(List <ProductViewModel> products, List <Datum> datas, string livePageID, string keywordPattern) { var resultOrderList = new List <OrderList>(); var cust_repo = new CustomerRepository(); foreach (var data in datas) { if (data.from == null) { continue; } var name = UTF8ConvertToString(data.from.name); if (!cust_repo.SelectCustomer(data.from.id)) { var customer = new Customer { CustomerID = data.from.id, CustomerName = name }; cust_repo.InsertCustomer(customer); } foreach (var item in products) { if (KeywordFilter(data.message, item.Keyword, keywordPattern) != 0) { var live_repo = new LivePostsRepository(); var order = new OrderList(); order.CustomerID = data.from.id; order.CustomerName = name; order.Keyword = data.message; order.Product = new ProductViewModel { Salepage_id = item.Salepage_id, SkuId = item.SkuId, ProductName = item.ProductName, UnitPrice = item.UnitPrice }; order.LiveID = live_repo.Select(livePageID); order.OrderDateTime = data.created_time.ToUniversalTime().AddHours(8); order.Quantity = 1; if (keywordPattern == "+1") { order.Quantity = int.Parse(data.message.Substring(data.message.IndexOf("+", StringComparison.Ordinal))); } resultOrderList.Add(order); break; } } } return(resultOrderList); }
public ActionResult ROIOrderList(int liveId) { //缺少觀看人數欄位(因為有問題) //缺少成單量和成單價(還不知道如何完成下單) //所以暫時一樣用ReportViewModel LivePostsRepository livePost_repo = new LivePostsRepository(); ViewData.Model = livePost_repo.GetLivePost(liveId); var SaleOrder = livePost_repo.SaleOrder(liveId); ViewData["SaleOrder"] = SaleOrder; return(View()); }
public static void FailedOrderToSendMsg(string livePageId, OrderList order, string token) { LivePostsRepository livePost_repo = new LivePostsRepository(); var liveId = livePost_repo.Select(livePageId); var userid = HttpContext.Current.User.Identity.GetUserId(); Context db = new Context(); string storeUrl = db.AspNetUsers.FirstOrDefault(x => x.Id == userid)?.ShopID; var link = "http://" + storeUrl + "/"; string msgText = $"{order.CustomerName}非常抱歉,您下標本商品-{order.Product.ProductName}的數量不足\r\n,您可以透過以下連結來本商店觀看其他商品資訊!{link}"; List <string> id = new List <string> { order.CustomerID }; FBSendMsgService.SendMsg(msgText, id, token); }
public static void OrderListToSendMsg(string livePageId, List <OrderList> orderList, string token) { LivePostsRepository livePost_repo = new LivePostsRepository(); var liveId = livePost_repo.Select(livePageId); foreach (var order in orderList) { var link = getAddToCartLink(liveId, order.Product.Salepage_id, order.Product.SkuId, order.Quantity); string msgText = $"{order.CustomerName}你好,感謝您訂購我們的產品!!\r\n{order.Product.ProductName}-數量{order.Quantity},請點擊下列連結完成接下來的購物流程!{link}"; List <string> id = new List <string> { order.CustomerID }; FBSendMsgService.SendMsg(msgText, id, token); } }
public static TotalAndSalesOrders GetTotalAndSalesOrders(string livepageId) { var salesorder_repo = new SalesOrderRepositories(); var live_repo = new LivePostsRepository(); int liveid = live_repo.Select(livepageId); var salesOrders = salesorder_repo.Select(liveid); var totalAndSalesOrders = new TotalAndSalesOrders() { salesOrderNum = salesOrders.Count, total = salesOrders.Sum(x => x.Total) }; return(totalAndSalesOrders); }
public static void CreateLivePost(string livePageID, string liveName, int fanPageId) { Context context = new Context(); //var fanPageID = context.FanPages.FirstOrDefault(x => x.FanPageName == fanPageName); var livepost_repo = new LivePostsRepository(); var livepost = new LivePost() { LivePageID = livePageID, LiveName = liveName, FanPageID = fanPageId, //目前只有一個粉絲團,所以也暫時寫死,之後可選粉絲團後改fanPageID postTime = DateTime.UtcNow.AddHours(8) }; livepost_repo.Create(livepost); }
public static SalesOrderViewModel ListSalesOrders(string livepageId) { var salesorder_repo = new SalesOrderRepositories(); var live_repo = new LivePostsRepository(); List <int> liveids = live_repo.SelectIds(livepageId); var salesOrders = salesorder_repo.Select(liveids); string name = live_repo.SelectLiveName(livepageId); var salesOrderVM = new SalesOrderViewModel() { salesOrders = salesOrders, salesOrderNum = salesOrders.Count, total = salesOrders.Sum(x => x.Total), livename = name }; return(salesOrderVM); }
public static void SuccessOrderToSendMsg(string livePageId, OrderList order, string token) { LivePostsRepository livePost_repo = new LivePostsRepository(); var liveId = livePost_repo.Select(livePageId); CartViewModel cart = new CartViewModel() { salepage_id = order.Product.Salepage_id, sku_id = order.Product.SkuId, qty = order.Quantity }; var link = getAddToCartLink(cart, livePageId, "FB"); string msgText = $"{order.CustomerName}你好,感謝您訂購我們的產品!!\r\n{order.Product.ProductName}-數量{order.Quantity},請點擊下列連結完成接下來的購物流程!{link}"; List <string> id = new List <string> { order.CustomerID }; FBSendMsgService.SendMsg(msgText, id, token); }
public static CommentsRoot ListComments(string livePageId) { var live_repo = new LivePostsRepository(); var current_comments = live_repo.SelectComments(livePageId); DateTime start, end; string livename; start = current_comments.Min((x) => x.postTime); end = current_comments.Max((x) => x.endTime); livename = current_comments.Select((x) => x.LiveName).First(); var productsNameList = current_comments.Select((x) => x.ProductName).Distinct().ToList(); var cmtsRoot = new CommentsRoot() { comments = current_comments, postInfos = new LivePostInfo { LiveName = livename, postTime = start, endTime = end, ProductsName = productsNameList } }; return(cmtsRoot); }
public static List <Datum> PostTimeFilter(List <Datum> comments, string livePageID) { LivePostsRepository livePost_repo = new LivePostsRepository(); var livePostTime = livePost_repo.GetMaxPostTime(livePageID); //去Orders Table 看有沒有留言,有的話就抓最後一個留言的時間沒有的話就過濾livePostTime 的時間 var order_repo = new OrderRepositories(); var live_repo = new LivePostsRepository(); int liveid = live_repo.Select(livePageID); DateTime selectResult = order_repo.SelectLastOrderComment(liveid); //SQL 要改 if (selectResult != DateTime.MaxValue) { comments = comments.Where(x => DateTime.Compare(x.created_time.ToUniversalTime().AddHours(8), selectResult) > 0).ToList(); } else { comments = comments.Where(x => DateTime.Compare(x.created_time.ToUniversalTime().AddHours(8), livePostTime) > 0).ToList(); } return(comments); }