/// <summary> /// 新增订单 /// </summary> /// <param name="order"></param> /// <param name="cart"></param> /// <param name="proCode"></param> /// <param name="pay"></param> /// <param name="userId"></param> public void addOrder(Bs_Orders order, Cart cart, ref string proCode, ref decimal pay, int userId) { decimal deliverPay = 0; DataTable dtDeliver = dao.getDeliverByCode(order.Sy_DeliverCode); if (dtDeliver.Rows.Count > 0) { deliverPay = decimal.Parse(dtDeliver.Rows[0]["amount"].ToString()); order.DeliverFee = deliverPay; } Random rd = new Random(); string orderCode = DateTime.Now.ToString("yyMMddHHmmssff") + rd.Next(1000, 9999).ToString(); order.Code = orderCode; // order.Discount = BLL.BsUser.User.GetDisCount(); decimal Amount = 0; int qty = 0; foreach (Product cartPro in cart.Values.Values) { Bs_Products pro = Factory.getProBllInstance().getProById(cartPro.ProId); Bs_OrdersDtl orderDtl = new Bs_OrdersDtl(); orderDtl.Bs_OrdersCode = orderCode; orderDtl.Price = decimal.Parse(cartPro.Price.ToString()); orderDtl.Quantity = cartPro.Qty; orderDtl.Bs_ProductsCode = pro.ID.ToString(); orderDtl.Amount = (decimal)(cartPro.Price * cartPro.Qty); orderDtl.Color = cartPro.Color; orderDtl.Width = cartPro.Width; orderDtl.Dimension = cartPro.Size; dao.addOrderDtl(orderDtl); qty += cartPro.Qty; Amount += (decimal)orderDtl.Amount; } order.DeliverFee = (decimal)deliverPay; order.ProductFee = Amount; Amount += (decimal)deliverPay; pay = Amount; order.Bs_UserID = userId; order.Quantity = qty; order.Amount = pay; order.ModTime = DateTime.Now.ToString("s"); order.AddTime = DateTime.Now.ToString("s"); order.Status = Const.orderState_new; proCode = order.Code; dao.addOrder(order); }
/// <summary> /// 传入订单号,初始化一个订单支付实体 /// </summary> /// <param name="num"></param> public PayOrder(string num, string payno) { // //TODO: 在此处添加构造函数逻辑 // _num = num; _type = "OD"; _typeName = "订单支付"; _payNo = payno; string sql = "select amount,Sy_DeliverCode from {0} where code='{1}'"; sql = string.Format(sql, tblName, num); DataTable obj = CSA.DAL.DBAccess.getRS(sql); if (obj != null && obj.Rows.Count != 0) { DataRow dr = obj.Rows[0]; _amount = double.Parse(dr["amount"].ToString()); Bs_OrderDao bs_orderDao = new Bs_OrderDao(); DataTable dtDelive = bs_orderDao.getDeliverByCode(dr["Sy_DeliverCode"].ToString()); if (dtDelive != null && dtDelive.Rows.Count != 0) { _delivName = dtDelive.Rows[0]["Name"].ToString(); } } else { _amount = 0; } }