Beispiel #1
0
def AdbSelectQueDtl( ):
   
    AfaLoggerFunc.tradeInfo( '>>>>>>>开始查询原交易<<<<<<<') 
      
    sql = "select * from YBT_INFO "
    sql = sql + " where WORKDATE = '" + TradeContext.workDate.strip() + "'"         #交易日期
    sql = sql + " and   SUBMINO  = '" + TradeContext.applno.strip()   + "'"         #投保单号
    sql = sql + " and   cpicno   = '" + TradeContext.unitno           + "'"         #保险公司单位编码
    sql = sql + " and   tellerno = '" + TradeContext.tellerno         + "'"         #交易柜员号
    
    AfaLoggerFunc.tradeInfo( '>>>>>>>开始查询原交易:'+ str(sql)) 
    
    records = AfaDBFunc.SelectSql( sql ) 
   
    AfaLoggerFunc.tradeInfo('查询到记录条数为:'+str(len(records)))
    
    #没有记录则插入数据
    if(len(records)==0):
        if not AdbInsertQueDtl( ):
            raise AfaFlowControl.flowException() 
        else:
            return True       
   
    #有记录则更新原纪录       
    else:
        if not AdbUpdateQueDtl( ):
            raise AfaFlowControl.flowException()
        else:
            return True    
Beispiel #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
Beispiel #3
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) )
Beispiel #4
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:                                                                     
Beispiel #5
0
def SubModuleDoFst( ):

    try:
        CrtJKMXFile( )
        TradeContext.count = "1"
        AfaLoggerFunc.tradeInfo(TradeContext.count)
        return True
    except  Exception, e:
        AfaLoggerFunc.tradeInfo( str(e) )
        AfaFlowControl.flowException( )
Beispiel #6
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', '交易成功')
Beispiel #7
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( )        
Beispiel #8
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( )       
                             
Beispiel #9
0
def SubModuleMainFst( ):

    try:
    
        #=============获取平台流水号====================
        if TipsFunc.GetSerialno( ) == -1 :
            raise AfaFlowControl.flowException( )
            
        TradeContext.TaxVouNo = '34234234'
        TradeContext.OriTaxOrgCode = '21100000000'
        TradeContext.OriEntrustDate = '20060623'
        TradeContext.OriTraNo = '00000012'
        TradeContext.TaxDate = '20060623'
        TradeContext.Result = '90000'
        TradeContext.AddWord = '交易成功'
        
        #=============与第三方通讯====================
        AfaAfeFunc.CommAfe()
        if( TradeContext.errorCode != '0000' ):
            return False

        TradeContext.errorCode = '0000'
        TradeContext.errorMsg = '交易成功'

    except AfaFlowControl.flowException, e:
        return False
Beispiel #10
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( )   
Beispiel #11
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
Beispiel #12
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+']退出***')
Beispiel #13
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) )
Beispiel #14
0
def ModifyVouhModify():
    if(not TradeContext.existVariable( "HostDate" )):
                TradeContext.HostDate = '' 

    #更新流水表
    sqlUpdate = "update VOUH_MODIFY SET TRANSTATUS = '" + TradeContext.sTranStatus + "',\
                HOSTDATE = '" + TradeContext.HostDate + "',\
                HOSTSERIAL = '" + TradeContext.HostSerno + "' where VOUHSERIAL = '" + TradeContext.sVouhSerial + "'"
    record = AfaDBFunc.UpdateSqlCmt( sqlUpdate )
    if record == -1 or record == 0 :
        tradeExit('A005062', '更新流水表失败!')
        raise AfaFlowControl.flowException( )
Beispiel #15
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+']退出********')
Beispiel #16
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
Beispiel #17
0
def SelectBesbName( sBesbNo):
    #=============前台上送数据====================
    #TradeContext.sBESBNO           机构号
    #TradeContext.sBesbSty          机构类型
    
    try:
        
        sqlStr = "SELECT SBSBNM FROM VOUH_FRONT_CRSBA WHERE SBSBNO ='" + sBesbNo + "'"
     
        records = AfaDBFunc.SelectSql( sqlStr)
        if( records == None ):
            tradeExit('A005067', '查询[机构表]操作异常!')
            raise AfaFlowControl.flowException( )
        elif( len( records ) == 0 ):
            tradeExit('A005068', '机构不存在!' )
            raise AfaFlowControl.flowException( )

        return str(records[0][0])
            
            
    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( )
Beispiel #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) )
Beispiel #19
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) )  
Beispiel #20
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+']退出********')
Beispiel #21
0
def SubModuleDoFst( ):
    
    #交易代码
    TradeContext.tradeCode = TradeContext.TransCode
    
    AfaLoggerFunc.tradeInfo( '反交易数据预查询,判断是否存在原续期缴费记录' )
   
    sql = "select workdate,worktime,userno,tellerno,brno,note9,unitno,amount,trxcode from afa_maintransdtl"
    sql = sql + " where agentserialno = '"+TradeContext.PreSerialno+"' and workdate = '"+TradeContext.workDate+"' and trxcode='8613'"
    sql = sql + " and revtranf = '0' and bankstatus = '0' and corpstatus = '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][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][6] != TradeContext.unitno):
            TradeContext.errorCode,TradeContext.errorMsg = "0001","与原交易保险公司不符,不能做此交易"
            return False
        
        if(records[0][7].strip() != TradeContext.amount.strip()):
            TradeContext.errorCode,TradeContext.errorMsg = "0001","与原交易金额不符,不能做此交易"
            return False
         
        if(records[0][5].split('|')[2] != TradeContext.policy):
            TradeContext.errorCode,TradeContext.errorMsg = "0001","与原交易保险单号不符,不能做此交易"
            return False
    
        #原交易日期
        TradeContext.PreWorkDate = records[0][0]
        
        #原交易时间
        TradeContext.PreWorktime = records[0][1]
        
        #金额
        TradeContext.amount = records[0][7]
        
        #保单印刷号
        TradeContext.userno = records[0][2]
        
        #流水号
        TradeContext.preAgentSerno = TradeContext.PreSerialno
        
        #保险单号
        TradeContext.policy =records[0][5].split('|')[2]
        
        #原交易码
        TradeContext.PreTrxCode = records[0][8]
        
        return True
Beispiel #22
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统: 往账.本地类操作交易[RCC004_1163]进入***' )

    #=====判断是否存在自动冲正报文====
    AfaLoggerFunc.tradeDebug('>>>判断是否存在自动冲正报文')

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

    if( len(atcbka_dict) > 0 ):
        #=====冲销业务存在自动冲正报文,更新表数据为冲销失败,回复冲销失败报文====
        AfaLoggerFunc.tradeDebug('>>>已存在自动冲正报文,抛弃报文')
        return AfaFlowControl.ExitThisFlow('S999','存在自动冲正报文,抛弃报文')
    else:
        AfaLoggerFunc.tradeDebug('>>>未查找到针对补正报文的自动冲正报文,流程继续')

    #=====判断原补正交易是否存在====
    AfaLoggerFunc.tradeDebug('>>>判断是否存在原补正报文')

    wtrbka_where={'MSGFLGNO':TradeContext.ORMFN}
    wtrbka_dict = rccpsDBTrcc_wtrbka.selectu(wtrbka_where)

    wtrbka_temp_dict = wtrbka_dict

    if len(wtrbka_dict) <= 0:
        AfaLoggerFunc.tradeDebug('>>>未找到原补正报文,抛弃报文,不做任何处理')
        return AfaFlowControl.ExitThisFlow('S999','未找到原补正报文,抛弃报文,不做任何处理')
    else:
        AfaLoggerFunc.tradeDebug('>>>找到原补正报文,继续流程处理')

    #=====查找原业务====
    AfaLoggerFunc.tradeDebug('>>>查询原业务')

    wtrbka_where={'BJEDTE':wtrbka_dict['NOTE1'],'BSPSQN':wtrbka_dict['NOTE2']}
    wtrbka_dict = rccpsDBTrcc_wtrbka.selectu(wtrbka_where)

    if len(wtrbka_dict) <= 0:
        AfaLoggerFunc.tradeDebug('>>>未找到原业务,抛弃报文,不做任何处理')
        return AfaFlowControl.ExitThisFlow('S999','未找到原业务,抛弃报文,不做任何处理')
    else:
        AfaLoggerFunc.tradeDebug('>>>找到原业务,继续流程处理')

    #=====查找原业务状态====
    AfaLoggerFunc.tradeDebug('>>>查找原业务状态')

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

    if len(spb_dict) <= 0:
        AfaLoggerFunc.tradeDebug('>>>查找原业务状态失败,抛弃报文,不做任何处理')
        return AfaFlowControl.ExitThisFlow('S999','查找原业务状态失败,抛弃报文,不做任何处理')
    else:
        AfaLoggerFunc.tradeDebug('>>>查找原业务状态成功,继续流程处理')

    #=====判断原业务状态是否允许进行补正账务补录====
    if spb_dict['BCSTAT'] != PL_BCSTAT_CANC and spb_dict['BDWFLG'] != PL_BDWFLG_SUCC:
        AfaLoggerFunc.tradeDebug('>>>原业务状态['+str(spbsta_dict['BCSTAT'])+'不允许补正,抛弃报文,不做任何处理')
        return AfaFlowControl.ExitThisFlow('S999','原业务不允许补正,抛弃报文,不做任何处理')
    else:
        AfaLoggerFunc.tradeDebug('>>>原业务进入补正账务流程处理')
        
    #=================若应答报文回复拒绝,则设置状态为拒绝,停止处理=============
    if TradeContext.PRCCO != 'RCCI0000':
        AfaLoggerFunc.tradeInfo(">>>对方返回拒绝应答")
        
        #=============设置业务状态为拒绝处理中=================================
        
        if not rccpsState.newTransState(wtrbka_temp_dict['BJEDTE'],wtrbka_temp_dict['BSPSQN'],PL_BCSTAT_MFERFE,PL_BDWFLG_SUCC):
            return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为拒绝处理中异常")
        
        if not AfaDBFunc.CommitSql( ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return AfaFlowControl.ExitThisFlow("S999","Commit异常")
            
        return AfaFlowControl.ExitThisFlow("S999","对方拒绝,停止处理")
    else:
        AfaLoggerFunc.tradeInfo(">>>对方返回成功应答")

    #=====记账接口8813I1赋值操作====
    TradeContext.HostCode  =  '8813'
    TradeContext.BESBNO    =  wtrbka_dict['BESBNO']          #机构号
    TradeContext.BETELR    =  wtrbka_dict['BETELR']          #柜员号
    TradeContext.TERMID    =  wtrbka_dict['TERMID']          #终端号
    TradeContext.BJEDTE    =  wtrbka_dict['BJEDTE']          #交易日期
    TradeContext.BSPSQN    =  wtrbka_dict['BSPSQN']          #报单序号

    #=====判断交易代码,进行账务补正====
    if TradeContext.ORTRCCO in ('3000002','3000004'):
        #=====通存====
        AfaLoggerFunc.tradeDebug('>>>通存业务补正')
    elif TradeContext.ORTRCCO in ('3000102','3000104'):
        #=====通兑====
        AfaLoggerFunc.tradeDebug('>>>通兑业务补正')

        if( wtrbka_dict['CHRGTYP'] != '1'):
            TradeContext.RCCSMCD  = PL_RCCSMCD_XJTDWZ                     #主机摘要代码
            TradeContext.RBAC =  ''                       #借方账户:付款人账户
            TradeContext.RBNM =  '现金'                       #借方户名 付款人户名
            TradeContext.SBAC = TradeContext.BESBNO + PL_ACC_NXYDQSWZ     #贷方账户:农信银待清算来账
            TradeContext.SBAC = rccpsHostFunc.CrtAcc(TradeContext.SBAC, 25)
            TradeContext.ACNM = '农信银待清算来账'                        #贷方户名:
            TradeContext.CTFG =  '7'                                      #本金 手续费标识  7 本金 8手续费 9 本金+手续费
            TradeContext.PKFG =  'T'                                      #通存通兑标识
            TradeContext.CATR =  '0'                                      #现金

            AfaLoggerFunc.tradeInfo( '借方账号:' + TradeContext.SBAC )
            AfaLoggerFunc.tradeInfo( '贷方账号:' + TradeContext.RBAC )

        else:
            #=====转账====
            TradeContext.ACUR    =  '3'                                           #记账次数
            TradeContext.I3TRAM  =  str(TradeContext.CUSCHRG)                       #发生额
            TradeContext.I2TRAM  =  str(TradeContext.OCCAMT)                       #发生额
            TradeContext.OCCAMT  =  rccpsUtilTools.AddDot(TradeContext.OCCAMT,TradeContext.CUSCHRG) #发生额

            #=========交易金额+手续费===================
            TradeContext.RCCSMCD    =  PL_RCCSMCD_XJTDWZ                               #摘要代码
            TradeContext.SBAC    =  TradeContext.BESBNO + PL_ACC_NXYDQSWZ         #借方账号
            TradeContext.SBAC    =  rccpsHostFunc.CrtAcc(TradeContext.SBAC,25)
            TradeContext.ACNM    =  '待解临时款项'                                #借方户名
            TradeContext.RBAC    =  TradeContext.BESBNO + PL_ACC_NXYDJLS          #贷方账号
            TradeContext.RBAC    =  rccpsHostFunc.CrtAcc(TradeContext.RBAC,25)
            TradeContext.OTNM    =  '农信银来账'                                  #贷方户名
            TradeContext.CTFG  = '9'                                              #本金 手续费标识  7 本金 8手续费 9 本金+手续费
            TradeContext.PKFG  = 'T'                                              #通存通兑标识
            AfaLoggerFunc.tradeInfo( '>>>交易金额+手续费:借方账号' + TradeContext.SBAC )
            AfaLoggerFunc.tradeInfo( '>>>交易金额+手续费:贷方账号' + TradeContext.RBAC )
            #=========交易金额============
            TradeContext.I2SMCD  =  PL_RCCSMCD_XJTDWZ                               #摘要代码
            TradeContext.I2RBAC  =  ''                           #借方账号
            TradeContext.I2ACNM  =  TradeContext.PYRNAM                           #借方户名
            TradeContext.I2SBAC  =  TradeContext.BESBNO + PL_ACC_NXYDJLS          #贷方账号
            TradeContext.I2SBAC  =  rccpsHostFunc.CrtAcc(TradeContext.I2SBAC,25)
            TradeContext.I2CTFG  = '7'                                            #本金 手续费标识  7 本金 8手续费 9 本金+手续费
            TradeContext.I2PKFG  = 'T'                                            #通存通兑标识
            TradeContext.I2CATR =  '0'                                      #现金
            AfaLoggerFunc.tradeInfo( '>>>交易金额:借方账号' + TradeContext.I2SBAC )
            AfaLoggerFunc.tradeInfo( '>>>交易金额:贷方账号' + TradeContext.I2RBAC )
            #=========结算手续费收入户===========
            TradeContext.I3SMCD  =  PL_RCCSMCD_SXF                                #摘要代码
            TradeContext.I3SBAC  =  TradeContext.BESBNO + PL_ACC_NXYDJLS          #借方账号
            TradeContext.I3ACNM  =  TradeContext.PYRNAM                           #借方户名
            TradeContext.I3RBAC  =  TradeContext.BESBNO + PL_ACC_TCTDSXF          #贷方账号
            TradeContext.I3RBAC  =  rccpsHostFunc.CrtAcc(TradeContext.I3RBAC,25)
            TradeContext.I3SBAC  =  rccpsHostFunc.CrtAcc(TradeContext.I3SBAC,25)
            TradeContext.I3OTNM  =  '待解临时款项'                                #贷方户名
            TradeContext.I3CTFG  = '8'                                              #本金 手续费标识  7 本金 8手续费 9 本金+手续费
            TradeContext.I3PKFG  = 'T'                                              #通存通兑标识
            AfaLoggerFunc.tradeInfo( '>>>结算手续费收入户:借方账号' + TradeContext.I3SBAC )
            AfaLoggerFunc.tradeInfo( '>>>结算手续费收入户:贷方账号' + TradeContext.I3RBAC )

    elif TradeContext.ORTRCCO in ('3000003','3000005'):
        #=====本转异====
        AfaLoggerFunc.tradeDebug('>>>本转异业务补正')
    elif TradeContext.ORTRCCO in ('3000103','3000105'):
        #=====异转本====
        AfaLoggerFunc.tradeDebug('>>>异转本业务补正')

        #=====判断手续费收取方式====
        if wtrbka_dict['CHRGTYP'] == '1':
            #=====转账====
            TradeContext.ACUR    =  '3'                                     #记账次数
            TradeContext.I3TRAM  =  str(TradeContext.CUSCHRG)                      #发生额 手续费
            TradeContext.I2TRAM  =  str(TradeContext.OCCAMT)                       #发生额 本金
            TradeContext.OCCAMT  =  str(float(TradeContext.OCCAMT) + float(TradeContext.CUSCHRG)) #发生额
            #=========交易金额+手续费===================
            TradeContext.RCCSMCD =  PL_RCCSMCD_YZBWZ                              #摘要代码  PL_RCCSMCD_YZBWZ 异转本
            TradeContext.SBAC    =  TradeContext.BESBNO + PL_ACC_NXYDQSWZ         #借方账号
            TradeContext.SBAC    =  rccpsHostFunc.CrtAcc(TradeContext.SBAC,25)
            TradeContext.ACNM    =  '农信银往账'                                  #借方户名
            TradeContext.RBAC    =  TradeContext.BESBNO + PL_ACC_NXYDJLS           #贷方账号
            TradeContext.RBAC    =  rccpsHostFunc.CrtAcc(TradeContext.RBAC,25)
            TradeContext.OTNM    =  '应解汇款'                                    #贷方户名
            TradeContext.CTFG  = '9'                                              #本金 手续费标识  7 本金 8手续费 9 本金+手续费
            TradeContext.PKFG  = 'T'                                              #通存通兑标识
            AfaLoggerFunc.tradeInfo( '>>>交易金额+手续费:借方账号' + TradeContext.SBAC )
            AfaLoggerFunc.tradeInfo( '>>>交易金额+手续费:贷方账号' + TradeContext.RBAC )
            #=========交易金额============
            TradeContext.I2SMCD  =  PL_RCCSMCD_YZBWZ                              #摘要代码
            TradeContext.I2SBAC  =  TradeContext.BESBNO + PL_ACC_NXYDJLS          #借方账号
            TradeContext.I2SBAC  =  rccpsHostFunc.CrtAcc(TradeContext.I2SBAC,25)
            TradeContext.I2ACNM  =  '应解汇款'                                    #借方户名
            TradeContext.I2RBAC  =  TradeContext.PYEACC                           #贷方账号
            TradeContext.I2OTNM  =  TradeContext.PYENAM                           #贷方户名
            TradeContext.I2CTFG  = '7'                                              #本金 手续费标识  7 本金 8手续费 9 本金+手续费
            TradeContext.I2PKFG  = 'T'                                              #通存通兑标识
            AfaLoggerFunc.tradeInfo( '>>>交易金额:借方账号' + TradeContext.I2SBAC )
            AfaLoggerFunc.tradeInfo( '>>>交易金额:贷方账号' + TradeContext.I2RBAC )
            #=========结算手续费收入户===========
            TradeContext.I3SMCD  =  PL_RCCSMCD_SXF                                #摘要代码
            TradeContext.I3SBAC  =  TradeContext.BESBNO + PL_ACC_NXYDJLS          #借方账号
            TradeContext.I3SBAC  =  rccpsHostFunc.CrtAcc(TradeContext.I3SBAC,25)
            TradeContext.I3ACNM  =  '应解汇款'                                    #借方户名
            TradeContext.I3RBAC  =  TradeContext.BESBNO + PL_ACC_TCTDSXF          #贷方账号
            TradeContext.I3RBAC  =  rccpsHostFunc.CrtAcc(TradeContext.I3RBAC,25)
            TradeContext.I3OTNM  =  '结算手续费'                                  #贷方户名
            TradeContext.I3CTFG  = '8'                                              #本金 手续费标识  7 本金 8手续费 9 本金+手续费
            TradeContext.I3PKFG  = 'T'                                              #通存通兑标识
        else:
            #=====不收费或者现金====
            TradeContext.ACUR    =  '1'                                           #记账次数
            TradeContext.RCCSMCD =  PL_RCCSMCD_YZBWZ                                #摘要代码
            TradeContext.SBAC    =  TradeContext.BESBNO + PL_ACC_NXYDQSWZ         #借方账号
            TradeContext.SBAC    =  rccpsHostFunc.CrtAcc(TradeContext.SBAC,25)
            TradeContext.RBAC    =  TradeContext.PYEACC                           #贷方账号
            TradeContext.OTNM    =  TradeContext.PYENAM                           #贷方户名
            TradeContext.CTFG  = '7'                                              #本金 手续费标识  7 本金 8手续费 9 本金+手续费
            TradeContext.PKFG  = 'T'                                              #通存通兑标识
    else:
        #=====原交易代码错,抛弃报文====
        AfaLoggerFunc.tradeDebug('>>>原交易代码错,抛弃报文')
        return AfaFlowControl.ExitThisFlow('S999','原交易代码错,抛弃报文')

    #=====重新生成前置流水号====
    if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 :
        return AfaFlowControl.ExitThisFlow('S999','重新生成前置流水号失败,抛弃报文')

    #=====modify  by pgt 12-8====
    if wtrbka_temp_dict['DCFLG'] == PL_DCFLG_DEB:
#    if TradeContext.ORTRCCO in ('3000102','3000104','3000103','3000105'):
        #=====通兑、异转本====
        if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_AUTOPAY,PL_BDWFLG_WAIT):
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow('S999','新增自动扣款-处理中失败,抛弃报文')
        else:
            AfaDBFunc.CommitSql()

        #=====向主机发起记账====
        rccpsHostFunc.CommHost( TradeContext.HostCode )

        #=====判断主机返回====
        sstlog_dict={}
        sstlog_dict['BJEDTE']  =  TradeContext.BJEDTE
        sstlog_dict['BSPSQN']  =  TradeContext.BSPSQN
        sstlog_dict['BCSTAT']  =  PL_BCSTAT_AUTOPAY
        if TradeContext.errorCode == '0000':
            sstlog_dict['BDWFLG'] =  PL_BDWFLG_SUCC
            sstlog_dict['RBSQ']   =  TradeContext.RBSQ
            sstlog_dict['TLSQ']   =  TradeContext.TLSQ
            sstlog_dict['TRDT']   =  TradeContext.TRDT
            sstlog_dict['MGID']   =  TradeContext.errorCode
            sstlog_dict['STRINFO']=  '主机补正记账成功'
            AfaLoggerFunc.tradeInfo('>>>补正记账成功')
        else:
            sstlog_dict['BDWFLG'] =  PL_BDWFLG_FAIL
            sstlog_dict['MGID']   =  TradeContext.errorCode
            sstlog_dict['STRINFO']=  TradeContext.errorMsg
            AfaLoggerFunc.tradeInfo('>>>补正记账失败')

        if not rccpsState.setTransState(sstlog_dict):
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow('S999','修改自动扣款-成功中失败,抛弃报文')
        else:
            AfaDBFunc.CommitSql()
    else:
        #====通存、本转异====
        AfaLoggerFunc.tradeDebug('>>>新增确认付款-处理中')

        if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CONFACC,PL_BDWFLG_SUCC):
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow('S999','新增确认付款-处理中失败,抛弃报文')
        else:
            AfaDBFunc.CommitSql()

        #=================为存款确认请求报文做准备=================================
        AfaLoggerFunc.tradeInfo(">>>开始为存款确认请求报文做准备")

        #=====================获取中心流水号====================================
        if rccpsGetFunc.GetRccSerialno( ) == -1 :
            raise AfaFlowControl.flowException( )

        TradeContext.MSGTYPCO = 'SET009'
        TradeContext.SNDSTLBIN = TradeContext.RCVMBRCO
        TradeContext.RCVSTLBIN = TradeContext.SNDMBRCO
        TradeContext.SNDBRHCO = TradeContext.BESBNO
        TradeContext.SNDCLKNO = TradeContext.BETELR
        TradeContext.ORMFN    = TradeContext.ORMFN 
        TradeContext.OPRTYPNO = '30'
        TradeContext.ROPRTPNO = '30'
        TradeContext.TRANTYP  = '0'
        TradeContext.ORTRCCO  = '3000505' 
        TradeContext.ORTRCNO  = TradeContext.TRCNO
        TradeContext.TRCCO    = '3000503'
        TradeContext.TRCNO    = TradeContext.SerialNo
        TradeContext.CURPIN   = ""
        TradeContext.STRINFO  = '收到补正应答,自动发送存款确认'

        AfaLoggerFunc.tradeInfo(">>>交易代码["+str(TradeContext.TRCCO)+"]")
        AfaLoggerFunc.tradeInfo(">>>结束为存款确认请求报文做准备")
 
        #=====更新原记录的存款确认字段====
        #=====modify by pgt 12-8====
        wtr_up_where = {'BJEDTE':wtrbka_temp_dict['BJEDTE'],'BSPSQN':wtrbka_temp_dict['BSPSQN']}
#        wtr_up_where = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN}
        wtr_end_dict = {}
        wtr_end_dict['COTRCDAT']  = TradeContext.TRCDAT
        wtr_end_dict['COTRCNO']   = TradeContext.TRCNO
        wtr_end_dict['TRCNO']     = TradeContext.ORTRCNO
        wtr_end_dict['COMSGFLGNO']= TradeContext.SNDBNKCO+TradeContext.TRCDAT+TradeContext.TRCNO
        wtr_end_dict['MSGFLGNO']  = TradeContext.MSGFLGNO

        rccpsDBTrcc_wtrbka.update(wtr_end_dict,wtr_up_where)
        AfaDBFunc.CommitSql()

        AfaAfeFunc.CommAfe()
 
        if TradeContext.errorCode == '0000':
            AfaLoggerFunc.tradeInfo('>>>发送成功')
        else:
            AfaLoggerFunc.tradeInfo('>>>发送失败')

    return True
Beispiel #23
0
def SubModuleDoFst( ):

    #校验保险公司代码和凭证种类是否合法
    if not AfaYbtdb.ADBCheckCert( ):
        return False
        
    try:
        AfaLoggerFunc.tradeInfo( '初始化新保投保交易变量' )
        
        #交易代码(8610)
        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( "productid" ) and len(TradeContext.productid.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "险种不存在"
            raise AfaFlowControl.flowException( )
            
        #投保人姓名
        if not( TradeContext.existVariable( "tbr_name" ) and len(TradeContext.tbr_name.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保人姓名不存在"
            raise AfaFlowControl.flowException( )
            
        #投保人证件类型
        if not( TradeContext.existVariable( "tbr_idtype" ) and len(TradeContext.tbr_idtype.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保人证件类型不存在"
            raise AfaFlowControl.flowException( )
            
        #投保人证件号码
        if not( TradeContext.existVariable( "tbr_idno" ) and len(TradeContext.tbr_idno.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保人证件号码不存在"
            raise AfaFlowControl.flowException( )
            
        #投保人性别
        if not( TradeContext.existVariable( "tbr_sex" ) and len(TradeContext.tbr_sex.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保人性别不存在"
            raise AfaFlowControl.flowException( )
            
        #投保人出生日期
        if not( TradeContext.existVariable( "tbr_birth" ) and len(TradeContext.tbr_birth.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保人出生日期不存在"
            raise AfaFlowControl.flowException( )
            
        #投保人家庭地址    
        if not( TradeContext.existVariable( "tbr_addr" ) and len(TradeContext.tbr_addr.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保人家庭地址不存在"
            raise AfaFlowControl.flowException( )
            
        #投保人家庭号码 投保人移动号码
        if not( TradeContext.existVariable( "tbr_tel" )  or TradeContext.existVariable( "tbr_mobile" ) ):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保人电话不存在"
            raise AfaFlowControl.flowException( )
            
        #投保人邮政编码
        if not( TradeContext.existVariable( "tbr_postcode" ) and len(TradeContext.tbr_postcode.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保人邮政编码不存在"
            raise AfaFlowControl.flowException( )
              
        #投保单号
        if not( TradeContext.existVariable( "applno" ) and len(TradeContext.applno.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保单号不存在"
            raise AfaFlowControl.flowException( ) 
             
        #保单印刷号
        if not( TradeContext.existVariable( "userno" ) and len(TradeContext.userno.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "保单印刷号不存在"
            raise AfaFlowControl.flowException( )
              
        #投保日期
        if not( TradeContext.existVariable( "tb_date" ) and len(TradeContext.tb_date.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保日期不存在"
            raise AfaFlowControl.flowException( )  
       
        #应缴保费
        if not( TradeContext.existVariable( "amount" ) and len(TradeContext.amount.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "应缴保费不存在"
            raise AfaFlowControl.flowException( ) 
             
        #保险期间类型
        if not( TradeContext.existVariable( "tormtype" ) and len(TradeContext.tormtype.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "保险期间类型不存在"
            raise AfaFlowControl.flowException( )
              
        #保险期间
        if not( TradeContext.existVariable( "coverage_year" ) and len(TradeContext.coverage_year.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "保险期间不存在"
            raise AfaFlowControl.flowException( )  
       
        #缴费方式
        if ( TradeContext.existVariable( "paymethod" ) and len(TradeContext.paymethod.strip()) > 0 ):
            if(TradeContext.paymethod=='1'):
                #当缴费方式为1(期缴)时缴费年期类型为2(按年限交)(中国人寿特有字段)
                TradeContext.charge_period='2'                                         
            else:
                #当缴费方式为5(趸交)时缴费年期类型为1(趸交)
                TradeContext.charge_period='1'  
        
        #缴费年限
        if not( TradeContext.existVariable( "paydatelimit" ) and len(TradeContext.paydatelimit.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "缴费年限不存在"
            raise AfaFlowControl.flowException( )  
       
        #被保险人姓名
        if not( TradeContext.existVariable( "bbr_name" ) and len(TradeContext.bbr_name.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "被保险人姓名不存在"
            raise AfaFlowControl.flowException( )
              
        #被保险人证件类型
        if not( TradeContext.existVariable( "bbr_idtype" ) and len(TradeContext.bbr_idtype.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "被保险人证件类型不存在"
            raise AfaFlowControl.flowException( )  
            
        #被保险人证件号码
        if not( TradeContext.existVariable( "bbr_idno" ) and len(TradeContext.bbr_idno.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "被保险人号码证件不存在"
            raise AfaFlowControl.flowException( ) 
             
        #被保险人性别
        if not( TradeContext.existVariable( "bbr_sex" ) and len(TradeContext.bbr_sex.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "被保险人性别不存在"
            raise AfaFlowControl.flowException( )
              
        #被保险人出生日期
        if not( TradeContext.existVariable( "bbr_birth" ) and len(TradeContext.bbr_birth.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "被保险人出生日期不存在"
            raise AfaFlowControl.flowException( )
            
        #被保险人职业
        if not( TradeContext.existVariable( "bbr_worktype" ) and len(TradeContext.bbr_worktype.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "被保险人职业不存在"
            raise AfaFlowControl.flowException( ) 
             
        #与投保人关系
        if not( TradeContext.existVariable( "tbr_bbr_rela" ) and len(TradeContext.tbr_bbr_rela.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "与投保人关系不存在"
            raise AfaFlowControl.flowException( )  
        
        #柜员工号
        if not( TradeContext.existVariable( "tellers" ) and len(TradeContext.tellers.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "柜员工号不存在"
            raise AfaFlowControl.flowException( )
              
        #行社营销人员工号
        if not( TradeContext.existVariable( "salerno" ) and len(TradeContext.salerno.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "行社营销人员工号不存在"
            raise AfaFlowControl.flowException( ) 
             
        #凭证种类
        if not( TradeContext.existVariable( "I1CETY" ) and len(TradeContext.I1CETY.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "凭证种类不存在"
            raise AfaFlowControl.flowException( )  
        if(TradeContext.syr_type=='1'):      
            #初始化受益人信息 ,最多有五组   
            syr_name = []
            syr_idtype = []
            syr_idno = []
            syr_sex = []
            syr_order = []
            syr_bbr_rela = []
            syr_bent_profit_pcent = []
            syr_bent_profit_base = []
            
             
            #受益人1信息
            if TradeContext.existVariable( "syr_1" ) :  
                if not (len(TradeContext.syr_1.strip())>0 ):
                    syr_name.append("")
                    syr_idtype.append("")
                    syr_idno.append("")
                    syr_sex.append("")
                    syr_order.append("")
                    syr_bbr_rela.append("")
                    syr_bent_profit_pcent.append("")
                    syr_bent_profit_base.append("")
                else:
                    syr1=TradeContext.syr_1.split('|')
                    #受益人名字
                    syr_name.append(syr1[0])
                    #受益人证件类型
                    syr_idtype.append(syr1[1])
                    #受益人证件号码
                    syr_idno.append(syr1[2])
                    #受益人性别
                    syr_sex.append(syr1[3])
                    #受益顺序
                    syr_order.append(syr1[5])
                    #与受益人关系
                    syr_bbr_rela.append(syr1[6])
                    #受益份额(分子部分)
                    syr_bent_profit_pcent.append(syr1[7])
                    #受益份额(分母部分)
                    syr_bent_profit_base.append(syr1[8])
            
            
       
            #受益人2信息
            if  TradeContext.existVariable( "syr_2" ) :  
                if not (len(TradeContext.syr_2.strip())>0 ):
                    syr_name.append("")
                    syr_idtype.append("")
                    syr_idno.append("")
                    syr_sex.append("")
                    syr_order.append("")
                    syr_bbr_rela.append("")
                    syr_bent_profit_pcent.append("")
                    syr_bent_profit_base.append("")
                else:
                    syr2=TradeContext.syr_2.split('|')
                    #受益人名字
                    syr_name.append(syr2[0])
                    #受益人证件类型
                    syr_idtype.append(syr2[1])
                    #受益人证件号码
                    syr_idno.append(syr2[2])
                    #受益人性别
                    syr_sex.append(syr2[3])
                    #受益顺序
                    syr_order.append(syr2[5])
                    #与受益人关系
                    syr_bbr_rela.append(syr2[6])
                    #受益份额(分子部分)
                    syr_bent_profit_pcent.append(syr2[7])
                    #受益份额(分母部分)
                    syr_bent_profit_base.append(syr2[8])
                
                
            #受益人3信息
            if  TradeContext.existVariable( "syr_3" ):  
                if not (len(TradeContext.syr_3.strip())>0 ): 
                    syr_name.append("")   
                    syr_idtype.append("") 
                    syr_idno.append("")  
                    syr_sex.append("")      
                    syr_order.append("")    
                    syr_bbr_rela.append("") 
                    syr_bent_profit_pcent.append("")    
                    syr_bent_profit_base.append("")     
                else:
                    syr3=TradeContext.syr_3.split('|')
                    #受益人名字
                    syr_name.append(syr3[0])
                    #受益人证件类型
                    syr_idtype.append(syr3[1])
                    #受益人证件号码
                    syr_idno.append(syr3[2])
                    #受益人性别
                    syr_sex.append(syr3[3])
                    #受益顺序
                    syr_order.append(syr3[5])
                    #与受益人关系
                    syr_bbr_rela.append(syr3[6])
                    #受益份额(分子部分)
                    syr_bent_profit_pcent.append(syr3[7])
                    #受益份额(分母部分)
                    syr_bent_profit_base.append(syr3[8])
                
                
            #受益人4信息
            if  TradeContext.existVariable( "syr_4" ):  
                if not (len(TradeContext.syr_4.strip())>0 ):   
                    syr_name.append("")                        
                    syr_idtype.append("")                      
                    syr_idno.append("")                        
                    syr_sex.append("")                         
                    syr_order.append("")                       
                    syr_bbr_rela.append("")                    
                    syr_bent_profit_pcent.append("")           
                    syr_bent_profit_base.append("")            
                else:
                    syr4=TradeContext.syr_4.split('|')
                    #受益人名字
                    syr_name.append(syr4[0])
                    #受益人证件类型
                    syr_idtype.append(syr4[1])
                    #受益人证件号码
                    syr_idno.append(syr4[2])
                    #受益人性别
                    syr_sex.append(syr4[3])
                    #受益顺序
                    syr_order.append(syr4[5])
                    #与受益人关系
                    syr_bbr_rela.append(syr4[6])
                    #受益份额(分子部分)
                    syr_bent_profit_pcent.append(syr4[7])
                    #受益份额(分母部分)
                    syr_bent_profit_base.append(syr4[8]) 
                    
        
            #受益人5信息
            if  TradeContext.existVariable( "syr_5" ) :  
                
                if not (len(TradeContext.syr_5.strip())>0 ):   
                    syr_name.append("")                        
                    syr_idtype.append("")                      
                    syr_idno.append("")                        
                    syr_sex.append("")                         
                    syr_order.append("")                       
                    syr_bbr_rela.append("")                    
                    syr_bent_profit_pcent.append("")           
                    syr_bent_profit_base.append("")            
                else:
                    syr5=TradeContext.syr_5.split('|')
                    #受益人名字
                    syr_name.append(syr5[0])
                    #受益人证件类型
                    syr_idtype.append(syr5[1])
                    #受益人证件号码
                    syr_idno.append(syr5[2])
                    #受益人性别
                    syr_sex.append(syr5[3])
                    #受益顺序
                    syr_order.append(syr5[5])
                    #与受益人关系
                    syr_bbr_rela.append(syr5[6])
                    #受益份额(分子部分)
                    syr_bent_profit_pcent.append(syr5[7])
                    #受益份额(分母部分)
                    syr_bent_profit_base.append(syr5[8])    
       
            
            TradeContext.syr_name = syr_name
            TradeContext.syr_idtype = syr_idtype
            TradeContext.syr_idno = syr_idno
            TradeContext.syr_sex = syr_sex
            TradeContext.syr_order = syr_order
            TradeContext.syr_bbr_rela = syr_bbr_rela
            TradeContext.syr_bent_profit_pcent = syr_bent_profit_pcent
            TradeContext.syr_bent_profit_base = syr_bent_profit_base
            
        
        return True 
                
    except Exception, e:
        AfaLoggerFunc.tradeInfo( str(e) )
        AfaFlowControl.flowException( )       
Beispiel #24
0
def VouhTrans( ):
    #===定义变量-输入的凭证号码与库表中状态为‘1’(已出未入)的凭证号码的连续标志======
    #sFlagContinue:continue:前后连续;
    #sFlagContinue:FrontContinue:前连续;
    #sFlagContinue:BackContinue:后连续;
    sFlagContinue = ''
    
    #=============进入凭证出库交易==========================
    
    #1.查询需要出库的凭证起止号码是否在库表中已入未发的凭证号码范围内
    #2.如果需要出库的凭证起止号码在库表中可出库的凭证号码范围内,那么需要
    #  判断库表中满足凭证状态为已发未领,地区号与签到柜员所在地区一致这几个条件的记录
    #与输入的凭证号码是否有连续关系
    #3.如果无连续关系,那么需要判断输入的凭证起止号码与库表中相应的凭证号码区间的关系
    #  1)输入的起始号码与区间的起始号码相同. 2)输入的终止号码与区间的结束号码相同
    #  3)输入的起始号码和终止号码与区间起始和结束号码都相同. 4)输入的起止号码完全在区间之内
    #4.如果有连续关系,那么需要判断输入的凭证起止号码与库表中凭证状态为已发未领的
    #凭证号码之间的关系  1) 前连续 2)后连续  3)前后连续
    
    for i in range(TradeContext.sNum):
        
        #begin凭证优化201202 李利君
        Len=''
        Len = int(len(TradeContext.sStartNo[i]))
        
        #=============计算输入的凭证数量==========================
        sStartNoMulti = str(int( TradeContext.sStartNo[i] ) - 1).rjust(Len,'0')
        sEndNoAdd = str(int( TradeContext.sEndNo[i] ) + 1).rjust(Len,'0')
        #end
        
        #查询数据库[凭证登记表],确认是否输入的凭证起始号码,终止号码在该柜员登陆分行
        #登记未出状态的凭证号码段内
        sqlStr = "select STARTNO,ENDNO,LSTTRXDAY,LSTTRXTIME,RIVTELLER,TELLERNO \
            from VOUH_REGISTER \
            where VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' \
            and BESBNO = '" + TradeContext.sBesbNo + "'\
            and TELLERNO = '" + TradeContext.sTellerTailNo + "'\
            and CUR = '" + TradeContext.sCur + "'\
            and DEPOSITORY = '" + TradeContext.sExDepos + "'\
            and VOUHSTATUS = '" + TradeContext.sExStatus+ "' \
            and ( ENDNO >= '" + TradeContext.sEndNo[i] + "' and STARTNO <= '" + TradeContext.sStartNo[i] + "' )"
        records = AfaDBFunc.SelectSql( sqlStr )
        AfaLoggerFunc.tradeDebug(sqlStr)
        if( records == None ):          #查询凭证登记表异常
            if( i > 0 ):
                AfaLoggerFunc.tradeInfo( '数据库回滚' )
                AfaDBFunc.RollbackSql( )
            tradeExit('A005061', '查询[凭证登记表]操作异常!')
            raise AfaFlowControl.flowException( )
        elif( len( records ) == 0 ):    #如果凭证登记表中无对应记录
            if( i > 0 ):
                AfaLoggerFunc.tradeInfo( '数据库回滚' )
                AfaDBFunc.RollbackSql( )
            tradeExit('A005067', '凭证操作失败,凭证库中不存在本次操作的凭证!')
            raise AfaFlowControl.flowException( )
        else :
            records = AfaUtilTools.ListFilterNone( records )
            sTempStartNo = records[0][0]           #保存输入的凭证号码所在的区间起始凭证号码
            sTempEndNo   = records[0][1]           #保存输入的凭证号码所在的区间终止凭证号码
            sTempLstTrxDay   = records[0][2]       #保存输入的凭证号码所在的区间最后交易日期
            sTempLstTrxTime  = records[0][3]       #保存输入的凭证号码所在的区间最后交易时间
            sTempRivTeller   = records[0][4]       #保存输入的凭证号码所在的区间对方柜员
            sTempTellerNo   = records[0][5]        #保存输入的凭证号码所在的区间对方柜员
        
            #当输入的凭证起止号码为合法号码时,查询库表中满足状态为已发未领,
            #柜员号地区号与签到柜员所在地区一致的条件的记录与输入的凭证号码是否有连续关系
            sqlStr = "select STARTNO,ENDNO from VOUH_REGISTER \
                    where VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' \
                    and BESBNO = '" + TradeContext.sInBesbNo + "'\
                    and TELLERNO = '" + TradeContext.sInTellerTailNo + "'\
                    and CUR = '" + TradeContext.sCur + "'\
                    and DEPOSITORY = '" + TradeContext.sDepository + "'\
                    and VOUHSTATUS = '"+ TradeContext.sVouhStatus+ "' \
                    and ( ENDNO = '" + sStartNoMulti + "' \
                    OR STARTNO = '" + sEndNoAdd + "' )"
    
            AfaLoggerFunc.tradeDebug(sqlStr)
            records = AfaDBFunc.SelectSql( sqlStr )
            records = AfaUtilTools.ListFilterNone( records )
            if( records == None ):          #查询凭证登记表异常
                if( i > 0 ):
                    AfaLoggerFunc.tradeInfo( '数据库回滚' )
                    AfaDBFunc.RollbackSql( )
                tradeExit('A005061', '查询[凭证登记表]操作异常!')
                raise AfaFlowControl.flowException( )
        
            #输入的凭证号码与库中已存在的状态为登记未出的凭证号码无连续关系
            elif( len( records ) == 0 ):
                #输入的起始号码和终止号码与区间起始和结束号码都相同
                if ( int( TradeContext.sEndNo[i] ) == int( sTempEndNo ) \
                    and int( TradeContext.sStartNo[i] ) == int( sTempStartNo ) ):
                    #直接更新对应记录
                    sqlStr = "update VOUH_REGISTER set \
                           DEPOSITORY = '"+TradeContext.sDepository+"',\
                           VOUHSTATUS = '"+ TradeContext.sVouhStatus+ "',\
                           BESBNO = '" + TradeContext.sInBesbNo + "', \
                           TELLERNO = '" + TradeContext.sInTellerTailNo + "', \
                           RIVTELLER = '" + TradeContext.sTellerTailNo + "', \
                           LSTTRXDAY = '" + TradeContext.sLstTrxDay + "',\
                           LSTTRXTIME = '" + TradeContext.sLstTrxTime + "'"
                    sqlStr = sqlStr + " where STARTNO = '" + TradeContext.sStartNo[i] + "' \
                            and DEPOSITORY = '" + TradeContext.sExDepos + "'\
                            and BESBNO = '" + TradeContext.sBesbNo + "'\
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "'\
                            and VOUHSTATUS = '" + TradeContext.sExStatus+ "' \
                            and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' \
                            and CUR = '"+ TradeContext.sCur+"'"
    
                    AfaLoggerFunc.tradeDebug('1'+sqlStr)
                    records = AfaDBFunc.UpdateSql( sqlStr )
                    if records == -1 or records == 0 :
                        AfaLoggerFunc.tradeInfo( '数据库回滚' )
                        AfaDBFunc.RollbackSql( )
                        tradeExit('A005062', TradeContext.sTransType+'失败!')
                        raise AfaFlowControl.flowException( )
                    else:
                        tradeExit('0000', TradeContext.sTransType+'成功')
        
                #输入的终止号码与区间的结束号码相同
                elif ( int( TradeContext.sEndNo[i] ) == int( sTempEndNo ) ):
                    #更新数据库中已存记录,更新成功后再新增出库记录
                    sqlStr = "update VOUH_REGISTER set \
                      VOUHNUM = '"+ ( str( int( TradeContext.sStartNo[i] ) - int( sTempStartNo ) ) )+ "',\
                      ENDNO = '" + sStartNoMulti + "'"
                    sqlStr = sqlStr + " where STARTNO = '" + sTempStartNo + "' \
                       and DEPOSITORY = '" + TradeContext.sExDepos + "'\
                       and BESBNO = '" + TradeContext.sBesbNo + "'\
                       and TELLERNO = '" + TradeContext.sTellerTailNo + "'\
                       and VOUHSTATUS = '" + TradeContext.sExStatus+ "' \
                       and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' \
                       and CUR ='"+ TradeContext.sCur+"'"
    
                    AfaLoggerFunc.tradeDebug('2'+sqlStr)
                    records = AfaDBFunc.UpdateSql( sqlStr )
                    if records == -1 or records == 0 :
                        AfaLoggerFunc.tradeInfo( '数据库回滚' )
                        AfaDBFunc.RollbackSql( )
                        tradeExit('A005062', TradeContext.sTransType+'失败!')
                        raise AfaFlowControl.flowException( )
                    else:
                        #更新成功后再新增出库记录
                        sqlStr = "insert into VOUH_REGISTER \
                         (BESBNO,TELLERNO,DEPOSITORY,CUR,VOUHTYPE,STARTNO,ENDNO,RIVTELLER,\
                          VOUHSTATUS,VOUHNUM,LSTTRXDAY,LSTTRXTIME) \
                          values \
                          ('" + TradeContext.sInBesbNo + "',\
                           '" + TradeContext.sInTellerTailNo + "','"+TradeContext.sDepository+"','"+ TradeContext.sCur+"',\
                           '"+ TradeContext.sVouhType[i] + "',\
                           '" + TradeContext.sStartNo[i] + "','" + sTempEndNo + "',\
                           '" + TradeContext.sTellerTailNo +"','"+ TradeContext.sVouhStatus+ "',\
                           '" + TradeContext.sVouhNum[i] + "',\
                           '" + TradeContext.sLstTrxDay + "','" + TradeContext.sLstTrxTime + "')"
                        record = AfaDBFunc.InsertSql( sqlStr )
                        if record == -1 or record == 0:
                            AfaLoggerFunc.tradeInfo( '数据库回滚' )
                            record = AfaDBFunc.RollbackSql( )
                            tradeExit('A005062', TradeContext.sTransType+'失败!')
                            raise AfaFlowControl.flowException( )
                        else: #调配成功
                            tradeExit('0000', TradeContext.sTransType+'成功')
        
                #输入的起始号码与区间的起始号码相同
                elif ( int( TradeContext.sStartNo[i] ) == int( sTempStartNo ) ):
                    #更新数据库中已存记录,更新成功后再新增出库记录
                    sqlStr = "update VOUH_REGISTER set \
                        VOUHNUM = '" + str( int( sTempEndNo ) - int ( TradeContext.sEndNo[i] ) )+ "',\
                        STARTNO = '" + sEndNoAdd + "'"
                    sqlStr = sqlStr + " where ENDNO = '" + sTempEndNo + "' \
                        and DEPOSITORY = '" + TradeContext.sExDepos + "'\
                        and BESBNO = '" + TradeContext.sBesbNo + "'\
                        and TELLERNO = '" + TradeContext.sTellerTailNo + "'\
                        and VOUHSTATUS = '" + TradeContext.sExStatus+ "' \
                        and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' \
                        and CUR ='"+ TradeContext.sCur+"'"
    
                    AfaLoggerFunc.tradeDebug('3'+sqlStr)
                    records = AfaDBFunc.UpdateSql( sqlStr )
                    if records == -1 or records == 0 :
                        AfaLoggerFunc.tradeInfo( '数据库回滚' )
                        record = AfaDBFunc.RollbackSql( )
                        tradeExit('A005062', TradeContext.sTransType+'失败!')
                        raise AfaFlowControl.flowException( )
                    else:
                        #更新成功后再新增出库记录
                        sqlStr = "insert into VOUH_REGISTER \
                           (BESBNO,TELLERNO,DEPOSITORY,CUR,VOUHTYPE,STARTNO,ENDNO,RIVTELLER,\
                            VOUHSTATUS,VOUHNUM,LSTTRXDAY,LSTTRXTIME) \
                            values \
                            ('" + TradeContext.sInBesbNo + "',\
                             '" + TradeContext.sInTellerTailNo + "','"+TradeContext.sDepository+"',\
                             '" + TradeContext.sCur+"',\
                             '" + TradeContext.sVouhType[i]+"',\
                             '" + sTempStartNo + "',\
                             '" + TradeContext.sEndNo[i] + "','"+TradeContext.sTellerTailNo+"',\
                             '" + TradeContext.sVouhStatus+ "','" + TradeContext.sVouhNum[i] + "',\
                             '" + TradeContext.sLstTrxDay + "',\
                             '" + TradeContext.sLstTrxTime + "')"
                        AfaLoggerFunc.tradeDebug('1'+sqlStr)
                        record = AfaDBFunc.InsertSql( sqlStr )
                        if record == -1 or record == 0 :
                            AfaLoggerFunc.tradeInfo( '数据库回滚' )
                            record = AfaDBFunc.RollbackSql( )
                            tradeExit('A005062', TradeContext.sTransType+'失败!')
                            raise AfaFlowControl.flowException( )
                        else: #调配成功
                            tradeExit('0000', TradeContext.sTransType+'成功')
                #输入的起止号码完全包含在区间之内
                else:
                    #1更新数据库中已存记录,更新成功后再新增出库记录和相应登记未出状态记录
                    sqlStr = "update VOUH_REGISTER set \
                       VOUHNUM = '" + str( int( TradeContext.sStartNo[i] ) - int( sTempStartNo ) ) + "',\
                       ENDNO = '" + sStartNoMulti + "'"
                    sqlStr = sqlStr + " where STARTNO = '" + sTempStartNo + "' \
                        and DEPOSITORY = '" + TradeContext.sExDepos + "'\
                        and BESBNO = '" + TradeContext.sBesbNo + "'\
                        and TELLERNO = '" + TradeContext.sTellerTailNo + "'\
                        and VOUHSTATUS = '" + TradeContext.sExStatus+ "' \
                        and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' \
                        and CUR ='"+ TradeContext.sCur+"'"
    
                    AfaLoggerFunc.tradeDebug('4'+sqlStr)
                    records = AfaDBFunc.UpdateSql( sqlStr )
                    if records == -1 or records == 0 :
                        AfaLoggerFunc.tradeInfo( '数据库回滚' )
                        record = AfaDBFunc.RollbackSql( )
                        tradeExit('A005062', '新增[凭证登记表]基本信息失败!')
                        raise AfaFlowControl.flowException( )
    
                    #2##############更新成功后再新增出库记录###########################################
                    sqlStr = "insert into VOUH_REGISTER \
                       (BESBNO,TELLERNO,DEPOSITORY,CUR,VOUHTYPE,STARTNO,ENDNO,RIVTELLER,\
                        VOUHSTATUS,VOUHNUM,LSTTRXDAY,LSTTRXTIME) \
                        values \
                        ('" + TradeContext.sInBesbNo + "',\
                         '" + TradeContext.sInTellerTailNo + "','"+TradeContext.sDepository+"',\
                         '" + TradeContext.sCur+"',\
                         '" + TradeContext.sVouhType[i]+"',\
                         '" + TradeContext.sStartNo[i] + "',\
                         '" + TradeContext.sEndNo[i] + "','"+TradeContext.sTellerTailNo+"',\
                         '" + TradeContext.sVouhStatus+ "','" + TradeContext.sVouhNum[i] + "',\
                         '" + TradeContext.sLstTrxDay + "',\
                         '" + TradeContext.sLstTrxTime + "')"
                    AfaLoggerFunc.tradeDebug('2'+sqlStr)
                    record = AfaDBFunc.InsertSql( sqlStr )
                    if record == -1 or record == 0 :
                        AfaLoggerFunc.tradeInfo( '数据库回滚' )
                        record = AfaDBFunc.RollbackSql( )
                        tradeExit('A005062', TradeContext.sTransType+'失败!')
                        raise AfaFlowControl.flowException( )
    
                    #3新增新增出库记录成功后,新增相应登记未出状态记录
                    sqlStr = "insert into VOUH_REGISTER \
                      (BESBNO,TELLERNO,DEPOSITORY,CUR,VOUHTYPE,STARTNO,ENDNO,RIVTELLER,\
                        VOUHSTATUS,VOUHNUM,LSTTRXDAY,LSTTRXTIME) \
                       values \
                       ('" + TradeContext.sBesbNo + "',\
                        '" + sTempTellerNo + "','"+TradeContext.sExDepos+ "','"+TradeContext.sCur+"',\
                        '" + TradeContext.sVouhType[i]+"',\
                        '" + sEndNoAdd + "',\
                        '" + sTempEndNo + "','"+sTempRivTeller+"',\
                        '"+ TradeContext.sExStatus+ "',\
                        '" + str( int( sTempEndNo ) - int ( TradeContext.sEndNo[i] ) )+ "',\
                        '" + sTempLstTrxDay + "',\
                        '" + sTempLstTrxTime + "')"
                    AfaLoggerFunc.tradeDebug('3'+sqlStr)
                    record = AfaDBFunc.InsertSql( sqlStr )
                    if record == -1 or record == 0 :
                        AfaLoggerFunc.tradeInfo( '数据库回滚' )
                        record = AfaDBFunc.RollbackSql( )
                        tradeExit('A005062', TradeContext.sTransType+'失败!')
                        raise AfaFlowControl.flowException( )
                    #新增成功
                    tradeExit('0000', '操作成功')
        
            else:      #判断前后连续关系
                #continue:前后连续标识;
                #FrontContinue:前连续标识;
                #BackContinue:后连续标识;
                for x in range( len(records) ):
                    if ( ( int( TradeContext.sStartNo[i] ) - 1 )  == int( records[x][1] ) ): #前连续
                        sTempStart = records[x][0] #records[x][0]:数据库中满足查询条件的凭证起始号码
                        if ( sFlagContinue == 'BackContinue' ):
                            sFlagContinue = 'Continue'
                        else:
                            sFlagContinue = 'FrontContinue'
                    if ( (int( TradeContext.sEndNo[i]) + 1 )  == int( records[x][0] ) ):  #后连续
                        sTempEnd   = records[x][1] #records[x][1]:数据库中满足查询条件的凭证终止号码
                        if ( sFlagContinue == 'FrontContinue' ):
                            sFlagContinue = 'Continue'
                        else:
                            sFlagContinue = 'BackContinue'
        
                #输入的凭证号码与库表中同凭证状态为登记未出的记录存在后连续关系,
                #则与相应的记录进行向后归并
                if (  sFlagContinue == 'BackContinue' ):
                    #1后连续:更新相应数据库中[凭证登记表]相应记录
                    sqlStr = "update VOUH_REGISTER set \
                      VOUHNUM = '" + str( int( sTempEnd ) - int( TradeContext.sStartNo[i] ) + 1 ) + "',\
                      LSTTRXDAY = '" + TradeContext.sLstTrxDay + "',\
                      LSTTRXTIME = '" + TradeContext.sLstTrxTime + "',\
                      STARTNO = '" + TradeContext.sStartNo[i] + "'"
                    sqlStr = sqlStr + " where STARTNO = '" + sEndNoAdd  + "'\
                      and TELLERNO = '" + TradeContext.sInTellerTailNo + "' \
                      and BESBNO = '" + TradeContext.sInBesbNo + "'\
                      and CUR = '" + TradeContext.sCur + "'\
                      and DEPOSITORY = '" + TradeContext.sDepository + "'\
                      and VOUHSTATUS = '"+ TradeContext.sVouhStatus+ "' \
                      and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "'"
                    AfaLoggerFunc.tradeDebug('5'+sqlStr)
                    records = AfaDBFunc.UpdateSql( sqlStr )
                    if records == -1 or records == 0 :
                        AfaLoggerFunc.tradeInfo( '数据库回滚' )
                        record = AfaDBFunc.RollbackSql( )
                        tradeExit('A005062', TradeContext.sTransType+'失败!')
                        raise AfaFlowControl.flowException( )
    
                        #2更新成功后,删除起始号码为sTempStartNo的原记录,输入凭证数量为1
                    if ( int( sTempStartNo ) == int( TradeContext.sStartNo[i] ) ) :
                        sqlDel = "delete from VOUH_REGISTER \
                            where STARTNO = '" + sTempStartNo + "' \
                            and DEPOSITORY = '" + TradeContext.sExDepos + "'\
                            and BESBNO = '" + TradeContext.sBesbNo + "'\
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "'\
                            and VOUHSTATUS = '" + TradeContext.sExStatus+ "' \
                            and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' \
                            and CUR ='"+ TradeContext.sCur+"'"
                        AfaLoggerFunc.tradeDebug(sqlDel)
                        record = AfaDBFunc.DeleteSql( sqlDel )
                        if record == -1 or record == 0 :
                            AfaLoggerFunc.tradeInfo( '数据库回滚' )
                            record = AfaDBFunc.RollbackSql( )
                            tradeExit('A005062', TradeContext.sTransType+'失败!')
                            raise AfaFlowControl.flowException( )
                        else:
                            tradeExit('0000', TradeContext.sTransType+'成功')
                    else:
                        #更新成功后,更新终止号码为TradeContext.sEndNo的原记录,输入凭证数量大于1
                        sqlStr = "update VOUH_REGISTER set \
                          VOUHNUM = '" + str( int( TradeContext.sStartNo[i] ) - int( sTempStartNo ) )+ "',\
                          LSTTRXDAY = '" + TradeContext.sLstTrxDay + "',\
                          LSTTRXTIME = '" + TradeContext.sLstTrxTime + "',\
                          ENDNO = '" +  sStartNoMulti  + "'"
                        sqlStr = sqlStr + " where ENDNO = '" + TradeContext.sEndNo[i] + "' \
                            and DEPOSITORY = '" + TradeContext.sExDepos + "'\
                            and BESBNO = '" + TradeContext.sBesbNo + "'\
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "'\
                            and VOUHSTATUS = '" + TradeContext.sExStatus+ "' \
                            and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' \
                            and CUR ='"+ TradeContext.sCur+"'"
    
                        AfaLoggerFunc.tradeDebug('6'+sqlStr)
                        record = AfaDBFunc.UpdateSql( sqlStr )
                        if record == -1 or record == 0:
                            AfaLoggerFunc.tradeInfo( '数据库回滚' )
                            record = AfaDBFunc.RollbackSql( )  #回滚
                            tradeExit('A005062', TradeContext.sTransType+'失败!')
                            raise AfaFlowControl.flowException( )
                        else:
                            tradeExit('0000', '操作成功')
        
                #输入的凭证号码与库表中同凭证状态为登记未出存在前连续关系,
                #则与相应的记录进行向前归并
                elif ( sFlagContinue == 'FrontContinue' ):
                    #前连续:更新相应数据库中[凭证登记表]相应记录
                    sqlStr = "update VOUH_REGISTER set \
                       VOUHNUM = '" + str( int( TradeContext.sEndNo[i] ) - int( sTempStart ) + 1 ) + "',\
                       LSTTRXDAY = '" + TradeContext.sLstTrxDay + "',\
                       LSTTRXTIME = '" + TradeContext.sLstTrxTime + "',\
                       ENDNO = '" + ( TradeContext.sEndNo[i] ) + "'"
                    sqlStr = sqlStr + " where ENDNO = '" + sStartNoMulti + "'\
                        and TELLERNO = '" + TradeContext.sInTellerTailNo + "' \
                        and BESBNO = '" + TradeContext.sInBesbNo + "'\
                        and CUR = '" + TradeContext.sCur + "'\
                        and DEPOSITORY = '" + TradeContext.sDepository + "'\
                        and VOUHSTATUS = '"+ TradeContext.sVouhStatus+ "' \
                        and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "'"
    
                    AfaLoggerFunc.tradeDebug('7'+sqlStr)
                    records = AfaDBFunc.UpdateSql( sqlStr )
                    if records == -1 or records == 0 :
                        AfaLoggerFunc.tradeInfo( '数据库回滚' )
                        AfaDBFunc.RollbackSql( )  #回滚
                        tradeExit('A005062', TradeContext.sTransType+'失败!')
                        raise AfaFlowControl.flowException( )
    
                    #2更新成功后,删除起始号码为sTempStartNo的原记录,输入凭证数量为1
                    if ( int( sTempEndNo ) == int( TradeContext.sEndNo[i] ) ) :
                        sqlDel = "delete from VOUH_REGISTER \
                            where STARTNO = '" + sTempStartNo + "' \
                            and DEPOSITORY = '" + TradeContext.sExDepos + "'\
                            and BESBNO = '" + TradeContext.sBesbNo + "'\
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "'\
                            and VOUHSTATUS = '" + TradeContext.sExStatus+ "' \
                            and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' \
                            and CUR ='"+ TradeContext.sCur+"'"
    
                        AfaLoggerFunc.tradeDebug(sqlDel)
                        record = AfaDBFunc.DeleteSql( sqlDel )
                        if record == -1 or record == 0 :
                            AfaLoggerFunc.tradeInfo( '数据库回滚' )
                            record = AfaDBFunc.RollbackSql( )
                            tradeExit('A005062', TradeContext.sTransType+'失败!')
                            raise AfaFlowControl.flowException( )
                        else:    #更新成功
                            tradeExit('0000', '操作成功')
                    else:
                        #更新成功后,更新起始号码为TradeContext.sStartNo的原记录,输入凭证数量大于1
                        sqlStr = "update VOUH_REGISTER set \
                           VOUHNUM = '" + str( int( sTempEndNo ) - int( TradeContext.sEndNo[i] ) ) + "',\
                           LSTTRXDAY = '" + TradeContext.sLstTrxDay + "',\
                           LSTTRXTIME = '" + TradeContext.sLstTrxTime + "',\
                           STARTNO = '" + sEndNoAdd  + "'"
                        sqlStr = sqlStr + " where STARTNO = '" + TradeContext.sStartNo[i] + "' \
                           and DEPOSITORY = '" + TradeContext.sExDepos + "'\
                            and BESBNO = '" + TradeContext.sBesbNo + "'\
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "'\
                            and VOUHSTATUS = '" + TradeContext.sExStatus+ "' \
                            and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' \
                            and CUR ='"+ TradeContext.sCur+"'"
    
                        AfaLoggerFunc.tradeDebug('8'+sqlStr)
                        record = AfaDBFunc.UpdateSql( sqlStr )
                        if record == -1 or record == 0 :
                            AfaLoggerFunc.tradeInfo( '数据库回滚' )
                            record = AfaDBFunc.RollbackSql( )
                            tradeExit('A005062', TradeContext.sTransType+'失败!')
                            raise AfaFlowControl.flowException( )
                        else:   #更新成功
                            tradeExit('0000', '操作成功')
        
            #输入的凭证号码与库表中同凭证状态为登记未出存在前后连续关系,
            #则与相应的记录进行前后归并
                elif (  sFlagContinue == 'Continue' ):
                    sTemVouhNum = str( int(sTempEnd) - int(sTempStart) + 1 )
                    #更新数据库表[凭证登记表]内相应记录
                    sqlStr = "update VOUH_REGISTER set \
                       ENDNO = '" + sTempEnd + "', \
                       VOUHNUM = '" + sTemVouhNum + "',\
                       LSTTRXDAY = '" + TradeContext.sLstTrxDay + "',\
                       LSTTRXTIME = '" + TradeContext.sLstTrxTime + "'"
                    sqlStr = sqlStr + " where STARTNO = '" + sTempStart + "' \
                       and TELLERNO = '" + TradeContext.sInTellerTailNo + "' \
                        and BESBNO = '" + TradeContext.sInBesbNo + "'\
                        and CUR = '" + TradeContext.sCur + "'\
                        and DEPOSITORY = '" + TradeContext.sDepository + "'\
                        and VOUHSTATUS = '"+ TradeContext.sVouhStatus+ "' \
                        and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "'"
    
                    AfaLoggerFunc.tradeDebug('9'+sqlStr)
                    records = AfaDBFunc.UpdateSql( sqlStr )
                    if records == -1 or records == 0 :
                        AfaLoggerFunc.tradeInfo( '数据库回滚' )
                        record = AfaDBFunc.RollbackSql( )
                        tradeExit('A005062', TradeContext.sTransType+'失败!')
                        raise AfaFlowControl.flowException( )
    
                    #2归并成功后,删除归并后其余一条
                    sqlDel = "delete from VOUH_REGISTER \
                       where STARTNO = '" + TradeContext.sStartNo[i] + "' \
                            and DEPOSITORY = '" + TradeContext.sExDepos + "'\
                            and BESBNO = '" + TradeContext.sBesbNo + "'\
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "'\
                            and VOUHSTATUS = '" + TradeContext.sExStatus+ "' \
                            and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "' \
                            and CUR ='"+ TradeContext.sCur+"'"
                    AfaLoggerFunc.tradeDebug(sqlDel)
                    record = AfaDBFunc.DeleteSql( sqlDel )
                    if record == -1 or record == 0 :
                        AfaLoggerFunc.tradeInfo( '数据库回滚' )
                        record = AfaDBFunc.RollbackSql( )
                        tradeExit('A005062', TradeContext.sTransType+'失败!')
                        raise AfaFlowControl.flowException( )
                    # 3
                    sqlDel = "delete from VOUH_REGISTER \
                      where STARTNO = '" + sEndNoAdd + "' \
                        and TELLERNO = '" + TradeContext.sInTellerTailNo + "' \
                        and BESBNO = '" + TradeContext.sInBesbNo + "'\
                        and CUR = '" + TradeContext.sCur + "'\
                        and DEPOSITORY = '" + TradeContext.sDepository + "'\
                        and VOUHSTATUS = '"+ TradeContext.sVouhStatus+ "' \
                        and VOUHTYPE = '" + TradeContext.sVouhType[i]+ "'"
                    AfaLoggerFunc.tradeDebug(sqlDel)
                    record = AfaDBFunc.DeleteSql( sqlDel )
                    if record == -1 or record == 0 :
                        AfaLoggerFunc.tradeInfo( '数据库回滚' )
                        record = AfaDBFunc.RollbackSql( )
                        tradeExit('A005062', TradeContext.sTransType+'失败!')
                        raise AfaFlowControl.flowException( )
    
                    tradeExit('0000', '操作成功')
                        
    return True
Beispiel #25
0
def main( ):

    sernoFlag = 0
    
    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( "zoneno" ) ):
            TradeFunc.exitOnError( 'A0001', '地区号[zoneno]值不存在,不能进行查询操作' )


        if( not TradeContext.existVariable( "brno" ) ):
            TradeFunc.exitOnError( 'A0001', '网点号[brno]值不存在,不能进行查询操作' )


        if( not TradeContext.existVariable( "tellerno" ) ):
            TradeFunc.exitOnError( 'A0001', '网点号[tellerno]值不存在,不能进行查询操作' )


        if( not TradeContext.existVariable( "transStatus" ) ):
            TradeFunc.exitOnError( 'A0001', '交易状态[transStatus]值不存在,不能进行查询操作' )


        if( not TradeContext.existVariable( "queryMode" ) ):
            TradeFunc.exitOnError( 'A0001', '查询方式[queryMode]值不存在,不能进行查询操作' )


        if( not TradeContext.existVariable( "orderMode" ) ):
            TradeFunc.exitOnError( 'A0001', '排序方式[orderMode]值不存在,不能进行查询操作' )


        if( not TradeContext.existVariable( "queryCount" ) ):
            TradeFunc.exitOnError( 'A0001', '查询条数[queryCount]值不存在,不能进行查询操作' )


        if( not TradeContext.existVariable( "TransType" ) ):
            TradeFunc.exitOnError( 'A0001', '传输类型[TransType]值不存在,不能进行查询操作' )


        AfaLoggerFunc.tradeInfo('>>>transStatus   = ' + TradeContext.transStatus)
        AfaLoggerFunc.tradeInfo('>>>queryMode     = ' + TradeContext.queryMode)
        AfaLoggerFunc.tradeInfo('>>>orderMode     = ' + TradeContext.orderMode)
        AfaLoggerFunc.tradeInfo('>>>queryCount    = ' + TradeContext.queryCount)
        AfaLoggerFunc.tradeInfo('>>>TransType     = ' + TradeContext.TransType)
        AfaLoggerFunc.tradeInfo('>>>tradeDate     = ' + TradeContext.tradeDate)


        #=====================定义每次返回的数据的记录数========================
        queryCount = int( TradeContext.queryCount )


        #=====================数据打包时使用list================================
        names=['agentSerialno', 'sysId', 'unitno', 'subUnitno', 'workDate', 'workTime','agentFlag', 'transCode', 'zoneno', 'brno', 'tellerno', \
        'channelCode', 'accType', 'drAccno', 'crAccno', 'userno', 'subuserno', 'username', 'vouhType', 'vouhno', \
        'vouhDate', 'amount', 'subAmount', 'bankStatus', 'bankSerno', 'corpStatus', 'errormsg', 'note1', \
        'note2', 'note3', 'note4', 'note5', 'note6', 'note7', 'note8', 'note9', 'note10']


        # =====================查询字段与数据打包的list一一对应=================
        SqlStr = "SELECT AGENTSERIALNO,SYSID,UNITNO,SUBUNITNO,WORKDATE,WORKTIME,AGENTFLAG,TRXCODE,ZONENO,BRNO,TELLERNO,"
        SqlStr = SqlStr + "CHANNELCODE,ACCTYPE,DRACCNO,CRACCNO,USERNO,SUBUSERNO,USERNAME,VOUHTYPE,VOUHNO,"
        SqlStr = SqlStr + "VOUHDATE,AMOUNT,SUBAMOUNT,BANKSTATUS,BANKSERNO,CORPSTATUS,ERRORMSG,NOTE1,"
        SqlStr = SqlStr + "NOTE2,NOTE3,NOTE4,NOTE5,NOTE6,NOTE7,NOTE8,NOTE9,NOTE10 FROM AFA_MAINTRANSDTL "


        #=====================统计总笔数和总金额================================
        sql_count = "SELECT COUNT(*),SUM(CAST(AMOUNT AS DECIMAL(17,2))) FROM AFA_MAINTRANSDTL"

        sql = ''
        if ( int( TradeContext.queryMode ) == 4 ):              #自由查询方式
            if( not TradeContext.existVariable( "whereClause" ) ):
                TradeFunc.exitOnError( 'A0001', '查询条件[whereClause]值不存在,不能进行查询操作' )

            sql= sql + TradeContext.whereClause + " AND REVTRANF='0' "

            AfaLoggerFunc.tradeInfo('>>>whereClause   = ' + TradeContext.whereClause)

        else:
            if( not TradeContext.existVariable( "tradeDate" ) ):
                TradeFunc.exitOnError( 'A0001', '交易日期[tradeDate]值不存在,不能进行查询操作' )

            if( not TradeContext.existVariable( "channelCode" ) ):
                TradeFunc.exitOnError( 'A0001', '渠道代码[channelCode]值不存在,不能进行查询操作' )

            #日期
            sql = sql + " WHERE WORKDATE='"     + TradeContext.tradeDate        + "'"

            #地区号
            sql = sql + " AND CHANNELCODE='"    + TradeContext.channelCode      + "'"

            #地区号
            sql = sql + " AND ZONENO='"         + TradeContext.zoneno           + "'"

            #网点号
            sql = sql + " AND BRNO='"           + TradeContext.brno             + "'"

            #柜员
            sql = sql + " AND TELLERNO='"       + TradeContext.tellerno         + "'"

            #柜员
            sql = sql + " AND REVTRANF='"       + "0"                           + "'"
            
            #用户
            if( TradeContext.existVariable( "userno" ) and len(TradeContext.userno)>0 ):
                sql = sql + " AND USERNO='"     + TradeContext.userno           + "'"

            #金额
            if( TradeContext.existVariable( "amount" ) and int(float(TradeContext.amount)*100)!=0 ):
                sAmount="0.00";
                for i in range(0, len(TradeContext.amount)):
                    if TradeContext.amount[i] == '0':
                        continue
                    sAmount = TradeContext.amount[i:]
                    break

                sql = sql + " AND AMOUNT='"     + sAmount           + "'"

            #用户名
            if( TradeContext.existVariable( "username" ) and len(TradeContext.username)>0 ):
                sql = sql + " AND USERNAME='******'"

            #帐号
            if( TradeContext.existVariable( "accno" ) and len(TradeContext.accno)>0 ):
                sql = sql + " AND (DRACCNO='"   + TradeContext.accno + "' OR CRACCNO='" + TradeContext.accno + "')"

        #transStatus:交易状态(1-正常, 2-未知, 3-全部)
        if( int( TradeContext.transStatus )   == 1 ):

            #查询正常交易
            sql = sql + " AND BANKSTATUS='0' AND CORPSTATUS='0'"

        elif( int( TradeContext.transStatus ) == 2 ):

            #查询未知交易
            sql = sql + " AND (AGENTFLAG IN ('01','03') AND (BANKSTATUS='2' OR (BANKSTATUS='0' AND CORPSTATUS IN ('1', '2','3')))) OR"
            sql = sql + " (AGENTFLAG IN ('02','04') AND (CORPSTATUS='2' OR (CORPSTATUS='0' AND BANKSTATUS IN ('1', '2','3')))) "

        elif( int( TradeContext.transStatus ) != 3 ):
            TradeContext.errorCode, TradeContext.errorMsg='A0041', "入口参数条件不符[交易状态]:"+str( TradeContext.transStatus )
            raise AfaFlowControl.flowException( )


        #queryMode:查询方式(1-按流水号查询, 2-按系统代码查询, 3-查询全部正交易, 4-自由查询方式)
        if( int( TradeContext.queryMode ) == 1 ):

            #按流水号查询
            if( not TradeContext.existVariable( "agentSerialno" ) ):
                TradeFunc.exitOnError( 'A0001', '流水号[agentSerialno]值不存在!' )

            sql = sql + " AND AGENTSERIALNO='"+TradeContext.agentSerialno + "'"
            sernoFlag = 1
            
        elif( int( TradeContext.queryMode ) == 2 ):

            #按系统代码查询
            if( not TradeContext.existVariable( "sysId" ) ):
                TradeFunc.exitOnError( 'A0001', '系统代码[sysId]值不存在!' )

            #系统代码
            sql = sql + " AND SYSID='"       + TradeContext.sysId     + "'"


            #按流水号查询
            if( TradeContext.existVariable( "agentSerialno" ) and len(TradeContext.agentSerialno)>0 ):
                sql = sql + " AND AGENTSERIALNO='"+TradeContext.agentSerialno + "'"
                sernoFlag = 1

            #业务方式
            if( TradeContext.existVariable( "agentFlag" ) and len(TradeContext.agentFlag)>0 ):
                sql=sql + " AND AGENTFLAG='" + TradeContext.agentFlag + "'"


            #单位代码
            if( TradeContext.existVariable( "unitno" ) and len(TradeContext.unitno)>0 ):
                sql=sql + " AND UNITNO='"    + TradeContext.unitno    + "'"


            #子单位代码
            if( TradeContext.existVariable( "subUnitno" ) and len(TradeContext.subUnitno)>0 ):
                sql=sql + " AND SUBUNITNO='" + TradeContext.subUnitno + "'"


        elif( int( TradeContext.queryMode ) != 3 and int( TradeContext.queryMode ) != 4 ):
            TradeContext.errorCode, TradeContext.errorMsg='A0041', "入口参数条件不符[查询方式]:"+str( TradeContext.queryMode )
            raise AfaFlowControl.flowException( )

        sql_count = sql_count + sql


        #按流水查询应该是单结果集的,没有排序的必要
        if( int( TradeContext.queryMode ) != 1  and sernoFlag==0):

            #orderMode:排序方式:1-正序 2-逆序
            if( int( TradeContext.orderMode ) == 1 ):

                #正序
                if( (not TradeContext.existVariable( "agentSerialno" )) or TradeContext.agentSerialno=='' ):
                    TradeContext.agentSerialno='0'

                sql = sql + " AND AGENTSERIALNO>'" + TradeContext.agentSerialno + "' ORDER BY AGENTSERIALNO ASC"

            else:

                #逆序
                if( (not TradeContext.existVariable( "agentSerialno" )) or TradeContext.agentSerialno=='' ):
                    TradeContext.agentSerialno='99999999'

                sql = sql + " AND AGENTSERIALNO<'"+TradeContext.agentSerialno + "' ORDER BY AGENTSERIALNO DESC"


        #查询数据库
        SqlStr = SqlStr + sql

        AfaLoggerFunc.tradeInfo( '>>>查询明细' )

        AfaLoggerFunc.tradeInfo( SqlStr )

        records=AfaDBFunc.SelectSql( SqlStr, queryCount )

        if( records == None ):
            #None 查询失败
            TradeContext.errorCode, TradeContext.errorMsg='A0025', "数据库操作错误"
            raise AfaFlowControl.flowException( )


        elif( len( records ) == 0 ):
            #无记录
            TradeContext.errorCode, TradeContext.errorMsg='A0025', "没有满足条件的记录"
            raise AfaFlowControl.flowException( )


        AfaLoggerFunc.tradeInfo( '>>>统计总数' )


        #统计总数
        AfaLoggerFunc.tradeInfo( sql_count )


        records_count=AfaDBFunc.SelectSql( sql_count )

        if( records_count == None ):
            TradeContext.errorCode, TradeContext.errorMsg='A0025', "数据库操作错误"
            raise AfaFlowControl.flowException( )

        # 过滤records中的所有None数据
        records=AfaUtilTools.ListFilterNone( records )

        #总共的返回记录数
        total=len( records )
        AfaLoggerFunc.tradeInfo( '返回记录数:[' + str(total) + ']' )

        #公共部分拼包
        TradeContext.tradeResponse=[]
        TradeContext.tradeResponse.append( ['errorCode',     '0000'] )
        TradeContext.tradeResponse.append( ['errorMsg',      '交易成功'] )
        TradeContext.tradeResponse.append( ['retCount',      str( total )] )
        TradeContext.tradeResponse.append( ['retTotalCount', str( records_count[0][0] )])
        TradeContext.tradeResponse.append( ['retTotalAmount',str( records_count[0][1] )])


        if ( TradeContext.TransType == '0' ):
            #按照变量名打包
            for i in range( 0, total ):
                k=0
                for name in names:
                    if( int( TradeContext.orderMode ) == 1 ):
                        TradeContext.tradeResponse.append( [name, records[i][k]] )
                    else:
                        TradeContext.tradeResponse.append( [name, records[total-i-1][k]] )
                    k=k+1
        else:
            MxFileName = os.environ['AFAP_HOME'] + '/tmp/MX' + TradeContext.zoneno + TradeContext.brno + TradeContext.tellerno + '.TXT'
            AfaLoggerFunc.tradeInfo('明细文件:['+MxFileName+']')

            if (os.path.exists(MxFileName) and os.path.isfile(MxFileName)):
                #文件存在,先删除-再创建
                os.system("rm " + MxFileName)

            #创建明细文件
            sfp = open(MxFileName, "w")

            #将每条记录打包成以竖线分隔的格式
            TradeContext.tradeResponse.append(['filename',  'MX' + TradeContext.zoneno + TradeContext.brno + TradeContext.tellerno + '.TXT'])

            for i in range( 0, total ):
                tmpBuffer = ""
                tmpBuffer = tmpBuffer + str(records[i][0]).strip()   + "|"         #AGENTSERIALNO
                tmpBuffer = tmpBuffer + str(records[i][1]).strip()   + "|"         #SYSID
                tmpBuffer = tmpBuffer + str(records[i][2]).strip()   + "|"         #UNITNO
                tmpBuffer = tmpBuffer + str(records[i][3]).strip()   + "|"         #SUBUNITNO
                tmpBuffer = tmpBuffer + str(records[i][4]).strip()   + "|"         #WORKDATE
                tmpBuffer = tmpBuffer + str(records[i][5]).strip()   + "|"         #WORKTIME
                tmpBuffer = tmpBuffer + str(records[i][6]).strip()   + "|"         #AGENTFLAG
                tmpBuffer = tmpBuffer + str(records[i][7]).strip()   + "|"         #TRXCODE
                tmpBuffer = tmpBuffer + str(records[i][8]).strip()   + "|"         #ZONENO
                tmpBuffer = tmpBuffer + str(records[i][9]).strip()   + "|"         #BRNO
                tmpBuffer = tmpBuffer + str(records[i][10]).strip()  + "|"         #TELLERNO
                tmpBuffer = tmpBuffer + str(records[i][11]).strip()  + "|"         #CHANNELCODE
                tmpBuffer = tmpBuffer + str(records[i][12]).strip()  + "|"         #ACCTYPE
                tmpBuffer = tmpBuffer + str(records[i][13]).strip()  + "|"         #DRACCNO
                tmpBuffer = tmpBuffer + str(records[i][14]).strip()  + "|"         #CRACCNO
                tmpBuffer = tmpBuffer + str(records[i][15]).strip()  + "|"         #USERNO
                tmpBuffer = tmpBuffer + str(records[i][16]).strip()  + "|"         #SUBUSERNO
                tmpBuffer = tmpBuffer + str(records[i][17]).strip()  + "|"         #USERNAME
                tmpBuffer = tmpBuffer + str(records[i][18]).strip()  + "|"         #VOUHTYPE
                tmpBuffer = tmpBuffer + str(records[i][19]).strip()  + "|"         #VOUHNO
                tmpBuffer = tmpBuffer + str(records[i][20]).strip()  + "|"         #VOUHDATE
                tmpBuffer = tmpBuffer + str(records[i][21]).strip()  + "|"         #AMOUNT
                tmpBuffer = tmpBuffer + str(records[i][22]).strip()  + "|"         #SUBAMOUNT
                tmpBuffer = tmpBuffer + str(records[i][23]).strip()  + "|"         #BANKSTATUS
                tmpBuffer = tmpBuffer + str(records[i][24]).strip()  + "|"         #BANKSERNO
                tmpBuffer = tmpBuffer + str(records[i][25]).strip()  + "|"         #CORPSTATUS
                tmpBuffer = tmpBuffer + str(records[i][26]).strip()  + "|"         #ERRORMSG
                tmpBuffer = tmpBuffer + str(records[i][27]).strip()  + "|"         #NOTE1
                tmpBuffer = tmpBuffer + str(records[i][28]).strip()  + "|"         #NOTE2
                tmpBuffer = tmpBuffer + str(records[i][29]).strip()  + "|"         #NOTE3
                tmpBuffer = tmpBuffer + str(records[i][30]).strip()  + "|"         #NOTE4
                tmpBuffer = tmpBuffer + str(records[i][31]).strip()  + "|"         #NOTE5
                tmpBuffer = tmpBuffer + str(records[i][32]).strip()  + "|"         #NOTE6
                tmpBuffer = tmpBuffer + str(records[i][33]).strip()  + "|"         #NOTE7
                tmpBuffer = tmpBuffer + str(records[i][34]).strip()  + "|"         #NOTE8
                tmpBuffer = tmpBuffer + str(records[i][35]).strip()  + "|"         #NOTE9
                tmpBuffer = tmpBuffer + str(records[i][36]).strip()  + "|"         #NOTE10

                sfp.write(tmpBuffer + '\n')
                    
            sfp.close()

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

        #=====================退出模板==========================================
        AfaLoggerFunc.tradeInfo( '******代收代付.查询明细模板['+TradeContext.TemplateCode+']退出******' )

    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( str(e) )
Beispiel #26
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))
Beispiel #27
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( )
Beispiel #28
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( "sysId") ):
            raise AfaFlowControl.flowException( 'A0001', '系统标识[sysId]值不存在,不能进行补打发票' )

        if( not TradeContext.existVariable( "userno") ):
            raise AfaFlowControl.flowException( 'A0001', '用户号[userno]值不存在,不能进行补打发票' )

        #=====================判断应用系统状态==================================
        if not AfaFunc.ChkSysStatus( ) :
            raise AfaFlowControl.flowException( )

        #=====================判断商户状态======================================
        if not AfaFunc.ChkUnitStatus( ) :
            raise AfaFlowControl.flowException( )

        #=====================判断渠道状态======================================
        if not AfaFunc.ChkChannelStatus( ) :
            raise AfaFlowControl.flowException( )

        #操作标志(0-查询发票信息 1-修改打印次数 2-从第三方获取发票信息,进行打印)
        if( not TradeContext.existVariable( "procFlag") ):
            raise AfaFlowControl.flowException( 'A0001', '操作标志[tradeFlag"]值不存在,不能进行补打发票' )

        if(TradeContext.procFlag=="0"):

            #查询发票信息
            sql="SELECT BILLDATA,ITEM1,ITEM2,ITEM3,ITEM4,ITEM5,ITEM6,BILLSERNO,SERIALNO,PRTNUM,WORKDATE,BILLSTATUS FROM AFA_BILLDTL WHERE "
            sql=sql + " SYSID='"      + TradeContext.sysId  + "'"
            sql=sql + " AND UNITNO='" + TradeContext.unitno + "'"

            if( TradeContext.existVariable( "subUnitno") ):
                sql=sql + " AND SUBUNITNO='" + TradeContext.subUnitno + "'"

            if( TradeContext.existVariable( "userno") ):
                sql=sql + " AND USERNO='" + TradeContext.userno + "'"

            if( TradeContext.existVariable( "payMonth") ):
                sql=sql + " AND WORKDATE LIKE '" + TradeContext.payMonth + "%'"

            if( TradeContext.existVariable( "item1") ):
                sql=sql + " AND ITEM1='"  + TradeContext.item1  + "'"

            if( TradeContext.existVariable( "item2") ):
                sql=sql + " AND ITEM2='"  + TradeContext.item1  + "'"

            if( TradeContext.existVariable( "item3") ):
                sql=sql + " AND ITEM3='"  + TradeContext.item1  + "'"

            if( TradeContext.existVariable( "item4") ):
                sql=sql + " AND ITEM4='"  + TradeContext.item1  + "'"

            if( TradeContext.existVariable( "item5") ):
                sql=sql + " AND ITEM5='"  + TradeContext.item1  + "'"

            if( TradeContext.existVariable( "item6") ):
                sql=sql + " AND ITEM6='"  + TradeContext.item1  + "'"

            sql=sql + " ORDER BY WORKDATE DESC,WORKTIME DESC "

            AfaLoggerFunc.tradeInfo( sql )

            records = AfaDBFunc.SelectSql(sql)

            if( records == None ):
                raise AfaFlowControl.flowException( 'A0002', '数据库操作异常:' + AfaDBFunc.sqlErrMsg )

            if(len(records)==0):
                raise AfaFlowControl.flowException( 'A0002', '无符合条件的记录' )

            if(int(records[0][9])==3):
                raise AfaFlowControl.flowException( 'A0002', '最多3次重打' )

            if(int(records[0][11])==1):
               raise AfaFlowControl.flowException( 'A0002', '票据已作废,不允许打印' )

            TradeContext.billNum = str(len(records))        #发票数量

            if ( TradeContext.TransType=='0' ):
                #变量初始化
                TradeContext.billData = []                  #发票信息
                TradeContext.item1    = []                  #附加项1
                TradeContext.item2    = []                  #附加项2
                TradeContext.item3    = []                  #附加项3
                TradeContext.item4    = []                  #附加项4
                TradeContext.item5    = []                  #附加项5
                TradeContext.item6    = []                  #附加项6
                TradeContext.billserno= []                  #发票序号
                TradeContext.serialno = []                  #中间业务流水号
                TradeContext.prtnum   = []                  #打印次数
                TradeContext.paydate  = []                  #支付日期

                #打包
                for i in range( 0, len(records) ):
                    TradeContext.billData.append(records[i][0])
                    TradeContext.item1.append(records[i][1])
                    TradeContext.item2.append(records[i][2])
                    TradeContext.item3.append(records[i][3])
                    TradeContext.item4.append(records[i][4])
                    TradeContext.item5.append(records[i][5])
                    TradeContext.item6.append(records[i][6])
                    TradeContext.billserno.append(records[i][7])
                    TradeContext.serialno.append(records[i][8])
                    TradeContext.prtnum.append(records[i][9])
                    TradeContext.paydate.append(records[i][10])
            else:
                MxFileName = os.environ['AFAP_HOME'] + '/tmp/MX' + TradeContext.zoneno + TradeContext.brno + TradeContext.tellerno + '.TXT'
                AfaLoggerFunc.tradeInfo('>>>明细文件:['+MxFileName+']')

                if (os.path.exists(MxFileName) and os.path.isfile(MxFileName)):
                    #文件存在,先删除-再创建
                    os.system("rm " + MxFileName)

                #创建明细文件
                sfp = open(MxFileName, "w")

                for i in range( 0, len(records) ):
                    wBuffer = ""
                    wBuffer = wBuffer + records[i][0]
                    wBuffer = wBuffer + records[i][1]
                    wBuffer = wBuffer + records[i][2]
                    wBuffer = wBuffer + records[i][3]
                    wBuffer = wBuffer + records[i][4]
                    wBuffer = wBuffer + records[i][5]
                    wBuffer = wBuffer + records[i][6]
                    wBuffer = wBuffer + records[i][7]
                    wBuffer = wBuffer + records[i][8]
                    wBuffer = wBuffer + records[i][9]
                    wBuffer = wBuffer + records[i][10]

                    sfp.write(wBuffer + '\n')

                sfp.close()

        elif(TradeContext.procFlag=="1"):

            #从第三方获取发票信息,进行打印

            #=====================获取平台流水号====================================
            if( not AfaFunc.GetSerialno( ) ):
                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( )

            #与通讯前置交换
            AfaAfeFunc.CommAfe()

            if TradeContext.errorCode!='0000' :
                raise AfaFlowControl.flowException( )

            #发票数量
            TradeContext.billNum = Party3Context.billNum

            if ( TradeContext.TransType=='0' ):
                #变量初始化
                TradeContext.billData = []                  #发票信息
                TradeContext.item1    = []                  #附加项1
                TradeContext.item2    = []                  #附加项2
                TradeContext.item3    = []                  #附加项3
                TradeContext.item4    = []                  #附加项4
                TradeContext.item5    = []                  #附加项5
                TradeContext.item6    = []                  #附加项6
                TradeContext.billserno= []                  #发票序号
                TradeContext.serialno = []                  #中间业务流水号
                TradeContext.prtnum   = []                  #打印次数
                TradeContext.paydate  = []                  #支付日期

                if ( int(Party3Context.billNum) == 1 ):
                    #打包(一张发票)
                        TradeContext.billData   = Party3Context.billData
                        TradeContext.item1      = Party3Context.item1
                        TradeContext.item2      = Party3Context.item2
                        TradeContext.item3      = Party3Context.item3
                        TradeContext.item4      = Party3Context.item4
                        TradeContext.item5      = Party3Context.item5
                        TradeContext.item6      = Party3Context.item6
                        TradeContext.billserno  = Party3Context.billserno
                        TradeContext.serialno   = Party3Context.serialno
                        TradeContext.prtnum     = Party3Context.prtnum
                        TradeContext.paydate    = Party3Context.paydate
                else:
                    #打包(多张发票)
                    for i in range( 0, int(Party3Context.billNum) ):
                        TradeContext.billData.append(Party3Context.billData[i])
                        TradeContext.item1.append(Party3Context.item1[i])
                        TradeContext.item2.append(Party3Context.item2[i])
                        TradeContext.item3.append(Party3Context.item3[i])
                        TradeContext.item4.append(Party3Context.item4[i])
                        TradeContext.item5.append(Party3Context.item5[i])
                        TradeContext.item6.append(Party3Context.item6[i])
                        TradeContext.billserno.append(Party3Context.billserno[i])
                        TradeContext.serialno.append(Party3Context.serialno[i])
                        TradeContext.prtnum.append(Party3Context.prtnum[i])
                        TradeContext.paydate.append(Party3Context.paydate[i])
            else:
                MxFileName = os.environ['AFAP_HOME'] + '/tmp/MX' + TradeContext.zoneno + TradeContext.brno + TradeContext.tellerno + '.TXT'
                AfaLoggerFunc.tradeInfo('>>>明细文件:['+MxFileName+']')

                if (os.path.exists(MxFileName) and os.path.isfile(MxFileName)):
                    #文件存在,先删除-再创建
                    os.system("rm " + MxFileName)

                #创建明细文件
                sfp = open(MxFileName, "w")

                if ( int(Party3Context.billNum) == 1 ):
                    #打包(一张发票)
                        wBuffer = ""
                        wBuffer = wBuffer + Party3Context.billData
                        wBuffer = wBuffer + Party3Context.item1
                        wBuffer = wBuffer + Party3Context.item2
                        wBuffer = wBuffer + Party3Context.item3
                        wBuffer = wBuffer + Party3Context.item4
                        wBuffer = wBuffer + Party3Context.item5
                        wBuffer = wBuffer + Party3Context.item6
                        wBuffer = wBuffer + Party3Context.billserno
                        wBuffer = wBuffer + Party3Context.serialno
                        wBuffer = wBuffer + Party3Context.prtnum
                        wBuffer = wBuffer + Party3Context.paydate
                        sfp.write(wBuffer + '\n')
                        sfp.close()
                else:
                    #打包(多张发票)
                    for i in range( 0, int(Party3Context.billNum) ):
                        wBuffer = ""
                        wBuffer = wBuffer + Party3Context.billData[i]
                        wBuffer = wBuffer + Party3Context.item1[i]
                        wBuffer = wBuffer + Party3Context.item2[i]
                        wBuffer = wBuffer + Party3Context.item3[i]
                        wBuffer = wBuffer + Party3Context.item4[i]
                        wBuffer = wBuffer + Party3Context.item5[i]
                        wBuffer = wBuffer + Party3Context.item6[i]
                        wBuffer = wBuffer + Party3Context.billserno[i]
                        wBuffer = wBuffer + Party3Context.serialno[i]
                        wBuffer = wBuffer + Party3Context.prtnum[i]
                        wBuffer = wBuffer + Party3Context.paydate[i]
                        sfp.write(wBuffer + '\n')
                    sfp.close()

            #=====================外调接口(后处理)==================================
            if ( subModuleExistFlag==1 ) :
                if not subModuleHandle.SubModuleDoSnd():
                    raise AfaFlowControl.flowException( )

        #=====================自动打包==========================================
        TradeContext.errorCode = '0000'
        TradeContext.errorMsg  = '交易成功'
        AfaFunc.autoPackData()

        #=====================程序退出==========================================
        AfaLoggerFunc.tradeInfo('******代收代付.补打发票模板[' + TradeContext.TemplateCode + ']退出******' )
Beispiel #29
0
def main( ):


    AfaLoggerFunc.tradeInfo('***农信银系统: 往账.主机类操作模板['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']进入***')


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


        #=====================获取系统日期时间==================================
        TradeContext.BJEDTE=AfaUtilTools.GetHostDate( )
        #TradeContext.BJEDTE = PL_BJEDTE
        TradeContext.BJETIM=AfaUtilTools.GetSysTime( )
        #TradeContext.TRCDAT = PL_BJEDTE
        #关彬捷 20081111 修改委托日期为中心日期
        #TradeContext.TRCDAT=AfaUtilTools.GetHostDate( )
        #修改结束


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

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

        #=====================机构合法性校验====================================
        if not rccpsFunc.ChkUnitInfo( PL_BRSFLG_SND ) :
            raise AfaFlowControl.flowException( )
 
        #=====================获取中心日期====================================
        if not rccpsFunc.GetNCCDate( ) :
            raise AfaFlowControl.flowException( )
            
        #关彬捷 20081111 修改委托日期为中心日期
        TradeContext.TRCDAT=TradeContext.NCCworkDate
        #修改结束

        #=====================获取平台流水号====================================
        if rccpsGetFunc.GetSerialno(PL_BRSFLG_SND) == -1 :
            raise AfaFlowControl.flowException( )


        #=====================获取中心流水号====================================
        if rccpsGetFunc.GetRccSerialno( ) == -1 :
            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.SubModuleDoFst( ) :
            raise AfaFlowControl.flowException( )

        #=====================与主机通讯========================================
        rccpsHostFunc.CommHost( TradeContext.HostCode )


        #=====================交易中处理(修改流水,主机后处理,中心前处理)========
        if not trxModuleHandle.SubModuleDoSnd( ) :
            raise AfaFlowControl.flowException( )


        #=====================与中心通讯(回执)==================================
        AfaAfeFunc.CommAfe()

        #=====================交易后处理========================================
        if not trxModuleHandle.SubModuleDoTrd():
            raise AfaFlowControl.flowException( )


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


        #=====================退出模板==========================================
        AfaLoggerFunc.tradeInfo('***农信银系统: 往账.主机类操作模板['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']退出***')
Beispiel #30
0
def TrxMain( ):
    
    try:
    
        AfaLoggerFunc.tradeInfo('客户签约信息查询[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']进入' )
        
        #业务编号
        if ( not (TradeContext.existVariable( "Appno" ) and len(TradeContext.Appno.strip()) > 0) ):
            TradeContext.errorCode,TradeContext.errorMsg = '0001', "不存在业务编号"
            raise AfaFlowControl.flowException( )
            
        #单位编号
        if ( not (TradeContext.existVariable( "Busino" ) and len(TradeContext.Busino.strip()) > 0) ):
            TradeContext.errorCode,TradeContext.errorMsg = '0001', "不存在单位编号"
            raise AfaFlowControl.flowException( )
            
        #社保编号
        if ( not (TradeContext.existVariable( "sbno" ) and len(TradeContext.sbno.strip()) > 0) ):
            TradeContext.errorCode,TradeContext.errorMsg = '0001', "不存在社保编号"
            raise AfaFlowControl.flowException( )
        
        #判断单位协议是否有效
        TradeContext.I1APPNO =TradeContext.Appno
        TradeContext.I1BUSINO=TradeContext.Busino
        if ( not AhXnbFunc.ChkUnitInfo( ) ):
            return False
        
        sql = ""
        sql = sql + "select USERNAME,IDCODE,ACCNO,VOUHTYPE,PROTOCOLNO,BRNO,CONTRACTDATE from abdt_custinfo where "
        sql = sql + " APPNO ='" + TradeContext.Appno + "'"
        sql = sql + " and BUSINO ='" + TradeContext.Busino+ "'"
        sql = sql + " and BUSIUSERNO ='" +TradeContext.sbno+"'" 
        
        AfaLoggerFunc.tradeInfo("客户签约查询sql="+sql)
        records = AfaDBFunc.SelectSql( sql )
        
        if(records == None):
            AfaLoggerFunc.tradeInfo("查询数据库异常")
            TradeContext.errorCode,TradeContext.errorMsg = "0001","查询数据库异常"
            
        elif(len(records)==0):
            AfaLoggerFunc.tradeInfo("没有查询到相关签约信息")
            TradeContext.errorCode,TradeContext.errorMsg = "0001","没有查询到相关签约信息"
            
        elif(len(records)>1):
            AfaLoggerFunc.tradeInfo("客户签约信息不唯一")
            TradeContext.errorCode,TradeContext.errorMsg = "0001","客户签约信息不唯一"
            
        else:
            TradeContext.name        = records[0][0].strip()     #客户姓名
            TradeContext.idcode      = records[0][1].strip()     #证件号码
            TradeContext.accno       = records[0][2].strip()     #账号
            TradeContext.vouhtype    = records[0][3].strip()     #凭证类型
            TradeContext.protocolno  = records[0][4].strip()     #协议编号
            TradeContext.brno        = records[0][5].strip()     #签约机构
            TradeContext.contract_date = records[0][6].strip()   #签约日期
            
            
            TradeContext.errorCode  = "0000"
            TradeContext.errorMsg   = "交易成功"
            return True
        AfaLoggerFunc.tradeInfo('客户签约查询交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']退出' )
        
    
    except Exception, e:                   
        AfaFlowControl.exitMainFlow(str(e))
Beispiel #31
0
def VouhModify( ):
    #判断报文变量是否存在,若存在则赋值到内部变量,用于插入数据库
    if( TradeContext.existVariable( "sLstTrxDay" ) ):
        _sWorkDate_    = TradeContext.sLstTrxDay       #工作日期
    else:
        _sWorkDate_    = ''
    if( TradeContext.existVariable( "sLstTrxTime" ) ):
        _sWorkTime_    = TradeContext.sLstTrxTime      #工作时间
    else:
        _sWorkTime_    = ''
    if( TradeContext.existVariable( "sBesbNo" ) ):
        _sBESBNO_      = TradeContext.sBesbNo          #机构号
    else:
        _sBESBNO_      = ''
    if( TradeContext.existVariable( "sCur" ) ):
        _sCur_      = TradeContext.sCur          #货币代号
    else:
        _sCur_      = ''
    if( TradeContext.existVariable( "sTellerTailNo" ) ):
        _sTellerTailNo_    = TradeContext.sTellerTailNo        #交易柜员尾箱号
    else:
        _sTellerNo_    = ''
    if( TradeContext.existVariable( "sVouhSerial" ) ):
        _sVouhSerial_    = TradeContext.sVouhSerial    #操作流水号
    else:
        _sVouhSerial_    = GetVouhSerial( )
    if( TradeContext.existVariable( "sRivTeller" ) ):
        _sRivTeller_   = TradeContext.sRivTeller       #对方柜员尾箱号
    else:
        _sRivTeller_   = ''
    if( TradeContext.existVariable( "sDepository" ) ):
        _sDepository_  = TradeContext.sDepository      #库箱标志
    else:
        _sDepository_  = ''
    if( TradeContext.existVariable( "sExDepos" ) ):
        _sExDepos_     = TradeContext.sExDepos         #原库箱标志
    else:
        _sExDepos_     = ''
    if( TradeContext.existVariable( "sVouhStatus" ) ):
        _sVouhStatus_  = TradeContext.sVouhStatus      #状态
    else:
        _sVouhStatus_  = ''
    if( TradeContext.existVariable( "sExStatus" ) ):
        _sExStatus_    = TradeContext.sExStatus        #原状态
    else:
        _sExStatus_    = ''
    if( TradeContext.existVariable( "sAuthTeller" ) ):
        _sAuthTeller_     = TradeContext.sAuthTeller         #授权柜员
    else:
        _sAuthTeller_     = ''
    if( TradeContext.existVariable( "sTransType" ) ):
        _sTransType_  = TradeContext.sTransType      #凭证状态
    else:
        _sTransType_  = ''
    if(not TradeContext.existVariable( "sNum" ) ):
        TradeContext.sNum = 1      #重复次数

        
    for i in range(TradeContext.sNum):
        if( TradeContext.existVariable( "sVouhType" ) ):
            _sVouhType_    = TradeContext.sVouhType[i]        #凭证种类
        else:
            _sVouhType_    = ''
        if( TradeContext.existVariable( "sStartNo" ) ):
            _sStartNo_     = TradeContext.sStartNo[i]         #起始号码
        else:
            _sStartNo_     = ''
        if( TradeContext.existVariable( "sEndNo" ) ):
            _sEndNo_       = TradeContext.sEndNo[i]           #终止号码
        else:
            _sEndNo_       = ''
        if( TradeContext.existVariable( "sVouhNum" ) ):
            _sVouhNum_       = TradeContext.sVouhNum[i]           #凭证数量
        else:
            _sVouhNum_       = ''
           
        #用内部变量拼插入数据库SQL
        sqlStrInsert = "insert into VOUH_MODIFY ( VOUHSERIAL, WORKDATE, WORKTIME,VOUHNUM, BESBNO, TELLERNO, CUR ,\
        VOUHTYPE, STARTNO, ENDNO, RIVTELLER, DEPOSITORY, EXDEPOS, VOUHSTATUS, EXSTATUS,TRANSTYPE) \
        VALUES ('" + _sVouhSerial_ + "','" + _sWorkDate_ + "','" + _sWorkTime_ + "','"+ _sVouhNum_ + "','" + _sBESBNO_ +  "','" \
            + _sTellerTailNo_ + "','" + _sCur_+ "','" + _sVouhType_+"','" \
            + _sStartNo_ + "','" + _sEndNo_ + "','" + _sRivTeller_ + "','" + _sDepository_ + "','" \
            + _sExDepos_ + "','" + _sVouhStatus_ + "','" + _sExStatus_ + "','" + _sTransType_  + "')"
        AfaLoggerFunc.tradeInfo( sqlStrInsert )
        records = AfaDBFunc.InsertSql( sqlStrInsert )
        if records == -1 :
            AfaLoggerFunc.tradeInfo( '数据库回滚' )
            record = AfaDBFunc.RollbackSql( )
            tradeExit('A005061', '插入[凭证流水表]操作异常!')
            raise AfaFlowControl.flowException( )
            return -1

    return 0
Beispiel #32
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  = '3' #状态       3.已领未用 6.已作废
        TradeContext.sExStatus    = '6' #原状态
        TradeContext.sRivTeller   = '   '     #对方柜员
        TradeContext.sTransType    = '凭证作废撤销'
        TradeContext.sInTellerTailNo  = TradeContext.sTellerTailNo
        TradeContext.sInBesbNo    = TradeContext.sBesbNo
        

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

        #更新凭证变更登记表
        VouhFunc.VouhModify()
        
        #数据库提交
        AfaDBFunc.CommitSql( )
        
        #主机记账
        AfaLoggerFunc.tradeInfo( '------------主机记账' )
        TradeContext.sOperSty = '0'
        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( )
Beispiel #33
0
def SubModuleDoFst( ):
    try:
        AfaLoggerFunc.tradeInfo('>>>>>>>>>>>>前一天数据汇总查询语句开始') 
        sql = "select sum(cast(amount as decimal(15,2))),count(*) from afa_maintransdtl"
        sql = sql + " where  workdate    = '" + TradeContext.workdate.strip()  + "'"
        sql = sql + " and    bankstatus  = '0'  and revtranf = '0' and chkflag = '0'"
        sql = sql + " and    sysid       = '" + TradeContext.sysId.strip()     +"'"
        sql = sql + " and    unitno      = '" + TradeContext.unitno.strip()    + "'"
        
        #20120709陈浩添加 note2 ---busino单位编码
        sql = sql + " and    note2       = '" + TradeContext.busino            +"'"     #单位编号
        
        AfaLoggerFunc.tradeInfo('汇总信息查询语句'+ sql)
        
        records = AfaDBFunc.SelectSql( sql )
        
        if records == None:
            TradeContext.errorCode,TradeContext.errorMsg = "0001" ,"查询数据库失败"
            raise AfaFlowControl.flowException( )
        
        if records[0][1] == 0:
            TradeContext.errorCode,TradeContext.errorMsg = "0001","没有查询到汇总记录信息"
            raise AfaFlowControl.flowException( )
        
        else:
            TradeContext.totalamt = str(records[0][0])             #总金额
            TradeContext.totalnum = str(records[0][1])             #总笔数 

     #20120706 陈浩修改注释,添加
     #begin
     #   sql = "select accno1 from afa_unitadm"
     #   sql = sql + " where sysid     = '" + TradeContext.sysId.strip() + "'"           
     #   sql = sql + " and   unitno    = '" + TradeContext.unitno.strip() + "'"          
     #                                                                                   
     #   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","无此信息"              
     #       raise AfaFlowControl.flowException( )                                                                 
     #                                                                                     
     #   else:                                                                             
     #       TradeContext.accno = records[0][0]             #收款人   
            
            
        sql = ""
        sql = sql + " select accno from abdt_unitinfo "
        sql = sql + " where appno = '" + TradeContext.sysId.strip()  + "' "
        sql = sql + " and  busino = '" + TradeContext.busino.strip() + "' "
        
        AfaLoggerFunc.tradeInfo('查询语句 : '+ sql)                          
                                                                                    
        record = AfaDBFunc.SelectSql( sql )                                        
        if record == None:                                                         
            TradeContext.errorCode,TradeContext.errorMsg = "0001" ,"查询数据库失败" 
            raise AfaFlowControl.flowException( )                                   
                                                                                    
        if(len(record) < 1):                                                       
            TradeContext.errorCode,TradeContext.errorMsg = "0001","该单位没有签约,不能做次业务!"        
            raise AfaFlowControl.flowException( )                                                             
                                                                                    
        else:                                                                       
            TradeContext.accno       = record[0][0]             #收款人帐户 
            
            #AfaLoggerFunc.tradeInfo('收款人帐户accno:'+ TradeContext.accno) 
        
     #end    
            
            
                              
        AfaLoggerFunc.tradeInfo('>>>>>>>>>>>>>>>前一天数据汇总查询语句结束') 
        return True 
    except  Exception, e:
        AfaLoggerFunc.tradeInfo( str(e) )
        AfaFlowControl.flowException( )
Beispiel #34
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( )
Beispiel #35
0
def SubModuleDoFst( ):

    
    #校验保险公司代码和凭证种类是否合法
    if not AfaYbtdb.ADBCheckCert( ):
        return False
   
    
    try:
        AfaLoggerFunc.tradeInfo( '初始化新保缴费交易变量' )
        
        #交易代码(8611)
        TradeContext.tradeCode = TradeContext.TransCode
        
        #如果缴费金额是0.00,则不让缴费
        if not( TradeContext.existVariable( "amount" ) and len(TradeContext.amount.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "缴费金额不存在"
            raise AfaFlowControl.flowException( )
        else:
            AfaLoggerFunc.tradeInfo("缴费金额:" + TradeContext.amount )
            if TradeContext.amount.strip( ) == "0.00":
                TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "缴费金额不能为零"
                raise AfaFlowControl.flowException( )
        
        #保险公司代码
        if not( TradeContext.existVariable( "unitno" ) and len(TradeContext.unitno.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "不存在保险公司代码"
            raise AfaFlowControl.flowException( )
       
        #投保单号
        if not( TradeContext.existVariable( "applno" ) and len(TradeContext.applno.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保单号不存在"
            raise AfaFlowControl.flowException( )   
        
        #保单印刷号
        if not( TradeContext.existVariable( "userno" ) and len(TradeContext.userno.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "保单印刷号不存在"
            raise AfaFlowControl.flowException( )  
        
        #新保投保(核保)流水号
        if not( TradeContext.existVariable( "PreSerialno"  ) and len(TradeContext.PreSerialno.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "新保投保(核保)流水号不存在"
            raise AfaFlowControl.flowException( )  
        
        #主险种
        if not( TradeContext.existVariable( "productid" ) and len(TradeContext.productid.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "险种不存在"
            raise AfaFlowControl.flowException( )
        
        #缴费方式
        if not( TradeContext.existVariable( "paymethod" ) and len(TradeContext.paymethod.strip()) > 0 ):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "缴费方式不存在"
            raise AfaFlowControl.flowException( )   
        
        #缴费年限
        if not( TradeContext.existVariable( "paydatelimit" ) and len(TradeContext.paydatelimit.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "缴费年限不存在"
            raise AfaFlowControl.flowException( )  
        
        #投保人姓名
        if not( TradeContext.existVariable( "tbr_name" ) and len(TradeContext.tbr_name.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保人姓名不存在"
            raise AfaFlowControl.flowException( )
        
        #投保人证件号码
        if not( TradeContext.existVariable( "tbr_idno" ) and len(TradeContext.tbr_idno.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "投保人证件号码不存在"
            raise AfaFlowControl.flowException( )
        
        #被保险人姓名
        if not( TradeContext.existVariable( "bbr_name" ) and len(TradeContext.bbr_name.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "被保险人姓名不存在"
            raise AfaFlowControl.flowException( )  
        
        #被保险人证件号码
        if not( TradeContext.existVariable( "bbr_idno" ) and len(TradeContext.bbr_idno.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "被保险人号码证件不存在"
            raise AfaFlowControl.flowException( )  
        
        #与投保人关系
        if not( TradeContext.existVariable( "tbr_bbr_rela" ) and len(TradeContext.tbr_bbr_rela.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "与投保人关系不存在"
            raise AfaFlowControl.flowException( )  
       
        #行社营销人员工号
        if not( TradeContext.existVariable( "salerno" ) and len(TradeContext.salerno.strip()) > 0):
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "行社营销人员工号不存在"
            raise AfaFlowControl.flowException( )  
        
        #paymethod1付费方式(0现金,1转账)  accType缴费介质代码(000:现金,001:对私账号,002:借记卡,
        #003:贷记卡,004:对公账号,005:公务卡)  payacc账号  paycard卡号
        TradeContext.accType = ''
        
        if TradeContext.paymethod1=="0":
            TradeContext.accType="000"
       
        else:
            if TradeContext.vouchtype == "49":                                 #vouchtype 49:存储存折
                TradeContext.accType="001"
                TradeContext.accno = TradeContext.payacc                       #账号
            
            elif TradeContext.vouchtype == "81":                               #vouchtype 81:金农借记卡
                TradeContext.accType="002"
                TradeContext.accno = TradeContext.paycard                      #卡号
            
            #paytype支付条件(0凭密码,1凭证件,2凭单折)vouchno凭证号码  tbr_idno投保人身份证号码
            if TradeContext.paytype == '0':                                    #凭密码
                TradeContext.accPwd = TradeContext.password 
                TradeContext.vouhType = TradeContext.vouchtype                 #凭证种类
                if(TradeContext.vouchtype == "81"):
                    TradeContext.vouhNo=TradeContext.paycard[8:18]
                else:
                    TradeContext.vouhNo = TradeContext.vouchno                 #凭证号码
            
            elif TradeContext.paytype == '1':                                  #凭证件
                TradeContext.idType = TradeContext.zjtype                      #证件种类
                TradeContext.idno = TradeContext.zjno                          #证件号码
                TradeContext.vouhType = TradeContext.vouchtype                 #凭证种类 
                TradeContext.vouhNo = TradeContext.vouchno                     #凭证号码
            
            elif TradeContext.paytype == "2":                                  #凭单折
                TradeContext.vouhType = TradeContext.vouchtype                 #凭证种类 
                TradeContext.vouhNo = TradeContext.vouchno                     #凭证号码
            AfaLoggerFunc.tradeInfo("TradeContext.vouhNo:"+TradeContext.vouhNo)
    except  Exception, e:
        AfaLoggerFunc.tradeInfo( str(e) )
        AfaFlowControl.flowException( )
Beispiel #36
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      
Beispiel #37
0
def main( ):
    
    AfaLoggerFunc.tradeInfo( '打印报表['+TradeContext.TemplateCode+']进入' )
    
    #=============前台上送数据====================
    #TradeContext.sTellerNo          柜员号 
    #TradeContext.sWorkDate          交易日期
    #TrddeContext.sBesbNo            机构号

    
    
    try:
        #=============获取机构类型==========================
        HostContext.I1OTSB = TradeContext.sBesbNo         #机构号
        HostContext.I1SBNO = TradeContext.sBesbNo         #机构号
        HostContext.I1USID = TradeContext.sTellerNo       #柜员号
        HostContext.I1WSNO = TradeContext.sWSNO           #终端号
        if(not VouhHostFunc.CommHost('2001')):
            tradeExit(TradeContext.errorCode, TradeContext.errorMsg)
            raise AfaFlowControl.flowException( )
        if(TradeContext.errorCode == '0000'):
            SBNO = HostContext.O1SBCH
            AfaLoggerFunc.tradeInfo( SBNO )
        
        #=============获取柜员级别==========================
        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 = []
        
        #=================获取机构名称==============================
        #begin 20100920 蔡永贵修改 避免机构不存在时查询结果为空而抛出错误
        #TradeContext.sBesbName = VouhFunc.SelectBesbName(TradeContext.sBesbNo)
        if not VouhFunc.SelectBesbName(TradeContext.sBesbNo):
            raise AfaFlowControl.flowException( )
        else:
            TradeContext.sBesbName = VouhFunc.SelectBesbName(TradeContext.sBesbNo)
        #end

        #=====================获取机构类型===============================
        #TradeContext.sBesbSty = VouhFunc.SelectBesbSty(TradeContext.sBesbNo)
        #AfaLoggerFunc.tradeInfo('================='+TradeContext.sBesbSty)

        #=============获取当前系统时间====================
        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   
        
        vouh = []
        count1 = 0
        count2 = 0
        count3 = 0
        AfaLoggerFunc.tradeInfo(TradeContext.sTellerTailNo)
        sqlStr = "select VOUHTYPE,VOUHNAME from VOUH_PARAMETER where substr(BESBNO,1,6) = '" + (TradeContext.sBesbNo)[:6] + "' order by VOUHTYPE"
        AfaLoggerFunc.tradeInfo(sqlStr)
        records = AfaDBFunc.SelectSql( sqlStr )
        if( records == None ):
            tradeExit('A005067', '查询[凭证参数表]操作异常!')
            raise AfaFlowControl.flowException( )
        elif( len( records ) == 0 ):
            tradeExit('A005068', '凭证不存在!' )
            raise AfaFlowControl.flowException( )
        else :
            for i in range(len(records)):
                num1 = 0
                num2 = 0
                num3 = 0
                if(SBNO == '33' and TELLER == "10"):
                    
                    #查询凭证领用数
                    sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \
                            where WORKDATE = '" + TradeContext.sWorkDate + "' \
                            and VOUHTYPE = '" + records[i][0] + "' \
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "' \
                            and BESBNO = '" + TradeContext.sBesbNo + "' \
                            and TRANSTATUS = '0' \
                            and VOUHSTATUS = '0'"
                    res1 = AfaDBFunc.SelectSql( sqlStr )
                    AfaLoggerFunc.tradeInfo('sql1 = '+sqlStr)
                    if( res1 == None ):
                        tradeExit('A005067', '查询[凭证表]操作异常!')
                        raise AfaFlowControl.flowException( )
                    elif( len( res1 ) == 0 ):
                        num1 = 0
                    else :
                        num1 = res1[0][0]
                        if(num1 == None):
                            num1 = 0
                        AfaLoggerFunc.tradeInfo(num1)  
                          
                    #查询凭证付出数
                    sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \
                            where WORKDATE = '" + TradeContext.sWorkDate + "' \
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "' \
                            and VOUHTYPE = '" + records[i][0] + "' \
                            and BESBNO = '" + TradeContext.sBesbNo + "' \
                            and TRANSTATUS = '0' \
                            and VOUHSTATUS in ('1','2')"
                    res2 = AfaDBFunc.SelectSql( sqlStr )
                    AfaLoggerFunc.tradeInfo('sql2 = '+sqlStr)
                    if( res2 == None ):
                        tradeExit('A005067', '查询[凭证表]操作异常!')
                        raise AfaFlowControl.flowException( )
                    elif( len( res2 ) == 0 ):
                        num2 = 0
                    else :
                        num2 = res2[0][0]
                        if(num2 == None):
                            num2 = 0
                        AfaLoggerFunc.tradeInfo(num2)  
                         
                    #查询凭证余数
                    sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_REGISTER \
                            where VOUHTYPE = '" + records[i][0] + "' \
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "' \
                            and BESBNO = '" + TradeContext.sBesbNo + "' \
                            and VOUHSTATUS = '0'"
                    res3 = AfaDBFunc.SelectSql( sqlStr )
                    AfaLoggerFunc.tradeInfo('sql3 = '+sqlStr)
                    if( res3 == None ):
                        tradeExit('A005067', '查询[凭证表]操作异常!')
                        raise AfaFlowControl.flowException( )
                    elif( len( res3 ) == 0 ):
                        num3 = 0
                    else :
                        num3 = res3[0][0]
                        if(num3 == None):
                            num3 = 0
                        AfaLoggerFunc.tradeInfo(num3)  
                          
                elif(TELLER == "10"):
                    
                    #查询凭证领用数
                    sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \
                            where WORKDATE = '" + TradeContext.sWorkDate + "' \
                            and VOUHTYPE = '" + records[i][0] + "' \
                            and (TELLERNO = '" + TradeContext.sTellerTailNo + "' \
                            or RIVTELLER = '" + TradeContext.sTellerTailNo + "') \
                            and BESBNO = '" + TradeContext.sBesbNo + "' \
                            and TRANSTATUS = '0' \
                            and VOUHSTATUS = '2'"
                    res1 = AfaDBFunc.SelectSql( sqlStr )
                    AfaLoggerFunc.tradeInfo('sql1 = '+sqlStr)
                    if( res1 == None ):
                        tradeExit('A005067', '查询[凭证表]操作异常!')
                        raise AfaFlowControl.flowException( )
                    elif( len( res1 ) == 0 ):
                        num1 = 0
                    else :
                        num1 = res1[0][0]
                        if(num1 == None):
                            num1 = 0
                            
                    #查询凭证付出数
                    sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \
                            where WORKDATE = '" + TradeContext.sWorkDate + "' \
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "' \
                            and BESBNO = '" + TradeContext.sBesbNo + "' \
                            and VOUHTYPE = '" + records[i][0] + "' \
                            and TRANSTATUS = '0' \
                            and EXSTATUS = '2' \
                            and VOUHSTATUS in ('0','3')"
                    res2 = AfaDBFunc.SelectSql( sqlStr )
                    AfaLoggerFunc.tradeInfo('sql2 = '+sqlStr)
                    if( res2 == None ):
                        tradeExit('A005067', '查询[凭证表]操作异常!')
                        raise AfaFlowControl.flowException( )
                    elif( len( res2 ) == 0 ):
                        num2 = 0
                    else :
                        num2 = res2[0][0]
                        if(num2 == None):
                            num2 = 0
                            
                    #查询凭证余数
                    sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_REGISTER \
                            where VOUHTYPE = '" + records[i][0] + "' \
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "' \
                            and BESBNO = '" + TradeContext.sBesbNo + "' \
                            and VOUHSTATUS = '2'"
                    res3 = AfaDBFunc.SelectSql( sqlStr )
                    AfaLoggerFunc.tradeInfo('sql3 = '+sqlStr)
                    if( res3 == None ):
                        tradeExit('A005067', '查询[凭证表]操作异常!')
                        raise AfaFlowControl.flowException( )
                    elif( len( res3 ) == 0 ):
                        num3 = 0
                    else :
                        num3 = res3[0][0]
                        if(num3 == None):
                            num3 = 0
                            
                elif(TELLER == "20"):
                    
                    #查询凭证领用数
                    sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \
                            where WORKDATE = '" + TradeContext.sWorkDate + "' \
                            and VOUHTYPE = '" + records[i][0] + "' \
                            and substr(BESBNO,1,6) = '" + (TradeContext.sBesbNo)[:6] + "' \
                            and BESBNO = '" + TradeContext.sBesbNo + "' \
                            and TRANSTATUS = '0' \
                            and VOUHSTATUS = '2'"
                    res1 = AfaDBFunc.SelectSql( sqlStr )
                    AfaLoggerFunc.tradeInfo('sql1 = '+sqlStr)
                    if( res1 == None ):
                        tradeExit('A005067', '查询[凭证表]操作异常!')
                        raise AfaFlowControl.flowException( )
                    elif( len( res1 ) == 0 ):
                        num1 = 0
                    else :
                        num1 = res1[0][0]
                        if(num1 == None):
                            num1 = 0
                            
                    #查询凭证付出数
                    sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \
                            where WORKDATE = '" + TradeContext.sWorkDate + "' \
                            and substr(BESBNO,1,6) = '" + (TradeContext.sBesbNo)[:6] + "' \
                            and BESBNO = '" + TradeContext.sBesbNo + "' \
                            and VOUHTYPE = '" + records[i][0] + "' \
                            and TRANSTATUS = '0' \
                            and EXSTATUS = '3' \
                            and VOUHSTATUS in ('2','4','5','6')"
                    res2 = AfaDBFunc.SelectSql( sqlStr )
                    AfaLoggerFunc.tradeInfo('sql2 = '+sqlStr)
                    if( res2 == None ):
                        tradeExit('A005067', '查询[凭证表]操作异常!')
                        raise AfaFlowControl.flowException( )
                    elif( len( res2 ) == 0 ):
                        num2 = 0
                    else :
                        num2 = res2[0][0]
                        if(num2 == None):
                            num2 = 0
                            
                    #查询凭证余数
                    sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_REGISTER \
                            where VOUHTYPE = '" + records[i][0] + "' \
                            and substr(BESBNO,1,6) = '" + (TradeContext.sBesbNo)[:6] + "' \
                            and BESBNO = '" + TradeContext.sBesbNo + "' \
                            and VOUHSTATUS in ('2','3')"
                    res3 = AfaDBFunc.SelectSql( sqlStr )
                    AfaLoggerFunc.tradeInfo('sql3 = '+sqlStr)
                    if( res3 == None ):
                        tradeExit('A005067', '查询[凭证表]操作异常!')
                        raise AfaFlowControl.flowException( )
                    elif( len( res3 ) == 0 ):
                        num3 = 0
                    else :
                        num3 = res3[0][0]
                        if(num3 == None):
                            num3 = 0
                            
                else:
                    
                    #查询凭证领用数
                    sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \
                            where WORKDATE = '" + TradeContext.sWorkDate + "' \
                            and VOUHTYPE = '" + records[i][0] + "' \
                            and (TELLERNO = '" + TradeContext.sTellerTailNo + "' \
                            or RIVTELLER = '" + TradeContext.sTellerTailNo + "') \
                            and BESBNO = '" + TradeContext.sBesbNo + "' \
                            and TRANSTATUS = '0' \
                            and VOUHSTATUS = '3'"
                    res1 = AfaDBFunc.SelectSql( sqlStr )
                    AfaLoggerFunc.tradeInfo('sql1 = '+sqlStr)
                    if( res1 == None ):
                        tradeExit('A005067', '查询[凭证表]操作异常!')
                        raise AfaFlowControl.flowException( )
                    elif( len( res1 ) == 0 ):
                        num1 = 0
                    else :
                        num1 = res1[0][0]
                        if(num1 == None):
                            num1 = 0
                            
                    #查询凭证付出数
                    sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_MODIFY \
                            where WORKDATE = '" + TradeContext.sWorkDate + "' \
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "' \
                            and BESBNO = '" + TradeContext.sBesbNo + "' \
                            and VOUHTYPE = '" + records[i][0] + "' \
                            and TRANSTATUS = '0' \
                            and EXSTATUS = '3' \
                            and VOUHSTATUS in ('2','4','5','6')"
                    res2 = AfaDBFunc.SelectSql( sqlStr )
                    AfaLoggerFunc.tradeInfo('sql2 = '+sqlStr)
                    if( res2 == None ):
                        tradeExit('A005067', '查询[凭证表]操作异常!')
                        raise AfaFlowControl.flowException( )
                    elif( len( res2 ) == 0 ):
                        num2 = 0
                    else :
                        num2 = res2[0][0]
                        if(num2 == None):
                            num2 = 0
                            
                    #查询凭证余数
                    sqlStr = "select SUM(CAST(VOUHNUM AS DECIMAL(25))) from VOUH_REGISTER \
                            where VOUHTYPE = '" + records[i][0] + "' \
                            and TELLERNO = '" + TradeContext.sTellerTailNo + "' \
                            and BESBNO = '" + TradeContext.sBesbNo + "' \
                            and VOUHSTATUS = '3'"
                    res3 = AfaDBFunc.SelectSql( sqlStr )
                    AfaLoggerFunc.tradeInfo('sql3 = '+sqlStr)
                    if( res3 == None ):
                        tradeExit('A005067', '查询[凭证表]操作异常!')
                        raise AfaFlowControl.flowException( )
                    elif( len( res3 ) == 0 ):
                        num3 = 0
                    else :
                        num3 = res3[0][0]
                        if(num3 == None):
                            num3 = 0
                    
                vouh.append([records[i][0],records[i][1],str(num1),str(num2),str(num3)])
                
                count1 = count1 + num1
                count2 = count2 + num2
                count3 = count3 + num3

        
        rBankFile= os.environ['AFAP_HOME'] + '/data/vouh/vouhtmp.txt'
      

        #创建业务报表文件
        bFp = open(rBankFile, "w")
        AfaLoggerFunc.tradeInfo('-----' + TradeContext.sBesbNo)
        AfaLoggerFunc.tradeInfo('-----' + TradeContext.sBesbName)
        AfaLoggerFunc.tradeInfo('-----' + TradeContext.sTellerTailNo)
        AfaLoggerFunc.tradeInfo('-----' + TradeContext.sWorkDate)
        
        #写入标题
        bFp.write('\n                          **************** 代理业务凭证余额表 ****************                         \n\n')
        bFp.write('              机构号码:' + TradeContext.sBesbNo + '        机构名称: ' + TradeContext.sBesbName +  '\n')
        bFp.write('              柜员号码:' + TradeContext.sTellerTailNo +  '            日期:' + TradeContext.sWorkDate +  '\n')
        bFp.write('    ------------------------------------------------------------------------------------------------------\n')
        bFp.write('    |   序号   | 凭证种类 |          凭证姓名            |   收方发生额  |   付方发生额  |      余额     |\n')
        bFp.write('    |----------|----------|------------------------------|---------------|---------------|---------------|\n')
            
        AfaLoggerFunc.tradeInfo('------------test5')
        for i in range( len( vouh ) ):

            wbuffer = '    |'
            wbuffer = wbuffer + str(i+1).ljust(10,' ') + '|'
            wbuffer = wbuffer +(vouh[i][0].strip()).ljust(10, ' ') + '|'
            wbuffer = wbuffer +(vouh[i][1].strip()).ljust(30, ' ') + '|'
            wbuffer = wbuffer +(vouh[i][2].strip()).rjust(15, ' ') + '|'
            wbuffer = wbuffer +(vouh[i][3].strip()).rjust(15, ' ') + '|'
            wbuffer = wbuffer +(vouh[i][4].strip()).rjust(15, ' ') + '|'

            #写入报表文件
            bFp.write(wbuffer + '\n')
            bFp.write('    |----------|----------|------------------------------|---------------|---------------|---------------|\n')
        
        bFp.write('    |   合计   |          |                              |' + str(count1).rjust(15,' ') + '|' + str(count2).rjust(15,' ') + '|' + str(count3).rjust(15,' ')+ '|\n')
        bFp.write('    ------------------------------------------------------------------------------------------------------\n')
        #关闭文件
        bFp.close()
        
        TradeContext.tradeResponse.append( ['sBesbNo',TradeContext.sBesbNo] )
        TradeContext.tradeResponse.append( ['sTellerTailNo',TradeContext.sTellerTailNo] )
        TradeContext.tradeResponse.append( ['sTellerNo',TradeContext.sTellerNo] )             #凭证优化更改201109 
        TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] )
        TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] )
        TradeContext.tradeResponse.append( ['sFileName','vouhtmp.txt'] )
        TradeContext.tradeResponse.append( ['errorCode','0000'] )
        TradeContext.tradeResponse.append( ['errorMsg','交易成功'] )
        AfaFunc.autoPackData()
        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '打印报表['+TradeContext.TemplateCode+']退出' )
    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( )