public void OrderDetailsPayInit(string oid, OrderDetail od) { this.oid = oid; StringBuilder sb = new StringBuilder(); OrderBuss ob = new OrderBuss(); DAO.OrderPay op = ob.GetOrderPay(oid); if (string.IsNullOrEmpty(od.order.OrderType) || od.order.OrderType == "0")//正常订单 { //string strsql = "select * from OrderProductList p where p.OrderId=" + id; //var list = db.Database.SqlQuery<DAO.OrderProductList>(strsql).ToList(); List <DAO.OrderProList> ordList = od.opList; foreach (DAO.OrderProList p in ordList) { sb.AppendFormat("{0}x{1},", p.ProductName, p.Num); } if (sb.Length > 0) { if (sb[sb.Length - 1] == ',') { sb.Remove(sb.Length - 1, 1); } } this.description = sb.ToString(); this.price = Math.Round(op.Amount, 2);//Math.Round(od.order.TotalPrice,2); this.Freight = "¥0"; this.uname = od.order.UserName; this.Pay = "支付宝"; this.phone = od.order.CellPhone; this.tel = od.order.CellPhone; this.Rinfo = string.Format("{0}-{1}{2}{3}{4}", od.order.UserName, od.order.Prov, od.order.City, od.order.Area, od.order.Address); this.rtime = ""; this.addTime = string.Format("{0:yyyy-MM-dd hh:mm:ss}", od.order.OrderTime); this.orderType = 0; } //else if (op.OrderType == 1) //{ // MemberCoinBusiness bmc = new MemberCoinBusiness(); // bmc.GetChargeByOrder(this.oid); // this.description = string.Format("充值{0}诚配币x1", bmc.mc.Amount); // this.price = "¥" + op.Amount; // this.Freight = "¥0.00"; // this.uname = op.ULoginName; // this.Pay = op.Bank; // this.phone = " "; // this.tel = ""; // this.addTime = Convert.ToDateTime(bmc.mc.CreateTime); // this.orderType = 1; //} }
/// <summary> /// 提交订单 /// </summary> /// <param name="shopList">商品列表</param> /// <param name="sendinfo">配送信息</param> /// <param name="uid">当前用户</param> /// <param name="ratio">当前用户折扣</param> /// <param name="orderPrice">订单金额</param> /// <param name="shopListTotle">商品列表总金额</param> /// <returns>订单号</returns> public string AddOrder(List <Shop> shopList, SendInfo sendinfo, string uid, decimal ratio, decimal orderPrice, decimal shopListTotle) { PartExtendBll pbll = new PartExtendBll(); ProductBll proBll = new ProductBll(); MemberBLL memBll = new MemberBLL(); DAO.MemberBase user = memBll.GetUserByID(uid); DAO.Order order = new DAO.Order(); order.OrderId = CommonUtils.OrderUtil.NewOrderId; if (order != null) { order.Uid = user.ID; order.UserName = user.LoginName; order.UserPhone = user.Mobile; } order.OrderSource = "0"; order.OrderTime = DateTime.Now; order.OrderStatus = "未处理";//订单初始状态 order.Consignee = sendinfo.Name; order.Address = sendinfo.Address; order.CellPhone = sendinfo.Phone; order.PayStatus = "未支付"; order.Payment = ""; order.Remarks = ""; order.Ratio = ratio; decimal disAmout = shopList.Where(h => h.Type == "-1").Sum(h => (decimal.Parse(h.Price))); order.DiscountAmount = (1 - ratio) * disAmout; order.ShippingCost = 0; order.TotalPrice = orderPrice; order.SearchTag = ""; order.OperatorRemarks = ""; order.OrderType = "0"; order.OrderFrom = 0;//网站 order.Prov = sendinfo.Prov; order.City = sendinfo.City; order.Area = sendinfo.Area; db.Order.Add(order); DAO.Addship addShip = new DAO.Addship(); addShip = isAddressByUid(uid); if (addShip != null) { upAddShip(sendinfo.Name, uid, sendinfo.City, sendinfo.Prov, sendinfo.Area, sendinfo.Address, sendinfo.Phone); } else { DAO.Addship addShipS = new DAO.Addship(); addShipS.name = sendinfo.Name; addShipS.province = sendinfo.Prov; addShipS.scity = sendinfo.City; addShipS.region = sendinfo.Area; addShipS.address = sendinfo.Address; addShipS.UID = Convert.ToInt32(uid); addShipS.phone = sendinfo.Phone; db.Addship.Add(addShipS); db.SaveChanges(); } //db.SaveChanges(); foreach (Shop item in shopList) { CarProductDetail m; int i = -1; int pid = -1; if (int.TryParse(item.ID, out pid)) { if (!string.IsNullOrEmpty(item.Attrs) && int.TryParse(item.Attrs, out i)) { m = proBll.GetProDetail(pid, i, item.Type); } else { m = proBll.GetProDetail(pid, -1, item.Type); } if (m != null) { m.Qty = int.Parse(item.Qty); m.lastAttr = item.Attrs; DAO.OrderProList pro = new DAO.OrderProList(); pro.OrderId = order.OrderId; pro.ProductID = m.proDetail.ID; pro.ProductName = m.proDetail.PartName; pro.SupplyNo = m.proDetail.PartSuppyNo; pro.Num = m.Qty; pro.Price = m.proDetail.Price; pro.InputTime = DateTime.Now; pro.PType = m.proDetail.CategoryID; pro.AttrID = i; pro.IsFlag = int.Parse(item.Type); //活动号 pro.activeName = m.activeM == null ? "" : m.activeM.Name; StringBuilder sb = new StringBuilder(""); foreach (var ext in m.partExt) { sb.Append("|" + ext.AttrName + ":" + ext.AttrValue + "|"); } pro.AttrDecribe = sb.ToString(); db.OrderProList.Add(pro); opActiveStock(pro.IsFlag, pro.ProductID, pro.AttrID, pro.Num); OrderBuss obll = new OrderBuss(); int number = Convert.ToInt32(obll.getPartStock(m.proDetail.ID).StockNUM) - 1; obll.upPartStock(m.proDetail.ID, number); //db.SaveChanges(); } } } int addResult = db.SaveChanges();//db.SaveChanges(); if (addResult > 0) { return(order.OrderId.ToString()); } else { return(null); } }