public ContentResult CapitalChargeNotify(string id) { id = DecodePaymentId(id); Log.Info("商家充值异步回调key:" + id); string str = string.Empty; try { var payment = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id); var payInfo = payment.Biz.ProcessReturn(HttpContext.Request); CashDepositDetailInfo model = new CashDepositDetailInfo(); string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds)); //获取支付状态缓存键 bool result = Cache.Get <bool>(payStateKey); //记录缓存,不重复处理 if (!result) { long orderIds = payInfo.OrderIds.FirstOrDefault(); Log.Info("商家充值异步回调订单号:" + orderIds); BillingApplication.ShopRecharge(orderIds, payInfo.TradNo, id); str = payment.Biz.ConfirmPayResult(); //写入支付状态缓存 Cache.Insert(payStateKey, true);//标记为已支付 } } catch (Exception ex) { Log.Error("商家充值异步回调错误:" + ex.Message); } return(Content(str)); }
public ActionResult CapitalChargeReturn(string id) { id = DecodePaymentId(id); Log.Info("商家充值同步回调key:" + id); string error = string.Empty; try { var payment = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id); var payInfo = payment.Biz.ProcessReturn(HttpContext.Request); CashDepositDetailInfo model = new CashDepositDetailInfo(); bool result = Cache.Get(CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds))) == null ? false : true;//记录缓存,不重复处理 if (!result) { long orderIds = payInfo.OrderIds.FirstOrDefault(); Log.Info("商家充值同步回调订单号:" + orderIds); BillingApplication.ShopRecharge(orderIds, payInfo.TradNo, id); //写入支付状态缓存 string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds)); //获取支付状态缓存键 Cache.Insert(payStateKey, true); //标记为已支付 } } catch (Exception ex) { Log.Error("商家充值同步回调错误:" + ex.Message); error = ex.Message; } ViewBag.Error = error; return(View()); }
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 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 JsonResult Deduction(long id, string balance, string description) { if (Convert.ToDecimal(balance) < new decimal(0)) { throw new HimallException("扣除保证金不能为负值"); } CashDepositDetailInfo cashDepositDetailInfo = new CashDepositDetailInfo() { AddDate = DateTime.Now, Balance = -Convert.ToDecimal(balance), CashDepositId = id, Description = description, Operator = base.CurrentManager.UserName }; ServiceHelper.Create <ICashDepositsService>().AddCashDepositDetails(cashDepositDetailInfo); return(Json(new { Success = true })); }
public JsonResult Deduction(long id, string balance, string description) { if (Convert.ToDecimal(balance) < 0) { throw new HimallException("扣除保证金不能为负值"); } CashDepositDetailInfo model = new CashDepositDetailInfo() { AddDate = DateTime.Now, Balance = -Convert.ToDecimal(balance), CashDepositId = id, Description = description, Operator = CurrentManager.UserName }; _iCashDepositsService.AddCashDepositDetails(model); return(Json(new { Success = true })); }
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) { 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(); }
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); }
/// <summary> /// 插入一条保证金流水号信息 /// </summary> /// <param name="cashDepositDetail"></param> public static void AddCashDepositDetails(CashDepositDetailInfo cashDepositDetail) { _iCashDepositsService.AddCashDepositDetails(cashDepositDetail); }
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)); }