public bool UpdateMoneyFlagByPayNum(string payNum) { VirtualOrderInfo model = Context.VirtualOrderInfo.Where(v => v.PayNum == payNum).FirstOrDefault(); model.MoneyFlag = 2; return(Context.SaveChanges() > 0); }
public bool UpdatePlatAccountByPayNum(string payNum) { VirtualOrderInfo model = Context.VirtualOrderInfo.Where(v => v.PayNum == payNum).FirstOrDefault(); var platAccount = Context.PlatAccountInfo.Where(p => true).FirstOrDefault(); platAccount.Balance += model.PayAmount * 0.06m; platAccount.PendingSettlement += model.PayAmount * 0.94m; return(Context.SaveChanges() > 0); }
public bool UpdateShopAccountByPayNum(string payNum) { VirtualOrderInfo model = Context.VirtualOrderInfo.Where(v => v.PayNum == payNum).FirstOrDefault(); var shopAccount = Context.ShopAccountInfo.Where(s => s.ShopId == model.ShopId).FirstOrDefault(); shopAccount.Balance += model.PayAmount * 0.94m; //更新商铺余额 shopAccount.PendingSettlement += model.PayAmount * 0.94m; //更新商铺待结算金额 return(Context.SaveChanges() > 0); }
public object GetPrepaidParameter(string openId, decimal payAmount, long shopId) { CheckUserLogin(); var mobilePayments = Core.PluginsManagement.GetPlugins <IPaymentPlugin>(true).Where(item => item.Biz.SupportPlatforms.Contains(Core.PlatformType.WeiXinSmallProg)); string webRoot = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + (HttpContext.Current.Request.Url.Port == 80 ? "" : (":" + HttpContext.Current.Request.Url.Port.ToString())); string notifyUrl = webRoot + "/m-" + Core.PlatformType.Android + "/Payment/NotifyVirtualOrder/"; string orderId = GenerateOrderNumber().ToString(); var models = mobilePayments.ToArray().Select(item => { string url = string.Empty; try { url = item.Biz.GetRequestUrl("", notifyUrl + item.PluginInfo.PluginId.Replace(".", "-"), orderId, payAmount, "商家:" + shopId + "快捷收款", CurrentUserOpenId); } catch (Exception ex) { Core.Log.Error("获取支付方式错误:", ex); } //适配小程序接口,从支付插件里解析出相应参数 //字符串格式:prepayId:234320480,partnerid:32423489,nonceStr=dslkfjsld #region 适配小程序接口,从支付插件里解析出相应参数 var prepayId = string.Empty; var nonceStr = string.Empty; var timeStamp = string.Empty; var sign = string.Empty; if (!string.IsNullOrWhiteSpace(url)) { var paras = url.Split(','); foreach (var str in paras) { var keyValuePair = str.Split(':'); if (keyValuePair.Length == 2) { switch (keyValuePair[0]) { case "prepayId": prepayId = keyValuePair[1]; break; case "nonceStr": nonceStr = keyValuePair[1]; break; case "timeStamp": timeStamp = keyValuePair[1]; break; case "sign": sign = keyValuePair[1]; break; } } } } #endregion return(new { prepayId = prepayId, nonceStr = nonceStr, timeStamp = timeStamp, sign = sign }); }); var model = models.FirstOrDefault(); if (!string.IsNullOrEmpty(model.prepayId)) { IVirtualOrderService virtualOrderService = ServiceHelper.Create <IVirtualOrderService>(); VirtualOrderInfo entity = new VirtualOrderInfo { MoneyFlag = 1, PayAmount = payAmount, PayTime = DateTime.Now, UserId = CurrentUserId, UserName = CurrentUser.Nick, PayNum = orderId, ShopId = shopId }; virtualOrderService.CreateVirtualOrder(entity); } return(Json(new { Status = "OK", Data = model })); }
public bool CreateVirtualOrder(VirtualOrderInfo model) { Context.VirtualOrderInfo.Add(model); return(Context.SaveChanges() > 0); }