public static int CreatePrintTask(string creator, DateTime createTime, bool isPO, string[] orderList) { int taskId = 0; using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection()) { IUser user = HiContext.Current.User; connection.Open(); DbTransaction dbTran = connection.BeginTransaction(); try { taskId = SalesProvider.Instance().CreatePrintTask(creator, createTime, isPO, dbTran); if (taskId <= 0) { dbTran.Rollback(); return(0); } if (!SalesProvider.Instance().CreatePrintOrders(taskId, orderList, dbTran)) { dbTran.Rollback(); return(0); } dbTran.Commit(); } catch { dbTran.Rollback(); connection.Close(); taskId = 0; } } return(taskId); }
public static bool SendPurchaseOrderGoods(PurchaseOrderInfo purchaseOrder) { Globals.EntityCoding(purchaseOrder, true); ManagerHelper.CheckPrivilege(Privilege.PurchaseorderSendGood); bool result; if (purchaseOrder.CheckAction(PurchaseOrderActions.MASTER_SEND_GOODS)) { bool flag; if (flag = SalesProvider.Instance().SendPurchaseOrderGoods(purchaseOrder)) { if (purchaseOrder.Gateway == "hishop.plugins.payment.podrequest") { SalesProvider.Instance().UpdateProductStock(purchaseOrder.PurchaseOrderId); SalesProvider.Instance().UpdateDistributorAccount(purchaseOrder.GetPurchaseTotal(), purchaseOrder.DistributorId); Users.ClearUserCache(Users.GetUser(purchaseOrder.DistributorId)); } EventLogs.WriteOperationLog(Privilege.PurchaseorderSendGood, string.Format(CultureInfo.InvariantCulture, "对编号为\"{0}\"的采购单发货", new object[] { purchaseOrder.PurchaseOrderId })); } result = flag; } else { result = false; } return(result); }
public static bool CheckReturn(OrderInfo order, string Operator, decimal refundMoney, string adminRemark, int refundType, bool accept) { ManagerHelper.CheckPrivilege(Privilege.OrderReturnsApply); if (order.OrderStatus != OrderStatus.ApplyForReturns) { return(false); } bool flag = SalesProvider.Instance().CheckReturn(order.OrderId, Operator, refundMoney, adminRemark, refundType, accept); if (flag) { if (accept) { order.RefundAmount = refundMoney; IUser user = Users.GetUser(order.UserId, false); if ((user != null) && (user.UserRole == UserRole.Member)) { ReducedPoint(order, user as Member); ReduceDeduct(order.OrderId, order.RefundAmount, user as Member); Users.ClearUserCache(user); } UpdateUserStatistics(order.UserId, order.RefundAmount, false); } EventLogs.WriteOperationLog(Privilege.RefundOrder, string.Format(CultureInfo.InvariantCulture, "对订单“{0}”成功的进行了退货", new object[] { order.OrderId })); } return(flag); }
public static bool CheckPurchaseRefund(PurchaseOrderInfo purchaseOrder, string Operator, string adminRemark, int refundType, bool accept) { ManagerHelper.CheckPrivilege(Privilege.PurchaseOrderRefundApply); bool result; if (purchaseOrder.PurchaseStatus != OrderStatus.ApplyForRefund) { result = false; } else { bool flag; if (flag = SalesProvider.Instance().CheckPurchaseRefund(purchaseOrder.PurchaseOrderId, Operator, adminRemark, refundType, accept)) { if (accept) { SalesProvider.Instance().UpdateRefundSubmitPurchaseOrderStock(purchaseOrder); } EventLogs.WriteOperationLog(Privilege.PurchaseorderRefund, string.Format(CultureInfo.InvariantCulture, "对编号为\"{0}\"的采购单退款", new object[] { purchaseOrder.PurchaseOrderId })); } result = flag; } return(result); }
public static bool CheckReplace(string orderId, string adminRemark, bool accept) { ManagerHelper.CheckPrivilege(Privilege.OrderReplaceApply); OrderInfo orderInfo = OrderHelper.GetOrderInfo(orderId); return(orderInfo.OrderStatus == OrderStatus.ApplyForReplacement && SalesProvider.Instance().CheckReplace(orderId, adminRemark, accept)); }
public static bool DeletePaymentMode(int modeId) { PaymentModeInfo paymentMode = new PaymentModeInfo(); paymentMode.ModeId = modeId; return(SalesProvider.Instance().CreateUpdateDeletePaymentMode(paymentMode, DataProviderAction.Delete) == PaymentModeActionStatus.Success); }
public static bool CheckRefund(OrderInfo order, string Operator, string adminRemark, int refundType, bool accept) { ManagerHelper.CheckPrivilege(Privilege.OrderRefundApply); if (order.OrderStatus != OrderStatus.ApplyForRefund) { return(false); } bool flag = SalesProvider.Instance().CheckRefund(order.OrderId, Operator, adminRemark, refundType, accept); if (flag) { if (accept) { IUser user = Users.GetUser(order.UserId, false); if ((user != null) && (user.UserRole == UserRole.Member)) { ReducedPoint(order, user as Member); ReduceDeduct(order.OrderId, order.GetTotal(), user as Member); Users.ClearUserCache(user); } UpdateUserStatistics(order.UserId, order.RefundAmount, true); SalesProvider.Instance().UpdateRefundOrderStock(order.OrderId); } if (accept && (order.GroupBuyId > 0)) { EventLogs.WriteOperationLog(Privilege.RefundOrder, string.Format(CultureInfo.InvariantCulture, "对订单“{0}”成功的扣除违约金后退款", new object[] { order.OrderId })); } else { EventLogs.WriteOperationLog(Privilege.RefundOrder, string.Format(CultureInfo.InvariantCulture, "对订单“{0}”成功的进行了全额退款", new object[] { order.OrderId })); } } return(flag); }
public static bool CreateShippingMode(ShippingModeInfo shippingMode) { if (null == shippingMode) { return(false); } return(SalesProvider.Instance().CreateShippingMode(shippingMode)); }
public static DataTable GetProductSalesNoPage(SaleStatisticsQuery productSale, out int totalProductSales) { if (productSale == null) { totalProductSales = 0; return(null); } return(SalesProvider.Instance().GetProductSalesNoPage(productSale, out totalProductSales)); }
public static bool CheckReplace(string orderId, string adminRemark, bool accept) { ManagerHelper.CheckPrivilege(Privilege.OrderReplaceApply); if (GetOrderInfo(orderId).OrderStatus != OrderStatus.ApplyForReplacement) { return(false); } return(SalesProvider.Instance().CheckReplace(orderId, adminRemark, accept)); }
public static IList <UserStatisticsInfo> GetUserStatistics(Pagination page, out int totalProductSaleVisits) { if (page == null) { totalProductSaleVisits = 0; return(null); } return(SalesProvider.Instance().GetUserStatistics(page, out totalProductSaleVisits)); }
public static bool SaveRemarkAPI(OrderInfo order) { bool flag = SalesProvider.Instance().SaveOrderRemark(order); if (flag) { EventLogs.WriteOperationLog(Privilege.RemarkOrder, string.Format(CultureInfo.InvariantCulture, "对订单“{0}”进行了备注", new object[] { order.OrderId })); } return(flag); }
public static bool DeletePrint(int taskId) { bool flag = SalesProvider.Instance().DeletePrintTask(taskId, null); if (flag) { SalesProvider.Instance().DeletePrintOrderByTaskId(taskId, null); } return(flag); }
public static bool SaveAPIPurchaseOrderRemark(PurchaseOrderInfo purchaseOrder) { bool flag = SalesProvider.Instance().SavePurchaseOrderRemark(purchaseOrder); if (flag) { EventLogs.WriteOperationLog(Privilege.PurchaseorderMark, string.Format(CultureInfo.InvariantCulture, "对编号为\"{0}\"的采购单备注", new object[] { purchaseOrder.PurchaseOrderId })); } return(flag); }
private static void UpdateUserAccount(OrderInfo order) { int num = order.UserId; if (num == 1100) { num = 0; } IUser user = Users.GetUser(num, false); if (user != null && user.UserRole == UserRole.Member) { Member member = user as Member; UserPointInfo userPointInfo = new UserPointInfo(); userPointInfo.OrderId = order.OrderId; userPointInfo.UserId = member.UserId; userPointInfo.TradeDate = DateTime.Now; userPointInfo.TradeType = UserPointTradeType.Bounty; userPointInfo.Increased = new int?(order.Points); userPointInfo.Points = order.Points + member.Points; int arg_A2_0 = userPointInfo.Points; if (userPointInfo.Points < 0) { userPointInfo.Points = 2147483647; } SalesProvider.Instance().AddMemberPoint(userPointInfo); 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.Member) { Member member2 = user2 as Member; if (member.ParentUserId == member2.ParentUserId && member2.IsOpenBalance) { decimal balance = member2.Balance + order.GetTotal() * referralDeduct / 100m; BalanceDetailInfo balanceDetailInfo = new BalanceDetailInfo(); balanceDetailInfo.UserId = member2.UserId; balanceDetailInfo.UserName = member2.Username; balanceDetailInfo.TradeDate = DateTime.Now; balanceDetailInfo.TradeType = TradeTypes.ReferralDeduct; balanceDetailInfo.Income = new decimal?(order.GetTotal() * referralDeduct / 100m); balanceDetailInfo.Balance = balance; balanceDetailInfo.Remark = string.Format("提成来自{0}的订单{1}", order.Username, order.OrderId); MemberProvider.Instance().InsertBalanceDetail(balanceDetailInfo); } } } SalesProvider.Instance().UpdateUserAccount(order.GetTotal(), order.UserId); int historyPoint = SalesProvider.Instance().GetHistoryPoint(member.UserId); SalesProvider.Instance().ChangeMemberGrade(member.UserId, member.GradeId, historyPoint); Users.ClearUserCache(user); } }
public static bool AddPurchaseOrderItem(PurchaseShoppingCartItemInfo item, string POrderId) { SalesProvider provider = SalesProvider.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 ClosePurchaseOrder(PurchaseOrderInfo purchaseOrder) { ManagerHelper.CheckPrivilege(Privilege.EditPurchaseorder); bool flag = SalesProvider.Instance().ClosePurchaseOrder(purchaseOrder); if (flag) { EventLogs.WriteOperationLog(Privilege.EditPurchaseorder, string.Format(CultureInfo.InvariantCulture, "关闭了编号为\"{0}\"的采购单", new object[] { purchaseOrder.PurchaseOrderId })); } return(flag); }
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; SalesProvider.Instance().AddMemberPoint(point); }
private static void ReducedPoint(OrderInfo order, Member member) { UserPointInfo userPointInfo = new UserPointInfo(); userPointInfo.OrderId = order.OrderId; userPointInfo.UserId = member.UserId; userPointInfo.TradeDate = DateTime.Now; userPointInfo.TradeType = UserPointTradeType.Refund; userPointInfo.Reduced = new int?(order.Points); userPointInfo.Points = member.Points - userPointInfo.Reduced.Value; SalesProvider.Instance().AddMemberPoint(userPointInfo); }
public static void SetOrderPrinted(string[] orderIds, bool isPrinted) { int num = 0; for (int i = orderIds.Length - 1; i >= 0; i--) { if (SalesProvider.Instance().SetOrderPrinted(orderIds[i], isPrinted)) { num++; } } }
public static bool UpdateLineItem(string string_0, OrderInfo order, int quantity) { ManagerHelper.CheckPrivilege(Privilege.EditOrders); Database database = DatabaseFactory.CreateDatabase(); bool result; bool flag; using (System.Data.Common.DbConnection dbConnection = database.CreateConnection()) { dbConnection.Open(); System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction(); try { SalesProvider salesProvider = SalesProvider.Instance(); order.LineItems[string_0].Quantity = quantity; order.LineItems[string_0].ShipmentQuantity = quantity; order.LineItems[string_0].ItemAdjustedPrice = order.LineItems[string_0].ItemListPrice; if (!salesProvider.UpdateLineItem(order.OrderId, order.LineItems[string_0], dbTransaction)) { dbTransaction.Rollback(); result = false; return(result); } if (!salesProvider.UpdateOrderAmount(order, dbTransaction)) { dbTransaction.Rollback(); result = false; return(result); } dbTransaction.Commit(); flag = true; } catch (Exception) { dbTransaction.Rollback(); flag = false; } finally { dbConnection.Close(); } } if (flag) { EventLogs.WriteOperationLog(Privilege.EditOrders, string.Format(CultureInfo.InvariantCulture, "修改了订单号为\"{0}\"的订单商品数量", new object[] { order.OrderId })); } result = flag; return(result); }
public static void SetPurchaseOrderShipNumber(string[] orderIds, string startNumber) { int num = 0; for (int i = orderIds.Length - 1; i >= 0; i--) { long num3 = long.Parse(startNumber) + num; if (SalesProvider.Instance().SetPurchaseOrderShipNumber(orderIds[i], num3.ToString())) { num++; } } }
public static void SetOrderShipNumber(string[] orderIds, string startNumber) { int num = 0; for (int i = 0; i < orderIds.Length; i++) { long num3 = long.Parse(startNumber) + num; if (SalesProvider.Instance().EditOrderShipNumber(orderIds[i], num3.ToString())) { num++; } } }