protected void Page_Load(object sender, EventArgs e) { id = TWRequest.GetQueryInt("id"); Tea.BLL.orders bll = new Tea.BLL.orders(); model = bll.GetModel(id); if (model.user_id != userModel.id) { Response.Redirect("order.aspx"); } try { area = model.area.Split(',')[1].ToString(); city = model.area.Split(',')[2].ToString(); } catch (Exception eee) { } payModel = new Tea.BLL.payment().GetModel(model.payment_id); if (payModel == null) { payModel = new Tea.Model.payment(); } data_cart.DataSource = Tea.DBUtility.DbHelperSQL.Query("select * from shop_order_goods where order_id=" + id + ""); data_cart.DataBind(); data_gift.DataSource = Tea.DBUtility.DbHelperSQL.Query("select * from view_order_gift where order_id=" + id + ""); data_gift.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { id = TWRequest.GetQueryInt("id"); if (id != 0) { weburl = config.weburl; model = bll.GetModel(id); } }
protected void Page_Load(object sender, EventArgs e) { id = TWRequest.GetQueryInt("id"); if (id != 0) { weburl = config.weburl; weburl = Utils.DelLastChar(weburl, "/"); model = bll.GetModel(id); data_cart.DataSource = Tea.DBUtility.DbHelperSQL.Query("select * from shop_order_goods where order_id=" + id + ""); data_cart.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { id = TWRequest.GetQueryInt("id"); if (id > 0) { model = bll.GetModel(id); if (model.user_id != userModel.id) { Response.Redirect("/"); } payModel = new Tea.BLL.payment().GetModel(model.payment_id); if (payModel == null) { payModel = new Tea.Model.payment(); } data_cart.DataSource = Tea.DBUtility.DbHelperSQL.Query("select * from shop_order_goods where order_id=" + id + ""); data_cart.DataBind(); data_gift.DataSource = Tea.DBUtility.DbHelperSQL.Query("select * from view_order_gift where order_id=" + id + ""); data_gift.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { cart = TWRequest.GetQueryString("cart"); if (string.IsNullOrEmpty(cart)) { cart = "1"; } cbquan = TWRequest.GetFormString("cbquan"); if (cart == "1") { cartModel = Tea.Web.UI.ShopCart.GetTotal(-1); } if (cart == "2") { cartModel = Tea.Web.UI.ShopCart.GetTotal(-2); } try { //Response.Write(cartModel.total_num_zhe); if (cartModel.total_point > 0 && cartModel.total_point > userModel.point) { Response.Write(ljd.function.LocalHint("紅利不足,請重新選擇商品!", "cart.aspx")); Response.End(); return; } } catch (Exception eee) { } try { guo = userModel.area.Split(',')[0].ToString(); area = userModel.area.Split(',')[1].ToString(); city = userModel.area.Split(',')[2].ToString(); zip = userModel.qq; } catch (Exception eee) { } DataSet ds_guo = Tea.DBUtility.DbHelperSQL.Query("select * from shop_basic where basic_where='city' order by basic_sort"); data_guo.DataSource = ds_guo; data_guo.DataBind(); dataguo.DataSource = ds_guo; dataguo.DataBind(); data_fp_guo.DataSource = ds_guo; data_fp_guo.DataBind(); data_invo_guo.DataSource = ds_guo; data_invo_guo.DataBind(); try { if (cartModel.real_amount > oconfig.yunmian) { yun = 0; } else { yun = oconfig.yunfei; } } catch (Exception eee) { } point = userModel.point - cartModel.total_point; // Response.Write(cartModel.total_num_zhe); if (cart == "1") { data_cart.DataSource = Tea.Web.UI.ShopCart.GetList(-1); data_cart.DataBind(); IList <Tea.Model.cart_items> iList = Tea.Web.UI.ShopCart.GetList(-1); int a = 0; foreach (Tea.Model.cart_items item in iList) { if (item.psmoney == "2") { a = a + 1; yudate = getps(item.id.ToString()); } } if (a > 1) { Response.Write(ljd.function.LocalHint("你的購物車中已有一預購商品,同時間只能購買一預購類型產品", "cart.aspx")); Response.End(); } } if (cart == "2") { data_cart.DataSource = Tea.Web.UI.ShopCart.GetList(-2); data_cart.DataBind(); IList <Tea.Model.cart_items> iList = Tea.Web.UI.ShopCart.GetList(-2); int a = 0; IList _list_3 = new ArrayList(); foreach (Tea.Model.cart_items item in iList) { if (item.psmoney == "3") { if (!_list_3.Contains(item.hdcode)) { _list_3.Add(item.hdcode); yudate = get_ps(item.hdcode.ToString()); //Response.Write(item.hdcode); } } a = _list_3.Count; } if (a > 1) { Response.Write(ljd.function.LocalHint("你的購物車中已有一特別活動商品,同時間只能購買一特別活動類型產品", "cart.aspx")); Response.End(); } } if (cart == "1" || cart == "2") { string year = System.DateTime.Now.ToString("yyyyMM"); DataSet ddss = Tea.DBUtility.DbHelperSQL.Query("select top 1 * from shop_gift where brand_id=" + year + " and status=1 and left_quantity>0 and amount<=" + (cartModel.real_amount - cartModel.total_moneyback) + ""); if (ddss.Tables[0].Rows.Count > 0) { decimal amount = Utils.StrToDecimal(ddss.Tables[0].Rows[0]["amount"].ToString(), 0); data_gift.DataSource = ddss; data_gift.DataBind(); giftmoney = Utils.StrToInt(amount.ToString(), 0); giftshow = 1; giftnum = Utils.StrToInt(((cartModel.real_amount - cartModel.total_moneyback) / amount).ToString().Split('.')[0].ToString(), 0); } } ////檢查物流方式 if (data_cart.Items.Count == 0) { Response.Write(ljd.function.LocalHint("購物車為空,請選購商品!", "cart.aspx")); Response.End(); return; } data_pay.DataSource = new Tea.BLL.payment().GetList(0, "is_lock=0", "sort_id desc,id desc"); data_pay.DataBind(); int aa = 0, b = 0, sc = -1; if (cart == "1") { sc = -1; } if (cart == "2") { sc = -2; } IList <Tea.Model.cart_items> iList_all = Tea.Web.UI.ShopCart.GetList(sc); if (iList_all != null) { foreach (Tea.Model.cart_items item in iList_all) { if (item.quantity > item.stock_quantity) { Tea.Web.UI.ShopCart.Update(item.key, item.stock_quantity); aa = aa + 1; } if (item.stock_quantity < 1) { b = b + 1; } } if (aa > 0) { Response.Write(ljd.function.LocalHint("庫存發生變化調整了購物數量", "cart.aspx")); Response.End(); return; } } if (b > 0) { Response.Write(ljd.function.LocalHint("購物車中有0庫存的商品請刪除!", "cart.aspx")); Response.End(); return; } act = Request["act"]; //Response.Write(cartModel.brand_id); if (act == "act_add") { if (TWRequest.GetFormString("txtguo") != "台灣") { string ycity = ""; DataSet yds = Tea.DBUtility.DbHelperSQL.Query("select basic_value,basic_type from shop_basic where basic_label='" + TWRequest.GetFormString("txtguo") + "' and basic_where='city'"); if (yds.Tables[0].Rows.Count > 0) { ycity = yds.Tables[0].Rows[0]["basic_type"].ToString(); DataSet yd_s = Tea.DBUtility.DbHelperSQL.Query("select top 1 basic_sort from shop_basic where basic_money>" + cartModel.total_num_zhe.ToString("0.") + " and basic_where='yunfei' and basic_type='" + ycity + "' order by basic_money"); if (yd_s.Tables[0].Rows.Count == 0) { Response.Write(ljd.function.LocalHint("材積重超出寄送限制,請調整訂單內容", "cart.aspx")); Response.End(); } } } if (cartModel.brandid == 3 && TWRequest.GetFormString("txtguo") != "台灣") { Response.Write(ljd.function.LocalHint("您的購物⾞內含有不配送⾄海外的商品,需分開購買。", "cart.aspx")); Response.End(); return; } yun = TWRequest.GetFormInt("yun"); //券 quan = TWRequest.GetFormString("txt_quan"); if (!string.IsNullOrEmpty(quan) && cbquan == "1") { Tea.Model.quan modelquan = new Tea.BLL.quan().GetModel(quan); if (modelquan != null) { if (int.Parse(modelquan.quan_end_date.Value.ToString("yyyyMMdd")) < int.Parse(System.DateTime.Now.ToString("yyyyMMdd"))) { Response.Write(ljd.function.LocalHint("優惠券無效", "order.aspx")); Response.End(); } fee = modelquan.quan_num.Value; } else { Response.Write(ljd.function.LocalHint("優惠券無效", "order.aspx")); Response.End(); } } int txt_point = TWRequest.GetFormInt("txt_point"); //紅利 hong = TWRequest.GetFormInt("cb_point"); if (hong > 0 && txt_point > 0 && uconfig.pint_money > 0) { if (txt_point > point) { Response.Write(ljd.function.LocalHint("紅利超出限制!", "order.aspx?cart=" + cart)); Response.End(); return; } int da = Tea.Common.Utils.StrToInt((txt_point / uconfig.pint_money).ToString(), 0); int xa = Tea.Common.Utils.StrToInt((cartModel.real_amount / 100 * uconfig.pint_yong).ToString(), 0); if (da > xa) { Response.Write(ljd.function.LocalHint("紅利超出限制!", "order.aspx?cart=" + cart)); Response.End(); return; } else { back = da; } //Response.Write(da+"_"+xa); //Response.End(); //int zuida = Utils.StrToInt((cartModel.real_amount * uconfig.pint_yong / 100).ToString(), 0); //if (cartModel.real_amount < uconfig.pint_mane && point > zuida) //{ // Response.Write(ljd.function.LocalHint("紅利超出限制!", "order.aspx")); // return; //} //else //{ // back = Utils.StrToInt((point / uconfig.pint_money).ToString(), 0); //} } payment_id = TWRequest.GetFormInt("txt_pay"); //獲得傳參信息 string accept_name = Utils.ToHtml(TWRequest.GetFormString("txt_name")); string post_code = Utils.ToHtml(TWRequest.GetFormString("txt_zip")); string mobile = Utils.ToHtml(TWRequest.GetFormString("txt_mobile")); string address = Utils.ToHtml(TWRequest.GetFormString("txt_address")); string email = Utils.ToHtml(TWRequest.GetFormString("txt_email")); string guo = Utils.ToHtml(TWRequest.GetFormString("txt_guo").Trim()); string selcity = Utils.ToHtml(TWRequest.GetFormString("txt_state")); string selarea = Utils.ToHtml(TWRequest.GetFormString("txt_city")); string selcity1 = Utils.ToHtml(TWRequest.GetFormString("txt_state1")); string selarea1 = Utils.ToHtml(TWRequest.GetFormString("txt_city1")); string telphone = Utils.ToHtml(TWRequest.GetFormString("txt_tel")); //獲取訂單配置資料 Tea.Model.orderconfig orderConfig = new Tea.BLL.orderconfig().loadConfig(); //檢查付款方式 if (payment_id == 0) { Response.Write(ljd.function.LocalHint("對不起,請選擇付款方式!", "")); Response.End(); return; } Tea.Model.payment payModel = new Tea.BLL.payment().GetModel(payment_id); if (payModel == null) { Response.Write(ljd.function.LocalHint("對不起,付款方式不存在或已刪除!", "")); Response.End(); return; } //檢查收貨人 if (string.IsNullOrEmpty(accept_name)) { Response.Write(ljd.function.LocalHint("對不起,請輸入收貨人姓名!", "")); Response.End(); return; } //檢查手機和電話 if (string.IsNullOrEmpty(telphone) && string.IsNullOrEmpty(mobile)) { Response.Write(ljd.function.LocalHint("對不起,請輸入收貨人聯絡電話或手機!", "")); Response.End(); return; } //檢查收貨區域 if (string.IsNullOrEmpty(selarea) && string.IsNullOrEmpty(selarea1)) { Response.Write(ljd.function.LocalHint("對不起,請選擇收貨區域!", "")); Response.End(); return; } //檢查地址 if (string.IsNullOrEmpty(address) && string.IsNullOrEmpty(address)) { Response.Write(ljd.function.LocalHint("對不起,請輸入詳細的收貨地址!", "")); Response.End(); return; } ////檢查郵箱 if (string.IsNullOrEmpty(email)) { Response.Write(ljd.function.LocalHint("對不起,請輸入郵箱!", "")); Response.End(); return; } //如果開啟暱名購物則不檢查會員是否登入 int user_id = 0; int user_group_id = 0; string user_name = string.Empty; //檢查用戶是否登入 if (userModel != null) { user_id = userModel.id; user_group_id = userModel.group_id; user_name = userModel.user_name; } if (orderConfig.maned == 0 && userModel == null) { Response.Write(ljd.function.LocalHint("對不起,用戶尚未登入或已超時!", "")); Response.End(); return; } int c = -1; if (cart == "1") { c = -1; } if (cart == "2") { c = -2; } //檢查購物車商品 IList <Tea.Model.cart_items> iList = Tea.Web.UI.ShopCart.GetList(c); if (iList == null) { Response.Write(ljd.function.LocalHint("對不起,購物車為空,無法結帳!", "")); return; } //統計購物車 //儲存訂單======================================================================= Tea.Model.orders model = new Tea.Model.orders(); if (cart == "1") { model.order_no = "B" + Utils.GetOrderNumber(); //訂單號B開頭為商品訂單 } if (cart == "2") { model.order_no = "T" + Utils.GetOrderNumber(); //訂單號開頭為特殊訂單 } model.user_id = user_id; model.user_name = user_name; model.payment_id = 0; model.express_id = express_id; model.accept_name = accept_name; model.post_code = post_code; model.telphone = telphone; model.mobile = mobile; model.email = email; if (guo == "台灣") { model.area = guo + "," + selcity + "," + selarea; } else { model.area = guo + "," + selcity1 + "," + selarea1; } model.address = address; model.payable_amount = cartModel.payable_amount; model.real_amount = cartModel.real_amount; model.express_status = 1; model.express_fee = yun; //物流費用 model.payment_id = payment_id; model.message = TWRequest.GetFormString("txtcontent"); if (TWRequest.GetFormString("txtguo") == "台灣") { model.user_add = TWRequest.GetFormString("txtname") + "|" + TWRequest.GetFormString("txtsex") + "|" + TWRequest.GetFormString("txtmobile") + "|" + TWRequest.GetFormString("txttel") + "|" + TWRequest.GetFormString("txtemail") + "|" + TWRequest.GetFormString("txtguo") + "|" + TWRequest.GetFormString("txtstate") + "|" + TWRequest.GetFormString("txtcity") + "|" + TWRequest.GetFormString("txtaddress") + "|" + TWRequest.GetFormString("txtzip"); } else { model.user_add = TWRequest.GetFormString("txtname") + "|" + TWRequest.GetFormString("txtsex") + "|" + TWRequest.GetFormString("txtmobile") + "|" + TWRequest.GetFormString("txttel") + "|" + TWRequest.GetFormString("txtemail") + "|" + TWRequest.GetFormString("txtguo") + "|" + TWRequest.GetFormString("txtstate1") + "|" + TWRequest.GetFormString("txtcity1") + "|" + TWRequest.GetFormString("txtaddress") + "|" + TWRequest.GetFormString("txtzip"); } model.point = -cartModel.total_point; model.is_invoice = TWRequest.GetFormInt("txtinvoice"); if (model.is_invoice == 1) { model.invoice_title = TWRequest.GetFormString("txt_invoice1"); } if (model.is_invoice == 2) { model.invoice_title = TWRequest.GetFormString("txt_invoice2"); } if (model.is_invoice == 3) { if (TWRequest.GetFormString("txtfaaddress_guo") == "台灣") { model.invoice_title = TWRequest.GetFormString("txt_invoice3") + "," + TWRequest.GetFormString("txtfaaddress") + "," + TWRequest.GetFormString("txtfaaddress_guo") + "," + TWRequest.GetFormString("txtfaaddress_state") + "," + TWRequest.GetFormString("txtfaaddress_city") + "," + TWRequest.GetFormString("txtfaaddress_zip") + "," + TWRequest.GetFormString("txtfa_address"); } else { model.invoice_title = TWRequest.GetFormString("txt_invoice3") + "," + TWRequest.GetFormString("txtfaaddress") + "," + TWRequest.GetFormString("txtfaaddress_guo") + "," + TWRequest.GetFormString("txtfaaddress_state1") + "," + TWRequest.GetFormString("txtfaaddress_city1") + "," + TWRequest.GetFormString("txtfaaddress_zip") + "," + TWRequest.GetFormString("txtfa_address"); } } if (model.is_invoice == 4) { if (TWRequest.GetFormString("txt_invoiceaddress_guo") == "台灣") { model.invoice_title = TWRequest.GetFormString("txt_invoice_4") + "," + TWRequest.GetFormString("txt_invoiceaddress") + "," + TWRequest.GetFormString("txt_invoiceaddress_guo") + "," + TWRequest.GetFormString("txt_invoiceaddress_state") + "," + TWRequest.GetFormString("txt_invoiceaddress_city") + "," + TWRequest.GetFormString("txt_invoiceaddress_zip") + "," + TWRequest.GetFormString("txt_invoice_address"); } else { model.invoice_title = TWRequest.GetFormString("txt_invoice_4") + "," + TWRequest.GetFormString("txt_invoiceaddress") + "," + TWRequest.GetFormString("txt_invoiceaddress_guo") + "," + TWRequest.GetFormString("txt_invoiceaddress_state1") + "," + TWRequest.GetFormString("txt_invoiceaddress_city1") + "," + TWRequest.GetFormString("txt_invoiceaddress_zip") + "," + TWRequest.GetFormString("txt_invoice_address"); } } if (!string.IsNullOrEmpty(quan)) { Tea.Model.quan modelquan1 = new Tea.BLL.quan().GetModel(quan); if (modelquan1 != null) { model.zhe_code = modelquan1.quan_code; } } model.zhe_else = cartModel.sales_str; model.point = -cartModel.total_point; //紅利兌換 model.express_fee = yun; //運費 model.payment_fee = -fee; //優惠券 model.tuid = -back; //紅利折扣 model.zhe_moeny = TWRequest.GetFormString("txt_date"); //訂單總金額=實付商品金額+運費+支付手續費-回饋金 if (model.order_amount < 0) { model.order_amount = 0; } model.zhe = -cartModel.total_moneyback; //折價金額 if (uconfig.money_pint > 0) { model.num = Utils.StrToInt(((model.real_amount + model.payment_fee + model.tuid + model.zhe) / uconfig.money_pint).ToString("0."), 0); //獲得紅利 } model.add_time = DateTime.Now; //商品詳細列表 List <Tea.Model.order_goods> gls = new List <Tea.Model.order_goods>(); foreach (Tea.Model.cart_items item in iList) { gls.Add(new Tea.Model.order_goods { article_id = item.id, goods_title = item.title, goods_price = item.price, real_price = item.user_price, quantity = item.quantity, point = item.point, goods_where = item.by, goods_code = item.goods_code, goods_no = item.goods_code, goods_img = item.img_url, spec_text = item.goods_color, img_url = item.img_url, goodsid = item.goodsid }); } model.order_goods = gls; if (hong > 0) { model.company = -txt_point; } model.order_amount = model.real_amount + model.express_fee + model.payment_fee + model.tuid + model.zhe; model.order_pay_code = model.order_no + Utils.Number(4); int result = new Tea.BLL.orders().Add(model); if (result < 1) { Response.Write(ljd.function.LocalHint("訂單儲存過程中發生錯誤,請重新送出!", "")); Response.End(); return; } string yearmonth = System.DateTime.Now.ToString("yyyyMM"); DataSet ds_gift = Tea.DBUtility.DbHelperSQL.Query("select top 1 * from shop_gift where brand_id=" + yearmonth + " and status=1 and left_quantity>0 and amount<=" + (model.order_amount - model.express_fee) + ""); if (ds_gift.Tables[0].Rows.Count > 0) { decimal amount = Utils.StrToDecimal(ds_gift.Tables[0].Rows[0]["amount"].ToString(), 0); giftnum = Utils.StrToInt(((model.order_amount - model.express_fee) / amount).ToString().Split('.')[0].ToString(), 0); foreach (DataRow dr in ds_gift.Tables[0].Rows) { int gid = Utils.StrToInt(dr["id"].ToString(), 0); Tea.Model.order_gift model_gift = new Tea.Model.order_gift(); model_gift.gift_id = gid; model_gift.order_id = result; model_gift.company = giftnum; new Tea.BLL.order_gift().Add(model_gift); new Tea.BLL.gift().UpdateField(gid, "left_quantity=left_quantity-1"); } } //扣除紅利 if (model.point < 0) { new Tea.BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "紅利兌換商品:" + model.order_no, false, result, 0); } //扣除紅利 if (model.company < 0) { new Tea.BLL.user_point_log().Add(model.user_id, model.user_name, model.company, "紅利折扣:" + model.order_no, false, result, 0); } if (!string.IsNullOrEmpty(quan)) { Tea.Model.quan modelquan = new Tea.BLL.quan().GetModel(quan); if (modelquan != null && modelquan.quan_where == "lin") { modelquan.quan_lock = 1; modelquan.quan_date = System.DateTime.Now; new Tea.BLL.quan().Update(modelquan); } } //userModel.point = userModel.point + model.point + model.tuid; //new Tea.BLL.users().Update(userModel); //Tea.Web.UI.ShopCart.ClearShop(cart); //清空購物車 Tea.Web.UI.ShopCart.ClearShop(cart); // Tea.Web.UI.ShopCart.Clear("0"); //送出成功,返回URL try { string mailTitle = "訂單通知信", mailContent = ""; string url = weburl + "mail/order.aspx?id=" + result, ss = ""; mailContent = ljd.function.GetPage(url, out ss); //發送郵件 TWMail.sendMail(config.emailsmtp, config.emailssl, config.emailport, config.emailusername, config.emailpassword, config.emailnickname, config.emailfrom, model.email, mailTitle, mailContent); } catch (Exception eee) { } //if (email != TWRequest.GetFormString("txtemail")) //{ // try // { // string mailTitle = "訂單通知信", mailContent = ""; // string url = weburl + "mail/order.aspx?id=" + result, ss = ""; // mailContent = ljd.function.GetPage(url, out ss); // //發送郵件 // TWMail.sendMail(config.emailsmtp, config.emailssl, config.emailport, config.emailusername, config.emailpassword, config.emailnickname, config.emailfrom, TWRequest.GetFormString("txtemail"), mailTitle, mailContent); // } // catch (Exception eee) { } //} if (model.payment_id != 1) { Response.Write(ljd.function.LocalHint("訂單已成功送出!", "pay.aspx?id=" + result)); Response.End(); return; } else { Response.Write(ljd.function.LocalHint("訂單已成功送出!", "pay.aspx?id=" + result)); Response.End(); return; } } }
protected void Page_Load(object sender, EventArgs e) { uid = TWRequest.GetQueryInt("uid"); cart = TWRequest.GetQueryString("cart"); if (string.IsNullOrEmpty(cart)) { cart = "3"; } if (uid > 0) { userModel = new Tea.BLL.users().GetModel(uid); } cbquan = TWRequest.GetFormString("cbquan"); if (cart == "3") { cartModel = Tea.Web.UI.AdminCart.GetTotal(-3, uid); } if (cartModel.total_point > userModel.point) { Response.Write(ljd.function.LocalHint("紅利不足,請重新選擇商品!", "adminorder.aspx")); Response.End(); return; } try { guo = userModel.area.Split(',')[0].ToString(); area = userModel.area.Split(',')[1].ToString(); city = userModel.area.Split(',')[2].ToString(); zip = userModel.qq; } catch (Exception eee) { } DataSet ds_guo = Tea.DBUtility.DbHelperSQL.Query("select * from shop_basic where basic_where='city' order by basic_sort"); data_guo.DataSource = ds_guo; data_guo.DataBind(); dataguo.DataSource = ds_guo; dataguo.DataBind(); data_fp_guo.DataSource = ds_guo; data_fp_guo.DataBind(); data_invo_guo.DataSource = ds_guo; data_invo_guo.DataBind(); try { Tea.Model.express expModel = new Tea.BLL.express().GetModel(express_id); if (decimal.Parse(expModel.maxmoney.ToString()) > cartModel.real_amount) { yun = expModel.express_fee; } else { yun = 0; } } catch (Exception eee) { } if (cart == "3") { data_cart.DataSource = Tea.Web.UI.AdminCart.GetList(-3, uid); data_cart.DataBind(); } data_pay.DataSource = new Tea.BLL.payment().GetList(0, "is_lock=0", "sort_id desc,id desc"); data_pay.DataBind(); act = Request["act"]; if (act == "act_add") { if (TWRequest.GetFormString("txtguo") != "台灣") { string ycity = ""; DataSet yds = Tea.DBUtility.DbHelperSQL.Query("select basic_value,basic_type from shop_basic where basic_label='" + TWRequest.GetFormString("txtguo") + "' and basic_where='city'"); if (yds.Tables[0].Rows.Count > 0) { ycity = yds.Tables[0].Rows[0]["basic_type"].ToString(); DataSet yd_s = Tea.DBUtility.DbHelperSQL.Query("select top 1 basic_sort from shop_basic where basic_money>" + cartModel.total_num_zhe.ToString("0.") + " and basic_where='yunfei' and basic_type='" + ycity + "' order by basic_money"); if (yd_s.Tables[0].Rows.Count == 0) { Response.Write(ljd.function.LocalHint("材積重超出寄送限制,請調整訂單內容", "adminorder.aspx?uid=" + uid)); Response.End(); } } } //////檢查物流方式 if (data_cart.Items.Count == 0) { Response.Write(ljd.function.LocalHint("購物車為空,請選購商品!", "adminorder.aspx?uid=" + uid)); Response.End(); return; } yun = TWRequest.GetFormInt("yun"); //券 quan = TWRequest.GetFormString("txt_quan"); if (!string.IsNullOrEmpty(quan) && cbquan == "1") { Tea.Model.quan modelquan = new Tea.BLL.quan().GetModel(quan); if (modelquan != null) { if (modelquan.quan_show > 0 || int.Parse(modelquan.quan_end_date.Value.ToString("yyyyMMdd")) < int.Parse(System.DateTime.Now.ToString("yyyyMMdd"))) { Response.Write(ljd.function.LocalHint("優惠券無效", "adminorder.aspx?uid=" + uid)); Response.End(); } fee = modelquan.quan_num.Value; } else { Response.Write(ljd.function.LocalHint("優惠券無效", "adminorder.aspx?uid=" + uid)); Response.End(); } } //紅利 //hong = TWRequest.GetFormInt("cb_point"); //int txt_point = TWRequest.GetFormInt("txt_point"); //if (hong > 0 && txt_point > 0) //{ // int zuida = Utils.StrToInt((cartModel.real_amount * uconfig.pint_yong / 100).ToString(), 0); // if (cartModel.real_amount < uconfig.pint_mane && userModel.point > zuida) // { // Response.Write(ljd.function.LocalHint("紅利超出限制!", "adminorder.aspx?uid="+uid)); // return; // } // else // { // back = Utils.StrToInt((userModel.point / uconfig.pint_money).ToString(), 0); // } //} payment_id = TWRequest.GetFormInt("txt_pay"); //獲得傳參信息 string accept_name = Utils.ToHtml(TWRequest.GetFormString("txt_name")); string post_code = Utils.ToHtml(TWRequest.GetFormString("txt_zip")); string mobile = Utils.ToHtml(TWRequest.GetFormString("txt_mobile")); string address = Utils.ToHtml(TWRequest.GetFormString("txt_address")); string email = Utils.ToHtml(TWRequest.GetFormString("txt_email")); string guo = Utils.ToHtml(TWRequest.GetFormString("txt_guo").Trim()); string selcity = Utils.ToHtml(TWRequest.GetFormString("txt_state")); string selarea = Utils.ToHtml(TWRequest.GetFormString("txt_city")); string selcity1 = Utils.ToHtml(TWRequest.GetFormString("txt_state1")); string selarea1 = Utils.ToHtml(TWRequest.GetFormString("txt_city1")); string telphone = Utils.ToHtml(TWRequest.GetFormString("txt_tel")); //獲取訂單配置資料 Tea.Model.orderconfig orderConfig = new Tea.BLL.orderconfig().loadConfig(); //檢查付款方式 if (payment_id == 0) { Response.Write(ljd.function.LocalHint("對不起,請選擇付款方式!", "")); Response.End(); return; } Tea.Model.payment payModel = new Tea.BLL.payment().GetModel(payment_id); if (payModel == null) { Response.Write(ljd.function.LocalHint("對不起,付款方式不存在或已刪除!", "")); Response.End(); return; } //檢查收貨人 if (string.IsNullOrEmpty(accept_name)) { Response.Write(ljd.function.LocalHint("對不起,請輸入收貨人姓名!", "")); Response.End(); return; } //檢查手機和電話 if (string.IsNullOrEmpty(telphone) && string.IsNullOrEmpty(mobile)) { Response.Write(ljd.function.LocalHint("對不起,請輸入收貨人聯絡電話或手機!", "")); Response.End(); return; } if (string.IsNullOrEmpty(selarea) && string.IsNullOrEmpty(selarea1)) { Response.Write(ljd.function.LocalHint("對不起,請選擇收貨區域!", "")); Response.End(); return; } //檢查地址 if (string.IsNullOrEmpty(address) && string.IsNullOrEmpty(address)) { Response.Write(ljd.function.LocalHint("對不起,請輸入詳細的收貨地址!", "")); Response.End(); return; } ////檢查郵箱 if (string.IsNullOrEmpty(email)) { Response.Write(ljd.function.LocalHint("對不起,請輸入郵箱!", "")); Response.End(); return; } //如果開啟暱名購物則不檢查會員是否登入 int user_id = 0; int user_group_id = 0; string user_name = string.Empty; //檢查用戶是否登入 if (userModel != null) { user_id = userModel.id; user_group_id = userModel.group_id; user_name = userModel.user_name; } if (orderConfig.maned == 0 && userModel == null) { Response.Write(ljd.function.LocalHint("對不起,用戶尚未登入或已超時!", "")); Response.End(); return; } //檢查購物車商品 IList <Tea.Model.cart_items> iList = Tea.Web.UI.AdminCart.GetList(-3, uid); if (iList == null) { Response.Write(ljd.function.LocalHint("對不起,購物車為空,無法結帳!", "")); Response.End(); return; } //統計購物車 //儲存訂單======================================================================= Tea.Model.orders model = new Tea.Model.orders(); model.order_no = "M" + Utils.GetOrderNumber(); //訂單號B開頭為商品訂單 model.user_id = user_id; model.user_name = user_name; model.payment_id = 0; model.express_id = express_id; model.accept_name = accept_name; model.post_code = post_code; model.telphone = telphone; model.mobile = mobile; model.email = email; if (guo == "台灣") { model.area = guo + "," + selcity + "," + selarea; } else { model.area = guo + "," + selcity1 + "," + selarea1; } model.address = address; model.payable_amount = cartModel.payable_amount; model.real_amount = cartModel.real_amount; model.express_status = 1; model.express_fee = yun; //物流費用 model.payment_id = payment_id; model.message = TWRequest.GetFormString("txtcontent"); if (TWRequest.GetFormString("txtguo") == "台灣") { model.user_add = TWRequest.GetFormString("txtname") + "|" + TWRequest.GetFormString("txtsex") + "|" + TWRequest.GetFormString("txtmobile") + "|" + TWRequest.GetFormString("txttel") + "|" + TWRequest.GetFormString("txtemail") + "|" + TWRequest.GetFormString("txtguo") + "|" + TWRequest.GetFormString("txtstate") + "|" + TWRequest.GetFormString("txtcity") + "|" + TWRequest.GetFormString("txtaddress") + "|" + TWRequest.GetFormString("txtzip"); } else { model.user_add = TWRequest.GetFormString("txtname") + "|" + TWRequest.GetFormString("txtsex") + "|" + TWRequest.GetFormString("txtmobile") + "|" + TWRequest.GetFormString("txttel") + "|" + TWRequest.GetFormString("txtemail") + "|" + TWRequest.GetFormString("txtguo") + "|" + TWRequest.GetFormString("txtstate1") + "|" + TWRequest.GetFormString("txtcity1") + "|" + TWRequest.GetFormString("txtaddress") + "|" + TWRequest.GetFormString("txtzip"); } model.point = -cartModel.total_point; model.is_invoice = TWRequest.GetFormInt("txtinvoice"); if (model.is_invoice == 1) { model.invoice_title = TWRequest.GetFormString("txt_invoice1"); } if (model.is_invoice == 2) { model.invoice_title = TWRequest.GetFormString("txt_invoice2"); } if (model.is_invoice == 3) { if (TWRequest.GetFormString("txtfaaddress_guo") == "台灣") { model.invoice_title = TWRequest.GetFormString("txt_invoice3") + "," + TWRequest.GetFormString("txtfaaddress") + "," + TWRequest.GetFormString("txtfaaddress_guo") + "," + TWRequest.GetFormString("txtfaaddress_state") + "," + TWRequest.GetFormString("txtfaaddress_city") + "," + TWRequest.GetFormString("txtfaaddress_zip") + "," + TWRequest.GetFormString("txtfa_address"); } else { model.invoice_title = TWRequest.GetFormString("txt_invoice3") + "," + TWRequest.GetFormString("txtfaaddress") + "," + TWRequest.GetFormString("txtfaaddress_guo") + "," + TWRequest.GetFormString("txtfaaddress_state1") + "," + TWRequest.GetFormString("txtfaaddress_city1") + "," + TWRequest.GetFormString("txtfaaddress_zip") + "," + TWRequest.GetFormString("txtfa_address"); } } if (model.is_invoice == 4) { if (TWRequest.GetFormString("txt_invoiceaddress_guo") == "台灣") { model.invoice_title = TWRequest.GetFormString("txt_invoice_4") + "," + TWRequest.GetFormString("txt_invoiceaddress") + "," + TWRequest.GetFormString("txt_invoiceaddress_guo") + "," + TWRequest.GetFormString("txt_invoiceaddress_state") + "," + TWRequest.GetFormString("txt_invoiceaddress_city") + "," + TWRequest.GetFormString("txt_invoiceaddress_zip") + "," + TWRequest.GetFormString("txt_invoice_address"); } else { model.invoice_title = TWRequest.GetFormString("txt_invoice_4") + "," + TWRequest.GetFormString("txt_invoiceaddress") + "," + TWRequest.GetFormString("txt_invoiceaddress_guo") + "," + TWRequest.GetFormString("txt_invoiceaddress_state1") + "," + TWRequest.GetFormString("txt_invoiceaddress_city1") + "," + TWRequest.GetFormString("txt_invoiceaddress_zip") + "," + TWRequest.GetFormString("txt_invoice_address"); } } if (!string.IsNullOrEmpty(quan)) { Tea.Model.quan modelquan1 = new Tea.BLL.quan().GetModel(quan); if (modelquan1 != null) { model.zhe_code = modelquan1.quan_code; } } //model.zhe_else = cartModel.sales_str; // model.point = -cartModel.total_point;//紅利兌換 //model.express_fee = yun;//運費 //model.payment_fee = -fee;//優惠券 //model.tuid = -back;//紅利折扣 //model.zhe = -cartModel.total_moneyback; //折價金額 model.num = 0;// Utils.StrToInt((cartModel.real_amount / uconfig.money_pint).ToString("0."), 0); //獲得紅利 //訂單總金額=實付商品金額+運費+支付手續費-回饋金 if (model.order_amount < 0) { model.order_amount = 0; } model.add_time = DateTime.Now; //商品詳細列表 List <Tea.Model.order_goods> gls = new List <Tea.Model.order_goods>(); foreach (Tea.Model.cart_items item in iList) { gls.Add(new Tea.Model.order_goods { article_id = item.id, goods_title = item.title, goods_price = item.price, real_price = item.user_price, quantity = item.quantity, point = item.point, goods_where = item.by, goods_code = item.goods_code, goods_no = item.goods_code, goods_img = item.img_url, spec_text = item.goods_color, img_url = item.img_url, goodsid = item.goodsid }); } model.order_goods = gls; model.order_amount = model.real_amount + model.express_fee + model.payment_fee + model.tuid + model.zhe; model.order_pay_code = model.order_no + Utils.Number(4); int result = new Tea.BLL.orders().Add(model); if (result < 1) { Response.Write(ljd.function.LocalHint("訂單儲存過程中發生錯誤,請重新送出!", "")); Response.End(); return; } try { string mailTitle = "待付款訂單通知信", mailContent = ""; string url = weburl + "mail/payorder.aspx?id=" + result, ss = ""; mailContent = ljd.function.GetPage(url, out ss); //發送郵件 TWMail.sendMail(siteConfig.emailsmtp, siteConfig.emailssl, siteConfig.emailport, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname, siteConfig.emailfrom, model.email, mailTitle, mailContent); } catch (Exception eee) { } //if (email != TWRequest.GetFormString("txtemail")) //{ // try // { // string mailTitle = "待付款訂單通知信", mailContent = ""; // string url = weburl + "mail/payorder.aspx?id=" + result, ss = ""; // mailContent = ljd.function.GetPage(url, out ss); // //發送郵件 // TWMail.sendMail(siteConfig.emailsmtp, siteConfig.emailssl, siteConfig.emailport, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname, siteConfig.emailfrom,TWRequest.GetFormString("txtemail"), mailTitle, mailContent); // } // catch (Exception eee) { } //} //扣除紅利 if (model.point < 0) { new Tea.BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "紅利兌換商品:" + model.order_no, false, 0, 0); } //if (!string.IsNullOrEmpty(quan)) //{ // Tea.Model.quan modelquan = new Tea.BLL.quan().GetModel(quan); // if (modelquan != null) // { // modelquan.quan_lock = 1; // modelquan.quan_date = System.DateTime.Now; // new Tea.BLL.quan().Update(modelquan); // } //} //userModel.point = userModel.point + model.point; //new Tea.BLL.users().Update(userModel); //清空購物車 Tea.Web.UI.AdminCart.ClearShop(cart, uid); // Tea.Web.UI.AdminCart.Clear("0"); //送出成功,返回URL if (model.payment_id != 1) { Response.Write(ljd.function.LocalHint("訂單已成功送出!", "/admin/index.aspx")); Response.End(); return; } else { Response.Write(ljd.function.LocalHint("訂單已成功送出!", "/admin/index.aspx")); Response.End(); return; } } }
protected void Page_Load(object sender, EventArgs e) { id = TWRequest.GetQueryInt("id"); pid = TWRequest.GetQueryInt("pid"); if (id > 0 && pid > 0) { model = bll.GetModel(id); if (model.order_pay.Length > 10) { Response.Redirect("ordershow.aspx?id=" + model.id); return; } if (model.payment_status == 2) { Response.Redirect("ordershow.aspx?id=" + model.id); return; } else { model.order_pay_code = model.order_no + Utils.Number(4); bll.Update(model); model = bll.GetModel(id); } modelpay = new Tea.BLL.payment().GetModel(pid); string ptype = "ALL"; if (modelpay != null) { ptype = modelpay.api_path; } string ok_urlall = weburl + "allpay_ok.aspx"; //返回地址 string ClientBackURL = weburl + "shop/payok.aspx?id=" + id; string ClientRedirectURL = weburl + "shop/payok.aspx?id=" + id; string OrderResultURL = weburl + "shop/payok.aspx?id=" + id; string PaymentInfoURL = weburl + "allpayok.aspx"; StringBuilder sb = new StringBuilder(); StringBuilder sbHtml = new StringBuilder(); XmlDocument doc = new XmlDocument(); if (ptype == "WeiXinpay") { ok_urlall = weburl + "allpay_okweixin.aspx"; //返回地址 doc = XmlHelper.LoadXmlDoc(Utils.GetMapPath(config.webpath + "xmlconfig/ofubao.config")); } else { doc = XmlHelper.LoadXmlDoc(Utils.GetMapPath(config.webpath + "xmlconfig/lvjie.config")); } string merchantid = doc.SelectSingleNode(@"Root/merID").InnerText; string HashKey = doc.SelectSingleNode(@"Root/MerchantID").InnerText; string HashIV = doc.SelectSingleNode(@"Root/TerminalID").InnerText; string ItemName = ""; DataSet ds = Tea.DBUtility.DbHelperSQL.Query("select * from shop_order_goods where order_id=" + id + ""); foreach (DataRow dr in ds.Tables[0].Rows) { ItemName = ItemName + dr["goods_title"].ToString() + dr["real_price"].ToString().Replace(".00", "") + "元X" + dr["quantity"] + "#"; } ItemName = Utils.DelLastChar(ItemName, "#"); string url = ""; //url sb.Append("HashKey=" + HashKey + ""); sb.Append("&ChoosePayment=" + ptype + ""); //if (ptype != "WeiXinpay") //{ sb.Append("&ClientBackURL=" + ClientBackURL + ""); sb.Append("&ClientRedirectURL=" + ClientRedirectURL + ""); //} sb.Append("&ItemName=" + ItemName + ""); sb.Append("&MerchantID=" + merchantid + ""); sb.Append("&MerchantTradeDate=" + model.add_time.ToString("yyyy/MM/dd HH:mm:ss").Replace("-", "/") + ""); sb.Append("&MerchantTradeNo=" + model.order_pay_code + ""); sb.Append("&OrderResultURL=" + OrderResultURL + ""); sb.Append("&PaymentInfoURL=" + PaymentInfoURL + ""); sb.Append("&PaymentType=aio"); sb.Append("&Remark=" + model.order_no + ""); sb.Append("&ReturnURL=" + ok_urlall + ""); sb.Append("&TotalAmount=" + (model.order_amount).ToString("0.") + ""); sb.Append("&TradeDesc=" + model.order_no + ""); sb.Append("&HashIV=" + HashIV + ""); url = sb.ToString(); url = getstr(url).ToLower(); sb.Append("&CheckMacValue=" + ljd.function.md5(url, 32) + ""); string CheckMacValue = ljd.function.md5(url, 32); if (ptype == "WeiXinpay") { sbHtml.Append("<form id='paysubmit' name='ecbanksubmit' action='https://payment-stage.opay.tw/Cashier/AioCheckOut/V5' method='post'>"); } else { sbHtml.Append("<form id='paysubmit' name='ecbanksubmit' action='https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5' method='post'>"); } sbHtml.Append("<input type='hidden' name='ChoosePayment' value='" + ptype + "'/>"); //if (ptype != "WeiXinpay") //{ sbHtml.Append("<input type='hidden' name='ClientBackURL' value='" + ClientBackURL + "'/>"); sbHtml.Append("<input type='hidden' name='ClientRedirectURL' value='" + ClientRedirectURL + "'/>"); // } sbHtml.Append("<input type='hidden' name='ItemName' value='" + ItemName + "'/>"); sbHtml.Append("<input type='hidden' name='MerchantID' value='" + merchantid + "'/>"); sbHtml.Append("<input type='hidden' name='MerchantTradeDate' value='" + model.add_time.ToString("yyyy/MM/dd HH:mm:ss").Replace("-", "/") + "'/>"); sbHtml.Append("<input type='hidden' name='MerchantTradeNo' value='" + model.order_pay_code + "'/>"); sbHtml.Append("<input type='hidden' name='OrderResultURL' value='" + OrderResultURL + "'/>"); sbHtml.Append("<input type='hidden' name='PaymentInfoURL' value='" + PaymentInfoURL + "'/>"); sbHtml.Append("<input type='hidden' name='PaymentType' value='aio'/>"); sbHtml.Append("<input type='hidden' name='Remark' value='" + model.order_no + "'/>"); sbHtml.Append("<input type='hidden' name='ReturnURL' value='" + ok_urlall + "'/>"); sbHtml.Append("<input type='hidden' name='TotalAmount' value='" + (model.order_amount).ToString("0.") + "'/>"); sbHtml.Append("<input type='hidden' name='TradeDesc' value='" + model.order_no + "'/>"); sbHtml.Append("<input type='hidden' name='CheckMacValue' value='" + CheckMacValue + "'/>"); sbHtml.Append("<input type='Submit'></form>");// style='display:none;' //sbHtml.Append("<script>document.forms['paysubmit'].submit();</script>"); Response.Write(sbHtml); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { _sql = "user_id='" + userModel.id + "' and status!=4"; end = TWRequest.GetQueryString("end"); begin = TWRequest.GetQueryString("begin"); this.page = TWRequest.GetQueryInt("page", 1); this.state = TWRequest.GetQueryInt("state", 0); this.day = TWRequest.GetQueryInt("day", 0); del = TWRequest.GetQueryInt("del"); if (del > 0) { try { Tea.Model.orders model = bll.GetModel(del); if (model.user_id == userModel.id) { if (model.status == 1) { model.status = 4; bll.Update(model); Response.Write(ljd.function.LocalHint("訂單取消成功!", "order.aspx")); } else { Response.Write(ljd.function.LocalHint("只是未確認的訂單才能取消!", "order.aspx")); } } } catch (Exception eee) { } } if (state != 0) { if (state == 1) { _sql = _sql + " and payment_status=2"; } if (state == 2) { _sql = _sql + " and express_status=2"; } if (state == 3) { _sql = _sql + " and payment_status!=2"; } } if (!string.IsNullOrEmpty(begin)) { _sql = _sql + " and (add_time between '" + begin + "' and '" + end + "')"; } if (day == 1) { _sql = "user_id='" + userModel.id + "' and status!=4 and datediff(year,add_time,getdate())=0"; } Tea.Web.UI.ShopPage bll_view = new Tea.Web.UI.ShopPage(); data_list.DataSource = bll_view.GetViewList("shop_orders", "", this.pageSize, this.page, _sql, _orderby, out this.totalCount); data_list.DataBind(); show = data_list.Items.Count; string pageUrl = Utils.CombUrlTxt("order.aspx", "state={0}&day={1}&begin={2}&end={3}&page={4}", state.ToString(), day.ToString(), begin, end, "__id__"); PageContent.InnerHtml = Utils.OutPageListWeb(this.pageSize, this.page, this.totalCount, pageUrl, 8); }