internal static string make(string UserID, int QIDnow, int OIDnow, string data) { NextHelper nextHelper = new NextHelper(QIDnow, OIDnow); QuestionDetail questionDetailNext = nextHelper.GetNext(); //如果是取得參加碼,直接回傳藏在postback裡的data if (QIDnow == 101 && OIDnow == 1) { return(data); } else if (QIDnow == 73 && OIDnow == 2) { return(data); } else if (QIDnow == 53 && OIDnow == 1) { return(data); } else if (QIDnow == 153 && OIDnow == 1) { return(data); } else if (QIDnow == 9998) { switch (data) { case "accept": return("已向訂購者傳送確認訊息!"); case "refuse": return("已向訂購者傳送婉拒訊息!"); default: break; } } QuestionDetail questionDetail = new QuestionDetail(QIDnow, OIDnow); List <QuestionDetail> questionDetailList = questionDetail.SelectByQidAndOid(); switch (QIDnow) { case 121: UserStatus userStatustemp = new UserStatus(UserID); userStatustemp.SelectByUserID(); data = userStatustemp.TempData; break; default: break; } UserStatus userStatus = new UserStatus(UserID, questionDetailNext.QID, questionDetailNext.OID, data); userStatus.UpdateByUserID(); // 先偷做一些事情 switch (QIDnow) { case 71: switch (OIDnow) { case 3: // 把UserID加入訂單 break; default: break; } break; case 194: switch (OIDnow) { case 2: // 改品項的時候要先記錄改之前的品項到ShopTemp,之後才知道要改哪一筆 ShopTemp shopTemp = new ShopTemp(UserID); shopTemp.ShopItem = data; shopTemp.UpdateItemToShopTemp(); break; case 6: // 清空 shopTemp = new ShopTemp(UserID); shopTemp.InitializeShopTempByUserID(); shopTemp.DeleteShopItemTempByUserID(); userStatus.InitializeUserStatusByUserID(); break; default: break; } break; case 294: switch (OIDnow) { case 2: // 改品項的時候要先記錄改之前的品項到ShopTemp,之後才知道要改哪一筆 ShopTemp shopTemp = new ShopTemp(UserID); shopTemp.ShopItem = data; shopTemp.UpdateItemToShopTemp(); break; case 6: // 清空 shopTemp = new ShopTemp(UserID); shopTemp.InitializeShopTempByUserID(); shopTemp.DeleteShopItemTempByUserID(); userStatus.InitializeUserStatusByUserID(); break; default: break; } break; default: break; } return(questionDetailList[0].AnswerOption); }
// 參數postbackData是藏在button裡,經由postback傳進來的 // 參加社團和退出社團需要clubID,建立社團需要ClubName internal static string CommunicateClubInfo(string userId, int QID, int OID, string postbackData, string channelAccessToken) { UserStatus userStatus; ClubInfo clubInfo; switch (QID) { case 91: switch (OID) { case 3: try { clubInfo = new ClubInfo(userId, postbackData, ""); // 這裡的postbackData是clubID clubInfo.InsertClubInfoToSQL(); OrderInfo orderInfo = new OrderInfo(postbackData); //ClubID List <OrderInfo> list = orderInfo.CheckClubOrderByUserID(); string CheckMessage = "成功加入社團"; foreach (OrderInfo item in list) { if (item.OrderStatus == "available") { CheckMessage = "成功加入社團~~\n此社團有訂單正在推播中~~\n可以直接點選上面選項直接訂購喔~~"; // isRock.LineBot.Utility.PushMessage(userId, CheckMessage, channelAccessToken); OrderTemp orderTemp = new OrderTemp(userId); orderTemp.OrderPartitionID = item.OrderPartitionID; orderTemp.UpdateOrderPartitionIDByUserID(); string JasonMessage = FlexMaker.MakeSearchingItem(QID, OID, userId); isRock.LineBot.Utility.PushMessagesWithJSON(userId, JasonMessage, channelAccessToken); userStatus = new UserStatus(userId, 0, 0); userStatus.UpdateByUserID(); } // return CheckMessage; } userStatus = new UserStatus(userId, 0, 0); userStatus.UpdateByUserID(); return(CheckMessage); } catch (Exception e) { return("加入社團失敗,或是已加入社團"); } default: break; } break; case 92: switch (OID) { case 3: clubInfo = new ClubInfo(userId, postbackData); // 這裡的postbackData是clubName clubInfo.InsertClubInfoToSQL(); userStatus = new UserStatus(userId, 0, 0); userStatus.UpdateByUserID(); isRock.LineBot.Utility.PushMessage(userId, clubInfo.ClubID, channelAccessToken); return("你的社團已經建立嘍~~\n上方是你的社團參加碼~\n將此參加碼分享給要參加此社團的人~"); default: break; } break; case 102: switch (OID) { case 2: clubInfo = new ClubInfo(userId, postbackData, ""); clubInfo.DeleteClubInfoToSQL(); userStatus = new UserStatus(userId, 0, 0); userStatus.UpdateByUserID(); return(MessageMaker.MakeLeaveClubMessage(userId, QID, OID, postbackData)); default: break; } break; default: break; } return("資料庫溝通失敗"); }