/// <summary>
        /// 申请提现
        /// </summary>
        /// <param name="post"></param>
        /// <returns></returns>
        public JsonResult <Result <bool> > PostWithdraw(DistributionApplyWithdraw post)
        {
            CheckUserLogin();
            var sitesettings = SiteSettingApplication.SiteSettings;

            post.MemberId = CurrentUser.Id;
            if (post.Type == DistributionWithdrawType.WeChat) //获取用户微信账户
            {
                var mo = MemberApplication.GetMemberOpenIdInfoByuserId(CurrentUser.Id, Entities.MemberOpenIdInfo.AppIdTypeEnum.Payment, "Himall.Plugin.OAuth.WeiXin");
                if (mo == null)
                {
                    return(Json(ErrorResult <bool>("无法获取微信账号,请先在微信端绑定账号!")));
                }
                var openid = mo.OpenId;
                post.WithdrawAccount = openid;
                if (!(string.IsNullOrWhiteSpace(sitesettings.WeixinAppId) || string.IsNullOrWhiteSpace(sitesettings.WeixinAppSecret)))
                {
                    string token = AccessTokenContainer.TryGetToken(sitesettings.WeixinAppId, sitesettings.WeixinAppSecret);
                    var    user  = CommonApi.GetUserInfo(token, openid);
                    post.WithdrawName = user?.nickname ?? string.Empty;
                }
            }
            DistributionApplication.ApplyWithdraw(post);
            return(JsonResult(true));
        }
Esempio n. 2
0
        /// <summary>
        /// 是否可以提现
        /// </summary>
        /// <returns></returns>
        public object GetCanWithDraw()
        {
            CheckUserLogin();
            bool canWeiXin   = false;
            bool canAlipay   = false;
            var  sitesetting = SiteSettingApplication.SiteSettings;
            //判断是否有微信openid
            var mo = MemberApplication.GetMemberOpenIdInfoByuserId(CurrentUser.Id, Entities.MemberOpenIdInfo.AppIdTypeEnum.Payment, PLUGIN_OAUTH_WEIXIN);

            if (mo != null && !string.IsNullOrWhiteSpace(mo.OpenId))
            {
                canWeiXin = true;
            }
            //判断是否开启支付宝
            if (sitesetting.Withdraw_AlipayEnable)
            {
                canAlipay = true;
            }
            bool    canWithDraw = MemberApplication.CanWithdraw(CurrentUser.Id);
            dynamic result      = new Result();

            result.success   = canWithDraw && (canWeiXin || canAlipay);
            result.canWeiXin = canWeiXin;
            result.canAlipay = canAlipay;
            return(result);
        }
        /// <summary>
        /// 是否可以提现
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetCanWithDraw()
        {
            CheckUserLogin();
            bool canWeiXin   = false;
            bool canAlipay   = false;
            var  sitesetting = SiteSettingApplication.SiteSettings;
            //判断是否有微信openid
            var mo = MemberApplication.GetMemberOpenIdInfoByuserId(CurrentUser.Id, Entities.MemberOpenIdInfo.AppIdTypeEnum.Payment, PLUGIN_OAUTH_WEIXIN);

            if (mo != null && !string.IsNullOrWhiteSpace(mo.OpenId))
            {
                canWeiXin = true;
            }
            //判断是否开启支付宝
            if (sitesetting.Withdraw_AlipayEnable)
            {
                canAlipay = true;
            }
            bool canWithDraw = MemberApplication.CanWithdraw(CurrentUser.Id);

            return(Json(ApiResult <dynamic>(canWithDraw && (canWeiXin || canAlipay), data: new { canWeiXin = canWeiXin, canAlipay = canAlipay })));
        }
Esempio n. 4
0
        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 }));
        }
Esempio n. 5
0
        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));
        }