Esempio n. 1
0
def getTransTrcAK(SNDBNKCO,TRCDAT,TRCNO,trc_dict):
    AfaLoggerFunc.tradeInfo( ">>>开始查询汇兑业务登记簿[" + SNDBNKCO + "][" + TRCDAT + "][" + TRCNO + "]交易信息" )
    
    #===========组织查询条件====================================================
    trcbka_where_dict = {'SNDBNKCO':SNDBNKCO,'TRCDAT':TRCDAT,'TRCNO':TRCNO}

    #===========查询汇兑登记簿相关业务信息======================================
    trcbka_dict = rccpsDBTrcc_trcbka.selectu(trcbka_where_dict)
    
    if trcbka_dict == None:
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow( 'S999', '获取汇兑业务详细信息异常' )
    
    if len(trcbka_dict) <= 0:
        return AfaFlowControl.ExitThisFlow( 'S999', '汇兑业务登记簿中无此汇兑业务详细信息' )
        
    AfaLoggerFunc.tradeInfo( ">>>结束查询汇兑业务登记簿[" + SNDBNKCO + "][" + TRCDAT + "][" + TRCNO + "]交易信息" )

    #==========将查询出的汇兑登记簿相关业务信息赋值到输出字典===================
    if not rccpsMap0000Dtrcbka2Dtrc_dict.map(trcbka_dict,trc_dict):
        return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的汇兑登记簿相关业务信息赋值到输出字典异常' )

    BJEDTE = trcbka_dict["BJEDTE"]
    BSPSQN = trcbka_dict["BSPSQN"]
    
    #==========查询当前业务状态=================================================
    AfaLoggerFunc.tradeInfo( ">>>开始查询交易[" + BJEDTE + "][" + BSPSQN + "]当前状态" )
    
    stat_dict = {}
    if not rccpsState.getTransStateCur(BJEDTE,BSPSQN,stat_dict):
        return False
    
    AfaLoggerFunc.tradeInfo( ">>>结束查询交易[" + BJEDTE + "][" + BSPSQN + "]当前状态" )

    #==========将查询出的业务状态详细信息赋值到输出字典=========================
    if not rccpsMap0000Dstat_dict2Dtrc_dict.map(stat_dict,trc_dict):
        return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的业务状态详细信息赋值到输出字典异常' )
    
    AfaLoggerFunc.tradeInfo( ">>>结束查询汇兑业务登记簿[" + BJEDTE + "][" + BSPSQN + "]交易信息" )
    return True
Esempio n. 2
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作(1.本地操作)交易[TRC001_8554]进入***' )
    
    ##===张恒增加于20091230==== 
    trcbka_where_dict1={}
    trcbka_where_dict1 = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN}            
 
    #==========查询汇兑登记簿相关业务信息=======================================
    trcbka_dict = rccpsDBTrcc_trcbka.selectu(trcbka_where_dict1)  
    
    if trcbka_dict == None:
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow( 'S999', '查询汇兑业务登记簿交易信息异常' )
        
    if len(trcbka_dict) <= 0:
        return AfaFlowControl.ExitThisFlow( 'S999', '汇兑业务登记簿中无此交易信息' )
    if trcbka_dict['BESBNO'] != TradeContext.BESBNO :
        return AfaFlowControl.ExitThisFlow( 'S999', '非本机构业务!' )
    ##====end=================
    
    #=====查询汇兑单笔信息====
    trcbka = {}
    bka = rccpsDBFunc.getTransTrc(TradeContext.BJEDTE,TradeContext.BSPSQN,trcbka)
    if bka == False:
        return  AfaFlowControl.ExitThisFlow('M999','查询单笔信息失败') 
    else:
        AfaLoggerFunc.tradeInfo( '>>>查询成功' )
        #=====字典赋值到TradeContext====
        rccpsMap8554Dtrcbka2CTradeContext.map(trcbka)
        
    TradeContext.OCCAMT    = str(trcbka['OCCAMT'])              #金额
    TradeContext.LOCCUSCHRG    = str(trcbka['LOCCUSCHRG'])      #手续费金额 增加于20091228  张恒
    
    TradeContext.errorCode = '0000'
    TradeContext.errorMsg  = '查询成功'

    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作(1.本地操作)交易[TRC001_8554]退出***' )
    return True
Esempio n. 3
0
def getTransTrc(BJEDTE,BSPSQN,trc_dict):
    AfaLoggerFunc.tradeInfo( ">>>开始查询汇兑业务登记簿[" + BJEDTE + "][" + BSPSQN + "]交易信息" )
                                                                     
    #==========组织查询条件=====================================================
    trcbka_where_dict = {'BJEDTE':BJEDTE,'BSPSQN':BSPSQN}            
                                                                     
    #==========查询汇兑登记簿相关业务信息=======================================
    trcbka_dict = rccpsDBTrcc_trcbka.selectu(trcbka_where_dict)  
    
    if trcbka_dict == None:
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow( 'S999', '查询汇兑业务登记簿交易信息异常' )
        
    if len(trcbka_dict) <= 0:
        return AfaFlowControl.ExitThisFlow( 'S999', '汇兑业务登记簿中无此交易信息' )
    
    #==========将查询出的汇兑登记簿相关业务信息赋值到输出字典===================
    if not rccpsMap0000Dtrcbka2Dtrc_dict.map(trcbka_dict,trc_dict):
        return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的汇兑登记簿相关业务信息赋值到输出字典异常' )
        
    #==========查询当前业务状态=================================================
    AfaLoggerFunc.tradeInfo( ">>>开始查询交易[" + BJEDTE + "][" + BSPSQN + "]当前状态" )
    
    stat_dict = {}
    
    if not rccpsState.getTransStateCur(BJEDTE,BSPSQN,stat_dict):
        return False
        
    AfaLoggerFunc.tradeInfo( ">>>结束查询交易[" + BJEDTE + "][" + BSPSQN + "]当前状态" )

    #==========将查询出的业务状态详细信息赋值到输出字典=========================
    if not rccpsMap0000Dstat_dict2Dtrc_dict.map(stat_dict,trc_dict):
        return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的业务状态详细信息赋值到输出字典异常' )
    
    AfaLoggerFunc.tradeInfo( ">>>结束查询汇兑业务登记簿[" + BJEDTE + "][" + BSPSQN + "]交易信息" )
    return True
Esempio n. 4
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( "====开始汇兑退汇来账接收处理====" )

    #=====判断是否重复交易====
    sel_dict = {'TRCNO':TradeContext.TRCNO,'TRCDAT':TradeContext.TRCDAT,'SNDBNKCO':TradeContext.SNDBNKCO}
    record = rccpsDBTrcc_trcbka.selectu(sel_dict)
    
    if record == None:
        return AfaFlowControl.ExitThisFlow('S999','判断是否重复报文,查询汇兑业务登记簿相同报文异常')
    elif len(record) > 0:
        AfaLoggerFunc.tradeInfo('汇兑业务登记簿中存在相同数据,重复报文,进入下一流程')
        #=====为通讯回执报文赋值====
        out_context_dict = {}
        out_context_dict['sysType']  = 'rccpst'
        out_context_dict['TRCCO']    = '9900503'
        out_context_dict['MSGTYPCO'] = 'SET008'
        out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
        out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
        out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
        out_context_dict['SNDCLKNO'] = TradeContext.BETELR
        out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
        out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
        out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
        out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
        out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
        out_context_dict['OPRTYPNO'] = '99'
        out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
        out_context_dict['TRANTYP']  = '0'
        out_context_dict['ORTRCCO']  = TradeContext.TRCCO
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '重复报文'

        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)

        #=====发送afe====
        AfaAfeFunc.CommAfe()

        return AfaFlowControl.ExitThisFlow('S999','重复报文,退出处理流程')

    AfaLoggerFunc.tradeInfo(">>>结束判断是否重复报文")

    #=====币种转换====
    if TradeContext.CUR == 'CNY':
        TradeContext.CUR  = '01'

    #===================查询原交易信息=========================================
    AfaLoggerFunc.tradeInfo(">>>开始查询原交易信息")
    
    ortrc_dict = {}
    if not rccpsDBFunc.getTransTrcAK(TradeContext.ORSNDBNK,TradeContext.ORTRCDAT,TradeContext.ORTRCNO,ortrc_dict):
        AfaLoggerFunc.tradeInfo("未找到原交易信息")
        TradeContext.BOJEDT = ""
        TradeContext.BOSPSQ = ""
    else:
        TradeContext.BOJEDT = ortrc_dict['BJEDTE']
        TradeContext.BOSPSQ = ortrc_dict['BSPSQN']
        #=====刘雨龙 2008-09-17 增加业务类型====
        TradeContext.OPRATTNO  = ortrc_dict['OPRATTNO']
    
    AfaLoggerFunc.tradeInfo(">>>结束查询原交易信息")
    
    #====开始向字典赋值====
    trcbka_dict = {}
    if not rccpsMap1101CTradeContext2Dtrcbka_dict.map(trcbka_dict):
        return AfaFlowControl.ExitThisFlow('M999', '字典赋值出错')

    trcbka_dict['DCFLG'] = PL_DCFLG_CRE                  #借贷标识
    trcbka_dict['OPRNO'] = '09'                          #业务属性

    #=====开始插入数据库====
    if not rccpsDBFunc.insTransTrc(trcbka_dict):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('D002', '插入数据库出错,RollBack成功')
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('插入汇兑业务登记簿,COMMIT成功')
        
    ##========================= START 张恒 增加于20091011 来帐落机构及入帐挂账处理  =====================##
    #初始化记挂账标识,记账.0,挂账.1,默认记账
    accflag = 0
    #接收机构暂存
    TradeContext.BESBNOFIRST = TradeContext.BESBNO
        
    #校验账号是否非法
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验账号是否非法")  
            
        if (len(TradeContext.PYEACC) != 23) and (len(TradeContext.PYEACC) != 19) :
            accflag = 1
            TradeContext.NOTE3 = '此账号不是对公或对私账号,挂账!'
            
        AfaLoggerFunc.tradeInfo("结束校验账号是否非法")

    #调用主机接口查询账户信息
    if accflag == 0:
        #调用8810查询账户信息
        AfaLoggerFunc.tradeInfo("开始查询账户信息")
        
        TradeContext.ACCNO = TradeContext.PYEACC      
        TradeContext.HostCode = '8810'                  
        rccpsHostFunc.CommHost( '8810' )   
        
        if TradeContext.errorCode != '0000':
            accflag = 1
            TradeContext.NOTE3 = '查询收款人信息失败,挂账!'
        elif TradeContext.errorCode == '0000' and len(TradeContext.ACCSO) == 0 :
            accflag = 1
            TradeContext.NOTE3 = '查询收款人开户机构失败,挂账!'
            
        AfaLoggerFunc.tradeInfo("结束查询账户信息")
        
    #校验账户状态是否正常
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验是否跨法人")     
         
        if TradeContext.ACCSO[0:6] != TradeContext.BESBNO[0:6] :
            accflag = 1
            TradeContext.NOTE3 = '接收行与账户开户行跨法人,挂账!'
            
        AfaLoggerFunc.tradeInfo("结束校验是否跨法人")
        
    #校验开户机构是否建立代理关系
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验接收行与开户机构是否为同一机构")
        
        if TradeContext.ACCSO != TradeContext.BESBNOFIRST:
            khjg = {}
            khjg['BESBNO'] = TradeContext.ACCSO
            khjg['BTOPSB'] = TradeContext.BESBNOFIRST
            khjg['SUBFLG'] = PL_SUBFLG_SUB                                 
            rec = rccpsDBTrcc_subbra.selectu(khjg)
            if rec == None:
                accflag = 1
                TradeContext.NOTE3 = '查询账户代理关系失败,挂账!'
            elif len(rec) <= 0:
                accflag = 1
                TradeContext.NOTE3 = '账户未建立代理关系,挂账!'
            else:
                #接收机构与开户机构存在代理关系,设置机构号为开户机构号
                TradeContext.BESBNO  =  TradeContext.ACCSO
                
        AfaLoggerFunc.tradeInfo("结束校验接收行与开户机构是否为同一机构")
        
    #校验账号状态是否正常
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验账号状态是否正常")
        
        if TradeContext.ACCST != '0' and  TradeContext.ACCST != '2':
           accflag = 1
           TradeContext.NOTE3 = '账户状态不正常,挂账!'
           
           #在建立代理关系的情况下,账户状态不正常,同样挂账
           TradeContext.BESBNO  = TradeContext.BESBNOFIRST
           
        AfaLoggerFunc.tradeInfo("结束校验账号状态是否正常")

    #校验收款人户名是否一致
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验收款人户名是否一致")
        
        if TradeContext.ACCNM != TradeContext.PYENAM :
             accflag = 1
             TradeContext.NOTE3 = '收款人户名不符,挂账!'
             
             #在建立代理关系的情况下,账户状态不正常,同样挂账
             TradeContext.BESBNO  = TradeContext.BESBNOFIRST
             
        AfaLoggerFunc.tradeInfo("结束校验收款人户名是否一致")

    if (TradeContext.existVariable( "PYEACC" ) and len(TradeContext.PYEACC) != 0):       #收款人名称
        TradeContext.PYEACC      = TradeContext.PYEACC
    else:
        TradeContext.PYEACC      = ''
         
    if (TradeContext.existVariable( "PYENAM" ) and len(TradeContext.PYENAM) != 0):       #收款人名称
        TradeContext.OTNM      = TradeContext.PYENAM
    else:
        TradeContext.OTNM      = ''
        
    #汇兑往帐记帐字典赋值
    input_dict = {}
    input_dict['accflag']     = str(accflag)                                #记挂标志
    input_dict['OCCAMT']      = TradeContext.OCCAMT                         #交易金额
    input_dict['PYEACC']      = TradeContext.PYEACC                         #收款人账号
    input_dict['OTNM']        = TradeContext.OTNM                           #收款人名称
    input_dict['BESBNO']      = TradeContext.BESBNO
        
    #调用汇兑记账接口
    rccpsEntries.HDLZJZ(input_dict)
    
    TradeContext.accflag    = accflag                                    #代理标志

    #=====开始调函数拼贷方账号第25位校验位====
    TradeContext.HostCode = '8813'                                   #调用8813主机接口
    TradeContext.RCCSMCD  = PL_RCCSMCD_HDLZ                          #主机摘要代码:汇兑来账
    TradeContext.ACUR = '1'
    ##========================= END 张恒 增加于20091011 来帐落机构及入帐挂账处理  =====================##
    
    #=====设置状态为收妥====
    sstlog   = {}
    sstlog['BSPSQN']   = TradeContext.BSPSQN
    sstlog['BJEDTE']   = TradeContext.BJEDTE
    sstlog['BCSTAT']   = PL_BCSTAT_BNKRCV
    sstlog['BDWFLG']   = PL_BDWFLG_SUCC

    #=====设置状态为 收妥-成功 ====
    if not rccpsState.setTransState(sstlog):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('>>>commit成功')

    return True
Esempio n. 5
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( ">>>开始汇兑来账接收处理" )

    #=====判断是否重复交易====
    sel_dict = {'TRCNO':TradeContext.TRCNO,'TRCDAT':TradeContext.TRCDAT,'SNDBNKCO':TradeContext.SNDBNKCO}
    record = rccpsDBTrcc_trcbka.selectu(sel_dict)
    if record == None:
        return AfaFlowControl.ExitThisFlow('S999','判断是否重复报文,查询汇兑业务登记簿相同报文异常')
    elif len(record) > 0:
        AfaLoggerFunc.tradeInfo('汇兑业务登记簿中存在相同数据,重复报文,进入下一流程')
        #=====为通讯回执报文赋值====
        out_context_dict = {}
        out_context_dict['sysType']  = 'rccpst'
        out_context_dict['TRCCO']    = '9900503'
        out_context_dict['MSGTYPCO'] = 'SET008'
        out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
        out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
        out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
        out_context_dict['SNDCLKNO'] = TradeContext.BETELR
        out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
        out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
        out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
        out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
        out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
        out_context_dict['OPRTYPNO'] = '99'
        out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
        out_context_dict['TRANTYP']  = '0'
        out_context_dict['ORTRCCO']  = TradeContext.TRCCO
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '重复报文'

        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)

        #=====发送afe====
        AfaAfeFunc.CommAfe()

        return AfaFlowControl.ExitThisFlow('S999','重复报文,退出处理流程')

    AfaLoggerFunc.tradeInfo(">>>结束判断是否重复报文")

    #=====币种转换====
    if TradeContext.CUR == 'CNY':
        TradeContext.CUR  = '01'

    #====开始向字典赋值====
    trcbka_dict = {}
    if not rccpsMap1101CTradeContext2Dtrcbka_dict.map(trcbka_dict):
        return AfaFlowControl.ExitThisFlow('M999', '字典赋值出错')

    trcbka_dict['DCFLG'] = PL_DCFLG_CRE                  #借贷标识.贷
    trcbka_dict['OPRNO'] = '00'                          #业务属性
    
    #=====开始插入数据库====
    if not rccpsDBFunc.insTransTrc(trcbka_dict):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('D002', '插入数据库出错,RollBack成功')
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('插入汇兑业务登记簿,COMMIT成功')

    #=====设置状态为收妥====
    sstlog   = {}
    sstlog['BSPSQN']   = TradeContext.BSPSQN
    sstlog['BJEDTE']   = TradeContext.BJEDTE
    sstlog['BCSTAT']   = PL_BCSTAT_BNKRCV
    sstlog['BDWFLG']   = PL_BDWFLG_SUCC

    #=====设置状态为 收妥-成功 ====
    if not rccpsState.setTransState(sstlog):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('>>>commit成功')
    
    ##========================= START 张恒 增加于20091011 来帐落机构及入帐挂账处理  =====================##
    #初始化记挂账标识,记账.0,挂账.1,默认记账
    accflag = 0
    #接收机构暂存
    TradeContext.BESBNOFIRST = TradeContext.BESBNO
    
    if accflag == 0:
        AfaLoggerFunc.tradeInfo(">>>开始校验密押")
        #=====开始调用密押服务器进行核押====
        SNDBANKCO  = TradeContext.SNDBNKCO
        RCVBANKCO  = TradeContext.RCVBNKCO
        SNDBANKCO = SNDBANKCO.rjust(12,'0')
        RCVBANKCO = RCVBANKCO.rjust(12,'0')
        AMOUNT = TradeContext.OCCAMT.split('.')[0] + TradeContext.OCCAMT.split('.')[1]
        AMOUNT = AMOUNT.rjust(15,'0')
        INFO   = ' '
        INFO   = INFO.rjust(60,' ')
        AfaLoggerFunc.tradeDebug('处理类型(0-编押 1-核押):' + str(PL_SEAL_DEC) )
        AfaLoggerFunc.tradeDebug('业务种类(1-现金汇票 2-转账汇票 3-电子汇兑业务):' +str(PL_TYPE_DZHD) )
        AfaLoggerFunc.tradeDebug('委托日期:' + TradeContext.TRCDAT )
        AfaLoggerFunc.tradeDebug('交易流水号:' + TradeContext.TRCNO )
        AfaLoggerFunc.tradeDebug('AMOUNT=' + str(AMOUNT) )
        AfaLoggerFunc.tradeDebug('SNDBANKCO=' + str(SNDBANKCO) )
        AfaLoggerFunc.tradeDebug('RCVBANKCO=' + str(RCVBANKCO) )
        AfaLoggerFunc.tradeDebug('密押:' + TradeContext.SEAL )
        AfaLoggerFunc.tradeDebug('OTHERINFO[' + str(INFO) + ']')
        
        ret = miya.DraftEncrypt(PL_SEAL_DEC,PL_TYPE_DZHD,TradeContext.TRCDAT,TradeContext.TRCNO,AMOUNT,SNDBANKCO,RCVBANKCO,'',TradeContext.SEAL)
    
        if ret != 0:
            #密押错,挂账
            AfaLoggerFunc.tradeInfo("密押校验未通过,ret=[" + str(ret) + "]")
            accflag = 1
            TradeContext.NOTE3 = "密押错,挂账!"
        else:
            #密押校验通过
            AfaLoggerFunc.tradeInfo("密押校验通过")
            
        AfaLoggerFunc.tradeInfo(">>>结束校验密押")
        
    #校验账号是否非法
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验账号是否非法")  
        
        if (len(TradeContext.PYEACC) != 23) and (len(TradeContext.PYEACC) != 19) :
            accflag = 1
            TradeContext.NOTE3 = '此账号不是对公或对私账号,挂账!'
            
        AfaLoggerFunc.tradeInfo("结束校验账号是否非法")

    #调用主机接口查询账户信息
    if accflag == 0:
        #调用8810查询账户信息
        AfaLoggerFunc.tradeInfo("开始查询账户信息")
        
        TradeContext.ACCNO = TradeContext.PYEACC      
        TradeContext.HostCode = '8810'                  
        rccpsHostFunc.CommHost( '8810' )   
        
        if TradeContext.errorCode != '0000':
            accflag = 1
            TradeContext.NOTE3 = '查询收款人信息失败,挂账!'
        elif TradeContext.errorCode == '0000' and len(TradeContext.ACCSO) == 0 :
            accflag = 1
            TradeContext.NOTE3 = '查询收款人开户机构失败,挂账!'
            
        AfaLoggerFunc.tradeInfo("结束查询账户信息")
        
    #校验账户状态是否正常
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验是否跨法人")     
         
        if TradeContext.ACCSO[0:6] != TradeContext.BESBNO[0:6] :
            accflag = 1
            TradeContext.NOTE3 = '接收行与账户开户行跨法人,挂账!'
            
        AfaLoggerFunc.tradeInfo("结束校验是否跨法人")
        
    #校验开户机构是否建立代理关系
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验接收行与开户机构是否为同一机构")
        
        if TradeContext.ACCSO != TradeContext.BESBNOFIRST:
            khjg = {}
            khjg['BESBNO'] = TradeContext.ACCSO
            khjg['BTOPSB'] = TradeContext.BESBNOFIRST
            khjg['SUBFLG'] = PL_SUBFLG_SUB                                
            rec = rccpsDBTrcc_subbra.selectu(khjg)
            if rec == None:
                accflag = 1
                TradeContext.NOTE3 = '查询账户代理关系失败,挂账!'
            elif len(rec) <= 0:
                accflag = 1
                TradeContext.NOTE3 = '账户未建立代理关系,挂账!'
            else:
                #接收机构与开户机构存在代理关系,设置机构号为开户机构号
                TradeContext.BESBNO  =  TradeContext.ACCSO
                
        AfaLoggerFunc.tradeInfo("结束校验接收行与开户机构是否为同一机构")
        
    #校验账号状态是否正常
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验账号状态是否正常")
        
        if TradeContext.ACCST != '0' and  TradeContext.ACCST != '2':
           accflag = 1
           TradeContext.NOTE3 = '账户状态不正常,挂账!'
           
           #在建立代理关系的情况下,账户状态不正常,同样挂账
           TradeContext.BESBNO  = TradeContext.BESBNOFIRST  
           
        AfaLoggerFunc.tradeInfo("结束校验账号状态是否正常")

    #校验收款人户名是否一致
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验收款人户名是否一致")
        
        if TradeContext.ACCNM != TradeContext.PYENAM :
           accflag = 1
           TradeContext.NOTE3 = '收款人户名不符,挂账!'
         
           #在建立代理关系的情况下,账户状态不正常,同样挂账
           TradeContext.BESBNO  = TradeContext.BESBNOFIRST
            
        AfaLoggerFunc.tradeInfo("结束校验收款人户名是否一致")

    if (TradeContext.existVariable( "PYEACC" ) and len(TradeContext.PYEACC) != 0):       #收款人名称
        TradeContext.PYEACCNO      = TradeContext.PYEACC
    else:
        TradeContext.PYEACCNO      = ''
         
    if (TradeContext.existVariable( "PYENAM" ) and len(TradeContext.PYENAM) != 0):       #收款人名称
        TradeContext.OTNM      = TradeContext.PYENAM
    else:
        TradeContext.OTNM      = ''
        
    #汇兑往帐记帐字典赋值
    TradeContext.SBACACNM = ''                                              #借方户名
    input_dict = {}
    if (TradeContext.existVariable( "PYRNAM" ) and len(TradeContext.PYRNAM) != 0):          #付款人户名
        TradeContext.SBACACNM      =      TradeContext.PYRNAM
    
    input_dict['accflag']     = str(accflag)                                #记挂标志
    input_dict['OCCAMT']      = TradeContext.OCCAMT                         #交易金额
    input_dict['PYEACC']      = TradeContext.PYEACCNO                       #收款人账号
    input_dict['OTNM']        = TradeContext.OTNM                           #收款人名称
    input_dict['BESBNO']      = TradeContext.BESBNO
        
    #调用汇兑记账接口
    rccpsEntries.HDLZJZ(input_dict)      
    
    TradeContext.accflag    = accflag                                           #代理标志

    #=====新增sstlog表状态记录====
    if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,TradeContext.BCSTAT,TradeContext.BDWFLG):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('M999', '设置状态['+TradeContext.BCSTAT+']['+TradeContext.BDWFLG+']失败,系统自动回滚')
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()

    return True
Esempio n. 6
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易[TRC001_8531]进入***' )
    
    #=====判断输入接口值是否存在====
    if( not TradeContext.existVariable( "STRDAT" ) ):
        return AfaFlowControl.ExitThisFlow('A099','起始日期[STRDAT]不存在' )
    
    if( not TradeContext.existVariable( "ENDDAT" ) ):
        return AfaFlowControl.ExitThisFlow('A099','终止日期[ENDDAT]不存在' ) 
    
    if( not TradeContext.existVariable( "RECSTRNO" ) ):
        return AfaFlowControl.ExitThisFlow('A099','起始笔数[RECSTRNO]不存在' )

    #=====生成查询语句====
    wheresql=""
    wheresql = wheresql + "BESBNO='"        + TradeContext.BESBNO + "' " 
    wheresql=wheresql   + " AND BJEDTE>='"  + TradeContext.STRDAT + "'"
    wheresql=wheresql   + " AND BJEDTE<='"  + TradeContext.ENDDAT + "'"
    
    #=====判断交易代码是否为空====
    if(TradeContext.TRCCO != ""):
        wheresql = wheresql + " AND TRCCO='"  + TradeContext.TRCCO   + "'"
        
    #=====判断往来标识是否为空====
    if(TradeContext.BRSFLG != ""):
        wheresql = wheresql + " AND BRSFLG='" + TradeContext.BRSFLG  + "'"

    #=====判断查复标识是否为空或者9-全部====        
    if(TradeContext.ISDEAL != "9" and TradeContext.ISDEAL!=""):
        wheresql = wheresql + " AND ISDEAL='" + TradeContext.ISDEAL  + "'"
        
    AfaLoggerFunc.tradeDebug(">>>生成查询语句sql="+wheresql)

    #=====查询机构名====
    subbra_dict={'BESBNO':TradeContext.BESBNO}
    
    sub=rccpsDBTrcc_subbra.selectu(subbra_dict)
    if(sub==None):
        return AfaFlowControl.ExitThisFlow('A099','查询机构名失败' )        
    if(len(sub)==0):
        return AfaFlowControl.ExitThisFlow('A099','没有相应的机构名' )
    
    #=====判断打印类型====
    #=====0 不打印====
    if TradeContext.PRTTYPE=='0':
        AfaLoggerFunc.tradeInfo(">>>进入不打印处理")
        #=====判断报单序号是否为空====
        if(TradeContext.BSPSQN!=""):    
            wheresql = wheresql + " AND BSPSQN='" + TradeContext.BSPSQN  + "'"
        
        #=====得到总记录数====
        allcount=rccpsDBTrcc_hdcbka.count(wheresql)

        if(allcount==-1):
            return AfaFlowControl.ExitThisFlow('A099','超找总记录数失败' )
        
        #=====查询数据库====
        ordersql=" order by BJEDTE DESC,BSPSQN DESC"
        records=rccpsDBTrcc_hdcbka.selectm(TradeContext.RECSTRNO,10,wheresql,ordersql)
        
        if(records==None):
            return AfaFlowControl.ExitThisFlow('A099','查询失败' )        
        elif( len(records)<=0 ):
            return AfaFlowControl.ExitThisFlow('A099','未查找到数据' )        
        else:
            #=====生成文件====
            filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetHostDate()+"_"+TradeContext.TransCode
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
            
            if(f==None):
                return AfaFlowControl.ExitThisFlow('A099','打开文件失败' )

            filecontext=""           
            #=====写文件操作====
            for i in range(0,len(records)):
                filecontext=records[i]['BJEDTE']  + "|" \
                           +records[i]['BSPSQN']  + "|" \
                           +records[i]['BRSFLG']  + "|" \
                           +records[i]['BESBNO']  + "|" \
                           +records[i]['BETELR']  + "|" \
                           +records[i]['BEAUUS']  + "|" \
                           +records[i]['NCCWKDAT']+ "|" \
                           +records[i]['TRCCO']   + "|" \
                           +records[i]['TRCDAT']  + "|" \
                           +records[i]['TRCNO']   + "|" \
                           +records[i]['SNDBNKCO']+ "|" \
                           +records[i]['SNDBNKNM']+ "|" \
                           +records[i]['RCVBNKCO']+ "|" \
                           +records[i]['RCVBNKNM']+ "|" \
                           +records[i]['BOJEDT']  + "|" \
                           +records[i]['BOSPSQ']  + "|" \
                           +records[i]['ORTRCCO'] + "|" \
                           +records[i]['CONT']    + "|" \
                           +records[i]['ISDEAL']  + "|" \
                           +records[i]['CUR']     + "|" \
                           +str(records[i]['OCCAMT'])+ "|" \
                           +records[i]['PYRACC']  + "|" \
                           +records[i]['PYEACC']  + "|" \
                           +records[i]['PRCCO']   + "|" \
                           +records[i]['STRINFO'] + "|" \
                           +records[i]['PYRNAM']  + "|" \
                           +records[i]['PYENAM']  + "|" 
                f.write(filecontext+"\n")
            AfaLoggerFunc.tradeInfo("生成文件结束")
            f.close()
            
            #=====输出接口赋值====
            TradeContext.RECCOUNT=str(len(records))     #查询笔数
            TradeContext.RECALLCOUNT=str(allcount)      #总笔数
            TradeContext.PBDAFILE=filename              #文件名
            TradeContext.errorCode="0000"
            TradeContext.errorMsg="查询成功"
    #=====1 打印====
    elif TradeContext.PRTTYPE=='1':
        #=====判断报单序号是否为空====
        if(TradeContext.BSPSQN!=""):    
            wheresql = wheresql + " AND BSPSQN='" + TradeContext.BSPSQN  + "'"
        else:
            return AfaFlowControl.ExitThisFlow('S999','报单序号[BSPSQN]不允许为空' )
            
        #=====查询数据库====
        records=rccpsDBTrcc_hdcbka.selectm(TradeContext.RECSTRNO,10,wheresql,"")
        
        if(records==None):
            return AfaFlowControl.ExitThisFlow('A099','查询失败' )        
        elif( len(records)<=0 ):
            return AfaFlowControl.ExitThisFlow('A099','未查找到数据' )        
        else:
            #=====查询书====
            if(TradeContext.TRCCO=='9900511'):                
                AfaLoggerFunc.tradeInfo(">>>业务类型为查询书")
                
                #=====查询原交易信息====
                where_dict={'BJEDTE':records[0]['BOJEDT'],'BSPSQN':records[0]['BOSPSQ']}
                
                ret=rccpsDBTrcc_trcbka.selectu(where_dict)
                if(ret==None):
                    return AfaFlowControl.ExitThisFlow('A099','查询原信息失败' )                    
                if(len(ret)==0):
                    return AfaFlowControl.ExitThisFlow('A099','未查找原信息' )
                    
                AfaLoggerFunc.tradeDebug(">>>开始生成查询书打印文本")
                
                #=====查询书打印格式====
                txt="""\
                
                                           %(BESBNM)s电子汇兑查询书
                               
                |-----------------------------------------------------------------------------|
                | 查询日期:     |      %(BJEDTE)s                                               |
                |-----------------------------------------------------------------------------|
                | 查询书号:     |      %(BSPSQN)s                                           |
                |-----------------------------------------------------------------------------|
                | 发起行行号:   |      %(SNDBNKCO)s                                             |
                |-----------------------------------------------------------------------------|
                | 接收行行号:   |      %(RCVBNKCO)s                                             |
                |-----------------------------------------------------------------------------|
                | 原交易金额:   |      %(OROCCAMT)-15.2f                                        |
                |-----------------------------------------------------------------------------|
                | 原发起行行号: |      %(ORSNDBNKCO)s                                             |
                |-----------------------------------------------------------------------------|
                | 原接收行行号: |      %(ORRCVBNKCO)s                                             |
                |-----------------------------------------------------------------------------|
                | 查询内容:     |                                                             |
                |-----------------------------------------------------------------------------|
                |                                                                             |
                |   %(CONT1)s      |
                |                                                                             |
                |   %(CONT2)s    |
                |                                                                             |
                |   %(CONT3)s    |
                |                                                                             |
                |   %(CONT4)s    |
                |                                                                             |
                |-----------------------------------------------------------------------------|
                打印日期: %(BJEDTE)s      授权:                       记账:         
            
                """
                
                #=====写文件操作====
                file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8531'    
                out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb")
                
                if out_file == None:
                    return AfaFlowControl.ExitThisFlow("S999", "生成文件异常")
                
                print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\
                                         'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\
                                         'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\
                                         'SNDBNKCO':(records[0]['SNDBNKCO']).ljust(10,' '),\
                                         'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\
                                         'OROCCAMT':(records[0]['OCCAMT']),\
                                         'ORSNDBNKCO':(ret['SNDBNKCO']).ljust(10,' '),\
                                         'ORRCVBNKCO':(ret['RCVBNKCO']).ljust(10,' '),\
                                         'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\
                                         'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\
                                         'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\
                                         'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')}
                
                out_file.close()
                
                TradeContext.PBDAFILE = file_name       #文件名
                
                AfaLoggerFunc.tradeDebug(">>>结束生成打印文本")            
            #=====查复书====
            elif(TradeContext.TRCCO=='9900512'):
                AfaLoggerFunc.tradeInfo(">>>业务类型为查复书")
                
                #=====查询原交易信息====
                where_dict={'BJEDTE':records[0]['BOJEDT'],'BSPSQN':records[0]['BOSPSQ']}
                    
                ret=rccpsDBTrcc_hdcbka.selectu(where_dict)
                if(ret==None):
                    return AfaFlowControl.ExitThisFlow('A099','查询原信息失败' )                    
                if(len(ret)==0):
                    return AfaFlowControl.ExitThisFlow('A099','未查找原信息' )

                #=====查复书打印格式====
                txt="""\
                
                                            %(BESBNM)s电子汇兑查复书
                                           
                    |-----------------------------------------------------------------------------|
                    | 查复日期:     |      %(BJEDTE)s                                               |
                    |-----------------------------------------------------------------------------|
                    | 查复书号:     |      %(BSPSQN)s                                           |
                    |-----------------------------------------------------------------------------|
                    | 接收行行号:   |      %(RCVBNKCO)s                                             |
                    |-----------------------------------------------------------------------------|
                    | 原查询日期:   |      %(BOJEDT)s                                               |
                    |-----------------------------------------------------------------------------|
                    | 原查询书号:   |      %(BOSPSQ)s                                           |
                    |-----------------------------------------------------------------------------|
                    | 原金额:       |      %(OROCCAMT)-15.2f                                        |
                    |-----------------------------------------------------------------------------|
                    | 原币种:       |      人民币                                                 |
                    |-----------------------------------------------------------------------------|
                    | 查复内容:     |                                                             |
                    |-----------------------------------------------------------------------------|
                    |                                                                             |
                    |   %(CONT1)s      |
                    |                                                                             |
                    |   %(CONT2)s    |
                    |                                                                             |
                    |   %(CONT3)s    |
                    |                                                                             |
                    |   %(CONT4)s    |
                    |                                                                             |
                    |-----------------------------------------------------------------------------|
                    打印日期: %(BJEDTE)s      授权:                       记账:
                """
                
                #====写文件操作====
                file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8531'                
                out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb")
                
                if out_file == None:
                    return AfaFlowControl.ExitThisFlow("S999", "生成文件异常")
                
                print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\
                                         'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\
                                         'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\
                                         'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\
                                         'BOJEDT':(records[0]['BOJEDT']).ljust(8,' '),\
                                         'BOSPSQ':(records[0]['BOSPSQ']).ljust(12,' '),\
                                         'OROCCAMT':(ret['OCCAMT']),\
                                         'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\
                                         'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\
                                         'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\
                                         'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')}
                
                out_file.close()
                
                TradeContext.PBDAFILE = file_name   #文件名
                
                AfaLoggerFunc.tradeDebug("结束生成打印文本")
            #=====自由格式书====
            elif(TradeContext.TRCCO=='9900513'):            
                AfaLoggerFunc.tradeInfo(">>>业务类型为自由格式书")
                
                #=====自由格式书打印格式====
                txt="""\
                 
                                            %(BESBNM)s自由格式书
                                           
                    |-----------------------------------------------------------------------------|
                    | 日期:          |      %(BJEDTE)s                                              |
                    |-----------------------------------------------------------------------------|
                    | 自由格式书号:  |      %(BSPSQN)s                                          |
                    |-----------------------------------------------------------------------------|
                    | 发起行行号:    |      %(SNDBNKCO)s                                            |
                    |-----------------------------------------------------------------------------|
                    | 接收行行号:    |      %(RCVBNKCO)s                                            |
                    |-----------------------------------------------------------------------------|
                    | 内容:          |                                                            |
                    |-----------------------------------------------------------------------------|
                    |                                                                             |
                    |   %(CONT1)s      |
                    |                                                                             |
                    |   %(CONT2)s    |
                    |                                                                             |
                    |   %(CONT3)s    |
                    |                                                                             |
                    |   %(CONT4)s    |
                    |                                                                             |
                    |-----------------------------------------------------------------------------|
                    打印日期: %(BJEDTE)s      授权:                       记账:
                """
                
                #=====写文件操作====            
                file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8531'    
                out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb")
                
                if out_file == None:
                    return AfaFlowControl.ExitThisFlow("S999", "生成文件异常")
                
                print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\
                                         'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\
                                         'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\
                                         'SNDBNKCO':(records[0]['SNDBNKCO']).ljust(10,' '),\
                                         'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\
                                         'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\
                                         'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\
                                         'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\
                                         'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')}
                
                out_file.close()
                
                TradeContext.PBDAFILE = file_name       #文件名
                
                AfaLoggerFunc.tradeDebug("结束生成打印文本")
            #=====特约汇兑查询书====
            elif(TradeContext.TRCCO=='9900522'):
                AfaLoggerFunc.tradeInfo(">>>业务类型为特约汇兑查询书")
                
                #=====查询原交易信息====
                where_dict={'BJEDTE':records[0]['BOJEDT'],'BSPSQN':records[0]['BOSPSQ']}
                    
                ret=rccpsDBTrcc_trcbka.selectu(where_dict)
                if(ret==None):
                    return AfaFlowControl.ExitThisFlow('A099','查询原信息失败' )                    
                if(len(ret)==0):
                    return AfaFlowControl.ExitThisFlow('A099','未查找原信息' )
  
                #=====特约电子汇兑查询书打印格式====
                txt="""\
                            
                                      %(BESBNM)s全国特约电子汇兑查询书
                                           
                    |-----------------------------------------------------------------------------|
                    | 查询日期:         |      %(BJEDTE)s                                           |
                    |-----------------------------------------------------------------------------|
                    | 特约汇兑查询书号: |      %(BSPSQN)s                                       |
                    |-----------------------------------------------------------------------------|
                    | 发起行行号:       |      %(SNDBNKCO)s                                         |
                    |-----------------------------------------------------------------------------|
                    | 接收行行号:       |      %(RCVBNKCO)s                                         |
                    |-----------------------------------------------------------------------------|  
                    | 原报单号:         |      %(BOSPSQ)s                                       |
                    |-----------------------------------------------------------------------------|  
                    | 原金额:           |      %(OROCCAMT)-15.2f                                    |
                    |-----------------------------------------------------------------------------|
                    | 原委托日期:       |      %(ORTRCDAT)s                                           |
                    |-----------------------------------------------------------------------------|
                    | 原发起行行号:     |      %(ORSNDBNKCO)s                                         |
                    |-----------------------------------------------------------------------------|
                    | 查询内容:         |                                                         |
                    |-----------------------------------------------------------------------------|
                    |                                                                             |
                    |     %(CONT1)s    |
                    |                                                                             |
                    |   %(CONT2)s    |
                    |                                                                             |
                    |   %(CONT3)s    |
                    |                                                                             |
                    |   %(CONT4)s    |
                    |                                                                             |
                    |-----------------------------------------------------------------------------|
                    打印日期: %(BJEDTE)s      授权:                       记账:
                """
                
                #====写文件操作====
                file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8531'
                out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb")
                
                if out_file == None:
                    return AfaFlowControl.ExitThisFlow("S999", "生成打印文件异常")
                
                print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\
                                         'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\
                                         'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\
                                         'SNDBNKCO':(records[0]['SNDBNKCO']).ljust(10,' '),\
                                         'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\
                                         'BOSPSQ':(records[0]['BOSPSQ']).ljust(10,' '),\
                                         'OROCCAMT':(ret['OCCAMT']),\
                                         'ORTRCDAT':(ret['TRCDAT']).ljust(8,' '),\
                                         'ORSNDBNKCO':(ret['SNDBNKCO']).ljust(10,' '),\
                                         'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\
                                         'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\
                                         'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\
                                         'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')}
                
                out_file.close()
                
                TradeContext.PBDAFILE = file_name       #文件名
                
                AfaLoggerFunc.tradeDebug("结束生成打印文本")
            #=====特约汇兑查复书====
            elif(TradeContext.TRCCO=='9900523'):                
                AfaLoggerFunc.tradeInfo(">>>业务类型为特约汇兑查复书")
                
                #=====查询原交易信息====
                where_dict={'BJEDTE':records[0]['BOJEDT'],'BSPSQN':records[0]['BOSPSQ']}
                    
                ret=rccpsDBTrcc_hdcbka.selectu(where_dict)
                if(ret==None):
                    return AfaFlowControl.ExitThisFlow('A099','查询原信息失败' )                    
                if(len(ret)==0):
                    return AfaFlowControl.ExitThisFlow('A099','未查找原信息' )
                    
                #=====特约电子汇兑查复书打印格式====
                txt="""\
                
                                 
                                           %(BESBNM)s全国特约电子汇兑查复书
                                           
                    |-----------------------------------------------------------------------------|
                    | 查复日期:             |      %(BJEDTE)s                                       |
                    |-----------------------------------------------------------------------------|
                    | 特约汇兑查复书号:     |      %(BSPSQN)s                                   |
                    |-----------------------------------------------------------------------------|
                    | 发起行行号:           |      %(SNDBNKCO)s                                     |
                    |-----------------------------------------------------------------------------|
                    | 接收行行号:           |      %(RCVBNKCO)s                                     |
                    |-----------------------------------------------------------------------------|
                    | 原特约查询发起行行号: |      %(ORSNDBNKCO)s                                     |
                    |-----------------------------------------------------------------------------|
                    | 原特约查询日期:       |      %(BOJEDT)s                                       |
                    |-----------------------------------------------------------------------------|
                    | 原金额:               |      %(OROCCAMT)-15.2f                                |
                    |-----------------------------------------------------------------------------|
                    | 原委托日期:           |      %(ORTRCDAT)s                                       |
                    |-----------------------------------------------------------------------------|
                    | 原特约查询交易流水号: |      %(ORTRCNO)s                                   |
                    |-----------------------------------------------------------------------------|
                    | 查询内容:             |                                                     |
                    |-----------------------------------------------------------------------------|
                    |                                                                             |
                    |   %(CONT1)s      |
                    |                                                                             |
                    |   %(CONT2)s    |
                    |                                                                             |
                    |   %(CONT3)s    |
                    |                                                                             |
                    |   %(CONT4)s    |
                    |                                                                             |
                    |-----------------------------------------------------------------------------|
                    打印日期: %(BJEDTE)s      授权:                       记账:
                """
                
                #====写文件操作====
                file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8531'               
                out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb")
                
                if out_file == None:
                    return AfaFlowControl.ExitThisFlow("S999", "生成打印文件异常")
                
                print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\
                                         'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\
                                         'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\
                                         'SNDBNKCO':(records[0]['SNDBNKCO']).ljust(10,' '),\
                                         'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\
                                         'ORSNDBNKCO':(ret['SNDBNKCO']).ljust(10,' '),\
                                         'BOJEDT':(records[0]['BJEDTE']).ljust(8,' '),\
                                         'OROCCAMT':(ret['OCCAMT']),\
                                         'ORTRCDAT':(ret['TRCDAT']).ljust(8,' '),\
                                         'ORTRCNO':(ret['TRCNO']).ljust(12,' '),\
                                         'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\
                                         'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\
                                         'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\
                                         'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')}
                
                out_file.close()
                
                TradeContext.PBDAFILE = file_name       #文件名
                
                AfaLoggerFunc.tradeDebug("结束生成打印文本")
            #=====特约汇兑自由格式书====
            elif(TradeContext.TRCCO=='9900524'):                
                AfaLoggerFunc.tradeInfo(">>>业务类型为特约汇兑自由格式书")
                
                #=====特约电子汇兑自由格式书打印格式====
                txt="""\
                
                                             %(BESBNM)s全国特约电子汇兑自由格式书
                                           
                    |-----------------------------------------------------------------------------|
                    | 日期:                  |      %(BJEDTE)s                                      |
                    |-----------------------------------------------------------------------------|
                    | 特约汇兑自由格式书号:  |      %(BSPSQN)s                                  |
                    |-----------------------------------------------------------------------------|
                    | 发起行行号:            |      %(SNDBNKCO)s                                    |
                    |-----------------------------------------------------------------------------|
                    | 接收行行号:            |      %(RCVBNKCO)s                                    |
                    |-----------------------------------------------------------------------------|
                    | 内容:                  |                                                    |
                    |-----------------------------------------------------------------------------|
                    |                                                                             |
                    |   %(CONT1)s      |
                    |                                                                             |
                    |   %(CONT2)s    |
                    |                                                                             |
                    |   %(CONT3)s    |
                    |                                                                             |
                    |   %(CONT4)s    |
                    |                                                                             |
                    |-----------------------------------------------------------------------------|
                    打印日期: %(BJEDTE)s      授权:                       记账:
                """
                
                #=====写文件操作====
                file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8531'                
                out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb")
                
                if out_file == None:
                    return AfaFlowControl.ExitThisFlow("S999", "生成文件异常")
                
                print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\
                                         'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\
                                         'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\
                                         'SNDBNKCO':(records[0]['SNDBNKCO']).ljust(10,' '),\
                                         'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\
                                         'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\
                                         'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\
                                         'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\
                                         'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')}
                
                out_file.close()
                
                TradeContext.PBDAFILE = file_name       #文件名                
                AfaLoggerFunc.tradeInfo("结束生成打印文本")                    
            else:
                return AfaFlowControl.ExitThisFlow('A099','没有相关的业务类型' )    
        
        
        TradeContext.RECCOUNT="1"           #查询笔数
        TradeContext.RECALLCOUNT="1"        #总笔数
        TradeContext.errorCode="0000"
        TradeContext.errorMsg="查询成功"
              
    elif( len(TradeContext.PRTTYPE) == 0 ):
        return AfaFlowControl.ExitThisFlow('A099','打印标志为必输项' )  
    else:
        return AfaFlowControl.ExitThisFlow('A099','打印标志非法' )
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易[TRC001_8531]退出***' )
    return True
Esempio n. 7
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( "====开始汇兑来账接收处理====" )

    #=====判断是否重复交易====
    sel_dict = {'TRCNO':TradeContext.TRCNO,'TRCDAT':TradeContext.TRCDAT,'SNDBNKCO':TradeContext.SNDBNKCO}
    record = rccpsDBTrcc_trcbka.selectu(sel_dict)
    if record == None:
        return AfaFlowControl.ExitThisFlow('S999','判断是否重复报文,查询汇兑业务登记簿相同报文异常')
    elif len(record) > 0:
        AfaLoggerFunc.tradeInfo('汇兑业务登记簿中存在相同数据,重复报文,进入下一流程')
        #=====为通讯回执报文赋值====
        out_context_dict = {}
        out_context_dict['sysType']  = 'rccpst'
        out_context_dict['TRCCO']    = '9900503'
        out_context_dict['MSGTYPCO'] = 'SET008'
        out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
        out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
        out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
        out_context_dict['SNDCLKNO'] = TradeContext.BETELR
        out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
        out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
        out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
        out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
        out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
        out_context_dict['OPRTYPNO'] = '99'
        out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
        out_context_dict['TRANTYP']  = '0'
        out_context_dict['ORTRCCO']  = TradeContext.TRCCO
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '重复报文'

        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)

        #=====发送afe====
        AfaAfeFunc.CommAfe()

        return AfaFlowControl.ExitThisFlow('S999','重复报文,退出处理流程')

    AfaLoggerFunc.tradeInfo(">>>结束判断是否重复报文")

    #=====币种转换====
    if TradeContext.CUR == 'CNY':
        TradeContext.CUR  = '01'

    #====开始向字典赋值====
    trcbka_dict = {}
    if not rccpsMap1101CTradeContext2Dtrcbka_dict.map(trcbka_dict):
        return AfaFlowControl.ExitThisFlow('M999', '字典赋值出错')

    trcbka_dict['DCFLG'] = PL_DCFLG_CRE                  #借贷标识
    trcbka_dict['OPRNO'] = '01'                          #业务属性

    #=====开始插入数据库====
    if not rccpsDBFunc.insTransTrc(trcbka_dict):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('D002', '插入数据库出错,RollBack成功')
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('插入汇兑业务登记簿,COMMIT成功')

    #=====设置状态为收妥====
    sstlog   = {}
    sstlog['BSPSQN']   = TradeContext.BSPSQN
    sstlog['BJEDTE']   = TradeContext.BJEDTE
    sstlog['BCSTAT']   = PL_BCSTAT_BNKRCV
    sstlog['BDWFLG']   = PL_BDWFLG_SUCC

    #=====设置状态为 收妥-成功 ====
    if not rccpsState.setTransState(sstlog):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('>>>commit成功')
        
    ##========================= START 张恒 增加于20091011 来帐落机构及入帐挂账处理  =====================##
    #初始化记挂账标识,记账.0,挂账.1,默认记账
    accflag = 0
    #接收机构暂存
    TradeContext.BESBNOFIRST = TradeContext.BESBNO
    
    if accflag == 0:
        AfaLoggerFunc.tradeInfo(">>>开始校验密押")
        #=====开始调用密押服务器进行核押====
        SNDBANKCO  = TradeContext.SNDBNKCO
        RCVBANKCO  = TradeContext.RCVBNKCO
        SNDBANKCO = SNDBANKCO.rjust(12,'0')
        RCVBANKCO = RCVBANKCO.rjust(12,'0')
        AMOUNT = TradeContext.OCCAMT.split('.')[0] + TradeContext.OCCAMT.split('.')[1]
        AMOUNT = AMOUNT.rjust(15,'0')
        
        AfaLoggerFunc.tradeDebug('AMOUNT=' + str(AMOUNT) )
        AfaLoggerFunc.tradeDebug('SNDBANKCO=' + str(SNDBANKCO) )
        AfaLoggerFunc.tradeDebug('RCVBANKCO=' + str(RCVBANKCO) )

        ret = miya.DraftEncrypt(PL_SEAL_DEC,PL_TYPE_DZHD,TradeContext.TRCDAT,TradeContext.TRCNO,AMOUNT,SNDBANKCO,RCVBANKCO,'',TradeContext.SEAL)

        if ret != 0:
            #密押错,挂账
            AfaLoggerFunc.tradeInfo("密押校验未通过,ret=[" + str(ret) + "]")
            accflag = 1
            TradeContext.NOTE3 = "密押错,挂账!"
        else:
            #密押校验通过
            AfaLoggerFunc.tradeInfo("密押校验通过")
            
        AfaLoggerFunc.tradeInfo(">>>结束校验密押")
        
    #校验账号是否非法
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验账号是否非法")  
        
        if (len(TradeContext.PYEACC) != 23) and (len(TradeContext.PYEACC) != 19) :
            accflag = 1
            TradeContext.NOTE3 = '此账号不是对公或对私账号,挂账!'
            
        AfaLoggerFunc.tradeInfo("结束校验账号是否非法")

    #调用主机接口查询账户信息
    if accflag == 0:
        #调用8810查询账户信息
        AfaLoggerFunc.tradeInfo("开始查询账户信息")
        
        TradeContext.ACCNO = TradeContext.PYEACC      
        TradeContext.HostCode = '8810'                  
        rccpsHostFunc.CommHost( '8810' )   
        
        if TradeContext.errorCode != '0000':
            accflag = 1
            TradeContext.NOTE3 = '查询收款人信息失败,挂账!'
        elif TradeContext.errorCode == '0000' and len(TradeContext.ACCSO) == 0 :
            accflag = 1
            TradeContext.NOTE3 = '查询收款人开户机构失败,挂账!'
            
        AfaLoggerFunc.tradeInfo("结束查询账户信息")
        
    #校验账户状态是否正常
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验是否跨法人")     
         
        if TradeContext.ACCSO[0:6] != TradeContext.BESBNO[0:6] :
            accflag = 1
            TradeContext.NOTE3 = '接收行与账户开户行跨法人,挂账!'
            
        AfaLoggerFunc.tradeInfo("结束校验是否跨法人")
        
    #校验开户机构是否建立代理关系
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验接收行与开户机构是否为同一机构")
        
        if TradeContext.ACCSO != TradeContext.BESBNOFIRST:
            khjg = {}
            khjg['BESBNO'] = TradeContext.ACCSO
            khjg['BTOPSB'] = TradeContext.BESBNOFIRST
            khjg['SUBFLG'] = PL_SUBFLG_SUB                                 
            rec = rccpsDBTrcc_subbra.selectu(khjg)
            if rec == None:
                accflag = 1
                TradeContext.NOTE3 = '查询账户代理关系失败,挂账!'
            elif len(rec) <= 0:
                accflag = 1
                TradeContext.NOTE3 = '账户未建立代理关系,挂账!'
            else:
                #接收机构与开户机构存在代理关系,设置机构号为开户机构号
                TradeContext.BESBNO  =  TradeContext.ACCSO
                
        AfaLoggerFunc.tradeInfo("结束校验接收行与开户机构是否为同一机构")
        
    #校验账号状态是否正常
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验账号状态是否正常")
        
        if TradeContext.ACCST != '0' and  TradeContext.ACCST != '2':
           accflag = 1
           TradeContext.NOTE3 = '账户状态不正常,挂账!'
           
           #在建立代理关系的情况下,账户状态不正常,同样挂账
           TradeContext.BESBNO  = TradeContext.BESBNOFIRST
           
        AfaLoggerFunc.tradeInfo("结束校验账号状态是否正常")

    #校验收款人户名是否一致
    if accflag == 0:
        AfaLoggerFunc.tradeInfo("开始校验收款人户名是否一致")
        
        if TradeContext.ACCNM != TradeContext.PYENAM :
             accflag = 1
             TradeContext.NOTE3 = '收款人户名不符,挂账!'
             
             #在建立代理关系的情况下,账户状态不正常,同样挂账
             TradeContext.BESBNO  = TradeContext.BESBNOFIRST
           
        AfaLoggerFunc.tradeInfo("结束校验收款人户名是否一致")

    if (TradeContext.existVariable( "PYEACC" ) and len(TradeContext.PYEACC) != 0):       #收款人名称
        TradeContext.PYEACC      = TradeContext.PYEACC
    else:
        TradeContext.PYEACC      = ''
         
    if (TradeContext.existVariable( "PYENAM" ) and len(TradeContext.PYENAM) != 0):       #收款人名称
        TradeContext.OTNM      = TradeContext.PYENAM
    else:
        TradeContext.OTNM      = ''
        
    #汇兑往帐记帐字典赋值
    input_dict = {}
    
    if (TradeContext.existVariable( "PYRNAM" ) and len(TradeContext.PYRNAM) != 0):          #付款人户名
        TradeContext.SBACACNM      =      TradeContext.PYRNAM
        
    input_dict['accflag']     = str(accflag)                                #记挂标志
    input_dict['OCCAMT']      = TradeContext.OCCAMT                         #交易金额
    input_dict['PYEACC']      = TradeContext.PYEACC                         #收款人账号
    input_dict['OTNM']        = TradeContext.OTNM                           #收款人名称
    input_dict['BESBNO']      = TradeContext.BESBNO
        
    #调用汇兑记账接口
    rccpsEntries.HDLZJZ(input_dict)
    
    TradeContext.accflag    = accflag                                    #代理标志

    #=====开始调函数拼贷方账号第25位校验位====
    TradeContext.HostCode = '8813'                                   #调用8813主机接口
    TradeContext.RCCSMCD  = PL_RCCSMCD_HDLZ                          #主机摘要代码:汇兑来账
    TradeContext.ACUR = '1'
    ##========================= END 张恒 增加于20091011 来帐落机构及入帐挂账处理  =====================##

    #=====新增sstlog表状态记录====
    if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,TradeContext.BCSTAT,TradeContext.BDWFLG):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('M999', '设置状态['+TradeContext.BCSTAT+']['+TradeContext.BDWFLG+']失败,系统自动回滚')
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()

    return True
Esempio n. 8
0
def SubModuleDoFst():
    time.sleep(10)
    AfaLoggerFunc.tradeInfo('>>>进入撤销应答接收')
    #==========判断是否重复报文,如果是重复报文,直接进入下一流程================
    AfaLoggerFunc.tradeInfo(">>>开始检查是否重复报文")
    trccan_where_dict = {}
    trccan_where_dict['SNDBNKCO'] = TradeContext.SNDBNKCO
    trccan_where_dict['TRCDAT']   = TradeContext.TRCDAT
    trccan_where_dict['TRCNO']    = TradeContext.TRCNO

    trc_dict = rccpsDBTrcc_trccan.selectu(trccan_where_dict)

    if trc_dict == None:
        return AfaFlowControl.ExitThisFlow("S999","校验重复报文异常")

    if len(trc_dict) > 0:
        AfaLoggerFunc.tradeInfo("汇兑查询查复自由格式登记簿中存在相同查复交易,此报文为重复报文,进入下一流程,发送表示成功的通讯回执")
        #======为通讯回执报文赋值===============================================
        out_context_dict = {}
        out_context_dict['TRCCO']    = '9900503'
        out_context_dict['MSGTYPCO'] = 'SET008'
        out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
        out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
        out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
        out_context_dict['SNDCLKNO'] = TradeContext.BETELR
        out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
        out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
        out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
        out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
        out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
        out_context_dict['OPRTYPNO'] = '99'
        out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
        out_context_dict['TRANTYP']  = '0'
        out_context_dict['ORTRCCO']  = TradeContext.TRCCO
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '重复报文'
        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)
        TradeContext.SNDSTLBIN       = TradeContext.RCVMBRCO     #发起成员行号

        return True

    AfaLoggerFunc.tradeInfo(">>>结束检查是否重复报文")

    #==========根据发送行号,委托日期,交易流水号查询原交易信息===========
    AfaLoggerFunc.tradeInfo(">>>开始根据发送行号,委托日期,交易流水号查询交易信息")
    dict_where = {}
    dict_where['SNDBNKCO']  = TradeContext.OQTSBNK
    dict_where['TRCDAT']    = TradeContext.OCADAT
    dict_where['TRCNO']     = TradeContext.OCATNO

    dict = rccpsDBTrcc_trccan.selectu(dict_where)
    if dict == None:
        return AfaFlowControl.ExitThisFlow("S999","校验重复报文异常")

    tran_dict_where = {}
    tran_dict_where['BJEDTE']  =  dict['BOJEDT']
    tran_dict_where['BSPSQN']  =  dict['BOSPSQ']

    tran_dict = rccpsDBTrcc_trcbka.selectu(tran_dict_where)
    if tran_dict <= 0:
        return AfaFlowControl.ExitThisFlow("S999","未找到原交易")

    AfaLoggerFunc.tradeInfo(">>>结束根据发送行号,委托日期,交易流水号查询交易信息")

    #=====从TradeContext向字典trccan_dict赋值====
    TradeContext.BBSSRC  =  tran_dict['BBSSRC']
    TradeContext.BOJEDT  =  dict['BJEDTE']
    TradeContext.BOSPSQ  =  dict['BSPSQN']
    TradeContext.ORTRCCO =  dict['TRCCO']
    TradeContext.CUR     =  '01'
    TradeContext.OCCAMT  =  str(dict['OCCAMT'])

    AfaLoggerFunc.tradeDebug('>>>资金来源['+TradeContext.BBSSRC+']')

    trccan_dict = {}
    if not rccpsMap1106CTradeContext2Dtrccan_dict.map(trccan_dict):
        return AfaFlowControl.ExitThisFlow('S999','赋值错误')

    #=====插入登记簿rcc_trccan====
    AfaLoggerFunc.tradeDebug('>>>开始插入数据库')
    ret = rccpsDBTrcc_trccan.insertCmt(trccan_dict)
    if ret <= 0:
        return AfaFlowControl.ExitThisFlow('S999','插入数据库撤销申请登记簿trccan错误,抛弃报文') 

    #=====更新原撤销申请状态====
    trc_update = {}
    trc_update_where = {}
    trc_update_where['BJEDTE'] = TradeContext.BOJEDT
    trc_update_where['BSPSQN'] = TradeContext.BSPSQN
    trc_update['CLRESPN']= TradeContext.CLRESPN
    ret = rccpsDBTrcc_trccan.updateCmt(trc_update,trc_update_where)
    if ret <= 0:
        return AfaFlowControl.ExitThisFlow('S999','修改撤销申请登记簿原记录状态错误,抛弃报文')

    #=====原汇兑交易流水号,8820抹账使用====
    TradeContext.BOJEDT  =  tran_dict['BJEDTE']
    TradeContext.BOSPSQ  =  tran_dict['BSPSQN']

    #=====判断撤销应答标志是否允许撤销  0-允许撤销  1-不允许撤销 ====
    if TradeContext.CLRESPN  ==  '1':
        #=====发送接收正常回执====
        AfaLoggerFunc.tradeDebug('>>>中心不允许撤销,发送成功回执')
        out_context_dict = {}
        out_context_dict['sysType']  = 'rccpst'
        out_context_dict['TRCCO']    = '9900503'
        out_context_dict['MSGTYPCO'] = 'SET008'
        out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
        out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
        out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
        out_context_dict['SNDCLKNO'] = TradeContext.BETELR
        out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
        out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
        out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
        out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
        out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
        out_context_dict['OPRTYPNO'] = '99'
        out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
        out_context_dict['TRANTYP']  = '0'
        out_context_dict['ORTRCCO']  = TradeContext.TRCCO
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '成功'

        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)
        return True

    AfaLoggerFunc.tradeDebug('>>>中心允许撤销,向主机发起记账')

    #=====设置sstlog表中原记录状态为:抹账-处理中====
    TradeContext.BCSTAT  = PL_BCSTAT_HCAC
    TradeContext.BDWFLG  = PL_BDWFLG_WAIT

    if not rccpsState.newTransState(dict['BOJEDT'],dict['BOSPSQ'],TradeContext.BCSTAT,TradeContext.BDWFLG):
        return AfaFlowControl.ExitThisFlow('S999','设置状态出错,抛弃此报文')
    
    #=====commit操作====
    AfaDBFunc.CommitSql()


    AfaLoggerFunc.tradeDebug('>>>开始向主机接口赋值')
    #=====设置主机记账/抹账数据====
    if TradeContext.BBSSRC == '3':
        #=====代销账要发起8813红蓝字记账====
        TradeContext.HostCode = '8813'
        TradeContext.RCCSMCD = '614'                                      #往撤销
        TradeContext.DASQ    = ''
        TradeContext.RVFG    = '0'                                        #红蓝字标志 0
        #关彬捷 20080728 修改抹账挂账原因
        #TradeContext.NOTE3   = '向主机发起红蓝字记账冲销'
        TradeContext.NOTE3   = '中心允许撤销,自动抹账'
        TradeContext.RBAC    =  TradeContext.BESBNO  +  PL_ACC_NXYDXZ     #贷方账号
        TradeContext.SBAC    =  TradeContext.BESBNO  +  PL_ACC_NXYDQSWZ   #借方账号
        #=====开始调函数拼贷方账号第25位校验位====
        TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC, 25)
        TradeContext.SBAC = rccpsHostFunc.CrtAcc(TradeContext.SBAC, 25)
        AfaLoggerFunc.tradeInfo( '贷方账号:' + TradeContext.RBAC )
        AfaLoggerFunc.tradeInfo( '借方账号:' + TradeContext.SBAC )
    else:
        TradeContext.HostCode = '8820'
        
        #关彬捷 20080728 修改抹账挂账原因
        #TradeContext.NOTE3   = '向主机发起抹账'
        TradeContext.NOTE3   = '中心允许撤销,自动抹账'

    AfaLoggerFunc.tradeDebug('>>>更新sstlog表中原交易状态成功,开始更新交易状态')
    #=====设置sstlog标志状态为:抹账-处理中====
    if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,TradeContext.BCSTAT,TradeContext.BDWFLG):
        return AfaFlowControl.ExitThisFlow('S999','设置状态出错,抛弃此报文')
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()

    AfaLoggerFunc.tradeDebug('>>>开始调用主机函数')
    AfaLoggerFunc.tradeDebug('>>>主机交易代码['+TradeContext.HostCode+']')
    #=====向主机发起抹账操作====
    rccpsHostFunc.CommHost(TradeContext.HostCode)
   
    #=====判断主机返回结果设置状态====
    sstlog_dict = {}
    sstlog_dict['BJEDTE'] = TradeContext.BJEDTE
    AfaLoggerFunc.tradeDebug('>>>交易日期['+TradeContext.BJEDTE+']')
    sstlog_dict['BSPSQN'] = TradeContext.BSPSQN
    AfaLoggerFunc.tradeDebug('>>>报单序号['+TradeContext.BSPSQN+']')
    sstlog_dict['BCSTAT']  = TradeContext.BCSTAT
    AfaLoggerFunc.tradeDebug('>>>业务状态['+TradeContext.BCSTAT+']')
    sstlog_dict['NOTE4']  = TradeContext.errorMsg
    AfaLoggerFunc.tradeDebug('>>>主机返回信息['+TradeContext.errorMsg+']')
    sstlog_dict['NOTE3']   = TradeContext.NOTE3
    AfaLoggerFunc.tradeDebug('>>>NOTE3['+TradeContext.NOTE3+']')
    AfaLoggerFunc.tradeDebug('>>>errorCode['+TradeContext.errorCode+']')
    if TradeContext.existVariable('TRDT'):
        sstlog_dict['TRDT']   = TradeContext.TRDT
        AfaLoggerFunc.tradeDebug('>>>主机日期['+TradeContext.TRDT+']')
    if TradeContext.existVariable('TLSQ'):
        sstlog_dict['TLSQ']   = TradeContext.TLSQ
        AfaLoggerFunc.tradeDebug('>>>主机流水['+TradeContext.TLSQ+']')

    if TradeContext.errorCode == '0000':
        AfaLoggerFunc.tradeDebug('>>>测试')

        if TradeContext.HostCode == '8813':
            sstlog_dict['DASQ']   = TradeContext.DASQ
            AfaLoggerFunc.tradeDebug('>>>销账序号['+TradeContext.DASQ+']')
            sstlog_dict['SBAC']   = TradeContext.SBAC
            AfaLoggerFunc.tradeDebug('>>>借方账号['+TradeContext.SBAC+']')
            sstlog_dict['RBAC']   = TradeContext.RBAC
            AfaLoggerFunc.tradeDebug('>>>贷方账号['+TradeContext.RBAC+']')

        AfaLoggerFunc.tradeDebug('>>>测试2')
        sstlog_dict['BDWFLG'] = PL_BDWFLG_SUCC
    else:
        AfaLoggerFunc.tradeDebug('>>>测试1')
        sstlog_dict['BDWFLG'] = PL_BDWFLG_FAIL

    AfaLoggerFunc.tradeDebug('>>>主机返回信息')
    #=====设置原交易状态====
    if not rccpsState.setTransState(sstlog_dict):
        return AfaFlowControl.ExitThisFlow('S999','更新主机返回信息出错,抛弃报文')
    
    #=====commit操作====
    AfaDBFunc.CommitSql()

    #=====设置交易状态====
    sstlog_dict['BJEDTE']  = TradeContext.BOJEDT
    sstlog_dict['BSPSQN']  = TradeContext.BOSPSQ

    if not rccpsState.setTransState(sstlog_dict):
        return AfaFlowControl.ExitThisFlow('S999','更新主机返回信息出错,抛弃报文')
    
    #=====commit操作====
    AfaDBFunc.CommitSql()


    #=====发送回执,其它错误====
    out_context_dict = {}
    out_context_dict['sysType']  = 'rccpst'
    out_context_dict['TRCCO']    = '9900503'
    out_context_dict['MSGTYPCO'] = 'SET008'
    out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
    out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
    out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
    out_context_dict['SNDCLKNO'] = TradeContext.BETELR
    out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
    out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
    out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
    out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
    out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
    out_context_dict['OPRTYPNO'] = '99'
    out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
    out_context_dict['TRANTYP']  = '0'
    out_context_dict['ORTRCCO']  = TradeContext.TRCCO
    out_context_dict['PRCCO']    = 'RCCI0000'
    out_context_dict['STRINFO']  = '成功'

    rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)
    
    return True
Esempio n. 9
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作(1.本地操作)对账差错登记簿查询[TRC001_8542]进入***' )
    
    #=====判断输入接口值是否存在====
    if( not TradeContext.existVariable( "STRDAT" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '起始日期[STRDAT]不存在')
    if( not TradeContext.existVariable( "ENDDAT" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '终止日期[ENDDAT]不存在')
    if( not TradeContext.existVariable( "OPRTYPNO" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '交易类型[OPRTYPNO]不存在')
    if( not TradeContext.existVariable( "RECSTRNO" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '起始笔数[RECSTRNO]不存在')
    
    #=====组织sql语句====
    wheresql=""
    wheresql=wheresql+"BJEDTE>='"+TradeContext.STRDAT+"'"
    wheresql=wheresql+" AND BJEDTE<='"+TradeContext.ENDDAT+"'"
    
    ordersql = " order by NCCWKDAT DESC"
    
    start_no=TradeContext.RECSTRNO          #起始笔数
    sel_size=10                             #查询笔数
    
    #=====20 汇兑====
    if TradeContext.OPRTYPNO == '20':
        #=====查询总笔数====
        allcount=rccpsDBTrcc_hddzcz.count(wheresql)
        if(allcount == -1):
            return AfaFlowControl.ExitThisFlow('S999', '查询总记录数异常')
        
        #=====查询明细====
        records=rccpsDBTrcc_hddzcz.selectm(start_no,sel_size,wheresql,ordersql)
        if(records == None):
            return AfaFlowControl.ExitThisFlow('S999', '查询汇兑错账登记簿异常')
        if(len(records) <= 0):
            return AfaFlowControl.ExitThisFlow('S999', '汇兑错账登记簿中无对应信息') 
    
    #=====21 汇票====        
    if TradeContext.OPRTYPNO == '21':
        #=====查询总笔数====
        allcount=rccpsDBTrcc_hpdzcz.count(wheresql)
        if(allcount == -1):
            return AfaFlowControl.ExitThisFlow('S999', '查询总记录数异常')
        
        #=====查询明细====
        records=rccpsDBTrcc_hpdzcz.selectm(start_no,sel_size,wheresql,ordersql)
        if(records == None):
            return AfaFlowControl.ExitThisFlow('S999', '查询汇票错账登记簿异常')
        if(len(records) <= 0):
            return AfaFlowControl.ExitThisFlow('S999', '汇票错账登记簿中无对应信息')
    
    #=====30 通存通兑(刘振东 20081024 添加)====        
    if TradeContext.OPRTYPNO == '30':
        #=====查询总笔数====
        allcount=rccpsDBTrcc_tddzcz.count(wheresql)
        if(allcount == -1):
            return AfaFlowControl.ExitThisFlow('S999', '查询总记录数异常')
        
        #=====查询明细====
        records=rccpsDBTrcc_tddzcz.selectm(start_no,sel_size,wheresql,ordersql)
        if(records == None):
            return AfaFlowControl.ExitThisFlow('S999', '查询汇票错账登记簿异常')
        if(len(records) <= 0):
            return AfaFlowControl.ExitThisFlow('S999', '汇票错账登记簿中无对应信息')
    
    #=====生成文件====
    AfaLoggerFunc.tradeInfo( "生成文件")
    filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
    try:
        pub_path = os.environ["AFAP_HOME"]
        pub_path = pub_path + "/tmp/"
        f=open(pub_path+filename,"w")
    except IOError:
        return AfaLoggerFunc.ExitThisFlow('S099','打开文件失败')
        
    #=====写文件操作====
    try:
        filecontext=""
        for i in range(0,len(records)):
            #=====生成文件内容====
            filecontext=records[i]['NCCWKDAT'] + "|" \
                       +records[i]['BJEDTE']   + "|" \
                       +records[i]['BSPSQN']   + "|" \
                       +records[i]['SNDBNKCO'] + "|" \
                       +records[i]['TRCDAT']   + "|" \
                       +records[i]['TRCNO']    + "|" \
                       +records[i]['EACTYP']   + "|" \
                       +records[i]['EACINF']   + "|" \
                       +records[i]['ISDEAL']   + "|" \
            
            #曾照泰20120614添加明细文件中增加接收行号
            filecontext1=""
            #=====20 汇兑====
            if(TradeContext.OPRTYPNO == '20'): 
                trcbka_sql = {}
                trcbka_sql = {'BJEDTE':records[i]['BJEDTE'],'BSPSQN':records[i]['BSPSQN']}
                result=rccpsDBTrcc_trcbka.selectu(trcbka_sql)
                if(result == None):
                    return AfaFlowControl.ExitThisFlow('S999', '查询汇兑业务登记簿异常')
                
                if(len(result) <= 0):
                    filecontext1=" " + "|" 
                else:
                    filecontext1= result['RCVBNKCO']+ "|" 
            #=====21 汇票====        
            elif TradeContext.OPRTYPNO == '21': 
                bilbka_sql = {}
                bilbka_sql = {'BJEDTE':records[i]['BJEDTE'],'BSPSQN':records[i]['BSPSQN']}
                result=rccpsDBTrcc_bilbka.selectu(bilbka_sql)
                AfaLoggerFunc.tradeInfo(result)
                if(result == None):
                    return AfaFlowControl.ExitThisFlow('S999', '查询汇票业务登记簿异常')
                
                if(len(result) <= 0):
                    filecontext1=" " + "|" 
                else:
                    filecontext1= result['RCVBNKCO']+ "|"              
            
            else:
                filecontext1= records[i]['RCVBNKCO'] + "|" 
            filecontext=filecontext+filecontext1 
            #end  
            f.write(filecontext+"\n")
    except Exception,e:     
        f.close()
        return AfaFlowControl.ExitThisFlow('S099','写文件失败')
Esempio n. 10
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统: 往账.本地类操作交易[RCC001_8522]进入***' )
    
    #=====判断接口是否存在====
    if( not TradeContext.existVariable( "BJEDTE" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '交易日期[BJEDTE]不存在')        
    if( not TradeContext.existVariable( "BSPSQN" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '报单序号[BSPSQN]不存在')       
    if( not TradeContext.existVariable( "OPRTYPNO" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '业务种类[OPRTYPNO]不存在')       
    if( not TradeContext.existVariable( "BCURSQ" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '当前处理编号[BCURSQ]不存在')
        
    #=====查询历史状态表得到主机日期和主机流水号====
    
    where_sql={'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'BCURSQ':TradeContext.BCURSQ}
    
    ret=rccpsDBTrcc_sstlog.selectu(where_sql)
    if(ret==None):
        return AfaFlowControl.ExitThisFlow('A099', '查询历史状态表失败')
    if(len(ret)==0):
        return AfaFlowControl.ExitThisFlow('A099', '查询历史状态表结果为空')
    if(ret['TRDT']=="" or ret['TLSQ']==""):
        return AfaFlowControl.ExitThisFlow('A099', '此序号状态非成功的账务状态')
             
    #=====PL_TRCCO_HP 21 汇票====
    if(TradeContext.OPRTYPNO==PL_TRCCO_HP):
        AfaLoggerFunc.tradeInfo("进入汇票处理")

        records1={}
        #=====查询汇票业务登记簿====
        bilbka_where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN} 
        res_bilbka = rccpsDBTrcc_bilbka.selectu(bilbka_where_dict)  
        if( res_bilbka == None):
            return AfaFlowControl.ExitThisFlow('S999', '查询汇票交易登记簿失败')          
        if( len(res_bilbka) == 0 ):
            return AfaFlowControl.ExitThisFlow('S999', '查询汇票交易登记簿结果为空')
            
        #=====查询状态明细表====
        sstlog_where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'BCURSQ':TradeContext.BCURSQ}
        res_sstlog = rccpsDBTrcc_sstlog.selectu(sstlog_where_dict)
        if( res_sstlog == None):
            return AfaFlowControl.ExitThisFlow('S999', '查询历史状态登记簿失败')            
        if( len(res_sstlog) == 0):
            return AfaFlowControl.ExitThisFlow('S999', '查询历史状态登记簿结果为空')
            
        #=====给resords1赋值,字典相加赋值到新的字典====
        records1.update(res_bilbka)
        records1.update(res_sstlog)
        
        #=====判断是否为签发机构====
        AfaLoggerFunc.tradeInfo("开始判断当前机构是否为交易机构")

        if( records1['BESBNO'] != TradeContext.BESBNO ):
            return AfaFlowControl.ExitThisFlow('S999', '为查找到数据')
            
        AfaLoggerFunc.tradeInfo("结束判断当前机构是否为交易机构")   
        
        #=====判断是否为往账业务====
        if records1['BRSFLG'] != PL_BRSFLG_SND:
            return AfaFlowControl.ExitThisFlow('S999','报单序号['+TradeContext.BSPSQN+']该笔业务为来账业务,不允许打印')
        
#        #=====判断汇票状态,如果是撤销则不让打印====
#        if(records1['HPSTAT'] == PL_HPSTAT_CANC ):
#            return AfaFlowControl.ExitThisFlow('S999','此汇票为撤销状态,不允许打印')
        
        #=====判断当前状态====
        #=====PL_BCSTAT_ACC  20 记账====
        #=====PL_BCSTAT_HCAC 21 抹账====
        if(records1['BCSTAT']!=PL_BCSTAT_ACC and records1['BCSTAT']!=PL_BCSTAT_HCAC):
            return AfaFlowControl.ExitThisFlow('A009',"当前状态[" + records1['BCSTAT'] + "]不允许打印")
                
        records2={}
        #=====查询汇票信息登记簿====
        res=rccpsDBFunc.getInfoBil(records1['BILVER'],records1['BILNO'],records1['BILRS'],records2)
        if(res==False):
            return AfaFlowControl.ExitThisFlow('D003','汇票信息登记簿中无记录')    
        
        #=====输出接口====
        rccpsMap8522DTrans2CTradeContext.map(records1)
        rccpsMap8522DInfo2CTradeContext.map(records2)
        
        TradeContext.PRTDAT  =  AfaUtilTools.GetHostDate()          #打印日期
        TradeContext.PRTTIM  =  AfaUtilTools.GetSysTime()           #打印时间
        TradeContext.PRTCNT  =  str(int(TradeContext.PRTCNT)+1)     #打印次数
        TradeContext.BCSTAT  =  ret['BCSTAT']                       #当前状态
        TradeContext.BDWFLG  =  ret['BDWFLG']                       #流转处理标识
        TradeContext.TRDT    =  ret['TRDT']                         #主机日期
        TradeContext.TLSQ    =  ret['TLSQ']                         #主机流水
        TradeContext.OCCAMT  =  str(TradeContext.OCCAMT)            #交易金额
        TradeContext.BILAMT  =  str(TradeContext.BILAMT)            #出票金额
        TradeContext.RMNAMT  =  str(TradeContext.RMNAMT)            #结余金额
                
        #=====更新打印标志====
        AfaLoggerFunc.tradeInfo("开始更新打印标志")
        
        update_dict={'PRTCNT':TradeContext.PRTCNT}
        where_dict={'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'BCSTAT':TradeContext.BCSTAT}
        
        rownum=rccpsDBTrcc_sstlog.update(update_dict,where_dict)
        if(rownum<=0):
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow('S999','修改数据库打印次数失败')
        else:
            AfaLoggerFunc.tradeDebug('>>>commit 成功')
        
        AfaDBFunc.CommitSql()
               
        TradeContext.errorCode="0000"
        TradeContext.errorMsg="查询成功"
       
    #=====PL_TRCCO_HD 20 汇兑====
    elif(TradeContext.OPRTYPNO==PL_TRCCO_HD):
        AfaLoggerFunc.tradeInfo("进入汇兑处理")

        records={}
        #=====查询汇兑登记簿====
        trcbka_where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN}
        res_trcbka = rccpsDBTrcc_trcbka.selectu(trcbka_where_dict)
        if( res_trcbka == None ):
            return AfaFlowControl.ExitThisFlow('S999', '查询汇兑登记簿异常')
            
        if( len(res_trcbka) == 0 ):
            return AfaFlowControl.ExitThisFlow('S999', '查询汇兑登记簿结果为空')
            
        #=====查询历史状态表====
        sstlog_where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'BCURSQ':TradeContext.BCURSQ}
        res_sstlog = rccpsDBTrcc_sstlog.selectu(sstlog_where_dict)
        if( res_sstlog == None):
            return AfaFlowControl.ExitThisFlow('S999', '查询历史状态登记簿失败')            
        if( len(res_sstlog) == 0):
            return AfaFlowControl.ExitThisFlow('S999', '查询历史状态登记簿结果为空')
            
        #=====给records赋值,字典相加赋值到新的字典====
        records.update(res_trcbka)
        records.update(res_sstlog)
        
        #=====判断是否为签发机构====
        AfaLoggerFunc.tradeInfo("开始判断当前机构是否为交易机构")
        if( records['BESBNO'] != TradeContext.BESBNO ):
            return AfaFlowControl.ExitThisFlow('S999', '非签发机构')
            
        AfaLoggerFunc.tradeInfo("结束判断当前机构是否为交易机构")
        
        #=====判断是否为往账业务====
        if records['BRSFLG'] != PL_BRSFLG_SND:
            return AfaFlowControl.ExitThisFlow('S999','报单序号['+TradeContext.BSPSQN+']该笔业务为来账业务,不允许打印')
        
        #=====判断当前状态====
        #=====PL_BCSTAT_ACC  20 记账====
        #=====PL_BCSTAT_HCAC 21 抹账====
        if not (records['BCSTAT']==PL_BCSTAT_ACC or records['BCSTAT'] == PL_BCSTAT_HCAC):
            return AfaFlowControl.ExitThisFlow('A009',"当前状态[" + records1['BCSTAT'] + "]不允许打印")
        
        rccpsMap8522DTransTrc2CTradeContext.map(records)
        
        #=====输出接口====
        TradeContext.PRTDAT  = AfaUtilTools.GetHostDate()       #打印日期
        TradeContext.PRTTIM  = AfaUtilTools.GetSysTime()        #打印时间
        TradeContext.PRTCNT  = str(int(TradeContext.PRTCNT)+1)  #打印次数
        TradeContext.OCCAMT  = str(TradeContext.OCCAMT)         #交易金额
        TradeContext.BILAMT  = str(TradeContext.COMAMT)	        #出票金额
        TradeContext.BCSTAT  = ret['BCSTAT']                    #当前状态
        TradeContext.BDWFLG  = ret['BDWFLG']                    #流转处理标识
        TradeContext.TRDT    = ret['TRDT']                      #主机日期
        TradeContext.TLSQ    = ret['TLSQ']                      #主机流水号
        
        #=====更新打印标志====
        AfaLoggerFunc.tradeInfo("开始更新打印标志")
        update_dict={'PRTCNT':TradeContext.PRTCNT}
        where_dict={'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'BCSTAT':TradeContext.BCSTAT}
        rownum=rccpsDBTrcc_sstlog.update(update_dict,where_dict)
        if(rownum<=0):
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow('S999','修改数据库打印次数失败')
        
        AfaDBFunc.CommitSql()
        TradeContext.errorCode="0000"
        TradeContext.errorMsg="查询成功"
    
    #=====30 通存通兑====
    elif( TradeContext.OPRTYPNO == PL_TRCCO_TCTD ):
        AfaLoggerFunc.tradeInfo("进入通存通兑处理")
        
        records = {}
        #=====查询交易信息====
        AfaLoggerFunc.tradeInfo("查询交易信息")
        wtrbka_where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN}
        res_wtrbka = rccpsDBTrcc_wtrbka.selectu(wtrbka_where_dict)
        if( len(res_wtrbka) == 0 ):
            return AfaFlowControl.ExitThisFlow('A009','查询交易信息结果为空')
        if( res_wtrbka == None ):
            return AfaFlowControl.ExitThisFlow('A009','查询交易信息失败')
            
        #=====查询交易的历史状态====    
        AfaLoggerFunc.tradeInfo("查询交易的历史状态")
        sstlog_where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'BCURSQ':TradeContext.BCURSQ}
        res_sstlog = rccpsDBTrcc_sstlog.selectu(sstlog_where_dict)
        if( len(res_sstlog) == 0 ):
            return AfaFlowControl.ExitThisFlow('A009','查询交易历史状态结果为空')
        if( res_sstlog == None ):
            return AfaFlowControl.ExitThisFlow('A009','查询交易历史状态失败')
            
        #=====给records字典赋值,字典相加,赋值到新的字典====
        records.update(res_wtrbka)
        records.update(res_sstlog)
        
        #=====判断是否为签发机构====
        AfaLoggerFunc.tradeInfo("判断是否为签发机构")
        if( records['BESBNO'] != TradeContext.BESBNO ):
            return AfaFlowControl.ExitThisFlow('A009','此机构不是签发机构')
        
        #=====判断此交易是否为往账====
        AfaLoggerFunc.tradeInfo("判断此交易是否为往账")
        if( records['BRSFLG'] != PL_BRSFLG_SND ):
            return AfaFlowControl.ExitThisFlow('A009','此交易不是往账交易')
            
        #=====判断交易状态====
        AfaLoggerFunc.tradeInfo("判断此交易状态")
        if not ( records['BCSTAT'] == PL_BCSTAT_ACC or records['BCSTAT'] == PL_BCSTAT_HCAC or records['BCSTAT'] == PL_BCSTAT_CANCEL or records['BCSTAT'] == PL_BCSTAT_CANC):
            return AfaFlowControl.ExitThisFlow('A009','此状态不允许打印')
        
        if(records['BCSTAT'] == PL_BCSTAT_CANCEL or records['BCSTAT'] == PL_BCSTAT_CANC):
            if(records['TRDT'] == "" or records['TLSQ'] == ""):
                return AfaFlowControl.ExitThisFlow('A009','此笔业务没有产生产生账务')
            
            
        rccpsMap8522Drecords2CTradeContext.map(records)
        
        #=====输出接口====
        AfaLoggerFunc.tradeInfo("给输出接口赋值")
        TradeContext.PRTDAT  = AfaUtilTools.GetHostDate()
        TradeContext.PRTTIM  = AfaUtilTools.GetSysTime() 
        TradeContext.PRTCNT  = str(int(records['PRTCNT'])+1) 
        TradeContext.USE     = ""
        TradeContext.BILAMT  = str(records['OCCAMT']) 
        TradeContext.BCSTAT  = ret['BCSTAT']                    #当前状态
        TradeContext.BDWFLG  = ret['BDWFLG']                    #流转处理标识
        TradeContext.TRDT    = ret['TRDT']                      #主机日期
        TradeContext.TLSQ    = ret['TLSQ']                      #主机流水号    
        TradeContext.REMARK  = ""
        TradeContext.DASQ    = records['DASQ']                  #销账序号
        TradeContext.BNKBKNO = records['BNKBKNO']               #存折号码
        TradeContext.CHSHTP  = records['CHRGTYP']               #手续费收取方式
        if(records['TRCCO'] in ('3000002','30000102')):         #卡折标志
            TradeContext.PYITYP = records['PYETYP']
        else:
            TradeContext.PYITYP = records['PYRTYP']

        #=====更新打印标志====        
        AfaLoggerFunc.tradeInfo("开始更新打印标志")
        update_dict={'PRTCNT':str(int(records['PRTCNT'])+1)}
        where_dict={'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'BCURSQ':TradeContext.BCURSQ}
        rownum=rccpsDBTrcc_sstlog.update(update_dict,where_dict)
        if(rownum<=0):
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow('S999','修改数据库打印次数失败')
        
        AfaDBFunc.CommitSql()
        TradeContext.errorCode="0000"
        TradeContext.errorMsg="查询成功"
         
    else:
        return AfaFlowControl.ExitThisFlow('A009','业务种类非法')

    AfaLoggerFunc.tradeInfo( '***农信银系统: 往账.本地类操作交易[RCC001_8522]退出***' )
    return True