Пример #1
0
        /// <summary>
        /// 根据应用id查询所属用户
        /// </summary>
        /// <param name="APPID">应用id</param>
        /// <param name="tname">接口名称</param>
        /// <param name="noticestr">传入的字符串</param>
        /// <returns></returns>
        private int selectUserID(int APPID, string tname, string noticestr)
        {
            int aid = 0;

            try
            {
                JMP.MDL.jmp_app app      = new JMP.MDL.jmp_app();
                JMP.BLL.jmp_app appbll   = new JMP.BLL.jmp_app();
                string          notfrurl = "notfrurl" + APPID;//缓存名称
                //判读是否存在缓存
                if (JMP.TOOL.CacheHelper.IsCache(notfrurl))
                {
                    app = JMP.TOOL.CacheHelper.GetCaChe <JMP.MDL.jmp_app>(notfrurl);//获取缓存
                    if (app != null)
                    {
                        aid = app.u_id;
                    }
                }
                else
                {
                    app = appbll.SelectId(APPID);
                    if (app != null)
                    {
                        aid = app.u_id;
                        JMP.TOOL.CacheHelper.CacheObjectLocak <JMP.MDL.jmp_app>(app, notfrurl, 5);//存入缓存
                    }
                    else
                    {
                        //AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, tname + "通知接口错误", "应用id:" + APPID + ",获取用户id失败!获取的参数:" + noticestr);//写入报错日志
                        PayNotifyGlobalErrorLogger.Log("应用id:" + APPID + ",获取用户id失败!获取的参数:" + noticestr, summary: tname + "通知接口错误");
                    }
                }
            }
            catch (Exception ex)
            {
                // AddLocLog.AddLog(1, 4, HttpContext.Current.Request.UserHostAddress, tname + "通知接口错误", "查询用户id失败,报错信息:" + ex.ToString() + ",获取的参数:" + noticestr);//写入报错日志
                PayNotifyGlobalErrorLogger.Log("查询用户id失败,报错信息:" + ex.ToString() + ",获取的参数:" + noticestr, summary: tname + "通知接口错误");
            }
            return(aid);
        }
Пример #2
0
        public ActionResult UpdateApp()
        {
            int appid = string.IsNullOrEmpty(Request["appid"]) ? 0 : Int32.Parse(Request["appid"]);

            JMP.BLL.jmp_app appbll = new JMP.BLL.jmp_app();
            JMP.MDL.jmp_app model  = new JMP.MDL.jmp_app();

            string yy = "";

            if (appid > 0)
            {
                model = appbll.SelectId(appid);
                #region =========获取应用平台在用信息=========
                JMP.BLL.jmp_platform        bll  = new JMP.BLL.jmp_platform();
                DataTable                   dt   = bll.GetList(" 1=1 and p_state='1' ").Tables[0];//获取应用平台在用信息
                List <JMP.MDL.jmp_platform> yypt = JMP.TOOL.MdlList.ToList <JMP.MDL.jmp_platform>(dt);
                ViewBag.glptdt = yypt;
                #endregion

                #region ========获取应用类型在用信息======
                JMP.BLL.jmp_apptype yybll = new JMP.BLL.jmp_apptype();
                string where = "  t_id in (select  DISTINCT(t_topid) from jmp_apptype where t_topid in( select t_id from jmp_apptype where t_topid='0'   )) and t_state='1' order by t_sort desc";
                DataTable           yydt   = yybll.GetList(where).Tables[0];//获取应用类型在用信息
                JMP.MDL.jmp_apptype models = new JMP.MDL.jmp_apptype();
                int t_topid = 0;
                if (model.a_apptype_id > 0)
                {
                    models  = yybll.GetModel(model.a_apptype_id);//查询单条信息
                    t_topid = models.t_topid;
                }
                string yyid = "";

                if (model.a_auditstate == 1)
                {
                    yy += "<select id='xzyylx' disabled ='disabled' > ";
                }
                else
                {
                    yy += "<select id='xzyylx' onclick='xzyylx()'> ";
                }

                for (int j = 0; j < yydt.Rows.Count; j++)
                {
                    yyid = yydt.Rows[j]["t_id"].ToString();
                    if (t_topid > 0)
                    {
                        if (Int32.Parse(yydt.Rows[j]["t_id"].ToString()) == models.t_topid)
                        {
                            yy += "<option value='" + yyid + "' selected=selected >" + yydt.Rows[j]["t_name"] + "</option>";
                        }
                        else
                        {
                            yy += "<option value='" + yyid + "' >" + yydt.Rows[j]["t_name"] + "</option>";
                        }
                    }
                    else
                    {
                        yy += "<option value='" + yyid + "' >" + yydt.Rows[j]["t_name"] + "</option>";
                    }
                }

                yy += "</select>";
                #endregion
            }
            int userid   = UserInfo.UserId;
            var userlist = _UserService.FindListBySql("relation_type='" + (int)Relationtype.Agent + "' and relation_person_id='" + userid + "' and u_state=1", "");

            ViewBag.userlist = userlist;

            #region 获取所有支付方式

            JMP.BLL.jmp_paymode zfbll = new JMP.BLL.jmp_paymode();

            DataTable zfdt = new DataTable();
            List <JMP.MDL.jmp_paymode> zflist = new List <JMP.MDL.jmp_paymode>();
            zfdt          = zfbll.GetList(" 1=1 and p_state='1' ").Tables[0];//获取支付类型在用信息
            zflist        = JMP.TOOL.MdlList.ToList <JMP.MDL.jmp_paymode>(zfdt);
            ViewBag.appid = appid;
            ViewBag.list  = zflist;
            #endregion

            ViewBag.yy    = yy;
            ViewBag.model = model;
            //支付方式
            string[] zffs = model.a_paymode_id.Split(',');
            ViewBag.zffs = zffs;
            return(View());
        }
Пример #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();
                    }
                }
            }
        }