Пример #1
0
def getTransWtrCK(SNDBNKCO,COTRCDAT,COTRCNO,wtr_dict):
    AfaLoggerFunc.tradeInfo( ">>>开始查询通存通兑业务登记簿[" + SNDBNKCO + "][" + COTRCDAT + "][" + COTRCNO + "]交易信息" )
    
    #===========组织查询条件===================================================
    wtrbka_where_dict = {'SNDBNKCO':SNDBNKCO,'COTRCDAT':COTRCDAT,'COTRCNO':COTRCNO}

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

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

    BJEDTE = wtrbka_dict["BJEDTE"]
    BSPSQN = wtrbka_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_dict2Dwtr_dict.map(stat_dict,wtr_dict):
        return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的业务状态详细信息赋值到输出字典异常' )
    
    AfaLoggerFunc.tradeInfo( ">>>结束查询通存通兑业务登记簿[" + BJEDTE + "][" + BSPSQN + "]交易信息" )
    return True
Пример #2
0
def getTransBilAK(SNDBNKCO,TRCDAT,TRCNO,bil_dict):
    AfaLoggerFunc.tradeInfo( ">>>开始查询汇票业务登记簿[" + SNDBNKCO + "][" + TRCDAT + "][" + TRCNO + "]交易信息" )
    
    #==========组织查询条件=====================================================
    bilbka_where_dict = {'SNDBNKCO':SNDBNKCO,'TRCDAT':TRCDAT,'TRCNO':TRCNO}

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

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

    BJEDTE = bilbka_dict["BJEDTE"]
    BSPSQN = bilbka_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_dict2Dbil_dict.map(stat_dict,bil_dict):
        return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的业务状态详细信息赋值到输出字典异常' )
    
    AfaLoggerFunc.tradeInfo( ">>>结束查询汇票业务登记簿[" + BJEDTE + "][" + BSPSQN + "]交易信息" )
    return True
Пример #3
0
def getTransBil(BJEDTE,BSPSQN,bil_dict):
    AfaLoggerFunc.tradeInfo( ">>>开始查询汇票业务登记簿[" + BJEDTE + "][" + BSPSQN + "]交易信息" )
    
    #==========组织查询条件=====================================================
    bilbka_where_dict = {'BJEDTE':BJEDTE,'BSPSQN':BSPSQN}

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

    #==========将查询出的汇票业务登记簿相关业务信息赋值到输出字典===============
    if not rccpsMap0000Dbilbka2Dbil_dict.map(bilbka_dict,bil_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_dict2Dbil_dict.map(stat_dict,bil_dict):
        return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的业务状态详细信息赋值到输出字典异常' )
    
    AfaLoggerFunc.tradeInfo( ">>>结束查询汇票业务登记簿[" + BJEDTE + "][" + BSPSQN + "]交易信息" )
    return True
Пример #4
0
def getTransWtr(BJEDTE,BSPSQN,wtr_dict):
    AfaLoggerFunc.tradeDebug( ">>>开始查询通存通兑业务登记簿[" + BJEDTE + "][" + BSPSQN + "]交易信息" )
                                                                     
    #==========组织查询条件=====================================================
    wtrbka_where_dict = {'BJEDTE':BJEDTE,'BSPSQN':BSPSQN}            
                                                                     
    #==========查询汇兑登记簿相关业务信息=======================================
    wtrbka_dict = rccpsDBTrcc_wtrbka.selectu(wtrbka_where_dict)  
    
    if wtrbka_dict == None:
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow( 'S999', '查询通存通兑业务登记簿交易信息异常' )
        
    if len(wtrbka_dict) <= 0:
        return AfaFlowControl.ExitThisFlow( 'S999', '通存通兑业务登记簿中无此交易信息' )
    
    #==========将查询出的通存通兑登记簿相关业务信息赋值到输出字典==============
    if not rccpsMap0000Dwtrbka2Dwtr_dict.map(wtrbka_dict,wtr_dict):
        return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的通存通兑登记簿相关业务信息赋值到输出字典异常' )
        
    #==========查询当前业务状态================================================
    AfaLoggerFunc.tradeDebug( ">>>开始查询交易[" + BJEDTE + "][" + BSPSQN + "]当前状态" )
    
    stat_dict = {}
    
    if not rccpsState.getTransStateCur(BJEDTE,BSPSQN,stat_dict):
        return False
        
    AfaLoggerFunc.tradeDebug( ">>>结束查询交易[" + BJEDTE + "][" + BSPSQN + "]当前状态" )

    #==========将查询出的业务状态详细信息赋值到输出字典========================
    if not rccpsMap0000Dstat_dict2Dwtr_dict.map(stat_dict,wtr_dict):
        return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的业务状态详细信息赋值到输出字典异常' )
    
    AfaLoggerFunc.tradeDebug( ">>>结束查询通存通兑业务登记簿[" + BJEDTE + "][" + BSPSQN + "]交易信息" )
    return True
Пример #5
0
 AfaLoggerFunc.tradeInfo(">>>Commit成功")
 
 AfaLoggerFunc.tradeInfo(">>>结束登记来账信息")
 
 AfaLoggerFunc.tradeInfo(">>>结束补来账")
 
 #========更新汇兑对账明细登记簿================================
 AfaLoggerFunc.tradeInfo(">>>开始更新汇兑明细登记簿")
 
 hddzmx_where_dict = {}
 hddzmx_where_dict['SNDBNKCO'] = hddzcz_list[i]['SNDBNKCO']
 hddzmx_where_dict['TRCDAT']   = hddzcz_list[i]['TRCDAT']
 hddzmx_where_dict['TRCNO']    = hddzcz_list[i]['TRCNO']
 
 stat_dict = {}
 if not rccpsState.getTransStateCur(TradeContext.BJEDTE,TradeContext.BSPSQN,stat_dict):
     rccpsCronFunc.cronExit(TradeContext.errorCode,TradeContext.errorMsg)
 
 hddzmx_update_dict = {}
 hddzmx_update_dict['BJEDTE'] = TradeContext.BJEDTE
 hddzmx_update_dict['BSPSQN'] = TradeContext.BSPSQN
 hddzmx_update_dict['BCSTAT'] = stat_dict['BCSTAT']
 hddzmx_update_dict['BDWFLG'] = stat_dict['BDWFLG']
 
 ret = rccpsDBTrcc_hddzmx.updateCmt(hddzmx_update_dict,hddzmx_where_dict)
 
 if ret <= 0:
     AfaLoggerFunc.tradeInfo("sqlErrMsg=" + AfaDBFunc.sqlErrMsg)
     rccpsCronFunc.cronExit("S999","登记汇兑对账明细登记簿交易行内信息异常")
 
 AfaLoggerFunc.tradeInfo(">>>结束更新汇兑明细登记簿")
Пример #6
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统: 往账.本地类操作交易[RCC001_8524]进入***' )
    
    #=====判断输入接口值是否存在====
    if( not TradeContext.existVariable( "STRDAT" ) ):
        return AfaFlowControl.ExitThisFlow('A099','起始日期[STRDAT]不存在' )
    if( not TradeContext.existVariable( "ENDDAT" ) ):
        return AfaFlowControl.ExitThisFlow('A099','终止日期[ENDDAT]不存在' )
    if( not TradeContext.existVariable( "BRSFLG" ) ):
        return AfaFlowControl.ExitThisFlow('A099','往来标志[BRSFLG]不存在' )
        
    #=====组织查询sql语句====
    AfaLoggerFunc.tradeInfo( "组织查询语句")


    if(TradeContext.BESBNO == "3400008889" and TradeContext.RCVBNKCO != ""):    
        sql= "BJEDTE >='"+TradeContext.STRDAT+"' and BJEDTE <='"
        sql= sql + TradeContext.ENDDAT + "'"
    else:
        sql= "BESBNO='" + TradeContext.BESBNO + "' " 
        sql= sql + "and BJEDTE >='"+TradeContext.STRDAT+"' and BJEDTE <='"
        sql= sql + TradeContext.ENDDAT + "'"
    
    if(TradeContext.BRSFLG != ""):
        sql= sql + " and BRSFLG='"+TradeContext.BRSFLG+"'"
        
    AfaLoggerFunc.tradeDebug( "1.sql=" + sql )
    #=====判断其它查询条件是否存在====
    if(TradeContext.OPRNO != ""):               #业务属性
        sql = sql + " and OPRNO='" + TradeContext.OPRNO + "'"
    if(TradeContext.OPRATTNO != ""):            #业务属性
        sql = sql + " and OPRATTNO='" + TradeContext.OPRATTNO + "'"
    if(TradeContext.BSPSQN != ""):              #报单序号
        sql = sql + " and BSPSQN='" + TradeContext.BSPSQN + "'"
    if(float(TradeContext.OCCAMT) != 0.0):      #交易金额
        sql = sql + " and OCCAMT=" + TradeContext.OCCAMT
    if(TradeContext.RCVBNKCO != ""):            #接收行号
        sql = sql + " and RCVBNKCO='" + TradeContext.RCVBNKCO + "'"
    if(TradeContext.BCSTAT != ""):              #交易状态
        if(TradeContext.BDWFLG!= ""):           #流转标志
            sql = sql + " and exists (select * from RCC_SPBSTA where "
            sql = sql + " BJEDTE = RCC_TRCBKA.BJEDTE"
            sql = sql + " and BSPSQN = RCC_TRCBKA.BSPSQN"
            sql = sql + " and BCSTAT = '" + TradeContext.BCSTAT + "'"
            sql = sql + " and BDWFLG='" + TradeContext.BDWFLG + "')"
        else:
            sql = sql + " and exists (select * from RCC_SPBSTA tab2 where "
            sql = sql + " BJEDTE = RCC_TRCBKA.BJEDTE"
            sql = sql + " and BSPSQN = RCC_TRCBKA.BSPSQN"
            sql = sql + " and BCSTAT = '" + TradeContext.BCSTAT + "')"
            
    AfaLoggerFunc.tradeDebug( "sql=" + sql )
    
    #=====开始查询总笔数====
    TradeContext.RECALLCOUNT=str(rccpsDBTrcc_trcbka.count(sql))     #总记录笔数
    
    AfaLoggerFunc.tradeDebug( '>>>总笔数=' + TradeContext.RECALLCOUNT )
    
    #=====查询数据库====    
    ordersql=" order by BJEDTE DESC,BSPSQN DESC"   #组织按降序排列排序
    AfaLoggerFunc.tradeInfo("查询条件为:"+sql)
    
    records=rccpsDBTrcc_trcbka.selectm(TradeContext.RECSTRNO,10,sql,ordersql)
    
    if(records==None):
        return AfaFlowControl.ExitThisFlow('A099','查询失败' )       
    elif(len(records)==0):
        return AfaFlowControl.ExitThisFlow('A099','没有查找到记录' )    
    else:        		
        try:
            #=====打开文件====	
            AfaLoggerFunc.tradeInfo(">>>生成文件")
            filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetHostDate()+"_"+TradeContext.TransCode
            fpath=os.environ["AFAP_HOME"]+"/tmp/"

            f=open(fpath+filename,"w")
	        
            #=====PL_HDOPRNO_TH 09 退汇====
            if(TradeContext.OPRNO==PL_HDOPRNO_TH):	
                AfaLoggerFunc.tradeInfo(">>>进入退汇处理")	
	            #=====得到文件内容,生成文件====
                for i in range(0,len(records)):
                    #=====得到业务状态BCSTAT====
                    state_dict={}
                    ret=rccpsState.getTransStateCur(records[i]['BJEDTE'],records[i]['BSPSQN'],state_dict)
                    if(ret==False):
                        return AfaFlowControl.ExitThisFlow( 'S999', '当前状态登记簿中无此交易状态' )
                    #=====写文件操作====
                    filecontext = records[i]['BJEDTE']        + "|" \
                                + records[i]['BSPSQN']        + "|" \
                                + records[i]['BRSFLG']        + "|" \
                                + records[i]['BESBNO']        + "|" \
                                + records[i]['BEACSB']        + "|" \
                                + records[i]['BETELR']        + "|" \
                                + records[i]['BEAUUS']        + "|" \
                                + records[i]['TRCCO']         + "|" \
                                + records[i]['OPRNO']         + "|" \
                                + records[i]['OPRATTNO']      + "|" \
                                + records[i]['TRCDAT']        + "|" \
                                + records[i]['TRCNO']         + "|" \
                                + records[i]['SNDBNKCO']      + "|" \
                                + records[i]['SNDBNKNM']      + "|" \
                                + records[i]['RCVBNKCO']      + "|" \
                                + records[i]['RCVBNKNM']      + "|" \
                                + records[i]['CUR']           + "|" \
                                + str(records[i]['OCCAMT'])   + "|" \
                                + records[i]['PYRACC']        + "|" \
                                + records[i]['PYRNAM']        + "|" \
                                + records[i]['PYRADDR']       + "|" \
                                + records[i]['PYEACC']        + "|" \
                                + records[i]['PYENAM']        + "|" \
                                + records[i]['PYEADDR']       + "|" \
                                + records[i]['USE']           + "|" \
                                + records[i]['REMARK']        + "|" \
                                + records[i]['BILTYP']        + "|" \
                                + records[i]['BILDAT']        + "|" \
                                + records[i]['BILNO']         + "|" \
                                + str(records[i]['COMAMT'])   + "|" \
                                + str(records[i]['OVPAYAMT']) + "|" \
                                + str(records[i]['CPSAMT'])   + "|" \
                                + str(records[i]['RFUAMT'])   + "|" \
                                + records[i]['CERTTYPE']      + "|" \
                                + records[i]['CERTNO']        + "|" \
                                + records[i]['ORTRCCO']       + "|" \
                                + records[i]['ORTRCDAT']      + "|" \
                                + records[i]['ORTRCNO']       + "|" \
                                + records[i]['ORSNDBNK']      + "|" \
                                + records[i]['ORRCVBNK']      + "|" \
                                + records[i]['PYRACC']        + "|" \
                                + records[i]['PYRNAM']        + "|" \
                                + records[i]['PYEACC']        + "|" \
                                + records[i]['PYENAM']        + "|" \
                                + records[i]['STRINFO']       + "|" \
                                + state_dict['BCSTAT']        + "|" \
                                + state_dict['BDWFLG']        + "|"	\
                                + records[i]['BOJEDT']        + "|" \
                                + records[i]['BOSPSQ']        + "|" \
                                + records[i]['CHRGTYP']       + "|" \
                                + str(records[i]['LOCCUSCHRG'])    + "|" 
                    f.write(filecontext+"\n")                    
            #=====非退汇====
            else:
                AfaLoggerFunc.tradeInfo(">>>进入非退汇处理")
                for i in range(len(records)):
                    #=====得到业务状态BCSTAT====
                    state_dict={}
                    ret=rccpsState.getTransStateCur(records[i]['BJEDTE'],records[i]['BSPSQN'],state_dict)
                    if(state_dict==False):
                        return AfaFlowControl.ExitThisFlow( 'S999', '当前状态登记簿中无此交易状态' )
                    #=====写文件操作====
                    filecontext = records[i]['BJEDTE']   +    "|" \
                                + records[i]['BSPSQN']   +    "|" \
                                + records[i]['BRSFLG']   +    "|" \
                                + records[i]['BESBNO']   +    "|" \
                                + records[i]['BEACSB']   +    "|" \
                                + records[i]['BETELR']   +    "|" \
                                + records[i]['BEAUUS']   +    "|" \
                                + records[i]['TRCCO']    +    "|" \
                                + records[i]['OPRNO']    +    "|" \
                                + records[i]['OPRATTNO'] +    "|" \
                                + records[i]['TRCDAT']   +    "|" \
                                + records[i]['TRCNO']    +    "|" \
                                + records[i]['SNDBNKCO'] +    "|" \
                                + records[i]['SNDBNKNM'] +    "|" \
                                + records[i]['RCVBNKCO'] +    "|" \
                                + records[i]['RCVBNKNM'] +    "|" \
                                + records[i]['CUR']      +    "|" \
                                + str(records[i]['OCCAMT'])+  "|" \
                                + records[i]['PYRACC']   +    "|" \
                                + records[i]['PYRNAM']   +    "|" \
                                + records[i]['PYRADDR']  +    "|" \
                                + records[i]['PYEACC']   +    "|" \
                                + records[i]['PYENAM']   +    "|" \
                                + records[i]['PYEADDR']  +    "|" \
                                + records[i]['USE']      +    "|" \
                                + records[i]['REMARK']   +    "|" \
                                + records[i]['BILTYP']   +    "|" \
                                + records[i]['BILDAT']   +    "|" \
                                + records[i]['BILNO']    +    "|" \
                                + str(records[i]['COMAMT'])+  "|" \
                                + str(records[i]['OVPAYAMT'])+"|" \
                                + str(records[i]['CPSAMT'])+  "|" \
                                + str(records[i]['RFUAMT'])+  "|" \
                                + records[i]['CERTTYPE']   +  "|" \
                                + records[i]['CERTNO']     +  "|" \
                                + records[i]['ORTRCCO']    +  "|" \
                                + records[i]['ORTRCDAT']   +  "|" \
                                + records[i]['ORTRCNO']    +  "|" \
                                + records[i]['ORSNDBNK']   +  "|" \
                                + records[i]['ORRCVBNK']   +  "|" \
                                + "" + "|" + "" + "|" + "" +  "|" + "" + "|" \
                                + records[i]['STRINFO']    +  "|" \
                                + state_dict['BCSTAT']     +  "|" \
                                + state_dict['BDWFLG']     +  "|" \
                                + records[i]['BOJEDT']     +  "|" \
                                + records[i]['BOSPSQ']     +  "|" \
                                + records[i]['CHRGTYP']    +  "|" \
                                + str(records[i]['LOCCUSCHRG']) +  "|" 
                    f.write(filecontext+"\n")
                    
                f.close()
                AfaLoggerFunc.tradeInfo(">>>生成文件结束")
	    
        except Exception, e:
            #=====关闭文件====
            f.close()
            return AfaFlowControl.ExitThisFlow('A099','写入返回文件失败' )    
	    
        #=====输出接口赋值====
        TradeContext.RECCOUNT=str(len(records))     #查询笔数
        TradeContext.errorCode="0000"               #返回码
        TradeContext.errorMsg="成功"                #返回信息
        TradeContext.PBDAFILE=filename              #文件名
Пример #7
0
def SubModuleDoFst():    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易(1.本地操作).通存通兑业务登记簿查询[TRCC001_8567]进入***' )
    
    #=====必要性检查====
    AfaLoggerFunc.tradeInfo(">>>开始必要性检查")
    
    if( not TradeContext.existVariable( "STRDAT" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '起始日期[STRDAT]不存在')
        
    if( not TradeContext.existVariable( "ENDDAT" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '终止日期[ENDDAT]不存在')
    
    if( not TradeContext.existVariable( "BRSFLG" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '往来标志[BRSFLG]不存在')

    if( not TradeContext.existVariable( "PYITYP" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '卡折标志[PYITYP]不存在')
    
    if( not TradeContext.existVariable( "RECSTRNO" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '起始笔数[RECSTRNO]不存在')
        
    #=====组织sql语句====
    AfaLoggerFunc.tradeInfo(">>>开始组织查询sql语句")
    
    wheresql = ""
    wheresql = wheresql + "BJEDTE>='" + TradeContext.STRDAT + "' AND BJEDTE<='" + TradeContext.ENDDAT + "' "
    
    ordersql = " order by BJEDTE DESC,BSPSQN DESC,NCCWKDAT DESC "
    
    start_no = TradeContext.RECSTRNO        #起始笔数
    sel_size = 10                           #查询笔数
    
    #====add by pgt 0106 增加新的机构号的判断====
    if(TradeContext.BESBNO1 != ""):
        wheresql = wheresql + " and BESBNO='" + TradeContext.BESBNO1 + "' " 
        
    else:
        if(TradeContext.BESBNO != PL_BESBNO_BCLRSB):
            wheresql = wheresql + " and BESBNO='" + TradeContext.BESBNO + "' " 
    
    #=====判断往来标志是否为空====
    if(TradeContext.BRSFLG != ""):
        wheresql = wheresql + " AND BRSFLG='" + TradeContext.BRSFLG + "' "
        
#    #=====判断交易种类是否为空====
#    if(TradeContext.OPRTPNO != ""):
#        wheresql = wheresql + " AND OPRTPNO='" + TradeContext.OPRTPNO + "' "
   
    #=====判断报单序号是否为空====
    if(TradeContext.BSPSQN != ""):
        wheresql = wheresql + " AND BSPSQN='" + TradeContext.BSPSQN + "' "
        
    #=====判断业务状态是否为空====
    if(TradeContext.BCSTAT != ""):
        wheresql = wheresql + " AND OPRATTNO='" + TradeContext.BCSTAT + "' "	
        
    #=====判断卡折标志是否为空====
    if(TradeContext.PYITYP != ""):
        #wheresql = wheresql + " AND BBSSRC='" + TradeContext.PYITYP + "' "
        wheresql = wheresql + " AND ((PYETYP = '" + TradeContext.PYITYP + "' AND TRCCO in ('3000002','3000003','3000004','3000005')) OR (PYRTYP = '" + TradeContext.PYITYP + "' AND TRCCO in ('3000102','3000103','3000104','3000105')))"
    
    #=====判断发起行行号是否为空====
    if(TradeContext.SNDBNKCO != ""):
        wheresql = wheresql + " AND SNDBNKCO='" + TradeContext.SNDBNKCO + "' "
    
    #=====判断接收行行号是否为空====
    if(TradeContext.RCVBNKCO != ""):
        wheresql = wheresql + " AND RCVBNKCO='" + TradeContext.RCVBNKCO + "' "
    
    AfaLoggerFunc.tradeDebug(">>>结束组织查询sql语句")    
    
    #=====查询总记录数====
    allcount=rccpsDBTrcc_wtrbka.count(wheresql)
    
    if(allcount<0):
        return AfaFlowControl.ExitThisFlow('A099','查询总笔数失败' )
        
    #=====查询数据库====
    
    AfaLoggerFunc.tradeInfo("wheresql=" + wheresql)
    records = rccpsDBTrcc_wtrbka.selectm(start_no,sel_size,wheresql,ordersql)
    
    if(records == None):
        return AfaFlowControl.ExitThisFlow('A099','查询失败' )    
    if len(records) <= 0:
        return AfaFlowControl.ExitThisFlow('A099','未查找到数据' )
    else:
        #=====生成文件====
        try:
            filename = "rccps_" + TradeContext.BETELR+"_" + AfaUtilTools.GetHostDate() + "_" + TradeContext.TransCode
            fpath = os.environ["AFAP_HOME"] + "/tmp/"
            f = open(fpath + filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S099','打开文件失败')
       
        #=====写文件操作====
        try:
            filecontext=""
            AfaLoggerFunc.tradeInfo ("生成文件内容 ")
            for i in range(0,len(records)):
                
                #=====得到业务状态BCSTAT==== 
                stat_dict = {}
                if not rccpsState.getTransStateCur(records[i]['BJEDTE'],records[i]['BSPSQN'],stat_dict):
                    return AfaFlowControl.ExitThisFlow( 'S999', '当前业务登记簿没有满足条件的记录' )
                    
                filecontext= records[i]['BJEDTE']          + "|" \
                           + records[i]['BSPSQN']          + "|" \
                           + records[i]['BRSFLG']          + "|" \
                           + stat_dict['BCSTAT']           + "|" \
                           + stat_dict['BDWFLG']           + "|" \
                           + records[i]['BESBNO']          + "|" \
                           + records[i]['BETELR']          + "|" \
                           + records[i]['BEAUUS']          + "|" \
                           + records[i]['DCFLG']           + "|" \
                           + records[i]['OPRNO']           + "|" \
                           + records[i]['NCCWKDAT']        + "|" \
                           + records[i]['TRCCO']           + "|" \
                           + records[i]['TRCDAT']          + "|" \
                           + records[i]['TRCNO']           + "|" \
                           + records[i]['COTRCNO']         + "|" \
                           + records[i]['SNDMBRCO']        + "|" \
                           + records[i]['RCVMBRCO']        + "|" \
                           + records[i]['SNDBNKCO']        + "|" \
                           + records[i]['SNDBNKNM']        + "|" \
                           + records[i]['RCVBNKCO']        + "|" \
                           + records[i]['RCVBNKNM']        + "|" \
                           + records[i]['CUR']             + "|" \
                           + str(records[i]['OCCAMT'])     + "|" \
                           + records[i]['CHRGTYP']         + "|" \
                           + str(records[i]['CUSCHRG'])    + "|" \
                           + records[i]['PYRACC']          + "|" \
                           + records[i]['PYRNAM']          + "|" \
                           + records[i]['PYEACC']          + "|" \
                           + records[i]['PYENAM']          + "|" \
                           + records[i]['STRINFO']         + "|" \
                           + records[i]['CERTTYPE']        + "|" \
                           + records[i]['CERTNO']          + "|" \
                           + records[i]['BNKBKNO']         + "|" \
                           + str(records[i]['BNKBKBAL'])   + "|" 
                           
                f.write(filecontext+"\n")      
        except Exception,e:                                        
            f.close()                                              
            return AfaFlowControl.ExitThisFlow('S099','写文件失败')
Пример #8
0
def SubModuleDoFst():
    #time.sleep(60)
        
    AfaLoggerFunc.tradeInfo("农信银系统:来账.中心类操作(1.本地操作).柜台冲销来账接收[TRCC006_1145]进入")
    
    #=====判断是否为重复交易====
    AfaLoggerFunc.tradeInfo(">>>判断是否为重复交易")

    where_dict = {}
    where_dict = {'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO,'SNDBNKCO':TradeContext.SNDBNKCO}
    record = rccpsDBTrcc_mpcbka.selectu(where_dict)

    if( record == None ):
        AfaLoggerFunc.tradeDebug(">>>查找冲销登记簿异常,抛弃报文,等待中心发送自动冲正报文")
        return AfaFlowControl.ExitThisFlow('A099',"查找冲销登记簿异常")
    elif( len(record) > 0 ):    #重复交易
        AfaLoggerFunc.tradeDebug(">>>冲销交易重复")
    else:
        AfaLoggerFunc.tradeDebug(">>>非重复交易")
        
        #=====开始登记柜台冲销登记簿====
        AfaLoggerFunc.tradeDebug(">>>开始登记冲销登记簿")

        #TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
        TradeContext.ORTRCDAT = TradeContext.TRCDAT

        mpcbka_insert_dict = {}
        if not rccpsMap1145CTradeContext2Dmpcbka_dict.map(mpcbka_insert_dict):
            AfaLoggerFunc.tradeDebug("为冲销登记簿字典赋值失败")
            return AfaFlowControl.ExitThisFlow('S999','为字典赋值失败,抛弃报文,等待中心自动冲正')
            
        res = rccpsDBTrcc_mpcbka.insertCmt(mpcbka_insert_dict)      
        if( res == -1):
            AfaLoggerFunc.tradeDebug(">>>登记冲销登记簿失败")
            return AfaFlowControl.ExitThisFlow('S999','插入数据库失败,抛弃报文,等待中心自动冲正')
        
        #=====commit数据====
        AfaDBFunc.CommitSql()

    #=====查找自动冲正登记簿是否存在记录====
    AfaLoggerFunc.tradeDebug(">>>判断是否存在自动冲正报文")

    atcbka_where = {'ORMFN':TradeContext.MSGFLGNO}
    atcbka_dict  = rccpsDBTrcc_atcbka.selectu(atcbka_where)

    if( len(atcbka_dict) > 0 ):
        #=====冲销业务存在自动冲正报文,更新表数据为冲销失败,回复冲销失败报文====
        AfaLoggerFunc.tradeDebug('>>>已存在自动冲正报文,拒绝冲销,回复拒绝报文')
        
        #=====为返回冲销成功发送拒绝回执====
        TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
        TradeContext.PRCCO    = 'NN1IA999'               #中心返回码
        TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
        TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
        TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
        TradeContext.STRINFO  = '原交易已自动冲正,不允许再次冲销'               #附言

        return True
    else:
        AfaLoggerFunc.tradeDebug('>>>未查找到针对冲销报文的自动冲正报文,流程继续')

    #=====查找原交易是否存在====
    AfaLoggerFunc.tradeDebug(">>>查找原交易是否存在")

    where_dict = {'TRCDAT':TradeContext.ORMFN[10:18],'TRCNO':TradeContext.ORTRCNO,'SNDBNKCO':TradeContext.SNDBNKCO}
    wtrbka_dict = rccpsDBTrcc_wtrbka.selectu(where_dict)

    if( wtrbka_dict == -1 ):
        AfaLoggerFunc.tradeInfo(">>>查找原交易失败,原业务中心流水号["+str(TradeContext.ORTRCNO)+"]")
        return AfaFlowControl.ExitThisFlow('A099',"查找原交易失败,抛弃报文,等待中心自动冲正")
        
    if( len(wtrbka_dict) == 0 ):
        #=====未查找到原交易====
        AfaLoggerFunc.tradeDebug(">>>查找原交易失败,未收到原交易,直接回复拒绝报文")
     
        #=====为返回冲销成功发送成功回执====
        TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
        TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
        TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
        TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
        #关彬捷  20081222  修改:如果未找到原业务,则返回拒绝应答
        TradeContext.PRCCO    = 'NN1IA999'               #中心返回码
        TradeContext.STRINFO  = '无此交易'               #附言

        return True
    else:
        #=====查找原交易成功====
        AfaLoggerFunc.tradeInfo(">>>查找原交易成功")

        #=====将原报单序号 原交易日期更新到冲销登记簿中====
        AfaLoggerFunc.tradeInfo('>>>更新原报单序号\原交易日期')

        mpcbka_where={}
        mpcbka_where['BSPSQN'] = TradeContext.BSPSQN      #报单序号
        mpcbka_where['BJEDTE'] = TradeContext.BJEDTE      #交易日期

        mpcbka_dict ={}
        mpcbka_dict['BOJEDT']  = wtrbka_dict['BJEDTE']    #原交易日期
        mpcbka_dict['BOSPSQ']  = wtrbka_dict['BSPSQN']    #原报单序号
        mpcbka_dict['BESBNO']  = wtrbka_dict['BESBNO']    #原机构号
        mpcbka_dict['STRINFO'] = TradeContext.STRINFO     #附言 
        mpcbka_dict['OPRNO']   = PL_TDOPRNO_CX            #业务类型

        ret = rccpsDBTrcc_mpcbka.update(mpcbka_dict,mpcbka_where)

        if ret <= 0:
            AfaDBFunc.RollBackSql( )
            return AfaFlowControl.ExitThisFlow('S999', "更新冲销登记簿原报单序号和原交易日期异常,抛弃报文")
        else:
            AfaDBFunc.CommitSql( )

        AfaLoggerFunc.tradeInfo(">>>结束更新冲销登记簿原交易日期和原报单序号")
        
        #=====查找原来账业务业务状态====
        AfaLoggerFunc.tradeInfo(">>>查找原业务状态")

        spbsta_where = {'BJEDTE':wtrbka_dict['BJEDTE'],'BSPSQN':wtrbka_dict['BSPSQN']}
        spbsta_dict = rccpsDBTrcc_spbsta.selectu(spbsta_where)

        if( spbsta_dict == None ):
            AfaLoggerFunc.tradeDebug(">>>查找原业务状态失败,发送中心失败报文")
     
            #=====为返回冲销成功发送拒绝回执====
            TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
            TradeContext.PRCCO    = 'RCCO1006'               #中心返回码
            TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
            TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
            TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
            TradeContext.STRINFO  = '开户行处理失败'         #附言

            return True
            
        #关彬捷  20081226  新增查询交易当前状态详细信息
        #查询交易当前状态详细信息
        sstlog_where = {'BJEDTE':wtrbka_dict['BJEDTE'],'BSPSQN':wtrbka_dict['BSPSQN'],'BCURSQ':spbsta_dict['BCURSQ']}
        spbsta_dict = rccpsDBTrcc_sstlog.selectu(sstlog_where)
        
        if( spbsta_dict == None ):
            AfaLoggerFunc.tradeDebug(">>>查找原业务状态失败,发送中心失败报文")
     
            #=====为返回冲销成功发送拒绝回执====
            TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
            TradeContext.PRCCO    = 'RCCO1006'               #中心返回码
            TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
            TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
            TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
            TradeContext.STRINFO  = '开户行处理失败'         #附言

            return True
            
        #关彬捷  20081226  新增若交易当前状态为自动扣款,自动入账,冲销,冲正处理中状态,则直接拒绝此冲销
        if (spbsta_dict['BCSTAT'] == PL_BCSTAT_AUTO or spbsta_dict['BCSTAT'] == PL_BCSTAT_AUTOPAY or spbsta_dict['BCSTAT'] == PL_BCSTAT_CANC or spbsta_dict['BCSTAT'] == PL_BCSTAT_CANCEL) and  spbsta_dict['BDWFLG'] == PL_BDWFLG_WAIT:
            #=====为返回冲销成功发送拒绝回执====
            TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
            TradeContext.PRCCO    = 'RCCO1006'               #中心返回码
            TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
            TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
            TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
            TradeContext.STRINFO  = '原交易账务状态未知'     #附言

            return True
        
        #关彬捷  20081226  新增若交易当前状态为自动扣款,自动入账,冲销,冲正失败状态,则调用8816查询账务状态
        if (spbsta_dict['BCSTAT'] == PL_BCSTAT_AUTO or spbsta_dict['BCSTAT'] == PL_BCSTAT_AUTOPAY or spbsta_dict['BCSTAT'] == PL_BCSTAT_CANC or spbsta_dict['BCSTAT'] == PL_BCSTAT_CANCEL) and  spbsta_dict['BDWFLG'] == PL_BDWFLG_FAIL:
            AfaLoggerFunc.tradeDebug('>>>调用8816查找该业务[' + wtrbka_dict['BSPSQN'] + ']状态')

            TradeContext.HostCode = '8816'                   #主机交易码
            TradeContext.OPFG     = '1'                      #查询类型
            TradeContext.NBBH     = 'RCC'                    #代理业务标识
            TradeContext.FEDT     = spbsta_dict['FEDT']      #原前置日期
            TradeContext.RBSQ     = spbsta_dict['RBSQ']      #原前置流水号
            TradeContext.DAFG     = '1'                      #抹/记账标志  1:记  2:抹
            TradeContext.BESBNO   = spbsta_dict['BESBNO']    #机构号
            TradeContext.BETELR   = spbsta_dict['BETELR']    #柜员号
            
            rccpsHostFunc.CommHost( TradeContext.HostCode )
            
            #=====分析主机返回====
            if TradeContext.errorCode == '0000':
                #此账务已成功记主机账,修改原交易状态为记账成功
                AfaLoggerFunc.tradeInfo("此账务已成功记主机账,修改原交易状态为记账成功")
                stat_dict = {}
                stat_dict['BJEDTE'] = spbsta_dict['BJEDTE']
                stat_dict['BSPSQN'] = spbsta_dict['BSPSQN']
                stat_dict['BCSTAT'] = spbsta_dict['BCSTAT']
                stat_dict['BDWFLG'] = PL_BDWFLG_SUCC
                stat_dict['TRDT']   = HostContext.O1DADT           #主机日期
                stat_dict['TLSQ']   = HostContext.O1AMTL           #主机流水
                stat_dict['MGID']   = '0000'
                stat_dict['STRINFO']= '主机成功'
                
                if not rccpsState.setTransState(stat_dict):
                    return AfaFlowControl.ExitThisFlow('S999','设置原交易业务状态为记账成功异常')
                
                if not AfaDBFunc.CommitSql( ):
                    AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
                    return AfaFlowControl.ExitThisFlow("S999","Commit异常")
                    
                #更新查询出交易状态
                spbsta_dict['BDWFLG'] = PL_BDWFLG_SUCC
                spbsta_dict['TRDT']   = HostContext.O1DADT
                spbsta_dict['TLSQ']   = HostContext.O1AMTL
            
            elif TradeContext.errorCode == 'XCR0001':
                AfaLoggerFunc.tradeInfo(">>>主机返回原交易记账失败,继续冲销")
                
            else:
                AfaLoggerFunc.tradeInfo(">>>查询原交易账务状态异常,返回拒绝应答")
                #=====为返回冲销成功发送拒绝回执====
                TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
                TradeContext.PRCCO    = 'RCCO1006'               #中心返回码
                TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
                TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
                TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
                TradeContext.STRINFO  = '原交易账务状态未知'     #附言
                
                return True

        #=====根据来往帐标识进行冲销状态判断====
        if( wtrbka_dict['BRSFLG'] == PL_BRSFLG_RCV ):
            #=====来账业务====
            AfaLoggerFunc.tradeDebug(">>>来账业务")

            #=====PL_BCSTAT_AUTOPAY  自动扣款====
            #=====PL_BCSTAT_AUTO     自动入账====
            #=====PL_BCSTAT_CONFPAY   确认付款====
            #=====PL_BCSTAT_CONFACC   确认入账====
            #=====PL_BCSTAT_MFERFE   拒绝====
            #=====PL_BCSTAT_CANC     冲销====
            #=====PL_BCSTAT_CANCEL   冲正====
            if( ((spbsta_dict['BCSTAT']==PL_BCSTAT_AUTO or spbsta_dict['BCSTAT']==PL_BCSTAT_AUTOPAY) and spbsta_dict['BDWFLG']==PL_BDWFLG_FAIL) \
                or (spbsta_dict['BCSTAT'] == PL_BCSTAT_MFERFE and spbsta_dict['BDWFLG'] == PL_BDWFLG_SUCC) \
                or (spbsta_dict['BCSTAT'] == PL_BCSTAT_CANC   and spbsta_dict['BDWFLG'] == PL_BDWFLG_SUCC) \
                or (spbsta_dict['BCSTAT'] == PL_BCSTAT_CANCEL and spbsta_dict['BDWFLG'] == PL_BDWFLG_SUCC) \
                or (spbsta_dict['BCSTAT'] == PL_BCSTAT_CONFPAY and spbsta_dict['BDWFLG'] == PL_BDWFLG_SUCC) \
                or (spbsta_dict['BCSTAT'] == PL_BCSTAT_CONFACC and spbsta_dict['BDWFLG'] == PL_BDWFLG_SUCC)):
                #=====不允许冲销====
                AfaLoggerFunc.tradeDebug(">>>原业务["+str(spbsta_dict['BSPSQN'])+"]记账失败或被拒绝,发送成功报文")

                #=====根据交易状态新增冲销-成功状态====
                if spbsta_dict['BCSTAT'] not in (PL_BCSTAT_MFERFE,PL_BCSTAT_CANC,PL_BCSTAT_CANCEL):
                    #=====新增原业务状态为冲销-成功====
                    AfaLoggerFunc.tradeDebug('>>>新增原业务状态为冲销-成功')

                    if not rccpsState.newTransState(spbsta_dict['BJEDTE'],spbsta_dict['BSPSQN'],PL_BCSTAT_CANC,PL_BDWFLG_SUCC):
                        AfaDBFunc.RollBackSql()
                        return AfaFlowControl.ExitThisFlow('S999','设置业务状态为冲销-成功异常')
                    else:
                        AfaDBFunc.CommitSql()
                else:
                    AfaLoggerFunc.tradeDebug('>>>原业务状态为[拒绝/冲销/冲正],不需要新增状态')
    
                #=====为返回冲销成功发送拒绝回执====
                TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
                TradeContext.PRCCO    = 'RCCI0000'               #中心返回码
                TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
                TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
                TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
                TradeContext.STRINFO  = '原业务冲销成功'         #附言

                return True
            else:
        
                #=====直接调用8820冲销原业务====
                status={}
                if not rccpsState.getTransStateCur(spbsta_dict['BJEDTE'],spbsta_dict['BSPSQN'],status):
                    return AfaFlowControl.ExitThisFlow('S999','取原业务主机流水号和日期失败,抛弃报文')

                TradeContext.BOSPSQ   = status['RBSQ']    #原报单序号
                TradeContext.BOJEDT   = status['FEDT']    #原交易日期
                TradeContext.HostCode = '8820'                   #主机交易码
                
                #=====新增原业务状态为冲销-处理中====
                AfaLoggerFunc.tradeDebug('>>>新增原业务状态为冲销-处理中')

                if not rccpsState.newTransState(spbsta_dict['BJEDTE'],spbsta_dict['BSPSQN'],PL_BCSTAT_CANC,PL_BDWFLG_WAIT):
                    AfaDBFunc.RollBackSql()
                    return AfaFlowControl.ExitThisFlow('S999','设置业务状态为冲销-处理中异常')
                else:
                    AfaDBFunc.CommitSql()

                #=====向主机发起8820抹账处理==== 
                AfaLoggerFunc.tradeDebug('>>>向主机发起8820抹账处理')

                rccpsHostFunc.CommHost( TradeContext.HostCode ) 

                #=====判断主机返回====
                sstlog_dict={}
                sstlog_dict['BJEDTE']  =  spbsta_dict['BJEDTE']
                sstlog_dict['BSPSQN']  =  spbsta_dict['BSPSQN']
                sstlog_dict['BCSTAT']  =  PL_BCSTAT_CANC
                sstlog_dict['MGID']    =  TradeContext.errorCode #主机返回码
                if TradeContext.existVariable('BOJEDT'):           #前置日期
                    sstlog_dict['FEDT'] = TradeContext.BOJEDT
                if TradeContext.existVariable('BOSPSQ'):           #前置流水号
                    sstlog_dict['RBSQ'] = TradeContext.BOSPSQ
                if TradeContext.existVariable('TRDT'):           #主机日期
                    sstlog_dict['TRDT'] = TradeContext.TRDT
                if TradeContext.existVariable('TLSQ'):           #主机流水号
                    sstlog_dict['TLSQ'] = TradeContext.TLSQ

                #关彬捷  20090219  增加冲销成功的主机错误码判断:SXR0010(此笔交易已被冲正)
                if TradeContext.errorCode in ('0000','SXR0010'):
                    #=====更改状态====
                    sstlog_dict['BDWFLG']    =  PL_BDWFLG_SUCC       #流转标识 PL_BDWFLG_SUCC 成功
                    sstlog_dict['STRINFO']   =  '来账冲销成功'       #附言
                    TradeContext.PRCCO       =  'RCCI0000'
                    TradeContext.STRINFO     =  '原业务冲销成功'
                else:
                    sstlog_dict['BDWFLG']    =  PL_BDWFLG_FAIL       #流转标识 PL_BDWFLG_FAIL 失败
                    sstlog_dict['MGID']      =  TradeContext.errorCode #主机返回码
                    sstlog_dict['STRINFO']   =  TradeContext.errorMsg  #主机返回信息
                    TradeContext.PRCCO       =  'NN1IA999'
                    TradeContext.STRINFO     =  '原业务冲销失败 ' + TradeContext.errorMsg

                #=====修改原业务状态====
                AfaLoggerFunc.tradeDebug('>>>修改原业务状态')

                res = rccpsState.setTransState(sstlog_dict)

                if( res == False ):
                    AfaDBFunc.RollbackSql()
                    return AfaFlowControl.ExitThisFlow('A099', '更改被冲正的交易状态失败')

                AfaDBFunc.CommitSql( )
                
                #关彬捷 20081226  修改如果冲销失败则回滚冲销前状态
                if TradeContext.errorCode not in ('0000','SXR0010'):
                    #冲销失败,回滚状态为冲销前状态
                    if not rccpsState.newTransState(spbsta_dict['BJEDTE'],spbsta_dict['BSPSQN'],spbsta_dict['BCSTAT'],spbsta_dict['BDWFLG']):
                        AfaDBFunc.RollBackSql()
                        return AfaFlowControl.ExitThisFlow('S999','回滚状态为冲销前状态异常')
                    else:
                        AfaDBFunc.CommitSql()
                        
                    sstlog_dict = {}
                    sstlog_dict['BJEDTE']    =  spbsta_dict['BJEDTE']
                    sstlog_dict['BSPSQN']    =  spbsta_dict['BSPSQN']
                    sstlog_dict['BCSTAT']    =  spbsta_dict['BCSTAT']
                    sstlog_dict['BDWFLG']    =  spbsta_dict['BDWFLG']
                    sstlog_dict['NOTE3']     =  '原业务冲销失败,回滚为冲销前状态'
                    if spbsta_dict.has_key('FEDT'):           #前置日期
                        sstlog_dict['FEDT']  =  spbsta_dict['FEDT']
                    if spbsta_dict.has_key('RBSQ'):           #前置流水号
                        sstlog_dict['RBSQ']  =  spbsta_dict['RBSQ']
                    if spbsta_dict.has_key('TRDT'):           #主机日期
                        sstlog_dict['TRDT']  =  spbsta_dict['TRDT']
                    if spbsta_dict.has_key('TLSQ'):           #主机流水号
                        sstlog_dict['TLSQ']  =  spbsta_dict['TLSQ']
                    sstlog_dict['MGID']      =  spbsta_dict['MGID'] #主机返回码
                    sstlog_dict['STRINFO']   =  spbsta_dict['STRINFO']  #主机返回信息
                    
                    if not rccpsState.setTransState(sstlog_dict):
                        return AfaFlowControl.ExitThisFlow('S999','回滚状态为冲销前状态详细信息异常')
                    else:
                        AfaDBFunc.CommitSql()

                #=====发送回执====
                AfaLoggerFunc.tradeDebug('>>>发送成功回执到对方行')
           
                #=====为返回冲销成功发送成功回执====
                TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
                #TradeContext.PRCCO    = 'RCCI0000'               #中心返回码
                #TradeContext.STRINFO  = '原业务冲销成功'         #附言
                TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
                TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
                TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
        else:
            #=====往帐业务====
            AfaLoggerFunc.tradeDebug(">>>往帐业务")

            #=====发送回执====
            AfaLoggerFunc.tradeDebug('>>>发送成功回执到对方行')
           
            #=====为返回冲销成功发送成功回执====
            TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
            TradeContext.PRCCO    = 'RCCO1006'               #中心返回码
            TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
            TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
            TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
            TradeContext.STRINFO  = '往帐业务只能受理方冲销'     #附言

    AfaLoggerFunc.tradeInfo("农信银系统:来账.中心类操作(1.本地操作).柜台冲销来账接收[TRCC006_1145]退出")
    
    return True
Пример #9
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作(1.本地操作).汇票业务明细查询[TRC001_8525]进入***' )
    
    #=================必要性检查================================================
    AfaLoggerFunc.tradeDebug(">>>开始必要性检查")
    
    if not TradeContext.existVariable('STRDAT'):
        return AfaFlowControl.ExitThisFlow('S999','起始日期[STRDAT]不存在' )
    elif len(TradeContext.STRDAT) <= 0:
        return AfaFlowControl.ExitThisFlow('S999','起始日期[STRDAT]不能为空' )
        
    if not TradeContext.existVariable('ENDDAT'):
        return AfaFlowControl.ExitThisFlow('S999','终止日期[ENDDAT]不存在' )
    elif len(TradeContext.ENDDAT) <= 0:
        return AfaFlowControl.ExitThisFlow('S999','终止日期[ENDDAT]不能为空' )
        
    AfaLoggerFunc.tradeDebug(">>>结束必要性检查")
    
    #=================组织查询sql语句===========================================
    AfaLoggerFunc.tradeDebug(">>>开始组织查询sql语句")
    
    bilbka_where_sql = ""
    bilbka_where_sql = bilbka_where_sql + "BESBNO='" + TradeContext.BESBNO + "' "
    bilbka_where_sql = bilbka_where_sql + "and BJEDTE >= '" + TradeContext.STRDAT + "' and BJEDTE <= '" + TradeContext.ENDDAT + "'"
    
    #=====判断往来标志是否存在====
    if TradeContext.existVariable('BRSFLG'):
        if len(TradeContext.BRSFLG) > 0:
            bilbka_where_sql = bilbka_where_sql + " and BRSFLG = '" + TradeContext.BRSFLG + "'"
    
    #=====判断交易代码是否存在====
    if TradeContext.existVariable('TRCCO'):
        if len(TradeContext.TRCCO) > 0:
            bilbka_where_sql = bilbka_where_sql + " and TRCCO = '" + TradeContext.TRCCO + "'"
    
    #=====判断报单序号是否存在====        
    if TradeContext.existVariable('BSPSQN'):
        if len(TradeContext.BSPSQN) > 0:
            bilbka_where_sql = bilbka_where_sql + " and BSPSQN = '" + TradeContext.BSPSQN + "'"
    
    #=====判断汇票本行他行标识是否存在====
    if TradeContext.existVariable('BILRS'):
        if len(TradeContext.BILRS) > 0:
            bilbka_where_sql = bilbka_where_sql + " and BILRS = '" + TradeContext.BILRS + "'"
    
    #=====判断汇票版本号是否存在====        
    if TradeContext.existVariable('BILVER'):
        if len(TradeContext.BILVER) > 0:
            bilbka_where_sql = bilbka_where_sql + " and BILVER = '" + TradeContext.BILVER + "'"
    
    #=====判断汇票号码是否存在====
    if TradeContext.existVariable('BILNO'):
        if len(TradeContext.BILNO) > 0:
            bilbka_where_sql = bilbka_where_sql + " and BILNO = '" + TradeContext.BILNO + "'"
    
    #=====判断接收行号是否存在====        
    if TradeContext.existVariable('RCVBNKCO'):
        if len(TradeContext.RCVBNKCO) > 0:
            bilbka_where_sql = bilbka_where_sql + " and RCVBNKCO = '" + TradeContext.RCVBNKCO + "'"
            
    AfaLoggerFunc.tradeDebug(">>>结束组织查询sql语句")
            
    #================查询总笔数==================================================
    AfaLoggerFunc.tradeInfo(">>>开始组织查询总笔数")
    
    all_count = rccpsDBTrcc_bilbka.count(bilbka_where_sql)
    
    AfaLoggerFunc.tradeInfo(">>>结束组织查询总笔数")
    
    if all_count < 0:
        return AfaFlowControl.ExitThisFlow('S999','查询总笔数异常')        
    if all_count == 0:
        return AfaFlowControl.ExitThisFlow('S999','无查询对应记录')        
    if all_count > 0:
        TradeContext.RECALLCOUNT = str(all_count)                #总笔数
        #============查询明细记录================================================
        AfaLoggerFunc.tradeDebug(">>>开始查询明细记录")
        
        bilbka_order_sql = " order by BJEDTE DESC,BSPSQN DESC "
        
        bilbka_dict = rccpsDBTrcc_bilbka.selectm(TradeContext.RECSTRNO,10,bilbka_where_sql,bilbka_order_sql)
        
        AfaLoggerFunc.tradeDebug(">>>结束查询明细记录")
        
        if bilbka_dict == None:
            return AfaFlowControl.ExitThisFlow('S999','查询明细记录异常')        
        if len(bilbka_dict) <= 0:
            return AfaFlowControl.ExitThisFlow('S999','查询明细无记录')
        else:
            TradeContext.RECCOUNT = str(len(bilbka_dict))         #本次查询笔数
            #========生成输出form文件============================================
            AfaLoggerFunc.tradeInfo(">>>开始生成文件")
            
            file_name = "rccps_" + TradeContext.BETELR + "_" + AfaUtilTools.GetHostDate() + "_" + TradeContext.TransCode
            
            try:
            	fpath=os.environ["AFAP_HOME"]+"/tmp/"
            	fp=open(fpath+file_name,"w") 
            except IOError:
                return AfaFlowControl.ExitThisFlow('S999','打开文件失败')
            
            for i in xrange(len(bilbka_dict)):
                #====查询此交易状态信息==========================================
                stat_dict = {}
                ret = rccpsState.getTransStateCur(bilbka_dict[i]['BJEDTE'],bilbka_dict[i]['BSPSQN'],stat_dict)
                
                if not ret:
                    AfaLoggerFunc.tradeDebug("查询交易状态信息异常")
                    return AfaFlowControl.ExitThisFlow('S999','生成文件异常')
                
                file_line = bilbka_dict[i]['BJEDTE']   + "|" \
                          + bilbka_dict[i]['BSPSQN']   + "|" \
                          + bilbka_dict[i]['BRSFLG']   + "|" \
                          + bilbka_dict[i]['OPRNO']    + "|" \
                          + bilbka_dict[i]['BESBNO']   + "|" \
                          + bilbka_dict[i]['BEACSB']   + "|" \
                          + bilbka_dict[i]['BETELR']   + "|" \
                          + bilbka_dict[i]['BEAUUS']   + "|" \
                          + bilbka_dict[i]['BBSSRC']   + "|" \
                          + bilbka_dict[i]['DASQ']     + "|" \
                          + bilbka_dict[i]['DCFLG']    + "|" \
                          + bilbka_dict[i]['NCCWKDAT'] + "|" \
                          + bilbka_dict[i]['TRCCO']    + "|" \
                          + bilbka_dict[i]['TRCDAT']   + "|" \
                          + bilbka_dict[i]['TRCNO']    + "|" \
                          + bilbka_dict[i]['SNDBNKCO'] + "|" \
                          + bilbka_dict[i]['SNDBNKNM'] + "|" \
                          + bilbka_dict[i]['RCVBNKCO'] + "|" \
                          + bilbka_dict[i]['RCVBNKNM'] + "|" \
                          + bilbka_dict[i]['BILVER']   + "|" \
                          + bilbka_dict[i]['BILNO']    + "|" \
                          + bilbka_dict[i]['BILRS']    + "|" \
                          + bilbka_dict[i]['HPSTAT']   + "|" \
                          + stat_dict['BCSTAT']        + "|" \
                          + stat_dict['BDWFLG']        + "|" 
                fp.write(file_line + "\n")
                
            fp.close()
            AfaLoggerFunc.tradeInfo(">>>结束生成文件")
        
        TradeContext.PBDAFILE = file_name       #文件名
        TradeContext.errorCode = "0000"
        TradeContext.errorMsg  = "成功"
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作(1.本地操作).汇票业务明细查询[TRC001_8525]退出***' )
    return True
Пример #10
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.差错账补记[8572] 进入")
    
    AfaLoggerFunc.tradeInfo("<<<<<<<个性化处理(本地操作) 进入")
    #=====校验变量的合法性====
    AfaLoggerFunc.tradeInfo("<<<<<<校验变量的合法性")   
    if not TradeContext.existVariable("SNDBNKCO"):
        return AfaFlowControl.ExitThisFlow('A099','没有发起行号')
        
    if not TradeContext.existVariable("TRCNO"):
        return AfaFlowControl.ExitThisFlow('A099','没有交易流水号')
        
    if not TradeContext.existVariable("TRCDAT"):
        return AfaFlowControl.ExitThisFlow('A099','没有委托日期')
        
    AfaLoggerFunc.tradeInfo("<<<<<<校验变量的合法性结束")
    
    #=====生成RBSQ,FEDT,BJEDTE,NCCworkDate,BSPSQN====
    TradeContext.FEDT=AfaUtilTools.GetHostDate( )      #FEDT
    
    TradeContext.BJEDTE=AfaUtilTools.GetHostDate( )    #BJEDTE 
    
    if not rccpsFunc.GetNCCDate( ) :                   #NCCworkDate
        raise AfaFlowControl.flowException( )
    
    if rccpsGetFunc.GetRBSQ(PL_BRSFLG_RCV) == -1 :     #RBSQ
        return AfaFlowControl.ExitThisFlow('S999','重新生成前置流水号失败,抛弃报文')
        
    if rccpsGetFunc.GetSerialno(PL_BRSFLG_RCV) == -1 : #BSPSQN
        raise AfaFlowControl.flowException( )
        
    #=====判断原业务是来账还是往账====
    AfaLoggerFunc.tradeInfo("<<<<<<判断原业务的往来标示")
    if(TradeContext.SNDBNKCO == '1340000008'):
        AfaLoggerFunc.tradeInfo("<<<<<<原业务为往账")
        #=====查询原业务信息====
        where_dict = {}
        where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO}
        wtrbka_record_dict = rccpsDBTrcc_wtrbka.selectu(where_dict)
        if(wtrbka_record_dict == None):
            return AfaFlowControl.ExitThisFlow('A099','查询通存通兑登记簿失败')
        
        elif(len(wtrbka_record_dict) == 0):
            return AfaFlowControl.ExitThisFlow('A099','查询通存通兑登记簿为空')
            
        else:
            AfaLoggerFunc.tradeInfo("<<<<<<查询原业务信息成功")
            
        #=====查询错账登记簿====
        where_dict = {}
        where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO}
        tddzcz_record_dict = rccpsDBTrcc_tddzcz.selectu(where_dict)
        if(tddzcz_record_dict == None):
            return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿失败')
        
        elif(len(tddzcz_record_dict) == 0):
            AfaLoggerFunc.tradeInfo("查询错账登记簿结果为空,应向其中插入相应的记录")
            #=====给插入错账登记簿的字典赋值====
            insert_dict = {}           
            insert_dict['NCCWKDAT']   = wtrbka_record_dict['NCCWKDAT']
            insert_dict['SNDBNKCO']   = wtrbka_record_dict['SNDBNKCO']
            insert_dict['TRCDAT']     = wtrbka_record_dict['TRCDAT']
            insert_dict['TRCNO']      = wtrbka_record_dict['TRCNO']
            insert_dict['RCVBNKCO']   = wtrbka_record_dict['RCVBNKCO']
            insert_dict['SNDMBRCO']   = wtrbka_record_dict['SNDMBRCO']
            insert_dict['RCVMBRCO']   = wtrbka_record_dict['RCVMBRCO']
            insert_dict['TRCCO']      = wtrbka_record_dict['TRCCO']
            if(wtrbka_record_dict['DCFLG'] == '0'):
                insert_dict['DCFLG'] = '1'
            else:
                insert_dict['DCFLG'] = '2'
            insert_dict['PYRACC']     = wtrbka_record_dict['PYRACC']
            insert_dict['PYEACC']     = wtrbka_record_dict['PYEACC']
            insert_dict['CUR']        = 'CNY'
            insert_dict['OCCAMT']     = wtrbka_record_dict['OCCAMT']
            insert_dict['LOCOCCAMT']  = wtrbka_record_dict['OCCAMT']
            if(wtrbka_record_dict['TRCCO'] in ('3000102','3000103','3000104','3000105') and wtrbka_record_dict['CHRGTYP'] == '1'):
                insert_dict['CUSCHRG']    = wtrbka_record_dict['CUSCHRG']
                insert_dict['LOCCUSCHRG'] = wtrbka_record_dict['CUSCHRG']
            else:
                insert_dict['CUSCHRG']    = 0.00
                insert_dict['LOCCUSCHRG'] = 0.00
            insert_dict['ORTRCNO']    = ""
            insert_dict['BJEDTE']     = wtrbka_record_dict['BJEDTE']
            insert_dict['BSPSQN']     = wtrbka_record_dict['BSPSQN']
            insert_dict['EACTYP']     = '02'
            insert_dict['EACINF']     = '中心有成员行无'
            insert_dict['LOCEACTYP']  = '03'
            insert_dict['LOCEACINF']  = '往账中心清算,行内未清算'
            insert_dict['ISDEAL']     = '0'
            insert_dict['NOTE1']      = ""
            insert_dict['NOTE2']      = ""
            insert_dict['NOTE3']      = ""
            insert_dict['NOTE4']      = ""
            
            #=====向错账登记簿中补记此笔交易====
            if not rccpsDBTrcc_tddzcz.insertCmt(insert_dict):
                return AfaFlowControl.ExitThisFlow('A099','向错账登记簿中补记交易失败')
                
            #=====补查错账登记簿,将刚插入的数据查出来====
            where_dict = {}
            where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO}
            tddzcz_record_dict = rccpsDBTrcc_tddzcz.selectu(where_dict)
            if(tddzcz_record_dict == None):
                return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿失败')
            elif(len(tddzcz_record_dict) == 0):
                return AfaFlowControl.ExitThisFlow('A099','查询通错账登记簿结果为空')
            else:
                AfaLoggerFunc.tradeInfo("<<<<<<补查错账登记簿成功")
                 
        else:
            AfaLoggerFunc.tradeInfo("<<<<<<查询错账登记簿成功")
                
    else:
        AfaLoggerFunc.tradeInfo("<<<<<<原业务为来账")
        #=====查询对账明细登记簿====
        AfaLoggerFunc.tradeInfo("<<<<<<开始查询对账明细登记簿")
        where_dict = {}
        where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO}
        tddzmx_record_dict = rccpsDBTrcc_tddzmx.selectu(where_dict)
        if(tddzmx_record_dict == None):
            return AfaFlowControl.ExitThisFlow('A099','查询对账明细登记簿失败')
            
        elif(len(tddzmx_record_dict) == 0):
            return AfaFlowControl.ExitThisFlow('A099','查询对账明细登记簿为空')
            
        else:
            AfaLoggerFunc.tradeInfo("<<<<<<查询对账明细登记簿成功")
        
        #=====查询错账登记簿====
        AfaLoggerFunc.tradeInfo("<<<<<<开始查询错账登记簿")
        where_dict = {}
        where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO}
        tddzcz_record_dict = rccpsDBTrcc_tddzcz.selectu(where_dict)
        if(tddzcz_record_dict == None):
            return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿失败')
        
        elif(len(tddzcz_record_dict) == 0):
            AfaLoggerFunc.tradeInfo("查询错账登记簿结果为空,应向其中插入相应的记录")
            #=====给插入错账登记簿的字典赋值====
            insert_dict = {}
            insert_dict['NCCWKDAT']   = tddzmx_record_dict['NCCWKDAT']
            insert_dict['SNDBNKCO']   = tddzmx_record_dict['SNDBNKCO']
            insert_dict['TRCDAT']     = tddzmx_record_dict['TRCDAT']
            insert_dict['TRCNO']      = tddzmx_record_dict['TRCNO']
            insert_dict['RCVBNKCO']   = tddzmx_record_dict['RCVBNKCO']
            insert_dict['SNDMBRCO']   = tddzmx_record_dict['SNDMBRCO']
            insert_dict['RCVMBRCO']   = tddzmx_record_dict['RCVMBRCO']
            insert_dict['TRCCO']      = tddzmx_record_dict['TRCCO']
            insert_dict['DCFLG']      = tddzmx_record_dict['DCFLG']
            insert_dict['PYRACC']     = tddzmx_record_dict['PYRACC']
            insert_dict['PYEACC']     = tddzmx_record_dict['PYEACC']
            insert_dict['CUR']        = tddzmx_record_dict['CUR']
            insert_dict['OCCAMT']     = tddzmx_record_dict['OCCAMT']
            insert_dict['LOCOCCAMT']  = tddzmx_record_dict['OCCAMT']
            insert_dict['CUSCHRG']    = tddzmx_record_dict['CUSCHRG']
            insert_dict['LOCCUSCHRG'] = tddzmx_record_dict['CUSCHRG']
            insert_dict['ORTRCNO']    = ""
            insert_dict['BJEDTE']     = tddzmx_record_dict['BJEDTE']
            insert_dict['BSPSQN']     = tddzmx_record_dict['BSPSQN']
            insert_dict['EACTYP']     = "02"
            insert_dict['EACINF']     = "中心有成员行无"
            insert_dict['LOCEACTYP']  = "08"
            insert_dict['LOCEACINF']  = "来账中心清算,行内未清算"
            insert_dict['ISDEAL']     = "0"
            insert_dict['NOTE1']      = ""
            insert_dict['NOTE2']      = ""
            insert_dict['NOTE3']      = ""
            insert_dict['NOTE4']      = ""
            
            #=====向错账登记簿中补记此笔交易====
            if not rccpsDBTrcc_tddzcz.insertCmt(insert_dict):
                return AfaFlowControl.ExitThisFlow('A099','向错账登记簿中补记交易失败')
                
            #=====补查错账登记簿,将刚插入的数据查出来====
            where_dict = {}
            where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO}
            tddzcz_record_dict = rccpsDBTrcc_tddzcz.selectu(where_dict)
            if(tddzcz_record_dict == None):
                return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿失败')
            elif(len(tddzcz_record_dict) == 0):
                return AfaFlowControl.ExitThisFlow('A099','查询通错账登记簿结果为空')
            else:
                AfaLoggerFunc.tradeInfo("<<<<<<补查错账登记簿成功")
             
        else:
            AfaLoggerFunc.tradeInfo("<<<<<<查询错账登记簿成功")
             
        AfaLoggerFunc.tradeInfo("<<<<<<结束查询错账明细登记簿")
        
        #=====查询原交易信息====
        AfaLoggerFunc.tradeInfo("<<<<<<开始查询原交易信息")
        where_dict = {}
        where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO}
        wtrbka_record_dict = rccpsDBTrcc_wtrbka.selectu(where_dict)
        if(wtrbka_record_dict == None):
            return AfaFlowControl.ExitThisFlow('A099','查询通存通兑业务登记簿失败')
        
        elif(len(wtrbka_record_dict) == 0):    #通存通兑登记簿结果为空,应向其中插入相应记录
            AfaLoggerFunc.tradeInfo("<<<<<<通存通兑业务登记簿结果为空")
            #=====开始登记通存通兑业务登记簿====
            AfaLoggerFunc.tradeInfo("<<<<<<开始登记通存通兑业务登记簿")
            
            #=====调用主机交易得到机构号====
            AfaLoggerFunc.tradeInfo("<<<<<<查询账户开户机构")
            TradeContext.HostCode = '8810'
            if(tddzmx_record_dict['TRCCO'] in ('3000002','3000003','3000004','3000005')):
                TradeContext.ACCNO = tddzmx_record_dict['PYEACC']
            else:
                TradeContext.ACCNO = tddzmx_record_dict['PYRACC']
            
            rccpsHostFunc.CommHost( TradeContext.HostCode )
            if(TradeContext.errorCode != '0000'):
                return AfaFlowControl.ExitThisFlow('A099','查询账户开户行信息失败')
            
            AfaLoggerFunc.tradeInfo("<<<<<<查询账户开户信息成功")
            
            #=====给插入通存通兑业务登记簿的字典赋值====
            insert_dict = {}
            insert_dict['BJEDTE']     = tddzmx_record_dict['BJEDTE']
            insert_dict['BSPSQN']     = tddzmx_record_dict['BSPSQN']
            if(tddzmx_record_dict['SNDMBRCO'] == '1340000008'):
                insert_dict['BRSFLG'] = PL_BRSFLG_SND
            else:
                insert_dict['BRSFLG'] = PL_BRSFLG_RCV
            insert_dict['BESBNO']     = TradeContext.ACCSO
            insert_dict['BEACSB']     = ""
            insert_dict['BETELR']     = PL_BETELR_AUTO
            insert_dict['BEAUUS']     = ""
            insert_dict['BEAUPS']     = ""
            insert_dict['TERMID']     = ""
            insert_dict['BBSSRC']     = ""
            insert_dict['DASQ']       = ""
            insert_dict['DCFLG']      = tddzmx_record_dict['DCFLG']
            if(tddzmx_record_dict['TRCCO'] in ('3000002','3000004')):
                insert_dict['OPRNO']  = PL_TDOPRNO_TC
            elif(tddzmx_record_dict['TRCCO'] in ('3000102','3000104')):
                insert_dict['OPRNO']  = PL_TDOPRNO_TD
            elif(tddzmx_record_dict['TRCCO'] in ('3000003','3000005')):
                insert_dict['OPRNO']  = PL_TDOPRNO_BZY
            else:
                insert_dict['OPRNO']  = PL_TDOPRNO_YZB
            insert_dict['OPRATTNO']   = ""
            insert_dict['NCCWKDAT']   = TradeContext.NCCworkDate
            insert_dict['TRCCO']      = tddzmx_record_dict['TRCCO']
            insert_dict['TRCDAT']     = tddzmx_record_dict['TRCDAT']
            insert_dict['TRCNO']      = tddzmx_record_dict['TRCNO']
            insert_dict['MSGFLGNO']   = tddzmx_record_dict['MSGFLGNO']
            insert_dict['COTRCDAT']   = ""
            insert_dict['COTRCNO']    = ""
            insert_dict['COMSGFLGNO'] = ""
            insert_dict['SNDMBRCO']   = tddzmx_record_dict['SNDMBRCO']
            insert_dict['RCVMBRCO']   = tddzmx_record_dict['RCVMBRCO']
            insert_dict['SNDBNKCO']   = tddzmx_record_dict['SNDBNKCO']
            insert_dict['SNDBNKNM']   = tddzmx_record_dict['SNDBNKNM']
            insert_dict['RCVBNKCO']   = tddzmx_record_dict['RCVBNKCO']
            insert_dict['RCVBNKNM']   = tddzmx_record_dict['RCVBNKNM']
            insert_dict['CUR']        = tddzmx_record_dict['CUR']
            insert_dict['OCCAMT']     = tddzmx_record_dict['OCCAMT']
            if(tddzmx_record_dict['CUSCHRG'] == 0.00):
                insert_dict['CHRGTYP']= PL_CHRG_CASH
            else:
                insert_dict['CHRGTYP']= PL_CHRG_TYPE  
            insert_dict['LOCCUSCHRG'] = ""
            insert_dict['CUSCHRG']    = tddzmx_record_dict['CUSCHRG']
            insert_dict['PYRTYP']     = ""
            insert_dict['PYRACC']     = tddzmx_record_dict['PYRACC']
            insert_dict['PYRNAM']     = ""
            insert_dict['PYRADDR']    = ""
            insert_dict['PYETYP']     = ""
            insert_dict['PYEACC']     = tddzmx_record_dict['PYEACC']
            insert_dict['PYENAM']     = ""
            insert_dict['PYEADDR']    = ""
            insert_dict['STRINFO']    = tddzmx_record_dict['STRINFO']
            insert_dict['CERTTYPE']   = ""
            insert_dict['CERTNO']     = ""
            insert_dict['BNKBKNO']    = ""
            insert_dict['BNKBKBAL']   = ""
            
            if not rccpsDBTrcc_wtrbka.insertCmt(insert_dict):
                return AfaFlowControl.ExitThisFlow('A099','登记通存通兑业务登记簿失败')
            
            AfaLoggerFunc.tradeInfo("<<<<<<结束登记通存通兑业务登记簿")
            
            #=====补查通存通兑业务登记簿,将刚才插入的数据查出来====
            where_dict = {}
            where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO}
            wtrbka_record_dict = rccpsDBTrcc_wtrbka.selectu(where_dict)
            if(wtrbka_record_dict == None):
                return AfaFlowControl.ExitThisFlow('A099','查询通存通兑业务登记簿失败')
            elif(len(wtrbka_record_dict) == 0):
                return AfaFlowControl.ExitThisFlow('A099','查询通存通兑业务登记簿结果为空')
            else:
                AfaLoggerFunc.tradeInfo("<<<<<<补查通存通兑业务登记簿成功")
            
        else:
            AfaLoggerFunc.tradeInfo("<<<<<<查询通存通兑业务登记簿成功")
        
    #=====判断此笔业务是否已经处理====
    if(tddzcz_record_dict['ISDEAL'] == PL_ISDEAL_ISDO):
        return AfaFlowControl.ExitThisFlow('A099','此笔账务已经处理过')
        
    #=====开始行内补记====
    AfaLoggerFunc.tradeInfo("<<<<<<开始行内补记")
    #=====判断原交易的往来标示====
    AfaLoggerFunc.tradeInfo("<<<<<<判断原交易的往来标示")
    if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_RCV):
        AfaLoggerFunc.tradeInfo("<<<<<<原交易为来账")
        
#        if(TradeContext.existVariable("BSPSQN")):
#            TradeContext.BSPSQN = wtrbka_record_dict['BSPSQN']    
        TradeContext.BESBNO   = wtrbka_record_dict['BESBNO']
        TradeContext.BRSFLG   = wtrbka_record_dict['BRSFLG']
        TradeContext.CHRGTYP  = wtrbka_record_dict['CHRGTYP']
        TradeContext.BETELR   = PL_BETELR_AUTO
        input_dict = {}
        input_dict['FEDT']    = TradeContext.FEDT
        input_dict['RBSQ']    = TradeContext.RBSQ
        input_dict['PYRACC']  = wtrbka_record_dict['PYRACC']
        input_dict['PYRNAM']  = wtrbka_record_dict['PYRNAM']
        input_dict['PYEACC']  = wtrbka_record_dict['PYEACC']
        input_dict['PYENAM']  = wtrbka_record_dict['PYENAM']
        input_dict['CHRGTYP'] = wtrbka_record_dict['CHRGTYP']
        input_dict['OCCAMT']  = wtrbka_record_dict['OCCAMT']
        input_dict['CUSCHRG'] = wtrbka_record_dict['CUSCHRG']
        
        if(wtrbka_record_dict['TRCCO'] in ('3000002','3000004')):  
            AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通存来账记账")
            input_dict['RCCSMCD'] = PL_RCCSMCD_XJTCLZ
            rccpsEntriesErr.KZTCLZJZ(input_dict)
            
        elif(wtrbka_record_dict['TRCCO'] in ('3000003','3000005')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折本转异来账记账")
            input_dict['RCCSMCD'] = PL_RCCSMCD_BZYLZ
            rccpsEntriesErr.KZBZYLZJZ(input_dict)
            
        elif(wtrbka_record_dict['TRCCO'] in ('3000102','3000104')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通兑来账记账")
            input_dict['RCCSMCD'] = PL_RCCSMCD_XJTDLZ
            rccpsEntriesErr.KZTDLZJZ(input_dict)
            
        elif(wtrbka_record_dict['TRCCO'] in ('3000103','3000105')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折异转本来账记账")
            input_dict['RCCSMCD'] = PL_RCCSMCD_YZBLZ
            rccpsEntriesErr.KZYZBLZJZ(input_dict)
            
        else:
            return AfaFlowControl.ExitThisFlow('A099','交易代码非法')
    
    elif(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_SND):
        AfaLoggerFunc.tradeInfo("<<<<<<原交易为往账")
         
#        if(TradeContext.existVariable("BSPSQN")):
#            TradeContext.BSPSQN = wtrbka_record_dict['BSPSQN']
        TradeContext.BESBNO   = wtrbka_record_dict['BESBNO']   
        TradeContext.CHRGTYP  = wtrbka_record_dict['CHRGTYP']
        TradeContext.BRSFLG   = wtrbka_record_dict['BRSFLG']    
        TradeContext.BETELR   = PL_BETELR_AUTO
        input_dict = {}
        input_dict['FEDT']    = TradeContext.FEDT
        input_dict['RBSQ']    = TradeContext.RBSQ
        input_dict['PYRACC']  = wtrbka_record_dict['PYRACC']
        input_dict['PYRNAM']  = wtrbka_record_dict['PYRNAM']
        input_dict['PYEACC']  = wtrbka_record_dict['PYEACC']
        input_dict['PYENAM']  = wtrbka_record_dict['PYENAM']
        input_dict['CHRGTYP'] = wtrbka_record_dict['CHRGTYP']
        input_dict['OCCAMT']  = wtrbka_record_dict['OCCAMT']
        input_dict['CUSCHRG'] = wtrbka_record_dict['CUSCHRG']
        
        if(wtrbka_record_dict['TRCCO'] in ('3000002','3000004')):  
            AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通存往账记账")
            input_dict['RCCSMCD'] = PL_RCCSMCD_XJTCWZ
            rccpsEntriesErr.KZTCWZJZ(input_dict)
            
        elif(wtrbka_record_dict['TRCCO'] in ('3000003','3000005')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折本转异往账记账")
            input_dict['RCCSMCD'] = PL_RCCSMCD_BZYWZ
            rccpsEntriesErr.KZBZYWZJZ(input_dict)
            
        elif(wtrbka_record_dict['TRCCO'] in ('3000102','3000104')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通兑往账记账")
            input_dict['RCCSMCD'] = PL_RCCSMCD_XJTDWZ
            rccpsEntriesErr.KZTDWZJZ(input_dict)
            
        elif(wtrbka_record_dict['TRCCO'] in ('3000103','3000105')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折异转本往账记账")
            input_dict['RCCSMCD'] = PL_RCCSMCD_YZBWZ
            rccpsEntriesErr.KZYZBWZJZ(input_dict)
        
        else:
            return AfaFlowControl.ExitThisFlow('A099','交易代码非法')
        
    else:
        return AfaFlowControl.ExitThisFlow('A099','往来标示非法')
        
    #=====主机前设置原交易的状态====
    bcstat = ''    #状态变量
    if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_SND):    #往账
        bcstat = PL_BCSTAT_ACC
    elif(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_RCV and wtrbka_record_dict['TRCCO'] in ('3000002','3000003','3000004','3000005')):    #来账通存
        bcstat = PL_BCSTAT_AUTO
    else:    #来账通兑
        bcstat = PL_BCSTAT_AUTOPAY
    
    #=====判断原交易是否有成功的账务状态====
    AfaLoggerFunc.tradeInfo("<<<<<<判断原交易是是否有成功的交易状态")
    isaccount = 0    #调用主机交易标示,0不调用,1调用
    acc = 0    
    hcac = 0    
    canc = 0
    cancel = 0
    if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_SND):
        #=====原业务为往账====
        #=====查询是否有记账成功的状态====
        sstlog_list = []
        if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_ACC,PL_BDWFLG_SUCC,sstlog_list):
            acc = len(sstlog_list)
        #=====查询是否有抹账的状态====
        sstlog_list = []
        if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_HCAC,PL_BDWFLG_SUCC,sstlog_list):
            hcac = len(sstlog_list)
        #=====查询是否有冲销的状态====
        sstlog_list = []
        if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_CANC,PL_BDWFLG_SUCC,sstlog_list):
            canc = len(sstlog_list)
        #=====查询是否有冲正的状态====
        ssltog_list = []
        if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_CANCEL,PL_BDWFLG_SUCC,sstlog_list):
            cancel = len(sstlog_list)
        
        if(acc - (hcac + canc + cancel) <= 0):
            isaccount = 1
            
    else:
        #======原业务为来账====
        stat_dict = {}
        res = rccpsState.getTransStateCur(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],stat_dict)
        if(res == False):
            return AfaFlowControl.ExitThisFlow('A099','查询业务的当前状态失败')
        else:
            AfaLoggerFunc.tradeInfo("查询业务当前状态成功")
            
        if(stat_dict['BCSTAT'] in (PL_BCSTAT_AUTO,PL_BCSTAT_AUTOPAY) and stat_dict['BDWFLG'] == PL_BDWFLG_SUCC):
            isaccount = 0
        else:
            isaccount = 1
            
    AfaLoggerFunc.tradeInfo("<<<<<<结束判断原交易是是否有成功的交易状态")
            
    #=====判断业务是否需要进行主机记账====
    if(isaccount == 0):
        return AfaFlowControl.ExitThisFlow('S999','原业务已记账,禁止提交')
    
    #=====主机前设置原交易状态====  
    AfaLoggerFunc.tradeInfo("<<<<<<主机前设置原交易状态")  
    if not rccpsState.newTransState(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],bcstat,PL_BDWFLG_WAIT):
        return AfaFlowControl.ExitThisFlow('S999','设置业务状态为记账处理中异常')
    else:
        AfaDBFunc.CommitSql()
        
    #=====开始调用主机交易====
    AfaLoggerFunc.tradeInfo("<<<<<<开始调用主机交易")
    rccpsHostFunc.CommHost( TradeContext.HostCode )
    AfaLoggerFunc.tradeInfo("<<<<<<结束调用主机交易")   
        
    AfaLoggerFunc.tradeInfo("<<<<<<结束行内补记")
    
    #=====给状态字典赋值====
    state_dict = {}
    state_dict['BJEDTE'] = wtrbka_record_dict['BJEDTE']
    state_dict['BSPSQN'] = wtrbka_record_dict['BSPSQN']
    state_dict['BCSTAT'] = bcstat
    state_dict['MGID']   = TradeContext.errorCode
    if TradeContext.existVariable('TRDT'):
        state_dict['TRDT']   = TradeContext.TRDT
    if TradeContext.existVariable('TLSQ'):
        state_dict['TLSQ']   = TradeContext.TLSQ
    if TradeContext.existVariable('RBSQ'): 
        state_dict['RBSQ'] = TradeContext.RBSQ
    if TradeContext.existVariable('FEDT'):
        state_dict['FEDT'] = TradeContext.FEDT
    
    #=====判断主机交易是否成功====
    AfaLoggerFunc.tradeInfo("<<<<<<判断主机交易是否成功")
    AfaLoggerFunc.tradeDebug("<<<<<<errorCode=" + TradeContext.errorCode)
    if(TradeContext.errorCode != '0000'):
        AfaLoggerFunc.tradeInfo("调用主机交易失败")
        #=====主机后更改原交易状态为失败====
        state_dict['BDWFLG'] = PL_BDWFLG_FAIL
        state_dict['STRINFO'] = TradeContext.errorMsg
        if not rccpsState.setTransState(state_dict):
            return AfaFlowControl.ExitThisFlow('S999','设置业务状态为失败异常')
        else:
            AfaDBFunc.CommitSql()
       
        return AfaFlowControl.ExitThisFlow('S999','主机交易失败')
        
    else:
        AfaLoggerFunc.tradeInfo("调用主机交易成功")
        #=====主机后更改原交易状态为成功====
        state_dict['BDWFLG'] = PL_BDWFLG_SUCC
        state_dict['STRINFO'] = '主机成功'
        if(TradeContext.existVariable("SBAC")):
            state_dict['SBAC'] = TradeContext.SBAC
        if(TradeContext.existVariable("RBAC")):
            state_dict['RBAC'] = TradeContext.RBAC
        if not rccpsState.setTransState(state_dict):
            return AfaFlowControl.ExitThisFlow('S999','设置业务状态为失败成功')
        else:
            AfaDBFunc.CommitSql()
            
        #=====如果是往账要将状态设置为清算成功====
        if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_SND):    #往账
            if not rccpsState.newTransState(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_MFESTL,PL_BDWFLG_SUCC):
                return AfaFlowControl.ExitThisFlow('S999','设置业务状态为清算成功异常')
            else:
                AfaDBFunc.CommitSql()
        
    #=====更改错账登记簿中的处理标示====
    AfaLoggerFunc.tradeInfo("<<<<<<更改错账登记簿中的处理标示")
    where_dict = {}
    where_dict = {'BJEDTE':tddzcz_record_dict['BJEDTE'],'BSPSQN':tddzcz_record_dict['BSPSQN']}
    update_dict = {}
    update_dict['ISDEAL'] = PL_ISDEAL_ISDO
    update_dict['NOTE3']  = '此笔错账已补记'
    res = rccpsDBTrcc_tddzcz.updateCmt(update_dict,where_dict)
    if(res == -1):
        return AfaFlowControl.ExitThisFlow('S999','主机记账已成功,但更新处理标示失败,请手动更改处理标示')
        
    else:
        AfaLoggerFunc.tradeInfo("<<<<<<更改错账登记簿中的处理标示成功")

    #=====向下发的通知表中插入数据====
    AfaLoggerFunc.tradeInfo("<<<<<<向通知表中插入数据")
    insert_dict = {}
    insert_dict['NOTDAT']  = TradeContext.BJEDTE
    insert_dict['BESBNO']  = wtrbka_record_dict['BESBNO']
    if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_RCV):
        insert_dict['STRINFO'] = "此笔错账["+wtrbka_record_dict['BSPSQN']+"]["+wtrbka_record_dict['BJEDTE']+"]已做补记处理"
    else:
        insert_dict['STRINFO'] = "此笔错账["+wtrbka_record_dict['BSPSQN']+"]["+wtrbka_record_dict['BJEDTE']+"]已做补记处理 请用8522补打往账凭证"
    if not rccpsDBTrcc_notbka.insertCmt(insert_dict):
        return AfaFlowControl.ExitThisFlow('S999','向下发的通知表中插入数据失败')
    AfaLoggerFunc.tradeInfo("<<<<<<向通知表中插入数据成功")
    
    
    #=====给输出接口赋值====
    AfaLoggerFunc.tradeInfo("<<<<<<开始给输出接口赋值")
    TradeContext.BOSPSQ     = wtrbka_record_dict['BSPSQN']
    TradeContext.BOJEDT     = wtrbka_record_dict['BJEDTE']
    TradeContext.TLSQ       = TradeContext.TLSQ
    TradeContext.TRCCO      = wtrbka_record_dict['TRCCO']
    TradeContext.BRSFLG     = wtrbka_record_dict['BRSFLG']
    TradeContext.BEACSB     = wtrbka_record_dict['BESBNO']
    TradeContext.OROCCAMT   = str(wtrbka_record_dict['OCCAMT'])
    TradeContext.ORCUR      = wtrbka_record_dict['CUR']
    TradeContext.ORSNDBNK   = wtrbka_record_dict['SNDBNKCO']
    TradeContext.ORSNDBNKNM = wtrbka_record_dict['SNDBNKNM']
    TradeContext.ORRCVBNK   = wtrbka_record_dict['RCVBNKCO']
    TradeContext.ORRCVBNKNM = wtrbka_record_dict['RCVBNKNM']
    TradeContext.ORPYRACC   = wtrbka_record_dict['PYRACC']
    TradeContext.ORPYRNAM   = wtrbka_record_dict['PYRNAM']
    TradeContext.ORPYEACC   = wtrbka_record_dict['PYEACC']
    TradeContext.ORPYENAM   = wtrbka_record_dict['PYENAM']
#    TradeContext.SBAC       = 
#    TradeContext.RBAC       = 
    
    AfaLoggerFunc.tradeInfo("<<<<<<结束给输出接口赋值")
    
    AfaLoggerFunc.tradeInfo("<<<<<<<个性化处理(本地操作) 退出")
    
    AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.差错账补记[8572] 退出")
    
    return True
Пример #11
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).存款确认请求报文接收[TRCC006_1143]进入***' )
    
    #判断是否重复报文
    AfaLoggerFunc.tradeInfo(">>>开始判断是否重复报文")
    
    sel_dict = {'COTRCNO':TradeContext.TRCNO,'COTRCDAT':TradeContext.TRCDAT,'SNDBNKCO':TradeContext.SNDBNKCO}
    record = rccpsDBTrcc_wtrbka.selectu(sel_dict)
    
    if record == None:
        return AfaFlowControl.ExitThisFlow('S999','判断是否重复存款确认报文,查询通存通兑业务登记簿相同报文异常')
        
    elif len(record) > 0:
        AfaLoggerFunc.tradeInfo('通存通兑业务登记簿中存在相同数据,重复报文,返回应答报文')
        TradeContext.STRINFO  = "重复报文"
    else:
        #查询原存款交易信息
        AfaLoggerFunc.tradeInfo(">>>非重复报文,开始查询原存款交易信息")
        
        wtrbka_dict = {}
        
        if not rccpsDBFunc.getTransWtrAK(TradeContext.SNDBNKCO,TradeContext.TRCDAT,TradeContext.ORTRCNO,wtrbka_dict):
            AfaFlowControl.ExitThisFlow('S999',"查询原存款交易信息异常")
            
        TradeContext.BJEDTE = wtrbka_dict['BJEDTE']
        TradeContext.BSPSQN = wtrbka_dict['BSPSQN']
        TradeContext.PYEACC = wtrbka_dict['PYEACC']
        TradeContext.PYENAM = wtrbka_dict['PYENAM']
        TradeContext.OCCAMT = wtrbka_dict['OCCAMT']
        TradeContext.BESBNO = wtrbka_dict['BESBNO']
        
        AfaLoggerFunc.tradeInfo(">>>结束查询原存款交易信息")
        
        
        #检查交易当前状态是否为确认入账成功,非此状态则丢弃报文
        AfaLoggerFunc.tradeInfo(">>>开始判断交易当前状态是否为确认入账成功")
        
        stat_dict = {}
        
        if not rccpsState.getTransStateCur(TradeContext.BJEDTE,TradeContext.BSPSQN,stat_dict):
            return AfaFlowControl.ExitThisFlow('S999',"获取原存款交易当前状态异常")
            
        #if not (stat_dict['BCSTAT'] == PL_BCSTAT_CONFACC and stat_dict['BDWFLG'] == PL_BDWFLG_SUCC):
        #    return AfaFlowControl.ExitThisFlow('S999',"原存款交易当前状态非确认入账成功,丢弃报文")
        
        AfaLoggerFunc.tradeInfo(">>>结束判断交易当前状态是否为确认入账成功")
        
        #更新通存通兑登记簿存款确认相关信息
        AfaLoggerFunc.tradeInfo(">>>开始更新通存通兑登记簿存款确认相关信息")
        
        wtrbka_where_dict = {}
        wtrbka_where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN}
            
        wtrbka_update_dict = {}
        wtrbka_update_dict = {'COTRCDAT':TradeContext.TRCDAT,'COTRCNO':TradeContext.TRCNO,'COMSGFLGNO':TradeContext.MSGFLGNO}
            
        ret = rccpsDBTrcc_wtrbka.update(wtrbka_update_dict,wtrbka_where_dict)
        
        if ret <= 0:
            return AfaFlowControl.ExitThisFlow('S999',"更新通存通兑登记簿存款确认相关信息异常")
        
        AfaLoggerFunc.tradeInfo(">>>结束更新通存通兑登记簿存款确认相关信息")
        
        
        #设置业务状态为自动入账处理中
        AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为自动入账处理中")
        
        if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CONFACC,PL_BDWFLG_WAIT):
                return AfaFlowControl.ExitThisFlow('S999','设置业务状态为自动入账处理中异常')
        
        if not AfaDBFunc.CommitSql( ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return AfaFlowControl.ExitThisFlow("S999","Commit异常")
            
        AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为自动入账处理中")
        
        #发起主机记账
        AfaLoggerFunc.tradeInfo(">>>开始发起主机记账")
        
        TradeContext.HostCode = '8813'                               #调用8813主机接口
        TradeContext.RCCSMCD  = PL_RCCSMCD_HDLZ                      #主机摘要代码:汇兑来账
        TradeContext.SBAC = TradeContext.BESBNO + PL_ACC_NXYDQSLZ    #借方账户:农信银待清算来账
        TradeContext.SBNM = "农信银待清算来账"
        TradeContext.RBAC = TradeContext.PYEACC                      #贷方账户:收款人账户
        TradeContext.RBNM = TradeContext.PYENAM                      #贷方户名:收款人户名
        TradeContext.OCCAMT = str(TradeContext.OCCAMT)
        
        #=====add by pgt 12-5====
        TradeContext.CTFG = '7'                                      #本金 手续费标识  7 本金 8手续费 9 本金+手续费 
        TradeContext.PKFG = 'T'                                      #通存通兑标识                                   
        
        TradeContext.SBAC = rccpsHostFunc.CrtAcc(TradeContext.SBAC, 25)
        
        AfaLoggerFunc.tradeInfo( '借方账号:' + TradeContext.SBAC )
        AfaLoggerFunc.tradeInfo( '贷方账号:' + TradeContext.RBAC )
        
        rccpsHostFunc.CommHost( TradeContext.HostCode )
        
        AfaLoggerFunc.tradeInfo(">>>结束发起主机记账")
        
        #根据主机返回码,设置业务状态为自动入账成功或失败
        AfaLoggerFunc.tradeInfo(">>>开始根据主机返回码,设置业务状态为自动入账成功或失败")
        
        stat_dict = {}
        stat_dict['BJEDTE']  = TradeContext.BJEDTE
        stat_dict['BJETIM']  = TradeContext.BJETIM
        stat_dict['BSPSQN']  = TradeContext.BSPSQN
        stat_dict['BESBNO']  = TradeContext.BESBNO
        stat_dict['BETELR']  = TradeContext.BETELR
        stat_dict['SBAC']    = TradeContext.SBAC
        stat_dict['ACNM']    = TradeContext.SBNM
        stat_dict['RBAC']    = TradeContext.RBAC
        stat_dict['OTNM']    = TradeContext.RBNM
        stat_dict['PRCCO']   = TradeContext.errorCode
        stat_dict['STRINFO'] = TradeContext.errorMsg
        
        AfaLoggerFunc.tradeInfo("主机返回码[" + TradeContext.errorCode + "],主机返回信息[" + TradeContext.errorMsg +"]")
        if TradeContext.errorCode == '0000':
            #=====发送农信银成功,设置状态为自动入账成功====
            stat_dict['TRDT']    = TradeContext.TRDT
            stat_dict['TLSQ']    = TradeContext.TLSQ
            stat_dict['BCSTAT']  = PL_BCSTAT_AUTO
            stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
            TradeContext.STRINFO = '成功'
            
            if not rccpsState.setTransState(stat_dict):
                return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为自动入账成功异常")
            
            AfaLoggerFunc.tradeInfo(">>>设置业务状态为自动入账成功完成")
        else:
            #=====发送农信银失败,设置状态为自动入账失败====       
            stat_dict['BCSTAT']  = PL_BCSTAT_AUTO
            stat_dict['BDWFLG']  = PL_BDWFLG_FAIL
            TradeContext.STRINFO = '行内自动入账失败'
            
            if not rccpsState.setTransState(stat_dict):
                return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为自动入账失败异常")
            
            AfaLoggerFunc.tradeInfo(">>>设置业务状态为自动入账失败完成")
        
        if not AfaDBFunc.CommitSql( ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return AfaFlowControl.ExitThisFlow("S999","Commit异常")
        
    #为存款确认应答报文赋值
    TradeContext.sysType  = 'rccpst'
    TradeContext.MSGTYPCO = 'SET010'
    TradeContext.RCVSTLBIN = TradeContext.SNDMBRCO
    TradeContext.SNDSTLBIN = TradeContext.RCVMBRCO
    TradeContext.SNDBRHCO = TradeContext.BESBNO
    TradeContext.SNDCLKNO = TradeContext.BETELR
    #TradeContext.SNDTRDAT = TradeContext.BJEDTE
    #TradeContext.SNDTRTIM = TradeContext.BJETIM
    TradeContext.ORMFN    = TradeContext.MSGFLGNO
    #TradeContext.MSGFLGNO = TradeContext.SNDMBRCO + TradeContext.BJEDTE + TradeContext.SerialNo
    #TradeContext.NCCWKDAT = TradeContext.NCCworkDate
    TradeContext.OPRTYPNO = '30'
    TradeContext.ROPRTPNO = TradeContext.OPRTYPNO
    TradeContext.TRANTYP  = '0'
    
    TradeContext.CUR      = 'CNY'
    TradeContext.PRCCO    = 'RCCI0000'
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).存款确认请求报文接收[TRCC006_1143]退出***' )
    
    return True
Пример #12
0
     file_line = file_line + tddzmx_list[i]['SNDBNKCO'].ljust(12,' ') + '|' #发起行号
     file_line = file_line + tddzmx_list[i]['SNDBNKNM'].ljust(62,' ') + '|' #发起行名
     file_line = file_line + trc_dict['BRSFLG'].ljust(1,' ')    + '|' #往来标识
     file_line = file_line + "".ljust(5,' ')                    + '|' #业务类型
     file_line = file_line + stat_dict['SBAC'].ljust(32,' ')    + '|' #借方账号
     file_line = file_line + stat_dict['ACNM'].ljust(62,' ')    + '|' #借方户名
     file_line = file_line + "".ljust(62,' ')                   + '|' #借方地址
     file_line = file_line + tddzmx_list[i]['RCVBNKCO'].ljust(12,' ') + '|' #接收行号
     file_line = file_line + tddzmx_list[i]['RCVBNKNM'].ljust(62,' ') + '|' #接收行名
     file_line = file_line + stat_dict['RBAC'].ljust(32,' ')    + '|' #贷方账号
     file_line = file_line + stat_dict['OTNM'].ljust(62,' ')    + '|' #贷方户名
     file_line = file_line + "".ljust(62,' ')                   + '|' #贷方地址
 else:
     #===来账查询自动入账/自动扣款状态信息中的借贷方账号信息==========
     stat_dict = {}
     if rccpsState.getTransStateCur(tddzmx_list[i]['BJEDTE'],tddzmx_list[i]['BSPSQN'],stat_dict):
         AfaLoggerFunc.tradeInfo("查询流水状态登记簿中当前状态成功")
         if not (stat_dict['BCSTAT'] in (PL_BCSTAT_AUTO,PL_BCSTAT_AUTOPAY) and stat_dict['BDWFLG']):
             rccpsCronFunc.cronExit("S999","交易当前状态非自动入账或自动扣款")
     else:
         rccpsCronFunc.cronExit("S999","流水状态登记簿中当前状态异常")
             
     file_line = file_line + "RCC".ljust(8,' ')                 + '|' #代理业务号
     file_line = file_line + stat_dict['FEDT'].ljust(8,' ')     + '|' #前置日期
     file_line = file_line + stat_dict['RBSQ'].ljust(12,' ')    + '|' #前置流水号
     file_line = file_line + tddzmx_list[i]['SNDBNKCO'].ljust(12,' ') + '|' #发起行号
     file_line = file_line + tddzmx_list[i]['SNDBNKNM'].ljust(62,' ') + '|' #发起行名
     file_line = file_line + trc_dict['BRSFLG'].ljust(1,' ')    + '|' #往来标识
     file_line = file_line + "".ljust(5,' ')                    + '|' #业务类型
     file_line = file_line + stat_dict['SBAC'].ljust(32,' ')    + '|' #借方账号
     file_line = file_line + stat_dict['ACNM'].ljust(62,' ')    + '|' #借方户名