/// <summary> /// 调用第三方支付 /// </summary> /// <param name="type"></param> /// <param name="account"></param> /// <param name="amount"></param> /// <param name="desc"></param> /// <param name="no"></param> /// <returns></returns> private static PaymentInfo Payment(DistributionWithdrawType type, string account, decimal amount, string desc, string no, string withdrawName = "") { Plugin <IPaymentPlugin> plugin = null; /// 支付宝真实姓名验证逻辑 bool isCheckName = false; switch (type) { case DistributionWithdrawType.Alipay: plugin = PluginsManagement.GetPlugins <IPaymentPlugin>(true).FirstOrDefault(e => e.PluginInfo.PluginId == "Mall.Plugin.Payment.Alipay"); isCheckName = true; break; case DistributionWithdrawType.WeChat: plugin = PluginsManagement.GetPlugins <IPaymentPlugin>(true).FirstOrDefault(e => e.PluginInfo.PluginId.ToLower().Contains("weixin")); break; default: throw new MallException("不支持的支付类型"); } if (plugin == null) { throw new MallException("未找到支付插件"); } var pay = new EnterprisePayPara() { amount = amount, openid = account, out_trade_no = no, check_name = isCheckName, re_user_name = withdrawName, desc = desc }; try { return(plugin.Biz.EnterprisePay(pay)); } catch (PluginException pex) { //插件异常,直接返回错误信息 Log.Error("调用付款接口异常:" + pex.Message); throw new MallException("调用企业付款接口异常:" + pex.Message); } catch (Exception ex) { Log.Error("付款异常:" + ex.Message); throw new MallException("企业付款异常:" + ex.Message); } }
public JsonResult ConfirmApply(long id, ApplyWithDrawInfo.ApplyWithDrawStatus comfirmStatus, string remark) { IMemberCapitalService memberCapitalService = this._iMemberCapitalService; ApplyWithDrawInfo.ApplyWithDrawStatus status = comfirmStatus; ApplyWithDrawInfo applyWithDrawInfo1 = memberCapitalService.GetApplyWithDrawInfo(id); if (status == ApplyWithDrawInfo.ApplyWithDrawStatus.Refuse) { memberCapitalService.RefuseApplyWithDraw(id, status, this.CurrentManager.UserName, remark); this._iOperationLogService.AddPlatformOperationLog(new LogInfo() { Date = DateTime.Now, Description = string.Format("会员提现审核拒绝,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark), IPAddress = this.Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = this.CurrentManager.UserName, ShopId = 0L }); return(this.Json((object)new BaseController.Result() { success = true, msg = "审核成功!" })); } UserWithdrawType?applyType = applyWithDrawInfo1.ApplyType; if ((applyType.GetValueOrDefault() != UserWithdrawType.ALiPay ? 0 : (applyType.HasValue ? 1 : 0)) != 0) { if (applyWithDrawInfo1.ApplyStatus == ApplyWithDrawInfo.ApplyWithDrawStatus.PayPending) { return(this.Json((object)new BaseController.Result() { success = false, msg = "等待第三方处理中,如有误操作,请先取消后再进行付款操作!" })); } Plugin <IPaymentPlugin> plugin = Enumerable.FirstOrDefault <Plugin <IPaymentPlugin> >(PluginsManagement.GetPlugins <IPaymentPlugin>(true), (Func <Plugin <IPaymentPlugin>, bool>)(e => e.PluginInfo.PluginId == "Himall.Plugin.Payment.Alipay")); if (plugin != null) { try { string format = CurrentUrlHelper.CurrentUrlNoPort() + "/Pay/EnterpriseNotify/{0}?outid={1}"; EnterprisePayPara para = new EnterprisePayPara() { amount = applyWithDrawInfo1.ApplyAmount, check_name = false, openid = applyWithDrawInfo1.OpenId, re_user_name = applyWithDrawInfo1.NickName, out_trade_no = applyWithDrawInfo1.Id.ToString(), desc = "提现", notify_url = string.Format(format, (object)this.EncodePaymentId(plugin.PluginInfo.PluginId), (object)applyWithDrawInfo1.Id.ToString()) }; PaymentInfo paymentInfo = plugin.Biz.EnterprisePay(para); ApplyWithDrawInfo applyWithDrawInfo2 = new ApplyWithDrawInfo(); applyWithDrawInfo2.PayNo = paymentInfo.TradNo; applyWithDrawInfo2.ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.PayPending; ApplyWithDrawInfo applyWithDrawInfo3 = applyWithDrawInfo2; DateTime? tradeTime = paymentInfo.TradeTime; DateTime now; if (!tradeTime.HasValue) { now = DateTime.Now; } else { tradeTime = paymentInfo.TradeTime; now = tradeTime.Value; } DateTime?nullable = new DateTime?(now); applyWithDrawInfo3.PayTime = nullable; applyWithDrawInfo2.ConfirmTime = new DateTime?(DateTime.Now); applyWithDrawInfo2.OpUser = this.CurrentManager.UserName; applyWithDrawInfo2.ApplyAmount = applyWithDrawInfo1.ApplyAmount; applyWithDrawInfo2.Id = applyWithDrawInfo1.Id; ApplyWithDrawInfo info = applyWithDrawInfo2; memberCapitalService.ConfirmApplyWithDraw(info); this._iOperationLogService.AddPlatformOperationLog(new LogInfo() { Date = DateTime.Now, Description = string.Format("会员提现审核成功,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark), IPAddress = this.Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = this.CurrentManager.UserName, ShopId = 0L }); return(this.Json((object)new BaseController.Result() { success = true, msg = "审核操作成功", status = 2, Data = (object)paymentInfo.ResponseContentWhenFinished })); } catch (PluginException ex) { Log.Error((object)("调用企业付款接口异常:" + ex.Message)); this._iOperationLogService.AddPlatformOperationLog(new LogInfo() { Date = DateTime.Now, Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark), IPAddress = this.Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = this.CurrentManager.UserName, ShopId = 0L }); return(this.Json((object)new BaseController.Result() { success = false, msg = ex.Message })); } catch (Exception ex) { Log.Error((object)("提现审核异常:" + ex.Message)); return(this.Json((object)new BaseController.Result() { success = false, msg = "付款接口异常" })); } } else { return(this.Json((object)new BaseController.Result() { success = false, msg = "未找到支付插件" })); } } else { Plugin <IPaymentPlugin> plugin = Enumerable.FirstOrDefault <Plugin <IPaymentPlugin> >(Enumerable.Where <Plugin <IPaymentPlugin> >(PluginsManagement.GetPlugins <IPaymentPlugin>(true), (Func <Plugin <IPaymentPlugin>, bool>)(e => e.PluginInfo.PluginId.ToLower().Contains("weixin")))); if (plugin != null) { try { EnterprisePayPara para = new EnterprisePayPara() { amount = applyWithDrawInfo1.ApplyAmount, check_name = false, openid = applyWithDrawInfo1.OpenId, out_trade_no = applyWithDrawInfo1.Id.ToString(), desc = "提现" }; PaymentInfo paymentInfo = plugin.Biz.EnterprisePay(para); ApplyWithDrawInfo applyWithDrawInfo2 = new ApplyWithDrawInfo(); applyWithDrawInfo2.PayNo = paymentInfo.TradNo; applyWithDrawInfo2.ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess; applyWithDrawInfo2.Remark = plugin.PluginInfo.Description; ApplyWithDrawInfo applyWithDrawInfo3 = applyWithDrawInfo2; DateTime? tradeTime = paymentInfo.TradeTime; DateTime now; if (!tradeTime.HasValue) { now = DateTime.Now; } else { tradeTime = paymentInfo.TradeTime; now = tradeTime.Value; } DateTime?nullable = new DateTime?(now); applyWithDrawInfo3.PayTime = nullable; applyWithDrawInfo2.ConfirmTime = new DateTime?(DateTime.Now); applyWithDrawInfo2.OpUser = this.CurrentManager.UserName; applyWithDrawInfo2.ApplyAmount = applyWithDrawInfo1.ApplyAmount; applyWithDrawInfo2.Id = applyWithDrawInfo1.Id; ApplyWithDrawInfo info = applyWithDrawInfo2; memberCapitalService.ConfirmApplyWithDraw(info); this._iOperationLogService.AddPlatformOperationLog(new LogInfo() { Date = DateTime.Now, Description = string.Format("会员提现审核成功,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark), IPAddress = this.Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = this.CurrentManager.UserName, ShopId = 0L }); } catch (PluginException ex) { Log.Error((object)("调用企业付款接口异常:" + ex.Message)); this._iOperationLogService.AddPlatformOperationLog(new LogInfo() { Date = DateTime.Now, Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark), IPAddress = this.Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = this.CurrentManager.UserName, ShopId = 0L }); return(this.Json((object)new BaseController.Result() { success = false, msg = ex.Message })); } catch (Exception ex) { Log.Error((object)("提现审核异常:" + ex.Message)); ApplyWithDrawInfo info = new ApplyWithDrawInfo() { ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail, Remark = plugin.PluginInfo.Description, ConfirmTime = new DateTime?(DateTime.Now), OpUser = this.CurrentManager.UserName, ApplyAmount = applyWithDrawInfo1.ApplyAmount, Id = applyWithDrawInfo1.Id }; memberCapitalService.ConfirmApplyWithDraw(info); this._iOperationLogService.AddPlatformOperationLog(new LogInfo() { Date = DateTime.Now, Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", (object)applyWithDrawInfo1.MemId, (object)status, (object)remark), IPAddress = this.Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = this.CurrentManager.UserName, ShopId = 0L }); return(this.Json((object)new BaseController.Result() { success = false, msg = "付款接口异常" })); } return(this.Json((object)new BaseController.Result() { success = true, msg = "审核操作成功" })); } return(this.Json((object)new BaseController.Result() { success = false, msg = "未找到支付插件" })); } }
public override PaymentInfo EnterprisePay(EnterprisePayPara para) { //创建请求对象 RequestHandler reqHandler = new RequestHandler(); PaymentInfo paymentInfo = new PaymentInfo(); string strResult = string.Empty; Config payConfig = Utility <Config> .GetConfig(WorkDirectory); if (string.IsNullOrEmpty(payConfig.AppId)) { throw new PluginException("未设置AppId"); } if (string.IsNullOrEmpty(payConfig.MCHID)) { throw new PluginException("未设置MCHID"); } if (string.IsNullOrWhiteSpace(payConfig.pkcs12)) { throw new PluginConfigException("未设置商户证书"); } //----------------------------- //设置请求参数 //----------------------------- reqHandler.SetKey(payConfig.Key); var nonceStr = TenPayUtil.GetNoncestr(); reqHandler.SetParameter("partner_trade_no", para.out_trade_no); reqHandler.SetParameter("amount", Convert.ToInt32((para.amount * 100)).ToString()); reqHandler.SetParameter("openid", para.openid); reqHandler.SetParameter("mch_appid", payConfig.AppId); reqHandler.SetParameter("mchid", payConfig.MCHID); reqHandler.SetParameter("nonce_str", nonceStr); string checkNameOption = "NO_CHECK"; if (para.check_name) {//是否检测真实姓名 checkNameOption = "OPTION_CHECK"; } reqHandler.SetParameter("check_name", checkNameOption); reqHandler.SetParameter("desc", para.desc); reqHandler.SetParameter("spbill_create_ip", string.IsNullOrWhiteSpace(para.spbill_create_ip) ? _httpContextAccessor.HttpContext.Features.Get <IHttpConnectionFeature>().RemoteIpAddress.ToString() : para.spbill_create_ip); string sign = reqHandler.CreateMd5Sign("key", payConfig.Key);//按约定规则生成MD5,规则参考接口文档 reqHandler.SetParameter("sign", sign); var pkcs12 = WorkDirectory + "\\" + payConfig.pkcs12; if (!System.IO.File.Exists(pkcs12)) { throw new PluginException("未找到商户证书文件"); } string strXml = reqHandler.ParseXML(); string result = string.Empty; try { result = TenPayV3.transfers(strXml, pkcs12, payConfig.MCHID);//调用统一接口 } catch (Exception ex) { throw new PluginException("企业付款时出错:" + ex.Message); } XDocument xmlDocument = XDocument.Parse(result); if (xmlDocument == null) { throw new PluginException("企业付款时出错:" + strXml); } XElement e_return = xmlDocument.Element("xml").Element("return_code"); XElement e_result = xmlDocument.Element("xml").Element("return_msg"); if (e_return == null) { throw new PluginException("企业付款时,返回参数异常"); } //处理返回时先判断协议错误码,再业务,最后交易状态 if (e_return.Value == "SUCCESS") { e_result = xmlDocument.Element("xml").Element("result_code"); XElement e_errdes = xmlDocument.Element("xml").Element("err_code_des"); if (e_result.Value == "SUCCESS") { //微信单号 string payment_no = xmlDocument.Element("xml").Element("payment_no").Value; //商户单号 string partner_trade_no = xmlDocument.Element("xml").Element("partner_trade_no").Value; string payment_time = xmlDocument.Element("xml").Element("payment_time").Value; //业务处理 paymentInfo.OrderIds = new List <long> { long.Parse(partner_trade_no) }; paymentInfo.TradNo = payment_no; paymentInfo.TradeTime = DateTime.Parse(payment_time); } else { throw new PluginException("企业付款时,接口返回异常:" + e_errdes.Value); } } else { throw new PluginException("企业付款时,接口返回异常:" + e_result.Value); } return(paymentInfo); }
public virtual PaymentInfo EnterprisePay(EnterprisePayPara para) { throw new PluginException("未实现此方法"); }
public JsonResult ConfirmPay(long id, ApplyWithDrawInfo.ApplyWithDrawStatus status, string remark) { JsonResult jsonResult; IMemberCapitalService memberCapitalService = ServiceHelper.Create <IMemberCapitalService>(); if (status == ApplyWithDrawInfo.ApplyWithDrawStatus.Refuse) { memberCapitalService.RefuseApplyWithDraw(id, status, base.CurrentManager.UserName, remark); return(Json(new { success = true, msg = "审核成功!" })); } ApplyWithDrawQuery applyWithDrawQuery = new ApplyWithDrawQuery() { withDrawNo = new long?(id), PageNo = 1, PageSize = 1 }; ApplyWithDrawQuery applyWithDrawQuery1 = applyWithDrawQuery; ApplyWithDrawInfo applyWithDrawInfo = memberCapitalService.GetApplyWithDraw(applyWithDrawQuery1).Models.FirstOrDefault(); Plugin <IPaymentPlugin> plugin = ( from e in PluginsManagement.GetPlugins <IPaymentPlugin>(true) where e.PluginInfo.PluginId.ToLower().Contains("weixin") select e).FirstOrDefault <Plugin <IPaymentPlugin> >(); if (plugin == null) { return(Json(new { success = false, msg = "未找到支付插件" })); } try { EnterprisePayPara enterprisePayPara = new EnterprisePayPara() { amount = applyWithDrawInfo.ApplyAmount, check_name = false, openid = applyWithDrawInfo.OpenId, out_trade_no = applyWithDrawInfo.Id.ToString(), desc = "提现" }; PaymentInfo paymentInfo = plugin.Biz.EnterprisePay(enterprisePayPara); ApplyWithDrawInfo applyWithDrawInfo1 = new ApplyWithDrawInfo() { PayNo = paymentInfo.TradNo, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess, Remark = plugin.PluginInfo.Description, PayTime = new DateTime?((paymentInfo.TradeTime.HasValue ? paymentInfo.TradeTime.Value : DateTime.Now)), ConfirmTime = new DateTime?(DateTime.Now), OpUser = base.CurrentManager.UserName, ApplyAmount = applyWithDrawInfo.ApplyAmount, Id = applyWithDrawInfo.Id }; memberCapitalService.ConfirmApplyWithDraw(applyWithDrawInfo1); return(Json(new { success = true, msg = "付款成功" })); } catch (Exception exception) { Log.Error(string.Concat("调用企业付款接口异常:", exception.Message)); ApplyWithDrawInfo applyWithDrawInfo2 = new ApplyWithDrawInfo() { ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail, Remark = plugin.PluginInfo.Description, ConfirmTime = new DateTime?(DateTime.Now), OpUser = base.CurrentManager.UserName, ApplyAmount = applyWithDrawInfo.ApplyAmount, Id = applyWithDrawInfo.Id }; memberCapitalService.ConfirmApplyWithDraw(applyWithDrawInfo2); jsonResult = Json(new { success = false, msg = "付款接口异常" }); } return(jsonResult); }
public override PaymentInfo EnterprisePay(EnterprisePayPara para) { RequestHandler requestHandler = new RequestHandler(); PaymentInfo paymentInfo = new PaymentInfo(); string empty = string.Empty; Config config = Utility <Config> .GetConfig(base.WorkDirectory); if (string.IsNullOrEmpty(config.AppId)) { throw new PluginException("未设置AppId"); } if (string.IsNullOrEmpty(config.MCHID)) { throw new PluginException("未设置MCHID"); } if (string.IsNullOrWhiteSpace(config.pkcs12)) { throw new PluginConfigException("未设置商户证书"); } requestHandler.SetKey(config.Key); string noncestr = TenPayUtil.GetNoncestr(); requestHandler.SetParameter("partner_trade_no", para.out_trade_no); int num = Convert.ToInt32(para.amount * new decimal(100)); requestHandler.SetParameter("amount", num.ToString()); requestHandler.SetParameter("openid", para.openid); requestHandler.SetParameter("mch_appid", config.AppId); requestHandler.SetParameter("mchid", config.MCHID); requestHandler.SetParameter("nonce_str", noncestr); string str = "NO_CHECK"; if (para.check_name) { str = "OPTION_CHECK"; } requestHandler.SetParameter("check_name", str); requestHandler.SetParameter("desc", para.desc); requestHandler.SetParameter("spbill_create_ip", (string.IsNullOrWhiteSpace(para.spbill_create_ip) ? "222.240.184.122" : para.spbill_create_ip)); string str1 = requestHandler.CreateMd5Sign("key", config.Key); requestHandler.SetParameter("sign", str1); string str2 = string.Concat(base.WorkDirectory, "\\", config.pkcs12); if (!File.Exists(str2)) { throw new PluginException("未找到商户证书文件"); } string str3 = requestHandler.ParseXML(); string empty1 = string.Empty; try { empty1 = TenPayV3.transfers(str3, str2, config.MCHID); } catch (Exception exception) { throw new PluginException(string.Concat("企业付款时出错:", exception.Message)); } XDocument xDocument = XDocument.Parse(empty1); if (xDocument == null) { throw new PluginException(string.Concat("企业付款时出错:", str3)); } XElement xElement = xDocument.Element("xml").Element("return_code"); XElement xElement1 = xDocument.Element("xml").Element("return_msg"); if (xElement == null) { throw new PluginException("企业付款时,返回参数异常"); } if (!(xElement.Value == "SUCCESS")) { throw new PluginException(string.Concat("企业付款时,接口返回异常:", xElement1.Value)); } xElement1 = xDocument.Element("xml").Element("result_code"); XElement xElement2 = xDocument.Element("xml").Element("err_code_des"); if (!(xElement1.Value == "SUCCESS")) { throw new PluginException(string.Concat("企业付款时,接口返回异常:", xElement2.Value)); } string value = xDocument.Element("xml").Element("payment_no").Value; string value1 = xDocument.Element("xml").Element("partner_trade_no").Value; string value2 = xDocument.Element("xml").Element("payment_time").Value; paymentInfo.OrderIds = new List <long>() { long.Parse(value1) }; paymentInfo.TradNo = value; paymentInfo.TradeTime = new DateTime?(DateTime.Parse(value2)); return(paymentInfo); }
public JsonResult BatchConfirmApply(string ids, Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus comfirmStatus, string remark) { if (string.IsNullOrWhiteSpace(ids)) { return(ErrorResult("审核的ID,不能为空")); } var idArray = ids.Split(',').Select(e => { long id = 0; long.TryParse(e, out id); return(id); }).Where(e => e > 0); var status = comfirmStatus; var models = _iMemberCapitalService.GetApplyWithDrawInfoByIds(idArray); var isHaveError = false; foreach (var model in models) { if (status == Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.Refuse) { _iMemberCapitalService.RefuseApplyWithDraw(model.Id, status, CurrentManager.UserName, remark); //操作日志 WithDrawOperateLog(string.Format("会员提现审核拒绝,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark)); //return Json(new Result { success = true, msg = "审核成功!" }); } else { if (model.ApplyStatus == Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.PayPending) { return(Json(new Result { success = false, msg = "等待第三方处理中,如有误操作,请先取消后再进行付款操作!" })); } Plugin <IPaymentPlugin> plugins = null; bool isCheckName = false; if (model.ApplyType == CommonModel.UserWithdrawType.ALiPay) { isCheckName = true; plugins = PluginsManagement.GetPlugins <IPaymentPlugin>(true).FirstOrDefault(e => e.PluginInfo.PluginId == PLUGIN_PAYMENT_ALIPAY); } else { plugins = PluginsManagement.GetPlugins <IPaymentPlugin>(true).Where(e => e.PluginInfo.PluginId.ToLower().Contains("weixin")).FirstOrDefault(); } if (plugins != null) { try { var tradeno = model.ApplyTime.ToString("yyyyMMddHHmmss") + model.Id.ToString(); EnterprisePayPara para = new EnterprisePayPara() { amount = model.ApplyAmount, check_name = isCheckName, openid = model.OpenId, re_user_name = model.NickName, out_trade_no = tradeno, desc = "提现" }; //调用转账接口 PaymentInfo result = plugins.Biz.EnterprisePay(para); //更新提现状态 Himall.Entities.ApplyWithDrawInfo info = new Himall.Entities.ApplyWithDrawInfo { PayNo = result.TradNo, ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess, Remark = remark, PayTime = result.TradeTime.HasValue ? result.TradeTime.Value : DateTime.Now, ConfirmTime = DateTime.Now, OpUser = CurrentManager.UserName, ApplyAmount = model.ApplyAmount, Id = model.Id }; _iMemberCapitalService.ConfirmApplyWithDraw(info); //操作日志 WithDrawOperateLog(string.Format("会员提现审核成功,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark)); } catch (PluginException pex) {//转账失败(业务级别),直接返回错误信息 Log.Error("调用企业付款接口异常:" + pex.Message); isHaveError = true; //更新提现状态 Himall.Entities.ApplyWithDrawInfo info = new Himall.Entities.ApplyWithDrawInfo { ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail, Remark = pex.Message, ConfirmTime = DateTime.Now, OpUser = CurrentManager.UserName, ApplyAmount = model.ApplyAmount, Id = model.Id }; _iMemberCapitalService.ConfirmApplyWithDraw(info); //操作日志 WithDrawOperateLog(string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark)); //return Json(new Result { success = false, msg = pex.Message }); } catch (Exception ex) {//转账失败(系统级别),直接返回错误信息 Log.Error("提现审核异常:" + ex.Message); isHaveError = true; //更新提现状态 Himall.Entities.ApplyWithDrawInfo info = new Himall.Entities.ApplyWithDrawInfo { ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail, Remark = "审核操作异常,请检查一下支付配置", ConfirmTime = DateTime.Now, OpUser = CurrentManager.UserName, ApplyAmount = model.ApplyAmount, Id = model.Id }; _iMemberCapitalService.ConfirmApplyWithDraw(info); //操作日志 WithDrawOperateLog(string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark)); //return Json(new Result { success = false, msg = "付款接口异常" }); } } else { return(Json(new Result { success = false, msg = "未找到支付插件" })); } } } if (isHaveError) { return(Json(new Result { success = true, msg = "审核操作完成,但部分提现失败,请检查!" })); } else { return(Json(new Result { success = true, msg = "审核操作完成!" })); } }
public JsonResult ConfirmApply(long id, Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus comfirmStatus, string remark) { var service = _iMemberCapitalService; var status = comfirmStatus; var model = service.GetApplyWithDrawInfo(id); if (status == Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.Refuse) { service.RefuseApplyWithDraw(id, status, CurrentManager.UserName, remark); //操作日志 _iOperationLogService.AddPlatformOperationLog( new Entities.LogInfo { Date = DateTime.Now, Description = string.Format("会员提现审核拒绝,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark), IPAddress = Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = CurrentManager.UserName, ShopId = 0 }); return(Json(new Result { success = true, msg = "审核成功!" })); } else { if (model.ApplyType == CommonModel.UserWithdrawType.ALiPay) { #region 支付宝提现 if (model.ApplyStatus == Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.PayPending) { return(Json(new Result { success = false, msg = "等待第三方处理中,如有误操作,请先取消后再进行付款操作!" })); } var plugins = PluginsManagement.GetPlugins <IPaymentPlugin>(true).FirstOrDefault(e => e.PluginInfo.PluginId == PLUGIN_PAYMENT_ALIPAY); if (plugins != null) { try { string webRoot = CurrentUrlHelper.CurrentUrlNoPort(); //异步通知地址 string payNotify = webRoot + "/Pay/EnterpriseNotify/{0}?outid={1}"; EnterprisePayPara para = new EnterprisePayPara() { amount = model.ApplyAmount, check_name = true,//支付宝验证实名 openid = model.OpenId, re_user_name = model.NickName, out_trade_no = model.ApplyTime.ToString("yyyyMMddHHmmss") + model.Id.ToString(), desc = "提现", notify_url = string.Format(payNotify, EncodePaymentId(plugins.PluginInfo.PluginId), model.Id.ToString()) }; PaymentInfo result = plugins.Biz.EnterprisePay(para); Himall.Entities.ApplyWithDrawInfo info = new Himall.Entities.ApplyWithDrawInfo { PayNo = result.TradNo, ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess, PayTime = result.TradeTime.HasValue ? result.TradeTime.Value : DateTime.Now, ConfirmTime = DateTime.Now, OpUser = CurrentManager.UserName, ApplyAmount = model.ApplyAmount, Id = model.Id, Remark = remark }; //Log.Debug("提现:" + info.PayNo); service.ConfirmApplyWithDraw(info); //操作日志 _iOperationLogService.AddPlatformOperationLog(new Entities.LogInfo { Date = DateTime.Now, Description = string.Format("会员提现审核成功,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark), IPAddress = Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = CurrentManager.UserName, ShopId = 0 }); //ResponseContentWhenFinished 会回传跳转付款的链接 return(Json(new Result { success = true, msg = "审核操作成功", status = 2, data = result.ResponseContentWhenFinished })); } catch (PluginException pex) { //插件异常,直接返回错误信息 Log.Error("调用企业付款接口异常:" + pex.Message); //操作日志 _iOperationLogService.AddPlatformOperationLog(new Entities.LogInfo { Date = DateTime.Now, Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark), IPAddress = Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = CurrentManager.UserName, ShopId = 0 }); return(Json(new Result { success = false, msg = pex.Message })); } catch (Exception ex) { Log.Error("提现审核异常:" + ex.Message); return(Json(new Result { success = false, msg = ex.Message })); } } else { return(Json(new Result { success = false, msg = "未找到支付插件" })); } #endregion } else { #region 微信提现 var plugins = PluginsManagement.GetPlugins <IPaymentPlugin>(true).Where(e => e.PluginInfo.PluginId.ToLower().Contains("weixin")).FirstOrDefault(); if (plugins != null) { try { EnterprisePayPara para = new EnterprisePayPara() { amount = model.ApplyAmount, check_name = false, openid = model.OpenId, out_trade_no = model.ApplyTime.ToString("yyyyMMddHHmmss") + model.Id.ToString(), desc = "提现" }; PaymentInfo result = plugins.Biz.EnterprisePay(para); Himall.Entities.ApplyWithDrawInfo info = new Himall.Entities.ApplyWithDrawInfo { PayNo = result.TradNo, ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess, Remark = remark, PayTime = result.TradeTime.HasValue ? result.TradeTime.Value : DateTime.Now, ConfirmTime = DateTime.Now, OpUser = CurrentManager.UserName, ApplyAmount = model.ApplyAmount, Id = model.Id }; //Log.Debug("提现:" + info.PayNo); service.ConfirmApplyWithDraw(info); //操作日志 _iOperationLogService.AddPlatformOperationLog(new Entities.LogInfo { Date = DateTime.Now, Description = string.Format("会员提现审核成功,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark), IPAddress = Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = CurrentManager.UserName, ShopId = 0 }); } catch (PluginException pex) {//插件异常,直接返回错误信息 Log.Error("调用企业付款接口异常:" + pex.Message); //操作日志 _iOperationLogService.AddPlatformOperationLog(new Entities.LogInfo { Date = DateTime.Now, Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark), IPAddress = Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = CurrentManager.UserName, ShopId = 0 }); return(Json(new Result { success = false, msg = pex.Message })); } catch (Exception ex) { Log.Error("提现审核异常:" + ex.Message); Himall.Entities.ApplyWithDrawInfo info = new Himall.Entities.ApplyWithDrawInfo { ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail, Remark = remark, ConfirmTime = DateTime.Now, OpUser = CurrentManager.UserName, ApplyAmount = model.ApplyAmount, Id = model.Id }; service.ConfirmApplyWithDraw(info); //操作日志 _iOperationLogService.AddPlatformOperationLog(new Entities.LogInfo { Date = DateTime.Now, Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark), IPAddress = Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = CurrentManager.UserName, ShopId = 0 }); return(Json(new Result { success = false, msg = ex.Message })); } } else { return(Json(new Result { success = false, msg = "未找到支付插件" })); } #endregion } } return(Json(new Result { success = true, msg = "审核操作成功" })); }
/// <summary> /// 店铺提现审核 /// </summary> /// <param name="Id">审核ID</param> /// <param name="status">审核状态</param> /// <param name="Remark">平台备注</param> /// <param name="IpAddress">操作IP</param> /// <param name="UserName">操作人名称</param> /// <returns></returns> public static bool ShopApplyWithDraw(long Id, Himall.CommonModel.WithdrawStaus status, string Remark, string IpAddress = "", string UserName = "") { var model = _iBillingService.GetShopWithDrawInfo(Id); if (status == Himall.CommonModel.WithdrawStaus.Refused)//拒绝 { model.Status = status; model.PlatRemark = Remark; model.DealTime = DateTime.Now; _iBillingService.UpdateShopWithDraw(model); lock (obj) { //处理余额 var mShopAccountInfo = _iBillingService.GetShopAccount(model.ShopId); mShopAccountInfo.Balance += model.CashAmount; _iBillingService.UpdateShopAccount(mShopAccountInfo); } //操作日志 _iOperationLogService.AddPlatformOperationLog( new LogInfo { Date = DateTime.Now, Description = string.Format("店铺提现拒绝,店铺Id={0},状态为:{1}, 说明是:{2}", model.ShopId, status, Remark), IPAddress = IpAddress, PageUrl = "/Admin/ShopWithDraw/Management", UserName = UserName, ShopId = 0 }); return(true); } else if (model.CashType == Himall.CommonModel.WithdrawType.BankCard)//银行卡 { model.Status = status; model.PlatRemark = Remark; model.DealTime = DateTime.Now; _iBillingService.UpdateShopWithDraw(model); //资金处理 updateAccount(model.ShopId, model.CashAmount, Himall.CommonModel.ShopAccountType.WithDraw, DateTime.Now.ToString("yyyyMMddHHmmssffff"), "银行卡提现", Id); //操作日志 _iOperationLogService.AddPlatformOperationLog( new LogInfo { Date = DateTime.Now, Description = string.Format("店铺银行卡提现审核成功,店铺Id={0},状态为:{1}, 说明是:{2}", model.ShopId, status, Remark), IPAddress = IpAddress, PageUrl = "/Admin/ShopWithDraw/Management", UserName = UserName, ShopId = 0 }); return(true); } else { var plugins = PluginsManagement.GetPlugins <IPaymentPlugin>(true).Where(e => e.PluginInfo.PluginId.ToLower().Contains("weixin")).FirstOrDefault(); if (plugins != null) { try { var shopModel = _iShopService.GetShop(model.ShopId); EnterprisePayPara para = new EnterprisePayPara() { amount = model.CashAmount, check_name = false, openid = shopModel.WeiXinOpenId, out_trade_no = model.CashNo.ToString(), desc = "提现" }; PaymentInfo result = plugins.Biz.EnterprisePay(para); model.SerialNo = result.TradNo; model.DealTime = DateTime.Now; model.Status = WithdrawStaus.Succeed; model.PlatRemark = Remark; _iBillingService.UpdateShopWithDraw(model); //资金处理 updateAccount(model.ShopId, model.CashAmount, Himall.CommonModel.ShopAccountType.WithDraw, result.TradNo, "微信提现", Id); //操作日志 _iOperationLogService.AddPlatformOperationLog( new LogInfo { Date = DateTime.Now, Description = string.Format("店铺微信提现审核成功,店铺Id={0},状态为:{1}, 说明是:{2}", model.ShopId, status, Remark), IPAddress = IpAddress, PageUrl = "/Admin/ShopWithDraw/Management", UserName = UserName, ShopId = 0 }); return(true); } catch (Exception ex) { Log.Error("调用企业付款接口异常:" + ex.Message); model.Status = WithdrawStaus.Fail; model.PlatRemark = Remark; model.DealTime = DateTime.Now; _iBillingService.UpdateShopWithDraw(model); //操作日志 _iOperationLogService.AddPlatformOperationLog( new LogInfo { Date = DateTime.Now, Description = string.Format("店铺微信提现审核失败,店铺Id={0},状态为:{1}, 说明是:{2}", model.ShopId, status, Remark), IPAddress = IpAddress, PageUrl = "/Admin/ShopWithDraw/Management", UserName = UserName, ShopId = 0 }); return(false); } } else { return(false); } } }
public JsonResult ConfirmApply(long id, ApplyWithDrawInfo.ApplyWithDrawStatus comfirmStatus, string remark) { var service = _iMemberCapitalService; ApplyWithDrawQuery query = new ApplyWithDrawQuery { withDrawNo = id, PageNo = 1, PageSize = 1 }; var status = comfirmStatus; var model = service.GetApplyWithDraw(query).Models.FirstOrDefault(); if (status == ApplyWithDrawInfo.ApplyWithDrawStatus.Refuse) { service.RefuseApplyWithDraw(id, status, CurrentManager.UserName, remark); //操作日志 _iOperationLogService.AddPlatformOperationLog( new LogInfo { Date = DateTime.Now, Description = string.Format("会员提现审核拒绝,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark), IPAddress = Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = CurrentManager.UserName, ShopId = 0 }); return(Json(new { success = true, msg = "审核成功!" })); } else { var plugins = PluginsManagement.GetPlugins <IPaymentPlugin>(true).Where(e => e.PluginInfo.PluginId.ToLower().Contains("weixin")).FirstOrDefault(); if (plugins != null) { try { EnterprisePayPara para = new EnterprisePayPara() { amount = model.ApplyAmount, check_name = false, openid = model.OpenId, out_trade_no = model.Id.ToString(), desc = "提现" }; PaymentInfo result = plugins.Biz.EnterprisePay(para); ApplyWithDrawInfo info = new ApplyWithDrawInfo { PayNo = result.TradNo, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess, Remark = plugins.PluginInfo.Description, PayTime = result.TradeTime.HasValue ? result.TradeTime.Value : DateTime.Now, ConfirmTime = DateTime.Now, OpUser = CurrentManager.UserName, ApplyAmount = model.ApplyAmount, Id = model.Id }; //Log.Debug("提现:" + info.PayNo); service.ConfirmApplyWithDraw(info); //操作日志 _iOperationLogService.AddPlatformOperationLog( new LogInfo { Date = DateTime.Now, Description = string.Format("会员提现审核成功,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark), IPAddress = Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = CurrentManager.UserName, ShopId = 0 }); } catch (PluginException pex) {//插件异常,直接返回错误信息 Log.Error("调用企业付款接口异常:" + pex.Message); //操作日志 _iOperationLogService.AddPlatformOperationLog( new LogInfo { Date = DateTime.Now, Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark), IPAddress = Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = CurrentManager.UserName, ShopId = 0 }); return(Json(new { success = false, msg = pex.Message })); } catch (Exception ex) { Log.Error("提现审核异常:" + ex.Message); ApplyWithDrawInfo info = new ApplyWithDrawInfo { ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail, Remark = plugins.PluginInfo.Description, ConfirmTime = DateTime.Now, OpUser = CurrentManager.UserName, ApplyAmount = model.ApplyAmount, Id = model.Id }; service.ConfirmApplyWithDraw(info); //操作日志 _iOperationLogService.AddPlatformOperationLog( new LogInfo { Date = DateTime.Now, Description = string.Format("会员提现审核失败,会员Id={0},状态为:{1}, 说明是:{2}", model.MemId, status, remark), IPAddress = Request.UserHostAddress, PageUrl = "/Admin/Capital/WithDraw", UserName = CurrentManager.UserName, ShopId = 0 }); return(Json(new { success = false, msg = "付款接口异常" })); } } else { return(Json(new { success = false, msg = "未找到支付插件" })); } } return(Json(new { success = true, msg = "付款成功" })); }