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); string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds));//获取支付状态缓存键 bool result = Cache.Get <bool>(payStateKey); if (!result) { var accountService = _iCashDepositsService; var model = new Entities.CashDepositDetailInfo(); model.AddDate = DateTime.Now; model.Balance = balance; model.Description = "充值"; model.Operator = userName; var list = new List <Entities.CashDepositDetailInfo>(); list.Add(model); if (accountService.GetCashDepositByShopId(shopId) == null) { var cashDeposit = new Entities.CashDepositInfo() { CurrentBalance = balance, Date = DateTime.Now, ShopId = shopId, TotalBalance = balance, EnableLabels = true, }; accountService.AddCashDeposit(cashDeposit, list); } else { model.CashDepositId = accountService.GetCashDepositByShopId(shopId).Id; _iCashDepositsService.AddCashDepositDetails(model); } response = payment.Biz.ConfirmPayResult(); Cache.Insert(payStateKey, true);//标记为已支付 } } catch (Exception ex) { errorMsg = ex.Message; } 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; Entities.CashDepositDetailInfo model = new Entities.CashDepositDetailInfo(); string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds));//获取支付状态缓存键 bool result = Cache.Get <bool>(payStateKey); if (!result) { model.AddDate = DateTime.Now; model.Balance = balance; model.Description = "充值"; model.Operator = CurrentSellerManager.UserName; var list = new List <Entities.CashDepositDetailInfo>(); list.Add(model); if (accountService.GetCashDepositByShopId(CurrentSellerManager.ShopId) == null) { var cashDeposit = new Entities.CashDepositInfo() { CurrentBalance = balance, Date = DateTime.Now, ShopId = CurrentSellerManager.ShopId, TotalBalance = balance, EnableLabels = true, }; accountService.AddCashDeposit(cashDeposit, list); } else { model.CashDepositId = accountService.GetCashDepositByShopId(CurrentSellerManager.ShopId).Id; _iCashDepositsService.AddCashDepositDetails(model); } //写入支付状态缓存 Cache.Insert(payStateKey, true);//标记为已支付 } } catch (Exception ex) { errorMsg = ex.Message; } ViewBag.Error = errorMsg; ViewBag.Logo = SiteSettingApplication.SiteSettings.Logo;//获取Logo return(View()); }
public ContentResult CashPayNotify_Post(string id, string str) { #region 如微信扫描支付参数特别处理 if (!string.IsNullOrEmpty(id) && string.IsNullOrEmpty(str)) { if (id.ToLower().IndexOf("weixinpay_native") != -1 && id.IndexOf("~") != -1) { str = id.Split('~')[1]; id = id.Split('~')[0]; } } #endregion //Log.Error("id:" + id + "--str:" + 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.ProcessNotify(HttpContext.Request); string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds));//获取支付状态缓存键 bool result = Cache.Get <bool>(payStateKey); if (!result) { var accountService = _iCashDepositsService; Entities.CashDepositDetailInfo model = new Entities.CashDepositDetailInfo(); model.AddDate = DateTime.Now; model.Balance = balance; model.Description = "充值"; model.Operator = userName; var list = new List <Entities.CashDepositDetailInfo>(); list.Add(model); if (accountService.GetCashDepositByShopId(shopId) == null) { var cashDeposit = new Entities.CashDepositInfo() { CurrentBalance = balance, Date = DateTime.Now, ShopId = shopId, TotalBalance = balance, EnableLabels = true, }; accountService.AddCashDeposit(cashDeposit, list); } else { model.CashDepositId = accountService.GetCashDepositByShopId(shopId).Id; _iCashDepositsService.AddCashDepositDetails(model); } response = payment.Biz.ConfirmPayResult(); Cache.Insert(payStateKey, true);//标记为已支付 } } catch (Exception ex) { errorMsg = ex.Message; Log.Error("CashPayNotify_Post", ex); } return(Content(response)); }
public JsonResult AccountBalancePay(decimal balance) { if (balance <= 0) { return(Json(new Result() { success = false, msg = "应缴金额不正确" })); } var shopAccount = ShopApplication.GetShopAccount(CurrentSellerManager.ShopId); if (shopAccount == null) { return(Json(new Result() { success = false, msg = "店铺账户信息异常" })); } if (shopAccount.Balance < balance) //店铺余额不足以支付费用 { return(Json(new Result() { success = false, msg = "您的店铺余额为:" + shopAccount.Balance + "元,不足以支付此次费用,请先充值。" })); } var userName = CurrentSellerManager.UserName; var shopId = CurrentSellerManager.ShopId; var accountService = _iCashDepositsService; if (accountService.ShopAccountRecord(shopId, balance, "充值保证金", "")) { Entities.CashDepositDetailInfo model = new Entities.CashDepositDetailInfo(); model.AddDate = DateTime.Now; model.Balance = balance; model.Description = "充值"; model.Operator = userName; var list = new List <Entities.CashDepositDetailInfo>(); list.Add(model); if (accountService.GetCashDepositByShopId(shopId) == null) { var cashDeposit = new Entities.CashDepositInfo() { CurrentBalance = balance, Date = DateTime.Now, ShopId = shopId, TotalBalance = balance, EnableLabels = true, }; accountService.AddCashDeposit(cashDeposit, list); } else { model.CashDepositId = accountService.GetCashDepositByShopId(shopId).Id; _iCashDepositsService.AddCashDepositDetails(model); } } return(Json(new Result() { success = true })); }