public InterBankInterestInfo GetTestSettleInfoCurrent()
        {
            DateTime accountDate = new DateTime(2011, 10, 22);
            int settlecount = 4;//int.Parse(总比数.Text.Trim());
            //int aicount = 2;
            InterBankInterestInfo info = new InterBankInterestInfo();
            InterBankInterestSummaryInfo summaryinfo = new InterBankInterestSummaryInfo();
            summaryinfo.KPSN = ClientUtility.GenerateBatchNO(accountDate);
            summaryinfo.BatchName = string.IsNullOrEmpty(批量名称.Text.Trim()) ? "活期" : 批量名称.Text.Trim();
            summaryinfo.TotalCount = settlecount;

            
            #region 3活期
            double totalInterest3 = 0.0;
            InterBankInterestSettleInfo settinfo3 = new InterBankInterestSettleInfo();
            settinfo3.AccountNO = "201000081387903";//活期
            settinfo3.InterestAccount = "201000081387903";
            settinfo3.RecordDate = accountDate;
            settinfo3.TermFlag = AidTypeDefine.INTER_BANK_BIZ_TERM_TYPE.Current;
            settinfo3.ValueDate = new DateTime(2011, 9, 21);
            DateTime beg3 = new DateTime(2011, 9, 21);
            
            InterBankInterestAIInfo aiinfo3 = new InterBankInterestAIInfo();
            aiinfo3.BeginDate = beg3;
            aiinfo3.EndDate = new DateTime(2011,9, 30);
            aiinfo3.Aggregate = 1000069.50;
            aiinfo3.Rate = 0.02;
            aiinfo3.Interest = Math.Round(aiinfo3.Aggregate * aiinfo3.Rate / 360, 2, MidpointRounding.AwayFromZero);
            totalInterest3 += aiinfo3.Interest;
            settinfo3.AICollection.Add(aiinfo3);

            InterBankInterestAIInfo aiinfo31 = new InterBankInterestAIInfo();
            aiinfo31.BeginDate = new DateTime(2011, 10, 1); 
            aiinfo31.EndDate = new DateTime(2011, 10, 20);
            aiinfo31.Aggregate = 2000139.00 ;
            aiinfo31.Rate = 0.024;
            aiinfo31.Interest = Math.Round(aiinfo31.Aggregate * aiinfo31.Rate / 360, 2, MidpointRounding.AwayFromZero);
            totalInterest3 += aiinfo31.Interest;
            settinfo3.AICollection.Add(aiinfo31);

            settinfo3.Interest = totalInterest3;
            info.SettleCollection.Add(settinfo3);
            #endregion

            #region 4
            double totalInterest4 = 0.0;
            InterBankInterestSettleInfo settinfo4 = new InterBankInterestSettleInfo();
            settinfo4.AccountNO = "201000081388053";//活期
            settinfo4.InterestAccount = "201000081388053";
            settinfo4.RecordDate = accountDate;
            settinfo4.TermFlag = AidTypeDefine.INTER_BANK_BIZ_TERM_TYPE.Current;
            settinfo4.ValueDate = new DateTime(2011, 9, 21);
            DateTime beg4 = new DateTime(2011, 9, 21);
            
            InterBankInterestAIInfo aiinfo4 = new InterBankInterestAIInfo();
            aiinfo4.BeginDate = beg4;
            aiinfo4.EndDate = new DateTime(2011, 9, 30);
            aiinfo4.Aggregate = 1000106.5;
            aiinfo4.Rate = 0.033333;
            aiinfo4.Interest = Math.Round(aiinfo4.Aggregate * aiinfo4.Rate / 360, 2, MidpointRounding.AwayFromZero);
            totalInterest4 += aiinfo4.Interest;
            settinfo4.AICollection.Add(aiinfo4);

            InterBankInterestAIInfo aiinfo41 = new InterBankInterestAIInfo();
            aiinfo41.BeginDate = new DateTime(2011, 10, 1);
            aiinfo41.EndDate = new DateTime(2011, 10, 20);
            aiinfo41.Aggregate = 2000213;
            aiinfo41.Rate = 0.035;
            aiinfo41.Interest = Math.Round(aiinfo41.Aggregate * aiinfo41.Rate / 360, 2, MidpointRounding.AwayFromZero);
            totalInterest4 += aiinfo41.Interest;
            settinfo4.AICollection.Add(aiinfo41);

            settinfo4.Interest = totalInterest4;
            info.SettleCollection.Add(settinfo4);
            #endregion

            #region 5
            double totalInterest5 = 0.0;
            InterBankInterestSettleInfo settinfo5 = new InterBankInterestSettleInfo();
            settinfo5.AccountNO = "201000081389113";//活期
            settinfo5.InterestAccount = "201000081389113";
            settinfo5.RecordDate = accountDate;
            settinfo5.TermFlag = AidTypeDefine.INTER_BANK_BIZ_TERM_TYPE.Current;
            settinfo5.ValueDate = new DateTime(2011, 9, 21);
            DateTime beg5 = new DateTime(2011, 9, 21);

            InterBankInterestAIInfo aiinfo5 = new InterBankInterestAIInfo();
            aiinfo5.BeginDate = beg5;
            aiinfo5.EndDate = new DateTime(2011, 10, 20);
            aiinfo5.Aggregate = 1500000;
            aiinfo5.Rate = 0.0072;
            aiinfo5.Interest = Math.Round(aiinfo5.Aggregate * aiinfo5.Rate / 360, 2, MidpointRounding.AwayFromZero);
            totalInterest5 += aiinfo5.Interest;
            settinfo5.AICollection.Add(aiinfo5);

            settinfo5.Interest = totalInterest5;
            info.SettleCollection.Add(settinfo5);
            #endregion

            #region 6
            double totalInterest6 = 0.0;
            InterBankInterestSettleInfo settinfo6 = new InterBankInterestSettleInfo();
            settinfo6.AccountNO = "201000081389406";//活期
            settinfo6.InterestAccount = "201000081389406";
            settinfo6.RecordDate = accountDate;
            settinfo6.TermFlag = AidTypeDefine.INTER_BANK_BIZ_TERM_TYPE.Current;
            settinfo6.ValueDate = new DateTime(2011, 9, 22);
            DateTime beg6 = new DateTime(2011, 9, 22);

            InterBankInterestAIInfo aiinfo6 = new InterBankInterestAIInfo();
            aiinfo6.BeginDate = beg6;
            aiinfo6.EndDate = new DateTime(2011, 10, 20);
            aiinfo6.Aggregate = 4686029;
            aiinfo6.Rate = 0;
            aiinfo6.Interest = Math.Round(aiinfo6.Aggregate * aiinfo6.Rate / 360, 2, MidpointRounding.AwayFromZero);
            totalInterest6 += aiinfo6.Interest;
            settinfo6.AICollection.Add(aiinfo6);

            settinfo6.Interest = totalInterest6;
            info.SettleCollection.Add(settinfo6);
            #endregion

            summaryinfo.TotalAmount = totalInterest3 + totalInterest4 + totalInterest5 + totalInterest6;
            info.SummaryInfo = summaryinfo;
            return info;
        }
        public InterBankInterestInfo GetTestSettleInfoFix()
        {
            DateTime accountDate = new DateTime(2011, 10, 22);
            int settlecount = 2;//int.Parse(总比数.Text.Trim());
            InterBankInterestInfo info = new InterBankInterestInfo();
            InterBankInterestSummaryInfo summaryinfo = new InterBankInterestSummaryInfo();
            summaryinfo.KPSN = ClientUtility.GenerateBatchNO(accountDate);
            summaryinfo.BatchName = string.IsNullOrEmpty(批量名称.Text.Trim()) ? "定期" : 批量名称.Text.Trim();
            summaryinfo.TotalCount = settlecount;

            #region 1定期
            double totalInterest1 = 0.0;
            InterBankInterestSettleInfo settinfo = new InterBankInterestSettleInfo();
            settinfo.AccountNO = "201000081389961";//活期
            settinfo.InterestAccount = "203000016308272"; //定期
            settinfo.RecordDate = accountDate;
            settinfo.TermFlag = AidTypeDefine.INTER_BANK_BIZ_TERM_TYPE.Fixed;
            settinfo.ValueDate = new DateTime(2011, 10, 20);
            DateTime beg = new DateTime(2011, 10, 20);
            
            InterBankInterestAIInfo aiinfo = new InterBankInterestAIInfo();
            aiinfo.BeginDate = beg;
            aiinfo.EndDate = new DateTime(2011, 10, 21);
            aiinfo.Aggregate = 29000;
            aiinfo.Rate = 0.00522;
            aiinfo.Interest = Math.Round(aiinfo.Aggregate * aiinfo.Rate/360, 2, MidpointRounding.AwayFromZero);
            totalInterest1 += aiinfo.Interest;
            settinfo.AICollection.Add(aiinfo);
            //beg = aiinfo.EndDate.AddDays(1);
            
            settinfo.Interest = totalInterest1;
            info.SettleCollection.Add(settinfo);
            #endregion

            #region 2定期
            double totalInterest2 = 0.0;
            InterBankInterestSettleInfo settinfo2 = new InterBankInterestSettleInfo();
            settinfo2.AccountNO = "201000081388801";//活期
            settinfo2.InterestAccount = "203000016306507";
            settinfo2.RecordDate = accountDate;
            settinfo2.TermFlag = AidTypeDefine.INTER_BANK_BIZ_TERM_TYPE.Fixed;
            settinfo2.ValueDate = new DateTime(2011, 9, 21);
            DateTime beg2 = new DateTime(2011, 04, 15);
            
            InterBankInterestAIInfo aiinfo2 = new InterBankInterestAIInfo();
            aiinfo2.BeginDate = new DateTime(2011, 9, 21);
            aiinfo2.EndDate = new DateTime(2011, 10, 21);
            aiinfo2.Aggregate = 20000;
            aiinfo2.Rate = 0.02;
            aiinfo2.Interest = Math.Round(aiinfo2.Aggregate * aiinfo2.Rate / 360, 2, MidpointRounding.AwayFromZero);
            totalInterest2 += aiinfo2.Interest;
            settinfo2.AICollection.Add(aiinfo2);
            //beg2 = aiinfo2.EndDate.AddDays(1);
            
            settinfo2.Interest = totalInterest2;
            info.SettleCollection.Add(settinfo2);
            #endregion

            summaryinfo.TotalAmount = totalInterest1 + totalInterest2;
            info.SummaryInfo = summaryinfo;
            return info;
        }
 /// <summary>
 /// 同业存放计息
 /// </summary>
 /// <param name="tellerno"></param>
 /// <param name="orgno"></param>
 /// <param name="tradedate"></param>
 /// <param name="info"></param>
 /// <param name="outmsg"></param>
 /// <returns></returns>
 public static RegularResult InterBankSetInterest(String tellerno, String orgno, DateTime tradedate, InterBankInterestInfo info)
 {
     string outmsg = "";
     bool result = ClientSyncHelper.OnSettleInterBank(tellerno, orgno, tradedate, info, out outmsg);
     if (!result)
     {
         outmsg = string.Format("{0}{1}", MsgHandlerEntry.Info_Return_Core, outmsg);
     }
     return new RegularResult(result,outmsg);
 }
        internal static bool OnSettleInterBank(String tellerNO, String orgNO, DateTime tradeDate, InterBankInterestInfo info, out String outmsg)
        {
            outmsg = "";
            
            byte[] codemsg = null;
            bool sent = false;
            string dbexception = "";
            MessageData reqdata = null;
            MessageData recdata = null;
            Guid msgid = Guid.Empty;
            try
            {
                msgid = MsgTransferUtility.InterBankInterestSettle(tellerNO, orgNO, tradeDate, info, ref codemsg);
                reqdata = MsgHandlerEntry.CreateMessageData(msgid, PlatformType.Core, tellerNO, orgNO, (int)MessageBizType.CoreInterBankSettle, codemsg, orgNO);
                recdata = MQMsgHandlerEntry.DeliverMessage(reqdata, codemsg, out sent);

                InterBankInterestData recddata = MsgTransfer.DecodeMsg(recdata.MessageID, recdata.CurrentRespPackage.PackageMessage) as InterBankInterestData;
                if (recddata != null)
                {
                    if (!String.IsNullOrEmpty(recddata.SyserrHandler.Message))
                    {
                        outmsg = recddata.SyserrHandler.Message;
                    }
                    else if (recddata.OmsgHandler.NUM_ENT > 0)
                    {
                        outmsg = MsgHandlerEntry.ExtractOMsg(recddata);
                    }
                    else
                    {
                        return true;
                    }
                }
                else
                {
                    outmsg = MsgHandlerEntry.Type_Convert_Error;
                }
                OnUpdateDBLog(recdata.MessageID, outmsg, MsgLogState.RecvFailed, out dbexception);
                return false;
            }
            catch (Exception ex)
            {
                outmsg = ex.Message;
                OnException(sent, reqdata, recdata, msgid, ex, outmsg);
                if (ex is BizArgumentsException)
                {
                    return false;
                }
                else
                {
                    throw ex;
                }
                //return false;
            }
        }
        /// <summary>
        /// 结息
        /// </summary>
        /// <param name="tellerNO"></param>
        /// <param name="orgNO"></param>
        /// <param name="tradeDate"></param>
        /// <param name="info"></param>
        /// <param name="codemsg"></param>
        /// <returns></returns>
        public static Guid InterBankInterestSettle(String tellerNO, String orgNO, DateTime tradeDate, InterBankInterestInfo info,ref byte[] codemsg)
        {
            InterBankInterestData interestData = new InterBankInterestData();

            interestData.RQhdrHandler.SYS_TXID = "415680"; //
            interestData.RQhdrHandler.TX_OUNO = orgNO;
            interestData.RQhdrHandler.TEL_ID = tellerNO;
            interestData.RQhdrHandler.TX_MODE = "0";
            interestData.RQhdrHandler.TX_DTE = tradeDate.ToString("yyyy-MM-dd");
            interestData.RQhdrHandler.SRV_JNO = CommonDataHelper.SpaceString(12);
            interestData.RQhdrHandler.SRV_REV_JNO = CommonDataHelper.SpaceString(12);
            interestData.RQhdrHandler.HOST_JNO = CommonDataHelper.SpaceString(11);

            if (info != null)
            {
                interestData.SetRQDTL(info.SummaryInfo);
                interestData.SetIBData(info.SettleCollection);
            }

            return MsgTransfer.CodeMsgToMultiBinary(interestData, ref codemsg);
        }