public ActionResult ApplyWithDraw() { var siteSetting = SiteSettingApplication.SiteSettings; if (string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret)) { throw new MallException("未配置公众号参数"); } var token = AccessTokenContainer.TryGetAccessToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret); SceneModel scene = new SceneModel(QR_SCENE_Type.WithDraw) { Object = CurrentUser.Id.ToString() }; SceneHelper helper = new SceneHelper(); var sceneid = helper.SetModel(scene); var ticket = QrCodeApi.Create(token, 300, sceneid, Senparc.Weixin.MP.QrCode_ActionName.QR_LIMIT_SCENE, null); ViewBag.ticket = ticket.ticket; ViewBag.Sceneid = sceneid; var balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id); ViewBag.ApplyWithMoney = balance; var member = _iMemberService.GetMember(CurrentUser.Id);//CurrentUser对象有缓存,取不到最新数据 ViewBag.IsSetPwd = string.IsNullOrWhiteSpace(member.PayPwd) ? false : true; ViewBag.WithDrawMinimum = siteSetting.WithDrawMinimum; ViewBag.WithDrawMaximum = siteSetting.WithDrawMaximum; ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; return(View()); }
public object GetUser(string UserKey) { CheckUserLogin(); dynamic data = SuccessResult(); long userId = CurrentUser.Id; var member = MemberApplication.GetMember(userId); data.UserId = member.Id; data.UserName = member.UserName; data.Photo = string.IsNullOrEmpty(member.Photo) ? "" : HimallIO.GetRomoteImagePath(member.Photo); data.CellPhone = member.CellPhone; data.QQ = member.QQ; data.BirthDay = member.BirthDay; data.Nick = member.Nick; data.RealName = member.RealName; data.Sex = (int)member.Sex; var orderStatic = StatisticApplication.GetMemberOrderStatistic(userId, true); //用户所有订单 data.AllOrders = orderStatic.OrderCount; //待付款订单 data.WaitingForPay = orderStatic.WaitingForPay; //待发货订单 data.WaitingForDelivery = orderStatic.WaitingForDelivery;//获取待发货订单数 //未评论订单 data.WaitingForComments = orderStatic.WaitingForComments; //待收货订单/待消费 data.WaitingForRecieve = orderStatic.WaitingForRecieve + OrderApplication.GetWaitConsumptionOrderNumByUserId(userId); //待处理的售后 data.RefundOrders = orderStatic.RefundCount; data.FavoriteShop = ShopApplication.GetUserConcernShopsCount(userId); data.FavoriteProduct = FavoriteApplication.GetFavoriteCountByUser(userId); data.Coupon = MemberApplication.GetAvailableCouponCount(userId); data.Integral = MemberIntegralApplication.GetAvailableIntegral(userId); data.Balance = MemberCapitalApplication.GetBalanceByUserId(userId); //用户参与的团数量 var seastatus = new List <FightGroupOrderJoinStatus> { FightGroupOrderJoinStatus.Ongoing, FightGroupOrderJoinStatus.JoinSuccess, FightGroupOrderJoinStatus.BuildFailed, FightGroupOrderJoinStatus.BuildSuccess }; //TODO:FG 查询待优化 data.GroupTotal = ServiceProvider.Instance <IFightGroupService> .Create.GetJoinGroups(userId, seastatus, 1, 1).Total; data.MyGroup = ServiceProvider.Instance <IFightGroupService> .Create.CountJoiningOrder(userId); data.IsOpenRechargePresent = SiteSettingApplication.SiteSettings.IsOpenRechargePresent; MemberApplication.AddIntegel(member);//给用户加积分//执行登录后初始化相关操作 return(data); }
public object GetCapital() { CheckUserLogin(); var capital = MemberCapitalApplication.GetCapitalInfo(CurrentUser.Id); var sitesetting = SiteSettingApplication.SiteSettings; var redPacketAmount = 0M; if (capital != null) { //redPacketAmount = capital.Mall_CapitalDetail.Where(e => e.SourceType == Mall.Model.CapitalDetailInfo.CapitalDetailType.RedPacket).Sum(e => e.Amount); redPacketAmount = MemberCapitalApplication.GetSumRedPacket(capital.Id); } else { capital = new CapitalInfo(); } bool canWithDraw = MemberApplication.CanWithdraw(CurrentUser.Id); return(Json(new { success = true, Balance = capital?.Balance ?? 0, RedPacketAmount = redPacketAmount, PresentAmount = capital?.PresentAmount ?? 0, ChargeAmount = capital?.ChargeAmount ?? 0, WithDrawMinimum = sitesetting.WithDrawMinimum, WithDrawMaximum = sitesetting.WithDrawMaximum, canWithDraw = canWithDraw, isOpen = sitesetting.IsOpenRechargePresent, rule = RechargePresentRuleApplication.GetRules() })); }
public object GetList(int pageNo = 1, int pageSize = 10) { CheckUserLogin(); var query = new CapitalDetailQuery { memberId = CurrentUser.Id, PageSize = pageSize, PageNo = pageNo }; var pageMode = MemberCapitalApplication.GetCapitalDetails(query); var model = pageMode.Models.ToList().Select(e => new CapitalDetailModel { Id = e.Id, Amount = e.Amount + e.PresentAmount, PresentAmount = e.PresentAmount, CapitalID = e.CapitalID, CreateTime = e.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), SourceData = e.SourceData, SourceType = e.SourceType, Remark = GetRemark(e), PayWay = e.Remark }); return(Json(new { rows = model, total = pageMode.Total })); }
public JsonResult ChageCapital(long userId, decimal amount, string remark) { var result = new Result { msg = "错误的会员编号" }; var _user = MemberApplication.GetMember(userId); if (_user != null) { if (string.IsNullOrWhiteSpace(remark)) { result.msg = "请填写备注信息"; } else { if (amount < 0) { var balance = MemberCapitalApplication.GetBalanceByUserId(userId); if (balance < Math.Abs(amount)) { throw new HimallException("用户余额不足相减"); } } if (amount < 0) { CapitalDetailModel capita = new CapitalDetailModel { UserId = userId, SourceType = CapitalDetailType.ChargeAmount, Amount = amount, CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = remark, PayWay = "管理员操作" }; _iMemberCapitalService.AddCapital(capita); } else { var detail = new Entities.ChargeDetailInfo() { ChargeAmount = amount, ChargeStatus = Entities.ChargeDetailInfo.ChargeDetailStatus.WaitPay, CreateTime = DateTime.Now, MemId = userId, ChargeWay = "管理员操作" }; long id = _iMemberCapitalService.AddChargeApply(detail); _iMemberCapitalService.ChargeSuccess(id, remark + " 管理员操作"); } result.success = true; result.msg = "操作成功"; } } return(Json(result)); }
// GET: Web/UserCapital public ActionResult Index() { var capitalService = _iMemberCapitalService; var model = MemberCapitalApplication.GetCapitalInfo(CurrentUser.Id); ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; ViewBag.CanWithDraw = MemberApplication.CanWithdraw(CurrentUser.Id); return(View(model)); }
public object PostSetPayPwd(PostSetPayPwdModel model) { CheckUserLogin(); if (string.IsNullOrWhiteSpace(model.pwd)) { return(Json(ErrorResult <int>("支付密码不能为空"))); } MemberCapitalApplication.SetPayPwd(CurrentUser.Id, model.pwd); return(Json(new { msg = "设置成功" })); }
public JsonResult Charge(string pluginId, decimal amount, bool ispresent = false) { amount = Math.Round(amount, 2); if (amount <= 0) { return(Json(new { success = false, msg = "请输入正确的金额" })); } var plugin = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(pluginId); var chargeDetail = new DTO.ChargeDetail(); chargeDetail.ChargeAmount = amount; chargeDetail.ChargeStatus = ChargeDetailInfo.ChargeDetailStatus.WaitPay; chargeDetail.ChargeWay = PaymentApplication.GetForeGroundPaymentName(plugin.PluginInfo.Description); chargeDetail.CreateTime = DateTime.Now; chargeDetail.MemId = CurrentUser.Id; if (ispresent && SiteSettings.IsOpenRechargePresent) { var rule = RechargePresentRuleApplication.GetRules().FirstOrDefault(d => d.ChargeAmount == amount); if (rule != null) { chargeDetail.PresentAmount = rule.PresentAmount; } } var id = MemberCapitalApplication.AddChargeApply(chargeDetail); string openId = Core.Helper.WebHelper.GetCookie(CookieKeysCollection.HIMALL_USER_OpenID); if (!string.IsNullOrWhiteSpace(openId)) { openId = Core.Helper.SecureHelper.AESDecrypt(openId, "Mobile"); } else { var openUserInfo = Application.MemberApplication.GetMemberOpenIdInfoByuserId(CurrentUser.Id, Entities.MemberOpenIdInfo.AppIdTypeEnum.Payment); if (openUserInfo != null) { openId = openUserInfo.OpenId; } } string webRoot = Request.Url.Scheme + "://" + Request.Url.Authority; string notifyUrl = webRoot + "/m-" + PlatformType + "/Payment/CapitalChargeNotify/" + plugin.PluginInfo.PluginId.Replace(".", "-") + "/"; string returnUrl = webRoot + "/m-" + PlatformType + "/Capital/Index"; var requestUrl = plugin.Biz.GetRequestUrl(returnUrl, notifyUrl, id.ToString(), amount, "会员充值", openId); return(Json(new { href = requestUrl, success = true })); }
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 MallException("支付密码不对,请重新输入!"); } if (applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode() && !SiteSettings.Withdraw_AlipayEnable) { throw new MallException("不支持支付宝提现方式!"); } //TODO:FG 存在多处申请提现逻辑,提取至Application中实现 var balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id); if (amount > balance) { throw new MallException("提现金额不能超出可用金额!"); } if (amount <= 0) { throw new MallException("提现金额不能小于等于0!"); } if (string.IsNullOrWhiteSpace(openid)) { throw new MallException("数据异常,OpenId或收款账号不可为空!"); } if (string.IsNullOrWhiteSpace(nickname) && applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode()) { throw new MallException("数据异常,真实姓名不可为空!"); } var siteSetting = SiteSettingApplication.SiteSettings; if (!(amount <= siteSetting.WithDrawMaximum) && !(amount >= siteSetting.WithDrawMinimum)) { throw new MallException("提现金额不能小于:" + siteSetting.WithDrawMinimum + ",不能大于:" + siteSetting.WithDrawMaximum); } Mall.Entities.ApplyWithdrawInfo model = new Mall.Entities.ApplyWithdrawInfo() { ApplyAmount = amount, ApplyStatus = Mall.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 ContentResult PayNotify_Charge(string id) { var plugin = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id.Replace("-", ".")); var payInfo = plugin.Biz.ProcessNotify(_httpContextAccessor); if (payInfo != null) { var chargeApplyId = payInfo.OrderIds.FirstOrDefault(); MemberCapitalApplication.ChargeSuccess(chargeApplyId); var response = plugin.Biz.ConfirmPayResult(); return(Content(response)); } return(Content(string.Empty)); }
public ContentResult EnterpriseNotify_Post(string id, string outid) { Log.Info("[ENP]" + Core.Helper.WebHelper.GetRawUrl()); id = DecodePaymentId(id); string errorMsg = string.Empty; string response = string.Empty; var _iOperationLogService = ServiceApplication.Create <IOperationLogService>(); var withdrawId = long.Parse(outid); var withdrawData = MemberCapitalApplication.GetApplyWithDrawInfo(withdrawId); if (withdrawData == null) { Log.Info("[EnterpriseNotify]" + id + " ^ " + outid); throw new HimallException("参数错误"); } try { var payment = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id); var payInfo = payment.Biz.ProcessEnterprisePayNotify(HttpContext.Request); if (withdrawData.ApplyStatus == Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.PayPending) { withdrawData.ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.WithDrawSuccess; withdrawData.PayTime = DateTime.Now; MemberCapitalApplication.ConfirmApplyWithDraw(withdrawData); } response = payment.Biz.ConfirmPayResult(); } catch (Exception ex) { //支付失败 withdrawData.ApplyStatus = Himall.Entities.ApplyWithDrawInfo.ApplyWithDrawStatus.PayFail; withdrawData.Remark = "异步通知失败,请查看日志"; withdrawData.ConfirmTime = DateTime.Now; MemberCapitalApplication.ConfirmApplyWithDraw(withdrawData); //操作日志 _iOperationLogService.AddPlatformOperationLog(new Entities.LogInfo { Date = DateTime.Now, Description = string.Format("会员提现审核失败,提现编号:{0}", outid), IPAddress = Request.UserHostAddress, PageUrl = "/Pay/EnterpriseNotify", UserName = "******", ShopId = 0 }); errorMsg = ex.Message; Log.Error("EnterpriseNotify_Post", ex); } return(Content(response)); }
public ActionResult ChargeSuccess(string id) { Log.Info("pluginId:" + id); Plugin <IPaymentPlugin> plugin = PluginsManagement.GetPlugin <IPaymentPlugin>(id.Replace("-", ".")); PaymentInfo info = plugin.Biz.ProcessNotify(base.HttpContext.Request); if (info != null) { long chargeDetailId = info.OrderIds.FirstOrDefault <long>(); Log.Info("chargeApplyId:" + chargeDetailId); MemberCapitalApplication.ChargeSuccess(chargeDetailId); string content = plugin.Biz.ConfirmPayResult(); return(base.Content(content)); } Log.Info("payInfo:为空"); return(base.Content(string.Empty)); }
public ActionResult ChargeSuccess(string id) { Log.Info("pluginId:" + id); var plugin = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id.Replace("-", ".")); var payInfo = plugin.Biz.ProcessNotify(this.HttpContext.Request); if (payInfo != null) { var chargeApplyId = payInfo.OrderIds.FirstOrDefault(); Log.Info("chargeApplyId:" + chargeApplyId); MemberCapitalApplication.ChargeSuccess(chargeApplyId); var response = plugin.Biz.ConfirmPayResult(); return(Content(response)); } Log.Info("payInfo:为空"); return(Content(string.Empty)); }
// GET: Mobile/Capital public ActionResult Index() { CapitalIndexChargeModel result = new CapitalIndexChargeModel(); //判断是否需要跳转到支付地址 if (this.Request.Url.AbsolutePath.EndsWith("/Capital/Index", StringComparison.OrdinalIgnoreCase) || this.Request.Url.AbsolutePath.EndsWith("/Capital", StringComparison.OrdinalIgnoreCase)) { return(Redirect(Url.RouteUrl("PayRoute") + "?area=mobile&platform=" + this.PlatformType.ToString() + "&controller=Capital&action=Index")); } var model = MemberCapitalApplication.GetCapitalInfo(CurrentUser.Id); var redPacketAmount = 0M; if (model != null) { //redPacketAmount = model.Himall_CapitalDetail.Where(e => e.SourceType == Model.CapitalDetailInfo.CapitalDetailType.RedPacket).Sum(e => e.Amount); redPacketAmount = MemberCapitalApplication.GetSumRedPacket(model.Id); result.CapitalDetails = MemberCapitalApplication.GetTopCapitalDetailList(model.Id, 15); } else { model = new CapitalInfo { Balance = 0, ChargeAmount = 0, FreezeAmount = 0, MemId = CurrentUser.Id, PresentAmount = 0 }; } result.UserCaptialInfo = model; result.IsEnableRechargePresent = SiteSettings.IsOpenRechargePresent; if (result.IsEnableRechargePresent) { result.RechargePresentRules = RechargePresentRuleApplication.GetRules(); } result.RedPacketAmount = redPacketAmount; result.IsSetPwd = string.IsNullOrWhiteSpace(CurrentUser.PayPwd) ? false : true; var siteSetting = SiteSettingApplication.SiteSettings; result.WithDrawMinimum = siteSetting.WithDrawMinimum; result.WithDrawMaximum = siteSetting.WithDrawMaximum; result.CanWithDraw = MemberApplication.CanWithdraw(CurrentUser.Id); return(View(result)); }
public ActionResult CapitalCharge() { UserCapitalChargeModel result = new UserCapitalChargeModel(); var model = MemberCapitalApplication.GetCapitalInfo(CurrentUser.Id); ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; result.UserCaptialInfo = model ?? new Entities.CapitalInfo(); result.CanWithdraw = MemberApplication.CanWithdraw(CurrentUser.Id); result.IsEnableRechargePresent = SiteSettings.IsOpenRechargePresent; if (result.IsEnableRechargePresent) { result.RechargePresentRules = RechargePresentRuleApplication.GetRules(); } return(View(result)); }
/// <summary> /// 个人中心主页 /// </summary> /// <returns></returns> public new JsonResult <Result <dynamic> > GetUser() { CheckUserLogin(); dynamic d = new System.Dynamic.ExpandoObject(); long id = CurrentUser.Id; var member = MemberApplication.GetMember(id); DistributorInfo currentDistributor = DistributionApplication.GetDistributor(member.Id); d.UserName = member.UserName; //用户名 d.RealName = member.RealName; //真实姓名 d.Nick = member.Nick; //昵称 d.UserId = member.Id.ToString(); d.CellPhone = member.CellPhone; //绑定的手机号码 d.Photo = String.IsNullOrEmpty(member.Photo) ? "" : HimallIO.GetRomoteImagePath(member.Photo); //头像 var statistic = StatisticApplication.GetMemberOrderStatistic(id, true); d.AllOrders = statistic.OrderCount; d.WaitingForPay = statistic.WaitingForPay; d.WaitingForRecieve = statistic.WaitingForRecieve + OrderApplication.GetWaitConsumptionOrderNumByUserId(id); d.WaitingForDelivery = statistic.WaitingForDelivery; d.WaitingForComments = statistic.WaitingForComments; d.RefundOrders = statistic.RefundCount; d.FavoriteShop = ShopApplication.GetUserConcernShopsCount(member.Id); //收藏的店铺数 d.FavoriteProduct = FavoriteApplication.GetFavoriteCountByUser(member.Id); //收藏的商品数 d.Counpon = MemberApplication.GetAvailableCouponCount(id); d.Integral = MemberIntegralApplication.GetAvailableIntegral(member.Id); //我的积分 d.Balance = MemberCapitalApplication.GetBalanceByUserId(member.Id); //我的资产 d.IsOpenRechargePresent = SiteSettingApplication.SiteSettings.IsOpenRechargePresent; var phone = SiteSettingApplication.SiteSettings.SitePhone; d.ServicePhone = string.IsNullOrEmpty(phone) ? "" : phone; d.IsDistributor = (currentDistributor != null && currentDistributor.DistributionStatus == (int)DistributorStatus.Audited); return(JsonResult <dynamic>(d)); }
public JsonResult Charge(string pluginId, decimal amount) { amount = Math.Round(amount, 2); if (amount <= 0M) { return(base.Json(new { success = false, msg = "请输入正确的金额" })); } Plugin <IPaymentPlugin> plugin = PluginsManagement.GetPlugin <IPaymentPlugin>(pluginId); ChargeDetail model = new ChargeDetail { ChargeAmount = amount, ChargeStatus = ChargeDetailInfo.ChargeDetailStatus.WaitPay, ChargeWay = plugin.PluginInfo.DisplayName, CreateTime = DateTime.Now, MemId = base.CurrentUser.Id }; long num = MemberCapitalApplication.AddChargeApply(model); string cookie = WebHelper.GetCookie("Himall-User_OpenId"); if (!string.IsNullOrWhiteSpace(cookie)) { cookie = SecureHelper.AESDecrypt(cookie, "Mobile"); } else { MemberOpenId id = MemberApplication.GetMemberOpenIdInfoByuserId(base.CurrentUser.Id, MemberOpenIdInfo.AppIdTypeEnum.Payment, ""); if (id != null) { cookie = id.OpenId; } } string str2 = base.Request.Url.Scheme + "://" + base.Request.Url.Authority; string notifyUrl = string.Concat(new object[] { str2, "/m-", base.PlatformType, "/Payment/CapitalChargeNotify/", plugin.PluginInfo.PluginId.Replace(".", "-") }); string returnUrl = string.Concat(new object[] { str2, "/m-", base.PlatformType, "/Capital/Index" }); string str5 = plugin.Biz.GetRequestUrl(returnUrl, notifyUrl, num.ToString(), amount, "会员充值", cookie); return(base.Json(new { href = str5, success = true })); }
public JsonResult GetMemberCapitals(CapitalQuery query) { var result = MemberCapitalApplication.GetCapitals(query); return(Json(result, true)); }
public object PostCharge(PaymentChargeModel para) { para.amount = Math.Round(para.amount, 2); if (para.amount <= 0) { return(Json(ErrorResult <dynamic>("请输入正确的金额"))); } if (string.IsNullOrWhiteSpace(para.openId)) { return(Json(ErrorResult <dynamic>("缺少OpenId"))); } try { //获取支付插件 var mobilePayments = Core.PluginsManagement.GetPlugins <IPaymentPlugin>(true).Where(item => item.Biz.SupportPlatforms.Contains(Core.PlatformType.WeiXinSmallProg)); if (mobilePayments.Any()) { var plugin = mobilePayments.Where(x => x.PluginInfo.PluginId.Contains(para.typeId)).FirstOrDefault(); //添加充值明细 var chargeDetail = new DTO.ChargeDetail(); chargeDetail.ChargeAmount = para.amount; chargeDetail.ChargeStatus = ChargeDetailInfo.ChargeDetailStatus.WaitPay; chargeDetail.ChargeWay = PaymentApplication.GetForeGroundPaymentName(plugin.PluginInfo.Description); chargeDetail.CreateTime = DateTime.Now; chargeDetail.MemId = CurrentUser.Id; var sitesetting = SiteSettingApplication.SiteSettings; if (para.ispresent && sitesetting.IsOpenRechargePresent) { var rule = RechargePresentRuleApplication.GetRules().FirstOrDefault(d => d.ChargeAmount == para.amount); if (rule != null) { chargeDetail.PresentAmount = rule.PresentAmount; } } var id = MemberCapitalApplication.AddChargeApply(chargeDetail); string webRoot = CurrentUrlHelper.CurrentUrlNoPort(); string urlPre = webRoot + "/m-" + Core.PlatformType.Android + "/Payment/"; string notifyPre = urlPre + "CapitalChargeNotify/"; string returnPre = ""; var models = mobilePayments.ToArray().Select(item => { string url = string.Empty; try { url = item.Biz.GetRequestUrl(returnPre, notifyPre + item.PluginInfo.PluginId.Replace(".", "-") + "/", id.ToString(), para.amount, "会员充值", openId: para.openId); } 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 (null == model) { return(Json(ErrorResult <dynamic>("获取支付方式失败,请与管理员联系"))); } return(Json(model)); } else { Core.Log.Error("暂未配置支付方式"); return(Json(ErrorResult <dynamic>("暂未配置支付方式"))); } } catch (Exception ex) { Core.Log.Error("预账户充值报错:", ex); return(Json(ErrorResult <dynamic>("预账户充值报错"))); } }
public ActionResult Center() { var userId = CurrentUser.Id; MemberCenterModel model = new MemberCenterModel(); var statistic = StatisticApplication.GetMemberOrderStatistic(userId, true); var member = _iMemberService.GetMember(userId); model.Member = member; model.AllOrders = statistic.OrderCount; model.WaitingForRecieve = statistic.WaitingForRecieve + OrderApplication.GetWaitConsumptionOrderNumByUserId(UserId); model.WaitingForPay = statistic.WaitingForPay; model.WaitingForDelivery = statistic.WaitingForDelivery; model.WaitingForComments = statistic.WaitingForComments; model.RefundOrders = statistic.RefundCount; model.FavoriteProductCount = FavoriteApplication.GetFavoriteCountByUser(userId); //拼团 model.CanFightGroup = FightGroupApplication.IsOpenMarketService(); model.BulidFightGroupNumber = FightGroupApplication.CountJoiningOrder(userId); model.Capital = MemberCapitalApplication.GetBalanceByUserId(userId); model.CouponsCount = MemberApplication.GetAvailableCouponCount(userId); var integral = MemberIntegralApplication.GetMemberIntegral(userId); model.GradeName = MemberGradeApplication.GetMemberGradeByUserIntegral(integral.HistoryIntegrals).GradeName; model.MemberAvailableIntegrals = MemberIntegralApplication.GetAvailableIntegral(userId); model.CollectionShop = ShopApplication.GetUserConcernShopsCount(userId); model.CanSignIn = _iMemberSignInService.CanSignInByToday(userId); model.SignInIsEnable = _iMemberSignInService.GetConfig().IsEnable; model.userMemberInfo = CurrentUser; model.IsOpenRechargePresent = SiteSettings.IsOpenRechargePresent; model.DistributionOpenMyShopShow = SiteSettings.DistributorRenameOpenMyShop; model.DistributionMyShopShow = SiteSettings.DistributorRenameMyShop; if (PlatformType == PlatformType.WeiXin) { //分销 model.IsShowDistributionOpenMyShop = SiteSettings.DistributionIsEnable; var duser = DistributionApplication.GetDistributor(CurrentUser.Id); if (duser != null && duser.DistributionStatus != (int)DistributorStatus.UnApply) { model.IsShowDistributionOpenMyShop = false; //拒绝的分销员显示“我要开店” if (duser.DistributionStatus == (int)DistributorStatus.Refused || duser.DistributionStatus == (int)DistributorStatus.UnAudit) { model.IsShowDistributionOpenMyShop = true && SiteSettings.DistributionIsEnable; } model.IsShowDistributionMyShop = true && SiteSettings.DistributionIsEnable; if (duser.DistributionStatus == (int)DistributorStatus.NotAvailable || duser.DistributionStatus == (int)DistributorStatus.Refused || duser.DistributionStatus == (int)DistributorStatus.UnAudit) { model.IsShowDistributionMyShop = false; } } } _iMemberService.AddIntegel(member); //给用户加积分//执行登录后初始化相关操作 return(View(model)); }
public object PostApplyWithDraw(MemberCapitalApplyWithDrawModel para) { CheckUserLogin(); if (para == null) { para = new MemberCapitalApplyWithDrawModel(); } var success = MemberApplication.VerificationPayPwd(CurrentUser.Id, para.pwd); var sitesetting = SiteSettingApplication.SiteSettings; if (para.applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode() && !sitesetting.Withdraw_AlipayEnable) { return(Json(ErrorResult <bool>("不支持支付宝提现方式"))); } if (!success) { return(Json(ErrorResult <bool>("支付密码不对,请重新输入"))); } var balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id); if (para.amount > balance) { return(Json(ErrorResult <bool>("提现金额不能超出可用金额!"))); } if (para.amount <= 0) { return(Json(ErrorResult <bool>("提现金额不能小于等于0!"))); } if (string.IsNullOrWhiteSpace(para.openId) && para.applyType == CommonModel.UserWithdrawType.WeiChat.GetHashCode()) { var mo = MemberApplication.GetMemberOpenIdInfoByuserId(CurrentUser.Id, Entities.MemberOpenIdInfo.AppIdTypeEnum.Payment, PLUGIN_OAUTH_WEIXIN); if (mo != null && !string.IsNullOrWhiteSpace(mo.OpenId)) { para.openId = mo.OpenId; } } if (string.IsNullOrWhiteSpace(para.nickname) && para.applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode()) { return(Json(ErrorResult <bool>("数据异常,真实姓名不可为空!"))); } if (!string.IsNullOrWhiteSpace(para.openId) && para.applyType == CommonModel.UserWithdrawType.WeiChat.GetHashCode()) { //para.openid = Core.Helper.SecureHelper.AESDecrypt(para.openid, "Mobile"); if (!string.IsNullOrWhiteSpace(sitesetting.WeixinAppletId) && !string.IsNullOrWhiteSpace(sitesetting.WeixinAppletSecret)) { string token = AccessTokenContainer.TryGetAccessToken(sitesetting.WeixinAppletId, sitesetting.WeixinAppletSecret); var userinfo = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetUserInfo(token, para.openId); if (userinfo != null) { para.nickname = userinfo.nickname; } } } if (string.IsNullOrWhiteSpace(para.openId)) { return(Json(ErrorResult <bool>("数据异常,OpenId或收款账号不可为空!"))); } Mall.Entities.ApplyWithdrawInfo model = new Mall.Entities.ApplyWithdrawInfo() { ApplyAmount = para.amount, ApplyStatus = Mall.Entities.ApplyWithdrawInfo.ApplyWithdrawStatus.WaitConfirm, ApplyTime = DateTime.Now, MemId = CurrentUser.Id, OpenId = para.openId, NickName = para.nickname, ApplyType = (CommonModel.UserWithdrawType)para.applyType }; MemberCapitalApplication.AddWithDrawApply(model); return(Json(true)); }
/// <summary> /// 设置密码 /// </summary> /// <param name="pwd"></param> /// <returns></returns> public object PostSetPayPwd(LoginModPwdModel model) { CheckUserLogin(); MemberCapitalApplication.SetPayPwd(CurrentUser.Id, model.Password); return(SuccessResult("设置成功")); }
public ActionResult Home() { UserCenterHomeModel viewModel = new UserCenterHomeModel(); viewModel.userCenterModel = MemberApplication.GetUserCenterModel(CurrentUser.Id); viewModel.UserName = CurrentUser.Nick == "" ? CurrentUser.UserName : CurrentUser.Nick; viewModel.Logo = CurrentUser.Photo; var items = _iCartService.GetCart(CurrentUser.Id).Items.OrderByDescending(a => a.AddTime).Select(p => p.ProductId).Take(3).ToArray(); viewModel.ShoppingCartItems = ProductManagerApplication.GetProductByIds(items).ToArray(); var UnEvaluatProducts = _iCommentService.GetUnEvaluatProducts(CurrentUser.Id).ToArray(); viewModel.UnEvaluatProductsNum = UnEvaluatProducts.Count(); viewModel.Top3UnEvaluatProducts = UnEvaluatProducts.Take(3).ToArray(); viewModel.Top3RecommendProducts = _iProductService.GetPlatHotSaleProductByNearShop(8, CurrentUser.Id).ToArray(); viewModel.BrowsingProducts = BrowseHistrory.GetBrowsingProducts(4, CurrentUser == null ? 0 : CurrentUser.Id); var messagePlugins = PluginsManagement.GetPlugins <IMessagePlugin>(); var data = messagePlugins.Select(item => new PluginsInfo { ShortName = item.Biz.ShortName, PluginId = item.PluginInfo.PluginId, Enable = item.PluginInfo.Enable, IsSettingsValid = item.Biz.IsSettingsValid, IsBind = !string.IsNullOrEmpty(_iMessageService.GetDestination(CurrentUser.Id, item.PluginInfo.PluginId, Entities.MemberContactInfo.UserTypes.General)) }); viewModel.BindContactInfo = data; var statistic = StatisticApplication.GetMemberOrderStatistic(CurrentUser.Id); viewModel.OrderCount = statistic.OrderCount; viewModel.OrderWaitReceiving = statistic.WaitingForRecieve; viewModel.OrderWaitPay = statistic.WaitingForPay; viewModel.OrderEvaluationStatus = statistic.WaitingForComments; viewModel.Balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id); //TODO:[YZG]增加账户安全等级 MemberAccountSafety memberAccountSafety = new MemberAccountSafety { AccountSafetyLevel = 1 }; if (CurrentUser.PayPwd != null) { memberAccountSafety.PayPassword = true; memberAccountSafety.AccountSafetyLevel += 1; } var ImessageService = _iMessageService; foreach (var messagePlugin in data) { if (messagePlugin.PluginId.IndexOf("SMS") > 0) { if (messagePlugin.IsBind) { memberAccountSafety.BindPhone = true; memberAccountSafety.AccountSafetyLevel += 1; } } else { if (messagePlugin.IsBind) { memberAccountSafety.BindEmail = true; memberAccountSafety.AccountSafetyLevel += 1; } } } viewModel.memberAccountSafety = memberAccountSafety; ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; return(View(viewModel)); }
/// <summary> /// 预账户充值接口 /// </summary> /// <param name="pluginId">支付插件Id</param> /// <param name="amount">充值金额</param> /// <returns></returns> public object Charge(PaymentChargeModel para) { para.amount = Math.Round(para.amount, 2); if (para.amount <= 0) { return(ErrorResult("请输入正确的金额")); } try { //获取支付插件 var mobilePayments = Core.PluginsManagement.GetPlugins <IPaymentPlugin>(true).OrderByDescending(d => d.PluginInfo.PluginId).Where(item => item.Biz.SupportPlatforms.Contains(Core.PlatformType.Android)); var plugin = mobilePayments.Where(x => x.PluginInfo.PluginId.Contains(para.typeid)).FirstOrDefault(); //添加充值明细 var chargeDetail = new DTO.ChargeDetail(); chargeDetail.ChargeAmount = para.amount; chargeDetail.ChargeStatus = ChargeDetailInfo.ChargeDetailStatus.WaitPay; //chargeDetail.ChargeWay = plugin.PluginInfo.DisplayName; chargeDetail.ChargeWay = PaymentApplication.GetForeGroundPaymentName(plugin.PluginInfo.Description); chargeDetail.CreateTime = DateTime.Now; chargeDetail.MemId = CurrentUser.Id; var sitesetting = SiteSettingApplication.SiteSettings; if (para.ispresent && sitesetting.IsOpenRechargePresent) { var rule = RechargePresentRuleApplication.GetRules().FirstOrDefault(d => d.ChargeAmount == para.amount); if (rule != null) { chargeDetail.PresentAmount = rule.PresentAmount; } } var id = MemberCapitalApplication.AddChargeApply(chargeDetail); string webRoot = CurrentUrlHelper.CurrentUrlNoPort(); string urlPre = webRoot + "/m-" + Core.PlatformType.Android + "/Payment/"; string notifyPre = urlPre + "CapitalChargeNotify/"; string returnPre = webRoot + "/m-" + Core.PlatformType.Android; var model = mobilePayments.ToArray().Select(item => { string url = string.Empty; try { url = item.Biz.GetRequestUrl(returnPre, notifyPre + item.PluginInfo.PluginId.Replace(".", "-") + "/", id.ToString(), para.amount, "会员充值"); } catch (Exception ex) { Core.Log.Error("获取支付方式错误:", ex); } return(new { id = item.PluginInfo.PluginId, //name = item.PluginInfo.DisplayName, name = PaymentApplication.GetForeGroundPaymentName(item.PluginInfo.DisplayName), logo = item.Biz.Logo, url = url }); }); model = model.Where(item => !string.IsNullOrWhiteSpace(item.url) && item.id.Contains(para.typeid)).OrderByDescending(d => d.id); dynamic result = SuccessResult(); result.data = model; return(result); } catch (Exception ex) { Core.Log.Error("预账户充值报错:", ex); return(ErrorResult("预账户充值报错")); } }
public JsonResult ApplyWithDrawSubmit(string openid, string nickname, decimal amount, string pwd, int applyType = 1) { var success = MemberApplication.VerificationPayPwd(CurrentUser.Id, pwd); if (!success) { throw new HimallException("支付密码不对,请重新输入!"); } if (applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode() && !SiteSettings.Withdraw_AlipayEnable) { throw new HimallException("不支持支付宝提现方式!"); } var balance = MemberCapitalApplication.GetBalanceByUserId(UserId); if (amount > balance) { throw new HimallException("提现金额不能超出可用金额!"); } if (amount <= 0) { throw new HimallException("提现金额不能小于等于0!"); } if (string.IsNullOrWhiteSpace(openid) && applyType == CommonModel.UserWithdrawType.WeiChat.GetHashCode()) { openid = Core.Helper.WebHelper.GetCookie(CookieKeysCollection.HIMALL_USER_OpenID); } if (string.IsNullOrWhiteSpace(nickname) && applyType == CommonModel.UserWithdrawType.ALiPay.GetHashCode()) { throw new HimallException("数据异常,真实姓名不可为空!"); } if (!string.IsNullOrWhiteSpace(openid) && applyType == CommonModel.UserWithdrawType.WeiChat.GetHashCode()) { openid = Core.Helper.SecureHelper.AESDecrypt(openid, "Mobile"); 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, openid); if (userinfo != null) { nickname = userinfo.nickname; } } } if (string.IsNullOrWhiteSpace(openid)) { throw new HimallException("数据异常,OpenId或收款账号不可为空!"); } 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 })); }