public static bool CreatePurchaseOrder(OrderInfo order) { if (order.CheckAction(OrderActions.SUBSITE_CREATE_PURCHASEORDER)) { using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { SubsiteSalesProvider provider = SubsiteSalesProvider.Instance(); PurchaseOrderInfo purchaseOrder = provider.ConvertOrderToPurchaseOrder(order); if (!provider.CreatePurchaseOrder(purchaseOrder, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); return(true); } catch { dbTran.Rollback(); return(false); } finally { connection.Close(); } } } return(false); }
public static bool DeletePaymentMode(int modeId) { PaymentModeInfo paymentMode = new PaymentModeInfo(); paymentMode.ModeId = modeId; return(SubsiteSalesProvider.Instance().CreateUpdateDeletePaymentMode(paymentMode, DataProviderAction.Delete) == PaymentModeActionStatus.Success); }
public static bool CheckReplace(string orderId, string adminRemark, bool accept) { if (GetOrderInfo(orderId).OrderStatus != OrderStatus.ApplyForReplacement) { return(false); } return(SubsiteSalesProvider.Instance().CheckReplace(orderId, adminRemark, accept)); }
public static DataTable GetProductSalesNoPage(SaleStatisticsQuery productSale, out int totalProductSales) { if (productSale == null) { totalProductSales = 0; return(null); } return(SubsiteSalesProvider.Instance().GetProductSalesNoPage(productSale, out totalProductSales)); }
public static IList <UserStatisticsInfo> GetUserStatistics(Pagination page, out int totalProductSaleVisits) { if (page == null) { totalProductSaleVisits = 0; return(null); } return(SubsiteSalesProvider.Instance().GetUserStatistics(page, out totalProductSaleVisits)); }
public static PaymentModeActionStatus CreatePaymentMode(PaymentModeInfo paymentMode) { if (null == paymentMode) { return(PaymentModeActionStatus.UnknowError); } Globals.EntityCoding(paymentMode, true); return(SubsiteSalesProvider.Instance().CreateUpdateDeletePaymentMode(paymentMode, DataProviderAction.Create)); }
public static bool AddOrderGift(OrderInfo order, GiftInfo gift, int quantity, int promotype) { bool flag; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { if (!SubsiteSalesProvider.Instance().AddOrderGift(order.OrderId, gift, quantity, promotype, dbTran)) { dbTran.Rollback(); return(false); } bool flag2 = false; foreach (OrderGiftInfo info in order.Gifts) { if (info.GiftId == gift.GiftId) { flag2 = true; info.Quantity += quantity; } } if (!flag2) { OrderGiftInfo item = new OrderGiftInfo(); item.GiftId = gift.GiftId; item.OrderId = order.OrderId; item.GiftName = gift.Name; item.Quantity = quantity; item.CostPrice = gift.PurchasePrice; item.ThumbnailsUrl = gift.ThumbnailUrl40; item.PromoteType = promotype; order.Gifts.Add(item); } if (!SubsiteSalesProvider.Instance().UpdateOrderAmount(order, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); flag = true; } catch { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return(flag); }
public static bool AddPurchaseOrderGift(PurchaseOrderInfo purchaseOrder, GiftInfo gift, int quantity) { bool flag; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { if (!SubsiteSalesProvider.Instance().AddPurchaseOrderGift(purchaseOrder.PurchaseOrderId, gift, quantity, dbTran)) { dbTran.Rollback(); return(false); } bool flag2 = false; foreach (PurchaseOrderGiftInfo info in purchaseOrder.PurchaseOrderGifts) { if (info.GiftId == gift.GiftId) { flag2 = true; info.Quantity += quantity; } } if (!flag2) { PurchaseOrderGiftInfo item = new PurchaseOrderGiftInfo(); item.GiftId = gift.GiftId; item.PurchaseOrderId = purchaseOrder.PurchaseOrderId; item.GiftName = gift.Name; item.Quantity = quantity; item.PurchasePrice = gift.PurchasePrice; item.ThumbnailsUrl = gift.ThumbnailUrl40; purchaseOrder.PurchaseOrderGifts.Add(item); } if (!SubsiteSalesProvider.Instance().ResetPurchaseTotal(purchaseOrder, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); flag = true; } catch { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return(flag); }
public static bool AddPurchaseOrderItem(PurchaseShoppingCartItemInfo item, string POrderId) { SubsiteSalesProvider provider = SubsiteSalesProvider.Instance(); int currentPOrderItemQuantity = provider.GetCurrentPOrderItemQuantity(POrderId, item.SkuId); if (currentPOrderItemQuantity == 0) { return(provider.AddPurchaseOrderItem(item, POrderId)); } return(provider.UpdatePurchaseOrderQuantity(POrderId, item.SkuId, item.Quantity + currentPOrderItemQuantity)); }
public static bool SendGoods(OrderInfo order) { bool flag = false; if (order.CheckAction(OrderActions.SELLER_SEND_GOODS)) { order.OrderStatus = OrderStatus.SellerAlreadySent; flag = SubsiteSalesProvider.Instance().SendGoods(order) > 0; } return(flag); }
public static bool SetMyShipper(ShippersInfo shipper) { ShippersInfo myShipper = SubsiteSalesProvider.Instance().GetMyShipper(); Globals.EntityCoding(shipper, true); if (myShipper == null) { return(SubsiteSalesProvider.Instance().AddShipper(shipper)); } return(SubsiteSalesProvider.Instance().UpdateShipper(shipper)); }
static void UpdateUserAccount(OrderInfo order) { int userId = order.UserId; if (userId == 0x44c) { userId = 0; } IUser user = Users.GetUser(userId, false); if ((user != null) && (user.UserRole == UserRole.Underling)) { Member member = user as Member; UserPointInfo point = new UserPointInfo(); point.OrderId = order.OrderId; point.UserId = member.UserId; point.TradeDate = DateTime.Now; point.TradeType = UserPointTradeType.Bounty; point.Increased = new int?(order.GetTotalPoints()); point.Points = order.GetTotalPoints() + member.Points; if ((point.Points > 0x7fffffff) || (point.Points < 0)) { point.Points = 0x7fffffff; } SubsiteSalesProvider.Instance().AddMemberPoint(point); int referralDeduct = HiContext.Current.SiteSettings.ReferralDeduct; if (((referralDeduct > 0) && member.ReferralUserId.HasValue) && (member.ReferralUserId.Value > 0)) { IUser user2 = Users.GetUser(member.ReferralUserId.Value, false); if ((user2 != null) && (user2.UserRole == UserRole.Underling)) { Member member2 = user2 as Member; if ((member.ParentUserId == member2.ParentUserId) && member2.IsOpenBalance) { decimal num3 = member2.Balance + ((order.GetTotal() * referralDeduct) / 100M); BalanceDetailInfo balanceDetails = new BalanceDetailInfo(); balanceDetails.UserId = member2.UserId; balanceDetails.UserName = member2.Username; balanceDetails.TradeDate = DateTime.Now; balanceDetails.TradeType = TradeTypes.ReferralDeduct; balanceDetails.Income = new decimal?((order.GetTotal() * referralDeduct) / 100M); balanceDetails.Balance = num3; balanceDetails.Remark = string.Format("提成来自'{0}'的订单{1}", order.Username, order.OrderId); UnderlingProvider.Instance().AddUnderlingBalanceDetail(balanceDetails); } } } SubsiteSalesProvider.Instance().UpdateUserAccount(order.GetTotal(), point.Points, order.UserId); int historyPoint = SubsiteSalesProvider.Instance().GetHistoryPoint(member.UserId); SubsiteSalesProvider.Instance().ChangeMemberGrade(member.UserId, member.GradeId, historyPoint); } Users.ClearUserCache(user); }
private static void ReducedPoint(OrderInfo order, Member member) { UserPointInfo point = new UserPointInfo(); point.OrderId = order.OrderId; point.UserId = member.UserId; point.TradeDate = DateTime.Now; point.TradeType = UserPointTradeType.Refund; point.Reduced = new int?(order.Points); point.Points = member.Points - point.Reduced.Value; SubsiteSalesProvider.Instance().AddMemberPoint(point); }
static void ReducedPoint(OrderInfo order, Member member) { UserPointInfo point = new UserPointInfo(); point.OrderId = order.OrderId; point.UserId = member.UserId; point.TradeDate = DateTime.Now; point.TradeType = UserPointTradeType.Refund; SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); point.Reduced = new int?(Convert.ToInt32((decimal)(order.RefundAmount / masterSettings.PointsRate))); point.Points = member.Points - point.Reduced.Value; SubsiteSalesProvider.Instance().AddMemberPoint(point); }
public static bool ConfirmPay(OrderInfo order) { if (order.CheckAction(OrderActions.SELLER_CONFIRM_PAY)) { bool flag; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { SubsiteSalesProvider provider = SubsiteSalesProvider.Instance(); if (provider.ConfirmPay(order, dbTran) <= 0) { dbTran.Rollback(); return(false); } if (order.GroupBuyId <= 0) { PurchaseOrderInfo purchaseOrder = provider.ConvertOrderToPurchaseOrder(order); if (!provider.CreatePurchaseOrder(purchaseOrder, dbTran)) { dbTran.Rollback(); return(false); } } dbTran.Commit(); flag = true; } catch { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } if (flag) { SubsiteSalesProvider.Instance().UpdateProductSaleCounts(order.LineItems); UpdateUserAccount(order); } return(flag); } return(false); }
public static bool ConfirmPay(BalanceDetailInfo balance, PurchaseOrderInfo purchaseOrder) { if (!purchaseOrder.CheckAction(PurchaseOrderActions.DISTRIBUTOR_CONFIRM_PAY)) { return(false); } bool flag = SubsiteSalesProvider.Instance().ConfirmPay(balance, purchaseOrder.PurchaseOrderId); if (flag) { SubsiteSalesProvider.Instance().UpdateProductStock(purchaseOrder.PurchaseOrderId); SubsiteSalesProvider.Instance().UpdateDistributorAccount(purchaseOrder.GetPurchaseTotal()); Users.ClearUserCache(Users.GetUser(purchaseOrder.DistributorId)); } return(flag); }
public static bool DelDebitNote(string[] noteIds, out int count) { bool flag = true; count = 0; foreach (string str in noteIds) { if (!string.IsNullOrEmpty(str)) { flag &= SubsiteSalesProvider.Instance().DelDebitNote(str); if (flag) { count++; } } } return(flag); }
public static bool DeletePurchaseOrderGift(PurchaseOrderInfo purchaseOrder, int giftId) { bool flag; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { if (!SubsiteSalesProvider.Instance().DeletePurchaseOrderGift(purchaseOrder.PurchaseOrderId, giftId, dbTran)) { dbTran.Rollback(); return(false); } foreach (PurchaseOrderGiftInfo info in purchaseOrder.PurchaseOrderGifts) { if (info.GiftId == giftId) { purchaseOrder.PurchaseOrderGifts.Remove(info); break; } } if (!SubsiteSalesProvider.Instance().ResetPurchaseTotal(purchaseOrder, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); flag = true; } catch { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return(flag); }
public static bool RefundOrder(OrderInfo order) { IUser user; bool flag = false; if (order.OrderStatus == OrderStatus.BuyerAlreadyPaid) { order.OrderStatus = OrderStatus.Closed; flag = SubsiteSalesProvider.Instance().RefundOrder(order); if (flag) { user = Users.GetUser(order.UserId, false); if ((user != null) && (user.UserRole == UserRole.Underling)) { ReducedPoint(order, user as Member); ReduceDeduct(order, user as Member); Users.ClearUserCache(user); } UpdateUserStatistics(order.UserId, order.RefundAmount, true); SubsiteSalesProvider.Instance().UpdateRefundOrderStock(order.OrderId); } return(flag); } if (order.OrderStatus == OrderStatus.SellerAlreadySent) { order.OrderStatus = OrderStatus.Finished; flag = SubsiteSalesProvider.Instance().RefundOrder(order); if (flag) { user = Users.GetUser(order.UserId, false); if ((user != null) && (user.UserRole == UserRole.Underling)) { ReducedPoint(order, user as Member); ReduceDeduct(order, user as Member); Users.ClearUserCache(user); } UpdateUserStatistics(order.UserId, order.RefundAmount, false); } return(flag); } return(false); }
public static bool DelReturnsApply(string[] returnsIds, out int count) { bool flag = true; count = 0; foreach (string str in returnsIds) { if (!string.IsNullOrEmpty(str)) { if (SubsiteSalesProvider.Instance().DelReturnsApply(int.Parse(str))) { count++; } else { flag = false; } } } return(flag); }
public static bool CheckRefund(OrderInfo order, string adminRemark, int refundType, bool accept) { if (order.OrderStatus != OrderStatus.ApplyForRefund) { return(false); } bool flag = SubsiteSalesProvider.Instance().CheckRefund(order.OrderId, adminRemark, refundType, accept); if (flag && accept) { IUser user = Users.GetUser(order.UserId, false); if ((user != null) && (user.UserRole == UserRole.Underling)) { ReducedPoint(order, user as Member); ReduceDeduct(order.OrderId, order.GetTotal(), user as Member); Users.ClearUserCache(user); } UpdateUserStatistics(order.UserId, order.RefundAmount, true); } return(flag); }
public static bool UpdateLineItem(string sku, OrderInfo order, int quantity) { bool flag; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { SubsiteSalesProvider provider = SubsiteSalesProvider.Instance(); order.LineItems[sku].ShipmentQuantity = quantity; order.LineItems[sku].Quantity = quantity; order.LineItems[sku].ItemAdjustedPrice = order.LineItems[sku].ItemListPrice; if (!provider.UpdateLineItem(order.OrderId, order.LineItems[sku], dbTran)) { dbTran.Rollback(); return(false); } if (!provider.UpdateOrderAmount(order, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); flag = true; } catch (Exception) { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return(flag); }
public static bool ClearPurchaseOrderGifts(PurchaseOrderInfo purchaseOrder) { bool flag; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { if (!SubsiteSalesProvider.Instance().ClearPurchaseOrderGifts(purchaseOrder.PurchaseOrderId, dbTran)) { dbTran.Rollback(); return(false); } purchaseOrder.PurchaseOrderGifts.Clear(); if (!SubsiteSalesProvider.Instance().ResetPurchaseTotal(purchaseOrder, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); flag = true; } catch { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return(flag); }
public static bool DeleteOrderProduct(string sku, OrderInfo order) { bool flag; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { if (!SubsiteSalesProvider.Instance().DeleteOrderProduct(sku, order.OrderId, dbTran)) { dbTran.Rollback(); return(false); } order.LineItems.Remove(sku); if (!SubsiteSalesProvider.Instance().UpdateOrderAmount(order, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); flag = true; } catch { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return(flag); }
public static bool UpdateLineItem(string sku, OrderInfo order, int quantity) { bool flag; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { SubsiteSalesProvider provider = SubsiteSalesProvider.Instance(); int userId = order.UserId; if (userId == 0x44c) { userId = 0; } Member user = Users.GetUser(userId) as Member; if (user != null) { int num; string str; int num2; int num3; string str2; decimal?nullable; int gradeId = user.GradeId; provider.GetLineItemPromotions(order.LineItems[sku].ProductId, quantity, out num, out str, out num2, out num3, out str2, out nullable, gradeId); order.LineItems[sku].PurchaseGiftId = num; order.LineItems[sku].PurchaseGiftName = str; order.LineItems[sku].ShipmentQuantity = quantity + num2; order.LineItems[sku].WholesaleDiscountId = num3; order.LineItems[sku].WholesaleDiscountName = str2; order.LineItems[sku].Quantity = quantity; if (nullable.HasValue) { decimal itemListPrice = order.LineItems[sku].ItemListPrice; order.LineItems[sku].ItemAdjustedPrice = Convert.ToDecimal((itemListPrice * nullable) / 100M); } else { order.LineItems[sku].ItemAdjustedPrice = order.LineItems[sku].ItemListPrice; } } else { order.LineItems[sku].ShipmentQuantity = quantity; order.LineItems[sku].Quantity = quantity; order.LineItems[sku].ItemAdjustedPrice = order.LineItems[sku].ItemListPrice; } if (!provider.UpdateLineItem(order.OrderId, order.LineItems[sku], dbTran)) { dbTran.Rollback(); return(false); } if (!provider.UpdateOrderAmount(order, dbTran)) { dbTran.Rollback(); return(false); } dbTran.Commit(); flag = true; } catch (Exception) { dbTran.Rollback(); flag = false; } finally { connection.Close(); } } return(flag); }
public static void SwapPaymentModeSequence(int modeId, int replaceModeId, int displaySequence, int replaceDisplaySequence) { SubsiteSalesProvider.Instance().SwapPaymentModeSequence(modeId, replaceModeId, displaySequence, replaceDisplaySequence); }
public static bool SaveRemark(OrderInfo order) { return(SubsiteSalesProvider.Instance().SaveRemark(order)); }
public static bool SavePurchaseOrderRemark(string purchaseOrderId, string remark) { return(SubsiteSalesProvider.Instance().SavePurchaseOrderRemark(purchaseOrderId, remark)); }
public static bool ResetPurchaseTotal(PurchaseOrderInfo purchaseOrder) { return(SubsiteSalesProvider.Instance().ResetPurchaseTotal(purchaseOrder, null)); }
public static bool MondifyAddress(OrderInfo order) { return(order.CheckAction(OrderActions.SUBSITE_SELLER_MODIFY_DELIVER_ADDRESS) && SubsiteSalesProvider.Instance().SaveShippingAddress(order)); }