Ejemplo n.º 1
0
        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()
            }));
        }
Ejemplo n.º 2
0
        public ActionResult RechargePresentRule()
        {
            RechargePresentRuleModel model = new RechargePresentRuleModel();

            model.IsEnable  = SiteSettings.IsOpenRechargePresent;
            model.Rules     = RechargePresentRuleApplication.GetRules();
            model.RulesJson = JsonConvert.SerializeObject(model.Rules);
            return(View(model));
        }
Ejemplo n.º 3
0
        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
            }));
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        // 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));
        }
Ejemplo n.º 6
0
        public JsonResult ChargeSubmit(decimal amount, bool ispresent = false)
        {
            //var ids = _iMemberCapitalService.CreateCode(CapitalDetailInfo.CapitalDetailType.ChargeAmount);
            Mall.Entities.ChargeDetailInfo detail = new Mall.Entities.ChargeDetailInfo()
            {
                ChargeAmount = amount,
                ChargeStatus = Mall.Entities.ChargeDetailInfo.ChargeDetailStatus.WaitPay,
                CreateTime   = DateTime.Now,
                MemId        = CurrentUser.Id
            };
            if (ispresent && SiteSettings.IsOpenRechargePresent)
            {
                var rule = RechargePresentRuleApplication.GetRules().FirstOrDefault(d => d.ChargeAmount == amount);
                if (rule != null)
                {
                    detail.PresentAmount = rule.PresentAmount;
                }
            }
            long id = _iMemberCapitalService.AddChargeApply(detail);

            return(Json(new { success = true, msg = id.ToString() }));
        }
Ejemplo n.º 7
0
        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>("预账户充值报错")));
            }
        }
Ejemplo n.º 8
0
        /// <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("预账户充值报错"));
            }
        }