Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public static bool DeletePaymentMode(int modeId)
        {
            PaymentModeInfo paymentMode = new PaymentModeInfo();

            paymentMode.ModeId = modeId;
            return(SalesProvider.Instance().CreateUpdateDeletePaymentMode(paymentMode, DataProviderAction.Delete) == PaymentModeActionStatus.Success);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
 public static bool CreateShippingMode(ShippingModeInfo shippingMode)
 {
     if (null == shippingMode)
     {
         return(false);
     }
     return(SalesProvider.Instance().CreateShippingMode(shippingMode));
 }
Esempio n. 9
0
 public static DataTable GetProductSalesNoPage(SaleStatisticsQuery productSale, out int totalProductSales)
 {
     if (productSale == null)
     {
         totalProductSales = 0;
         return(null);
     }
     return(SalesProvider.Instance().GetProductSalesNoPage(productSale, out totalProductSales));
 }
Esempio n. 10
0
 public static IList <UserStatisticsInfo> GetUserStatistics(Pagination page, out int totalProductSaleVisits)
 {
     if (page == null)
     {
         totalProductSaleVisits = 0;
         return(null);
     }
     return(SalesProvider.Instance().GetUserStatistics(page, out totalProductSaleVisits));
 }
Esempio n. 11
0
 public static PaymentModeActionStatus UpdatePaymentMode(PaymentModeInfo paymentMode)
 {
     if (null == paymentMode)
     {
         return(PaymentModeActionStatus.UnknowError);
     }
     Globals.EntityCoding(paymentMode, true);
     return(SalesProvider.Instance().CreateUpdateDeletePaymentMode(paymentMode, DataProviderAction.Update));
 }
Esempio n. 12
0
 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));
 }
Esempio n. 13
0
 public static bool UpdateShippMode(ShippingModeInfo shippingMode)
 {
     if (shippingMode == null)
     {
         return(false);
     }
     Globals.EntityCoding(shippingMode, true);
     return(SalesProvider.Instance().UpdateShippingMode(shippingMode));
 }
Esempio n. 14
0
        public static bool RefundOrder(OrderInfo order)
        {
            int   userId;
            IUser user;

            ManagerHelper.CheckPrivilege(Privilege.RefundOrder);
            bool flag = false;

            if (order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
            {
                order.OrderStatus = OrderStatus.Closed;
                flag = SalesProvider.Instance().RefundOrder(order);
                if (flag)
                {
                    userId = order.UserId;
                    if (userId == 0x44c)
                    {
                        userId = 0;
                    }
                    user = Users.GetUser(userId, false);
                    if ((user != null) && (user.UserRole == UserRole.Member))
                    {
                        ReducedPoint(order, user as Member);
                        ReduceDeduct(order, user as Member);
                        Users.ClearUserCache(user);
                    }
                    UpdateUserStatistics(order.UserId, order.RefundAmount, true);
                    SalesProvider.Instance().UpdateRefundOrderStock(order.OrderId);
                    EventLogs.WriteOperationLog(Privilege.RefundOrder, string.Format(CultureInfo.InvariantCulture, "对订单“{0}”成功的进行了全额退款", new object[] { order.OrderId }));
                }
                return(flag);
            }
            if (order.OrderStatus == OrderStatus.SellerAlreadySent)
            {
                order.OrderStatus = OrderStatus.Finished;
                flag = SalesProvider.Instance().RefundOrder(order);
                if (flag)
                {
                    userId = order.UserId;
                    if (userId == 0x44c)
                    {
                        userId = 0;
                    }
                    user = Users.GetUser(userId, false);
                    if ((user != null) && (user.UserRole == UserRole.Member))
                    {
                        ReducedPoint(order, user as Member);
                        ReduceDeduct(order, 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);
            }
            return(false);
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        public static bool DeletePrint(int taskId)
        {
            bool flag = SalesProvider.Instance().DeletePrintTask(taskId, null);

            if (flag)
            {
                SalesProvider.Instance().DeletePrintOrderByTaskId(taskId, null);
            }
            return(flag);
        }
Esempio n. 18
0
        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);
            }
        }
Esempio n. 19
0
        public static int DeleteOrders(string orderIds)
        {
            ManagerHelper.CheckPrivilege(Privilege.DeleteOrder);
            int num = SalesProvider.Instance().DeleteOrders(orderIds);

            if (num > 0)
            {
                EventLogs.WriteOperationLog(Privilege.DeleteOrder, string.Format(CultureInfo.InvariantCulture, "删除了编号为\"{0}\"的订单", new object[] { orderIds }));
            }
            return(num);
        }
Esempio n. 20
0
        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));
        }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
        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.Member))
            {
                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;
                }
                SalesProvider.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.Member))
                    {
                        Member member2 = user2 as Member;
                        if ((member.ParentUserId == member2.ParentUserId) && member2.IsOpenBalance)
                        {
                            decimal           num3          = member2.Balance + ((order.GetTotal() * referralDeduct) / 100M);
                            BalanceDetailInfo balanceDetail = new BalanceDetailInfo();
                            balanceDetail.UserId    = member2.UserId;
                            balanceDetail.UserName  = member2.Username;
                            balanceDetail.TradeDate = DateTime.Now;
                            balanceDetail.TradeType = TradeTypes.ReferralDeduct;
                            balanceDetail.Income    = new decimal?((order.GetTotal() * referralDeduct) / 100M);
                            balanceDetail.Balance   = num3;
                            balanceDetail.Remark    = string.Format("提成来自'{0}'的订单{1}", order.Username, order.OrderId);
                            MemberProvider.Instance().InsertBalanceDetail(balanceDetail);
                        }
                    }
                }
                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);
            }
        }
Esempio n. 23
0
        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?(Convert.ToInt32((decimal)(order.RefundAmount / HiContext.Current.SiteSettings.PointsRate)));
            point.Points    = member.Points - point.Reduced.Value;
            SalesProvider.Instance().AddMemberPoint(point);
        }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        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++;
                }
            }
        }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
        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++;
                }
            }
        }
Esempio n. 29
0
        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++;
                }
            }
        }
Esempio n. 30
0
 public static bool UpdateOrderShippingMode(OrderInfo order)
 {
     ManagerHelper.CheckPrivilege(Privilege.EditOrders);
     if (order.CheckAction(OrderActions.MASTER_SELLER_MODIFY_SHIPPING_MODE))
     {
         bool flag = SalesProvider.Instance().UpdateOrderShippingMode(order);
         if (flag)
         {
             EventLogs.WriteOperationLog(Privilege.EditOrders, string.Format(CultureInfo.InvariantCulture, "修改了订单“{0}”的配送方式", new object[] { order.OrderId }));
         }
         return(flag);
     }
     return(false);
 }