/// <summary> /// 确认订单按钮 /// </summary> /// <returns></returns> public Boolean CheckOutStoreOrder(IList <StoreOrderModel> orders, string storeid) { using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { conn.Open(); //打开连接 SqlTransaction tr = conn.BeginTransaction(); //开启事务 try { decimal ordermoney = 0; decimal turnmoney = 0; string orderids = ""; foreach (StoreOrderModel order in orders) { if (!StoreOrderDAL.GetIsCheckOut(tr, order.StoreorderId)) //判断该订单是否已经支付 { if (StoreOrderDAL.UpdateOrderGoodsState(tr, order.StoreorderId)) //更改订单成已支付状态 { orderids += order.StoreorderId + ";"; if (order.OrderType == 0) { ordermoney += order.TotalMoney; } else if (order.OrderType == 1) { turnmoney += order.TotalMoney; } if (!StockDAL.UpdateInWayCount(tr, OrderDetailDAL.GetOrderGoodsDetail(order.StoreorderId), storeid))//跟新店库存,添加在途数量,去除预定数量 { tr.Rollback(); return(false); } if (!LogicProductInventoryDAL.UpdateToatlOut(tr, CommonDataBLL.GetNewOrderDetail(OrderDetailDAL.GetOrderGoodsDetail(order.StoreorderId))))//更新公司 逻辑库存 { tr.Rollback(); return(false); } } else { tr.Rollback(); return(false); } } } //添加对账单 D_AccountBLL.AddAccount(storeid, Convert.ToDouble(ordermoney), D_AccountSftype.StoreType, D_AccountKmtype.StoreOrderout, DirectionEnum.AccountReduced, "店铺【" + storeid + "】在线订货,订货款扣除额,订单号为【" + orderids + "】", tr); //跟新店货款 if (!StoreInfoDAL.UpdateSomeMoney(tr, ordermoney, turnmoney, storeid)) { tr.Rollback(); return(false); } tr.Commit(); } catch { tr.Rollback(); return(false); } finally { conn.Close(); } } return(true); }
///// <summary> ///// 查询订单信息 ///// </summary> ///// <param name="storeId"></param> ///// <returns></returns> //public IList<StoreOrderModel> GetStoreOrderList(int storeId) //{ // StoreOrderDAL server = new StoreOrderDAL(); // return server.GetStoreOrderLists(storeId.ToString()); //} /// <summary> /// 验证 公司逻辑库存是否足够 /// </summary> /// <param name="orders">订单列表</param> /// <returns></returns> public static bool CheckLogicProductInventory(IList <StoreOrderModel> orders) { return(LogicProductInventoryDAL.SelectProductNum(orders)); }