Exemple #1
0
        public AppIdOwnerIdTypeDTO GetAppOwnerInfo(System.Guid appId, ContextDTO contextDTO = null)
        {
            AppIdOwnerIdTypeDTO applicationDTO = null;

            contextDTO = AuthorizeHelper.CoinInitAuthorizeInfo();
            try
            {
                applicationDTO = RedisHelper.GetHashValue <AppIdOwnerIdTypeDTO>(RedisKeyConst.AppOwnerType, appId.ToString());
                if (applicationDTO != null && applicationDTO.OwnerId != Guid.Empty)
                {
                    return(applicationDTO);
                }

                Jinher.AMP.App.ISV.Facade.AppManagerFacade appManagerFacade = new App.ISV.Facade.AppManagerFacade();
                appManagerFacade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo();
                applicationDTO = appManagerFacade.GetAppOwnerType(appId);
                if (applicationDTO != null)
                {
                    RedisHelper.AddHash(RedisKeyConst.AppOwnerType, appId.ToString(), applicationDTO);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("APPSV.GetAppOwnerInfo服务异常:获取应用信息异常。 appId:{0}", appId), ex);
            }
            return(applicationDTO);
        }
Exemple #2
0
        /// <summary>
        /// Redis重置活动资源数据
        /// </summary>
        /// <param name="promotionId">活动ID</param>
        public static int PromotionRedis(Guid promotionId)
        {
            try
            {
                var userLimits = (from ul in UserLimited.ObjectSet()
                                  where ul.PromotionId == promotionId
                                  select ul).ToList();

                var promotionItems = (from p in PromotionItems.ObjectSet()
                                      where p.PromotionId == promotionId
                                      select new
                {
                    Id = p.Id,
                    CommodityId = p.CommodityId,
                    SurplusLimitBuyTotal = p.SurplusLimitBuyTotal
                }).ToList();
                if (promotionItems.Any())
                {
                    string hashProSaleCountId = RedisKeyConst.ProSaleCountPrefix + promotionId.ToString();
                    foreach (var promotion in promotionItems)
                    {
                        var surplusLimitBuyTotal = promotion.SurplusLimitBuyTotal.HasValue
                                                       ? promotion.SurplusLimitBuyTotal.Value
                                                       : 0;
                        RedisHelper.AddHash(hashProSaleCountId, promotion.CommodityId.ToString(), surplusLimitBuyTotal);
                        string hashGulId       = RedisKeyConst.UserLimitPrefix + promotionId.ToString() + ":" + promotion.CommodityId;
                        var    userLimitedList = from p in userLimits
                                                 where p.PromotionId == promotionId && p.CommodityId == promotion.CommodityId
                                                 group p by p.UserId
                                                 into g
                                                 select new
                        {
                            UserId    = g.Key,
                            userCount = g.Sum(c => c.Count)
                        };
                        if (userLimitedList.Any())
                        {
                            foreach (var userLimited in userLimitedList)
                            {
                                RedisHelper.AddHash(hashGulId, userLimited.UserId.ToString(), userLimited.userCount);
                            }
                        }
                    }
                }

                if (userLimits.Any())
                {
                    var uids = (from ul in userLimits select ul.UserId).Distinct();
                    foreach (Guid uid in uids)
                    {
                        //活动全场限购,用户在当前活动已购买数量
                        var ubc = (from ul in userLimits
                                   where ul.UserId == uid
                                   select ul.Count).Sum();
                        RedisHelper.AddHash(RedisKeyConst.UserPromotionLimitPrefix + promotionId.ToString(), uid.ToString(), ubc);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("Promotion.PromotionRedis异常:Exception={0}", ex));
                return(0);
            }

            return(1);
        }