Exemple #1
0
        /// <summary>
        /// 更新用户第三方余额
        /// </summary>
        /// <param name="usrid"></param>
        /// <returns></returns>
        public ReQueryBalanceBg Querybalance(int usrid)
        {
            M_QueryBalanceBg mbg       = new M_QueryBalanceBg();
            ReQueryBalanceBg retloan   = new ReQueryBalanceBg();
            hx_member_table  mt        = ef.hx_member_table.Where(p => p.registerid == usrid).FirstOrDefault();
            string           UsrCustId = "";

            if (mt != null)
            {
                UsrCustId = mt.UsrCustId;
            }


            if (UsrCustId != null && UsrCustId != "")
            {
                if (UsrCustId.Length > 0)
                {
                    mbg.Version   = "10";
                    mbg.CmdId     = "QueryBalanceBg";
                    mbg.MerCustId = Utils.GetMerCustID();
                    mbg.UsrCustId = UsrCustId;

                    StringBuilder chkVal = new StringBuilder();
                    chkVal.Append(mbg.Version);
                    chkVal.Append(mbg.CmdId);
                    chkVal.Append(mbg.MerCustId);
                    chkVal.Append(mbg.UsrCustId);
                    string chkv = chkVal.ToString();
                    string log  = "更新用户第三方余额";
                    log += "<br>加签chkv字符:" + chkv;

                    //私钥文件的位置(这里是放在了站点的根目录下)
                    string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetMerPr();
                    //需要指定提交字符串的长度
                    int           len        = Encoding.UTF8.GetBytes(chkv).Length;
                    StringBuilder sbChkValue = new StringBuilder(256);
                    //加签
                    int str = DllInterop.SignMsg(Utils.GetMerId(), merKeyFile, chkv, len, sbChkValue);

                    LogInfo.WriteLog("加签字符:" + str.ToString());

                    mbg.ChkValue = sbChkValue.ToString();

                    log += "<br>提交信息:" + FastJSON.toJOSN(mbg);
                    log += "<br>ChkValue:" + mbg.ChkValue;


                    using (var client = new WebClient())
                    {
                        var values = new NameValueCollection();
                        values.Add("Version", mbg.Version);
                        values.Add("CmdId", mbg.CmdId);
                        values.Add("MerCustId", mbg.MerCustId);
                        values.Add("UsrCustId", mbg.UsrCustId);
                        values.Add("ChkValue", mbg.ChkValue);


                        string url = Utils.GetChinapnrUrl();
                        //同步发送form表单请求
                        byte[] result = client.UploadValues(url, "POST", values);
                        var    retStr = Encoding.UTF8.GetString(result);
                        // Response.Write(retStr);

                        LogInfo.WriteLog(retStr);

                        ReQueryBalanceBg reg = new ReQueryBalanceBg();
                        retloan = (ReQueryBalanceBg)FastJSON.ToObject(retStr, reg);


                        StringBuilder builder = new StringBuilder();
                        builder.Append(retloan.CmdId);
                        builder.Append(retloan.RespCode);
                        //builder.Append(retloan.RespDesc);
                        builder.Append(retloan.MerCustId);
                        builder.Append(retloan.UsrCustId);
                        builder.Append(retloan.AvlBal);
                        builder.Append(retloan.AcctBal);
                        builder.Append(retloan.FrzBal);
                        //  builder.Append(retloan.ChkValue);

                        var msg = builder.ToString();

                        log += "<br>返回参数:" + msg;
                        //验签
                        string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();
                        int    ret        = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, retloan.ChkValue);

                        log += "<br>验签ret:" + ret.ToString();
                        if (ret == 0)
                        {
                            if (retloan.RespCode == "000")
                            {
                                B_usercenter bu = new B_usercenter();
                                bu.DataSync(retloan, UsrCustId, 1);


                                //  Response.Write("账户余额:  " + retloan.AcctBal + "<br>");

                                //  Response.Write("可用余额:  " + retloan.AvlBal + "<br>");

                                //   Response.Write("冻结余额:  " + retloan.FrzBal + "<br>");


                                //  AvlBal.Value = retloan.AvlBal;

                                //  FrzBal.Value = retloan.FrzBal;


                                //  string sql = "update  hx_member_table  set  available_balance=" + decimal.Parse(retloan.AvlBal) + " ,frozen_sum=" + decimal.Parse(retloan.FrzBal) + " where  UsrCustId='" + UsrCustId + "'";

                                // DbHelperSQL.RunSql(sql);
                            }
                            else
                            {
                                // Response.Write(HttpUtility.UrlDecode(retloan.RespDesc));
                            }
                        }
                    }
                    LogInfo.WriteLog(log);
                }
            }

            return(retloan);
        }
Exemple #2
0
 /// <summary>
 /// 根据用户客户号获取用户资金信息  ---待重构
 /// </summary>
 /// <param name="UsrCustId">用户汇付客户号</param>
 /// <returns>ReQueryBalanceBg 汇付帐户余额实体对象</returns>
 public static ReQueryBalanceBg QueryBalance(string usrCustId)
 {
     if (usrCustId != null && usrCustId.Length > 0)
     {
         string           strLog = "";
         M_QueryBalanceBg m      = new M_QueryBalanceBg();
         m.Version   = "10";
         m.CmdId     = "QueryBalanceBg";
         m.MerCustId = Utils.GetMerCustID();
         m.UsrCustId = usrCustId;
         StringBuilder chkVal = new StringBuilder();
         chkVal.Append(m.Version);
         chkVal.Append(m.CmdId);
         chkVal.Append(m.MerCustId);
         chkVal.Append(m.UsrCustId);
         string chkv = chkVal.ToString();
         strLog = "后台余额同步:加签chkv字符:" + chkv;
         //私钥文件的位置(这里是放在了站点的根目录下)
         string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetMerPr();
         //需要指定提交字符串的长度
         int           len        = Encoding.UTF8.GetBytes(chkv).Length;
         StringBuilder sbChkValue = new StringBuilder(256);
         //加签
         int str = DllInterop.SignMsg(Utils.GetMerId(), merKeyFile, chkv, len, sbChkValue);
         strLog    += ";加签字符:" + str.ToString();
         m.ChkValue = sbChkValue.ToString();
         strLog    += ";提交信息:" + FastJSON.toJOSN(m);
         strLog    += ";ChkValue:" + m.ChkValue;
         using (var client = new WebClient())
         {
             var values = new NameValueCollection();
             values.Add("Version", m.Version);
             values.Add("CmdId", m.CmdId);
             values.Add("MerCustId", m.MerCustId);
             values.Add("UsrCustId", m.UsrCustId);
             values.Add("ChkValue", m.ChkValue);
             string url = Utils.GetChinapnrUrl();
             //同步发送form表单请求
             byte[] result = client.UploadValues(url, "POST", values);
             var    retStr = Encoding.UTF8.GetString(result);
             // Response.Write(retStr);
             LogInfo.WriteLog(retStr);
             ReQueryBalanceBg reg  = new ReQueryBalanceBg();
             var           retloan = (ReQueryBalanceBg)FastJSON.ToObject(retStr, reg);
             StringBuilder builder = new StringBuilder();
             builder.Append(retloan.CmdId);
             builder.Append(retloan.RespCode);
             //builder.Append(retloan.RespDesc);
             builder.Append(retloan.MerCustId);
             builder.Append(retloan.UsrCustId);
             builder.Append(retloan.AvlBal);
             builder.Append(retloan.AcctBal);
             builder.Append(retloan.FrzBal);
             //  builder.Append(retloan.ChkValue);
             var msg = builder.ToString();
             strLog += ";返回参数:" + msg;
             //验签
             string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();
             int    ret        = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, retloan.ChkValue);
             strLog += ";验签ret:" + ret.ToString();
             LogInfo.WriteLog(strLog);
             if (ret == 0)
             {
                 return(retloan);
             }
         }
     }
     return(null);
 }