Exemple #1
0
        public void delCard(List <M_UsrCardInfolist> orderdetail, ReQueryCardInfo list)
        {
            ArrayList cc = new ArrayList();

            List <hx_UsrBindCardC> ubc = ef.hx_UsrBindCardC.Where(p => p.UsrCustId == list.UsrCustId).ToList();

            foreach (var item in ubc)
            {
                foreach (M_UsrCardInfolist it in orderdetail)
                {
                    if (!item.OpenAcctId.Contains(it.CardId))
                    {
                        cc.Add(item.OpenAcctId);

                        break;
                    }
                }
            }



            foreach (var d in cc)
            {
                ef.hx_UsrBindCardC.Where(p => p.OpenAcctId == d.ToString()).Delete();
            }
        }
        public void delCard(List <M_UsrCardInfolist> orderdetail, ReQueryCardInfo list)
        {
            ArrayList cc = new ArrayList();

            List <hx_UsrBindCardC> ubc = ef.hx_UsrBindCardC.Where(p => p.UsrCustId == list.UsrCustId).ToList();

            //foreach (var item in ubc)
            //{

            //    foreach (M_UsrCardInfolist it in orderdetail)
            //    {

            //        if (!item.OpenAcctId.Contains(it.CardId))
            //        {
            //            cc.Add(item.OpenAcctId);

            //            break;
            //        }
            //    }
            //}
            cc.AddRange(ubc.Where(c => !orderdetail.Select(d => d.CardId).Contains(c.OpenAcctId)).Select(c => c.OpenAcctId).ToArray());


            foreach (var d in cc)
            {
                ef.hx_UsrBindCardC.Where(p => p.OpenAcctId == d.ToString()).Delete();
            }
        }
Exemple #3
0
        private void checkbank(string UsrCustId)
        {
            M_QueryCardInfo m = new M_QueryCardInfo();

            m.Version   = "10";
            m.CmdId     = "QueryCardInfo";
            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();


            //私钥文件的位置(这里是放在了站点的根目录下)
            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);

            //  Response.Write("加签字符:" + str.ToString() + "<br>");

            m.ChkValue = sbChkValue.ToString();

            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);



                ReQueryCardInfo reg = new ReQueryCardInfo();

                JavaScriptSerializer js   = new JavaScriptSerializer();               //实例化一个能够序列化数据的类
                ReQueryCardInfo      list = js.Deserialize <ReQueryCardInfo>(retStr); //将json数据转化为对象类型并赋值给list


                LogInfo.WriteLog("卡查询:" + retStr);

                string RespCode = list.RespCode;

                List <M_UsrCardInfolist> orderdetail = list.UsrCardInfolist;



                StringBuilder builder = new StringBuilder();
                builder.Append(list.CmdId);
                builder.Append(list.RespCode);
                builder.Append(list.MerCustId);
                builder.Append(list.UsrCustId);
                var    msg        = builder.ToString();
                string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();
                int    ret        = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, list.ChkValue);

                if (ret == 0)
                {
                    delCard(orderdetail, list);

                    if (list.RespCode == "000")
                    {
                        string sql = "";



                        for (int i = 0; i < orderdetail.Count; i++)
                        {
                            if (checkcard(orderdetail[i].CardId) <= 0)
                            {
                                int iy = 0;

                                if (orderdetail[i].IsDefault == "Y")
                                {
                                    iy = 1;
                                }



                                sql = "  update hx_member_table   set isbankcard=1  where  UsrCustId='" + orderdetail[i].UsrCustId + "' and  isbankcard=0 ";

                                DbHelperSQL.RunSql(sql);
                                sql = " insert into hx_UsrBindCardC (UsrCustId,OpenAcctId,OpenBankId,defCard)values('" + orderdetail[i].UsrCustId + "','" + orderdetail[i].CardId + "','" + orderdetail[i].BankId + "'," + iy + ")";

                                // Response.Write(sql + "<br>");

                                DbHelperSQL.RunSql(sql);
                                // Response.Write(orderdetail[i].BankId + "  " + orderdetail[i].IsDefault + "  " + orderdetail[i].CardId + "  " + orderdetail[i].UsrCustId + "<br>");
                            }
                            else
                            {
                                //如果卡在

                                if (orderdetail[i].IsDefault == "Y")
                                {
                                    sql = "update hx_UsrBindCardC  set defCard = 0  where UsrCustId = '" + orderdetail[i].UsrCustId + "'";
                                    DbHelperSQL.RunSql(sql);
                                    sql = "update hx_UsrBindCardC  set defCard = 1  where UsrCustId = '" + orderdetail[i].UsrCustId + "' and OpenAcctId = '" + orderdetail[i].CardId + "'";
                                    DbHelperSQL.RunSql(sql);
                                }



                                // Response.Write("没有执行");
                            }
                        }
                    }
                }
            }
        }
Exemple #4
0
        private void QueryCardInfoByHuiFu(string usrCustId)
        {
            M_QueryCardInfo m = new M_QueryCardInfo();

            m.Version   = "10";
            m.CmdId     = "QueryCardInfo";
            m.MerCustId = Settings.Instance.MerCustId;
            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();


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

            //  Response.Write("加签字符:" + str.ToString() + "<br>");

            m.ChkValue = sbChkValue.ToString();

            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 = Settings.Instance.ChinapnrUrl;
                //同步发送form表单请求
                byte[] result = client.UploadValues(url, "POST", values);
                var    retStr = Encoding.UTF8.GetString(result);

                ReQueryCardInfo reg = new ReQueryCardInfo();

                JavaScriptSerializer js   = new JavaScriptSerializer();               //实例化一个能够序列化数据的类
                ReQueryCardInfo      list = js.Deserialize <ReQueryCardInfo>(retStr); //将json数据转化为对象类型并赋值给list

                string RespCode = list.RespCode;

                List <M_UsrCardInfolist> orderdetail = list.UsrCardInfolist;

                StringBuilder builder = new StringBuilder();
                builder.Append(list.CmdId);
                builder.Append(list.RespCode);
                builder.Append(list.MerCustId);
                builder.Append(list.UsrCustId);
                var    msg        = builder.ToString();
                string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Settings.Instance.PgPubk;
                int    ret        = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, list.ChkValue);

                if (ret == 0)
                {
                    var delSql = " delete hx_UsrBindCardC  where UsrCustId = '" + usrCustId + "' ";

                    DbHelper.ExecuteSql(delSql);


                    if (list.RespCode == "000")
                    {
                        string sql = "";
                        if (orderdetail.Count > 0)
                        {
                            sql = "  update hx_member_table set isbankcard=1  where  UsrCustId='" + usrCustId + "' and  isbankcard=0 ";
                            DbHelper.ExecuteSql(sql);
                        }
                        for (int i = 0; i < orderdetail.Count; i++)
                        {
                            int iy = 0;

                            if (orderdetail[i].IsDefault == "Y")
                            {
                                iy = 1;
                            }

                            int bindcartype = 0;

                            if (orderdetail[i].ExpressFlag == "Y")
                            {
                                bindcartype = 1;
                            }

                            sql = " insert into hx_UsrBindCardC (UsrCustId,OpenAcctId,OpenBankId,defCard,BindCardType)values('" + orderdetail[i].UsrCustId + "','" + orderdetail[i].CardId + "','" + orderdetail[i].BankId + "'," + iy + "," + bindcartype + ")";

                            DbHelper.ExecuteSql(sql);
                        }
                    }
                }
            }
        }