public void SendEmailToGuest(OrderComplete orderlist, Member memberdata)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<p>" + orderlist.buyers + "您好:</p>");
            sb.Append("<p>已經收到您的訂購單,感謝您的訂購!</p>");
            sb.Append("<p>感謝您向 FUNN 訂購商品,以下為您的訂購清單,您可以至<strong>「<a href='http://funnmtb.com.tw/Member/Orderlist?mem=2'>訂單查詢</a>」</strong>了解最新訂單處理進度。</p>");
            sb.Append("<p><strong><span style='font-size:18px;'>商店資訊:</span></strong></p>");
            sb.Append("<table border='0' cellpadding='1' cellspacing='1' width='100%'>");
            sb.Append("<tbody>");
            sb.Append("<tr>");
            sb.Append("<th scope='col' width='20%'>訂單編號</th>");
            sb.Append("<th scope='col' style='text-align: left;' width='80%'>" + orderlist.orderId + "</th>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>訂購人</th>");
            sb.Append("<td>" + orderlist.buyemail + "</td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>聯絡電話</th>");
            sb.Append("<td>" + orderlist.buyers_tel + "</td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>取貨人</th>");
            sb.Append("<td>" + orderlist.consignee + "</td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>取貨人電話</th>");
            sb.Append("<td>" + orderlist.consignee_tel + "</td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>取貨人手機</th>");
            sb.Append("<td>" + orderlist.consignee_phone + "<</td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>取貨人地址</th>");
            sb.Append("<td>" + (orderlist.city + orderlist.area + orderlist.address) + "</td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>發票格式</th>");
            sb.Append("<td>" + orderlist.pay_invoice + "</td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>統一編號</th>");
            sb.Append("<td>" + orderlist.number + "</td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>抬頭</th>");
            sb.Append("<td>" + orderlist.invoice_title + "</td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>下單時間</th>");
            sb.Append("<td>" + orderlist.wdate + "</td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>運送方式</th>");
            sb.Append("<td>" + orderlist.transport + "</td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>付款方式</th>");
            sb.Append("<td>" + orderlist.pay_mode + "</td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<th scope='row'>備註</th>");
            sb.Append("<td>" + orderlist.demo + "</td>");
            sb.Append("</tr>");
            sb.Append("</tbody>");
            sb.Append("</table>");
            sb.Append("<p><strong><span style='font-size:18px;'>訂購資訊:</span></strong></p>");
            sb.Append("<table border='0'cellpadding='1' cellspacing='1' style='width:100%;'>");
            sb.Append("<tbody>");
            sb.Append("<tr>");
            sb.Append("<td style='text-align: center;'>產品名稱</td>");
            sb.Append("<td style='text-align: center;'>數量</td>");
            sb.Append("<td style='text-align: center;'>小計</td>");
            sb.Append("</tr>");

            var jsonstr = JsonConvert.DeserializeObject<List<productlistforCart>>(orderlist.productJson);
            var jsonProSize = "";
            var jsonProColor = "";
            if (jsonstr != null)
            {
                foreach (var j in jsonstr)
                {
                    var procolor = pcd.Get().ToList().Where(a => a.num == j.pcolor);
                    var prosize = psd.Get().ToList().Where(a => a.num == j.psize);
                    if (prosize != null)
                    {
                        var prosized = prosize.SingleOrDefault();
                        jsonProSize = prosized.size;
                    }
                    if (procolor != null)
                    {
                        var procolord = procolor.SingleOrDefault();
                        jsonProColor = procolord.color;
                    }
                    sb.Append("<tr>");
                    sb.Append("<td style='text-align: center;'>" + j.pname + "-" + jsonProSize + "-" + jsonProColor + "</td>");
                    sb.Append("<td style='text-align: center;'>" + j.qty + "</td>");
                    sb.Append("<td style='text-align: center;'>$" + j.price + "</td>");
                    sb.Append("</tr>");
                }
            }

            sb.Append("<tr>");
            sb.Append("<td colspan='3' style='text-align: center;'>總計:$" + orderlist.Total + "元</td>");
            sb.Append("</tr>");
            sb.Append("</tbody>");
            sb.Append("</table>");
            //sb.Append("<p><strong><span style='font-size:18px;'>繳費資訊:</span></strong></p>");
            //sb.Append("<table border='0' cellpadding='1' cellspacing='1' style='width:100%;'>");
            //sb.Append("<tbody>");
            //sb.Append("<tr>");
            //sb.Append("<td colspan='2' style='text-align: center;'>繳費資訊</td>");
            //sb.Append("</tr>");
            //sb.Append("<tr>");
            //sb.Append("<td style='text-align: center;'>應付金額</td>");
            //sb.Append("<td style='text-align: center;'>$" + orderlist.Total + "元</td>");
            //sb.Append("</tr>");
            //sb.Append("<tr>");
            //sb.Append("<td style='text-align: center;'>付款方式</td>");
            //sb.Append("<td style='text-align: center;'>" + orderlist.pay_mode + "</td>");
            //sb.Append("</tr>");
            //sb.Append("<tr>");
            //sb.Append("<td style='text-align: center;'>銀行代碼</td>");
            //sb.Append("<td style='text-align: center;'>808</td>");
            //sb.Append("</tr>");
            //sb.Append("<tr>");
            //sb.Append("<td style='text-align: center;'>ATM繳費帳號</td>");
            //sb.Append("<td style='text-align: center;'>123456789987654321</td>");
            //sb.Append("</tr>");
            //sb.Append("<tr>");
            //sb.Append("<td style='text-align: center;'>繳費截止時間</td>");
            //sb.Append("<td style='text-align: center;'>2016/01/01 23:59:59</td>");
            //sb.Append("</tr>");
            //sb.Append("</tbody>");
            //sb.Append("</table>");
            sb.Append("<p><strong><span style='font-size:18px;'>特別資訊:</span></strong></p>");
            sb.Append("<p>若您仍有訂單相關問題,請洽FUNN客服中心 星期一至星期五09:00-17:30 中午休息時間12:00-13:00</p>");
            sb.Append("<p>Customer service | (04)2271-6160 |&nbsp;<a href='mailto:[email protected]' target='_blank'>[email protected]</a>&nbsp;或是臉書台灣官網詢問<a href='https://www.facebook.com/funn.tw/' target='_blank'>https://www.facebook.com/funn.tw/</a></p>");
            sb.Append("<p><strong>【注意事項】</strong></p>");
            sb.Append("<p>虛擬帳號有效期限至您訂購當日算起三天內,逾期失效無法轉入,訂單將自動取消。若超過期限,請線上重新訂購。</p>");
            sb.Append("<p><strong>【商品】</strong></p>");
            sb.Append("<p>商品將於您付款完成後的3-5個工作天左右送達您指定定址。</p>");
            sb.Append("<p><strong>【防詐騙提醒】</strong></p>");
            sb.Append("<p>若您接獲任何電話要您依照指示操作ATM,提供剩額、變更付款方式或更改分期設定等,請不要依電話指示操作,建議您直接與本公司客服中心聯繫確認,謝謝您!</p>");

            SendMailToEveryOne.SendMail(orderlist.buyemail ?? orderlist.memberAccount, "*****@*****.**", "funnmtb-訂單", "funnmtb-訂單", sb.ToString(), false);
            SendMailToEveryOne.SendMail("*****@*****.**", orderlist.buyemail ?? orderlist.memberAccount, "funnmtb-訂單", "funnmtb-訂單", sb.ToString(), false);
        }
        public ActionResult AllpayWebsite(OrderComplete orderlist)
        {
            string itemresult = "";
            if (DEBUG_MODE)
            {
                config = AllpayUrl;
            }
            else
            {
                config = AllpayTestUrl;

            }
            //Random ran = new Random();
            SortedDictionary<string, string> dic = new SortedDictionary<string, string>();
            dic.Add("MerchantID", "1083575");//1083575  //2000132
            dic.Add("MerchantTradeNo", orderlist.orderId);
            dic.Add("MerchantTradeDate", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
            dic.Add("PaymentType", "aio");
            dic.Add("TotalAmount", orderlist.Total.ToString());
            dic.Add("TradeDesc", "馭捷股份有限公司-商城購物");
            var jsondata = JsonConvert.DeserializeObject<List<productlistforCart>>(orderlist.productJson);
            var psizedata = "";
            var pcolordata = "";
            foreach (var i in jsondata)
            {
                var psizecheck = psd.Get().ToList().Where(a => a.num == i.psize);
                var pcolorcheck = pcd.Get().ToList().Where(a => a.num == i.pcolor);
                if (psizecheck != null)
                {
                    var psizecheckd = psd.Get().ToList().Where(a => a.num == i.psize).SingleOrDefault();
                    psizedata = psizecheckd.size;
                }
                if (pcolorcheck != null)
                {
                    var pcolorcheckd = pcd.Get().ToList().Where(a => a.num == i.pcolor).SingleOrDefault();
                    pcolordata = pcolorcheckd.color;
                }
                itemresult += i.pname + "-" + psizedata + "-" + pcolordata + " X " + i.qty + "#";
            }
            dic.Add("ItemName", itemresult);
            dic.Add("ReturnURL", "http://www.allpay.com.tw/receive.php");
            dic.Add("ChoosePayment", "Credit");
            //dic.Add("OrderResultURL", "http://localhost:2620/Home/PayFinish");
            dic.Add("ClientBackURL", "http://www.funnmtb.com.tw/product?m=2");
            //dic.Add("PaymentInfoURL", "https://www.google.com.tw/?rct=j");
            //dic.Add("PeriodReturnURL", "http://localhost:2620/Home/PayFinish");
            var str = string.Empty;
            var str_pre = string.Empty;
            foreach (var i in dic)
            {
                str += string.Format("&{0}={1}", i.Key, i.Value);
            }
            //str_pre += "HashKey=5294y06JbISpM5x9" + str + "&" + "HashIV=v77hoKGq4kWxNNIS";
            str_pre += "HashKey=M1VtB9iXJvaFE8CK" + str + "&" + "HashIV=Dybw5hlkZM9qPOHs";
            var urlEncode = HttpUtility.UrlEncode(str_pre);
            var strtolower = urlEncode.ToLower();
            MD5 strtoMd5 = MD5.Create();
            var data = strtoMd5.ComputeHash(Encoding.Default.GetBytes(strtolower));
            StringBuilder strBuilder = new StringBuilder();
            var result = BitConverter.ToString(data).Replace("-", string.Empty);
            strBuilder.Append(result);
            dic.Add("CheckMacValue", strBuilder.ToString());

            var model = new AllPayWebSiteViewModel()
            {
                SortedDictionary = dic,
                ActionUrl = config
            };

            return View(model);
        }
        public ActionResult Complete(OrderComplete orderlist, string keyin = "")
        {
            //try
            //{
            if (Session["Account"] != null)
            {
                if (keyin == "")
                {
                    TempData["ordercheckempty"] = true;
                    return RedirectToAction("Index", "Order");
                }

                if (keyin != Session["ordercheck"].ToString())
                {
                    TempData["ordercheckmsg"] = true;
                    return RedirectToAction("Index", "Order");
                }
                //------會員------
                var memberdata = md.Get().ToList().Where(a => a.uAccount == Session["Account"].ToString()).SingleOrDefault();
                orderlist.memberId = memberdata.num;
                orderlist.memberAccount = memberdata.uAccount;
                orderlist.memberName = memberdata.uName;
                //------地址------
                var cd = citydata.Get().ToList().Where(a => a.num == Convert.ToInt32(orderlist.city)).SingleOrDefault();
                var ad = areadata.Get().ToList().Where(a => a.num == Convert.ToInt32(orderlist.area)).SingleOrDefault();
                orderlist.city = cd.cityName;
                orderlist.area = ad.AreaName;
                orderlist.Status = 0;
                orderlist.isRead = 0;
                orderlist.isdel = 0;
                if (Convert.ToInt32(orderlist.pay_mode) == 3)
                {
                    orderlist.Status = 5;
                }
                //-------產生訂單----------
                //發票格式
                orderlist.pay_invoice = ((Enum_pay_invoice)Convert.ToInt32(orderlist.pay_invoice)).ToString();
                //付款方式
                orderlist.pay_mode = ((Enum_pay_mode)Convert.ToInt32(orderlist.pay_mode)).ToString();
                //運送方式
                orderlist.transport = ((Enum_transport)Convert.ToInt32(orderlist.transport)).ToString();
                orderlist.wdate = DateTime.Now;
                orderlist.udate = DateTime.Now;
                var dataCount = ocd.Get().ToList().Count();
                orderlist.orderId = "FUN" + DateTime.Now.ToString("yyyyMMdd") + (dataCount + 1).ToString().PadLeft(3, '0');

                //var id = "";
                //將購物車內容轉json
                orderlist.productJson = JsonConvert.SerializeObject(GetCartProduct());

                if (Session["CartDesCoupon"] != null)
                {
                    orderlist.Total = Convert.ToInt32(Session["CartDesCoupon"]);
                }
                else
                {
                    TempData["totalerror"] = "Error";
                    return RedirectToAction("Index", "Order");
                }
                if (Session["couponcoin"] != null)
                {
                    orderlist.coupon = Convert.ToInt32(Session["couponcoin"]);
                }
                else
                {
                    orderlist.coupon = 0;
                }
                if (Session["couponID"] != null)
                {
                    orderlist.couponID = Session["couponID"].ToString();
                }
                else
                {
                    orderlist.couponID = "";
                }

                //**************************************************************************************************************************

                //將優惠券變成已使用
                DeleCoupon();
                //刪除購物車內容物
                DeleCart();

                ocd.Create(orderlist);

                if (orderlist.pay_mode == "線上刷卡")
                {
                    return RedirectToAction("AllpayWebsite", orderlist);
                }

                var model = new OrderViewModel()
                {
                    Order = ocd.Get().ToList().Where(a => a.memberId == memberdata.num && a.orderId == orderlist.orderId),
                    prodcut = pd.Get().ToList().Where(a => a.isdel == 0),
                    productsize = psd.Get().ToList().Where(a => a.isdel == 0),
                    productcolor = pcd.Get().ToList().Where(a => a.isdel == 0)
                };

                return View(model);
            }
            else
            {
                TempData["loginmsg"] = "請先登入會員";
                return RedirectToAction("Index", "login");
            }
            //}
            //catch (Exception ex)
            //{
            //    return RedirectToAction("Index", "Home");
            //}
        }
 public JsonResult Orderlist(string MyChecked)
 {
     OrderComplete n = new OrderComplete();
     OrderCompleteData nd = new OrderCompleteData();
     var array = MyChecked.Split(',');
     if (MyChecked != "" && MyChecked != null)
     {
         for (var i = 0; i < array.Length; i++)
         {
             //var Original = nd.Get().ToList().Where(a => a.num.ToString() == array[i]).SingleOrDefault();
             //var DelPath = System.IO.Path.Combine(Server.MapPath("~/upload/News/"), Original.pic1);
             //System.IO.File.Delete(DelPath);
             //if (Original.jsonimg != "no_img.jpg")
             //{
             //    var jsonstr = JsonConvert.DeserializeObject<List<jsonSer>>(Original.jsonimg);
             //    var DelJsonPath = Server.MapPath("~/upload/photograhy/");
             //    foreach (var j in jsonstr)
             //    {
             //        var DelJsonPathing = System.IO.Path.Combine(DelJsonPath, j.content);
             //        System.IO.File.Delete(DelJsonPathing);
             //    }
             //}
             n.isdel = 1;
             n.udate = DateTime.Now;
             n.num = Convert.ToInt32(array[i]);
             nd.Delete(n);
         }
     }
     return Json("");
 }
        //歐富寶系列導向頁
        public ActionResult Complete_AllPay(AllPay_RedirectVal allpay)
        {
            try
            {
                if ((allpay.RtnCode == 2 && allpay.PaymentType.Contains("ATM")) ||
                    (allpay.RtnCode == 10100073 && allpay.PaymentType.Contains("CVS")) ||
                    (allpay.RtnCode == 1 && allpay.PaymentType.Contains("Credit")))
                {

                    if (Session["Account"] != null)
                    {
                        var memberdata = md.Get().ToList().Where(a => a.uAccount == Session["Account"].ToString());
                        if (memberdata != null)
                        {
                            var memberdatas = md.Get().ToList().Where(a => a.uAccount == Session["Account"].ToString()).SingleOrDefault();
                            var orderlist = ocd.Get().ToList().Where(a => a.memberId == memberdatas.num && a.orderId == allpay.MerchantTradeNo);
                            if (orderlist != null)
                            {
                                SendEmailToGuest(orderlist.SingleOrDefault(), allpay);
                            }

                            var model = new OrderViewModel()
                               {
                                   Order = orderlist,
                                   prodcut = pd.Get().ToList().Where(a => a.isdel == 0),
                                   productsize = psd.Get().ToList().Where(a => a.isdel == 0),
                                   productcolor = pcd.Get().ToList().Where(a => a.isdel == 0),
                                   AllPay_RedirectVal = allpay
                               };

                            return View(model);
                        }
                        else
                        {
                            TempData["msg"] = "會員取得失敗";
                            return RedirectToAction("Index", "Home");
                        }
                    }
                    else
                    {
                        TempData["msg"] = "會員取得失敗";
                        return RedirectToAction("Index", "Home");
                    }

                }
                else
                {
                    var memberdata = md.Get().ToList().Where(a => a.uAccount == Session["Account"].ToString());
                    if (memberdata != null)
                    {
                        var memberdatas = md.Get().ToList().Where(a => a.uAccount == Session["Account"].ToString()).SingleOrDefault();
                        var orderlist = ocd.Get().ToList().Where(a => a.memberId == memberdatas.num && a.orderId == allpay.MerchantTradeNo);
                        if (orderlist != null)
                        {
                            var orderlists = ocd.Get().ToList().Where(a => a.memberId == memberdatas.num && a.orderId == allpay.MerchantTradeNo).SingleOrDefault();
                            OrderComplete od = new OrderComplete();
                            od.udate = DateTime.Now;
                            od.isdel = 1;
                            od.num = orderlists.num;
                            ocd.Delete(od);
                        }
                    }
                    TempData["msg"] = "交易失敗,導回首頁";
                    return RedirectToAction("Index", "Home");
                }
            }
            catch (Exception ex)
            {

                TempData["msg"] = "交易失敗,導回首頁";
                return RedirectToAction("Index", "Home");
            }
        }
        public ActionResult Complete(OrderComplete orderlist, string keyin = "")
        {
            //判斷session, 會員是否有登入
            if (Session["Account"] != null)
            {
                //再次判斷前端驗證碼是否符合session值
                if (keyin != Session["ordercheck"].ToString())
                {
                    TempData["msg"] = "驗證碼錯誤";
                    return RedirectToAction("Index", "OrderNoAllpay");
                }

                //------會員------
                //取得會員
                var memberdata = md.Get().ToList().Where(a => a.uAccount == Session["Account"].ToString()).SingleOrDefault();
                //會員自動編號
                orderlist.memberId = memberdata.num;
                //會員帳號
                orderlist.memberAccount = memberdata.uAccount;
                //會員姓名
                orderlist.memberName = memberdata.uName;

                //------地址------
                //取得城市
                var cityd = citydata.Get().ToList().Where(a => a.num == Convert.ToInt32(orderlist.city)).SingleOrDefault();
                //取得地區
                var aread = areadata.Get().ToList().Where(a => a.num == Convert.ToInt32(orderlist.area)).SingleOrDefault();

                //城市
                orderlist.city = cityd.cityName;
                //地區
                orderlist.area = aread.AreaName;
                //訂單狀態
                orderlist.Status = 0;
                orderlist.isRead = 0;
                //是否刪除
                orderlist.isdel = 0;
                //發票格式
                orderlist.pay_invoice = ((Enum_pay_invoice)Convert.ToInt32(orderlist.pay_invoice)).ToString();
                //付款方式
                orderlist.pay_mode = ((Enum_pay_mode)Convert.ToInt32(orderlist.pay_mode)).ToString();
                //運送方式
                //orderlist.transport = ((Enum_transport)Convert.ToInt32(orderlist.transport)).ToString();
                orderlist.transport = "";
                //建檔日期
                orderlist.wdate = DateTime.Now;
                //更新日期
                orderlist.udate = DateTime.Now;
                //訂單筆數
                var dataCount = ocd.Get().ToList().Count();
                //訂單編號
                orderlist.orderId = "SUN" + DateTime.Now.ToString("yyyyMMdd") + (dataCount + 1).ToString().PadLeft(3, '0');
                //優惠券金額
                orderlist.coupon = 0;
                //優惠券序號
                orderlist.couponID = "";
                //將購物車內容轉json
                orderlist.productJson = JsonConvert.SerializeObject(GetCartProduct());
                //每筆商品總額相加
                int total = 0;
                foreach (var i in cd.Get().ToList().Where(a => a.isdel == 0 && a.memberID == memberdata.num))
                {
                    total += i.total;
                }

                //****************需要運費不須註解*******************
                //運費已城市為主
                //int pay = 0, paydesc = 0;
                //bool isPaytf = false;
                //int totalAddPay = 0;
                //pay = PayFn.GetPay(cityd.num);
                //paydesc = PayFn.GetDescPay(cityd.num);
                //if (total < paydesc)
                //{
                //    isPaytf = true;
                //    totalAddPay = total + pay;
                //}
                //else
                //{
                //    isPaytf = false;
                //    totalAddPay = total;
                //}
                //****************//需要運費不須註解*******************

                //總金額
                orderlist.Total = total;
                //刪除購物車內容物
                DeleCart();
                //新增訂單
                ocd.Create(orderlist);

                //******寄信***********
                string toEmail = orderlist.buyemail;
                string fromEmail = "*****@*****.**";
                string Title = "杉魁-訂單通知";
                string Subject = "杉魁-訂單通知";
                string Content = "";
                bool isSSL = false;

                Content =
                "<table align='center' border='1' cellpadding='2' cellspacing='0' width='700'>" +
                "<tbody>" +
                        "<tr><td align='right' width='15%'>訂單編號</td><td align='left' width='85%'>" + orderlist.orderId + "</td></tr>" +
                        "<tr><td align='right'>訂購人</td><td align='left'>" + orderlist.buyers + "</td></tr>" +
                        "<tr><td align='right'>聯絡電話</td><td align='left'>" + orderlist.buyers_tel + "</td></tr>" +
                        "<tr><td align='right'>取貨人</td><td align='left'>" + orderlist.consignee + "</td></tr>" +
                        "<tr><td align='right'>取貨人電話</td><td align='left'>" + orderlist.consignee_tel + "</td></tr>" +
                        "<tr><td align='right'>取貨人手機</td><td align='left'>" + orderlist.consignee_phone + "</td></tr>" +
                        "<tr><td align='right'>取貨人地址</td><td align='left'>" + orderlist.city + orderlist.area + orderlist.address + "</td></tr>" +
                        "<tr><td align='right'>發票格式</td><td align='left'>" + orderlist.pay_invoice + "</td></tr>" +
                        "<tr><td align='right'>統一編號</td><td align='left'>" + orderlist.number + "</td></tr>" +
                        "<tr><td align='right'>抬頭</td><td align='left'>" + orderlist.invoice_title + "</td></tr>" +
                        "<tr><td align='right'>下單時間</td><td align='left'>" + orderlist.wdate + "</td></tr>" +
                        "<tr><td align='right'>付款方式</td><td align='left'>" + orderlist.pay_mode + "</td></tr>" +
                        "<tr><td align='right'>總金額</td><td align='left'>" + orderlist.Total + "元</td></tr>" +
                        "<tr><td align='right'>運費</td><td align='left'>" + orderlist.thispay + "元(出貨時會另行通知)</td></tr>" +
                        "<tr><td align='right'>備 註</td><td align='left'>" + orderlist.demo + "</td></tr>" +
                        "<tr><td align='right'>產品清單</td><td align='left'>" +
                                "<table border='1'>" +
                                    "<thead>" +
                    //"<th align='center'>圖片</th>" +
                                        "<th align='center'>產品名稱</th>" +
                                        "<th align='center'>形式</th>" +
                                        "<th align='center' width='5%'>價錢</th>" +
                                        "<th align='center' width='5%'>數量</th>" +
                                    "</thead>" +
                                    "<tbody>";
                var alltotal = 0;
                if (!String.IsNullOrEmpty(orderlist.productJson))
                {
                    var jsonstr = JsonConvert.DeserializeObject<List<productlistforCart>>(orderlist.productJson);
                    foreach (var i in jsonstr)
                    {
                        Content += "<tr>";
                        //Content += "<td align='center'><img src='" + AppDomain.CurrentDomain.BaseDirectory +"/upload/product/" + i.pic1 + "' width='50' height='50'/></td>";
                        Content += "<td align='center'>" + i.pname + "</td>";
                        Content += "<td align='center'>" + i.pro_type_name + "</td>";
                        Content += "<td align='center'>" + i.price + "</td>";
                        Content += "<td align='center'>" + i.qty + "</td>";
                        Content += " </tr>";
                        alltotal += (i.qty * i.price);

                    }

                }

                Content += "<tr>";
                Content += "<td align='center' colspan='5'>";
                Content += "<span>總計(原金額):" + alltotal + "</span>";
                Content += "</td>";
                Content += "</tr>";
                Content += "<tr>";
                Content += "<td align='center' colspan='5'>";
                Content += "<span>運費:" + orderlist.thispay + "</span>";
                Content += "</td>";
                Content += "</tr>";
                Content += "<tr>";
                Content += "<td align='center' colspan='5'>";
                Content += "<span>(總金額+運費):" + (orderlist.Total + orderlist.thispay) + "</span>";
                Content += "</td>";
                Content += "</tr>";
                Content += "</tbody></table></td></tr></tbody></table>";
                SendMailToEveryOne.SendMail(toEmail, fromEmail, Title, Subject, Content, isSSL);
                SendMailToEveryOne.SendMail(fromEmail, toEmail, Title, Subject, Content, isSSL);

                //*********//寄信***********
                //製作成ViewModel供訂單完成頁面使用
                var model = new OrderViewModel()
                {
                    Order = ocd.Get().ToList().Where(a => a.memberId == memberdata.num && a.orderId == orderlist.orderId),
                    prodcut = pd.Get().ToList().Where(a => a.isdel == 0),
                    total = total,
                    //pay = pay,
                    //ispay = isPaytf

                };

                return View(model);
            }
            else
            {
                TempData["msg"] = "請先登入會員";
                return RedirectToAction("Index", "login");
            }
        }