예제 #1
0
파일: AppLib.cs 프로젝트: AlCher2018/KDS
        }  // method

        // узнать, в каком состоянии находятся ВСЕ БЛЮДА заказа
        public static OrderStatusEnum GetStatusAllDishes(List <OrderDishViewModel> dishes)
        {
            OrderStatusEnum retVal = OrderStatusEnum.None;

            if ((dishes == null) || (dishes.Count == 0))
            {
                return(retVal);
            }

            int iLen      = Enum.GetValues(typeof(OrderStatusEnum)).Length;
            int dishCount = dishes.Count;

            int[] statArray = new int[iLen];

            int iStatus;

            foreach (OrderDishViewModel modelDish in dishes)
            {
                iStatus = modelDish.DishStatusId;
                statArray[iStatus]++;
            }

            for (int i = 0; i < iLen; i++)
            {
                if (statArray[i] == dishCount)
                {
                    retVal = (OrderStatusEnum)i; break;
                }
            }

            return(retVal);
        }
예제 #2
0
 public Order()
 {
     Id          = Guid.NewGuid().ToString();
     CreatedAt   = DateTime.Now;
     UpdatedAt   = DateTime.Now;
     OrderStatus = OrderStatusEnum.Pending;
 }
예제 #3
0
        // для ингредиента попытаться обновить статус блюда по всем ингредиентам
        private void updateDishStatusByIngrStatuses()
        {
            OrderDishModel parentDish = getParentDish();

            if (parentDish != null)
            {
                List <OrderDishModel> ingrs = getIngredients();

                int   iLen      = Enum.GetValues(typeof(OrderStatusEnum)).Length;
                int[] statArray = new int[iLen];

                int iStatus, iDishesCount = ingrs.Count;
                foreach (OrderDishModel modelDish in ingrs)
                {
                    iStatus = modelDish.DishStatusId;
                    statArray[iStatus]++;
                }

                // в состояние 0 заказ автоматом переходить не должен
                for (int i = 1; i < iLen; i++)
                {
                    if (statArray[i] == iDishesCount)
                    {
                        OrderStatusEnum statDishes = AppLib.GetStatusEnumFromNullableInt(i);
                        if (parentDish.Status != statDishes)
                        {
                            parentDish.UpdateStatus(statDishes);
                        }
                        break;
                    }
                }
            }
        }
예제 #4
0
        public static OrdStatus?convert(OrderStatusEnum ordStatus, Order order)
        {
            switch (ordStatus)
            {
            case OrderStatusEnum.osCanceled:
                return(OrdStatus.Canceled);

            case OrderStatusEnum.osNew:
                return(OrdStatus.New);

            case OrderStatusEnum.osReplaced:
                return(OrdStatus.Replaced);

            case OrderStatusEnum.osRejected:
                if (order.ordStatus == OrdStatus.PendingNew)
                {
                    return(OrdStatus.Rejected);
                }

                return(order.ordStatus);

            case OrderStatusEnum.osPartiallyFilled:
                if (PriceUtils.EqualGreaterThan(order.cumQty, order.quantity))
                {
                    return(OrdStatus.Filled);
                }
                else
                {
                    return(OrdStatus.PartiallyFilled);
                }
            }

            return(null);
        }
예제 #5
0
        private void saveReturnTimeRecord(OrderStatusEnum statusFrom, OrderStatusEnum statusTo, DateTime dtEnterToNewStatus, int secondsInPrevState)
        {
            string sLogMsg = " - updating sql-table OrderDishReturnTime..";

            AppLib.WriteLogTraceMessage(sLogMsg);

            string sqlText = string.Format("INSERT INTO [OrderDishReturnTime] ([OrderDishId], [ReturnDate], [StatusFrom], [StatusFromTimeSpan], [StatusTo]) VALUES ({0}, {1}, {2}, {3}, {4})",
                                           this.Id.ToString(), dtEnterToNewStatus.ToSQLExpr(), ((int)statusFrom).ToString(), secondsInPrevState.ToString(), ((int)statusTo).ToString());

            int result = 0; string dbError = null;

            using (DBContext db = new DBContext())
            {
                result  = db.ExecuteCommand(sqlText);
                dbError = db.ErrMsg;
            }

            if (result == 1)
            {
                sLogMsg += " - Ok";
            }
            else if (dbError != null)
            {
                sLogMsg += " - error: " + dbError;
                _serviceErrorMessage = string.Format("Ошибка записи в БД: {0}", dbError);
            }
            AppLib.WriteLogTraceMessage(sLogMsg);
        }
        public void updateOrder(long key, OrderStatusEnum status)
        {
            Order order = GetOrder(key);

            order.Status = status;
            updateOrder(order);
        }
예제 #7
0
        public static string GetEnumValue(this OrderStatusEnum statusEnum)
        {
            switch (statusEnum)
            {
            case OrderStatusEnum.PendingPayment:
                return("Pending Payment");

            case OrderStatusEnum.Processing:
                return("Processing");

            case OrderStatusEnum.Shipped:
                return("Shipped");

            case OrderStatusEnum.Delivered:
                return("Delivered");

            case OrderStatusEnum.Canceled:
                return("Canceled");

            case OrderStatusEnum.Returned:
                return("Returned");

            default:
                throw new ArgumentException("Invalid status found");
            }
        }
예제 #8
0
파일: App.xaml.cs 프로젝트: AlCher2018/KDS
        }         // method

        private static bool getFinReadyValue(OrderStatusEnum state)
        {
            bool confReady = WpfHelper.GetAppGlobalBool("UseReadyConfirmedState");

            return((confReady && (state == OrderStatusEnum.ReadyConfirmed)) ||
                   (!confReady && (state == OrderStatusEnum.Ready)));
        }
예제 #9
0
        public bool SetNewDishStatus(int orderId, int dishId, OrderStatusEnum newStatus)
        {
            if (_setClient == null)
            {
                return(false);
            }

            AppLib.WriteLogClientAction("Установить статус БЛЮДА, состояние службы: {0}", _getClient.State);
            bool retVal = false;

            try
            {
                checkSvcState();
                DateTime dtTmr = DateTime.Now;
                AppLib.WriteLogClientAction(" - svc.ChangeOrderDishStatus({0}, {1}, {2}) - START", orderId, dishId, newStatus);

                retVal = _setClient.ChangeOrderDishStatus(_machineName, orderId, dishId, (int)newStatus);

                AppLib.WriteLogClientAction(" - svc.ChangeOrderDishStatus({0}, {1}, {2}) - FINISH - {3}", orderId, dishId, newStatus, (DateTime.Now - dtTmr).ToString());
                retVal = true;
            }
            catch (Exception)
            {
                throw;
            }

            return(retVal);
        }
예제 #10
0
        public async Task <FunctionResult> ChangeOrderStatus(int orderId, OrderStatusEnum status, string adminRemark)
        {
            Order order = await(from p in context.Orders
                                where p.OrderId == orderId
                                select p).FirstOrDefaultAsync();

            if (order == null)
            {
                return(new FunctionResult("订单不存在"));
            }

            // 订单状态是否能被修改
            if (order.OrderStatus >= status)
            {
                return(new FunctionResult("无法改变订单状态"));
            }

            // 增加统计数
            if ((order.OrderStatus == OrderStatusEnum.Confirming || order.OrderStatus == OrderStatusEnum.OnGoing) && status != OrderStatusEnum.OnGoing)
            {
                await ConfigManager.ReduceOrderActiveCount(order.OrderType == OrderTypeEnum.Get);
            }

            order.OrderStatus = status;
            if (adminRemark != null)
            {
                order.AdminRemark = adminRemark;
            }
            await context.SaveChangesAsync();

            return(new FunctionResult());
        }
예제 #11
0
        async Task <bool> __return_success__(string out_trade_no)
        {
            out_trade_no.Should().NotBeNullOrEmpty();

            var order = await this.orderService.GetOrderByNo(out_trade_no);

            if (order != null)
            {
                var status = new OrderStatusEnum[]
                {
                    OrderStatusEnum.待付款
                }.Select(x => (int)x).ToArray();

                //还是待付款就提示失败,让微信再次回调
                if (status.Contains(order.Status))
                {
                    return(false);
                }
            }
            else
            {
                this._logger.AddErrorLog($"回调订单号不存在:{out_trade_no}");
            }
            return(true);
        }
예제 #12
0
        /// <summary>
        /// The update complete status
        /// Author: ThanhDT
        /// Created date: 8/11/2020 2:53 PM
        /// </summary>
        /// <param name="orderId">The order identifier.</param>
        /// <param name="changeStatus">The change status.</param>
        /// <param name="deliveryStatus">The delivery status.</param>
        /// <param name="reasonNote">The reason note.</param>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        public ErrorCodes UpdateCompleteStatus(int orderId, OrderStatusEnum changeStatus, DeliveryStatus deliveryStatus, string reasonNote = "", string user = "")
        {
            Entities.Order order;
            try
            {
                order = _orderDal.GetById(orderId);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(ErrorCodes.Exception);
            }
            if (order == null || order.order_id == 0)
            {
                return(ErrorCodes.UnknowError);
            }

            //var currentStatus = (OrderStatusEnum)order.status;
            // Bắt buộc trạng thái trước đó phải là Delivering

            /*if (currentStatus != OrderStatusEnum.Delivering || !ValidateChangeStatus(currentStatus, changeStatus))
             * {
             *  return ErrorCodes.StatusError;
             * }*/

            var changeStatusShort = (short)changeStatus;
            int result;

            try
            {
                result = _orderDal.UpdateCompleteStatus(orderId, changeStatusShort, (short)deliveryStatus, user, reasonNote: order.reason_note);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(ErrorCodes.Exception);
            }

            ErrorCodes errorCodes;

            if (result <= 0)
            {
                errorCodes = ErrorCodes.BusinessError;
            }
            else
            {
                _orderHistoryBo.Insert(new OrderHistory
                {
                    change_log = reasonNote,
                    created_by = user,
                    order_id   = orderId,
                    status     = changeStatusShort
                });

                errorCodes = ErrorCodes.Success;
            }

            return(errorCodes);
        }
예제 #13
0
 private bool BasicCheck(IOrderStatusChangedMessage m, OrderStatusEnum status)
 {
     return (
                m.PartnerId == partnerId &&
                m.PurchaseOrderNumber == purchaseOrderNumber &&
                m.Status == status
            );
 }
예제 #14
0
        public static Order ChangeOrderStatus(Guid orderId, OrderStatusEnum newStatus, IPrincipal user)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            Order orderDetails      = ChangeOrderStatus(db, orderId, newStatus, user);

            db.Dispose();
            return(orderDetails);
        }
예제 #15
0
 private bool BasicCheck(IOrderStatusChangedMessage m, OrderStatusEnum status)
 {
     return(
         m.PartnerId == partnerId &&
         m.PurchaseOrderNumber == purchaseOrderNumber &&
         m.Status == status
         );
 }
예제 #16
0
        private async Task CancelAndUpdateOrder(Trading activeTrading, OrderStatusEnum statusChangeReason)
        {
            await _tradingApi.CancelOrder(activeTrading.TradingTransactions.Last().ExchangeOperationId, TradingContants.Bids);

            await _strategyDatabaseAccess.UpdateOrderStatus(activeTrading, statusChangeReason);

            await SetBidOrder(activeTrading);
        }
예제 #17
0
        // метод, который возвращает значения полей даты/времени состояния
        private StatusDTS getStatusRunTimeDTS(OrderStatusEnum status)
        {
            StatusDTS retVal = new StatusDTS();

            switch (status)
            {
            case OrderStatusEnum.None:
                break;

            case OrderStatusEnum.WaitingCook:
                retVal.DateEntered  = Convert.ToDateTime(_dbRunTimeRecord.InitDate);
                retVal.TimeStanding = Convert.ToInt32(_dbRunTimeRecord.WaitingCookTS);
                break;

            case OrderStatusEnum.Cooking:
                retVal.DateEntered  = Convert.ToDateTime(_dbRunTimeRecord.CookingStartDate);
                retVal.TimeStanding = Convert.ToInt32(_dbRunTimeRecord.CookingTS);
                break;

            case OrderStatusEnum.Ready:
                retVal.DateEntered = Convert.ToDateTime(_dbRunTimeRecord.ReadyDate);
                if (_isUseReadyConfirmed)
                {
                    retVal.TimeStanding = Convert.ToInt32(_dbRunTimeRecord.ReadyTS);
                }
                else
                {
                    retVal.TimeStanding = Convert.ToInt32(_dbRunTimeRecord.WaitingTakeTS);
                }
                break;

            case OrderStatusEnum.ReadyConfirmed:
                retVal.DateEntered  = Convert.ToDateTime(_dbRunTimeRecord.ReadyConfirmedDate);
                retVal.TimeStanding = Convert.ToInt32(_dbRunTimeRecord.WaitingTakeTS);
                break;

            case OrderStatusEnum.Took:
                retVal.DateEntered  = Convert.ToDateTime(_dbRunTimeRecord.TakeDate);
                retVal.TimeStanding = Convert.ToInt32(_dbRunTimeRecord.WaitingCommitTS);
                break;

            case OrderStatusEnum.Cancelled:
                retVal.DateEntered = Convert.ToDateTime(_dbRunTimeRecord.CancelDate);
                break;

            case OrderStatusEnum.Commit:
                retVal.DateEntered = Convert.ToDateTime(_dbRunTimeRecord.CommitDate);
                break;

            case OrderStatusEnum.CancelConfirmed:
                retVal.DateEntered = Convert.ToDateTime(_dbRunTimeRecord.CancelConfirmedDate);
                break;

            default:
                break;
            }
            return(retVal);
        }
예제 #18
0
        private OrderSelectCriteria GetSelectCriteria()
        {
            var criteria = new OrderSelectCriteria();

            // only query for device in this partition
            criteria.ServerPartitionKey.EqualTo(Partition.Key);

            QueryHelper.SetGuiStringCondition(criteria.PatientId, PatientId);
            QueryHelper.SetGuiStringCondition(criteria.PatientsName, PatientName);

            QueryHelper.SetGuiStringCondition(criteria.AccessionNumber, AccessionNumber);

            if (!String.IsNullOrEmpty(ToStudyDate) && !String.IsNullOrEmpty(FromStudyDate))
            {
                var toKey   = DateTime.ParseExact(ToStudyDate, DateFormats, null);
                var fromKey = DateTime.ParseExact(FromStudyDate, DateFormats, null);
                criteria.ScheduledDateTime.Between(fromKey, toKey.AddHours(24));
            }
            else if (!String.IsNullOrEmpty(ToStudyDate))
            {
                var toKey = DateTime.ParseExact(ToStudyDate, DateFormats, null);
                criteria.InsertTime.LessThanOrEqualTo(toKey.AddHours(24));
            }
            else if (!String.IsNullOrEmpty(FromStudyDate))
            {
                var fromKey = DateTime.ParseExact(FromStudyDate, DateFormats, null);
                criteria.ScheduledDateTime.MoreThanOrEqualTo(fromKey);
            }

            if (!string.IsNullOrEmpty(ReferringPhysiciansName))
            {
                var staffCriteria = new StaffSelectCriteria();
                QueryHelper.SetGuiStringCondition(staffCriteria.Name, ReferringPhysiciansName);
                criteria.ReferringStaffRelatedEntityCondition.Exists(staffCriteria);
            }

            if (Statuses != null && Statuses.Length > 0)
            {
                if (Statuses.Length == 1)
                {
                    criteria.OrderStatusEnum.EqualTo(OrderStatusEnum.GetEnum(Statuses[0]));
                }
                else
                {
                    var statusList = Statuses.Select(OrderStatusEnum.GetEnum).ToList();
                    criteria.OrderStatusEnum.In(statusList);
                }
            }

            criteria.ScheduledDateTime.SortDesc(0);

            if (QCExpected.HasValue)
            {
                criteria.QCExpected.EqualTo(QCExpected.Value);
            }

            return(criteria);
        }
예제 #19
0
        public async Task ChangeStatus(Guid orderId, OrderStatusEnum orderStatus)
        {
            var entity = await EntityRepo.GetAsync(orderId);


            entity.Status = orderStatus;

            await EntityRepo.UpdateAsync(entity);
        }
예제 #20
0
 public Order(string orderId, DateTime orderDate, double orderTotal, string customerName, OrderStatusEnum orderStatus, string trackingNumber)
 {
     Id             = orderId;
     Date           = orderDate;
     Total          = orderTotal;
     CustomerName   = customerName;
     Status         = orderStatus;
     TrackingNumber = trackingNumber;
 }
예제 #21
0
        // кисти фона и текста
        public static void SetStateButtonBrushes(OrderStatusEnum eState, out Brush backgroundBrush, out Brush foregroundBrush)
        {
            Dictionary <string, BrushesPair> appBrushes = BrushHelper.AppBrushes;

            BrushesPair bp = appBrushes[eState.ToString()];

            backgroundBrush = bp.Background;
            foregroundBrush = bp.Foreground;
        }  // method
예제 #22
0
        public void UpdateOrderStatus(long idOrder, OrderStatusEnum status)
        {
            var order = orderList.FirstOrDefault(ol => ol.IdOrder == idOrder);

            if (order != null)
            {
                order.Status = status;
            }
        }
예제 #23
0
        /// <summary>
        /// Get order status name
        /// </summary>
        /// <param name="os">Order status</param>
        /// <returns>Order status name</returns>
        public static string GetOrderStatusName(this OrderStatusEnum os)
        {
            string name = IoC.Resolve <ILocalizationManager>().GetLocaleResourceString(
                string.Format("OrderStatus.{0}", os.ToString()),
                NopContext.Current.WorkingLanguage.LanguageId,
                true,
                CommonHelper.ConvertEnum(os.ToString()));

            return(name);
        }
예제 #24
0
 private OrderStatusChangedMessage GetStatus(OrderStatusEnum status, List <Messages.OrderLine> lines)
 {
     return(Bus.CreateInstance <OrderStatusChangedMessage>(m =>
     {
         m.PurchaseOrderNumber = Data.PurchaseOrderNumber;
         m.PartnerId = Data.PartnerId;
         m.Status = status;
         m.OrderLines = lines;
     }));
 }
예제 #25
0
 private void UpdateStock(Order order, OrderStatusEnum oldStatus, OrderStatusEnum newStatus)
 {
     if (order.IfItWasNotCanceledAndIsNow(oldStatus, newStatus))
     {
         stockService.Add(order);
     }
     else if (order.IfItWasCanceledAndNowItIsNot(oldStatus, newStatus))
     {
         stockService.Remove(order);
     }
 }
예제 #26
0
        public async Task RecordEventAsync(int orderId, string userId, OrderStatusEnum toStatus)
        {
            OrderRecord record = new OrderRecord {
                OrderId  = orderId,
                UserId   = userId,
                ToStatus = toStatus
            };

            context.OrderRecords.Add(record);
            await context.SaveChangesAsync();
        }
예제 #27
0
        public void SetOrderStatus(OrderStatusEnum status, long oxid)
        {
            var order = this.orderRepository.GetQuery().FirstOrDefault(o => o.OxId == oxid);

            if (order != null)
            {
                order.OrderStatus = (byte)status;
                this.orderRepository.Update(order);
                this.orderRepository.SaveChanges();
            }
        }
        /// <summary>
        /// 订单收货
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public async Task <Result <int> > receiveOrder(List <InStorageRecord> list, string receivedOrder, string userName)
        {
            list.ForEach(x => { x.receivedOrder = receivedOrder; x.createdBy = userName; });
            OrderStatusEnum status = OrderStatusEnum.completed;

            if (list.Where(x => x.countReference != x.countReal).Count() > 0)
            {
                status = OrderStatusEnum.excepted;
            }
            return(await dao.receiveOrder(list, userName, status));
        }
예제 #29
0
 private bool Check(IOrderStatusChangedMessage m, OrderStatusEnum status)
 {
     return(
         m.PartnerId == partnerId &&
         m.PurchaseOrderNumber == purchaseOrderNumber &&
         m.Status == status &&
         m.OrderLines.Count == 1 &&
         m.OrderLines[0].ProductId == productId &&
         m.OrderLines[0].Quantity == quantity
         );
 }
예제 #30
0
        // обновление состояния заказа проверкой состояний всех блюд
        // установить сост.заказа в 0,2,3,4,5 если ВСЕ блюда наход.в этом состоянии
        // установить сост.заказа в 1, если ХОТЬ одно блюдо наход.в сост. 1
        public void UpdateStatusByVerificationDishes()
        {
            int           iStat      = -1;
            HashSet <int> unUsedDeps = (HashSet <int>)AppProperties.GetProperty("UnusedDepartments");

            foreach (OrderDishModel dish in _dishesDict.Values)
            {
                // пропуск блюд, входящих в неотображаемые цеха
                // или имеющие отрицательное количество - отмененные
                if ((unUsedDeps != null) && (unUsedDeps.Contains(dish.DepartmentId)))
                {
                    continue;
                }
                if (dish.Quantity < 0)
                {
                    continue;
                }

                // первое доступное блюдо
                if (iStat == -1)
                {
                    iStat = dish.DishStatusId;
                }

                // если хотя бы одно блюдо в состояние Готовится, то и заказ переводим в это состояние, если он был не в этом состоянии
                if ((dish.DishStatusId == (int)OrderStatusEnum.Cooking) &&
                    (this.OrderStatusId != (int)OrderStatusEnum.Cooking))
                {
                    AppLib.WriteLogOrderDetails(string.Format("   изменение статуса заказа {0}/{1} с {2} на 'Готовится', т.к. есть блюдо в состоянии 'Готовится'"
                                                              , this.Id, this.Number
                                                              , ((OrderStatusEnum)this.OrderStatusId).ToString()));

                    UpdateStatus(OrderStatusEnum.Cooking, false);
                    _isUpdStatusFromDishes = true;
                    return;
                }

                // есть неодинаковый статус - выйти
                if (iStat != dish.DishStatusId)
                {
                    return;
                }
            }

            if ((iStat != -1) && (this.OrderStatusId != iStat))
            {
                string sLog = string.Format("   изменение статуса заказа {0}/{1} на {2} согласно общему статусу всех блюд ПРИ ОБНОВЛЕНИИ БЛЮДА...", this.Id, this.Number, iStat);
                AppLib.WriteLogOrderDetails(sLog);

                OrderStatusEnum statDishes = AppLib.GetStatusEnumFromNullableInt(iStat);
                UpdateStatus(statDishes, false);
                _isUpdStatusFromDishes = true;
            }
        }  // method
예제 #31
0
        public IViewComponentResult Invoke(List <Order> orderList, OrderStatusEnum orderStatus)
        {
            OrderListViewModel orderListViewModel = new OrderListViewModel
            {
                ListCount   = orderList.Count,
                Orders      = orderList,
                OrderStatus = orderStatus,
                OrderListPanelInformation = OrderListHelper.GetOrderListPanelInformation(orderStatus)
            };

            return(View(orderListViewModel));
        }
예제 #32
0
 public static string GetOrderStatusDescription(OrderStatusEnum ose)
 {
     string message="";
     switch (ose)
     {
         case OrderStatusEnum.OPEN:
             message= "The order is open.";
             break;
         case OrderStatusEnum.CLOSED:
             message= "The order is closed.";
             break;
         case OrderStatusEnum.EDITING:
             message = "The order is being edited.";
             break;
         case OrderStatusEnum.PLACED:
             message = "The order has been placed.";
             break;
         case OrderStatusEnum.ERROR:
             message= "There was an error with your order, see error message.";
             break;
         case OrderStatusEnum.COMPLETE:
             message= "The order is complete.";
             break;
         case OrderStatusEnum.CANCELED:
             message = "The order is canceled.";
             break;
         case OrderStatusEnum.PROCESSING:
             message = "The order is processing.";
             break;
     }
     return message;
 }
예제 #33
0
        /// <summary>
        /// Sets an order status
        /// </summary>
        /// <param name="order">Order</param>
        /// <param name="os">New order status</param>
        /// <param name="notifyCustomer">True to notify customer</param>
        protected void SetOrderStatus(Order order,
            OrderStatusEnum os, bool notifyCustomer)
        {
            if (order == null)
                throw new ArgumentNullException("order");

            OrderStatusEnum prevOrderStatus = order.OrderStatus;
            if (prevOrderStatus == os)
                return;

            //set and save new order status
            order.OrderStatusId = (int)os;
            UpdateOrder(order);

            //order notes, notifications
            InsertOrderNote(order.OrderId, string.Format("Order status has been changed to {0}", os.ToString()), false, DateTime.UtcNow);

            if (prevOrderStatus != OrderStatusEnum.Complete &&
                os == OrderStatusEnum.Complete
                && notifyCustomer)
            {
                int orderCompletedCustomerNotificationQueuedEmailId = IoC.Resolve<IMessageService>().SendOrderCompletedCustomerNotification(order, order.CustomerLanguageId);
                if (orderCompletedCustomerNotificationQueuedEmailId > 0)
                {
                    InsertOrderNote(order.OrderId, string.Format("\"Order completed\" email (to customer) has been queued. Queued email identifier: {0}.", orderCompletedCustomerNotificationQueuedEmailId), false, DateTime.UtcNow);
                }
            }

            if (prevOrderStatus != OrderStatusEnum.Cancelled &&
                os == OrderStatusEnum.Cancelled
                && notifyCustomer)
            {
                int orderCancelledCustomerNotificationQueuedEmailId = IoC.Resolve<IMessageService>().SendOrderCancelledCustomerNotification(order, order.CustomerLanguageId);
                if (orderCancelledCustomerNotificationQueuedEmailId > 0)
                {
                    InsertOrderNote(order.OrderId, string.Format("\"Order cancelled\" email (to customer) has been queued. Queued email identifier: {0}.", orderCancelledCustomerNotificationQueuedEmailId), false, DateTime.UtcNow);
                }
            }

            //reward points
            if (this.RewardPointsEnabled)
            {
                if (this.RewardPointsForPurchases_Amount > decimal.Zero)
                {
                    //Ensure that reward points are applied only to registered users
                    if (order.Customer != null && !order.Customer.IsGuest)
                    {
                        int points = (int)Math.Truncate(order.OrderTotal / this.RewardPointsForPurchases_Amount * this.RewardPointsForPurchases_Points);
                        if (points != 0)
                        {
                            if (this.RewardPointsForPurchases_Awarded == order.OrderStatus)
                            {
                                InsertRewardPointsHistory(order.CustomerId,
                                    0, points, decimal.Zero,
                                    decimal.Zero, string.Empty,
                                    string.Format(IoC.Resolve<ILocalizationManager>().GetLocaleResourceString("RewardPoints.Message.EarnedForOrder"), order.OrderId),
                                    DateTime.UtcNow);
                            }

                            if (this.RewardPointsForPurchases_Canceled == order.OrderStatus)
                            {
                               InsertRewardPointsHistory(order.CustomerId,
                                    0, -points, decimal.Zero,
                                    decimal.Zero, string.Empty,
                                    string.Format(IoC.Resolve<ILocalizationManager>().GetLocaleResourceString("RewardPoints.Message.ReducedForOrder"), order.OrderId),
                                    DateTime.UtcNow);
                            }
                        }
                    }
                }
            }

            //gift cards activation
            if (this.GiftCards_Activated.HasValue &&
               this.GiftCards_Activated.Value == order.OrderStatus)
            {
                var giftCards = GetAllGiftCards(order.OrderId, null, null, null, null, null, null, false, string.Empty);
                foreach (var gc in giftCards)
                {
                    bool isRecipientNotified = gc.IsRecipientNotified;
                    switch (gc.PurchasedOrderProductVariant.ProductVariant.GiftCardType)
                    {
                        case (int)GiftCardTypeEnum.Virtual:
                            {
                                //send email for virtual gift card
                                if (!String.IsNullOrEmpty(gc.RecipientEmail) &&
                                    !String.IsNullOrEmpty(gc.SenderEmail))
                                {
                                    Language customerLang = IoC.Resolve<ILanguageService>().GetLanguageById(order.CustomerLanguageId);
                                    if (customerLang == null)
                                        customerLang = NopContext.Current.WorkingLanguage;
                                    int queuedEmailId = IoC.Resolve<IMessageService>().SendGiftCardNotification(gc, customerLang.LanguageId);
                                    if (queuedEmailId > 0)
                                    {
                                        isRecipientNotified = true;
                                    }
                                }
                            }
                            break;
                        case (int)GiftCardTypeEnum.Physical:
                            {
                            }
                            break;
                        default:
                            break;
                    }

                    gc.IsGiftCardActivated = true;
                    gc.IsRecipientNotified = isRecipientNotified;
                    this.UpdateGiftCard(gc);
                }
            }

            //gift cards deactivation
            if (this.GiftCards_Deactivated.HasValue &&
               this.GiftCards_Deactivated.Value == order.OrderStatus)
            {
                var giftCards = GetAllGiftCards(order.OrderId,
                    null, null, null, null, null, null, true, string.Empty);
                foreach (var gc in giftCards)
                {
                    gc.IsGiftCardActivated = false;
                    this.UpdateGiftCard(gc);
                }
            }
        }
예제 #34
0
 /// <summary>
 /// Search recurring payments
 /// </summary>
 /// <param name="customerId">The customer identifier; 0 to load all records</param>
 /// <param name="initialOrderId">The initial order identifier; 0 to load all records</param>
 /// <param name="initialOrderStatus">Initial order status identifier; null to load all records</param>
 /// <returns>Recurring payment collection</returns>
 public List<RecurringPayment> SearchRecurringPayments(int customerId, 
     int initialOrderId, OrderStatusEnum? initialOrderStatus)
 {
     bool showHidden = NopContext.Current.IsAdmin;
     return SearchRecurringPayments(showHidden,
         customerId, initialOrderId, initialOrderStatus);
 }
예제 #35
0
 /// <summary>
 /// Search orders
 /// </summary>
 /// <param name="startTime">Order start time; null to load all orders</param>
 /// <param name="endTime">Order end time; null to load all orders</param>
 /// <param name="customerEmail">Customer email</param>
 /// <param name="os">Order status; null to load all orders</param>
 /// <param name="ps">Order payment status; null to load all orders</param>
 /// <param name="ss">Order shippment status; null to load all orders</param>
 /// <returns>Order collection</returns>
 public List<Order> SearchOrders(DateTime? startTime, DateTime? endTime,
     string customerEmail, OrderStatusEnum? os, PaymentStatusEnum? ps, 
     ShippingStatusEnum? ss)
 {
     return SearchOrders(startTime, endTime,
      customerEmail, os, ps, ss, string.Empty);
 }
예제 #36
0
        /// <summary>
        /// Sets an order status
        /// </summary>
        /// <param name="orderId">Order identifier</param>
        /// <param name="os">New order status</param>
        /// <param name="notifyCustomer">True to notify customer</param>
        /// <returns>Order</returns>
        protected static Order SetOrderStatus(int orderId, 
            OrderStatusEnum os, bool notifyCustomer)
        {
            var order = GetOrderById(orderId);
            if (order != null)
            {
                if (order.OrderStatus == os)
                    return order;

                OrderStatusEnum prevOrderStatus = order.OrderStatus;

                var updatedOrder = UpdateOrder(order.OrderId,
                    order.OrderGuid,
                    order.CustomerId,
                    order.CustomerLanguageId,
                    order.CustomerTaxDisplayType,
                    order.CustomerIP,
                    order.OrderSubtotalInclTax,
                    order.OrderSubtotalExclTax,
                    order.OrderShippingInclTax,
                    order.OrderShippingExclTax,
                    order.PaymentMethodAdditionalFeeInclTax,
                    order.PaymentMethodAdditionalFeeExclTax,
                    order.TaxRates,
                    order.OrderTax,
                    order.OrderTotal,
                    order.RefundedAmount,
                    order.OrderDiscount,
                    order.OrderSubtotalInclTaxInCustomerCurrency,
                    order.OrderSubtotalExclTaxInCustomerCurrency,
                    order.OrderShippingInclTaxInCustomerCurrency,
                    order.OrderShippingExclTaxInCustomerCurrency,
                    order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency,
                    order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency,
                    order.TaxRatesInCustomerCurrency,
                    order.OrderTaxInCustomerCurrency,
                    order.OrderTotalInCustomerCurrency,
                    order.OrderDiscountInCustomerCurrency,
                    order.CheckoutAttributeDescription,
                    order.CheckoutAttributesXml,
                    order.CustomerCurrencyCode,
                    order.OrderWeight,
                    order.AffiliateId,
                    os,
                    order.AllowStoringCreditCardNumber,
                    order.CardType,
                    order.CardName, order.CardNumber,
                    order.MaskedCreditCardNumber,
                    order.CardCvv2, order.CardExpirationMonth,
                    order.CardExpirationYear,
                    order.PaymentMethodId,
                    order.PaymentMethodName,
                    order.AuthorizationTransactionId,
                    order.AuthorizationTransactionCode,
                    order.AuthorizationTransactionResult,
                    order.CaptureTransactionId,
                    order.CaptureTransactionResult,
                    order.SubscriptionTransactionId,
                    order.PurchaseOrderNumber,
                    order.PaymentStatus, order.PaidDate,
                    order.BillingFirstName,
                    order.BillingLastName,
                    order.BillingPhoneNumber,
                    order.BillingEmail,
                    order.BillingFaxNumber,
                    order.BillingCompany,
                    order.BillingAddress1,
                    order.BillingAddress2,
                    order.BillingCity,
                    order.BillingStateProvince,
                    order.BillingStateProvinceId,
                    order.BillingZipPostalCode,
                    order.BillingCountry,
                    order.BillingCountryId,
                    order.ShippingStatus,
                    order.ShippingFirstName,
                    order.ShippingLastName,
                    order.ShippingPhoneNumber,
                    order.ShippingEmail,
                    order.ShippingFaxNumber,
                    order.ShippingCompany,
                    order.ShippingAddress1,
                    order.ShippingAddress2,
                    order.ShippingCity,
                    order.ShippingStateProvince,
                    order.ShippingStateProvinceId,
                    order.ShippingZipPostalCode,
                    order.ShippingCountry,
                    order.ShippingCountryId,
                    order.ShippingMethod,
                    order.ShippingRateComputationMethodId,
                    order.ShippedDate,
                    order.DeliveryDate,
                    order.TrackingNumber,
                    order.VatNumber,
                    order.Deleted,
                    order.CreatedOn);

                //order notes, notifications
                InsertOrderNote(orderId, string.Format("Order status has been changed to {0}", os.ToString()), false, DateTime.UtcNow);

                if (prevOrderStatus != OrderStatusEnum.Complete &&
                    os == OrderStatusEnum.Complete
                    && notifyCustomer)
                {
                    int orderCompletedCustomerNotificationQueuedEmailId = MessageManager.SendOrderCompletedCustomerNotification(updatedOrder, updatedOrder.CustomerLanguageId);
                    if (orderCompletedCustomerNotificationQueuedEmailId > 0)
                    {
                        InsertOrderNote(orderId, string.Format("\"Order completed\" email (to customer) has been queued. Queued email identifier: {0}.", orderCompletedCustomerNotificationQueuedEmailId), false, DateTime.UtcNow);
                    }
                }

                if (prevOrderStatus != OrderStatusEnum.Cancelled &&
                    os == OrderStatusEnum.Cancelled
                    && notifyCustomer)
                {
                    int orderCancelledCustomerNotificationQueuedEmailId = MessageManager.SendOrderCancelledCustomerNotification(updatedOrder, updatedOrder.CustomerLanguageId);
                    if (orderCancelledCustomerNotificationQueuedEmailId > 0)
                    {
                        InsertOrderNote(orderId, string.Format("\"Order cancelled\" email (to customer) has been queued. Queued email identifier: {0}.", orderCancelledCustomerNotificationQueuedEmailId), false, DateTime.UtcNow);
                    }
                }

                //reward points
                if (OrderManager.RewardPointsEnabled)
                {
                    if (OrderManager.RewardPointsForPurchases_Amount > decimal.Zero)
                    {
                        int points = (int)Math.Truncate(updatedOrder.OrderTotal / OrderManager.RewardPointsForPurchases_Amount * OrderManager.RewardPointsForPurchases_Points);
                        if (points != 0)
                        {
                            if (OrderManager.RewardPointsForPurchases_Awarded == updatedOrder.OrderStatus)
                            {
                                var rph = InsertRewardPointsHistory(order.CustomerId,
                                    0, points, decimal.Zero,
                                    decimal.Zero, string.Empty,
                                    string.Format(LocalizationManager.GetLocaleResourceString("RewardPoints.Message.EarnedForOrder"), order.OrderId),
                                    DateTime.UtcNow);
                            }

                            if (OrderManager.RewardPointsForPurchases_Canceled == updatedOrder.OrderStatus)
                            {
                                var rph = InsertRewardPointsHistory(order.CustomerId,
                                    0, -points, decimal.Zero,
                                    decimal.Zero, string.Empty,
                                    string.Format(LocalizationManager.GetLocaleResourceString("RewardPoints.Message.ReducedForOrder"), order.OrderId),
                                    DateTime.UtcNow);
                            }
                        }
                    }
                }

                //gift cards activation
                if (OrderManager.GiftCards_Activated.HasValue &&
                   OrderManager.GiftCards_Activated.Value == updatedOrder.OrderStatus)
                {
                    var giftCards = GetAllGiftCards(order.OrderId,
                        null, null,null,null,null,null,false, string.Empty);
                    foreach (var gc in giftCards)
                    {
                        bool isRecipientNotified = gc.IsRecipientNotified;
                        switch (gc.PurchasedOrderProductVariant.ProductVariant.GiftCardType)
                        {
                            case (int)GiftCardTypeEnum.Virtual:
                                {
                                    //send email for virtual gift card
                                    if (!String.IsNullOrEmpty(gc.RecipientEmail) &&
                                        !String.IsNullOrEmpty(gc.SenderEmail))
                                    {
                                        Language customerLang = LanguageManager.GetLanguageById(updatedOrder.CustomerLanguageId);
                                        if (customerLang == null)
                                            customerLang = NopContext.Current.WorkingLanguage;
                                        int queuedEmailId = MessageManager.SendGiftCardNotification(gc, customerLang.LanguageId);
                                        if (queuedEmailId > 0)
                                        {
                                            isRecipientNotified = true;
                                        }
                                    }
                                }
                                break;
                            case (int)GiftCardTypeEnum.Physical:
                                {
                                }
                                break;
                            default:
                                break;
                        }

                        OrderManager.UpdateGiftCard(gc.GiftCardId,
                            gc.PurchasedOrderProductVariantId, gc.Amount, true,
                            gc.GiftCardCouponCode, gc.RecipientName, gc.RecipientEmail,
                            gc.SenderName, gc.SenderEmail, gc.Message,
                            isRecipientNotified, gc.CreatedOn);
                    }
                }

                //gift cards deactivation
                if (OrderManager.GiftCards_Deactivated.HasValue &&
                   OrderManager.GiftCards_Deactivated.Value == updatedOrder.OrderStatus)
                {
                    var giftCards = GetAllGiftCards(order.OrderId,
                        null, null, null, null, null, null, true, string.Empty);
                    foreach (var gc in giftCards)
                    {
                        OrderManager.UpdateGiftCard(gc.GiftCardId,
                            gc.PurchasedOrderProductVariantId, gc.Amount, false,
                            gc.GiftCardCouponCode, gc.RecipientName, gc.RecipientEmail,
                            gc.SenderName, gc.SenderEmail, gc.Message,
                            gc.IsRecipientNotified, gc.CreatedOn);
                    }
                }

                return updatedOrder;
            }
            return null;
        }
예제 #37
0
        /// <summary>
        /// Updates the order
        /// </summary>
        /// <param name="orderId">The order identifier</param>
        /// <param name="orderGuid">The order identifier</param>
        /// <param name="customerId">The customer identifier</param>
        /// <param name="customerLanguageId">The customer language identifier</param>
        /// <param name="customerTaxDisplayType">The customer tax display type</param>
        /// <param name="customerIP">The customer IP address</param>
        /// <param name="orderSubtotalInclTax">The order subtotal (incl tax)</param>
        /// <param name="orderSubtotalExclTax">The order subtotal (excl tax)</param>
        /// <param name="orderShippingInclTax">The order shipping (incl tax)</param>
        /// <param name="orderShippingExclTax">The order shipping (excl tax)</param>
        /// <param name="paymentMethodAdditionalFeeInclTax">The payment method additional fee (incl tax)</param>
        /// <param name="paymentMethodAdditionalFeeExclTax">The payment method additional fee (excl tax)</param>
        /// <param name="taxRates">The tax rates</param>
        /// <param name="orderTax">The order tax</param>
        /// <param name="orderTotal">The order total</param>
        /// <param name="refundedAmount">The refunded amount</param>
        /// <param name="orderDiscount">The order discount</param>
        /// <param name="orderSubtotalInclTaxInCustomerCurrency">The order subtotal incl tax (customer currency)</param>
        /// <param name="orderSubtotalExclTaxInCustomerCurrency">The order subtotal excl tax (customer currency)</param>
        /// <param name="orderShippingInclTaxInCustomerCurrency">The order shipping incl tax (customer currency)</param>
        /// <param name="orderShippingExclTaxInCustomerCurrency">The order shipping excl tax (customer currency)</param>
        /// <param name="paymentMethodAdditionalFeeInclTaxInCustomerCurrency">The payment method additional fee incl tax (customer currency)</param>
        /// <param name="paymentMethodAdditionalFeeExclTaxInCustomerCurrency">The payment method additional fee excl tax (customer currency)</param>
        /// <param name="taxRatesInCustomerCurrency">The tax rates (customer currency)</param>
        /// <param name="orderTaxInCustomerCurrency">The order tax (customer currency)</param>
        /// <param name="orderTotalInCustomerCurrency">The order total (customer currency)</param>
        /// <param name="orderDiscountInCustomerCurrency">The order discount (customer currency)</param>
        /// <param name="checkoutAttributeDescription">The checkout attribute description</param>
        /// <param name="checkoutAttributesXml">The checkout attributes in XML format</param>
        /// <param name="customerCurrencyCode">The customer currency code</param>
        /// <param name="orderWeight">The order weight</param>
        /// <param name="affiliateId">The affiliate identifier</param>
        /// <param name="orderStatus">The order status</param>
        /// <param name="allowStoringCreditCardNumber">The value indicating whether storing of credit card number is allowed</param>
        /// <param name="cardType">The card type</param>
        /// <param name="cardName">The card name</param>
        /// <param name="cardNumber">The card number</param>
        /// <param name="maskedCreditCardNumber">The masked credit card number</param>
        /// <param name="cardCvv2">The card CVV2</param>
        /// <param name="cardExpirationMonth">The card expiration month</param>
        /// <param name="cardExpirationYear">The card expiration year</param>
        /// <param name="paymentMethodId">The payment method identifier</param>
        /// <param name="paymentMethodName">The payment method name</param>
        /// <param name="authorizationTransactionId">The authorization transaction identifier</param>
        /// <param name="authorizationTransactionCode">The authorization transaction code</param>
        /// <param name="authorizationTransactionResult">The authorization transaction result</param>
        /// <param name="captureTransactionId">The capture transaction identifier</param>
        /// <param name="captureTransactionResult">The capture transaction result</param>
        /// <param name="subscriptionTransactionId">The subscription transaction identifier</param>
        /// <param name="purchaseOrderNumber">The purchase order number</param>
        /// <param name="paymentStatus">The payment status</param>
        /// <param name="paidDate">The paid date and time</param>
        /// <param name="billingFirstName">The billing first name</param>
        /// <param name="billingLastName">The billing last name</param>
        /// <param name="billingPhoneNumber">he billing phone number</param>
        /// <param name="billingEmail">The billing email</param>
        /// <param name="billingFaxNumber">The billing fax number</param>
        /// <param name="billingCompany">The billing company</param>
        /// <param name="billingAddress1">The billing address 1</param>
        /// <param name="billingAddress2">The billing address 2</param>
        /// <param name="billingCity">The billing city</param>
        /// <param name="billingStateProvince">The billing state/province</param>
        /// <param name="billingStateProvinceId">The billing state/province identifier</param>
        /// <param name="billingZipPostalCode">The billing zip/postal code</param>
        /// <param name="billingCountry">The billing country</param>
        /// <param name="billingCountryId">The billing country identifier</param>
        /// <param name="shippingStatus">The shipping status</param>
        /// <param name="shippingFirstName">The shipping first name</param>
        /// <param name="shippingLastName">The shipping last name</param>
        /// <param name="shippingPhoneNumber">The shipping phone number</param>
        /// <param name="shippingEmail">The shipping email</param>
        /// <param name="shippingFaxNumber">The shipping fax number</param>
        /// <param name="shippingCompany">The shipping  company</param>
        /// <param name="shippingAddress1">The shipping address 1</param>
        /// <param name="shippingAddress2">The shipping address 2</param>
        /// <param name="shippingCity">The shipping city</param>
        /// <param name="shippingStateProvince">The shipping state/province</param>
        /// <param name="shippingStateProvinceId">The shipping state/province identifier</param>
        /// <param name="shippingZipPostalCode">The shipping zip/postal code</param>
        /// <param name="shippingCountry">The shipping country</param>
        /// <param name="shippingCountryId">The shipping country identifier</param>
        /// <param name="shippingMethod">The shipping method</param>
        /// <param name="shippingRateComputationMethodId">The shipping rate computation method identifier</param>
        /// <param name="shippedDate">The shipped date and time</param>
        /// <param name="deliveryDate">The delivery date and time</param>
        /// <param name="trackingNumber">The tracking number of order</param>
        /// <param name="vatNumber">The VAT number (the European Union Value Added Tax)</param>
        /// <param name="deleted">A value indicating whether the entity has been deleted</param>
        /// <param name="createdOn">The date and time of order creation</param>
        /// <returns>Order</returns>
        public static Order UpdateOrder(int orderId,
            Guid orderGuid,
            int customerId,
            int customerLanguageId,
            TaxDisplayTypeEnum customerTaxDisplayType,
            string customerIP,
            decimal orderSubtotalInclTax,
            decimal orderSubtotalExclTax,
            decimal orderShippingInclTax,
            decimal orderShippingExclTax,
            decimal paymentMethodAdditionalFeeInclTax,
            decimal paymentMethodAdditionalFeeExclTax,
            string taxRates,
            decimal orderTax,
            decimal orderTotal,
            decimal refundedAmount,
            decimal orderDiscount,
            decimal orderSubtotalInclTaxInCustomerCurrency,
            decimal orderSubtotalExclTaxInCustomerCurrency,
            decimal orderShippingInclTaxInCustomerCurrency,
            decimal orderShippingExclTaxInCustomerCurrency,
            decimal paymentMethodAdditionalFeeInclTaxInCustomerCurrency,
            decimal paymentMethodAdditionalFeeExclTaxInCustomerCurrency,
            string taxRatesInCustomerCurrency,
            decimal orderTaxInCustomerCurrency,
            decimal orderTotalInCustomerCurrency,
            decimal orderDiscountInCustomerCurrency,
            string checkoutAttributeDescription,
            string checkoutAttributesXml,
            string customerCurrencyCode,
            decimal orderWeight,
            int affiliateId,
            OrderStatusEnum orderStatus,
            bool allowStoringCreditCardNumber,
            string cardType,
            string cardName,
            string cardNumber,
            string maskedCreditCardNumber,
            string cardCvv2,
            string cardExpirationMonth,
            string cardExpirationYear,
            int paymentMethodId,
            string paymentMethodName,
            string authorizationTransactionId,
            string authorizationTransactionCode,
            string authorizationTransactionResult,
            string captureTransactionId,
            string captureTransactionResult,
            string subscriptionTransactionId,
            string purchaseOrderNumber,
            PaymentStatusEnum paymentStatus,
            DateTime? paidDate,
            string billingFirstName,
            string billingLastName,
            string billingPhoneNumber,
            string billingEmail,
            string billingFaxNumber,
            string billingCompany,
            string billingAddress1,
            string billingAddress2,
            string billingCity,
            string billingStateProvince,
            int billingStateProvinceId,
            string billingZipPostalCode,
            string billingCountry,
            int billingCountryId,
            ShippingStatusEnum shippingStatus,
            string shippingFirstName,
            string shippingLastName,
            string shippingPhoneNumber,
            string shippingEmail,
            string shippingFaxNumber,
            string shippingCompany,
            string shippingAddress1,
            string shippingAddress2,
            string shippingCity,
            string shippingStateProvince,
            int shippingStateProvinceId,
            string shippingZipPostalCode,
            string shippingCountry,
            int shippingCountryId,
            string shippingMethod,
            int shippingRateComputationMethodId,
            DateTime? shippedDate,
            DateTime? deliveryDate,
            string trackingNumber,
            string vatNumber,
            bool deleted,
            DateTime createdOn)
        {
            if (trackingNumber == null)
                trackingNumber = string.Empty;

            taxRates = CommonHelper.EnsureMaximumLength(taxRates, 4000);
            taxRatesInCustomerCurrency = CommonHelper.EnsureMaximumLength(taxRatesInCustomerCurrency, 4000);
            customerIP = CommonHelper.EnsureMaximumLength(customerIP, 50);
            cardType = CommonHelper.EnsureMaximumLength(cardType, 100);
            cardName = CommonHelper.EnsureMaximumLength(cardName, 1000);
            cardNumber = CommonHelper.EnsureMaximumLength(cardNumber, 100);
            maskedCreditCardNumber = CommonHelper.EnsureMaximumLength(maskedCreditCardNumber, 100);
            cardCvv2 = CommonHelper.EnsureMaximumLength(cardCvv2, 100);
            cardExpirationMonth = CommonHelper.EnsureMaximumLength(cardExpirationMonth, 100);
            cardExpirationYear = CommonHelper.EnsureMaximumLength(cardExpirationYear, 100);
            paymentMethodName = CommonHelper.EnsureMaximumLength(paymentMethodName, 100);
            authorizationTransactionId = CommonHelper.EnsureMaximumLength(authorizationTransactionId, 4000);
            authorizationTransactionCode = CommonHelper.EnsureMaximumLength(authorizationTransactionCode, 4000);
            authorizationTransactionResult = CommonHelper.EnsureMaximumLength(authorizationTransactionResult, 4000);
            captureTransactionId = CommonHelper.EnsureMaximumLength(captureTransactionId, 4000);
            captureTransactionResult = CommonHelper.EnsureMaximumLength(captureTransactionResult, 4000);
            subscriptionTransactionId = CommonHelper.EnsureMaximumLength(subscriptionTransactionId, 4000);
            purchaseOrderNumber = CommonHelper.EnsureMaximumLength(purchaseOrderNumber, 100);
            billingFirstName = CommonHelper.EnsureMaximumLength(billingFirstName, 100);
            billingLastName = CommonHelper.EnsureMaximumLength(billingLastName, 100);
            billingPhoneNumber = CommonHelper.EnsureMaximumLength(billingPhoneNumber, 50);
            billingEmail = CommonHelper.EnsureMaximumLength(billingEmail, 255);
            billingFaxNumber = CommonHelper.EnsureMaximumLength(billingFaxNumber, 50);
            billingCompany = CommonHelper.EnsureMaximumLength(billingCompany, 100);
            billingAddress1 = CommonHelper.EnsureMaximumLength(billingAddress1, 100);
            billingAddress2 = CommonHelper.EnsureMaximumLength(billingAddress2, 100);
            billingCity = CommonHelper.EnsureMaximumLength(billingCity, 100);
            billingStateProvince = CommonHelper.EnsureMaximumLength(billingStateProvince, 100);
            billingZipPostalCode = CommonHelper.EnsureMaximumLength(billingZipPostalCode, 30);
            billingCountry = CommonHelper.EnsureMaximumLength(billingCountry, 100);
            shippingFirstName = CommonHelper.EnsureMaximumLength(shippingFirstName, 100);
            shippingLastName = CommonHelper.EnsureMaximumLength(shippingLastName, 100);
            shippingPhoneNumber = CommonHelper.EnsureMaximumLength(shippingPhoneNumber, 50);
            shippingEmail = CommonHelper.EnsureMaximumLength(shippingEmail, 255);
            shippingFaxNumber = CommonHelper.EnsureMaximumLength(shippingFaxNumber, 50);
            shippingCompany = CommonHelper.EnsureMaximumLength(shippingCompany, 100);
            shippingAddress1 = CommonHelper.EnsureMaximumLength(shippingAddress1, 100);
            shippingAddress2 = CommonHelper.EnsureMaximumLength(shippingAddress2, 100);
            shippingCity = CommonHelper.EnsureMaximumLength(shippingCity, 100);
            shippingStateProvince = CommonHelper.EnsureMaximumLength(shippingStateProvince, 100);
            shippingZipPostalCode = CommonHelper.EnsureMaximumLength(shippingZipPostalCode, 30);
            shippingCountry = CommonHelper.EnsureMaximumLength(shippingCountry, 100);
            shippingMethod = CommonHelper.EnsureMaximumLength(shippingMethod, 100);
            trackingNumber = CommonHelper.EnsureMaximumLength(trackingNumber, 100);
            vatNumber = CommonHelper.EnsureMaximumLength(vatNumber, 100);

            var order = GetOrderById(orderId);
            if (order == null)
                return null;

            var context = ObjectContextHelper.CurrentObjectContext;
            if (!context.IsAttached(order))
                context.Orders.Attach(order);

            order.OrderGuid = orderGuid;
            order.CustomerId = customerId;
            order.CustomerLanguageId = customerLanguageId;
            order.CustomerTaxDisplayTypeId = (int)customerTaxDisplayType;
            order.CustomerIP = customerIP;
            order.OrderSubtotalInclTax = orderSubtotalInclTax;
            order.OrderSubtotalExclTax = orderSubtotalExclTax;
            order.OrderShippingInclTax = orderShippingInclTax;
            order.OrderShippingExclTax = orderShippingExclTax;
            order.PaymentMethodAdditionalFeeInclTax = paymentMethodAdditionalFeeInclTax;
            order.PaymentMethodAdditionalFeeExclTax = paymentMethodAdditionalFeeExclTax;
            order.TaxRates = taxRates;
            order.OrderTax = orderTax;
            order.OrderTotal = orderTotal;
            order.RefundedAmount = refundedAmount;
            order.OrderDiscount = orderDiscount;
            order.OrderSubtotalInclTaxInCustomerCurrency = orderSubtotalInclTaxInCustomerCurrency;
            order.OrderSubtotalExclTaxInCustomerCurrency = orderSubtotalExclTaxInCustomerCurrency;
            order.OrderShippingInclTaxInCustomerCurrency = orderShippingInclTaxInCustomerCurrency;
            order.OrderShippingExclTaxInCustomerCurrency = orderShippingExclTaxInCustomerCurrency;
            order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency = paymentMethodAdditionalFeeInclTaxInCustomerCurrency;
            order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency = paymentMethodAdditionalFeeExclTaxInCustomerCurrency;
            order.TaxRatesInCustomerCurrency = taxRatesInCustomerCurrency;
            order.OrderTaxInCustomerCurrency = orderTaxInCustomerCurrency;
            order.OrderTotalInCustomerCurrency = orderTotalInCustomerCurrency;
            order.OrderDiscountInCustomerCurrency = orderDiscountInCustomerCurrency;
            order.CheckoutAttributeDescription = checkoutAttributeDescription;
            order.CheckoutAttributesXml = checkoutAttributesXml;
            order.CustomerCurrencyCode = customerCurrencyCode;
            order.OrderWeight = orderWeight;
            order.AffiliateId = affiliateId;
            order.OrderStatusId = (int)orderStatus;
            order.AllowStoringCreditCardNumber = allowStoringCreditCardNumber;
            order.CardType = cardType;
            order.CardName = cardName;
            order.CardNumber = cardNumber;
            order.MaskedCreditCardNumber = maskedCreditCardNumber;
            order.CardCvv2 = cardCvv2;
            order.CardExpirationMonth = cardExpirationMonth;
            order.CardExpirationYear = cardExpirationYear;
            order.PaymentMethodId = paymentMethodId;
            order.PaymentMethodName = paymentMethodName;
            order.AuthorizationTransactionId = authorizationTransactionId;
            order.AuthorizationTransactionCode = authorizationTransactionCode;
            order.AuthorizationTransactionResult = authorizationTransactionResult;
            order.CaptureTransactionId = captureTransactionId;
            order.CaptureTransactionResult = captureTransactionResult;
            order.SubscriptionTransactionId = subscriptionTransactionId;
            order.PurchaseOrderNumber = purchaseOrderNumber;
            order.PaymentStatusId = (int)paymentStatus;
            order.PaidDate = paidDate;
            order.BillingFirstName = billingFirstName;
            order.BillingLastName = billingLastName;
            order.BillingPhoneNumber = billingPhoneNumber;
            order.BillingEmail = billingEmail;
            order.BillingFaxNumber = billingFaxNumber;
            order.BillingCompany = billingCompany;
            order.BillingAddress1 = billingAddress1;
            order.BillingAddress2 = billingAddress2;
            order.BillingCity = billingCity;
            order.BillingStateProvince = billingStateProvince;
            order.BillingStateProvinceId = billingStateProvinceId;
            order.BillingZipPostalCode = billingZipPostalCode;
            order.BillingCountry = billingCountry;
            order.BillingCountryId = billingCountryId;
            order.ShippingStatusId = (int)shippingStatus;
            order.ShippingFirstName = shippingFirstName;
            order.ShippingLastName = shippingLastName;
            order.ShippingPhoneNumber = shippingPhoneNumber;
            order.ShippingEmail = shippingEmail;
            order.ShippingFaxNumber = shippingFaxNumber;
            order.ShippingCompany = shippingCompany;
            order.ShippingAddress1 = shippingAddress1;
            order.ShippingAddress2 = shippingAddress2;
            order.ShippingCity = shippingCity;
            order.ShippingStateProvince = shippingStateProvince;
            order.ShippingStateProvinceId = shippingStateProvinceId;
            order.ShippingZipPostalCode = shippingZipPostalCode;
            order.ShippingCountry = shippingCountry;
            order.ShippingCountryId = shippingCountryId;
            order.ShippingMethod = shippingMethod;
            order.ShippingRateComputationMethodId = shippingRateComputationMethodId;
            order.ShippedDate = shippedDate;
            order.DeliveryDate = deliveryDate;
            order.TrackingNumber = trackingNumber;
            order.VatNumber = vatNumber;
            order.Deleted = deleted;
            order.CreatedOn = createdOn;
            context.SaveChanges();

            //quickbooks
            if (QBManager.QBIsEnabled)
            {
                QBManager.RequestSynchronization(order);
            }

            //raise event
            EventContext.Current.OnOrderUpdated(null,
                new OrderEventArgs() { Order = order });

            return order;
        }
예제 #38
0
        /// <summary>
        /// Search recurring payments
        /// </summary>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <param name="customerId">The customer identifier; 0 to load all records</param>
        /// <param name="initialOrderId">The initial order identifier; 0 to load all records</param>
        /// <param name="initialOrderStatus">Initial order status identifier; null to load all records</param>
        /// <returns>Recurring payment collection</returns>
        public static List<RecurringPayment> SearchRecurringPayments(bool showHidden,
            int customerId, int initialOrderId, OrderStatusEnum? initialOrderStatus)
        {
            int? initialOrderStatusId = null;
            if (initialOrderStatus.HasValue)
                initialOrderStatusId = (int)initialOrderStatus.Value;

            var context = ObjectContextHelper.CurrentObjectContext;

            var recurringPayments = context.Sp_RecurringPaymentLoadAll(showHidden,
                customerId, initialOrderId, initialOrderStatusId);
            return recurringPayments;
        }
예제 #39
0
        /// <summary>
        /// Get order average report
        /// </summary>
        /// <param name="os">Order status</param>
        /// <returns>Result</returns>
        public static OrderAverageReportLineSummary OrderAverageReport(OrderStatusEnum os)
        {
            int orderStatusId = (int)os;

            DateTime nowDT = DateTimeHelper.ConvertToUserTime(DateTime.Now);

            //today
            DateTime? startTime = DateTimeHelper.ConvertToUtcTime(new DateTime(nowDT.Year, nowDT.Month, nowDT.Day), DateTimeHelper.CurrentTimeZone);
            DateTime? endTime = null;
            var todayResult = GetOrderAverageReportLine(os, startTime, endTime);
            //week
            DayOfWeek fdow = CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;
            DateTime today = new DateTime(nowDT.Year, nowDT.Month, nowDT.Day);
            startTime = DateTimeHelper.ConvertToUtcTime(today.AddDays(-(today.DayOfWeek - fdow)), DateTimeHelper.CurrentTimeZone);
            endTime = null;
            var weekResult = GetOrderAverageReportLine(os, startTime, endTime);
            //month
            startTime = DateTimeHelper.ConvertToUtcTime(new DateTime(nowDT.Year, nowDT.Month, 1), DateTimeHelper.CurrentTimeZone);
            endTime = null;
            var monthResult = GetOrderAverageReportLine(os, startTime, endTime);
            //year
            startTime = DateTimeHelper.ConvertToUtcTime(new DateTime(nowDT.Year, 1, 1), DateTimeHelper.CurrentTimeZone);
            endTime = null;
            var yearResult = GetOrderAverageReportLine(os, startTime, endTime);
            //all time
            startTime = null;
            endTime = null;
            var allTimeResult = GetOrderAverageReportLine(os, startTime, endTime);

            var item = new OrderAverageReportLineSummary();
            item.SumTodayOrders = todayResult.SumOrders;
            item.CountTodayOrders = todayResult.CountOrders;
            item.SumThisWeekOrders = weekResult.SumOrders;
            item.CountThisWeekOrders = weekResult.CountOrders;
            item.SumThisMonthOrders = monthResult.SumOrders;
            item.CountThisMonthOrders = monthResult.CountOrders;
            item.SumThisYearOrders = yearResult.SumOrders;
            item.CountThisYearOrders = yearResult.CountOrders;
            item.SumAllTimeOrders = allTimeResult.SumOrders;
            item.CountAllTimeOrders = allTimeResult.CountOrders;
            item.OrderStatus = os;

            return item;
        }
예제 #40
0
        /// <summary>
        /// Get order average report
        /// </summary>
        /// <param name="os">Order status;</param>
        /// <param name="startTime">Start date</param>
        /// <param name="endTime">End date</param>
        /// <returns>Result</returns>
        public static OrderAverageReportLine GetOrderAverageReportLine(OrderStatusEnum os, 
            DateTime? startTime, DateTime? endTime)
        {
            int orderStatusId = (int)os;

            var context = ObjectContextHelper.CurrentObjectContext;
            var item = context.Sp_OrderAverageReport(startTime, endTime, orderStatusId);
            return item;
        }
예제 #41
0
        /// <summary>
        /// Gets all gift cards
        /// </summary>
        /// <param name="orderId">Order identifier; null to load all records</param>
        /// <param name="customerId">Customer identifier; null to load all records</param>
        /// <param name="startTime">Order start time; null to load all records</param>
        /// <param name="endTime">Order end time; null to load all records</param>
        /// <param name="os">Order status; null to load all records</param>
        /// <param name="ps">Order payment status; null to load all records</param>
        /// <param name="ss">Order shippment status; null to load all records</param>
        /// <param name="isGiftCardActivated">Value indicating whether gift card is activated; null to load all records</param>
        /// <param name="giftCardCouponCode">Gift card coupon code; null or string.empty to load all records</param>
        /// <returns>Gift cards</returns>
        public static List<GiftCard> GetAllGiftCards(int? orderId,
            int? customerId, DateTime? startTime, DateTime? endTime,
            OrderStatusEnum? os, PaymentStatusEnum? ps, ShippingStatusEnum? ss,
            bool? isGiftCardActivated, string giftCardCouponCode)
        {
            int? orderStatusId = null;
            if (os.HasValue)
                orderStatusId = (int)os.Value;

            int? paymentStatusId = null;
            if (ps.HasValue)
                paymentStatusId = (int)ps.Value;

            int? shippingStatusId = null;
            if (ss.HasValue)
                shippingStatusId = (int)ss.Value;

            if (giftCardCouponCode != null)
                giftCardCouponCode = giftCardCouponCode.Trim();

            var context = ObjectContextHelper.CurrentObjectContext;
            var giftCards = context.Sp_GiftCardLoadAll(orderId,
                customerId, startTime, endTime, orderStatusId, paymentStatusId, shippingStatusId,
                isGiftCardActivated, giftCardCouponCode);
            return giftCards;
        }
예제 #42
0
        /// <summary>
        /// Get order average report
        /// </summary>
        /// <param name="os">Order status</param>
        /// <returns>Result</returns>
        public OrderAverageReportLineSummary OrderAverageReport(OrderStatusEnum os)
        {
            var item = new OrderAverageReportLineSummary();
            item.OrderStatus = os;

            DateTime nowDT = DateTimeHelper.ConvertToUserTime(DateTime.Now);
            TimeZoneInfo timeZone = DateTimeHelper.CurrentTimeZone;

            //today
            DateTime t1 = new DateTime(nowDT.Year, nowDT.Month, nowDT.Day);
            if (!timeZone.IsInvalidTime(t1))
            {
                DateTime? startTime1 = DateTimeHelper.ConvertToUtcTime(t1, timeZone);
                DateTime? endTime1 = null;
                var todayResult = GetOrderAverageReportLine(os, startTime1, endTime1);
                item.SumTodayOrders = todayResult.SumOrders;
                item.CountTodayOrders = todayResult.CountOrders;
            }
            //week
            DayOfWeek fdow = CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;
            DateTime today = new DateTime(nowDT.Year, nowDT.Month, nowDT.Day);
            DateTime t2 = today.AddDays(-(today.DayOfWeek - fdow));
            if (!timeZone.IsInvalidTime(t2))
            {
                DateTime? startTime2 = DateTimeHelper.ConvertToUtcTime(t2, timeZone);
                DateTime? endTime2 = null;
                var weekResult = GetOrderAverageReportLine(os, startTime2, endTime2);
                item.SumThisWeekOrders = weekResult.SumOrders;
                item.CountThisWeekOrders = weekResult.CountOrders;
            }
            //month
            DateTime t3 = new DateTime(nowDT.Year, nowDT.Month, 1);
            if (!timeZone.IsInvalidTime(t3))
            {
                DateTime? startTime3 = DateTimeHelper.ConvertToUtcTime(t3, timeZone);
                DateTime? endTime3 = null;
                var monthResult = GetOrderAverageReportLine(os, startTime3, endTime3);
                item.SumThisMonthOrders = monthResult.SumOrders;
                item.CountThisMonthOrders = monthResult.CountOrders;
            }
            //year
            DateTime t4 = new DateTime(nowDT.Year, 1, 1);
            if (!timeZone.IsInvalidTime(t4))
            {
                DateTime? startTime4 = DateTimeHelper.ConvertToUtcTime(t4, timeZone);
                DateTime? endTime4 = null;
                var yearResult = GetOrderAverageReportLine(os, startTime4, endTime4);
                item.SumThisYearOrders = yearResult.SumOrders;
                item.CountThisYearOrders = yearResult.CountOrders;
            }
            //all time
            DateTime? startTime5 = null;
            DateTime? endTime5 = null;
            var allTimeResult = GetOrderAverageReportLine(os, startTime5, endTime5);
            item.SumAllTimeOrders = allTimeResult.SumOrders;
            item.CountAllTimeOrders = allTimeResult.CountOrders;

            return item;
        }
예제 #43
0
        /// <summary>
        /// Get order product variant sales report
        /// </summary>
        /// <param name="startTime">Order start time; null to load all</param>
        /// <param name="endTime">Order end time; null to load all</param>
        /// <param name="os">Order status; null to load all records</param>
        /// <param name="ps">Order payment status; null to load all records</param>
        /// <param name="billingCountryId">Billing country identifier; null to load all records</param>
        /// <returns>Result</returns>
        public List<OrderProductVariantReportLine> OrderProductVariantReport(DateTime? startTime,
            DateTime? endTime, OrderStatusEnum? os, PaymentStatusEnum? ps,
            int? billingCountryId)
        {
            int? orderStatusId = null;
            if (os.HasValue)
                orderStatusId = (int)os.Value;

            int? paymentStatusId = null;
            if (ps.HasValue)
                paymentStatusId = (int)ps.Value;

            var report = _context.Sp_OrderProductVariantReport(startTime,
                endTime, orderStatusId, paymentStatusId, billingCountryId).ToList();
            return report;
        }
예제 #44
0
 private bool Check(IOrderStatusChangedMessage m, OrderStatusEnum status)
 {
     return (
                m.PartnerId == partnerId &&
                m.PurchaseOrderNumber == purchaseOrderNumber &&
                m.Status == status &&
                m.OrderLines.Count == 1 &&
                m.OrderLines[0].ProductId == productId &&
                m.OrderLines[0].Quantity == quantity
            );
 }
예제 #45
0
        /// <summary>
        /// Search orders
        /// </summary>
        /// <param name="startTime">Order start time; null to load all orders</param>
        /// <param name="endTime">Order end time; null to load all orders</param>
        /// <param name="customerEmail">Customer email</param>
        /// <param name="os">Order status; null to load all orders</param>
        /// <param name="ps">Order payment status; null to load all orders</param>
        /// <param name="ss">Order shippment status; null to load all orders</param>
        /// <param name="orderGuid">Search by order GUID (Global unique identifier) or part of GUID. Leave empty to load all orders.</param>
        /// <returns>Order collection</returns>
        public List<Order> SearchOrders(DateTime? startTime, DateTime? endTime,
            string customerEmail, OrderStatusEnum? os, PaymentStatusEnum? ps,
            ShippingStatusEnum? ss, string orderGuid)
        {
            int? orderStatusId = null;
            if (os.HasValue)
                orderStatusId = (int)os.Value;

            int? paymentStatusId = null;
            if (ps.HasValue)
                paymentStatusId = (int)ps.Value;

            int? shippingStatusId = null;
            if (ss.HasValue)
                shippingStatusId = (int)ss.Value;

            var query = from o in _context.Orders
                        join c in _context.Customers on o.CustomerId equals c.CustomerId
                        where (String.IsNullOrEmpty(customerEmail) || c.Email.Contains(customerEmail)) &&
                        (!startTime.HasValue || startTime.Value <= o.CreatedOn) &&
                        (!endTime.HasValue || endTime.Value >= o.CreatedOn) &&
                        (!orderStatusId.HasValue || orderStatusId == o.OrderStatusId) &&
                        (!paymentStatusId.HasValue || paymentStatusId.Value == o.PaymentStatusId) &&
                        (!shippingStatusId.HasValue || shippingStatusId.Value == o.ShippingStatusId) &&
                        !o.Deleted
                        orderby o.CreatedOn descending
                        select o;

            var orders = query.ToList();

            //filter by GUID. Filter in BLL because EF doesn't support casting of GUID to string
            if (!String.IsNullOrEmpty(orderGuid))
            {
                orders = orders.FindAll(o => o.OrderGuid.ToString().ToLowerInvariant().Contains(orderGuid.ToLowerInvariant()));
            }

            return orders;
        }
예제 #46
0
		/// <summary>
		/// Gets an order report
		/// </summary>
		/// <param name="OS">Order status; null to load all orders</param>
		/// <param name="PS">Order payment status; null to load all orders</param>
		/// <param name="SS">Order shippment status; null to load all orders</param>
		/// <returns>IDataReader</returns>
		public static IDataReader GetOrderReport(OrderStatusEnum? OS, PaymentStatusEnum? PS, ShippingStatusEnum? SS)
		{
			int? orderStatusID = null;
			if (OS.HasValue)
				orderStatusID = (int)OS.Value;

			int? paymentStatusID = null;
			if (PS.HasValue)
				paymentStatusID = (int)PS.Value;

			int? shippmentStatusID = null;
			if (SS.HasValue)
				shippmentStatusID = (int)SS.Value;

			return DBProviderManager<DBOrderProvider>.Provider.GetOrderReport(orderStatusID, paymentStatusID, shippmentStatusID);
		}
예제 #47
0
        /// <summary>
        /// Search recurring payments
        /// </summary>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <param name="customerId">The customer identifier; 0 to load all records</param>
        /// <param name="initialOrderId">The initial order identifier; 0 to load all records</param>
        /// <param name="initialOrderStatus">Initial order status identifier; null to load all records</param>
        /// <returns>Recurring payment collection</returns>
        public List<RecurringPayment> SearchRecurringPayments(bool showHidden,
            int customerId, int initialOrderId, OrderStatusEnum? initialOrderStatus)
        {
            int? initialOrderStatusId = null;
            if (initialOrderStatus.HasValue)
                initialOrderStatusId = (int)initialOrderStatus.Value;

            var query1 = from rp in _context.RecurringPayments
                         join o in _context.Orders on rp.InitialOrderId equals o.OrderId
                         join c in _context.Customers on o.CustomerId equals c.CustomerId
                         where
                         (!rp.Deleted && !o.Deleted && !c.Deleted) &&
                         (showHidden || rp.IsActive) &&
                         (customerId == 0 || o.CustomerId == customerId) &&
                         (initialOrderId == 0 || rp.InitialOrderId == initialOrderId) &&
                         (!initialOrderStatusId.HasValue || initialOrderStatusId.Value == 0 || o.OrderStatusId == initialOrderStatusId.Value)
                         select rp.RecurringPaymentId;

            var query2 = from rp in _context.RecurringPayments
                         where query1.Contains(rp.RecurringPaymentId)
                         orderby rp.StartDate, rp.RecurringPaymentId
                         select rp;

            var recurringPayments = query2.ToList();
            return recurringPayments;
        }
예제 #48
0
		/// <summary>
		/// Search orders
		/// </summary>
		/// <param name="StartTime">Order start time; null to load all orders</param>
		/// <param name="EndTime">Order end time; null to load all orders</param>
		/// <param name="CustomerEmail">Customer email</param>
		/// <param name="OS">Order status; null to load all orders</param>
		/// <param name="PS">Order payment status; null to load all orders</param>
		/// <param name="SS">Order shippment status; null to load all orders</param>
		/// <returns>Order collection</returns>
		public static OrderCollection SearchOrders(DateTime? StartTime, DateTime? EndTime, string CustomerEmail, OrderStatusEnum? OS, PaymentStatusEnum? PS, ShippingStatusEnum? SS)
		{
			int? orderStatusID = null;
			if (OS.HasValue)
				orderStatusID = (int)OS.Value;

			int? paymentStatusID = null;
			if (PS.HasValue)
				paymentStatusID = (int)PS.Value;

			int? shippingStatusID = null;
			if (SS.HasValue)
				shippingStatusID = (int)SS.Value;

			DBOrderCollection dbCollection = DBProviderManager<DBOrderProvider>.Provider.SearchOrders(StartTime, EndTime, CustomerEmail, orderStatusID, paymentStatusID, shippingStatusID);
			OrderCollection orders = DBMapping(dbCollection);
			return orders;
		}
        /// <summary>
        /// Get best customers
        /// </summary>
        /// <param name="startTime">Order start time; null to load all</param>
        /// <param name="endTime">Order end time; null to load all</param>
        /// <param name="os">Order status; null to load all records</param>
        /// <param name="ps">Order payment status; null to load all records</param>
        /// <param name="ss">Order shippment status; null to load all records</param>
        /// <param name="orderBy">1 - order by order total, 2 - order by number of orders</param>
        /// <returns>Report</returns>
        public List<CustomerBestReportLine> GetBestCustomersReport(DateTime? startTime,
            DateTime? endTime, OrderStatusEnum? os, PaymentStatusEnum? ps,
            ShippingStatusEnum? ss, int orderBy)
        {
            int? orderStatusId = null;
            if (os.HasValue)
                orderStatusId = (int)os.Value;

            int? paymentStatusId = null;
            if (ps.HasValue)
                paymentStatusId = (int)ps.Value;

            int? shippingStatusId = null;
            if (ss.HasValue)
                shippingStatusId = (int)ss.Value;

            var report = _context.Sp_CustomerBestReport(startTime, endTime,
                orderStatusId, paymentStatusId, shippingStatusId, orderBy).ToList();

            return report;
        }
예제 #50
0
		/// <summary>
		/// Get order average report
		/// </summary>
		/// <param name="OS">Order status; null to load all orders</param>
		/// <returns>Result</returns>
		public static OrderAverageReportLine OrderAverageReport(OrderStatusEnum OS)
		{
			int orderStatusID = (int)OS;
			DBOrderAverageReportLine dbItem = DBProviderManager<DBOrderProvider>.Provider.OrderAverageReport(orderStatusID);
			OrderAverageReportLine orderAverageReportLine = DBMapping(dbItem);
			orderAverageReportLine.OrderStatus = OS;
			return orderAverageReportLine;
		}
예제 #51
0
		/// <summary>
		/// Sets an order status
		/// </summary>
		/// <param name="OrderID">Order identifier</param>
		/// <param name="OS">New order status</param>
		/// <param name="notifyCustomer">True to notify customer</param>
		/// <returns>Order</returns>
		protected static Order SetOrderStatus(int OrderID, OrderStatusEnum OS, bool notifyCustomer)
		{
			Order order = GetOrderByID(OrderID);
			if (order != null)
			{
				if (order.OrderStatus == OS)
					return order;

				InsertOrderNote(OrderID, string.Format("Order status has been changed to {0}", OS.ToString()), DateTime.Now);

				if (order.OrderStatus != OrderStatusEnum.Complete &&
					OS == OrderStatusEnum.Complete
					&& notifyCustomer)
				{
					int orderCompletedCustomerNotificationQueuedEmailID = MessageManager.SendOrderCompletedCustomerNotification(order, order.CustomerLanguageID);
					InsertOrderNote(OrderID, string.Format("\"Order completed\" email (to customer) has been queued. Queued email identifier: {0}.", orderCompletedCustomerNotificationQueuedEmailID), DateTime.Now);
				}

				if (order.OrderStatus != OrderStatusEnum.Cancelled &&
					OS == OrderStatusEnum.Cancelled
					&& notifyCustomer)
				{
					int orderCancelledCustomerNotificationQueuedEmailID = MessageManager.SendOrderCancelledCustomerNotification(order, order.CustomerLanguageID);
					InsertOrderNote(OrderID, string.Format("\"Order cancelled\" email (to customer) has been queued. Queued email identifier: {0}.", orderCancelledCustomerNotificationQueuedEmailID), DateTime.Now);
				}

				order = UpdateOrder(order.OrderID, order.OrderGUID, order.CustomerID, order.CustomerLanguageID,
					order.CustomerTaxDisplayType, order.OrderSubtotalInclTax, order.OrderSubtotalExclTax, order.OrderShippingInclTax,
					order.OrderShippingExclTax, order.PaymentMethodAdditionalFeeInclTax, order.PaymentMethodAdditionalFeeExclTax,
					order.OrderTax, order.OrderTotal, order.OrderDiscount,
					order.OrderSubtotalInclTaxInCustomerCurrency, order.OrderSubtotalExclTaxInCustomerCurrency,
					order.OrderShippingInclTaxInCustomerCurrency, order.OrderShippingExclTaxInCustomerCurrency,
					order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency,
					order.OrderTaxInCustomerCurrency, order.OrderTotalInCustomerCurrency, order.CustomerCurrencyCode, order.OrderWeight,
					order.AffiliateID, OS, order.AllowStoringCreditCardNumber, order.CardType,
					order.CardName, order.CardNumber, order.MaskedCreditCardNumber,
					order.CardCVV2, order.CardExpirationMonth, order.CardExpirationYear,
					order.PaymentMethodID, order.PaymentMethodName,
					order.AuthorizationTransactionID,
					order.AuthorizationTransactionCode, order.AuthorizationTransactionResult,
					order.CaptureTransactionID, order.CaptureTransactionResult,
					order.PurchaseOrderNumber, order.PaymentStatus,
					order.BillingFirstName, order.BillingLastName, order.BillingPhoneNumber,
					order.BillingEmail, order.BillingFaxNumber, order.BillingCompany, order.BillingAddress1,
					order.BillingAddress2, order.BillingCity,
					order.BillingStateProvince, order.BillingStateProvinceID, order.BillingZipPostalCode,
					order.BillingCountry, order.BillingCountryID, order.ShippingStatus,
					order.ShippingFirstName, order.ShippingLastName, order.ShippingPhoneNumber,
					order.ShippingEmail, order.ShippingFaxNumber, order.ShippingCompany,
					order.ShippingAddress1, order.ShippingAddress2, order.ShippingCity,
					order.ShippingStateProvince, order.ShippingStateProvinceID, order.ShippingZipPostalCode,
					order.ShippingCountry, order.ShippingCountryID,
					order.ShippingMethod, order.ShippingRateComputationMethodID, order.ShippedDate,
					order.Deleted, order.CreatedOn);
			}
			return order;
		}
예제 #52
0
        /// <summary>
        /// Gets all gift cards
        /// </summary>
        /// <param name="orderId">Order identifier; null to load all records</param>
        /// <param name="customerId">Customer identifier; null to load all records</param>
        /// <param name="startTime">Order start time; null to load all records</param>
        /// <param name="endTime">Order end time; null to load all records</param>
        /// <param name="os">Order status; null to load all records</param>
        /// <param name="ps">Order payment status; null to load all records</param>
        /// <param name="ss">Order shippment status; null to load all records</param>
        /// <param name="isGiftCardActivated">Value indicating whether gift card is activated; null to load all records</param>
        /// <param name="giftCardCouponCode">Gift card coupon code; null or string.empty to load all records</param>
        /// <returns>Gift cards</returns>
        public List<GiftCard> GetAllGiftCards(int? orderId,
            int? customerId, DateTime? startTime, DateTime? endTime,
            OrderStatusEnum? os, PaymentStatusEnum? ps, ShippingStatusEnum? ss,
            bool? isGiftCardActivated, string giftCardCouponCode)
        {
            int? orderStatusId = null;
            if (os.HasValue)
                orderStatusId = (int)os.Value;

            int? paymentStatusId = null;
            if (ps.HasValue)
                paymentStatusId = (int)ps.Value;

            int? shippingStatusId = null;
            if (ss.HasValue)
                shippingStatusId = (int)ss.Value;

            if (giftCardCouponCode != null)
                giftCardCouponCode = giftCardCouponCode.Trim();

            giftCardCouponCode = CommonHelper.EnsureNotNull(giftCardCouponCode);

            var gcQuery = from gc in _context.GiftCards
                          join opv in _context.OrderProductVariants on gc.PurchasedOrderProductVariantId equals opv.OrderProductVariantId
                          join o in _context.Orders on opv.OrderId equals o.OrderId
                          where
                          (!orderId.HasValue || orderId.Value == 0 || o.OrderId == orderId.Value) &&
                          (!customerId.HasValue || customerId.Value == 0 || o.CustomerId == customerId.Value) &&
                          (!startTime.HasValue || startTime.Value <= gc.CreatedOn) &&
                          (!endTime.HasValue || endTime.Value >= gc.CreatedOn) &&
                          (!orderStatusId.HasValue || orderStatusId.Value == 0 || o.OrderStatusId == orderStatusId.Value) &&
                          (!paymentStatusId.HasValue || paymentStatusId.Value == 0 || o.PaymentStatusId == paymentStatusId.Value) &&
                          (!shippingStatusId.HasValue || shippingStatusId.Value == 0 || o.ShippingStatusId == shippingStatusId.Value) &&
                          (!isGiftCardActivated.HasValue || gc.IsGiftCardActivated == isGiftCardActivated.Value) &&
                          (string.IsNullOrEmpty(giftCardCouponCode) || gc.GiftCardCouponCode == giftCardCouponCode)
                          select gc.GiftCardId;

            var query = from gc in _context.GiftCards
                        where gcQuery.Contains(gc.GiftCardId)
                        orderby gc.CreatedOn descending, gc.GiftCardId
                        select gc;

            var giftCards = query.ToList();
            return giftCards;
        }
예제 #53
0
		/// <summary>
		/// Get order product variant sales report
		/// </summary>
		/// <param name="StartTime">Order start time; null to load all</param>
		/// <param name="EndTime">Order end time; null to load all</param>
		/// <param name="OS">Order status; null to load all orders</param>
		/// <param name="PS">Order payment status; null to load all orders</param>
		/// <returns>Result</returns>
		public static IDataReader OrderProductVariantReport(DateTime? StartTime, DateTime? EndTime,
			OrderStatusEnum? OS, PaymentStatusEnum? PS)
		{
			int? orderStatusID = null;
			if (OS.HasValue)
				orderStatusID = (int)OS.Value;

			int? paymentStatusID = null;
			if (PS.HasValue)
				paymentStatusID = (int)PS.Value;

			return DBProviderManager<DBOrderProvider>.Provider.OrderProductVariantReport(StartTime, EndTime, orderStatusID, paymentStatusID);
		}
예제 #54
0
 /// <summary>
 /// Gets all order product variants
 /// </summary>
 /// <param name="orderId">Order identifier; null to load all records</param>
 /// <param name="customerId">Customer identifier; null to load all records</param>
 /// <param name="startTime">Order start time; null to load all records</param>
 /// <param name="endTime">Order end time; null to load all records</param>
 /// <param name="os">Order status; null to load all records</param>
 /// <param name="ps">Order payment status; null to load all records</param>
 /// <param name="ss">Order shippment status; null to load all records</param>
 /// <returns>Order collection</returns>
 public List<OrderProductVariant> GetAllOrderProductVariants(int? orderId,
     int? customerId, DateTime? startTime, DateTime? endTime,
     OrderStatusEnum? os, PaymentStatusEnum? ps, ShippingStatusEnum? ss)
 {
     return GetAllOrderProductVariants(orderId, customerId, startTime,
         endTime, os, ps, ss, false);
 }
예제 #55
0
		/// <summary>
		/// Updates the order
		/// </summary>
		/// <param name="OrderID">he order identifier</param>
		/// <param name="OrderGUID">The order identifier</param>
		/// <param name="CustomerID">The customer identifier</param>
		/// <param name="CustomerLanguageID">The customer language identifier</param>
		/// <param name="CustomerTaxDisplayType">The customer tax display type</param>
		/// <param name="OrderSubtotalInclTax">The order subtotal (incl tax)</param>
		/// <param name="OrderSubtotalExclTax">The order subtotal (excl tax)</param>
		/// <param name="OrderShippingInclTax">The order shipping (incl tax)</param>
		/// <param name="OrderShippingExclTax">The order shipping (excl tax)</param>
		/// <param name="PaymentMethodAdditionalFeeInclTax">The payment method additional fee (incl tax)</param>
		/// <param name="PaymentMethodAdditionalFeeExclTax">The payment method additional fee (excl tax)</param>
		/// <param name="OrderTax">The order tax</param>
		/// <param name="OrderTotal">The order total</param>
		/// <param name="OrderDiscount">The order discount</param>
		/// <param name="OrderSubtotalInclTaxInCustomerCurrency">The order subtotal incl tax (customer currency)</param>
		/// <param name="OrderSubtotalExclTaxInCustomerCurrency">The order subtotal excl tax (customer currency)</param>
		/// <param name="OrderShippingInclTaxInCustomerCurrency">The order shipping incl tax (customer currency)</param>
		/// <param name="OrderShippingExclTaxInCustomerCurrency">The order shipping excl tax (customer currency)</param>
		/// <param name="PaymentMethodAdditionalFeeInclTaxInCustomerCurrency">The payment method additional fee incl tax (customer currency)</param>
		/// <param name="PaymentMethodAdditionalFeeExclTaxInCustomerCurrency">The payment method additional fee excl tax (customer currency)</param>
		/// <param name="OrderTaxInCustomerCurrency">The order tax (customer currency)</param>
		/// <param name="OrderTotalInCustomerCurrency">The order total (customer currency)</param>
		/// <param name="CustomerCurrencyCode">The customer currency code</param>
		/// <param name="OrderWeight">The order weight</param>
		/// <param name="AffiliateID">The affiliate identifier</param>
		/// <param name="OrderStatus">The order status</param>
		/// <param name="AllowStoringCreditCardNumber">The value indicating whether storing of credit card number is allowed</param>
		/// <param name="CardType">The card type</param>
		/// <param name="CardName">The card name</param>
		/// <param name="CardNumber">The card number</param>
		/// <param name="MaskedCreditCardNumber">The masked credit card number</param>
		/// <param name="CardCVV2">The card CVV2</param>
		/// <param name="CardExpirationMonth">The card expiration month</param>
		/// <param name="CardExpirationYear">The card expiration year</param>
		/// <param name="PaymentMethodID">The payment method identifier</param>
		/// <param name="PaymentMethodName">The payment method name</param>
		/// <param name="AuthorizationTransactionID">The authorization transaction ID</param>
		/// <param name="AuthorizationTransactionCode">The authorization transaction code</param>
		/// <param name="AuthorizationTransactionResult">The authorization transaction result</param>
		/// <param name="CaptureTransactionID">The capture transaction ID</param>
		/// <param name="CaptureTransactionResult">The capture transaction result</param>
		/// <param name="PurchaseOrderNumber">The purchase order number</param>
		/// <param name="PaymentStatus">The payment status</param>
		/// <param name="BillingFirstName">The billing first name</param>
		/// <param name="BillingLastName">The billing last name</param>
		/// <param name="BillingPhoneNumber">he billing phone number</param>
		/// <param name="BillingEmail">The billing email</param>
		/// <param name="BillingFaxNumber">The billing fax number</param>
		/// <param name="BillingCompany">The billing company</param>
		/// <param name="BillingAddress1">The billing address 1</param>
		/// <param name="BillingAddress2">The billing address 2</param>
		/// <param name="BillingCity">The billing city</param>
		/// <param name="BillingStateProvince">The billing state/province</param>
		/// <param name="BillingStateProvinceID">The billing state/province identifier</param>
		/// <param name="BillingZipPostalCode">The billing zip/postal code</param>
		/// <param name="BillingCountry">The billing country</param>
		/// <param name="BillingCountryID">The billing country identifier</param>
		/// <param name="ShippingStatus">The shipping status</param>
		/// <param name="ShippingFirstName">The shipping first name</param>
		/// <param name="ShippingLastName">The shipping last name</param>
		/// <param name="ShippingPhoneNumber">The shipping phone number</param>
		/// <param name="ShippingEmail">The shipping email</param>
		/// <param name="ShippingFaxNumber">The shipping fax number</param>
		/// <param name="ShippingCompany">The shipping  company</param>
		/// <param name="ShippingAddress1">The shipping address 1</param>
		/// <param name="ShippingAddress2">The shipping address 2</param>
		/// <param name="ShippingCity">The shipping city</param>
		/// <param name="ShippingStateProvince">The shipping state/province</param>
		/// <param name="ShippingStateProvinceID">The shipping state/province identifier</param>
		/// <param name="ShippingZipPostalCode">The shipping zip/postal code</param>
		/// <param name="ShippingCountry">The shipping country</param>
		/// <param name="ShippingCountryID">The shipping country identifier</param>
		/// <param name="ShippingMethod">The shipping method</param>
		/// <param name="ShippingRateComputationMethodID">The shipping rate computation method identifier</param>
		/// <param name="ShippedDate">The shipped date and time</param>
		/// <param name="Deleted">A value indicating whether the entity has been deleted</param>
		/// <param name="CreatedOn">The date and time of order creation</param>
		/// <returns>Order</returns>
		public static Order UpdateOrder(int OrderID, Guid OrderGUID, int CustomerID, int CustomerLanguageID,
			TaxDisplayTypeEnum CustomerTaxDisplayType, decimal OrderSubtotalInclTax, decimal OrderSubtotalExclTax,
			decimal OrderShippingInclTax, decimal OrderShippingExclTax,
			decimal PaymentMethodAdditionalFeeInclTax, decimal PaymentMethodAdditionalFeeExclTax,
			decimal OrderTax, decimal OrderTotal, decimal OrderDiscount,
			decimal OrderSubtotalInclTaxInCustomerCurrency, decimal OrderSubtotalExclTaxInCustomerCurrency,
			decimal OrderShippingInclTaxInCustomerCurrency, decimal OrderShippingExclTaxInCustomerCurrency,
			decimal PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, decimal PaymentMethodAdditionalFeeExclTaxInCustomerCurrency,
			decimal OrderTaxInCustomerCurrency, decimal OrderTotalInCustomerCurrency,
			string CustomerCurrencyCode, decimal OrderWeight,
			int AffiliateID, OrderStatusEnum OrderStatus, bool AllowStoringCreditCardNumber,
			string CardType, string CardName, string CardNumber, string MaskedCreditCardNumber, string CardCVV2,
			string CardExpirationMonth, string CardExpirationYear, int PaymentMethodID,
			string PaymentMethodName, string AuthorizationTransactionID, string AuthorizationTransactionCode,
			string AuthorizationTransactionResult, string CaptureTransactionID, string CaptureTransactionResult,
			string PurchaseOrderNumber, PaymentStatusEnum PaymentStatus, string BillingFirstName, string BillingLastName,
			string BillingPhoneNumber, string BillingEmail, string BillingFaxNumber, string BillingCompany,
			string BillingAddress1, string BillingAddress2, string BillingCity, string BillingStateProvince,
			int BillingStateProvinceID, string BillingZipPostalCode, string BillingCountry,
			int BillingCountryID, ShippingStatusEnum ShippingStatus, string ShippingFirstName,
			string ShippingLastName, string ShippingPhoneNumber, string ShippingEmail,
			string ShippingFaxNumber, string ShippingCompany, string ShippingAddress1,
			string ShippingAddress2, string ShippingCity, string ShippingStateProvince,
			int ShippingStateProvinceID, string ShippingZipPostalCode,
			string ShippingCountry, int ShippingCountryID, string ShippingMethod, int ShippingRateComputationMethodID, DateTime? ShippedDate,
			bool Deleted, DateTime CreatedOn)
		{
			if (ShippedDate.HasValue)
				ShippedDate = DateTimeHelper.ConvertToUtcTime(ShippedDate.Value);
			CreatedOn = DateTimeHelper.ConvertToUtcTime(CreatedOn);

			DBOrder dbItem = DBProviderManager<DBOrderProvider>.Provider.UpdateOrder(OrderID, OrderGUID, CustomerID, CustomerLanguageID,
				(int)CustomerTaxDisplayType, OrderSubtotalInclTax, OrderSubtotalExclTax,
				OrderShippingInclTax, OrderShippingExclTax,
				PaymentMethodAdditionalFeeInclTax, PaymentMethodAdditionalFeeExclTax,
				OrderTax, OrderTotal, OrderDiscount,
				OrderSubtotalInclTaxInCustomerCurrency, OrderSubtotalExclTaxInCustomerCurrency,
				OrderShippingInclTaxInCustomerCurrency, OrderShippingExclTaxInCustomerCurrency,
				PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, PaymentMethodAdditionalFeeExclTaxInCustomerCurrency,
				OrderTaxInCustomerCurrency, OrderTotalInCustomerCurrency, CustomerCurrencyCode, OrderWeight,
				AffiliateID, (int)OrderStatus, AllowStoringCreditCardNumber,
				CardType, CardName, CardNumber, MaskedCreditCardNumber, CardCVV2,
				CardExpirationMonth, CardExpirationYear, PaymentMethodID,
				PaymentMethodName, AuthorizationTransactionID, AuthorizationTransactionCode,
				AuthorizationTransactionResult, CaptureTransactionID, CaptureTransactionResult, PurchaseOrderNumber,
				(int)PaymentStatus, BillingFirstName, BillingLastName,
				BillingPhoneNumber, BillingEmail, BillingFaxNumber, BillingCompany,
				BillingAddress1, BillingAddress2, BillingCity, BillingStateProvince, BillingStateProvinceID,
				BillingZipPostalCode, BillingCountry, BillingCountryID, (int)ShippingStatus, ShippingFirstName, ShippingLastName,
				ShippingPhoneNumber, ShippingEmail,
				ShippingFaxNumber, ShippingCompany, ShippingAddress1,
				ShippingAddress2, ShippingCity, ShippingStateProvince, ShippingStateProvinceID, ShippingZipPostalCode,
				ShippingCountry, ShippingCountryID, ShippingMethod, ShippingRateComputationMethodID, ShippedDate,
				Deleted, CreatedOn);

			Order order = DBMapping(dbItem);
			return order;
		}
예제 #56
0
        /// <summary>
        /// Gets all order product variants
        /// </summary>
        /// <param name="orderId">Order identifier; null to load all records</param>
        /// <param name="customerId">Customer identifier; null to load all records</param>
        /// <param name="startTime">Order start time; null to load all records</param>
        /// <param name="endTime">Order end time; null to load all records</param>
        /// <param name="os">Order status; null to load all records</param>
        /// <param name="ps">Order payment status; null to load all records</param>
        /// <param name="ss">Order shippment status; null to load all records</param>
        /// <param name="loadDownloableProductsOnly">Value indicating whether to load downloadable products only</param>
        /// <returns>Order collection</returns>
        public List<OrderProductVariant> GetAllOrderProductVariants(int? orderId,
            int? customerId, DateTime? startTime, DateTime? endTime,
            OrderStatusEnum? os, PaymentStatusEnum? ps, ShippingStatusEnum? ss,
            bool loadDownloableProductsOnly)
        {
            int? orderStatusId = null;
            if (os.HasValue)
                orderStatusId = (int)os.Value;

            int? paymentStatusId = null;
            if (ps.HasValue)
                paymentStatusId = (int)ps.Value;

            int? shippingStatusId = null;
            if (ss.HasValue)
                shippingStatusId = (int)ss.Value;

            var query = from opv in _context.OrderProductVariants
                        join o in _context.Orders on opv.OrderId equals o.OrderId
                        join pv in _context.ProductVariants on opv.ProductVariantId equals pv.ProductVariantId
                        where (!orderId.HasValue || orderId.Value == 0 || orderId == o.OrderId) &&
                        (!customerId.HasValue || customerId.Value == 0 || customerId == o.CustomerId) &&
                        (!startTime.HasValue || startTime.Value <= o.CreatedOn) &&
                        (!endTime.HasValue || endTime.Value >= o.CreatedOn) &&
                        (!orderStatusId.HasValue || orderStatusId == o.OrderStatusId) &&
                        (!paymentStatusId.HasValue || paymentStatusId.Value == o.PaymentStatusId) &&
                        (!shippingStatusId.HasValue || shippingStatusId.Value == o.ShippingStatusId) &&
                        (!loadDownloableProductsOnly || pv.IsDownload) &&
                        !o.Deleted
                        orderby o.CreatedOn descending, opv.OrderProductVariantId
                        select opv;

            var orderProductVariants = query.ToList();
            return orderProductVariants;
        }
예제 #57
0
        /// <summary>
        /// Get order average report
        /// </summary>
        /// <param name="os">Order status;</param>
        /// <param name="startTime">Start date</param>
        /// <param name="endTime">End date</param>
        /// <returns>Result</returns>
        public OrderAverageReportLine GetOrderAverageReportLine(OrderStatusEnum os,
            DateTime? startTime, DateTime? endTime)
        {
            int orderStatusId = (int)os;

            var query = from o in _context.Orders
                        where (!o.Deleted) &&
                        (o.OrderStatusId == orderStatusId) &&
                        (!startTime.HasValue || startTime.Value <= o.CreatedOn) &&
                        (!endTime.HasValue || endTime.Value >= o.CreatedOn)
                        select o;

            var item = new OrderAverageReportLine();
            item.SumOrders = Convert.ToDecimal(query.Sum(o => (decimal?)o.OrderTotal));
            item.CountOrders = query.Count();
            return item;
        }
예제 #58
0
        /// <summary>
        /// Gets an order report
        /// </summary>
        /// <param name="os">Order status; null to load all orders</param>
        /// <param name="ps">Order payment status; null to load all orders</param>
        /// <param name="ss">Order shippment status; null to load all orders</param>
        /// <returns>IdataReader</returns>
        public OrderIncompleteReportLine GetOrderReport(OrderStatusEnum? os,
            PaymentStatusEnum? ps, ShippingStatusEnum? ss)
        {
            int? orderStatusId = null;
            if (os.HasValue)
                orderStatusId = (int)os.Value;

            int? paymentStatusId = null;
            if (ps.HasValue)
                paymentStatusId = (int)ps.Value;

            int? shippingStatusId = null;
            if (ss.HasValue)
                shippingStatusId = (int)ss.Value;

            var query = from o in _context.Orders
                        where (!o.Deleted) &&
                        (!orderStatusId.HasValue || orderStatusId.Value == 0 || o.OrderStatusId == orderStatusId.Value) &&
                        (!paymentStatusId.HasValue || paymentStatusId.Value == 0 || o.PaymentStatusId == paymentStatusId.Value) &&
                        (!shippingStatusId.HasValue || shippingStatusId.Value == 0 || o.ShippingStatusId == shippingStatusId.Value)
                        select o;

            var item = new OrderIncompleteReportLine();
            item.Total = Convert.ToDecimal(query.Sum(o => (decimal?)o.OrderTotal));
            item.Count = query.Count();
            return item;
        }
예제 #59
0
        /// <summary>
        /// Gets an order report
        /// </summary>
        /// <param name="os">Order status; null to load all orders</param>
        /// <param name="ps">Order payment status; null to load all orders</param>
        /// <param name="ss">Order shippment status; null to load all orders</param>
        /// <returns>IdataReader</returns>
        public static OrderIncompleteReportLine GetOrderReport(OrderStatusEnum? os, 
            PaymentStatusEnum? ps, ShippingStatusEnum? ss)
        {
            int? orderStatusId = null;
            if (os.HasValue)
                orderStatusId = (int)os.Value;

            int? paymentStatusId = null;
            if (ps.HasValue)
                paymentStatusId = (int)ps.Value;

            int? shippmentStatusId = null;
            if (ss.HasValue)
                shippmentStatusId = (int)ss.Value;

            var context = ObjectContextHelper.CurrentObjectContext;
            var item = context.Sp_OrderIncompleteReport(orderStatusId, paymentStatusId, shippmentStatusId);
            return item;
        }
 /// <summary>
 /// Sets the OrderStatus property
 /// </summary>
 /// <param name="orderStatus">OrderStatus property</param>
 /// <returns>this instance</returns>
 public Order WithOrderStatus(OrderStatusEnum orderStatus)
 {
     this.orderStatusField = orderStatus;
     return this;
 }