public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd) { if (ServiceHelper.Create <IMemberCapitalService>().GetMemberInfoByPayPwd(base.CurrentUser.Id, pwd) == null) { throw new HimallException("支付密码不对,请重新输入!"); } CapitalInfo capitalInfo = ServiceHelper.Create <IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id); decimal num = amount; decimal? balance = capitalInfo.Balance; if ((num <= balance.GetValueOrDefault() ? false : balance.HasValue)) { throw new HimallException("提现金额不能超出可用金额!"); } ApplyWithDrawInfo applyWithDrawInfo = new ApplyWithDrawInfo() { ApplyAmount = amount, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = base.CurrentUser.Id, OpenId = openid, NickName = nickname }; ServiceHelper.Create <IMemberCapitalService>().AddWithDrawApply(applyWithDrawInfo); return(Json(new { success = true })); }
public object ApplyWithDraw(ApplayWithDraw applay) { var userInfo = Application.MemberApplication.GetMemberByOpenId(SmallProgServiceProvider, applay.openid); if (userInfo != null) { var _iMemberCapitalService = ServiceProvider.Instance <IMemberCapitalService> .Create; var capitalInfo = _iMemberCapitalService.GetCapitalInfo(CurrentUser.Id); if (applay.amount > capitalInfo.Balance) { return(Json(new { Success = false, Message = "提现金额不能超出可用金额" })); } if (applay.amount <= 0) { return(Json(new { Success = false, Message = "提现金额不能小于等于0" })); } ApplyWithDrawInfo model = new ApplyWithDrawInfo() { ApplyAmount = applay.amount, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = CurrentUser.Id, OpenId = applay.openid, NickName = CurrentUser.Nick }; _iMemberCapitalService.AddWithDrawApply(model); return(Json(new { success = true, Message = "申请提现成功" })); } else { return(Json(new { Success = false, Message = "未登录" })); } }
public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd) { var success = Application.MemberApplication.VerificationPayPwd(CurrentUser.Id, pwd); if (!success) { throw new HimallException("支付密码不对,请重新输入!"); } var capitalInfo = _iMemberCapitalService.GetCapitalInfo(CurrentUser.Id); if (amount > capitalInfo.Balance) { throw new HimallException("提现金额不能超出可用金额!"); } if (amount <= 0) { throw new HimallException("提现金额不能小于等于0!"); } ApplyWithDrawInfo model = new ApplyWithDrawInfo() { ApplyAmount = amount, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = CurrentUser.Id, OpenId = openid, NickName = nickname }; _iMemberCapitalService.AddWithDrawApply(model); return(Json(new { success = true })); }
public void ConfirmApplyWithDraw(ApplyWithDrawInfo info) { var model = Context.ApplyWithDrawInfo.FirstOrDefault(e => e.Id == info.Id); using (TransactionScope scope = new TransactionScope()) { model.ApplyStatus = info.ApplyStatus; model.OpUser = info.OpUser; model.Remark = info.Remark; model.ConfirmTime = info.ConfirmTime.HasValue ? info.ConfirmTime.Value : DateTime.Now; Context.SaveChanges(); if (info.ApplyStatus == ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess) { model.PayNo = info.PayNo; model.PayTime = info.PayTime.HasValue ? info.PayTime.Value : DateTime.Now; CapitalDetailModel capitalDetail = new CapitalDetailModel { Amount = -info.ApplyAmount, UserId = model.MemId, PayWay = info.Remark, SourceType = CapitalDetailInfo.CapitalDetailType.WithDraw, SourceData = info.Id.ToString() }; AddCapital(capitalDetail); } scope.Complete(); } }
public void ConfirmApplyWithDraw(ApplyWithDrawInfo info) { ApplyWithDrawInfo applyStatus = context.ApplyWithDrawInfo.FirstOrDefault((ApplyWithDrawInfo e) => e.Id == info.Id); using (TransactionScope transactionScope = new TransactionScope()) { applyStatus.ApplyStatus = info.ApplyStatus; applyStatus.OpUser = info.OpUser; applyStatus.Remark = info.Remark; applyStatus.ConfirmTime = new DateTime?((info.ConfirmTime.HasValue ? info.ConfirmTime.Value : DateTime.Now)); context.SaveChanges(); if (info.ApplyStatus == ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess) { applyStatus.PayNo = info.PayNo; applyStatus.PayTime = new DateTime?((info.PayTime.HasValue ? info.PayTime.Value : DateTime.Now)); CapitalDetailModel capitalDetailModel = new CapitalDetailModel() { Amount = -info.ApplyAmount, UserId = applyStatus.MemId, PayWay = info.Remark, SourceType = CapitalDetailInfo.CapitalDetailType.WithDraw, SourceData = info.Id.ToString() }; AddCapital(capitalDetailModel); } transactionScope.Complete(); } }
public void GetStateAsync(string sceneid) { base.AsyncManager.OutstandingOperations.Increment(); int num1 = 200; int num2 = 10000; Task.Factory.StartNew(() => { int num = 0; while (true) { ApplyWithDrawInfo applyWithDrawInfo = Cache.Get(CacheKeyCollection.SceneReturn(sceneid)) as ApplyWithDrawInfo; if (applyWithDrawInfo != null) { AsyncManager.Parameters["state"] = true; AsyncManager.Parameters["model"] = applyWithDrawInfo; break; } else if (num < num2) { num = num + num1; Thread.Sleep(num1); } else { AsyncManager.Parameters["state"] = false; AsyncManager.Parameters["model"] = applyWithDrawInfo; break; } } AsyncManager.OutstandingOperations.Decrement(); }); }
public void RefuseApplyWithDraw(long id, ApplyWithDrawInfo.ApplyWithDrawStatus status, string opuser, string remark) { decimal? nullable; ApplyWithDrawInfo applyWithDrawInfo = context.ApplyWithDrawInfo.FirstOrDefault((ApplyWithDrawInfo e) => e.Id == id); applyWithDrawInfo.ApplyStatus = status; applyWithDrawInfo.OpUser = opuser; applyWithDrawInfo.Remark = remark; applyWithDrawInfo.ConfirmTime = new DateTime?(DateTime.Now); CapitalInfo capitalInfo = context.CapitalInfo.FirstOrDefault((CapitalInfo e) => e.MemId == applyWithDrawInfo.MemId); decimal? balance = capitalInfo.Balance; capitalInfo.Balance = new decimal?(balance.Value + applyWithDrawInfo.ApplyAmount); CapitalInfo capitalInfo1 = capitalInfo; decimal? freezeAmount = capitalInfo.FreezeAmount; decimal applyAmount = applyWithDrawInfo.ApplyAmount; if (freezeAmount.HasValue) { nullable = new decimal?(freezeAmount.GetValueOrDefault() - applyAmount); } else { nullable = null; } capitalInfo1.FreezeAmount = nullable; context.SaveChanges(); }
/* public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd) //仅仅支持微信支付 * { * if (ServiceHelper.Create<IMemberCapitalService>().GetMemberInfoByPayPwd(base.CurrentUser.Id, pwd) == null) * { * throw new HimallException("支付密码不对,请重新输入!"); * } * CapitalInfo capitalInfo = ServiceHelper.Create<IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id); * decimal num = amount; * decimal? balance = capitalInfo.Balance; * if ((num <= balance.GetValueOrDefault() ? false : balance.HasValue)) * { * throw new HimallException("提现金额不能超出可用金额!"); * } * ApplyWithDrawInfo applyWithDrawInfo = new ApplyWithDrawInfo() * { * ApplyAmount = amount, * ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, * ApplyTime = DateTime.Now, * MemId = base.CurrentUser.Id, * OpenId = openid, * NickName = nickname * }; * ServiceHelper.Create<IMemberCapitalService>().AddWithDrawApply(applyWithDrawInfo); * return Json(new { success = true }); * }*/ public JsonResult ApplyWithDrawSubmit(string withdrawtype, string myaccount, string nickname, decimal amount, string pwd) //扩展版本(提现方式、账号、人名) { //if (withdrawtype == null) // return Json(new { success = true }); if (ServiceHelper.Create <IMemberCapitalService>().GetMemberInfoByPayPwd(base.CurrentUser.Id, pwd) == null) { // throw new HimallException("支付密码不对,请重新输入!"); return(Json(new { success = false, msg = "Payment pwd error,please try again!" })); } CapitalInfo capitalInfo = ServiceHelper.Create <IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id); decimal num = amount; decimal? balance = capitalInfo.Balance; if ((num <= balance.GetValueOrDefault() ? false : balance.HasValue)) { throw new HimallException("withdraw amount exceed Balance!"); } ApplyWithDrawInfo applyWithDrawInfo = new ApplyWithDrawInfo() { ApplyAmount = amount, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = base.CurrentUser.Id, AccountId = 0, WithdrawType = withdrawtype, Myaccount = myaccount, NickName = nickname, }; ServiceHelper.Create <IMemberCapitalService>().AddWithDrawApply(applyWithDrawInfo); return(base.Json(new { success = true })); }
public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd, int applyType = 1) { if (!MemberApplication.VerificationPayPwd(base.CurrentUser.Id, pwd)) { throw new HimallException("支付密码不对,请重新输入!"); } if (!((applyType != UserWithdrawType.ALiPay.GetHashCode()) || base.CurrentSiteSetting.Withdraw_AlipayEnable)) { throw new HimallException("不支持支付宝提现方式!"); } CapitalInfo capitalInfo = this._iMemberCapitalService.GetCapitalInfo(base.CurrentUser.Id); if (amount > capitalInfo.Balance) { throw new HimallException("提现金额不能超出可用金额!"); } if (amount <= 0M) { throw new HimallException("提现金额不能小于等于0!"); } if (string.IsNullOrWhiteSpace(openid) && (applyType == UserWithdrawType.WeiChat.GetHashCode())) { openid = WebHelper.GetCookie("Himall-User_OpenId"); } if (string.IsNullOrWhiteSpace(nickname) && (applyType == UserWithdrawType.ALiPay.GetHashCode())) { throw new HimallException("数据异常,真实姓名不可为空!"); } if (!string.IsNullOrWhiteSpace(openid) && (applyType == UserWithdrawType.WeiChat.GetHashCode())) { openid = SecureHelper.AESDecrypt(openid, "Mobile"); SiteSettingsInfo siteSettings = this._iSiteSettingService.GetSiteSettings(); if (!string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) && !string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret)) { WeixinUserInfoResult userInfo = CommonApi.GetUserInfo(AccessTokenContainer.TryGetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, false), openid); if (userInfo != null) { nickname = userInfo.nickname; } } } if (string.IsNullOrWhiteSpace(openid)) { throw new HimallException("数据异常,OpenId或收款账号不可为空!"); } ApplyWithDrawInfo model = new ApplyWithDrawInfo { ApplyAmount = amount, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = base.CurrentUser.Id, OpenId = openid, NickName = nickname, ApplyType = new UserWithdrawType?((UserWithdrawType)applyType) }; this._iMemberCapitalService.AddWithDrawApply(model); return(base.Json(new { success = true })); }
public void AddWithDrawApply(ApplyWithDrawInfo model) { Context.ApplyWithDrawInfo.Add(model); var capital = Context.CapitalInfo.FirstOrDefault(e => e.MemId == model.MemId); capital.Balance -= model.ApplyAmount; capital.FreezeAmount = capital.FreezeAmount.HasValue ? capital.FreezeAmount.Value + model.ApplyAmount : model.ApplyAmount; Context.SaveChanges(); }
public void ConfirmApplyWithDraw(ApplyWithDrawInfo info) { var model = DbFactory.Default.Get <ApplyWithDrawInfo>().Where(e => e.Id == info.Id).FirstOrDefault(); var flag = DbFactory.Default.InTransaction(() => { model.ApplyStatus = info.ApplyStatus; model.OpUser = info.OpUser; model.Remark = info.Remark; model.ConfirmTime = info.ConfirmTime.HasValue ? info.ConfirmTime.Value : DateTime.Now; //Context.SaveChanges(); DbFactory.Default.Update(model); if (info.ApplyStatus == ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess) { //model.PayNo = info.PayNo; //model.PayTime = info.PayTime.HasValue ? info.PayTime.Value : DateTime.Now; //DbFactory.Default.Update(model); DbFactory.Default.Set <ApplyWithDrawInfo>().Set(n => n.PayNo, info.PayNo).Set(n => n.PayTime, info.PayTime.HasValue ? info.PayTime.Value : DateTime.Now).Where(p => p.Id == model.Id).Succeed(); CapitalDetailModel capitalDetail = new CapitalDetailModel { Amount = -info.ApplyAmount, UserId = model.MemId, PayWay = info.Remark, SourceType = CapitalDetailInfo.CapitalDetailType.WithDraw, SourceData = info.Id.ToString() }; AddCapital(capitalDetail, false); } //scope.Complete(); return(true); }); if (flag) { //发送消息 var member = DbFactory.Default.Get <MemberInfo>(m => m.Id == model.MemId).FirstOrDefault(); var message = new MessageWithDrawInfo(); message.UserName = model.NickName; message.UserName = member != null ? member.UserName : ""; message.Amount = model.ApplyAmount; message.ApplyType = model.ApplyType.GetHashCode(); message.ApplyTime = model.ApplyTime; message.Remark = model.Remark; message.SiteName = SiteSettingApplication.SiteSettings.SiteName; if (info.ApplyStatus == ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess) { Task.Factory.StartNew(() => ServiceProvider.Instance <IMessageService> .Create.SendMessageOnMemberWithDrawSuccess(model.MemId, message)); } if (info.ApplyStatus == ApplyWithDrawInfo.ApplyWithDrawStatus.Refuse) { Task.Factory.StartNew(() => ServiceProvider.Instance <IMessageService> .Create.SendMessageOnMemberWithDrawFail(model.MemId, message)); } } }
public JsonResult ApplyWithDrawSubmit(string nickname, decimal amount, string pwd) { var success = MemberApplication.VerificationPayPwd(CurrentUser.Id, pwd); if (!success) { throw new HimallException("支付密码不对,请重新输入!"); } var capitalInfo = _iMemberCapitalService.GetCapitalInfo(CurrentUser.Id); if (amount > capitalInfo.Balance) { throw new HimallException("提现金额不能超出可用金额!"); } if (amount <= 0) { throw new HimallException("提现金额不能小于等于0!"); } var openid = Core.Helper.WebHelper.GetCookie(CookieKeysCollection.HIMALL_USER_OpenID); string strNick = string.Empty; if (!string.IsNullOrWhiteSpace(openid)) { openid = Core.Helper.SecureHelper.AESDecrypt(openid, "Mobile"); var siteSetting = _iSiteSettingService.GetSiteSettings(); if (!(string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret))) { string token = AccessTokenContainer.TryGetToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret); var userinfo = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetUserInfo(token, openid); if (userinfo != null) { strNick = userinfo.nickname; } } } else { throw new HimallException("数据异常,OpenId不能为空!"); } ApplyWithDrawInfo model = new ApplyWithDrawInfo() { ApplyAmount = amount, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = CurrentUser.Id, OpenId = openid, NickName = strNick }; _iMemberCapitalService.AddWithDrawApply(model); return(Json(new { success = true })); }
/// <summary> /// 取消支付 /// </summary> /// <param name="Id"></param> /// <returns></returns> public bool CancelPay(long Id) { bool flag = false; ApplyWithDrawInfo applyWithDrawInfo = Queryable.FirstOrDefault <ApplyWithDrawInfo>((IQueryable <ApplyWithDrawInfo>) this.Context.ApplyWithDrawInfo, (Expression <Func <ApplyWithDrawInfo, bool> >)(r => r.Id == Id)); if (applyWithDrawInfo != null && applyWithDrawInfo.ApplyStatus == ApplyWithDrawInfo.ApplyWithDrawStatus.PayPending) { applyWithDrawInfo.ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm; flag = this.Context.SaveChanges() > 0; } return(flag); }
public JsonResult ApplyWithDrawSubmit(string nickname, decimal amount, string pwd) { if (ServiceHelper.Create <IMemberCapitalService>().GetMemberInfoByPayPwd(base.CurrentUser.Id, pwd) == null) { throw new HimallException("支付密码不对,请重新输入!"); } CapitalInfo capitalInfo = ServiceHelper.Create <IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id); decimal num = amount; decimal? balance = capitalInfo.Balance; if ((num <= balance.GetValueOrDefault() ? false : balance.HasValue)) { throw new HimallException("提现金额不能超出可用金额!"); } string cookie = WebHelper.GetCookie("Himall-User_OpenId"); string empty = string.Empty; if (string.IsNullOrWhiteSpace(cookie)) { throw new HimallException("数据异常,OpenId不能为空!"); } cookie = SecureHelper.AESDecrypt(cookie, "Mobile"); SiteSettingsInfo siteSettings = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings(); if (!string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) && !string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret)) { //string str = AccessTokenContainer.TryGetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, false); string str = CommonApi.GetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret).access_token; // WeixinUserInfoResult userInfo = CommonApi.GetUserInfo(str, cookie); if (userInfo != null) { empty = userInfo.nickname; } } ApplyWithDrawInfo applyWithDrawInfo = new ApplyWithDrawInfo() { ApplyAmount = amount, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = base.CurrentUser.Id, OpenId = cookie, NickName = empty }; ServiceHelper.Create <IMemberCapitalService>().AddWithDrawApply(applyWithDrawInfo); return(Json(new { success = true })); }
private string ProcessWithDrawScene(RequestMessageEventBase weixinMsg, string sceneid, SceneModel model) { try { string str = CacheKeyCollection.SceneReturn(sceneid); if (!(Cache.Get(str) is ApplyWithDrawInfo)) { SiteSettingsInfo siteSettings = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings(); if (string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) || string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret)) { Log.Error("微信事件回调:未设置公众号配置参数!"); } else { //string str1 = AccessTokenContainer.TryGetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, false); string str1 = CommonApi.GetToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret).access_token; // WeixinUserInfoResult userInfo = CommonApi.GetUserInfo(str1, weixinMsg.FromUserName); ApplyWithDrawInfo applyWithDrawInfo = new ApplyWithDrawInfo() { MemId = long.Parse(model.Object.ToString()), OpenId = weixinMsg.FromUserName, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, NickName = userInfo.nickname }; ApplyWithDrawInfo applyWithDrawInfo1 = applyWithDrawInfo; if (Cache.Get(str) != null) { Cache.Remove(str); } Cache.Insert(str, applyWithDrawInfo1, 300); } } } catch (Exception exception) { Log.Error(string.Concat("ProcessWithDrawScene:", exception.Message)); } return(string.Empty); }
public void AddWithDrawApply(ApplyWithDrawInfo model) { decimal?nullable; context.ApplyWithDrawInfo.Add(model); CapitalInfo capitalInfo = context.CapitalInfo.FirstOrDefault((CapitalInfo e) => e.MemId == model.MemId); CapitalInfo capitalInfo1 = capitalInfo; decimal? balance = capitalInfo1.Balance; decimal applyAmount = model.ApplyAmount; if (balance.HasValue) { nullable = new decimal?(balance.GetValueOrDefault() - applyAmount); } else { nullable = null; } capitalInfo1.Balance = nullable; capitalInfo.FreezeAmount = new decimal?((capitalInfo.FreezeAmount.HasValue ? capitalInfo.FreezeAmount.Value + model.ApplyAmount : model.ApplyAmount)); context.SaveChanges(); }
/// <summary> /// 提现 /// </summary> /// <param name="weixinMsg"></param> /// <param name="sceneid"></param> /// <param name="model"></param> /// <returns></returns> private string ProcessWithDrawScene(RequestMessageEventBase weixinMsg, string sceneid, SceneModel model) { try { var key = CacheKeyCollection.SceneReturn(sceneid); var sceneResult = Core.Cache.Get <ApplyWithDrawInfo>(key); if (sceneResult == null) { var siteSetting = SiteSettingApplication.SiteSettings; if (!(string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret))) { string token = AccessTokenContainer.TryGetToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret); var userinfo = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetUserInfo(token, weixinMsg.FromUserName); var withDraw = new ApplyWithDrawInfo { MemId = long.Parse(model.Object.ToString()), OpenId = weixinMsg.FromUserName, ApplyStatus = ApplyWithDrawInfo.ApplyWithDrawStatus.WaitConfirm, NickName = userinfo.nickname }; if (Core.Cache.Get <ApplyWithDrawInfo>(key) != null) { Core.Cache.Remove(key); } Core.Cache.Insert(key, withDraw, 300); } else { Core.Log.Error("微信事件回调:未设置公众号配置参数!"); } } } catch (Exception ex) { Log.Error("ProcessWithDrawScene:" + ex.Message); } return(string.Empty); }
public void AddWithDrawApply(ApplyWithDrawInfo model) { if (model.WithdrawType != null) { decimal?nullable; decimal value; context.ApplyWithDrawInfo.Add(model); CapitalInfo capitalInfo = context.CapitalInfo.FirstOrDefault((CapitalInfo e) => e.MemId == model.MemId); CapitalInfo capitalInfo1 = capitalInfo; decimal? balance = capitalInfo1.Balance; decimal applyAmount = model.ApplyAmount; if (balance.HasValue) { nullable = new decimal?(balance.GetValueOrDefault() - applyAmount); } else { nullable = null; } capitalInfo1.Balance = nullable; CapitalInfo nullable1 = capitalInfo; balance = capitalInfo.FreezeAmount; if (balance.HasValue) { balance = capitalInfo.FreezeAmount; value = balance.Value + model.ApplyAmount; } else { value = model.ApplyAmount; } nullable1.FreezeAmount = new decimal?(value); this.context.SaveChanges(); } }
public void AddWithDrawApply(ApplyWithDrawInfo model) { DbFactory.Default.Add(model); var capital = DbFactory.Default.Get <CapitalInfo>().Where(e => e.MemId == model.MemId).FirstOrDefault(); capital.Balance -= model.ApplyAmount; capital.FreezeAmount = capital.FreezeAmount + model.ApplyAmount; var result = DbFactory.Default.Update(capital); //发送消息 if (result > 0) { var member = DbFactory.Default.Get <MemberInfo>(m => m.Id == model.MemId).FirstOrDefault(); var message = new MessageWithDrawInfo(); message.UserName = model.NickName; message.UserName = member != null ? member.UserName : ""; message.Amount = model.ApplyAmount; message.ApplyType = model.ApplyType.GetHashCode(); message.ApplyTime = model.ApplyTime; message.Remark = model.Remark; message.SiteName = SiteSettingApplication.SiteSettings.SiteName; Task.Factory.StartNew(() => ServiceProvider.Instance <IMessageService> .Create.SendMessageOnMemberWithDrawApply(model.MemId, message)); } }
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); }
/// <summary> /// 添加提现申请 /// </summary> /// <param name="memid"></param> /// <param name="amount"></param> /// <param name="nickname"></param> public static void AddWithDrawApply(ApplyWithDrawInfo model) { Service.AddWithDrawApply(model); }
/// <summary> /// 审核会员申请提现 /// </summary> /// <param name="id"></param> public static void ConfirmApplyWithDraw(ApplyWithDrawInfo info) { _iMemberCapitalService.ConfirmApplyWithDraw(info); }
public JsonResult GetStateCompleted(bool state, ApplyWithDrawInfo model) { return(Json(new { success = state, data = model }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 添加提现申请 /// </summary> /// <param name="memid"></param> /// <param name="amount"></param> /// <param name="nickname"></param> public static void AddWithDrawApply(ApplyWithDrawInfo model) { _iMemberCapitalService.AddWithDrawApply(model); }
/// <summary> /// 审核会员申请提现 /// </summary> /// <param name="id"></param> public static void ConfirmApplyWithDraw(ApplyWithDrawInfo info) { Service.ConfirmApplyWithDraw(info); }
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 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 = "付款成功" })); }