internal static string MakeSearchingItem(int QIDnow, int OIDnow, string UserID) { // 從OrderTemp裡面拿到OrderPartitionID OrderTemp orderTemp = new OrderTemp(UserID); orderTemp.SelectByUserID(); // 用OrderPartitionID去找到ShopID,再用ShopID找到ShopItem OrderInfo orderInfo = new OrderInfo(UserID); orderInfo.OrderPartitionID = orderTemp.OrderPartitionID; string OrderPartitionIDSplitted = orderTemp.OrderPartitionID.Substring(0, 2); switch (OrderPartitionIDSplitted) { case "MO": // MyOrder orderInfo.SelectMyOrderTableByOrderPartitionID(); break; case "CO": // ClubOrder orderInfo.SelectClubOrderTableByOrderPartitionID(); break; default: break; } //NextHelper nextHelper = new NextHelper(QIDnow, OIDnow); //QuestionDetail questionDetailNext = nextHelper.GetNext(); //PreviousHelper previousHelper = new PreviousHelper(QIDnow, OIDnow); //QuestionDetail questionDetailPrevious = previousHelper.GetPrevious(); //CancelHelper cancelHelper = new CancelHelper(QIDnow, OIDnow); //QuestionDetail questionDetailCancel = cancelHelper.GetCancel(); ShopItem shopItem = new ShopItem(orderInfo.ShopID); List <ShopItem> myshopItems = shopItem.SelectByMyShopID(); List <ShopItem> bossshopItems = shopItem.SelectByBossShopID(); List <ShopItem> clubshopItems = shopItem.SelectByClubShopID(); ShopInfo shopInfo = new ShopInfo(); shopInfo.ShopID = orderInfo.ShopID; string OrderShopName; ShopImage shopImage = new ShopImage(orderInfo.ShopID); List <string> BossShopimagesUris = shopImage.SelectImageByShopID(); //抓出該商店的圖片 ShuffleImage(BossShopimagesUris); //隨機洗亂 ///// string DefaultUri = "https://i220.photobucket.com/albums/dd130/jung_04/GJ.gif"; //Flex圖片超連結 int ButtonControl = 4; //設定Button數量 ///// int ButtonCount = 0; //控制Button數量 FlexPushOrderMenu flexPushOrderMenu = new FlexPushOrderMenu(); if (myshopItems.Count > 0) { shopInfo.SelectMyShopNameByShopID(); OrderShopName = shopInfo.ShopName; int BubbleCount = 0; flexPushOrderMenu.contents.contents.Add(new FlexPushOrderMenu.Bubble(DefaultUri)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.OrderName(orderInfo.OrderName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName("結單時間:" + orderInfo.StartTime.ToString("yyyy-MM-dd HH:mm"))); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName(OrderShopName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.Content2() { type = "separator", margin = "xxl" }); //分隔線 foreach (ShopItem item in myshopItems) { if (ButtonCount >= ButtonControl) { ButtonCount = 0; BubbleCount++; flexPushOrderMenu.contents.contents.Add(new FlexPushOrderMenu.Bubble(DefaultUri)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.OrderName(orderInfo.OrderName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName("結單時間:" + orderInfo.EndTime.ToString("yyyy-MM-dd HH:mm"))); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName(OrderShopName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.Content2() { type = "separator", margin = "xxl" }); //分隔線 } flexPushOrderMenu.contents.contents[BubbleCount].footer.contents.Add(new FlexPushOrderMenu.OrderButton(item.shopItem, item.ShopItemPrice)); flexPushOrderMenu.contents.contents[BubbleCount].footer.contents[ButtonCount].action.data = DateTime.Now.Add((orderInfo.EndTime - orderInfo.StartTime).Add(new TimeSpan(0, -5, 0)))//主程式檢查按鈕有效時間為5分鐘 + "," + 9999 + "," + 2 + "," + orderInfo.OrderPartitionID + "," + item.shopItem + "," + item.ShopItemPrice; ButtonCount++; } } if (bossshopItems.Count > 0) { if (bossshopItems.Count >= BossShopimagesUris.Count * ButtonControl) { int NeedAddcount = bossshopItems.Count - BossShopimagesUris.Count; for (int i = 0; i <= NeedAddcount; i++) { BossShopimagesUris.Add(BossShopimagesUris[i]); } } shopInfo.SelectBossShopNameByShopID(); OrderShopName = shopInfo.ShopName; int BubbleCount = 0; flexPushOrderMenu.contents.contents.Add(new FlexPushOrderMenu.Bubble(BossShopimagesUris[0])); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.OrderName(orderInfo.OrderName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName("結單時間:" + orderInfo.EndTime.ToString("yyyy-MM-dd HH:mm"))); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName(OrderShopName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.Content2() { type = "separator", margin = "xxl" }); //分隔線 foreach (ShopItem item in bossshopItems) { if (ButtonCount >= ButtonControl) { ButtonCount = 0; BubbleCount++; flexPushOrderMenu.contents.contents.Add(new FlexPushOrderMenu.Bubble(BossShopimagesUris[BubbleCount])); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.OrderName(orderInfo.OrderName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName("結單時間:" + orderInfo.EndTime.ToString("yyyy-MM-dd HH:mm"))); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName(OrderShopName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.Content2() { type = "separator", margin = "xxl" }); //分隔線 } flexPushOrderMenu.contents.contents[BubbleCount].footer.contents.Add(new FlexPushOrderMenu.OrderButton(item.shopItem, item.ShopItemPrice)); flexPushOrderMenu.contents.contents[BubbleCount].footer.contents[ButtonCount].action.data = DateTime.Now.Add((orderInfo.EndTime - orderInfo.StartTime).Add(new TimeSpan(0, -5, 0)))//主程式檢查按鈕有效時間為5分鐘 + "," + 9999 + "," + 2 + "," + orderInfo.OrderPartitionID + "," + item.shopItem + "," + item.ShopItemPrice; ButtonCount++; } } if (clubshopItems.Count > 0) { shopInfo.SelectClubShopNameByShopID(); OrderShopName = shopInfo.ShopName; int BubbleCount = 0; flexPushOrderMenu.contents.contents.Add(new FlexPushOrderMenu.Bubble(DefaultUri)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.OrderName(orderInfo.OrderName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName("結單時間:" + orderInfo.EndTime.ToString("yyyy-MM-dd HH:mm"))); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName(OrderShopName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.Content2() { type = "separator", margin = "xxl" }); //分隔線 foreach (ShopItem item in clubshopItems) { if (ButtonCount >= ButtonControl) { ButtonCount = 0; BubbleCount++; flexPushOrderMenu.contents.contents.Add(new FlexPushOrderMenu.Bubble(DefaultUri)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.OrderName(orderInfo.OrderName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName("結單時間:" + orderInfo.EndTime.ToString("yyyy-MM-dd HH:mm"))); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.DateAndShopName(OrderShopName)); flexPushOrderMenu.contents.contents[BubbleCount].body.contents.Add(new FlexPushOrderMenu.Content2() { type = "separator", margin = "xxl" }); //分隔線 } flexPushOrderMenu.contents.contents[BubbleCount].footer.contents.Add(new FlexPushOrderMenu.OrderButton(item.shopItem, item.ShopItemPrice)); flexPushOrderMenu.contents.contents[BubbleCount].footer.contents[ButtonCount].action.data = DateTime.Now.Add((orderInfo.EndTime - orderInfo.StartTime).Add(new TimeSpan(0, -5, 0)))//主程式檢查按鈕有效時間為5分鐘 + "," + 9999 + "," + 2 + "," + orderInfo.OrderPartitionID + "," + item.shopItem + "," + item.ShopItemPrice; ButtonCount++; } } JsonSerializerSettings settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; var json = JsonConvert.SerializeObject(flexPushOrderMenu, settings); return("[" + json + "]"); }
internal static string CommunicateUserInfo(string userId, int QID, int OID, string postbackData, string channelAccessToken) { UserStatus userStatus; OrderInfo orderInfo; int result; switch (QID) { case 71: switch (OID) { case 3: // 先拿到UserStatus裡面的TempData,上一步存的是OrderID userStatus = new UserStatus(userId); userStatus.SelectByUserID(); // 把資料存進OrderUserTable裡 orderInfo = new OrderInfo(userId); orderInfo.OrderID = userStatus.TempData; result = orderInfo.InsertOrdeUserTable(); if (result > 0) { List <OrderInfo> list = orderInfo.SelectMyOrderByOrderID(); if (list[0].OrderStatus == "available") { string CheckMessage = "成功參加訂單~~\n此訂單正在推播中~~\n可以直接點選上面選項直接訂購喔~~"; // isRock.LineBot.Utility.PushMessage(userId, CheckMessage, channelAccessToken); OrderTemp orderTemp = new OrderTemp(userId); orderTemp.OrderPartitionID = list[0].OrderPartitionID; orderTemp.UpdateOrderPartitionIDByUserID(); string JasonMessage = FlexMaker.MakeSearchingItem(QID, OID, userId); isRock.LineBot.Utility.PushMessagesWithJSON(userId, JasonMessage, channelAccessToken); return(CheckMessage); } else { return("成功參加訂單"); } } else { return("參加訂單失敗"); } default: break; } break; case 82: switch (OID) { case 2: OrderTemp orderTemp = new OrderTemp(userId); orderTemp.SelectByUserID(); orderInfo = new OrderInfo(userId); orderInfo.OrderPartitionID = orderTemp.OrderPartitionID; orderInfo.SelectMyOrderTableByOrderPartitionID(); switch (postbackData) { case "MyOrderPartition": // 刪除我的週期性訂單的其中一筆 result = orderInfo.DeleteMyOrderPartitionByUserIDandOrderPartitionID(); if (result > 0) { return("成功刪除訂單"); } else { return("刪除訂單失敗"); } case "MyOrder": // 刪除完整我的週期性訂單 result = orderInfo.DeleteMyOrderByUserIDandOrderID(); if (result > 0) { return("成功刪除訂單"); } else { return("刪除訂單失敗"); } case "MyOnceOrder": // 刪除一次性我的訂單 result = orderInfo.DeleteMyOrderByUserIDandOrderID(); if (result > 0) { return("成功刪除訂單"); } else { return("刪除訂單失敗"); } default: break; } break; default: break; } break; default: break; } return("資料庫溝通失敗"); }
internal static string UpdateOrder(int QID, int OID, string userId) { int result = 0; OrderTemp orderTemp; OrderInfo orderInfo; switch (QID) { case 61: orderTemp = new OrderTemp(userId); orderTemp.SelectByUserID(); orderInfo = new OrderInfo(userId); orderInfo.OrderPartitionID = orderTemp.OrderPartitionID; orderInfo.SelectMyOrderTableByOrderPartitionID(); orderInfo.StartTime = orderTemp.StartTime; orderInfo.EndTime = orderTemp.EndTime; switch (orderInfo.OrderStatus) { case "wait": orderInfo.OrderStatus = "wait"; result = orderInfo.UpdateTimeByOrderPartitionIDToMyOrder(); break; case "available": orderInfo.OrderStatus = "wait"; result = orderInfo.UpdateTimeByOrderPartitionIDToMyOrder(); break; case "done": return("此訂單已經結單,無法再改時間囉~"); break; default: break; } // result = orderInfo.UpdateTimeByOrderPartitionIDToMyOrder(); break; case 161: orderTemp = new OrderTemp(userId); orderTemp.ClubIDSelectByUserID(); orderTemp.SelectByUserID(); orderInfo = new OrderInfo(orderTemp.ClubID); orderInfo.OrderPartitionID = orderTemp.OrderPartitionID; orderInfo.SelectClubOrderTableByOrderPartitionID(); orderInfo.StartTime = orderTemp.StartTime; orderInfo.EndTime = orderTemp.EndTime; switch (orderInfo.OrderStatus) { case "wait": orderInfo.OrderStatus = "wait"; result = orderInfo.UpdateTimeByOrderPartitionIDTOClubOrder(); break; case "available": orderInfo.OrderStatus = "wait"; result = orderInfo.UpdateTimeByOrderPartitionIDTOClubOrder(); break; case "done": return("此訂單已經結單,無法再改時間囉~"); break; default: break; } // result = orderInfo.UpdateTimeByOrderPartitionIDTOClubOrder(); break; default: break; } if (result > 0) { orderTemp = new OrderTemp(userId); orderTemp.UpdateInitialOrderTemp(); return("修改成功"); } else { return("修改失敗"); } }
internal static string CommunicateOrder(string userId, int QID, int OID, string OrderName, string channelAccessToken) { OrderTemp orderTmp = new OrderTemp(userId); orderTmp.SelectByUserID(); //這裡主要從OrderTmp抓取起始時間跟結束時間,ShopID OrderInfo orderinfo = new OrderInfo(); //準備輸入SQL的資料 switch (QID) //根據QID不同初始化clubOrderAndMyOrder { case 201: orderinfo = new OrderInfo(userId, OrderName); break; case 231: //231只修改shopID orderinfo = new OrderInfo(userId); orderTmp.SelectByUserID(); orderTmp.ShopID = OrderName; //在此處傳進來OrderName是ShopID break; case 241: orderTmp.ClubIDSelectByUserID(); //撈取ClubID orderinfo = new OrderInfo(orderTmp.ClubID, OrderName); break; case 261: orderTmp.ClubIDSelectByUserID(); //撈取ClubID orderinfo = new OrderInfo(orderTmp.ClubID); orderTmp.SelectByUserID(); orderTmp.ShopID = OrderName; //在此處傳進來OrderName是ShopID break; default: break; } orderinfo.StartTime = orderTmp.StartTime; orderinfo.EndTime = orderTmp.EndTime; orderinfo.ShopID = orderTmp.ShopID; if (QID == 201 | QID == 241) { orderinfo.OrderType = "Once"; } else { orderinfo.OrderType = "Period"; } orderinfo.OrderStatus = "wait"; int result = 0; switch (QID) { case 201: orderinfo.OrderPartitionID = "MOO" + orderinfo.OrderID; result = orderinfo.InserMyOrderTableToSQL(); break; case 231: //修改MyOrder訂單店家 orderinfo.OrderPartitionID = orderTmp.OrderPartitionID; result = orderinfo.UpdateShopIDByOrderPartitionIDToMyOrder(); if (result > 0) { return("修改完成"); } else { return("修改失敗"); } break; case 241: orderinfo.OrderPartitionID = "COO" + orderinfo.OrderID; result = orderinfo.InserClubOrderTableToSQL(); if (result > 0) { UserStatus userStatus = new UserStatus(userId); userStatus.InitializeUserStatusByUserID(); orderTmp.UpdateInitialOrderTemp(); orderTmp = new OrderTemp(userId); return("社團訂單建立成功,所有社團成員皆能收到此訂單通知,無須再讓成員加入訂單喔~"); } break; case 261: orderinfo.OrderPartitionID = orderTmp.OrderPartitionID; result = orderinfo.UpdateShopIDByOrderPartitionIDToClubOrder(); if (result > 0) { return("修改完成"); } else { return("修改失敗"); } break; default: break; } if (result > 0) { UserStatus userStatus = new UserStatus(userId); userStatus.InitializeUserStatusByUserID(); orderTmp = new OrderTemp(userId); orderinfo.InsertOrdeUserTable(); orderTmp.UpdateInitialOrderTemp(); isRock.LineBot.Utility.PushMessage(userId, orderinfo.OrderID, channelAccessToken); // string orderCreateMessage = "上面是你的訂單參加碼,可以將此參加碼分享給其他人,讓其他人加入你的訂單喔~"; // isRock.LineBot.Utility.PushMessage(userId, orderCreateMessage, channelAccessToken); return("訂單建立成功喔~~\n上面是你的訂單參加碼,可以將此參加碼分享給其他人,讓其他人加入你的訂單喔~"); } else { return("訂單建立失敗"); } }
private static string GetConfirmText(int QID, int OID, string UserIDorClubIDorOrderID) { OrderInfo orderInfo; switch (QID) { case 52: orderInfo = new OrderInfo(); orderInfo.OrderID = UserIDorClubIDorOrderID; orderInfo.SelectMyOrderNameByOrderID(); return($"確定要刪除:{orderInfo.OrderName} 嗎???"); case 61: switch (OID) { case 2: OrderTemp orderTemp = new OrderTemp(UserIDorClubIDorOrderID); orderTemp.SelectByUserID(); return($"請確認將開單時間修改為:{orderTemp.StartTime.ToString("yyyy-MM-dd HH:mm")},結單時間修改為:{orderTemp.EndTime.ToString("yyyy-MM-dd HH:mm")} 嗎???"); default: break; } break; case 102: switch (OID) { case 1: ClubInfo clubInfo = new ClubInfo(); clubInfo.ClubID = UserIDorClubIDorOrderID; // 這裡用ClubID return($"確定離開 {clubInfo.SelectByClubid()[0].ClubName} 嗎???"); default: break; } break; case 152: orderInfo = new OrderInfo(); orderInfo.OrderID = UserIDorClubIDorOrderID; orderInfo.SelectClubOrderNameByOrderID(); return($"確定要刪除:{orderInfo.OrderName} 嗎???"); case 161: switch (OID) { case 2: OrderTemp orderTemp = new OrderTemp(UserIDorClubIDorOrderID); orderTemp.SelectByUserID(); return($"請確認將開單時間修改為:{orderTemp.StartTime.ToString("yyyy-MM-dd HH:mm")},結單時間修改為:{orderTemp.EndTime.ToString("yyyy-MM-dd HH:mm")} 嗎???"); default: break; } break; case 171: switch (OID) { case 7: ShopTemp shopTemp = new ShopTemp(UserIDorClubIDorOrderID); // 這裡用UserID shopTemp.GetMyShopTempInfoFromSQL(); List <ShopTemp> shopItems = shopTemp.GetShopItemTempFromSQL(); string confirmText1 = $"請確認建立商店資訊:" + $"商店名稱:{shopTemp.ShopName}," + $"商店電話:{shopTemp.ShopPhone}," + $"商店地址:{shopTemp.ShopAddress},商店品項:"; string confirmText2 = ""; for (int i = 0; i < shopItems.Count; i++) { confirmText2 += $"{shopItems[i].ShopItem}({shopItems[i].ShopItemPrice} TWD) "; } return(confirmText1 + confirmText2); default: break; } break; case 201: switch (OID) { case 3: return($"確定建立嗎???"); default: break; } break; case 211: switch (OID) { case 3: return($"要繼續選擇商店嗎???"); default: break; } break; case 231: switch (OID) { case 3: ShopInfo shopInfo = new ShopInfo(); shopInfo.ShopID = UserIDorClubIDorOrderID; shopInfo.SelectMyShopNameByShopID(); if (shopInfo.ShopName != null) { return($"確定將此訂單商店換成 {shopInfo.ShopName} 嗎???"); } else { List <ShopInfo> shopInfos = shopInfo.BossShopSelectShopNameByShopid(); return($"確定將此訂單商店換成 {shopInfos[0].ShopName} 嗎???"); } default: break; } return(""); case 241: switch (OID) { case 3: return($"確定建立嗎???"); default: break; } break; case 251: switch (OID) { case 3: return($"要繼續選擇商店嗎???"); default: break; } break; case 261: switch (OID) { case 3: ShopInfo shopInfo = new ShopInfo(); shopInfo.ShopID = UserIDorClubIDorOrderID; shopInfo.SelectMyShopNameByShopID(); if (shopInfo.ShopName != null) { return($"確定將此訂單商店換成 {shopInfo.ShopName} 嗎???"); } else { List <ShopInfo> shopInfos = shopInfo.BossShopSelectShopNameByShopid(); return($"確定將此訂單商店換成 {shopInfos[0].ShopName} 嗎???"); } default: break; } return(""); case 121: switch (OID) { case 5: return("需要繼續修改其他品項嗎?"); default: break; } break; case 271: switch (OID) { case 7: ShopTemp shopTemp = new ShopTemp(UserIDorClubIDorOrderID); // 這裡用UserID shopTemp.GetClubShopTempInfoFromSQL(); List <ShopTemp> shopItems = shopTemp.GetShopItemTempFromSQL(); string confirmText1 = $"請確認建立社團商店資訊:" + $"商店名稱:{shopTemp.ShopName}," + $"商店電話:{shopTemp.ShopPhone}," + $"商店地址:{shopTemp.ShopAddress},商店品項:"; string confirmText2 = ""; for (int i = 0; i < shopItems.Count; i++) { confirmText2 += $"{shopItems[i].ShopItem}({shopItems[i].ShopItemPrice} TWD) "; } return(confirmText1 + confirmText2); default: break; } break; default: break; } return(""); }