public void DeleteCartItem(string skuId, long memberId) { DbFactory.Default.Del <ShoppingCartInfo>().Where(item => item.SkuId == skuId && item.UserId == memberId && item.ShopBranchId.ExIfNull(0) == 0).Succeed(); Cache.Remove(CacheKeyCollection.CACHE_CART(memberId)); }
private void ClearErrorTimes(string username) { Cache.Remove(CacheKeyCollection.MemberLoginError(username)); }
public void ClearCart(long memeberId) { base.Context.ShoppingCartItemInfo.Remove <ShoppingCartItemInfo>(item => (item.UserId == memeberId) && !item.ShopBranchId.HasValue); base.Context.SaveChanges(); Cache.Remove(CacheKeyCollection.CACHE_CART(memeberId)); }
public ActionResult CheckCode(string pluginId, string code, string destination) { var cache = CacheKeyCollection.MemberPluginCheck(CurrentUser.UserName, pluginId + destination); var cacheCode = Core.Cache.Get(cache); var member = CurrentUser; var mark = ""; if (cacheCode != null && cacheCode.ToString() == code) { var service = _iMessageService; if (service.GetMemberContactsInfo(pluginId, destination, MemberContactsInfo.UserTypes.General) != null) { return(Json(new Result() { success = false, msg = destination + "已经绑定过了!" })); } if (pluginId.ToLower().Contains("email")) { member.Email = destination; mark = "邮箱"; } else if (pluginId.ToLower().Contains("sms")) { member.CellPhone = destination; mark = "手机"; } _iMemberService.UpdateMember(member); service.UpdateMemberContacts(new Model.MemberContactsInfo() { Contact = destination, ServiceProvider = pluginId, UserId = CurrentUser.Id, UserType = MemberContactsInfo.UserTypes.General }); Core.Cache.Remove(CacheKeyCollection.MemberPluginCheck(CurrentUser.UserName, pluginId)); Core.Cache.Remove(CacheKeyCollection.Member(CurrentUser.Id));//移除用户缓存 Core.Cache.Remove("Rebind" + CurrentUser.Id); MemberIntegralRecord info = new MemberIntegralRecord(); //_iMemberIntegralConversionFactoryService = ServiceHelper.Create<im; //_iMemberIntegralService = ServiceHelper.Create<IMemberIntegralService>(); //_iMemberInviteService = ServiceHelper.Create<IMemberInviteService>(); info.UserName = member.UserName; info.MemberId = member.Id; info.RecordDate = DateTime.Now; info.TypeId = MemberIntegral.IntegralType.Reg; info.ReMark = "绑定" + mark; var memberIntegral = ServiceHelper.Create <IMemberIntegralConversionFactoryService>().Create(MemberIntegral.IntegralType.Reg); ServiceHelper.Create <IMemberIntegralService>().AddMemberIntegral(info, memberIntegral); if (member.InviteUserId.HasValue) { //获取会员积分与相应折扣 var inviteMember = _iMemberService.GetMember(member.InviteUserId.Value); if (inviteMember != null) { ServiceHelper.Create <IMemberInviteService>().AddInviteIntegel(member, inviteMember); } } return(Json(new Result() { success = true, msg = "验证正确" })); } else { return(Json(new Result() { success = false, msg = "验证码不正确或者已经超时" })); } }
void ClearErrorTimes(string username) { Core.Cache.Remove(CacheKeyCollection.ManagerLoginError(username)); }
public JsonResult Index(string serviceProvider, string openId, string username, string password, string checkCode, string mobilecheckCode, string headimgurl, long introducer = 0, string unionid = null, string sex = null, string city = null, string province = null, string country = null, string nickName = null, string email = "", string emailcheckCode = "") { var mobilepluginId = "Himall.Plugin.Message.SMS"; var emailpluginId = "Himall.Plugin.Message.Email"; string systemCheckCode = Session[CHECK_CODE_KEY] as string; if (systemCheckCode.ToLower() != checkCode.ToLower()) { throw new Core.HimallException("验证码错误"); } if (Core.Helper.ValidateHelper.IsMobile(username)) { var cache = CacheKeyCollection.MemberPluginCheck(username, mobilepluginId); var cacheCode = Core.Cache.Get(cache); if (string.IsNullOrEmpty(mobilecheckCode) || mobilecheckCode.ToLower() != cacheCode.ToString().ToLower()) { throw new Core.HimallException("手机验证码错误"); } } if (!string.IsNullOrEmpty(email) && Core.Helper.ValidateHelper.IsMobile(email)) { var cache = CacheKeyCollection.MemberPluginCheck(username, emailpluginId); var cacheCode = Core.Cache.Get(cache); if (string.IsNullOrEmpty(emailcheckCode) || emailcheckCode.ToLower() != cacheCode.ToString().ToLower()) { throw new Core.HimallException("手机验证码错误"); } } headimgurl = System.Web.HttpUtility.UrlDecode(headimgurl); nickName = System.Web.HttpUtility.UrlDecode(nickName); province = System.Web.HttpUtility.UrlDecode(province); city = System.Web.HttpUtility.UrlDecode(city); UserMemberInfo member; var mobile = ""; if (Core.Helper.ValidateHelper.IsMobile(username)) { mobile = username; } if (!string.IsNullOrWhiteSpace(serviceProvider) && !string.IsNullOrWhiteSpace(openId)) { OAuthUserModel userModel = new OAuthUserModel { UserName = username, Password = password, LoginProvider = serviceProvider, OpenId = openId, Headimgurl = headimgurl, Sex = sex, NickName = nickName, Email = email, UnionId = unionid, introducer = introducer, Province = province, City = city }; member = _iMemberService.Register(userModel); } else { member = _iMemberService.Register(username, password, mobile, email, introducer); } if (member != null) { Session.Remove(CHECK_CODE_KEY); MessageHelper helper = new MessageHelper(); helper.ClearErrorTimes(member.UserName); if (!string.IsNullOrEmpty(email)) { helper.ClearErrorTimes(member.Email); } } //TODO:ZJT 在用户注册的时候,检查此用户是否存在OpenId是否存在红包,存在则添加到用户预存款里 _iBonusService.DepositToRegister(member.Id); //用户注册的时候,检查是否开启注册领取优惠券活动,存在自动添加到用户预存款里 int num = CouponApplication.RegisterSendCoupon(member.Id, member.UserName); base.SetUserLoginCookie(member.Id); Application.MemberApplication.UpdateLastLoginDate(member.Id); return(Json(new { success = true, memberId = member.Id, num = num })); }
public ContentResult ReNewPayNotify_Post(string id, string str) { decimal balance = decimal.Parse(str.Split('-')[0]); string userName = str.Split('-')[1]; long shopId = long.Parse(str.Split('-')[2]); int type = int.Parse(str.Split('-')[3]); int value = int.Parse(str.Split('-')[4]); id = DecodePaymentId(id); string errorMsg = string.Empty; string response = string.Empty; try { var payment = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id); var payInfo = payment.Biz.ProcessNotify(HttpContext.Request); ShopRenewRecord model = new ShopRenewRecord(); model.TradeNo = payInfo.TradNo; bool result = Cache.Get(CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds))) == null ? false : true; if (!result) { //添加店铺续费记录 model.ShopId = shopId; model.OperateDate = DateTime.Now; model.Operator = userName; model.Amount = balance; //续费操作 if (type == 1) { model.OperateType = ShopRenewRecord.EnumOperateType.ReNew; var shopInfo = _iShopService.GetShop(shopId); DateTime beginTime = shopInfo.EndDate.Value; if (beginTime < DateTime.Now) { beginTime = DateTime.Now; } string strNewEndTime = beginTime.AddYears(value).ToString("yyyy-MM-dd"); model.OperateContent = "续费 " + value + " 年至 " + strNewEndTime; _iShopService.AddShopRenewRecord(model); //店铺续费 _iShopService.ShopReNew(shopId, value); } //升级操作 else { model.ShopId = shopId; model.OperateType = ShopRenewRecord.EnumOperateType.Upgrade; var shopInfo = _iShopService.GetShop(shopId); var shopGrade = _iShopService.GetShopGrades().Where(c => c.Id == shopInfo.GradeId).FirstOrDefault(); var newshopGrade = _iShopService.GetShopGrades().Where(c => c.Id == (long)value).FirstOrDefault(); model.OperateContent = "将套餐‘" + shopGrade.Name + "'升级为套餐‘" + newshopGrade.Name + "'"; _iShopService.AddShopRenewRecord(model); //店铺升级 _iShopService.ShopUpGrade(shopId, (long)value); } response = payment.Biz.ConfirmPayResult(); string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds)); //获取支付状态缓存键 Cache.Insert(payStateKey, true); //标记为已支付 if (Cache.Exists(CacheKeyCollection.CACHE_SHOP(shopId, false))) { Cache.Remove(CacheKeyCollection.CACHE_SHOP(shopId, false)); } } } catch (Exception ex) { errorMsg = ex.Message; Log.Error("ReNewPayNotify_Post", ex); } return(Content(response)); }
public object PostRegisterUser(RegisterUserModel user) { dynamic d = new System.Dynamic.ExpandoObject(); try { var email = ""; //普通注册 if (user.userName != null && user.password != null && user.userName != "" && user.password != "") { string userName = user.userName; string password = user.password; email = user.email; string code = user.code; var pluginId = ""; if (!string.IsNullOrEmpty(email) && Core.Helper.ValidateHelper.IsEmail(email)) { pluginId = "Himall.Plugin.Message.Email"; var cache = CacheKeyCollection.MemberPluginCheck(email, pluginId); var cacheCode = Core.Cache.Get(cache); if (cacheCode == null || cacheCode.ToString() != code) { return(Json(new { success = false, ErrorMsg = "验证码输入错误或者已经超时" })); } } Regex reg = new Regex("^[a-zA-Z0-9_\u4e00-\u9fa5]+$"); if (!reg.IsMatch(userName) || userName.Length < 4 || userName.Length > 20) { throw new HimallException("用户名由4-20个中文英文数字字母下划线组成"); } var member = ServiceProvider.Instance <IMemberService> .Create.Register(userName, password, string.Empty, email, 0); if (member == null) { d.Success = "false"; } else { //手机注册直接绑定手机 if (Core.Helper.ValidateHelper.IsMobile(userName)) { pluginId = "Himall.Plugin.Message.SMS"; member.CellPhone = userName; ServiceProvider.Instance <IMemberService> .Create.UpdateMember(member); ServiceProvider.Instance <IMessageService> .Create.UpdateMemberContacts(new MemberContactsInfo() { Contact = userName, ServiceProvider = pluginId, UserId = member.Id, UserType = MemberContactsInfo.UserTypes.General }); } //注册赠送优惠券 int num = this.RegisterSendCoupon(member.Id, member.UserName); d.Success = "true"; d.UserId = member.Id; d.CouponNum = num; string memberId = UserCookieEncryptHelper.Encrypt(member.Id, "Mobile"); //WebHelper.SetCookie(CookieKeysCollection.HIMALL_USER_KEY(platformType), memberId, DateTime.MaxValue); } } //信任登录并且不绑定,后台给一个快速注册 else { string username = DateTime.Now.ToString("yyMMddHHmmssffffff"); var member = ServiceProvider.Instance <IMemberService> .Create.QuickRegister(username, string.Empty, user.oauthNickName, user.oauthType, user.oauthOpenId, user.unionid, user.sex, user.headimgurl, MemberOpenIdInfo.AppIdTypeEnum.Normal); //注册赠送优惠券 int num = this.RegisterSendCoupon(member.Id, member.UserName); string memberId = UserCookieEncryptHelper.Encrypt(member.Id, "Mobile"); //WebHelper.SetCookie(CookieKeysCollection.HIMALL_USER_KEY(platformType), memberId); d.Success = "true"; d.UserId = member.Id; d.CouponNum = num; } } catch (Exception ex) { d.Success = "false"; d.ErrorMsg = ex.Message; } return(d); }
public void DeleteCartItem(IEnumerable <string> skuIds, long memberId) { Context.ShoppingCartItemInfo.Remove(item => skuIds.Contains(item.SkuId) && item.UserId == memberId); Context.SaveChanges(); Cache.Remove(CacheKeyCollection.CACHE_CART(memberId)); }
public void ImportProductAsync(long paraCategory, long paraShopCategory, long?paraBrand, int paraSaleStatus, long _shopid, long _userid, string file) { base.AsyncManager.OutstandingOperations.Increment(); Task.Factory.StartNew(() => { string str = Server.MapPath(string.Concat("/temp/", file)); string str1 = string.Format("/Storage/Shop/{0}/Products", _shopid); string str2 = Server.MapPath(str1); long value = 0; if (paraBrand.HasValue) { value = paraBrand.Value; } JsonResult jsonResult = new JsonResult(); if (!System.IO.File.Exists(str)) { AsyncManager.Parameters["success"] = false; AsyncManager.Parameters["message"] = "上传文件不存在"; } else { ZipHelper.ZipInfo zipInfo = ZipHelper.UnZipFile(str); if (!zipInfo.Success) { Log.Error(string.Concat("解压文件异常:", zipInfo.InfoMessage)); AsyncManager.Parameters["success"] = false; AsyncManager.Parameters["message"] = "解压出现异常,请检查压缩文件格式"; } else { try { int num = ProcessProduct(paraCategory, paraShopCategory, value, paraSaleStatus, _shopid, _userid, zipInfo.UnZipPath, str1, str2); if (num <= 0) { Cache.Remove(CacheKeyCollection.UserImportProductCount(_userid)); Cache.Remove(CacheKeyCollection.UserImportProductTotal(_userid)); AsyncManager.Parameters["success"] = false; AsyncManager.Parameters["message"] = "导入【0】件商品,请检查数据包格式,或是否重复导入"; } else { AsyncManager.Parameters["success"] = true; AsyncManager.Parameters["message"] = string.Concat("成功导入【", num.ToString(), "】件商品"); } } catch (Exception exception1) { Exception exception = exception1; Log.Error(string.Concat("导入商品异常:", exception.Message)); Cache.Remove(CacheKeyCollection.UserImportProductCount(_userid)); Cache.Remove(CacheKeyCollection.UserImportProductTotal(_userid)); AsyncManager.Parameters["success"] = false; AsyncManager.Parameters["message"] = string.Concat("导入商品异常:", exception.Message); } } } AsyncManager.OutstandingOperations.Decrement(); object obj = Cache.Get("Cache-UserImportOpCount"); if (obj != null) { Cache.Insert("Cache-UserImportOpCount", int.Parse(obj.ToString()) - 1); } }); }
public void UpdateFreightTemplate(FreightTemplateInfo templateInfo) { FreightTemplateInfo model; if (templateInfo.Id == 0) { DbFactory.Default.InTransaction(() => { var ret1 = DbFactory.Default.Add(templateInfo); foreach (var t in templateInfo.FreightAreaContentInfo) { t.FreightTemplateId = templateInfo.Id; } if (templateInfo.FreightAreaContentInfo.Count() > 0) { var ret2 = DbFactory.Default.Add <FreightAreaContentInfo>(templateInfo.FreightAreaContentInfo); } var areaDetailList = new List <FreightAreaDetailInfo>(); foreach (var t in templateInfo.FreightAreaContentInfo) { foreach (var d in t.FreightAreaDetailInfo) { d.FreightAreaId = t.Id; d.FreightTemplateId = t.FreightTemplateId; areaDetailList.Add(d); } } if (areaDetailList.Count > 0) { var ret3 = DbFactory.Default.Add <FreightAreaDetailInfo>(areaDetailList); } #region 指定地区包邮 if (templateInfo.ShippingFreeGroupInfo != null) { foreach (var t in templateInfo.ShippingFreeGroupInfo) { t.TemplateId = templateInfo.Id;//模板ID DbFactory.Default.Add(t); if (t.Id > 0) { foreach (var item in t.ShippingFreeRegionInfo) { item.GroupId = t.Id; //组ID item.TemplateId = templateInfo.Id; //模板ID DbFactory.Default.Add(item); } } } } }); #endregion } else { model = DbFactory.Default.Get <FreightTemplateInfo>().Where(e => e.Id == templateInfo.Id).FirstOrDefault(); model.Name = templateInfo.Name; model.IsFree = templateInfo.IsFree; model.ValuationMethod = templateInfo.ValuationMethod; model.ShopID = templateInfo.ShopID; model.SourceAddress = templateInfo.SourceAddress; model.SendTime = templateInfo.SendTime; var flag = DbFactory.Default.InTransaction(() => { DbFactory.Default.Update(model); //先删除 DbFactory.Default.Del <FreightAreaContentInfo>(e => e.FreightTemplateId == model.Id); //删除详情表 DbFactory.Default.Del <FreightAreaDetailInfo>(e => e.FreightTemplateId == model.Id); if (model.IsFree == FreightTemplateType.SelfDefine) { //重新插入地区运费 templateInfo.FreightAreaContentInfo.ForEach(e => { e.FreightTemplateId = model.Id; }); if (templateInfo.FreightAreaContentInfo.Count > 0) { DbFactory.Default.Add <FreightAreaContentInfo>(templateInfo.FreightAreaContentInfo); } var detailList = new List <FreightAreaDetailInfo>(); foreach (var t in templateInfo.FreightAreaContentInfo) { foreach (var d in t.FreightAreaDetailInfo) { d.FreightAreaId = t.Id; d.FreightTemplateId = model.Id; detailList.Add(d); } } if (detailList.Count > 0) { DbFactory.Default.Add <FreightAreaDetailInfo>(detailList); } } #region 指定地区包邮 DbFactory.Default.Del <ShippingFreeGroupInfo>(e => e.TemplateId == model.Id); DbFactory.Default.Del <ShippingFreeRegionInfo>(e => e.TemplateId == model.Id); if (templateInfo.ShippingFreeGroupInfo != null) { foreach (var t in templateInfo.ShippingFreeGroupInfo) { t.TemplateId = model.Id;//模板ID DbFactory.Default.Add(t); if (t.Id > 0) { foreach (var item in t.ShippingFreeRegionInfo) { item.GroupId = t.Id; //组ID item.TemplateId = model.Id; //模板ID DbFactory.Default.Add(item); } } } } #endregion return(true); }); Cache.Remove(CacheKeyCollection.CACHE_FREIGHTTEMPLATE(templateInfo.Id)); Cache.Remove(CacheKeyCollection.CACHE_FREIGHTAREADETAIL(templateInfo.Id)); } }
private int ProcessProduct(long paraCategory, long paraShopCategory, long paraBrand, int paraSaleStatus, long _shopid, long _userid, string mainpath, string imgpath1, string imgpath2) { string str; ProductQuery productQuery; IProductService productService; long nextProductId; long num; decimal num1; ProductInfo productInfo; int num2 = 0; string str1 = mainpath; CategoryInfo category = ServiceHelper.Create <ICategoryService>().GetCategory(paraCategory); if (Directory.Exists(str1)) { string[] files = Directory.GetFiles(str1, "*.csv", SearchOption.AllDirectories); string empty = string.Empty; string[] strArrays = new string[0]; for (int i = 0; i < files.Length; i++) { using (StreamReader streamReader = System.IO.File.OpenText(files[i])) { int num3 = 0; List <string> strs = new List <string>(); while (true) { string str2 = streamReader.ReadLine(); empty = str2; if (str2 == null || string.IsNullOrEmpty(empty)) { break; } num3++; if (num3 >= 4) { strs.Add(empty); } } Cache.Insert(CacheKeyCollection.UserImportProductTotal(_userid), strs.Count); foreach (string str3 in strs) { string[] strArrays1 = new string[] { "\t" }; strArrays = str3.Split(strArrays1, StringSplitOptions.None); int length = strArrays.Length; if (length == 58) { str = strArrays[0].Replace("\"", ""); productQuery = new ProductQuery() { CategoryId = new long?(category.Id), ShopId = new long?(_shopid), KeyWords = str }; productService = ServiceHelper.Create <IProductService>(); if (productService.GetProducts(productQuery).Total <= 0) { nextProductId = productService.GetNextProductId(); num = 0; num1 = decimal.Parse((strArrays[7] == string.Empty ? "0" : strArrays[7])); ProductInfo productInfo1 = new ProductInfo() { Id = nextProductId, TypeId = category.TypeId, AddedDate = DateTime.Now, BrandId = paraBrand, CategoryId = category.Id, CategoryPath = category.Path, MarketPrice = num1, ShortDescription = string.Empty, ProductCode = strArrays[33].Replace("\"", ""), ImagePath = "", DisplaySequence = 1, ProductName = strArrays[0].Replace("\"", ""), MinSalePrice = num1, ShopId = _shopid, HasSKU = true, ProductAttributeInfo = new List <ProductAttributeInfo>() }; List <ProductShopCategoryInfo> productShopCategoryInfos = new List <ProductShopCategoryInfo>(); ProductShopCategoryInfo productShopCategoryInfo = new ProductShopCategoryInfo() { ProductId = nextProductId, ShopCategoryId = paraShopCategory }; productShopCategoryInfos.Add(productShopCategoryInfo); productInfo1.Himall_ProductShopCategories = productShopCategoryInfos; ProductDescriptionInfo productDescriptionInfo = new ProductDescriptionInfo() { AuditReason = "", Description = strArrays[20].Replace("\"", ""), DescriptiondSuffixId = 0, DescriptionPrefixId = 0, Meta_Description = string.Empty, Meta_Keywords = string.Empty, Meta_Title = string.Empty, ProductId = nextProductId }; productInfo1.ProductDescriptionInfo = productDescriptionInfo; ProductInfo productInfo2 = productInfo1; List <SKUInfo> sKUInfos = new List <SKUInfo>(); List <SKUInfo> sKUInfos1 = sKUInfos; SKUInfo sKUInfo = new SKUInfo(); object[] objArray = new object[] { nextProductId, "0", "0", "0" }; sKUInfo.Id = string.Format("{0}_{1}_{2}_{3}", objArray); sKUInfo.Stock = (long.TryParse(strArrays[9], out num) ? num : 0); sKUInfo.SalePrice = num1; sKUInfo.CostPrice = num1; sKUInfos1.Add(sKUInfo); productInfo2.SKUInfo = sKUInfos; productInfo1.SaleStatus = (paraSaleStatus == 1 ? ProductInfo.ProductSaleStatus.OnSale : ProductInfo.ProductSaleStatus.InStock); productInfo1.AuditStatus = ProductInfo.ProductAuditStatus.WaitForAuditing; productInfo = productInfo1; long id = productInfo.Id; productInfo.ImagePath = string.Concat(imgpath1, "//", id.ToString()); if (strArrays[28] != string.Empty) { ImportProductImg(productInfo.Id, _shopid, files[i], strArrays[28]); } productService.AddProduct(productInfo); num2++; Log.Debug(strArrays[0].Replace("\"", "")); Cache.Insert(CacheKeyCollection.UserImportProductCount(_userid), num2); } else { num2++; Log.Debug(string.Concat(strArrays[0].Replace("\"", ""), " : 商品不能重复导入")); Cache.Insert(CacheKeyCollection.UserImportProductCount(_userid), num2); } } else if (length == 63) { str = strArrays[0].Replace("\"", ""); productQuery = new ProductQuery() { CategoryId = new long?(category.Id), ShopId = new long?(_shopid), KeyWords = str }; productService = ServiceHelper.Create <IProductService>(); if (productService.GetProducts(productQuery).Total <= 0) { nextProductId = productService.GetNextProductId(); num1 = decimal.Parse((strArrays[7] == string.Empty ? "0" : strArrays[7])); ProductInfo productInfo3 = new ProductInfo() { Id = nextProductId, TypeId = category.TypeId, AddedDate = DateTime.Now, BrandId = paraBrand, CategoryId = category.Id, CategoryPath = category.Path, MarketPrice = num1, ShortDescription = string.Empty, ProductCode = strArrays[33].Replace("\"", ""), ImagePath = "", DisplaySequence = 1, ProductName = strArrays[0].Replace("\"", ""), MinSalePrice = num1, ShopId = _shopid, HasSKU = true, ProductAttributeInfo = new List <ProductAttributeInfo>() }; List <ProductShopCategoryInfo> productShopCategoryInfos1 = new List <ProductShopCategoryInfo>(); ProductShopCategoryInfo productShopCategoryInfo1 = new ProductShopCategoryInfo() { ProductId = nextProductId, ShopCategoryId = paraShopCategory }; productShopCategoryInfos1.Add(productShopCategoryInfo1); productInfo3.Himall_ProductShopCategories = productShopCategoryInfos1; ProductDescriptionInfo productDescriptionInfo1 = new ProductDescriptionInfo() { AuditReason = "", Description = strArrays[20].Replace("\"", ""), DescriptiondSuffixId = 0, DescriptionPrefixId = 0, Meta_Description = string.Empty, Meta_Keywords = string.Empty, Meta_Title = string.Empty, ProductId = nextProductId }; productInfo3.ProductDescriptionInfo = productDescriptionInfo1; ProductInfo productInfo4 = productInfo3; List <SKUInfo> sKUInfos2 = new List <SKUInfo>(); List <SKUInfo> sKUInfos3 = sKUInfos2; SKUInfo sKUInfo1 = new SKUInfo(); object[] objArray1 = new object[] { nextProductId, "0", "0", "0" }; sKUInfo1.Id = string.Format("{0}_{1}_{2}_{3}", objArray1); sKUInfo1.Stock = (long.TryParse(strArrays[9], out num) ? num : 0); sKUInfo1.SalePrice = num1; sKUInfo1.CostPrice = num1; sKUInfos3.Add(sKUInfo1); productInfo4.SKUInfo = sKUInfos2; productInfo3.SaleStatus = (paraSaleStatus == 1 ? ProductInfo.ProductSaleStatus.OnSale : ProductInfo.ProductSaleStatus.InStock); productInfo3.AuditStatus = ProductInfo.ProductAuditStatus.WaitForAuditing; productInfo = productInfo3; long id1 = productInfo.Id; productInfo.ImagePath = string.Concat(imgpath1, "//", id1.ToString()); if (strArrays[28] != string.Empty) { ImportProductImg(productInfo.Id, _shopid, files[i], strArrays[28]); } productService.AddProduct(productInfo); num2++; Log.Debug(strArrays[0].Replace("\"", "")); Cache.Insert(CacheKeyCollection.UserImportProductCount(_userid), num2); } else { num2++; Log.Debug(string.Concat(strArrays[0].Replace("\"", ""), " : 商品不能重复导入")); Cache.Insert(CacheKeyCollection.UserImportProductCount(_userid), num2); } } } } } } return(num2); }
public ContentResult CashPayNotify_Post(string id, string str) { char[] chrArray = new char[] { '-' }; decimal num = decimal.Parse(str.Split(chrArray)[0]); char[] chrArray1 = new char[] { '-' }; string str1 = str.Split(chrArray1)[1]; char[] chrArray2 = new char[] { '-' }; long num1 = long.Parse(str.Split(chrArray2)[2]); id = DecodePaymentId(id); string empty = string.Empty; string empty1 = string.Empty; try { Plugin <IPaymentPlugin> plugin = PluginsManagement.GetPlugin <IPaymentPlugin>(id); PaymentInfo paymentInfo = plugin.Biz.ProcessReturn(base.HttpContext.Request); if ((Cache.Get(CacheKeyCollection.PaymentState(string.Join <long>(",", paymentInfo.OrderIds))) == null ? true : false)) { ICashDepositsService cashDepositsService = ServiceHelper.Create <ICashDepositsService>(); CashDepositDetailInfo cashDepositDetailInfo = new CashDepositDetailInfo() { AddDate = DateTime.Now, Balance = num, Description = "充值", Operator = str1 }; List <CashDepositDetailInfo> cashDepositDetailInfos = new List <CashDepositDetailInfo>() { cashDepositDetailInfo }; if (cashDepositsService.GetCashDepositByShopId(num1) != null) { cashDepositDetailInfo.CashDepositId = cashDepositsService.GetCashDepositByShopId(num1).Id; ServiceHelper.Create <ICashDepositsService>().AddCashDepositDetails(cashDepositDetailInfo); } else { CashDepositInfo cashDepositInfo = new CashDepositInfo() { CurrentBalance = num, Date = DateTime.Now, ShopId = num1, TotalBalance = num, EnableLabels = true, ChemCloud_CashDepositDetail = cashDepositDetailInfos }; cashDepositsService.AddCashDeposit(cashDepositInfo); } empty1 = plugin.Biz.ConfirmPayResult(); string str2 = CacheKeyCollection.PaymentState(string.Join <long>(",", paymentInfo.OrderIds)); Cache.Insert(str2, true); } } catch (Exception exception) { string message = exception.Message; } return(base.Content(empty1)); }
/// <summary> /// 清理模板缓存 /// </summary> /// <param name="client"></param> /// <param name="type"></param> /// <param name="shopId"></param> public static void ClearCache(string client, VTemplateClientTypes type, long shopId = 0) { string cachename = CacheKeyCollection.MobileHomeTemplate(shopId.ToString(), client); Cache.Remove(cachename); }
/// <summary> /// 商品明细处理 /// </summary> /// <param name="paraCategory"></param> /// <param name="paraShopCategory"></param> /// <param name="paraBrand"></param> /// <param name="paraSaleStatus"></param> /// <param name="_shopid"></param> /// <param name="_userid"></param> /// <param name="mainpath">压缩文件的路径</param> /// <param name="imgpath1">虚拟相对路径</param> /// <param name="imgpath2">绝对路径(mappath)包含</param> /// <returns></returns> private int ProcessProduct(long paraCategory, long paraShopCategory, long paraBrand, int paraSaleStatus, long _shopid, long _userid, long freightId, string mainpath, string imgpath1, string imgpath2) { int result = 0; string strPath = mainpath; //var iProcudt = _iProductService; var category = _iCategoryService.GetCategory(paraCategory); if (Directory.Exists(strPath)) { string[] csvfiles = Directory.GetFiles(strPath, "*.csv", SearchOption.AllDirectories); string line = string.Empty; List <string> cells = new List <string>(); for (int i = 0; i < csvfiles.Length; i++) { StreamReader reader = new StreamReader(csvfiles[i], Encoding.Unicode); string str2 = reader.ReadToEnd(); reader.Close(); str2 = str2.Substring(str2.IndexOf('\n') + 1); str2 = str2.Substring(str2.IndexOf('\n') + 1); StreamWriter writer = new StreamWriter(csvfiles[i], false, Encoding.Unicode); writer.Write(str2); writer.Close(); using (CsvReader reader2 = new CsvReader(new StreamReader(csvfiles[i], Encoding.UTF8), true, '\t')) { int num = 0; while (reader2.ReadNextRecord()) { num++; int columnCount = reader2.FieldCount; //string[] heads = reader2.GetFieldHeaders(); string strProductName = reader2["宝贝名称"].Replace("\"", ""); ProductQuery productQuery = new ProductQuery(); productQuery.CategoryId = category.Id; productQuery.ShopId = _shopid; productQuery.KeyWords = strProductName; var iProcudt = _iProductService; ObsoletePageModel <ProductInfo> products = iProcudt.GetProducts(productQuery); if (products.Total > 0) {//当前店铺、分类已经存在相同编码的商品 result++; Core.Log.Debug(strProductName + " : 商品不能重复导入"); Core.Cache.Insert(CacheKeyCollection.UserImportProductCount(_userid), result); continue; } long pid = iProcudt.GetNextProductId(); long lngStock = 0; decimal price = decimal.Parse(reader2["宝贝价格"] == string.Empty ? "0" : reader2["宝贝价格"]); var p = new ProductInfo() { Id = pid, TypeId = category.TypeId, AddedDate = DateTime.Now, BrandId = paraBrand, CategoryId = category.Id, CategoryPath = category.Path, MarketPrice = price, ShortDescription = string.Empty, ProductCode = reader2["商家编码"].Replace("\"", ""), ImagePath = "", DisplaySequence = 1, ProductName = strProductName, MinSalePrice = price, ShopId = _shopid, HasSKU = false,//判断是否有多规格才能赋值 ProductAttributeInfo = new List <ProductAttributeInfo>(), Himall_ProductShopCategories = paraShopCategory == 0 ? null : new List <ProductShopCategoryInfo>() { new ProductShopCategoryInfo() { ProductId = pid, ShopCategoryId = paraShopCategory } }, ProductDescriptionInfo = new ProductDescriptionInfo { AuditReason = "", Description = reader2["宝贝描述"],//.Replace("\"", ""),//不能纯去除 DescriptiondSuffixId = 0, DescriptionPrefixId = 0, Meta_Description = string.Empty, Meta_Keywords = string.Empty, Meta_Title = string.Empty, ProductId = pid }, SKUInfo = new List <SKUInfo>() { new SKUInfo() { Id = string.Format("{0}_{1}_{2}_{3}", pid, "0", "0", "0"), Stock = long.TryParse(reader2["宝贝数量"], out lngStock)?lngStock:0, SalePrice = price, CostPrice = price } }, SaleStatus = paraSaleStatus == 1 ? ProductInfo.ProductSaleStatus.OnSale : ProductInfo.ProductSaleStatus.InStock, AuditStatus = ProductInfo.ProductAuditStatus.WaitForAuditing, FreightTemplateId = freightId }; //图片处理 p.ImagePath = imgpath1 + "//" + p.Id.ToString(); if (reader2["新图片"] != string.Empty) { ImportProductImg(p.Id, _shopid, csvfiles[i], reader2["新图片"]); } iProcudt.AddProduct(p); _iSearchProductService.AddSearchProduct(p.Id); result++; Core.Log.Debug(strProductName); Core.Cache.Insert(CacheKeyCollection.UserImportProductCount(_userid), result); } } } } return(result); }
public void ClearCart(long memeberId) { Context.ShoppingCartItemInfo.Remove(item => item.UserId == memeberId); Context.SaveChanges(); Cache.Remove(CacheKeyCollection.CACHE_CART(memeberId)); }
public void DeleteCartItem(string skuId, long memberId, long shopbranchId) { base.Context.ShoppingCartItemInfo.Remove <ShoppingCartItemInfo>(item => (((item.SkuId == skuId) && (item.UserId == memberId)) && item.ShopBranchId.HasValue) && (item.ShopBranchId.Value == shopbranchId)); base.Context.SaveChanges(); Cache.Remove(CacheKeyCollection.CACHE_BRANCHCART(memberId)); }
public void DeleteCartItem(string skuId, long memberId) { Context.ShoppingCartItemInfo.Remove(item => item.SkuId == skuId && item.UserId == memberId); Context.SaveChanges(); Cache.Remove(CacheKeyCollection.CACHE_CART(memberId)); }
/// <summary> /// 移除场景Model /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key"></param> public void RemoveModel <T>(string key) { var cachkey = CacheKeyCollection.SceneState(key); Core.Cache.Remove(cachkey); }
public ContentResult CashPayNotify_Post(string id, string str) { decimal balance = decimal.Parse(str.Split('-')[0]); string userName = str.Split('-')[1]; long shopId = long.Parse(str.Split('-')[2]); id = DecodePaymentId(id); string errorMsg = string.Empty; string response = string.Empty; try { var payment = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id); var payInfo = payment.Biz.ProcessReturn(HttpContext.Request); bool result = Cache.Get(CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds))) == null ? false : true; if (!result) { var accountService = _iCashDepositsService; CashDepositDetailInfo model = new CashDepositDetailInfo(); model.AddDate = DateTime.Now; model.Balance = balance; model.Description = "充值"; model.Operator = userName; List <CashDepositDetailInfo> list = new List <CashDepositDetailInfo>(); list.Add(model); if (accountService.GetCashDepositByShopId(shopId) == null) { CashDepositInfo cashDeposit = new CashDepositInfo() { CurrentBalance = balance, Date = DateTime.Now, ShopId = shopId, TotalBalance = balance, EnableLabels = true, Himall_CashDepositDetail = list }; accountService.AddCashDeposit(cashDeposit); } else { model.CashDepositId = accountService.GetCashDepositByShopId(shopId).Id; _iCashDepositsService.AddCashDepositDetails(model); } response = payment.Biz.ConfirmPayResult(); string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds)); //获取支付状态缓存键 Cache.Insert(payStateKey, true); //标记为已支付 } } catch (Exception ex) { errorMsg = ex.Message; } return(Content(response)); }
/// <summary> /// 通过坐标获取地址 /// </summary> /// <param name="address"></param> /// <returns></returns> public static void GetAddressByLatLng(string latLng, ref string address, ref string province, ref string city, ref string district, ref string street) { string[] latlngarr = latLng.Split(','); string gaodeLngLat = latlngarr[1] + "," + latlngarr[0]; string newLatLng = Math.Round(decimal.Parse(latlngarr[1]), 4) + "," + Math.Round(decimal.Parse(latlngarr[0]), 4); object objlatlng = Core.Cache.Get(CacheKeyCollection.LatlngCacheKey(newLatLng)); if (objlatlng != null) { GaodeGetAddressByLatLngResult resultobj = (GaodeGetAddressByLatLngResult)objlatlng; if (resultobj.status == 1 && resultobj.info == "OK") { province = resultobj.regeocode.addressComponent.province; city = string.IsNullOrEmpty(resultobj.regeocode.addressComponent.city) ? resultobj.regeocode.addressComponent.province : resultobj.regeocode.addressComponent.city; district = resultobj.regeocode.addressComponent.district; street = resultobj.regeocode.addressComponent.township; if (string.IsNullOrEmpty(resultobj.regeocode.addressComponent.building.name)) { address = resultobj.regeocode.addressComponent.neighborhood.name; } else { address = resultobj.regeocode.addressComponent.building.name; } if (string.IsNullOrEmpty(address)) { string preAddr = province + resultobj.regeocode.addressComponent.city + district + street; address = resultobj.regeocode.formatted_address.Remove(0, preAddr.Length); } } } else { string gaoDeAPIKey = "53e4f77f686e6a2b5bf53521e178c6e7"; string url = "http://restapi.amap.com/v3/geocode/regeo?output=json&radius=3000&location=" + gaodeLngLat + "&key=" + gaoDeAPIKey; string result = GetResponseResult(url); GaodeGetAddressByLatLngResult resultobj = ParseFormJson <GaodeGetAddressByLatLngResult>(result); if (resultobj.status == 1 && resultobj.info == "OK") { var cacheTimeout = DateTime.Now.AddDays(1); Core.Cache.Insert(CacheKeyCollection.LatlngCacheKey(newLatLng), resultobj, cacheTimeout); //坐标地址信息缓存一天 province = resultobj.regeocode.addressComponent.province; city = string.IsNullOrWhiteSpace(resultobj.regeocode.addressComponent.city) ? resultobj.regeocode.addressComponent.province : resultobj.regeocode.addressComponent.city; district = resultobj.regeocode.addressComponent.district; street = resultobj.regeocode.addressComponent.township; if (string.IsNullOrWhiteSpace(resultobj.regeocode.addressComponent.building.name)) { address = resultobj.regeocode.addressComponent.neighborhood.name; } else { address = resultobj.regeocode.addressComponent.building.name; } if (string.IsNullOrWhiteSpace(address)) { string preAddr = province + resultobj.regeocode.addressComponent.city + district + street; address = resultobj.regeocode.formatted_address.Remove(0, preAddr.Length); } } } }
//public void CopyTemplate(long templateId) //{ // var model = Context.FreightTemplateInfo.Where(e => e.Id == templateId).FirstOrDefault(); // FreightTemplateInfo templateInfo = new FreightTemplateInfo(); // templateInfo.IsFree = model.IsFree; // templateInfo.Name = model.Name + "复制"; // templateInfo.SendTime = model.SendTime; // templateInfo.ShippingMethod = model.ShippingMethod; // templateInfo.ShopID = model.ShopID; // templateInfo.ValuationMethod = model.ValuationMethod; // templateInfo.SourceAddress = model.SourceAddress; // templateInfo.Himall_FreightAreaContent = model.Himall_FreightAreaContent; // Context.FreightTemplateInfo.Add(templateInfo); // Context.SaveChanges(); // var oldArea = Context.FreightAreaDetailInfo.Where(a => a.FreightTemplateId == templateId).ToList(); // List<FreightAreaDetailInfo> infos = new List<FreightAreaDetailInfo>(); // var newAreas = templateInfo.Himall_FreightAreaContent.ToList(); // for (int i= 0;i < newAreas.Count; i++) // { // FreightAreaDetailInfo info = new FreightAreaDetailInfo(); // info.FreightAreaId = newAreas[i].Id; // info.FreightTemplateId = newAreas[i].FreightTemplateId; // info.CityId // } //} public void UpdateFreightTemplate(FreightTemplateInfo templateInfo) { FreightTemplateInfo model; if (templateInfo.Id == 0) { model = Context.FreightTemplateInfo.Add(templateInfo); Context.SaveChanges(); foreach (var t in templateInfo.Himall_FreightAreaContent) { foreach (var d in t.FreightAreaDetailInfo) { d.FreightAreaId = t.Id; d.FreightTemplateId = t.FreightTemplateId; Context.FreightAreaDetailInfo.Add(d); } } Context.SaveChanges(); } else { model = Context.FreightTemplateInfo.Where(e => e.Id == templateInfo.Id).FirstOrDefault(); model.Name = templateInfo.Name; model.IsFree = templateInfo.IsFree; model.ValuationMethod = templateInfo.ValuationMethod; model.ShopID = templateInfo.ShopID; model.SourceAddress = templateInfo.SourceAddress; model.SendTime = templateInfo.SendTime; using (TransactionScope scope = new TransactionScope()) { //先删除 Context.FreightAreaContentInfo.RemoveRange(Context.FreightAreaContentInfo.Where(e => e.FreightTemplateId == model.Id).ToList()); //删除详情表 Context.FreightAreaDetailInfo.RemoveRange(Context.FreightAreaDetailInfo.Where(a => a.FreightTemplateId == model.Id).ToList()); Context.SaveChanges();//保存主表 if (model.IsFree == FreightTemplateType.SelfDefine) { //重新插入地区运费 //model = context.FreightTemplateInfo.Where(e => e.Id == templateInfo.Id).FirstOrDefault(); // List<FreightAreaContentInfo> fre = new List<FreightAreaContentInfo>(); templateInfo.Himall_FreightAreaContent.ToList().ForEach(e => { //var freightContent = new FreightAreaContentInfo(); //freightContent.AreaContent = e.AreaContent; //freightContent.FirstUnit = e.FirstUnit; //freightContent.FirstUnitMonry = e.FirstUnitMonry; //freightContent.AccumulationUnit = e.AccumulationUnit; //freightContent.AccumulationUnitMoney = e.AccumulationUnitMoney; //freightContent.IsDefault = e.IsDefault; //freightContent.FreightTemplateId = model.Id; e.FreightTemplateId = model.Id; // fre.Add(freightContent); }); Context.FreightAreaContentInfo.AddRange(templateInfo.Himall_FreightAreaContent.ToList()); Context.SaveChanges(); // var index = 0; foreach (var t in templateInfo.Himall_FreightAreaContent) { foreach (var d in t.FreightAreaDetailInfo) { d.FreightAreaId = t.Id; d.FreightTemplateId = model.Id; Context.FreightAreaDetailInfo.Add(d); } } Context.SaveChanges(); } scope.Complete(); } Cache.Remove(CacheKeyCollection.CACHE_FREIGHTTEMPLATE(templateInfo.Id)); Cache.Remove(CacheKeyCollection.CACHE_FREIGHTAREADETAIL(templateInfo.Id)); } }
/// <summary> /// 发送手机或邮箱验证码 /// </summary> /// <param name="imageCheckCode"></param> /// <param name="contact"></param> /// <returns></returns> public object GetPhoneOrEmailCheckCode(string contact, string id = null, string imageCheckCode = null) { if (CurrentUser == null) { if (string.IsNullOrEmpty(imageCheckCode)) { return(ErrorResult("请输入验证码")); } var key = "ImageCheckCode:" + id; var systemCheckCode = Cache.Get <string>(key); if (systemCheckCode == null) { return(ErrorResult("验证码已过期")); } if (systemCheckCode.ToLower() != imageCheckCode.ToLower()) { return(ErrorResult("验证码错误")); } else { Cache.Remove(key); } } string msg; var checkResult = this.CheckContact(contact, out msg); if (!checkResult) { return(ErrorResult(string.IsNullOrEmpty(msg) ? "手机或邮箱号码不存在" : msg)); } PluginInfo pluginInfo; var isMobile = Core.Helper.ValidateHelper.IsMobile(contact); if (isMobile) { pluginInfo = PluginsManagement.GetInstalledPluginInfos(Core.Plugins.PluginType.SMS).First(); } else { pluginInfo = PluginsManagement.GetInstalledPluginInfos(PluginType.Email).First(); } if (pluginInfo == null) { Log.Error(string.Format("未找到{0}发送插件", isMobile ? "短信" : "邮件")); return(ErrorResult("验证码发送失败")); } var timeoutKey = CacheKeyCollection.MemberPluginCheckTime(contact, pluginInfo.PluginId); if (Core.Cache.Get(timeoutKey) != null) { return(ErrorResult("请求过于频繁,请稍后再试!")); } int cacheTime = 60; Core.Cache.Insert(timeoutKey, cacheTime, DateTime.Now.AddSeconds(cacheTime)); var checkCode = new Random().Next(10000, 99999); var siteName = Application.SiteSettingApplication.GetSiteSettings().SiteName; var message = new Himall.Core.Plugins.Message.MessageUserInfo() { UserName = contact, SiteName = siteName, CheckCode = checkCode.ToString() }; Application.MessageApplication.SendMessageCode(contact, pluginInfo.PluginId, message); //缓存验证码 Core.Cache.Insert(CacheKeyCollection.MemberPluginCheck(contact, pluginInfo.PluginId), checkCode, DateTime.Now.AddMinutes(10)); return(SuccessResult("验证码发送成功")); }
public ActionResult ReNewPayReturn(string id, decimal balance) { id = DecodePaymentId(id); string errorMsg = string.Empty; try { var payment = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id); var payInfo = payment.Biz.ProcessReturn(HttpContext.Request); ShopRenewRecord model = new ShopRenewRecord(); bool result = Cache.Get(CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds))) == null ? false : true; if (!result) { throw new Exception("支付未成功"); #region "废弃,因为参数不足,无法在这里处理续费逻辑" ////添加店铺续费记录 //model.ShopId = CurrentSellerManager.ShopId; //model.OperateDate = DateTime.Now; //model.Operator = CurrentSellerManager.UserName; //model.Amount = balance; ////续费操作 //if (type == 1) //{ // model.OperateType = ShopRenewRecord.EnumOperateType.ReNew; // var shopInfo = _iShopService.GetShop(CurrentSellerManager.ShopId); // string strNewEndTime = shopInfo.EndDate.Value.AddYears(value).ToString("yyyy-MM-dd"); // model.OperateContent = "续费 " + value + " 年至 " + strNewEndTime; // _iShopService.AddShopRenewRecord(model); // //店铺续费 // _iShopService.ShopReNew(CurrentSellerManager.ShopId, value); //} ////升级操作 //else //{ // model.ShopId = CurrentSellerManager.ShopId; // model.OperateType = ShopRenewRecord.EnumOperateType.Upgrade; // var shopInfo = _iShopService.GetShop(CurrentSellerManager.ShopId); // var shopGrade = _iShopService.GetShopGrades().Where(c => c.Id == shopInfo.GradeId).FirstOrDefault(); // var newshopGrade = _iShopService.GetShopGrades().Where(c => c.Id == (long)value).FirstOrDefault(); // model.OperateContent = "将套餐‘" + shopGrade.Name + "'升级为套餐‘" + newshopGrade.Name + "'"; // _iShopService.AddShopRenewRecord(model); // //店铺升级 // _iShopService.ShopUpGrade(CurrentSellerManager.ShopId, (long)value); //} ////写入支付状态缓存 //string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds));//获取支付状态缓存键 //Cache.Insert(payStateKey, true);//标记为已支付 #endregion } } catch (Exception ex) { errorMsg = ex.Message; } ViewBag.Error = errorMsg; return(View()); }
public string GetShopGoodTagFromCache(long shopId, long page, string tName = "") { string crrentTemplateName = "t1"; string html = string.Empty; var curr = new Himall.Model.TemplateVisualizationSettingsInfo(); if (Core.Cache.Exists(CacheKeyCollection.MobileHomeTemplate(shopId.ToString())))//如果存在缓存,则从缓存中读取 { curr = Core.Cache.Get <Himall.Model.TemplateVisualizationSettingsInfo>(CacheKeyCollection.MobileHomeTemplate(shopId.ToString())); } else { curr = Context.TemplateVisualizationSettingsInfo.FirstOrDefault(t => t.ShopId.Equals(shopId)); Core.Cache.Insert <Himall.Model.TemplateVisualizationSettingsInfo>(CacheKeyCollection.MobileHomeTemplate(shopId.ToString()), curr); } if (curr != null) { crrentTemplateName = curr.CurrentTemplateName; } if (!string.IsNullOrWhiteSpace(tName)) { crrentTemplateName = tName; } if (Core.Cache.Exists(CacheKeyCollection.MobileShopHomeProductInfo(shopId.ToString(), crrentTemplateName, page)))//如果存在缓存,则从缓存中读取 { html = Core.Cache.Get(CacheKeyCollection.MobileShopHomeProductInfo(shopId.ToString(), crrentTemplateName, page)).ToString(); } return(html); }
// GET: SellerAdmin/Shop public JsonResult SaveFreightSetting(ShopFreightModel shopFreight) { _iShopService.UpdateShopFreight(CurrentSellerManager.ShopId, shopFreight.Freight, shopFreight.FreeFreight); Cache.Remove(CacheKeyCollection.CACHE_SHOP(CurrentSellerManager.ShopId, false)); return(Json(new { success = true })); }
private int GetErrorTimes(string username) { object obj = Cache.Get(CacheKeyCollection.MemberLoginError(username)); return(obj == null ? 0 : (int)obj); }
/// <summary> /// 异步导入商品 /// </summary> /// <param name="paraCategory"></param> /// <param name="paraShopCategory"></param> /// <param name="paraBrand"></param> /// <param name="paraSaleStatus"></param> /// <param name="_shopid"></param> /// <param name="_userid"></param> /// <param name="file">压缩文件名</param> /// <returns></returns> public void ImportProductAsync(long paraCategory, long paraShopCategory, long?paraBrand, int paraSaleStatus, long _shopid, long _userid, long freightId, string file) { /* * 产品ID/主图 * 产品ID/Details/明细图片 */ AsyncManager.OutstandingOperations.Increment(); Task.Factory.StartNew(() => { string filePath = Server.MapPath("/temp/" + file); string imgpath1 = string.Format(@"/Storage/Shop/{0}/Products", _shopid); string imgpath2 = Server.MapPath(imgpath1); long brand = 0; if (paraBrand.HasValue) { brand = paraBrand.Value; } JsonResult result = new JsonResult(); if (System.IO.File.Exists(filePath)) { try { ZipHelper.ZipInfo zipinfo = ZipHelper.UnZipFile(filePath); if (zipinfo.Success) { int intCnt = ProcessProduct(paraCategory, paraShopCategory, brand, paraSaleStatus, _shopid, _userid, freightId, zipinfo.UnZipPath, imgpath1, imgpath2); if (intCnt > 0) { AsyncManager.Parameters["success"] = true; AsyncManager.Parameters["message"] = "成功导入【" + intCnt.ToString() + "】件商品"; } else { Core.Cache.Remove(CacheKeyCollection.UserImportProductCount(_userid)); Core.Cache.Remove(CacheKeyCollection.UserImportProductTotal(_userid)); AsyncManager.Parameters["success"] = false; AsyncManager.Parameters["message"] = "导入【0】件商品,请检查数据包格式,或是否重复导入"; } } else { Core.Log.Error("解压文件异常:" + zipinfo.InfoMessage); AsyncManager.Parameters["success"] = false; AsyncManager.Parameters["message"] = "解压出现异常,请检查压缩文件格式"; } } catch (Exception ex) { Core.Log.Error("导入商品异常:" + ex.Message); Core.Cache.Remove(CacheKeyCollection.UserImportProductCount(_userid)); Core.Cache.Remove(CacheKeyCollection.UserImportProductTotal(_userid)); AsyncManager.Parameters["success"] = false; AsyncManager.Parameters["message"] = "导入商品异常:" + ex.Message; } } else { AsyncManager.Parameters["success"] = false; AsyncManager.Parameters["message"] = "上传文件不存在"; } AsyncManager.OutstandingOperations.Decrement(); object opcount = Core.Cache.Get(CacheKeyCollection.UserImportOpCount); if (opcount != null) { Core.Cache.Insert(CacheKeyCollection.UserImportOpCount, int.Parse(opcount.ToString()) - 1); } }); }
public void DeleteCartItem(IEnumerable <string> skuIds, long memberId) { base.Context.ShoppingCartItemInfo.Remove <ShoppingCartItemInfo>(item => (skuIds.Contains <string>(item.SkuId) && (item.UserId == memberId)) && !item.ShopBranchId.HasValue); base.Context.SaveChanges(); Cache.Remove(CacheKeyCollection.CACHE_CART(memberId)); }
public void ClearCart(long memeberId, long shopbranchId) { DbFactory.Default.Del <ShoppingCartInfo>().Where(item => item.UserId == memeberId && item.ShopBranchId.ExIsNotNull() && item.ShopBranchId.ExIfNull(0) == shopbranchId).Succeed(); Cache.Remove(CacheKeyCollection.CACHE_BRANCHCART(memeberId)); }