/// <summary> /// 获得数据列表 /// </summary> public List <JMP.MDL.jmp_queuelist> DataTableToList(DataTable dt) { List <JMP.MDL.jmp_queuelist> modelList = new List <JMP.MDL.jmp_queuelist>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { JMP.MDL.jmp_queuelist model; for (int n = 0; n < rowsCount; n++) { model = new JMP.MDL.jmp_queuelist(); if (dt.Rows[n]["q_id"].ToString() != "") { model.q_id = int.Parse(dt.Rows[n]["q_id"].ToString()); } if (dt.Rows[n]["trade_time"].ToString() != "") { model.trade_time = DateTime.Parse(dt.Rows[n]["trade_time"].ToString()); } if (dt.Rows[n]["trade_price"].ToString() != "") { model.trade_price = decimal.Parse(dt.Rows[n]["trade_price"].ToString()); } model.trade_paycode = dt.Rows[n]["trade_paycode"].ToString(); model.trade_code = dt.Rows[n]["trade_code"].ToString(); model.trade_no = dt.Rows[n]["trade_no"].ToString(); model.q_privateinfo = dt.Rows[n]["q_privateinfo"].ToString(); model.q_address = dt.Rows[n]["q_address"].ToString(); model.q_sign = dt.Rows[n]["q_sign"].ToString(); if (dt.Rows[n]["q_noticestate"].ToString() != "") { model.q_noticestate = int.Parse(dt.Rows[n]["q_noticestate"].ToString()); } if (dt.Rows[n]["q_times"].ToString() != "") { model.q_times = int.Parse(dt.Rows[n]["q_times"].ToString()); } if (dt.Rows[n]["q_noticetimes"].ToString() != "") { model.q_noticetimes = DateTime.Parse(dt.Rows[n]["q_noticetimes"].ToString()); } model.q_tablename = dt.Rows[n]["q_tablename"].ToString(); if (dt.Rows[n]["q_o_id"].ToString() != "") { model.q_o_id = int.Parse(dt.Rows[n]["q_o_id"].ToString()); } if (dt.Rows[n]["trade_type"].ToString() != "") { model.trade_type = int.Parse(dt.Rows[n]["trade_type"].ToString()); } if (dt.Rows[n]["q_uersid"].ToString() != "") { model.q_uersid = int.Parse(dt.Rows[n]["q_uersid"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_queuelist model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into jmp_queuelist("); strSql.Append("trade_time,trade_price,trade_paycode,trade_code,trade_no,q_privateinfo,q_uersid,q_address,q_sign,q_noticestate,q_times,q_noticetimes,q_tablename,q_o_id,trade_type"); strSql.Append(") values ("); strSql.Append("@trade_time,@trade_price,@trade_paycode,@trade_code,@trade_no,@q_privateinfo,@q_uersid,@q_address,@q_sign,@q_noticestate,@q_times,@q_noticetimes,@q_tablename,@q_o_id,@trade_type"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@trade_time", SqlDbType.DateTime), new SqlParameter("@trade_price", SqlDbType.Money, 8), new SqlParameter("@trade_paycode", SqlDbType.NVarChar, -1), new SqlParameter("@trade_code", SqlDbType.NVarChar, -1), new SqlParameter("@trade_no", SqlDbType.NVarChar, -1), new SqlParameter("@q_privateinfo", SqlDbType.NVarChar, -1), new SqlParameter("@q_uersid", SqlDbType.Int, 4), new SqlParameter("@q_address", SqlDbType.NVarChar, -1), new SqlParameter("@q_sign", SqlDbType.NVarChar, -1), new SqlParameter("@q_noticestate", SqlDbType.Int, 4), new SqlParameter("@q_times", SqlDbType.Int, 4), new SqlParameter("@q_noticetimes", SqlDbType.DateTime), new SqlParameter("@q_tablename", SqlDbType.NVarChar, -1), new SqlParameter("@q_o_id", SqlDbType.Int, 4), new SqlParameter("@trade_type", SqlDbType.Int, 4) }; parameters[0].Value = model.trade_time; parameters[1].Value = model.trade_price; parameters[2].Value = model.trade_paycode; parameters[3].Value = model.trade_code; parameters[4].Value = model.trade_no; parameters[5].Value = model.q_privateinfo; parameters[6].Value = model.q_uersid; parameters[7].Value = model.q_address; parameters[8].Value = model.q_sign; parameters[9].Value = model.q_noticestate; parameters[10].Value = model.q_times; parameters[11].Value = model.q_noticetimes; parameters[12].Value = model.q_tablename; parameters[13].Value = model.q_o_id; parameters[14].Value = model.trade_type; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 添加到队列通知表 /// </summary> /// <param name="morder">根据订单查询后的moder实体类型</param> /// <param name="orderTableName">订单归档表表名</param> /// <param name="noticestr">传入的字符串</param> /// <returns></returns> private string addqueuelist(JMP.MDL.jmp_order morder, string orderTableName, string tname, string noticestr) { string message = ""; try { int appid = selectUserID(morder.o_app_id, tname, noticestr); if (appid > 0) { 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 = appid; int cg = bllq.Add(quli); if (cg > 0) { message = "ok"; } else { //AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, tname + "通知接口错误", "订单号:" + morder.o_code + "添加到通知队列失败,传入参数:" + noticestr);//写入报错日志 PayNotifyGlobalErrorLogger.Log("订单号:" + morder.o_code + "添加到通知队列失败,传入参数:" + noticestr, summary: tname + "通知接口错误"); message = "error"; } } else { message = "error"; } } catch (Exception ex) { //AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, tname + "通知接口错误", "订单号:" + morder.o_code + "添加到通知队列失败,错误信息:" + ex.ToString() + ",传入参数:" + noticestr);//写入报错日志 PayNotifyGlobalErrorLogger.Log("订单号:" + morder.o_code + "添加到通知队列失败,错误信息:" + ex.ToString() + ",传入参数:" + noticestr, summary: tname + "通知接口错误"); message = "error"; throw; } return(message); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_queuelist model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_queuelist model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_queuelist model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update jmp_queuelist set "); strSql.Append(" trade_time = @trade_time , "); strSql.Append(" trade_price = @trade_price , "); strSql.Append(" trade_paycode = @trade_paycode , "); strSql.Append(" trade_code = @trade_code , "); strSql.Append(" trade_no = @trade_no , "); strSql.Append(" q_privateinfo = @q_privateinfo , "); strSql.Append(" q_uersid = @q_uersid , "); strSql.Append(" q_address = @q_address , "); strSql.Append(" q_sign = @q_sign , "); strSql.Append(" q_noticestate = @q_noticestate , "); strSql.Append(" q_times = @q_times , "); strSql.Append(" q_noticetimes = @q_noticetimes , "); strSql.Append(" q_tablename = @q_tablename , "); strSql.Append(" q_o_id = @q_o_id , "); strSql.Append(" trade_type = @trade_type "); strSql.Append(" where q_id=@q_id "); SqlParameter[] parameters = { new SqlParameter("@q_id", SqlDbType.Int, 4), new SqlParameter("@trade_time", SqlDbType.DateTime), new SqlParameter("@trade_price", SqlDbType.Money, 8), new SqlParameter("@trade_paycode", SqlDbType.NVarChar, -1), new SqlParameter("@trade_code", SqlDbType.NVarChar, -1), new SqlParameter("@trade_no", SqlDbType.NVarChar, -1), new SqlParameter("@q_privateinfo", SqlDbType.NVarChar, -1), new SqlParameter("@q_uersid", SqlDbType.Int, 4), new SqlParameter("@q_address", SqlDbType.NVarChar, -1), new SqlParameter("@q_sign", SqlDbType.NVarChar, -1), new SqlParameter("@q_noticestate", SqlDbType.Int, 4), new SqlParameter("@q_times", SqlDbType.Int, 4), new SqlParameter("@q_noticetimes", SqlDbType.DateTime), new SqlParameter("@q_tablename", SqlDbType.NVarChar, -1), new SqlParameter("@q_o_id", SqlDbType.Int, 4), new SqlParameter("@trade_type", SqlDbType.Int, 4) }; parameters[0].Value = model.q_id; parameters[1].Value = model.trade_time; parameters[2].Value = model.trade_price; parameters[3].Value = model.trade_paycode; parameters[4].Value = model.trade_code; parameters[5].Value = model.trade_no; parameters[6].Value = model.q_privateinfo; parameters[7].Value = model.q_uersid; parameters[8].Value = model.q_address; parameters[9].Value = model.q_sign; parameters[10].Value = model.q_noticestate; parameters[11].Value = model.q_times; parameters[12].Value = model.q_noticetimes; parameters[13].Value = model.q_tablename; parameters[14].Value = model.q_o_id; parameters[15].Value = model.trade_type; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.jmp_queuelist GetModel(int q_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select q_id, trade_time, trade_price, trade_paycode, trade_code, trade_no, q_privateinfo, q_uersid, q_address, q_sign, q_noticestate, q_times, q_noticetimes, q_tablename, q_o_id, trade_type "); strSql.Append(" from jmp_queuelist "); strSql.Append(" where q_id=@q_id"); SqlParameter[] parameters = { new SqlParameter("@q_id", SqlDbType.Int, 4) }; parameters[0].Value = q_id; JMP.MDL.jmp_queuelist model = new JMP.MDL.jmp_queuelist(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["q_id"].ToString() != "") { model.q_id = int.Parse(ds.Tables[0].Rows[0]["q_id"].ToString()); } if (ds.Tables[0].Rows[0]["trade_time"].ToString() != "") { model.trade_time = DateTime.Parse(ds.Tables[0].Rows[0]["trade_time"].ToString()); } if (ds.Tables[0].Rows[0]["trade_price"].ToString() != "") { model.trade_price = decimal.Parse(ds.Tables[0].Rows[0]["trade_price"].ToString()); } model.trade_paycode = ds.Tables[0].Rows[0]["trade_paycode"].ToString(); model.trade_code = ds.Tables[0].Rows[0]["trade_code"].ToString(); model.trade_no = ds.Tables[0].Rows[0]["trade_no"].ToString(); model.q_privateinfo = ds.Tables[0].Rows[0]["q_privateinfo"].ToString(); if (ds.Tables[0].Rows[0]["q_uersid"].ToString() != "") { model.q_uersid = int.Parse(ds.Tables[0].Rows[0]["q_uersid"].ToString()); } model.q_address = ds.Tables[0].Rows[0]["q_address"].ToString(); model.q_sign = ds.Tables[0].Rows[0]["q_sign"].ToString(); if (ds.Tables[0].Rows[0]["q_noticestate"].ToString() != "") { model.q_noticestate = int.Parse(ds.Tables[0].Rows[0]["q_noticestate"].ToString()); } if (ds.Tables[0].Rows[0]["q_times"].ToString() != "") { model.q_times = int.Parse(ds.Tables[0].Rows[0]["q_times"].ToString()); } if (ds.Tables[0].Rows[0]["q_noticetimes"].ToString() != "") { model.q_noticetimes = DateTime.Parse(ds.Tables[0].Rows[0]["q_noticetimes"].ToString()); } model.q_tablename = ds.Tables[0].Rows[0]["q_tablename"].ToString(); if (ds.Tables[0].Rows[0]["q_o_id"].ToString() != "") { model.q_o_id = int.Parse(ds.Tables[0].Rows[0]["q_o_id"].ToString()); } if (ds.Tables[0].Rows[0]["trade_type"].ToString() != "") { model.trade_type = int.Parse(ds.Tables[0].Rows[0]["trade_type"].ToString()); } return(model); } else { return(null); } }
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(); } } } }
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 { AddLocLog.AddLog(1, 4, Request.UserHostAddress, "管理平台手动重发通知失败", "订单号:" + 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)); }