public void UpdateEnableLabels(long id, bool enableLabels) { CashDepositInfo cashDepositInfo = context.CashDepositInfo.FindById <CashDepositInfo>(id); cashDepositInfo.EnableLabels = enableLabels; context.SaveChanges(); }
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(); IEnumerable <long> parentCategoryId = from item in list where item.ParentCategoryId == 0 select item.Id; //decimal num1 = context.CategoryCashDepositInfo.FindBy((CategoryCashDepositInfo item) => parentCategoryId.Contains(item.CategoryId)).Max<CategoryCashDepositInfo, decimal>((CategoryCashDepositInfo item) => item.NeedPayCashDeposit); decimal num1 = 1; CashDepositInfo cashDepositInfo = ( from item in context.CashDepositInfo where item.ShopId == shopId select item).FirstOrDefault(); if (cashDepositInfo != null && cashDepositInfo.CurrentBalance < num1) { num = num1 - cashDepositInfo.CurrentBalance; } if (cashDepositInfo == null) { num = num1; } return(num); }
public ActionResult Management() { CashDepositInfo cashDepositByShopId = ServiceHelper.Create <ICashDepositsService>().GetCashDepositByShopId(base.CurrentSellerManager.ShopId); ViewBag.NeedPayCashDeposit = ServiceHelper.Create <ICashDepositsService>().GetNeedPayCashDepositByShopId(base.CurrentSellerManager.ShopId); return(View(cashDepositByShopId)); }
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; Log.Error("CashPayNotify_Post", ex); } return(Content(response)); }
public CashDepositInfo GetCashDepositByShopId(long shopId) { CashDepositInfo cashDepositInfo = ( from item in this.context.CashDepositInfo where item.ShopId == shopId select item).FirstOrDefault <CashDepositInfo>(); return(cashDepositInfo); }
public void AddCashDeposit(CashDepositInfo cashDeposit, List <CashDepositDetailInfo> details) { DbFactory.Default.Add(cashDeposit); if (details != null && details.Count > 0) { details.ForEach(p => p.CashDepositId = cashDeposit.Id); DbFactory.Default.AddRange(details); } }
public ActionResult Return(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); var accountService = _iCashDepositsService; CashDepositDetailInfo model = new CashDepositDetailInfo(); bool result = Cache.Get(CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds))) == null ? false : true; if (!result) { model.AddDate = DateTime.Now; model.Balance = balance; model.Description = "充值"; model.Operator = CurrentSellerManager.UserName; List <CashDepositDetailInfo> list = new List <CashDepositDetailInfo>(); list.Add(model); if (accountService.GetCashDepositByShopId(CurrentSellerManager.ShopId) == null) { CashDepositInfo cashDeposit = new CashDepositInfo() { CurrentBalance = balance, Date = DateTime.Now, ShopId = CurrentSellerManager.ShopId, TotalBalance = balance, EnableLabels = true, Himall_CashDepositDetail = list }; accountService.AddCashDeposit(cashDeposit); } else { model.CashDepositId = accountService.GetCashDepositByShopId(CurrentSellerManager.ShopId).Id; _iCashDepositsService.AddCashDepositDetails(model); } //写入支付状态缓存 string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds)); //获取支付状态缓存键 Cache.Insert(payStateKey, true); //标记为已支付 } } catch (Exception ex) { errorMsg = ex.Message; } ViewBag.Error = errorMsg; ViewBag.Logo = _iSiteSettingService.GetSiteSettings().Logo;//获取Logo return(View()); }
public ActionResult Return(string id, decimal balance) { id = DecodePaymentId(id); string empty = string.Empty; try { Plugin <IPaymentPlugin> plugin = PluginsManagement.GetPlugin <IPaymentPlugin>(id); PaymentInfo paymentInfo = plugin.Biz.ProcessReturn(base.HttpContext.Request); ICashDepositsService cashDepositsService = ServiceHelper.Create <ICashDepositsService>(); CashDepositDetailInfo cashDepositDetailInfo = new CashDepositDetailInfo(); if ((Cache.Get(CacheKeyCollection.PaymentState(string.Join <long>(",", paymentInfo.OrderIds))) == null ? true : false)) { cashDepositDetailInfo.AddDate = DateTime.Now; cashDepositDetailInfo.Balance = balance; cashDepositDetailInfo.Description = "保证金充值"; cashDepositDetailInfo.Operator = base.CurrentSellerManager.UserName; List <CashDepositDetailInfo> cashDepositDetailInfos = new List <CashDepositDetailInfo>() { cashDepositDetailInfo }; if (cashDepositsService.GetCashDepositByShopId(base.CurrentSellerManager.ShopId) != null) { cashDepositDetailInfo.CashDepositId = cashDepositsService.GetCashDepositByShopId(base.CurrentSellerManager.ShopId).Id; ServiceHelper.Create <ICashDepositsService>().AddCashDepositDetails(cashDepositDetailInfo); } else { CashDepositInfo cashDepositInfo = new CashDepositInfo() { CurrentBalance = balance, Date = DateTime.Now, ShopId = base.CurrentSellerManager.ShopId, TotalBalance = balance, EnableLabels = true, Himall_CashDepositDetail = cashDepositDetailInfos }; cashDepositsService.AddCashDeposit(cashDepositInfo); } string str = CacheKeyCollection.PaymentState(string.Join <long>(",", paymentInfo.OrderIds)); Cache.Insert(str, true); } } catch (Exception exception) { empty = exception.Message; } ViewBag.Error = empty; ViewBag.Logo = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings().Logo; return(View()); }
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 JsonResult WeiXinPayReturn(decimal balance) { Result result = new Result(); try { ICashDepositsService cashDepositsService = ServiceHelper.Create <ICashDepositsService>(); CashDepositDetailInfo cashDepositDetailInfo = new CashDepositDetailInfo(); cashDepositDetailInfo.AddDate = DateTime.Now; cashDepositDetailInfo.Balance = balance; cashDepositDetailInfo.Description = "保证金充值"; cashDepositDetailInfo.Operator = base.CurrentSellerManager.UserName; List <CashDepositDetailInfo> cashDepositDetailInfos = new List <CashDepositDetailInfo>() { cashDepositDetailInfo }; if (cashDepositsService.GetCashDepositByShopId(base.CurrentSellerManager.ShopId) != null) { cashDepositDetailInfo.CashDepositId = cashDepositsService.GetCashDepositByShopId(base.CurrentSellerManager.ShopId).Id; ServiceHelper.Create <ICashDepositsService>().AddCashDepositDetails(cashDepositDetailInfo); } else { CashDepositInfo cashDepositInfo = new CashDepositInfo() { CurrentBalance = balance, Date = DateTime.Now, ShopId = base.CurrentSellerManager.ShopId, TotalBalance = balance, EnableLabels = true, Himall_CashDepositDetail = cashDepositDetailInfos }; cashDepositsService.AddCashDeposit(cashDepositInfo); } result.success = false; } catch (Exception exception) { result.msg = exception.Message; } return(Json(result)); }
public void AddCashDepositDetails(CashDepositDetailInfo cashDepositDetail) { context.CashDepositDetailInfo.Add(cashDepositDetail); CashDepositInfo currentBalance = context.CashDepositInfo.FindById <CashDepositInfo>(cashDepositDetail.CashDepositId); if (cashDepositDetail.Balance < new decimal(0) && (currentBalance.CurrentBalance + cashDepositDetail.Balance) < new decimal(0)) { HimallException himallException = new HimallException("扣除金额不能多余供应商可用余额"); } currentBalance.CurrentBalance = currentBalance.CurrentBalance + cashDepositDetail.Balance; if (cashDepositDetail.Balance > new decimal(0)) { currentBalance.EnableLabels = true; } if (cashDepositDetail.Balance > new decimal(0)) { currentBalance.TotalBalance = currentBalance.TotalBalance + cashDepositDetail.Balance; currentBalance.Date = DateTime.Now; } context.SaveChanges(); }
public void AddCashDepositDetails(CashDepositDetailInfo cashDepositDetail) { this.context.CashDepositDetailInfo.Add(cashDepositDetail); CashDepositInfo currentBalance = this.context.CashDepositInfo.FindById <CashDepositInfo>(cashDepositDetail.CashDepositId); if ((cashDepositDetail.Balance >= new decimal(0) ? false : (currentBalance.CurrentBalance + cashDepositDetail.Balance) < new decimal(0))) { TaoLaException exception = new TaoLaException("扣除金额不能多余店铺可用余额"); } currentBalance.CurrentBalance = currentBalance.CurrentBalance + cashDepositDetail.Balance; if (cashDepositDetail.Balance > new decimal(0)) { currentBalance.EnableLabels = true; } if (cashDepositDetail.Balance > new decimal(0)) { currentBalance.TotalBalance = currentBalance.TotalBalance + cashDepositDetail.Balance; currentBalance.Date = DateTime.Now; } this.context.SaveChanges(); }
public void AddCashDepositDetails(CashDepositDetailInfo cashDepositDetail) { DbFactory.Default.Add(cashDepositDetail); CashDepositInfo cashDeposit = DbFactory.Default.Get <CashDepositInfo>().Where(p => p.Id == cashDepositDetail.CashDepositId).FirstOrDefault(); if (cashDepositDetail.Balance < 0 && cashDeposit.CurrentBalance + cashDepositDetail.Balance < 0) { new HimallException("扣除金额不能多余店铺可用余额"); } cashDeposit.CurrentBalance = cashDeposit.CurrentBalance + cashDepositDetail.Balance; if (cashDepositDetail.Balance > 0) { cashDeposit.EnableLabels = true; } if (cashDepositDetail.Balance > 0) { cashDeposit.TotalBalance = cashDeposit.TotalBalance + cashDepositDetail.Balance; cashDeposit.Date = DateTime.Now; } DbFactory.Default.Update(cashDeposit); }
public void AddCashDepositDetails(CashDepositDetailInfo cashDepositDetail) { Context.CashDepositDetailInfo.Add(cashDepositDetail); CashDepositInfo cashDeposit = Context.CashDepositInfo.FindById(cashDepositDetail.CashDepositId); if (cashDepositDetail.Balance < 0 && cashDeposit.CurrentBalance + cashDepositDetail.Balance < 0) { new HimallException("扣除金额不能多余诊所可用余额"); } cashDeposit.CurrentBalance = cashDeposit.CurrentBalance + cashDepositDetail.Balance; if (cashDepositDetail.Balance > 0) { cashDeposit.EnableLabels = true; } if (cashDepositDetail.Balance > 0) { cashDeposit.TotalBalance = cashDeposit.TotalBalance + cashDepositDetail.Balance; cashDeposit.Date = DateTime.Now; } Context.SaveChanges(); }
/// <summary> /// 第一次充值保证金时插入记录 /// </summary> /// <param name="cashDeposit"></param> public static void AddCashDeposit(CashDepositInfo cashDeposit) { _iCashDepositsService.AddCashDeposit(cashDeposit); }
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, Himall_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)); }
public void AddCashDeposit(CashDepositInfo cashDeposit) { Context.CashDepositInfo.Add(cashDeposit); Context.SaveChanges(); }