public ActionResult CashDepositRule()
        {
            var data       = _iCashDepositsService.GetCategoryCashDeposits();
            var categories = CategoryApplication.GetCategories();

            ViewBag.Categories = categories;

            #region 老套餐可能漏掉了一级分类保证金,这里同步下
            var cIds = categories.Where(t => t.ParentCategoryId == 0).Select(t => t.Id);
            if (cIds != null && cIds.Count() > 0)
            {
                var addIds = cIds.Except(data.Select(a => a.CategoryId));
                if (addIds != null && addIds.Count() > 0)
                {
                    foreach (var value in addIds)
                    {
                        CategoryCashDepositInfo addm = new CategoryCashDepositInfo();
                        addm.CategoryId = value;
                        CashDepositsApplication.AddCategoryCashDeposits(addm);
                    }
                    Log.Error("保证金少了一级分类Id:" + string.Join(",", addIds));
                    data = _iCashDepositsService.GetCategoryCashDeposits();//说明之前漏掉了重新读取最新的
                }
            }
            #endregion

            ViewBag.Categories = categories;
            return(View(data));
        }
        public void CloseNoReasonReturn(long categoryId)
        {
            CategoryCashDepositInfo categoryCashDepositInfo = (
                from item in context.CategoryCashDepositInfo
                where item.CategoryId == categoryId
                select item).FirstOrDefault();

            categoryCashDepositInfo.EnableNoReasonReturn = false;
            context.SaveChanges();
        }
        public void UpdateNeedPayCashDeposit(long categoryId, decimal cashDeposit)
        {
            CategoryCashDepositInfo categoryCashDepositInfo = (
                from item in context.CategoryCashDepositInfo
                where item.CategoryId == categoryId
                select item).FirstOrDefault();

            categoryCashDepositInfo.NeedPayCashDeposit = cashDeposit;
            context.SaveChanges();
        }
Beispiel #4
0
        //public decimal GetNeedPayCashDepositByShopId(long shopId)
        //{
        //    decimal num = new decimal(0, 0, 0, false, 2);
        //    IShopService create = Instance<IShopService>.Create;
        //    IShopCategoryService shopCategoryService = Instance<IShopCategoryService>.Create;
        //    List<CategoryInfo> list = shopCategoryService.GetBusinessCategory(shopId).ToList<CategoryInfo>();
        //    IEnumerable<long> parentCategoryId =
        //        from item in list
        //        where item.ParentCategoryId == (long)0
        //        select item.Id;
        //    decimal num1 = this.context.CategoryCashDepositInfo.FindBy<CategoryCashDepositInfo>((CategoryCashDepositInfo item) => parentCategoryId.Contains<long>(item.CategoryId)).Max<CategoryCashDepositInfo, decimal>((CategoryCashDepositInfo item) => item.NeedPayCashDeposit);
        //    CashDepositInfo cashDepositInfo = (
        //        from item in this.context.CashDepositInfo
        //        where item.ShopId == shopId
        //        select item).FirstOrDefault<CashDepositInfo>();
        //    if ((cashDepositInfo == null ? false : cashDepositInfo.CurrentBalance < num1))
        //    {
        //        num = num1 - cashDepositInfo.CurrentBalance;
        //    }
        //    if (cashDepositInfo == null)
        //    {
        //        num = num1;
        //    }
        //    return num;
        //}

        public void OpenNoReasonReturn(long categoryId)
        {
            CategoryCashDepositInfo categoryCashDepositInfo = (
                from item in this.context.CategoryCashDepositInfo
                where item.CategoryId == categoryId
                select item).FirstOrDefault <CategoryCashDepositInfo>();

            categoryCashDepositInfo.EnableNoReasonReturn = true;
            this.context.SaveChanges();
        }
        public void DeleteCategoryCashDeposits(long categoryId)
        {
            CategoryCashDepositInfo categoryCashDepositInfo = (
                from item in context.CategoryCashDepositInfo
                where item.CategoryId == categoryId
                select item).FirstOrDefault();

            if (categoryCashDepositInfo != null)
            {
                context.CategoryCashDepositInfo.Remove(categoryCashDepositInfo);
                context.SaveChanges();
            }
        }
        public CashDepositsObligation GetCashDepositsObligation(long productId)
        {
            CashDepositsObligation cashDepositsObligation = new CashDepositsObligation()
            {
                IsCustomerSecurity       = false,
                IsSevenDayNoReasonReturn = false,
                IsTimelyShip             = false
            };
            CashDepositsObligation enableNoReasonReturn = cashDepositsObligation;
            IProductService        create              = Instance <IProductService> .Create;
            IShopService           shopService         = Instance <IShopService> .Create;
            IShopCategoryService   shopCategoryService = Instance <IShopCategoryService> .Create;
            ICategoryService       categoryService     = Instance <ICategoryService> .Create;
            ProductInfo            product             = create.GetProduct(productId);
            ShopInfo shop = shopService.GetShop(product.ShopId, false);

            CashDepositInfo cashDepositInfo = (
                from item in context.CashDepositInfo
                where item.ShopId == shop.Id
                select item).FirstOrDefault();
            List <CategoryInfo> list             = shopCategoryService.GetBusinessCategory(shop.Id).ToList();
            IEnumerable <long>  parentCategoryId =
                from item in list
                where item.ParentCategoryId == 0
                select item.Id;
            //decimal num = context.CategoryCashDepositInfo.FindBy((CategoryCashDepositInfo item) => parentCategoryId.Contains(item.CategoryId)).Max<CategoryCashDepositInfo, decimal>((CategoryCashDepositInfo item) => item.NeedPayCashDeposit);
            decimal num = 1;

            if (shop.IsSelf || cashDepositInfo != null && cashDepositInfo.CurrentBalance >= num || cashDepositInfo != null && cashDepositInfo.CurrentBalance < num && cashDepositInfo.EnableLabels)
            {
                List <long> nums = new List <long>()
                {
                    product.CategoryId
                };
                CategoryInfo            categoryInfo            = categoryService.GetTopLevelCategories(nums).FirstOrDefault();
                CategoryCashDepositInfo categoryCashDepositInfo = (
                    from item in context.CategoryCashDepositInfo
                    where item.CategoryId == categoryInfo.Id
                    select item).FirstOrDefault();
                enableNoReasonReturn.IsSevenDayNoReasonReturn = categoryCashDepositInfo.EnableNoReasonReturn;
                enableNoReasonReturn.IsCustomerSecurity       = true;
                if (!string.IsNullOrEmpty(product.ChemCloud_FreightTemplate.SendTime))
                {
                    enableNoReasonReturn.IsTimelyShip = true;
                }
            }
            return(enableNoReasonReturn);
        }
 public void AddCategory(CategoryInfo model)
 {
     if (null == model)
     {
         throw new ArgumentNullException("model", "添加一个分类时,Model为空");
     }
     if (model.ParentCategoryId == 0)
     {
         CategoryCashDepositInfo categoryCashDeposit = new CategoryCashDepositInfo()
         {
             Id = 0, CategoryId = model.Id
         };
         model.Himall_CategoryCashDeposit = categoryCashDeposit;
     }
     Context.CategoryInfo.Add(model);
     Context.SaveChanges();
     Cache.Remove(CacheKeyCollection.Category);
 }
Beispiel #8
0
 public void AddCategory(CategoryInfo model)
 {
     if (model == null)
     {
         throw new ArgumentNullException("model", "添加一个分类时,Model为空");
     }
     if (model.ParentCategoryId == 0)
     {
         CategoryCashDepositInfo categoryCashDepositInfo = new CategoryCashDepositInfo()
         {
             Id         = 0,
             CategoryId = model.Id
         };
         model.Himall_CategoryCashDeposit = categoryCashDepositInfo;
     }
     context.CategoryInfo.Add(model);
     context.SaveChanges();
     Cache.Remove("Cache-Categories");
 }
Beispiel #9
0
 /// <summary>
 /// 新增类目保证金
 /// </summary>
 /// <param name="model"></param>
 public static void AddCategoryCashDeposits(CategoryCashDepositInfo model)
 {
     _iCashDepositsService.AddCategoryCashDeposits(model);
 }
Beispiel #10
0
 public void AddCategoryCashDeposits(CategoryCashDepositInfo model)
 {
     Context.CategoryCashDepositInfo.Add(model);
     Context.SaveChanges();
 }
Beispiel #11
0
 public void AddCategoryCashDeposits(CategoryCashDepositInfo model)
 {
     DbFactory.Default.Add(model);
 }