/// <summary> /// 增加一条数据 /// </summary> public void Add(SOSOshop.Model.Order.Orders model, DbTransaction tran) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Orders("); strSql.Append("OrderId,UserName,ReceiverId,ShopDate,OrderDate,ConsigneeRealName,ConsigneeName,ConsigneePhone,ConsigneeProvince,ConsigneeAddress,ConsigneeZip,ConsigneeTel,ConsigneeFax,ConsigneeEmail,PaymentType,Payment,TotalPrice,Fees,OtherFees,Invoice,Remark,OrderStatus,PaymentStatus,OgisticsStatus,BusinessmanID,BusinessmanName,Carriage,OrderType,ContractNo,ConsigneeCity,ConsigneeBorough,ConsigneeConstructionSigns,ConsignesTime,TradeFees,TradeFeesPay,Editer,parentid,parentCorpName,BillingCorp,BillingCorpName,IsBusinessCheck,isFinancialReview,BusinessCheckDate,FinancialCheckDate,IsSend,source)"); strSql.Append(" values ("); strSql.Append("@OrderId,@UserName,@ReceiverId,@ShopDate,@OrderDate,@ConsigneeRealName,@ConsigneeName,@ConsigneePhone,@ConsigneeProvince,@ConsigneeAddress,@ConsigneeZip,@ConsigneeTel,@ConsigneeFax,@ConsigneeEmail,@PaymentType,@Payment,@TotalPrice,@Fees,@OtherFees,@Invoice,@Remark,@OrderStatus,@PaymentStatus,@OgisticsStatus,@BusinessmanID,@BusinessmanName,@Carriage,@OrderType,@ContractNo,@ConsigneeCity,@ConsigneeBorough,@ConsigneeConstructionSigns,@ConsignesTime,@TradeFees,@TradeFeesPay,@Editer,@parentid,@parentCorpName,@BillingCorp,@BillingCorpName,@IsBusinessCheck,@isFinancialReview,@BusinessCheckDate,@FinancialCheckDate,@IsSend,@source)"); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "OrderId", DbType.AnsiString, model.OrderId); db.AddInParameter(dbCommand, "UserName", DbType.AnsiString, model.UserName); db.AddInParameter(dbCommand, "ReceiverId", DbType.Int32, model.ReceiverId); db.AddInParameter(dbCommand, "ShopDate", DbType.DateTime, model.ShopDate); db.AddInParameter(dbCommand, "OrderDate", DbType.DateTime, model.OrderDate); db.AddInParameter(dbCommand, "ConsigneeRealName", DbType.AnsiString, model.ConsigneeRealName); db.AddInParameter(dbCommand, "ConsigneeName", DbType.AnsiString, model.ConsigneeName); db.AddInParameter(dbCommand, "ConsigneePhone", DbType.AnsiString, model.ConsigneePhone); db.AddInParameter(dbCommand, "ConsigneeProvince", DbType.AnsiString, model.ConsigneeProvince); db.AddInParameter(dbCommand, "ConsigneeAddress", DbType.AnsiString, model.ConsigneeAddress); db.AddInParameter(dbCommand, "ConsigneeZip", DbType.AnsiString, model.ConsigneeZip); db.AddInParameter(dbCommand, "ConsigneeTel", DbType.AnsiString, model.ConsigneeTel); db.AddInParameter(dbCommand, "ConsigneeFax", DbType.AnsiString, model.ConsigneeFax); db.AddInParameter(dbCommand, "ConsigneeEmail", DbType.AnsiString, model.ConsigneeEmail); db.AddInParameter(dbCommand, "PaymentType", DbType.Int32, model.PaymentType); db.AddInParameter(dbCommand, "Payment", DbType.Int32, model.Payment); db.AddInParameter(dbCommand, "TotalPrice", DbType.Double, model.TotalPrice); db.AddInParameter(dbCommand, "Fees", DbType.Double, model.Fees); db.AddInParameter(dbCommand, "OtherFees", DbType.Double, model.OtherFees); db.AddInParameter(dbCommand, "Invoice", DbType.Int32, model.Invoice); db.AddInParameter(dbCommand, "Remark", DbType.AnsiString, model.Remark); db.AddInParameter(dbCommand, "OrderStatus", DbType.Int32, model.OrderStatus); db.AddInParameter(dbCommand, "PaymentStatus", DbType.Int32, model.PaymentStatus); db.AddInParameter(dbCommand, "OgisticsStatus", DbType.Int32, model.OgisticsStatus); db.AddInParameter(dbCommand, "BusinessmanID", DbType.Int32, model.BusinessmanID); db.AddInParameter(dbCommand, "BusinessmanName", DbType.AnsiString, model.BusinessmanName); db.AddInParameter(dbCommand, "Carriage", DbType.Int32, model.Carriage); db.AddInParameter(dbCommand, "OrderType", DbType.Int32, model.OrderType); db.AddInParameter(dbCommand, "ContractNo", DbType.AnsiString, model.ContractNo); db.AddInParameter(dbCommand, "ConsigneeCity", DbType.AnsiString, model.ConsigneeCity); db.AddInParameter(dbCommand, "ConsigneeBorough", DbType.AnsiString, model.ConsigneeBorough); db.AddInParameter(dbCommand, "ConsigneeConstructionSigns", DbType.AnsiString, model.ConsigneeConstructionSigns); db.AddInParameter(dbCommand, "ConsignesTime", DbType.AnsiString, model.ConsignesTime); db.AddInParameter(dbCommand, "TradeFees", DbType.Double, model.TradeFees); db.AddInParameter(dbCommand, "TradeFeesPay", DbType.Int32, model.TradeFeesPay); db.AddInParameter(dbCommand, "Editer", DbType.Int32, model.Editer); db.AddInParameter(dbCommand, "parentid", DbType.Int32, model.parentid); db.AddInParameter(dbCommand, "parentCorpName", DbType.AnsiString, model.parentCorpName); db.AddInParameter(dbCommand, "BillingCorp", DbType.Int32, model.BillingCorp); db.AddInParameter(dbCommand, "BillingCorpName", DbType.AnsiString, model.BillingCorpName); db.AddInParameter(dbCommand, "IsBusinessCheck", DbType.Int32, model.IsBusinessCheck); db.AddInParameter(dbCommand, "isFinancialReview", DbType.Int32, model.isFinancialReview); db.AddInParameter(dbCommand, "BusinessCheckDate", DbType.DateTime, model.BusinessCheckDate); db.AddInParameter(dbCommand, "FinancialCheckDate", DbType.DateTime, model.FinancialCheckDate); db.AddInParameter(dbCommand, "IsSend", DbType.Boolean, model.IsSend); db.AddInParameter(dbCommand, "source", DbType.Int32, model.source); db.ExecuteScalar(dbCommand, tran); }
/// <summary> /// 添加订单(一般来说添加订单必须用此api) /// </summary> /// <param name="order">订单model</param> /// <param name="li">订单商品列表</param> /// <returns>如果添加成功则返回订单号,否则则返回null</returns> public string Add(SOSOshop.Model.Order.Orders order, List <SOSOshop.Model.Order.OrderProduct> li) { order.TotalPrice = (decimal)(from a in li select a.ProNum * a.ProPrice).Sum(); //如果不是在线支付则取消需要在后台手动确认付款 //如果有E商的品种就不执行上述规则(取消此规则2014-06-17) if (order.PaymentType == 2) { order.PaymentStatus = 1; order.OrderStatus = (int)Enums.OrderStatus.Paid; order.FinancialCheckDate = DateTime.Now; } if (li.Count < 1) { throw new Exception("品种数量不能为空!"); } order.OrderId = CreateOrderId(order.ReceiverId); using (DbConnection conn = db.CreateConnection()) { conn.Open(); DbTransaction tran = conn.BeginTransaction(); try { order.splitStatus = 1; Add(order, tran); SOSOshop.BLL.Order.OrderProduct bll = new OrderProduct(); foreach (var item in li) { if (item.ProNum > 0 && item.ProPrice > 0) { item.OrderId = order.OrderId; bll.Add(item, tran); } else { SOSOshop.BLL.Logs.Log.LogShopAdd(string.Format("订单商品数量为零,或价格为零,订单号:{0},商品id:{1}", order.OrderId, item.ProId), "", 0, "", 2); } } tran.Commit(); } catch (Exception e) { tran.Rollback(); throw e; } } base.ExecuteNonQuery(string.Format("INSERT INTO OrdersMQ (orderid) VALUES('{0}')", order.OrderId)); return(order.OrderId); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(SOSOshop.Model.Order.Orders model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Orders set "); strSql.Append("UserName=@UserName,"); strSql.Append("ReceiverId=@ReceiverId,"); strSql.Append("ShopDate=@ShopDate,"); strSql.Append("OrderDate=@OrderDate,"); strSql.Append("ConsigneeRealName=@ConsigneeRealName,"); strSql.Append("ConsigneeName=@ConsigneeName,"); strSql.Append("ConsigneePhone=@ConsigneePhone,"); strSql.Append("ConsigneeProvince=@ConsigneeProvince,"); strSql.Append("ConsigneeAddress=@ConsigneeAddress,"); strSql.Append("ConsigneeZip=@ConsigneeZip,"); strSql.Append("ConsigneeTel=@ConsigneeTel,"); strSql.Append("ConsigneeFax=@ConsigneeFax,"); strSql.Append("ConsigneeEmail=@ConsigneeEmail,"); strSql.Append("PaymentType=@PaymentType,"); strSql.Append("Payment=@Payment,"); strSql.Append("TotalPrice=@TotalPrice,"); strSql.Append("Fees=@Fees,"); strSql.Append("OtherFees=@OtherFees,"); strSql.Append("Invoice=@Invoice,"); strSql.Append("Remark=@Remark,"); strSql.Append("OrderStatus=@OrderStatus,"); strSql.Append("PaymentStatus=@PaymentStatus,"); strSql.Append("OgisticsStatus=@OgisticsStatus,"); strSql.Append("BusinessmanID=@BusinessmanID,"); strSql.Append("BusinessmanName=@BusinessmanName,"); strSql.Append("Carriage=@Carriage,"); strSql.Append("OrderType=@OrderType,"); strSql.Append("ContractNo=@ContractNo,"); strSql.Append("ConsigneeCity=@ConsigneeCity,"); strSql.Append("ConsigneeBorough=@ConsigneeBorough,"); strSql.Append("ConsigneeConstructionSigns=@ConsigneeConstructionSigns,"); strSql.Append("ConsignesTime=@ConsignesTime,"); strSql.Append("TradeFees=@TradeFees,"); strSql.Append("TradeFeesPay=@TradeFeesPay,"); strSql.Append("Editer=@Editer,"); strSql.Append("parentid=@parentid,"); strSql.Append("parentCorpName=@parentCorpName,"); strSql.Append("BillingCorp=@BillingCorp,"); strSql.Append("BillingCorpName=@BillingCorpName,"); strSql.Append("IsBusinessCheck=@IsBusinessCheck,"); strSql.Append("isFinancialReview=@isFinancialReview,"); strSql.Append("BusinessCheckDate=@BusinessCheckDate,"); strSql.Append("FinancialCheckDate=@FinancialCheckDate"); strSql.Append(" where Id=@Id "); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "Id", DbType.Int32, model.Id); db.AddInParameter(dbCommand, "OrderId", DbType.AnsiString, model.OrderId); db.AddInParameter(dbCommand, "UserName", DbType.AnsiString, model.UserName); db.AddInParameter(dbCommand, "ReceiverId", DbType.Int32, model.ReceiverId); db.AddInParameter(dbCommand, "ShopDate", DbType.DateTime, model.ShopDate); db.AddInParameter(dbCommand, "OrderDate", DbType.DateTime, model.OrderDate); db.AddInParameter(dbCommand, "ConsigneeRealName", DbType.AnsiString, model.ConsigneeRealName); db.AddInParameter(dbCommand, "ConsigneeName", DbType.AnsiString, model.ConsigneeName); db.AddInParameter(dbCommand, "ConsigneePhone", DbType.AnsiString, model.ConsigneePhone); db.AddInParameter(dbCommand, "ConsigneeProvince", DbType.AnsiString, model.ConsigneeProvince); db.AddInParameter(dbCommand, "ConsigneeAddress", DbType.AnsiString, model.ConsigneeAddress); db.AddInParameter(dbCommand, "ConsigneeZip", DbType.AnsiString, model.ConsigneeZip); db.AddInParameter(dbCommand, "ConsigneeTel", DbType.AnsiString, model.ConsigneeTel); db.AddInParameter(dbCommand, "ConsigneeFax", DbType.AnsiString, model.ConsigneeFax); db.AddInParameter(dbCommand, "ConsigneeEmail", DbType.AnsiString, model.ConsigneeEmail); db.AddInParameter(dbCommand, "PaymentType", DbType.Int32, model.PaymentType); db.AddInParameter(dbCommand, "Payment", DbType.Int32, model.Payment); db.AddInParameter(dbCommand, "TotalPrice", DbType.Double, model.TotalPrice); db.AddInParameter(dbCommand, "Fees", DbType.Double, model.Fees); db.AddInParameter(dbCommand, "OtherFees", DbType.Double, model.OtherFees); db.AddInParameter(dbCommand, "Invoice", DbType.Int32, model.Invoice); db.AddInParameter(dbCommand, "Remark", DbType.AnsiString, model.Remark); db.AddInParameter(dbCommand, "OrderStatus", DbType.Int32, model.OrderStatus); db.AddInParameter(dbCommand, "PaymentStatus", DbType.Int32, model.PaymentStatus); db.AddInParameter(dbCommand, "OgisticsStatus", DbType.Int32, model.OgisticsStatus); db.AddInParameter(dbCommand, "BusinessmanID", DbType.Int32, model.BusinessmanID); db.AddInParameter(dbCommand, "BusinessmanName", DbType.AnsiString, model.BusinessmanName); db.AddInParameter(dbCommand, "Carriage", DbType.Int32, model.Carriage); db.AddInParameter(dbCommand, "OrderType", DbType.Int32, model.OrderType); db.AddInParameter(dbCommand, "ContractNo", DbType.AnsiString, model.ContractNo); db.AddInParameter(dbCommand, "ConsigneeCity", DbType.AnsiString, model.ConsigneeCity); db.AddInParameter(dbCommand, "ConsigneeBorough", DbType.AnsiString, model.ConsigneeBorough); db.AddInParameter(dbCommand, "ConsigneeConstructionSigns", DbType.AnsiString, model.ConsigneeConstructionSigns); db.AddInParameter(dbCommand, "ConsignesTime", DbType.AnsiString, model.ConsignesTime); db.AddInParameter(dbCommand, "TradeFees", DbType.Double, model.TradeFees); db.AddInParameter(dbCommand, "TradeFeesPay", DbType.Int32, model.TradeFeesPay); db.AddInParameter(dbCommand, "Editer", DbType.Int32, model.Editer); db.AddInParameter(dbCommand, "parentid", DbType.Int32, model.parentid); db.AddInParameter(dbCommand, "parentCorpName", DbType.AnsiString, model.parentCorpName); db.AddInParameter(dbCommand, "BillingCorp", DbType.Int32, model.BillingCorp); db.AddInParameter(dbCommand, "BillingCorpName", DbType.AnsiString, model.BillingCorpName); db.AddInParameter(dbCommand, "IsBusinessCheck", DbType.Int32, model.IsBusinessCheck); db.AddInParameter(dbCommand, "isFinancialReview", DbType.Int32, model.isFinancialReview); db.AddInParameter(dbCommand, "BusinessCheckDate", DbType.DateTime, model.BusinessCheckDate); db.AddInParameter(dbCommand, "FinancialCheckDate", DbType.DateTime, model.FinancialCheckDate); int rows = db.ExecuteNonQuery(dbCommand); if (rows > 0) { return(true); } else { return(false); } }