public static ProductActionStatus AddProduct(ProductInfo product, Dictionary<string, SKUItem> skus, Dictionary<int, IList<int>> attrs, IList<int> tagsId) { 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(); int productId = dao.AddProduct(product, dbTran); if (productId == 0) { dbTran.Rollback(); return ProductActionStatus.DuplicateSKU; } product.ProductId = productId; if (((skus != null) && (skus.Count > 0)) && !dao.AddProductSKUs(productId, skus, dbTran)) { dbTran.Rollback(); return ProductActionStatus.SKUError; } if (((attrs != null) && (attrs.Count > 0)) && !dao.AddProductAttributes(productId, attrs, dbTran)) { dbTran.Rollback(); return ProductActionStatus.AttributeError; } if (((tagsId != null) && (tagsId.Count > 0)) && !new TagDao().AddProductTags(productId, tagsId, 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.AddProducts, string.Format(CultureInfo.InvariantCulture, "上架了一个新商品:”{0}”", new object[] { product.ProductName })); } return unknowError; }
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 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 int DeleteProduct(string productIds, bool isDeleteImage) { ManagerHelper.CheckPrivilege(Privilege.DeleteProducts); if (string.IsNullOrEmpty(productIds)) { return 0; } string[] strArray = productIds.Split(new char[] { ',' }); IList<int> list = new List<int>(); foreach (string str in strArray) { list.Add(int.Parse(str)); } IList<ProductInfo> products = new ProductDao().GetProducts(list); int num = new ProductDao().DeleteProduct(productIds); if (num > 0) { EventLogs.WriteOperationLog(Privilege.DeleteProducts, string.Format(CultureInfo.InvariantCulture, "删除了 “{0}” 件商品", new object[] { list.Count })); if (isDeleteImage) { foreach (ProductInfo info in products) { try { DeleteProductImage(info); } catch { } } } } return num; }
public static int UpShelf(string productIds) { ManagerHelper.CheckPrivilege(Privilege.UpShelfProducts); if (string.IsNullOrEmpty(productIds)) { return 0; } int num = new ProductDao().UpdateProductSaleStatus(productIds, ProductSaleStatus.OnSale); if (num > 0) { EventLogs.WriteOperationLog(Privilege.UpShelfProducts, string.Format(CultureInfo.InvariantCulture, "批量上架了 “{0}” 件商品", new object[] { num })); } return num; }
public static bool UpdateProductCategory(int productId, int newCategoryId) { bool flag; if (newCategoryId != 0) { flag = new ProductDao().UpdateProductCategory(productId, newCategoryId, CatalogHelper.GetCategory(newCategoryId).Path + "|"); } else { flag = new ProductDao().UpdateProductCategory(productId, newCategoryId, null); } if (flag) { EventLogs.WriteOperationLog(Privilege.EditProducts, string.Format(CultureInfo.InvariantCulture, "修改编号 “{0}” 的店铺分类为 “{1}”", new object[] { productId, newCategoryId })); } return flag; }
public static int SetFreeShip(string productIds, bool isFree) { if (string.IsNullOrEmpty(productIds)) { return 0; } int num = new ProductDao().UpdateProductShipFree(productIds, isFree); if (num > 0) { EventLogs.WriteOperationLog(Privilege.OffShelfProducts, string.Format(CultureInfo.InvariantCulture, "{0}了“{1}” 件商品包邮", new object[] { isFree ? "设置" : "取消", num })); } return num; }
public static ProductInfo GetProductDetails(int productId, out Dictionary<int, IList<int>> attrs, out IList<int> tagsId) { ProductDao dao = new ProductDao(); attrs = dao.GetProductAttributes(productId); tagsId = dao.GetProductTags(productId); return dao.GetProductDetails(productId); }
public static DataSet GetExportProducts(AdvancedProductQuery query, bool includeCostPrice, bool includeStock, string removeProductIds) { DataSet set = new ProductDao().GetExportProducts(query, includeCostPrice, includeStock, removeProductIds); set.Tables[0].TableName = "types"; set.Tables[1].TableName = "attributes"; set.Tables[2].TableName = "values"; set.Tables[3].TableName = "products"; set.Tables[4].TableName = "skus"; set.Tables[5].TableName = "skuItems"; set.Tables[6].TableName = "productAttributes"; set.Tables[7].TableName = "taobaosku"; return set; }