public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd, int applyType = 1) { var success = Application.MemberApplication.VerificationPayPwd(CurrentUser.Id, pwd); if (!success) { throw new HimallException("支付密码不对,请重新输入!"); } if (applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode() && !SiteSettings.Withdraw_AlipayEnable) { throw new HimallException("不支持支付宝提现方式!"); } //TODO:FG 存在多处申请提现逻辑,提取至Application中实现 var balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id); if (amount > balance) { throw new HimallException("提现金额不能超出可用金额!"); } if (amount <= 0) { throw new HimallException("提现金额不能小于等于0!"); } if (string.IsNullOrWhiteSpace(openid)) { throw new HimallException("数据异常,OpenId或收款账号不可为空!"); } if (string.IsNullOrWhiteSpace(nickname) && applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode()) { throw new HimallException("数据异常,真实姓名不可为空!"); } var siteSetting = SiteSettingApplication.SiteSettings; if (!(amount <= siteSetting.WithDrawMaximum) && !(amount >= siteSetting.WithDrawMinimum)) { throw new HimallException("提现金额不能小于:" + siteSetting.WithDrawMinimum + ",不能大于:" + siteSetting.WithDrawMaximum); } Himall.Entities.ApplyWithDrawInfo model = new Himall.Entities.ApplyWithDrawInfo() { ApplyAmount = amount, ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = CurrentUser.Id, OpenId = openid, NickName = nickname, ApplyType = (CommonModel.UserWithdrawType)applyType }; _iMemberCapitalService.AddWithDrawApply(model); return(Json(new { success = true })); }
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 = "审核操作成功" })); }