Example #1
0
        public SingleGoodsModel(SingleGoods model)
        {
            SingleGoodsId = model.Id;
            SingleGoodsNo = model.SingleGoodsNo;
            Price         = model.Price;
            Stock         = model.Stock;
            Unit          = model.Unit;
            Image         = model.Image;
            GrouponPrice  = model.GrouponPrice;

            Attributes = model.Attributes.Select(me => new SingleGoodsAttributeModel
            {
                AttributeId    = me.AttributeId,
                AttributeValue = me.AttributeValue
            }).ToList();
        }
Example #2
0
        public OrderCalculationGoodsModel(SingleGoods model, int quantity)
        {
            GoodsId        = model.GoodsId;
            SingleGoodsId  = model.Id;
            Quantity       = quantity;
            GoodsName      = model.Goods.Name;
            GoodsAttribute = string.Join(",", model.Attributes.Select(me => me.AttributeValue).ToList());
            Price          = model.Goods.IsGroupon ? ((model.Goods.GrouponStartTime <= DateTime.Now && DateTime.Now <= model.Goods.GrouponEndTime) ? model.GrouponPrice : model.Price) : model.Price;

            var fileService = HostConstObject.Container.Resolve <IStorageFileService>();

            var goodsImage = fileService.GetFiles(SingleGoodsId, MallModule.Instance.InnerKey, GoodsId.ToString()).FirstOrDefault() ??
                             fileService.GetFiles(GoodsId, MallModule.Key, "MainImage").FirstOrDefault();

            GoodsImage = goodsImage?.Simplified();
        }
Example #3
0
    public int GetRemainBuyCount(long goodsNumber)
    {
        for (int i = 0; i < this.m_BuyGoodsInfos.get_Count(); i++)
        {
            if (this.m_BuyGoodsInfos.get_Item(i).goodsNumber == goodsNumber)
            {
                return(this.m_BuyGoodsInfos.get_Item(i).remainBuyCount);
            }
        }
        SingleGoods good = this.GetGood(goodsNumber);

        if (good != null)
        {
            return(good.limitBuyCount);
        }
        return(0);
    }
Example #4
0
    public List <SingleGoods> GetCurrentShowGoods()
    {
        if (this.m_TimeLimitedSalesRes == null)
        {
            return(null);
        }
        List <SingleGoods> list = new List <SingleGoods>();

        for (int i = 0; i < this.m_TimeLimitedSalesRes.goods.get_Count(); i++)
        {
            SingleGoods singleGoods = this.m_TimeLimitedSalesRes.goods.get_Item(i);
            if (this.IsGoodShow(singleGoods))
            {
                list.Add(singleGoods);
            }
        }
        return(list);
    }
    private void OnClickButton()
    {
        SingleGoods good = LimitTimeMarketManager.Instance.GetGood(this.goodsNumber);

        if (good == null)
        {
            return;
        }
        if (this.IsTimeOver())
        {
            UIManagerControl.Instance.ShowToastText("购买日期截止,无法购买");
            return;
        }
        UIManagerControl.Instance.OpenUI("BuyUI", UINodesManager.MiddleUIRoot, false, UIType.NonPush);
        BuyUIViewModel.Instance.BuyCallback = delegate(int count)
        {
            this.DoOK();
        };
        BuyUIViewModel.Instance.RefreshInfo(good.goodsInfo.cfgId, good.goodsInfo.count, good.priceInfo.price, 1);
    }
Example #6
0
    private void RefreshGoods()
    {
        List <SingleGoods> goods = LimitTimeMarketManager.Instance.GetCurrentShowGoods();

        if (goods == null)
        {
            this.m_listPool.Create(0, null);
            return;
        }
        this.m_listPool.Create(goods.get_Count(), delegate(int index)
        {
            if (index < goods.get_Count() && index < this.m_listPool.Items.get_Count())
            {
                LimitTimeShoppingUnit component = this.m_listPool.Items.get_Item(index).GetComponent <LimitTimeShoppingUnit>();
                SingleGoods singleGoods         = goods.get_Item(index);
                component.goodsNumber           = singleGoods.goodsNumber;
                component.SetItem(singleGoods.goodsInfo.cfgId, singleGoods.goodsInfo.count);
                component.SetPrice(singleGoods.priceInfo.originalCost, singleGoods.priceInfo.price);
                component.SetCount(LimitTimeMarketManager.Instance.GetRemainBuyCount(singleGoods.goodsNumber));
                component.SetEndTime(singleGoods.limitSecond);
            }
        });
    }
Example #7
0
        public ActionResult EditOnPost(GoodsViewModel postGoods)
        {
            var result   = new DataJsonResult();
            var category = _currencyService.GetSingleById <GoodsCategory>(postGoods.CategoryId);

            if (category.ParentId == Guid.Empty)
            {
                result.ErrorMessage = "一级分类下不能添加产品";
            }
            else
            {
                postGoods.SingleGoods = postGoods.SingleGoodsJson.DeserializeJsonToList <SingleGoodsViewModel>();
                var goods = _currencyService.GetSingleById <Goods>(postGoods.Id);
                var isNew = false;
                if (goods == null)
                {
                    goods = new Goods
                    {
                        Id            = postGoods.Id,
                        CategoryId    = postGoods.CategoryId,
                        BrandId       = postGoods.BrandId,
                        Name          = postGoods.Name,
                        OriginalPrice = postGoods.OriginalPrice,
                        GoodsType     = postGoods.GoodsType,
                        GoodsNo       = postGoods.GoodsNo,
                        Description   = postGoods.Description,
                        Status        = GoodsStatus.NotInSale,
                        CreateTime    = DateTime.Now,
                        SingleGoods   = new List <SingleGoods>(),
                        FreeShipping  = postGoods.FreeShipping,
                        IsHot         = postGoods.IsHot,
                        IsNew         = postGoods.IsNew,
                        IsBest        = postGoods.IsBest,
                        UsualWeight   = postGoods.UsualWeight,
                        IsPresell     = postGoods.IsPresell,
                        Brief         = postGoods.Brief,
                        Sort          = postGoods.Sort
                    };
                    goods.LastUpdateTime = goods.CreateTime;
                    isNew = true;
                }
                else
                {
                    goods.CategoryId     = postGoods.CategoryId;
                    goods.BrandId        = postGoods.BrandId;
                    goods.Name           = postGoods.Name;
                    goods.OriginalPrice  = postGoods.OriginalPrice;
                    goods.GoodsNo        = postGoods.GoodsNo;
                    goods.GoodsType      = postGoods.GoodsType;
                    goods.Description    = postGoods.Description;
                    goods.SingleGoods    = new List <SingleGoods>();
                    goods.LastUpdateTime = DateTime.Now;
                    goods.FreeShipping   = postGoods.FreeShipping;
                    goods.IsHot          = postGoods.IsHot;
                    goods.IsNew          = postGoods.IsNew;
                    goods.IsBest         = postGoods.IsBest;
                    goods.UsualWeight    = postGoods.UsualWeight;
                    goods.IsPresell      = postGoods.IsPresell;
                    goods.Brief          = postGoods.Brief;
                    goods.Sort           = postGoods.Sort;
                }

                foreach (var postSingleGoods in postGoods.SingleGoods)
                {
                    if (postSingleGoods.Stock > 0)
                    {
                        var singleGoods = new SingleGoods
                        {
                            Id           = postSingleGoods.Id,
                            CreateTime   = goods.CreateTime,
                            Stock        = postSingleGoods.Stock,
                            Unit         = postSingleGoods.Unit,
                            Price        = postSingleGoods.Price,
                            GoodsId      = goods.Id,
                            Weight       = postSingleGoods.Weight,
                            GrouponPrice = postSingleGoods.GrouponPrice,
                            Attributes   = new List <SingleGoodsAttribute>(),
                        };

                        foreach (var attr in postSingleGoods.Attrs)
                        {
                            singleGoods.Attributes.Add(new SingleGoodsAttribute
                            {
                                Id             = KeyGenerator.GetGuidKey(),
                                AttributeId    = attr.Id,
                                AttributeValue = attr.Val.Trim(),
                                SingleGoodsId  = singleGoods.Id
                            });
                        }
                        singleGoods.Image = new StorageFile {
                            Id = postSingleGoods.Image?.Id ?? Guid.Empty
                        }.Simplified();
                        goods.SingleGoods.Add(singleGoods);
                    }
                }

                goods.ShopPrice    = goods.SingleGoods.Min(g => g.Price);
                goods.Stock        = goods.SingleGoods.Sum(g => g.Stock);
                goods.GrouponPrice = goods.SingleGoods.Min(g => g.GrouponPrice);

                result.Success = _goodsService.SaveGoods(goods, isNew);

                if (result.Success)
                {
                    //扩展分类
                    _goodsCategoryService.DeleteRelations(goods.Id);
                    if (!string.IsNullOrWhiteSpace(postGoods.ExtendCategoryIds))
                    {
                        foreach (var cId in postGoods.ExtendCategoryIds.Split(','))
                        {
                            var relateModel = new GoodsCategoryRelation()
                            {
                                GoodsId    = goods.Id,
                                CategoryId = cId.ToGuid()
                            };
                            _goodsCategoryService.InsetCategoryRelation(relateModel);
                        }
                    }

                    //佣金
                    _currencyService.DeleteByConditon <GoodsCommission>(c => c.GoodsId.Equals(goods.Id));
                    for (int i = 0; i < postGoods.Commission.Length; i++)
                    {
                        _currencyService.Create(new GoodsCommission
                        {
                            Id      = KeyGenerator.GetGuidKey(),
                            GoodsId = goods.Id,
                            Level   = i + 1,
                            Value   = postGoods.Commission[i]
                        });
                    }
                }

                //处理主图图片关联
                _storageFileService.ReplaceFile(goods.Id, MallModule.Key, MallModule.DisplayName, postGoods.MainImage, MainImage);
            }

            return(Json(result));
        }
Example #8
0
 private bool IsGoodShow(SingleGoods good)
 {
     return(TimeManager.Instance.GetRemainSecond(good.beginUtc) <= 0 && TimeManager.Instance.GetRemainSecond(good.endUtc) > 0);
 }