예제 #1
0
        /// <summary>
        /// 签约华夏银行,开户他行,入金登记
        /// </summary>
        /// <param name="remit">汇款信息</param>
        /// <param name="FdInfo">资金信息</param>
        /// <param name="codeDesc">入金登记结果代码描述</param>
        /// <returns>成功返回true 失败返回fasle</returns>
        public static bool RuJinDengJiHuaxiaBank(RemitInfo remit, Fundinfo FdInfo, ref string codeDesc)
        {
            bool IsSuc = false;
            IntersServerImplClient ic = new IntersServerImplClient();
            try
            {
                string MerAccountNo = GetTanUser(FdInfo.TanUser);
                StringBuilder inXml = new StringBuilder();
                inXml.Append("<HXBB2B>");
                inXml.Append("<MessageData>");

                inXml.Append("<Base>");
                inXml.Append("<Version>1.0</Version>");
                inXml.Append("<SignFlag>0</SignFlag>");
                inXml.Append("<Language>GB2312</Language>");
                inXml.Append("</Base>");

                inXml.Append("<ReqHeader>");
                inXml.AppendFormat("<ClientTime>{0}</ClientTime>", DateTime.Now.ToString("yyyyMMddHHmmss"));
                inXml.Append("<MerchantNo>600014</MerchantNo>");
                inXml.Append("</ReqHeader>");

                inXml.Append("<DataBody>");
                inXml.AppendFormat("<MerTxSerNo>{0}</MerTxSerNo>", FdInfo.CashUser);
                inXml.Append("<TrnxCode>DZ022</TrnxCode>");
                inXml.AppendFormat("<AccountNo>{0}</AccountNo>", FdInfo.SubUser);
                inXml.AppendFormat("<MerAccountNo>{0}</MerAccountNo>", MerAccountNo);
                inXml.AppendFormat("<Amt>{0}</Amt>", remit.Money);
                inXml.AppendFormat("<InOutStart>{0}</InOutStart>", remit.RemitType);
                inXml.AppendFormat("<PersonName>{0}</PersonName>", remit.RemitName);
                inXml.AppendFormat("<AmoutDate>{0}</AmoutDate>", remit.RemitTime);
                inXml.AppendFormat("<BankName>{0}</BankName>", remit.RemitBank);
                inXml.AppendFormat("<OutAccount>{0}</OutAccount>", remit.RemitAccount);
                inXml.Append("</DataBody>");

                inXml.Append("</MessageData>");
                inXml.Append("</HXBB2B>");
                com.individual.helper.LogNet4.WriteMsg("华夏银行入金登记,请求的Xml报文:" + inXml.ToString());
                string outXml = ic.Process(inXml.ToString());
                com.individual.helper.LogNet4.WriteMsg("华夏银行入金登记,响应的Xml报文:" + outXml);
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.LoadXml(outXml);
                if (HuaxiaSuc == xmldoc.SelectSingleNode("HXBB2B/MessageData/ResHeader/Status/Code").InnerText)
                {
                    IsSuc = true;
                }
                codeDesc = xmldoc.SelectSingleNode("HXBB2B/MessageData/ResHeader/Status/Message").InnerText;
                ic.Close();
            }
            catch (Exception ex)
            {
                ic.Abort();
                throw new Exception(ex.Message, ex);
            }

            return IsSuc;
        }
예제 #2
0
        /// <summary>
        /// 用户出入金
        /// </summary>
        /// <param name="remit">出入金信息</param>
        /// <returns>出入金结果</returns>
        public ResultDesc HuaXiaRemitMoney(RemitInfo remit)
        {
            //ReasonType字段说明:(该接口取4,5)
            //0----入金(金商或管理员操作);
            //1----出金(金商或管理员操作);
            //2----订单操作
            //3----库存结算(金商或管理员操作);
            //4----银行入金 (用户操作);
            //5----银行出金 (用户操作)
            //6----金额调整(金商或管理员操作)
            //7----在线回购(用户操作);
            //8----其他费用;

            ResultDesc rsdc = new ResultDesc();
            string userid = remit.userid; //用户ID
            string operUser = string.Empty; //操作人
            bool IsOpenOtherBank = false;//他行开户 入金 只做入金登记
            try
            {
                #region 判断用户ID是否为空

                if (string.IsNullOrEmpty(userid))
                {
                    rsdc.Result = false;
                    rsdc.Desc = "用户ID不能为空";
                    return rsdc;
                }
                #endregion

                if (remit.ReasonType != 4 && remit.ReasonType != 5)
                {
                    rsdc.Result = false;
                    rsdc.Desc = "原因类型错误";
                    return rsdc;
                }

                operUser = ComFunction.GetTradeAccount(userid);
                if (Math.Abs(remit.Money) <= ComFunction.dzero)
                {
                    rsdc.Result = false;
                    rsdc.Desc = "金额不能为0";
                    return rsdc;
                }

                if (5 == remit.ReasonType && remit.Money > ComFunction.dzero) //出金时,金额为负数
                {
                    remit.Money = -remit.Money;
                }
                //获取现有资金信息 ConBankType='1'表示签约行是华夏银行
                Fundinfo Fdinfo = ComFunction.GetFdinfo(string.Format("select * from Trade_FundInfo where userid='{0}' and state='2' and ConBankType='1'", userid));
                if (string.IsNullOrEmpty(Fdinfo.CashUser))
                {
                    rsdc.Result = false;
                    rsdc.Desc = "未签约银行,不能出入金";
                    return rsdc;
                }
                #region 出入金操作
                string codeDesc = string.Empty;
                if (4 == remit.ReasonType) //入金,走银行接口
                {
                    if ("1" == Fdinfo.ConBankType) //华夏银行入金
                    {
                        if (Fdinfo.SameBank)
                        {
                            if (!ComFunction.RuJinHuaxiaBank(Fdinfo, Math.Abs(remit.Money), remit.PasswordChar, ref codeDesc))
                            {
                                rsdc.Result = false;
                                rsdc.Desc = string.Format("签约华夏银行,开户华夏银行,入金失败,华夏银行返回信息:{0}", codeDesc);
                                return rsdc;
                            }
                        }
                        else //入金登记
                        {
                            if (!ComFunction.RuJinDengJiHuaxiaBank(remit, Fdinfo, ref codeDesc))
                            {
                                rsdc.Result = false;
                                rsdc.Desc = string.Format("签约华夏银行,开户他行,入金登记失败,华夏银行返回信息:{0}", codeDesc);
                                return rsdc;
                            }
                            IsOpenOtherBank = true;
                        }
                    }
                    else
                    {
                        rsdc.Result = false;
                        rsdc.Desc = "签约银行不是华夏银行";
                        return rsdc;
                    }

                }
                else if (5 == remit.ReasonType) //出金,走银行接口
                {
                    //判断用户是否存在有效订单 有效挂单 ,如果存在不允许出金
                    if (ComFunction.UserExistOrderAndHoldOrder(userid))
                    {
                        rsdc.Result = false;
                        rsdc.Desc = "用户存在有效订单或挂单,不能出金";
                        return rsdc;
                    }
                    //判断出金金额是否小于等于帐户结余
                    if (!(Math.Abs(remit.Money) - Fdinfo.Money <= ComFunction.dzero))
                    {
                        rsdc.Result = false;
                        rsdc.Desc = "金额大于帐户结余,不能出金";
                        return rsdc;
                    }
                    if ("1" == Fdinfo.ConBankType) //华夏银行出金,可以立即出金,可能不会实时到帐
                    {
                        if (!ComFunction.ChuJinHuaxiaBank(Fdinfo, Math.Abs(remit.Money), ref codeDesc))
                        {
                            rsdc.Result = false;
                            rsdc.Desc = string.Format("华夏银行出金失败,华夏银行返回信息:{0}", codeDesc);
                            return rsdc;
                        }
                    }
                    else
                    {
                        rsdc.Result = false;
                        rsdc.Desc = "签约银行不是华夏银行";
                        return rsdc;
                    }
                }

                #endregion

                #region 数据库事务处理
                if (!IsOpenOtherBank) // 开户行不是其他银行 而是华夏银行时 需要执行
                {
                    //SQL语句
                    List<string> sqlList = new List<string>();
                    string sql1 = string.Format("update Trade_FundInfo set money=money+{0} where userid='{1}' and [state]<>'4' and tanuser={2} and subuser='******'", remit.Money, userid, Fdinfo.TanUser, Fdinfo.SubUser);
                    //调整资金sql语句
                    sqlList.Add(sql1);

                    string sql2 = string.Format("insert into Fund_Change([userId],[reason],[Oldvalue],[NewValue],[OperUser],[OperTime],[RelaOrder],[ChangeValue],[CashUser]) values('{0}','{1}',{2},{3},'{4}','{5}','{6}',{7},'{8}')", userid, remit.ReasonType, Fdinfo.Money, Fdinfo.Money + remit.Money, operUser, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), string.Empty, remit.Money, Fdinfo.CashUser);
                    //添加资金变动记录sql语句
                    sqlList.Add(sql2);

                    if (!ComFunction.SqlTransaction(sqlList))
                    {
                        LogNet4.WriteMsg(string.Format("华夏银行出入金成功,但是SQL语句执行失败,SQL语句是:{0}\n{1}", sql1, sql2));
                    }
                }
                else
                {
                    List<string> SqlList = new List<string>();
                    DateTime dt = DateTime.Now;
                    string insertsql = string.Format("insert into Trade_InMoneyApply([Dtime],[applyid],[MerTxSerNo],[TrnxCode],[AccountNo],[MerAccountNo],[Amt],[InOutStart],[PersonName],[AmoutDate],[BankName],[OutAccount],[state]) values('{0}','{1}','{2}','{3}','{4}','{5}',{6},'{7}','{8}','{9}','{10}','{11}','{12}')",
                        dt.ToString("yyyy-MM-dd HH:mm:ss"),dt.ToString("yyyyMMddHHmmssfff"), Fdinfo.CashUser, "DZ022", Fdinfo.SubUser, Fdinfo.TanUser, remit.Money, remit.RemitType, remit.RemitName,
                        remit.RemitTime, remit.RemitBank, remit.RemitAccount,"2");
                    SqlList.Add(insertsql);
                    if (!ComFunction.SqlTransaction(SqlList))
                    {
                        LogNet4.WriteMsg(string.Format("华夏银行,入金登记申请成功,但是SQL语句执行失败,SQL语句是:{0}", insertsql));
                    }
                }
                rsdc.Result = true;
                rsdc.Desc = (4 == remit.ReasonType) ? "入金成功" : "出金成功";
                #endregion
            }
            catch (Exception ex)
            {
                ComFunction.WriteErr(ex);

                rsdc.Result = false;
                rsdc.Desc = (4 == remit.ReasonType) ? "入金失败" : "出金失败";
            }
            return rsdc;
        }