Esempio n. 1
0
        public static async Task <FixedPriceActivityRoundResponse> GetFixedPriceActivityRoundCache(Guid activityId)
        {
            FixedPriceActivityRoundResponse result = null;
            var activityConfig = await GetBaoYangActivityConfig(activityId);

            var round = ActivityValidator.GetCurrentRoundConfig(activityConfig, DateTime.Now);

            if (round != null)
            {
                var counter       = new BaoYangCounter(activityId, round.LimitedQuantity, activityConfig.ItemQuantityPerUser, round);
                var purchaseCount = await counter.GetCurrentActivityPurchaseCount();

                var orderInfos = await counter.GetOrderHistory();

                result = new FixedPriceActivityRoundResponse
                {
                    ActivityId           = activityConfig.ActivityId,
                    ActivityName         = activityConfig.ActivityName,
                    UserLimitedQuantity  = activityConfig.ItemQuantityPerUser,
                    LimitedQuantity      = round.LimitedQuantity,
                    StartTime            = round.StartTime,
                    EndTime              = round.EndTime,
                    CurrentPurchaseCount = purchaseCount,
                    OrderInfos           = orderInfos,
                };
            }
            return(result);
        }
Esempio n. 2
0
        public static async Task <bool> UpdateBaoYangPurchaseCount(Guid activityId)
        {
            bool success        = false;
            var  activityConfig = await GetBaoYangActivityConfig(activityId);

            var round = ActivityValidator.GetCurrentRoundConfig(activityConfig, DateTime.Now);

            if (round != null)
            {
                var counter = new BaoYangCounter(activityId, round.LimitedQuantity, activityConfig.ItemQuantityPerUser, round);
                success = await counter.ResetPurchaseCount();
            }
            return(success);
        }