Exemplo n.º 1
0
        public void Process(Core.IUnitOfWork db,
                            DTO.OrderToTrackDTO shipping,
                            string status,
                            DateTime?statusDate,
                            IList <TrackingRecord> records,
                            DateTime when)
        {
            if (IsAccept(shipping, status, statusDate, records))
            {
                var order = db.ItemOrderMappings.GetOrderWithItems(null, shipping.OrderNumber, unmaskReferenceStyle: false, includeSourceItems: false);

                var isExist = db.OrderEmailNotifies.IsExist(order.OrderId,
                                                            OrderEmailNotifyType.OutputUndeliveredAsAddressedEmail);

                if (!isExist)
                {
                    db.OrderComments.Add(new OrderComment()
                    {
                        OrderId    = order.Id,
                        Message    = "Order being returned. Undelivered As Addressed email sent to customer",
                        Type       = (int)CommentType.ReturnExchange,
                        CreateDate = _time.GetAppNowTime(),
                        UpdateDate = _time.GetAppNowTime()
                    });

                    var emailInfo = new UndeliverableAsAddressedRequestEmailInfo(_emailService.AddressService,
                                                                                 null,
                                                                                 order.OrderId,
                                                                                 (MarketType)order.Market,
                                                                                 order.Items,
                                                                                 shipping.Carrier,
                                                                                 shipping.TrackingNumber,
                                                                                 order.BuyerName,
                                                                                 order.BuyerEmail);

                    _emailService.SendEmail(emailInfo, CallSource.Service);

                    db.OrderEmailNotifies.Add(new OrderEmailNotify()
                    {
                        Type        = (int)OrderEmailNotifyType.OutputUndeliveredAsAddressedEmail,
                        OrderNumber = shipping.OrderNumber,
                        CreateDate  = when,
                    });

                    db.Commit();
                }
            }
        }
Exemplo n.º 2
0
        public void Process(Core.IUnitOfWork db,
                            DTO.OrderToTrackDTO shipping,
                            string status,
                            DateTime?statusDate,
                            IList <TrackingRecord> records,
                            DateTime when)
        {
            /*
             * NO AUTHORIZED RECIPIENT AVAILABLE
             *  Notice Left
             *  Notice Left (No Authorized Recipient Available)
             *  Notice Left (No Secure Location Available)
             *  Notice Left (Receptacle Full/Item Oversized)
             */
            /*
             * Please send message similar to Notice Left to orders with status “Available for pickup”.
             *  Like 115-0119209-8758666
             */
            var labelType  = shipping.MailInfoId.HasValue ? LabelFromType.Mail : LabelFromType.Batch;
            var shippingId = shipping.MailInfoId.HasValue ? shipping.MailInfoId.Value : shipping.ShipmentInfoId.Value;

            if (IsAccept(shipping, status, statusDate, records))
            {
                if (!db.OrderEmailNotifies.IsExist(shipping.OrderNumber, OrderEmailNotifyType.OutputNoticeLeft))
                {
                    _log.Info(String.Format("Order: {0}, has status: {1}",
                                            shipping.OrderNumber,
                                            status));

                    var sendEmailActionId = _actionService.AddAction(db,
                                                                     SystemActionType.SendEmail,
                                                                     shipping.OrderNumber,
                                                                     new SendEmailInput()
                    {
                        EmailType = EmailTypes.NoticeLeft,
                        OrderId   = shipping.OrderNumber,
                        Args      = new Dictionary <string, string>()
                        {
                            { "LabelType", labelType.ToString() },
                            { "ShippingOrderId", shippingId.ToString() }
                        }
                    },
                                                                     null,
                                                                     null);

                    _actionService.AddAction(db,
                                             SystemActionType.AddComment,
                                             shipping.OrderNumber,
                                             new AddCommentInput()
                    {
                        OrderId = shipping.OrderId,
                        Message = "[System] Notice Left email sent",
                        Type    = (int)CommentType.OutputEmail,
                    },
                                             sendEmailActionId,
                                             null);


                    db.OrderEmailNotifies.Add(new OrderEmailNotify()
                    {
                        Type        = (int)OrderEmailNotifyType.OutputNoticeLeft,
                        OrderNumber = shipping.OrderNumber,
                        CreateDate  = when,
                    });
                    db.Commit();
                }
                else
                {
                    _log.Info("Notice left already sent");
                }
            }
        }