/// <summary>变更SKU数据 /// </summary> /// <param name="id">商品ID</param> public void ChangeProductSKU(long id) { string redisKey = RedisKeyConst.GetProductInfoKey(id).Key; ProductInfoModel prodInfo = CN100.Redis.Client.RedisClientUtility.GetData <ProductInfoModel>(redisKey); if (prodInfo == null) { PublishProduct(id); } else { using (WcfTcpClient <IProductService> clint = factory.CreateClient <IProductService>()) { prodInfo.SkuList = clint.Channel.GetProductSKUList(id); } if (prodInfo != null) { CN100.Redis.Client.RedisClientUtility.SetData <ProductInfoModel>(redisKey, prodInfo); ChangeProductSKUDetail(prodInfo.SkuList, prodInfo.ProductActivityList, RedisKeyConst.GetProductSKUKey(id).Key); } else { DeleteByKey(redisKey); } } }
/// <summary>产品发布 /// </summary> /// <param name="redisKey"></param> /// <param name="pid"></param> public void PublishProduct(long pid) { string ProductInfoKey = RedisKeyConst.GetProductInfoKey(pid).Key; //商品信息 //获取商品信息 using (WcfTcpClient <IProductService> clint = factory.CreateClient <IProductService>()) { ProductInfoModel productInfo = clint.Channel.GetProductInfo(pid); //保存商品数据 if (productInfo != null) { CN100.Redis.Client.RedisClientUtility.SetData(ProductInfoKey, productInfo); } else { CN100.Redis.Client.RedisClientUtility.DelBySearchKey("Pro_*_" + pid); return; } } //生成SKU价格 ChangeProductSKUDetail(pid); //生成商品统计信息 ChangeProductStatistics(pid); //生成默认运费模板 ChangeProductDefaultFreight(pid); }
public ResponseContext <UserInfoType> Register(RequestContext <RegisterRequest> request) { var response = new ResponseContext <UserInfoType>(); var userInfo = GetUserInfoByUid(request.Head.UId); if (userInfo == null) { response.ResultCode = ErrCodeEnum.UserNoExist; response.ResultMessage = "请求服务器失败,请重试!"; return(response); } userInfo.Gender = request.Data.Gender; userInfo.NickName = request.Data.NickName; userInfo.Portrait = request.Data.AvatarUrl; userInfo.Country = request.Data.Country; userInfo.Province = request.Data.Province; userInfo.City = request.Data.City; bool success = userInfoDao.Register(request.Head.UId, request.Data.Gender, request.Data.NickName, request.Data.AvatarUrl, request.Data.Country, request.Data.Province, request.Data.City); if (success) { userInfo.IsRegister = true; //刷新缓存 var userInfoKey = RedisKeyConst.UserInfoByOpenIdAndUIdCacheKey(userInfo.OpenId, userInfo.UId); if (redisClient.Remove(userInfoKey)) { userInfo = GetUserInfoByUid(request.Head.UId); } response.Data = UserInfoBuilder.BuildUserInfoV1(userInfo, request.Head); response.Data.NickName = userInfo.NickName; } return(response); }
public UserInfoEntity GetUserInfoByOpenId(string openId) { if (string.IsNullOrEmpty(openId)) { return(null); } UserInfoEntity userInfo = null; string cacheKey = RedisKeyConst.UserInfoKeyByOpenIdCacheKey(openId); string userInfoKey = redisClient.Get(cacheKey); if (!string.IsNullOrEmpty(userInfoKey)) { userInfo = redisClient.Get <UserInfoEntity>(userInfoKey); } if (userInfo != null) { return(userInfo); } userInfo = userInfoDao.GetUserInfoByOpenId(openId); if (userInfo != null) { if (string.IsNullOrEmpty(userInfoKey)) { userInfoKey = RedisKeyConst.UserInfoByOpenIdAndUIdCacheKey(userInfo.OpenId, userInfo.UId); redisClient.Set(cacheKey, userInfoKey, RedisKeyConst.UserInfoCacheSecond); } //缓存一个月 redisClient.Set(userInfoKey, userInfo, RedisKeyConst.UserInfoCacheSecond); } return(userInfo); }
/// <summary>保存店铺页面背景设置 /// </summary> /// <param name="storeId"></param> public void SaveStorePageBackGround(Int64 storeId) { using (WcfTcpClient <IStoreService> clint = factory.CreateClient <IStoreService>()) { var item = clint.Channel.GetStoreBackGround(storeId, VersionEnum.Published); string key = RedisKeyConst.GetStorePageBGKey(storeId).Key; CN100.Redis.Client.RedisClientUtility.SetData <StoreBackGroundModel>(key, item); } }
/// <summary>保存店铺 /// </summary> /// <param name="storeId"></param> public void SaveStoreInfo(Int64 storeId) { using (WcfTcpClient <IStoreService> clint = factory.CreateClient <IStoreService>()) { string key = RedisKeyConst.GetStoreInfoKey(storeId).Key; var item = clint.Channel.GetStoreInfo(storeId); CN100.Redis.Client.RedisClientUtility.SetData <StoreBaseInfoModel>(key, item); } }
public void CreateBuyRecodByProductId(long ID) { string key = RedisKeyConst.GetProductBuyRecordsKey(ID).Key; using (var client = factory.CreateClient <IOrderService>()) { var orderDetailList = client.Channel.GetProductBuyRecords(ID); CN100.Redis.Client.RedisClientUtility.Del(key); CN100.Redis.Client.RedisClientUtility.SetDataList <OrderDetailModel>(key, orderDetailList); } }
/// <summary>保存店铺评价 /// </summary> /// <param name="storeId"></param> public void SaveStoreEvaluat(Int64 storeId) { using (WcfTcpClient <IStoreService> clint = factory.CreateClient <IStoreService>()) { var item = clint.Channel.GetStoreEvaluation(storeId); var key = RedisKeyConst.GetStoreEvaluatKey(storeId).Key; if (item != null) { CN100.Redis.Client.RedisClientUtility.SetData <StoreEvaluationModel>(key, item); } else { DeleteByKey(key); } } }
/// <summary>保存店铺客服信息 /// </summary> /// <param name="storeId"></param> public void SaveCustomServices(Int64 storeId) { using (WcfTcpClient <IStoreService> clint = factory.CreateClient <IStoreService>()) { var item = clint.Channel.GetCustomServices(storeId); string key = RedisKeyConst.GetStoreCustomServiceKey(storeId).Key; if (item != null && item.Count > 0) { CN100.Redis.Client.RedisClientUtility.SetData <IList <StoreCustomServiceModel> >(key, item); } else { DeleteByKey(key); } } }
/// <summary>保存店铺页头 /// </summary> /// <param name="storeId"></param> public void SaveStoreTopModule(Int64 storeId) { using (WcfTcpClient <IStoreService> clint = factory.CreateClient <IStoreService>()) { var item = clint.Channel.GetStorePageHeader(storeId); string key = RedisKeyConst.GetStorePageHeaderKey(storeId).Key; if (item != null) { CN100.Redis.Client.RedisClientUtility.SetData <StoreTopModel>(key, item); } else { DeleteByKey(key); } } }
public void SaveAdressBase() { using (var client = factory.CreateClient <IFreightTemplateService>()) { var item = client.Channel.GetFreightProvince(); var keyType = RedisKeyConst.GetProvincesKey(); if (item != null) { CN100.Redis.Client.RedisClientUtility.SetData <IList <FreightProvinceModel> >(keyType.Key, item); } else { CN100.Redis.Client.RedisClientUtility.Del(keyType.Key); } } }
/// <summary> /// /// </summary> /// <param name="ID"></param> public void ChangeProductTuan(long ID) { var redisKey = RedisKeyConst.GetProductTuanInfoKey(ID).Key; using (WcfTcpClient <IActivityService> clint = factory.CreateClient <IActivityService>()) { var item = clint.Channel.GetTuanActivity(ID); if (item != null) { CN100.Redis.Client.RedisClientUtility.SetData <TuanGouModel>(redisKey, item); } else { DeleteByKey(redisKey); } } }
public static MomentEntity GetMoment(Guid momentId) { string cacheKey = RedisKeyConst.MomentCacheKey(momentId); var moment = redisClient.Get <MomentEntity>(cacheKey); if (moment != null) { return(moment); } moment = momentDao.GetMomentByMomentId(momentId); if (moment != null) { //缓存一个月 redisClient.Set(cacheKey, moment, RedisKeyConst.UserInfoCacheSecond); } return(moment); }
/// <summary>保存商品默认运费 /// </summary> /// <param name="pid"></param> public void ChangeProductDefaultFreight(Int64 pid) { var proKey = RedisKeyConst.GetProductDefaultFreightKey(pid).Key; using (WcfTcpClient <IFreightTemplateService> clint = factory.CreateClient <IFreightTemplateService>()) { var item = clint.Channel.GetProductDetailFreight(pid); if (item != null && item.Count > 0) { CN100.Redis.Client.RedisClientUtility.SetData <IList <ProductFreightModel> >(proKey, item); } else { DeleteByKey(proKey); } } }
public void ChangeProductStatistics(Int64 pid) { var proKey = RedisKeyConst.GetProductStatisticsKey(pid).Key; using (WcfTcpClient <IProductService> clint = factory.CreateClient <IProductService>()) { var item = clint.Channel.GetProductStatistics(pid); if (item != null) { CN100.Redis.Client.RedisClientUtility.SetData <ProductStatisticsModel>(proKey, item); } else { DeleteByKey(proKey); } } }
public void ChangeProductQty(long pid) { var proKey = RedisKeyConst.GetProductInfoKey(pid).Key; var item = CN100.Redis.Client.RedisClientUtility.GetData <ProductInfoModel>(proKey); if (item == null) { return; } using (WcfTcpClient <IProductService> clint = factory.CreateClient <IProductService>()) { item.ProductStoreQty = clint.Channel.GetProductQty(pid); CN100.Redis.Client.RedisClientUtility.SetData <ProductInfoModel>(proKey, item); } }
public void SaveFreightTemplate(long ID) { var key = RedisKeyConst.GetStoreFreightInfoKey(ID).Key; using (var client = factory.CreateClient <IFreightTemplateService>()) { var item = client.Channel.GetFreightTemplateDetail(ID); if (item != null) { CN100.Redis.Client.RedisClientUtility.SetData <IList <FreightTempleteDetailModel> >(key, item); } else { CN100.Redis.Client.RedisClientUtility.Del(key); } } }
public bool UpdateUserLocation(long uId, double latitude, double longitude) { bool success = userInfoDao.UpdateUserLocation(uId, latitude, longitude); if (success) { var userInfo = GetUserInfoByUid(uId); if (userInfo != null) { //刷新缓存 var userInfoKey = RedisKeyConst.UserInfoByOpenIdAndUIdCacheKey(userInfo.OpenId, userInfo.UId); if (redisClient.Remove(userInfoKey)) { GetUserInfoByUid(uId); } } } return(success); }
public Response UpdateUserInfo(RequestContext <UpdateUserInfoType> request) { Response response = new Response(); var userInfo = GetUserInfoByUid(request.Head.UId); if (userInfo == null || userInfo.Platform != request.Head.Platform) { response.ResultCode = ErrCodeEnum.UserNoExist; response.ResultMessage = "用户不存在"; return(response); } userInfo = new UserInfoEntity() { UId = request.Head.UId, OpenId = userInfo.OpenId, NickName = request.Data.NickName, Gender = request.Data.Gender, LiveState = request.Data.LiveState, Grade = request.Data.Grade, SchoolName = request.Data.SchoolName, BirthDate = Convert.ToDateTime(request.Data.BirthDate), Mobile = request.Data.Mobile, WeChatNo = request.Data.WeChatNo, QQNo = request.Data.QQNo, UpdateTime = DateTime.Now }; bool success = userInfoDao.UpdateUserInfo(userInfo); if (!success) { return(new Response(ErrCodeEnum.Failure, "修改失败")); } else { //刷新缓存 var userInfoKey = RedisKeyConst.UserInfoByOpenIdAndUIdCacheKey(userInfo.OpenId, userInfo.UId); if (redisClient.Remove(userInfoKey)) { GetUserInfoByUid(request.Head.UId); } } return(response); }
/// <summary> /// 商品状态批量变更 /// </summary> /// <param name="Ids"></param> public void ChangeProductStatusList(string Ids) { if (string.IsNullOrWhiteSpace(Ids)) { return; } string[] productIdstrs = Ids.Split(','); if (productIdstrs == null || productIdstrs.Length <= 0) { return; } List <long> productIdList = new List <long>(); foreach (string item in productIdstrs) { productIdList.Add(CN100.ProductDetail.Common.DataTypeConvert.ToLong(item, 0)); } Dictionary <long, int> productIdDir = null; //根据产品ID获取产品状态 using (WcfTcpClient <IProductService> clint = factory.CreateClient <IProductService>()) { productIdDir = clint.Channel.GetProductStatusList(productIdList.ToArray()); } if (productIdDir == null || productIdDir.Count <= 0) { return; } //修改Redis中的产品状态 foreach (KeyValuePair <long, int> item in productIdDir) { //获取商品信息 string ProductInfoKey = RedisKeyConst.GetProductInfoKey(item.Key).Key; ProductInfoModel productObj = CN100.Redis.Client.RedisClientUtility.GetData <ProductInfoModel>(ProductInfoKey); productObj.Status = item.Value; CN100.Redis.Client.RedisClientUtility.SetData(ProductInfoKey, productObj); } }
/// <summary> /// 变更商品推荐 /// </summary> /// <param name="storeId"></param> public void SaveChangeStoreRecommend(long storeId) { using (WcfTcpClient <IStoreService> clint = factory.CreateClient <IStoreService>()) { var storePageContent = clint.Channel.GetStorePageContents(storeId, VersionEnum.Published, PageTypeEnum.DetailPage); string moduleTag = string.Empty; string redisKey = string.Empty; JSONPage jsonPage; if (storePageContent != null && storePageContent.Count > 0) { foreach (var item in storePageContent) { if (item != null) { jsonPage = JsonConvert.DeserializeObject <JSONPage>(item.PageContent); var moduleList = GetStoreModules(jsonPage.PageLayoutUnits); CN100.Redis.Client.RedisClientUtility.SetData(RedisKeyConst.GetStorePageContentKey(item.StoreId, item.PageId).Key, JsonConvert.SerializeObject(item)); #region 处理店铺所有受装修配置影响的模块 //插入前先删除掉页面的所有Module数据 CN100.Redis.Client.RedisClientUtility.DelBySearchKey(RedisKeyConst.GetModuleKey(item.StoreId, item.PageId, "*", string.Empty).Key); foreach (var moduleItem in moduleList) { var jobj = (Newtonsoft.Json.Linq.JObject)moduleItem; moduleTag = jobj[moduleTagStr].ToString(); JsonObject ModuleJson = EasyJson.Parse(RegexFixSystemChar.Replace(moduleItem.ToString(), string.Empty)); redisKey = RedisKeyConst.GetModuleKey(item.StoreId, item.PageId, ModuleJson[moduleIdStr].Value, moduleTag).Key; switch (moduleTag) { case ModuleTag.RankingProduct: //排行模块 case ModuleTag.RecommProduct: case ModuleTag.PromotionProduct: SaveProductList(ModuleJson, redisKey, storeId); break; default: break; } } #endregion } } } } }
/// <summary>活动信息变更 /// </summary> /// <param name="redisKey"></param> /// <param name="pid"></param> public void ChangeProductActivity(long pid) { ProductService pservice = new ProductService(); string redisKey = RedisKeyConst.GetProductInfoKey(pid).Key; var prodInfo = CN100.Redis.Client.RedisClientUtility.GetData <ProductInfoModel>(redisKey); if (prodInfo == null) { pservice.PublishProduct(pid); } else { using (WcfTcpClient <IActivityService> clint = factory.CreateClient <IActivityService>()) { prodInfo.ProductActivityList = clint.Channel.GetProductActivitys(pid); } CN100.Redis.Client.RedisClientUtility.SetData <ProductInfoModel>(redisKey, prodInfo); pservice.ChangeProductSKUDetail(prodInfo.SkuList, prodInfo.ProductActivityList, RedisKeyConst.GetProductSKUKey(pid).Key); } }
/// <summary>评论新增 /// </summary> /// <param name="productId">商品ID</param> public void AddComment(long productId) { var Key = RedisKeyConst.GetProductCommentsKey(productId).Key; var LastItem = CN100.Redis.Client.RedisClientUtility.GetDataListByRange <ProductCommentModel>(Key, 0, 0); using (var client = factory.CreateClient <IOrderService>()) { IList <ProductCommentModel> list; if (LastItem != null && LastItem.Count > 0) { list = client.Channel.GetProductCommentsAfterMinCommentID(productId, LastItem[0].Id); } else { list = client.Channel.GetProductComments(productId); } list = list.OrderByDescending(it => it.Id).ToList(); CN100.Redis.Client.RedisClientUtility.SetDataList <ProductCommentModel>(Key, list); productService.ChangeProductStatistics(productId); } }
/// <summary>订单完成 /// </summary> /// <param name="orderCode"></param> public void FinishOrder(string orderCode) { using (var client = factory.CreateClient <IOrderService>()) { var orderDetailList = client.Channel.GetOrderDetail(orderCode); if (orderDetailList != null && orderDetailList.Count > 0) { var keys = orderDetailList.Select(it => it.ProductID).Distinct().ToArray(); var key = string.Empty; IList <OrderDetailModel> list; foreach (var item in keys) { key = RedisKeyConst.GetProductBuyRecordsKey(item).Key; list = orderDetailList.Where(it => it.ProductID == item).OrderByDescending(it => it.Id).ToList(); CN100.Redis.Client.RedisClientUtility.SetDataList <OrderDetailModel>(key, list); productService.ChangeProductStatistics(item); productService.ChangeProductSKU(item); } } } }
public void SaveComboActivity(Int64 storeId) { try { using (WcfTcpClient <IActivityService> client = factory.CreateClient <IActivityService>()) { var item = client.Channel.GetStorePackageActivitys(storeId); var key = RedisKeyConst.GetStorePackageInfoKey(storeId).Key; if (item != null && item.Count > 0) { CN100.Redis.Client.RedisClientUtility.SetData <IList <StorePackageModel> >(key, item); } else { DeleteByKey(key); } } } catch (Exception ex) { } }
/// <summary>满就送 /// </summary> /// <param name="storeId"></param> public void SaveFullActivity(Int64 storeId) { using (WcfTcpClient <IActivityService> client = factory.CreateClient <IActivityService>()) { var item = client.Channel.GetStoreFullSends(storeId); string key = RedisKeyConst.GetFullActivityNoticeKey(storeId).Key; if (item != null && item.Count > 0) { List <string> noFreeArea = new List <string>(); var splitChar = new char[] { ',', ',' }; var allArea = CN100.Redis.Client.RedisClientUtility.GetData <IList <FreightProvinceModel> >(RedisKeyConst.GetProvincesKey().Key); foreach (var sub in item) { if (!string.IsNullOrWhiteSpace(sub.AreaNotFreeShipping)) { var arr = sub.AreaNotFreeShipping.Split(splitChar); foreach (var sub2 in arr) { var address = allArea.FirstOrDefault(it => it.Code.Equals(sub2.Trim())); if (address != null) { noFreeArea.Add(address.Name); } } sub.AreaNotFreeShipping = string.Join(",", noFreeArea); noFreeArea.Clear(); } } CN100.Redis.Client.RedisClientUtility.SetData <IList <FullSendModel> >(key, item); } else { DeleteByKey(key); } } }
/// <summary> SKU价格列表变更 /// </summary> /// <param name="pid"></param> public void ChangeProductSKUDetail(long pid) { IList <ProductSKUModel> productSKUList; IList <ProductActivityItem> activityList; try { string productKey = RedisKeyConst.GetProductInfoKey(pid).Key; var productInfo = CN100.Redis.Client.RedisClientUtility.GetData <ProductInfoModel>(productKey); if (productInfo == null) { return; } //获取SKU信息 productSKUList = productInfo.SkuList; activityList = productInfo.ProductActivityList; ChangeProductSKUDetail(productSKUList, activityList, RedisKeyConst.GetProductSKUKey(pid).Key); } catch (Exception ex) { throw; } }