Example #1
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo('进入单证重打交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']与第三方通信后处理' )
    
    try:
        names = Party3Context.getNames( )
       
        for name in names:
            value = getattr( Party3Context, name )
            if ( not name.startswith( '__' ) and type(value) is StringType or type(value) is ListType) :
                setattr( TradeContext, name, value )
            
        if(TradeContext.errorCode=='0000'):
            #第三方返回成功后更新原保单印刷号
            update_sql = "update afa_maintransdtl set "                                             
            update_sql = update_sql + " userno            = '" + TradeContext.userno1     + "'"       #user1新保单印刷号
            update_sql = update_sql + " where userno      = '" + TradeContext.userno      + "'"       #user原保单印刷号 
            update_sql = update_sql + " and workdate      = '" + TradeContext.workDate    + "'"       #日期  
            update_sql = update_sql + " and agentserialno = '" + TradeContext.PreSerialno + "'"       #缴费成功的中间业务流水号
            
            #更新并提交数据
            if  AfaDBFunc.UpdateSqlCmt(update_sql)<0:
                return AfaFlowControl.ExitThisFlow("A999","更新投保单号失败")
                
            #第三方返回成功后生成现金价值文件
            if not YbtFunc.createFile( ):
                return False

        AfaLoggerFunc.tradeInfo('退出单证重打[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']与第三方通讯后处理' )
        return True
    
    except Exception, e:
        AfaFlowControl.exitMainFlow(str(e))
Example #2
0
def ChkParam(ChkCode='11111111'):

    if ChkCode[0]=='1':
    	#===============判断应用系统状态======================
    	if not AfaFunc.ChkSysStatus( ) :
    		raise AfaFlowControl.flowException( )
    		    
    if ChkCode[1]=='1':
    	#===============判断商户状态======================
    	if not AfaFunc.ChkUnitStatus( ) :
    		raise AfaFlowControl.flowException( )

    if ChkCode[2]=='1':
        #=============判断交易状态=====================
        if not AfaFunc.ChkTradeStatus( ) :
            raise AfaFlowControl.flowException( )

    if ChkCode[3]=='1':
    	#=============判断渠道状态====================
    	if not AfaFunc.ChkChannelStatus( ) :
    		raise AfaFlowControl.flowException( )

    if ChkCode[4]=='1':
    	#=============判断缴费介质状态====================
    	if not AfaFunc.ChkActStatus( ) :
    		raise AfaFlowControl.flowException( )

    return True
Example #3
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo('进入续期查询交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']与第三方通讯后处理' )
    
    try:
        names = Party3Context.getNames( )
        for name in names:
            value = getattr( Party3Context, name )
            if ( not name.startswith( '__' ) and type(value) is StringType) :
                setattr( TradeContext, name, value )
          
        if(TradeContext.errorCode=='0000'):
            TradeContext.errorMsg="续期查询成功"
        
        
        #TradeContext.syr_name1 = ''
        #syr_name = []
        #if TradeContext.existVariable('syr_name1'):
        #    syr_name.append('xiaozhang')
        #    syr_name.append('xig')
        TradeContext.O1ACUR = '1'
        #    TradeContext.syr_name = syr_name 
     
        AfaLoggerFunc.tradeInfo('退出续期查询交易与第三方通讯后处理' )    
        return True
        
    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( str(e) )
Example #4
0
def ChkUnitLimit( ):

    try:
        AfaLoggerFunc.tradeInfo('>>>判断该单位是否有批量签约的权限')
        sql = ""
        sql = "SELECT FLAG FROM ABDT_QYFLAG WHERE "
        sql = sql + " SYSID = '" + TradeContext.sysId + "'" 
        sql = sql + " AND STATUS = '1'"
        
        records = AfaDBFunc.SelectSql( sql )
        AfaLoggerFunc.tradeInfo('查询数据库 sql: ' +sql)
        
        if(records==None):
            TradeContext.errorCode,TradeContext.errorMsg = "9999" , "查询ABDT_QYFLAG数据库异常!"
            raise AfaFlowControl.flowException( ) 
                      
        elif(len(records)==0):
            TradeContext.errorCode,TradeContext.errorMsg = "9999" , "无该单位签约权限信息!"
            raise AfaFlowControl.flowException( ) 

        else:
            if (records[0][0]=='0'):
                TradeContext.errorCode,TradeContext.errorMsg = "9999" , "该单位无签约权限!"
                raise AfaFlowControl.flowException( ) 
                
            if (records[0][0]=='1'):
                AfaLoggerFunc.tradeInfo('>>>该单位有签约权限')
                return True 
                         
        return True
        
    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( str(e) )
Example #5
0
def main( ):
    AfaLoggerFunc.tradeInfo('******统缴业务行内查询模板[' + TradeContext.TemplateCode + ']进入******')
    try:
        
        #=====================初始化返回报文变量================================
        TradeContext.tradeResponse=[]
        
        #获取当前系统时间
        TradeContext.workDate=AfaUtilTools.GetSysDate( )
        TradeContext.workTime=AfaUtilTools.GetSysTime( )
        
        #=====================判断应用系统状态==================================  
            
        if not AfaFunc.ChkSysStatus( ) :                                          
            raise AfaFlowControl.flowException( ) 
        
     #20120711注释 修改
     #begin
        #=====================判断单位状态======================================
        if not AfaTjFunc.ChkUnitInfo( ):
            raise AfaFlowControl.flowException( )
            
     #end                                    
                                                                                  
        #=====================外调接口(前处理)==================================  
        subModuleExistFlag = 0                                                    
        subModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode  
        try:                                                                      
            subModuleHandle=__import__( subModuleName )                           
        except Exception, e:                                                      
            AfaLoggerFunc.tradeInfo( e)                                           
        else:                                                                     
Example #6
0
def SubModuleMainFst( ):
    try:
        
        AfaLoggerFunc.tradeInfo( '进入变更开户行行号[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
        
        #检查原开户行行号是否与数据库中登记的开户行行号一致
        sqlStr = ""
        sqlStr = sqlStr + "SELECT PAYOPBKCODE FROM TIPS_CUSTINFO WHERE TAXORGCODE = '" + TradeContext.taxOrgCode + "'" 
        sqlStr = sqlStr + " AND PAYACCT ='" + TradeContext.payAcct + "'"
        #sqlStr = sqlStr + " AND PAYOPBKCODE ='" + TradeContext.payBkCode+ "'"
        sqlStr = sqlStr + " AND PROTOCOLNO ='" +TradeContext.protocolNo+"'"
        
        AfaLoggerFunc.tradeInfo(sqlStr)
        
        records = AfaDBFunc.SelectSql( sqlStr )
        
        if( records == None ):
            
            return TipsFunc.ExitThisFlow( 'A0027', '表操作异常:'+AfaDBFunc.sqlErrMsg )
                
        elif( len( records )==0 ):
                
            return TipsFunc.ExitThisFlow( 'A0027', '没有满足条件的数据记录!' )
            
        else: 
            AfaLoggerFunc.tradeDebug("原开户行行号为:" +records[0][0])
                
        if(records[0][0] !=TradeContext.payBkCode):
            TradeContext.errorCode,TradeContext.errorMsg = "A0001","原开户行行号不正确!"
            return False
                
        
        #====================更新开户行行号====================
        AfaLoggerFunc.tradeInfo(">>>更改开户行行号")
        update_sql = ""
        update_sql = "UPDATE TIPS_CUSTINFO SET PAYOPBKCODE = '" + TradeContext.payBkCode1 + "'"
        update_sql = update_sql + "WHERE TAXORGCODE = '" + TradeContext.taxOrgCode + "'"
        update_sql = update_sql + " AND PAYACCT ='" + TradeContext.payAcct + "'"
        update_sql = update_sql + " AND PAYOPBKCODE ='" + TradeContext.payBkCode+ "'"
        update_sql = update_sql + " AND PROTOCOLNO ='" +TradeContext.protocolNo+"'" 
        
        AfaLoggerFunc.tradeInfo(update_sql)
        
        if  AfaDBFunc.UpdateSqlCmt(update_sql)<0:
                return AfaFlowControl.ExitThisFlow("A0027","更新开户行行号失败!")
        
        TradeContext.errorCode,TradeContext.errorMsg = "0000","交易成功"

        AfaLoggerFunc.tradeInfo( '退出变更开户行行号[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
    
        return True 
    
    except Exception, e:             

        AfaFlowControl.exitMainFlow(str(e))    
Example #7
0
def TrxMain( ):
    AfaLoggerFunc.tradeInfo('---------新农保柜面业务进入------------')
    
    #业务编号
    if ( not (TradeContext.existVariable( "Appno" ) and len(TradeContext.Appno.strip()) > 0) ):
        TradeContext.errorCode,TradeContext.errorMsg = 'NB001', "不存在业务编号"
        raise AfaFlowControl.flowException( )
    #单位编号
    if ( not (TradeContext.existVariable( "Busino" ) and len(TradeContext.Busino.strip()) > 0) ):
        TradeContext.errorCode,TradeContext.errorMsg = 'NB001', "不存在单位编号"
        raise AfaFlowControl.flowException( )
    #上传文件名
    if ( not (TradeContext.existVariable( "FileName" ) and len(TradeContext.FileName.strip()) > 0) ):
        TradeContext.errorCode,TradeContext.errorMsg = 'NB001', "不存在上传文件名"
        raise AfaFlowControl.flowException( )
    #申请日期
    if ( not (TradeContext.existVariable( "ApplyDate" ) and len(TradeContext.ApplyDate.strip()) > 0) ):
        TradeContext.errorCode,TradeContext.errorMsg = 'NB001', "不存在申请日期"
        raise AfaFlowControl.flowException( )
    
    sql = ""
    sql = sql + "select BATCHNO,FILENAME,SWAPFILENAME,WORKDATE,STATUS,"
    sql = sql + "PROCMSG,APPLYDATE,APPNO,BUSINO,TOTALNUM,TOTALAMT,FILETYPE,"
    sql = sql + "BRNO,TELLERNO,BEGINDATE,ENDDATE,WORKTIME,NOTE1,NOTE2,NOTE3,NOTE4"
    sql = sql + " from ahnx_file where"
    sql = sql + " FileName = '"+ TradeContext.FileName +"'"            #上传文件名
    sql = sql + " and ApplyDate = '"+ TradeContext.ApplyDate +"'"      #申请日期
    sql = sql + " and status <>"  + "'2'"                              #文件状态
    
    sql = sql + " and Appno = '"+ TradeContext.Appno +"'"              #业务编号
    sql = sql + " and Busino = '"+ TradeContext.Busino +"'"            #单位编号
    
    AfaLoggerFunc.tradeInfo("批量处理信息查询sql="+sql)
    records = AfaDBFunc.SelectSql( sql )
    
    if(records == None):
        AfaLoggerFunc.tradeInfo("批量处理信息查询数据库异常")
        return ExitSubTrade('NB000', '批量处理信息查询数据库异常')
    elif(len(records)==0):
        AfaLoggerFunc.tradeInfo("没有查询到相关的批量处理信息")
        return ExitSubTrade('NB002', '没有查询到相关的批量处理信息')
    elif(len(records)>1):
        AfaLoggerFunc.tradeInfo("该批量处理信息不唯一")
        return ExitSubTrade('NB003', '该批量处理信息不唯一')
    else:
        TradeContext.SwapFileName = records[0][2].strip()
        TradeContext.ProcMsg      = records[0][5].strip()
        TradeContext.FileType     = records[0][11].strip()
        TradeContext.batchNo      = records[0][0].strip()
        
    TradeContext.errorCode  = "0000"
    TradeContext.errorMsg   = "交易成功"
    AfaLoggerFunc.tradeInfo('---------新农保柜面业务退出------------')
    
    return ExitSubTrade('0000', '交易成功')
Example #8
0
def ChkSysInfo( ):
    AfaLoggerFunc.tradeInfo( '=====判断业务编号开始=====' )
 
    #判断业务编号 AG2016
    if not( TradeContext.existVariable( "sysId" ) and len(TradeContext.sysId.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "业务编号不存在"
            raise AfaFlowControl.flowException( )
            
    if not(TradeContext.sysId == 'AG2016') :
        TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "非此业务编号,不能做此业务!"
        raise AfaFlowControl.flowException( )        
Example #9
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo('缴费信息查询交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
    try:
        sql = "select agentserialno,"
        sql = sql + "userno,username,idcode,amount,usernameb,idcodeb,loandate,loanenddate,crevouno,crebarno,procode,cpicteller,note1 "
        sql = sql + " from afa_adbinfo where userno = '" + TradeContext.CpicNo.strip() + "' and note3 = '" + TradeContext.unitno.strip() + "'"
        sql = sql + " and workdate = '"+TradeContext.workDate + "'"
        sql = sql + " and tellerno = '"+TradeContext.tellerno + "'"
        sql = sql + " and dtlstatus = '0' "
        sql = sql + " order by agentserialno desc"
        AfaLoggerFunc.tradeInfo('缴费信息查询语句'+ sql)
        records = AfaDBFunc.SelectSql( sql )
        if(len(records) < 1):
            TradeContext.errorCode,TradeContext.errorMsg = "0001","无此投保信息"
            return False
        else:
            #用户编号(保险单号)
            TradeContext.CpicNo = records[0][1]
            #投保人名称
            TradeContext.UserName = records[0][2]
            #投保人身份证号码
            TradeContext.GovtID = records[0][3]
            #金额
            TradeContext.PaymentAmt = records[0][4]
            #被保人姓名
            TradeContext.UserNameB = records[0][5]
            #被保人身份证号码
            TradeContext.GovtIDB = records[0][6]
            #借款日期
            TradeContext.LoanDate = records[0][7]
            #借款到期日
            TradeContext.LoanEndDate = records[0][8]
            #借款凭证编号
            TradeContext.CreVouNo = records[0][9]
            #贷款合同编号
            TradeContext.CreBarNo = records[0][10]
            #保险种类
            TradeContext.ProCode = records[0][11]
            #太保业务员代码
            TradeContext.CpicTeller = records[0][12]
            #保单号
            TradeContext.CpciPNo = records[0][13]
            #交易返回码
            TradeContext.errorCode = '0000'
        AfaLoggerFunc.tradeInfo('退出缴费信息查询交易' )
        return True
    except Exception, e:
        AfaFlowControl.exitMainFlow(str(e))
Example #10
0
def SubModuleDoFst( ):
    
    AfaLoggerFunc.tradeInfo( '反交易数据预查询,查询是否有此缴费记录' )
    try:
        sql = "select workdate,worktime,userno,tellerno,brno,unitno,amount,trxcode from afa_maintransdtl"
        sql = sql + " where agentserialno = '"+TradeContext.preAgentSerno+"' and workdate = '"+TradeContext.workDate+"' and trxcode='8495'"
        sql = sql + " and revtranf = '0' and bankstatus = '0'and chkflag = '9'"
        
        #20120718陈浩添加
        sql = sql + " and  sysid = '" + TradeContext.sysId.strip()   + "' "
        sql = sql + " and  note2 = '" + TradeContext.busino.strip()  + "' "
        
        
        AfaLoggerFunc.tradeInfo('反交易查询语句:'+ sql)
        
        records = AfaDBFunc.SelectSql( sql )
        AfaLoggerFunc.tradeInfo('反交易查询的结果:'+ str(records))
        
        if records == None:
            TradeContext.errorCode,TradeContext.errorMsg = "0001","反交易查询数据失败"
            raise AfaFlowControl.flowException( )
        elif(len(records) < 1):
            TradeContext.errorCode,TradeContext.errorMsg = "0001","无此交易"
            return False
        else:
            if(records[0][3] != TradeContext.tellerno):
                TradeContext.errorCode,TradeContext.errorMsg = "0001","原交易非本柜员所做,不能做此交易"
                return False
            if(records[0][4] != TradeContext.brno):
                TradeContext.errorCode,TradeContext.errorMsg = "0001","原交易非本网点所做,不能做此交易"
                return False
            if(records[0][5] != TradeContext.unitno):
                TradeContext.errorCode,TradeContext.errorMsg = "0001","与原交易公司不符,不能做此交易"
                return False
            if(records[0][6].strip() != TradeContext.amount.strip()):
                TradeContext.errorCode,TradeContext.errorMsg = "0001","与原交易金额不符,不能做此交易"
                return False
           
            TradeContext.PreWorkDate = records[0][0]                  #原交易日期
            TradeContext.PreWorktime = records[0][1]                  #原交易时间
            TradeContext.PreTrxCode  = records[0][7]                  #原交易码
            TradeContext.amount = records[0][6]                       #金额
            TradeContext.preAgentSerno = TradeContext.preAgentSerno   #原交易流水号
        return True     
    except  Exception, e:                       
        AfaLoggerFunc.tradeInfo( str(e) )     
        AfaFlowControl.flowException( )       
                             
Example #11
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo('进入查询交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']与第三方通讯后处理' )
    try:
        
        Party3Context.agentSerialno = TradeContext.agentserialno
        Party3Context.workDate      = TradeContext.workDate
        Party3Context.workTime      = TradeContext.workTime
        Party3Context.amount        = TradeContext.amount
        Party3Context.hostserialno  = TradeContext.hostserialno
        Party3Context.CreBarNo      = TradeContext.CreBarNo  
        Party3Context.CreVouNo      = TradeContext.CreVouNo  
        Party3Context.LoanDate      = TradeContext.LoanDate
        Party3Context.LoanEndDate   = TradeContext.LoanEndDate
        Party3Context.ProCode       = TradeContext.ProCode
        Party3Context.ProCodeStr    = TradeContext.ProCodeStr
        Party3Context.PlanName      = TradeContext.PlanName  
        Party3Context.AccType       = TradeContext.AccType   
        
        names = Party3Context.getNames( )
        for name in names:
            value = getattr( Party3Context, name )
            setattr( TradeContext, name, value )
            #AfaLoggerFunc.tradeInfo("字段名称  ["+str(name)+"] =  "+str(value))
        if( TradeContext.errorCode == '0000' ):
            #if( TradeContext.existVariable( "ProCodeStr" ) ):
            #    if (TradeContext.ProCodeStr == "EL5602"):
            #        TradeContext.ProCode == "1"
            #    else:
            #        TradeContext.ProCode == "0"
            #责任起始日期日期
            if ( TradeContext.existVariable( "EffDate" )):
                if ( len(str(TradeContext.EffDate)) == 14 ):
                    TradeContext.EffDate = TradeContext.EffDate[0:4]+TradeContext.EffDate[6:8]+TradeContext.EffDate[10:12]
            if ( TradeContext.existVariable( "TermDate" )):
                if ( len(str(TradeContext.TermDate)) == 14 ):
                    TradeContext.TermDate = TradeContext.TermDate[0:4]+TradeContext.TermDate[6:8]+TradeContext.TermDate[10:12]
            update_sql = "update afa_maintransdtl set "
            update_sql = update_sql + " userno = '" + TradeContext.NCpicNo + "'"
            update_sql = update_sql + " where userno = '" + TradeContext.OCpicNo + "'"
            if not AfaDBFunc.UpdateSqlCmt(update_sql):
                return AfaFlowControl.exitThisFlow("A999","更新投保单号失败")

        AfaLoggerFunc.tradeInfo('退出查询交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']与第三方通讯后处理' )
        return True
    except Exception, e:
        AfaFlowControl.exitMainFlow(str(e))
Example #12
0
def FalseMsg():

    AfaLoggerFunc.tradeInfo('>>>存放导入错误信息...') 
    
    try:
        
        errorFile = '/home/maps/afa/data/batch/down/' + TradeContext.sysId + TradeContext.busiNo[6:] + TradeContext.workDate + TradeContext.prefileName[-7:-4]+ "_WF.TXT"
        
        mfp = open( errorFile, 'a' ) 
        AfaLoggerFunc.tradeInfo("错误信息的文件为:"  + errorFile) 
        TradeContext.errorFile = TradeContext.errorMsg                                                           
        mfp = open( errorFile, 'a' )                
        mfp.write( TradeContext.errorFile + "\n")
        mfp.close()  
        
    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( str(e) )
Example #13
0
def SubModuleDoFst( ):
    
    AfaLoggerFunc.tradeInfo( '反交易数据预查询,查询是否有此缴费记录' )
    try:
        sql = "select workdate,userno,tellerno,brno,amount from afa_maintransdtl"
        sql = sql + " where agentserialno = '"+TradeContext.preAgentSerno+"' and workdate = '"+TradeContext.workDate+"' and trxcode='8627'"
        sql = sql + " and revtranf = '0' and bankstatus = '0'and chkflag = '9'"
        
        AfaLoggerFunc.tradeInfo('反交易查询语句:'+ sql)
        
        records = AfaDBFunc.SelectSql( sql )
        AfaLoggerFunc.tradeInfo('反交易查询的结果:'+ str(records))
        
        if records == None:
            TradeContext.errorCode,TradeContext.errorMsg = "0001","反交易查询数据失败"
            raise AfaFlowControl.flowException( )
        elif(len(records) < 1):
            TradeContext.errorCode,TradeContext.errorMsg = "0001","无此交易"
            return False
        else:
            if(records[0][1] != TradeContext.punishNo):
                TradeContext.errorCode,TradeContext.errorMsg = "0001","与原交易的处罚交款书编号不一致,不能做此交易"
                return False
            
            if(records[0][2] != TradeContext.tellerno):
                TradeContext.errorCode,TradeContext.errorMsg = "0001","原交易非本柜员所做,不能做此交易"
                return False
            if(records[0][3] != TradeContext.brno):
                TradeContext.errorCode,TradeContext.errorMsg = "0001","原交易非本网点所做,不能做此交易"
                return False
            if(records[0][4].strip() != TradeContext.amount.strip()):
                TradeContext.errorCode,TradeContext.errorMsg = "0001","与原交易金额不符,不能做此交易"
                return False
           
            TradeContext.orgDate       = records[0][0]                #原交易日期
            TradeContext.punishNo      = records[0][1]                #处罚交款书编号 
            TradeContext.userno        = records[0][1]                #初始化userno的值,取消变量检查时需要
            TradeContext.amount        = records[0][4]                #金额 
            TradeContext.preAgentSerno = TradeContext.preAgentSerno   #原交易流水号
        TradeContext.note2             = TradeContext.busino          #签约单位编号
            
        return True     
    except  Exception, e:                     
        AfaLoggerFunc.tradeInfo( str(e) )     
        AfaFlowControl.flowException( )   
Example #14
0
def SubModuleDoFst( ):

    AfaLoggerFunc.tradeInfo( '初始化续期查询交易变量' )
    
    #交易代码(8612)
    TradeContext.tradeCode = TradeContext.TransCode
    
    #保险公司代码
    if not( TradeContext.existVariable( "unitno" ) and len(TradeContext.unitno.strip()) > 0):
        TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "不存在保险公司代码"
        raise AfaFlowControl.flowException( ) 
   
    #保险单号
    if not( TradeContext.existVariable( "policy" ) and len(TradeContext.policy.strip()) > 0):
        TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "不存在保险单号"
        raise AfaFlowControl.flowException( )
   
    return True
Example #15
0
def CrtBatchNo( ):

    AfaLoggerFunc.tradeInfo('>>>生成批次委托号')

    try:
        sqlStr = "SELECT NEXTVAL FOR ABDT_ONLINE_SEQ FROM SYSIBM.SYSDUMMY1"

        records = AfaDBFunc.SelectSql( sqlStr )
        if records == None :
            TradeContext.errorCode, TradeContext.errorMsg='E8623', "生成委托号异常"
            raise AfaFlowControl.flowException( )

        #批次号
        TradeContext.BATCHNO = TradeContext.TranDate + str(records[0][0]).rjust(8, '0')

        return True

    except Exception, e:
        AfaFlowControl.exitMainFlow( str(e) )  
Example #16
0
def main( ):

    AfaLoggerFunc.tradeInfo('***农信银系统: 往账.本地类操作模板['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']进入***')
    try:
        #=====================初始化返回报文变量================================
        TradeContext.tradeResponse=[]

        #=====================获取系统日期时间==================================
        #TradeContext.BJEDTE=AfaUtilTools.GetHostDate( )
        TradeContext.BJETIM=AfaUtilTools.GetSysTime( )
        #TradeContext.BESBNO = '3400008889'

        #=====================系统公共校验======================================
        if not rccpsFunc.ChkPubInfo(PL_BRSFLG_SND) :
            raise AfaFlowControl.flowException( )

        #=====================系统状态校验======================================
        if not rccpsFunc.ChkSysInfo( 'AFA' ) :
            raise AfaFlowControl.flowException( )

        #=====================机构合法性校验====================================
        #if not rccpsFunc.ChkUnitInfo( ) :
        #    raise AfaFlowControl.flowException( )

        #=====================动态加载交易脚本==================================
        trxModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode
        try:
            trxModuleHandle=__import__( trxModuleName )

        except Exception, e:
            AfaLoggerFunc.tradeInfo(e)
            raise AfaFlowControl.flowException( 'A0001', '加载交易脚本失败或交易脚本不存在,执行交易失败' )

        #=====================个性化处理(本地操作)==============================
        AfaLoggerFunc.tradeInfo( 'TransCode:' + TradeContext.TransCode )
        if not trxModuleHandle.SubModuleDoFst( ) :
            raise AfaFlowControl.flowException( )

        #=====================自动打包==========================================
        AfaFunc.autoPackData()

        #=====================退出模板==========================================
        AfaLoggerFunc.tradeInfo('***农信银系统: 往账.本地类操作模板['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']退出***')
Example #17
0
def main( ):
    AfaLoggerFunc.tradeInfo('***农信银系统: ECHO操作模板['+TradeContext.TemplateCode+']进入***')
    try:
        #=====================初始化返回报文变量================================
        #TradeContext.tradeResponse=[]

        TradeContext.sysId = 'RCC01'
        TradeContext.TRCCO = '9900517'
 
        #=====================与中心通讯(回执)==================================
        AfaAfeFunc.CommAfe()

        #=====================退出模板==========================================
        AfaLoggerFunc.tradeInfo('***农信银系统: ECHO操作模板['+TradeContext.TemplateCode+']退出***')


    except AfaFlowControl.flowException, e:
        #流程异常
        AfaFlowControl.exitMainFlow( str(e) )
Example #18
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo('进入查询交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']与第三方通讯后处理' )
    try:
        names = Party3Context.getNames( )
        for name in names:
            value = getattr( Party3Context, name )
            if ( not name.startswith( '__' ) and type(value) is StringType) :
                setattr( TradeContext, name, value )
                #AfaLoggerFunc.tradeInfo("name:" + str(name) + "     value:" + str(value))
            
        if( TradeContext.errorCode == '0000' ):
            if not AfaYbtdb.AdbSelectQueDtl( ):                             #根据投保单号和日期查询YBT_INFO表,有记录更新,无记录插入
                raise AfaFlowControl.flowException()
        
        AfaLoggerFunc.tradeInfo('退出查询交易与第三方通讯后处理' )
        return True
        
    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( str(e) )
Example #19
0
def main( ):

    AfaLoggerFunc.tradeInfo('******代收代付.通用轧帐模板[' + TradeContext.TemplateCode + ']进入******' )

    try:

        #=====================初始化返回报文变量================================
        TradeContext.tradeResponse=[]

        #=====================获取当前系统时间==================================
        TradeContext.workDate=AfaUtilTools.GetSysDate( )
        TradeContext.workTime=AfaUtilTools.GetSysTime( )

        #=====================判断应用系统状态==================================
        #if not AfaFunc.ChkSysStatus( ) :
        #    raise AfaFlowControl.flowException( )
                
        #=====================校验公共节点的有效性==============================
        if( not TradeContext.existVariable( "statType" ) ):
            raise AfaFlowControl.flowException( 'A0001', '轧帐类型[statType]值不存在,不能进行轧帐' )

        if( not TradeContext.existVariable( "TransType" ) ):
            raise AfaFlowControl.flowException( 'A0001', '传输类型[TransType]值不存在,不能进行轧帐' )

        AfaLoggerFunc.tradeInfo( '>>>statType  = ' + TradeContext.statType )
        AfaLoggerFunc.tradeInfo( '>>>TransType = ' + TradeContext.TransType)

        #=====================轧帐操作==========================================
        if not StatAccountInfo( TradeContext.statType ) :
            raise AfaFlowControl.flowException( )

        #=====================自动打包==========================================
        TradeContext.tradeResponse.append( ['errorCode',     '0000'] )
        TradeContext.tradeResponse.append( ['errorMsg',      '交易成功'] )

        AfaFunc.autoPackData()

        #=====================退出模板==========================================
        AfaLoggerFunc.tradeInfo( '******代收代付.通用轧帐模板[' + TradeContext.TemplateCode + ']退出******' )

    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( str(e) )
Example #20
0
def main( ):

    AfaLoggerFunc.tradeInfo('********安徽省新农保.批量模板['+TradeContext.TemplateCode+']进入********')

    try:
    
        #=====================初始化返回报文变量================================
        TradeContext.tradeResponse=[]

       
        #=====================获取系统日期时间==================================
        TradeContext.WorkDate=AfaUtilTools.GetSysDate( )
        TradeContext.WorkTime=AfaUtilTools.GetSysTime( )
        
        #=====================判断应用系统状态==================================
        if not AfaFunc.ChkSysStatus( ) :
            raise AfaFlowControl.flowException( )


        #=====================动态加载交易脚本==================================
        trxModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode
        try:
            trxModuleHandle=__import__( trxModuleName )

        except Exception, e:
            AfaLoggerFunc.tradeInfo(e)
            raise AfaFlowControl.flowException( 'A0001', '加载交易脚本失败或交易脚本不存在' )


        #=====================安徽新农保业务个性化操作==========================
        if not trxModuleHandle.TrxMain( ) :
            raise AfaFlowControl.flowException( TradeContext.errorCode,TradeContext.errorMsg)


        #=====================自动打包==========================================
        AfaFunc.autoPackData()


        #=====================退出模板==========================================
        AfaLoggerFunc.tradeInfo('********安徽省新农保.批量模板['+TradeContext.TemplateCode+']退出********')
Example #21
0
def main( ):


    AfaLoggerFunc.tradeInfo('********abs.通用模板进入********')


    try:
    
        #=====================初始化返回报文变量================================
        TradeContext.tradeResponse=[]

       
        #=====================获取系统日期时间==================================
        TradeContext.TranDate=AfaUtilTools.GetSysDate( )
        TradeContext.TranTime=AfaUtilTools.GetSysTime( )


        #=====================动态加载交易脚本==================================
        trxModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode
        try:
            trxModuleHandle=__import__( trxModuleName )


        except Exception, e:
            AfaLoggerFunc.tradeInfo(e)
            raise AfaFlowControl.flowException( 'A0001', '加载交易脚本失败或交易脚本不存在' )


        #=====================批量业务个性化操作================================
        if not trxModuleHandle.TrxMain( ) :
            raise AfaFlowControl.accException( )


        #=====================自动打包==========================================
        AfaFunc.autoPackData()


        #=====================退出模板==========================================
        AfaLoggerFunc.tradeInfo('********批量业务.通用模板['+TradeContext.TemplateCode+']退出********')
Example #22
0
def main( ):

    AfaLoggerFunc.tradeInfo('******柜面对账['+TradeContext.TemplateCode+']进入******')

    try:

        #=====================初始化返回报文变量================================
        TradeContext.tradeResponse=[]
        
        #=====================获取当前系统时间==================================
        TradeContext.workDate=AfaUtilTools.GetSysDate( )
        TradeContext.workTime=AfaUtilTools.GetSysTime( )
        #=====================柜面对账处理======================================
        admin()
        #=============自动打包====================
        AfaFunc.autoPackData()

        #=====================退出模板==========================================
        AfaLoggerFunc.tradeInfo('******柜面对账['+TradeContext.TemplateCode+']退出******')

    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( str(e) )
Example #23
0
def SubModuleDoFst( ):

    AfaLoggerFunc.tradeInfo( '初始化处罚决定书查询交易变量' )
    
    #交易代码(8625)
    TradeContext.tradeCode = TradeContext.TransCode
    
    #处罚决定书编号
    if not( TradeContext.existVariable( "punishNo" ) and len(TradeContext.punishNo.strip()) > 0):
        TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "处罚决定书编号不存在"
        raise AfaFlowControl.flowException( ) 
   
    return True
Example #24
0
def SubModuleDoSnd( ):
    AfaLoggerFunc.tradeInfo('进入缴费反交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']与第三方通讯后处理' )
    try:
        
        Party3Context.preAgentSerno = TradeContext.preAgentSerno
        Party3Context.Amount        = TradeContext.amount        
        Party3Context.workDate      = TradeContext.workDate      

        names = Party3Context.getNames( )
        for name in names:
            value = getattr( Party3Context, name )
            setattr( TradeContext, name, value )
            #AfaLoggerFunc.tradeInfo("字段名称  ["+str(name)+"] =  "+str(value))

        if( TradeContext.errorCode != '0000' ):
            AfaLoggerFunc.tradeInfo("太保返回错误代码 ["+TradeContext.errorCode+"]")
            AfaLoggerFunc.tradeInfo("太保返回错误信息 ["+TradeContext.errorMsg+"]")
            #第三方交易失败后记录错误码和错误信息
            if not AfaAhAdb.ADBUpdateTransdtlRev( ):
                raise AfaFlowControl.accException()
        return True
    except Exception, e:
        AfaFlowControl.exitMainFlow(str(e))
Example #25
0
def SubModuleDoSnd( ):
    AfaLoggerFunc.tradeInfo('进入缴费反交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']与第三方通讯后处理' )
    
    try:
        names = Party3Context.getNames( )
        
        for name in names:
            value = getattr( Party3Context, name )
            if ( not name.startswith( '__' ) and type(value) is StringType) :
                setattr( TradeContext, name, value )
           
        if( TradeContext.errorCode != '0000' ):
            
            AfaLoggerFunc.tradeInfo("银保通返回错误代码 ["+TradeContext.errorCode+"]")
            AfaLoggerFunc.tradeInfo("银保通返回错误信息 ["+TradeContext.errorMsg+"]")
            
            #第三方交易失败后记录错误码和错误信息
            if not AfaYbtdb.ADBUpdateTransdtlRev( ):
                raise AfaFlowControl.accException()
       
        return True
    
    except Exception, e:
        AfaFlowControl.exitMainFlow(str(e))
Example #26
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(1.本地操作).个人现金通存[TRCC002_8561]进入***' )
    #=================必要性检查===============================================
    AfaLoggerFunc.tradeInfo(">>>开始必要性检查")
    
    #检查本机构是否有通存通兑业务权限
    if not rccpsDBFunc.chkTDBESAuth(TradeContext.BESBNO):
        return AfaFlowControl.ExitThisFlow("S999","本机构无通存通兑业务权限")
    
    #磁道信息
    if TradeContext.PYETYP == '0':
        if TradeContext.SCTRKINF == '':
            return AfaFlowControl.ExitThisFlow("磁道信息不能为空")
        
        #if TradeContext.THTRKINF == '':
        #    return AfaFlowControl.ExitThisFlow("磁道信息不能为空")
            
        if len(TradeContext.SCTRKINF) > 37:
            return AfaFlowControl.ExitThisFlow('S999','磁道信息非法')
            
        #if len(TradeContext.THTRKINF) > 104:
        #    return AfaFlowControl.ExitThisFlow('S999','磁道信息非法')
    elif TradeContext.PYETYP == '2':
        TradeContext.SCTRKINF = ''.rjust(37,'0')
        TradeContext.THTRKINF = ''.rjust(37,'0')
        
    #存折号码
    if TradeContext.PYETYP == '1':
        if TradeContext.BNKBKNO == '':
            return AfaFlowControl.ExitThisFlow('存折号码不能为空')
    elif TradeContext.PYETYP == '3':
        TradeContext.BNKBKNO = ''
    
    AfaLoggerFunc.tradeInfo(">>>结束必要性检查")
    
    #=================登记通存通兑业务登记簿===================================
    AfaLoggerFunc.tradeInfo(">>>开始登记通存通兑业务登记簿")
    
    TradeContext.SNDMBRCO = TradeContext.SNDSTLBIN      #发送成员行号
    TradeContext.RCVMBRCO = TradeContext.RCVSTLBIN      #接收成员行号
    TradeContext.TRCNO    = TradeContext.SerialNo       #交易流水号
    TradeContext.NCCWKDAT = TradeContext.NCCworkDate    #中心工作日期
    TradeContext.MSGFLGNO = TradeContext.SNDMBRCO + TradeContext.TRCDAT + TradeContext.TRCNO  #报文标识号
    TradeContext.OPRNO    = PL_TDOPRNO_TC               #业务种类:个人现金通存
    TradeContext.DCFLG    = PL_DCFLG_CRE                #借贷标识:贷记
    TradeContext.BRSFLG   = PL_BRSFLG_SND               #往来标识:往账
    #if TradeContext.PYITYP == '0' or '2':
    #    TradeContext.TRCCO = '3000002'                  #交易代码:3000002卡现金通存
    #elif TradeContext.PYITYP == '1' or '3':
    #    TradeContext.TRCCO = '3000004'                  #交易代码:3000004折现金通存
    #else:
    #    return AfaFlowContorl.ExitThisFlow("S999","收款人账户类型非法")
    TradeContext.PYRMBRCO = TradeContext.SNDSTLBIN
    TradeContext.PYEMBRCO = TradeContext.RCVSTLBIN
    
    wtrbka_dict = {}
    if not rccpsMap8563CTradeContext2Dwtrbka_dict.map(wtrbka_dict):
        return AfaFlowContorl.ExitThisFlow("S999","为通存通兑业务登记簿赋值异常")
        
    if not rccpsDBFunc.insTransWtr(wtrbka_dict):
        return AfaFlowControl.ExitThisFlow('S999','登记通存通兑业务登记簿异常')
    
    AfaLoggerFunc.tradeInfo(">>>结束登记通存通兑业务登记簿")
    
    #=================设置业务状态为记账处理中=================================
    AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为记账处理中")
    
    stat_dict = {}
    stat_dict['BJEDTE'] = TradeContext.BJEDTE       #交易日期
    stat_dict['BSPSQN'] = TradeContext.BSPSQN       #报单序号
    stat_dict['BCSTAT'] = PL_BCSTAT_ACC             #PL_BCSTAT_ACC 记账
    stat_dict['BDWFLG'] = PL_BDWFLG_WAIT            #PL_BDWFLG_WAIT 处理中
    
    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异常")
    
    AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为记账处理中")
    
    #=================为主机记账做准备=========================================
    AfaLoggerFunc.tradeInfo(">>>开始为主机记账做准备")
    
    TradeContext.HostCode = '8813' 
       
    TradeContext.PKFG = 'T'                                         #通存通兑标识
    TradeContext.CATR = '0'                                         #现转标识:0-现金
    TradeContext.RCCSMCD  = PL_RCCSMCD_XJTCWZ                         #主机摘要码:现金通存往账
    TradeContext.SBAC = ''
    TradeContext.ACNM = ''
    TradeContext.RBAC = TradeContext.BESBNO + PL_ACC_NXYDQSWZ       #贷方账号
    TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25)
    TradeContext.OTNM = "农信银待清算往账"
    TradeContext.CTFG = '7'                                         #结转标识:结转-0
    
    AfaLoggerFunc.tradeInfo("借方账号1:[" + TradeContext.SBAC + "]")
    AfaLoggerFunc.tradeInfo("贷方账号1:[" + TradeContext.RBAC + "]")
    
    if TradeContext.CHRGTYP == '0':
        #现金收取手续费
        TradeContext.ACUR = '2'                                         #重复次数 
        
        TradeContext.I2PKFG = 'T'                                       #通存通兑标识
        TradeContext.I2CATR = '0'                                       #现转标识:0-现金
        TradeContext.I2TRAM = TradeContext.CUSCHRG                      #手续费金额
        TradeContext.I2SMCD = PL_RCCSMCD_SXF                            #主机摘要码:手续费
        TradeContext.I2SBAC = ''
        TradeContext.I2ACNM = ''
        TradeContext.I2RBAC = TradeContext.BESBNO + PL_ACC_TCTDSXF      #贷方账号:通存通兑手续费
        TradeContext.I2RBAC = rccpsHostFunc.CrtAcc(TradeContext.I2RBAC,25)
        TradeContext.I2OTNM = "农信银手续费"
        TradeContext.I2CTFG = '8'                                       #结转标识:不结转-1
    elif TradeContext.CHRGTYP == '1':
        #现金通存无法收取本行账户手续费
        return AfaFlowControl.ExitThisFlow("S999","现金通存无法转账收取手续费")
    elif TradeContext.CHRGTYP == '2':
        AfaLoggerFunc.tradeInfo(">>>不收手续费")
    else:
        return AfaFlowControl.ExitThisFlow("S999","非法手续费收取方式")
        
    if TradeContext.existVariable("I2SBAC") and TradeContext.existVariable('I2RBAC'):
        AfaLoggerFunc.tradeInfo("借方账号2:[" + TradeContext.I2SBAC + "]")
        AfaLoggerFunc.tradeInfo("贷方账号2:[" + TradeContext.I2RBAC + "]")
    
    AfaLoggerFunc.tradeInfo(">>>结束为主机记账做准备")
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(1.本地操作).个人现金通存[TRCC002_8561]退出***' )
    
    return True
Example #27
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(2.主机记账).个人现金通存[TRCC002_8561]进入***' )
    
    #=================设置业务状态为记账成功或失败=============================
    
    stat_dict = {}
    stat_dict['BJEDTE']  = TradeContext.BJEDTE
    stat_dict['BSPSQN']  = TradeContext.BSPSQN
    stat_dict['BESBNO']  = TradeContext.BESBNO
    stat_dict['BETELR']  = TradeContext.BETELR
    stat_dict['SBAC']    = TradeContext.SBAC
    stat_dict['ACNM']    = TradeContext.ACNM
    stat_dict['RBAC']    = TradeContext.RBAC
    stat_dict['OTNM']    = TradeContext.OTNM
    if TradeContext.existVariable('TRDT'):
        stat_dict['TRDT'] = TradeContext.TRDT
    if TradeContext.existVariable('TLSQ'):
        stat_dict['TLSQ'] = TradeContext.TLSQ
    stat_dict['MGID']    = TradeContext.errorCode
    stat_dict['STRINFO'] = TradeContext.errorMsg
    
    if TradeContext.errorCode == '0000':
        AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为记账成功")
        
        stat_dict['BCSTAT']  = PL_BCSTAT_ACC
        stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
        stat_dict['PRTCNT']  = 1
        
        if not rccpsState.setTransState(stat_dict):
            return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为记账成功异常")
        
        AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为记账成功")
        
    else:
        AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为记账失败")
        
        stat_dict['BCSTAT']  = PL_BCSTAT_ACC
        stat_dict['BDWFLG']  = PL_BDWFLG_FAIL
        
        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异常")
    
    if TradeContext.errorCode != '0000':
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode,TradeContext.errorMsg)
    
    #=================为发送农信银中心做准备===================================
    AfaLoggerFunc.tradeInfo(">>>开始为发送农信银中心做准备")
    
    TradeContext.MSGTYPCO = 'SET003'
    TradeContext.SNDBRHCO = TradeContext.BESBNO
    TradeContext.SNDCLKNO = TradeContext.BETELR
    TradeContext.SNDTRDAT = TradeContext.BJEDTE
    TradeContext.SNDTRTIM = TradeContext.BJETIM
    TradeContext.MSGFLGNO = TradeContext.SNDMBRCO + TradeContext.BJEDTE + TradeContext.TRCNO
    TradeContext.ORMFN    = ''
    TradeContext.OPRTYPNO = '30'
    TradeContext.ROPRTPNO = ''
    TradeContext.TRANTYP  = '0'
    
    TradeContext.CUR = 'CNY'
    TradeContext.LOCCUSCHRG = TradeContext.CUSCHRG
    TradeContext.CUSCHRG = '0.00'
    
    
    AfaLoggerFunc.tradeInfo(">>>结束为发送农信银中心做准备")
    
    
    #=================设置业务状态为发送处理中=================================
    AfaLoggerFunc.tradeInfo(">>>开始设置状态为发送处理中")
    
    if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_SND,PL_BDWFLG_WAIT):
        return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为发送处理中异常")
    
    AfaLoggerFunc.tradeInfo(">>>结束设置状态为发送处理中")
    
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow("S999","Commit异常")
        
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(2.主机记账).个人现金通存[TRCC002_8561]退出***' )
    return True
Example #28
0
def SubModuleDoSnd():
    #=================判断afe是否发送成功=======================================
    if TradeContext.errorCode != '0000':
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    
    AfaLoggerFunc.tradeInfo('发送成功')
    
    #=====查询机构名====
    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','没有相应的机构名' )
    
    #=================生成打印文本=============================================
    AfaLoggerFunc.tradeInfo("开始生成打印文本")
    
    txt = """\
            
            
                               %(BESBNM)s全国特约电子汇兑查询书
                               
        |-----------------------------------------------------------------------------|
        | 查询日期:             |      %(BJEDTE)s                                       |
        |-----------------------------------------------------------------------------|
        | 特约汇兑查询书号:     |      %(BSPSQN)s                                   |
        |-----------------------------------------------------------------------------|
        | 发起行行号:           |      %(SNDBNKCO)s                                     |
        |-----------------------------------------------------------------------------|
        | 接收行行号:           |      %(RCVBNKCO)s                                     |
        |-----------------------------------------------------------------------------|
        | 原金额:               |      %(OROCCAMT)-15.2f                                |
        |-----------------------------------------------------------------------------|
        | 原委托日期:           |      %(ORTRCDAT)s                                       |
        |-----------------------------------------------------------------------------|
        | 原发起行行号:         |      %(ORSNDBNKCO)s                                     |
        |-----------------------------------------------------------------------------|
        | 查询内容:             |                                                     |
        |-----------------------------------------------------------------------------|
        |                                                                             |
        |     %(CONT1)s    |
        |                                                                             |
        |   %(CONT2)s    |
        |                                                                             |
        |   %(CONT3)s    |
        |                                                                             |
        |   %(CONT4)s    |
        |                                                                             |
        |-----------------------------------------------------------------------------|
        打印日期: %(BJEDTE)s      授权:                       记账:
    """
    
    file_name = 'rccps_' + TradeContext.BJEDTE + '_' + TradeContext.BSPSQN + '_8518'
    
    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':(TradeContext.BJEDTE).ljust(8,' '),\
                             'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\
                             'SNDBNKCO':(TradeContext.SNDBNKCO).ljust(10,' '),\
                             'RCVBNKCO':(TradeContext.RCVBNKCO).ljust(10,' '),\
                             'OROCCAMT':(TradeContext.OR_OCCAMT),\
                             'ORTRCDAT':(TradeContext.OR_TRCDAT).ljust(8,' '),\
                             'ORSNDBNKCO':(TradeContext.OR_SNDBNKCO).ljust(10,' '),\
                             'CONT1':(TradeContext.CONT[:68]).ljust(68,' '),\
                             'CONT2':(TradeContext.CONT[68:138]).ljust(70,' '),\
                             'CONT3':(TradeContext.CONT[138:208]).ljust(70,' '),\
                             'CONT4':(TradeContext.CONT[208:]).ljust(70,' ')}
    
    out_file.close
    
    TradeContext.PBDAFILE = file_name
    
    AfaLoggerFunc.tradeInfo("结束生成打印文本")
    
    return True
Example #29
0
def SubModuleDoFst():
    #==========判断是否重复报文,如果是重复报文,直接进入下一流程================
    AfaLoggerFunc.tradeInfo(">>>开始检查是否重复报文")
    cshalm_where_dict = {}
    cshalm_where_dict['SNDBNKCO'] = TradeContext.SNDBNKCO
    cshalm_where_dict['TRCDAT']   = TradeContext.TRCDAT
    cshalm_where_dict['TRCNO']    = TradeContext.TRCNO

    cshalm_dict = rccpsDBTrcc_cshalm.selectu(cshalm_where_dict)

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

    if len(cshalm_dict) > 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['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(">>>结束检查是否重复报文")

    #=====向字典赋值====
    cshalm = {}
    cshalm['BJEDTE']   =  TradeContext.BJEDTE       #交易日期
    cshalm['BSPSQN']   =  TradeContext.BSPSQN       #报单序号
    #cshalm['NCCWKDAT'] =  TradeContext.NCCworkDate  #中心日期
    #关彬捷 20080924 中心日期赋值报文中的中心日期
    cshalm['NCCWKDAT'] =  TradeContext.NCCWKDAT     #中心日期
    cshalm['TRCCO']    =  TradeContext.TRCCO        #交易代码
    cshalm['TRCDAT']   =  TradeContext.TRCDAT       #委托日期
    cshalm['TRCNO']    =  TradeContext.TRCNO        #交易流水号
    cshalm['SNDBNKCO'] =  TradeContext.SNDBNKCO     #发送行号
    cshalm['RCVBNKCO'] =  TradeContext.RCVBNKCO     #接收行号
    #=====币种转换====
    if TradeContext.CUR == 'CNY':
        cshalm['CUR']  =  '01'                      #币种
    cshalm['POSITION'] =  TradeContext.POSITION     #头寸当前金额
    cshalm['POSALAMT'] =  TradeContext.POSALAMT     #头寸预警金额

    #=====登记头寸预警登记簿====
    AfaLoggerFunc.tradeInfo('>>>开始登记头寸预警登记簿')
    AfaLoggerFunc.tradeInfo('>>>字典:' + str(cshalm))
    ret = rccpsDBTrcc_cshalm.insertCmt(cshalm)
    if ret <= 0:
        #=====发送回执字典赋值====
        TradeContext.PRCCO    = 'RCCS1105'
        TradeContext.STRINFO  = '其它错误'
    else:
        TradeContext.PRCCO    = 'RCCI0000'
        TradeContext.STRINFO  = '成功'
 
    #=====发送通存回执====
    TradeContext.sysType  = 'rccpst'
    TradeContext.ORTRCCO  = TradeContext.TRCCO
    TradeContext.TRCCO    = '9900503'
    TradeContext.MSGTYPCO = 'SET008'
    TradeContext.SNDBRHCO = TradeContext.BESBNO
    TradeContext.SNDCLKNO = TradeContext.BETELR
    TradeContext.SNDTRDAT = TradeContext.BJEDTE
    TradeContext.SNDTRTIM = TradeContext.BJETIM
    TradeContext.ORMFN    = TradeContext.MSGFLGNO
    TradeContext.NCCWKDAT = TradeContext.NCCworkDate
    TradeContext.ROPRTPNO = TradeContext.OPRTYPNO
    TradeContext.OPRTYPNO = '99'
    TradeContext.TRANTYP  = '0'

    #=====通过接收行号取行名和成员行号====
    rccpsGetFunc.GetRcvBnkCo(TradeContext.RCVBNKCO)
    
    #=====通过发送行号取行名和成员行号====
    rccpsGetFunc.GetSndBnkCo(TradeContext.SNDBNKCO)

    TradeContext.tmp      = TradeContext.SNDSTLBIN
    TradeContext.SNDSTLBIN= TradeContext.RCVSTLBIN
    TradeContext.RCVSTLBIN= TradeContext.tmp

    return True
Example #30
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.中心类操作(1.本地操作).特约电子汇兑查询书发送[TRC003_8518]进入***' )
    
    #=================查询原交易信息============================================
    
    if not TradeContext.existVariable('BOJEDT'):
        return AfaFlowControl.ExitThisFlow("S999", "原交易日期不能为空")
    
    if not TradeContext.existVariable('BOSPSQ'):
        return AfaFlowControl.ExitThisFlow("S999", "原报单序号不能为空")

    AfaLoggerFunc.tradeInfo(">>>开始查询原特约电子汇兑业务交易信息")
    
    trcbka_dict = {}
    ret = rccpsDBFunc.getTransTrc(TradeContext.BOJEDT,TradeContext.BOSPSQ,trcbka_dict)
    
    if not ret:
        return False

    #====刘雨龙 20080701 增加是否来账业务判断====
    if trcbka_dict['BRSFLG'] != PL_BRSFLG_RCV:
        return AfaFlowControl.ExitThisFlow('S999','原交易非来账业务不允许做此业务')
    
    #====刘雨龙 20080701 增加是否特约汇兑业务判断====
    if trcbka_dict['TRCCO'] != '2000009':
        return AfaFlowControl.ExitThisFlow('S999','原交易非特约汇兑业务不允许做此交易')

    AfaLoggerFunc.tradeInfo(">>>开始查询原特约电子汇兑业务交易信息")
    #=================登记查询书信息============================================
    AfaLoggerFunc.tradeInfo(">>>开始登记特约电子汇兑业务查询书信息")
    
    TradeContext.RCVBNKCO = trcbka_dict['SNDBNKCO']
    TradeContext.RCVBNKNM = trcbka_dict['SNDBNKNM']
    TradeContext.NCCWKDAT = TradeContext.NCCworkDate
    TradeContext.ISDEAL   = PL_ISDEAL_UNDO            #查复标识为未查复

    #=====刘雨龙 20080701 增加汇兑业务查询查复登记簿信息====
    TradeContext.RCVSTLBIN= '9999999997'              #特约业务接收行特殊
    TradeContext.BRSFLG   = PL_BRSFLG_SND             #往来标志
    TradeContext.ORTRCCO  = trcbka_dict['TRCCO']      #原交易代码
    TradeContext.CUR      = trcbka_dict['CUR']        #币种
    TradeContext.OCCAMT   = trcbka_dict['OCCAMT']     #交易金额
    TradeContext.PYRACC   = trcbka_dict['PYRACC']     #付款人账号
    TradeContext.PYEACC   = trcbka_dict['PYEACC']     #收款人账号
    TradeContext.PRCCO    = trcbka_dict['PRCCO']      #中心返回码
    TradeContext.NOTE1    = trcbka_dict['NOTE1']      #备注1
    TradeContext.NOTE2    = trcbka_dict['NOTE2']      #备注2
    TradeContext.NOTE3    = trcbka_dict['NOTE3']      #备注3
    TradeContext.NOTE4    = trcbka_dict['NOTE4']      #备注4
    
    #=====PGT 20080728 打印表格中的字段====
    TradeContext.OR_TRCDAT   = trcbka_dict['TRCDAT']    
    TradeContext.OR_SNDBNKCO = trcbka_dict['SNDBNKCO']
    TradeContext.OR_OCCAMT  = trcbka_dict['OCCAMT']
    
    hdcbka_insert_dict = {}
    if not rccpsMap8518CTradeContext2Dhdcbka.map(hdcbka_insert_dict):
        return AfaFlowControl.ExitThisFlow("S999", "为特约电子汇兑业务查询查复登记簿赋值异常")
        
    ret = rccpsDBTrcc_hdcbka.insertCmt(hdcbka_insert_dict)
    
    if ret <= 0:
        return AfaFlowControl.ExitThisFlow("S999", "登记特约电子汇兑业务查询书信息异常")
    
    AfaLoggerFunc.tradeInfo(">>>结束登记特约电子汇兑业务查询书信息")
    
    
    #=================为特约电子汇兑查询书报文赋值======================================
    AfaLoggerFunc.tradeInfo(">>>开始为特约电子汇兑查询书报文赋值")
    
    TradeContext.MSGTYPCO   = 'SET008'
    TradeContext.SNDBRHCO   = TradeContext.BESBNO
    TradeContext.SNDCLKNO   = TradeContext.BETELR
    TradeContext.SNDTRDAT   = TradeContext.BJEDTE
    TradeContext.SNDTRTIM   = TradeContext.BJETIM
    TradeContext.MSGFLGNO   = TradeContext.SNDSTLBIN + TradeContext.TRCDAT + TradeContext.SerialNo
    TradeContext.ORMFN      = trcbka_dict['SNDMBRCO'] + trcbka_dict['TRCDAT'] + trcbka_dict['TRCNO']
    TradeContext.NCCWKDAT   = TradeContext.NCCworkDate
    TradeContext.OPRTYPNO   = '99'
    TradeContext.ROPRTPNO   = '20'
    TradeContext.TRANTYP    = '0'
    TradeContext.TRCDAT     = TradeContext.TRCDAT
    TradeContext.TRCNO      = TradeContext.SerialNo
    TradeContext.ORTRCDAT   = trcbka_dict['TRCDAT']
    TradeContext.ORTRCNO    = trcbka_dict['TRCNO']
    TradeContext.ORSNDBNK   = trcbka_dict['SNDBNKCO']
    TradeContext.ORTRCCO    = trcbka_dict['TRCCO']
    TradeContext.ORCUR      = trcbka_dict['CUR']
    TradeContext.OROCCAMT   = str(trcbka_dict['OCCAMT'])
    TradeContext.PYENAM     = trcbka_dict['PYENAM']
    TradeContext.PYRNAM     = trcbka_dict['PYRNAM']
       
    AfaLoggerFunc.tradeInfo(">>>结束为特约电子汇兑查询书报文赋值")
    
    return True
Example #31
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.回执类操作(1.回执操作).通存通兑冲正应答报文接收[TRC004_1161]进入***' )
    
    #=================初始化返回信息============================================
    if AfaUtilTools.trim(TradeContext.STRINFO) == "":
        TradeContext.STRINFO = rccpsDBFunc.getErrInfo(TradeContext.PRCCO)
        
    AfaLoggerFunc.tradeDebug("TradeContext.STRINFO=" + TradeContext.STRINFO)
    
    #=================初始化返回信息============================================
    if AfaUtilTools.trim(TradeContext.STRINFO) == "":
        TradeContext.STRINFO = rccpsDBFunc.getErrInfo(TradeContext.PRCCO)
        
    AfaLoggerFunc.tradeDebug("TradeContext.STRINFO=" + TradeContext.STRINFO)
    
    #查询原冲正交易信息
    atcbka_dict = {}
    
    atcbka_where_dict = {}
    atcbka_where_dict['MSGFLGNO'] = TradeContext.ORMFN
    
    atcbka_dict = rccpsDBTrcc_atcbka.selectu(atcbka_where_dict)
    
    if atcbka_dict == None:
        return AfaFlowControl.ExitThisFlow("S999","查询原冲正交易信息异常")
        
    if len(atcbka_dict) <= 0:
        return AfaFlowControl.ExitThisFlow("S999","未找到原冲正交易信息,丢弃报文")
        
    #查询原被冲正交易是否已开始被冲销
    mpcbka_dict = {}
    
    mpcbka_where_dict = {}
    mpcbka_where_dict['ORMFN'] = atcbka_dict['ORMFN']
    
    mpcbka_dict = rccpsDBTrcc_mpcbka.selectu(mpcbka_where_dict)
    
    if mpcbka_dict == None:
        return AfaFlowControl.ExitThisFlow("S999","查询原冲正交易信息异常")
        
    if len(mpcbka_dict) > 0:
        return AfaFlowControl.ExitThisFlow("S999","原交易已开始冲销,停止处理本冲正应答")
        
    #=====给机构号和柜员号赋值====
    TradeContext.BETELR = atcbka_dict['BETELR']
    TradeContext.BESBNO = atcbka_dict['BESBNO']
    
    #更新冲正登记簿中心返回信息
    AfaLoggerFunc.tradeInfo(">>>开始更新冲正登记簿中心返回信息")
    
    atcbka_update_dict = {}
    atcbka_update_dict['PRCCO'] = TradeContext.PRCCO
    atcbka_update_dict['STRINFO'] = TradeContext.STRINFO
    
    ret = rccpsDBTrcc_atcbka.update(atcbka_update_dict,atcbka_where_dict)
    
    if ret <= 0:
        return AfaFlowControl.ExitThisFlow("S999","更新冲正登记簿异常")
    
    AfaLoggerFunc.tradeInfo(">>>结束更新冲正登记簿中心返回信息")
    
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow("S999","Commit异常")
    
    if atcbka_dict['ORTRCCO'] != '3000504':
        AfaLoggerFunc.tradeInfo(">>>原被冲正交易为通存或通兑账务类交易")
        
        #查询原被冲正交易信息
        wtr_dict = {}
        
        if not rccpsDBFunc.getTransWtr(atcbka_dict['BOJEDT'],atcbka_dict['BOSPSQ'],wtr_dict):
            return AfaFlowControl.ExitThisFlow("S999","查询原被冲正交易信息异常")
        
        #如果原被冲正交易当前状态已为冲正,表示已收到冲正应答,停止处理
        if wtr_dict['BCSTAT'] == PL_BCSTAT_CANCEL:
            return AfaFlowControl.ExitThisFlow("S999","已收到冲正应答,丢弃报文")
        
        TradeContext.TERMID = wtr_dict['TERMID']
        TradeContext.BRSFLG = wtr_dict['BRSFLG']
        
        
        
        #若原被冲正交易为通存类交易,应抹账
        if wtr_dict['TRCCO'] in ('3000002','3000003','3000004','3000005'):
            
            AfaLoggerFunc.tradeInfo(">>>开始发起主机抹账")
            
            #为抹账赋值会计分录
            entries_dict = {}
            entries_dict['FEDT']     = wtr_dict['BJEDTE']
            entries_dict['RBSQ']     = wtr_dict['BSPSQN']
            entries_dict['PYRACC']   = wtr_dict['PYRACC']
            entries_dict['PYRNAM']   = wtr_dict['PYRNAM']
            entries_dict['PYEACC']   = wtr_dict['PYEACC']
            entries_dict['PYENAM']   = wtr_dict['PYENAM']
            entries_dict['OCCAMT']   = wtr_dict['OCCAMT']
            entries_dict['CHRGTYP']  = wtr_dict['CHRGTYP']
            entries_dict['CUSCHRG']  = wtr_dict['CUSCHRG']
            entries_dict['RCCSMCD']  = PL_RCCSMCD_CX
            TradeContext.BRSFLG      = wtr_dict['BRSFLG']
            
            if TradeContext.ORTRCCO == '3000002' or TradeContext.ORTRCCO == '3000004':
                rccpsEntries.KZTCWZMZ(entries_dict)
            
            if TradeContext.ORTRCCO == '3000003' or TradeContext.ORTRCCO == '3000005':
                rccpsEntries.KZBZYWZMZ(entries_dict)
                
            #=====生成新的前置日期和前置流水号====
            if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 :
                return AfaFlowControl.ExisThisFlow('S999',"产生新的前置流水号异常")
            
            #设置原交易状态为冲正处理中
            AfaLoggerFunc.tradeInfo('>>>开始设置原交易状态为冲正处理中')
                
            if not rccpsState.newTransState(wtr_dict['BJEDTE'],wtr_dict['BSPSQN'],PL_BCSTAT_CANCEL,PL_BDWFLG_WAIT):
                return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为冲正处理中异常")
            
            if not AfaDBFunc.CommitSql( ):
                AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
                return AfaFlowControl.ExitThisFlow("S999","Commit异常")
            
            AfaLoggerFunc.tradeInfo('>>>结束设置原交易状态为冲正处理中')
            
            #=====调起主机接口=====
            rccpsHostFunc.CommHost( TradeContext.HostCode )
            
            AfaLoggerFunc.tradeInfo(">>>结束发起主机记账")
            
        else:
            AfaLoggerFunc.tradeInfo(">>>原交易未记账,冲正不抹账")
            
            #设置原交易状态为冲正处理中
            AfaLoggerFunc.tradeInfo('>>>开始设置原交易状态为冲正处理中')
                
            if not rccpsState.newTransState(wtr_dict['BJEDTE'],wtr_dict['BSPSQN'],PL_BCSTAT_CANCEL,PL_BDWFLG_WAIT):
                return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为冲正处理中异常")
            
            if not AfaDBFunc.CommitSql( ):
                AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
                return AfaFlowControl.ExitThisFlow("S999","Commit异常")
            
            AfaLoggerFunc.tradeInfo('>>>结束设置原交易状态为冲正处理中')
            
            TradeContext.errorCode = "0000"
            TradeContext.errorMsg  = "冲正前未记账,冲正不抹账"
           
        #根据主机返回信息,设置交易状态 
        stat_dict = {}
        
        stat_dict['BJEDTE']  = wtr_dict['BJEDTE']
        stat_dict['BSPSQN']  = wtr_dict['BSPSQN']
        stat_dict['MGID']    = TradeContext.errorCode
        stat_dict['STRINFO'] = TradeContext.errorMsg
        
        AfaLoggerFunc.tradeInfo("TradeContext.errorCode = [" + TradeContext.errorCode + "]")
        if TradeContext.errorCode == '0000':
            #设置原交易状态为冲正成功
            AfaLoggerFunc.tradeInfo("<<<<<<<开始更改原交易状态为冲正成功")
            
            stat_dict['BCSTAT'] = PL_BCSTAT_CANCEL
            stat_dict['BDWFLG'] = PL_BDWFLG_SUCC
            if TradeContext.existVariable('TRDT'):
                stat_dict['TRDT']   = TradeContext.TRDT
            if TradeContext.existVariable('TLSQ'):
                stat_dict['TLSQ']   = TradeContext.TLSQ
            
            if not rccpsState.setTransState(stat_dict):
                return AfaFlowControl.ExitThisFlow('S999','设置业务状态为冲正成功异常')
            
            AfaLoggerFunc.tradeInfo("<<<<<<<结束更改原交易状态为冲正成功")
        else:
            #设置原交易状态为冲正失败
            AfaLoggerFunc.tradeInfo("<<<<<<<开始更改原交易状态为冲正失败")
            
            stat_dict['BCSTAT'] = PL_BCSTAT_CANCEL
            stat_dict['BDWFLG'] = PL_BDWFLG_FAIL
            
            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异常")
            
    else:
        AfaLoggerFunc.tradeInfo(">>>原被冲正交易为冲销交易")
        
        #查询原冲销交易详细信息
        AfaLoggerFunc.tradeInfo(">>>冲销交易报单日期[" + atcbka_dict['BOJEDT'] + "]报单序号[" + atcbka_dict['BOSPSQ'] + "]")
        
        AfaLoggerFunc.tradeInfo(">>>开始查询原冲销交易详细信息")
        
        mpc_dict = {}
        
        if not rccpsDBFunc.getTransMpc(atcbka_dict['BOJEDT'],atcbka_dict['BOSPSQ'],mpc_dict):
            return AfaFlowControl.ExitThisFlow("S999","查询原冲销交易详细信息异常")
            
        AfaLoggerFunc.tradeInfo(">>>结束查询原冲销交易详细信息")
        
        #查询原被冲销交易详细信息
        AfaLoggerFunc.tradeInfo(">>>被冲销交易报单日期[" + mpc_dict['BOJEDT'] + "]报单序号[" + mpc_dict['BOSPSQ'] + "]")
        
        AfaLoggerFunc.tradeInfo(">>>开始查询原被冲销交易详细信息")
        
        wtr_dict = {}
        
        if not rccpsDBFunc.getTransWtr(mpc_dict['BOJEDT'],mpc_dict['BOSPSQ'],wtr_dict):
            return AfaFlowControl.ExitThisFlow("S999","查询原被冲销交易详细信息异常")
            
        AfaLoggerFunc.tradeInfo(">>>结束查询原被冲销交易详细信息")
        
        #更新冲销登记簿
        AfaLoggerFunc.tradeInfo(">>>开始更新冲销登记簿")
        
        mpcbka_update_dict = {}
        mpcbka_update_dict['PRCCO'] = "RCCI1000"
        mpcbka_update_dict['STRINFO'] = "冲销交易被成功冲正"
        
        mpcbka_where_dict = {}
        mpcbka_where_dict['BJEDTE'] = mpc_dict['BJEDTE']
        mpcbka_where_dict['BSPSQN'] = mpc_dict['BSPSQN']
        
        ret = rccpsDBTrcc_mpcbka.update(mpcbka_update_dict,mpcbka_where_dict)
        
        if ret <= 0:
            return AfaFlowControl.ExitThisFlow("更新冲销登记簿返回码和返回信息异常")
        
        AfaLoggerFunc.tradeInfo(">>>结束更新冲销登记簿")
        
        if not AfaDBFunc.CommitSql( ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return AfaFlowControl.ExitThisFlow("S999","Commit异常")
        
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.回执类操作(1.回执操作).通存通兑冲正应答报文接收[TRC004_1161]退出***' )
    
    return True
Example #32
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              #文件名
Example #33
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易[TRC001_8532]进入***' )
    
    #=====判断输入接口值是否存在====
    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]不存在')
    
    if(len(TradeContext.PRTTYPE)==0):
        return AfaFlowControl.ExitThisFlow("S999", "打印标志[PRTTYPE]不允许为空")  
    
    #=====组织sql语句====
    wheresql=""
    wheresql = wheresql + "BESBNO='" + TradeContext.BESBNO + "' "
    wheresql=wheresql+" and BJEDTE>='"+TradeContext.STRDAT+"'"
    wheresql=wheresql+" AND BJEDTE<='"+TradeContext.ENDDAT+"'"
    
    #=====判断查复标识是否为空或为9-全部====
    if(TradeContext.ISDEAL != "" and TradeContext.ISDEAL != "9"):
        wheresql=wheresql+" AND ISDEAL='"+TradeContext.ISDEAL+"'"
    
    #=====判断往来标识是否为空====
    if(TradeContext.BRSFLG!=""):
        wheresql=wheresql+" AND BRSFLG='"+TradeContext.BRSFLG+"'"
    
    #=====判断交易代码是否为空====
    if(TradeContext.TRCCO !="" ):
        wheresql=wheresql+" AND TRCCO='"+TradeContext.TRCCO+"'" #业务类型(交易代码)
    
    start_no=TradeContext.RECSTRNO      #起始笔数
    sel_size=10
    
    #=====查询机构名====
    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_pjcbka.count(wheresql)
        if(allcount==-1):
            return AfaFlowControl.ExitThisFlow('A099','查找总记录数失败' )
            
        #=====查询数据库====
        ordersql=" order by BJEDTE DESC,BSPSQN DESC"
        records=rccpsDBTrcc_pjcbka.selectm(start_no,sel_size,wheresql,ordersql)
        
        if records==None:
            return AfaFlowControl.ExitThisFlow('A099','查询失败' )
        if len(records)<=0:
            return AfaFlowControl.ExitThisFlow('A099','没有查找到数据' )        
        else:
            #=====生成文件====
            filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetHostDate()+"_"+TradeContext.TransCode   
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
                
            try:
                f=open(fpath+filename,"w") 
            except :
                AfaLoggerFunc.tradeInfo(">>>打开文件失败")
                return AfaFlowControl.ExitThisFlow('A099','打开文件失败' )
            filecontext=""
            
            #=====写文件操作====
            for i in range(0,len(records)):
                #=====生成文件内容====
                AfaLoggerFunc.tradeDebug( "生成文件内容 ")
                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]['BILDAT']     + "|" \
                           +records[i]['BILNO']      + "|" \
                           +records[i]['BILPNAM']    + "|" \
                           +records[i]['BILENDDT']   + "|" \
                           +str(records[i]['BILAMT'])+ "|" \
                           +records[i]['PYENAM']     + "|" \
                           +records[i]['HONBNKNM']   + "|" \
                           +records[i]['PRCCO']      + "|" \
                           +records[i]['STRINFO']    + "|"
                f.write(filecontext+"\n")
            f.close()
            
            #=====输出接口赋值====
            TradeContext.PBDAFILE=filename              #文件名
            TradeContext.RECCOUNT=str(len(records))     #查询笔数
            TradeContext.RECALLCOUNT=str(allcount)      #总笔数
            
    #=====打印处理 1 打印====        
    elif(TradeContext.PRTTYPE=='1'):
        AfaLoggerFunc.tradeInfo(">>>进入打印处理")
        
        #=====判断查询查复书号是否为空====
        if(TradeContext.BSPSQN!="" ):
            wheresql=wheresql+" AND BSPSQN='"+TradeContext.BSPSQN+"'"           
        else:
            return AfaFlowControl.ExitThisFlow('A099','查询查复书号[BSPSQN]不允许为空' )
            
        #=====查询数据库====
        records = rccpsDBTrcc_pjcbka.selectm(TradeContext.RECSTRNO,10,wheresql,"")
        
        if(records==None):
            return AfaFlowControl.ExitThisFlow('A099','查询失败' )        
        elif( len(records)<=0 ):
            return AfaFlowControl.ExitThisFlow('A099','未查找到数据' )            
        else:
            #=====票据查询书====
            if(TradeContext.TRCCO=='9900520'):                
                AfaLoggerFunc.tradeInfo(">>>业务类型为票据查询书")
                
                #=====票据查询书打印格式====
                txt = """\
                        
                        
                                 %(BESBNM)s票据查询书
                                 
          |-----------------------------------------------------------------------------|
          | 查询日期:     | %(BJEDTE)s                                                    |
          |-----------------------------------------------------------------------------|
          | 票据查询书号: | %(BSPSQN)s                                                | 
          |-----------------------------------------------------------------------------|
          | 发起行行号:   | %(SNDBNKCO)s                                                  |
          |-----------------------------------------------------------------------------|
          | 接收行行号:   | %(RCVBNKCO)s                                                  |
          |-----------------------------------------------------------------------------|
          | 票据日期:     | %(BILDAT)s                                                    |
          |-----------------------------------------------------------------------------|
          | 票据到期日:   | %(BILENDDT)s                                                    |
          |-----------------------------------------------------------------------------|
          | 票据号码:     | %(BILNO)s                                            |
          |-----------------------------------------------------------------------------|
          | 出票人名称:   | %(BILPNAM)s|                                                
          |-----------------------------------------------------------------------------|
          | 付款行名称:   | %(HONBNKNM)s|                                               
          |-----------------------------------------------------------------------------|
          | 查询内容:     |                                                             |
          |-----------------------------------------------------------------------------|
          |                                                                             |
          |   %(CONT1)s      |                                                          
          |                                                                             |
          |   %(CONT2)s    |                                                            
          |                                                                             |
          |   %(CONT3)s    |                                                            
          |                                                                             |
          |   %(CONT4)s    |                                                            
          |                                                                             |
          |-----------------------------------------------------------------------------|
          打印日期: %(BJEDTE)s      授权:                       记账:
                """
                
                #====写文件操作====
                file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8532'
                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,' '),\
                                         'BILDAT':(records[0]['BILDAT']).ljust(8,' '),\
                                         'BILENDDT':(records[0]['BILENDDT']).ljust(8,' '),\
                                         'BILNO':(records[0]['BILNO']).ljust(16,' '),\
                                         'BILPNAM':(records[0]['BILPNAM']).ljust(60,' '),\
                                         'HONBNKNM':(records[0]['HONBNKNM']).ljust(60,' '),\
                                         '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=='9900521'):               
                AfaLoggerFunc.tradeInfo(">>>业务类型为票据查复书")
                
                #=====查询原交易信息====
                where_dict={'BJEDTE':records[0]['BOJEDT'],'BSPSQN':records[0]['BOSPSQ']}
                
                ret=rccpsDBTrcc_pjcbka.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                                                  |
           |---------------------------------------------------------------------------------------|
           | 票据日期:               | %(BILDAT)s                                                    |
           |---------------------------------------------------------------------------------------|
           | 票据到期日:             | %(BILENDDT)s                                                    |
           |---------------------------------------------------------------------------------------|
           | 票据号码:               | %(BILNO)s                                            |
           |---------------------------------------------------------------------------------------|
           | 出票人名称:             | %(BILPNAM)s|                               
           |---------------------------------------------------------------------------------------|
           | 收款人名称:             | %(PYENAM)s|                                
           |---------------------------------------------------------------------------------------|
           | 付款行名称:             | %(HONBNKNM)s|                              
           |---------------------------------------------------------------------------------------|
           | 原票据查询日期:         | %(BOJEDT)s                                                    |
           |---------------------------------------------------------------------------------------|
           | 原票据查询发起行行号:   | %(ORSNDBNKCO)s                                                  |
           |---------------------------------------------------------------------------------------|
           | 原票据查询书号:         | %(BOSPSQ)s                                                |
           |---------------------------------------------------------------------------------------|
           | 查复内容:               |                                                             |
           |---------------------------------------------------------------------------------------|
           |                                                                                       |
           |        %(CONT1)s           |                                            
           |                                                                                       |
           |        %(CONT2)s         |                                              
           |                                                                                       |
           |        %(CONT3)s         |                                              
           |                                                                                       |
           |        %(CONT4)s         |                                              
           |                                                                                       |
           |---------------------------------------------------------------------------------------|
           打印日期: %(BJEDTE)s      授权:                       记账:
                """
                
                #====写文件操作====
                file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8532'
                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,' '),\
                                         'BILDAT':(records[0]['BILDAT']).ljust(8,' '),\
                                         'BILENDDT':(records[0]['BILENDDT']).ljust(8,' '),\
                                         'BILNO':(records[0]['BILNO']).ljust(16,' '),\
                                         'BILPNAM':(records[0]['BILPNAM']).ljust(60,' '),\
                                         'PYENAM':(records[0]['PYENAM']).ljust(60,' '),\
                                         'HONBNKNM':(records[0]['HONBNKNM']).ljust(60,' '),\
                                         'BOJEDT':(records[0]['BOJEDT']).ljust(8,' '),\
                                         'ORSNDBNKCO':(ret['SNDBNKCO']).ljust(10,' '),\
                                         'BOSPSQ':(records[0]['BOSPSQ']).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("结束生成打印文本")                            
            else:
                return AfaFlowControl.ExitThisFlow("S999", "业务类型非法")   
    
        TradeContext.RECCOUNT='1'           #查询笔数
        TradeContext.RECALLCOUNT='1'        #总笔数
        TradeContext.errorCode="0000"
        TradeContext.errorMsg="查询成功"
      
    else:
        return AfaFlowControl.ExitThisFlow("S999", "打印标志非法")  

    TradeContext.errorCode="0000"
    TradeContext.errorMsg="查询成功"
                
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易[TRC001_8532]退出***' )
    return True
Example #34
0
def SubModuleDoSnd(): 
    AfaLoggerFunc.tradeInfo("进入交易后处理")
    #=================判断afe是否发送成功=======================================
    if TradeContext.errorCode != '0000':
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
        
    #=====查询机构名====
    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','没有相应的机构名' )
        
    #=================生成打印文本=============================================
    AfaLoggerFunc.tradeInfo("开始生成打印文本")

    txt = """\
            
            
                               %(BESBNM)s汇票查询书
                               
        |-----------------------------------------------------------------------------|
        | 查询日期:     | %(BJEDTE)s                                                    |
        |-----------------------------------------------------------------------------|
        | 查询书号:     | %(BSPSQN)s                                                |
        |-----------------------------------------------------------------------------|
        | 发起行行号:   | %(SNDBNKCO)s                                                  |
        |-----------------------------------------------------------------------------|
        | 接收行行号:   | %(RCVBNKCO)s                                                  |
        |-----------------------------------------------------------------------------|
        | 出票日期:     | %(BILDAT)s                                                    |
        |-----------------------------------------------------------------------------|
        | 汇票金额:     | %(BILAMT)s                                             |
        |-----------------------------------------------------------------------------|
        | 汇票号码:     | %(BILNO)s                                            |
        |-----------------------------------------------------------------------------|
        | 付款人账号:   | %(PYRACC)s                            |
        |-----------------------------------------------------------------------------|
        | 付款人名称:   | %(PYRNAM)s|
        |-----------------------------------------------------------------------------|
        | 收款人账号:   | %(PYEACC)s                            |
        |-----------------------------------------------------------------------------|
        | 收款人名称:   | %(PYENAM)s|
        |-----------------------------------------------------------------------------|
        | 查询内容:     |                                                             |
        |-----------------------------------------------------------------------------|
        |                                                                             |
        |     %(CONT1)s    |
        |                                                                             |
        |   %(CONT2)s    |
        |                                                                             |
        |   %(CONT3)s    |
        |                                                                             |
        |   %(CONT4)s    |
        |                                                                             |
        |-----------------------------------------------------------------------------|
        打印日期: %(BJEDTE)s      授权:                       记账:
    """
    
    file_name = 'rccps_' + TradeContext.BJEDTE + '_' + TradeContext.BSPSQN + '_8516'
    
    out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb")
    
    if out_file == None:
        return AfaFlowControl.ExitThisFlow("S999", "生成打印文件异常")
    AfaLoggerFunc.tradeInfo(">>>>>>开始赋值")
    print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\
                             'BJEDTE':(TradeContext.BJEDTE).ljust(8,' '),\
                             'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\
                             'SNDBNKCO':(TradeContext.SNDBNKCO).ljust(10,' '),\
                             'RCVBNKCO':(TradeContext.RCVBNKCO).ljust(10,' '),\
                             'BILDAT':(TradeContext.BILDAT).ljust(8,' '),\
                             'BILAMT':(TradeContext.BILAMT).ljust(15,' '),\
                             'BILNO':(TradeContext.BILNO).ljust(16,' '),\
                             'PYRACC':(TradeContext.PYRACC).ljust(32,' '),\
                             'PYRNAM':(TradeContext.PYRNAM).ljust(60,' '),\
                             'PYEACC':(TradeContext.PYEACC).ljust(32,' '),\
                             'PYENAM':(TradeContext.PYENAM).ljust(60,' '),\
                             'CONT1':(TradeContext.CONT[:68]).ljust(68,' '),\
                             'CONT2':(TradeContext.CONT[68:138]).ljust(70,' '),\
                             'CONT3':(TradeContext.CONT[138:208]).ljust(70,' '),\
                             'CONT4':(TradeContext.CONT[208:]).ljust(70,' ')}
    AfaLoggerFunc.tradeInfo(">>>>>>结束赋值")
    out_file.close
    
    TradeContext.PBDAFILE = file_name
    
    AfaLoggerFunc.tradeInfo("结束生成打印文本")
    
    AfaLoggerFunc.tradeInfo("结束交易后处理")
    
    return True
Example #35
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***往账.本地类操作(1.本地操作).县中心机构维护[TRC001_8549]进入***' )

    AfaLoggerFunc.tradeInfo(">>>开始必要性校验")
    #=====校验机构号与柜员号是否为同一机构  20091116 张恒 =======
    if TradeContext.OPRNO != '3':
        if TradeContext.BESBNO[0:6] != TradeContext.BRNO[0:6] :
            return AfaFlowControl.ExitThisFlow("S999","不是同一机构不允许做此业务")
    #===== END ==================================================
    
    #=====校验机构权限  3  查询====   
    if TradeContext.OPRNO != '3':
        chk_subbra_where_dict = {}
        chk_subbra_where_dict['BESBNO'] = TradeContext.BESBNO
        chk_subbra_where_dict['SUBFLG'] = '1'
        chk_subbra_dict = rccpsDBTrcc_subbra.selectu(chk_subbra_where_dict)
        
        if chk_subbra_dict == None:
            return AfaFlowControl.ExitThisFlow("S999","查询本机构信息异常")
        if len(chk_subbra_dict) <= 0:
            return AfaFlowControl.ExitThisFlow("S999","机构登记簿中不存在本机构,本机构无操作权限")
            
#===== 张恒 注释于20091116=======     
#        else:
#            if chk_subbra_dict['BESBTP'] != '31':   #机构属性非县联社财务部
#                return AfaFlowControl.ExitThisFlow("S999","本机构非县联社清算中心,禁止提交")
#                
#            elif TradeContext.BTOPSB != TradeContext.BESBNO:
#                return AfaFlowControl.ExitThisFlow("S999","此机构非本机构下属机构,禁止除查询以外的任何处理")
    
    #=================必要性校验================================================

    #=====0  增加====
#    if TradeContext.OPRNO == '0':
#        #=================校验此机构是否已存在==================================
#        subbra_where_dict = {}
#        subbra_where_dict['BESBNO'] = TradeContext.BRNO
#        
#        subbra_dict = rccpsDBTrcc_subbra.selectu(subbra_where_dict)
#        
#        if subbra_dict == None:
#            return AfaFlowControl.ExitThisFlow("S999","校验机构是否已存在异常")
#        if len(subbra_dict) > 0:
#            return AfaFlowControl.ExitThisFlow("S999","机构登记簿中存在此机构")
    #=====0  增加或 1  修改====
#    #if TradeContext.OPRNO == '0' or TradeContext.OPRNO == '1':
#        #=================校验农信银系统行号是否已被分配========================
#        subbra_where_sql = "BANKBIN = '" + TradeContext.BANKBIN + "' and BESBNO != '" + TradeContext.BRNO + "'"
#        subbra_count = rccpsDBTrcc_subbra.count(subbra_where_sql)
#        
#        if subbra_count < 0:
#            return AfaFlowControl.ExitThisFlow("S999","校验农信银系统行号是否已被分配异常")       
#        if subbra_count > 0:
#            return AfaFlowControl.ExitThisFlow("S999","农信银系统行号已被分配给其他机构,禁止提交")
#            
    AfaLoggerFunc.tradeInfo(">>>结束必要性校验")
    
    #=====判断操作类型  3  查询====
    if( TradeContext.OPRNO == "3" ):
        AfaLoggerFunc.tradeInfo(">>>开始查询机构信息")
        
        subbra_where_dict = {}
        subbra_where_dict['BESBNO'] = TradeContext.BRNO
        
        subbra_dict = rccpsDBTrcc_subbra.selectu(subbra_where_dict)
        
        if subbra_dict == None:
            return AfaFlowControl.ExitThisFlow("S999","查询机构登记簿异常")
        if len(subbra_dict) <= 0:
            return AfaFlowControl.ExitThisFlow("S999","机构登记簿中不存在此机构")
        else:
            rccpsMap8549Dsubbra2CTradeContext.map(subbra_dict)
            
        AfaLoggerFunc.tradeInfo(">>>结束查询机构信息")
    #=====操作类型为0  增加====
    elif TradeContext.OPRNO == '0':
        AfaLoggerFunc.tradeInfo(">>>开始新增机构信息")
        
        #=====校验此机构是否已存在====
        subbra_where_dict = {}
        subbra_where_dict['BESBNO'] = TradeContext.BRNO
        
        subbra_dict = rccpsDBTrcc_subbra.selectu(subbra_where_dict)
        
        if subbra_dict == None:
            return AfaFlowControl.ExitThisFlow("S999","校验机构是否已存在异常")
        if len(subbra_dict) > 0:
            return AfaFlowControl.ExitThisFlow("S999","机构登记簿中存在此机构")
        
        #=====增加新机构====
        subbra_insert_dict = {}
        rccpsMap8549CTradeContext2Dsubbra.map(subbra_insert_dict)
        ret = rccpsDBTrcc_subbra.insertCmt(subbra_insert_dict)
        if ret <= 0:
            return AfaFlowControl.ExitThisFlow("S999","新增机构信息异常")
        
        AfaLoggerFunc.tradeInfo(">>>结束新增机构信息")
        
#===== 张恒 注释于20091116=======   
#=====操作类型为1  修改====
#    elif TradeContext.OPRNO == '1':       
#        AfaLoggerFunc.tradeInfo(">>>开始修改机构信息")
#        
#        subbra_where_dict = {}
#        subbra_where_dict['BESBNO'] = TradeContext.BRNO
#        
#        subbra_update_dict = {}
#        rccpsMap8549CTradeContext2Dsubbra.map(subbra_update_dict)
#        
#        ret = rccpsDBTrcc_subbra.updateCmt(subbra_update_dict,subbra_where_dict)
#        
#        if ret <= 0:
#            return AfaFlowControl.ExitThisFlow("S999","修改机构信息异常")
#        
#        AfaLoggerFunc.tradeInfo(">>>结束修改机构信息")
    #=====操作类型为2  删除====
    elif TradeContext.OPRNO == '2':        
        AfaLoggerFunc.tradeInfo(">>>开始删除机构信息")
        
        subbra_where_dict = {}
        subbra_where_dict['BESBNO'] = TradeContext.BRNO
        
        ret = rccpsDBTrcc_subbra.deleteCmt(subbra_where_dict)
        
        if ret <= 0:
            return AfaFlowControl.ExitThisFlow("S999","删除机构信息异常")
        
        AfaLoggerFunc.tradeInfo(">>>结束删除机构信息")
    
    else:
        #=================操作类型非法==========================================
        return AfaFlowControl.ExitThisFlow("S999","操作类型非法")

    TradeContext.errorCode = '0000'
    TradeContext.errorMsg  = '处理成功'

    AfaLoggerFunc.tradeInfo( '***往账.本地类操作(1.本地操作).县中心机构维护[TRC001_8549]退出***' )
    return True
Example #36
0
def SubModuleMainFst( ):
    try:
        
        AfaLoggerFunc.tradeInfo( '进入差错明细查询['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']'  )
        
        #明细写入文件
        #begin李利君优化20120611
        #mx_file_name = os.environ['AFAP_HOME'] + '/data/batch/tips/' + 'AH_ERROR_' + TradeContext.teller + '_'+TradeContext.workDate+'.txt'
        mx_file_name = os.environ['AFAP_HOME'] + '/tmp/' + 'AH_ERROR_' + TradeContext.teller + '_'+TradeContext.workDate+'.txt'
        #end
        
        TradeContext.tradeResponse.append(['fileName',  'AH_ERROR_' + TradeContext.teller +'_'+TradeContext.workDate+'.txt'])
        
        if (os.path.exists(mx_file_name) and os.path.isfile(mx_file_name)):
            #文件存在,先删除-再创建
            os.system("rm " + mx_file_name)
        
        #====获取清算信息=======   
        if not ChkLiquidStatus( ):
            return False
        
        
        #查询对账失败的交易明细
        sqlStr=''
        sqlStr=sqlStr + "SELECT BRNO,SERIALNO,DRACCNO,CRACCNO,TRADETYPE,TAXPAYNAME,AMOUNT,BANKSTATUS,CORPSTATUS,CHKFLAG,CORPCHKFLAG,REVTRANF,NOTE10 FROM TIPS_MAINTRANSDTL "
        sqlStr=sqlStr + " WHERE NOTE3 = '" + TradeContext.payBkCode.strip() + "' and WORKDATE = '" + TradeContext.date + "'"
        sqlStr=sqlStr + "and ((REVTRANF = '0' and BANKSTATUS = '0' and CORPSTATUS = '0' and ((CHKFLAG ='9' and CORPCHKFLAG ='9')or(CHKFLAG ='9' and CORPCHKFLAG ='0')or(CHKFLAG ='0' and CORPCHKFLAG ='9'))) "
        sqlStr=sqlStr + " or ( REVTRANF = '1' and BANKSTATUS != '0'))"
          
        AfaLoggerFunc.tradeInfo(sqlStr) 
           
        Records = AfaDBFunc.SelectSql( sqlStr )
           
        if( Records == None ):
            
            return TipsFunc.ExitThisFlow( 'A0027', '表操作异常:'+AfaDBFunc.sqlErrMsg )
            
        elif( len( Records )==0 ):
            
            return TipsFunc.ExitThisFlow( 'A0027', '没有满足条件的数据' )
        else:
            sfp = open(mx_file_name, "w")
            AfaLoggerFunc.tradeInfo('明细文件=['+mx_file_name+']')
            for i in range(0,len(Records)):
                A0 = str(Records[i][0]).strip()           #机构号
                A1 = str(Records[i][1]).strip()           #平台流水号     
                A2 = str(Records[i][2]).strip()           #借方账号   
                A3 = str(Records[i][3]).strip()           #贷方账号
                A4 = str(Records[i][4]).strip()           #交易类型
                A5 = str(Records[i][5]).strip()           #纳税人名称
                A6 = str(Records[i][6]).strip()           #交易金额
                A7 = str(Records[i][7]).strip()           #主机状态
                A8 = str(Records[i][8]).strip()           #企业状态
                A9 = str(Records[i][9]).strip()           #主机对账标志
                A10 = str(Records[i][10]).strip()         #企业对账标志
                A11 = str(Records[i][11]).strip()         #正反交易标志
                A12 = str(Records[i][12]).strip()         #清算金库名      
       
                sfp.write(A0 + '|' + A1 + '|' + A2 + '|' + A3 + '|' + A4 + '|' + A5 + '|' + A6 + '|' + A7 + '|' + A8 + '|' + A9 + '|' + A10 + '|' + A11 + '|' + A12 + '\n')
                
            sfp.close()                
        
        TradeContext.tradeResponse.append(['errorCode','0000'])
        TradeContext.tradeResponse.append(['errorMsg','交易成功'])
       
        AfaLoggerFunc.tradeInfo( '退出差错明细查询[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
    
        return True 
    
    except Exception, e:                  

        AfaFlowControl.exitMainFlow(str(e))      
Example #37
0
def main( ):
    AfaLoggerFunc.tradeInfo( '凭证柜员交接['+TradeContext.TemplateCode+']进入' )

    #=============前台上送数据===================================
    #TradeContext.sBesbNo                                 机构号
    #TradeContext.sBesbSty                                机构类型
    #TradeContext.sCur                                    货币代码
    #TradeContext.sTellerNo                               柜员号
    #TradeContext.sRivTeller                              对方柜员
    #TradeContext.sLstTrxDay                              最后交易日期
    #TradeContext.sLstTrxTime                             最后交易时间
    
    try: 
        #=============获取柜员级别==========================
        HostContext.I1TELR = TradeContext.sTellerNo       #柜员号
        HostContext.I1SBNO = TradeContext.sBesbNo         #机构号
        HostContext.I1USID = TradeContext.sTellerNo       #柜员号
        HostContext.I1WSNO = TradeContext.sWSNO           #终端号
        if(not VouhHostFunc.CommHost('8809')):
            tradeExit(TradeContext.errorCode, TradeContext.errorMsg)
            raise AfaFlowControl.flowException( )
        if(TradeContext.errorCode == '0000'):
            TELLER = HostContext.O1TLRK
            AfaLoggerFunc.tradeInfo( TELLER )
        
        #=============初始化返回报文变量========================
        TradeContext.tradeResponse = []
        TradeContext.sRivTeller = TradeContext.sInTellerNo
        
        #=============生成流水号========================
        TradeContext.sVouhSerial = VouhFunc.GetVouhSerial( )

        #=============获取当前系统时间==========================
        TradeContext.sLstTrxDay  = AfaUtilTools.GetSysDate( )
        TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( )

        TradeContext.sTransType    = '凭证柜员交接'
        
        #================判断对方柜员是否有凭证==================================
        if(len(TradeContext.sInTellerNo) == 0):
            VouhFunc.tradeExit('A005061', '对方柜员不能为空!')
            raise AfaFlowControl.flowException( )
        
        #if(TELLER == '01' or TELLER == '02' or TELLER == '03'):
        #    VouhFunc.tradeExit('A005061', '该柜员不能进行此操作!')
        #    raise AfaFlowControl.flowException( )
            
        sqlStr = "select * from VOUH_REGISTER where TELLERNO = '" + TradeContext.sInTellerNo + "' and VOUHSTATUS = '3'"
        
        records = AfaDBFunc.SelectSql( sqlStr )
        AfaLoggerFunc.tradeDebug(sqlStr)
        if records==-1 :
            VouhFunc.tradeExit( 'A005057', '查询[凭证登记表]信息异常!' )
            raise AfaFlowControl.flowException( )
        elif len(records) > 0 :
            VouhFunc.tradeExit( 'A005058', '['+TradeContext.sInTellerNo+']柜员不能交接!' )
            raise AfaFlowControl.flowException( )
        
        #================判断柜员是否有凭证==================================
        
        #if((TradeContext.sTellerNo)[4:] == '01' or (TradeContext.sTellerNo)[4:] == '02' or (TradeContext.sTellerNo)[4:] == '03'):
        #    VouhFunc.tradeExit('A005061', '该柜员不能进行此操作!')
        #    raise AfaFlowControl.flowException( )
            
        sqlStr = "select * from VOUH_REGISTER where TELLERNO = '" + TradeContext.sTellerNo + "' and VOUHSTATUS = '3'"
        
        records = AfaDBFunc.SelectSql( sqlStr )
        AfaLoggerFunc.tradeDebug(sqlStr)
        if records==-1 :
            VouhFunc.tradeExit( 'A005057', '查询[凭证登记表]信息异常!' )
            raise AfaFlowControl.flowException( )
        elif records==0 :
            VouhFunc.tradeExit( 'A005058', '无凭证!' )
            raise AfaFlowControl.flowException( )
        
        #======================柜员交接=====================================
        sqlStr = "update VOUH_REGISTER set TELLERNO = '" + TradeContext.sInTellerNo + "' where TELLERNO = '" + TradeContext.sTellerNo + "' and VOUHSTATUS = '3'"
        
        records = AfaDBFunc.UpdateSqlCmt( sqlStr )
        AfaLoggerFunc.tradeDebug(sqlStr)
        if records==-1 :
            VouhFunc.tradeExit( 'A005057', '更新[凭证登记表]信息异常!' )
            raise AfaFlowControl.flowException( )
        elif records==0 :
            VouhFunc.tradeExit( 'A005058', '修改[凭证登记表]基本信息失败!' )
            raise AfaFlowControl.flowException( )

        #更新凭证变更登记表
        VouhFunc.VouhModify()
        #数据库提交
        AfaDBFunc.CommitSql( )
        
        #==================查询交接凭证明细==================================
	#=====李亚杰  20080812  修改凭证查询条件,增加凭证状态为'3'的情况====
        #sqlStr = "select distinct t.VOUHTYPE,t1.VOUHNAME,t.STARTNO,t.ENDNO,t.VOUHNUM FROM VOUH_REGISTER t,VOUH_PARAMETER t1 \
        #         where t.VOUHTYPE = t1.VOUHTYPE AND substr(t.BESBNO,1,6) = substr(t1.BESBNO,1,6) \
        #         AND t.TELLERNO = '" + TradeContext.sInTellerNo + "'"

        sqlStr = "select distinct t.VOUHTYPE,t1.VOUHNAME,t.STARTNO,t.ENDNO,t.VOUHNUM FROM VOUH_REGISTER t,VOUH_PARAMETER t1 \
                 where t.VOUHTYPE = t1.VOUHTYPE AND substr(t.BESBNO,1,6) = substr(t1.BESBNO,1,6) \
                 AND t.VOUHSTATUS = '3' AND t.TELLERNO = '" + TradeContext.sInTellerNo + "'"

        AfaLoggerFunc.tradeDebug(sqlStr);
        #查询数据库并将返回的结果压至对应变量中
        records = AfaDBFunc.SelectSql( sqlStr )
        if( records == None ):
            VouhFunc.tradeExit('A005067', '查询[凭证表]操作异常!')
            raise AfaFlowControl.flowException( )
        elif( len( records ) == 0 ):
            VouhFunc.tradeExit('A005068', '凭证不存在!' )
            raise AfaFlowControl.flowException( )
        else :
            record=AfaUtilTools.ListFilterNone( records )
            total=len( records )
            
            sVouhType = ''
            sVouhName = ''
            sStartNo = ''
            sEndNo = ''
            sVouhNum = ''
            
            for i in range( 0, total ):
                if( i <> 0):
                    strSplit = '|'
                else:
                    strSplit = ''
                sVouhType = sVouhType + strSplit + records[i][0]
                sVouhName = sVouhName + strSplit + records[i][1]
                sStartNo = sStartNo + strSplit + records[i][2]
                sEndNo = sEndNo + strSplit + records[i][3]
                sVouhNum = sVouhNum + strSplit + records[i][4]
                
        TradeContext.tradeResponse.append( ['sVouhType',sVouhType] )
        TradeContext.tradeResponse.append( ['sVouhName',sVouhName] )
        TradeContext.tradeResponse.append( ['sTellerNo',TradeContext.sTellerNo] )
        TradeContext.tradeResponse.append( ['sInTellerNo',TradeContext.sInTellerNo] )
        TradeContext.tradeResponse.append( ['sStartNo',sStartNo] )
        TradeContext.tradeResponse.append( ['sEndNo',sEndNo] )
        TradeContext.tradeResponse.append( ['sVouhNum',sVouhNum] )
        TradeContext.tradeResponse.append( ['sNum',str(total)] )
        TradeContext.tradeResponse.append( ['sVouhSerial',TradeContext.sVouhSerial] )
        TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] )
        TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] )
        TradeContext.tradeResponse.append( ['errorCode','0000'] )
        TradeContext.tradeResponse.append( ['errorMsg','交易成功'] )

        #自动打包
        AfaFunc.autoPackData()

        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '凭证柜员交接['+TradeContext.TemplateCode+']退出' )
    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( )
Example #38
0
def SubModuleMainFst( ):
    AfaLoggerFunc.tradeInfo( '进入查询交易明细['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']'  )

    AfaLoggerFunc.tradeInfo('数据类型为:'+TradeContext.dataType)
    if(TradeContext.dataType=="0"):
        sqlStr=" WHERE status='0' "
        sqlStr=sqlStr+" AND TaxOrgCode like '%"+ TradeContext.code +"%'"
        sqlStr=sqlStr+" AND TaxOrgName like '%"+ TradeContext.name +"%'"
        #if( TradeContext.existVariable( "dataCode" ) ):
        #    if len(TradeContext.dataCode)>0:
        #        sqlStr=sqlStr+" AND TaxOrgCode like '%"+ TradeContext.dataCode +"%'"
        #if( TradeContext.existVariable( "dataName" ) ):
        #    if len(TradeContext.dataName)>0:
        #        sqlStr=sqlStr+" AND TaxOrgName like '%"+ TradeContext.dataName +"%'"

        sqlStr_detail="SELECT TAXORGCODE,TAXORGNAME,TAXORGTYPE,UPTRECODE,OFPROVORG,"
        sqlStr_detail=sqlStr_detail+"OFCITYORG,OFCOUNTYORG,ADDRESS,PEOPLENAME,PEOPLEPHONE,POSTALCODE,STATUS,EFFECTDATE FROM TIPS_TAXCODE "
        sqlStr_detail=sqlStr_detail+sqlStr
        AfaLoggerFunc.tradeInfo(sqlStr_detail)     
        records = AfaDBFunc.SelectSql( sqlStr_detail )
        if( records == None ):
            return AfaFlowControl.ExitThisFlow( '0027', '表操作异常:'+AfaDBFunc.sqlErrMsg )
        elif( len( records )==0 ):
            return AfaFlowControl.ExitThisFlow( '0028', '没有满足条件的数据' )
        
        mx_file_name = os.environ['AFAP_HOME'] + '/tmp/' + 'AH_' + TradeContext.teller + '.txt'
        TradeContext.tradeResponse.append(['fileName',  'AH_' + TradeContext.teller + '.txt'])
    
        if (os.path.exists(mx_file_name) and os.path.isfile(mx_file_name)):
            #文件存在,先删除-再创建
            os.system("rm " + mx_file_name)
    
        sfp = open(mx_file_name, "w")
        AfaLoggerFunc.tradeInfo('明细文件=['+mx_file_name+']')
    
        i = 0
        while ( i  < len(records) ):
            lineStr = ''
            lineStr = lineStr + str(records[i][0]).strip() + '|'        
            lineStr = lineStr + str(records[i][1]).strip() + '|'       
            lineStr = lineStr + str(records[i][2]).strip() + '|'      
            lineStr = lineStr + str(records[i][3]).strip() + '|'       
            lineStr = lineStr + str(records[i][4]).strip() + '|'       
            lineStr = lineStr + str(records[i][5]).strip() + '|'       
            lineStr = lineStr + str(records[i][6]).strip() + '|'        
            lineStr = lineStr + str(records[i][7]).strip() + '|'       
            lineStr = lineStr + str(records[i][8]).strip() + '|'        
            lineStr = lineStr + str(records[i][9]).strip() + '|'       
            lineStr = lineStr + str(records[i][10]).strip() + '|'        
            lineStr = lineStr + str(records[i][11]).strip() + '|'       
            lineStr = lineStr + str(records[i][12]).strip() + '|'        
    
            sfp.write(lineStr  +  '\n')
    
            i=i+1
    
        sfp.close()
    if(TradeContext.dataType=="1"): #银行代码
        sqlStr=" WHERE status='0' "
        sqlStr=sqlStr+" AND RECKBANKNO like '%"+ TradeContext.code +"%'"
        sqlStr=sqlStr+" AND GENBANKNAME like '%"+ TradeContext.name +"%'"

        sqlStr_detail="SELECT RECKBANKNO,GENBANKNAME,OFNODECODE,ADDRESS,PEOPLENAME,PEOPLEPHONE,STATUS,EFFECTDATE"
        sqlStr_detail=sqlStr_detail+" FROM TIPS_BANKCODE "
        sqlStr_detail=sqlStr_detail+sqlStr
        AfaLoggerFunc.tradeInfo(sqlStr_detail)     
        records = AfaDBFunc.SelectSql( sqlStr_detail )
        if( records == None ):
            return AfaFlowControl.ExitThisFlow( '0027', '表操作异常:'+AfaDBFunc.sqlErrMsg )
        elif( len( records )==0 ):
            return AfaFlowControl.ExitThisFlow( '0028', '没有满足条件的数据' )
        
        mx_file_name = os.environ['AFAP_HOME'] + '/tmp/' + 'AH_' + TradeContext.teller + '.txt'
        TradeContext.tradeResponse.append(['fileName',  'AH_' + TradeContext.teller + '.txt'])
    
        if (os.path.exists(mx_file_name) and os.path.isfile(mx_file_name)):
            #文件存在,先删除-再创建
            os.system("rm " + mx_file_name)
    
        sfp = open(mx_file_name, "w")
        AfaLoggerFunc.tradeInfo('明细文件=['+mx_file_name+']')
    
        i = 0
        while ( i  < len(records) ):
            lineStr = ''
            lineStr = lineStr + str(records[i][0]).strip() + '|'        
            lineStr = lineStr + str(records[i][1]).strip() + '|'       
            lineStr = lineStr + str(records[i][2]).strip() + '|'      
            lineStr = lineStr + str(records[i][3]).strip() + '|'       
            lineStr = lineStr + str(records[i][4]).strip() + '|'       
            lineStr = lineStr + str(records[i][5]).strip() + '|'       
            lineStr = lineStr + str(records[i][6]).strip() + '|'        
            lineStr = lineStr + str(records[i][7]).strip() + '|'            
    
            sfp.write(lineStr  +  '\n')
    
            i=i+1
    
        sfp.close()
    if(TradeContext.dataType=="2"): #国库代码
        sqlStr=" WHERE status='0' "
        sqlStr=sqlStr+" AND TRECODE like '%"+ TradeContext.code +"%'"
        sqlStr=sqlStr+" AND TRENAME like '%"+ TradeContext.name +"%'"

        sqlStr_detail="SELECT TRECODE,TRENAME,TRELEVEL,PAYBANKNO,RECKONTRECODE,UPTRECODE,OFPROVTREA,"
        sqlStr_detail=sqlStr_detail+"OFCITYTREA,OFCOUNTYTREA,ADDRESS,PEOPLENAME,PEOPLEPHONE,STATUS,EFFECTDATE FROM TIPS_TRECODE "
        sqlStr_detail=sqlStr_detail+sqlStr
        AfaLoggerFunc.tradeInfo(sqlStr_detail)     
        records = AfaDBFunc.SelectSql( sqlStr_detail )
        if( records == None ):
            return AfaFlowControl.ExitThisFlow( '0027', '表操作异常:'+AfaDBFunc.sqlErrMsg )
        elif( len( records )==0 ):
            return AfaFlowControl.ExitThisFlow( '0028', '没有满足条件的数据' )
        
        mx_file_name = os.environ['AFAP_HOME'] + '/tmp/' + 'AH_' + TradeContext.teller + '.txt'
        TradeContext.tradeResponse.append(['fileName',  'AH_' + TradeContext.teller + '.txt'])
    
        if (os.path.exists(mx_file_name) and os.path.isfile(mx_file_name)):
            #文件存在,先删除-再创建
            os.system("rm " + mx_file_name)
    
        sfp = open(mx_file_name, "w")
        AfaLoggerFunc.tradeInfo('明细文件=['+mx_file_name+']')
    
        i = 0
        while ( i  < len(records) ):
            lineStr = ''
            lineStr = lineStr + str(records[i][0]).strip() + '|'        
            lineStr = lineStr + str(records[i][1]).strip() + '|'       
            lineStr = lineStr + str(records[i][2]).strip() + '|'      
            lineStr = lineStr + str(records[i][3]).strip() + '|'       
            lineStr = lineStr + str(records[i][4]).strip() + '|'       
            lineStr = lineStr + str(records[i][5]).strip() + '|'       
            lineStr = lineStr + str(records[i][6]).strip() + '|'        
            lineStr = lineStr + str(records[i][7]).strip() + '|'       
            lineStr = lineStr + str(records[i][8]).strip() + '|'        
            lineStr = lineStr + str(records[i][9]).strip() + '|'       
            lineStr = lineStr + str(records[i][10]).strip() + '|'        
            lineStr = lineStr + str(records[i][11]).strip() + '|'       
            lineStr = lineStr + str(records[i][12]).strip() + '|'        
            lineStr = lineStr + str(records[i][13]).strip() + '|' 
    
            sfp.write(lineStr  +  '\n')
    
            i=i+1
    
        sfp.close()                   
    if(TradeContext.dataType=="3"): #预算科目代码
        sqlStr=" WHERE status='0' "
        sqlStr=sqlStr+" AND BUDGETSUBJECTCODE like '%"+ TradeContext.code +"%'"
        sqlStr=sqlStr+" AND BUDGETSUBJECTNAME like '%"+ TradeContext.name +"%'"

        sqlStr_detail="SELECT BUDGETSUBJECTCODE,BUDGETSUBJECTNAME,"
        sqlStr_detail=sqlStr_detail+"STATUS FROM TIPS_BUDGETSUBJECTCODE "
        sqlStr_detail=sqlStr_detail+sqlStr
        AfaLoggerFunc.tradeInfo(sqlStr_detail)     
        records = AfaDBFunc.SelectSql( sqlStr_detail )
        if( records == None ):
            return AfaFlowControl.ExitThisFlow( '0027', '表操作异常:'+AfaDBFunc.sqlErrMsg )
        elif( len( records )==0 ):
            return AfaFlowControl.ExitThisFlow( '0028', '没有满足条件的数据' )
        
        mx_file_name = os.environ['AFAP_HOME'] + '/tmp/' + 'AH_' + TradeContext.teller + '.txt'
        TradeContext.tradeResponse.append(['fileName',  'AH_' + TradeContext.teller + '.txt'])
    
        if (os.path.exists(mx_file_name) and os.path.isfile(mx_file_name)):
            #文件存在,先删除-再创建
            os.system("rm " + mx_file_name)
    
        sfp = open(mx_file_name, "w")
        AfaLoggerFunc.tradeInfo('明细文件=['+mx_file_name+']')
    
        i = 0
        while ( i  < len(records) ):
            A0 = str(records[i][0]).strip()         #TRECODE
            A1 = str(records[i][1]).strip()         #TRENAME
    
            sfp.write(A0 +  '|'  +  A1 +  '|'  +  '\n')
    
            i=i+1
    
        sfp.close() 
    if(TradeContext.dataType=="4"): #税种代码
        sqlStr=" WHERE status='0' "
        sqlStr=sqlStr+" AND TAXTYPECODE like '%"+ TradeContext.code +"%'"
        sqlStr=sqlStr+" AND TAXTYPENAME like '%"+ TradeContext.name +"%'"

        sqlStr_detail="SELECT TAXTYPECODE,TAXORGTYPE,TAXTYPENAME,"
        sqlStr_detail=sqlStr_detail+"STATUS FROM TIPS_TAXTYPECODE "
        sqlStr_detail=sqlStr_detail+sqlStr
        AfaLoggerFunc.tradeInfo(sqlStr_detail)     
        records = AfaDBFunc.SelectSql( sqlStr_detail )
        if( records == None ):
            return AfaFlowControl.ExitThisFlow( '0027', '表操作异常:'+AfaDBFunc.sqlErrMsg )
        elif( len( records )==0 ):
            return AfaFlowControl.ExitThisFlow( '0028', '没有满足条件的数据' )
        
        mx_file_name = os.environ['AFAP_HOME'] + '/tmp/' + 'AH_' + TradeContext.teller + '.txt'
        TradeContext.tradeResponse.append(['fileName',  'AH_' + TradeContext.teller + '.txt'])
    
        if (os.path.exists(mx_file_name) and os.path.isfile(mx_file_name)):
            #文件存在,先删除-再创建
            os.system("rm " + mx_file_name)
    
        sfp = open(mx_file_name, "w")
        AfaLoggerFunc.tradeInfo('明细文件=['+mx_file_name+']')
    
        i = 0
        while ( i  < len(records) ):
            A0 = str(records[i][0]).strip()         #TRECODE
            A1 = str(records[i][1]).strip()         #TRENAME
            A2 = str(records[i][2]).strip()         #TRENAME
            
            sfp.write(A0 +  '|'  +  A1 +  '|'  + A2 +  '|'  +  '\n')
    
            i=i+1
    
        sfp.close() 
    if(TradeContext.dataType=="5"): #税目代码
        sqlStr=" WHERE status='0' "
        sqlStr=sqlStr+" AND TAXSUBJECTCODE like '%"+ TradeContext.code +"%'"
        sqlStr=sqlStr+" AND TAXSUBJECTNAME like '%"+ TradeContext.name +"%'"

        sqlStr_detail="SELECT TAXSUBJECTCODE,TAXORGTYPE,TAXSUBJECTNAME,"
        sqlStr_detail=sqlStr_detail+"STATUS FROM TIPS_TAXSUBJECTCODE "
        sqlStr_detail=sqlStr_detail+sqlStr
        AfaLoggerFunc.tradeInfo(sqlStr_detail)     
        records = AfaDBFunc.SelectSql( sqlStr_detail )
        if( records == None ):
            return AfaFlowControl.ExitThisFlow( '0027', '表操作异常:'+AfaDBFunc.sqlErrMsg )
        elif( len( records )==0 ):
            return AfaFlowControl.ExitThisFlow( '0028', '没有满足条件的数据' )
        
        mx_file_name = os.environ['AFAP_HOME'] + '/tmp/' + 'AH_' + TradeContext.teller + '.txt'
        TradeContext.tradeResponse.append(['fileName',  'AH_' + TradeContext.teller + '.txt'])
    
        if (os.path.exists(mx_file_name) and os.path.isfile(mx_file_name)):
            #文件存在,先删除-再创建
            os.system("rm " + mx_file_name)
    
        sfp = open(mx_file_name, "w")
        AfaLoggerFunc.tradeInfo('明细文件=['+mx_file_name+']')
    
        i = 0
        while ( i  < len(records) ):
            A0 = str(records[i][0]).strip()         #TRECODE
            A1 = str(records[i][1]).strip()         #TRENAME
            A2 = str(records[i][2]).strip()         #TRENAME
    
            sfp.write(A0 +  '|'  +  A1 +  '|'   +  A2 +  '|'  +  '\n')
    
            i=i+1
    
        sfp.close() 
    TradeContext.tradeResponse.append(['dataType',  TradeContext.dataType])
    TradeContext.tradeResponse.append(['errorCode',  '0000'])
    TradeContext.tradeResponse.append(['errorMsg',   '交易成功'])
    return True                    
Example #39
0
def SubModuleDoTrd():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(3.中心记账).个人现金通存[TRCC002_8561]进入***' )
    
    #=================设置业务状态为发送成功或失败,若发送失败则自动抹账========
    
    stat_dict = {}
    stat_dict['BJEDTE']  = TradeContext.BJEDTE
    stat_dict['BSPSQN']  = TradeContext.BSPSQN
    stat_dict['BESBNO']  = TradeContext.BESBNO
    stat_dict['BETELR']  = TradeContext.BETELR
    stat_dict['BCSTAT']  = PL_BCSTAT_SND
    stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
    stat_dict['PRCCO']   = TradeContext.errorCode
    stat_dict['STRINFO'] = TradeContext.errorMsg
    
    AfaLoggerFunc.tradeInfo("TradeContext.errorCode = [" + TradeContext.errorCode + "]")
    
    if TradeContext.errorCode == '0000':
        AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送成功")
        
        stat_dict['BCSTAT']  = PL_BCSTAT_SND
        stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
        
        if not rccpsState.setTransState(stat_dict):
            return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为发送成功异常")
        
        AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为发送成功")
        
    else:
        AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送失败")
        
        stat_dict['BCSTAT']  = PL_BCSTAT_SND
        stat_dict['BDWFLG']  = PL_BDWFLG_FAIL
        
        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异常")
        
        #=============发起主机抹账=============================================
        AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为抹账处理中")
        
        #=====特殊处理  关彬捷 20081127 调8813抹账,需产生新的前置流水号进行记账====
        if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 :
            return AfaFlowControl.ExisThisFlow('S999',"产生新的前置流水号异常")
        
        
        #为抹账会计分录赋值
        TradeContext.HostCode='8813'
        
        TradeContext.PKFG = 'T'                                         #通存通兑标识
        TradeContext.RVFG = '2'                                         #红蓝字标志 2
        TradeContext.CATR = '0'                                         #现转标识:0-现金
        TradeContext.RCCSMCD = PL_RCCSMCD_XJTCWZ                        #主机摘要码:现金通存往账
        TradeContext.SBAC = ''
        TradeContext.ACNM = ''
        TradeContext.RBAC = TradeContext.BESBNO + PL_ACC_NXYDQSWZ       #贷方账号
        TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25)
        TradeContext.OTNM = "农信银待清算往账"
        TradeContext.CTFG = '7'                                         #结转标识:结转-0
        
        AfaLoggerFunc.tradeInfo("借方账号1:[" + TradeContext.SBAC + "]")
        AfaLoggerFunc.tradeInfo("贷方账号1:[" + TradeContext.RBAC + "]")
        
        if TradeContext.CHRGTYP == '0':
            #现金收取手续费
            TradeContext.ACUR   = '2'                                       #重复次数
            
            TradeContext.I2PKFG = 'T'                                       #通存通兑标识
            TradeContext.I2RVFG = '2'                                       #红蓝字标志 2
            TradeContext.I2CATR = '0'                                       #现转标识:0-现金
            TradeContext.I2TRAM = TradeContext.LOCCUSCHRG                   #手续费金额
            TradeContext.I2SMCD = PL_RCCSMCD_SXF                            #主机摘要码:手续费
            TradeContext.I2SBAC = ''
            TradeContext.I2ACNM = ''
            TradeContext.I2RBAC = TradeContext.BESBNO + PL_ACC_TCTDSXF      #贷方账号:通存通兑手续费
            TradeContext.I2RBAC = rccpsHostFunc.CrtAcc(TradeContext.I2RBAC,25)
            TradeContext.I2OTNM = "农信银手续费"
            TradeContext.I2CTFG = '8'                                       #结转标识:不结转-1
        
        
        #====设置业务状态为抹账处理中====
        if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_HCAC,PL_BDWFLG_WAIT):
            return AfaFlowControl.ExitThisFlow('S999','设置业务状态为抹账处理中异常')
        
        AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为抹账处理中")
        
        if not AfaDBFunc.CommitSql( ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return AfaFlowControl.ExitThisFlow("S999","Commit异常")
            
        AfaLoggerFunc.tradeInfo(">>>开始发起主机抹账")
        
        #=====调起抹账主机接口====
        rccpsHostFunc.CommHost( TradeContext.HostCode )
        
        AfaLoggerFunc.tradeInfo(">>>结束发起主机抹账")
        
        stat_dict = {}
        
        stat_dict['BJEDTE']  = TradeContext.BJEDTE
        stat_dict['BSPSQN']  = TradeContext.BSPSQN
        stat_dict['MGID']    = TradeContext.errorCode
        stat_dict['STRINFO'] = TradeContext.errorMsg
            
        AfaLoggerFunc.tradeInfo("TradeContext.errorCode = [" + TradeContext.errorCode + "]")
        if TradeContext.errorCode == '0000':
            AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为抹账成功")
            
            stat_dict['BCSTAT'] = PL_BCSTAT_HCAC
            stat_dict['BDWFLG'] = PL_BDWFLG_SUCC
            stat_dict['TRDT']   = TradeContext.TRDT
            stat_dict['TLSQ']   = TradeContext.TLSQ
            stat_dict['PRTCNT'] = 1                            #打印次数
            
            if not rccpsState.setTransState(stat_dict):
                return AfaFlowControl.ExitThisFlow('S999','设置业务状态抹账成功异常')
            
            AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为抹账成功")
            
        else:
            AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为抹账失败")
            
            stat_dict['BCSTAT'] = PL_BCSTAT_HCAC
            stat_dict['BDWFLG'] = PL_BDWFLG_FAIL
            
            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.errorCode = '0000'
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(3.中心记账).个人现金通存[TRCC002_8561]退出***' )
    return True
Example #40
0
def SubModuleDoFst( ):
    
    
    AfaLoggerFunc.tradeInfo( '单证重打查询变量值的有效性校验' )
    
    if( not TradeContext.existVariable( "unitno" ) ):
        return AfaFlowControl.ExitThisFlow( 'A0001', '单位编号[unitno]值不存在!' )
    
    if( not TradeContext.existVariable( "policy" ) ):
        return AfaFlowControl.ExitThisFlow( 'A0001', '投保单号[policy]值不存在!' )
    
    if( not TradeContext.existVariable( "userno" ) ):
        return AfaFlowControl.ExitThisFlow( 'A0001', '原保单印刷号[userno]值不存在!' )
    
    if( not TradeContext.existVariable( "userno1" ) ):
        return AfaFlowControl.ExitThisFlow( 'A0001', '新保单印刷号[userno1]值不存在!' )    
    
    if( not TradeContext.existVariable( "transrno" ) ):
        return AfaFlowControl.ExitThisFlow( 'A0001', '原交易流水号[transrno]值不存在!' ) 
    
    if( not TradeContext.existVariable( "amount" ) ):
        return AfaFlowControl.ExitThisFlow( 'A0001', '原交易金额[amount]值不存在!' )  
   
    if( not TradeContext.existVariable( "I1CETY" ) ):
        return AfaFlowControl.ExitThisFlow( 'A0001', '原保单凭证[I1CETY]值不存在!' )  
           
    if( not TradeContext.existVariable( "channelCode" ) ):
        return AfaFlowControl.ExitThisFlow( 'A0001', '渠道代码[channelCode]值不存在!' )
    
    if( TradeContext.channelCode == '005' ):
        
        if( not TradeContext.existVariable( "tellerno" ) ):
            return AfaFlowControl.ExitThisFlow( 'A0001', '柜员号[tellerno]值不存在!' )
        
        if( not TradeContext.existVariable( "brno" ) ): 
            return AfaFlowControl.ExitThisFlow( 'A0001', '网点号[brno]值不存在!' )
        
        if( not TradeContext.existVariable( "termId" ) ):
            return AfaFlowControl.ExitThisFlow( 'A0001', '终端号[termId]值不存在!' )
   
    return True
Example #41
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统: 通存通兑.本地类操作交易[RCC003_8562]进入***' )

    #检查本机构是否有通存通兑业务权限
    if not rccpsDBFunc.chkTDBESAuth(TradeContext.BESBNO):
        return AfaFlowControl.ExitThisFlow("S999","本机构无通存通兑业务权限")
    
    #=====接收行判断====
    if TradeContext.SNDSTLBIN == TradeContext.RCVSTLBIN:
        return AfaFlowControl.ExitThisFlow('S999','同一清算行不允许做此业务')

    #=====账户类型判断====
    if not TradeContext.existVariable('PYRTYP'):
        return AfaFlowControl.ExitThisFlow('S999','账户类型不存在[PYRTYP]')

    if TradeContext.PYRTYP == '0':
        #=====银行卡====        
        if len(TradeContext.PYRNAM)   == 0:
            return AfaFlowControl.ExitThisFlow('S999','付款人名称[PYRNAM]不允许为空')
        if len(TradeContext.SCTRKINF) == 0:
            return AfaFlowControl.ExitThisFlow('S999','二磁道[SCTRKINF]信息不允许为空')
        #if len(TradeContext.THTRKINF) == 0:
        #    return AfaFlowControl.ExitThisFlow('S999','三磁道[THTRKINF]信息不允许为空')
            
        if len(TradeContext.SCTRKINF) > 37:
            return AfaFlowControl.ExitThisFlow('S999','磁道信息非法')
            
        #if len(TradeContext.THTRKINF) > 104:
        #    return AfaFlowControl.ExitThisFlow('S999','磁道信息非法')
    elif TradeContext.PYRTYP == '1':
        #=====存折====
        if len(TradeContext.BNKBKNO)  == 0:
            return AfaFlowControl.ExitThisFlow('S999','存折号码[BNKBKNO]不允许为空')
        if float(TradeContext.BNKBKBAL) == 0.0:
            return AfaFlowControl.ExitThisFlow('S999','存折余额[BNKBKBAL]不允许为空')
            
        TradeContext.SCTRKINF = ''.rjust(37,'0')
        TradeContext.THTRKINF = ''.rjust(37,'0')
    else:
        return AfaFlowControl.ExitThisFlow('S999','账户类型错误')
    
    #=====交易金额判断====
    sel_dict = {}
    sel_dict['BPARAD'] = 'TD001'    #通存通兑凭证金额校验
    
    dict = rccpsDBTrcc_pamtbl.selectu(sel_dict) 
    AfaLoggerFunc.tradeInfo('dict='+str(dict))

    if dict == None:
        return AfaFlowControl.ExitThisFlow('S999','校验交易金额失败')
    if len(dict) == 0:
        return AfaFlowControl.ExitThisFlow('S999','查询PAMTBL校验交易金额表记录错误')
    
    #=====判断农信银中心规定校验凭证上线====
    if float(TradeContext.OCCAMT) >= float(dict['BPADAT']):
         #=====交易金额大于农信银中心规定金额,需要输入证件====
         if TradeContext.existVariable('CERTTYPE') and len(TradeContext.CERTTYPE) == 0:
             return AfaFlowControl.ExitThisFlow('S999','请选择证件类型!')
         if TradeContext.existVariable('CERTNO')   and len(TradeContext.CERTNO)   == 0:
             return AfaFlowControl.ExitThisFlow('S999','请输入证件号码!')

    #加密客户密码
    MIMA = '                '
    #PIN = '888888'
    #ACC = '12311111111111111111111111111111'
    PIN  = TradeContext.CURPIN
    ACC  = TradeContext.PYRACC
    AfaLoggerFunc.tradeDebug('密码[' + PIN + ']')
    AfaLoggerFunc.tradeDebug('账号[' + ACC + ']')
    ret = jiami.secEncryptPin(PIN,ACC,MIMA)
    if ret != 0:
        AfaLoggerFunc.tradeDebug("ret=[" + str(ret) + "]")
        return AfaFlowControl.ExitThisFlow('M9999','调用加密服务器失败')
    else:
        TradeContext.CURPIN = MIMA
        AfaLoggerFunc.tradeDebug('密码new[' + TradeContext.CURPIN + ']')

    #=====字段赋值====
    TradeContext.OPRNO   =  PL_TDOPRNO_TD          #业务种类
    TradeContext.DCFLG   =  PL_DCFLG_DEB           #借贷标识

    #=====字典赋值,插入数据库====
    wtrbka_dict = {}
    if not rccpsMap8562CTradeContext2Dwtrbka_dict.map(wtrbka_dict):
        return AfaFlowControl.ExitThisFlow('S999','字典赋值错误!')
        
    wtrbka_dict['MSGFLGNO'] = TradeContext.SNDSTLBIN + TradeContext.TRCDAT + TradeContext.SerialNo       #报文标识号

    #=====插入数据库表====
    if not rccpsDBFunc.insTransWtr(wtrbka_dict):
        return AfaFlowControl.ExitThisFlow('S999','登记通存通兑业务登记簿异常')
    AfaDBFunc.CommitSql( )

    #=====设置业务状态为发送处理中====
    AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送处理中")
    
    stat_dict = {}
    stat_dict['BJEDTE'] = TradeContext.BJEDTE       #交易日期
    stat_dict['BSPSQN'] = TradeContext.BSPSQN       #报单序号
    stat_dict['BCSTAT'] = PL_BCSTAT_SND             #PL_BCSTAT_SND  发送
    stat_dict['BDWFLG'] = PL_BDWFLG_WAIT            #PL_BDWFLG_WAIT 处理中
    
    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异常")
    
    AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为发送处理中")
    
    #=====发送农信银中心====
    AfaLoggerFunc.tradeInfo(">>>开始发送农信银中心处理")
    
    TradeContext.MSGTYPCO   =   'SET004'              #报文类代码
    TradeContext.OPRTYPNO   =   '30'                  #通存通兑
    
    #=====根据手续费收取方式判断是否发送农信银中心====
    TradeContext.sCuschrg = TradeContext.CUSCHRG
    if TradeContext.CHRGTYP != PL_CHRG_TYPE:          #PL_CHRG_TYPE 1 转账
        #=====转账收取手续费====
        TradeContext.CUSCHRG = '0.0'
    
    AfaLoggerFunc.tradeDebug(">>>结束发送农信银中心处理")

    AfaLoggerFunc.tradeInfo( '***农信银系统: 通存通兑.本地类操作交易[RCC003_8562]退出***' )
    return True
Example #42
0
            VouhFunc.tradeExit(tmpErrorCode, tmpErrorMsg)
            raise AfaFlowControl.flowException( )
        
        #更新流水表
        VouhFunc.ModifyVouhModify()     
        
        TradeContext.tradeResponse.append( ['sVouhSerial',TradeContext.sVouhSerial] )
        TradeContext.tradeResponse.append( ['sVouhType',TradeContext.rVouhType] )
        TradeContext.tradeResponse.append( ['sVouhName',TradeContext.rVouhName] )
        TradeContext.tradeResponse.append( ['sStartNo',TradeContext.rStartNo] )
        TradeContext.tradeResponse.append( ['sEndNo',TradeContext.rEndNo] )
        TradeContext.tradeResponse.append( ['sVouhNum',TradeContext.rVouhNum] )
        TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] )
        TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] )
        TradeContext.tradeResponse.append( ['sNum',str(TradeContext.sNum)] )
        TradeContext.tradeResponse.append( ['errorCode','0000'] )
        TradeContext.tradeResponse.append( ['errorMsg','交易成功'] )

        #自动打包
        AfaFunc.autoPackData()

        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '凭证上缴['+TradeContext.TemplateCode+']退出' )
    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( )
    except AfaFlowControl.accException:
        AfaFlowControl.exitMainFlow( )
    except Exception, e:
        AfaFlowControl.exitMainFlow(str(e))

Example #43
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
Example #44
0
def SubModuleDoFst():    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作(1.本地操作).通存通兑主机错帐查询[TRCC001_8588]进入***' )
    
    #=====必要性检查====
    AfaLoggerFunc.tradeInfo(">>>开始必要性检查")
    
    if( not TradeContext.existVariable( "RECSTRNO" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '起始笔数[RECSTRNO]不存在')
        
    AfaLoggerFunc.tradeInfo(">>>必要性检查结束")
    
    #=====组织sql语句====
    AfaLoggerFunc.tradeInfo(">>>开始组织查询sql语句")
    
    wheresql = ""
    wheresql = wheresql + "NCCWKDAT='" + TradeContext.NCCWKDAT + "' " 
    
    ordersql = " order by NCCWKDAT DESC "
    
    start_no = TradeContext.RECSTRNO        #起始笔数
    sel_size = 10                           #查询笔数
    
    ##=====判断报单序号是否为空====
    #if(TradeContext.BSPSQN != ""):
    #    wheresql = wheresql + " AND BSPSQN='" + TradeContext.BSPSQN + "' "
    
    #=====判断处理标识是否为空====
    if(TradeContext.ISDEAL == "0"):
        wheresql = wheresql + "AND ISDEAL='0'" 
    elif(TradeContext.ISDEAL == "1"):
        wheresql = wheresql + "AND ISDEAL='1'" 
    else:
        pass
        
    AfaLoggerFunc.tradeDebug(">>>结束组织查询sql语句")   
    
    #=====查询总记录数====
    allcount=rccpsDBTrcc_tdzjcz.count(wheresql)
    
    if(allcount<0):
        return AfaFlowControl.ExitThisFlow('A099','查询总笔数失败' )
        
    #=====查询数据库====
    
    AfaLoggerFunc.tradeInfo("wheresql=" + wheresql)
    records = rccpsDBTrcc_tdzjcz.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)):
                #AfaLoggerFunc.tradeDebug("写入第"+str(i)+"笔记录开始")
                filecontext= records[i]['NCCWKDAT']        + "|" \
                           + records[i]['SCFEDT']          + "|" \
                           + records[i]['SCRBSQ']          + "|" \
                           + records[i]['RCFEDT']          + "|" \
                           + records[i]['RCRBSQ']          + "|" \
                           + str(records[i]['SCTRAM'])     + "|" \
                           + str(records[i]['RCTRAM'])     + "|" \
                           + records[i]['SCTRDT']          + "|" \
                           + records[i]['SCTLSQ']          + "|" \
                           + records[i]['ERRTYP']          + "|" \
                           + records[i]['ERRINF']          + "|" \
                           + records[i]['ISDEAL']          + "|" 
                           
                f.write(filecontext+"\n") 
                #AfaLoggerFunc.tradeDebug("写入第"+str(i)+"笔记录结束")     
        except Exception,e:                                        
            f.close()                                              
            return AfaFlowControl.ExitThisFlow('S099','写文件失败')
            AfaLoggerFunc.tradeInfo ("生成文件内容结束 ")
Example #45
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo("进入汇票查询书录入 1.本地操作 ")
    
    #====begin 蔡永贵 20110215 增加====
    #新票据号是16位,需要取后8位,版本号为02,同时要兼容老票据号8位,版本号为01
    if TradeContext.BILVER == '02':
        TradeContext.TMP_BILNO = TradeContext.BILNO[-8:]
    else:
        TradeContext.TMP_BILNO = TradeContext.BILNO
    #============end============
    
    #=====查询汇票信息=====
#    where_dict_bilinf = {'BILVER':TradeContext.BILVER,'BILNO':TradeContext.BILNO,'BILRS':PL_BILRS_OUT}
#    res_bilinf = rccpsDBTrcc_bilinf.selectu(where_dict_bilinf)
#    if( res_bilinf == None ):
#        return AfaFlowControl.ExitThisFlow("S999", "查询汇票信息失败")
#        
#    if( len(res_bilinf) == 0 ):
#        return AfaFlowControl.ExitThisFlow("S999", "查询汇票信息为空")
        

#    #=====查询行名行号====
#    where_dict_paybnk = {'BANKBIN':TradeContext.BESBNO}
#    res_paybnk = rccpsDBTrcc_paybnk.selectu(where_dict_paybnk)
#    if( res_paybnk == None ):
#        return AfaFlowControl.ExitThisFlow("S999", "查询行名行号失败")
#        
#    if( len(res_paybnk) == 0 ):
#        return AfaFlowControl.ExitThisFlow("S999", "查询行名行号为空")
#        
    #=====登记查询书信息====
    AfaLoggerFunc.tradeInfo("开始登记查询书信息")
    
    TradeContext.BRSFLG      =  PL_BRSFLG_SND
    TradeContext.NCCWKDAT    =  TradeContext.NCCworkDate
    TradeContext.TRCNO       =  TradeContext.SerialNo
#    TradeContext.SNDBNKCO    =  TradeContext.BESBNO
#    TradeContext.SNDBNKNM    =  res_paybnk['BANKNAM']
#    TradeContext.RCVBNKCO    =  res_bilinf['PAYBNKCO']
#    TradeContext.RCVBNKNM    =  res_bilinf['PAYBNKNM']
    TradeContext.BOJEDT      =  ""
    TradeContext.BOSPSQ      =  ""
    TradeContext.ORTRCCO     =  ""
    #TradeContext.TRCDAT      =  TradeContext.BJEDTE
#    TradeContext.BILDAT      =  res_bilinf['BILDAT']
#    TradeContext.PAYWAY      =  res_bilinf['PAYWAY']
#    TradeContext.CUR         =  res_bilinf['CUR']
#    TradeContext.BILAMT      =  str(res_bilinf['BILAMT'])
#    TradeContext.PYRACC      =  res_bilinf['PYRACC']
#    TradeContext.PYRNAM      =  res_bilinf['PYRNAM']
#    TradeContext.PYEACC      =  res_bilinf['PYEACC']
#    TradeContext.PYENAM      =  res_bilinf['PYENAM']
    TradeContext.ISDEAL      =  PL_ISDEAL_UNDO
    TradeContext.PRCCO       =  ""
    TradeContext.SNDMBRCO    =  TradeContext.SNDSTLBIN
    TradeContext.RCVMBRCO    =  TradeContext.RCVSTLBIN

    hpcbka_insert_dict = {}
    if not rccpsMap8516CTradeContext2Dhpcbka_dict.map(hpcbka_insert_dict):
        return AfaFlowControl.ExitThisFlow("S999", "为汇票查询查复登记薄赋值失败")
        
    ret = rccpsDBTrcc_hpcbka.insertCmt(hpcbka_insert_dict)
    if( ret <= 0 ):
        return AfaFlowControl.ExitThisFlow("S999", "为汇票查询查复登记薄赋值异常")
    
    AfaLoggerFunc.tradeInfo("结束登记查询书信息")
        
    #=====为汇票查询书报文赋值====
    AfaLoggerFunc.tradeInfo("开始为汇票查询书报文赋值")
    #=====报文头====
    TradeContext.MSGTYPCO = 'SET008'
    TradeContext.SNDBRHCO = TradeContext.BESBNO
    TradeContext.SNDCLKNO = TradeContext.BETELR
    TradeContext.SNDTRDAT = TradeContext.BJEDTE
    TradeContext.SNDTRTIM = TradeContext.BJETIM
    TradeContext.MSGFLGNO = TradeContext.SNDSTLBIN + TradeContext.TRCDAT + TradeContext.SerialNo
    TradeContext.NCCWKDAT = TradeContext.NCCworkDate
    TradeContext.OPRTYPNO = '99'
    TradeContext.ROPRTPNO = '21'
    TradeContext.TRANTYP  = '0'
    #=====扩展数据====
    TradeContext.TRCCO    = '9900526'    
#    TradeContext.BILDAT   = res_bilinf['BILDAT']
#    TradeContext.BILAMT   = str(res_bilinf['BILAMT'])
    
    #=====给前台接口赋值====
    TradeContext.BILENDDT = ""  #先这么放着
    
    AfaLoggerFunc.tradeInfo("结束为汇票查询书报文赋值")
    
    return True
Example #46
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo('>>>主机记账后处理')
   
    #=====开始向字典赋值====
    sst_dict = {}
    sst_dict['BSPSQN']  = TradeContext.BSPSQN            #报单序号
    sst_dict['BJEDTE']  = TradeContext.BJEDTE            #交易日期
    sst_dict['SBAC']    = TradeContext.SBAC              #借方账号
    sst_dict['BESBNO']  = TradeContext.BESBNO            #机构号
    if (TradeContext.existVariable( "NOTE3" ) and len(TradeContext.NOTE3) != 0):  
        sst_dict['NOTE3']   = TradeContext.NOTE3         #备注3
        AfaLoggerFunc.tradeDebug('>>>test  NOTE3 =['+TradeContext.NOTE3 +']')
    sst_dict['BJETIM']  = TradeContext.BJETIM            #交易时间
    sst_dict['MGID']     = TradeContext.errorCode         #主机返回代码
    sst_dict['STRINFO']  = TradeContext.errorMsg          #主机返回信息
    sst_dict['BETELR']  = TradeContext.BETELR            #柜员号

    #=====开始判断主机返回结果====
    out_context_dict = {}
    
    if TradeContext.errorCode == '0000' :
        AfaLoggerFunc.tradeDebug('>>>主机通讯成功,更新表状态开始')
        trcbka_jgh = {}
        trcbka_where = {}
        trcbka_jgh['BESBNO'] = TradeContext.BESBNO  
        trcbka_where['BSPSQN'] = TradeContext.BSPSQN 
        trcbka_where['BJEDTE'] = TradeContext.BJEDTE
        
        if not rccpsDBTrcc_trcbka.updateCmt( trcbka_jgh,trcbka_where ):
            #=====RollBack操作====
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow('D002', '更新数据库出错,RollBack成功')
        else:
            #=====commit操作====
            AfaDBFunc.CommitSql()
            AfaLoggerFunc.tradeInfo('更新登记簿,COMMIT成功')
            
        if (TradeContext.existVariable( "RBAC" ) and len(TradeContext.RBAC) != 0):  
            sst_dict['RBAC']   = TradeContext.RBAC                 
            AfaLoggerFunc.tradeDebug('>>>test  RBAC =['+TradeContext.RBAC +']')
        if (TradeContext.existVariable( "REAC" ) and len(TradeContext.REAC) != 0):  
            sst_dict['REAC']   = TradeContext.REAC                 
            AfaLoggerFunc.tradeDebug('>>>test  REAC =['+TradeContext.REAC +']')

        #自动挂账
        if TradeContext.accflag == 1 :
            sst_dict['BCSTAT']  = PL_BCSTAT_HANG                #自动挂账
            AfaLoggerFunc.tradeDebug('>>>test  BCSTAT=['+str(sst_dict['BCSTAT']) +']')
        #自动入账
        elif TradeContext.accflag == 0 :
            sst_dict['BCSTAT']  = PL_BCSTAT_AUTO                 #自动入账 
            AfaLoggerFunc.tradeDebug('>>>test  BCSTAT=['+str(sst_dict['BCSTAT']) +']')
        if (TradeContext.existVariable( "DASQ" ) and len(TradeContext.DASQ) != 0):  
           sst_dict['DASQ']    = TradeContext.DASQ              #销账序号
           AfaLoggerFunc.tradeDebug('>>>test  DASQ  =['+TradeContext.DASQ +']')
        sst_dict['BDWFLG']  = PL_BDWFLG_SUCC                 #成功
        AfaLoggerFunc.tradeDebug('>>>test  BDWFLG=['+str(sst_dict['BDWFLG']) +']')
        sst_dict['TRDT']    = TradeContext.TRDT              #主机日期
        AfaLoggerFunc.tradeDebug('>>>test  TRDT  =['+TradeContext.TRDT   +']')
        sst_dict['TLSQ']    = TradeContext.TLSQ              #主机流水
        AfaLoggerFunc.tradeDebug('>>>test  TLSQ  =['+TradeContext.TLSQ   +']')
        
        AfaLoggerFunc.tradeDebug('>>>主机通讯成功,更新表状态结束')
        
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '成功'
        
    else :    
        if TradeContext.accflag == 1 :
            sst_dict['BCSTAT']  = PL_BCSTAT_HANG                            #自动挂账
            sst_dict['BDWFLG']  = PL_BDWFLG_FAIL                            #处理失败
            
            out_context_dict['PRCCO']    = 'RCCI1056'
            out_context_dict['STRINFO']  = '挂账失败,交易失败'
        
        elif TradeContext.accflag == 0 :
            #记账失败,挂代理机构账
            TradeContext.BESBNO = TradeContext.BESBNOFIRST
            #汇兑来帐挂帐字典赋值
            input_dict = {}
            input_dict['accflag']     = str(TradeContext.accflag)                   #记挂标志
            input_dict['OCCAMT']      = TradeContext.OCCAMT                         #交易金额
            input_dict['BESBNO']      = TradeContext.BESBNOFIRST
                
            #调用汇兑记账接口
            rccpsEntries.HDLZGZ(input_dict)
            
            rccpsHostFunc.CommHost( '8813' )
            
            sst_dict = {}
            sst_dict['BSPSQN']  = TradeContext.BSPSQN            #报单序号
            AfaLoggerFunc.tradeDebug('>>>test  BSPSQN=['+TradeContext.BSPSQN+']')
            sst_dict['BJEDTE']  = TradeContext.BJEDTE            #交易日期
            AfaLoggerFunc.tradeDebug('>>>test  BJEDTE=['+TradeContext.BJEDTE+']')
            sst_dict['SBAC']    = TradeContext.SBAC              #借方账号
            AfaLoggerFunc.tradeDebug('>>>test  SBAC=['+TradeContext.SBAC+']')
            sst_dict['BESBNO']  = TradeContext.BESBNO            #机构号
            AfaLoggerFunc.tradeDebug('>>>test  BESBNO=['+TradeContext.BESBNO+']')
            if (TradeContext.existVariable( "NOTE3" ) and len(TradeContext.NOTE3) != 0):  
                sst_dict['NOTE3']   = TradeContext.NOTE3         #备注3
                AfaLoggerFunc.tradeDebug('>>>test  NOTE3 =['+TradeContext.NOTE3 +']')
            sst_dict['BJETIM']  = TradeContext.BJETIM            #交易时间
            AfaLoggerFunc.tradeDebug('>>>test  BJETIM=['+TradeContext.BJETIM+']')
            sst_dict['MGID']     = TradeContext.errorCode        #主机返回代码
            sst_dict['STRINFO']  = TradeContext.errorMsg         #主机返回信息
            sst_dict['BETELR']  = TradeContext.BETELR            #柜员号
            
            if TradeContext.errorCode == '0000':
                AfaLoggerFunc.tradeDebug(">>>SubModuleDoSnd--挂帐成功")            
                sst_dict['BCSTAT']  = PL_BCSTAT_HANG          
                sst_dict['BDWFLG']  = PL_BDWFLG_SUCC
                
                out_context_dict['PRCCO']    = 'RCCI0000'
                out_context_dict['STRINFO']  = '成功'
                
            else:
                AfaLoggerFunc.tradeDebug(">>>SubModuleDoSnd--挂帐失败")
                sst_dict['BCSTAT']  = PL_BCSTAT_HANG             
                sst_dict['BDWFLG']  = PL_BDWFLG_FAIL
                out_context_dict['PRCCO']    = 'RCCI1056'
                out_context_dict['STRINFO']  = '挂账失败,交易失败'


    AfaLoggerFunc.tradeDebug('>>>当前业务状态[' + str(sst_dict['BCSTAT']) + ']')
    AfaLoggerFunc.tradeDebug('>>>当前流转标志[' + str(sst_dict['BDWFLG']) + ']')
            
    #=====设置状态为 记账/挂账-成功 ====
    if not rccpsState.setTransState(sst_dict):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeDebug('>>>commit成功')

    #=====开始设置通讯回执报文信息====
    AfaLoggerFunc.tradeInfo('>>>开始组织通讯回执报文')

    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

    rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)

    return True
Example #47
0
            raise AfaFlowControl.flowException( )
                
        #=====================外调接口(前处理)==================================
        subModuleExistFlag = 0
        subModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode
        try:
            subModuleHandle=__import__( subModuleName )

        except Exception, e:
            AfaLoggerFunc.tradeInfo( e)

        else:
            AfaLoggerFunc.tradeInfo( '执行['+subModuleName+']模块' )
            subModuleExistFlag=1
            if not subModuleHandle.SubModuleDoFst( ) :
                raise AfaFlowControl.flowException( )


        #=====================校验公共节点的有效性==============================
        if( not AfaFunc.Pay_ChkVariableExist( ) ):
            raise AfaFlowControl.flowException( )

                        
        #=====================判断单位状态======================================
        if not AfaFunc.ChkUnitStatus( ) :
            raise AfaFlowControl.flowException( )
            
            
        #=====================判断渠道状态======================================
        if not AfaFunc.ChkChannelStatus( ) :
            raise AfaFlowControl.flowException( )
Example #48
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.回执类操作(1.回执操作).通存通兑冲销应答报文接收[TRC004_1162]进入***' )
    
    #=================初始化返回信息============================================
    if AfaUtilTools.trim(TradeContext.STRINFO) == "":
        TradeContext.STRINFO = rccpsDBFunc.getErrInfo(TradeContext.PRCCO)
        
    AfaLoggerFunc.tradeDebug("TradeContext.STRINFO=" + TradeContext.STRINFO)
    
    #=================初始化返回信息============================================
    if AfaUtilTools.trim(TradeContext.STRINFO) == "":
        TradeContext.STRINFO = rccpsDBFunc.getErrInfo(TradeContext.PRCCO)
        
    AfaLoggerFunc.tradeDebug("TradeContext.STRINFO=" + TradeContext.STRINFO)
    
    #查询冲正登记簿中是否有对此冲销交易的冲正
    AfaLoggerFunc.tradeInfo(">>>开始检查此冲销交易是否已被冲正")
    
    where_sql = "ORMFN = '" + TradeContext.ORMFN + "'"
    
    ret = rccpsDBTrcc_atcbka.count(where_sql)
    
    if ret < 0:
        return AfaFlowControl.ExitThisFlow("S999","查询冲正登记簿异常,退出主流程")
        
    if ret > 0:
        return AfaFlowControl.ExitThisFlow("S999","冲正登记簿中存在对此冲销交易的冲正,退出主流程")
        
    AfaLoggerFunc.tradeInfo(">>>结束检查此冲销交易是否已被冲正")
    
    #=====更改柜员号和机构号为发起柜员号、发起机构号====
    AfaLoggerFunc.tradeInfo("<<<<<<开始更改柜员号,机构号")
    
    #=====查找冲销交易的信息=====
    mpcbka_where_dict = {}
    mpcbka_where_dict['MSGFLGNO'] = TradeContext.ORMFN
    
    mpcbka_record = rccpsDBTrcc_mpcbka.selectu(mpcbka_where_dict)
    
    if(mpcbka_record == None):
        return AfaFlowControl.ExitThisFlow("S999","查询原冲销交易信息异常")
        
    if(len(mpcbka_record) <= 0):
        return AfaFlowControl.ExitThisFlow("S999","未找到原冲销交易信息,丢弃报文")
        
    #=====给机构号和柜员号赋值====
    TradeContext.BETELR = mpcbka_record['BETELR']
    TradeContext.BESBNO = mpcbka_record['BESBNO']
    
    AfaLoggerFunc.tradeInfo("<<<<<<更改柜员号,机构号结束")
    
        
    #更新冲销登记簿中心返回信息
    AfaLoggerFunc.tradeInfo(">>>开始更新冲销登记簿中心返回信息")
    
    mpcbka_update_dict = {}
    mpcbka_update_dict['PRCCO'] = TradeContext.PRCCO
    mpcbka_update_dict['STRINFO'] = TradeContext.STRINFO
    
    ret = rccpsDBTrcc_mpcbka.update(mpcbka_update_dict,mpcbka_where_dict)
    
    if ret <= 0:
        return AfaFlowControl.ExitThisFlow("S999","更新冲销登记簿异常")
    
    AfaLoggerFunc.tradeInfo(">>>结束更新冲销登记簿中心返回信息")
    
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow("S999","Commit异常")
        
    #=====查询被冲销交易信息====
    AfaLoggerFunc.tradeInfo("<<<<<<开始查询被冲销的交易的信息")
    
    wtrbka_record = {}
    
    if not rccpsDBFunc.getTransWtr(mpcbka_record['BOJEDT'],mpcbka_record['BOSPSQ'],wtrbka_record):
        return AfaFlowControl.ExitThisFlow("S999","查询被冲销原交易详细信息异常")
        
    AfaLoggerFunc.tradeInfo("<<<<<<结束查询被冲销的交易的信息")
    
    #====为终端号和往来标识赋值====
    TradeContext.TERMID = wtrbka_record['TERMID']
    TradeContext.BRSFLG = wtrbka_record['BRSFLG']
    
    #=====判断对方行冲销是否成功=====
    AfaLoggerFunc.tradeInfo("<<<<<<判断对方行冲销是否成功PRCCO=[" + TradeContext.PRCCO + "]")
    if(TradeContext.PRCCO == 'RCCI0000' or TradeContext.PRCCO == 'RCCO1106'):
        AfaLoggerFunc.tradeInfo("<<<<<<对方行冲销成功")
        
        #=====发起主机记账====
        AfaLoggerFunc.tradeInfo("<<<<<<开始发起主机记账")
        
        #=====取最后一个记账成功状态的前置日期和前置流水号====
        stat_list = []
        
        if rccpsState.getTransStateSetm(wtrbka_record['BJEDTE'],wtrbka_record['BSPSQN'],PL_BCSTAT_ACC,PL_BDWFLG_SUCC,stat_list):
            
            entries_dict = {}
            entries_dict['FEDT']     = stat_list[0]['FEDT']
            entries_dict['RBSQ']     = stat_list[0]['RBSQ']
            entries_dict['PYRACC']   = wtrbka_record['PYRACC']
            entries_dict['PYRNAM']   = wtrbka_record['PYRNAM']
            entries_dict['PYEACC']   = wtrbka_record['PYEACC']
            entries_dict['PYENAM']   = wtrbka_record['PYENAM']
            entries_dict['OCCAMT']   = wtrbka_record['OCCAMT']
            entries_dict['CHRGTYP']  = wtrbka_record['CHRGTYP']
            entries_dict['CUSCHRG']  = wtrbka_record['CUSCHRG']
            entries_dict['RCCSMCD']  = PL_RCCSMCD_CX
            TradeContext.BRSFLG      = wtrbka_record['BRSFLG']
            
            #卡折通存往账抹账会计分录赋值
            if wtrbka_record['TRCCO'] == '3000002' or wtrbka_record['TRCCO'] == '3000004':
                rccpsEntries.KZTCWZMZ(entries_dict)
            
            #卡折本转异往账抹账会计分录赋值
            if wtrbka_record['TRCCO'] == '3000003' or wtrbka_record['TRCCO'] == '3000005':
                rccpsEntries.KZBZYWZMZ(entries_dict)
                
            #卡折通兑往账抹账会计分录赋值
            if wtrbka_record['TRCCO'] == '3000102' or wtrbka_record['TRCCO'] == '3000104':
                rccpsEntries.KZTDWZMZ(entries_dict)
            
            #卡折异转本往账抹账会计分录赋值
            if wtrbka_record['TRCCO'] == '3000103' or wtrbka_record['TRCCO'] == '3000105':
                rccpsEntries.KZYZBWZMZ(entries_dict)
            
            
            #=====生成新的前置日期和前置流水号,并且更新到数据库中====
            if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 :
                return AfaFlowControl.ExisThisFlow('S999',"产生新的前置流水号异常")
            
            #设置原交易状态为冲销处理中
            AfaLoggerFunc.tradeInfo('>>>开始设置原交易状态为冲销处理中')
            if not rccpsState.newTransState(mpcbka_record['BOJEDT'],mpcbka_record['BOSPSQ'],PL_BCSTAT_CANC,PL_BDWFLG_WAIT):
                return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为冲销处理中异常")
            
            if not AfaDBFunc.CommitSql( ):
                AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
                return AfaFlowControl.ExitThisFlow("S999","Commit异常")
                
            AfaLoggerFunc.tradeInfo('>>>结束设置原交易状态为冲销处理中')
            
            #=====调用主机接口函数=====
            rccpsHostFunc.CommHost( TradeContext.HostCode )
            
            AfaLoggerFunc.tradeInfo("<<<<<<发起主机抹账结束")
            
        else:
            AfaLoggerFunc.tradeInfo(">>>原交易未记账,冲销不抹账")
            
            #设置原交易状态为冲销处理中
            AfaLoggerFunc.tradeInfo('>>>开始设置原交易状态为冲销处理中')
            if not rccpsState.newTransState(mpcbka_record['BOJEDT'],mpcbka_record['BOSPSQ'],PL_BCSTAT_CANC,PL_BDWFLG_WAIT):
                return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为冲销处理中异常")
            
            if not AfaDBFunc.CommitSql( ):
                AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
                return AfaFlowControl.ExitThisFlow("S999","Commit异常")
                
            AfaLoggerFunc.tradeInfo('>>>结束设置原交易状态为冲销处理中')
            
            TradeContext.errorCode = '0000'
            TradeContext.errorMsg  = '原交易未记账,冲销不抹账'
            
            
        #根据主机返回信息,设置交易状态
        
        stat_dict = {}
        stat_dict['BJEDTE'] = wtrbka_record['BJEDTE']
        stat_dict['BSPSQN'] = wtrbka_record['BSPSQN']
        stat_dict['MGID']   = TradeContext.errorCode
        stat_dict['STRINFO']= TradeContext.errorMsg
        
        AfaLoggerFunc.tradeInfo("TradeContext.errorCode = [" + TradeContext.errorCode + "]")
        if(TradeContext.errorCode == '0000'):
            #=====设置原交易状态为冲销成功====
            AfaLoggerFunc.tradeInfo("<<<<<<<开始更改原交易状态为冲销成功")
            
            stat_dict['BCSTAT'] = PL_BCSTAT_CANC
            stat_dict['BDWFLG'] = PL_BDWFLG_SUCC
            if TradeContext.existVariable('TRDT'):
                stat_dict['TRDT']   = TradeContext.TRDT
            if TradeContext.existVariable('TLSQ'):
                stat_dict['TLSQ']   = TradeContext.TLSQ
            
            if not rccpsState.setTransState(stat_dict):
                return AfaFlowControl.ExitThisFlow('S999','设置业务状态冲销成功异常')
            
            AfaLoggerFunc.tradeInfo("<<<<<<<结束更改原交易状态为冲销成功")
            
        else:
            #=====设置原交易状态为冲销失败====
            AfaLoggerFunc.tradeInfo("<<<<<<<开始更改原交易状态为冲销失败")
            
            stat_dict['BCSTAT'] = PL_BCSTAT_CANC
            stat_dict['BDWFLG'] = PL_BDWFLG_FAIL
            
            if not rccpsState.setTransState(stat_dict):
                return AfaFlowControl.ExitThisFlow('S999','设置业务状态冲销失败异常')
                
            AfaLoggerFunc.tradeInfo("<<<<<<<结束更改原交易状态为冲销失败")
            
    else:
        AfaLoggerFunc.tradeInfo("<<<<<<对方行冲销拒绝应答,不设置原交易状态")
        
        ##设置原交易状态为冲销处理中
        #AfaLoggerFunc.tradeInfo('>>>开始设置原交易状态为冲销处理中')
        #
        #if not rccpsState.newTransState(wtrbka_record['BJEDTE'],wtrbka_record['BSPSQN'],PL_BCSTAT_CANC,PL_BDWFLG_WAIT):
        #    return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为冲销处理中异常")
        #
        #AfaLoggerFunc.tradeInfo('>>>结束设置原交易状态为冲销处理中')
        #
        #if not AfaDBFunc.CommitSql( ):
        #    AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        #    return AfaFlowControl.ExitThisFlow("S999","Commit异常")
        #    
        ##=====设置原交易状态为冲销失败====
        #AfaLoggerFunc.tradeInfo("<<<<<<<开始更改原交易状态为冲销失败")
        #
        #stat_dict = {}
        #stat_dict['BJEDTE'] = wtrbka_record['BJEDTE']
        #stat_dict['BSPSQN'] = wtrbka_record['BSPSQN']
        #stat_dict['PRCCO']  = TradeContext.PRCCO
        #stat_dict['STRINFO']= TradeContext.STRINFO
        #stat_dict['BCSTAT'] = PL_BCSTAT_CANC
        #stat_dict['BDWFLG'] = PL_BDWFLG_FAIL
        #
        #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异常")
        
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.回执类操作(1.回执操作).通存通兑冲销应答报文接收[TRC004_1162]退出***' )
    
    return True
Example #49
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo('单证重打子查询交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']进入' )
    
    try:
        sql = "select unitno,amount,userno,note4,note5,note8,note9,note10,craccno,note7 from afa_maintransdtl"
        sql = sql + " where agentserialno = '" + TradeContext.transrno.strip() + "'"
        sql = sql + " and   workdate      = '" + TradeContext.workDate.strip() + "'"
        sql = sql + " and   bankstatus    = '0' and corpstatus = '0' and revtranf = '0'"
        
        AfaLoggerFunc.tradeInfo('单证重打信息查询语句'+ sql)
        
        records = AfaDBFunc.SelectSql( sql )
        
        if records == None:
            TradeContext.errorCode,TradeContext.errorMsg = "0001" ,"查询银保通数据库失败"
            raise AfaFlowControl.flowException( )
        
        if(len(records) < 1):
            TradeContext.errorCode,TradeContext.errorMsg = "0001","无此缴费信息"
            return False
        
        else:
            if(records[0][0]!=TradeContext.unitno):
                TradeContext.errorCode,TradeContext.errorMsg='E9999',"单位编号不符"
                return False
            
            if(records[0][1].split()!=TradeContext.amount.split()):
                TradeContext.errorCode,TradeContext.errorMsg='E9999',"与原交易金额不符"
                return False
            
            if(records[0][2]!=TradeContext.userno):
                TradeContext.errorCode,TradeContext.errorMsg='E9999',"与原保单印刷号不符"
                return False
           
            note9=records[0][6].split('|')
            AfaLoggerFunc.tradeInfo(note9[2] + "||"+TradeContext.policy)
            if(note9[2]!=TradeContext.policy):
                TradeContext.errorCode,TradeContext.errorMsg='E9999',"与原保险单号不符"  
                return False
            
            #note9保险单号
            TradeContext.policy=note9[2]
            
            #note8主险险种和附加险种      
            note8= records[0][5].split('|') 
            TradeContext.productid=note8[0]
            TradeContext.productid1=note8[2] 
            
            #note4:投保人姓名|投保人证件号码|与投保人关系        
            note4= records[0][3].split('|') 
            TradeContext.tbr_name=note4[0]
            TradeContext.tbr_idno=note4[1]
            TradeContext.tbr_bbr_rela=note4[2] 
          
            #note5:被保人姓名|被保人证件号码|与被保险人关系 
            note5= records[0][4].split('|') 
            TradeContext.bbr_name=note5[0]
            TradeContext.bbr_idno=note5[1]
            TradeContext.syr_bbr_rela=note5[2] 
            TradeContext.payacc=records[0][8] 

            #note7:交费方式|缴费期次|交费期间
            TradeContext.paymethod = records[0][9].split('|')[0]
            
        #查询受益人信息
        sql = "select syr_info1,syr_info2,syr_info3,syr_info4,syr_info5 from ybt_info"
        sql = sql + " where submino  = '" + note9[1]                    + "'"            #投保单号
        sql = sql + " and   cpicno   = '" + TradeContext.unitno         + "'"            #保险公司代码
        sql = sql + " and   workdate = '" + TradeContext.workDate       + "'"            #交易日期
        sql = sql + " and   tellerno = '" + TradeContext.tellerno       + "'"            #交易柜员
        
        AfaLoggerFunc.tradeInfo('查询受益人信息:'+ sql)
        
        results = AfaDBFunc.SelectSql( sql )
        
        if results == None:
            TradeContext.errorCode,TradeContext.errorMsg = "0001" ,"查询受益人信息异常"
            return False
        
        if(len(results) < 1):
            TradeContext.errorCode,TradeContext.errorMsg = "0001","没有找到相关的受益人信息"
            return False
            
        else:
            TradeContext.syr_1 = results[0][0]                        #受益人1信息
            TradeContext.syr_2 = results[0][1]                        #受益人2信息
            TradeContext.syr_3 = results[0][2]                        #受益人3信息
            TradeContext.syr_4 = results[0][3]                        #受益人4信息
            TradeContext.syr_5 = results[0][4]                        #受益人5信息
            
        TradeContext.errorCode = '0000'
        AfaLoggerFunc.tradeInfo('单证重打子查询交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']退出' )
        return True
    
    except Exception, e:
        AfaFlowControl.exitMainFlow(str(e))
Example #50
0
def main( ):
    AfaLoggerFunc.tradeInfo( '凭证作废['+TradeContext.TemplateCode+']进入' )

    #=============前台上送数据===================================
    #TradeContext.sBesbNo                                 机构号
    #TradeContext.sBesbSty                                机构类型
    #TradeContext.sCur                                    货币代码
    #TradeContext.sTellerNo                               柜员号
    #TradeContext.sVouhType                               凭证种类
    #TradeContext.sStartNo                                起始号码
    #TradeContext.sEndNo                                  终止号码
    #TradeContext.sRivTeller                              对方柜员
    #TradeContext.sVouhStatus                             凭证状态
    #TradeContext.sVouhNum                                凭证数量
    #TradeContext.sLstTrxDay                              最后交易日期
    #TradeContext.sLstTrxTime                             最后交易时间
    #TradeContext.sDepository                             库箱标志
    #TradeContext.sVouhName                               凭证名称
       
    try:
        #================拆包========================
        TradeContext.sVouhType = VouhFunc.DelSpace(TradeContext.sVouhType.split("|"))
        TradeContext.sVouhName = VouhFunc.DelSpace(TradeContext.sVouhName.split("|"))
        TradeContext.sStartNo  = VouhFunc.DelSpace(TradeContext.sStartNo.split("|"))
        TradeContext.sEndNo    = VouhFunc.DelSpace(TradeContext.sEndNo.split("|"))
        TradeContext.sVouhNum  = VouhFunc.DelSpace(TradeContext.sVouhNum.split("|"))
        TradeContext.sNum      = len(TradeContext.sVouhType)
        
        #==================暂存==================================
        TradeContext.rVouhType = VouhFunc.AddSplit(TradeContext.sVouhType)
        TradeContext.rVouhName = VouhFunc.AddSplit(TradeContext.sVouhName)
        TradeContext.rStartNo  = VouhFunc.AddSplit(TradeContext.sStartNo)
        TradeContext.rEndNo    = VouhFunc.AddSplit(TradeContext.sEndNo)
        TradeContext.rVouhNum  = VouhFunc.AddSplit(TradeContext.sVouhNum)
    
        #=============初始化返回报文变量========================
        TradeContext.tradeResponse = []
        
        #=============生成流水号========================
        TradeContext.sVouhSerial = VouhFunc.GetVouhSerial( )

        #=============获取当前系统时间==========================
        TradeContext.sLstTrxDay  = AfaUtilTools.GetSysDate( )
        TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( )
        
        #begin凭证优化更改201109  
        #=============获取柜员尾箱号===============================
        HostContext.I1SBNO = TradeContext.sBesbNo         #机构号
        HostContext.I1USID = TradeContext.sTellerNo       #柜员号
        HostContext.I1WSNO = TradeContext.sWSNO           #终端号
        HostContext.I1EDDT = TradeContext.sLstTrxDay      #终止日期
        HostContext.I1TELR = TradeContext.sTellerNo       #柜员代号
        
        if(not VouhHostFunc.CommHost('0104')):
            VouhFunc.tradeExit( TradeContext.errorCode, TradeContext.errorMsg )
            raise AfaFlowControl.flowException( )
        if(TradeContext.errorCode == '0000'):
            TradeContext.sTellerTailNobak = HostContext.O2CABO
            TradeContext.sTellerTailNo    = TradeContext.sTellerTailNobak[0]                 
            AfaLoggerFunc.tradeInfo( '交易柜员尾箱号:' + TradeContext.sTellerTailNo ) 
        #end 
        
        #=============置凭证操作状态及库箱标志====================
        TradeContext.sDepository  = '4' #库箱标志   1.分行管理库 2.支行管理库 3.网点管理库 4.柜员凭证箱
        TradeContext.sExDepos = '4' #原库箱标志

        TradeContext.sVouhStatus  = '6' #状态       3.已领未用 6.已作废
        TradeContext.sExStatus    = '3' #原状态
        TradeContext.sRivTeller   = '   '     #对方柜员
        TradeContext.sTransType    = '凭证作废'
        TradeContext.sInTellerTailNo  = TradeContext.sTellerTailNo
        TradeContext.sInBesbNo    = TradeContext.sBesbNo
        

        #交易公共部分    
        VouhFunc.VouhTrans()

        #更新凭证变更登记表
        VouhFunc.VouhModify()
        
        #数据库提交
        AfaDBFunc.CommitSql( )
        
        #主机记账
        AfaLoggerFunc.tradeInfo( '------------主机记账' )
        TradeContext.sOperSty = '1'
        VouhHostFunc.VouhCommHost()
        TradeContext.sTranStatus = '0'
        AfaLoggerFunc.tradeInfo( '=======================12'+TradeContext.errorCode )
        #TradeContext.errorCode = '0000'
        if(TradeContext.errorCode <> '0000'):
            tmpErrorCode= TradeContext.errorCode
            tmpErrorMsg = TradeContext.errorMsg
        
            #冲正
            
            #=============置凭证操作状态及库箱标志====================
            tmpDepos = TradeContext.sDepository
            TradeContext.sDepository = TradeContext.sExDepos
            TradeContext.sExDepos = tmpDepos

            tmpStatus = TradeContext.sVouhStatus
            TradeContext.sVouhStatus = TradeContext.sExStatus
            TradeContext.sExStatus = tmpStatus

            TradeContext.sRivTeller   = '   '     #对方柜员
            TradeContext.sTransType    = '冲正'
            

            #交易公共部分    
            VouhFunc.VouhTrans()
            AfaDBFunc.CommitSql( )
            
            TradeContext.sTranStatus = '1'
            if(not TradeContext.existVariable( "HostSerno" )):
                TradeContext.HostSerno = ''    
            
            #更新流水表
            VouhFunc.ModifyVouhModify()
            
            AfaLoggerFunc.tradeInfo( '============================自动冲正!' )

            
            VouhFunc.tradeExit(tmpErrorCode, tmpErrorMsg)
            raise AfaFlowControl.flowException( )
        
        #更新流水表
        VouhFunc.ModifyVouhModify()
        
        TradeContext.tradeResponse.append( ['sVouhSerial',TradeContext.sVouhSerial] )
        TradeContext.tradeResponse.append( ['sVouhType',TradeContext.rVouhType] )
        TradeContext.tradeResponse.append( ['sVouhName',TradeContext.rVouhName] )
        TradeContext.tradeResponse.append( ['sStartNo',TradeContext.rStartNo] )
        TradeContext.tradeResponse.append( ['sEndNo',TradeContext.rEndNo] )
        TradeContext.tradeResponse.append( ['sVouhNum',TradeContext.rVouhNum] )
        TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] )
        TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] )
        TradeContext.tradeResponse.append( ['sNum',str(TradeContext.sNum)] )
        TradeContext.tradeResponse.append( ['errorCode','0000'] )
        TradeContext.tradeResponse.append( ['errorMsg','交易成功'] )

        #自动打包
        AfaFunc.autoPackData()

        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '凭证作废['+TradeContext.TemplateCode+']退出' )
    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( )
Example #51
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.差错抹账[8571] 进入")
    
    AfaLoggerFunc.tradeInfo("<<<<<<<个性化处理(本地操作) 进入")
    
    #=====校验变量的合法性====
    AfaLoggerFunc.tradeInfo("<<<<<<校验变量的合法性")   
    if not TradeContext.existVariable("TRCDAT"):
        return AfaFlowControl.ExitThisFlow('A099','没有委托日期')
        
    if not TradeContext.existVariable("SNDBNKCO"):
        return AfaFlowControl.ExitThisFlow('A099','没有发送行号')
        
    if not TradeContext.existVariable("TRCNO"):
        return AfaFlowControl.ExitThisFlow('A099','没有交易流水号')
        
    AfaLoggerFunc.tradeInfo("<<<<<<校验变量的合法性结束")
    
    #=====产生FEDT,RBSQ,NCCworkDate,BJEDTE====
    TradeContext.BJEDTE = AfaUtilTools.GetHostDate( )   #BJEDTE
    
    TradeContext.FEDT=AfaUtilTools.GetHostDate( )    #FEDT
    
    if not rccpsFunc.GetNCCDate( ) :                   #NCCworkDate
        raise AfaFlowControl.flowException( )
    
    if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 :   #RBSQ
        return AfaFlowControl.ExitThisFlow('A099','产生前置流水号失败')
    
    #=====查询交易信息====
    AfaLoggerFunc.tradeInfo("<<<<<<开始查询通存通兑业务登记簿")
    where_dict = {}
    where_dict = {'TRCNO':TradeContext.TRCNO,'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT}
    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("<<<<<<查询通存通兑业务登记簿成功")
            
    #=====查询错账登记簿======
    AfaLoggerFunc.tradeInfo("<<<<<<开始查询错账登记簿")
    where_dict = {}
    where_dict = {'TRCNO':TradeContext.TRCNO,'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT}
    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']
        insert_dict['DCFLG']      = wtrbka_record_dict['DCFLG']
        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']     = ""
        insert_dict['EACINF']     = ""
        insert_dict['LOCEACTYP']  = ""
        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','向错账登记簿中补记交易失败')
            
        #=====补查错账登记簿,将刚插入的数据查出来====
        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):
            return AfaFlowControl.ExitThisFlow('A099','查询通错账登记簿结果为空')
        else:
            AfaLoggerFunc.tradeInfo("<<<<<<补查错账登记簿成功")
        
    else:
        AfaLoggerFunc.tradeInfo("<<<<<<查询错账登记簿成功")
    
    #=====判断此笔业务是否已经处理====
    if(tddzcz_record_dict['ISDEAL'] == PL_ISDEAL_ISDO):
        return AfaFlowControl.ExitThisFlow('A099','此笔账务已经处理过')
        
    #=====开始行内抹账====
    AfaLoggerFunc.tradeInfo("<<<<<<开始行内抹账")
    input_dict = {}   
    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']
    input_dict['RCCSMCD'] = PL_RCCSMCD_CX
    TradeContext.NCCworkDate = wtrbka_record_dict['NCCWKDAT']
    TradeContext.BESBNO = wtrbka_record_dict['BESBNO']
    TradeContext.BETELR = PL_BETELR_AUTO
    TradeContext.TERMID = wtrbka_record_dict['TERMID']
        
    #=====判断原交易的往来标示====
    AfaLoggerFunc.tradeInfo("<<<<<<判断原交易是来账还是往账")
    if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_SND):
        AfaLoggerFunc.tradeInfo("<<<<<原业务为往账")
        
        TradeContext.BRSFLG   = PL_BRSFLG_SND
        
        if(wtrbka_record_dict['TRCCO'] in ('3000002','3000004')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通存往账抹账")
            rccpsEntriesErr.KZTCWZMZ(input_dict)
        
        elif(wtrbka_record_dict['TRCCO'] in ('3000003','3000005')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折本转异往账抹账")
            rccpsEntriesErr.KZBZYWZMZ(input_dict)
            
        elif(wtrbka_record_dict['TRCCO'] in ('3000102','3000104')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通兑往账抹账")
            rccpsEntriesErr.KZTDWZMZ(input_dict)
            
        elif(wtrbka_record_dict['TRCCO'] in ('3000103','3000105')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折异转本往账抹账")    
            rccpsEntriesErr.KZYZBWZMZ(input_dict)     
            
        else:
            return AfaFlowControl.ExitThisFlow('S999','非法交易代码')
            
    else:
        AfaLoggerFunc.tradeInfo("<<<<<原业务为来账")      
        
        TradeContext.BRSFLG   = PL_BRSFLG_RCV

        if(wtrbka_record_dict['TRCCO'] in ('3000002','3000004')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通存来账抹账")
            rccpsEntriesErr.KZTCLZMZ(input_dict)
        
        elif(wtrbka_record_dict['TRCCO'] in ('3000003','3000005')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折本转异来账抹账")
            rccpsEntriesErr.KZBZYLZMZ(input_dict)
            
        elif(wtrbka_record_dict['TRCCO'] in ('3000102','3000104')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通兑来账抹账")
            rccpsEntriesErr.KZTDLZMZ(input_dict)
            
        elif(wtrbka_record_dict['TRCCO'] in ('3000103','3000105')):
            AfaLoggerFunc.tradeDebug("<<<<<<卡折异转本来账抹账")    
            rccpsEntriesErr.KZYZBLZMZ(input_dict)     
            
        else:
            return AfaFlowControl.ExitThisFlow('S999','非法交易代码')
            
    #=====判断当前状态是否允许抹账====
#    AfaLoggerFunc.tradeInfo("<<<<<<判断交易当前状态是否允许抹账")
#    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_HCAC,PL_BCSTAT_CANC,PL_BCSTAT_CANCEL) and stat_dict['BDWFLG'] == PL_BDWFLG_SUCC):
#        return AfaFlowControl.ExitThisFlow('S999','原业务当前状态不需要抹账,请手工更改处理标识')
    
    
    acc = 0 
    autopay = 0
    auto = 0   
    hcac = 0    
    canc = 0
    cancel = 0
    #=====查询是否有记账成功的状态====
    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_AUTOPAY,PL_BDWFLG_SUCC,sstlog_list):
        autopay = len(sstlog_list)
    sstlog_list = []
    if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_AUTO,PL_BDWFLG_SUCC,sstlog_list):
        auto = 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 + autopay + auto) - (hcac + canc + cancel) <= 0):
        return AfaFlowControl.ExitThisFlow('S999','此交易未记账或已抹账,禁止提交')
        
    AfaLoggerFunc.tradeInfo("<<<<<<结束判断交易当前状态是否允许抹账")
            
        
    #=====在上主机前设置原交易的状态====
    AfaLoggerFunc.tradeInfo("<<<<<<在上主机前设置原交易的状态")
    if not rccpsState.newTransState(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_HCAC,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'] = PL_BCSTAT_HCAC
    state_dict['MGID']   = TradeContext.errorCode
    state_dict['STRINFO']= TradeContext.errorMsg
    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.tradeDebug("主机抹账失败")
        #=====主机后更改原交易为失败====
        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("<<<<<<主机抹账成功")
        
    #=====主机后更改原交易状态=====
    AfaLoggerFunc.tradeInfo("<<<<<<主机后更改原交易为成功")
    state_dict['BDWFLG'] = PL_BDWFLG_SUCC
    state_dict['STRINFO'] = '主机成功'
    if not rccpsState.setTransState(state_dict):
        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.BRSFLG     = wtrbka_record_dict['BRSFLG']
    TradeContext.TRCCO      = wtrbka_record_dict['TRCCO']
    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.tradeDebug("<<<<<<OROCCAMT="+str(TradeContext.OROCCAMT))
    AfaLoggerFunc.tradeInfo("<<<<<<结束给输出接口赋值")
        
    AfaLoggerFunc.tradeInfo("<<<<<<<个性化处理(本地操作) 退出")
    
    AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.差错抹账[8571] 退出")
    
    return True
Example #52
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo("个性化处理(本地操作)")
    
    #=====校验变量的合法性====
    if( not TradeContext.existVariable( "BJEDTE" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '交易日期不存在')
    
    if( not TradeContext.existVariable( "BSPSQN" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '报单序号不存在')
        
    #=====组织查询字典====
    where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'BESBNO':TradeContext.BESBNO}
    
    #=====开始查询通存通兑业务登记簿====
    AfaLoggerFunc.tradeInfo("开始查询通存通兑业务登记簿")
    record = rccpsDBTrcc_wtrbka.selectu(where_dict)
    if( record == None ):
        return AfaFlowControl.ExitThisFlow('A099', '查询通存通兑业务登记簿失败')
        
    elif( len(record) == 0 ):
        return AfaFlowControl.ExitThisFlow('A099', '查询通存通兑业务登记簿为空')
        
    else:
#        #=====判断是否为往账业务====
#        if( record['BRSFLG'] == PL_BRSFLG_RCV ):
#            return AfaFlowControl.ExitThisFlow('A099', '该笔业务不是往账业务')
            
        #=====开始组织输出接口====
        AfaLoggerFunc.tradeInfo("开始组织输出接口")    
          
        TradeContext.BJEDTE     = record['BJEDTE']
        TradeContext.BSPSQN     = record['BSPSQN']
        TradeContext.BRSFLG     = record['BRSFLG']
        TradeContext.BESBNO     = record['BESBNO']   
        TradeContext.BETELR     = record['BETELR']
        TradeContext.BEAUUS     = record['BEAUUS']
        TradeContext.DCFLG      = record['DCFLG']
        TradeContext.OPRNO      = record['OPRNO']
        TradeContext.NCCWKDAT   = record['NCCWKDAT']
        TradeContext.TRCCO      = record['TRCCO']
        TradeContext.TRCDAT     = record['TRCDAT']
        TradeContext.TRCNO      = record['TRCNO']
        TradeContext.COTRCNO    = record['COTRCNO']
        TradeContext.SNDMBRCO   = record['SNDMBRCO']
        TradeContext.RCVMBRCO   = record['RCVMBRCO']
        TradeContext.SNDBNKCO   = record['SNDBNKCO']
        TradeContext.SNDBNKNM   = record['SNDBNKNM']
        TradeContext.RCVBNKCO   = record['RCVBNKCO']
        TradeContext.RCVBNKNM   = record['RCVBNKNM']
        TradeContext.CUR        = record['CUR']
        TradeContext.OCCAMT     = str(record['OCCAMT'])
        TradeContext.CHRGTYP    = record['CHRGTYP']
        TradeContext.CUSCHRG    = str(record['CUSCHRG'])
        TradeContext.PYRACC     = record['PYRACC']
        TradeContext.PYRNAM     = record['PYRNAM']
        TradeContext.PYEACC     = record['PYEACC']
        TradeContext.PYENAM     = record['PYENAM']
        TradeContext.STRINFO    = record['STRINFO']
        TradeContext.CERTTYPE   = record['CERTTYPE']
        TradeContext.CERTNO     = record['CERTNO']
        TradeContext.BNKBKNO    = record['BNKBKNO']
        TradeContext.BNKBKBAL   = str(record['BNKBKBAL'])
        
    TradeContext.errorCode = '0000'
    TradeContext.errorMsg  = '交易成功'
    
    return True
        
Example #53
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.中心类操作(1.本地操作).自动冲正[TRCC003_8582]进入***' )
    
    #=====校验变量的合法性====
    if not TradeContext.existVariable("BOJEDT"):
        return AfaFlowControl.ExitThisFlow('A099','原交易日期不能为空')  
        
    if not TradeContext.existVariable("BOSPSQ"):
        return AfaFlowControl.ExitThisFlow('A099','原报单序号不能为空')
        
    #if not TradeContext.existVariable("RESNNM"):
    #    return AfaFlowControl.ExitThisFlow('A099','冲正原因不能为空')
    
    #查询原交易信息
    trc_dict = {}
    
    if rccpsDBFunc.getTransWtr(TradeContext.BOJEDT,TradeContext.BOSPSQ,trc_dict):
        AfaLoggerFunc.tradeInfo(">>>通存通兑登记簿中找到原交易")
        
    elif rccpsDBFunc.getTransMpc(TradeContext.BOJEDT,TradeContext.BOSPSQ,trc_dict):
        AfaLoggerFunc.tradeInfo(">>>冲销登记簿中找到原交易")
        
    else:
        return AfaFlowControl.ExitThisFlow("S999","无此交易")
        
    #判断原交易是否为往账
    if( trc_dict['BRSFLG'] != PL_BRSFLG_SND):
        return AfaFlowControl.ExitThisFlow('A099','此交易非往账,禁止冲正')
        
    #判断被冲销交易的日期是否为当日
    if( trc_dict['NCCWKDAT'] != TradeContext.NCCworkDate ):
        return AfaFlowControl.ExitThisFlow('A099','此交易非当日交易,禁止冲正')
        
    #判断当前机构是否为原交易机构
    if( trc_dict['BESBNO'] != TradeContext.BESBNO ):
        return AfaFlowControl.ExitThisFlow('A099','当前机构非原交易机构,禁止冲正')
    
    #判断当前柜员是否为原交易柜员
    if( trc_dict['BETELR'] != TradeContext.BETELR ):
        return AfaFlowControl.ExitThisFlow('A099','当前柜员非原交易柜员,禁止冲正')
        
    if trc_dict['TRCCO'] in('3000002','3000003','3000004','3000005','3000102','3000103','3000104','3000105','3000505'):
        AfaLoggerFunc.tradeInfo(">>>原交易为通存或通兑账务类交易")
        
        #判断原交易当前状态是否可以冲正
        #原交易当前状态为:发送处理中,发送成功,记账失败,允许冲正
        if not ((trc_dict['BCSTAT'] == PL_BCSTAT_SND and (trc_dict['BDWFLG'] == PL_BDWFLG_WAIT or trc_dict['BDWFLG'] == PL_BDWFLG_SUCC)) or (trc_dict['BCSTAT'] == PL_BCSTAT_ACC) and trc_dict['BDWFLG'] == PL_BDWFLG_FAIL):
            return AfaFlowControl.ExitThisFlow("S999","此交易当前状态为[" + trc_dict['BCSTAT'] + "][" + trc_dict['BDWFLG'] + "],禁止冲正")
        
        #登记冲正登记簿
        AfaLoggerFunc.tradeInfo(">>>开始登记冲正登记簿")
        
        TradeContext.SNDMBRCO = TradeContext.SNDSTLBIN
        TradeContext.RCVMBRCO = trc_dict['RCVMBRCO']
        TradeContext.ORTRCDAT = trc_dict['TRCDAT']
        TradeContext.OPRNO    = PL_TDOPRNO_CZ
        TradeContext.NCCWKDAT = TradeContext.NCCworkDate
        TradeContext.MSGFLGNO = TradeContext.SNDSTLBIN + TradeContext.NCCworkDate + TradeContext.SerialNo
        TradeContext.ORMFN    = trc_dict['MSGFLGNO']
        TradeContext.TRCCO    = "3000506" 
        TradeContext.TRCNO    = TradeContext.SerialNo
        TradeContext.ORTRCCO  = trc_dict['TRCCO']
        TradeContext.ORTRCNO  = trc_dict['TRCNO']
        TradeContext.SNDBNKCO = trc_dict['SNDBNKCO']
        TradeContext.SNDBNKNM = trc_dict['SNDBNKNM']
        TradeContext.RCVBNKCO = trc_dict['RCVBNKCO']
        TradeContext.RCVBNKNM = trc_dict['RCVBNKNM']
        
        insert_dict = {}
        
        rccpsMap8582CTradeContext2Datcbka_dict.map(insert_dict)
        
        ret = rccpsDBTrcc_atcbka.insertCmt(insert_dict)
        
        if( ret <= 0 ):
            return AfaFlowControl.ExitThisFlow('S999','登记自动冲正登记簿失败')
        
        AfaLoggerFunc.tradeInfo(">>>结束登记冲正登记簿")
        
        #若原交易当前状态非冲正处理中,则设置原交易状态为冲正处理中
        #if not (trc_dict['BCSTAT'] == PL_BCSTAT_CANCEL and trc_dict['BDWFLG'] == PL_BDWFLG_WAIT):
        #    AfaLoggerFunc.tradeInfo(">>>开始设置原交易状态为冲正处理中")
        #    
        #    if not rccpsState.newTransState(trc_dict['BJEDTE'],trc_dict['BSPSQN'],PL_BCSTAT_CANCEL,PL_BDWFLG_WAIT):
        #        return AfaFlowControl.ExitThisFlow("S999","设置原交易当前状态为冲正处理中异常")
        #
        #    AfaLoggerFunc.tradeInfo(">>>结束设置原交易状态为冲正处理中")
        #    
        #if not AfaDBFunc.CommitSql( ):
        #    AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        #    return AfaFlowControl.ExitThisFlow("S999","Commit异常")
            
        #为冲正报文做准备
        #=====报文头====
        TradeContext.MSGTYPCO = 'SET009'
        TradeContext.RCVSTLBIN= trc_dict['RCVMBRCO']
        #TradeContext.SNDBRHCO = TradeContext.BESBNO
        #TradeContext.SNDCLKNO = TradeContext.BETELR
        #TradeContext.SNDTRDAT = TradeContext.BJEDTE
        #TradeContext.SNDTRTIM = TradeContext.BJETIM
        #TradeContext.MSGFLGNO = TradeContext.SNDSTLBIN + TradeContext.TRCDAT + TradeContext.SerialNo
        #TradeContext.ORMFN    = wtr_dict['MSGFLGNO']
        #TradeContext.NCCWKDAT = TradeContext.NCCworkDate
        TradeContext.OPRTYPNO = "30"
        TradeContext.ROPRTPNO = "30"
        TradeContext.TRANTYP  = "0"
        #=====业务要素集====
        TradeContext.CUR      = trc_dict['CUR']
        TradeContext.OCCAMT   = str(trc_dict['OCCAMT'])
        
        #手续费处理
        if trc_dict['TRCCO'] == '3000002' or trc_dict['TRCCO'] == '3000003' or trc_dict['TRCCO'] == '3000004' or trc_dict['TRCCO'] == '3000005':
            TradeContext.CUSCHRG  = "0.00"
        elif trc_dict['TRCCO'] == '3000102' or trc_dict['TRCCO'] == '3000103' or trc_dict['TRCCO'] == '3000104' or trc_dict['TRCCO'] == '3000105':
            if trc_dict['CHRGTYP'] == '1':
                TradeContext.CUSCHRG = str(trc_dict['CUSCHRG'])
            else:
                TradeContext.CUSCHRG = '0.00'
                
        TradeContext.PYRACC   = trc_dict['PYRACC']
        TradeContext.PYRNAM   = trc_dict['PYRNAM']
        TradeContext.PYEACC   = trc_dict['PYEACC']
        TradeContext.PYENAM   = trc_dict['PYENAM']
        TradeContext.CURPIN   = ""
        TradeContext.STRINFO  = ""
        TradeContext.PRCCO    = ""
        #=====扩展要素集====
        TradeContext.RESNCO = TradeContext.RESNNM  
        
        
    elif trc_dict['TRCCO'] == '3000504':
        AfaLoggerFunc.tradeInfo(">>>原交易为冲销交易")
        
        if trc_dict['PRCCO'].lstrip() != "":
            return AfaFlowControl.ExitThisFlow("S999","已收到冲销应答,禁止冲正此冲销交易")
        
        wtr_dict = {}
        
        if not rccpsDBFunc.getTransWtr(trc_dict['BOJEDT'],trc_dict['BOSPSQ'],wtr_dict):
            return AfaFlowControl.ExitThisFlow("S999","通存通兑登记簿中未找到原被冲销交易")
            
        #若原被冲销交易当前状态为冲销,禁止冲正此冲销交易
        if wtr_dict['BCSTAT'] == PL_BCSTAT_CANC:
            return AfaFlowControl.ExitThisFlow("S999","原被冲销交易已被冲销成功或失败,禁止冲正此冲销交易")
            
        #登记冲正登记簿
        AfaLoggerFunc.tradeInfo(">>>开始登记冲正登记簿")
        
        TradeContext.SNDMBRCO = TradeContext.SNDSTLBIN
        TradeContext.RCVMBRCO = trc_dict['RCVMBRCO']
        TradeContext.ORTRCDAT = trc_dict['TRCDAT']
        TradeContext.OPRNO    = PL_TDOPRNO_CZ
        TradeContext.NCCWKDAT = TradeContext.NCCworkDate
        TradeContext.MSGFLGNO = TradeContext.SNDSTLBIN + TradeContext.NCCworkDate + TradeContext.SerialNo
        TradeContext.ORMFN    = trc_dict['MSGFLGNO']
        TradeContext.TRCCO    = "3000506"
        TradeContext.TRCNO    = TradeContext.SerialNo
        TradeContext.ORTRCCO  = trc_dict['TRCCO']
        TradeContext.ORTRCNO  = trc_dict['TRCNO']
        TradeContext.SNDBNKCO = trc_dict['SNDBNKCO']
        TradeContext.SNDBNKNM = trc_dict['SNDBNKNM']
        TradeContext.RCVBNKCO = trc_dict['RCVBNKCO']
        TradeContext.RCVBNKNM = trc_dict['RCVBNKNM']
        
        insert_dict = {}
        
        rccpsMap8582CTradeContext2Datcbka_dict.map(insert_dict)
        
        ret = rccpsDBTrcc_atcbka.insertCmt(insert_dict)
        
        if( ret <= 0 ):
            return AfaFlowControl.ExitThisFlow('S999','登记自动冲正登记簿失败')
        
        AfaLoggerFunc.tradeInfo(">>>结束登记冲正登记簿")
        
        #为冲正报文做准备
        #=====报文头====
        TradeContext.MSGTYPCO = 'SET009'
        TradeContext.RCVSTLBIN= trc_dict['RCVMBRCO']
        #TradeContext.SNDBRHCO = TradeContext.BESBNO
        #TradeContext.SNDCLKNO = TradeContext.BETELR
        #TradeContext.SNDTRDAT = TradeContext.BJEDTE
        #TradeContext.SNDTRTIM = TradeContext.BJETIM
        #TradeContext.MSGFLGNO = TradeContext.SNDSTLBIN + TradeContext.TRCDAT + TradeContext.SerialNo
        #TradeContext.ORMFN    = wtr_dict['MSGFLGNO']
        #TradeContext.NCCWKDAT = TradeContext.NCCworkDate
        TradeContext.OPRTYPNO = "30"
        TradeContext.ROPRTPNO = "30"
        TradeContext.TRANTYP  = "0"
        #=====业务要素集====
        TradeContext.CUR      = wtr_dict['CUR']
        TradeContext.OCCAMT   = str(wtr_dict['OCCAMT'])
        
        #手续费处理
        if wtr_dict['TRCCO'] == '3000002' or wtr_dict['TRCCO'] == '3000003' or wtr_dict['TRCCO'] == '3000004' or wtr_dict['TRCCO'] == '3000005':
            TradeContext.CUSCHRG  = "0.00"
        elif wtr_dict['TRCCO'] == '3000102' or wtr_dict['TRCCO'] == '3000103' or wtr_dict['TRCCO'] == '3000104' or wtr_dict['TRCCO'] == '3000105':
            if wtr_dict['CHRGTYP'] == '1':
                TradeContext.CUSCHRG = str(wtr_dict['CUSCHRG'])
            else:
                TradeContext.CUSCHRG = '0.00'
                
        TradeContext.PYRACC   = wtr_dict['PYRACC']
        TradeContext.PYRNAM   = wtr_dict['PYRNAM']
        TradeContext.PYEACC   = wtr_dict['PYEACC']
        TradeContext.PYENAM   = wtr_dict['PYENAM']
        TradeContext.CURPIN   = ""
        TradeContext.STRINFO  = ""
        TradeContext.PRCCO    = ""
        #=====扩展要素集====
        TradeContext.RESNCO = TradeContext.RESNNM  
        
    else:
        return AfaFlowControl.ExitThisFlow("S999","原交易非通存或通兑账务类交易或冲销交易,禁止冲正")
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.中心类操作(1.本地操作).自动冲正[TRCC003_8582]进入***' )
    
    return True
Example #54
0
def SubModuleDoSnd():
    #=====判断afe返回====
    if TradeContext.errorCode != '0000':
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode,TradeContext.errorMsg)
    
    return True
Example #55
0
                sStartNo = sStartNo + strSplit + records[i][2]
                sEndNo = sEndNo + strSplit + records[i][3]
                sVouhNum = sVouhNum + strSplit + records[i][4]
                
        TradeContext.tradeResponse.append( ['sVouhType',sVouhType] )
        TradeContext.tradeResponse.append( ['sVouhName',sVouhName] )
        TradeContext.tradeResponse.append( ['sTellerNo',TradeContext.sTellerNo] )
        TradeContext.tradeResponse.append( ['sInTellerNo',TradeContext.sInTellerNo] )
        TradeContext.tradeResponse.append( ['sStartNo',sStartNo] )
        TradeContext.tradeResponse.append( ['sEndNo',sEndNo] )
        TradeContext.tradeResponse.append( ['sVouhNum',sVouhNum] )
        TradeContext.tradeResponse.append( ['sNum',str(total)] )
        TradeContext.tradeResponse.append( ['sVouhSerial',TradeContext.sVouhSerial] )
        TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] )
        TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] )
        TradeContext.tradeResponse.append( ['errorCode','0000'] )
        TradeContext.tradeResponse.append( ['errorMsg','交易成功'] )

        #自动打包
        AfaFunc.autoPackData()

        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '凭证柜员交接['+TradeContext.TemplateCode+']退出' )
    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( )
    except AfaFlowControl.accException:
        AfaFlowControl.exitMainFlow( )
    except Exception, e:
        AfaFlowControl.exitMainFlow(str(e))

Example #56
0
def SubModuleMainFst( ):

    #=====刘雨龙  20080811  新增查找fa15表中财政区划内码,条件为单位内码====
    AfaLoggerFunc.tradeInfo( ">>>AFA050=" + TradeContext.busiNo)
    sql = "select AAA010 from fs_fa22 where busino='" + TradeContext.busiNo + "'"

    #begin 20100629 蔡永贵增加查询条件
    sql = sql + " and afa101 = '" + TradeContext.bankbm + "'"
    AfaLoggerFunc.tradeInfo( sql )
    #end

    ret = AfaDBFunc.SelectSql( sql )
    if ret == None:
        return AfaFlowControl.ExitThisFlow('0001','通过单位内码查找财政区划内码失败')
    elif len(ret) <= 0:
        return AfaFlowControl.ExitThisFlow('0001','通过单位内码查找财政区划内码无满足条件记录')
    else:
        TradeContext.AAA010  =  ret[0][0]
        
    TradeContext.__agentEigen__  = '0'   #从表标志
    
    AfaLoggerFunc.tradeInfo( "中台查找数据库开始" )
        
    #在中台数据库中查询
    #=====刘雨龙  20080811  新增条件财政区划内码====
    #sqlstr = "select AFC306,AAA010,AFA050,AFC041,AFC061,AFC062,AFC063,AFC064,AAZ016,AAZ015 from FS_FC06 where AFC060='" + TradeContext.AFC060 + "'"
    
    sqlstr = "select AFC306,AAA010,AFA050,AFC041,AFC061,AFC062,AFC063,AFC064,AAZ016,AAZ015 from FS_FC06 where AFC060='" + TradeContext.AFC060 + "'"
    sqlstr = sqlstr + " AND AAA010 = '" + TradeContext.AAA010 + "'"
    
    AfaLoggerFunc.tradeInfo( sqlstr )
    records = AfaDBFunc.SelectSql( sqlstr )
    if( records == None or len( records)==0 ):
        TradeContext.errorCode  =   "0001"
        TradeContext.errorMsg   =   "查找退付信息失败"
        AfaLoggerFunc.tradeInfo( "***************中台查找数据库结束*******************" )
        return False

    elif ( len( records )==1 ):

        #将查找到的信息赋值到TradeContext中
        TradeContext.AFC306     =   records[0][0]
        TradeContext.AAA010     =   records[0][1]
        TradeContext.AFA050     =   records[0][2]
        TradeContext.AFC041     =   records[0][3]
        TradeContext.AFC061     =   records[0][4]
        TradeContext.AFC062     =   records[0][5]
        TradeContext.AFC063     =   records[0][6]
        TradeContext.AFC064     =   records[0][7]
        TradeContext.AAZ016     =   records[0][8]
        TradeContext.AAZ015     =   records[0][9]
        
        if not (TradeContext.AAZ015.strip()  == '1') :
            TradeContext.errorCode  =   "0001"
            TradeContext.errorMsg   =   "该退付编号不能退付"
            return False 
        
        #根据财政区划内码查询财政区划
        
        if TradeContext.AAA010 :
            sqlstr  =   ""
            sqlstr  =   "select aaa012 from fs_aa11 where aaa010='" + TradeContext.AAA010 + "'"
            records = AfaDBFunc.SelectSql( sqlstr )
            if( records == None or len( records)==0 ):
                TradeContext.errorCode  =   "0001"
                TradeContext.errorMsg   =   "查找财政区划失败"
                AfaLoggerFunc.tradeInfo( TradeContext.errorMsg )
                return False
            else:   
                TradeContext.AAA012     =   records[0][0]
        else:
            TradeContext.AAA012         =   ''
            
        #根据执收单位内码查询征收单位名称
        if TradeContext.AFA050:
            sqlstr  =   ""
            sqlstr  =   "select afa052 from fs_fa15 where afa050='" + TradeContext.AFA050 + "'"
            AfaLoggerFunc.tradeInfo( sqlstr )
            records = AfaDBFunc.SelectSql( sqlstr )
            if( records == None or len( records)==0 ):
                TradeContext.errorCode  =   "0001"
                TradeContext.errorMsg   =   "查找执收单位名称失败"
                AfaLoggerFunc.tradeInfo( TradeContext.errorMsg )
                return False
            else:   
                TradeContext.AFA052     =   records[0][0]
        else:
            TradeContext.AFA052         =   ''
            
        #根据收费项目内码查询收费项目名称
        if TradeContext.AFC041 :
            sqlstr  =   ""
            sqlstr  =   "select afa032 from fs_fa13 where afa030='" + TradeContext.AFC041 + "'"
            AfaLoggerFunc.tradeInfo( sqlstr )
            records = AfaDBFunc.SelectSql( sqlstr )
            if( records == None or len( records)==0 ):
                TradeContext.errorCode  =   "0001"
                TradeContext.errorMsg   =   "查找项目名称名称失败"
                AfaLoggerFunc.tradeInfo( TradeContext.errorMsg )
                return False
            else:   
                TradeContext.AFA032     =   records[0][0]
        else:
            TradeContext.AFA032         =   ''       
        
        TradeContext.errorCode  =   "0000"
        TradeContext.errorMsg   =   "查找退付信息成功"
        AfaLoggerFunc.tradeInfo( "********************中台查找数据库结束***************" )
        return True
        
    else:
        TradeContext.errorCode  =   "9999"
        TradeContext.errorMsg   =   "发现多条退付记录,不能进行退付操作(请检查数据)"
        return False
Example #57
0
     raise AfaFlowControl.flowException( )
         
 #=====================外调接口(前处理)==================================
 subModuleExistFlag=0
 subModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode
 try:
     subModuleHandle=__import__( subModuleName )
     
 except Exception, e:
     AfaLoggerFunc.tradeInfo( e)
     
 else:
     AfaLoggerFunc.tradeInfo( '执行['+subModuleName+']模块' )
     subModuleExistFlag=1
     if not subModuleHandle.SubModuleDoFst( ) :
         raise AfaFlowControl.flowException( )
         
         
 #=====================校验公共节点的有效性==============================
 if( not AfaFunc.Pay_ChkVariableExist( ) ):
     raise AfaFlowControl.flowException( )
                
                 
 #=====================判断商户状态======================================
 if not AfaFunc.ChkUnitStatus( ) :
     raise AfaFlowControl.flowException( )
                
                                    
 #=====================判断渠道状态======================================
 if not AfaFunc.ChkChannelStatus( ) :
     raise AfaFlowControl.flowException( )
Example #58
0
def SubModuleDoFst():    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易[TRC001_8526]进入***' )
        
    #=====得到起始笔数====
    start_no=TradeContext.RECSTRNO
        
    #=====组织sql语句====
    wheresql=""
    wheresql = wheresql + "NOTE3='" + TradeContext.BESBNO + "' and "
    
    #=====判断起始时间是否为空====
    if (TradeContext.STRDAT != "00000000"):
        wheresql = wheresql + "BILDAT>='"+TradeContext.STRDAT+"' and "

    #=====判断终止时间是否为空====
    if (TradeContext.ENDDAT != "00000000"):
        wheresql=wheresql+" BILDAT<='"+TradeContext.ENDDAT+"' and "
    
    #=====判断汇票类别是否为空====
    if (TradeContext.BILTYP != ""):
        wheresql=wheresql+" BILTYP='"+TradeContext.BILTYP+"' and "
    
    #=====判断汇票状态是否为空====
    if (TradeContext.HPSTAT != ""):
        wheresql=wheresql+" HPSTAT='"+TradeContext.HPSTAT+"' and "

    #=====判断兑付方式是否为空==== 
    if (TradeContext.PAYWAY != ""):
        wheresql=wheresql+" PAYWAY='"+TradeContext.PAYWAY+"' and "

    #=====判断汇票本行他行标识是否为空====
    if(TradeContext.BILRS !="" ):
        wheresql=wheresql+" BILRS='"+TradeContext.BILRS+"' and "

    #=====判断汇票版本号是否为空====        
    if(TradeContext.BILVER!="" ):
        wheresql=wheresql+" BILVER='"+TradeContext.BILVER+"' and "

    #=====判断汇票号码是否为空====        
    if(TradeContext.BILNO!="" ):
        wheresql=wheresql+" BILNO='"+TradeContext.BILNO+"' and "

    #=====判断出票金额是否为0====        
    if((TradeContext.BILAMT).strip() != '0.00' ):
        wheresql = wheresql + " BILAMT=" + str(TradeContext.BILAMT) + ' and '
    
    #=====去除sql查询语句最后4位"end "====    
    wheresql = wheresql[:-4]
        
    #=====开始查询总笔数====
    allcount=rccpsDBTrcc_bilinf.count(wheresql)
    
    if(allcount<0):
        return AfaFlowControl.ExitThisFlow('A099','查找总记录数失败' )
        
    #=====开始查询明细====
    ordersql = " order by BILNO DESC"
    records=rccpsDBTrcc_bilinf.selectm(start_no,10,wheresql,ordersql)
    
    if(records==None):
        return AfaFlowControl.ExitThisFlow('A099','查询异常' )
        
    elif(len(records)==0):
        return AfaFlowControl.ExitThisFlow('S999','无对应记录' )
        
    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('S999','打开文件失败')
        
        for i in range(0,len(records)):            
            #=====生成文件内容====
            AfaLoggerFunc.tradeDebug ("生成文件内容 ")
            
            filecontext = ""
            filecontext = filecontext + records[i]['BILVER']      + "|"    #汇票版本号
            filecontext = filecontext + records[i]['BILNO']       + "|"    #汇票号码
            filecontext = filecontext + records[i]['BILRS']       + "|"    #汇票本行他行标识
            filecontext = filecontext + records[i]['BILTYP']      + "|"    #汇票类别
            filecontext = filecontext + records[i]['BILDAT']      + "|"    #汇票日期
            filecontext = filecontext + records[i]['PAYWAY']      + "|"    #兑付方式
            filecontext = filecontext + records[i]['REMBNKCO']    + "|"    #出票行行号
            filecontext = filecontext + records[i]['REMBNKNM']    + "|"    #出票行行名
            filecontext = filecontext + records[i]['PAYBNKCO']    + "|"    #代理付款行行号
            filecontext = filecontext + records[i]['PAYBNKNM']    + "|"    #代理付款行行名
            filecontext = filecontext + records[i]['PYRACC']      + "|"    #出票人账号
            filecontext = filecontext + records[i]['PYRNAM']      + "|"    #出票人户名
            filecontext = filecontext + records[i]['PYRADDR']     + "|"    #出票人地址
            filecontext = filecontext + records[i]['PYEACC']      + "|"    #收款人账号
            filecontext = filecontext + records[i]['PYENAM']      + "|"    #收款人户名
            filecontext = filecontext + records[i]['PYEADDR']     + "|"    #收款人地址
            filecontext = filecontext + records[i]['PYHACC']      + "|"    #持票人账号
            filecontext = filecontext + records[i]['PYHNAM']      + "|"    #持票人户名
            filecontext = filecontext + records[i]['PYHADDR']     + "|"    #持票人地址
            filecontext = filecontext + records[i]['PYITYP']      + "|"    #入账账户类型
            filecontext = filecontext + records[i]['PYIACC']      + "|"    #入账账户账号
            filecontext = filecontext + records[i]['PYINAM']      + "|"    #入账账户户名
            filecontext = filecontext + records[i]['CUR']         + "|"    #币种
            filecontext = filecontext + str(records[i]['BILAMT']) + "|"    #出票金额
            filecontext = filecontext + str(records[i]['OCCAMT']) + "|"    #实际结算金额
            filecontext = filecontext + str(records[i]['RMNAMT']) + "|"    #结余金额
            filecontext = filecontext + records[i]['SEAL']        + "|"    #密押
            filecontext = filecontext + records[i]['USE']         + "|"    #用途
            filecontext = filecontext + records[i]['REMARK']      + "|"    #备注
            filecontext = filecontext + records[i]['HPSTAT']      + "|"    #汇票状态

            f.write(filecontext+"\n")
            
        f.close()
        
    #=====输出接口====
    TradeContext.PBDAFILE=filename              #文件名
    TradeContext.RECCOUNT=str(len(records))     #查询笔数
    TradeContext.RECALLCOUNT=str(allcount)      #总笔数
    TradeContext.errorCode="0000"
    TradeContext.errorMsg="查询成功"
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易[TRC001_8526]退出***' )
        
    return True
Example #59
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统: 往账.本地类操作交易[RCC001_8591]通存通兑错帐处理标识维护进入***' )
    
    AfaLoggerFunc.tradeInfo('个性化处理(本地操作)')
    
    #=====判断接口变量是否存在====
    if not TradeContext.existVariable("SNDBNKCO"):
        return AfaFlowControl.ExitThisFlow('A099','发送行号不能为空' )
        
    if not TradeContext.existVariable("TRCDAT"):
        return AfaFlowControl.ExitThisFlow('A009','委托日期不能为空')
        
    if not TradeContext.existVariable("TRCNO"):
        return AfaFlowControl.ExitThisFlow('A009','交易流水号不能为空')
        
    if not TradeContext.existVariable("BJEDTE"):
        return AfaFlowControl.ExitThisFlow('A009','报单日期不能为空')
        
    if not TradeContext.existVariable("BSPSQN"):
        return AfaFlowControl.ExitThisFlow('A009','报单序号不能为空')
    
    AfaLoggerFunc.tradeInfo('个性化处理结束(本地操作)') 
    
    #=====得到nccwkdat====
    if not rccpsFunc.GetNCCDate( ) :                   #NCCworkDate
        raise AfaFlowControl.flowException( )
    
    #=====查询错账登记簿====
    where_dict = {}
    where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO}
    tddzcz_record = rccpsDBTrcc_tddzcz.selectu(where_dict)
    if(tddzcz_record == None):
        return AfaFlowControl.ExitThisFlow('A009','查询错账登记簿失败')
        
    elif(len(tddzcz_record) == 0):
        return AfaFlowControl.ExitThisFlow('A009','查询错账登记簿为空')
        
    else:
        AfaLoggerFunc.tradeInfo("查询错账登记簿成功")
    
    #=====查询原业务的信息====
    AfaLoggerFunc.tradeInfo('查询原业务信息')
    where_dict = {}
    where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN}
    wtrbka_record = rccpsDBTrcc_wtrbka.selectu(where_dict)
    if(wtrbka_record == None):
        return AfaFlowControl.ExitThisFlow('A009','查询业务登记簿失败')
        
    elif(len(wtrbka_record) == 0):
        return AfaFlowControl.ExitThisFlow('A009','查询业务登记簿为空')   
        
    else:
        AfaLoggerFunc.tradeInfo('查询业务登记簿成功') 
        
    #=====查询业务的当前信息====
    wtr_dict = {}
    if not rccpsDBFunc.getTransWtr(TradeContext.BJEDTE,TradeContext.BSPSQN,wtr_dict):
        return AfaFlowControl.ExitThisFlow('A009','查询业务的当前信息失败')
        
    if(wtr_dict['BRSFLG'] == PL_BRSFLG_SND):
        sstlog_dict = {}
        if not rccpsState.getTransStateSet(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_ACC,PL_BDWFLG_SUCC,sstlog_dict):
            return AfaFlowControl.ExitThisFlow('A009','查询业务状态信息失败')
            
        wtr_dict['FEDT'] = sstlog_dict['FEDT']
        wtr_dict['RBSQ'] = sstlog_dict['RBSQ']
        
    TradeContext.CLDT = wtr_dict['FEDT']
    TradeContext.UNSQ = wtr_dict['RBSQ']
    if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 :   #RBSQ
        return AfaFlowControl.ExitThisFlow('A099','产生前置流水号失败')
    TradeContext.FEDT=AfaUtilTools.GetHostDate( )    #FEDT
    
    #=====判断当前业务是否已经结转====
    if(wtr_dict['BCSTAT'] == PL_BCSTAT_TRAS and wtr_dict['BDWFLG'] == PL_BDWFLG_SUCC):
        return AfaFlowControl.ExitThisFlow('A009','该账务已经结转')
        
        
    #=====判断业务的往来标示====
    AfaLoggerFunc.tradeInfo('<<<<<<判断业务的往来标示')
    if(wtrbka_record['BRSFLG'] == PL_BRSFLG_SND):
        AfaLoggerFunc.tradeInfo('<<<<<<业务为往账')
        acc    = 0    
        hcac   = 0   
        canc   = 0
        cancel = 0
        
        #=====查询是否有记账成功的状态====
        sstlog_list = []
        if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_ACC,PL_BDWFLG_SUCC,sstlog_list):
            acc = len(sstlog_list)
        #=====查询是否有抹账的状态====
        sstlog_list = []
        if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_HCAC,PL_BDWFLG_SUCC,sstlog_list):
            hcac = len(sstlog_list)
        #=====查询是否有冲销的状态====
        sstlog_list = []
        if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CANC,PL_BDWFLG_SUCC,sstlog_list):
            canc = len(sstlog_list)
        #=====查询是否有冲正的状态====
        ssltog_list = []
        if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CANCEL,PL_BDWFLG_SUCC,sstlog_list):
            cancel = len(sstlog_list)
        
        #=====判断是否需要清算状态调整====
        AfaLoggerFunc.tradeInfo('<<<<<<判断是否需要清算状态调整')
        if(acc - (hcac + canc + cancel) >= 0):
            AfaLoggerFunc.tradeInfo('<<<<<<需要进行清算状态调整')
                
            TradeContext.BETELR   = PL_BETELR_AUTO
            TradeContext.BRSFLG   = wtrbka_record['BRSFLG']    
            TradeContext.CHRGTYP  = wtrbka_record['CHRGTYP']
            TradeContext.BESBNO   = wtrbka_record['BESBNO'] 
            #=====卡折存现/本转异地====
            if(wtrbka_record['TRCCO'] in ('3000002','3000003','3000004','3000005')):
                AfaLoggerFunc.tradeInfo('卡折存现/本转异地')
                TradeContext.HostCode = '8813' 
                TradeContext.ACUR     = '1'
                TradeContext.RCCSMCD  = PL_RCCSMCD_DZBJ
                TradeContext.SBAC     = wtrbka_record['BESBNO'] + PL_ACC_NXYDQSWZ          #借方账号
                TradeContext.SBAC     = rccpsHostFunc.CrtAcc(TradeContext.SBAC,25)
                TradeContext.ACNM     = '农信银待清算往账'                                 #借方户名
                TradeContext.RBAC     = wtrbka_record['BESBNO'] + PL_ACC_NXYWZ             #贷方账号
                TradeContext.RBAC     = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25)
                TradeContext.OTNM     = '农信银往账'                                       #贷方户名
                TradeContext.OCCAMT   = str(wtrbka_record['OCCAMT'])                       #发生额
                TradeContext.PKFG     = 'W'
                TradeContext.CTFG     = '7'
                    
            #=====卡折取现/异地转本地====
            elif(wtrbka_record['TRCCO'] in ('3000102','3000103','3000104','3000105')): 
                AfaLoggerFunc.tradeInfo('卡折取现/异地转本地')
                if(wtrbka_record['CHRGTYP'] == '1'):    #转收           
                    AfaLoggerFunc.tradeInfo("<<<<<转收手续费")
                    TradeContext.HostCode = '8813' 
                    TradeContext.ACUR     = '1'
                    TradeContext.RCCSMCD  = PL_RCCSMCD_DZBJ
                    TradeContext.SBAC     = wtrbka_record['BESBNO'] + PL_ACC_NXYWZ    #借方账号
                    TradeContext.SBAC     = rccpsHostFunc.CrtAcc(TradeContext.SBAC,25) 
                    TradeContext.ACNM     = '农信银往账'
                    TradeContext.RBAC     = wtrbka_record['BESBNO'] + PL_ACC_NXYDQSWZ #贷方账号 
                    TradeContext.RBAC     = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25)
                    TradeContext.OTNM     = '农信银待清算往账'
                    TradeContext.OCCAMT   = str(wtrbka_record['OCCAMT'] + wtrbka_record['CUSCHRG'])
                    TradeContext.PKFG     = 'W'
                    TradeContext.CTFG     = '9'
                    
                else:    #现收
                    AfaLoggerFunc.tradeInfo("<<<<<现收手续费,或不收")
                    TradeContext.HostCode = '8813' 
                    TradeContext.ACUR     = '1'
                    TradeContext.RCCSMCD  = PL_RCCSMCD_DZBJ
                    TradeContext.SBAC     = wtrbka_record['BESBNO'] + PL_ACC_NXYWZ    #借方账号
                    TradeContext.SBAC     = rccpsHostFunc.CrtAcc(TradeContext.SBAC,25) 
                    TradeContext.ACNM     = '农信银往账'
                    TradeContext.RBAC     = wtrbka_record['BESBNO'] + PL_ACC_NXYDQSWZ #贷方账号 
                    TradeContext.RBAC     = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25)
                    TradeContext.OTNM     = '农信银待清算往账'
                    TradeContext.OCCAMT   = str(wtrbka_record['OCCAMT'])
                    TradeContext.PKFG     = 'W'
                    TradeContext.CTFG     = '9'
                
            else:
                return AfaFlowControl.ExitThisFlow('A099','原交易交易代码非法')
                
            #=====增加原交易的状态--结转====
            if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_TRAS,PL_BDWFLG_WAIT):
                AfaDBFunc.RollbackSql()
                return AfaFlowControl.ExitThisFlow('A099','增加原交易的状态--结转,失败')
            else:
                AfaDBFunc.CommitSql()  
                
            #=====调用主机交易====
            rccpsHostFunc.CommHost( TradeContext.HostCode )
            
            #=====判断主机交易是否成功====
            if(TradeContext.errorCode != '0000'):
                AfaLoggerFunc.tradeInfo("主机交易失败")
                #=====更改原交易状态====
                state_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'BCSTAT':PL_BCSTAT_TRAS,'BDWFLG':PL_BDWFLG_FAIL}
                state_dict['STRINFO'] = TradeContext.errorMsg
                if not rccpsState.setTransState(state_dict):
                    AfaDBFunc.RollbackSql()
                    return AfaFlowControl.ExitThisFlow('A099','更改原交易状态失败')
                else:
                    AfaDBFunc.CommitSql()   
                    
                return AfaFlowControl.ExitThisFlow('A099','主机记账失败')
                
            else:
                AfaLoggerFunc.tradeInfo('主机记账成功')
                #=====更改原交易状态====
                state_dict = {}
                state_dict['BJEDTE'] = TradeContext.BJEDTE
                state_dict['BSPSQN'] = TradeContext.BSPSQN
                state_dict['BCSTAT'] = PL_BCSTAT_TRAS
                state_dict['BDWFLG'] = PL_BDWFLG_SUCC
                if(TradeContext.existVariable("SBAC")):
                    state_dict['SBAC'] = TradeContext.SBAC
                if(TradeContext.existVariable("RBAC")):
                    state_dict['RBAC'] = TradeContext.RBAC
                state_dict['STRINFO'] = '主机成功'
                if(TradeContext.existVariable('TRDT')):
                    state_dict['TRDT'] = TradeContext.TRDT
                if(TradeContext.existVariable('TLSQ')):
                    state_dict['TLSQ'] = TradeContext.TLSQ
                if not rccpsState.setTransState(state_dict):
                    AfaDBFunc.RollbackSql()
                    return AfaFlowControl.ExitThisFlow('A099','更改原交易状态失败')
                else:
                    AfaDBFunc.CommitSql()   
                     
        else:
            return AfaFlowControl.ExitThisFlow('A009','原交易不能进行清算调整')
        
    else:
        AfaLoggerFunc.tradeInfo('<<<<<<业务为来账')
        autopay = 0    
        auto    = 0
        hcac    = 0   
        canc    = 0
        cancel  = 0
        #=====查询是否有记账成功的状态====
        sstlog_list = []
        if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_AUTO,PL_BDWFLG_SUCC,sstlog_list):
            auto = len(sstlog_list)
        sstlog_list = []
        if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_AUTOPAY,PL_BDWFLG_SUCC,sstlog_list):
            autopay = len(sstlog_list)      
        #=====查询是否有抹账的状态====
        sstlog_list = []
        if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_HCAC,PL_BDWFLG_SUCC,sstlog_list):
            hcac = len(sstlog_list)
        #=====查询是否有冲销的状态====
        sstlog_list = []
        if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CANC,PL_BDWFLG_SUCC,sstlog_list):
            canc = len(sstlog_list)
        #=====查询是否有冲正的状态====
        ssltog_list = []
        if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CANCEL,PL_BDWFLG_SUCC,sstlog_list):
            cancel = len(sstlog_list)
            
        #=====判断原业务是否需要进行清算状态调整====
        AfaLoggerFunc.tradeInfo("判断原业务是否需要进行清算状态调整")
        if((auto + autopay) - (hcac + canc + cancel) >= 0):
            AfaLoggerFunc.tradeInfo("原业务需要进行清算状态调整")
            
            TradeContext.BETELR   = PL_BETELR_AUTO
            TradeContext.BRSFLG   = wtrbka_record['BRSFLG']    
            TradeContext.CHRGTYP  = wtrbka_record['CHRGTYP']
            TradeContext.BESBNO   = wtrbka_record['BESBNO']  
            #=====卡折存现/本转异地====
            if(wtrbka_record['TRCCO'] in ('3000002','3000003','3000004','3000005')):
                AfaLoggerFunc.tradeInfo('卡折存现/本转异地')
                TradeContext.HostCode = '8813' 
                TradeContext.ACUR     = '1'
                TradeContext.RCCSMCD  = PL_RCCSMCD_DZBJ
                TradeContext.SBAC     = wtrbka_record['BESBNO'] + PL_ACC_NXYLZ
                TradeContext.SBAC     = rccpsHostFunc.CrtAcc(TradeContext.SBAC,25) 
                TradeContext.ACNM     = '农信银来账'
                TradeContext.RBAC     = wtrbka_record['BESBNO'] + PL_ACC_NXYDQSLZ 
                TradeContext.RBAC     = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25)
                TradeContext.OTNM     = '农信银待清算来账'
                TradeContext.OCCAMT   = str(wtrbka_record['OCCAMT'])
                TradeContext.PKFG     = 'W'
                TradeContext.CTFG     = '7'
            
            #=====卡折取现/异地转本地====    
            elif(wtrbka_record['TRCCO'] in ('3000102','3000103','3000104','3000105')):
                AfaLoggerFunc.tradeInfo('卡折存现/本转异地')
                TradeContext.HostCode = '8813'
                TradeContext.ACUR     = '1'
                TradeContext.RCCSMCD  = PL_RCCSMCD_DZBJ
                TradeContext.SBAC     = wtrbka_record['BESBNO'] + PL_ACC_NXYDQSLZ 
                TradeContext.SBAC     = rccpsHostFunc.CrtAcc(TradeContext.SBAC,25) 
                TradeContext.ACNM     = '农信银待清算来账'
                TradeContext.RBAC     = wtrbka_record['BESBNO'] + PL_ACC_NXYLZ 
                TradeContext.RBAC     = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25)
                TradeContext.OTNM     = '农信银来账'
                TradeContext.OCCAMT   = str(wtrbka_record['OCCAMT'] + wtrbka_record['CUSCHRG'])
                TradeContext.PKFG     = 'W'
                TradeContext.CTFG     = '9'
                
            else:
                return AfaFlowControl.ExitThisFlow('A099','原交易交易代码非法')
                
            #=====增加原交易的状态--结转====
            if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_TRAS,PL_BDWFLG_WAIT):
                AfaDBFunc.RollbackSql()
                return AfaFlowControl.ExitThisFlow('A099','增加原交易的状态--结转,失败')
            else:
                AfaDBFunc.CommitSql()  
                
            #=====调用主机交易====
            rccpsHostFunc.CommHost( TradeContext.HostCode )
            
            #=====判断主机交易是否成功====
            if(TradeContext.errorCode != '0000'):
                AfaLoggerFunc.tradeInfo("主机交易失败")
                #=====更改原交易状态====
                state_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'BCSTAT':PL_BCSTAT_TRAS,'BDWFLG':PL_BDWFLG_FAIL}
                state_dict['STRINFO'] = TradeContext.errorMsg
                if not rccpsState.setTransState(state_dict):
                    AfaDBFunc.RollbackSql()
                    return AfaFlowControl.ExitThisFlow('A099','更改原交易状态失败')
                else:
                    AfaDBFunc.CommitSql()   
                    
                return AfaFlowControl.ExitThisFlow('A099','主机记账失败')
                
            else:
                AfaLoggerFunc.tradeInfo('主机记账成功')
                #=====更改原交易状态====
                state_dict = {}
                state_dict['BJEDTE'] = TradeContext.BJEDTE
                state_dict['BSPSQN'] = TradeContext.BSPSQN
                state_dict['BCSTAT'] = PL_BCSTAT_TRAS
                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(TradeContext.existVariable('TRDT')):
                    state_dict['TRDT'] = TradeContext.TRDT
                if(TradeContext.existVariable('TLSQ')):
                    state_dict['TLSQ'] = TradeContext.TLSQ
                if not rccpsState.setTransState(state_dict):
                    AfaDBFunc.RollbackSql()
                    return AfaFlowControl.ExitThisFlow('A099','更改原交易状态失败')
                else:
                    AfaDBFunc.CommitSql()   
            
        else:
            return AfaFlowControl.ExitThisFlow('A009','原交易不能进行清算调整')
       
    #=====给修改字典赋值====
    update_dict = {}
    update_dict = {'ISDEAL':'1','NOTE3':'此笔错账已结转'}
    where_dict = {}               
    where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO,\
                  'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN}                                               

    #=====修改数据库中的数据====
    AfaLoggerFunc.tradeInfo("通存通兑错帐处理标识修改")
    res = rccpsDBTrcc_tddzcz.updateCmt(update_dict,where_dict)
    if( res == -1 ):
        return AfaFlowControl.ExitThisFlow('A099','修改通存通兑错帐处理标识失败')
    elif( res == 0 ):
        return AfaFlowControl.ExitThisFlow('A099','交易记录不存在')
        
    #=====向下发的通知表中插入数据====
    AfaLoggerFunc.tradeInfo("<<<<<<向通知表中插入数据")
    insert_dict = {}
    insert_dict['NOTDAT']  = AfaUtilTools.GetHostDate( )
    insert_dict['BESBNO']  = wtrbka_record['BESBNO']
    if(wtrbka_record['BRSFLG'] == PL_BRSFLG_RCV):
        insert_dict['STRINFO'] = "此笔错账["+wtrbka_record['BSPSQN']+"]["+wtrbka_record['BJEDTE']+"]已做手工结转处理"
    else:
        insert_dict['STRINFO'] = "此笔错账["+wtrbka_record['BSPSQN']+"]["+wtrbka_record['BJEDTE']+"]已做手工结转处理 请用8522补打往账凭证"
    if not rccpsDBTrcc_notbka.insertCmt(insert_dict):
        return AfaFlowControl.ExitThisFlow('S999','向下发的通知表中插入数据失败')
    AfaLoggerFunc.tradeInfo("<<<<<<向通知表中插入数据成功")
    
    #=====给输出接口赋值====
    TradeContext.errorCode = "0000"
    TradeContext.errorMsg  = "修改通存通兑错帐处理标识成功"
    TradeContext.ISDEAL    = '1'
#    TradeContext.TLSQ      = TradeContext.TLSQ
#    TradeContext.RBSQ      = TradeContext.RBSQ
#    TradeContext.TRDT      = TradeContext.TRDT

    AfaLoggerFunc.tradeInfo( '***农信银系统: 往账.本地类操作交易[RCC001_8591]通存通兑错帐处理标识维护退出***' )
    
    return True      
Example #60
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统: 往账.本地类操作交易[RCC001_8530]进入***' )

    #=====判断输入接口值是否存在====
    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( "RECSTRNO" ) ):
        return AfaFlowControl.ExitThisFlow('A099', '起始笔数[RECSTRNO]不存在')
        
    start_no = TradeContext.RECSTRNO        #起始笔数
    sel_size = 10                           #查询笔数
        
    #=====生成查询语句====
    wheresql = ""
    wheresql = wheresql + "BESBNO='" + TradeContext.BESBNO + "' " 
    wheresql = wheresql + " AND BJEDTE>='" + TradeContext.STRDAT + "'"
    wheresql = wheresql + " AND BJEDTE<='" + TradeContext.ENDDAT + "'"

    #=====判断往来标志是否为空====
    if(TradeContext.BRSFLG != ""):
        wheresql = wheresql +" AND BRSFLG='" + TradeContext.BRSFLG + "'"

    #=====判断报单序号是否为空====
    if(TradeContext.BSPSQN != ""):
        wheresql = wheresql + " AND BSPSQN='" + TradeContext.BSPSQN + "'"
    
    #=====判断原交易日期是否为空====    
    if(TradeContext.BOJEDT != "00000000"):
        wheresql = wheresql + " AND BOJEDT='" + TradeContext.BOJEDT + "'"
    
    #=====判断原表单序号是否为空====    
    if(TradeContext.BOSPSQ != ""):
        wheresql = wheresql + " AND BOSPSQ='" + TradeContext.BOSPSQ + "'"
    
    #=====判断复查标志是否为空====    
    if(TradeContext.ISDEAL != ""):
        wheresql = wheresql + " AND ISDEAL='" + TradeContext.ISDEAL + "'"
        
    AfaLoggerFunc.tradeInfo( "查询条件: "+wheresql)
    
    #=====查询总记录数====
    allcount = rccpsDBTrcc_ztcbka.count(wheresql)
    if(allcount < 0):
        return AfaFlowControl.ExitThisFlow('A099', '查询总记录数失败')
        
    AfaLoggerFunc.tradeDebug("查询总记录数完成")
    
    #=====查询数据库====
    ordersql = " order by BJEDTE DESC,BSPSQN DESC"
    
    records = rccpsDBTrcc_ztcbka.selectm(start_no,sel_size,wheresql,ordersql)
    
    if(records == None):
        return AfaFlowControl.ExitThisFlow('A099','查询失败' )    
    if 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 AfaLoggerFunc.tradeInfo("S999","打开文件异常")
        filecontext = ""
        
        #=====写文件操作====
        for i in range(0,len(records)):
            filecontext = records[i]['BJEDTE']      + "|" \
                        + records[i]['BSPSQN']      + "|" \
                        + records[i]['BRSFLG']      + "|" \
                        + 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]['CUR']         + "|" \
                        + str(records[i]['OCCAMT']) + "|" \
                        + records[i]['CONT']        + "|" \
                        + records[i]['NCCTRCST']    + "|" \
                        + records[i]['MBRTRCST']    + "|" \
                        + records[i]['PRCCO']       + "|" \
                        + records[i]['STRINFO']     + "|"
                        
            f.write(filecontext+"\n")
        
        f.close()        
        AfaLoggerFunc.tradeInfo("生成文件结束")
        
    #=====输出接口赋值====
    TradeContext.RECSTRNO=start_no              #起始笔数
    TradeContext.RECCOUNT=str(len(records))     #查询笔数
    TradeContext.RECALLCOUNT=str(allcount)      #总笔数
    TradeContext.errorCode="0000"
    TradeContext.errorMsg="查询成功"
    TradeContext.PBDAFILE=filename              #文件名
    
    AfaLoggerFunc.tradeInfo( '***农信银系统: 往账.本地类操作交易[RCC001_8530]退出***' )
    return True