/// <summary> /// 获取商品 /// 商品不存在时返回null,存在时同时获取关联的数据 /// 结果会按商品Id缓存一定时间 /// </summary> /// <param name="productId"></param> /// <returns></returns> public virtual Entities.Product GetWithCache(Guid productId) { return(ProductCache.GetOrCreate(productId, () => { using (UnitOfWork.Scope()) { var product = Get(productId); if (product == null) { return null; // 商品不存在 } var category = product.Category; if (category != null) { category.Properties.ToList(); category.Properties.SelectMany(p => p.PropertyValues).ToList(); } var seller = product.Seller; if (seller != null) { var _ = seller.Username; } product.MatchedDatas.ToList(); product.PropertyValues.ToList(); return product; } }, ProductCacheTime)); }
public ActionResult Index() { try { CustomIdentity customIdentity = null; if (ControllerContext.HttpContext.User.Identity.IsAuthenticated) { customIdentity = (CustomIdentity)ControllerContext.HttpContext.User.Identity; } string username = string.Empty; if (customIdentity != null) { username = customIdentity.Name; } //ProductBO productBO = new ProductBO(username); ProductCache cache = new ProductCache(); List <Product> list = (List <Product>)cache.GetAvailableProducts(username);//productBO.GetCampains(); return(View(list.Where(x => x.IsCampain == true).ToList())); } catch (Exception) { throw; } }
/// <summary> /// Does the express checkout. /// </summary> /// <param name="order">The order.</param> /// <param name="authorizeOnly">if set to <c>true</c> [authorize only].</param> /// <param name="userName">Name of the user.</param> /// <returns></returns> public static Transaction DoExpressCheckout(Order order, bool authorizeOnly, string userName) { PaymentService paymentService = new PaymentService(); Transaction transaction = paymentService.DoExpressCheckout(order, authorizeOnly); order.OrderStatusDescriptorId = (int)OrderStatus.ReceivedPaymentProcessingOrder; order.Save(userName); try { //Adjust the Inventory Sku sku; foreach (OrderItem orderItem in order.OrderItemCollection) { sku = new Sku(SKU, orderItem.Sku); sku.Inventory = sku.Inventory - orderItem.Quantity; sku.Save(SYSTEM); ProductCache.RemoveSKUFromCache(orderItem.Sku); } //Send out the messages MessageService messageService = new MessageService(); messageService.SendOrderReceivedNotificationToCustomer(order); messageService.SendOrderReceivedNotificationToMerchant(order); } catch (Exception ex) { //swallow the exception here because the transaction is saved //and, while this is an inconvenience, it's not critical Logger.Error(typeof(OrderController).Name + ".DoExpressCheckout", ex); } return(transaction); }
public ActionResult GetProductSKUInfoFromCache(int cateid, int pid) { ProductCache pcache = RemotingHelp.GetModelObject <ProductCache>(); var skuinfos = pcache.GetProductInfoFromCache(cateid, pid).skuInfos; List <ShowSkuInfoForLayuiTable> list = new List <ShowSkuInfoForLayuiTable>(); foreach (var skuinfo in skuinfos) { ShowSkuInfoForLayuiTable newitem = new ShowSkuInfoForLayuiTable() { sku_guid = skuinfo.sku_guid, sku_input = skuinfo.sku_input, sku_isdefaultprice = skuinfo.sku_isdefaultprice, sku_isdefaultprice_text = skuinfo.sku_isdefaultprice == 0 ? "否" : "是", sku_price = skuinfo.sku_price, sku_price_text = skuinfo.sku_price == -1 ? "默认" : skuinfo.sku_price.ToString(), sku_stock = skuinfo.sku_stock, sku_stock_text = skuinfo.sku_stock == -1 ? "默认" : skuinfo.sku_stock.ToString() }; list.Add(newitem); } return(Json( new LayuiTableApiResult() { code = 0, msg = "", count = list.Count, data = list }, JsonRequestBehavior.AllowGet)); }
// GET: Common public ActionResult ModelQuery(string modelCode) { /*List<Series> seriesList = productService.doFindAllSeries(); * ViewData["seriesList"] = seriesList;*/ ViewData["modelCode"] = modelCode; ViewData["seriesList"] = ProductCache.GetSeriesDic(); return(View("ModelQuery")); }
public Model doGetModelInfo(string modelCode) { IDictionary <string, Model> modelDic = ProductCache.GetModelDic(); return(modelDic[modelCode]); //BaseDao<Model> baseDao = DaoFactory<Model>.CreateBaseDao(typeof(Model)); //return baseDao.FindByid("SELECT BSCLDM AS ModelCode,XSCLMC AS ModelName,XSCXFL SeriesCode FROM SJVDTALIB.KCM09 MODEL WHERE ZMDWDM='08' AND BSCLDM =@MODEL_CODE", "MODEL_CODE", modelCode); }
/// <summary> /// Refunds the specified transaction. /// </summary> /// <param name="transaction">The transaction.</param> /// <param name="refundedOrder">The order the refund should be applied to.</param> /// <param name="userName">Name of the user.</param> public static void Refund(Transaction transaction, Order refundedOrder, string userName) { Order order = new Order(transaction.OrderId); PaymentService paymentService = new PaymentService(); Transaction refundTransaction = paymentService.Refund(transaction, refundedOrder); refundedOrder.Save(userName); //set the orderid for the refund foreach (OrderItem orderItem in refundedOrder.OrderItemCollection) { orderItem.OrderId = refundedOrder.OrderId; } refundedOrder.OrderItemCollection.SaveAll(userName); //set the orderId to the refunded orderId refundTransaction.OrderId = refundedOrder.OrderId; refundTransaction.Save(userName); Guid userGuid = new Guid(Membership.GetUser(order.UserName).ProviderUserKey.ToString()); foreach (OrderItem orderItem in refundedOrder.OrderItemCollection) { new Product(orderItem.ProductId); //put the stock back Sku sku = new Sku(Sku.Columns.SkuX, orderItem.Sku); sku.Inventory = sku.Inventory + orderItem.Quantity; sku.Save(userName); ProductCache.RemoveSKUFromCache(orderItem.Sku); //remove the access control DownloadCollection downloadCollection = new ProductController().FetchAssociatedDownloadsByProductIdAndForPurchase(orderItem.ProductId); if (downloadCollection.Count > 0) { foreach (Download download in downloadCollection) { new DownloadAccessControlController().Delete(userGuid, download.DownloadId); } } } if (refundedOrder.Total == order.Total) { order.OrderStatusDescriptorId = (int)OrderStatus.OrderFullyRefunded; } else { order.OrderStatusDescriptorId = (int)OrderStatus.OrderPartiallyRefunded; } order.Save(userName); //Add an OrderNote OrderNote orderNote = new OrderNote(); orderNote.OrderId = order.OrderId; orderNote.Note = Strings.ResourceManager.GetString(ORDER_REFUNDED); orderNote.Save(userName); //send off the notifications MessageService messageService = new MessageService(); messageService.SendOrderRefundToCustomer(refundedOrder); }
private void CreateProductCache(uint timeout, uint warningThreshold) { _productCache = new ProductCache <Tuple <bool, DataCached> >(timeout) { WarningThreshold = warningThreshold }; _productCache.ThreadName = "GenericMonitorControl 缓冲池线程"; _productCache.ProductCreated += OnCacheProductCreated; _productCache.Open(); }
private void CheckChangeImg(Product product, ProductCache productInCache) { var hashImageNew = product.GetHashImage(); var hashImageOld = productInCache.hash_image; if (product.Valid && hashImageNew != hashImageOld && !string.IsNullOrEmpty(product.ImageUrl)) { _productIdWaitChangeImage.Add(product.ID); } }
public ActionResult Product(int cateid = 0, int isonsale = -1) { ProductCache pcache = RemotingHelp.GetModelObject <ProductCache>(); ViewBag.productList = pcache.GetProductList(cateid, isonsale); ViewBag.cateid = cateid; PRODUCT product = RemotingHelp.GetModelObject <PRODUCT>(); ViewBag.cates = product.GetCategories(); ViewBag.isonsale = isonsale; return(View()); }
public ActionResult BannerAdd(int bannerid = 0) { ViewBag.bannerid = bannerid; if (bannerid > 0) { BannerCache bannerCache = RemotingHelp.GetModelObject <BannerCache>(); ViewBag.banner = bannerCache.GetBanners().SingleOrDefault(t => t.id == bannerid); } ProductCache productCache = RemotingHelp.GetModelObject <ProductCache>(); ViewBag.products = productCache.GetNoRepeatProducts(); return(View()); }
public Color doGetColorInfo(string colorCode) { IDictionary <string, string> colorDic = ProductCache.GetColorDic(); Color color = null; if (colorDic.ContainsKey(colorCode)) { color = new Color(); color.ColorCode = colorCode; color.ColorName = colorDic[colorCode]; } return(color); }
public Interior doGetInteriorInfo(string interiorCode) { IDictionary <string, string> interiorDic = ProductCache.GetInteriorDic(); Interior interior = null; if (interiorDic.ContainsKey(interiorCode)) { interior = new Interior(); interior.InteriorCode = interiorCode; interior.InteriorName = interiorDic[interiorCode]; } return(interior); }
public static void Subscribe() { RedisManager.Subscribe("RefreshProductCache", (channel, info) => { try { // Console.WriteLine(info); var qrefresh = JsonConvert.DeserializeObject <IEnumerable <ObjectModels.DTOs.MemoryCacheRefreshQuery> >(info); ProductCache.RefreshProduct(qrefresh); } catch { } }); }
public ActionResult CouponAdd(int coupontypeid = 0) { ViewBag.coupontypeid = coupontypeid; ViewBag.coupontype = null; if (coupontypeid > 0) { COUPON coupon = RemotingHelp.GetModelObject <COUPON>(); ViewBag.coupontype = (coupon.GetCouponType().data as List <ShowCouponTypeInfo>).SingleOrDefault(t => t.ct_coupontypeid == coupontypeid); } ProductCache productCache = RemotingHelp.GetModelObject <ProductCache>(); ViewBag.products = productCache.GetNoRepeatProducts(); return(View()); }
protected override void Dispose(bool disposing) { if (_logCache != null) { if (disposing) { _logCache.Close(); } _logCache = null; } base.Dispose(disposing); }
public void Show() { _controller = _controller ?? GetComponent <MultiProductShopController>(); _productCache = _productCache ?? new ProductCache(); if (_waitForHiddenAndDeactivateRoutine != null) { StopCoroutine(_waitForHiddenAndDeactivateRoutine); } gameObject.SetActive(true); Animator.Play("Show", 0); _controller.Load(); }
private void CheckChangePrice(Product product, ProductCache productInCache) { if (product.Price != productInCache.price) { this._jobClientLogChangePrice.PushQueueChangePriceLog(new JobRabbitChangePrice() { Name = product.Name, OldPrice = productInCache.price, NewPrice = product.Price, ProductID = product.ID, CompanyID = product.IDCongTy }); } }
/// <summary> /// Gets the inventory. /// </summary> /// <param name="skuId">The sku id.</param> public void GetInventory(string skuId) { if (ThisPage.Product.AllowNegativeInventories) { ThisPage.AddToCart.Enabled = true; } else { Sku sku = ProductCache.GetSKU(skuId); if (sku.SkuId > 0 && sku.Inventory > 0) { string previouslySelectedValue = ThisPage.Quantity.SelectedValue; ThisPage.AddToCart.Enabled = true; ThisPage.Quantity.Enabled = true; ThisPage.Quantity.Items.Clear(); if (sku.Inventory < SiteSettingCache.GetSiteSettings().MaxProductsAddToCart) { for (int i = 1; i <= sku.Inventory; i++) { ThisPage.Quantity.Items.Add(new ListItem(i.ToString(), i.ToString())); } } else { for (int i = 1; i <= SiteSettingCache.GetSiteSettings().MaxProductsAddToCart; i++) { ThisPage.Quantity.Items.Add(new ListItem(i.ToString(), i.ToString())); } } //If they selected a quantity and the quantity is valid for the new selection then keep it selected //Otherwise, select the first one. if (ThisPage.Quantity.Items.FindByValue(previouslySelectedValue) != null) { ThisPage.Quantity.SelectedValue = previouslySelectedValue; } else { ThisPage.Quantity.SelectedIndex = 0; } } else { ThisPage.Quantity.Enabled = false; ThisPage.AddToCart.Enabled = false; } } }
public ActionResult ProductEdit(int cateid = 0, int pid = 0) { if (cateid == 0) { return(null); } ProductCache pcache = RemotingHelp.GetModelObject <ProductCache>(); ViewBag.ProductInfo = pcache.GetProductInfoFromCache(cateid, pid); PRODUCT product = RemotingHelp.GetModelObject <PRODUCT>(); ViewBag.allcates = product.GetCategories(); ViewBag.pcates = product.GetCategories(pid); return(View()); }
public IDictionary <string, string> doFindModelList(string seriesCode, string modelCode) { IDictionary <string, Model> modelDic = ProductCache.GetModelDic(); if (!string.IsNullOrWhiteSpace(seriesCode)) { return(modelDic.Where(x => x.Value.SeriesCode == seriesCode).ToDictionary(x => x.Key, x => x.Value.ModelName)); } else if (!string.IsNullOrWhiteSpace(modelCode)) { return(modelDic.Where(x => x.Key.Contains(modelCode)).ToDictionary(x => x.Key, x => x.Value.ModelName)); } else { return(modelDic.ToDictionary(x => x.Key, x => x.Value.ModelName)); } }
public IDictionary <string, string> doFindInteriorList(string interiorCode, string interiorName) { IDictionary <string, string> interiorDic = ProductCache.GetInteriorDic(); if (!string.IsNullOrWhiteSpace(interiorCode)) { return(interiorDic.Where(x => x.Key.Contains(interiorCode)).ToDictionary(x => x.Key, x => x.Value)); } else if (!string.IsNullOrWhiteSpace(interiorName)) { return(interiorDic.Where(x => x.Key.Contains(interiorName)).ToDictionary(x => x.Key, x => x.Value)); } else { return(ProductCache.GetInteriorDic()); } }
public IDictionary <string, string> doFindColorList(string colorCode, string colorName) { IDictionary <string, string> colorDic = ProductCache.GetColorDic(); if (!string.IsNullOrWhiteSpace(colorCode)) { return(colorDic.Where(x => x.Key.Contains(colorCode)).ToDictionary(x => x.Key, x => x.Value)); } else if (!string.IsNullOrWhiteSpace(colorName)) { return(colorDic.Where(x => x.Value.Contains(colorName)).ToDictionary(x => x.Key, x => x.Value)); } else { return(colorDic); } }
/// <summary> /// 获取商品 /// 商品不存在时返回null,存在时同时获取关联的数据 /// 结果会按商品Id缓存一定时间 /// </summary> /// <param name="productId"></param> /// <returns></returns> public virtual Database.Product GetProduct(long productId) { return(ProductCache.GetOrCreate(productId, () => UnitOfWork.ReadData <Database.Product, Database.Product>(r => { var product = r.GetByIdWhereNotDeleted(productId); var category = product.Category; if (category != null) { category.Properties.ToList(); category.Properties.SelectMany(p => p.PropertyValues).ToList(); } var seller = product.Seller; if (seller != null) { var _ = seller.Username; } product.MatchedDatas.ToList(); product.PropertyValues.ToList(); return product; }), ProductCacheTime)); }
async void GetInterestAndProduct() { var api = this.api; var Comp = api.CompanyEntity; InterestCache = Comp.GetCache(typeof(Uniconta.DataModel.CrmInterest)) ?? await api.LoadCache(typeof(Uniconta.DataModel.CrmInterest)); cmbInterests.ItemsSource = InterestCache?.GetKeyList(); ProductCache = Comp.GetCache(typeof(Uniconta.DataModel.CrmProduct)) ?? await api.LoadCache(typeof(Uniconta.DataModel.CrmProduct)); cmbProducts.ItemsSource = ProductCache?.GetKeyList(); Debtors = Comp.GetCache(typeof(Uniconta.DataModel.Debtor)) ?? await api.LoadCache(typeof(Uniconta.DataModel.Debtor)); Prospects = Comp.GetCache(typeof(Uniconta.DataModel.CrmProspect)) ?? await api.LoadCache(typeof(Uniconta.DataModel.CrmProspect)); Creditors = Comp.GetCache(typeof(Uniconta.DataModel.Creditor)) ?? await api.LoadCache(typeof(Uniconta.DataModel.Creditor)); Contacts = Comp.GetCache(typeof(Uniconta.DataModel.Contact)) ?? await api.LoadCache(typeof(Uniconta.DataModel.Contact)); }
public PageResult <RetailOrderQueryListVo> QueryRetailOrderList(QueryCriteria queryCriteria) { PageResult <RetailOrderQueryListVo> result = doFindRetailOrderByCondition(queryCriteria); if (result.Content.Count > 0) { IDictionary <string, ModelGroup> modelGroupDic = ProductCache.GetModelGroupDic(); foreach (var item in result.Content) { string key = item.ModelCode + item.Interior + item.PrList; if (modelGroupDic.ContainsKey(key)) { item.ModelYear = modelGroupDic[key].ModelYear.ToString(); item.ModelVersion = modelGroupDic[key].ModelVersion; item.PrList = modelGroupDic[key].PrList; } else { item.ModelYear = "数据错误"; item.ModelVersion = "数据错误"; item.PrList = item.PrList + "数据错误"; } IDictionary <string, string> colorDic = ProductCache.GetColorDic(); if ((item.Color != null) && colorDic.ContainsKey(item.Color)) { item.Color = item.Color + "(" + item.Color1 + ")" + '-' + colorDic[item.Color]; } else { item.Color = item.Color + "(" + item.Color1 + ")"; } item.SalesSource = RetailCache.GetSalesSource(item.SalesSource); item.OrderStatus = RetailCache.GetOrderStatus(item.OrderStatus); item.Accessory = RetailCache.GetYesNo(item.Accessory); item.Club = RetailCache.GetYesNo(item.Club); } } return(result); }
/// <summary> /// Commits the standard transaction. /// </summary> /// <param name="order">The order.</param> /// <param name="transactionId">The transaction id.</param> /// <param name="grossAmount">The gross amount.</param> /// <returns></returns> public static Transaction CommitStandardTransaction(Order order, string transactionId, decimal grossAmount) { order.OrderStatusDescriptorId = (int)OrderStatus.ReceivedPaymentProcessingOrder; order.Save(SYSTEM); Transaction transaction = new Transaction(); transaction.OrderId = order.OrderId; transaction.TransactionTypeDescriptorId = (int)TransactionType.Charge; transaction.PaymentMethod = PAYPAL; transaction.GatewayName = PAYPAL_STANDARD; transaction.GatewayResponse = SUCCESS; transaction.GatewayTransactionId = transactionId; transaction.GrossAmount = grossAmount; transaction.TransactionDate = DateTime.UtcNow; transaction.Save(SYSTEM); try { //Adjust the Inventory Sku sku; foreach (OrderItem orderItem in order.OrderItemCollection) { sku = new Sku("Sku", orderItem.Sku); sku.Inventory = sku.Inventory - orderItem.Quantity; sku.Save("System"); ProductCache.RemoveSKUFromCache(orderItem.Sku); } //Send out the messages MessageService messageService = new MessageService(); messageService.SendOrderReceivedNotificationToCustomer(order); messageService.SendOrderReceivedNotificationToMerchant(order); } catch (Exception ex) { //swallow the exception here because the transaction is saved //and, while this is an inconvenience, it's not critical Logger.Error(typeof(OrderController).Name + ".CommitStandardTransaction", ex); } return(transaction); }
private void Awake() { _controller = GetComponent <MultiProductShopController>(); _productCache = new ProductCache(); }
private void ProcessJob(long pId, string url) { if (string.IsNullOrEmpty(url)) { return; } if (!ExistInCache(pId, url)) { return; } if (!IsLinkProduct(pId, url)) { return; } ProductCache ptCache = null; if (_dicCacheProduct.ContainsKey(pId)) { ptCache = _dicCacheProduct[pId]; } var pt = new Product() { ID = pId }; DelayTime(); var status = Analysic(pt, url); if (status == WebExceptionStatus.Timeout || status == WebExceptionStatus.ConnectFailure) { _log.Info(string.Format("Fail download link: {0}", status)); } else { _countVisited++; if (pt.Valid) { _countProduct++; if (_dicDuplicate.ContainsKey(pt.GetHashCheckDuplicate()) && _dicDuplicate[pt.GetHashCheckDuplicate()] != pt.ID) { _productIdWaitDeleteGroup.Add(pt.ID); LogProduct_ChangeInfo(DateTime.Now, pt.ImageUrl, pt.Name, "duplicate info", pt.Price, pt.ID, (int)pt.Instock, _session, url, pt.Valid); } else { CheckChangeDesc(pt); if (ptCache == null || pt.GetHashChange() != ptCache.hash_change) { CheckChangePrice(pt, ptCache); CheckChangeImg(pt, ptCache); LogProduct_ChangeInfo(DateTime.Now, pt.ImageUrl, pt.Name, "change info", pt.Price, pt.ID, (int)pt.Instock, _session, url, pt.Valid); if (_dicCacheProduct.ContainsKey(pt.ID)) { lock (_productWaitUpdateGroup) { _productWaitUpdateGroup.Add(pt); } } else { _productWaitInsertGroup.Add(pt); } } else { LogProduct_ChangeInfo(DateTime.Now, "", "", "Not change", 0, pId, 0, _session, pt.DetailUrl, false); } } } else { if (_dicTrackDie.ContainsKey(pt.ID) && _dicTrackDie[pt.ID] > 1) { _productIdWaitDeleteGroup.Add(pt.ID); } else { _cacheCheckDelete.IncreatementDieProduct(_companyId, pt.ID); } } } }
public static void ClearCache() { ProductCache?.Clear(); }