public void ProcessRequest(HttpContext context) { string orderId = context.Request["order_id"]; if (string.IsNullOrEmpty(orderId)) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; apiResp.msg = "order_id 为必填项,请检查"; bllPay.ContextResponse(context, apiResp); return; } OrderPay orderInfo = bllOrder.GetOrderPay(orderId); if (orderInfo == null) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; apiResp.msg = "订单号不存在"; bllPay.ContextResponse(context, apiResp); return; } if (orderInfo.UserId != CurrentUserInfo.UserID) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound; apiResp.msg = "订单号无效"; bllPay.ContextResponse(context, apiResp); return; } if (orderInfo.Status == 1) { apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsRepeat; apiResp.msg = "订单已经支付,不需重复支付"; bllPay.ContextResponse(context, apiResp); return; } RequestWeiXin weixin = new RequestWeiXin(); weixin.notifyUrl = "http://" + context.Request.Url.Host + "/WxPayNotify/NotifyWeixinPay.aspx";//支付通知地址 PayConfig payConfig = bllPay.GetPayConfig(); weixin.appId = payConfig.WXAppId; weixin.mch_Id = payConfig.WXMCH_ID; weixin.key = payConfig.WXPartnerKey; weixin.openId = CurrentUserInfo.WXOpenId; weixin.ip = context.Request.UserHostAddress; string payReqStr = bllPay.GetBrandWcPayRequest(orderInfo.OrderId, orderInfo.Total_Fee, weixin.appId, weixin.mch_Id, weixin.key, weixin.openId, weixin.ip, weixin.notifyUrl, weixin.body, "APP"); BllPay.WXPayReq payReqModel = ZentCloud.Common.JSONHelper.JsonToModel <BllPay.WXPayReq>(payReqStr); if (!string.IsNullOrEmpty(payReqModel.paySign)) { bllPay.ContextResponse(context, new { status = true, pay_req = payReqModel }); } apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail; apiResp.msg = "出错"; bllPay.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { string orderId = context.Request["order_id"]; if (string.IsNullOrEmpty(orderId)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "order_id必传"; bll.ContextResponse(context, apiResp); return; } OrderPay orderPay = bllOrder.GetOrderPay(orderId); PayConfig payConfig = bllPay.GetPayConfig(); if (payConfig == null || string.IsNullOrEmpty(payConfig.WXAppId) || string.IsNullOrEmpty(payConfig.WXMCH_ID) || string.IsNullOrEmpty(payConfig.WXPartnerKey)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "该商户微信支付还没有配置"; bll.ContextResponse(context, apiResp); return; } string appId = payConfig.WXAppId; //微信AppId string mchId = payConfig.WXMCH_ID; //商户号 string key = payConfig.WXPartnerKey; //api密钥 string openId = CurrentUserInfo.WXOpenId; //openid string ip = context.Request.UserHostAddress; //ip string notifyUrl = string.Format("http://{0}/WxPayNotify/SmsRechargeNotify.aspx", context.Request.Url.Authority); //支付充值通知地址 string body = ""; //订单内容 string payReqStr = bllPay.GetBrandWcPayRequest(orderPay.OrderId, orderPay.Total_Fee, appId, mchId, key, openId, ip, notifyUrl, body); BllPay.WXPayReq payReqModel = ZentCloud.Common.JSONHelper.JsonToModel <BllPay.WXPayReq>(payReqStr); if (string.IsNullOrEmpty(payReqModel.paySign)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "构造支付信息失败"; bll.ContextResponse(context, apiResp); return; } apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.result = new { pay_req = payReqModel }; bll.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { BLLJIMP.Model.API.User.PayUpgrade payUpgrade = bll.ConvertRequestToModel <BLLJIMP.Model.API.User.PayUpgrade>(new BLLJIMP.Model.API.User.PayUpgrade()); payUpgrade.level = CurrentUserInfo.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; } if (string.IsNullOrWhiteSpace(CurrentUserInfo.WXOpenId)) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "请先绑定微信"; bll.ContextResponse(context, apiResp); return; } PayConfig payConfig = bllPay.GetPayConfig(); if (payConfig == null || string.IsNullOrEmpty(payConfig.WXAppId) || string.IsNullOrEmpty(payConfig.WXMCH_ID) || string.IsNullOrEmpty(payConfig.WXPartnerKey)) { 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 = CurrentUserInfo.UserID; orderPay.Ex1 = JsonConvert.SerializeObject(payUpgrade); if (!bll.Add(orderPay)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "生成支付订单失败"; bll.ContextResponse(context, apiResp); return; } string appId = payConfig.WXAppId; //微信AppId string mchId = payConfig.WXMCH_ID; //商户号 string key = payConfig.WXPartnerKey; //api密钥 string openId = CurrentUserInfo.WXOpenId; //openid string ip = context.Request.UserHostAddress; //ip string notifyUrl = string.Format("http://{0}/WxPayNotify/PayUpgradeNotify.aspx", context.Request.Url.Authority); //支付升级通知地址 string body = ""; //订单内容 string payReqStr = bllPay.GetBrandWcPayRequest(orderPay.OrderId, orderPay.Total_Fee, appId, mchId, key, openId, ip, notifyUrl, body); BllPay.WXPayReq payReqModel = ZentCloud.Common.JSONHelper.JsonToModel <BllPay.WXPayReq>(payReqStr); if (string.IsNullOrEmpty(payReqModel.paySign)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "构造支付信息失败"; bll.ContextResponse(context, apiResp); return; } apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.result = new { pay_req = payReqModel }; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { 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; if (string.IsNullOrWhiteSpace(CurrentUserInfo.WXOpenId)) { apiResp.code = (int)APIErrCode.IsNotFound; apiResp.msg = "请先绑定微信"; bll.ContextResponse(context, apiResp); return; } PayConfig payConfig = bllPay.GetPayConfig(); if (payConfig == null || string.IsNullOrEmpty(payConfig.WXAppId) || string.IsNullOrEmpty(payConfig.WXMCH_ID) || string.IsNullOrEmpty(payConfig.WXPartnerKey)) { 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 = CurrentUserInfo.UserID; if (!bll.Add(orderPay)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "生成支付订单失败"; bll.ContextResponse(context, apiResp); return; } string appId = payConfig.WXAppId; //微信AppId string mchId = payConfig.WXMCH_ID; //商户号 string key = payConfig.WXPartnerKey; //api密钥 string openId = CurrentUserInfo.WXOpenId; //openid string ip = context.Request.UserHostAddress; //ip string notifyUrl = string.Format("http://{0}/WxPayNotify/PayRechargeNotify.aspx", context.Request.Url.Authority); //支付充值通知地址 string body = ""; //订单内容 string payReqStr = bllPay.GetBrandWcPayRequest(orderPay.OrderId, orderPay.Total_Fee, appId, mchId, key, openId, ip, notifyUrl, body); BllPay.WXPayReq payReqModel = ZentCloud.Common.JSONHelper.JsonToModel <BllPay.WXPayReq>(payReqStr); if (string.IsNullOrEmpty(payReqModel.paySign)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "构造支付信息失败"; bll.ContextResponse(context, apiResp); return; } apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.result = new { pay_req = payReqModel }; bllUser.ContextResponse(context, apiResp); }
public void ProcessRequest(HttpContext context) { BLLJIMP.Model.API.User.PayRegisterUser requestUser = bll.ConvertRequestToModel <BLLJIMP.Model.API.User.PayRegisterUser>(new BLLJIMP.Model.API.User.PayRegisterUser()); string websiteOwner = bll.WebsiteOwner; if (context.Session["currWXOpenId"] == null) { 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; } string currWXOpenId = context.Session["currWXOpenId"].ToString(); if (string.IsNullOrWhiteSpace(requestUser.level.ToString())) { 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 = 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 >= 10) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "该手机已注册会员"; bll.ContextResponse(context, apiResp); return; } if (oldUserInfo != null && oldUserInfo.MemberLevel > requestUser.level) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "该会员有更高级别"; bll.ContextResponse(context, apiResp); return; } PayConfig payConfig = bllPay.GetPayConfig(); if (payConfig == null || string.IsNullOrEmpty(payConfig.WXAppId) || string.IsNullOrEmpty(payConfig.WXMCH_ID) || string.IsNullOrEmpty(payConfig.WXPartnerKey)) { 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; if (!bll.Add(orderPay)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "生成支付订单失败"; bll.ContextResponse(context, apiResp); return; } string appId = payConfig.WXAppId; //微信AppId string mchId = payConfig.WXMCH_ID; //商户号 string key = payConfig.WXPartnerKey; //api密钥 string openId = currWXOpenId; //openid string notifyUrl = string.Format("http://{0}/WxPayNotify/PayRegisterNotify.aspx", context.Request.Url.Authority); //支付注册通知地址 string body = ""; //订单内容 string payReqStr = bllPay.GetBrandWcPayRequest(orderPay.OrderId, orderPay.Total_Fee, appId, mchId, key, openId, requestUser.regIP, notifyUrl, body); BllPay.WXPayReq payReqModel = ZentCloud.Common.JSONHelper.JsonToModel <BllPay.WXPayReq>(payReqStr); if (string.IsNullOrEmpty(payReqModel.paySign)) { apiResp.code = (int)APIErrCode.OperateFail; apiResp.msg = "构造支付信息失败"; bll.ContextResponse(context, apiResp); return; } apiResp.code = (int)APIErrCode.IsSuccess; apiResp.status = true; apiResp.result = new { pay_req = payReqModel }; bllUser.ContextResponse(context, apiResp); }