internal static string MakeToShopBossFlex(string OrderPartitionID, string ShopID, string userId, out string BossID) { ShopInfo shopInfo = new ShopInfo(); shopInfo.ShopID = ShopID; shopInfo.SelectBossIDByShopID();//找出店家負責人shopInfo.ClubIDorUserIDorBossID BossID = shopInfo.ClubIDorUserIDorBossID; OrderInfo orderInfo = new OrderInfo(); orderInfo.OrderPartitionID = OrderPartitionID; string OrderPartitionIDSplitted = orderInfo.OrderPartitionID.Substring(0, 2); switch (OrderPartitionIDSplitted) { case "MO": // MyOrder orderInfo.SelectMyOrderTableByOrderPartitionID(); break; case "CO": // ClubOrder orderInfo.SelectClubOrderTableByOrderPartitionID(); break; default: break; } UserStatus userStatus = new UserStatus(userId); userStatus.SelectDisplayNameByUserID();//傳送訂單者名字 FlexReportToShop flexReportToShop = new FlexReportToShop(userStatus.UserDisplayName, orderInfo.OrderPartitionID); flexReportToShop.contents.body.contents.Add(new ShopNameAndDate() { text = $"{orderInfo.EndTime.ToString("yyyy-MM-dd HH:mm")}" }); flexReportToShop.contents.body.contents.Add(new FlexReportToShop.Content() { type = "separator", margin = "xxl" }); //分隔線 //// BuyerInfo buyerInfo = new BuyerInfo(); buyerInfo.OrderPartitionID = orderInfo.OrderPartitionID; List <string> Buyers = buyerInfo.SelectAllBuyerTotalPartitionID(); double totalprice = 0;//總價 // List<BuyerInfo> list = new List<BuyerInfo>(); ;//所有訂餐者 foreach (string Buyer in Buyers)//針對每個訂餐者做事 { userStatus = new UserStatus(Buyer); BuyerInfo buyer = new BuyerInfo(); buyer.OrderPartitionID = orderInfo.OrderPartitionID; buyer.BuyerID = Buyer; List <BuyerInfo> list = buyer.SelectItemAndAmontByBuyerID(); //選出訂餐者的訂餐細節 double subtotalprice = 0; //該訂餐者總價 foreach (BuyerInfo BuyerInfo in list) //處理訂餐細節 { subtotalprice += (BuyerInfo.Price * BuyerInfo.Amount); } totalprice += subtotalprice;//計算總價 } List <BuyerInfo> infos = buyerInfo.SelectBuyerSUMItemAndAmountByOrderPartitionID();//直接用SQL選出每個品項總數 List <TotalItem> totalItems = new List <TotalItem>(); foreach (BuyerInfo buyerinfo in infos) { totalItems.Add(new TotalItem() { Item = buyerinfo.Item, Amount = buyerinfo.Amount }); } flexReportToShop.AddTotal(totalItems, totalprice, Buyers, orderInfo.OrderPartitionID); //// JsonSerializerSettings settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; var json = JsonConvert.SerializeObject(flexReportToShop, settings); json = "[" + json + "]"; return(json); }