public static bool UserPayOrder(OrderInfo order) { OrderDao dao = new OrderDao(); order.OrderStatus = OrderStatus.BuyerAlreadyPaid; order.PayDate = new DateTime?(DateTime.Now); bool flag = dao.UpdateOrder(order, null); if (flag) { dao.UpdatePayOrderStock(order.OrderId); foreach (LineItemInfo info in order.LineItems.Values) { ProductDao dao2 = new ProductDao(); ProductInfo productDetails = dao2.GetProductDetails(info.ProductId); productDetails.SaleCounts += info.Quantity; productDetails.ShowSaleCounts += info.Quantity; dao2.UpdateProduct(productDetails, null); } MemberInfo member = GetMember(order.UserId); if (member == null) { return flag; } MemberDao dao3 = new MemberDao(); PointDetailInfo point = new PointDetailInfo { OrderId = order.OrderId, UserId = member.UserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Bounty, Increased = new int?(order.Points), Points = order.Points + member.Points }; if ((point.Points > 0x7fffffff) || (point.Points < 0)) { point.Points = 0x7fffffff; } PointDetailDao dao4 = new PointDetailDao(); dao4.AddPointDetail(point); member.Expenditure += order.GetTotal(); member.OrderNumber++; dao3.Update(member); Messenger.OrderPayment(member, order.OrderId, order.GetTotal()); int historyPoint = dao4.GetHistoryPoint(member.UserId); List<MemberGradeInfo> memberGrades = new MemberGradeDao().GetMemberGrades() as List<MemberGradeInfo>; foreach (MemberGradeInfo info5 in from item in memberGrades orderby item.Points descending select item) { if (member.GradeId == info5.GradeId) { return flag; } if (info5.Points <= historyPoint) { member.GradeId = info5.GradeId; dao3.Update(member); return flag; } } } return flag; }
public static bool SendGoods(OrderInfo order) { ManagerHelper.CheckPrivilege(Privilege.OrderSendGoods); bool flag = false; if (order.CheckAction(OrderActions.SELLER_SEND_GOODS)) { OrderDao dao = new OrderDao(); order.OrderStatus = OrderStatus.SellerAlreadySent; order.ShippingDate = new DateTime?(DateTime.Now); flag = dao.UpdateOrder(order, null); if (!flag) { return flag; } if (order.Gateway.ToLower() == "hishop.plugins.payment.podrequest") { dao.UpdatePayOrderStock(order.OrderId); foreach (LineItemInfo info in order.LineItems.Values) { ProductDao dao2 = new ProductDao(); ProductInfo productDetails = dao2.GetProductDetails(info.ProductId); productDetails.SaleCounts += info.Quantity; productDetails.ShowSaleCounts += info.Quantity; dao2.UpdateProduct(productDetails, null); } UpdateUserAccount(order); } EventLogs.WriteOperationLog(Privilege.OrderSendGoods, string.Format(CultureInfo.InvariantCulture, "发货编号为\"{0}\"的订单", new object[] { order.OrderId })); } return flag; }
public static bool ConfirmPay(OrderInfo order) { ManagerHelper.CheckPrivilege(Privilege.CofimOrderPay); bool flag = false; if (order.CheckAction(OrderActions.SELLER_CONFIRM_PAY)) { OrderDao dao = new OrderDao(); order.OrderStatus = OrderStatus.BuyerAlreadyPaid; order.PayDate = new DateTime?(DateTime.Now); flag = dao.UpdateOrder(order, null); if (!flag) { return flag; } dao.UpdatePayOrderStock(order.OrderId); foreach (LineItemInfo info in order.LineItems.Values) { ProductDao dao2 = new ProductDao(); ProductInfo productDetails = dao2.GetProductDetails(info.ProductId); productDetails.SaleCounts += info.Quantity; productDetails.ShowSaleCounts += info.Quantity; dao2.UpdateProduct(productDetails, null); } UpdateUserAccount(order); Messenger.OrderPayment(new MemberDao().GetMember(order.UserId), order.OrderId, order.GetTotal()); EventLogs.WriteOperationLog(Privilege.CofimOrderPay, string.Format(CultureInfo.InvariantCulture, "确认收款编号为\"{0}\"的订单", new object[] { order.OrderId })); } return flag; }
public static ProductActionStatus UpdateProduct(ProductInfo product, Dictionary<string, SKUItem> skus, Dictionary<int, IList<int>> attrs, IList<int> tagIds) { if (null == product) { return ProductActionStatus.UnknowError; } Globals.EntityCoding(product, true); int decimalLength = SettingsManager.GetMasterSettings(true).DecimalLength; if (product.MarketPrice.HasValue) { product.MarketPrice = new decimal?(Math.Round(product.MarketPrice.Value, decimalLength)); } ProductActionStatus unknowError = ProductActionStatus.UnknowError; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { ProductDao dao = new ProductDao(); if (!dao.UpdateProduct(product, dbTran)) { dbTran.Rollback(); return ProductActionStatus.DuplicateSKU; } if (!dao.DeleteProductSKUS(product.ProductId, dbTran)) { dbTran.Rollback(); return ProductActionStatus.SKUError; } if (((skus != null) && (skus.Count > 0)) && !dao.AddProductSKUs(product.ProductId, skus, dbTran)) { dbTran.Rollback(); return ProductActionStatus.SKUError; } if (!dao.AddProductAttributes(product.ProductId, attrs, dbTran)) { dbTran.Rollback(); return ProductActionStatus.AttributeError; } if (!new TagDao().DeleteProductTags(product.ProductId, dbTran)) { dbTran.Rollback(); return ProductActionStatus.ProductTagEroor; } if ((tagIds.Count > 0) && !new TagDao().AddProductTags(product.ProductId, tagIds, dbTran)) { dbTran.Rollback(); return ProductActionStatus.ProductTagEroor; } dbTran.Commit(); unknowError = ProductActionStatus.Success; } catch (Exception) { dbTran.Rollback(); } finally { connection.Close(); } } if (unknowError == ProductActionStatus.Success) { EventLogs.WriteOperationLog(Privilege.EditProducts, string.Format(CultureInfo.InvariantCulture, "修改了编号为 “{0}” 的商品", new object[] { product.ProductId })); } return unknowError; }