コード例 #1
0
        /// <summary>
        /// 充值汇付后台主动通知
        /// </summary>
        /// <returns></returns>
        public ActionResult ReQPNetSave()
        {
            string str1 = "";

            lock (this)
            {
                Settings.Instance.SetSYSDateTimeFormat();

                ReQPNetSave m = new ReQPNetSave();

                m.CmdId      = DNTRequest.GetString("CmdId");
                m.RespCode   = DNTRequest.GetString("RespCode");
                m.RespDesc   = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc"));
                m.MerCustId  = DNTRequest.GetString("MerCustId");
                m.UsrCustId  = DNTRequest.GetString("UsrCustId");
                m.OrdId      = DNTRequest.GetString("OrdId");
                m.OrdDate    = DNTRequest.GetString("OrdDate");
                m.TransAmt   = DNTRequest.GetString("TransAmt");
                m.TrxId      = DNTRequest.GetString("TrxId");
                m.GateBusiId = DNTRequest.GetString("GateBusiId");
                m.GateBankId = DNTRequest.GetString("GateBankId");
                m.FeeAmt     = DNTRequest.GetString("FeeAmt");
                m.FeeCustId  = DNTRequest.GetString("FeeCustId");
                m.FeeAcctId  = DNTRequest.GetString("FeeAcctId");
                m.RetUrl     = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl"));
                m.BgRetUrl   = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl"));
                m.CardId     = DNTRequest.GetString("CardId");
                m.MerPriv    = HttpUtility.UrlDecode(DNTRequest.GetString("MerPriv"));
                // m.MerPriv = DESEncrypt.Decrypt(DNTRequest.GetString("MerPriv"), ConfigurationManager.AppSettings["webp"].ToString());
                m.ChkValue = DNTRequest.GetString("ChkValue");

                StringBuilder chkVal = new StringBuilder();
                chkVal.Append(m.CmdId);
                chkVal.Append(m.RespCode);
                chkVal.Append(m.MerCustId);
                chkVal.Append(m.UsrCustId);
                chkVal.Append(m.OrdId);
                chkVal.Append(m.OrdDate);
                chkVal.Append(m.TransAmt);
                chkVal.Append(m.TrxId);
                chkVal.Append(m.RetUrl);
                chkVal.Append(m.BgRetUrl);
                chkVal.Append(m.MerPriv);
                string msg = chkVal.ToString();

                //私钥文件的位置(这里是放在了站点的根目录下)
                string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Settings.Instance.PgPubk;
                //需要指定提交字符串的长度
                int           len        = Encoding.UTF8.GetBytes(msg).Length;
                StringBuilder sbChkValue = new StringBuilder(256);
                int           ret        = DllInterop.VeriSignMsg(merKeyFile, msg, msg.Length, m.ChkValue);
                // Response.Write("验签:" + ret.ToString());
                LoggerHelper.Info("快充接口后台验签:ret=" + ret.ToString() + " RespCode:" + m.RespCode + m.RespDesc);

                LoggerHelper.Info("快充接口后台充值返回报文:" + JsonHelper.Entity2Json(m));
                StringBuilder str = new StringBuilder();
                string        sql = "";

                if (ret == 0)
                {
                    if (m.RespCode == "000")
                    {
                        string   MerPrivTemp = EncryptHelper.Decrypt(m.MerPriv, Settings.Instance.WebPass);
                        string[] arr         = Settings.Instance.SplitString(MerPrivTemp, "_"); //第一位是用户id 二是 记录id
                        int      userid      = int.Parse(arr[0]);
                        int      reid        = int.Parse(arr[1]);
                        string   cachename   = m.OrdId + userid.ToString() + reid.ToString();

                        if (Settings.Instance.GeTThirdCache(cachename) == 0)
                        {
                            Settings.Instance.SetThirdCache(cachename);
                            sql = "select recharge_condition  from hx_Recharge_history where recharge_condition=0  and recharge_history_id=" + reid + " and order_No='" + m.OrdId + "'";
                            DataTable dtr = DbHelper.Query(sql).Tables[0];
                            if (dtr.Rows.Count > 0)
                            {
                                LoggerHelper.Info("快充接口后台充值数据没有写入情况下操作>>>>>>>>>>>>>>>>>>>>>>>");
                                M_Recharge_history      rh = new M_Recharge_history();
                                M_Capital_account_water aw = new M_Capital_account_water();
                                B_member_table          o  = new B_member_table();
                                M_member_table          p  = new M_member_table();
                                p = o.GetModel(userid);
                                rh.membertable_registerid = userid;
                                rh.recharge_amount        = decimal.Parse(m.TransAmt);
                                rh.recharge_time          = DateTime.Now;
                                rh.account_amount         = decimal.Parse(m.TransAmt);
                                rh.order_No               = m.OrdId;
                                rh.recharge_condition     = 1;            //1表示充值成功
                                rh.recharge_bank          = m.GateBankId; // 得接口返回;
                                rh.recharge_history_id    = reid;         //本值提交里存的充值id
                                aw.membertable_registerid = userid;
                                aw.income             = decimal.Parse(m.TransAmt);
                                aw.expenditure        = 0.00M;
                                aw.time_of_occurrence = rh.recharge_time;
                                aw.account_balance    = p.available_balance + aw.income; //要得么帐户余额
                                aw.types_Finance      = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.充值.ToString());
                                aw.createtime         = DateTime.Now;
                                aw.keyid   = 0;
                                aw.remarks = m.OrdId;
                                B_usercenter BUC    = new B_usercenter();
                                int          bucrec = BUC.rechargeTran(rh, aw);
                                LoggerHelper.Info("后台充值事务操作返回码小于=0 操作失败:" + bucrec.ToString());
                                if (m.GateBusiId == "QP")
                                {
                                    sql = "select UsrBindCardID from hx_UsrBindCardC where UsrCustId='" + m.UsrCustId + "' and OpenAcctId='" + m.CardId + "'";
                                    DataTable dt = DbHelper.Query(sql).Tables[0];
                                    if (dt.Rows.Count > 0)
                                    {
                                    }
                                    else
                                    {
                                        sql = "INSERT INTO hx_UsrBindCardC (UsrCustId,OpenAcctId,OpenBankId,defCard) VALUES ('" + m.UsrCustId + "','" + m.CardId + "','" + m.GateBankId + "',1)";
                                        DbHelper.Query(sql);
                                        sql = "update hx_member_table set  isbankcard=1 where registerid=" + userid.ToString();
                                        DbHelper.Query(sql);
                                    }
                                }
                            }
                        }
                        str1 = "RECV_ORD_ID_" + m.TrxId;
                    }
                }
            }
            return(Content(str1));
        }