public static bool UpdateGroupBuy(GroupBuyInfo groupBuy) { bool flag; Globals.EntityCoding(groupBuy, true); Database database = DatabaseFactory.CreateDatabase(); GroupBuyDao dao = new GroupBuyDao(); using (DbConnection connection = database.CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { if (!dao.UpdateGroupBuy(groupBuy, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); flag = true; } catch (Exception) { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return(flag); }
public static bool UpdateGroupBuy(GroupBuyInfo groupBuy) { Globals.EntityCoding(groupBuy, true); Database database = DatabaseFactory.CreateDatabase(); bool result; using (System.Data.Common.DbConnection dbConnection = database.CreateConnection()) { dbConnection.Open(); System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction(); try { GroupBuyDao groupBuyDao = new GroupBuyDao(); if (!groupBuyDao.UpdateGroupBuy(groupBuy, dbTransaction)) { dbTransaction.Rollback(); result = false; } else { if (!groupBuyDao.DeleteGroupBuyCondition(groupBuy.GroupBuyId, dbTransaction)) { dbTransaction.Rollback(); result = false; } else { if (!groupBuyDao.AddGroupBuyCondition(groupBuy.GroupBuyId, groupBuy.GroupBuyConditions, dbTransaction)) { dbTransaction.Rollback(); result = false; } else { dbTransaction.Commit(); result = true; } } } } catch (Exception var_4_99) { dbTransaction.Rollback(); result = false; } finally { dbConnection.Close(); } } return(result); }
public static bool CreatOrder(OrderInfo orderInfo) { bool flag = false; Database database = DatabaseFactory.CreateDatabase(); int quantity = orderInfo.LineItems.Sum <KeyValuePair <string, LineItemInfo> >((Func <KeyValuePair <string, LineItemInfo>, int>)(item => item.Value.Quantity)); lock (createOrderLocker) { if (orderInfo.GroupBuyId > 0) { checkCanGroupBuy(quantity, orderInfo.GroupBuyId); } using (DbConnection connection = database.CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { //WriteLog(orderInfo == null ? "orderinfo空" : "不为空"); if (string.IsNullOrEmpty(orderInfo.OrderId)) { orderInfo.OrderId = GenerateOrderIdByOrder(0, dbTran); } if (!new OrderDao().CreatOrder(orderInfo, dbTran)) { dbTran.Rollback(); return(false); } if ((orderInfo.LineItems.Count > 0) && !new LineItemDao().AddOrderLineItems(orderInfo.OrderId, orderInfo.LineItems.Values, dbTran)) { dbTran.Rollback(); return(false); } //如果有礼品,添加到礼品表 //add@20150921 by hj if (orderInfo.Gifts.Count > 0) { OrderGiftDao dao = new OrderGiftDao(); foreach (OrderGiftInfo info in orderInfo.Gifts) { if (!dao.AddOrderGift(orderInfo.OrderId, info, 0, dbTran)) { dbTran.Rollback(); return(false); } } } if (!string.IsNullOrEmpty(orderInfo.CouponCode) && !new CouponDao().AddCouponUseRecord(orderInfo, dbTran)) { dbTran.Rollback(); return(false); } //代金券功能目前不使用,redpagerId字段废除,用迪蔓的新规则:选择服务天使门店id代替 /* * if ((orderInfo.RedPagerID > 0) && !new UserRedPagerDao().AddUserRedPagerRecord(orderInfo, dbTran)) * { * dbTran.Rollback(); * return false; * } */ if (orderInfo.GroupBuyId > 0) { GroupBuyDao dao = new GroupBuyDao(); GroupBuyInfo groupBuy = dao.GetGroupBuy(orderInfo.GroupBuyId, dbTran); groupBuy.SoldCount += quantity; dao.UpdateGroupBuy(groupBuy, dbTran); dao.RefreshGroupBuyFinishState(orderInfo.GroupBuyId, dbTran); } dbTran.Commit(); flag = true; } catch (Exception ex) { //WriteLog(ex.Message); dbTran.Rollback(); throw; } finally { connection.Close(); } } } return(flag); }
public static bool CreatOrder(OrderInfo orderInfo) { bool flag = false; Database database = DatabaseFactory.CreateDatabase(); int quantity = orderInfo.LineItems.Sum <KeyValuePair <string, LineItemInfo> >((Func <KeyValuePair <string, LineItemInfo>, int>)(item => item.Value.Quantity)); lock (createOrderLocker) { if (orderInfo.GroupBuyId > 0) { checkCanGroupBuy(quantity, orderInfo.GroupBuyId); } using (DbConnection connection = database.CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { if (!new OrderDao().CreatOrder(orderInfo, dbTran)) { dbTran.Rollback(); return(false); } if ((orderInfo.LineItems.Count > 0) && !new LineItemDao().AddOrderLineItems(orderInfo.OrderId, orderInfo.LineItems.Values, dbTran)) { dbTran.Rollback(); return(false); } if (!string.IsNullOrEmpty(orderInfo.CouponCode) && !new CouponDao().AddCouponUseRecord(orderInfo, dbTran)) { dbTran.Rollback(); return(false); } if ((orderInfo.RedPagerID > 0) && !new UserRedPagerDao().AddUserRedPagerRecord(orderInfo, dbTran)) { dbTran.Rollback(); return(false); } if (orderInfo.GroupBuyId > 0) { GroupBuyDao dao = new GroupBuyDao(); GroupBuyInfo groupBuy = dao.GetGroupBuy(orderInfo.GroupBuyId, dbTran); groupBuy.SoldCount += quantity; dao.UpdateGroupBuy(groupBuy, dbTran); dao.RefreshGroupBuyFinishState(orderInfo.GroupBuyId, dbTran); } dbTran.Commit(); flag = true; } catch { dbTran.Rollback(); throw; } finally { connection.Close(); } } } return(flag); }
public static bool CreatOrder(OrderInfo orderInfo) { bool flag = false; Database database = DatabaseFactory.CreateDatabase(); int quantity = orderInfo.LineItems.Sum <KeyValuePair <string, LineItemInfo> >((Func <KeyValuePair <string, LineItemInfo>, int>)(item => item.Value.Quantity)); lock (createOrderLocker) { if (orderInfo.GroupBuyId > 0) { checkCanGroupBuy(quantity, orderInfo.GroupBuyId); } using (DbConnection connection = database.CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { try { if (!new OrderDao().CreatOrder(orderInfo, dbTran)) { dbTran.Rollback(); return(false); } if ((orderInfo.LineItems.Count > 0) && !new LineItemDao().AddOrderLineItems(orderInfo.OrderId, orderInfo.LineItems.Values, dbTran)) { dbTran.Rollback(); return(false); } if (!string.IsNullOrEmpty(orderInfo.CouponCode) && !new CouponDao().AddCouponUseRecord(orderInfo, dbTran)) { dbTran.Rollback(); return(false); } ICollection values = orderInfo.LineItems.Values; MemberInfo currentMember = MemberProcessor.GetCurrentMember(); foreach (LineItemInfo info2 in values) { if ((info2.Type == 1) && (info2.ExchangeId > 0)) { PointExchangeChangedInfo info3 = new PointExchangeChangedInfo(); info3.exChangeId = info2.ExchangeId; info3.exChangeName = new OrderDao().GetexChangeName(info3.exChangeId); info3.ProductId = info2.ProductId; info3.PointNumber = info2.PointNumber; info3.MemberID = orderInfo.UserId; info3.Date = DateTime.Now; info3.MemberGrades = currentMember.GradeId; if (!new OrderDao().InsertPointExchange_Changed(info3, dbTran, info2.Quantity)) { dbTran.Rollback(); return(false); } IntegralDetailInfo point = new IntegralDetailInfo { IntegralChange = -info2.PointNumber, IntegralSource = "积分兑换商品-订单号:" + orderInfo.OrderMarking, IntegralSourceType = 2, Remark = "积分兑换商品", Userid = orderInfo.UserId, GoToUrl = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId, IntegralStatus = Convert.ToInt32(IntegralDetailStatus.IntegralExchange) }; if (!new IntegralDetailDao().AddIntegralDetail(point, dbTran)) { dbTran.Rollback(); return(false); } } } if (orderInfo.PointExchange > 0) { IntegralDetailInfo info5 = new IntegralDetailInfo { IntegralChange = -orderInfo.PointExchange, IntegralSource = "积分抵现-订单号:" + orderInfo.OrderMarking, IntegralSourceType = 2, Remark = "积分抵现", Userid = orderInfo.UserId, GoToUrl = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId, IntegralStatus = Convert.ToInt32(IntegralDetailStatus.NowArrived) }; if (!new IntegralDetailDao().AddIntegralDetail(info5, dbTran)) { dbTran.Rollback(); return(false); } } if ((orderInfo.RedPagerID > 0) && !new OrderDao().UpdateCoupon_MemberCoupons(orderInfo, dbTran)) { dbTran.Rollback(); return(false); } if (orderInfo.GroupBuyId > 0) { GroupBuyDao dao = new GroupBuyDao(); GroupBuyInfo groupBuy = dao.GetGroupBuy(orderInfo.GroupBuyId, dbTran); groupBuy.SoldCount += quantity; dao.UpdateGroupBuy(groupBuy, dbTran); dao.RefreshGroupBuyFinishState(orderInfo.GroupBuyId, dbTran); } dbTran.Commit(); flag = true; } catch { dbTran.Rollback(); throw; } return(flag); } finally { connection.Close(); } return(flag); } } return(flag); }