Пример #1
0
        /// <summary>
        /// 添加分享日志
        /// </summary>
        /// <returns></returns>
        public async Task <bool> AddShareLogWithChanceType(int chanceType = 2)
        {
            var listLoger =
                await GetBigBrandLogListByUserIdCache(this.entity.PKID, this.entity.PeriodType, this.UserId,
                                                      this.UnionId);

            if (listLoger?.Where(_ => _.ChanceType == chanceType)?.Count() == 0)
            {
                for (int i = 0; i < this.entity.CompletedTimes; i++)
                {
                    var model = new BigBrandRewardLogModel()
                    {
                        ChanceType         = chanceType,
                        Channel            = this.Channel,
                        CreateDateTime     = DateTime.Now,
                        DeviceSerialNumber = this.DeviceId,
                        FKPKID             = 0,
                        Phone          = this.Phone,
                        Refer          = this.Refer,
                        Status         = true,
                        UserId         = this.UserId,
                        UnionId        = this.UnionId,
                        FKBigBrandPkid = this.entity.PKID
                    };
                    await DalBigBrand.AddBigBrandLog(model);

                    string key = BigBrandLogByUser + this.entity.PKID.ToString() + this.entity.PeriodType.ToString() + this.StartDateTime.ToString("yyyyMMddHHmmss") + this.EndDateTime.ToString("yyyyMMddHHmmss");
                    using (var client = CacheHelper.CreateCacheClient(key))
                    {
                        listLoger.Add(model);
                        if (this.UserId != Guid.Empty)
                        {
                            await client.SetAsync(this.UserId.ToString(), listLoger, TimeSpan.FromDays(30));
                        }
                        else if (!string.IsNullOrEmpty(this.UnionId))
                        {
                            await client.SetAsync(this.UnionId, listLoger, TimeSpan.FromDays(30));
                        }
                    }
                }

                // DistributedCache.Upsert("BigBrandShareCount", this.ShareCount + 1);
                // 这个计数查出来 暂时没有用到 ,而且是慢查询,暂时注释掉 俊桥说是一个功能做了一半结果没有做了,之后可以用计数器来实现
                //using (var redisClient = Tuhu.Nosql.CacheHelper.CreateCacheClient("BigBrandLogic"))
                //{
                //    var result = await redisClient.SetAsync("BigBrandShareCount",DalBigBrand.GetBigBrandShareCount(entity.PKID));//增加分享次数
                //}
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        public async Task <bool> AddShareLog(int times, int chanceType = 2)
        {
            var isExist = DalBigBrand.IsExistShareLog(this.UserId, this.entity.HashKeyValue, this.Channel);

            if (isExist)
            {
                return(false);
            }

            for (int i = 0; i < times; i++)
            {
                var model = new BigBrandRewardLogModel()
                {
                    ChanceType         = chanceType,
                    Channel            = this.Channel,
                    CreateDateTime     = DateTime.Now,
                    DeviceSerialNumber = this.DeviceId,
                    FKPKID             = 0,
                    Phone          = this.Phone,
                    Refer          = this.Refer,
                    Status         = true,
                    UserId         = this.UserId,
                    UnionId        = this.UnionId,
                    FKBigBrandPkid = this.entity.PKID
                };
                await DalBigBrand.AddBigBrandLog(model);

                string key = BigBrandLogByUser + this.entity.PKID.ToString() + this.entity.PeriodType.ToString() + this.StartDateTime.ToString("yyyyMMddHHmmss") + this.EndDateTime.ToString("yyyyMMddHHmmss");

                using (var client = CacheHelper.CreateCacheClient(key))
                {
                    if (this.UserId != Guid.Empty)
                    {
                        await client.RemoveAsync(this.UserId.ToString());
                    }
                    else if (!string.IsNullOrEmpty(this.UnionId))
                    {
                        await client.RemoveAsync(this.UnionId);
                    }
                }
            }
            return(true);
        }
Пример #3
0
        public async Task <bool> AddPackageLog(int fkpkid, string promotionCodePKIDs)
        {
            var model = new BigBrandRewardLogModel()
            {
                ChanceType         = 1,
                Channel            = this.Channel,
                CreateDateTime     = DateTime.Now,
                DeviceSerialNumber = this.DeviceId,
                FKPKID             = fkpkid,
                Phone              = this.Phone,
                Refer              = this.Refer,
                Status             = true,
                UserId             = this.UserId,
                UnionId            = this.UnionId,
                FKBigBrandPkid     = this.entity.PKID,
                PromotionCodePKIDs = promotionCodePKIDs
            };
            var result = await DalBigBrand.AddBigBrandLog(model);

            if (result)
            {
                string key = BigBrandCountLogKey + this.entity.PKID + this.StartDateTime.ToString("yyyyMMddHHmmss") + this.EndDateTime.ToString("yyyyMMddHHmmss");
                using (var counter = CacheHelper.CreateCounterClient(key, TimeSpan.FromDays(30)))
                {
                    counter.Increment(fkpkid.ToString());
                }

                string keyCache = BigBrandLogByUser + this.entity.PKID.ToString() + this.entity.PeriodType.ToString() + this.StartDateTime.ToString("yyyyMMddHHmmss") + this.EndDateTime.ToString("yyyyMMddHHmmss");
                using (var client = CacheHelper.CreateCacheClient(keyCache))
                {
                    if (this.UserId != Guid.Empty)
                    {
                        await client.RemoveAsync(this.UserId.ToString());
                    }
                    else if (!string.IsNullOrEmpty(this.UnionId))
                    {
                        await client.RemoveAsync(this.UnionId);
                    }
                }
            }
            return(result);
        }