protected void Submit_Btn_Click(object sender, EventArgs e) { //创建一张新订单,完毕后更新老订单时间 M_OrderList orderMod = orderBll.SelModelByOrderNo(OrderNo); M_Order_IDC idcMod = idcBll.SelModelByOrderNo(OrderNo); M_Product proMod = proBll.GetproductByid(idcMod.ProID); M_UserInfo mu = buser.SelReturnModel(orderMod.Userid); if (mu.IsNull) { function.WriteErrMsg("订单未绑定用户[" + orderMod.Userid + "],或用户不存在"); } //根据所选,生成新的ID充值订单 DataRow timeMod = idcBll.GetSelTime(proMod, IDCTime_DP.SelectedValue); M_OrderList newMod = orderBll.NewOrder(mu, M_OrderList.OrderEnum.IDCRen); newMod.Ordersamount = Convert.ToDouble(timeMod["price"]); newMod.Promoter = idcMod.ID; newMod.Ordermessage = idcBll.ToProInfoStr(timeMod); newMod.id = orderBll.insert(newMod); //----------------------------------------------- M_Payment payMod = payBll.CreateByOrder(newMod); payBll.Add(payMod); Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo); }
public void GetDonate(double Money) { if (Money < 0.01) { function.WriteErrMsg("请输入有效的金额"); } //mu = buser.SelReturnModel(Identity); mu = buser.GetLogin(); M_OrderList Odata = orderBll.NewOrder(mu, M_OrderList.OrderEnum.Donate); Odata.Ordermessage = "打赏:" + Money + "元"; Odata.Ordersamount = Money; Odata.Userid = mu.IsNull ? Int32.MaxValue : mu.UserID; Odata.Balance_price = Odata.Ordersamount; Odata.Specifiedprice = Odata.Ordersamount; Odata.id = orderBll.Adds(Odata); M_Payment payMod = payBll.CreateByOrder(Odata); payMod.Remark = "打赏:" + Money + "元"; payMod.SysRemark = "donate"; payMod.PaymentID = payBll.Add(payMod); //判断是不是来自微信 if (DeviceHelper.GetBrower() == DeviceHelper.Brower.Micro) { //弹出微信支付窗口 Response.Redirect("/PayOnline/wxpay_mp.aspx?PayNo=" + payMod.PayNo); } else { Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo + "&OrderCode=" + Odata.OrderNo); } }
//用于后台确认支付 public static void FinalStep(M_OrderList mod) { if (mod.id < 1) { throw new Exception("未指定订单ID"); } if (mod.Ordertype < 1) { throw new Exception("未指定订单类型"); } if (string.IsNullOrEmpty(mod.OrderNo)) { throw new Exception("未指定订单号"); } M_AdminInfo adminMod = B_Admin.GetLogin(); B_Payment payBll = new B_Payment(); M_Payment pinfo = new M_Payment(); pinfo.PaymentNum = mod.OrderNo; pinfo.UserID = mod.Userid; pinfo.PayNo = payBll.CreatePayNo(); pinfo.MoneyPay = (decimal)mod.Ordersamount; pinfo.MoneyTrue = pinfo.MoneyPay;//看是否需要支持手输 pinfo.Status = (int)M_Payment.PayStatus.HasPayed; pinfo.CStatus = true; pinfo.Remark = "管理员确认支付,ID:" + adminMod.AdminId + ",登录名:" + adminMod.AdminName + ",真实姓名:" + adminMod.AdminTrueName; pinfo.PaymentID = payBll.Add(pinfo); pinfo.SuccessTime = DateTime.Now; pinfo.PayPlatID = (int)M_PayPlat.Plat.CashOnDelivery;//默认为线下支付 pinfo.PlatformInfo = ""; M_Order_PayLog paylogMod = new M_Order_PayLog(); FinalStep(pinfo, mod, paylogMod); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { M_UserInfo mu = buser.GetLogin(); DataRow dr = ExOrder.SelReturnModel(Mid); int user = DataConvert.CLng(dr["status_user"]); int teacher = DataConvert.CLng(dr["status_teacher"]); if (mu.IsNull) { function.WriteErrMsg("用户未登录"); } if (DataConvert.CLng(dr["status_money"]) == 1) { function.WriteErrMsg("订单已支付过佣金"); } if (teacher != (int)ExConast.Order_Teacher.签约成功) { function.WriteErrMsg("订单状态不正确"); } //-----------------生成支付单 //检测是否已有支付单 DataTable payDT = DBCenter.Sel(payBll.TbName, "code='" + Mid + "'", "PaymentID DESC"); if (payDT.Rows.Count > 0) { M_Payment payMod = payBll.SelReturnModel(Convert.ToInt32(payDT.Rows[0]["PaymentID"])); if (payMod.Status == (int)M_Payment.PayStatus.HasPayed) { function.WriteErrMsg("支付单已付过款"); } Response.Redirect("/Payonline/OrderPay.aspx?payno=" + payMod.PayNo); } else { M_OrderList orderMod = orderBll.NewOrder(mu, M_OrderList.OrderEnum.Normal); orderMod.Ordersamount = PlugConfig.Instance.Order_YJ; orderMod.Specifiedprice = PlugConfig.Instance.Order_YJ; orderMod.Balance_price = PlugConfig.Instance.Order_YJ; orderMod.Money_code = Mid.ToString(); orderMod.id = orderBll.insert(orderMod); M_CartPro cpMod = new M_CartPro(); cpMod.Orderlistid = orderMod.id; cpMod.Proname = "佣金"; cpMod.Pronum = 1; cpMod.Shijia = orderMod.Ordersamount; cpMod.UserID = mu.UserID; cpMod.Username = mu.UserName; cpMod.ID = cpBll.GetInsert(cpMod); M_Payment payMod = payBll.CreateByOrder(orderMod); payMod.code = Mid.ToString(); payMod.PaymentID = payBll.Add(payMod); //进去支付界面 Response.Redirect("/Payonline/OrderPay.aspx?payno=" + payMod.PayNo); } } }
protected void Charge_Btn_Click(object sender, EventArgs e) { double money = Unbrealla.T_CheckForegift(mu, Num); M_OrderList foreMod = Unbrealla.H_NewFGOrder(mu, money); M_Payment payMod = Unbrealla.H_NewFGPayment(foreMod); orderBll.insert(foreMod); payMod.PaymentID = payBll.Add(payMod); Response.Redirect("/PayOnline/OrderPay.aspx?Payno=" + payMod.PayNo + "&StoreID=" + StoreID); }
protected void BatReturn_Btn_Click(object sender, EventArgs e) { string ids = Request.Form["idchk"]; if (string.IsNullOrEmpty(ids)) { function.WriteErrMsg("未选择需要归还的伞"); } SafeSC.CheckIDSEx(ids); //计算金额,生成余额充值订单 double money = 0; foreach (string id in ids.Split(',')) { int rid = DataConvert.CLng(Request["repair" + id + "_rad"]); DataRow dr = Conast.Repair_Get(rid); money += DataConvert.CDouble(dr["price"]); string msg = dr["name"] + " " + Convert.ToDouble(dr["price"]) + "元"; DBCenter.UpdateSQL("ZL_OrderInfo", "Internalrecords='" + msg + "',Specifiedprice='" + dr["price"] + "'", "ID=" + id); } if (money < 1) { function.WriteErrMsg("充值金额不正确"); } if ((mu.Purse - 9) >= money) { //余额充足,则直接修改金额 Unbrealla.RepairOrder(ids, mu.UserID, StoreID, money); function.WriteSuccessMsg("报修成功,请等待店主审核"); } else { //缺多少充多少 M_OrderList orderMod = orderBll.NewOrder(mu, M_OrderList.OrderEnum.Purse); orderMod.Ordersamount = money - (mu.Purse - 9); orderMod.Ordermessage = "报修充值"; orderMod.StoreID = StoreID; //money用于检测充完值后,金额是否达标 orderMod.Freight_remark = JsonHelper.GetJson(new string[] { "type", "ids", "money" }, new string[] { "repair", ids, money.ToString("F2") }); M_Payment payMod = payBll.CreateByOrder(orderMod); orderBll.insert(orderMod); payBll.Add(payMod); Response.Redirect("/Payonline/wxpay_mp.aspx?payno=" + payMod.PayNo); } }
protected void Pay_Btn_Click(object sender, EventArgs e) { M_UserInfo mu = buser.GetLogin(); double charge = DataConvert.CLng(Request.Form["charge_rad"]); M_OrderList chargeMod = orderBll.NewOrder(mu, M_OrderList.OrderEnum.Purse); chargeMod.Ordersamount = charge; M_Payment payMod = payBll.CreateByOrder(chargeMod); payMod.Remark += "充值" + chargeMod.Ordersamount.ToString("F2") + "元"; if (payMod.MoneyReal < 1) { function.WriteErrMsg("充值金额错误"); } orderBll.insert(chargeMod); payMod.PaymentID = payBll.Add(payMod); Response.Redirect("/PayOnline/OrderPay.aspx?Payno=" + payMod.PayNo + "&StoreID=" + StoreID); }
protected void Submit_Btn_Click(object sender, EventArgs e) { M_UserInfo mu = buser.GetLogin(); M_Product proMod = proBll.GetproductByid(ProID); DataRow timeMod = idcBll.GetSelTime(proMod, IDCTime_DP.SelectedValue); //----------------------------------- M_OrderList Odata = orderBll.NewOrder(mu, M_OrderList.OrderEnum.IDC); Odata.Balance_price = DataConvert.CDouble(timeMod["price"]);//需付金额 Odata.Ordersamount = Odata.Balance_price; //----------------------------- M_Order_IDC idcMod = new M_Order_IDC(); idcMod.OrderNo = Odata.OrderNo; idcMod.ProID = proMod.ID; idcMod.ProInfo = idcBll.ToProInfoStr(timeMod); idcMod.Domain = BindDomain_T.Text; idcMod.AdminName = "webmater@" + idcMod.Domain; idcMod.AdminPwd = Pwd_T.Text; idcMod.Remind = OPSys_DP.SelectedValue + "|" + ServerPos_DP.SelectedValue + "|" + Record_T.Text; idcMod.ID = idcBll.Insert(idcMod); Odata.id = orderBll.Adds(Odata); //----------------------------- M_CartPro cpMod = new M_CartPro(); cpMod.Orderlistid = Odata.id; cpMod.ProID = proMod.ID; cpMod.Pronum = 1; cpMod.Proname = proMod.Proname; cpMod.Username = mu.UserName; cpMod.Shijia = Convert.ToDouble(timeMod["price"]); cpMod.AllMoney = Convert.ToDouble(timeMod["price"]); cpMod.code = timeMod["time"].ToString(); cartProBll.GetInsert(cpMod); //----------------------------- M_Payment payMod = payBll.CreateByOrder(Odata); payBll.Add(payMod); Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo); }
protected void OrderPay_B_Click(object sender, EventArgs e) { string plat = Plat_RBT.SelectedValue; double money = DataConverter.CDouble(Money_T.Text); M_OrderList orderMod = orderBll.SelReturnModel(OrderID); M_Payment payMod = payBll.CreateByOrder(orderMod); M_UserInfo mu = buser.GetSelect(orderMod.Userid); string adminName = badmin.GetAdminLogin().AdminName; string remind = "管理员[" + adminName + "]确认支付,支付单号:" + payMod.PayNo; //虚拟币支付 switch (plat) { case "Purse": { if (SyncDeduct_Chk.Checked) { if (mu.Purse < money) { function.WriteErrMsg("该用户余额不足"); } buser.MinusVMoney(mu.UserID, money, M_UserExpHis.SType.Purse, remind); } payMod.PlatformInfo = plat; } break; case "SilverCoin": { if (SyncDeduct_Chk.Checked) { if (mu.SilverCoin < money) { function.WriteErrMsg("该用户银币不足"); } buser.MinusVMoney(mu.UserID, money, M_UserExpHis.SType.SIcon, remind); } payMod.PlatformInfo = plat; } break; case "Score": { if (SyncDeduct_Chk.Checked) { if (mu.UserExp < money) { function.WriteErrMsg("该用户积分不足"); } buser.MinusVMoney(mu.UserID, money, M_UserExpHis.SType.Point, remind); } payMod.PlatformInfo = plat; } break; } payMod.PayPlatID = DataConverter.CLng(plat); payMod.MoneyPay = money; payMod.Remark = ""; payMod.SysRemark = "管理员[" + adminName + "]确认支付"; payMod.PaymentID = payBll.Add(payMod); orderMod.PaymentNo = payMod.PayNo; orderMod.Paymentstatus = (int)M_OrderList.PayEnum.HasPayed; orderBll.UpdateByID(orderMod); function.Script(this, "parent.CloseDiag();parent.location.reload();"); }
//确定,生成信息写入ZL_Payment protected void BtnSubmit_Click(object sender, EventArgs e) { int platid = DataConverter.CLng(Request.Form["payplat_rad"]); M_UserInfo mu = buser.GetLogin(false); M_Payment pinfo = new M_Payment(); M_OrderList orderMod = new M_OrderList(); if (!string.IsNullOrEmpty(PayNo))//支付单付款 { pinfo = payBll.SelModelByPayNo(PayNo); if (pinfo.Status != (int)M_Payment.PayStatus.NoPay) { function.WriteErrMsg("该支付单已付款,请勿重复支付"); return; } } else { //传入订单,或直接充值 if (Money > 0)//直接充值 { orderMod.OrderNo = B_OrderList.CreateOrderNo(M_OrderList.OrderEnum.Purse); orderMod.Ordertype = (int)M_OrderList.OrderEnum.Purse;//Purse等充值 orderMod.Userid = mu.UserID; orderMod.Rename = mu.UserName; orderMod.AddUser = mu.UserName; orderMod.Ordersamount = Money; if (orderMod.Ordersamount < 0.01) { function.WriteErrMsg("错误,金额过小"); } orderBll.Add(orderMod); pinfo.PaymentNum = orderMod.OrderNo; pinfo.MoneyPay = orderMod.Ordersamount; pinfo.Remark = "用户充值"; } else { DataTable orderDT = orderBll.GetOrderbyOrderNo(OrderNo); GetTotal(orderDT, ref price, ref fare, ref allamount); if (allamount < 0.01) { function.WriteErrMsg("每次划款金额不能低于0.01元"); } if (orderDT != null && orderDT.Rows.Count > 0) { orderMod = orderBll.GetOrderListByid(DataConverter.CLng(orderDT.Rows[0]["id"])); orderMod.Payment = platid; orderBll.Update(orderMod); } pinfo.PaymentNum = OrderNo; pinfo.MoneyPay = allamount; DataTable cartDT = new DataTable(); //cartDT = bcart.GetSelectTableBySql("select * From ZL_CartPro Where OrderListID = " + orderMod.id, null); //pinfo.Remark = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string; } } pinfo.UserID = mu.UserID; pinfo.PayPlatID = platid; pinfo.MoneyID = 0; pinfo.MoneyReal = pinfo.MoneyPay; //用于支付宝网银 pinfo.PlatformInfo = Request.Form["payplat_rad"]; if (!string.IsNullOrEmpty(PayNo)) { payBll.Update(pinfo); } else { pinfo.Status = (int)M_Payment.PayStatus.NoPay; pinfo.PayNo = payBll.CreatePayNo(); payBll.Add(pinfo); } string url = "PayOnline.aspx?PayNo=" + pinfo.PayNo; if (pinfo.PayPlatID == 0) { url += "&method=" + Request.Form["payplat_rad"]; } Response.Redirect(url); }
protected void Page_Load(object sender, EventArgs e) { B_User.CheckIsLogged(Request.RawUrl); if (!IsPostBack) { int num = 1; M_OrderList orderMod = orderBll.SelReturnModel(Oid); M_UserInfo frommu = buser.SelReturnModel(orderMod.Userid); M_UserInfo mu = buser.GetLogin(false); //检测订单是否可借 if (orderMod == null) { HttpContext.Current.Response.Write("<script>alert('订单不存在')</script>"); } if (orderMod.Ordertype != (int)M_OrderList.OrderEnum.Fast) { HttpContext.Current.Response.Write("<script>alert('订单不可操作')</script>"); } if (orderMod.OrderStatus != 0) { HttpContext.Current.Response.Write("<script>alert('订单状态不正确')</script>"); } if (mu.UserID == orderMod.Userid) { HttpContext.Current.Response.Write("<script>alert('不可转借给本人')</script>"); } //=================================检测是否符合条件 double money = Unbrealla.T_CheckForegift(mu, num); //---------需要充值押金 string json = JsonHelper.GetJson("oid,action".Split(','), (orderMod.id + ",ue_lenttouser").Split(',')); if (money > 0) { M_OrderList foreMod = Unbrealla.H_NewFGOrder(mu, money); foreMod.StoreID = orderMod.StoreID; M_Payment forePay = Unbrealla.H_NewFGPayment(foreMod); forePay.SysRemark = json; orderBll.insert(foreMod); payBll.Add(forePay); Response.Redirect("/PayOnline/wxpay_mp.aspx?payno=" + forePay.PayNo); return; } //---------余额必须为正数,否则必须充值 if (mu.Purse <= 0) { //9,19,50,100 M_OrderList chargeMod = orderBll.NewOrder(mu, M_OrderList.OrderEnum.Purse); chargeMod.Ordersamount = 9; chargeMod.StoreID = orderMod.StoreID; M_Payment payMod = payBll.CreateByOrder(chargeMod); payMod.SysRemark = json; payMod.Remark += "充值" + chargeMod.Ordersamount.ToString("F2") + "元"; orderBll.insert(chargeMod); payMod.PaymentID = payBll.Add(payMod); Response.Redirect("/PayOnline/wxpay_mp.aspx?payno=" + payMod.PayNo); return; } //================================= //终止上一份订单,并生成新的转借订单 orderMod.Ordermessage = "转借"; Unbrealla.FinalOrder(orderMod); //创建新的订单 M_OrderList newMod = orderBll.NewOrder(mu, M_OrderList.OrderEnum.Fast); newMod.Balance_remark = orderMod.Balance_remark; newMod.Promoter = frommu.UserID; newMod.StoreID = orderMod.StoreID; newMod.Extend = DateTime.Now.ToString(); newMod.id = orderBll.insert(newMod); //新用户 mu = buser.GetLogin(false); if (mu.PageID == 0) { buser.AddMoney(orderMod.Userid, 5, M_UserExpHis.SType.Purse, "新用户转借奖励,订单[" + newMod.id + "]"); mu.PageID = 1; buser.UpdateByID(mu); WxAPI wxapi = WxAPI.Code_Get(); M_UserAPP appMod = appBll.SelModelByUid(orderMod.Userid, "wechat"); if (appMod != null && !string.IsNullOrEmpty(appMod.OpenID)) { string tlp1 = "{\"first\": {\"value\":\"奖励到帐提醒\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + orderMod.OrderNo + "\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + orderMod.Ordersamount.ToString("0.00") + "元\",\"color\":\"#173177\"},\"remark\":{\"value\":\"转借5元奖励已到账,该奖励可提现,请注意查收账户内余额\",\"color\":\"#173177\"}}"; wxapi.Tlp_SendTlpMsg(appMod.OpenID, "dlAIEAkV0lgDfc7-RYsdLVFMyP9UF7gHi_9kjPblVAU", ZoomLa.Components.SiteConfig.SiteInfo.SiteUrl + "/BU/UE/MyLend.aspx", tlp1); } } HttpContext.Current.Response.Write("<script>alert('操作成功')</script>"); Response.Redirect("/BU/UE/MyLend.aspx"); } }
//提交订单 protected void AddOrder_Btn_Click(object sender, EventArgs e) { if (Address_Div.Visible && DataConvert.CLng(Request.Form["address_rad"]) < 1) { function.WriteErrMsg("尚未选定收货地址"); } //1,生成订单,2,关联购物车中商品为已绑定订单 M_UserInfo mu = buser.GetLogin(false); M_UserRecei receMod = receBll.GetSelect(Convert.ToInt32(Request.Form["address_rad"]), mu.UserID); DataTable cartDT = cartBll.SelByCookID(CartCookID, ProClass, ids);//需要购买的商品 if (cartDT.Rows.Count < 1) { function.WriteErrMsg("你尚未选择商品,<a href='/User/Order/OrderList.aspx'>查看我的订单</a>"); } //------生成订单前检测区 foreach (DataRow dr in cartDT.Rows) { if (!HasStock(dr["Allowed"], DataConvert.CLng(dr["stock"]), Convert.ToInt32(dr["Pronum"]))) { function.WriteErrMsg("购买失败," + dr["proname"] + "的库存数量不足"); } } //------检测End //按店铺生成订单,统一存ZL_Orderinfo DataTable storeDT = cartDT.DefaultView.ToTable(true, "StoreID"); M_Payment payMod = new M_Payment(); payMod.PayNo = payBll.CreatePayNo(); List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse) foreach (DataRow dr in storeDT.Rows) { #region 暂不使用字段 //Odata.province = this.DropDownList1.SelectedValue; //Odata.city = this.DropDownList2.SelectedValue;//将地址省份与市ID存入,XML数据源 //Odata.Guojia = "";//国家 //Odata.Chengshi = DropDownList2.SelectedItem.Text;//城市 //Odata.Diqu = DropDownList3.SelectedItem.Text;//地区 //Odata.Delivery = DataConverter.CLng(Request.Form["Delivery"]); //Odata.Deliverytime = DataConverter.CLng(this.Deliverytime.Text); //Odata.Mobile = receMod.MobileNum; #endregion M_OrderList Odata = new M_OrderList(); Odata.Ordertype = OrderHelper.GetOrderType(ProClass); Odata.OrderNo = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype); Odata.StoreID = Convert.ToInt32(dr["StoreID"]); cartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID; DataTable storeCartDT = cartDT.DefaultView.ToTable(); switch (ProClass)//旅游机票等,以联系人信息为地址 { case 7: case 8: M_Cart_Travel model = JsonConvert.DeserializeObject <M_Cart_Travel>(storeCartDT.Rows[0]["Additional"].ToString()); M_Cart_Contract user = model.Contract[0]; Odata.Receiver = user.Name; Odata.Reuser = user.Name; Odata.Phone = user.Mobile; Odata.MobileNum = user.Mobile; Odata.Email = user.Email; break; default: //普通订单 Odata.Receiver = receMod.ReceivName; Odata.Reuser = receMod.ReceivName; Odata.Phone = receMod.phone; Odata.MobileNum = receMod.MobileNum; Odata.Email = receMod.Email; Odata.Shengfen = receMod.Provinces; Odata.Jiedao = receMod.Street; Odata.ZipCode = receMod.Zipcode; break; } Odata.Invoiceneeds = DataConverter.CLng(Request.Form["invoice_rad"]);//是否需开发票 Odata.Invoice = Odata.Invoiceneeds == 0 ? "" : InvoTitle_T.Text + "||" + Invoice_T.Text; Odata.Rename = mu.UserName; Odata.Outstock = 0; //缺货处理 Odata.Ordermessage = ORemind_T.Text; //订货留言 Odata.Merchandiser = ""; //跟单员 Odata.Internalrecords = ""; //内部记录 Odata.IsCount = false; //-----金额计算 Odata.Balance_price = GetTotalMoney(storeCartDT); Odata.Freight = GetFarePrice(storeCartDT, Odata.StoreID); //运费计算 Odata.Ordersamount = Odata.Balance_price + Odata.Freight; //订单金额 Odata.AllMoney_Json = orderCom.GetTotalJson(storeCartDT); //附加需要的虚拟币 Odata.Specifiedprice = Odata.Ordersamount; //订单金额; Odata.Receivablesamount = 0; //收款金额 Odata.Developedvotes = 0; Odata.OrderStatus = (int)M_OrderList.StatusEnum.Normal; //订单状态 Odata.Paymentstatus = (int)M_OrderList.PayEnum.NoPay; //付款状态 Odata.StateLogistics = 0; //物流状态 Odata.Signed = 0; //签收 Odata.Settle = 0; //结清 Odata.Aside = 0; //作废 Odata.Suspended = 0; //暂停 Odata.AddTime = DateTime.Now; Odata.AddUser = mu.UserName;; Odata.Userid = mu.UserID; Odata.Integral = DataConverter.CLng(Request.QueryString["jifen"]); Odata.Freight_remark = " "; Odata.Balance_remark = ""; Odata.Promoter = 0; Odata.id = orderBll.Adds(Odata); cartProBll.CopyToCartPro(mu, storeCartDT, Odata.id); orderList.Add(Odata); orderCom.SendMessage(Odata, null, "ordered"); userappMod = userappBll.SelModelByUid(buser.GetLogin().UserID, "wechat"); if (userappMod != null) { //function.WriteErrMsg(Odata.AddTime.ToString("yyyy年MM月dd日 HH:mm:ss")); WxAPI wxapi = WxAPI.Code_Get(1); string json = "{ \"touser\":\"" + userappMod.OpenID + "\",\"template_id\":\"6kw4rUCX3IpE7k8_kn3ocmaaQBZF4blWq25ualnz1qw\",\"url\":\"http://www.wodian8.com/User/Order/OrderList1.aspx\",\"data\":{\"first\": {\"value\":\"订单提交成功!\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + Odata.AddTime.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"keyword2\": {\"value\":\"" + Odata.Ordersamount.ToString("0.00") + "元\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + GetProname(Odata.id) + "\",\"color\":\"#173177\"},\"keyword4\": {\"value\":\"" + Odata.Shengfen + Odata.Jiedao + "\",\"color\":\"#173177\"},\"remark\":{\"value\":\"您好,订单提交成功,请尽快付款!\",\"color\":\"#173177\"}}}"; wxapi.SendTlpMsg(json); //wxapi.SendMsg(userappMod.OpenID, "你已下订单,订单号为:" + Odata.OrderNo); } } cartBll.DelByids(ids); //-----------------订单生成后处理 //进行减库存等操作 foreach (DataRow dr in cartDT.Rows) { M_Product model = proBll.GetproductByid(Convert.ToInt32(dr["Proid"])); model.Stock = model.Stock - DataConvert.CLng(dr["Pronum"]); SqlHelper.ExecuteSql("Update ZL_Commodities Set Stock=" + model.Stock + " Where ID=" + model.ID); } //生成支付单,处理优惠券,并进入付款步骤 foreach (M_OrderList model in orderList) { payMod.PaymentNum += model.OrderNo + ","; payMod.MoneyPay += model.Ordersamount; } //优惠券 if (!string.IsNullOrEmpty(Arrive_T.Text)) { double arriveAmount = arriveBll.UserArrive(Arrive_T.Text, Arrive_Pwd.Text); payMod.MoneyPay = payMod.MoneyPay - arriveAmount; payMod.ArriveMoney = arriveAmount; payMod.ArriveDetail = Arrive_T.Text + "|" + Arrive_Pwd.Text; } //积分处理 if (point_body.Visible && DataConvert.CLng(Point_T.Text) > 0) { int point = DataConvert.CLng(Point_T.Text); int maxPoint = (int)((SiteConfig.ShopConfig.PointRatiot * 0.01) * (double)payMod.MoneyPay / SiteConfig.ShopConfig.PointRate); //if (point <= 0) { function.WriteErrMsg("积分数值不正确"); } if (point > mu.UserExp) { function.WriteErrMsg("您的积分不足!"); } if (point > maxPoint) { function.WriteErrMsg("积分不能大于可兑换金额!"); } //生成支付单时扣除用户积分 buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis() { ScoreType = (int)M_UserExpHis.SType.Point, score = -point, detail = "积分抵扣,支付单号:" + payMod.PayNo }); payMod.MoneyPay = payMod.MoneyPay - (point * SiteConfig.ShopConfig.PointRate); payMod.UsePoint = point; } if (payMod.MoneyPay <= 0) { payMod.MoneyPay = 0.01; } payMod.PaymentNum = payMod.PaymentNum.TrimEnd(','); payMod.Remark = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string; payMod.UserID = mu.UserID; payMod.Status = 1; payMod.PaymentID = payBll.Add(payMod); string redirect_uri = HttpUtility.UrlEncode("http://www.wodian8.com/Payonline/wxpayonline.aspx?PayNo=" + payMod.PayNo); string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8c5c2dc7b10a36f3&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"; //Response.Redirect(url); Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo); }
public IActionResult GetOrderInfo_Submit() { //1,生成订单,2,关联购物车中商品为已绑定订单 string ids = GetParam("ids"); M_UserInfo mu = buser.GetLogin(false); DataTable cartDT = cartBll.SelByCartID(B_Cart.GetCartID(HttpContext), mu.UserID, ProClass, ids);//需要购买的商品 if (cartDT.Rows.Count < 1) { return(WriteErr("你尚未选择商品,<a href='/User/Order/OrderList'>查看我的订单</a>")); } VM_CartOrder vmMod = new VM_CartOrder(); vmMod.IsShowAddress(DataConvert.CLng(cartDT.Rows[0]["ProClass"])); //------------------------------ #region 检测缓存中的值与数据库中是否匹配 //string refreshTip = ",请点击<a href='" + Request.RawUrl() + "'>刷新页面</a>"; //if (VerifyDT == null || VerifyDT.Rows.Count < 1 || VerifyDT.Rows.Count != cartDT.Rows.Count) //{ return WriteErr("验证失效" + refreshTip, Request.RawUrl()); } //for (int i = 0; i < VerifyDT.Rows.Count; i++) //{ // //检测每一个商品,是否发生了ID/金额/数量/价格/总金额上面的差异或缺少 // DataRow verifyDR = VerifyDT.Rows[i]; // DataRow cartDR = GetDRFromDT(cartDT, Convert.ToInt32(verifyDR["ID"])); // if (cartDR == null) { return WriteErr("购物车信息不匹配" + refreshTip, Request.RawUrl()); } // foreach (string field in verifyFields) // { // double verifyVal = DataConvert.CDouble(verifyDR[field]); // double cartVal = DataConvert.CDouble(cartDR[field]); // if (verifyVal != cartVal) { return WriteErr("购物车的[" + field + "]不匹配" + refreshTip, Request.RawUrl()); } // } //} #endregion //------生成订单前检测区 foreach (DataRow dr in cartDT.Rows) { if (!HasStock(dr["Allowed"], DataConvert.CLng(dr["stock"]), Convert.ToInt32(dr["Pronum"]))) { return(WriteErr("购买失败," + dr["proname"] + "的库存数量不足")); } } //------检测End //按店铺生成订单 DataTable storeDT = cartDT.DefaultView.ToTable(true, "StoreID"); List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse) foreach (DataRow dr in storeDT.Rows) { #region 暂不使用字段 //Odata.province = this.DropDownList1.SelectedValue; //Odata.city = this.DropDownList2.SelectedValue;//将地址省份与市ID存入,XML数据源 //Odata.Guojia = "";//国家 //Odata.Chengshi = DropDownList2.SelectedItem.Text;//城市 //Odata.Diqu = DropDownList3.SelectedItem.Text;//地区 //Odata.Delivery = DataConverter.CLng(Request.Form["Delivery"]); //Odata.Deliverytime = DataConverter.CLng(this.Deliverytime.Text); //Odata.Mobile = receMod.MobileNum; #endregion M_OrderList Odata = new M_OrderList(); Odata.Ordertype = OrderHelper.GetOrderType(ProClass); Odata.OrderNo = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype); Odata.StoreID = Convert.ToInt32(dr["StoreID"]); cartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID; DataTable storeCartDT = cartDT.DefaultView.ToTable(); switch (vmMod.ProClass)//旅游机票等,以联系人信息为地址 { case 7: case 8: M_Cart_Travel model = JsonConvert.DeserializeObject <M_Cart_Travel>(storeCartDT.Rows[0]["Additional"].ToString()); M_Cart_Contract user = model.Contract[0]; Odata.Receiver = user.Name; Odata.Phone = user.Mobile; Odata.MobileNum = user.Mobile; Odata.Email = user.Email; break; default: if (vmMod.ShowAddress) { int arsID = DataConvert.CLng(GetParam("address_rad")); string arsChk = GetParam("ars_chk"); if (!string.IsNullOrEmpty(arsChk)) { #region 自提或微信共享地址 switch (arsChk) { case "self": { Odata.Receiver = "[用户自提]" + GetParam("arsInfo_name"); //用户上门购买,然后自提取商品 Odata.MobileNum = GetParam("arsInfo_mobile"); } break; case "wechat": { Odata.Receiver = GetParam("wxad_name"); Odata.MobileNum = GetParam("wxad_mobile"); Odata.Shengfen = GetParam("wxad_city"); Odata.Jiedao = GetParam("address"); } break; } #endregion } else { M_UserRecei receMod = receBll.GetSelect(arsID, mu.UserID); if (receMod == null) { return(WriteErr("用户尚未选择送货地址,或地址不存在")); } Odata.Receiver = receMod.ReceivName; Odata.Phone = receMod.phone; Odata.MobileNum = receMod.MobileNum; Odata.Email = receMod.Email; Odata.Shengfen = receMod.Provinces; Odata.Jiedao = receMod.Street; Odata.ZipCode = receMod.Zipcode; } } break; } Odata.Invoiceneeds = DataConverter.CLng(GetParam("invoice_rad"));//是否需开发票 Odata.Rename = mu.UserName; Odata.AddUser = mu.UserName;; Odata.Userid = mu.UserID; Odata.Ordermessage = GetParam("ORemind_T");//订货留言 //-----金额计算 Odata.Balance_price = GetTotalMoney(storeCartDT); Odata.Freight = GetFarePrice(storeCartDT, Odata.StoreID); //运费计算 Odata.Ordersamount = Odata.Balance_price + Odata.Freight; //订单金额 Odata.AllMoney_Json = orderCom.GetTotalJson(storeCartDT); //附加需要的虚拟币 Odata.Specifiedprice = Odata.Ordersamount; //订单金额; Odata.OrderStatus = (int)M_OrderList.StatusEnum.Normal; //订单状态 Odata.Paymentstatus = (int)M_OrderList.PayEnum.NoPay; //付款状态 //Odata.Integral = DataConverter.CLng(Request.QueryString["jifen"]); Odata.ExpTime = GetParam("exptime_hid"); Odata.id = orderBll.insert(Odata); //是否需要开发票 if (Odata.Invoiceneeds == 1) { M_Order_Invoice invMod = new M_Order_Invoice(); invMod.OrderID = Odata.id; invMod.InvHead = GetParam("InvoTitle_T").Trim(','); invMod.UserCode = GetParam("InvoUserCode_T").Trim(','); invMod.InvClass = GetParam("invUseType_rad"); invMod.InvContent = GetParam("Invoice_T").Trim(','); invMod.UserID = Odata.Userid; invBll.Insert(invMod); new B_Order_InvTlp().Sync(invMod); } cpBll.CopyToCartPro(mu, storeCartDT, Odata.id); orderList.Add(Odata); orderCom.SendMessage(Odata, null, "ordered"); } cartBll.DelByids(ids); //-----------------订单生成后处理 //进行减库存等操作 foreach (DataRow dr in cartDT.Rows) { M_Product model = proBll.GetproductByid(Convert.ToInt32(dr["Proid"])); model.Stock = model.Stock - DataConvert.CLng(dr["Pronum"]); SqlHelper.ExecuteSql("Update ZL_Commodities Set Stock=" + model.Stock + " Where ID=" + model.ID); } //生成支付单,处理优惠券,并进入付款步骤 M_Payment payMod = payBll.CreateByOrder(orderList); //优惠券 if (!string.IsNullOrEmpty(GetParam("Arrive_Hid"))) { M_Arrive avMod = avBll.SelModelByFlow(GetParam("Arrive_Hid"), mu.UserID); double money = payMod.MoneyPay; string remind = "支付单抵扣[" + payMod.PayNo + "]"; M_Arrive_Result retMod = avBll.U_UseArrive(avMod, mu.UserID, cartDT, money, remind); if (retMod.enabled) { payMod.MoneyPay = retMod.money; payMod.ArriveMoney = retMod.amount; payMod.ArriveDetail = avMod.ID.ToString(); } else { payMod.ArriveDetail = "优惠券[" + avMod.ID + "]异常 :" + retMod.err; } } //积分处理 int maxPoint = Point_CanBeUse(payMod.MoneyPay + payMod.ArriveMoney); if (maxPoint > 0 && DataConvert.CLng(GetParam("Point_T")) > 0) { int point = DataConvert.CLng(GetParam("Point_T")); //此处需咨询,上限额度是否要扣减掉优惠券 //if (point <= 0) { return WriteErr("积分数值不正确"); } if (point > mu.UserExp) { return(WriteErr("您的积分不足!")); } if (point > maxPoint) { return(WriteErr("积分不能大于可兑换金额[" + maxPoint + "]!")); } //生成支付单时扣除用户积分 buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis() { ScoreType = (int)M_UserExpHis.SType.Point, score = -point, detail = "积分抵扣,支付单号:" + payMod.PayNo }); payMod.UsePoint = point; payMod.UsePointArrive = Point_ToMoney(point); payMod.MoneyPay = payMod.MoneyPay - payMod.UsePointArrive; } payMod.MoneyReal = payMod.MoneyPay; payMod.Remark = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string; payMod.PaymentID = payBll.Add(payMod); { string notify_url = CustomerPageAction.customPath2 + "Shop/Orderlistinfo?ID=" + orderList[0].id; ZoomLa.BLL.User.M_User_Notify notify = new ZoomLa.BLL.User.M_User_Notify(); notify.Title = "有新的订单了"; notify.Content = "<a href='" + notify_url + "' target='main_right' style='font-size:12px;' title='查看详情'>新订单:" + orderList[0].OrderNo + "</a>"; notify.NType = 1; notify.Gid = orderList[0].id.ToString(); notify.AppendReceUser("admin"); ZoomLa.BLL.User.B_User_Notify.Add(notify); } return(Redirect("/PayOnline/Orderpay?PayNo=" + payMod.PayNo)); }
protected void AddOrder_Btn_Click(object sender, EventArgs e) { //1,生成订单,2,关联购物车中商品为已绑定订单 M_UserInfo mu = SnsHelper.GetLogin(); DataTable cartDT = SelByCartID(B_Cart.GetCartID(), mu.UserID, ProClass, ids);//需要购买的商品 if (cartDT.Rows.Count < 1) { function.WriteErrMsg("You have not yet chosen the goods"); } //------检测End //按店铺生成订单 DataTable storeDT = cartDT.DefaultView.ToTable(true, "StoreID"); List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse) foreach (DataRow dr in storeDT.Rows) { M_OrderList Odata = new M_OrderList(); Odata.Ordertype = OrderHelper.GetOrderType(ProClass); Odata.OrderNo = GetOrderNo(); Odata.StoreID = Convert.ToInt32(dr["StoreID"]); cartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID; DataTable storeCartDT = cartDT.DefaultView.ToTable(); Odata.Promoter = TipID; Odata.Invoiceneeds = DataConverter.CLng(Request.Form["invoice_rad"]);//是否需开发票 //Odata.Invoice = Odata.Invoiceneeds == 0 ? "" : InvoTitle_T.Text + "||" + Invoice_T.Text; Odata.Rename = mu.UserName; Odata.AddUser = mu.UserName;; Odata.Userid = mu.UserID; Odata.Ordermessage = Server.HtmlEncode((Request.Form["orderMsg"] ?? ""));// ORemind_T.Text;//订货留言 //-----金额计算 Odata.Balance_price = GetTotalMoney(storeCartDT); Odata.Freight = 0; Odata.Ordersamount = Odata.Balance_price + Odata.Freight; //订单金额 Odata.AllMoney_Json = orderCom.GetTotalJson(storeCartDT); //附加需要的虚拟币 Odata.Specifiedprice = Odata.Ordersamount; //订单金额; Odata.OrderStatus = (int)M_OrderList.StatusEnum.Normal; //订单状态 Odata.Paymentstatus = (int)M_OrderList.PayEnum.NoPay; //付款状态 //Odata.Integral = DataConverter.CLng(Request.QueryString["jifen"]); //Odata.ExpTime = exptime_hid.Value; M_Grade countryMod = B_GradeOption.GetGradeOption(Convert.ToInt32(Request.Form["country"])); M_Grade stateMod = B_GradeOption.GetGradeOption(Convert.ToInt32(Request.Form["state"])); Odata.Money_rate = 0; Odata.Receiver = Request.Form["FullName"]; Odata.Phone = Request.Form["phone"]; Odata.MobileNum = Request.Form["phone"]; Odata.Email = Request.Form["email"]; Odata.Diqu = countryMod.GradeName; Odata.Shengfen = stateMod.GradeName; Odata.Chengshi = Request.Form["city"]; Odata.Jiedao = Request.Form["address"]; Odata.ZipCode = Request.Form["zip"]; Odata.id = orderBll.insert(Odata); CopyToCartPro(mu, storeCartDT, Odata.id); orderList.Add(Odata); //orderCom.SendMessage(Odata, null, "ordered"); //-----联系人 B_Order_Contact conBll = new B_Order_Contact(); M_Order_Contact conMod = new M_Order_Contact(); conMod.OrderID = Odata.id; conMod.FullName = Request.Form["fullname"]; conMod.Email = Request.Form["email"]; conMod.Address = Request.Form["address"]; conMod.City = Request.Form["city"]; conMod.State = stateMod.GradeName; conMod.Country = countryMod.GradeName; conMod.Zip = Request.Form["zip"]; conMod.Phone = Request.Form["phone"]; conMod.Remark = ""; conBll.Insert(conMod); } //cartBll.DelByids(ids);//客户希望保留购物车中信息 //-----------------订单生成后处理 M_Payment payMod = payBll.CreateByOrder(orderList); //优惠券,编号与密码 if (!string.IsNullOrEmpty(Coupon_Num.Text)) { B_Ex_Coupon cupBll = new B_Ex_Coupon(); string code = Coupon_Num.Text.Trim(); //string pwd = Coupon_Pwd.Text.Trim(); //M_Arrive avMod = SnsHelper.AV_SelModel(code); //M_Arrive_Result retMod = SnsHelper.CheckArrive(code, pwd, payMod.MoneyPay); //if (retMod.enabled) //{ // payMod.MoneyPay = retMod.money; // payMod.ArriveMoney = retMod.amount; // payMod.ArriveDetail = "优惠券号:" + code + ",密码:" + pwd; // SnsHelper.Use_Arrive(avMod, "支付单[" + payMod.PayNo + "]使用,优惠金额:" + retMod.amount.ToString("F2")); //} //else { function.WriteErrMsg(retMod.err); } M_Arrive_Result retMod = cupBll.CheckArrive(code, payMod.MoneyPay); if (retMod.enabled) { payMod.MoneyPay = retMod.money; payMod.ArriveMoney = retMod.amount; payMod.ArriveDetail = "优惠券号:" + code; } } payMod.MoneyReal = payMod.MoneyPay; payMod.Remark = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string; payMod.PaymentID = payBll.Add(payMod); //取消下面注释激活下单立即发送邮件 EventDeal.SendOrderEmailByType(orderList[0].id, "order", SiteConfig.SiteInfo.WebmasterEmail); Response.Cookies["agree_save"].Value = Request.Form["agree_save_chk"]; Response.Cookies["agree_save"].Expires = DateTime.Now.AddYears(1); Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo); }
//提交订单 protected void AddOrder_Btn_Click(object sender, EventArgs e) { if (Address_Div.Visible && DataConvert.CLng(Request.Form["address_rad"]) < 1) { function.WriteErrMsg("尚未选定收货地址"); } //1,生成订单,2,关联购物车中商品为已绑定订单 M_UserInfo mu = buser.GetLogin(false); M_UserRecei receMod = receBll.GetSelect(Convert.ToInt32(Request.Form["address_rad"]), mu.UserID); DataTable cartDT = cartBll.SelByCartID(B_Cart.GetCartID(), mu.UserID, ProClass, ids);//需要购买的商品 if (cartDT.Rows.Count < 1) { function.WriteErrMsg("你尚未选择商品,<a href='/User/Order/OrderList'>查看我的订单</a>"); } //------生成订单前检测区 foreach (DataRow dr in cartDT.Rows) { if (!HasStock(dr["Allowed"], DataConvert.CLng(dr["stock"]), Convert.ToInt32(dr["Pronum"]))) { function.WriteErrMsg("购买失败," + dr["proname"] + "的库存数量不足"); } } //------检测End //按店铺生成订单,统一存ZL_Orderinfo DataTable storeDT = cartDT.DefaultView.ToTable(true, "StoreID"); List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse) foreach (DataRow dr in storeDT.Rows) { #region 暂不使用字段 //Odata.province = this.DropDownList1.SelectedValue; //Odata.city = this.DropDownList2.SelectedValue;//将地址省份与市ID存入,XML数据源 //Odata.Guojia = "";//国家 //Odata.Chengshi = DropDownList2.SelectedItem.Text;//城市 //Odata.Diqu = DropDownList3.SelectedItem.Text;//地区 //Odata.Delivery = DataConverter.CLng(Request.Form["Delivery"]); //Odata.Deliverytime = DataConverter.CLng(this.Deliverytime.Text); //Odata.Mobile = receMod.MobileNum; #endregion M_OrderList Odata = new M_OrderList(); Odata.Ordertype = OrderHelper.GetOrderType(ProClass); Odata.OrderNo = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype); Odata.StoreID = Convert.ToInt32(dr["StoreID"]); cartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID; DataTable storeCartDT = cartDT.DefaultView.ToTable(); switch (ProClass)//旅游机票等,以联系人信息为地址 { case 7: case 8: M_Cart_Travel model = JsonConvert.DeserializeObject <M_Cart_Travel>(storeCartDT.Rows[0]["Additional"].ToString()); M_Cart_Contract user = model.Contract[0]; Odata.Receiver = user.Name; Odata.Reuser = user.Name; Odata.Phone = user.Mobile; Odata.MobileNum = user.Mobile; Odata.Email = user.Email; break; default: if (Address_Div.Visible) { Odata.Receiver = receMod.ReceivName; Odata.Reuser = receMod.ReceivName; Odata.Phone = receMod.phone; Odata.MobileNum = receMod.MobileNum; Odata.Email = receMod.Email; Odata.Shengfen = receMod.Provinces; Odata.Jiedao = receMod.Street; Odata.ZipCode = receMod.Zipcode; } break; } Odata.Invoiceneeds = DataConverter.CLng(Request.Form["invoice_rad"]);//是否需开发票 Odata.Invoice = Odata.Invoiceneeds == 0 ? "" : InvoTitle_T.Text + "||" + Invoice_T.Text; Odata.Rename = mu.UserName; Odata.Outstock = 0; //缺货处理 Odata.Ordermessage = ORemind_T.Text; //订货留言 Odata.Merchandiser = ""; //跟单员 Odata.Internalrecords = ""; //内部记录 Odata.IsCount = false; //-----金额计算 Odata.Balance_price = GetTotalMoney(storeCartDT); Odata.Freight = GetFarePrice(storeCartDT, Odata.StoreID); //运费计算 Odata.Ordersamount = Odata.Balance_price + Odata.Freight; //订单金额 Odata.AllMoney_Json = orderCom.GetTotalJson(storeCartDT); //附加需要的虚拟币 Odata.Specifiedprice = Odata.Ordersamount; //订单金额; Odata.Receivablesamount = 0; //收款金额 Odata.Developedvotes = 0; Odata.OrderStatus = (int)M_OrderList.StatusEnum.Normal; //订单状态 Odata.Paymentstatus = (int)M_OrderList.PayEnum.NoPay; //付款状态 Odata.StateLogistics = 0; //物流状态 Odata.Signed = 0; //签收 Odata.Settle = 0; //结清 Odata.Aside = 0; //作废 Odata.Suspended = 0; //暂停 Odata.AddUser = mu.UserName;; Odata.Userid = mu.UserID; Odata.Integral = DataConverter.CLng(Request.QueryString["jifen"]); Odata.Freight_remark = " "; Odata.Balance_remark = ""; Odata.Promoter = 0; Odata.id = orderBll.Adds(Odata); cartProBll.CopyToCartPro(mu, storeCartDT, Odata.id); orderList.Add(Odata); orderCom.SendMessage(Odata, null, "ordered"); } cartBll.DelByids(ids); //-----------------订单生成后处理 //进行减库存等操作 foreach (DataRow dr in cartDT.Rows) { M_Product model = proBll.GetproductByid(Convert.ToInt32(dr["Proid"])); model.Stock = model.Stock - DataConvert.CLng(dr["Pronum"]); SqlHelper.ExecuteSql("Update ZL_Commodities Set Stock=" + model.Stock + " Where ID=" + model.ID); } //生成支付单,处理优惠券,并进入付款步骤 M_Payment payMod = payBll.CreateByOrder(orderList); //优惠券 if (!string.IsNullOrEmpty(Arrive_Hid.Value)) { M_Arrive avMod = avBll.SelModelByFlow(Arrive_Hid.Value, mu.UserID); double money = payMod.MoneyPay; string err = ""; string remind = "支付单抵扣[" + payMod.PayNo + "]"; if (avBll.U_UseArrive(avMod, mu.UserID, ref money, ref err, remind)) { payMod.MoneyPay = money; payMod.ArriveMoney = avMod.Amount; payMod.ArriveDetail = avMod.ID.ToString(); } else { payMod.ArriveDetail = "优惠券[" + avMod.ID + "]异常 :" + err; } } //积分处理 if (point_body.Visible && DataConvert.CLng(Point_T.Text) > 0) { int point = DataConvert.CLng(Point_T.Text); int maxPoint = (int)((SiteConfig.ShopConfig.PointRatiot * 0.01) * (double)payMod.MoneyPay / SiteConfig.ShopConfig.PointRate); //if (point <= 0) { function.WriteErrMsg("积分数值不正确"); } if (point > mu.UserExp) { function.WriteErrMsg("您的积分不足!"); } if (point > maxPoint) { function.WriteErrMsg("积分不能大于可兑换金额!"); } //生成支付单时扣除用户积分 buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis() { ScoreType = (int)M_UserExpHis.SType.Point, score = -point, detail = "积分抵扣,支付单号:" + payMod.PayNo }); payMod.MoneyPay = payMod.MoneyPay - (point * SiteConfig.ShopConfig.PointRate); payMod.UsePoint = point; } if (payMod.MoneyPay <= 0) { payMod.MoneyPay = 0.01; } payMod.Remark = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string; payMod.PaymentID = payBll.Add(payMod); Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo); }
protected void Page_Load(object sender, EventArgs e) { ExHelper.CheckUserAuth("cash"); mu = buser.GetLogin(); M_Store_Info storeMod = ExHelper.Store_User(); orderMod = orderBll.SelReturnModel(OrderID); client = buser.SelReturnModel(DataConvert.CLng(orderMod.Receiver)); OrderHelper.CheckIsCanPay(orderMod); if (function.isAjax()) { M_Payment payMod = payBll.CreateByOrder(orderMod); payMod.UserID = mu.UserID; payMod.CStatus = true; payMod.Status = (int)M_Payment.PayStatus.HasPayed; string result = ""; try { string type = Request.Form["type"]; switch (type) { case "money": #region 现金支付/扫码支付 { double rece = DataConvert.CDouble(Request.Form["rece"]); if (rece < payMod.MoneyPay) { throw new Exception("金额不正确,不能少于应收金额"); } payMod.Remark = string.Format("应收{0},实收{1},找零{2}", payMod.MoneyPay, rece, rece - payMod.MoneyPay); payMod.MoneyTrue = rece > payMod.MoneyPay ? payMod.MoneyPay : rece; payMod.PayPlatID = (int)M_PayPlat.Plat.Offline; //现金扫码支付 } #endregion break; case "mcard": #region 会员卡支付 { if (client.IsNull) { throw new Exception("未指定会员,无法使用会员卡支付"); } else if (client.Purse < orderMod.Ordersamount) { throw new Exception("会员卡余额不足"); } else { buser.MinusVMoney(client.UserID, orderMod.Ordersamount, M_UserExpHis.SType.Purse, "会员卡支付[" + orderMod.OrderNo + "]"); //检测会员卡余额是否充足 payMod.Remark = "会员卡支付"; payMod.MoneyTrue = orderMod.Ordersamount; payMod.PayPlatID = (int)M_PayPlat.Plat.ECPSS; //会员卡支付 } } #endregion break; default: throw new Exception("支付方式[" + type + "]不存在"); } payMod.PaymentID = payBll.Add(payMod); OrderHelper.FinalStep(payMod, orderMod, null); result = "1"; } catch (Exception ex) { ZLLog.L(ZLEnum.Log.pay, "订单:" + orderMod.id + ",原因:" + ex.Message); result = ex.Message; } if (client.UserID > 0) { DBCenter.UpdateSQL(client.TbName, "UpdateTime=getdate()", "UserID=" + client.UserID); } Response.Write(result); Response.Flush(); Response.End(); } if (!IsPostBack) { StoreName_L.Text = storeMod.Title; Cart_RPT.DataSource = cpBll.SelByOrderID(orderMod.id); Cart_RPT.DataBind(); } }
//确定,生成信息写入ZL_Payment protected void BtnSubmit_Click(object sender, EventArgs e) { int platid = DataConverter.CLng(Request.Form["payplat_rad"]); M_UserInfo mu = buser.GetLogin(false); M_Payment pinfo = new M_Payment(); M_OrderList orderMod = new M_OrderList(); if (!string.IsNullOrEmpty(PayNo))//支付单付款 { pinfo = payBll.SelModelByPayNo(PayNo); if (pinfo.Status != (int)M_Payment.PayStatus.NoPay) { function.WriteErrMsg("该支付单已付款,请勿重复支付"); return; } } else { DataTable orderDT = orderBll.GetOrderbyOrderNo(OrderNo); GetTotal(orderDT, ref price, ref fare, ref allamount); if (allamount < 0.01) { function.WriteErrMsg("每次划款金额不能低于0.01元"); } if (orderDT != null && orderDT.Rows.Count > 0) { orderMod = orderBll.GetOrderListByid(DataConverter.CLng(orderDT.Rows[0]["id"])); orderBll.Update(orderMod); } pinfo.PaymentNum = OrderNo; pinfo.MoneyPay = allamount; DataTable cartDT = new DataTable(); if (orderMod.id > 0) { cartDT = bcart.GetCartProOrderID(orderMod.id); pinfo.Remark = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string; } else { pinfo.Remark = "没有对应订单"; } } pinfo.UserID = mu.UserID; pinfo.PayPlatID = platid; pinfo.MoneyID = 0; pinfo.MoneyReal = pinfo.MoneyPay; //用于支付宝网银 pinfo.PlatformInfo = Request.Form["payplat_rad"]; if (!string.IsNullOrEmpty(PayNo)) { payBll.Update(pinfo); } else { pinfo.Status = (int)M_Payment.PayStatus.NoPay; pinfo.PayNo = payBll.CreatePayNo(); payBll.Add(pinfo); } string url = "PayOnline.aspx?PayNo=" + pinfo.PayNo + "&StoreID=" + StoreID; if (pinfo.PayPlatID == 0) { url += "&method=" + Request.Form["payplat_rad"]; } Response.Redirect(url); }
protected void AddOrder_Btn_Click(object sender, EventArgs e) { //1,生成订单,2,关联购物车中商品为已绑定订单 M_UserInfo mu = buser.GetLogin(false); CartDT = cartBll.SelByCartID(B_Cart.GetCartID(), mu.UserID, ProClass, ids);//需要购买的商品 if (CartDT.Rows.Count < 1) { function.WriteErrMsg("你尚未选择商品,<a href='/Extend/Mobile/UserOrder.aspx'>查看我的订单</a>"); } CartDT.DefaultView.RowFilter = "StoreID=" + StoreID; CartDT = CartDT.DefaultView.ToTable(); //------生成订单前检测区 foreach (DataRow dr in CartDT.Rows) { if (!HasStock(dr["Allowed"], DataConvert.CLng(dr["stock"]), Convert.ToInt32(dr["Pronum"]))) { function.WriteErrMsg("购买失败," + dr["proname"] + "的库存数量不足"); } } //------检测End //按店铺生成订单 DataTable storeDT = CartDT.DefaultView.ToTable(true, "StoreID"); List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse) foreach (DataRow dr in storeDT.Rows) { #region 暂不使用字段 //Odata.province = this.DropDownList1.SelectedValue; //Odata.city = this.DropDownList2.SelectedValue;//将地址省份与市ID存入,XML数据源 //Odata.Guojia = "";//国家 //Odata.Chengshi = DropDownList2.SelectedItem.Text;//城市 //Odata.Diqu = DropDownList3.SelectedItem.Text;//地区 //Odata.Delivery = DataConverter.CLng(Request.Form["Delivery"]); //Odata.Deliverytime = DataConverter.CLng(this.Deliverytime.Text); //Odata.Mobile = receMod.MobileNum; #endregion M_OrderList Odata = new M_OrderList(); //通过微信支付的预购订单[special] Odata.Ordertype = (int)M_OrderList.OrderEnum.Cloud; Odata.OrderNo = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype); Odata.StoreID = Convert.ToInt32(dr["StoreID"]); CartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID; DataTable storeCartDT = CartDT.DefaultView.ToTable(); //M_UserRecei receMod = receBll.GetSelect(arsID, mu.UserID); //if (receMod == null) { function.WriteErrMsg("用户尚未选择送货地址,或地址不存在"); } //直接使用微信获取的用户信息填充 Odata.Receiver = mu.UserID.ToString(); Odata.Rename = mu.HoneyName; Odata.AddUser = mu.UserName;; Odata.Userid = mu.UserID; //Odata.Phone = receMod.phone; //Odata.MobileNum = receMod.MobileNum; //Odata.Email = receMod.Email; //Odata.Shengfen = receMod.Provinces; //Odata.Jiedao = receMod.Street; //Odata.ZipCode = receMod.Zipcode; Odata.Invoiceneeds = DataConverter.CLng(Request.Form["invoice_rad"]); //是否需开发票 Odata.Ordermessage = ORemind_T.Text; //订货留言 //-----金额计算 Odata.Balance_price = GetTotalMoney(storeCartDT); Odata.Freight = 0; Odata.Ordersamount = Odata.Balance_price + Odata.Freight; //订单金额 Odata.AllMoney_Json = orderCom.GetTotalJson(storeCartDT); //附加需要的虚拟币 Odata.Specifiedprice = Odata.Ordersamount; //订单金额; Odata.OrderStatus = (int)M_OrderList.StatusEnum.Normal; //订单状态 Odata.Paymentstatus = (int)M_OrderList.PayEnum.NoPay; //付款状态 //Odata.Integral = DataConverter.CLng(Request.QueryString["jifen"]); //Odata.ExpTime = exptime_hid.Value; Odata.id = orderBll.insert(Odata); cartProBll.CopyToCartPro(mu, storeCartDT, Odata.id); orderList.Add(Odata); orderCom.SendMessage(Odata, null, "ordered"); } cartBll.DelByids(ids); //-----------------订单生成后处理 //进行减库存等操作 foreach (DataRow dr in CartDT.Rows) { M_Product model = proBll.GetproductByid(Convert.ToInt32(dr["Proid"])); model.Stock = model.Stock - DataConvert.CLng(dr["Pronum"]); SqlHelper.ExecuteSql("Update ZL_Commodities Set Stock=" + model.Stock + " Where ID=" + model.ID); } //生成支付单,处理优惠券,并进入付款步骤 M_Payment payMod = payBll.CreateByOrder(orderList); //优惠券 //if (!string.IsNullOrEmpty(Request.Form["Arrive_Hid"])) //{ // M_Arrive avMod = avBll.SelModelByFlow(Request.Form["Arrive_Hid"], mu.UserID); // double money = payMod.MoneyPay; // string remind = "支付单抵扣[" + payMod.PayNo + "]"; // M_Arrive_Result retMod = avBll.U_UseArrive(avMod, mu.UserID, cartDT, money, remind); // if (retMod.enabled) // { // payMod.MoneyPay = retMod.money; // payMod.ArriveMoney = retMod.amount; // payMod.ArriveDetail = avMod.ID.ToString(); // } // else { payMod.ArriveDetail = "优惠券[" + avMod.ID + "]异常 :" + retMod.err; } //} //积分处理 //if (point_body.Visible && DataConvert.CLng(Point_T.Text) > 0) //{ // int point = DataConvert.CLng(Point_T.Text); // //此处需咨询,上限额度是否要扣减掉优惠券 // int maxPoint = Point_CanBeUse(payMod.MoneyPay + payMod.ArriveMoney); // //if (point <= 0) { function.WriteErrMsg("积分数值不正确"); } // if (point > mu.UserExp) { function.WriteErrMsg("您的积分不足!"); } // if (point > maxPoint) { function.WriteErrMsg("积分不能大于可兑换金额[" + maxPoint + "]!"); } // //生成支付单时扣除用户积分 // buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis() { ScoreType = (int)M_UserExpHis.SType.Point, score = -point, detail = "积分抵扣,支付单号:" + payMod.PayNo }); // payMod.UsePoint = point; // payMod.UsePointArrive = Point_ToMoney(point); // payMod.MoneyPay = payMod.MoneyPay - payMod.UsePointArrive; //} payMod.MoneyReal = payMod.MoneyPay; payMod.Remark = CartDT.Rows.Count > 1 ? "[" + CartDT.Rows[0]["ProName"] as string + "]等" : CartDT.Rows[0]["ProName"] as string; payMod.PaymentID = payBll.Add(payMod); Response.Redirect("/PayOnline/wxpay_mp.aspx?PayNo=" + payMod.PayNo); //Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo); }