Пример #1
0
        public AskvilleStatus Askville(int?customerMarketPlaceId, string merchantId, string marketplaceId,
                                       string askvilleGuid = "")
        {
            MP_CustomerMarketPlace marketplace = _customerMarketPlaceRepository.GetAll().FirstOrDefault(x => x.Id == customerMarketPlaceId);

            if (marketplace == null)
            {
                throw new Exception(string.Format("Marketplace {0} does not found", customerMarketPlaceId));
            }

            var securityInfo = (AmazonSecurityInfo)marketplace.GetRetrieveDataHelper().RetrieveCustomerSecurityInfo(marketplace.Id);

            merchantId    = merchantId ?? securityInfo.MerchantId;
            marketplaceId = marketplaceId ?? securityInfo.MarketplaceId[0];

            var guid = askvilleGuid == "" ? Guid.NewGuid().ToString() : askvilleGuid;

            var acceptUrl = Url.Action("ActivateStore", "Home", new { Area = "", id = guid, approve = true.ToString().ToLower() },
                                       "https");
            var disAcceptUrl = Url.Action("ActivateStore", "Home",
                                          new { Area = "", id = guid, approve = false.ToString().ToLower() }, "https");

            string origin = marketplace.Customer.CustomerOrigin.Name;
            string phone  = marketplace.Customer.CustomerOrigin.PhoneNumber;

            var message = @"
            Confirm your store on Amazon.

            Your Amazon shop has been added on" + origin + @".
            To confirm store please <a href=""" + acceptUrl + @""">click here</a>" + Environment.NewLine
                          + @"If you have not added the store on " + origin + @" please <a href=""" + disAcceptUrl + @""">click here </a>" + Environment.NewLine
                          + @"

            Thank you!

            Kindest regards," + Environment.NewLine +
                          origin + @"team,
            www." + origin + @".com
            customercare@" + origin + @".com" + Environment.NewLine + phone;

            var sendingStatus = _askvilleService.AskQuestion(merchantId, marketplaceId, 31, message);
            var askville      = askvilleGuid == ""
                                               ? (new Askville
            {
                Guid = guid,
                IsPassed = false,
                MarketPlace = marketplace,
                SendStatus = sendingStatus,
                MessageBody = message,
                CreationDate = DateTime.UtcNow
            })
                                               : _askvilleRepository.GetAskvilleByGuid(askvilleGuid);

            askville.Status = askvilleGuid == "" ? AskvilleStatus.NotPerformed : AskvilleStatus.ReCheck;
            _askvilleRepository.SaveOrUpdate(askville);
            Utils.WriteLog("Send askville message", sendingStatus.ToString(), ExperianServiceType.Askville,
                           marketplace.Customer.Id);
            return(askville.Status);
        }
Пример #2
0
        }         // constructor

        public MarketPlaceModel Create(MP_CustomerMarketPlace mp, DateTime?history)
        {
            string      lastChecked         = "";
            string      updatingStatus      = "";
            string      updatingError       = "";
            string      age                 = "";
            string      url                 = "";
            DateTime?   lastTransactionDate = null;
            TimeCounter tc = new TimeCounter("MarketplaceModelBuilder building time for mp " + mp.Id);

            using (tc.AddStep("lastChecked Time taken")) {
                lastChecked = mp.UpdatingEnd.HasValue
                                        ? FormattingUtils.FormatDateToString(mp.UpdatingEnd.Value)
                                        : "never/in progress";
            }
            using (tc.AddStep("GetUpdatingStatus Time taken")) {
                updatingStatus = mp.GetUpdatingStatus(history);
            }
            using (tc.AddStep("GetUpdatingError Time taken")) {
                updatingError = mp.GetUpdatingError(history);
            }
            using (tc.AddStep("GetAccountAge Time taken")) {
                DateTime?originationDate;
                age = GetAccountAge(mp, out originationDate);
            }
            using (tc.AddStep("GetUrl Time taken")) {
                url = GetUrl(mp, mp.GetRetrieveDataHelper()
                             .RetrieveCustomerSecurityInfo(mp.Id));
            }
            using (tc.AddStep("GetLastTransactionDate Time taken")) {
                lastTransactionDate = GetLastTransactionDate(mp);
            }

            var model = new MarketPlaceModel {
                Id                  = mp.Id,
                Type                = mp.DisplayName,
                Name                = mp.Marketplace.Name,
                LastChecked         = lastChecked,
                UpdatingStatus      = updatingStatus,
                UpdateError         = updatingError,
                AccountAge          = age,
                PositiveFeedbacks   = 0,
                NegativeFeedbacks   = 0,
                NeutralFeedbacks    = 0,
                RaitingPercent      = 0,
                SellerInfoStoreURL  = url,
                IsPaymentAccount    = mp.Marketplace.IsPaymentAccount,
                UWPriority          = mp.Marketplace.UWPriority,
                Disabled            = mp.Disabled,
                IsNew               = mp.IsNew,
                IsHistory           = history.HasValue,
                History             = history,
                LastTransactionDate = lastTransactionDate,
            };
            List <IAnalysisDataParameterInfo> aggregations = new List <IAnalysisDataParameterInfo>();

            using (tc.AddStep("SetAggregationData Time taken")) {
                aggregations = mp.Marketplace.GetAggregations(mp, history).ToList();
                SetAggregationData(model, aggregations);
            }

            using (tc.AddStep("monthSales Time taken")) {
                var monthSales = aggregations.FirstOrDefault(x =>
                                                             x.TimePeriod.TimePeriodType == TimePeriodEnum.Month &&
                                                             x.ParameterName == AggregationFunction.Turnover.ToString()
                                                             );
                model.MonthSales = monthSales == null ? 0 : (decimal)monthSales.Value;
            }
            using (tc.AddStep("yearSales Time taken")) {
                var yearSales = aggregations.FirstOrDefault(x =>
                                                            x.TimePeriod.TimePeriodType == TimePeriodEnum.Year &&
                                                            x.ParameterName == AggregationFunction.Turnover.ToString()
                                                            );
                model.AnnualSales = yearSales == null ? 0 : (decimal)yearSales.Value;
            }

            using (tc.AddStep("InitializeSpecificData Time taken")) {
                InitializeSpecificData(mp, model, history);
            }
            using (tc.AddStep("GetFeedbackData Time taken")) {
                var feedbacks = GetFeedbackData(aggregations);
                model.RaitingPercent    = feedbacks.RaitingPercent;
                model.PositiveFeedbacks = feedbacks.PositiveFeedbacks;
                model.NegativeFeedbacks = feedbacks.NegativeFeedbacks;
                model.NeutralFeedbacks  = feedbacks.NeutralFeedbacks;
                model.AmazonSelerRating = feedbacks.AmazonSelerRating;
            }

            using (tc.AddStep("GetPaymentAccountModel Time taken")) {
                if (model.IsPaymentAccount)
                {
                    var paymentModel = GetPaymentAccountModel(mp, history, aggregations);
                    model.TotalNetInPayments  = paymentModel.TotalNetInPayments;
                    model.TotalNetOutPayments = paymentModel.TotalNetOutPayments;
                    model.TransactionsNumber  = paymentModel.TransactionsNumber;
                    model.MonthInPayments     = paymentModel.MonthInPayments;
                }                 // if
            }

            Log.Info(tc.ToString());
            return(model);
        }         // Create
Пример #3
0
        }         // Create

        public MarketPlaceDataModel CreateLightModel(MP_CustomerMarketPlace mp, DateTime?history)
        {
            var lastChecked = mp.UpdatingEnd.HasValue
                                ? FormattingUtils.FormatDateToString(mp.UpdatingEnd.Value)
                                : "never/in progress";
            var      updatingStatus = mp.GetUpdatingStatus(history);
            var      updatingError  = mp.GetUpdatingError(history);
            DateTime?originationDate;
            var      age = GetAccountAge(mp, out originationDate);
            var      url = GetUrl(mp, mp.GetRetrieveDataHelper().RetrieveCustomerSecurityInfo(mp.Id));
            var      lastTransactionDate = GetLastTransactionDate(mp);

            var model = new MarketPlaceDataModel {
                Id                  = mp.Id,
                Type                = mp.DisplayName,
                Name                = mp.Marketplace.Name,
                LastChecked         = lastChecked,
                UpdatingStatus      = updatingStatus,
                UpdateError         = updatingError,
                AccountAge          = age,
                RaitingPercent      = 0,
                SellerInfoStoreURL  = url,
                IsPaymentAccount    = mp.Marketplace.IsPaymentAccount,
                UWPriority          = mp.Marketplace.UWPriority,
                Disabled            = mp.Disabled,
                IsNew               = mp.IsNew,
                IsHistory           = history.HasValue,
                History             = history,
                LastTransactionDate = lastTransactionDate,
                OriginationDate     = originationDate
            };

            var aggregations = mp.Marketplace.GetAggregations(mp, history).ToList();

            model.TurnoverTrend =
                ThisLibrary.Instance.DB.Fill <TurnoverTrend>(
                    "LoadActiveMarketplaceTurnovers",
                    CommandSpecies.StoredProcedure,
                    new QueryParameter("MpID", mp.Id)
                    )
                .OrderByDescending(x => x.TheMonth)
                .Take(12)
                .ToList();

            var monthSales = aggregations.FirstOrDefault(x =>
                                                         x.TimePeriod.TimePeriodType == TimePeriodEnum.Month &&
                                                         x.ParameterName == AggregationFunction.Turnover.ToString()
                                                         );

            model.MonthSales = monthSales == null ? 0 : (decimal)monthSales.Value;

            var yearSales = aggregations.FirstOrDefault(x =>
                                                        x.TimePeriod.TimePeriodType == TimePeriodEnum.Year &&
                                                        x.ParameterName == AggregationFunction.Turnover.ToString()
                                                        );

            model.AnnualSales = yearSales == null ? 0 : (decimal)yearSales.Value;

            var feedbacks = GetFeedbackData(aggregations);

            model.RaitingPercent = feedbacks.RaitingPercent;

            if (model.IsPaymentAccount)
            {
                var paymentModel = GetPaymentAccountModel(mp, history, aggregations);
                model.TotalNetInPayments  = paymentModel.TotalNetInPayments;
                model.TotalNetOutPayments = paymentModel.TotalNetOutPayments;
                model.MonthInPayments     = paymentModel.MonthInPayments;
                model.TransactionsNumber  = paymentModel.TransactionsNumber;
            }             // if

            return(model);
        }         // CreateLightModel