Exemple #1
0
        /// <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);
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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();
                    }
                }
            }
        }