コード例 #1
0
 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);
 }
コード例 #2
0
        public static bool DeletePaymentMode(int modeId)
        {
            PaymentModeInfo paymentMode = new PaymentModeInfo();

            paymentMode.ModeId = modeId;
            return(SubsiteSalesProvider.Instance().CreateUpdateDeletePaymentMode(paymentMode, DataProviderAction.Delete) == PaymentModeActionStatus.Success);
        }
コード例 #3
0
 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));
 }
コード例 #4
0
 public static DataTable GetProductSalesNoPage(SaleStatisticsQuery productSale, out int totalProductSales)
 {
     if (productSale == null)
     {
         totalProductSales = 0;
         return(null);
     }
     return(SubsiteSalesProvider.Instance().GetProductSalesNoPage(productSale, out totalProductSales));
 }
コード例 #5
0
 public static IList <UserStatisticsInfo> GetUserStatistics(Pagination page, out int totalProductSaleVisits)
 {
     if (page == null)
     {
         totalProductSaleVisits = 0;
         return(null);
     }
     return(SubsiteSalesProvider.Instance().GetUserStatistics(page, out totalProductSaleVisits));
 }
コード例 #6
0
 public static PaymentModeActionStatus CreatePaymentMode(PaymentModeInfo paymentMode)
 {
     if (null == paymentMode)
     {
         return(PaymentModeActionStatus.UnknowError);
     }
     Globals.EntityCoding(paymentMode, true);
     return(SubsiteSalesProvider.Instance().CreateUpdateDeletePaymentMode(paymentMode, DataProviderAction.Create));
 }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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));
        }
コード例 #12
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.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);
        }
コード例 #13
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;
            SubsiteSalesProvider.Instance().AddMemberPoint(point);
        }
コード例 #14
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;
            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);
        }
コード例 #15
0
 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);
 }
コード例 #16
0
        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);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        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);
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        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);
        }
コード例 #23
0
        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);
        }
コード例 #24
0
        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);
        }
コード例 #25
0
        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);
        }
コード例 #26
0
 public static void SwapPaymentModeSequence(int modeId, int replaceModeId, int displaySequence, int replaceDisplaySequence)
 {
     SubsiteSalesProvider.Instance().SwapPaymentModeSequence(modeId, replaceModeId, displaySequence, replaceDisplaySequence);
 }
コード例 #27
0
 public static bool SaveRemark(OrderInfo order)
 {
     return(SubsiteSalesProvider.Instance().SaveRemark(order));
 }
コード例 #28
0
 public static bool SavePurchaseOrderRemark(string purchaseOrderId, string remark)
 {
     return(SubsiteSalesProvider.Instance().SavePurchaseOrderRemark(purchaseOrderId, remark));
 }
コード例 #29
0
 public static bool ResetPurchaseTotal(PurchaseOrderInfo purchaseOrder)
 {
     return(SubsiteSalesProvider.Instance().ResetPurchaseTotal(purchaseOrder, null));
 }
コード例 #30
0
 public static bool MondifyAddress(OrderInfo order)
 {
     return(order.CheckAction(OrderActions.SUBSITE_SELLER_MODIFY_DELIVER_ADDRESS) && SubsiteSalesProvider.Instance().SaveShippingAddress(order));
 }