예제 #1
0
        public void BuildOrder(HttpContext context, int payType, UserInfo user)
        {
            decimal amount = Convert.ToDecimal(context.Request["amount"]);

            if (amount <= 0)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "金额必须大于0";
                bll.ContextResponse(context, apiResp);
                return;
            }
            string    websiteOwner = bll.WebsiteOwner;
            PayConfig payConfig    = bllPay.GetPayConfig();

            if (payType == 1 && !bllPay.IsAliPay(payConfig))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "该商户支付宝支付还没有配置";
                bll.ContextResponse(context, apiResp);
                return;
            }
            else if (payType == 2 && !bllPay.IsJDPay(payConfig))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "该商户京东支付还没有配置";
                bll.ContextResponse(context, apiResp);
                return;
            }
            OrderPay orderPay = new OrderPay();

            orderPay.OrderId      = bll.GetGUID(TransacType.PayRegisterOrder);
            orderPay.InsertDate   = DateTime.Now;
            orderPay.Subject      = "支付充值";
            orderPay.Total_Fee    = amount;
            orderPay.Type         = "4";
            orderPay.WebsiteOwner = websiteOwner;
            orderPay.UserId       = user.UserID;
            orderPay.PayType      = payType;
            if (!bll.Add(orderPay))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "生成支付订单失败";
                bll.ContextResponse(context, apiResp);
                return;
            }

            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.status = true;
            apiResp.result = new
            {
                pay_order_id = orderPay.OrderId
            };
            bllUser.ContextResponse(context, apiResp);
        }
예제 #2
0
파일: PayMethod.ashx.cs 프로젝트: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            PayConfig payConfig = bllPay.GetPayConfig();

            apiResp.result = new
            {
                is_wx_pay  = bllPay.IsWeixinPay(payConfig),
                is_ali_pay = bllPay.IsAliPay(payConfig),
                is_jd_pay  = bllPay.IsJDPay(payConfig)
            };
            apiResp.status = true;
            bllPay.ContextResponse(context, apiResp);
        }
예제 #3
0
        public void BuildOrder(HttpContext context, int payType, UserInfo user)
        {
            BLLJIMP.Model.API.User.PayUpgrade payUpgrade = bll.ConvertRequestToModel <BLLJIMP.Model.API.User.PayUpgrade>(new BLLJIMP.Model.API.User.PayUpgrade());
            payUpgrade.level = user.MemberLevel;
            string websiteOwner = bll.WebsiteOwner;

            UserLevelConfig levelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", payUpgrade.level.ToString());

            if (levelConfig == null)
            {
                payUpgrade.userTotalAmount = 0;
            }
            else
            {
                payUpgrade.userTotalAmount = Convert.ToDecimal(levelConfig.FromHistoryScore);
            }
            UserLevelConfig toLevelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", payUpgrade.toLevel.ToString());

            if (toLevelConfig == null)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = "会员等级未找到";
                bll.ContextResponse(context, apiResp);
                return;
            }
            if (toLevelConfig.IsDisable == 1)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = "会员级别禁止升级";
                bll.ContextResponse(context, apiResp);
                return;
            }
            payUpgrade.needAmount = Convert.ToDecimal(toLevelConfig.FromHistoryScore);
            payUpgrade.amount     = payUpgrade.needAmount - payUpgrade.userTotalAmount;
            if (payUpgrade.amount < 0)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "暂时不支持降级";
                bll.ContextResponse(context, apiResp);
                return;
            }
            PayConfig payConfig = bllPay.GetPayConfig();

            if (payType == 1 && !bllPay.IsAliPay(payConfig))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "该商户支付宝支付还没有配置";
                bll.ContextResponse(context, apiResp);
                return;
            }
            else if (payType == 2 && !bllPay.IsJDPay(payConfig))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "该商户京东支付还没有配置";
                bll.ContextResponse(context, apiResp);
                return;
            }
            OrderPay orderPay = new OrderPay();

            orderPay.OrderId      = bll.GetGUID(TransacType.PayRegisterOrder);
            orderPay.InsertDate   = DateTime.Now;
            orderPay.Subject      = "支付升级";
            orderPay.Total_Fee    = payUpgrade.amount;
            orderPay.Type         = "6";
            orderPay.WebsiteOwner = websiteOwner;
            orderPay.UserId       = user.UserID;
            orderPay.Ex1          = JsonConvert.SerializeObject(payUpgrade);
            orderPay.PayType      = payType;
            if (!bll.Add(orderPay))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "生成支付订单失败";
                bll.ContextResponse(context, apiResp);
                return;
            }
            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.status = true;
            apiResp.result = new
            {
                user_id      = user.AutoID,
                pay_order_id = orderPay.OrderId
            };
            bllUser.ContextResponse(context, apiResp);
        }
예제 #4
0
        public void BuildOrder(HttpContext context, int payType)
        {
            BLLJIMP.Model.API.User.PayRegisterUser requestUser = bll.ConvertRequestToModel <BLLJIMP.Model.API.User.PayRegisterUser>(new BLLJIMP.Model.API.User.PayRegisterUser());
            string websiteOwner = bll.WebsiteOwner;

            if (string.IsNullOrWhiteSpace(requestUser.level.ToString()))
            {
                apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "请选择会员级别";
                bll.ContextResponse(context, apiResp);
                return;
            }
            if (string.IsNullOrWhiteSpace(requestUser.spreadid))
            {
                apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "请输入推荐人编号";
                bll.ContextResponse(context, apiResp);
                return;
            }
            if (string.IsNullOrWhiteSpace(requestUser.phone))
            {
                apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "请输入手机号码";
                bll.ContextResponse(context, apiResp);
                return;
            }
            if (!ZentCloud.Common.MyRegex.PhoneNumLogicJudge(requestUser.phone))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "手机号码格式不正确";
                bll.ContextResponse(context, apiResp);
                return;
            }

            if (!ZentCloud.Common.MyRegex.IsIDCard(requestUser.idcard))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "身份证号码必须如实填写";
                bll.ContextResponse(context, apiResp);
                return;
            }
            UserLevelConfig levelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", requestUser.level.ToString());

            if (levelConfig == null)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = "会员级别未找到";
                bll.ContextResponse(context, apiResp);
                return;
            }
            if (levelConfig.IsDisable == 1)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = "会员级别禁止注册";
                bll.ContextResponse(context, apiResp);
                return;
            }
            requestUser.levelname = levelConfig.LevelString;
            UserInfo spreadUser = bllUser.GetSpreadUser(requestUser.spreadid, websiteOwner);

            if (spreadUser == null)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = "推荐人未找到";
                bll.ContextResponse(context, apiResp);
                return;
            }
            requestUser.spreadid = spreadUser.UserID; //推荐人
            UserInfo oldUserInfo = bllUser.GetUserInfoByPhone(requestUser.phone, websiteOwner);

            if (oldUserInfo != null && oldUserInfo.MemberLevel > 0)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "该手机已注册会员";
                bll.ContextResponse(context, apiResp);
                return;
            }

            PayConfig payConfig = bllPay.GetPayConfig();

            if (payType == 1 && !bllPay.IsAliPay(payConfig))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "该商户支付宝支付还没有配置";
                bll.ContextResponse(context, apiResp);
                return;
            }
            else if (payType == 2 && !bllPay.IsJDPay(payConfig))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "该商户京东支付还没有配置";
                bll.ContextResponse(context, apiResp);
                return;
            }
            if (oldUserInfo != null)
            {
                requestUser.userid = oldUserInfo.UserID;
            }
            else
            {
                requestUser.userid = string.Format("ZYUser{0}{1}", DateTime.Now.ToString("yyyyMMdd"), Guid.NewGuid().ToString("N").ToUpper());
            }
            requestUser.regIP    = context.Request.UserHostAddress;//ip
            requestUser.password = ZentCloud.Common.Rand.Number(6);

            OrderPay orderPay = new OrderPay();

            orderPay.OrderId      = bll.GetGUID(TransacType.PayRegisterOrder);
            orderPay.InsertDate   = DateTime.Now;
            orderPay.Subject      = "支付注册会员";
            orderPay.Total_Fee    = Convert.ToDecimal(levelConfig.FromHistoryScore);
            orderPay.Type         = "5";
            orderPay.WebsiteOwner = websiteOwner;
            orderPay.UserId       = requestUser.userid;
            orderPay.Ex1          = JsonConvert.SerializeObject(requestUser);
            orderPay.Ex2          = requestUser.phone;
            orderPay.PayType      = payType;
            if (!bll.Add(orderPay))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "生成支付订单失败";
                bll.ContextResponse(context, apiResp);
                return;
            }

            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.status = true;
            apiResp.result = new
            {
                pay_order_id = orderPay.OrderId
            };
            bllUser.ContextResponse(context, apiResp);
        }