protected void Page_Load(object sender, EventArgs e) { string orderId = this.Request["OrderId"]; OrderPay orderPay = bllOrder.GetOrderPay(orderId); if (orderPay != null && orderPay.Status == 0) { PayConfig payConfig = bllPay.GetPayConfig(); PayString = bllPay.GetBrandWcPayRequest(orderId, orderPay.Total_Fee, payConfig.WXAppId, payConfig.WXMCH_ID, payConfig.WXPartnerKey, bllOrder.GetCurrentUserInfo().WXOpenId, this.Request.UserHostAddress, string.Format("http://{0}/Admin/DoPay/DoPayWxNotify.aspx", this.Request.Url.Host), "易劳积分充值" + orderPay.Total_Fee + "元"); } }
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); }
/// <summary> /// 微信支付 /// </summary> /// <param name="context"></param> /// <returns></returns> private string BrandWcPayRequest(HttpContext context) { if (!bllPay.IsWeiXinBrowser) { resp.errcode = 1; resp.errmsg = "请在微信中打开"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } string orderId = context.Request["order_id"]; decimal totalAmount = 0; //订单金额 string appId = ""; //微信AppId string mchId = ""; //商户号 string key = ""; //api密钥 string openId = ""; //openid string ip = ""; //ip string notifyUrl = baseUrl + "/WxPayNotify/NotifyV2.aspx"; //支付通知地址 string body = ""; //订单内容 if (string.IsNullOrEmpty(orderId)) { resp.errcode = 1; resp.errmsg = "order_id 必传"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } var orderInfo = bllMall.GetOrderInfo(orderId); if (orderInfo != null) { totalAmount = orderInfo.TotalAmount; //if (orderInfo.OrderUserID != CurrentUserInfo.UserID) //{ // resp.errcode = 1; // resp.errmsg = "订单号无效"; // return ZentCloud.Common.JSONHelper.ObjectToJson(resp); //} if (orderInfo.PaymentStatus == 1) { resp.errcode = 1; resp.errmsg = "该订单已经支付,不需重复支付"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } //更改支付方式 bllMall.Update(orderInfo, " PaymentType=2 ", string.Format(" (OrderID = '{0}' Or ParentOrderId='{0}') ", orderInfo.OrderID)); //resp.errcode = 1; //resp.errmsg = "订单号不存在"; //return ZentCloud.Common.JSONHelper.ObjectToJson(resp); } else { #region 众筹 var orderInfoCrowd = bllMall.Get <CrowdFundRecord>(string.Format(" RecordID={0}", orderId)); if (orderInfoCrowd == null) { resp.errcode = 1; resp.errmsg = "订单号不存在"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (orderInfoCrowd.UserID != currentUserInfo.UserID) { resp.errcode = 1; resp.errmsg = "订单号无效"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (orderInfoCrowd.Status == 1) { resp.errcode = 1; resp.errmsg = "订单已经支付,不需重复支付"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } totalAmount = orderInfoCrowd.Amount; notifyUrl = baseUrl + "/WxPayNotify/NotifyCrowdFundV2.aspx"; #endregion } PayConfig payConfig = bllPay.GetPayConfig(); if (payConfig == null) { resp.errcode = 1; resp.errmsg = "该商户微信支付还没有配置"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if ((string.IsNullOrEmpty(payConfig.WXAppId)) || (string.IsNullOrEmpty(payConfig.WXMCH_ID)) || (string.IsNullOrEmpty(payConfig.WXPartnerKey))) { resp.errcode = 1; resp.errmsg = "该商户微信支付还没有配置"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } appId = payConfig.WXAppId; mchId = payConfig.WXMCH_ID; key = payConfig.WXPartnerKey; openId = currentUserInfo.WXOpenId; ip = context.Request.UserHostAddress; string payReqStr = bllPay.GetBrandWcPayRequest(orderId, totalAmount, appId, mchId, key, openId, ip, notifyUrl, body); WXPayReq payReqModel = ZentCloud.Common.JSONHelper.JsonToModel <WXPayReq>(payReqStr); if (!string.IsNullOrEmpty(payReqModel.paySign)) { return(ZentCloud.Common.JSONHelper.ObjectToJson(new { errcode = 0, pay_req = payReqModel })); } resp.errcode = 1; resp.errmsg = "获取配置失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); }
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); }