/// <summary> /// 修改时时订单表数据 /// </summary> /// <param name="morder">根据订单查询后的mode实体类型</param> /// <param name="trade_no">第三方流水号</param> /// <param name="gmt_payment">支付时间</param> /// <param name="price">支付金额</param> /// <param name="payuser">付款账号</param> /// <param name="noticestr">传入的字符串</param> /// <param name="channelId">支付通道id</param> /// <returns></returns> private bool UpdateOrder(JMP.MDL.jmp_order morder, string trade_no, DateTime gmt_payment, decimal price, string payuser, string noticestr, int channelId) { try { JMP.BLL.jmp_order order = new JMP.BLL.jmp_order(); string TableName = "jmp_order"; morder.o_tradeno = trade_no; morder.o_ptime = gmt_payment; morder.o_payuser = payuser; morder.o_state = 1; morder.o_noticestate = 0; morder.o_price = price; if (morder.o_interface_id != channelId) { morder.o_interface_id = channelId; } if (order.Update(morder, TableName)) { return(true); } else { //AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, "通知接口错误", "修改订单失败!订单号:" + morder.o_code + ",传入参数:" + noticestr);//写入报错日志 PayNotifyGlobalErrorLogger.Log("修改订单失败!订单号:" + morder.o_code + ",传入参数:" + noticestr, summary: "通知接口错误"); return(false); } } catch (Exception ex) { // AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, "通知接口错误", "修改订单失败!订单号:" + morder.o_code + ",错误信息:" + ex.ToString() + ",传入参数:" + noticestr);//写入报错日志 PayNotifyGlobalErrorLogger.Log("修改订单失败!订单号:" + morder.o_code + ",错误信息:" + ex.ToString() + ",传入参数:" + noticestr, summary: "通知接口错误"); return(false); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Params["oid"] != null) { try { int oid = int.Parse(Request.QueryString["oid"].ToString()); JMP.BLL.jmp_order order = new JMP.BLL.jmp_order(); JMP.MDL.jmp_order morder = new JMP.MDL.jmp_order(); string TableName = "jmp_order"; morder = order.GetModelbyid(oid, TableName); if (morder != null) { if (string.IsNullOrEmpty(morder.o_showaddress)) { morder.o_showaddress = ConfigurationManager.AppSettings["succeed"].ToString(); } string url = morder.o_showaddress.Contains("?") ? morder.o_showaddress + "&trade_no=" + morder.o_bizcode + "&trade_status=TRADE_SUCCESS" : morder.o_showaddress + "?trade_no=" + morder.o_bizcode + "&trade_status=TRADE_SUCCESS"; Response.Redirect(url); } else { Response.Write("非法访问"); } } catch { Response.Write("非法访问"); } } else { Response.Write("非法访问"); } }
/// <summary> /// 根据商户订单号和appid查询订单信息 /// </summary> /// <param name="mod">参数实体</param> /// <param name="json">参数json字符串</param> /// <returns></returns> private jmp_order SelectOrder(QueryModels mod, string json) { JMP.MDL.jmp_order mode = new JMP.MDL.jmp_order(); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); try { mode = bll.SelectOrderbizcode(mod.appid, mod.code, mod.bizcode, "jmp_order"); if (mode == null) { string orderTableName = JMP.TOOL.WeekDateTime.GetOrderTableName(DateTime.Now.ToString("yyyy-MM-dd")); //获取订单表名 mode = bll.SelectOrderbizcode(mod.appid, mod.code, mod.bizcode, orderTableName); //查询本周归档表 string weekstr = DateTime.Now.DayOfWeek.ToString(); if (mode == null && weekstr == "Monday" && Int32.Parse(DateTime.Now.ToString("HH")) <= 2) { string TableName = JMP.TOOL.WeekDateTime.GetOrderTableName(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")); //获取订单表名 mode = bll.SelectOrderbizcode(mod.appid, mod.code, mod.bizcode, orderTableName); //查询上周归档表 } } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace.ToString();//报错信息 PayApiGlobalErrorLogger.Log("报错信息:查询接口查询订单报错,获取到的参数:" + json + ",报错信息:" + bcxx, summary: "接口错误信息"); return(null); } return(mode); }
/// <summary> /// 修改订单状态 /// </summary> /// <param name="code">订单编号</param> /// <param name="tname">表名</param> /// <returns></returns> public static bool UpdateOrderState(string code, string tname) { JMP.BLL.jmp_order order = new JMP.BLL.jmp_order(); bool re = false; if (order.ChangeStateToAbnormal(tname, code)) { re = true; } return(re); }
/// <summary> /// 修改原订单支付方式 /// </summary> /// <param name="oid"></param> /// <param name="paymode"></param> /// <returns></returns> private bool UpdateCode(int oid, int paymode) { bool Success = false; JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); if (bll.UpdatePayMode(oid, paymode)) { Success = true; } return(Success); }
/// <summary> /// 微信公众号第一次跳转 /// </summary> /// <param name="Oid">订单id</param> private void OnJump(int Oid) { try { string str = ""; JMP.MDL.jmp_app mo = new JMP.MDL.jmp_app(); JMP.BLL.jmp_app blls = new JMP.BLL.jmp_app(); mo = JMP.TOOL.MdlList.ToModel <JMP.MDL.jmp_app>(blls.GetList(" a_id=(SELECT o_app_id FROM jmp_order WHERE o_id=" + Oid + ") ").Tables[0]); if (mo != null) { SelectInterface SeIn = new SelectInterface(); string cache = "wxgfgzh" + Oid; SeIn = SelectInfo(cache, mo.a_rid, mo.a_id, int.Parse(ConfigurationManager.AppSettings["CacheTime"].ToString())); if (SeIn == null || SeIn.PayId <= 0 || string.IsNullOrEmpty(SeIn.UserId) || string.IsNullOrEmpty(SeIn.UserKey)) { str = "{\"Message\":\"支付通道未配置\",\"ErrorCode\":106}"; Response.Write(str); } JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); JMP.MDL.jmp_order morder = bll.SelectOrderGoodsName(Oid, "jmp_order"); if (morder.o_price < SeIn.minmun) { str = "{\"Message\":\"订单金额不能小于单笔最小支付金额\",\"ErrorCode\":8990}"; Response.Write(str); } if (morder.o_price > SeIn.maximum) { str = "{\"Message\":\"订单金额不能大于单笔最大支付金额\",\"ErrorCode\":8989}"; Response.Write(str); } if (bll.UpdatePay(Oid, SeIn.PayId)) { string redirect_uri = ConfigurationManager.AppSettings["WxGzhRturnUrl"].ToString() + Oid + ".html"; PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + "回调地址:" + redirect_uri, summary: "微信官方公众号第一次跳转支付接口错误信息", channelId: Oid); string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + SeIn.wxappid + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_base#wechat_redirect"; Response.Redirect(url, false); } } else { str = "{\"Message\":\"支付接口异常\",\"ErrorCode\":102}"; Response.Write(str); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.Message, summary: "微信官方公众号第一次跳转支付接口错误信息", channelId: Oid); Response.Write("非法访问!"); } }
/// <summary> /// 根据id修改支付通道(非appid方式) /// </summary> /// <param name="oid">订单id</param> /// <param name="payid">支付通道id</param> /// <returns></returns> public bool OrdeUpdateInfo(int oid, int payid, string code) { bool isSuccess = false; JMP.BLL.jmp_order blls = new JMP.BLL.jmp_order(); if (!blls.UpdatePay(oid, payid)) { PayApiGlobalErrorLogger.Log("修改支付渠道失败!订单id:" + oid + ",通道id:" + payid + ",订单编号:" + code, summary: "修改支付通道报错"); } else { isSuccess = true; } return(isSuccess); }
/// <summary> /// 根据id修改支付通道(非appid方式) /// </summary> /// <param name="oid">订单id</param> /// <param name="payid">支付通道id</param> /// <returns></returns> public static bool OrdeUpdateInfo(int oid, int payid) { bool isSuccess = false; JMP.BLL.jmp_order blls = new JMP.BLL.jmp_order(); if (!blls.UpdatePay(oid, payid)) { //AddLocLog.AddLog(1, 4, "", "修改支付通道报错", "修改支付渠道失败!订单id:" + oid.ToString() + ",通道id:" + payid);//写入报错日志 PayApiGlobalErrorLogger.Log("修改支付渠道失败!订单id:" + oid + ",通道id:" + payid, summary: "修改支付通道报错"); } else { isSuccess = true; } return(isSuccess); }
/// <summary> /// 支付包支付通道H5调用方式 /// </summary> /// <param name="apptype">应用类型id</param> /// <param name="code">订单编号</param> /// <param name="goodsname">商品名称</param> /// <param name="price">商品价格</param> /// <param name="TableName">订单表表名</param> /// <returns></returns> private InnerResponse PayZfbH5(int apptype, string code, string goodsname, decimal price, int oderid, string IP, int appid) { InnerResponse inn = new InnerResponse(); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); Config cfg = new Config(apptype, appid); SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); if (!UpdateOrde.OrdeUpdateInfo(oderid, cfg.pay_id)) { inn = inn.ToResponse(ErrorCode.Code101); return(inn); } if (!JudgeMoney.JudgeMinimum(price, cfg.minmun)) { inn = inn.ToResponse(ErrorCode.Code8990); return(inn); } if (!JudgeMoney.JudgeMaximum(price, cfg.maximum)) { inn = inn.ToResponse(ErrorCode.Code8989); return(inn); } sParaTemp.Add("partner", cfg.partner); sParaTemp.Add("seller_id", cfg.seller_id); sParaTemp.Add("_input_charset", cfg.input_charset.ToLower()); sParaTemp.Add("service", "alipay.wap.create.direct.pay.by.user"); sParaTemp.Add("payment_type", "1"); sParaTemp.Add("sign_type", "RSA"); sParaTemp.Add("notify_url", ConfigurationManager.AppSettings["TokenUrl"].ToString().Replace("{0}", cfg.pay_id.ToString())); //需要封装TokenUrl(异步回调地址) sParaTemp.Add("return_url", ConfigurationManager.AppSettings["GOTOUrl"].ToString().Replace("{0}", oderid.ToString())); //同步支付成功界面跳转地址 string overtime = (int.Parse(ConfigurationManager.AppSettings["overtime"].ToString()) / 60) + "m"; sParaTemp.Add("it_b_pay", overtime); //订单超时时间 sParaTemp.Add("out_trade_no", code); //我们的订单号 sParaTemp.Add("subject", goodsname); //商品名称(根据商品id查询商品名称) sParaTemp.Add("total_fee", price.ToString()); //价格(已传入的为准,无就从数据库读取) sParaTemp.Add("body", goodsname); //商品名称(备注) sParaTemp.Add("app_pay", "Y"); //吊起app string httpurl = new Alipay.Submit(apptype, appid).BuildRequestHttp(sParaTemp); inn = inn.ToResponse(ErrorCode.Code100); inn.ExtraData = httpurl;//http提交方式; inn.IsJump = true; return(inn); }
/// <summary> /// 根据订单编号获取订单信息 /// </summary> /// <param name="code">订单编号</param> /// <param name="noticestr">传入的字符串</param> /// <returns>返回一个实体类型</returns> private JMP.MDL.jmp_order SelectOrder(string code, string noticestr) { try { //订单支付完成执行 JMP.BLL.jmp_order order = new JMP.BLL.jmp_order(); JMP.MDL.jmp_order morder = new JMP.MDL.jmp_order(); string TableName = "jmp_order"; morder = order.GetModelbycode(code, TableName); return(morder); } catch (Exception ex) { //AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, "通知接口错误", "订单号:" + code + "根据订单号查询出错,传入参数:" + noticestr + "!错误信息:" + ex.ToString());//写入报错日志 PayNotifyGlobalErrorLogger.Log("订单号:" + code + "根据订单号查询出错,传入参数:" + noticestr + "!错误信息:" + ex.ToString(), summary: "通知接口错误"); return(null); } }
/// <summary> /// 验证商户订单号是否唯一 /// </summary> /// <param name="bizcode">商户订单号</param> /// <param name="appid">应用id</param> /// <returns></returns> private bool VerificationCode(string bizcode, int appid) { bool IsRepeat = false; JMP.MDL.jmp_order mode = new JMP.MDL.jmp_order(); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); string Cachekey = "VerificationCode" + bizcode + appid; if (JMP.TOOL.CacheHelper.IsCache(Cachekey))//判读是否存在缓存 { PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:支付接口验证参数错误,商户订单重复,缓存值:" + Cachekey + ",商户订单号:" + bizcode, summary: "接口错误信息", appId: appid, errorType: EnumForLogForApi.ErrorType.OrderNoRepeat); IsRepeat = true; } else { IsRepeat = false; } return(IsRepeat); }
/// <summary> /// 添加订单入库 /// </summary> /// <param name="mode">传入参数实体</param> /// <param name="json">传入参数json字符串</param> /// <returns></returns> private InnerResponse DownOrder(RequestParameter mode, string json) { InnerResponse Inn = new InnerResponse(); JMP.MDL.jmp_order mod = new JMP.MDL.jmp_order(); //订单表实体类 JMP.BLL.jmp_order jmp_orderbll = new JMP.BLL.jmp_order(); //订单表业务逻辑层 mod.o_address = mode.address; mod.o_showaddress = mode.showaddress; mod.o_app_id = mode.appid; mod.o_bizcode = mode.bizcode; mod.o_term_key = mode.termkey; mod.o_paymode_id = mode.paytype.ToString(); mod.o_goodsname = mode.goodsname; mod.o_price = mode.price; mod.o_privateinfo = mode.privateinfo; Random r = new Random(BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0)); mod.o_code = DateTime.Now.ToString("yyyyMMddHHmmssfff") + r.Next(111111111, 999999999).ToString() + r.Next(1111, 9999).ToString(); mod.o_state = 0; mod.o_times = 0; mod.o_noticestate = 0; mod.o_ctime = DateTime.Now; mod.o_noticetimes = DateTime.Now; mod.o_ptime = DateTime.Now; int cg = 0; cg = jmp_orderbll.AddOrder(mod); if (cg > 0) { pr.orderid = cg; pr.code = mod.o_code; pr.goodsname = mode.goodsname; pr.price = mode.price; Inn = Inn.ToResponse(ErrorCode.Code100); } else { PayApiGlobalErrorLogger.Log("报错信息:支付信息生成订单失败,获取到的参数:" + json, summary: "接口错误信息"); Inn = Inn.ToResponse(ErrorCode.Code101); } return(Inn); }
/// <summary> /// 支付宝支付通道安卓调用方式 /// </summary> /// <param name="apptype">应用类型子id</param> /// <param name="code">订单编号</param> /// <param name="goodsname">商品名称</param> /// <param name="price">价格(单位元)</param> /// <param name="oderid">订单id</param> /// <param name="ip">ip地址</param> /// <returns></returns> private InnerResponse PayZfbAz(int apptype, string code, string goodsname, decimal price, int oderid, string ip, int appid) { InnerResponse inn = new InnerResponse(); Config cfg = new Config(apptype, appid); SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); if (!UpdateOrde.OrdeUpdateInfo(oderid, cfg.pay_id)) { inn = inn.ToResponse(ErrorCode.Code101); return(inn); } if (!JudgeMoney.JudgeMinimum(price, cfg.minmun)) { inn = inn.ToResponse(ErrorCode.Code8990); return(inn); } if (!JudgeMoney.JudgeMaximum(price, cfg.maximum)) { inn = inn.ToResponse(ErrorCode.Code8989); return(inn); } sParaTemp.Add("partner", cfg.partner); sParaTemp.Add("seller_id", cfg.seller_id); sParaTemp.Add("_input_charset", cfg.input_charset.ToLower()); sParaTemp.Add("service", "mobile.securitypay.pay"); sParaTemp.Add("payment_type", "1"); sParaTemp.Add("notify_url", ConfigurationManager.AppSettings["TokenUrl"].ToString().Replace("{0}", cfg.pay_id.ToString()));//需要封装(接收回传地址)TokenUrl string overtime = (int.Parse(ConfigurationManager.AppSettings["overtime"].ToString()) / 60) + "m"; sParaTemp.Add("it_b_pay", overtime); //订单超时时间 sParaTemp.Add("out_trade_no", code); //我们的订单号 sParaTemp.Add("subject", goodsname); //商品i名称(根据商品id查询商品名称) sParaTemp.Add("total_fee", price.ToString()); //价格(已传入的为准,无就从数据库读取) sParaTemp.Add("body", goodsname); //商品名称(备注) string str = "{\"data\":\"" + new Alipay.Submit(apptype, appid).BuildRequest1(sParaTemp) + "\",\"PaymentType\":\"1\",\"SubType\":\"1\",\"IsH5\":\"0\"} "; inn = inn.ToResponse(ErrorCode.Code100); inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(str, ConfigurationManager.AppSettings["encryption"].ToString()); return(inn); }
/// <summary> /// 根据订单编号查询订单信息并调取支付当时 /// </summary> /// <param name="Code">订单编号</param> /// <param name="json">接受参数json字符串</param> /// <param name="ip">请求ip地址</param> /// <returns></returns> private JMP.MDL.jmp_order SelectCode(string Code, int CacheTime, string paytype) { JMP.MDL.jmp_order mode = new JMP.MDL.jmp_order(); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); string Cachekey = "SelectCode" + Code + paytype; if (JMP.TOOL.CacheHelper.IsCache(Cachekey))//判读是否存在缓存 { if (paytype == "4") { mode = JMP.TOOL.CacheHelper.GetCaChe <JMP.MDL.jmp_order>(Cachekey);//获取缓存 } else { JMP.MDL.jmp_order moded = new JMP.MDL.jmp_order(); moded = JMP.TOOL.CacheHelper.GetCaChe <JMP.MDL.jmp_order>(Cachekey);//获取缓存 PayApiDetailErrorLogger.DownstreamErrorLog("报错信息:商户发起重复下单请求,订单编号" + Code, summary: "接口错误信息,商户多次发起支付请求!", appId: moded.o_app_id, errorType: EnumForLogForApi.ErrorType.RequestRepeat); mode = null; } //mode = JMP.TOOL.CacheHelper.GetCaChe<JMP.MDL.jmp_order>(Cachekey);//获取缓存 //if (mode == null) //{ // mode = bll.GetModelbycode(Code, "jmp_order"); // if (mode != null) // { // JMP.TOOL.CacheHelper.CacheObjectLocak<JMP.MDL.jmp_order>(mode, Cachekey, CacheTime);//存入缓存 // } //} } else { mode = bll.SelectCode(Code, "jmp_order"); if (mode != null) { JMP.TOOL.CacheHelper.CacheObjectLocak <JMP.MDL.jmp_order>(mode, Cachekey, CacheTime);//存入缓存 } } return(mode); }
/// <summary> /// 根据订单编号查询订单信息并调取支付当时 /// </summary> /// <param name="od">参数实体</param> /// <returns></returns> public static string SelectCode(OrderCode od, string json) { string StrJson = "{\"message\":\"参数code有误\",\"result\":8997}"; try { JMP.MDL.jmp_order mode = new JMP.MDL.jmp_order(); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); mode = bll.GetModelbycode(od.code, "jmp_order"); if (mode != null && mode.o_state == 0) { if (mode.o_price == od.price) { if (bll.UpdatePayMode(mode.o_id, od.paymode)) { StrJson = PayType.PaySelect(od.paymode.ToString(), mode.o_app_id, od.tid, od.paytype, mode.o_code, od.goodsname, mode.o_price, mode.o_id, mode.o_privateinfo);//直接调取支付方式 } } else { StrJson = "{\"message\":\"请求金额不一致\",\"result\":8994}"; } } else { StrJson = "{\"message\":\"参数code有误\",\"result\":8997}"; } } catch (Exception e) { string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace.ToString(); //报错信息 StrJson = "{\"message\":\"参数异常\",\"result\":8990}"; AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, "收银台调取支付接口错误信息", "报错信息:" + bcxx + ",支付接口请求数据" + json); //写入报错日志 throw; } return(StrJson); }
public ActionResult DcDev() { #region 查询 string sql = "select ord.o_id,ord.o_code,ord.o_bizcode,ord.o_tradeno,ord.o_paymode_id,ord.o_app_id,ord.o_goodsname,ord.o_term_key,ord.o_price,ord.o_payuser,ord.o_ctime,ord.o_ptime,ord.o_state,ord.o_times,ord.o_address,ord.o_noticestate,ord.o_noticetimes,ord.o_privateinfo,ord.o_interface_id,ord.o_showaddress,app.a_name, users.u_id,users.u_realname,users.DisplayName,users.relation_type,users.bpname,paymode.p_name,inn.l_corporatename ,app.a_platform_id from( "; //组装查询条件 string sql1 = ""; string TableName = ""; //表名 string order = " order by o_ctime desc"; //排序字段 int searchType = string.IsNullOrEmpty(Request["searchType"]) ? 0 : Int32.Parse(Request["searchType"]); //查询条件选择 string searchname = string.IsNullOrEmpty(Request["searchname"]) ? "" : Request["searchname"]; //查询类容 string stime = string.IsNullOrEmpty(Request["stime"]) ? DateTime.Now.ToString("yyyy-MM-dd") : Request["stime"]; //开始时间 string etime = string.IsNullOrEmpty(Request["etime"]) ? DateTime.Now.ToString("yyyy-MM-dd") : Request["etime"]; //结束时间 int paymode = string.IsNullOrEmpty(Request["paymode"]) ? 0 : Int32.Parse(Request["paymode"]); //支付类型 string paymentstate = string.IsNullOrEmpty(Request["paymentstate"]) ? "1" : Request["paymentstate"]; //支付状态 string noticestate = string.IsNullOrEmpty(Request["noticestate"]) ? "" : Request["noticestate"]; //通知状态 ArrayList sjfw = JMP.TOOL.WeekDateTime.WeekMonday(DateTime.Parse(stime), DateTime.Parse(etime)); //根据时间返回获取每周周一组装查询语句 string where = ""; for (int i = 0; i < sjfw.Count; i++) { TableName = "jmp_order_" + DateTime.Parse(sjfw[i].ToString()).ToString("yyyyMMdd"); sql += " SELECT o_id,o_code,o_bizcode,o_tradeno,o_paymode_id,o_app_id,o_goodsname,o_term_key,o_price,o_payuser,o_ctime,o_ptime,o_state,o_times,o_address,o_noticestate,o_noticetimes,o_privateinfo,o_interface_id, o_showaddress FROM " + TableName + " where 1=1 "; if (!string.IsNullOrEmpty(stime) && !string.IsNullOrEmpty(etime)) { sql += " and convert(varchar(10),o_ptime,120)>='" + stime + "' and convert(varchar(10),o_ptime,120)<='" + etime + "' "; } if (paymode > 0) { sql += " and o_paymode_id='" + paymode + "' "; } if (!string.IsNullOrEmpty(paymentstate)) { sql += " and o_state='" + paymentstate + "' "; } if (!string.IsNullOrEmpty(noticestate)) { sql += " and o_noticestate='" + noticestate + "' "; } sql += " UNION ALL "; } if (searchType > 0 && !string.IsNullOrEmpty(searchname)) { switch (searchType) { case 1: where += " and a.o_code='" + searchname + "' "; break; case 2: where += " and b.a_name='" + searchname + "' "; break; case 3: where += " and d.g_name='" + searchname + "' "; break; case 4: where += " and a.o_tradeno= '" + searchname + "' "; break; case 5: where += " and a.o_bizcode like '%" + searchname + "%' "; break; } } // sql = sql.Remove(sql.Length - 10);//去掉最后一个UNION ALL sql1 = "SELECT o_id,o_code,o_bizcode,o_tradeno,o_paymode_id,o_app_id,o_goodsname,o_term_key,o_price,o_payuser,o_ctime,o_ptime,o_state,o_times,o_address,o_noticestate,o_noticetimes,o_privateinfo,o_interface_id, o_showaddress FROM jmp_order where 1=1"; if (!string.IsNullOrEmpty(stime) && !string.IsNullOrEmpty(etime)) { sql1 += " and convert(varchar(10),o_ptime,120)>='" + stime + "' and convert(varchar(10),o_ptime,120)<='" + etime + "' "; } if (paymode > 0) { sql1 += " and o_paymode_id='" + paymode + "' "; } if (!string.IsNullOrEmpty(paymentstate)) { sql1 += " and o_state='" + paymentstate + "' "; } if (!string.IsNullOrEmpty(noticestate)) { sql1 += " and o_noticestate='" + noticestate + "' "; } sql = sql + sql1; sql += " ) ord , jmp_app app ,(select aa.u_id, aa.u_realname, aa.DisplayName, aa.bpname, aa.relation_type from( select a.u_id, a.u_realname, c.DisplayName, null as bpname, a.relation_type from jmp_user a left join dx_base.dbo.CoAgent c on c.Id = a.relation_person_id where a.relation_type = 2 and c.OwnerId = " + UserInfo.UserId + ") aa group by aa.u_id, aa.u_realname, aa.DisplayName, aa.relation_type, aa.bpname ) users, jmp_paymode as paymode, jmp_interface as inn where app.a_id = ord.o_app_id and users.u_id = app.a_user_id and paymode.p_id = ord.o_paymode_id and inn.l_id = ord.o_interface_id " + where + order; List <JMP.MDL.jmp_order> list = new List <JMP.MDL.jmp_order>(); JMP.BLL.jmp_order orderbll = new JMP.BLL.jmp_order(); list = orderbll.DcSelectList(sql); var lst = list.Select(x => new { x.o_code, x.a_name, x.o_goodsname, x.o_bizcode, x.o_tradeno, x.p_name, x.o_price, o_state = x.o_state.ConvertPayState(), o_ctime = x.o_ctime.ToString("yyyy-MM-dd HH:mm:ss"), o_ptime = x.o_ptime.ToString("yyyy-MM-dd HH:mm:ss"), o_times = x.o_noticestate == 0 ? "--" : x.o_times.ToString(), o_noticestate = x.o_noticestate.ConvertNoticeState(x.o_state), o_noticetimes = x.o_noticestate != 0 ? x.o_noticetimes.ToString("yyyy-MM-dd HH:mm:ss") : "--", o_privateinfo = x.o_privateinfo }); var caption = "订单列表"; byte[] fileBytes; //命名导出表格的StringBuilder变量 using (var pck = new ExcelPackage()) { var ws = pck.Workbook.Worksheets.Add(caption); ws.Cells["A1"].LoadFromCollection(lst, false); ws.InsertRow(1, 1); ws.Cells["A1"].Value = "订单编号"; ws.Cells["B1"].Value = "应用名称"; ws.Cells["C1"].Value = "商品名称"; ws.Cells["D1"].Value = "商家订单号"; ws.Cells["E1"].Value = "支付流水号"; ws.Cells["F1"].Value = "支付类型"; ws.Cells["G1"].Value = "支付金额"; ws.Cells["H1"].Value = "支付状态"; ws.Cells["I1"].Value = "创建时间"; ws.Cells["J1"].Value = "支付时间"; ws.Cells["K1"].Value = "通知次数"; ws.Cells["L1"].Value = "通知状态"; ws.Cells["M1"].Value = "通知时间"; ws.Cells["N1"].Value = "私有信息"; fileBytes = pck.GetAsByteArray(); } Session["daochu"] = DateTime.Now; string fileName = "订单列表" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xls"; #endregion return(File(fileBytes, "application/vnd.ms-excel", fileName)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int oid = !string.IsNullOrEmpty(Request["pid"]) ? Convert.ToInt32(Request["pid"].ToString()) : 0; //订单表ID if (oid > 0) { //获取缓存 try { string code = !string.IsNullOrEmpty(Request["code"]) ? Request["code"] : ""; if (!string.IsNullOrEmpty(code)) { string url = ""; System.Threading.Thread.Sleep(new Random().Next(100, 500)); if (JMP.TOOL.CacheHelper.IsCache(oid.ToString()) == false) { url = "/pfwxgzhorder" + oid + ".html?code=" + code; JMP.TOOL.CacheHelper.CacheObject(url, oid.ToString(), 1);//存入缓存 } else { url = JMP.TOOL.CacheHelper.GetCaChe <string>(oid.ToString()); } Response.Redirect(url, false); } else { string appid = ""; JMP.MDL.jmp_app mo = new JMP.MDL.jmp_app(); JMP.BLL.jmp_app blls = new JMP.BLL.jmp_app(); mo = JMP.TOOL.MdlList.ToModel <JMP.MDL.jmp_app>(blls.GetList(" a_id=(SELECT o_app_id FROM jmp_order WHERE o_id=" + oid + ") ").Tables[0]); int pay_id = SelectUserInfo(mo.a_rid, mo.a_id); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); if (pay_id > 0) { if (bll.UpdatePay(oid, pay_id)) { string ddjj = Get_paystr(pay_id.ToString()); appid = ddjj.ToString().Split(',')[2]; string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + ConfigurationManager.AppSettings["redirecturipf"].ToString() + oid + ".html&response_type=code&scope=snsapi_base&state=1#wechat_redirect"; Response.Redirect(url, false); } } else { Response.Write("非法访问!"); } } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.Message, summary: "浦发银行公众号支付接口错误信息", channelId: oid); Response.Write("非法访问!"); } } else { Response.Write("非法访问!"); } } }
public override void ProcessNotify(int tid) { WxPayData notifyData = GetNotifyData(tid); //检查支付结果中transaction_id是否存在 if (!notifyData.IsSet("transaction_id")) { //若transaction_id不存在,则立即返回结果给微信支付后台 WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "支付结果中微信订单号不存在"); page.Response.Write(res.ToXml()); page.Response.End(); } string transaction_id = notifyData.GetValue("transaction_id").ToString(); //查询订单,判断订单真实性 string ordertime = notifyData.GetValue("time_end").ToString(); if (ordertime == "null") { //若订单查询失败,则立即返回结果给微信支付后台 WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "订单查询失败"); page.Response.Write(res.ToXml()); page.Response.End(); } //查询订单成功 else { //商户订单号 string out_trade_no = notifyData.GetValue("out_trade_no").ToString(); //交易号 string trade_no = notifyData.GetValue("transaction_id").ToString(); //交易状态 string trade_status = notifyData.GetValue("result_code").ToString(); //买家账号 string buyer_email = notifyData.GetValue("transaction_id").ToString(); //买家付款时间 string gmt_payment = ordertime; //交易金额(单位:分转换成元) decimal o_price = decimal.Parse((decimal.Parse(notifyData.GetValue("total_fee").ToString()) / 100).ToString("f2")); if (trade_status == "SUCCESS") { try { JMP.BLL.jmp_order order = new JMP.BLL.jmp_order(); JMP.MDL.jmp_order morder = new JMP.MDL.jmp_order(); string TableName = "jmp_order"; string orderTableName = JMP.TOOL.WeekDateTime.GetOrderTableName(DateTime.ParseExact(gmt_payment, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy-MM-dd"));//获取订单表名 morder = order.GetModelbycode(out_trade_no, TableName); if (morder != null) { if (morder.o_price == o_price) { int payid = !string.IsNullOrEmpty(morder.o_paymode_id) ? Int32.Parse(morder.o_paymode_id) : 0; if (JMP.TOOL.OrderProportion.ddbl(morder.o_app_id, o_price, payid)) { WxPayData res = new WxPayData(); res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); page.Response.Write(res.ToXml()); page.Response.End(); } else { if (morder.o_state != 1) { morder.o_tradeno = trade_no; morder.o_ptime = DateTime.ParseExact(gmt_payment, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture); morder.o_payuser = buyer_email; morder.o_state = 1; morder.o_noticestate = 0; morder.o_price = o_price; order.Update(morder, TableName); JMP.MDL.jmp_app app = new JMP.MDL.jmp_app(); JMP.BLL.jmp_app appbll = new JMP.BLL.jmp_app(); app = appbll.SelectId(morder.o_app_id); if (app != null) { JMP.MDL.jmp_queuelist quli = new JMP.MDL.jmp_queuelist(); JMP.BLL.jmp_queuelist bllq = new JMP.BLL.jmp_queuelist(); quli.q_address = morder.o_address; quli.q_sign = new JMP.BLL.jmp_app().GetModel(morder.o_app_id).a_secretkey; quli.q_noticestate = 0; quli.q_times = 0; quli.q_noticetimes = DateTime.Now; quli.q_tablename = orderTableName; quli.q_o_id = morder.o_id; quli.trade_type = Int32.Parse(morder.o_paymode_id); quli.trade_time = morder.o_ptime; quli.trade_price = morder.o_price; quli.trade_paycode = morder.o_tradeno; quli.trade_code = morder.o_code; quli.trade_no = morder.o_bizcode; quli.q_privateinfo = morder.o_privateinfo; quli.q_uersid = app.u_id; int cg = bllq.Add(quli); if (cg > 0) { WxPayData res = new WxPayData(); res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); page.Response.Write(res.ToXml()); page.Response.End(); } else { //AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, "微信官网通知错误", "订单号:" + morder.o_code + "添加到通知队列失败");//写入报错日志 PayApiGlobalErrorLogger.Log("订单号:" + morder.o_code + "添加到通知队列失败", summary: "微信官网通知错误"); WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "FAIL"); page.Response.Write(res.ToXml()); page.Response.End(); } } else { //AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, "微信官网通知错误", "应用id:" + morder.o_app_id + ",获取用户id失败!");//写入报错日志 PayApiGlobalErrorLogger.Log("应用id:" + morder.o_app_id + ",获取用户id失败!", summary: "微信官网通知错误"); WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "FAIL"); page.Response.Write(res.ToXml()); page.Response.End(); } } else { //AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, "微信官网通知接口错误", "订单号:" + out_trade_no + ",未查询到相关信息!");//写入报错日志 PayApiGlobalErrorLogger.Log("订单号:" + out_trade_no + ",未查询到相关信息!", summary: "微信官网通知接口错误"); WxPayData res = new WxPayData(); res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); page.Response.Write(res.ToXml()); page.Response.End(); } } } else { if (JMP.TOOL.UpdateOrder.OrderState.UpdateOrderState(morder.o_code, TableName)) { string ddsm = "订单号:" + morder.o_code + ",支付信息异常请核实!";//短信说明 JMP.TOOL.Auditor.IAuditor audit = new JMP.TOOL.Auditor.OrderAbnormalAuditor(morder.o_code, orderTableName, morder.o_app_id, ddsm, trade_no, DateTime.ParseExact(gmt_payment, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture), o_price, "成功", morder.o_price); audit.Add(); WxPayData res = new WxPayData(); res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); page.Response.Write(res.ToXml()); page.Response.End(); } else { WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "FAIL"); page.Response.Write(res.ToXml()); page.Response.End(); } } } else { WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "FAIL"); page.Response.Write(res.ToXml()); page.Response.End(); } } catch { WxPayData res = new WxPayData(); res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "FAIL"); page.Response.Write(res.ToXml()); page.Response.End(); } } } }
/// <summary> /// 根据订单号查询订单信息 /// </summary> /// <param name="code">订单编号</param> /// <returns></returns> public static string SelectOrder(string code) { string str = ""; try { JMP.MDL.jmp_order mode = new JMP.MDL.jmp_order(); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); mode = bll.GetModelbycode(code, "jmp_order"); if (mode != null) { #region 查询时时表信息 if (mode.o_state == 1) { str = "{\"message\":\"success\",\"price\":\"" + mode.o_price.ToString("f2") + "\"}"; } else { str = "{\"message\":\"fail\"}"; } #endregion } else { #region 根据指定时间查询归档表 string orderTableName = JMP.TOOL.WeekDateTime.GetOrderTableName(DateTime.Now.ToString("yyyy-MM-dd")); //获取订单表名 mode = bll.GetModelbycode(code, orderTableName); //查询本周归档表 if (mode != null) { if (mode.o_state == 1) { str = "{\"message\":\"success\",\"price\":\"" + mode.o_price.ToString("f2") + "\"}"; } else { str = "{\"message\":\"fail\"}"; } } else { string TableName = JMP.TOOL.WeekDateTime.GetOrderTableName(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")); //获取订单表名 mode = bll.GetModelbycode(code, TableName); //查询上周归档表 if (mode != null) { if (mode.o_state == 1) { str = "{\"message\":\"success\",\"price\":\"" + mode.o_price.ToString("f2") + "\"}"; } else { str = "{\"message\":\"fail\"}"; } } else { str = "{\"message\":\"fail\"}"; } } #endregion } } catch (Exception ex) { AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, "查询接口查询订单出错", "报错信息:" + ex.ToString() + ",查询参数:" + code);//写入报错日志 return(str = "{\"message\":\"fail\"}"); } return(str); }
/// <summary> /// 威富通应用支付通道苹果调用方式 /// </summary> /// <param name="appid">应用id</param> /// <param name="code">订单编号</param> /// <param name="goodsname">商品名称</param> /// <param name="price">商品价格</param> ///<param name="orderid">订单id</param> ///<param name="apptype">风控配置表id</param> /// <returns></returns> private InnerResponse PayWftAppIos(int appid, string code, string goodsname, decimal price, int orderid, string ip, int apptype) { InnerResponse inn = new InnerResponse(); Dictionary <string, string> cfg = new Dictionary <string, string>(); try { ClientResponseHandler resHandler = new ClientResponseHandler(); PayHttpClient pay = new PayHttpClient(); RequestHandler reqHandler = new RequestHandler(null); cfg = Utils.loadCfgWxApp(appid, apptype); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); if (!UpdateOrde.OrdeUpdateInfo(orderid, int.Parse(cfg["pay_id"].ToString()))) { inn = inn.ToResponse(ErrorCode.Code101); return(inn); } if (!JudgeMoney.JudgeMinimum(price, decimal.Parse(cfg["minmun"].ToString()))) { inn = inn.ToResponse(ErrorCode.Code8990); return(inn); } if (!JudgeMoney.JudgeMaximum(price, decimal.Parse(cfg["maximum"].ToString()))) { inn = inn.ToResponse(ErrorCode.Code8989); return(inn); } //初始化数据 reqHandler.setGateUrl(cfg["req_url"].ToString()); reqHandler.setKey(cfg["key"].ToString()); reqHandler.setParameter("out_trade_no", code); //我们的订单号 reqHandler.setParameter("body", goodsname); //商品描述 // reqHandler.setParameter("attach", privateinfo);//附加信息 reqHandler.setParameter("total_fee", (Convert.ToInt32(price * 100)).ToString()); //价格(已传入的为准,无就从数据库读取) reqHandler.setParameter("mch_create_ip", ip); //终端IP reqHandler.setParameter("service", "unified.trade.pay"); reqHandler.setParameter("mch_id", cfg["mch_id"].ToString()); reqHandler.setParameter("version", cfg["version"].ToString()); reqHandler.setParameter("notify_url", ConfigurationManager.AppSettings["WftTokenUrl"].ToString().Replace("{0}", cfg["pay_id"].ToString()));//回掉地址 reqHandler.setParameter("nonce_str", Utils.random()); reqHandler.setParameter("charset", "UTF-8"); reqHandler.setParameter("sign_type", "MD5"); reqHandler.setParameter("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); //订单生成时间 reqHandler.setParameter("time_expire", DateTime.Now.AddMinutes(30).ToString("yyyyMMddHHmmss")); //订单超时时间 reqHandler.createSign(); string datawft = Utils.toXml(reqHandler.getAllParameters()); Dictionary <string, string> reqContent = new Dictionary <string, string>(); reqContent.Add("url", reqHandler.getGateUrl()); reqContent.Add("data", datawft); pay.setReqContent(reqContent); if (pay.call()) { resHandler.setContent(pay.getResContent()); resHandler.setKey(cfg["key"].ToString()); Hashtable param = resHandler.getAllParameters(); if (resHandler.isTenpaySign()) { //原生态会返回:result_code ,非原生态不返回。 if (int.Parse(param["status"].ToString()) == 0) { string wxpay = "{\"token_id\":\"" + param["token_id"].ToString() + "\", \"services\":\"pay.weixin.app\", \"sign\":\"" + param["sign"] + "\",\"status\":\"0\", \"charset\":\"UTF-8\", \"version\":\"2.0\", \"sign_type\":\"MD5\",\"appid\":\"" + cfg["appid"].ToString() + "\",\"PaymentType\":\"5\",\"SubType\":\"2\",\"IsH5\":\"0\"}"; //str = "{\"message\":\"成功\",\"result\":100,\"data\":" + wxpay + "}"; inn = inn.ToResponse(ErrorCode.Code100); inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(wxpay, ConfigurationManager.AppSettings["encryption"].ToString()); } else { string wftzfsbxin = "威富通应用IOS接口支付通道支付失败信息,错误代码:" + param["err_code"] + ",错误信息:" + param["err_msg"] + ",商户号:" + cfg["mch_id"].ToString(); PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + wftzfsbxin, summary: "威富通appid接口错误信息", channelId: int.Parse(cfg["pay_id"].ToString())); inn = inn.ToResponse(ErrorCode.Code104); } } else { string mesage = "威富通支付失败信息,错误代码:" + resHandler.getContent() + ",错误信息:" + resHandler.getDebugInfo() + ",商户号:" + cfg["mch_id"].ToString(); PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + mesage, summary: "威富通appid接口错误信息", channelId: int.Parse(cfg["pay_id"].ToString())); inn = inn.ToResponse(ErrorCode.Code104); } } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:第一步验证错误", summary: "威富通appid接口错误信息", channelId: int.Parse(cfg["pay_id"].ToString())); inn = inn.ToResponse(ErrorCode.Code104); } } catch (Exception E) { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "威富通微信appid接口错误信息", channelId: int.Parse(cfg["pay_id"].ToString())); inn = inn.ToResponse(ErrorCode.Code104); } return(inn); }
/// <summary> /// 威富通微信公众号支付 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { int oid = !string.IsNullOrEmpty(Request["pid"]) ? Convert.ToInt32(Request["pid"].ToString()) : 0; if (oid > 0) { //获取缓存 try { string appid = ""; string appms = ""; string code = !string.IsNullOrEmpty(Request["code"]) ? Request["code"] : ""; if (!String.IsNullOrEmpty(code)) { //第二次 JMP.MDL.jmp_order morder = new JMP.BLL.jmp_order().SelectOrderGoodsName(oid, "jmp_order"); string ddjj = Get_paystr(morder.o_interface_id.ToString()); appid = ddjj.ToString().Split(',')[2]; appms = ddjj.ToString().Split(',')[3]; string openid = ""; string URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appid + "&secret=" + appms + "&code=" + code + "&grant_type=authorization_code"; Encoding encoding = Encoding.UTF8; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL); request.Timeout = 3000; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8)) { string jmpay = reader.ReadToEnd(); //解析json对象 JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> json = (Dictionary <string, object>)serializer.DeserializeObject(jmpay); object value = null; json.TryGetValue("openid", out value); openid = value.ToString(); } string str = ""; ClientResponseHandler resHandler = new ClientResponseHandler(); PayHttpClient pay = new PayHttpClient(); RequestHandler reqHandler = new RequestHandler(null); Dictionary <string, string> cfg = Utils.Load_CfgInterfaceId(morder.o_interface_id); reqHandler.setGateUrl(cfg["req_url"].ToString()); reqHandler.setKey(cfg["key"].ToString()); reqHandler.setParameter("out_trade_no", morder.o_code); //我们的订单号 reqHandler.setParameter("body", morder.o_goodsname); //商品描述 // reqHandler.setParameter("attach", string.IsNullOrEmpty(morder.o_privateinfo) ? "404" : morder.o_privateinfo);//附加信息 reqHandler.setParameter("total_fee", (Convert.ToInt32(morder.o_price * 100)).ToString()); //价格 reqHandler.setParameter("mch_create_ip", HttpContext.Current.Request.UserHostAddress); //终端IP reqHandler.setParameter("service", "pay.weixin.jspay"); reqHandler.setParameter("mch_id", cfg["mch_id"].ToString()); reqHandler.setParameter("version", cfg["version"].ToString()); reqHandler.setParameter("notify_url", ConfigurationManager.AppSettings["notifyurl"].ToString().Replace("{0}", morder.o_interface_id.ToString())); //回掉地址 reqHandler.setParameter("callback_url", ConfigurationManager.AppSettings["callbackurl"].ToString().Replace("{0}", oid.ToString())); //同步回掉地址 reqHandler.setParameter("sub_openid", openid); //获取openid reqHandler.setParameter("nonce_str", Utils.random()); //随机字符串 reqHandler.setParameter("charset", "UTF-8"); reqHandler.setParameter("sign_type", "MD5"); reqHandler.setParameter("is_raw", "1");//原生JS #region 判断是否需要禁用信用卡 //JMP.MDL.jmp_app moapp = new JMP.MDL.jmp_app(); //int tid = 0; //string hc = "gzhpdxykjy" + morder.o_app_id; //if (JMP.TOOL.CacheHelper.IsCache(hc))//判读是否存在缓存 //{ // moapp = JMP.TOOL.CacheHelper.GetCaChe<JMP.MDL.jmp_app>(hc);//获取缓存 // if (moapp != null) // { // tid = moapp.a_apptype_id > 0 ? moapp.a_apptype_id : 0; // if (tid == 0) // { // JMP.BLL.jmp_app blapp = new JMP.BLL.jmp_app(); // moapp = blapp.SelectId(morder.o_app_id); // JMP.TOOL.CacheHelper.CacheObjectLocak<JMP.MDL.jmp_app>(moapp, hc, 5);//存入缓存 // } // } // else // { // JMP.BLL.jmp_app blapp = new JMP.BLL.jmp_app(); // moapp = blapp.SelectId(morder.o_app_id); // tid = moapp.a_apptype_id > 0 ? moapp.a_apptype_id : 0; // JMP.TOOL.CacheHelper.CacheObjectLocak<JMP.MDL.jmp_app>(moapp, hc, 5);//存入缓存 // } //} //else //{ // JMP.BLL.jmp_app blapp = new JMP.BLL.jmp_app(); // moapp = blapp.SelectId(morder.o_app_id); // tid = moapp.a_apptype_id > 0 ? moapp.a_apptype_id : 0; // JMP.TOOL.CacheHelper.CacheObjectLocak<JMP.MDL.jmp_app>(moapp, hc, 5);//存入缓存 //} //if (tid == 71) //{ // reqHandler.setParameter("limit_credit_pay", "1");//是否限制信用卡(1:限制,0:不限制) //} #endregion reqHandler.createSign(); string datawft = Utils.toXml(reqHandler.getAllParameters()); Dictionary <string, string> reqContent = new Dictionary <string, string>(); reqContent.Add("url", reqHandler.getGateUrl()); reqContent.Add("data", datawft); pay.setReqContent(reqContent); if (pay.call()) { resHandler.setContent(pay.getResContent()); resHandler.setKey(cfg["key"].ToString()); Hashtable param = resHandler.getAllParameters(); Dictionary <string, string> dic = JMP.TOOL.UrlStr.hastable(param); string wftmsg = JMP.TOOL.JsonHelper.DictJsonstr(dic); if (resHandler.isTenpaySign()) { if (int.Parse(param["status"].ToString()) == 0 && int.Parse(param["result_code"].ToString()) == 0) { string pay_info = dic["pay_info"]; if (!string.IsNullOrEmpty(pay_info)) { Dictionary <string, object> List = new Dictionary <string, object>(); List = JMP.TOOL.JsonHelper.DataRowFromJSON(pay_info); try { string chengstr = "<script type=\"text/javascript\">function onBridgeReady(){WeixinJSBridge.invoke( 'getBrandWCPayRequest', {\"appId\": \"" + List["appId"] + "\", \"timeStamp\": \"" + List["timeStamp"] + "\", \"nonceStr\": \"" + List["nonceStr"] + "\",\"package\":\"" + List["package"] + "\",\"signType\": \"MD5\",\"paySign\": \"" + List["paySign"] + "\" },function(res) {if (res.err_msg ==\"get_brand_wcpay_request:ok\") { window.location.href=\"" + List["callback_url"] + "\" }else{ alert(res.err_msg) } });}if (typeof WeixinJSBridge == \"undefined\"){if (document.addEventListener){document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);}else if (document.attachEvent){document.attachEvent('WeixinJSBridgeReady', onBridgeReady); document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);} }else{onBridgeReady();}</script> "; Response.Write(chengstr); } catch { string wftzfsbxin = "威富通公众号支付失败信息,错误信息:" + wftmsg; PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息openid:" + openid + ":" + wftzfsbxin, summary: "威富通公众号接口错误信息2", channelId: oid); str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}"; } } else { string wftzfsbxin = "威富通公众号支付失败信息,错误信息:" + wftmsg; PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息openid:" + openid + ":" + wftzfsbxin, summary: "威富通公众号接口错误信息4", channelId: oid); str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}"; } } else { string wftzfsbxin = "威富通公众号支付失败信息,错误信息:" + wftmsg; PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息openid:" + openid + ":" + wftzfsbxin, summary: "威富公众号通接口错误信息3", channelId: oid); str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}"; } } else { str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}"; PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息openid:" + openid, summary: "威富公众号通接口错误信息4", channelId: oid); } } else { str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}"; PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息openid:" + openid, summary: "威富公众号通接口错误信息5", channelId: oid); } Response.Write(str); } else { JMP.MDL.jmp_app mo = new JMP.MDL.jmp_app(); JMP.BLL.jmp_app blls = new JMP.BLL.jmp_app(); mo = JMP.TOOL.MdlList.ToModel <JMP.MDL.jmp_app>(blls.GetList(" a_id=(SELECT o_app_id FROM jmp_order WHERE o_id=" + oid + ") ").Tables[0]); if (mo != null) { Dictionary <string, string> cfg = Utils.loadCfgWxgzh(mo.a_rid, mo.a_id); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); if (bll.UpdatePay(oid, int.Parse(cfg["pay_id"].ToString()))) { string ddjj = Get_paystr(cfg["pay_id"].ToString()); appid = ddjj.ToString().Split(',')[2]; appms = ddjj.ToString().Split(',')[3]; string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + ConfigurationManager.AppSettings["redirecturi"].ToString() + oid + ".html&response_type=code&scope=snsapi_base#wechat_redirect"; Response.Redirect(url, false); } } else { string str = "{\"Message\":\"支付接口异常\",\"ErrorCode\":102}"; Response.Write(str); } } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.ToString() + "订单表id:" + oid, summary: "威富公众号通接口错误信息", channelId: oid); Response.Write("非法访问!"); } } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:第一步判断,订单表id:" + oid, summary: "威富公众号通接口错误信息", channelId: oid); Response.Write("非法访问!"); } }
public ActionResult OrderList() { #region 获取信息 JMP.BLL.jmp_paymode paymodebll = new JMP.BLL.jmp_paymode(); List <JMP.MDL.jmp_paymode> paymodeList = paymodebll.GetModelList("1=1 and p_state='1' ");//支付类型 ViewBag.paymodeList = paymodeList; #endregion #region 查询 string sql = ""; string sql1 = ""; //组装查询条件 string TableName = ""; //表名 string order = "o_ptime "; //排序字段 int pageCount = 0; int pageIndexs = string.IsNullOrEmpty(Request["pageIndexs"]) ? 1 : Int32.Parse(Request["pageIndexs"]); //当前页 int PageSize = string.IsNullOrEmpty(Request["PageSize"]) ? 20 : Int32.Parse(Request["PageSize"]); //每页显示数量 int searchType = string.IsNullOrEmpty(Request["searchType"]) ? 0 : Int32.Parse(Request["searchType"]); //查询条件选择 string searchname = string.IsNullOrEmpty(Request["searchname"]) ? "" : Request["searchname"]; //查询类容 string stime = string.IsNullOrEmpty(Request["stime"]) ? DateTime.Now.ToString("yyyy-MM-dd") : Request["stime"]; //开始时间 string etime = string.IsNullOrEmpty(Request["etime"]) ? DateTime.Now.ToString("yyyy-MM-dd") : Request["etime"]; //结束时间 int paymode = string.IsNullOrEmpty(Request["paymode"]) ? 0 : Int32.Parse(Request["paymode"]); //支付类型 string paymentstate = string.IsNullOrEmpty(Request["paymentstate"]) ? "1" : Request["paymentstate"]; //支付状态 string noticestate = string.IsNullOrEmpty(Request["noticestate"]) ? "" : Request["noticestate"]; //通知状态 int platformid = string.IsNullOrEmpty(Request["platformid"]) ? 0 : Int32.Parse(Request["platformid"]); //关联平台 int relationtype = string.IsNullOrEmpty(Request["relationtype"]) ? -1 : Int32.Parse(Request["relationtype"]); //商户类型 ViewBag.platformid = platformid; ArrayList sjfw = JMP.TOOL.WeekDateTime.WeekMonday(DateTime.Parse(stime), DateTime.Parse(etime));//根据时间返回获取每周周一组装查询语句 for (int i = 0; i < sjfw.Count; i++) { TableName = "jmp_order_" + DateTime.Parse(sjfw[i].ToString()).ToString("yyyyMMdd"); // TableName = "jmp_order_20161107"; sql += " SELECT o_id,o_code,o_bizcode,o_tradeno,o_paymode_id,o_app_id,o_goodsname,o_term_key,o_price,o_payuser,o_ctime,o_ptime,o_state,o_times,o_address,o_noticestate,o_noticetimes,o_privateinfo,o_interface_id, o_showaddress FROM " + TableName + " where 1=1 "; if (!string.IsNullOrEmpty(stime) && !string.IsNullOrEmpty(etime)) { sql += " and convert(varchar(10),o_ptime,120)>='" + stime + "' and convert(varchar(10),o_ptime,120)<='" + etime + "' "; } if (paymode > 0) { sql += " and o_paymode_id='" + paymode + "' "; } if (!string.IsNullOrEmpty(paymentstate)) { sql += " and o_state='" + paymentstate + "' "; } if (!string.IsNullOrEmpty(noticestate)) { sql += " and o_noticestate='" + noticestate + "' "; } sql += " UNION ALL "; } string where = "where 1=1";//组装查询条件 if (searchType > 0 && !string.IsNullOrEmpty(searchname)) { switch (searchType) { case 1: where += " and a.o_code='" + searchname + "' "; break; case 2: where += " and b.a_name='" + searchname + "' "; break; case 3: where += " and a.o_goodsname='" + searchname + "' "; break; case 4: where += " and e.u_realname like '%" + searchname + "%' "; break; case 5: where += " and a.o_tradeno= '" + searchname + "' "; break; case 6: where += " and a.o_bizcode= '" + searchname + "' "; break; case 7: where += " and inn.l_corporatename like '%" + searchname + "%' "; break; } } if (platformid > 0) { where += " and b.a_platform_id=" + platformid; } if (relationtype > -1) { where += " and e.relation_type=" + relationtype; } //组装时时表数据 sql1 = "SELECT o_id,o_code,o_bizcode,o_tradeno,o_paymode_id,o_app_id,o_goodsname,o_term_key,o_price,o_payuser,o_ctime,o_ptime,o_state,o_times,o_address,o_noticestate,o_noticetimes,o_privateinfo,o_interface_id, o_showaddress FROM jmp_order where 1=1"; if (!string.IsNullOrEmpty(stime) && !string.IsNullOrEmpty(etime)) { sql1 += " and convert(varchar(10),o_ptime,120)>='" + stime + "' and convert(varchar(10),o_ptime,120)<='" + etime + "' "; } if (paymode > 0) { sql1 += " and o_paymode_id='" + paymode + "' "; } if (!string.IsNullOrEmpty(paymentstate)) { sql1 += " and o_state='" + paymentstate + "' "; } if (!string.IsNullOrEmpty(noticestate)) { sql1 += " and o_noticestate='" + noticestate + "' "; } sql = sql + sql1; ViewBag.searchname = searchname; ViewBag.searchType = searchType; ViewBag.stime = stime; ViewBag.etime = etime; ViewBag.paymode = paymode; ViewBag.paymentstate = paymentstate; ViewBag.noticestate = noticestate; List <JMP.MDL.jmp_order> list = new List <JMP.MDL.jmp_order>(); JMP.BLL.jmp_order orderbll = new JMP.BLL.jmp_order(); list = orderbll.SelectPager(where, sql, order, pageIndexs, PageSize, out pageCount); ViewBag.pageIndexs = pageIndexs; ViewBag.PageSize = PageSize; ViewBag.pageCount = pageCount; ViewBag.list = list; ViewBag.relationtype = relationtype; #endregion return(View()); }
public JsonResult CustomAdd(JMP.MDL.CsComplainOrder mode) { object retJson = new { success = 0, msg = "操作失败" }; if (mode.Id > 0) { #region 修改 //得到一个实体对象 cscomod = cscobll.GetModel(mode.Id); //拷贝 var mocolne = cscomod.Clone(); cscomod.ComplainTypeId = mode.ComplainTypeId; cscomod.ComplainTypeName = mode.ComplainTypeName; cscomod.ComplainDate = mode.ComplainDate; cscomod.Envidence = mode.Envidence; cscomod.DownstreamStartTime = mode.DownstreamStartTime; cscomod.DownstreamEndTime = mode.DownstreamEndTime; if (cscobll.Update(cscomod)) { Logger.ModifyLog("修改投诉", mocolne, cscomod); retJson = new { success = 1, msg = "修改成功" }; } else { retJson = new { success = 0, msg = "修改失败" }; } #endregion } else { //判断该订单是否已经添加到投诉表中 var exists = cscobll.GetModelList(string.Format("OrderNumber='{0}'", mode.OrderNumber.Replace("'", "''"))); if (exists != null && exists.Count > 0) { return(Json(new { success = 0, msg = "此订单已提交过了" })); } var time = DateTime.ParseExact(mode.OrderNumber.Substring(0, 8), "yyyyMMdd", CultureInfo.CurrentCulture); var tableName = WeekDateTime.GetOrderTableName(time.ToString(CultureInfo.InvariantCulture)); mode.state = 0; mode.CreatedOn = DateTime.Now; mode.FounderId = UserInfo.UserId; mode.FounderName = UserInfo.UserName; mode.OrderTable = tableName; try { //从订单归档表读取订单金额 var orderBll = new JMP.BLL.jmp_order(); var archiveOrder = orderBll.FindOrderByTableNameAndOrderNo(tableName, mode.OrderNumber); if (archiveOrder == null || archiveOrder.o_price <= 0) { retJson = new { success = 0, msg = "添加失败[读取订单金额失败]" }; GlobalErrorLogger.Log("添加失败[读取订单金额失败]", summary: "添加投诉失败"); return(Json(retJson)); } mode.Price = archiveOrder.o_price; } catch (Exception ex) { retJson = new { success = 0, msg = "添加失败[读取订单金额失败]" }; GlobalErrorLogger.Log("添加失败[读取订单金额失败]", summary: "添加投诉失败"); return(Json(retJson)); } int num = cscobll.Add(mode); if (num > 0) { Logger.CreateLog("添加投诉", mode); retJson = new { success = 1, msg = "添加成功" }; } else { retJson = new { success = 0, msg = "添加失败" }; } } return(Json(retJson)); }
public JsonResult Orderrewire() { object retJson = new { success = 0, msg = "操作失败" }; string ordercode = string.IsNullOrEmpty(Request["code"]) ? "" : Request["code"]; string ptime = string.IsNullOrEmpty(Request["ptime"]) ? "" : Request["ptime"]; bool sess = Convert.ToDateTime(Session["sendtime_" + ordercode]) > System.DateTime.Now.AddMinutes(-1) ? true : false; if (!string.IsNullOrEmpty(ordercode) && !string.IsNullOrEmpty(ptime)) { if (DateTime.Parse(DateTime.Parse(ptime).ToString("yyyy-MM-dd")) > DateTime.Parse(DateTime.Now.AddDays(-3).ToString("yyyy-MM-dd"))) { if (sess) { retJson = new { success = 0, msg = "请间隔一分钟,再次发送!" }; return(Json(retJson)); } else { JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); JMP.MDL.jmp_order morder = new JMP.MDL.jmp_order(); string tabalename = "dbo.jmp_order_" + JMP.TOOL.WeekDateTime.GetWeekFirstDayMon(DateTime.Parse(ptime)).ToString("yyyyMMdd"); morder = bll.SelectOrder(ordercode, tabalename); if (morder != null) { if (morder.o_times > 8 && morder.o_times < 12) { JMP.MDL.jmp_queuelist quli = new JMP.MDL.jmp_queuelist(); JMP.BLL.jmp_queuelist bllq = new JMP.BLL.jmp_queuelist(); quli.q_address = morder.o_address; quli.q_sign = new JMP.BLL.jmp_app().GetModel(morder.o_app_id).a_secretkey; quli.q_noticestate = 0; quli.q_times = morder.o_times; quli.q_noticetimes = DateTime.Now; quli.q_tablename = tabalename; quli.q_o_id = morder.o_id; quli.trade_type = Int32.Parse(morder.o_paymode_id); quli.trade_time = morder.o_ptime; quli.trade_price = morder.o_price; quli.trade_paycode = morder.o_tradeno; quli.trade_code = morder.o_code; quli.trade_no = morder.o_bizcode; quli.q_privateinfo = morder.o_privateinfo; quli.q_uersid = UserInfo.UserId; int cg = bllq.Add(quli); if (cg > 0) { Session["sendtime_" + morder.o_code] = System.DateTime.Now; retJson = new { success = 1, msg = "已重发通知!手动通知次数剩余:" + (11 - morder.o_times) + "次" }; } else { Logger.OperateLog("商务平台手动重发通知失败", "订单号:" + morder.o_code + ",表名:" + tabalename); //写入报错日 retJson = new { success = 0, msg = "操作失败!" }; } } else { retJson = new { success = 0, msg = "手动通知无效!" }; } } } } else { retJson = new { success = 0, msg = "只能重发三天以内的数据!" }; } } else { retJson = new { success = 0, msg = "数据异常!" }; } return(Json(retJson)); }
/// <summary> /// 订单列表 /// </summary> /// <returns></returns> public ActionResult OrderList() { #region 获取用户实名认证状态信息 JMP.BLL.jmp_user sm_bll = new JMP.BLL.jmp_user(); JMP.MDL.jmp_user sm_model = new JMP.MDL.jmp_user(); int u_ids = UserInfo.Uid; //查询登录信息 sm_model = sm_bll.GetModel(u_ids); ViewBag.auditstate = sm_model.u_auditstate; ViewBag.linkEmail = sm_model.u_email; #endregion #region 获取信息 JMP.BLL.jmp_paymode paymodebll = new JMP.BLL.jmp_paymode(); List <JMP.MDL.jmp_paymode> paymodeList = paymodebll.GetModelList("1=1 and p_state='1' ");//支付类型 ViewBag.paymodeList = paymodeList; #endregion #region 查询 //string sql = " select o_id,o_code,o_bizcode,o_tradeno,o_paymode_id,o_app_id,o_goods_id,o_term_key,o_price,o_payuser,o_ctime,o_ptime,o_state,o_times,o_address,o_noticestate,o_noticetimes,o_privateinfo,o_interface_id,o_showaddress,b.a_key,b.a_name,c.p_name,d.g_name from ( ";//组装查询条件 string sql = ""; string sql1 = ""; string TableName = ""; //表名 string order = "o_ptime"; //排序字段 int pageCount = 0; int pageIndexs = string.IsNullOrEmpty(Request["pageIndexs"]) ? 1 : Int32.Parse(Request["pageIndexs"]); //当前页 int PageSize = string.IsNullOrEmpty(Request["PageSize"]) ? 20 : Int32.Parse(Request["PageSize"]); //每页显示数量 int searchType = string.IsNullOrEmpty(Request["searchType"]) ? 0 : Int32.Parse(Request["searchType"]); //查询条件选择 string searchname = string.IsNullOrEmpty(Request["searchname"]) ? "" : Request["searchname"]; //查询类容 string stime = string.IsNullOrEmpty(Request["stime"]) ? DateTime.Now.ToString("yyyy-MM-dd") : Request["stime"]; //开始时间 string etime = string.IsNullOrEmpty(Request["etime"]) ? DateTime.Now.ToString("yyyy-MM-dd") : Request["etime"]; //结束时间 int paymode = string.IsNullOrEmpty(Request["paymode"]) ? 0 : Int32.Parse(Request["paymode"]); //支付类型 string paymentstate = string.IsNullOrEmpty(Request["paymentstate"]) ? "1" : Request["paymentstate"]; //支付状态 string noticestate = string.IsNullOrEmpty(Request["noticestate"]) ? "" : Request["noticestate"]; //通知状态 ArrayList sjfw = JMP.TOOL.WeekDateTime.WeekMonday(DateTime.Parse(stime), DateTime.Parse(etime)); //根据时间返回获取每周周一组装查询语句 string where = "where 1=1"; for (int i = 0; i < sjfw.Count; i++) { TableName = "jmp_order_" + DateTime.Parse(sjfw[i].ToString()).ToString("yyyyMMdd"); // TableName = "jmp_order_20161107"; sql += " SELECT o_id,o_code,o_bizcode,o_tradeno,o_paymode_id,o_app_id,o_goodsname,o_term_key,o_price,o_payuser,o_ctime,o_ptime,o_state,o_times,o_address,o_noticestate,o_noticetimes,o_privateinfo,o_interface_id,o_showaddress FROM " + TableName + " where 1=1 "; if (!string.IsNullOrEmpty(stime) && !string.IsNullOrEmpty(etime)) { sql += " and convert(varchar(10),o_ptime,120)>='" + stime + "' and convert(varchar(10),o_ptime,120)<='" + etime + "' "; } if (paymode > 0) { sql += " and o_paymode_id='" + paymode + "' "; } if (!string.IsNullOrEmpty(paymentstate)) { sql += " and o_state='" + paymentstate + "' "; } if (!string.IsNullOrEmpty(noticestate)) { sql += " and o_noticestate='" + noticestate + "' "; } sql += " UNION ALL "; } if (searchType > 0 && !string.IsNullOrEmpty(searchname)) { switch (searchType) { case 1: where += " and a.o_code='" + searchname + "' "; break; case 2: where += " and b.a_name='" + searchname + "' "; break; case 3: where += " and a.o_goodsname='" + searchname + "' "; break; case 4: where += " and a.o_tradeno= '" + searchname + "' "; break; case 5: where += " and a.o_bizcode like '%" + searchname + "%' "; break; } } where += "and b.a_user_id='" + UserInfo.UserId + "'"; //sql = sql.Remove(sql.Length - 10);//去掉最后一个UNION ALL //sql += " ) a left join jmp_app b on a.o_app_id=b.a_id left join jmp_paymode c on c.p_id=a.o_paymode_id left join jmp_goods d on d.g_id=a.o_goods_id and d.g_app_id=b.a_id and d.g_app_id=a.o_app_id where 1=1 and " + where; //组装时时表数据 sql1 = "SELECT o_id,o_code,o_bizcode,o_tradeno,o_paymode_id,o_app_id,o_goodsname,o_term_key,o_price,o_payuser,o_ctime,o_ptime,o_state,o_times,o_address,o_noticestate,o_noticetimes,o_privateinfo,o_interface_id, o_showaddress FROM jmp_order where 1=1"; if (!string.IsNullOrEmpty(stime) && !string.IsNullOrEmpty(etime)) { sql1 += " and convert(varchar(10),o_ptime,120)>='" + stime + "' and convert(varchar(10),o_ptime,120)<='" + etime + "' "; } if (paymode > 0) { sql1 += " and o_paymode_id='" + paymode + "' "; } if (!string.IsNullOrEmpty(paymentstate)) { sql1 += " and o_state='" + paymentstate + "' "; } if (!string.IsNullOrEmpty(noticestate)) { sql1 += " and o_noticestate='" + noticestate + "' "; } sql = sql + sql1; ViewBag.searchname = searchname; ViewBag.searchType = searchType; ViewBag.stime = stime; ViewBag.etime = etime; ViewBag.paymode = paymode; ViewBag.paymentstate = paymentstate; ViewBag.noticestate = noticestate; List <JMP.MDL.jmp_order> list = new List <JMP.MDL.jmp_order>(); JMP.BLL.jmp_order orderbll = new JMP.BLL.jmp_order(); list = orderbll.SelectPager(where, sql, order, pageIndexs, PageSize, out pageCount); ViewBag.pageIndexs = pageIndexs; ViewBag.PageSize = PageSize; ViewBag.pageCount = pageCount; ViewBag.list = list; #endregion return(View()); }
/// <summary> /// 微信支付通道安卓调用方式 /// </summary> /// <param name="appid">应用id</param> /// <param name="code">订单编号</param> /// <param name="goodsname">商品名称</param> /// <param name="price">商品价格</param> /// <param name="orderid">订单id</param> /// <param name="apptype">风控配置表id</param> /// <returns></returns> private InnerResponse PayWxAz(int appid, string code, string goodsname, decimal price, int orderid, string ip, int apptype, int infoTimes) { InnerResponse inn = new InnerResponse(); SelectInterface SeIn = new SelectInterface(); try { string wxappidzfjk = "wxappidzfjk" + appid;//组装缓存key值 SeIn = SelectUserInfo(wxappidzfjk, appid, apptype, infoTimes); if (SeIn == null || SeIn.PayId <= 0) { inn = inn.ToResponse(ErrorCode.Code106); return(inn); } if (SeIn.PayId > 0) { WxPayConfig wx = new WxPayConfig(SeIn.PayId); JMP.BLL.jmp_order bll = new JMP.BLL.jmp_order(); if (!UpdateOrde.OrdeUpdateInfo(orderid, SeIn.PayId)) { inn = inn.ToResponse(ErrorCode.Code101); return(inn); } if (!JudgeMoney.JudgeMinimum(price, SeIn.minmun)) { inn = inn.ToResponse(ErrorCode.Code8990); return(inn); } if (!JudgeMoney.JudgeMaximum(price, SeIn.maximum)) { inn = inn.ToResponse(ErrorCode.Code8989); return(inn); } WxPayData data = new WxPayData(); data.SetValue("body", goodsname); //商品名称 data.SetValue("out_trade_no", code); //我们的订单号 data.SetValue("total_fee", (Convert.ToInt32(price * 100)).ToString()); //价格 data.SetValue("notify_url", ConfigurationManager.AppSettings["WxTokenUrl"].ToString().Replace("{0}", SeIn.PayId.ToString())); //回调地址 data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); data.SetValue("time_expire", DateTime.Now.AddMinutes(30).ToString("yyyyMMddHHmmss")); data.SetValue("trade_type", "APP"); WxPayData result = WxPayApi.UnifiedOrder(data, SeIn.PayId); string noncestr = WxPayApi.GenerateNonceStr(); string timestamp = WxPayApi.GenerateTimeStamp(); WxPayData data1 = new WxPayData(); data1.SetValue("appid", wx.APPID); data1.SetValue("noncestr", noncestr); data1.SetValue("package", "Sign=WXPay"); data1.SetValue("partnerid", wx.MCHID); data1.SetValue("prepayid", result.GetValue("prepay_id")); data1.SetValue("timestamp", timestamp); string sign = data1.MakeSign(SeIn.PayId); string wxstr = "{\"appid\":\"" + result.GetValue("appid") + "\",\"partnerid\":\"" + result.GetValue("mch_id") + "\",\"prepayid\":\"" + result.GetValue("prepay_id") + "\",\"pkg\":\"Sign=WXPay\",\"noncestr\":\"" + noncestr + "\",\"timestamp\":\"" + timestamp + "\",\"sign\":\"" + sign + "\",\"PaymentType\":\"5\",\"SubType\":\"1\",\"IsH5\":\"0\"}"; // str = "{\"message\":\"成功\",\"result\":100,\"data\":" + wxstr + "}"; inn = inn.ToResponse(ErrorCode.Code100); inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(wxstr, ConfigurationManager.AppSettings["encryption"].ToString()); } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:支付通道异常", summary: "微信appid支付接口错误信息", channelId: SeIn.PayId); inn = inn.ToResponse(ErrorCode.Code104); } } catch (Exception E) { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + E.ToString(), summary: "微信appid支付接口错误信息", channelId: SeIn.PayId); inn = inn.ToResponse(ErrorCode.Code104); } return(inn); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int oid = !string.IsNullOrEmpty(Request.QueryString["pid"]) ? Convert.ToInt32(Request.QueryString["pid"].ToString()) : 0; //订单表ID string code = !string.IsNullOrEmpty(Request.QueryString["code"]) ? Request.QueryString["code"] : ""; string UserId = ""; string UserKey = ""; string appid = ""; string appms = ""; if (!String.IsNullOrEmpty(code) && oid > 0) { string json = ""; string str = ""; string openid = ""; //System.Threading.Thread.Sleep(new Random().Next(100, 500)); JMP.MDL.jmp_order morder = new JMP.BLL.jmp_order().SelectOrderGoodsName(oid, "jmp_order"); if (JMP.TOOL.CacheHelper.IsCache(morder.o_code) == false) { string ddjj = Get_paystr(morder.o_interface_id.ToString()); UserId = ddjj.ToString().Split(',')[0]; UserKey = ddjj.ToString().Split(',')[1]; appid = ddjj.ToString().Split(',')[2]; appms = ddjj.ToString().Split(',')[3]; string URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appid + "&secret=" + appms + "&code=" + code + "&grant_type=authorization_code"; Encoding encoding = Encoding.UTF8; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL); request.Timeout = 3000; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8)) { string jmpay = reader.ReadToEnd(); //解析json对象 JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> jsonstr = (Dictionary <string, object>)serializer.DeserializeObject(jmpay); object value = null; jsonstr.TryGetValue("openid", out value); openid = value.ToString(); } string xml = "<?xml version='1.0' encoding='utf-8' ?><ORDER_REQ><BUSI_ID>" + UserId + "</BUSI_ID><OPER_ID>oper01</OPER_ID><DEV_ID>dev01</DEV_ID><AMT>" + morder.o_price + "</AMT><CHANNEL_TYPE>2</CHANNEL_TYPE><TRADE_TYPE>JSAPI</TRADE_TYPE><subAppid>" + appid + "</subAppid><subOpenid>" + openid + "</subOpenid><PAY_SUBJECT>" + morder.o_goodsname + "</PAY_SUBJECT ><CHARGE_CODE>" + morder.o_code + "</CHARGE_CODE><NODIFY_URL>" + ConfigurationManager.AppSettings["pfalpayNotifyUrl"].ToString().Replace("{0}", morder.o_interface_id.ToString()) + "</NODIFY_URL></ORDER_REQ>"; string timestamp = JMP.TOOL.WeekDateTime.GetMilis;//时间戳 string signstr = timestamp + UserKey + xml.Replace(" ", ""); string sign = JMP.TOOL.MD5.md5strGet(signstr, true).ToLower() + ":" + timestamp;; string url = ConfigurationManager.AppSettings["pfalpayPostUrl"].ToString() + "?sign=" + sign + "&_type=json&busiCode=" + UserId; json = JMP.TOOL.postxmlhelper.postxml(url, xml); JMP.TOOL.CacheHelper.CacheObject(morder.o_code, json, 1);//存入缓存 } else { json = JMP.TOOL.CacheHelper.GetCaChe <string>(morder.o_code); } RootObject obj = new RootObject(); obj = JMP.TOOL.JsonHelper.Deserializes <RootObject>(json); if (obj != null && obj.ORDER_RESP.RESULT.CODE == "SUCCESS") { if (string.IsNullOrEmpty(morder.o_showaddress)) { morder.o_showaddress = ConfigurationManager.AppSettings["succeed"].ToString(); } string chengstr = "<script src=\"http://res.wx.qq.com/open/js/jweixin-1.2.0.js\"></script><script type=\"text/javascript\">function onBridgeReady(){WeixinJSBridge.invoke( 'getBrandWCPayRequest', {\"appId\": \"" + obj.ORDER_RESP.appId + "\", \"timeStamp\": \"" + obj.ORDER_RESP.timeStamp + "\", \"nonceStr\": \"" + obj.ORDER_RESP.nonceStr + "\",\"package\":\"" + obj.ORDER_RESP.packageData + "\",\"signType\": \"MD5\",\"paySign\": \"" + obj.ORDER_RESP.sign + "\" },function(res) {if (res.err_msg ==\"get_brand_wcpay_request:ok\") { window.location.href=\"" + morder.o_showaddress + "\" }else{ alert(res.err_msg) } });}if (typeof WeixinJSBridge == \"undefined\"){if (document.addEventListener){document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);}else if (document.attachEvent){document.attachEvent('WeixinJSBridgeReady', onBridgeReady); document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);} }else{onBridgeReady();}</script> "; Response.Write(chengstr); } else { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("浦发银行公众号支付失败信息:" + json, channelId: oid); str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}"; Response.Write(str); } } else { Response.Write("非法访问!"); } } }
public bool Check() { var str = ""; var bll = new JMP.BLL.jmp_order(); var resHandler = new ClientResponseHandler(); var pay = new PayHttpClient(); var reqHandler = new RequestHandler(null); var cfg = Utils.Load_CfgInterfaceId(Tid); //初始化数据 reqHandler.setGateUrl(cfg["req_url"].ToString()); reqHandler.setKey(cfg["key"].ToString()); reqHandler.setParameter("out_trade_no", new Random().Next(111111, 999999).ToString()); //我们的订单号 reqHandler.setParameter("body", "会员商品"); //商品描述 reqHandler.setParameter("attach", "会员"); //附加信息 reqHandler.setParameter("total_fee", "100"); //价格(已传入的为准,无就从数据库读取) reqHandler.setParameter("mch_create_ip", "127.0.0.1"); //终端IP reqHandler.setParameter("service", "pay.weixin.wappay"); reqHandler.setParameter("mch_id", cfg["mch_id"].ToString()); reqHandler.setParameter("version", cfg["version"].ToString()); reqHandler.setParameter("notify_url", "http://baidu.com"); //回掉地址 reqHandler.setParameter("callback_url", "http://baidu.com"); //同步回掉地址 reqHandler.setParameter("nonce_str", Utils.random()); reqHandler.setParameter("charset", "UTF-8"); reqHandler.setParameter("sign_type", "MD5"); reqHandler.createSign(); var datawft = Utils.toXml(reqHandler.getAllParameters()); var reqContent = new Dictionary <string, string> { { "url", reqHandler.getGateUrl() }, { "data", datawft } }; pay.setReqContent(reqContent); var success = false; if (pay.call()) { resHandler.setContent(pay.getResContent()); resHandler.setKey(cfg["key"].ToString()); var param = resHandler.getAllParameters(); if (resHandler.isTenpaySign()) { if (int.Parse(param["status"].ToString()) == 0) { try { var wxpay = param["pay_info"].ToString(); if (wxpay.Contains("http")) { success = true; } } catch { } } } } return(success); }
/// <summary> /// 微信公众号第二次跳转 /// </summary> /// <param name="Oid">订单id</param> /// <param name="Code">微信回传的Code编码</param> private void TwoJump(int Oid, string Code) { try { String AppId = ""; String AppSecret = ""; String UserId = ""; String UserKey = ""; JMP.MDL.jmp_order morder = new JMP.BLL.jmp_order().SelectOrderGoodsName(Oid, "jmp_order"); WeChatOpenId weChatOpenId = new WeChatOpenId(); String PayStr = weChatOpenId.GetPayStr(morder.o_interface_id.ToString(), "WxGfGZH"); UserId = PayStr.ToString().Split(',')[0]; //商户号 UserKey = PayStr.ToString().Split(',')[1]; //api秘钥 AppId = PayStr.ToString().Split(',')[2]; //微信appid AppSecret = PayStr.ToString().Split(',')[3]; //微信app秘钥 string openid = weChatOpenId.SelectOpendi(AppId, AppSecret, Code); if (!string.IsNullOrEmpty(openid)) { Dictionary <string, string> List = new Dictionary <string, string>(); List.Add("appid", AppId); //微信appid List.Add("mch_id", UserId); //商户号 List.Add("nonce_str", morder.o_code); //随机字符串 List.Add("body", morder.o_goodsname); //商品名称 List.Add("out_trade_no", morder.o_code); //商户订单号 List.Add("total_fee", (Convert.ToInt32(morder.o_price * 100)).ToString()); //支付金额(单位:分) List.Add("spbill_create_ip", HttpContext.Current.Request.UserHostAddress); //ip地址 int overtime = int.Parse(ConfigurationManager.AppSettings["overtime"].ToString()); List.Add("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); //交易起始时间 List.Add("time_expire", DateTime.Now.AddSeconds(overtime).ToString("yyyyMMddHHmmss")); //交易结束时间 List.Add("notify_url", ConfigurationManager.AppSettings["WxTokenUrl"].ToString().Replace("{0}", morder.o_interface_id.ToString())); //异步通知地址 List.Add("trade_type", "JSAPI"); //交易类型 NATIVE 微信扫码 JSAPI公众号 List.Add("openid", openid); //微信openid string signstr = JMP.TOOL.UrlStr.AzGetStr(List) + "&key=" + UserKey; string md5str = JMP.TOOL.MD5.md5strGet(signstr, true).ToUpper(); List.Add("sign", md5str); //签名 string PostXmlStr = JMP.TOOL.xmlhelper.ToXml(List); string url = ConfigurationManager.AppSettings["WxPayUrl"].ToString(); // 请求地址 string Respon = JMP.TOOL.postxmlhelper.postxml(url, PostXmlStr); Dictionary <string, object> dictionary = JMP.TOOL.xmlhelper.FromXml(Respon); if (dictionary.Count > 0 && dictionary["return_code"].ToString() == "SUCCESS" && dictionary["return_msg"].ToString() == "OK") { CallJsApid(Oid, dictionary, UserKey, morder.o_showaddress); } else { string wftzfsbxin = "微信官方公众号支付失败信息,错误信息:" + Respon; PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息openid:" + openid + ":" + wftzfsbxin, summary: "微信官方公众号第二次跳转接口错误信息", channelId: Oid); String str = "{\"Message\":\"支付通道异常\",\"ErrorCode\":104}"; Response.Write(str); } } else { Response.Write("非法访问!"); } } catch (Exception ex) { PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex.Message, summary: "微信官方公众号支付接口错误信息", channelId: Oid); Response.Write("非法访问!"); } }