Beispiel #1
0
def HostParseRet( hostType ):
    AfaLoggerFunc.tradeInfo(HostContext.O1MGID)
    if (HostContext.host_Error == True):    #主机通讯错误
        AfaLoggerFunc.tradeInfo('4')
        TradeContext.__status__='2'
        TradeContext.errorCode, TradeContext.errorMsg = 'A9998', '主机通讯错误'
        TradeContext.MGID  = HostContext.host_ErrorType    #通讯错误代码
        return False
    
    if( HostContext.O1MGID == 'AAAAAAA' ): #成功
        TradeContext.__status__='0'
        TradeContext.errorCode, TradeContext.errorMsg = '0000', '主机成功'
        TradeContext.MGID  = HostContext.O1MGID  #主机返回代码

        #=====根据交易码不同选择不同的信息返回====
        if TradeContext.HostCode == '8813':
            TradeContext.TRDT   = HostContext.O1TRDT  #主机日期
            TradeContext.TLSQ   = HostContext.O1TLSQ  #主机流水号
            TradeContext.DASQ   = str(HostContext.O2DASQ[0])   #代销帐序号
            AfaLoggerFunc.tradeInfo('销账序号[' + TradeContext.DASQ +']')
        elif TradeContext.HostCode == '8820':
            TradeContext.TRDT   = HostContext.O1TRDT  #主机日期
            TradeContext.TLSQ   = HostContext.O1TLSQ  #主机流水号
        elif TradeContext.HostCode == '8810':
            TradeContext.ACCNM  = UtilTools.trim(HostContext.O1CUNM)  #账号名称
            TradeContext.ACCSO  = HostContext.O1OPNT  #开户机构
            TradeContext.ACCST  = HostContext.O1ACST  #账户状态
            TradeContext.ACCCD  = HostContext.O1ITCD  #业务代号
            TradeContext.ACCEM  = HostContext.O1ITEM  #科目代号
            TradeContext.ACITY  = HostContext.O1IDTY  #证件类型
            TradeContext.ACINO  = HostContext.O1IDNO  #证件号码
        elif TradeContext.HostCode == '8811':
            TradeContext.HPAYTYP = HostContext.O1WDTP
            TradeContext.ACCSTCD = HostContext.O1STCD #凭证状态
            AfaLoggerFunc.tradeDebug('>>>查询凭证信息完成')
        #===========关彬捷 20080725 增加8820接口返回信息解析===================
        elif TradeContext.HostCode == '8820':
            TradeContext.TRDT   = HostContext.O1TRDT  #主机日期
            TradeContext.TLSQ   = HostContext.O1TLSQ  #主机流水号
        else:
            AfaLoggerFunc.tradeDebug('>>>主机记账完成')

        AfaLoggerFunc.tradeDebug('>>>主机成功返回')
        return True

    else:                                  #失败
        TradeContext.__status__='1'
        AfaLoggerFunc.tradeInfo('8')

        TradeContext.errorCode, TradeContext.errorMsg = HostContext.O1MGID, HostContext.O1INFO
        return False
Beispiel #2
0
def SubModuleMainFst( ):
    AfaLoggerFunc.tradeInfo('财税库行_对账处理开始[TTPS001_8450041]' )
    try:
        #=============获取当前系统时间====================
        #TradeContext.workDate=UtilTools.GetSysDate( )
        TradeContext.workTime=UtilTools.GetSysTime( )
        #============变量值的有效性校验============
        if( not TradeContext.existVariable( "chkAcctOrd" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '[chkAcctOrd]值不存在!' )
        if( not TradeContext.existVariable( "chkDate" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '[chkDate]值不存在!' )
        if( not TradeContext.existVariable( "chkAcctType" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '[chkAcctType]值不存在!' )
        if( not TradeContext.existVariable( "payeeBankNo" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '[payeeBankNo]值不存在!' )
        if( not TradeContext.existVariable( "payBkCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '[payBkCode]值不存在!' )
        #TradeContext.workDate=TradeContext.chkDate
        AfaLoggerFunc.tradeInfo('>>>对帐日期:'+TradeContext.chkDate+'对账批次:'+TradeContext.chkAcctOrd)
        
        #====判断应用状态=======
        if not TipsFunc.ChkAppStatus():
            return False
        #====获取清算信息=======
        if not TipsFunc.ChkLiquidStatus():
            return False
        
        #开始处理批次
        if not UpdateBatchAdm('2','','正在与国库数据进行对账') :
            return TipsFunc.ExitThisFlow( 'A0001', '更新批次状态失败!' )
        
        totalnum_succ=0
        totalamt_succ=0

        #逐笔流水与中间业务对账
        AfaLoggerFunc.tradeInfo('>>>逐笔流水与中间业务对账')
        sqlStr = "SELECT accno,amount,status,corpserialno FROM TIPS_CHECKDATA WHERE "
        sqlStr =sqlStr +" workDate = '"         + TradeContext.chkDate              + "'"
        sqlStr =sqlStr +" AND BATCHNO = '"      + TradeContext.chkAcctOrd           + "'"
        sqlStr =sqlStr +" AND PAYEEBANKNO ='"   + TradeContext.payeeBankNo.strip()    + "'"   
        sqlStr =sqlStr +" AND PAYBKCODE ='"     + TradeContext.payBkCode.strip()  + "'"
        sqlStr =sqlStr +" order by corpserialno"
        Records = AfaDBFunc.SelectSql( sqlStr )
        AfaLoggerFunc.tradeInfo(sqlStr)
        if( Records == None ):
            AfaLoggerFunc.tradeFatal('对账明细表操作异常:'+AfaDBFunc.sqlErrMsg)
            UpdateBatchAdm('1','','对账失败:数据库异常(TIPS_CHECKDATA)')
            return TipsFunc.ExitThisFlow( 'A0027', '数据库错,批量管理表操作异常' )
        else:
            AfaLoggerFunc.tradeInfo('第三方笔数:'+str(len(Records)))
            for i in range(0, len(Records)):
                if (Records[i][2]=='0' ): #已成功
                    continue
                if (Records[i][2]=='1' ): #已成功
                    continue
                elif Records[i][2]=='9':    #流水尚未处理
                    #准备与中间业务对账
                    ChkFlag = '*'
                    #先查询数据库中记录是否存在
                    sqlstr_m = "SELECT AMOUNT,DRACCNO,SERIALNO,CORPCHKFLAG,BANKSTATUS FROM TIPS_MAINTRANSDTL WHERE"
                    sqlstr_m = sqlstr_m + " CORPTIME='"  + TradeContext.chkDate.strip()  + "'"
                    sqlstr_m = sqlstr_m + " AND CORPSERNO='"  + Records[i][3].strip()        + "'"
                    sqlstr_m = sqlstr_m + " AND NOTE3 = '" + TradeContext.payBkCode.strip() + "'"
                    sqlstr_m = sqlstr_m + " AND NOTE4 = '" + TradeContext.payeeBankNo.strip() + "'"
                    sqlstr_m = sqlstr_m + " AND BANKSTATUS = '0' AND REVTRANF='0'"
                    AfaLoggerFunc.tradeInfo(sqlstr_m)
                    records_m = AfaDBFunc.SelectSql( sqlstr_m )
                    if ( records_m==None ):
                        AfaLoggerFunc.tradeFatal('数据库异常:查询业务流水表。'+AfaDBFunc.sqlErrMsg)
                        UpdateBatchAdm('1','','对账失败:数据库异常(TIPS_MAINTRANSDTL)')
                        return TipsFunc.ExitThisFlow( 'A0027', '中间业务流水表操作异常' )
                    if (len(records_m) == 0 ):
                        AfaLoggerFunc.tradeInfo(Records[i])
                        UpdateBatchAdm('1','','对账失败:国库比本行多付款记录')
                        #发起对账回执交易
                        TradeContext.OriPayBankNo  =TradeContext.payBkCode
                        TradeContext.OriChkDate    =TradeContext.chkDate
                        TradeContext.OriChkAcctOrd =TradeContext.chkAcctOrd
                        TradeContext.OriPayeeBankNo=TradeContext.payeeBankNo
                        TradeContext.Result        ='24030'
                        TradeContext.AddWord       ='对帐不符,TIPS比商业银行多付款记录'
                        subModuleName = 'TTPS001_032111'
                        subModuleHandle=__import__( subModuleName )
                        AfaLoggerFunc.tradeInfo( '执行['+subModuleName+']模块' )
                        if not subModuleHandle.SubModuleMainFst( ) :
                            return False
                        return TipsFunc.ExitThisFlow( '24030', '对帐不符,TIPS比商业银行多付款记录' )
                    else:
                        if (records_m[0][3]=='0' ): #已成功
                            continue
                        if (records_m[0][3]=='1' ): #已成功
                            continue
                        elif records_m[0][3]=='9':    #流水尚未处理
                            c_tradeamt = (long)((float)(Records[i][1].strip())*100 + 0.1)
                            m_tradeamt = (long)((float)(records_m[0][0].strip())*100 + 0.1)
                            if ( c_tradeamt != m_tradeamt ):
                                UpdateBatchAdm('1','','对账失败:流水金额不符')
                                #发起对账回执交易
                                TradeContext.OriPayBankNo  =TradeContext.payBkCode
                                TradeContext.OriChkDate    =TradeContext.chkDate
                                TradeContext.OriChkAcctOrd =TradeContext.chkAcctOrd
                                TradeContext.OriPayeeBankNo=TradeContext.payeeBankNo
                                TradeContext.Result        ='24030'
                                TradeContext.AddWord       ='对帐失败,金额不符'
                                subModuleName = 'TTPS001_032111'
                                subModuleHandle=__import__( subModuleName )
                                AfaLoggerFunc.tradeInfo( '执行['+subModuleName+']模块' )
                                if not subModuleHandle.SubModuleMainFst( ) :
                                    return False
                                return TipsFunc.ExitThisFlow( '24030', '对帐失败,金额不符' )
                        ChkFlag = '0'
                        totalnum_succ = totalnum_succ+1
                        totalamt_succ = totalamt_succ + c_tradeamt
                
                    #修改记录对账状态,对账日期和场次
                    sqlstr_m = "UPDATE TIPS_MAINTRANSDTL SET CORPCHKFLAG='" + ChkFlag + "',NOTE1='"+TradeContext.chkDate+"',NOTE2='"+TradeContext.chkAcctOrd+"'"
                    #sqlstr_m = sqlstr_m + " ,CHKFLAG = '0'"
                    #sqlstr_m = sqlstr_m + " ,NOTE3 = '" + TradeContext.payBkCode + "',NOTE4 = '" + TradeContext.payeeBankNo + "' WHERE"
                    sqlstr_m = sqlstr_m + " WHERE"
                    sqlstr_m = sqlstr_m + " CORPTIME='"  + TradeContext.chkDate.strip()  + "'"
                    sqlstr_m = sqlstr_m + " AND CORPSERNO='"  + Records[i][3].strip()        + "'"
                    sqlstr_m = sqlstr_m + " AND NOTE3 = '" + TradeContext.payBkCode.strip() + "'"
                    sqlstr_m = sqlstr_m + " AND NOTE4 = '" + TradeContext.payeeBankNo.strip() + "'"
                    sqlstr_m = sqlstr_m + " AND BANKSTATUS = '0' AND REVTRANF='0'"
                    AfaLoggerFunc.tradeInfo(sqlstr_m)
                    retcode = AfaDBFunc.UpdateSqlCmt( sqlstr_m )
                    if (retcode==None or retcode <= 0):
                        UpdateBatchAdm('1','','对账失败:数据库异常(对账明细表)2')
                        return TipsFunc.ExitThisFlow( 'A0027', '修改记录对帐状态,数据库异常' )
        
        #更新批次状态
        if not UpdateBatchAdm('3','0000','与国库对帐完成') :
            return TipsFunc.ExitThisFlow( 'A0001', '更新批次状态失败!' )
        
        #读取配置文件中信息
        GetLappConfig( )
        
        #日切对账
        if(TradeContext.chkAcctType=='1'):
            #冲正 银行比TIPS多的流水
            if not rev_proc():
                return TipsFunc.ExitThisFlow( 'A0027', '冲正异常' )            
        
        #发起对账回执交易
        TradeContext.OrMsgRef  =TradeContext.MsgRef
        TradeContext.OriPayBankNo  =TradeContext.payBkCode
        TradeContext.OriChkDate    =TradeContext.chkDate
        TradeContext.OriChkAcctOrd =TradeContext.chkAcctOrd
        TradeContext.OriPayeeBankNo=TradeContext.payeeBankNo
        TradeContext.Result        ='90000'
        TradeContext.AddWord       ='对帐完成'
        subModuleName = 'TTPS001_032111'
        subModuleHandle=__import__( subModuleName )
        AfaLoggerFunc.tradeInfo( '执行['+subModuleName+']模块' )
        if not subModuleHandle.SubModuleMainFst( ) :
            UpdateBatchAdm('1','','对账失败:发送对账回执失败')
            return False
        if not UpdateBatchAdm('5','0000','人行对账回执发送完成') :
            return TipsFunc.ExitThisFlow( 'A0001', '更新批次状态失败!' )
   
        #对账完成
        TradeContext.errorCode='0000'
        TradeContext.errorMsg='交易成功'
        
        AfaLoggerFunc.tradeInfo('财税库行_对账处理结束[TTPS001_8450041]' )
        return True
    except Exception, e:
        TipsFunc.exitMainFlow(str(e))
Beispiel #3
0
def rev_proc():
    #查询需要冲正的明细
    AfaLoggerFunc.tradeInfo('>>>查询需要冲正的明细')
    sql_m="select taxpaycode,amount,serialno,zoneno,brno,tellerno,bankstatus,corpstatus from tips_maintransdtl "
    sql_m=sql_m+" where corpTime='"+TradeContext.chkDate +"' and  revtranf='0' and bankstatus='0' and corpchkflag='9' "
    sql_m=sql_m+" and note3='"+TradeContext.payBkCode.strip()+"' and note4='"+TradeContext.payeeBankNo.strip()+"'"
    AfaLoggerFunc.tradeInfo(sql_m)
    records_m=AfaDBFunc.SelectSql(sql_m)
    if records_m==None:
        return TipsFunc.ExitThisFlow( 'A0027', '数据库异常' )
    elif(len(records_m)==0):
        AfaLoggerFunc.tradeInfo('>>>没有需要冲正的明细')
        return True
    else:
        records_m=UtilTools.ListFilterNone( records_m )
        for i in range(0,len(records_m)):
            TradeContext.taxPayCode     =records_m[i][0]   #用户号
            TradeContext.amount         =records_m[i][1]   #金额
            TradeContext.preAgentSerno  =records_m[i][2]   #原交易流水号
            TradeContext.zoneno         =records_m[i][3]    
            TradeContext.brno           =records_m[i][4]    
            TradeContext.teller         =records_m[i][5] 
            
            TradeContext.channelCode = '007'
            TradeContext.workDate = TradeContext.chkDate
            TradeContext.workTime = UtilTools.GetSysTime( )
            TradeContext.appNo      ='AG2010'
            TradeContext.busiNo     ='00000000000001'
            
            TradeContext.TransCode = '8450041'
            
            #============校验公共节点的有效性==================
            if ( not TipsFunc.Cancel_ChkVariableExist( ) ):
                raise TipsFunc.flowException( )
            
            #=============判断应用状态====================
            #if( not TipsFunc.ChkAppStatus( ) ):
            #    raise TipsFunc.flowException( )
            
            #=============判断反交易数据是否匹配原交易====================
            if( not TipsFunc.ChkRevInfo( TradeContext.preAgentSerno ) ):
                raise TipsFunc.flowException( )
            
            #=============获取平台流水号====================
            if( not TipsFunc.GetSerialno( ) ):
                raise TipsFunc.flowException( )
            
            #=============插入流水表====================
            if( not TipsFunc.InsertDtl( ) ):
                raise TipsFunc.flowException( )
            
            #=============与主机通讯====================
            TipsFunc.CommHost( )
            
            errorCode=TradeContext.errorCode
            if TradeContext.errorCode=='SXR0010' :  #原交易主机已冲正,当成成功处理
                TradeContext.__status__='0'
                TradeContext.errorCode, TradeContext.errorMsg = '0000', '主机成功'
            
            #=============更新交易流水====================
            if( not TipsFunc.UpdateDtl( 'TRADE' ) ):
                if errorCode == '0000':
                    TradeContext.errorMsg='取消交易成功 '+TradeContext.errorMsg
                raise TipsFunc.flowException( )
                
            #===== add by liu.yl at 2011/5/17 ====
            #===== 新增更新原交易状态为3-冲正 ====
            if TradeContext.errorCode == '0000':
                sql_u = "update tips_maintransdtl set bankstatus='3', errormsg='人行对账冲正成功' "
                sql_u = sql_u + " where corpTime='" + TradeContext.chkDate
                sql_u = sql_u + "' and serialno='" + TradeContext.preAgentSerno               #原交易流水号
                sql_u = sql_u + "' and note3='"+TradeContext.payBkCode.strip()
                sql_u = sql_u + "' and note4='"+TradeContext.payeeBankNo.strip()+"'"
                
                rec = AfaDBFunc.UpdateSqlCmt(sql_u)
                if rec < 0:
                    TipsFunc.WrtLog(sql_u)
                    TradeContext.errorCode, TradeContext.errorMsg = "S999",'数据库异常'
                    TipsFunc.exitMainFlow()
                AfaLoggerFunc.tradeInfo('>>>交易流水号:' + TradeContext.preAgentSerno + '冲正成功')
    return True
Beispiel #4
0
def CommHost( result = '' ):

    AfaLoggerFunc.tradeInfo('>>>主机通讯函数[CommHost]')

    #根据正反交易标志TradeContext.BRSFLG判断具体选择哪个map文件和主机接口方式
    #===================初始化=======================
    if not InitHostReq(result) :
        TradeContext.__status__='1'
        return False
    if (result == '8813'):
        AfaLoggerFunc.tradeInfo('>>>单笔记帐')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8813.map'

    elif (result == '8820' ):
        AfaLoggerFunc.tradeInfo('>>>单笔抹帐')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8820.map'
        TradeContext.HostCode = '8820'

    elif (result == '8810'):
        AfaLoggerFunc.tradeInfo('>>>查询帐户信息')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8810.map'
        TradeContext.HostCode = '8810'

        #关彬捷 20081105 将8810主机输入接口初始化程序从InitGLHostReq函数移动至InitHostReq函数中
        #InitGLHostReq()

    elif (result == '8811'):
        AfaLoggerFunc.tradeInfo('>>>查询凭证信息')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8811.map'
        TradeContext.HostCode = '8811'
        InitGLHostReq()

    elif (result == '8812'):
        AfaLoggerFunc.tradeInfo('>>>外联关联帐户登记交易')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8812.map'
        TradeContext.HostCode = '8812'
        InitGLHostReq()

    elif (result == '8814'):
        AfaLoggerFunc.tradeInfo('>>>批量申请')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8814.map'
        TradeContext.HostCode = '8814'
        InitGLHostReq()

    elif (result == '8815'):
        AfaLoggerFunc.tradeInfo('>>>批量查询')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8815.map'
        TradeContext.HostCode = '8815'
        InitGLHostReq()
    
    #=====刘雨龙 20081129 新增查询主机账务信息====
    elif (result == '8816'):
        AfaLoggerFunc.tradeInfo('>>>查询主机账务信息')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8816.map'
        TradeContext.HostCode = '8816'
        InitGLHostReq()

    #=====刘雨龙 20081129 新增查询主机账务信息====
    elif (result == '8825'):
        AfaLoggerFunc.tradeInfo('>>>查询主机账务信息')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8825.map'
        TradeContext.HostCode = '8825'
        InitGLHostReq()

    elif (result == '8818'):
        AfaLoggerFunc.tradeInfo('>>>对帐明细申请')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8818.map'
        TradeContext.HostCode = '8818'
        InitGLHostReq()

    elif (result == '8819'):
        AfaLoggerFunc.tradeInfo('>>>检查文件是否生成')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8819.map'
        TradeContext.HostCode = '8819'
        InitGLHostReq()

    elif (result == '8847'):
        AfaLoggerFunc.tradeInfo('>>>对公帐号流水明细查询')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8847.map'
        TradeContext.HostCode = '8847'
        InitGLHostReq()

    elif (result == '8826'):
        AfaLoggerFunc.tradeInfo('>>>对账请求')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8826.map'
        TradeContext.HostCode = '8826'
        InitGLHostReq()
        
    #关彬捷 20081215  新增0652校验磁道信息接口
    elif (result == '0652' ):
        AfaLoggerFunc.tradeInfo('>>>校验磁道信息')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH0652.map'
        TradeContext.HostCode = '0652'
        
    #=====刘雨龙 20081128 新增8823关于农信银手续费接口====
    elif (result == '8823'):
        AfaLoggerFunc.tradeInfo('>>>手续费清单文件上传')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8823.map'
        TradeContext.HostCode = '8823'
        InitGLHostReq()
    
    #曾照泰20110520 新增0061 错帐控制解控交易
    elif (result == '0061'):
        AfaLoggerFunc.tradeInfo('>>>错帐控制解控')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH0061.map'
        TradeContext.HostCode = '0061'
        InitGLHostReq()
    else:
        TradeContext.errorCode = 'A9999'
        TradeContext.errorMsg  = '主机代码错误'
        return False
    
    #此处交易代码要求10位,右补空格
    HostComm.callHostTrade( mapfile, UtilTools.Rfill(TradeContext.HostCode,10,' ') ,'0002' )
    
    AfaLoggerFunc.tradeInfo( 'host_Error:'+str( HostContext.host_ErrorType )+':'+HostContext.host_ErrorMsg )
    if HostContext.host_Error:
        AfaLoggerFunc.tradeFatal( 'host_Error:'+str( HostContext.host_ErrorType )+':'+HostContext.host_ErrorMsg )
        AfaLoggerFunc.tradeInfo('5')

        if HostContext.host_ErrorType != 5 :
            TradeContext.__status__='1'
            TradeContext.errorCode='A0101'
            TradeContext.errorMsg=HostContext.host_ErrorMsg
        else :
            TradeContext.__status__='2'
            TradeContext.errorCode='A0102'
            TradeContext.errorMsg=HostContext.host_ErrorMsg
        return False

    #================分析主机返回包====================
    return HostParseRet(result )
Beispiel #5
0
def SubModuleMainFst( ):
    AfaLoggerFunc.tradeInfo('财税库行_行内资金清算开始[T003001_0331112]' )
    TradeContext.TransCode='0331112'
    try:
        #=============获取当前系统时间====================
        TradeContext.workDate=UtilTools.GetSysDate( )
        TradeContext.workTime=UtilTools.GetSysTime( )
        
        #============系统标识============
        sqlStr = "SELECT * FROM AFA_UNITADM WHERE APPNO = '" + TradeContext.appNo + "' AND "
        #============商户代码============
        sqlStr = sqlStr+"UNITNO = '" + TradeContext.unitno + "' "
        AfaLoggerFunc.tradeInfo( sqlStr )
        records = AfaDBFunc.SelectSql( sqlStr )
        if( records == None ):
            return AfaFlowControll.ExitThisFlow( 'A0002', '商户信息表操作异常:'+AfaDBFunc.sqlErrMsg )
        elif( len( records )==0 ):
            AfaLoggerFunc.tradeError( sqlStr )
            return AfaFlowControll.ExitThisFlow( 'A0003', '无此商户信息' )
        else:
            records=UtilTools.ListFilterNone( records )
            ##=============商户名称=============
            #TradeContext.unitName = records[0][2]
            ##=============商户简称=============
            #TradeContext.unitSName = records[0][3]
            #
            ##===============判断商户状态============================
            #if( records[0][4]=="0" ):
            #    return AfaFlowControll.ExitThisFlow( 'A0004', '该商户处于关闭状态,不能做交易' )
            #elif( records[0][4]=="2" ):
            #    return AfaFlowControll.ExitThisFlow( 'A0005', '该商户处于暂停状态,不能做交易' )
            #elif( records[0][4]=="3" ):
            #    return AfaFlowControll.ExitThisFlow( 'A0005', '该商户处于未启用状态,不能做交易' )
            ##=============银行角色=============
            #TradeContext.__bankMode__ = records[0][5]
            #=============业务模式=============
            TradeContext.__busiMode__ = records[0][6]
            #=============账户模式=============
            TradeContext.__accMode__ = records[0][7]
            AfaLoggerFunc.tradeInfo( '业务模式:'+TradeContext.__busiMode__+'  账户模式:'+ TradeContext.__accMode__)
            ##===============业务模式============================
            #if( TradeContext.__busiMode__!="2" ): 
            #======================账户模式============================
            if( TradeContext.__accMode__ !="2" ):   #无分支商户单位,不需行内清算
                return True
                ##===============银行商户代码(商户号)============================
                #TradeContext.bankUnitno = records[0][8]
                ##===============主办分行号============================
                #if(len(records[0][9])>0):
                #    TradeContext.mainZoneno = records[0][9]
                ##===============主办网点号============================
                #if(len(records[0][10])>0):
                #    TradeContext.mainBrno = records[0][10]
                ##===============银行编码============================
                #TradeContext.bankno = records[0][16]
                ##=============单位账号=============
                #TradeContext.__agentAccno__ = records[0][17]
                ##=============摘要代码(帐务核心系统需要)=============
                #TradeContext.__zhaiYaoCode__ = records[0][32]
                ##=============摘要(帐务核心系统需要)=============
                #TradeContext.__zhaiYao__ = records[0][33]
            if( TradeContext.__accMode__ == '2' ):
                #=============贷方账号(清算行帐号)=============
                TradeContext.agentAccno = records[0][17]
                #=========商户分支单位=============
                #============系统标识============
                sqlStr = "SELECT * FROM AFA_SUBUNITADM WHERE APPNO = '" + TradeContext.appNo + "' AND "
                #============商户代码============
                sqlStr = sqlStr+"UNITNO = '" + TradeContext.unitno + "' "
                AfaLoggerFunc.tradeInfo( sqlStr )
                subRecords = AfaDBFunc.SelectSql( sqlStr )
                if(subRecords == None ):
                    # AfaLoggerFunc.tradeFatal( sqlStr )
                    return AfaFlowControll.ExitThisFlow( 'A0002', '商户分支单位信息表操作异常:'+AfaDBFunc.sqlErrMsg )
                elif( len( subRecords )==0 ):
                    return AfaFlowControll.ExitThisFlow( 'A0002', '商户分支单位中无记录,参数设置有误' )
                else:
                    subRecords=UtilTools.ListFilterNone( subRecords )
                    for i in range( 0, len( subRecords ) ):
                        subUnitno = subRecords[i][2]
                        AfaLoggerFunc.tradeInfo( 'subunitno:'+subUnitno )
                        #=============摘要代码=============
                        TradeContext.__zhaiYaoCode__ = subRecords[i][32]
                        #=============摘要=============
                        TradeContext.__zhaiYao__    = subRecords[i][33]
                        #=============清算:出现清算金额大于银行发生额,需要联社1391科目垫款====================
                        #统计县联社对账差异金额作为转账金额
                        if not DoSumAmountDiff(subUnitno):
                            return AfaFlowControll.ExitThisFlow( 'A0027', '汇总发生额失败' )
                        #TradeContext.amount='1'
                        TradeContext.amount     =str(long(float(TradeContext.amountDiff)))
                        if long(TradeContext.amount)>0 :
                            #检查是否已经清算
                            sqlStr_qs = "SELECT COUNT(*) FROM AFA_MAINTRANSDTL WHERE APPNO = '" + TradeContext.appNo + "'"
                            sqlStr_qs = sqlStr_qs + "AND  UNITNO = '" + TradeContext.unitno + "' "
                            sqlStr_qs = sqlStr_qs + "AND  SUBUNITNO = '" + subUnitno + "' "
                            sqlStr_qs = sqlStr_qs + "AND  USERNO = '-' "
                            sqlStr_qs = sqlStr_qs + "AND  NOTE2 = '" + TradeContext.ChkDate + "' "
                            sqlStr_qs = sqlStr_qs + "AND  NOTE3 = '" + TradeContext.ChkAcctOrd + "' "
                            sqlStr_qs = sqlStr_qs + "AND  NOTE4 = '" + TradeContext.PayBkCode.strip()   + "' "
                            sqlStr_qs = sqlStr_qs + "AND  NOTE5 = '" + TradeContext.PayeeBankNo.strip() + "' "
                            sqlStr_qs = sqlStr_qs + "AND  NOTE6 = '0'" 
                            AfaLoggerFunc.tradeInfo( sqlStr_qs )
                            Records_qs = AfaDBFunc.SelectSql( sqlStr_qs )
                            if(Records_qs == None ):
                                # AfaLoggerFunc.tradeFatal( sqlStr )
                                return AfaFlowControll.ExitThisFlow( 'A0002', '流水表操作异常:'+AfaDBFunc.sqlErrMsg )
                            elif (len(Records_qs)=0): 
                                TradeContext.__chkAccPwdCtl__='0'   
                                TradeContext.channelCode='009'
                                TradeContext.accType    ='001'
                                TradeContext.tellerno   ='999986'                   #
                                TradeContext.cashTelno  ='999986'                   #
                                TradeContext.termId     ='tips'
                                TradeContext.brno       =subUnitno                  #unitno作为记账网点号
                                TradeContext.zoneno     =TradeContext.brno[0:3]
                                TradeContext.accno      =subRecords[i][18]          #联社1391账户作为借方账户
                                TradeContext.__agentAccno__=subRecords[i][17]       #联社2013账户作为贷方账户
                                AfaLoggerFunc.tradeInfo( '借方:'+TradeContext.accno+'贷方:' +TradeContext.__agentAccno__)
                                TradeContext.userno      ='-'
                                TradeContext.tradeType   ='T'                       #转账类交易
                                TradeContext.userName    =subRecords[i][3]+'.清算流水'
                                AfaFlowControl.GetBranchInfo(TradeContext.brno)
                                TradeContext.note1      =TradeContext.__mngZoneno__ #上级管理机构
                                TradeContext.note2      =TradeContext.ChkDate            
                                TradeContext.note3      =TradeContext.ChkAcctOrd         
                                TradeContext.note4      =TradeContext.PayBkCode.strip()  
                                TradeContext.note5      =TradeContext.PayeeBankNo.strip()
                                TradeContext.note6      ='0' #垫款流水
                                TradeContext.revTranF   ='0'
                                #TradeContext.tradeType  ='T' #转账类交易
                                TradeContext.workTime   =UtilTools.GetSysTime( )
                                #=============获取平台流水号====================
                                if AfaFlowControl.GetSerialno( ) == -1 :
                                    AfaLoggerFunc.tradeInfo('>>>处理结果:获取平台流水号异常' )
                                    return AfaFlowControll.ExitThisFlow( 'A0027', '获取流水号失败' )
                                #
                                TradeContext.subUnitno  =subUnitno       #流水中分支商户代码
                                #=============插入流水表====================
                                if not TransDtlFunc.InsertDtl( ) :
                                    return AfaFlowControll.ExitThisFlow( 'A0027', '插入流水表失败' )
                                
                                #=============与主机通讯====================
                                AfaHostFunc.AfaCommHost('705050') 
                                #if TradeContext.errorCode!='0000':
                                #    return False
                                #=============更新主机返回状态====================
                                TransDtlFunc.UpdateDtl( 'TRADE' )
                            
                        #=============清算:从联社2013进清算行2621====================
                        ##统计县联社总发生额作为转账金额
                        #if not DoSumAmount(subUnitno):
                        #    return AfaFlowControll.ExitThisFlow( 'A0027', '汇总发生额失败' )
                        #TradeContext.amount='1'
                        TradeContext.amount     =str(long(float(TradeContext.amountQS)))
                        if long(TradeContext.amount)>0 :
                            #检查是否已经清算
                            sqlStr_qs = "SELECT COUNT(*) FROM AFA_MAINTRANSDTL WHERE APPNO = '" + TradeContext.appNo + "'"
                            sqlStr_qs = sqlStr_qs + "AND  UNITNO = '" + TradeContext.unitno + "' "
                            sqlStr_qs = sqlStr_qs + "AND  SUBUNITNO = '" + subUnitno + "' "
                            sqlStr_qs = sqlStr_qs + "AND  USERNO = '-' "
                            sqlStr_qs = sqlStr_qs + "AND  NOTE2 = '" + TradeContext.ChkDate + "' "
                            sqlStr_qs = sqlStr_qs + "AND  NOTE3 = '" + TradeContext.ChkAcctOrd + "' "
                            sqlStr_qs = sqlStr_qs + "AND  NOTE4 = '" + TradeContext.PayBkCode.strip()   + "' "
                            sqlStr_qs = sqlStr_qs + "AND  NOTE5 = '" + TradeContext.PayeeBankNo.strip() + "' "
                            sqlStr_qs = sqlStr_qs + "AND  NOTE6 = '1'" 
                            AfaLoggerFunc.tradeInfo( sqlStr_qs )
                            Records_qs = AfaDBFunc.SelectSql( sqlStr_qs )
                            if(Records_qs == None ):
                                # AfaLoggerFunc.tradeFatal( sqlStr )
                                return AfaFlowControll.ExitThisFlow( 'A0002', '流水表操作异常:'+AfaDBFunc.sqlErrMsg )
                            elif (len(Records_qs)=0): 
                                TradeContext.__chkAccPwdCtl__='0'   
                                TradeContext.channelCode='009'
                                TradeContext.accType    ='001'
                                TradeContext.tellerno   ='999986'                   #
                                TradeContext.cashTelno  ='999986'                   #
                                TradeContext.termId     ='tips'
                                TradeContext.brno       =TradeContext.unitno        #unitno作为记账网点号
                                TradeContext.zoneno     =TradeContext.brno[0:3]
                                TradeContext.accno      =subRecords[i][17]          #联社2013结算账户作为借方账户
                                TradeContext.__agentAccno__=TradeContext.agentAccno #清算行2621作为贷方
                                AfaLoggerFunc.tradeInfo( '借方:'+TradeContext.accno+'贷方:' +TradeContext.__agentAccno__)
                                if TradeContext.accno==TradeContext.__agentAccno__: #无需清算
                                    continue
                                TradeContext.userno      ='-'
                                TradeContext.tradeType   ='T'                       #转账类交易
                                TradeContext.userName    =subRecords[i][3]+'.清算流水'
                                AfaFlowControl.GetBranchInfo(TradeContext.brno)
                                TradeContext.note1      =TradeContext.__mngZoneno__ #上级管理机构
                                TradeContext.note2      =TradeContext.ChkDate            
                                TradeContext.note3      =TradeContext.ChkAcctOrd         
                                TradeContext.note4      =TradeContext.PayBkCode.strip()  
                                TradeContext.note5      =TradeContext.PayeeBankNo.strip()
                                TradeContext.note6      ='1' #清算流水
                                TradeContext.revTranF   ='0'
                                TradeContext.workTime   =UtilTools.GetSysTime( )
                                #=============获取平台流水号====================
                                if AfaFlowControl.GetSerialno( ) == -1 :
                                    AfaLoggerFunc.tradeInfo('>>>处理结果:获取平台流水号异常' )
                                    return AfaFlowControll.ExitThisFlow( 'A0027', '获取流水号失败' )
                                #
                                TradeContext.subUnitno  =TradeContext.unitno       #流水中分支商户代码=商户代码
                                #=============插入流水表====================
                                if not TransDtlFunc.InsertDtl( ) :
                                    return AfaFlowControll.ExitThisFlow( 'A0027', '插入流水表失败' )
                                
                                #=============与主机通讯====================
                                AfaHostFunc.AfaCommHost('705050') 
                                #if TradeContext.errorCode!='0000':
                                #    return False
                                #=============更新主机返回状态====================
                                TransDtlFunc.UpdateDtl( 'TRADE' )
                            
        #TradeContext.errorCode='0000'
        #TradeContext.errorMsg='交易成功'
        AfaLoggerFunc.tradeInfo('财税库行_行内资金清算结束[T003001_0331112]' )
        return True
    except Exception, e:
        AfaFlowControll.exitMainFlow(str(e))
Beispiel #6
0
def SubModuleMainFst( ):

    AfaLoggerFunc.tradeInfo( '进入三方协议验证/撤销(人行发起)[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
    try:
        #============校验公共节点的有效性==================
        # 完整性检查
        if( not TradeContext.existVariable( "VCSign" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '标识[VCSign]值不存在!' )
        if( not TradeContext.existVariable( "payAcct" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '帐号[payAcct]值不存在!' )
        if( not TradeContext.existVariable( "taxPayCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '用户号[taxPayCode]值不存在!' )
        if( not TradeContext.existVariable( "taxPayName" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '用户名[taxPayName]值不存在!' )
        if( not TradeContext.existVariable( "taxOrgCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '征收机关[taxOrgCode]值不存在!' )
        if( not TradeContext.existVariable( "protocolNo" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '协议号[protocolNo]值不存在!' )
        if( not TradeContext.existVariable( "PayOpBkCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '付款开户行行号[PayOpBkCode]值不存在!' )
        if( not TradeContext.existVariable( "PayBkCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '清算行行号[PayBkCode]值不存在!' )
        
        #验证撤销结果    0	验证通过,协议已可以使用
        #                1	验证失败,协议不存在或信息有误
        #                2	撤销通过,协议已不能使用
        #                3	撤销失败,协议不存在或信息有误
        if TradeContext.VCSign=='0':
            TradeContext.VCResult='1'
            TradeContext.AddWord='验证失败,协议不存在或信息有误'
        else:
            TradeContext.VCResult='3'
            TradeContext.AddWord='撤销失败,协议不存在或信息有误'
                   
        #=============获取平台流水号==================== 
        if TipsFunc.GetSerialno( ) == -1 :
            return False
        
        if TradeContext.VCSign=='0':
            #=============判断状态====================
            sql = "SELECT STATUS FROM TIPS_CUSTINFO WHERE "
            sql = sql +" TAXPAYCODE='"      +TradeContext.taxPayCode+"'"
            sql = sql +"AND PAYACCT='"      +TradeContext.payAcct+"'"
            sql = sql +"AND TAXORGCODE='"   +TradeContext.taxOrgCode+"'"
            sql = sql +"AND PROTOCOLNO='"   +TradeContext.protocolNo+"'"
            sql = sql +"AND PAYOPBKCODE='"   +TradeContext.PayOpBkCode+"'"
            sql = sql +"AND NOTE2='"   +TradeContext.PayBkCode+"'"
            AfaLoggerFunc.tradeInfo(sql)
            records = AfaDBFunc.SelectSql(sql)
            if( records == None or records < 0 ):
                AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            elif( len( records ) == 0 ):
                AfaLoggerFunc.tradeInfo( "该客户尚未签约")
                TradeContext.errorCode='9999'
                TradeContext.errorMsg='验证失败,协议不存在'
                TradeContext.VCResult='1'
                TradeContext.AddWord='验证失败,协议不存在'
                return True
            else:
                AfaLoggerFunc.tradeFatal(sql)
                AfaLoggerFunc.tradeInfo(records[0][0])
                UtilTools.ListFilterNone( records )
                #0-注销 1-正常(双方都已验证) 2-临时状态(银行方柜面已验证)3-临时状态(银行方柜面已撤销)
                if (records[0][0] =="0" or records[0][0]=="3" ): #已有该客户记录,状态为未签约,无法验证
                    AfaLoggerFunc.tradeInfo( "已有该客户记录,状态为未签约,无法验证")
                    TradeContext.errorCode='9999'
                    TradeContext.errorMsg='验证失败,协议不存在'
                    TradeContext.VCResult='1'
                    TradeContext.AddWord='验证失败,协议不存在'
                    return True
            sql = "update TIPS_CUSTINFO set  STATUS     ='1'"
            sql = sql+" WHERE TAXPAYCODE='" +TradeContext.taxPayCode+"'"
            sql = sql +"AND PAYACCT='"      +TradeContext.payAcct   +"'"
            sql = sql +"AND TAXORGCODE='"   +TradeContext.taxOrgCode+"'"
            sql = sql +"AND PROTOCOLNO='"   +TradeContext.protocolNo+"'"
            AfaLoggerFunc.tradeInfo(sql)
            if( AfaDBFunc.UpdateSqlCmt(sql) == -1 ):
                AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            TradeContext.errorCode='0000'
            TradeContext.errorMsg='验证通过,协议已可以使用'
            TradeContext.VCResult='0'
            TradeContext.AddWord='验证通过,协议已可以使用'
            

        elif TradeContext.VCSign=='1':
            #=============判断状态====================
            sql = "SELECT STATUS FROM TIPS_CUSTINFO WHERE "
            sql = sql +" TAXPAYCODE='"      +TradeContext.taxPayCode+"'"
            sql = sql +"AND PAYACCT='"      +TradeContext.payAcct+"'"
            sql = sql +"AND TAXORGCODE='"   +TradeContext.taxOrgCode+"'"
            sql = sql +"AND PROTOCOLNO='"   +TradeContext.protocolNo+"'"
            sql = sql +"AND PAYOPBKCODE='"   +TradeContext.PayOpBkCode+"'"
            sql = sql +"AND NOTE2='"   +TradeContext.PayBkCode+"'"
            AfaLoggerFunc.tradeInfo(sql)
            records = AfaDBFunc.SelectSql(sql)
            if( records == None or records < 0 ):
                AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            elif( len( records ) == 0 ):
                AfaLoggerFunc.tradeInfo( "该客户尚未签约")
                TradeContext.errorCode='9999'
                TradeContext.errorMsg='撤销失败,协议不存在或信息有误'
                TradeContext.VCResult='3'
                TradeContext.AddWord='撤销失败,协议不存在或信息有误'
                return True
            sql="update TIPS_CUSTINFO set "
            sql=sql+" STATUS     ='0'"
            sql = sql+" WHERE TAXPAYCODE='" +TradeContext.taxPayCode+"'"
            sql = sql +"AND PAYACCT='"      +TradeContext.payAcct   +"'"
            sql = sql +"AND TAXORGCODE='"   +TradeContext.taxOrgCode+"'"
            sql = sql +"AND PROTOCOLNO='"   +TradeContext.protocolNo+"'"
            AfaLoggerFunc.tradeInfo(sql)
            if( AfaDBFunc.UpdateSqlCmt(sql) == -1 ):
                AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            TradeContext.errorCode='0000'
            TradeContext.errorMsg='撤销通过,协议已不能使用'
            TradeContext.VCResult='2'
            TradeContext.AddWord='撤销通过,协议已不能使用'
            
            
                       
               
            #TradeContext.revTranF       ='0' #正交易
            #TradeContext.tradeType      ='U' #签约类交易
            #TradeContext.amount         ='0' #
            #TradeContext.__agentAccno__ =''  #借方帐号置空
            #TradeContext.note1          =TradeContext.upBranchno       
            ##记录签约流水
            #if not TransDtlFunc.InsertDtl( ) :
            #    return False
            #TradeContext.__status__='0'
            #TradeContext.errorCode='0000'
            #TradeContext.errorMsg='交易成功'
            #if( not TransDtlFunc.UpdateDtl( 'TRADE' ) ):
            #    return False
            
        AfaLoggerFunc.tradeInfo(TradeContext.errorCode)
        AfaLoggerFunc.tradeInfo(TradeContext.errorMsg)
        AfaLoggerFunc.tradeInfo(TradeContext.VCResult)
        AfaLoggerFunc.tradeInfo(TradeContext.AddWord)
        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '退出三方协议验证(撤销)[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
        TradeContext.tradeResponse=[]
        return True
    except TipsFunc.flowException, e:
        TipsFunc.exitMainFlow( )
Beispiel #7
0
def SubModuleMainFst( ):
    AfaLoggerFunc.tradeInfo( '进入自由格式报文查询和发送[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
    TradeContext.appNo      ='AG2010'
    TradeContext.busiNo      ='00000000000001'
    try:
        #=============获取当前系统时间====================
        TradeContext.workDate=UtilTools.GetSysDate( )
        TradeContext.workTime=UtilTools.GetSysTime( )
        
        ##====获取工作日期=======
        #if not TipsFunc.GetUnitWorkdate( ):
        #    return False
        
        #============校验公共节点的有效性==================
        # 完整性检查
        if( not TradeContext.existVariable( "operFlag" ) ):
            return AfaFlowControl.ExitThisFlow( 'A0001', '标识[operFlag]值不存在!' )
        
        ##=============获取平台流水号==================== 
        #if AfaFlowControl.GetSerialno( ) == -1 :
        #    raise AfaFlowControl.flowException( )
        #
        if TradeContext.operFlag=='0': #查询
            if( not TradeContext.existVariable( "beginDate" ) ):
                return AfaFlowControl.ExitThisFlow( 'A0001', '起始日[beginDate]值不存在!' )
            if( not TradeContext.existVariable( "endDate" ) ):
                return AfaFlowControl.ExitThisFlow( 'A0001', '截至日[endDate]值不存在!' )
            
            #=================================
            sql="SELECT * FROM TIPS_NOTE WHERE WORKDATE BETWEEN '"+ TradeContext.beginDate +"' AND '"+TradeContext.endDate+"'" 
            if( TradeContext.existVariable( "srcNodeCode" ) and len(TradeContext.srcNodeCode)>0):
                sql=sql+" AND SRCNODECODE ='"+TradeContext.srcNodeCode     +"'"
            if( TradeContext.existVariable( "desNodeCode" ) and len(TradeContext.desNodeCode)>0):
                sql=sql+" AND DESNODECODE ='"+TradeContext.desNodeCode     +"'"
            sql=sql+" ORDER BY WORKDATE,WORKTIME"
            AfaLoggerFunc.tradeInfo(sql)
            records = AfaDBFunc.SelectSql(sql)
            if( records == None ):
                AfaLoggerFunc.tradeFatal(sql)
                return AfaFlowControl.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            elif( len( records )==0 ):
                return AfaFlowControl.ExitThisFlow( 'A0002', '无满足条件的记录')
            else:
                records=UtilTools.ListFilterNone( records ,'')
                
                mx_file_name = os.environ['AFAP_HOME'] + '/tmp/' + 'AH_' + TradeContext.teller + '.txt'
                TradeContext.tradeResponse.append(['fileName',  'AH_' + TradeContext.teller + '.txt'])
            
                if (os.path.exists(mx_file_name) and os.path.isfile(mx_file_name)):
                    #文件存在,先删除-再创建
                    os.system("rm " + mx_file_name)
            
                sfp = open(mx_file_name, "w")
                AfaLoggerFunc.tradeInfo('明细文件=['+mx_file_name+']')
                i = 0
                while ( i  < len(records) ):
                    A0 = str(records[i][0]).strip()         #WORKDATE
                    A1 = str(records[i][1]).strip()         #WORKTIME
                    A2 = str(records[i][2]).strip()         #SrcNodeCode
                    A3 = str(records[i][3]).strip()         #DesNodeCode
                    A4 = str(records[i][4]).strip()         #SendOrgCode
                    A5 = str(records[i][5]).strip()         #RcvOrgCode 
                    A6 = str(records[i][6]).strip()         #Content    
            
                    sfp.write(A0 +  '|'  +  A1[0:2]+':' +A1[2:4]+':' + A1[4:6] +  '|'  +  A2 +  '|'  +  A3 +  '|'  +  A4 +  '|'  +  A5 +  '|'  +  A6 +  '|'  + '\n')
                    i=i+1
                sfp.close()

        elif TradeContext.operFlag=='1':
            #=============获取平台流水号====================
            if AfaFlowControl.GetSerialno( ) == -1 :
                WrtLog('>>>处理结果:获取平台流水号异常' )
                sys.exit()
            
            #=============与第三方通讯====================
            AfaAfeFunc.CommAfe()
            if( TradeContext.errorCode != '0000' ):
                return False
            else:
                sql="insert into TIPS_NOTE"
                sql=sql+" values"
                sql=sql+"('"+TradeContext.workDate     +"'"
                sql=sql+",'"+TradeContext.workTime    +"'"
                sql=sql+",'"+TradeContext.srcNodeCode    +"'"
                sql=sql+",'"+TradeContext.desNodeCode    +"'"
                if( TradeContext.existVariable( "sendOrgCode" ) ):
                    sql=sql+",'"+TradeContext.sendOrgCode    +"'"
                else:
                    sql=sql+",''"
                if( TradeContext.existVariable( "rcvOrgCode" ) ):
                    sql=sql+",'"+TradeContext.rcvOrgCode    +"'"
                else:
                    sql=sql+",''"
                sql=sql+",'"+TradeContext.content +"'"
                sql=sql+")"
                AfaLoggerFunc.tradeInfo(sql)
                if( AfaDBFunc.InsertSqlCmt(sql) == -1 ):
                    AfaLoggerFunc.tradeFatal(sql)
                    return AfaFlowControl.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
        else :
            return AfaFlowControl.ExitThisFlow( 'A0002', '操作类型错误')
            
        #=============自动打包==================== 
        TradeContext.tradeResponse.append(['errorCode',  '0000'])
        TradeContext.tradeResponse.append(['errorMsg',  '交易成功'])
        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '退出三方协议验证/撤消['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
        return True
    except AfaFlowControl.flowException, e:
        return False
Beispiel #8
0
def CommHost( result = None ):

    AfaLoggerFunc.tradeInfo('>>>主机通讯函数[CommHost]')
        
    TradeContext.errorCode = 'H999'
    TradeContext.errorMsg  = '系统异常(与主机通讯)'

    if (result == '8813'):
        AfaLoggerFunc.tradeInfo('>>>单笔记帐')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8813.map'
        TradeContext.HostCode = '8813'
        InitGLHostReq()

    elif (result == '8860'):
        AfaLoggerFunc.tradeInfo('>>>查询帐户信息')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8860.map'
        TradeContext.HostCode = '8860'
        InitGLHostReq()
    elif (result == '8800'):
        AfaLoggerFunc.tradeInfo('>>>短信平台查询')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8800.map'
        TradeContext.HostCode = '8800'
        InitGLHostReq()           
    elif (result == '8861'):
        AfaLoggerFunc.tradeInfo('>>>校验密码')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8861.map'
        TradeContext.HostCode = '8861'
        InitGLHostReq()

    elif (result == '8862'):
        AfaLoggerFunc.tradeInfo('>>>密码修改或重置')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8862.map'
        TradeContext.HostCode = '8862'
        InitGLHostReq()

    elif (result == '8863'):
        AfaLoggerFunc.tradeInfo('>>>重要凭证挂失')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8863.map'
        TradeContext.HostCode = '8863'
        InitGLHostReq()

    elif (result == '8864'):
        AfaLoggerFunc.tradeInfo('>>>查询账户明细')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8864.map'
        TradeContext.HostCode = '8864'
        InitGLHostReq()
        
    elif(result == '8865'):
        AfaLoggerFunc.tradeInfo('>>>查询客户信息')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8865.map'
        TradeContext.HostCode = '8865'
        InitGLHostReq()
        
    elif(result == '8866'):
        AfaLoggerFunc.tradeInfo('>>>证件号查询账户明细')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8866.map'
        TradeContext.HostCode = '8866'
        InitGLHostReq()

    else:
        TradeContext.errorCode = 'A9999'
        TradeContext.errorMsg  = '主机代码错误'
        return False

    #此处交易代码要求10位,右补空格
    HostComm.callHostTrade( mapfile, UtilTools.Rfill(TradeContext.HostCode,10,' ') ,'0002' )

    if HostContext.host_Error:
        AfaLoggerFunc.tradeFatal( 'host_Error:'+str( HostContext.host_ErrorType )+':'+HostContext.host_ErrorMsg )

        if HostContext.host_ErrorType != 5 :
            TradeContext.__status__='1'
            TradeContext.errorCode='A0101'
            TradeContext.errorMsg=HostContext.host_ErrorMsg
        else :
            TradeContext.__status__='2'
            TradeContext.errorCode='A0102'
            TradeContext.errorMsg=HostContext.host_ErrorMsg
        return False

    #================分析主机返回包====================
    return HostParseRet(result )
Beispiel #9
0
def SubModuleMainFst( ):
    AfaLoggerFunc.tradeInfo( '进入三方协议验证/撤消[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )

    try:
        #=============获取当前系统时间====================
        #TradeContext.workDate=UtilTools.GetSysDate( )
        TradeContext.workTime=UtilTools.GetSysTime( )
        
        ##====获取工作日期=======
        #if not TipsFunc.GetUnitWorkdate( ):
        #    return False
        
        #============校验公共节点的有效性==================
        # 完整性检查
        if( not TradeContext.existVariable( "VCSign" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '标识[VCSign]值不存在!' )
        if( not TradeContext.existVariable( "zoneno" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '分行号[zoneno]值不存在!' )
        if( not TradeContext.existVariable( "channelCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '渠道代码[channelCode]值不存在!' )
        if( not TradeContext.existVariable( "brno" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '行所号[brno]值不存在!' )
        if( not TradeContext.existVariable( "teller" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '柜员号[teller]值不存在!' )
        if( not TradeContext.existVariable( "accno" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '帐号[accno]值不存在!' )
        if( not TradeContext.existVariable( "taxPayCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '纳税人编码[taxPayCode]值不存在!' )
        if( not TradeContext.existVariable( "taxPayName" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '纳税人名称[taxPayName]值不存在!' )
        if( not TradeContext.existVariable( "passWDFlag" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '密码验证标志[passWDFlag]值不存在!' )
        if( not TradeContext.existVariable( "payBkCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '清算行行号[payBkCode]值不存在!' )
            
        TradeContext.note2 = TradeContext.payBkCode    #付款行行号
        
        AfaLoggerFunc.tradeInfo((TradeContext.accno)[0])
        if((TradeContext.accno)[0] == '1'):
            if(TradeContext.passWDFlag == '0'):
                #验证密码
                TradeContext.sBrNo = TradeContext.brno          #交易机构
                TradeContext.sTeller = TradeContext.teller      #交易柜员
                TradeContext.sTermId = TradeContext.termId      #终端号 
                HostContext.I1ACNO = TradeContext.accno         #付款帐户
                HostContext.I1CYNO = '01'
                accnoLen = len(TradeContext.accno)
                if(accnoLen == 23):
                    HostContext.I1CFFG = 'A'
                elif(accnoLen == 19):
                    HostContext.I1CFFG = '0'
                    HostContext.I1CETY = (TradeContext.accno)[6:8]
                    HostContext.I1CCSQ = (TradeContext.accno)[8:19]
                else:
                    return TipsFunc.ExitThisFlow( 'A0001', '帐号错误!' )
                HostContext.I1PSWD = TradeContext.passWD    
                
                if(not TipsHostFunc.CommHost('8810')):    
                    return TipsFunc.ExitThisFlow( TradeContext.errorCode, TradeContext.errorMsg )
                if(TradeContext.errorCode == '0000'):
                    if(HostContext.O1CFFG == '1'):
                        return TipsFunc.ExitThisFlow( 'A0001', '密码错误!' )
        
        #=============判断应用状态====================
        if not TipsFunc.ChkAppStatus( ) :
            raise TipsFunc.flowException( )
        #=============判断机构是否开通此应用===============
        #if not TipsFunc.ChkBranchStatus( ) :
        #    raise TipsFunc.flowException( )
        #=============获取平台流水号==================== 
        if TipsFunc.GetSerialno( ) == -1 :
            raise TipsFunc.flowException( )
        
        #签约
        if TradeContext.VCSign=='0':
            #=============判断状态====================
            sql="SELECT STATUS FROM TIPS_CUSTINFO WHERE "
            sql=sql+" TAXORGCODE ='"+TradeContext.taxOrgCode     +"'"
            sql=sql+" AND TAXPAYCODE='"+TradeContext.taxPayCode+"'"
            sql=sql+" AND PROTOCOLNO='"+TradeContext.protocolNo+"'"
            sql=sql+" AND PAYACCT='"+TradeContext.accno+"'"
            records = AfaDBFunc.SelectSql(sql)
            AfaLoggerFunc.tradeFatal(sql)
            if( records == None or  records <0):
                #AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            elif( len( records )==0 ):
                AfaLoggerFunc.tradeInfo( "该客户尚未签约,可正常处理" )
            else:
                AfaLoggerFunc.tradeFatal(sql)
                AfaLoggerFunc.tradeInfo(records[0][0])
                UtilTools.ListFilterNone( records )
                #0-注销 1-正常(双方都已验证) 2-临时状态(银行方柜面已验证)3-临时状态(银行方柜面已撤销)
                if (records[0][0]=="1" or records[0][0]=="2" ): #已有该客户记录,状态为"已启用",不允许签约
                    return TipsFunc.ExitThisFlow( 'A0002', '客户编号或帐号已经签约,不能重复签约')
            TradeContext.status = '2'
            #TradeContext.revTranF       ='0' #正交易
            #TradeContext.tradeType      ='S' #签约类交易
            #TradeContext.amount         ='0' #
            #TradeContext.__agentAccno__ =''  #借方帐号置空
            ##记录签约流水
            #if not TipsFunc.InsertDtl( ) :
            #    return False
            #=============与第三方通讯====================
            #AfaAfeFunc.CommAfe()
            TradeContext.__status__='0'
            TradeContext.errorCode='0000'
            TradeContext.errorMsg='交易成功'
            
            ##=============更新流水表====================
            #if( not TipsFunc.UpdateDtl( 'TRADE' ) ):
            #    return False

            if TradeContext.errorCode!='0000':
                return TipsFunc.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
            if ( len( records )!=0 ):
                sql="update TIPS_CUSTINFO set "
                sql=sql+" PAYACCT         ='"+TradeContext.accno      +"'"
                sql=sql+",STATUS     ='"+'2'                     +"'"
                sql=sql+",TAXPAYNAME      ='"+TradeContext.taxPayName  +"'"
                sql=sql+",HANDORGNAME      ='"+TradeContext.handOrgName  +"'"
                sql=sql+",STARTDATE     ='"+TradeContext.workDate   +"'"
                sql=sql+",ZONENO     ='"+TradeContext.zoneno     +"'"
                sql=sql+",BRNO       ='"+TradeContext.brno       +"'"
                sql=sql+",TELLERNO   ='"+TradeContext.teller   +"'"
                if( TradeContext.existVariable( "NOTE1" ) ):
                    sql=sql+",NOTE1         ='"+TradeContext.note1   +"'"
                if( TradeContext.existVariable( "NOTE2" ) ):
                    sql=sql+",NOTE2         ='"+TradeContext.note2   +"'"
                if( TradeContext.existVariable( "NOTE3" ) ):
                    sql=sql+",NOTE3         ='"+TradeContext.note3   +"'"
                if( TradeContext.existVariable( "NOTE4" ) ):
                    sql=sql+",NOTE4         ='"+TradeContext.note4   +"'"
                if( TradeContext.existVariable( "NOTE5" ) ):
                    sql=sql+",NOTE5         ='"+TradeContext.note5   +"'"
                sql=sql+" WHERE TAXORGCODE ='"+TradeContext.taxOrgCode     +"'"
                sql=sql+" AND TAXPAYCODE ='"+TradeContext.taxPayCode     +"'"
                AfaLoggerFunc.tradeInfo(sql)
                if( AfaDBFunc.UpdateSqlCmt(sql) == -1 ):
                    AfaLoggerFunc.tradeFatal(sql)
                    return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            else:                 
                sql="insert into TIPS_CUSTINFO(TAXPAYCODE,TAXORGCODE,PROTOCOLNO,PAYACCT,IDTYPE,IDCODE,TAXPAYNAME,STATUS,"
                sql=sql+"HANDORGNAME,STARTDATE,ENDDATE,ZONENO,BRNO,TELLERNO,WORKDATE,PAYOPBKCODE,"
                sql=sql+"NOTE1,NOTE2,NOTE3,NOTE4,NOTE5)"
                sql=sql+" values"
                sql=sql+"('"+TradeContext.taxPayCode    +"'"
                sql=sql+",'"+TradeContext.taxOrgCode    +"'"
                sql=sql+",'"+TradeContext.protocolNo+"'"
                sql=sql+",'"+TradeContext.accno     +"'"
                sql=sql+",'',''"
                sql=sql+",'"+TradeContext.taxPayName +"'"
                sql=sql+",'2'" #临时状态,待第三方验证后改为1
                if( TradeContext.existVariable( "handOrgName" ) ):
                    sql=sql+",'"+TradeContext.handOrgName    +"'"
                else:
                    sql=sql+",''"
                #if( TradeContext.existVariable( "custAdd" ) ):
                #    sql=sql+",'"+TradeContext.custAdd    +"'"
                #else:
                #    sql=sql+",''"
                #if( TradeContext.existVariable( "zipCode" ) ):
                #    sql=sql+",'"+TradeContext.zipCode    +"'"
                #else:
                #    sql=sql+",''"
                #if( TradeContext.existVariable( "email" ) ):
                #    sql=sql+",'"+TradeContext.email    +"'"
                #else:
                #    sql=sql+",''"
                sql=sql+",'"+TradeContext.workDate    +"'"
                sql=sql+",''"
                sql=sql+",'"+TradeContext.zoneno      +"'"
                sql=sql+",'"+TradeContext.brno    +"'"
                sql=sql+",'"+TradeContext.teller    +"'"
                sql=sql+",'"+TradeContext.workDate    +"'"
                sql=sql+",'"+TradeContext.payOpBkCode    +"'"
                if( TradeContext.existVariable( "note1" ) ):
                    sql=sql+",'"+TradeContext.note1    +"'"
                else:
                    sql=sql+",''"
                if( TradeContext.existVariable( "note2" ) ):
                    sql=sql+",'"+TradeContext.note2    +"'"
                else:
                    sql=sql+",''"          
                if( TradeContext.existVariable( "note3" ) ):
                    sql=sql+",'"+TradeContext.note3    +"'"
                else:
                    sql=sql+",''"
                if( TradeContext.existVariable( "note4" ) ):
                    sql=sql+",'"+TradeContext.note4    +"'"
                else:
                    sql=sql+",''"
                if( TradeContext.existVariable( "note5" ) ):
                    sql=sql+",'"+TradeContext.note5    +"'"
                else:
                    sql=sql+",''"
                sql=sql+")"
                AfaLoggerFunc.tradeInfo(sql)
                records=AfaDBFunc.InsertSqlCmt(sql)
                if( records == 0 ):
                    return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
                
                if( records == -1 ):
                    return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
                AfaLoggerFunc.tradeInfo('***************')
        elif TradeContext.VCSign=='1':
            #=============判断状态====================
            sql="SELECT STATUS"
            sql=sql+" FROM TIPS_CUSTINFO WHERE TAXPAYCODE ='"+TradeContext.taxPayCode +"'"
            sql=sql+" and PAYACCT     ='"+TradeContext.accno  +"'"
            sql=sql+" and PROTOCOLNO  ='"+TradeContext.protocolNo  +"'"
            sql=sql+" and TAXORGCODE  ='"+TradeContext.taxOrgCode  +"'"
            AfaLoggerFunc.tradeInfo(sql)
            records = AfaDBFunc.SelectSql(sql)
            if( records == None or  records <0):
                AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            elif( len( records )==0 ):
                #begin 20101102 蔡永贵修改
                #return TipsFunc.ExitThisFlow( 'A0027', '该客户三方协议尚未验证,无法撤消' )
                return TipsFunc.ExitThisFlow( 'A0027', '该客户不存在三方协议,请检查录入项是否正确' )
                #end
            elif( len( records )>1 ):
                return TipsFunc.ExitThisFlow( 'A0027', '存在多条验证记录' )
            else:
                AfaLoggerFunc.tradeFatal(sql)
                AfaLoggerFunc.tradeInfo(records[0][0])
                UtilTools.ListFilterNone( records )
                if (records[0][0]=='0' or records[0][0]=='3'):
                    return TipsFunc.ExitThisFlow( 'A0027', '三方协议状态为已撤消,不能重复撤消' )
                if (records[0][0]=='2'):
                    #begin 20101102 蔡永贵修改
                    #return TipsFunc.ExitThisFlow( 'A0027', '第三方未验证,只能做删除交易,不能解约' )
                    return TipsFunc.ExitThisFlow( 'A0027', '第三方未验证,不能解约,请做删除交易' )
                    #end
            TradeContext.status = '3'

            #TradeContext.revTranF       ='0' #正交易
            #TradeContext.tradeType      ='U' #解约类交易
            #TradeContext.amount         ='0' #
            #TradeContext.__agentAccno__ =''  #借方帐号置空
            ##记录签约流水
            #if not TipsFunc.InsertDtl( ) :
            #    return False
            #=============与第三方通讯通讯====================
            #AfaAfeFunc.CommAfe()

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

            ##=============更新流水表====================
            #if( not TipsFunc.UpdateDtl( 'TRADE' ) ):
            #    return False

            #if TradeContext.errorCode!='0000':
            #    return TipsFunc.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
            #if TradeContext.errorCode=='0000':
            
            sql="update TIPS_CUSTINFO set "
            sql=sql+" STATUS     ='"+'3'                     +"'"
            sql=sql+",ENDDATE      ='"+TradeContext.workDate   +"'"
            sql=sql+",ZONENO     ='"+TradeContext.zoneno     +"'"
            sql=sql+",BRNO       ='"+TradeContext.brno       +"'"
            sql=sql+",TELLERNO   ='"+TradeContext.teller   +"'"
            sql=sql+" WHERE TAXPAYCODE ='"  +TradeContext.taxPayCode   +"'"
            sql=sql+" AND PAYACCT ='"       +TradeContext.accno        +"'"
            sql=sql+" AND PROTOCOLNO  ='"   +TradeContext.protocolNo   +"'"
            sql=sql+" AND TAXORGCODE  ='"   +TradeContext.taxOrgCode   +"'"
            AfaLoggerFunc.tradeInfo(sql)
            if( AfaDBFunc.UpdateSqlCmt(sql) == -1 ):
                AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
        #=============自动打包==================== 
        TradeContext.errorCode='0000'
        TradeContext.errorMsg='交易成功'
        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '退出三方协议验证/撤消['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
        return True
    except TipsFunc.flowException, e:
        return False
Beispiel #10
0
def CommHost( result = None ):

    AfaLoggerFunc.tradeInfo('>>>主机通讯函数[CommHost]')
        
    TradeContext.errorCode = 'H999'
    TradeContext.errorMsg  = '系统异常(与主机通讯)'

    #根据正反交易标志TradeContext.revTranF判断具体选择哪个map文件和主机接口方式
    if not result:
        result=TradeContext.revTranF
        #===================初始化=======================
        if not InitHostReq(result) :
            TradeContext.__status__='1'
            return False

    if (result == '0'):
        AfaLoggerFunc.tradeInfo('>>>单笔记帐')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8813.map'
        TradeContext.HostCode = '8813'

    elif (result == '1' or result == '2' ):
        AfaLoggerFunc.tradeInfo('>>>单笔抹帐')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8820.map'
        TradeContext.HostCode = '8820'

    elif (result == '8808'):
        AfaLoggerFunc.tradeInfo('>>>查询主机日期')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8808.map'
        TradeContext.HostCode = '8808'
        InitGLHostReq()
            
    elif (result == '8810'):
        AfaLoggerFunc.tradeInfo('>>>查询帐户信息')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8810.map'
        TradeContext.HostCode = '8810'
        InitGLHostReq()
            
    elif (result == '8812'):
        AfaLoggerFunc.tradeInfo('>>>外联关联帐户登记交易')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8812.map'
        TradeContext.HostCode = '8812'
        InitGLHostReq()

    elif (result == '8814'):
        AfaLoggerFunc.tradeInfo('>>>批量申请')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8814.map'
        TradeContext.HostCode = '8814'
        InitGLHostReq()

    elif (result == '8815'):
        AfaLoggerFunc.tradeInfo('>>>批量查询')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8815.map'
        TradeContext.HostCode = '8815'
        InitGLHostReq()

    elif (result == '8818'):
        AfaLoggerFunc.tradeInfo('>>>对帐明细申请')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8818.map'
        TradeContext.HostCode = '8818'
        InitGLHostReq()

    elif (result == '8819'):
        AfaLoggerFunc.tradeInfo('>>>检查文件是否生成')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8819.map'
        TradeContext.HostCode = '8819'
        InitGLHostReq()

    elif (result == '8847'):
        AfaLoggerFunc.tradeInfo('>>>对公帐号流水明细查询')
        mapfile=os.environ['AFAP_HOME'] + '/conf/hostconf/AH8847.map'
        TradeContext.HostCode = '8847'
        InitGLHostReq()

    else:
        TradeContext.errorCode = 'A9999'
        TradeContext.errorMsg  = '主机代码错误'
        return False

    #此处交易代码要求10位,右补空格
    HostComm.callHostTrade( mapfile, UtilTools.Rfill(TradeContext.HostCode,10,' ') ,'0002' )

    if HostContext.host_Error:
        AfaLoggerFunc.tradeFatal( 'host_Error:'+str( HostContext.host_ErrorType )+':'+HostContext.host_ErrorMsg )

        if HostContext.host_ErrorType != 5 :
            TradeContext.__status__='1'
            TradeContext.errorCode='A0101'
            TradeContext.errorMsg=HostContext.host_ErrorMsg
        else :
            TradeContext.__status__='2'
            TradeContext.errorCode='A0102'
            TradeContext.errorMsg=HostContext.host_ErrorMsg
        return False

    #================分析主机返回包====================
    return HostParseRet(result )
Beispiel #11
0
def SubModuleMainFst( ):

    AfaLoggerFunc.tradeInfo( '进入客户签约查询[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
    try:
        #=============获取当前系统时间====================
        TradeContext.workDate=UtilTools.GetSysDate( )
        TradeContext.workTime=UtilTools.GetSysTime( )

          #============校验公共节点的有效性==================
        # 完整性检查
        if( not TradeContext.existVariable( "channelCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '渠道代码[channelCode]值不存在!' )
        if( not TradeContext.existVariable( "zoneno" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '分行号[zoneno]值不存在!' )
        if( not TradeContext.existVariable( "brno" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '行所号[brno]值不存在!' )
        if( not TradeContext.existVariable( "opType" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '操作类型[opType]值不存在!' )
        if( not TradeContext.existVariable( "taxOrgCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '征收机关代码[taxOrgCode]值不存在!' )
        if( not TradeContext.existVariable( "taxPayCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '纳税人编码[taxPayCode]值不存在!' )
        if( not TradeContext.existVariable( "accno" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '付款账户[accno]值不存在!' )
        if( not TradeContext.existVariable( "protocolNo" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '协议书号[protocolNo]值不存在!' )

        if TradeContext.opType=='0':
            AfaLoggerFunc.tradeInfo('>>>查询')
            #=============判断状态====================
            sql="SELECT STATUS,TAXPAYCODE,PROTOCOLNO,PAYACCT,IDTYPE,IDCODE,TAXPAYNAME,"
            sql=sql+"TAXORGCODE,HANDORGNAME,STARTDATE,ENDDATE,ZONENO,BRNO,TELLERNO,WORKDATE,"
            sql=sql+"NOTE1,NOTE2,NOTE3,NOTE4,NOTE5"
            sql=sql+" FROM TIPS_CUSTINFO WHERE 1=1 "
            sql=sql+" and TAXORGCODE     ='"+TradeContext.taxOrgCode  +"'"
            
            if( len(TradeContext.taxPayCode) != 0 ):
            	AfaLoggerFunc.tradeInfo('>>>' + TradeContext.taxPayCode)
            	sql=sql+" AND TAXPAYCODE ='"+TradeContext.taxPayCode +"'"
            if( len(TradeContext.accno) != 0 ):
            	sql=sql+" and PAYACCT     ='"+TradeContext.accno  +"'"
            if( len(TradeContext.protocolNo) != 0 ):
            	sql=sql+" and PROTOCOLNO     ='"+TradeContext.protocolNo  +"'"
            
            AfaLoggerFunc.tradeInfo(sql)
            records = AfaDBFunc.SelectSql(sql)
            if( records == None ):
                AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            elif( len( records )==0 ):
                return TipsFunc.ExitThisFlow( 'A0027', '该客户尚未签约' )
            elif( len( records )>1 ):
                return TipsFunc.ExitThisFlow( 'A0027', '存在多条签约记录' )
            else:
                AfaLoggerFunc.tradeFatal(sql)
                AfaLoggerFunc.tradeInfo(records[0][0])
                UtilTools.ListFilterNone( records )
                if (records[0][0]=='1'):
                    TradeContext.status='协议已验证,可正常使用'
                elif (records[0][0]=='2'):
                    TradeContext.status='银行端已签约,等待征收机关验证协议'
                elif (records[0][0]=='3'):
                    TradeContext.status='银行端已解约,等待征收机关撤销协议'
                else:
                    TradeContext.status='协议已撤消'
                TradeContext.taxPayCode =records[0][1]
                TradeContext.protocolNo =records[0][2]
                TradeContext.accno      =records[0][3]
                TradeContext.idType     =records[0][4]
                TradeContext.idCode     =records[0][5]
                TradeContext.taxPayName =records[0][6]
                TradeContext.taxOrgCode =records[0][7]
                TradeContext.handOrgName =records[0][8]
                TradeContext.workDate = records[0][14]
                TradeContext.note2      =records[0][16]
                
                TipsFunc.GetTaxOrg(TradeContext.taxOrgCode)
        elif TradeContext.opType=='1':
            AfaLoggerFunc.tradeInfo('>>>删除')
            #=============判断状态====================
            sql="SELECT STATUS,TAXPAYCODE,PROTOCOLNO,PAYACCT,IDTYPE,IDCODE,TAXPAYNAME,"
            sql=sql+"TAXORGCODE,HANDORGNAME,STARTDATE,ENDDATE,ZONENO,BRNO,TELLERNO,WORKDATE,"
            sql=sql+"NOTE1,NOTE2,NOTE3,NOTE4,NOTE5"
            sql=sql+" FROM TIPS_CUSTINFO WHERE TAXORGCODE  ='"+TradeContext.taxOrgCode +"'"
            
            if( len(TradeContext.taxPayCode) != 0 ):
            	AfaLoggerFunc.tradeInfo('>>>' + TradeContext.taxPayCode)
            	sql=sql+" AND TAXPAYCODE ='"+TradeContext.taxPayCode +"'"
            if( len(TradeContext.accno) != 0 ):
            	sql=sql+" and PAYACCT     ='"+TradeContext.accno  +"'"
            if( len(TradeContext.protocolNo) != 0 ):
            	sql=sql+" and PROTOCOLNO     ='"+TradeContext.protocolNo  +"'"

            AfaLoggerFunc.tradeInfo(sql)
            records = AfaDBFunc.SelectSql(sql)
            if( records == None or  records <0):
                AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            elif( len( records )==0 ):
                #return TipsFunc.ExitThisFlow( 'A0027', '该客户三方协议尚未签约,无法撤消' )
                return TipsFunc.ExitThisFlow( 'A0027', '该客户三方协议尚未签约,无法删除' )
            elif( len( records )>1 ):
                return TipsFunc.ExitThisFlow( 'A0027', '存在多条验证记录' )
            else:
                AfaLoggerFunc.tradeFatal(sql)
                AfaLoggerFunc.tradeInfo(records[0][0])
                UtilTools.ListFilterNone( records )
                #if (records[0][0]=='0' or records[0][0]=='3'):
                #    return TipsFunc.ExitThisFlow( 'A0027', '三方协议状态为已撤消,不能重复撤消' )
                if (records[0][0]=='1'):
                    #return TipsFunc.ExitThisFlow( 'A0027', '三方协议状态为已验证,不能撤消' )
                    return TipsFunc.ExitThisFlow( 'A0027', '三方协议状态为已验证,不能删除,请做解约交易' )
            TradeContext.taxPayCode =records[0][1]
            TradeContext.protocolNo =records[0][2]
            TradeContext.accno      =records[0][3]
            TradeContext.idType     =records[0][4]
            TradeContext.idCode     =records[0][5]
            TradeContext.taxPayName =records[0][6]
            TradeContext.taxOrgCode =records[0][7]
            TradeContext.handOrgName =records[0][8]
            TradeContext.workDate = records[0][14]
            TradeContext.note2      =records[0][16]
            TipsFunc.GetTaxOrg(TradeContext.taxOrgCode)
            TradeContext.status = '删除成功'

            #sql="update TIPS_CUSTINFO set "
            #sql=sql+" STATUS     ='"+'3'                     +"'"
            #sql=sql+",ENDDATE      ='"+TradeContext.workDate   +"'"
            #sql=sql+",ZONENO     ='"+TradeContext.zoneno     +"'"
            #sql=sql+",BRNO       ='"+TradeContext.brno       +"'"
            #sql=sql+",TELLERNO   ='"+TradeContext.teller   +"'"
            #sql=sql+" WHERE TAXPAYCODE ='"  +TradeContext.taxPayCode   +"'"
            #sql=sql+" AND PAYACCT ='"       +TradeContext.accno        +"'"
            #sql=sql+" AND PROTOCOLNO  ='"   +TradeContext.protocolNo   +"'"
            #sql=sql+" AND TAXORGCODE  ='"   +TradeContext.taxOrgCode   +"'"
            #AfaLoggerFunc.tradeInfo(sql)
            #if( AfaDBFunc.UpdateSqlCmt(sql) == -1 ):
            #    AfaLoggerFunc.tradeFatal(sql)
            #    return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            sql="delete "
            sql="DELETE FROM TIPS_CUSTINFO WHERE TAXORGCODE  ='"+TradeContext.taxOrgCode +"'"
            
            if( len(TradeContext.taxPayCode) != 0 ):
            	AfaLoggerFunc.tradeInfo('>>>' + TradeContext.taxPayCode)
            	sql=sql+" AND TAXPAYCODE ='"+TradeContext.taxPayCode +"'"
            if( len(TradeContext.accno) != 0 ):
            	sql=sql+" and PAYACCT     ='"+TradeContext.accno  +"'"
            if( len(TradeContext.protocolNo) != 0 ):
            	sql=sql+" and PROTOCOLNO     ='"+TradeContext.protocolNo  +"'"

            AfaLoggerFunc.tradeInfo(sql)
            rec=AfaDBFunc.DeleteSqlCmt(sql)
            if rec<0:
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            
        else:
            return TipsFunc.ExitThisFlow('0001', '未定义该操作类型')
            
        #=============自动打包==================== 
        TradeContext.errorCode='0000'
        TradeContext.errorMsg='交易成功'
        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '退出客户信息维护模板['+TradeContext.TemplateCode+']\n' )
        return True
    except TipsFunc.flowException, e:
        TipsFunc.exitMainFlow( )
Beispiel #12
0
def SubModuleMainFst( ):
    LoggerFunc.tradeInfo('财税库行_止付请求交易_前处理[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
    try:
        #=============获取当前系统时间====================
        TradeContext.workDate=UtilTools.GetSysDate( )
        TradeContext.workTime=UtilTools.GetSysTime( )
        
        ##============校验公共节点的有效性==================
        #if( not AfapFunc.Query_ChkVariableExist( ) ):
        #    raise AfaFlowControl.flowException( )
        ##===============判断应用系统状态======================
        #if not AfapFunc.ChkSysStatus( ) :
        #    raise AfaFlowControl.flowException( )
        ##===============判断商户状态======================
        #if not AfapFunc.ChkUnitStatus( ) :
        #    raise AfaFlowControl.flowException( )
        ##=============判断应用状态====================
        #if not AfapFunc.ChkAppStatus( ) :
        #    raise AfaFlowControl.flowException( )
        #
                    
        #============变量值的有效性校验============
        if( not TradeContext.existVariable( "TaxOrgCode" ) ):
            return AfaFlowControl.ExitThisFlow( 'A0001', '[TaxOrgCode]值不存在!' )
        if( not TradeContext.existVariable( "OriPackNo" ) ):
            return AfaFlowControl.ExitThisFlow( 'A0001', '[OriPackNo]值不存在!' )
        if( not TradeContext.existVariable( "EntrustDate" ) ):
            return AfaFlowControl.ExitThisFlow( 'A0001', '[EntrustDate]值不存在!' )
        if( not TradeContext.existVariable( "OriEntrustDate" ) ):
            return AfaFlowControl.ExitThisFlow( 'A0001', '[OriEntrustDate]值不存在!' )
        if( not TradeContext.existVariable( "StopReason" ) ):
            return AfaFlowControl.ExitThisFlow( 'A0001', '[StopReason]值不存在!' )
        if( not TradeContext.existVariable( "StopType" ) ):
            return AfaFlowControl.ExitThisFlow( 'A0001', '[StopType]值不存在!' )
        
        if (TradeContext.StopType=='0'):
            if( not TradeContext.existVariable( "OriTraNo" ) ):
                return AfaFlowControl.ExitThisFlow( 'A0001', '[OriTraNo]值不存在!' )
            #查询批量流水处理状态
            sqlStr = "SELECT STATUS FROM BATCH_TRANSDTL WHERE "
            sqlStr =sqlStr +" sysid             = '" + TradeContext.appNo           + "'"
            sqlStr =sqlStr +"and unitno         = '" + TradeContext.unitno          + "'"
            #sqlStr =sqlStr +"and subUnitno      = '" + TradeContext.subUnitno       + "'"
            sqlStr =sqlStr +"and workDate       = '" + TradeContext.OriEntrustDate  + "'"
            sqlStr =sqlStr +"and Batchno        = '" + TradeContext.PackNo          + "'"
            sqlStr =sqlStr +"and CORPSERIALNO   = '" + TradeContext.OriTraNo        + "'"
            sqlStr =sqlStr +"and NOTE1          = '" + TradeContext.TaxOrgCode      + "'"
            Records = DBFunc.SelectSql( sqlStr )
            LoggerFunc.tradeInfo(sqlStr)
            if( Records == None ):
                LoggerFunc.tradeFatal('批量管理表操作异常:'+DBFunc.sqlErrMsg)
                return AfaFlowControl.ExitThisFlow( 'A0027', '数据库错,批量管理表操作异常' )
            elif(len(Records)>0):
                if Records[0][0]=='9': #流水尚未处理
                    sqlStr = "UPDATE BATCH_TRANSDTL SET STATUS='1',ERRORMSG='已止付' WHERE "
                    sqlStr =sqlStr +" sysid             = '" + TradeContext.appNo           + "'"
                    sqlStr =sqlStr +"and unitno         = '" + TradeContext.unitno          + "'"
                    #sqlStr =sqlStr +"and subUnitno      = '" + TradeContext.subUnitno       + "'"
                    sqlStr =sqlStr +"and workDate       = '" + TradeContext.OriEntrustDate  + "'"
                    sqlStr =sqlStr +"and Batchno        = '" + TradeContext.OriPackNo          + "'"
                    sqlStr =sqlStr +"and CORPSERIALNO   = '" + TradeContext.OriTraNo        + "'"
                    sqlStr =sqlStr +"and NOTE1          = '" + TradeContext.TaxOrgCode      + "'"
                    LoggerFunc.tradeInfo(sqlStr )
                    records=DBFunc.UpdateSqlCmt( sqlStr )
                    if( records <0 ):
                        TradeContext.errorCode='A0027'
                        TradeContext.StopAnswer='3'
                        TradeContext.errorMsg='止付失败,数据库异常'
                    TradeContext.errorCode='0000'
                    TradeContext.StopAnswer='1'
                    TradeContext.errorMsg='止付成功'
                elif Records[0][0]=='1': #原流水处理失败,则止付成功
                    TradeContext.errorCode='0000'
                    TradeContext.StopAnswer='1'
                    TradeContext.errorMsg='止付成功'
                elif Records[0][0]=='0': #原流水处理成功,则止付成功
                    TradeContext.errorCode='0000'
                    TradeContext.StopAnswer='2'
                    TradeContext.errorMsg='止付成功'
                else:
                    TradeContext.errorCode='A0027'
                    TradeContext.StopAnswer='3'
                    TradeContext.errorMsg='止付失败,交易已处理'
        else:
            #查询批量处理状态
            sqlStr = "SELECT DEALSTATUS FROM BATCH_ADM WHERE "
            sqlStr =sqlStr +" sysid     = '" + TradeContext.appNo       + "'"
            sqlStr =sqlStr +"and unitno    = '" + TradeContext.unitno      + "'"
            #sqlStr =sqlStr +"and subUnitno = '" + TradeContext.subUnitno   + "'"
            sqlStr =sqlStr +"and workDate  = '" + TradeContext.OriEntrustDate + "'"
            sqlStr =sqlStr +"and Batchno   = '" + TradeContext.OriPackNo      + "'"
            sqlStr =sqlStr +"and note1     = '" + TradeContext.TaxOrgCode  + "'"
            Records = DBFunc.SelectSql( sqlStr )
            LoggerFunc.tradeInfo(sqlStr)
            if( Records == None ):
                LoggerFunc.tradeFatal('批量管理表操作异常:'+DBFunc.sqlErrMsg)
                return AfaFlowControl.ExitThisFlow( 'A0027', '数据库错,批量管理表操作异常' )
            elif(len(Records)>0):
                if Records[0][0]=='9': #原批次尚未处理
                    sqlStr = "UPDATE  BATCH_ADM SET DEALSTATUS='1',ERRORCODE='24020',ERRORMSG='已止付' WHERE "
                    sqlStr =sqlStr +" sysid             = '" + TradeContext.appNo           + "'"
                    sqlStr =sqlStr +"and unitno         = '" + TradeContext.unitno          + "'"
                    #sqlStr =sqlStr +"and subUnitno      = '" + TradeContext.subUnitno       + "'"
                    sqlStr =sqlStr +"and workDate       = '" + TradeContext.OriEntrustDate  + "'"
                    sqlStr =sqlStr +"and Batchno        = '" + TradeContext.OriPackNo          + "'"
                    sqlStr =sqlStr +"and NOTE1          = '" + TradeContext.TaxOrgCode      + "'"
                    LoggerFunc.tradeInfo(sqlStr )
                    records=DBFunc.UpdateSqlCmt( sqlStr )
                    if( records <0 ):
                        TradeContext.errorCode='A0027'
                        TradeContext.StopAnswer='3'
                        TradeContext.errorMsg='止付失败,数据库异常'
                    TradeContext.errorCode='0000'
                    TradeContext.StopAnswer='1'
                    TradeContext.errorMsg='止付成功'
                elif Records[0][0]=='1': #原批次处理失败,则止付成功
                    TradeContext.errorCode='0000'
                    TradeContext.StopAnswer='1'
                    TradeContext.errorMsg='止付成功'
                elif Records[0][0]=='0': #原批次处理成功,则止付成功
                    TradeContext.errorCode='0000'
                    TradeContext.StopAnswer='2'
                    TradeContext.errorMsg='止付成功'
                else:
                    TradeContext.errorCode='A0027'
                    TradeContext.StopAnswer='3'
                    TradeContext.errorMsg='止付失败,交易已处理'
        
        #=============获取平台流水号====================
        if AfapFunc.GetSerialno( ) == -1 :
            raise AfaFlowControl.flowException( )
        #=============与第三方通讯,发送止付应答====================
        TradeContext.TransCode='2123' #止付应答
        AfaAfeFunc.CommAfe()
        
        TradeContext.errorCode='0000'
        TradeContext.errorMsg='交易成功'
        LoggerFunc.tradeInfo('处理结果:')
        LoggerFunc.tradeInfo('财税库行_止付请求交易_前处理结束[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
        return True
    except Exception, e:
        AfaFlowControl.exitMainFlow(str(e))