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("訂單建立失敗"); } }
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("修改失敗"); } }