internal static string MyPeriodOrderCommunicate(string userId, int QID, int OID, string OrderName, string channelAccessToken) { PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(userId); periodOrderTmp.SelectAllByUserID(); OrderInfo orderinfo = new OrderInfo(); //準備輸入SQL switch (QID) //根據QID不同初始化clubOrderAndMyOrder { case 211: orderinfo = new OrderInfo(userId, OrderName); break; default: break; } //切割週期時間 DateTime st1 = periodOrderTmp.StartDate.Add(periodOrderTmp.StartTime); //第一次開單時間點 DateTime et1 = periodOrderTmp.EndDate.Add(periodOrderTmp.StartTime); //最後一次開單時間點 DateTime st2 = periodOrderTmp.StartDate.Add(periodOrderTmp.EndTime); //第一次收單時間點 DateTime et2 = periodOrderTmp.EndDate.Add(periodOrderTmp.EndTime); //最後一次收單時間點 if (DateTimeChecker.DateTimeCheckIsEarlierThanNow(st1)) //週期單開始時間點若是比現在時間點早則往後一天 { st1 = st1.AddDays(1); st2 = st2.AddDays(1); } List <string> weekList = new List <string>(); if (periodOrderTmp.Monday == "Y") { weekList.Add("Monday"); } if (periodOrderTmp.Tuesday == "Y") { weekList.Add("Tuesday"); } if (periodOrderTmp.Wednesday == "Y") { weekList.Add("Wednesday"); } if (periodOrderTmp.Thursday == "Y") { weekList.Add("Thursday"); } if (periodOrderTmp.Friday == "Y") { weekList.Add("Friday"); } if (periodOrderTmp.Saturday == "Y") { weekList.Add("Saturday"); } if (periodOrderTmp.Sunday == "Y") { weekList.Add("Sunday"); } List <DateTime> dateTimes = PeriodSplitter.Cut(st1, et1, weekList); //得到每次的開單時間點 List <DateTime> dateTimes2 = PeriodSplitter.Cut(st2, et2, weekList); //得到每次的收單時間點 // orderinfo.OrderType = "Period"; orderinfo.OrderStatus = "wait"; //開始撈取使用者選擇的複數商店 ShopListTemp shopListTemp = new ShopListTemp(userId); List <ShopListTemp> shopListTemps = shopListTemp.SelectByUserID(); //選取的商店清單 List <ShopListTemp> randomshopListTemps = new List <ShopListTemp>(); //準備一個要裝進符合選取天數的清單 //將randomshopListTemps打亂 while (randomshopListTemps.Count <= dateTimes.Count) { for (int i = 0; i < shopListTemps.Count; i++) { Swap(shopListTemps); } for (int i = 0; i < shopListTemps.Count; i++) { randomshopListTemps.Add(shopListTemps[i]); } } // int result = 0; int count = 0; //用來檢查迴圈有沒有跑完 string OrderID; switch (QID) { case 211: OrderID = orderinfo.OrderID; for (int i = 0; i < dateTimes.Count; i++) { orderinfo.StartTime = dateTimes[i]; orderinfo.EndTime = dateTimes2[i]; orderinfo.ShopID = randomshopListTemps[i].ShopID; orderinfo.OrderPartitionID = "MOP" + OrderID + $"-{ dateTimes[i].ToString("yyyyMMdd")}"; result = orderinfo.InserMyOrderTableToSQL(); if (result <= 0) { break; } count++; } break; default: break; } if (count == dateTimes.Count) { UserStatus userStatus = new UserStatus(userId); userStatus.InitializeUserStatusByUserID(); periodOrderTmp = new PeriodOrderTmp(userId); periodOrderTmp.UpdateInitialPeriodOrderTmp(); orderinfo.InsertOrdeUserTable(); shopListTemp.DeleteByUserID(); isRock.LineBot.Utility.PushMessage(userId, orderinfo.OrderID, channelAccessToken); // string orderCreateMessage = "上面是你的訂單參加碼,可以將此參加碼分享給其他人,讓其他人加入你的訂單喔~"; // isRock.LineBot.Utility.PushMessage(userId, orderCreateMessage, channelAccessToken); return("訂單建立成功喔~~\n上面是你的訂單參加碼,可以將此參加碼分享給其他人,讓其他人加入你的訂單喔~"); } else { return("訂單建立失敗"); } }
internal static string ClubPeriodOrderCommunicate(string userId, int QID, int OID, string OrderName, string channelAccessToken) { PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(userId); periodOrderTmp.SelectAllByUserID(); OrderInfo orderinfo = new OrderInfo(); //準備輸入SQL switch (QID) //根據QID不同初始化clubOrderAndMyOrder { case 251: periodOrderTmp.ClubIDSelectByUserID(); //撈取ClubID orderinfo = new OrderInfo(periodOrderTmp.ClubID, OrderName); break; default: break; } //切割週期時間 DateTime st1 = periodOrderTmp.StartDate.Add(periodOrderTmp.StartTime); //第一次開單時間點 DateTime et1 = periodOrderTmp.EndDate.Add(periodOrderTmp.StartTime); //最後一次開單時間點 DateTime st2 = periodOrderTmp.StartDate.Add(periodOrderTmp.EndTime); //第一次收單時間點 DateTime et2 = periodOrderTmp.EndDate.Add(periodOrderTmp.EndTime); //最後一次收單時間點 List <string> weekList = new List <string>(); if (periodOrderTmp.Monday == "Y") { weekList.Add("Monday"); } if (periodOrderTmp.Tuesday == "Y") { weekList.Add("Tuesday"); } if (periodOrderTmp.Wednesday == "Y") { weekList.Add("Wednesday"); } if (periodOrderTmp.Thursday == "Y") { weekList.Add("Thursday"); } if (periodOrderTmp.Friday == "Y") { weekList.Add("Friday"); } if (periodOrderTmp.Saturday == "Y") { weekList.Add("Saturday"); } if (periodOrderTmp.Sunday == "Y") { weekList.Add("Sunday"); } List <DateTime> dateTimes = PeriodSplitter.Cut(st1, et1, weekList); //得到每次的開單時間點 List <DateTime> dateTimes2 = PeriodSplitter.Cut(st2, et2, weekList); //得到每次的收單時間點 orderinfo.OrderType = "Period"; orderinfo.OrderStatus = "wait"; //開始撈取使用者選擇的複數商店 ShopListTemp shopListTemp = new ShopListTemp(userId); List <ShopListTemp> shopListTemps = shopListTemp.SelectByUserID(); //選取的商店清單 List <ShopListTemp> randomshopListTemps = new List <ShopListTemp>(); //準備一個要裝進符合選取天數的清單 //將randomshopListTemps打亂 while (randomshopListTemps.Count <= dateTimes.Count) { for (int i = 0; i < shopListTemps.Count; i++) { Swap(shopListTemps); } for (int i = 0; i < shopListTemps.Count; i++) { randomshopListTemps.Add(shopListTemps[i]); } } int result = 0; int count = 0; //用來檢查迴圈有沒有跑完 string clubOrderAndMyOrderID; switch (QID) { case 251: clubOrderAndMyOrderID = orderinfo.OrderID; for (int i = 0; i < dateTimes.Count; i++) { orderinfo.StartTime = dateTimes[i]; orderinfo.EndTime = dateTimes2[i]; orderinfo.ShopID = randomshopListTemps[i].ShopID; orderinfo.OrderPartitionID = "COP" + clubOrderAndMyOrderID + $"-{ dateTimes[i].ToString("yyyyMMdd")}"; result = orderinfo.InserClubOrderTableToSQL(); if (result <= 0) { break; } count++; } break; default: break; } if (count == dateTimes.Count) { UserStatus userStatus = new UserStatus(userId); userStatus.InitializeUserStatusByUserID(); periodOrderTmp = new PeriodOrderTmp(userId); periodOrderTmp.UpdateInitialPeriodOrderTmp(); shopListTemp.DeleteByUserID(); return("訂單建立成功"); } else { return("訂單建立失敗"); } }
internal static ImagemapMessage MakeMenu(Event item) { // 先做初始化 UserStatus userStatus = new UserStatus(item.source.userId); userStatus.InitializeUserStatusByUserID(); ShopTemp shopTemp = new ShopTemp(item.source.userId); shopTemp.InitializeShopTempByUserID(); shopTemp.DeleteShopItemTempByUserID(); OrderTemp orderTemp = new OrderTemp(item.source.userId); orderTemp.UpdateInitialOrderTemp(); PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(item.source.userId); periodOrderTmp.UpdateInitialPeriodOrderTmp(); ShopListTemp shopListTemp = new ShopListTemp(item.source.userId); shopListTemp.DeleteByUserID(); BuyerTemp buyerTemp = new BuyerTemp(item.source.userId); buyerTemp.DeleteByBuyerID(); // 先做初始化 ImagemapMessage imagemapMessage = new ImagemapMessage(); Uri uri = new Uri("https://i220.photobucket.com/albums/dd130/jung_04/Menu2.png#"); imagemapMessage.baseUrl = uri; imagemapMessage.altText = "這是imagemap"; Size size = new Size(1040, 1040); imagemapMessage.baseSize = size; #region LeftUp isRock.LineBot.ImagemapArea imagemapAreaLeftUp = new isRock.LineBot.ImagemapArea() { x = 0, y = 0, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionLeftUp = new ImagemapMessageAction(); imagemapMessageActionLeftUp.area = imagemapAreaLeftUp; imagemapMessageActionLeftUp.text = "我要進入訂單模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionLeftUp); #endregion #region RightUp isRock.LineBot.ImagemapArea imagemapAreaRightUp = new isRock.LineBot.ImagemapArea() { x = 520, y = 0, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionRightUp = new ImagemapMessageAction(); imagemapMessageActionRightUp.area = imagemapAreaRightUp; imagemapMessageActionRightUp.text = "我要進入個人模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionRightUp); #endregion #region LeftDown isRock.LineBot.ImagemapArea imagemapAreaLeftDown = new isRock.LineBot.ImagemapArea() { x = 0, y = 520, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionLeftDown = new ImagemapMessageAction(); imagemapMessageActionLeftDown.area = imagemapAreaLeftDown; imagemapMessageActionLeftDown.text = "我要進入社團模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionLeftDown); #endregion #region RightDown var actions1 = new List <isRock.LineBot.ImagemapActionBase>(); isRock.LineBot.ImagemapArea imagemapAreaRightDown = new isRock.LineBot.ImagemapArea() { x = 520, y = 520, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionRightDown = new ImagemapMessageAction(); imagemapMessageActionRightDown.area = imagemapAreaRightDown; imagemapMessageActionRightDown.text = "我要進入商店模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionRightDown); #endregion return(imagemapMessage); }