示例#1
0
        public ServiceResult <bool> OnekeyReadMessage()
        {
            bool result = false;

            try
            {
                new ArticleComponent().OnekeyRead(this.GetUser().Id);
                result = MessagesComponent.OnekeyReadMessage(this.GetUser().Id);
            }
            catch (Exception ex)
            {
                _log.Error(string.Format("OnekeyReadMessage:{0}", ex));
            }
            return(new ServiceResult <bool>
            {
                Data = result
            });
        }
示例#2
0
        public ServiceResult <bool> DeleteMessage(DeleteMessageIM model)
        {
            bool result = false;

            try
            {
                result = MessagesComponent.DeleteMessage(model.Id, this.GetUser().Id);
            }
            catch (Exception ex)
            {
                _log.Error(string.Format("DeleteMessage:{0}", ex));
            }

            return(new ServiceResult <bool>
            {
                Data = result
            });
        }
        public void MerchantLv2Verified(long id)
        {
            var record = new VerifyRecordDAC().GetById(id);

            var    regId       = RedisHelper.StringGet($"{FiiiPOS_APP_Notice_MerchantId}:{record.AccountId}");
            var    lang        = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"{FiiiPOS_APP_Language_MerchantId}:{record.AccountId}") ?? "en";
            var    titleKey    = "MerchantLv2Verified";
            var    subTitleKey = "MerchantLv2VerifiedSubTitle";
            var    title       = ResourceHelper.FiiiPos.GetResource(titleKey, lang);
            var    subTitle    = ResourceHelper.FiiiPos.GetResource(subTitleKey, lang);
            string noticeId    = "";

            MessagesComponent.AddMessage(record.AccountId, UserType.Merchant, record.Id.ToString(), FiiiPayPushType.TYPE_Merchant_KYC_LV2_VERIFIED, titleKey, subTitleKey, null, title, subTitle, out noticeId);

            RegPush(FiiiPayPushType.TYPE_Merchant_KYC_LV2_VERIFIED, new List <string> {
                regId
            }, id, title, subTitle, Guid.NewGuid().ToString());
            LogHelper.Info($"--------{lang}------{title}----------{subTitle}");
        }
        public PricingModel(Money listPrice, Money sellPrice, MessagesComponent messagesComponent) : this()
        {
            ListPrice = listPrice;
            SellPrice = sellPrice;

            var listPriceMessages = messagesComponent.GetListPriceMessages().Select(m => m.Text);

            if (listPriceMessages != null)
            {
                ListPriceMessages.AddRange(listPriceMessages);
            }

            var sellPriceMessages = messagesComponent.GetSellPriceMessages().Select(m => m.Text);

            if (sellPriceMessages != null)
            {
                SellPriceMessages.AddRange(sellPriceMessages);
            }
        }
示例#5
0
        public GetFirstTitleAndNotReadCountOM GetFirstTitleAndNotReadCount(ArticleAccountType articleAccountType, Guid AccountId, bool isZH)
        {
            string GetDefault(string key)
            {
                return(Resources.ResourceManager.GetString(key, new System.Globalization.CultureInfo(isZH ? "zh" : "en")));
            }

            var tuple = new ArticleDAC().GetFirstTitleAndNotReadCount(articleAccountType, AccountId);

            var model = tuple.Item1;

            return(new GetFirstTitleAndNotReadCountOM
            {
                SysCount = tuple.Item2,
                Title = model == null ? null : model.Type == SystemMessageESType.Article ? model.Title : GetDefault(VerifyTypeList[int.Parse(model.Attach)]),
                Timestamp = model?.CreateTime.ToUnixTime().ToString(),
                Count = MessagesComponent.GetMessagesCountByStatus(AccountId, UserType.Merchant, MessageStatus.Normal)
            });
        }
        public void PushInviteSuccess(long id)
        {
            var pfDAC     = new ProfitDetailDAC();
            var accountId = pfDAC.GetAccountId(id);

            var    regId       = RedisHelper.StringGet($"{FiiiPOS_APP_Notice_MerchantId}:{accountId}");
            var    lang        = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"{FiiiPOS_APP_Language_MerchantId}:{accountId}") ?? "en";
            string titleKey    = "奖励FIII";
            string subTitleKey = "奖励子标题";
            var    title       = ResourceHelper.FiiiPos.GetResource(titleKey, new CultureInfo(lang));
            var    subTitle    = ResourceHelper.FiiiPos.GetResource(subTitleKey, new CultureInfo(lang));

            string noticeId = "";

            MessagesComponent.AddMessage(accountId, UserType.User, id.ToString(), FiiiPayPushType.TYPE_INVITE_REWARD, titleKey, subTitleKey, "FIII", title, subTitle, out noticeId);

            RegPush(FiiiPayPushType.TYPE_INVITE_REWARD, new List <string> {
                regId
            }, id, title, subTitle, noticeId);
            LogHelper.Info($"--------{lang}------{title}----------{subTitle}");
        }
        public void FiiipayMerchantProfileVerified(FiiiPayMerchantProfileVerified profileMessage)
        {
            var    regId = RedisHelper.StringGet($"FiiiPay:Notice:UserId:{profileMessage.AccountId}");
            var    lang = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"FiiiPay:Language:{profileMessage.AccountId}") ?? "en";
            string titleKey = "", subTitleKey = "";
            int    pushType;

            if (profileMessage.VerifyResult == Entities.Enums.VerifyStatus.Certified)
            {
                titleKey    = "FiiipayMerchantCertifiedTitle";
                subTitleKey = "FiiipayMerchantCertifiedSubTitle";
                pushType    = FiiiPayPushType.FIIIPAY_MERCHANT_VERIFIED;
            }
            else if (profileMessage.VerifyResult == Entities.Enums.VerifyStatus.Disapproval)
            {
                titleKey    = "FiiipayMerchantDisapprovalTitle";
                subTitleKey = "FiiipayMerchantDisapprovalSubTitle";
                pushType    = FiiiPayPushType.FIIIPAY_MERCHANT_DISAPPROVED;
            }
            else
            {
                return;
            }
            if (!(_resourcePropertyNames.Contains(titleKey) && _resourcePropertyNames.Contains(subTitleKey)))
            {
                throw new Exception($"没有找到资源:{titleKey},{subTitleKey}");
            }
            var content  = ResourceHelper.FiiiPay.GetFormatResource(titleKey, lang);
            var subTitle = ResourceHelper.FiiiPay.GetFormatResource(subTitleKey, lang);

            string noticeId = "";

            LogHelper.Info($"--------{lang}------{content}----------{subTitle}");

            MessagesComponent.AddMessage(profileMessage.AccountId, UserType.User, profileMessage.VerifyRecordId.ToString(), pushType, titleKey, subTitleKey, null, content, subTitle, out noticeId);

            RegPush(pushType, new List <string> {
                regId
            }, profileMessage.VerifyRecordId, content, subTitle, noticeId);
        }
        public void PushTransferToEx(long id)
        {
            var order  = new MerchantExTransferOrderDAC().GetById(id);
            var crypto = new CryptocurrencyDAC().GetById(order.CryptoId);

            var regId       = RedisHelper.StringGet($"{FiiiPOS_APP_Notice_MerchantId}:{order.AccountId}");
            var lang        = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"{FiiiPOS_APP_Language_MerchantId}:{order.AccountId}") ?? "en";
            var titleKey    = "TransferToFiiiExTitle";
            var subTitleKey = "TransferToFiiiExSubTitle";
            var title       = ResourceHelper.FiiiPos.GetFormatResource(titleKey, lang, crypto.Code);
            var subTitle    = ResourceHelper.FiiiPos.GetFormatResource(subTitleKey, lang, crypto.Code);

            string noticeId = "";

            //写MongoDB []
            MessagesComponent.AddMessage(order.AccountId, UserType.Merchant, id.ToString(), FiiiPayPushType.TYPE_TRANSFER_TO_EX, titleKey, subTitleKey, crypto.Code, title, subTitle, out noticeId);

            RegPush(FiiiPayPushType.TYPE_TRANSFER_TO_EX, new List <string> {
                regId
            }, id, title, subTitle, noticeId);
            LogHelper.Info($"--------{lang}------{title}----------{subTitle}");
        }
        public void PushDepositCancel(long id)
        {
            var deposit = new MerchantDepositDAC().GetById(id);
            var wallet  = new MerchantWalletDAC().GetById(deposit.MerchantWalletId);
            var crypto  = new CryptocurrencyDAC().GetById(wallet.CryptoId);

            var regId       = RedisHelper.StringGet($"{FiiiPOS_APP_Notice_MerchantId}:{deposit.MerchantAccountId}");
            var lang        = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"{FiiiPOS_APP_Language_MerchantId}:{deposit.MerchantAccountId}") ?? "en";
            var titleKey    = "DepositCancelTitle";
            var subTitleKey = "DepositCancelSubTitle";
            var title       = ResourceHelper.FiiiPos.GetFormatResource(titleKey, lang, crypto.Code);
            var subTitle    = ResourceHelper.FiiiPos.GetFormatResource(subTitleKey, lang, crypto.Code);

            string noticeId = "";

            //写MongoDB [充币失败]
            MessagesComponent.AddMessage(deposit.MerchantAccountId, UserType.Merchant, id.ToString(), FiiiPayPushType.TYPE_DEPOSIT_CANCEL, titleKey, subTitleKey, crypto.Code, title, subTitle, out noticeId);

            RegPush(FiiiPayPushType.TYPE_DEPOSIT_CANCEL, new List <string> {
                regId
            }, id, title, subTitle, noticeId);
            LogHelper.Info($"--------{lang}------{title}----------{subTitle}");
        }
示例#10
0
        public void PushRefundOrder(string orderno)
        {
            var order = new OrderDAC().GetByOrderNo(orderno);
            var coin  = new CryptocurrencyDAC().GetById(order.CryptoId);

            var regId       = RedisHelper.StringGet($"{FiiiPOS_APP_Notice_MerchantId}:{order.MerchantAccountId}");
            var lang        = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"{FiiiPOS_APP_Language_MerchantId}:{order.MerchantAccountId}") ?? "en";
            var titleKey    = "BackOfficeRefundOrderTitle";
            var subTitleKey = "BackOfficeRefundOrderSubTitle";
            var content     = ResourceHelper.FiiiPos.GetFormatResource(titleKey, lang, coin.Code);
            var subTitle    = ResourceHelper.FiiiPos.GetFormatResource(subTitleKey, lang, coin.Code);

            string noticeId = "";

            //写MongoDB [提币成功]
            MessagesComponent.AddMessage(order.MerchantAccountId, UserType.Merchant, order.Id.ToString(), FiiiPayPushType.TYPE_REFUND_ORDER, titleKey, subTitleKey, coin.Code, content, subTitle, out noticeId);

            RegPush(FiiiPayPushType.TYPE_REFUND_ORDER, new List <string> {
                regId
            }, order.Id, content, subTitle, noticeId);

            LogHelper.Info($"--------{lang}------{content}----------{subTitle}");
        }
示例#11
0
        public void PushWithdrawReject(long id)
        {
            var withdraw = new MerchantWithdrawalDAC().GetById(id);
            var wallet   = new MerchantWalletDAC().GetById(withdraw.MerchantWalletId);
            var crypto   = new CryptocurrencyDAC().GetById(wallet.CryptoId);

            var regId       = RedisHelper.StringGet($"{FiiiPOS_APP_Notice_MerchantId}:{withdraw.MerchantAccountId}");
            var lang        = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"{FiiiPOS_APP_Language_MerchantId}:{withdraw.MerchantAccountId}") ?? "en";
            var titleKey    = "WithdrawalRejectTitle";
            var subTitleKey = "WithdrawalRejectSubTitle";
            var title       = ResourceHelper.FiiiPos.GetFormatResource(titleKey, lang, crypto.Code);
            var subTitle    = ResourceHelper.FiiiPos.GetResource(subTitleKey, lang);

            string noticeId = "";

            //写MongoDB [提币失败]
            MessagesComponent.AddMessage(withdraw.MerchantAccountId, UserType.Merchant, id.ToString(), FiiiPayPushType.TYPE_WITHDRAWAL_Reject, titleKey, subTitleKey, crypto.Code, title, subTitle, out noticeId);

            RegPush(FiiiPayPushType.TYPE_WITHDRAWAL_Reject, new List <string> {
                regId
            }, id, title, subTitle, noticeId);
            LogHelper.Info($"--------{lang}------{title}----------{subTitle}");
        }
示例#12
0
        private void PushStoreOrderIncome(StoreOrderMessage order)
        {
            var regId       = RedisHelper.StringGet($"FiiiPay:Notice:UserId:{order.MerchantInfoId}");
            var lang        = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"FiiiPay:Language:{order.MerchantInfoId}") ?? "en";
            var titleKey    = "StoreOrderIncomeTitle";
            var subTitleKey = "StoreOrderIncomeSubTitle";

            if (!(_resourcePropertyNames.Contains(titleKey) && _resourcePropertyNames.Contains(subTitleKey)))
            {
                throw new Exception("没有找到资源");
            }
            var content  = ResourceHelper.FiiiPay.GetFormatResource(titleKey, lang, order.CryptoCode);
            var subTitle = ResourceHelper.FiiiPay.GetFormatResource(subTitleKey, lang, order.CryptoCode);

            string noticeId = "";

            LogHelper.Info($"--------{lang}------{content}----------{subTitle}");

            MessagesComponent.AddMessage(order.MerchantInfoId, UserType.User, order.Id.ToString(), FiiiPayPushType.TYPE_STOREORDER_INCOME, titleKey, subTitleKey, order.CryptoCode, content, subTitle, out noticeId);

            RegPush(FiiiPayPushType.TYPE_STOREORDER_INCOME, new List <string> {
                regId
            }, order.Id, content, subTitle, noticeId);
        }
示例#13
0
        public ServiceResult <MessageListOM> GetMessageList(MessageListIM model)
        {
            model.MaxType = 27;//旧版本可显示27或之前的类型
            if (model.PageSize > 20)
            {
                model.PageSize = 20;
            }
            var outPutList = new List <MessageListOMItem>();

            try
            {
                var isZH = this.IsZH();

                var list = MessagesComponent.GetMessagesByPage(this.GetUser().Id, UserType.User, model.PageIndex, model.PageSize);

                if (list != null && list.Count > 0)
                {
                    list.RemoveAll(t => t.MsgType > model.MaxType);
                }

                foreach (var entity in list)
                {
                    var lang = isZH ? "zh" : "en";
                    if (entity.Title == "奖励FIII")
                    {
                        entity.Title = "BonusFIII";
                    }

                    if (entity.SubTitleKey == "奖励子标题")
                    {
                        entity.SubTitleKey = "BonusSubTitle";
                    }
                    string content  = ResourceHelper.FiiiPay.GetFormatResource(entity.TitleKey, lang, entity.CoinCode);
                    string subTitle = ResourceHelper.FiiiPay.GetFormatResource(entity.SubTitleKey, lang, entity.CoinCode);

                    var outPutModel = new MessageListOMItem
                    {
                        NoticeId  = entity._id.ToString(),
                        Type      = entity.MsgType,
                        QueryId   = entity.QueryId,
                        Title     = content,
                        SubTitle  = subTitle,
                        Timestamp = entity.CreateTime.ToUnixTime(),
                        Status    = entity.Status
                    };
                    outPutList.Add(outPutModel);
                }
            }
            catch (Exception ex)
            {
                _log.Error(string.Format("GetMessageList:{0}", ex));
            }

            return(new ServiceResult <MessageListOM>
            {
                Data = new MessageListOM
                {
                    List = outPutList
                }
            });
        }
示例#14
0
 public bool DeleteMessage(string id, Guid merchantAccountId)
 {
     return(MessagesComponent.DeleteMessage(id, merchantAccountId));
 }
示例#15
0
 public bool ReadMessage(Guid merchantAccountId)
 {
     return(MessagesComponent.OnekeyReadMessage(merchantAccountId));
 }
示例#16
0
        public override async Task <SellableItem> Run(
            SellableItem arg,
            CommercePipelineExecutionContext context)
        {
            if (arg == null)
            {
                return(null);
            }

            if (arg.HasPolicy <PurchaseOptionMoneyPolicy>() && arg.GetPolicy <PurchaseOptionMoneyPolicy>().Expires > DateTimeOffset.UtcNow && arg.GetPolicy <PurchaseOptionMoneyPolicy>().SellPrice.CurrencyCode.Equals(context.CommerceContext.CurrentCurrency(), StringComparison.OrdinalIgnoreCase))
            {
                return(arg);
            }

            if (arg.HasComponent <PriceSnapshotComponent>())
            {
                arg.Components.Remove(arg.GetComponent <PriceSnapshotComponent>());
            }

            string                 currentCurrency   = context.CommerceContext.CurrentCurrency();
            MessagesComponent      messagesComponent = arg.GetComponent <MessagesComponent>();
            Money                  sellPrice         = null;
            PriceCardPolicy        priceCardPolicy   = arg.Policies.OfType <PriceCardPolicy>().FirstOrDefault();
            PriceSnapshotComponent snapshotComponent = null;
            bool pricingByTags = false;

            if (!string.IsNullOrEmpty(priceCardPolicy?.PriceCardName))
            {
                snapshotComponent = await _resolveSnapshotByCardPipeline.Run(priceCardPolicy.PriceCardName, context);
            }
            else if (arg.Tags.Any())
            {
                snapshotComponent = await _resolveSnapshotByTagsPipeline.Run(arg.Tags, context);

                pricingByTags = true;
            }

            PriceTier priceTier = snapshotComponent?.Tiers.FirstOrDefault(t =>
            {
                return(t.Currency.Equals(currentCurrency, StringComparison.OrdinalIgnoreCase) ? t.Quantity == decimal.One : false);
            });

            Customer customer = await _findEntityPipeline.Run(new FindEntityArgument(typeof(Customer), context.CommerceContext.CurrentCustomerId(), false), context) as Customer;

            bool isMembershipLevelPrice = false;

            if (customer != null && customer.HasComponent <MembershipSubscriptionComponent>())
            {
                var membershipSubscriptionComponent = customer.GetComponent <MembershipSubscriptionComponent>();
                var customerMemerbshipLevelName     = membershipSubscriptionComponent.MemerbshipLevelName;
                var memerbshipLevelName             = membershipSubscriptionComponent.MemerbshipLevelName;

                if (snapshotComponent != null && snapshotComponent.HasComponent <MembershipTiersComponent>())
                {
                    var membershipTiersComponent = snapshotComponent.GetComponent <MembershipTiersComponent>();
                    var membershipPriceTier      = membershipTiersComponent.Tiers.FirstOrDefault(x => x.MembershipLevel == memerbshipLevelName);

                    if (membershipPriceTier != null)
                    {
                        sellPrice = new Money(membershipPriceTier.Currency, membershipPriceTier.Price);
                        isMembershipLevelPrice = true;
                        messagesComponent.AddMessage(context.GetPolicy <KnownMessageCodePolicy>().Pricing, pricingByTags
                            ? string.Format("SellPrice<=Tags.Snapshot: MembershipLevel={0}|Price={1}|Qty={2}|Tags='{3}'", customerMemerbshipLevelName, sellPrice.AsCurrency(false, null), membershipPriceTier.Quantity, string.Join(", ", snapshotComponent.Tags.Select(c => c.Name)))
                            : string.Format("SellPrice<=PriceCard.Snapshot: MembershipLevel={0}|Price={1}|Qty={2}|PriceCard={3}", customerMemerbshipLevelName, sellPrice.AsCurrency(false, null), membershipPriceTier.Quantity, priceCardPolicy.PriceCardName));
                    }
                }
            }

            if (!isMembershipLevelPrice && priceTier != null)
            {
                sellPrice = new Money(priceTier.Currency, priceTier.Price);
                messagesComponent.AddMessage(context.GetPolicy <KnownMessageCodePolicy>().Pricing, pricingByTags ? string.Format("SellPrice<=Tags.Snapshot: Price={0}|Qty={1}|Tags='{2}'", sellPrice.AsCurrency(false, null), priceTier.Quantity, string.Join(", ", snapshotComponent.Tags.Select(c => c.Name))) : string.Format("SellPrice<=PriceCard.Snapshot: Price={0}|Qty={1}|PriceCard={2}", sellPrice.AsCurrency(false, null), priceTier.Quantity, priceCardPolicy.PriceCardName));
            }

            if (snapshotComponent != null)
            {
                arg.SetComponent(snapshotComponent);
            }

            if (sellPrice != null)
            {
                arg.SetPolicy(new PurchaseOptionMoneyPolicy()
                {
                    SellPrice = sellPrice
                });
            }

            return(arg);
        }
示例#17
0
        private async Task <bool?> CalculateCartLinePrice(
            CartLineComponent arg,
            CommercePipelineExecutionContext context)
        {
            ProductArgument productArgument = ProductArgument.FromItemId(arg.ItemId);
            SellableItem    sellableItem    = null;

            if (productArgument.IsValid())
            {
                sellableItem = context.CommerceContext.GetEntity((Func <SellableItem, bool>)(s => s.ProductId.Equals(productArgument.ProductId, StringComparison.OrdinalIgnoreCase)));

                if (sellableItem == null)
                {
                    string simpleName = productArgument.ProductId.SimplifyEntityName();
                    sellableItem = context.CommerceContext.GetEntity((Func <SellableItem, bool>)(s => s.ProductId.Equals(simpleName, StringComparison.OrdinalIgnoreCase)));

                    if (sellableItem != null)
                    {
                        sellableItem.ProductId = simpleName;
                    }
                }
            }
            if (sellableItem == null)
            {
                CommercePipelineExecutionContext executionContext = context;
                CommerceContext commerceContext = context.CommerceContext;
                string          error           = context.GetPolicy <KnownResultCodes>().Error;
                object[]        args            = new object[] { arg.ItemId };
                string          defaultMessage  = "Item '" + arg.ItemId + "' is not purchasable.";
                executionContext.Abort(await commerceContext.AddMessage(error, "LineIsNotPurchasable", args, defaultMessage), context);
                executionContext = null;
                return(new bool?());
            }

            MessagesComponent messagesComponent = arg.GetComponent <MessagesComponent>();

            messagesComponent.Clear(context.GetPolicy <KnownMessageCodePolicy>().Pricing);

            if (sellableItem.HasComponent <MessagesComponent>())
            {
                List <MessageModel> messages = sellableItem.GetComponent <MessagesComponent>().GetMessages(context.GetPolicy <KnownMessageCodePolicy>().Pricing);
                messagesComponent.AddMessages(messages);
            }
            arg.UnitListPrice = sellableItem.ListPrice;
            string listPriceMessage = "CartItem.ListPrice<=SellableItem.ListPrice: Price=" + arg.UnitListPrice.AsCurrency(false, null);
            string sellPriceMessage = string.Empty;
            PurchaseOptionMoneyPolicy optionMoneyPolicy = new PurchaseOptionMoneyPolicy();

            if (sellableItem.HasPolicy <PurchaseOptionMoneyPolicy>())
            {
                optionMoneyPolicy.SellPrice = sellableItem.GetPolicy <PurchaseOptionMoneyPolicy>().SellPrice;
                sellPriceMessage            = "CartItem.SellPrice<=SellableItem.SellPrice: Price=" + optionMoneyPolicy.SellPrice.AsCurrency(false, null);
            }

            PriceSnapshotComponent snapshotComponent;

            if (sellableItem.HasComponent <ItemVariationsComponent>())
            {
                ItemVariationSelectedComponent lineVariant             = arg.ChildComponents.OfType <ItemVariationSelectedComponent>().FirstOrDefault();
                ItemVariationsComponent        itemVariationsComponent = sellableItem.GetComponent <ItemVariationsComponent>();
                ItemVariationComponent         itemVariationComponent;

                if (itemVariationsComponent == null)
                {
                    itemVariationComponent = null;
                }
                else
                {
                    IList <Component> childComponents = itemVariationsComponent.ChildComponents;
                    itemVariationComponent = childComponents?.OfType <ItemVariationComponent>().FirstOrDefault(v =>
                    {
                        return(!string.IsNullOrEmpty(v.Id) ? v.Id.Equals(lineVariant?.VariationId, StringComparison.OrdinalIgnoreCase) : false);
                    });
                }

                if (itemVariationComponent != null)
                {
                    if (itemVariationComponent.HasComponent <MessagesComponent>())
                    {
                        List <MessageModel> messages = itemVariationComponent.GetComponent <MessagesComponent>().GetMessages(context.GetPolicy <KnownMessageCodePolicy>().Pricing);
                        messagesComponent.AddMessages(messages);
                    }

                    arg.UnitListPrice = itemVariationComponent.ListPrice;
                    listPriceMessage  = "CartItem.ListPrice<=SellableItem.Variation.ListPrice: Price=" + arg.UnitListPrice.AsCurrency(false, null);

                    if (itemVariationComponent.HasPolicy <PurchaseOptionMoneyPolicy>())
                    {
                        optionMoneyPolicy.SellPrice = itemVariationComponent.GetPolicy <PurchaseOptionMoneyPolicy>().SellPrice;
                        sellPriceMessage            = "CartItem.SellPrice<=SellableItem.Variation.SellPrice: Price=" + optionMoneyPolicy.SellPrice.AsCurrency(false, null);
                    }
                }
                snapshotComponent = itemVariationComponent != null?itemVariationComponent.ChildComponents.OfType <PriceSnapshotComponent>().FirstOrDefault() : null;
            }
            else
            {
                snapshotComponent = sellableItem.Components.OfType <PriceSnapshotComponent>().FirstOrDefault();
            }

            string currentCurrency = context.CommerceContext.CurrentCurrency();

            PriceTier priceTier = snapshotComponent?.Tiers.OrderByDescending(t => t.Quantity).FirstOrDefault(t =>
            {
                return(t.Currency.Equals(currentCurrency, StringComparison.OrdinalIgnoreCase) ? t.Quantity <= arg.Quantity : false);
            });

            Customer customer = await _findEntityPipeline.Run(new FindEntityArgument(typeof(Customer), context.CommerceContext.CurrentCustomerId(), false), context) as Customer;

            bool isMembershipLevelPrice = false;

            if (customer != null && customer.HasComponent <MembershipSubscriptionComponent>())
            {
                var membershipSubscriptionComponent = customer.GetComponent <MembershipSubscriptionComponent>();
                var membershipLevel = membershipSubscriptionComponent.MemerbshipLevelName;

                if (snapshotComponent != null && snapshotComponent.HasComponent <MembershipTiersComponent>())
                {
                    var membershipTiersComponent = snapshotComponent.GetComponent <MembershipTiersComponent>();
                    var membershipPriceTier      = membershipTiersComponent.Tiers.FirstOrDefault(x => x.MembershipLevel == membershipLevel);

                    if (membershipPriceTier != null)
                    {
                        optionMoneyPolicy.SellPrice = new Money(membershipPriceTier.Currency, membershipPriceTier.Price);
                        isMembershipLevelPrice      = true;

                        sellPriceMessage = string.Format("CartItem.SellPrice<=PriceCard.ActiveSnapshot: MembershipLevel={0}|Price={1}|Qty={2}", membershipSubscriptionComponent.MemerbshipLevelName, optionMoneyPolicy.SellPrice.AsCurrency(false, null), membershipPriceTier.Quantity);
                    }
                }
            }

            if (!isMembershipLevelPrice && priceTier != null)
            {
                optionMoneyPolicy.SellPrice = new Money(priceTier.Currency, priceTier.Price);
                sellPriceMessage            = string.Format("CartItem.SellPrice<=PriceCard.ActiveSnapshot: Price={0}|Qty={1}", optionMoneyPolicy.SellPrice.AsCurrency(false, null), priceTier.Quantity);
            }

            arg.Policies.Remove(arg.Policies.OfType <PurchaseOptionMoneyPolicy>().FirstOrDefault());

            if (optionMoneyPolicy.SellPrice == null)
            {
                return(false);
            }

            arg.SetPolicy(optionMoneyPolicy);

            if (!string.IsNullOrEmpty(sellPriceMessage))
            {
                messagesComponent.AddMessage(context.GetPolicy <KnownMessageCodePolicy>().Pricing, sellPriceMessage);
            }

            if (!string.IsNullOrEmpty(listPriceMessage))
            {
                messagesComponent.AddMessage(context.GetPolicy <KnownMessageCodePolicy>().Pricing, listPriceMessage);
            }

            return(true);
        }
 public static IEnumerable <MessageModel> GetListPriceMessages(this MessagesComponent messagesComponent)
 {
     return(messagesComponent.Messages.Where(m => m.Code.Equals("Pricing", StringComparison.InvariantCultureIgnoreCase) && (m.Text.StartsWith("ListPrice") || m.Text.StartsWith("Variation.ListPrice"))));
 }