public async Task <int> GetCancelOrderState(string OrderId) { var ret = 0; ret = await IMER.UpdateOrderState(OrderId, 8); return(ret); }
public async Task <IActionResult> Success(ContactDataViewModel ContactData, string OrderId, string MemberMobile, byte OrderStateId = 40) { PostOrderViewModel1 povm = null; int ret = 0; try { if (OrderStateId == 1) { // 3.系統在Action【Cart/Success】判斷2傳送OrderStateId==1。 // 4.系統變更訂單狀態為1。 ret = await IMER.UpdateOrderState(OrderId, OrderStateId); if (ret != 0) { return(View(new PostOrderViewModel1 { OrderDetail = null, ContactData = null, CartTobal = -1, OrderId = "", RtnModel = null, MemberMobile = MemberMobile, ret = ret })); } } if (OrderStateId == 2) { // 3.系統在Action【Cart/Success】判斷2傳送OrderStateId==2。 // 4.系統變更訂單狀態為2。 ret = await IMER.UpdateOrderState(OrderId, OrderStateId); if (ret != 0) { return(View(new PostOrderViewModel1 { OrderDetail = null, ContactData = null, CartTobal = -1, OrderId = "", RtnModel = null, MemberMobile = MemberMobile, ret = ret })); } } List <OrderCheckProductStockEnoughViewModel> OCPSE = await IOR.OrderCheckProductStockEnough(OrderId); if (OCPSE == null) { return(View(new PostOrderViewModel1 { OrderDetail = null, ContactData = null, CartTobal = -1, OrderId = "", RtnModel = null, MemberMobile = MemberMobile, ret = ret, OCPSE = OCPSE })); } // 3a.系統在Action【Cart/Success】判斷2傳送OrderStateId!=1。 // 3a-1.回4-1。 // 4-1.系統刪除會員之所有購物車資料。 ret = await IMER.DeleteAllMemberCarts(MemberMobile); if (ret != 0) { return(View(new PostOrderViewModel1 { OrderDetail = null, ContactData = null, CartTobal = -1, OrderId = "", RtnModel = null, MemberMobile = MemberMobile })); } // 16.系統讀取訂單明細。 List <CartListViewModel> lstCLVM = await IOR.GetOrderDetail(OrderId); // 17.系統更新商品庫存。 ret = await IOR.UpdateProductStock(lstCLVM); if (ret != 0) { return(View(new PostOrderViewModel1 { OrderDetail = null, ContactData = null, CartTobal = -1, OrderId = "", RtnModel = null, MemberMobile = MemberMobile })); } // 5.系統在Action【Cart/Success】寄發建立訂單eMail(含平台連結)。 //EmailMessage em = new EmailMessage(); //EmailAddress fAdd = new EmailAddress(); //fAdd.Name = IEC.SmtpUsername; //fAdd.Address = $@"{IEC.SmtpUsername}"; ////fAdd.Address = $@"{IEC.SmtpUsername}@{IEC.SmtpServer}"; //em.FromAddresses.Add(fAdd); //EmailAddress tAdd = new EmailAddress(); //tAdd.Name = ContactData.MemberName; //tAdd.Address = ContactData.eMail; //em.ToAddresses.Add(tAdd); //em.Subject = "288訂購訊息"; //em.Content = "您好,\n"; //em.Content += $"您在288建立的訂單己完成,訂單代碼為{OrderId},<br>"; //em.Content += $"若為會員,請至本平台會員中心查詢訂單處理狀態,<br>"; //em.Content += $"若非會員,本平台會寄送eMail告知訂單處理狀況,<br>"; //em.Content += $"288網址:http://dreammaker.game.tw/YunQiWholesale,<br>"; //em.Content += $"客服專線:04-28825252"; //em.Content += $"288應謝您!"; // System.Net.Mail.MailMessage Message //IES.Send(em); // 5.系統在Action【Cart/Success】寄發建立訂單eMail(含平台連結)。 System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); mail.To.Add(ContactData.eMail); mail.From = new System.Net.Mail.MailAddress($@"{IEC.SmtpUsername}@{IEC.SmtpServer}"); mail.Subject = "288訂購訊息"; mail.Body = "您好,\n"; mail.Body += $"您在288建立的訂單己完成,訂單代碼為{OrderId},<br>"; mail.Body += $"若為會員,請至本平台會員中心查詢訂單處理狀態,<br>"; mail.Body += $"若非會員,本平台會寄送eMail告知訂單處理狀況,<br>"; mail.Body += $"288網址:http://dreammaker.game.tw/YunQiWholesale,<br>"; mail.Body += $"客服專線:04-28825252"; mail.Body += $"288應謝您!"; mail.IsBodyHtml = true; IES.SendMail(mail); // 6.系統判斷5執行成功。 // 7.系統回傳View【Cart/Success】,並傳回new PostOrderViewModel1 { OrderDetail=null, ContactData=contactData, CartTobal= null, OrderId=4上傳orderId, RtnModel=null }。 povm = new PostOrderViewModel1 { OrderDetail = null, ContactData = ContactData, CartTobal = -1, OrderId = OrderId, RtnModel = null, MemberMobile = MemberMobile }; } catch (Exception ex) { string msg = ex.Message; // 6a.系統判斷5執行失敗。 // 6a-1.系統回傳View【Cart/Success】,並傳回new PostOrderViewModel1 { OrderDetail=null, ContactData=null, CartTobal= null, OrderId="", RtnModel=null }。 povm = new PostOrderViewModel1 { OrderDetail = null, ContactData = null, CartTobal = -1, OrderId = "", RtnModel = null, MemberMobile = MemberMobile }; } return(View(povm)); }