Exemple #1
0
def SubModuleDoSnd():

    AfaLoggerFunc.tradeInfo( '>>>开始判断主机返回结果' )
    status_dict = {}
    status_dict['BSPSQN']  = TradeContext.BSPSQN       #报单序号
    status_dict['BJEDTE']  = TradeContext.BJEDTE       #交易日期
    status_dict['BCSTAT']  = PL_BCSTAT_ACC             #记账

    #=====判断主机返回结果====
    if TradeContext.errorCode != '0000':
        status_dict['BDWFLG']  = PL_BDWFLG_FAIL        #失败
        status_dict['STRINFO'] = TradeContext.errorMsg
        #return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        status_dict['BDWFLG']  = PL_BDWFLG_SUCC        #成功
        status_dict['TRDT']    = TradeContext.TRDT     #主机日期
        status_dict['TLSQ']    = TradeContext.TLSQ     #主机流水号
        status_dict['MGID']    = TradeContext.MGID     #主机返回信息
        status_dict['DASQ']    = TradeContext.DASQ     #销账序号

    #=====修改退汇记录的状态====
    if not rccpsState.setTransState(status_dict):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('>>>commit成功')

    #=====判断主机返回结果,是否继续流程====
    if TradeContext.errorCode != '0000':
        return AfaFlowControl.ExitThisFlow('D011', '该笔业务已入账,不允许退汇')
        #return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)

    #=====新增记录的状态为:发送-处理中====
    if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_SND,PL_BDWFLG_WAIT):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('M999', '设置状态失败,系统自动回滚')
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()

    #=====发送中心====
    TradeContext.ROPRTPNO  =  '20'

    return True
Exemple #2
0
def SubModuleDoSnd():

    AfaLoggerFunc.tradeDebug('>>>结束发送农信银中心')
    AfaLoggerFunc.tradeDebug('>>>开始状态变更')

    sstlog = {}

    sstlog['BJEDTE'] = TradeContext.BJEDTE
    sstlog['BSPSQN'] = TradeContext.BSPSQN
    sstlog['BCSTAT'] = PL_BCSTAT_SND
    sstlog['NOTE3']  = TradeContext.errorMsg

    if TradeContext.errorCode == '0000':
        sstlog['BDWFLG'] = PL_BDWFLG_SUCC
    else:
        sstlog['BDWFLG'] = PL_BDWFLG_FAIL

    #=====修改sstlog表中数据====
    if not rccpsState.setTransState(sstlog):
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()

    AfaLoggerFunc.tradeDebug('>>>结束状态变更')

    
    return True
Exemple #3
0
def SubModuledoSnd():

    #在退付信息写到本地数据库里面
    sqlstr  =   "insert into FS_FC75(AAA010,AFC060,AFC041,AFA050,AFC061,AFC062,AFC063,AFC064,FBLRQ,AFA101,BUSINO,TELLER,BRNO,FLAG,DATE,TIME) values("
    FLAG    =   '0'
    sqlstr          =   sqlstr + "'" + TradeContext.AAA010   + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.AFC060   + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.AFC041   + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.AFA050   + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.AFC061   + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.AFC062   + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.AFC063   + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.AFC064   + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.FBLRQ    + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.bankbm   + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.busiNo   + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.teller   + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.brno     + "',"
    sqlstr          =   sqlstr + "'" + FLAG                  + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.workDate + "',"
    sqlstr          =   sqlstr + "'" + TradeContext.workTime + "')"

    TradeContext.errorCode  =   "0000"
    TradeContext.errorMsg   =   "退付成功"

    if( AfaDBFunc.InsertSql( sqlstr ) < 1 ):
        AfaDBFunc.RollbackSql( )
        AfaLoggerFunc.tradeInfo( '插入退付信息表失败' + sqlstr )
        AfaLoggerFunc.tradeInfo( AfaDBFunc.sqlErrMsg )
        TradeContext.errorCode  =   "0001"
        TradeContext.errorMsg   =   "退付失败"
        return False

    AfaDBFunc.CommitSql( )

    AfaLoggerFunc.tradeInfo( '插入退付信息表结束' )


    #本模块主要是为了填写发票数据
    if (TradeContext.channelCode =='001' ): #柜面交易不计发票
        TradeContext.__billSaveCtl__  = '0'
    else:
        TradeContext.__billSaveCtl__  = '1'

    bill    =   []
    bill.append('1')
    bill.append('')
    bill.append('')
    bill.append('')
    bill.append('')
    bill.append('')
    bill.append('')
    bill.append('')

    return bill
Exemple #4
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(2.中心操作).汇票解付[TRCC003_8502]进入***' )
    
    #=================判断afe是否发送成功=======================================
    if TradeContext.errorCode != '0000':
        #=============AFE发送失败,设置状态为发送失败============================
        AfaLoggerFunc.tradeInfo('>>>AFE发送失败,开始设置状态为发送失败')
        
        stat_dict = {}
        stat_dict['BJEDTE']  = TradeContext.BJEDTE
        stat_dict['BSPSQN']  = TradeContext.BSPSQN
        stat_dict['BESBNO']  = TradeContext.BESBNO
        stat_dict['BETELR']  = TradeContext.BETELR
        stat_dict['BCSTAT']  = PL_BCSTAT_SND
        stat_dict['BDWFLG']  = PL_BDWFLG_FAIL
        stat_dict['PRCCO']   = TradeContext.errorCode
        stat_dict['STRINFO'] = TradeContext.errorMsg
        
        if not rccpsState.setTransState(stat_dict):
            return AfaFlowControl.ExitThisFlow('S999','设置状态为发送失败异常')
            
        AfaLoggerFunc.tradeInfo('>>>结束设置状态为发送失败')
    else:
        #=============AFE发送成功,设置状态为发送成功============================
        AfaLoggerFunc.tradeInfo('>>>AFE发送成功,开始设置状态为发送成功')
        
        stat_dict = {}
        stat_dict['BJEDTE']  = TradeContext.BJEDTE
        stat_dict['BSPSQN']  = TradeContext.BSPSQN
        stat_dict['BESBNO']  = TradeContext.BESBNO
        stat_dict['BETELR']  = TradeContext.BETELR
        stat_dict['BCSTAT']  = PL_BCSTAT_SND
        stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
        stat_dict['PRCCO']   = TradeContext.errorCode
        stat_dict['STRINFO'] = TradeContext.errorMsg
        
        if not rccpsState.setTransState(stat_dict):
            return AfaFlowControl.ExitThisFlow('S999','设置状态为发送成功异常')
            
        AfaLoggerFunc.tradeInfo('>>>结束设置状态为发送成功')
    
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow("S999","Commit异常")
    AfaLoggerFunc.tradeInfo(">>>Commit成功")
    
    TradeContext.errorCode = '0000'
    TradeContext.errorMsg  = '发送农信银中心成功'
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(2.中心操作).汇票解付[TRCC003_8502]结束***' )
    
    return True
Exemple #5
0
def SubModuleDoTrd():
    AfaLoggerFunc.tradeDebug('>>>开始处理AFE返回结果')
    status = {}
    status['BSPSQN']  = TradeContext.BSPSQN       #报单序号
    status['BJEDTE']  = TradeContext.BJEDTE       #交易日期
    status['BCSTAT']  = PL_BCSTAT_SND             #发送
    #=====开始判断afe返回结果====
    if TradeContext.errorCode != '0000':
         status['BDWFLG']  = PL_BDWFLG_FAIL       #失败
         #==== 张恒增于20091216 退汇业务发送MFE失败更新原业务状态=====
         #===========退汇业务,更新原交易挂账代销账序号==============
         AfaLoggerFunc.tradeInfo(">>>开始更新原交易挂账代销账序号(8509)")
        
         orstat_dict = {}
         orstat_dict['BJEDTE'] = TradeContext.BOJEDT
         orstat_dict['BSPSQN'] = TradeContext.BOSPSQ
         orstat_dict['BCSTAT'] = PL_BCSTAT_HANG
         orstat_dict['BDWFLG'] = PL_BDWFLG_FAIL
         if TradeContext.existVariable('DASQ'):
            orstat_dict['DASQ']   = TradeContext.DASQ
        
         if not rccpsState.setTransState(orstat_dict):
            return False
            
         AfaLoggerFunc.tradeInfo(">>>结束更新原交易挂账代销账序号(8509)")
         
    else:
         status['BDWFLG']  = PL_BDWFLG_SUCC       #成功

    #=====修改退汇记录的状态====
    if not rccpsState.setTransState(status):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('>>>commit成功')

    #关彬捷 2008-07-23
    #此处不更改原交易状态为退汇,在清算回执中修改
    ##=====设置原记录状态为:退汇-成功====
    #if not rccpsState.newTransState(TradeContext.BOJEDT,TradeContext.BOSPSQ,PL_BCSTAT_QTR,PL_BDWFLG_SUCC):
    #    #=====RollBack操作====
    #    AfaDBFunc.RollbackSql()
    #    return AfaFlowControl.ExitThisFlow('M999', '设置状态失败,系统自动回滚')
    #else:
    #    #=====commit操作====
    #    AfaDBFunc.CommitSql()

    
    return True
Exemple #6
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeDebug('>>>开始处理AFE返回结果')
    status = {}
    status['BSPSQN']  = TradeContext.BSPSQN       #报单序号
    status['BJEDTE']  = TradeContext.BJEDTE       #交易日期
    status['BCSTAT']  = PL_BCSTAT_SND             #发送
    status['STRINFO'] = TradeContext.errorMsg
    #=====开始判断afe返回结果====
    if TradeContext.errorCode != '0000':
        status['BDWFLG']       = PL_BDWFLG_FAIL       #失败
    else:
        status['BDWFLG']       = PL_BDWFLG_SUCC       #成功

    #=====修改退汇记录的状态====
    if not rccpsState.setTransState(status):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()

    AfaLoggerFunc.tradeDebug('>>>通讯回执处理成功')
    
    #=====发送退汇报文2000004====
    TradeContext.sysType  = 'rccpst'
    TradeContext.TRCCO    = '2000004'
    TradeContext.MSGTYPCO = 'SET005'
    TradeContext.OPRTYPNO =  '20'   #汇兑
    TradeContext.STRINFO  = '收到紧急止付,系统自动退汇' 
   
    #=====接收行号与发送行号互换====
    TradeContext.TEMP     = TradeContext.RCVBNKCO
    TradeContext.RCVBNKCO = TradeContext.SNDBNKCO
    TradeContext.SNDBNKCO = TradeContext.TEMP

    #=====接收行名与发送行名互换====
    TradeContext.NAME     = TradeContext.RCVBNKNM
    TradeContext.RCVBNKNM = TradeContext.SNDBNKNM
    TradeContext.SNDBNKNM = TradeContext.NAME

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

    #=====开始判断afe返回结果====
    if TradeContext.errorCode != '0000':
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        AfaLoggerFunc.tradeDebug('>>>发送退汇成功')

    return True
Exemple #7
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.中心类操作(2.中心操作).汇票撤销[TRCC003_8503]进入***' )
    
    stat_dict = {}
    stat_dict['BJEDTE']  = TradeContext.BJEDTE
    stat_dict['BSPSQN']  = TradeContext.BSPSQN
    stat_dict['BESBNO']  = TradeContext.BESBNO
    stat_dict['BETELR']  = TradeContext.BETELR
    stat_dict['BCSTAT']  = PL_BCSTAT_SND
    stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
    stat_dict['PRCCO']   = TradeContext.errorCode
    stat_dict['STRINFO'] = TradeContext.errorMsg
    
    AfaLoggerFunc.tradeInfo("TradeContext.errorCode = [" + TradeContext.errorCode + "]")
    if TradeContext.errorCode == '0000':
        #发送农信银成功,设置业务状态为发送成功
        AfaLoggerFunc.tradeInfo(">>>发送农信银总中心成功")
        AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送成功")
        
        stat_dict['BCSTAT']  = PL_BCSTAT_SND
        stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
        
        if not rccpsState.setTransState(stat_dict):
            return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为发送成功异常")
        
        AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为发送成功")
        
    else:
        #发送农信银失败,设置业务状态为发送失败
        AfaLoggerFunc.tradeInfo(">>>发送农信银总中心失败")
        AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送失败")
        
        stat_dict['BCSTAT']  = PL_BCSTAT_SND
        stat_dict['BDWFLG']  = PL_BDWFLG_FAIL
        
        if not rccpsState.setTransState(stat_dict):
            return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为发送失败异常")
        
        AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为发送失败")
    
    #COMMIT
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow("S999","Commit异常")
    AfaLoggerFunc.tradeInfo(">>>Commit成功")
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.中心类操作(2.中心操作).汇票撤销[TRCC003_8503]退出***' )
    
    return True
Exemple #8
0
def InsertDB(record):
    tradeLogger.info(HostContext.O1ACBL)
    #=====向8446表中插入数据====
    tradeLogger.info("进入InsertDB,向8446表中插入数据")
    #TradeContext.serDate  =   AfaAdminFunc.getTimeFromNow(int(-1))
    #TradeContext.serDate  ='20091231'
    insertsql = "insert into FS_8446_REMAIN(BUSINO,DATE,THIS,ACCNO,BANKNO) VALUES('"+ \
                 record[0] + "','" + TradeContext.serDate + "','" + str(float(HostContext.O1ACBL)) + "','" + record[1] + "','" + record[3] + "')"
    tradeLogger.info(insertsql)
    res = AfaDBFunc.InsertSql(insertsql)
    if(res < -1):
        AfaDBFunc.RollbackSql( )
        tradeLogger.info('BUSINO>>>'+record[0])
        tradeLogger.info("插入8446余额表失败")
        return False

    AfaDBFunc.CommitSql( )
    return True
Exemple #9
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo(" 农信银系统:来账.中心类操作(2.中心回执).卡本转异应答报文接收[TRCC006_1155]进入 ")

    stat_dict = {}
    stat_dict['BJEDTE']  = TradeContext.BJEDTE
    stat_dict['BSPSQN']  = TradeContext.BSPSQN
    stat_dict['BESBNO']  = TradeContext.BESBNO
    stat_dict['BETELR']  = TradeContext.BETELR
    stat_dict['BCSTAT']  = PL_BCSTAT_CONFPAY
    stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
    stat_dict['PRCCO']   = TradeContext.errorCode
    stat_dict['STRINFO'] = TradeContext.errorMsg
    
    AfaLoggerFunc.tradeInfo("TradeContext.errorCode = [" + TradeContext.errorCode + "]")
    if TradeContext.errorCode == '0000':
        #=====发送农信银成功,设置状态为确认付款成功====
        stat_dict['BCSTAT']  = PL_BCSTAT_CONFPAY
        stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
        
        if not rccpsState.setTransState(stat_dict):
            return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为确认付款成功异常")
        
        AfaLoggerFunc.tradeInfo(">>>设置业务状态为确认付款成功")
    else:
        #=====发送农信银失败,设置状态为确认付款失败====       
        stat_dict['BCSTAT']  = PL_BCSTAT_CONFPAY
        stat_dict['BDWFLG']  = PL_BDWFLG_FAIL
        
        if not rccpsState.setTransState(stat_dict):
            return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为确认付款失败异常")
        
        AfaLoggerFunc.tradeInfo(">>>设置业务状态为确认付款失败")
        
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow("S999","Commit异常")
    
    AfaLoggerFunc.tradeInfo(" 农信银系统:来账.中心类操作(2.中心回执).卡本转异应答报文接收[TRCC006_1155]退出 ")
    
    return True
        
Exemple #10
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(2.中心回执).卡通存请求报文接收[TRCC006_1135]进入***' )
    
    stat_dict = {}
    stat_dict['BJEDTE']  = TradeContext.BJEDTE
    stat_dict['BSPSQN']  = TradeContext.BSPSQN
    stat_dict['BESBNO']  = TradeContext.BESBNO
    stat_dict['BETELR']  = TradeContext.BETELR
    stat_dict['PRCCO']   = TradeContext.PRCCO
    stat_dict['STRINFO'] = TradeContext.STRINFO
    
    #根据afe返回码判断应答报文是否发送成功,并设置相应业务状态
    AfaLoggerFunc.tradeInfo("TradeContext.errorCode = [" + TradeContext.errorCode + "]")
    if TradeContext.errorCode == '0000':
        #=====发送农信银成功,设置状态为确认入账\拒绝\冲正成功====
        stat_dict['BCSTAT']  = TradeContext.BCSTAT
        stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
        
        if not rccpsState.setTransState(stat_dict):
            return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为" +  + "成功异常")
        
        AfaLoggerFunc.tradeInfo(">>>成功设置业务状态为" + TradeContext.BCSTATNM + "成功")
    else:
        #=====发送农信银失败,设置状态为确认入账\拒绝\冲正失败====       
        stat_dict['BCSTAT']  = TradeContext.BCSTAT
        stat_dict['BDWFLG']  = PL_BDWFLG_FAIL
        
        if not rccpsState.setTransState(stat_dict):
            return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为确认入账\拒绝\冲正失败异常")
        
        AfaLoggerFunc.tradeInfo(">>>成功设置业务状态为" + TradeContext.BCSTATNM + "失败")
        
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow("S999","Commit异常")
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(2.中心回执).卡通存请求报文接收[TRCC006_1135]退出***' )
    return True
        
Exemple #11
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo('>>>中心后处理')
    
    if TradeContext.errorCode == '0000':
        TradeContext.BDWFLG = PL_BDWFLG_SUCC
    else:
        TradeContext.BDWFLG = PL_BDWFLG_FAIL
        
    sstlog_dict={}
    sstlog_dict['BSPSQN']  = TradeContext.BSPSQN
    sstlog_dict['BJEDTE']  = TradeContext.BJEDTE
    sstlog_dict['BCSTAT']  = PL_BCSTAT_SND
    sstlog_dict['BDWFLG']  = TradeContext.BDWFLG
    
    if not rccpsState.setTransState(sstlog_dict):
        AfaDBFunc.RollBackSql()
        return AfaFlowControl.ExitThisFlow("S999","修改原交易当前状态为发送-成功异常")
    else:
        AfaDBFunc.CommitSql( )
        AfaLoggerFunc.tradeInfo(">>>结束修改原交易状态为发送-成功")
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.中心类操作(1.本地操作).柜台补正[TRCC003_8587]退出***' )
    return True
Exemple #12
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo( '***农信银系统: 通存通兑.中心类操作交易[RCC003_8562]进入***' )
    
    #=====判断中心返回是否成功====
    stat_dict = {}
    stat_dict['BJEDTE']  = TradeContext.BJEDTE
    stat_dict['BSPSQN']  = TradeContext.BSPSQN
    stat_dict['BESBNO']  = TradeContext.BESBNO
    stat_dict['BETELR']  = TradeContext.BETELR
    stat_dict['BCSTAT']  = PL_BCSTAT_SND             #PL_BCSTAT_SND  发送
    
    AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送成功")    
    
    if TradeContext.errorCode != '0000':
        stat_dict['BDWFLG'] = PL_BDWFLG_FAIL         #PL_BDWFLG_FAIL 失败
    else:
        stat_dict['BDWFLG'] = PL_BDWFLG_SUCC         #PL_BDWFLG_SUCC 成功
        stat_dict['PRTCNT'] = 1
    
    if not rccpsState.setTransState(stat_dict):
        return AfaFlowControl.ExitThisFlow('S999','设置状态为发送成功异常')
    
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow("S999","Commit异常")
    
    AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为发送成功")
    
    if TradeContext.errorCode != '0000':
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode,TradeContext.errorMsg)
    
    TradeContext.CUSCHRG = TradeContext.sCuschrg
    
    AfaLoggerFunc.tradeInfo( '***农信银系统: 通存通兑.中心类操作交易[RCC003_8562]退出***' )
    
    return True
Exemple #13
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).折通兑来帐请求报文接收[TRCC006_1140]进入***' )
    #初始化返回码
    TradeContext.PRCCO = 'RCCI0000'
    TradeContext.STRINFO = "成功"
    
    #判断是否重复报文
    AfaLoggerFunc.tradeInfo(">>>开始判断是否重复报文")
    
    sel_dict = {'COTRCNO':TradeContext.TRCNO,'COTRCDAT':TradeContext.TRCDAT,'SNDBNKCO':TradeContext.SNDBNKCO}
    record = rccpsDBTrcc_wtrbka.selectu(sel_dict)
    
    if record == None:
        AfaLoggerFunc.tradeDebug('>>>判断是否重复扣款确认报文,查询通存通兑业务登记簿相同报文异常')
        TradeContext.PRCCO    = "NN1ID999"
        TradeContext.STRINFO  = "数据库其他错误"
        
    elif len(record) > 0:
        AfaLoggerFunc.tradeInfo('通存通兑业务登记簿中存在相同数据,重复报文,返回拒绝应答报文')
        TradeContext.PRCCO    = 'NN1ISO999'
        TradeContext.STRINFO  = "重复报文"

    AfaLoggerFunc.tradeInfo(">>>结束判断是否重复报文")
    
    
    #登记通存通兑登记簿
    AfaLoggerFunc.tradeInfo(">>>开始登记通存通兑业务登记簿")
    
    #=====币种转换====
    if TradeContext.CUR == 'CNY':
        TradeContext.CUR  = '01'
        
    #=====手续费收取方式=====
    if float(TradeContext.CUSCHRG) > 0.001:
        TradeContext.CHRGTYP = '1'
    else:
        TradeContext.CHRGTYP = '0'
        
    #====开始向字典赋值====
    if TradeContext.PRCCO == 'RCCI0000':
        wtrbka_dict = {}
        if not rccpsMap1140CTradeContext2Dwtrbka_dict.map(wtrbka_dict):
            AfaLoggerFunc.tradeDebug('>>>字典赋值出错')
            TradeContext.PRCCO    = "NN1ID999"
            TradeContext.STRINFO  = "数据库其他错误"
    
    wtrbka_dict['DCFLG'] = PL_DCFLG_DEB                  #借贷标识
    wtrbka_dict['OPRNO'] = PL_TDOPRNO_TD                 #业务种类
    
    #=====开始插入数据库====
    if TradeContext.PRCCO == 'RCCI0000':
        if not rccpsDBFunc.insTransWtr(wtrbka_dict):
            AfaLoggerFunc.tradeDebug('>>>登记通存通兑业务登记簿异常')
            TradeContext.PRCCO    = "NN1ID999"
            TradeContext.STRINFO  = "数据库其他错误"
        
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        TradeContext.PRCCO    = "NN1ID999"
        TradeContext.STRINFO  = "数据库其他错误"
        
    AfaLoggerFunc.tradeInfo(">>>结束登记通存通兑业务登记簿")
    
    #设置业务状态为行内收妥成功
    AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为收妥成功")
    
    stat_dict   = {}
    stat_dict['BSPSQN']   = TradeContext.BSPSQN
    stat_dict['BJEDTE']   = TradeContext.BJEDTE
    stat_dict['BCSTAT']   = PL_BCSTAT_BNKRCV
    stat_dict['BDWFLG']   = PL_BDWFLG_SUCC
    
    if TradeContext.PRCCO == 'RCCI0000':
        if not rccpsState.setTransState(stat_dict):
            AfaLoggerFunc.tradeDebug('>>>设置业务状态收妥成功异常')
            TradeContext.PRCCO    = "NN1ID999"
            TradeContext.STRINFO  = "数据库其他错误"
        
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        TradeContext.PRCCO    = "NN1ID999"
        TradeContext.STRINFO  = "数据库其他错误"
        
    AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为收妥成功")
    
    #设置业务状态为自动扣款处理中
    AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为自动扣款处理中")
    
    if TradeContext.PRCCO == 'RCCI0000':
       if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_AUTOPAY,PL_BDWFLG_WAIT):
            AfaLoggerFunc.tradeDebug('>>>设置业务状态为自动扣款处理中异常')
            TradeContext.PRCCO    = "NN1ID999"
            TradeContext.STRINFO  = "数据库其他错误"
    
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        TradeContext.PRCCO    = "NN1ID999"
        TradeContext.STRINFO  = "数据库其他错误"
        
    AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为自动扣款处理中")
    
    TradeContext.BCSTAT = PL_BCSTAT_AUTOPAY #状态:自动扣款
    TradeContext.BCSTATNM = "自动扣款"
    #进行必要性检查,若校验通过,则返回成功应答报文,若校验未通过,则返回拒绝应答报文
    AfaLoggerFunc.tradeInfo(">>>开始必要性检查")

    #检查冲正登记簿中是否有此笔业务的冲正业务,存在则返回拒绝应答报文,并设置业务状态为冲正处理中
    if TradeContext.PRCCO == 'RCCI0000':
        atcbka_where_dict = {}
        atcbka_where_dict['ORMFN'] = TradeContext.MSGFLGNO

        atcbka_dict = rccpsDBTrcc_atcbka.selectu(atcbka_where_dict)
        
        if atcbka_dict == None:
            AfaLoggerFunc.tradeInfo(">>>查询冲正登记簿异常")
            TradeContext.PRCCO = 'NN1ID999'
            TradeContext.STRINFO = "查询冲正登记簿异常"
            TradeContext.BCSTAT = PL_BCSTAT_MFERFE
            TradeContext.BCSTATNM = "拒绝"
        
        else:
            if len(atcbka_dict) <= 0:
                AfaLoggerFunc.tradeInfo(">>>此交易未被冲正,继续校验")

            else:
                AfaLoggerFunc.tradeInfo(">>>此交易已被冲正,返回拒绝应答报文")
                TradeContext.PRCCO = 'NN1IO307'
                TradeContext.STRINFO = "此交易已被冲正"
                TradeContext.BCSTAT = PL_BCSTAT_MFERFE
                TradeContext.BCSTATNM = "拒绝"
                
    #解密客户密码
    if TradeContext.PRCCO == 'RCCI0000':
        MIMA = '      '
        PIN  = TradeContext.CURPIN
        ACC  = TradeContext.PYRACC
        AfaLoggerFunc.tradeDebug('密码[' + PIN + ']')
        AfaLoggerFunc.tradeDebug('账号[' + ACC + ']')
        ret = jiami.secDecryptPin(PIN,ACC,MIMA)
        if ret != 0:
            AfaLoggerFunc.tradeDebug("ret=[" + str(ret) + "]")
            AfaLoggerFunc.tradeDebug('调用加密服务器失败')
            TradeContext.PRCCO = 'NN1IS999'
            TradeContext.STRINFO = "解密密码失败"
            TradeContext.BCSTAT = PL_BCSTAT_MFERFE
            TradeContext.BCSTATNM = "拒绝"
        else:
            TradeContext.CURPIN = MIMA
            AfaLoggerFunc.tradeDebug('密码new[' + TradeContext.CURPIN + ']')
    
    #唐斌新增#
    sql = "SELECT ischkactname,ischklate FROM rcc_chlabt where transcode='"+TradeContext.TransCode+"' and channelno= '"+(TradeContext.SNDCLKNO)[6:8]+"'"
    AfaLoggerFunc.tradeInfo(sql)
    records = AfaDBFunc.SelectSql( sql)
    if (records == None):
        return False
    elif (len(records) == 0):
        AfaLoggerFunc.tradeDebug("查询结果为空,查询条件[" + sql + "]")
        return False
    AfaLoggerFunc.tradeDebug(str(records))
    
    #校验账户状态是否正常和账号户名是否相符
    if TradeContext.PRCCO == 'RCCI0000':
    
        #调用主机接口查询账户信息
        TradeContext.HostCode = '8810'
        
        TradeContext.ACCNO = TradeContext.PYRACC
        
        AfaLoggerFunc.tradeDebug("gbj test :" + TradeContext.ACCNO)
        
        rccpsHostFunc.CommHost( TradeContext.HostCode )
        
        if TradeContext.errorCode != '0000':
            #return AfaFlowControl.ExitThisFlow(TradeContext.errorCode,TradeContext.errorMsg)
            AfaLoggerFunc.tradeInfo("查询账户信息异常,主机返回码[" + TradeContext.errorCode + "],主机返回信息[" + TradeContext.errorMsg +"]")
            #TradeContext.PRCCO = 'NN1IA999'
            TradeContext.PRCCO = rccpsDBFunc.HostErr2RccErr(TradeContext.errorCode)
            TradeContext.STRINFO = TradeContext.errorMsg
            TradeContext.BCSTAT = PL_BCSTAT_MFERFE
            TradeContext.BCSTATNM = "拒绝"
        
        else:
            #查询成功,更新通存通兑登记簿账务机构号
            AfaLoggerFunc.tradeInfo(">>>查询主机账户成功")
            
            #if( TradeContext.BESBNO != PL_BESBNO_BCLRSB ):
            #    AfaLoggerFunc.tradeInfo(">>>" + TradeContext.BESBNO + ">>>" + TradeContext.ACCSO)
            #    if( TradeContext.BESBNO[:6] != TradeContext.ACCSO[:6] ):
            #        AfaLoggerFunc.tradeInfo(">>>不许跨法人做此交易")
            #        TradeContext.PRCCO = 'NN1IO999'
            #        TradeContext.STRINFO = "接收行与账户开户行不属于同一法人"
            #        TradeContext.BCSTAT = PL_BCSTAT_MFERFE
            #        TradeContext.BCSTATNM = "拒绝"
            
            #检查本机构是否有通存通兑业务权限
            if not rccpsDBFunc.chkTDBESAuth(TradeContext.ACCSO):
                TradeContext.PRCCO = 'NN1IO999'
                TradeContext.STRINFO = "本账户开户机构无通存通兑业务权限"
                TradeContext.BCSTAT = PL_BCSTAT_MFERFE
                TradeContext.BCSTATNM = "拒绝"
            
            AfaLoggerFunc.tradeInfo(">>>开始更新机构号为开户机构")
            TradeContext.BESBNO = TradeContext.ACCSO
            wtrbka_update_dict = {'BESBNO':TradeContext.ACCSO}
            wtrbka_where_dict  = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN}
            ret = rccpsDBTrcc_wtrbka.updateCmt(wtrbka_update_dict,wtrbka_where_dict)
            
            if ret <= 0:
                AfaLoggerFunc.tradeInfo(">>>更新机构号为开户机构异常")
                TradeContext.PRCCO = 'NN1ID006'
                TradeContext.STRINFO = "更新账务机构号异常"
                TradeContext.BCSTAT = PL_BCSTAT_MFERFE
                TradeContext.BCSTATNM = "拒绝"
            
            else:
                AfaLoggerFunc.tradeInfo(">>>更新机构号为开户机构成功")
                AfaLoggerFunc.tradeDebug("主机返回户名ACCNM :[" + TradeContext.ACCNM + "]")
                AfaLoggerFunc.tradeDebug("报文接收户名PYRNAM:[" + TradeContext.PYRNAM + "]")
                AfaLoggerFunc.tradeDebug("主机返回账户状态ACCST:[" + TradeContext.ACCST + "]")
                AfaLoggerFunc.tradeDebug("证件类型ACITY:[" + TradeContext.ACITY + "]")
                AfaLoggerFunc.tradeDebug("证件号码ACINO:[" + TradeContext.ACINO + "]")
                
                
                if TradeContext.ACCNM != TradeContext.PYRNAM:
                    #唐斌新增#
                    if(records[0][0]=='1'):
                        AfaLoggerFunc.tradeInfo(">>>账号户名不符")
                        TradeContext.PRCCO = 'NN1IA102'
                        TradeContext.STRINFO = '账号户名不符'
                        TradeContext.BCSTAT = PL_BCSTAT_MFERFE
                        TradeContext.BCSTATNM = "拒绝"
                
                elif TradeContext.ACCST != '0' and TradeContext.ACCST != '2':
                    AfaLoggerFunc.tradeInfo(">>>账户状态不正常")
                    TradeContext.PRCCO = 'NN1IA999'
                    TradeContext.STRINFO = '账户状态不正常'
                    TradeContext.BCSTAT = PL_BCSTAT_MFERFE
                    TradeContext.BCSTATNM = "拒绝"
                    
                elif not (TradeContext.ACCCD == '0428' and TradeContext.ACCEM == '21111'):
                    AfaLoggerFunc.tradeInfo(">>>此账户非个人结算户")
                    TradeContext.PRCCO    = 'NN1IA999'
                    TradeContext.STRINFO  = '此账户非个人结算户'
                    TradeContext.BCSTAT   = PL_BCSTAT_MFERFE
                    TradeContext.BCSTATNM = "拒绝"
                    
                #=====交易金额判断====
                chk_dict = {}
                chk_dict['BPARAD'] = 'TD001'    #通存通兑凭证金额校验
                
                dict = rccpsDBTrcc_pamtbl.selectu(chk_dict) 
                AfaLoggerFunc.tradeInfo('dict='+str(dict))
                
                if dict == None:
                    AfaLoggerFunc.tradeInfo(">>>校验交易金额失败")
                    TradeContext.PRCCO    = 'NN1ID003'
                    TradeContext.STRINFO  = '校验交易金额失败'
                    TradeContext.BCSTAT   = PL_BCSTAT_MFERFE
                    TradeContext.BCSTATNM = "拒绝"
                if len(dict) == 0:
                    AfaLoggerFunc.tradeInfo(">>>查询PAMTBL校验交易金额表记录错误")
                    TradeContext.PRCCO    = 'NN1ID010'
                    TradeContext.STRINFO  = '查询PAMTBL校验交易金额表记录错误'
                    TradeContext.BCSTAT   = PL_BCSTAT_MFERFE
                    TradeContext.BCSTATNM = "拒绝"
                
                #=====判断农信银中心规定校验凭证上线====
                if float(TradeContext.OCCAMT) > float(dict['BPADAT']):
                    #=====交易金额大于农信银中心规定金额,需要输入证件====
                    if TradeContext.existVariable('CERTTYPE') and len(TradeContext.CERTTYPE) == 0:
                        AfaLoggerFunc.tradeInfo(">>>请选择证件类型")
                        TradeContext.PRCCO    = 'NN1IA999'
                        TradeContext.STRINFO  = '请选择证件类型'
                        TradeContext.BCSTAT   = PL_BCSTAT_MFERFE
                        TradeContext.BCSTATNM = "拒绝"
                    elif(TradeContext.CERTTYPE == '06'):
                        if( TradeContext.ACITY != '06' and TradeContext.ACITY != '07' and TradeContext.ACITY != '08' and TradeContext.ACITY != '09'):
                            AfaLoggerFunc.tradeInfo(">>>证件类型错误")
                            TradeContext.PRCCO    = 'NN1IA999'
                            TradeContext.STRINFO  = '证件类型错误'
                            TradeContext.BCSTAT   = PL_BCSTAT_MFERFE
                            TradeContext.BCSTATNM = "拒绝"
                    elif( TradeContext.CERTTYPE != TradeContext.ACITY ):
                        AfaLoggerFunc.tradeInfo(">>>证件类型错误")
                        TradeContext.PRCCO    = 'NN1IA999'
                        TradeContext.STRINFO  = '证件类型错误'
                        TradeContext.BCSTAT   = PL_BCSTAT_MFERFE
                        TradeContext.BCSTATNM = "拒绝"
                        
                    if TradeContext.existVariable('CERTNO')   and len(TradeContext.CERTNO)   == 0:
                        AfaLoggerFunc.tradeInfo(">>>请输入证件号码")
                        TradeContext.PRCCO    = 'NN1IA999'
                        TradeContext.STRINFO  = '请输入证件号码'
                        TradeContext.BCSTAT   = PL_BCSTAT_MFERFE
                        TradeContext.BCSTATNM = "拒绝"
                    elif( TradeContext.CERTNO != TradeContext.ACINO ):
                        AfaLoggerFunc.tradeInfo(">>>证件号码错误")
                        TradeContext.PRCCO    = 'NN1IA999'
                        TradeContext.STRINFO  = '证件号码错误'
                        TradeContext.BCSTAT   = PL_BCSTAT_MFERFE
                        TradeContext.BCSTATNM = "拒绝"
    
    #校验交易金额是否超当日限额
    if not rccpsDBFunc.chkLimited(TradeContext.BJEDTE,TradeContext.PYRACC,TradeContext.OCCAMT):
        AfaLoggerFunc.tradeInfo(">>>交易金额超限")
        TradeContext.PRCCO    = 'NN1IA999'
        TradeContext.STRINFO  = '交易金额超限'
        TradeContext.BCSTAT   = PL_BCSTAT_MFERFE
        TradeContext.BCSTATNM = "拒绝"                
    
    AfaLoggerFunc.tradeInfo(">>>结束必要性检查")
    
    #发起主机记账
    AfaLoggerFunc.tradeInfo(">>>开始发起主机记账")
    
    TradeContext.sCertType = TradeContext.CERTTYPE
    TradeContext.sCertNo   = TradeContext.CERTNO
    TradeContext.sOccamt  = TradeContext.OCCAMT
    TradeContext.sCuschrg = TradeContext.CUSCHRG
    
    AfaLoggerFunc.tradeInfo(">>>" + TradeContext.PRCCO)
    if TradeContext.PRCCO == 'RCCI0000':
        TradeContext.HostCode = '8813'                               #调用8813主机接口
        #TradeContext.PASSWD = TradeContext.CURPIN
        #来账对方现金收取手续费
        if( TradeContext.CHRGTYP != '1' ):
        
            TradeContext.RCCSMCD  = PL_RCCSMCD_XJTDLZ                     #主机摘要代码
            TradeContext.SBAC = TradeContext.PYRACC                       #借方账户:付款人账户
            TradeContext.ACNM = TradeContext.PYRNAM                       #借方户名 付款人户名
            TradeContext.RBAC = TradeContext.BESBNO + PL_ACC_NXYDQSLZ     #贷方账户:农信银待清算来账
            TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC, 25)
            TradeContext.OTNM = '农信银待清算来账'                        #贷方户名:
            TradeContext.CTFG =  '7'                                      #本金 手续费标识  7 本金 8手续费 9 本金+手续费
            TradeContext.PKFG =  'T'                                      #通存通兑标识                                  
            TradeContext.WARNTNO = '49' + TradeContext.BNKBKNO
            TradeContext.CERTTYPE = ''
            TradeContext.CERTNO = ''
            TradeContext.PASSWD = TradeContext.CURPIN                     #密码
            
            AfaLoggerFunc.tradeInfo( '借方账号:' + TradeContext.SBAC )
            AfaLoggerFunc.tradeInfo( '贷方账号:' + TradeContext.RBAC )
            AfaLoggerFunc.tradeInfo( '凭证号码:' + TradeContext.WARNTNO )
            
        else:
            #对方转账收取手续费时s
            TradeContext.ACUR    =  '3'                                           #记账次数
            
            #=========交易金额============
            TradeContext.RCCSMCD  =  PL_RCCSMCD_XJTDLZ                               #摘要代码
            TradeContext.SBAC  =  TradeContext.PYRACC                           #借方账号
            TradeContext.ACNM  =  TradeContext.PYRNAM                           #借方户名
            TradeContext.RBAC  =  TradeContext.BESBNO + PL_ACC_NXYDJLS          #贷方账号
            TradeContext.RBAC  =  rccpsHostFunc.CrtAcc(TradeContext.RBAC,25)
            TradeContext.OTNM  =  '待解临时款项'                                #贷方户名
            TradeContext.OCCAMT  =  str(TradeContext.sOccamt)                       #发生额
            TradeContext.CTFG  = '7'                                            #本金 手续费标识  7 本金 8手续费 9 本金+手续费
            TradeContext.PKFG  = 'T'                                            #通存通兑标识                                  
            TradeContext.WARNTNO = '49' + TradeContext.BNKBKNO
            TradeContext.PASSWD = TradeContext.CURPIN                           #密码
            TradeContext.sCertType = TradeContext.CERTTYPE
            TradeContext.sCertNo   = TradeContext.CERTNO
            TradeContext.CERTTYPE = ''
            TradeContext.CERTNO = ''
            AfaLoggerFunc.tradeInfo( '>>>交易金额:借方账号' + TradeContext.SBAC )
            AfaLoggerFunc.tradeInfo( '>>>交易金额:贷方账号' + TradeContext.RBAC )
            AfaLoggerFunc.tradeInfo( '凭证号码:' + TradeContext.WARNTNO )
            #=========结算手续费收入户===========
            TradeContext.I2SMCD  =  PL_RCCSMCD_SXF                                #摘要代码
            TradeContext.I2SBAC  =  TradeContext.PYRACC                           #借方账号
            TradeContext.I2ACNM  =  TradeContext.PYRNAM                           #借方户名
            TradeContext.I2RBAC  =  TradeContext.BESBNO + PL_ACC_NXYDJLS          #贷方账号
            TradeContext.I2RBAC  =  rccpsHostFunc.CrtAcc(TradeContext.I2RBAC,25)
            TradeContext.I2OTNM  =  '待解临时款项'                                #贷方户名
            TradeContext.I2TRAM  =  str(TradeContext.sCuschrg)                      #发生额
            TradeContext.I2CTFG  = '8'                                              #本金 手续费标识  7 本金 8手续费 9 本金+手续费
            TradeContext.I2PKFG  = 'T'                                              #通存通兑标识                                  
            TradeContext.I2WARNTNO = '49' + TradeContext.BNKBKNO
            TradeContext.I2PASSWD  = TradeContext.CURPIN                             #密码
            AfaLoggerFunc.tradeInfo( '>>>结算手续费收入户:借方账号' + TradeContext.I2SBAC )
            AfaLoggerFunc.tradeInfo( '>>>结算手续费收入户:贷方账号' + TradeContext.I2RBAC )
            AfaLoggerFunc.tradeInfo( '凭证号码:' + TradeContext.I2WARNTNO )
            #=========交易金额+手续费===================
            TradeContext.I3SMCD    =  PL_RCCSMCD_XJTDLZ                               #摘要代码
            TradeContext.I3SBAC    =  TradeContext.BESBNO + PL_ACC_NXYDJLS          #借方账号
            TradeContext.I3SBAC    =  rccpsHostFunc.CrtAcc(TradeContext.I3SBAC,25)
            TradeContext.I3ACNM    =  '待解临时款项'                                #借方户名
            TradeContext.I3RBAC    =  TradeContext.BESBNO + PL_ACC_NXYDQSLZ         #贷方账号
            TradeContext.I3RBAC    =  rccpsHostFunc.CrtAcc(TradeContext.I3RBAC,25)
            TradeContext.I3OTNM    =  '农信银来账'                                  #贷方户名
            TradeContext.I3TRAM    =  rccpsUtilTools.AddDot(TradeContext.OCCAMT,TradeContext.CUSCHRG) #发生额
            TradeContext.I3CTFG  = '9'                                              #本金 手续费标识  7 本金 8手续费 9 本金+手续费 
            TradeContext.I3PKFG  = 'T'                                              #通存通兑标识                                   
            AfaLoggerFunc.tradeInfo( '>>>交易金额+手续费:借方账号' + TradeContext.I3SBAC )
            AfaLoggerFunc.tradeInfo( '>>>交易金额+手续费:贷方账号' + TradeContext.I3RBAC )
        
        rccpsHostFunc.CommHost( TradeContext.HostCode )
        
        AfaLoggerFunc.tradeInfo(">>>结束发起主机记账")
        
        
        #TradeContext.errorCode, TradeContext.errorMsg = '0000', '主机成功'
        
        #根据主机返回码,设置业务状态为自动入账成功或失败
        AfaLoggerFunc.tradeInfo(">>>开始根据主机放回码,设置业务状态为自动扣款成功或失败")
        
        stat_dict = {}
        stat_dict['BJEDTE']  = TradeContext.BJEDTE
        stat_dict['BSPSQN']  = TradeContext.BSPSQN
        stat_dict['BESBNO']  = TradeContext.BESBNO
        stat_dict['BETELR']  = TradeContext.BETELR
        stat_dict['SBAC']    = TradeContext.SBAC
        stat_dict['ACNM']    = TradeContext.ACNM
        stat_dict['RBAC']    = TradeContext.RBAC
        stat_dict['OTNM']    = TradeContext.OTNM
        #=====modify by pgt 1129====
        stat_dict['MGID']   = TradeContext.errorCode
        if TradeContext.existVariable('TRDT'):
    	    stat_dict['TRDT'] = TradeContext.TRDT
    	if TradeContext.existVariable('TLSQ'):
    		stat_dict['TLSQ'] = TradeContext.TLSQ
        stat_dict['STRINFO'] = TradeContext.errorMsg
        
        AfaLoggerFunc.tradeInfo("主机返回码[" + TradeContext.errorCode + "],主机返回信息[" + TradeContext.errorMsg +"]")
        if TradeContext.errorCode == '0000':
            #=====发送农信银成功,设置状态为自动入账成功====
            stat_dict['BCSTAT']  = PL_BCSTAT_AUTOPAY
            stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
            TradeContext.PRCCO = 'RCCI0000'
            TradeContext.STRINFO = '成功'
            
            if not rccpsState.setTransState(stat_dict):
                return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为自动入账成功异常")
            
            AfaLoggerFunc.tradeInfo(">>>设置业务状态为自动扣款成功完成")
        else:
            #=====发送农信银失败,设置状态为拒绝成功====       
            stat_dict['BCSTAT']  = PL_BCSTAT_MFERFE
            stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
            #TradeContext.PRCCO = 'NN1CA999'
            TradeContext.PRCCO = rccpsDBFunc.HostErr2RccErr(TradeContext.errorCode)
            AfaLoggerFunc.tradeInfo(">>>>>>>>>>>>>>>>>>>>" + TradeContext.PRCCO)
            TradeContext.STRINFO = TradeContext.errorMsg
            
            if not rccpsState.setTransState(stat_dict):
                AfaLoggerFunc.tradeFatal( '设置业务状态为拒绝成功异常' )
                TradeContext.PRCCO    = "NN1ID999"
                TradeContext.STRINFO  = "数据库其他错误"
            
            AfaLoggerFunc.tradeInfo(">>>设置业务状态为拒绝成功完成")
    
    else:
        stat_dict = {}
        stat_dict['BJEDTE']  = TradeContext.BJEDTE
        stat_dict['BSPSQN']  = TradeContext.BSPSQN
        stat_dict['BESBNO']  = TradeContext.BESBNO
        stat_dict['BETELR']  = TradeContext.BETELR
        stat_dict['PRCCO']   = TradeContext.PRCCO
        stat_dict['STRINFO'] = TradeContext.STRINFO
        stat_dict['BCSTAT']  = PL_BCSTAT_MFERFE
        stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
        
        if not rccpsState.setTransState(stat_dict):
            AfaLoggerFunc.tradeFatal( '设置业务状态为拒绝成功异常' )
            TradeContext.PRCCO    = "NN1ID999"
            TradeContext.STRINFO  = "数据库其他错误"
            
        AfaLoggerFunc.tradeInfo(">>>设置业务状态为拒绝成功完成")
        
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        TradeContext.PRCCO    = "NN1ID999"
        TradeContext.STRINFO  = "数据库其他错误"
    
    AfaLoggerFunc.tradeInfo(">>>开始根据主机放回码,设置业务状态为自动入账成功或失败")
        
    #为自动扣款应答报文赋值
    TradeContext.sysType  = 'rccpst'
    TradeContext.MSGTYPCO = 'SET007'                                          #报文类代码
    #TradeContext.RCVMBRCO = TradeContext.SNDMBRCO                             #接收方成员行号
    TradeContext.RCVSTLBIN = TradeContext.SNDMBRCO                            #收款方成员行号
    TradeContext.SNDSTLBIN = TradeContext.RCVMBRCO                            #付款方成员行号
    TradeContext.SNDBRHCO = TradeContext.BESBNO                               #发起行网点号
    TradeContext.SNDCLKNO = TradeContext.BETELR                               #发起行柜员号
    TradeContext.SNDTRDAT = TradeContext.BJEDTE                               #发起行交易日期
    TradeContext.SNDTRTIM = TradeContext.BJETIM                               #发起行交易时间
    TradeContext.ORMFN    = TradeContext.MSGFLGNO                             #参考报文标识号
    TradeContext.MSGFLGNO = TradeContext.SNDMBRCO + TradeContext.BJEDTE + TradeContext.SerialNo       #报文标识号
    TradeContext.NCCWKDAT = TradeContext.NCCworkDate                          #中心工作日期
    TradeContext.OPRTYPNO = '30'                                              #业务类型
    TradeContext.ROPRTPNO = TradeContext.OPRTYPNO                             #参考业务类型
    TradeContext.TRANTYP  = '0'                                               #传输类型
    TradeContext.CERTTYPE = TradeContext.sCertType
    TradeContext.CERTNO   = TradeContext.sCertNo
    TradeContext.OCCAMT   = TradeContext.sOccamt
    TradeContext.CUSCHRG  = TradeContext.sCuschrg   
    TradeContext.CUR      = 'CNY'                                             #货币符号
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).折通兑来帐请求报文接收[TRCC006_1140]退出***' )
    return True
Exemple #14
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
Exemple #15
0
def SubModuleDoTrd():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(3.中心记账).往账发送[TRCC002_8506]进入***' )
    AfaLoggerFunc.tradeInfo( '>>>判断发送农信银中心返回结果' )

    #=====设置记账函数接口====
    sstlog_dict = {}
    sstlog_dict["BJEDTE"] = TradeContext.BJEDTE   #交易日期
    sstlog_dict["BSPSQN"] = TradeContext.BSPSQN     #报单序号

    #=====判断第三方返回值,返回成功时====
    if TradeContext.errorCode == '0000':
        sstlog_dict['BCSTAT'] = PL_BCSTAT_SND
        sstlog_dict['BDWFLG'] = PL_BDWFLG_SUCC

        #=====设置状态为发送成功====
        if not rccpsState.setTransState(sstlog_dict):
            #=====RollBack操作====
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
        else:
            #=====commit操作====
            AfaDBFunc.CommitSql()
            TradeContext.errorCode = '0000'
            TradeContext.errorMsg  = '发送农信银中心成功'
    #=====判断第三方返回值,返回失败时====
    else:
        sstlog_dict['BCSTAT'] = PL_BCSTAT_SND
        sstlog_dict['BDWFLG'] = PL_BDWFLG_FAIL
        #=====设置状态为发送失败====
        if not rccpsState.setTransState(sstlog_dict):
            #=====RollBack操作====
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
        else:
            #=====commit操作====
            AfaDBFunc.CommitSql()
            AfaLoggerFunc.tradeDebug( '>>>commit send succ' )

        #=====调用主机函数进行抹账====
        AfaLoggerFunc.tradeInfo('>>>开始抹账处理')

        #=====设置sstlog表中状态为:抹账-处理中====
        TradeContext.BOSPSQ  = TradeContext.BSPSQN
        TradeContext.BOJEDT  = TradeContext.BJEDTE
        TradeContext.BCSTAT  = PL_BCSTAT_HCAC
        TradeContext.BDWFLG  = PL_BDWFLG_WAIT

        if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,TradeContext.BCSTAT,TradeContext.BDWFLG):
            #=====RollBack操作====
            if not AfaDBFunc.RollbackSql():
                return AfaFlowControl.ExitThisFlow('M999', '发送农信银中心失败,设置状态失败,系统自动回滚')
        else:
            #=====commit操作====
            if not AfaDBFunc.CommitSql():
                AfaDBFunc.RollbackSql()
                return AfaFlowControl.ExitThisFlow('M999', '发送农信银中心失败,设置状态失败,系统自动回滚')

        #=====字典赋值==== 
        sstlog_new = {}
        sstlog_new["BJEDTE"] = TradeContext.BJEDTE                                   #交易日期
        sstlog_new["BSPSQN"] = TradeContext.BSPSQN                                   #报单序号
        
        #汇兑往帐抹帐字典赋值
        input_dict = {}
        input_dict['BJEDTE']     = TradeContext.BJEDTE
        input_dict['BSPSQN']     = TradeContext.BSPSQN
        input_dict['PYRACC']     = TradeContext.PYRACC                         #付款人账号
        input_dict['OCCAMT']     = str(TradeContext.OCCAMT)
        input_dict['BBSSRC']     = TradeContext.BBSSRC
        input_dict['BESBNO']     = TradeContext.BESBNO

        #调用汇兑往帐抹帐
        rccpsEntries.HDWZMZ(input_dict) 

        #=====设置记账函数接口====
        rccpsHostFunc.CommHost( TradeContext.HostCode )
            
        if TradeContext.errorCode == '0000':
            sstlog_new['DASQ']   = TradeContext.DASQ
            sstlog_new['PRTCNT'] = 1                     #打印次数
            sstlog_new['BCSTAT'] = PL_BCSTAT_HCAC
            sstlog_new['BDWFLG'] = PL_BDWFLG_SUCC
            sstlog_new['SBAC']   = TradeContext.SBAC
            sstlog_new['RBAC']   = TradeContext.RBAC      
            sstlog_new["MGID"]   = TradeContext.errorCode       #主机返回码
            sstlog_new["STRINFO"]= TradeContext.errorMsg        #主机返回信息
            sstlog_new["TRDT"]   = TradeContext.TRDT            #主机日期
            sstlog_new["TLSQ"]   = TradeContext.TLSQ            #主机流水号
            
            TradeContext.errorCode = 'D011'             #赋值返回错误
            TradeContext.errorMsg  = '发送农信银中心失败,系统自动冲正成功'
        else:
            sstlog_new['BCSTAT'] = PL_BCSTAT_HCAC
            sstlog_new['BDWFLG'] = PL_BDWFLG_FAIL
            TradeContext.errorCode = 'D011'             #赋值返回错误
            TradeContext.errorMsg  = '发送农信银中心失败,系统自动冲正失败'

        #=====修改sstlog表中记录状态为:抹账-成功/失败====
        if not rccpsState.setTransState(sstlog_new):
            return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
        else:
            #=====commit操作====
            AfaDBFunc.CommitSql()
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(3.中心记账).往账发送[TRCC002_8506]退出***' )
    return True
Exemple #16
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(1.本地操作).往账发送[TRCC002_8506]进入***' )
    
    #====begin 蔡永贵 20110215 增加====
    #新票据号是16位,需要取后8位,版本号为02,同时要兼容老票据号8位,版本号为01
    if len(TradeContext.BILNO) == 16:
        TradeContext.TMP_BILNO = TradeContext.BILNO[-8:]
    else:
        TradeContext.TMP_BILNO = TradeContext.BILNO
    #============end============
    
    AfaLoggerFunc.tradeInfo('>>>RCVSTLBIN: '+TradeContext.RCVSTLBIN)
    AfaLoggerFunc.tradeInfo('>>>SNDSTLBIN: '+TradeContext.SNDSTLBIN)
    #=====判断是否为同一成员行内====
    if TradeContext.RCVSTLBIN == TradeContext.SNDSTLBIN:
        return AfaFlowControl.ExitThisFlow('M999','同一成员行内禁止做此业务')
     
    ##===== 张恒  增加条件,如网银支付则不校验重复次数. 将手续费标志及金额字段赋值 20091109 ========##
    if (TradeContext.existVariable( "CHSHTP" ) and len(TradeContext.CHSHTP) != 0):          #手续费收取方式
        TradeContext.CHRGTYP      =      TradeContext.CHSHTP 
    else:
        TradeContext.CHRGTYP      =      '2'                                                #默认为不收
    if (TradeContext.existVariable( "CUSCHRG" ) and len(TradeContext.CUSCHRG) != 0):        #手续费金额
        TradeContext.LOCCUSCHRG   =      TradeContext.CUSCHRG  
    else :
        TradeContext.LOCCUSCHRG   =      '0.00'                                             #默认为0.00
    TradeContext.CUSCHRG          =      '0.00'                                             #异地手续费清0
    
    if str(TradeContext.OPRATTNO) != '12':                                                  #网银支付
    ##=====END=====================================================================================##
    
        #=====检查数据库是否有相同交易====
        sql = "BJEDTE = '" + TradeContext.BJEDTE + "'"                                      #日期
        sql = sql + " and BESBNO ='" + TradeContext.BESBNO + "'"                            #机构号
        if (TradeContext.existVariable( "PYRACC" ) and len(TradeContext.PYRACC) != 0):      #付款人账号
            sql = sql + " and PYRACC ='" + TradeContext.PYRACC + "'"
        if (TradeContext.existVariable( "RCVBNKCO" ) and len(TradeContext.RCVBNKCO) != 0):  #收款行行号
            sql = sql + " and RCVBNKCO = '" + TradeContext.RCVBNKCO + "'"
        if (TradeContext.existVariable( "PYEACC" ) and len(TradeContext.PYEACC) != 0):      #收款人账号
            sql = sql + " and PYEACC ='" + TradeContext.PYEACC + "'"
        if (TradeContext.existVariable( "OCCAMT" ) and len(TradeContext.OCCAMT) != 0):      #金额
            sql = sql + " and OCCAMT ="  + TradeContext.OCCAMT + ""
        if (TradeContext.existVariable( "OPRNO" ) and len(TradeContext.OPRNO) != 0):        #业务种类
            sql = sql + " and OPRNO  ='" + TradeContext.OPRNO  + "'"
        if (TradeContext.existVariable( "OPRATTNO" ) and len(TradeContext.OPRATTNO) != 0):  #业务属性
            sql = sql + " and OPRATTNO ='" + TradeContext.OPRATTNO + "'"
        if (TradeContext.existVariable( "BBSSRC" ) and len(TradeContext.BBSSRC) != 0):      #资金来源
            sql = sql + " and BBSSRC ='" + TradeContext.BBSSRC + "'"
        if (TradeContext.existVariable( "DASQ" ) and len(TradeContext.DASQ) != 0):          #销账序号
            sql = sql + " and DASQ   ='" + TradeContext.DASQ + "'"
        if (TradeContext.existVariable( "BILTYP" ) and len(TradeContext.BILTYP) != 0):      #票据种类
            sql = sql + " and BILTYP = '" + TradeContext.BILTYP  + "'"
        if (TradeContext.existVariable( "BILDAT" ) and len(TradeContext.BILDAT) != 0):      #票据日期
            sql = sql + " and BILDAT = '" + TradeContext.BILDAT  + "'"
        if (TradeContext.existVariable( "BILNO" ) and len(TradeContext.BILNO) != 0):        #票据号码
            sql = sql + " and BILNO  = '" + TradeContext.BILNO   + "'"
        if (TradeContext.existVariable( "NOTE1" ) and len(TradeContext.NOTE1) != 0):        #备注1
            sql = sql + " and NOTE1  = '" + TradeContext.NOTE1   + "'"

        #=====调用函数进行多笔查询====
        AfaLoggerFunc.tradeInfo( '>>>判断必要的字段是否重复,重复返回错误')
        record = rccpsDBTrcc_trcbka.selectm(1,10,sql,"")
        if record == None:
            return AfaFlowControl.ExitThisFlow('D000','数据库操作失败')
        if len(record) > 0:
            #====判断必要的字段是否重复,重复返回错误====
            for next in range(0, len(record)):
                spbsta = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':record[next]['BSPSQN']}
                rep = rccpsDBTrcc_spbsta.selectu(spbsta)
                if rep == None:
                    return AfaFlowControl.ExitThisFlow('D000', '数据库操作错误')
                elif len(rep) <= 0:
                    return AfaFlowControl.ExitThisFlow('D001', '数据库查询相同业务错误')
                else:
                    if rep['BDWFLG'] != PL_BDWFLG_FAIL:
                        return AfaFlowControl.ExitThisFlow('S000', '相同业务已录入,不允许重复提交')
    AfaLoggerFunc.tradeInfo( '>>>开始处理此笔业务' )
    #=====资金来源为1-个人结算户时,需要调用8811校验支付条件====
    if TradeContext.BBSSRC == '1':
        TradeContext.HostCode = '8811'
        TradeContext.ACCNO    = TradeContext.PYRACC     #付款人账户

        rccpsHostFunc.CommHost( '8811' )
       
        if TradeContext.errorCode != '0000':
            return AfaFlowControl.ExitThisFlow('S999','查询凭证信息出错')
        else:
            if TradeContext.PAYTYP != TradeContext.HPAYTYP:
                return AfaFlowControl.ExitThisFlow('S999','支付条件错误')

    #=====开始调用密押服务器====
    SEAL = '          '
    SNDBANKCO  = TradeContext.SNDBNKCO
    RCVBANKCO  = TradeContext.RCVBNKCO
    SNDBANKCO = SNDBANKCO.rjust(12,'0')
    RCVBANKCO = RCVBANKCO.rjust(12,'0')
    AMOUNT = TradeContext.OCCAMT.split('.')[0] + TradeContext.OCCAMT.split('.')[1]
    AMOUNT = AMOUNT.rjust(15,'0')
    
    AfaLoggerFunc.tradeDebug('AMOUNT=' + str(AMOUNT) )
    AfaLoggerFunc.tradeDebug('SNDBANKCO=' + str(SNDBANKCO) )
    AfaLoggerFunc.tradeDebug('RCVBANKCO=' + str(RCVBANKCO) )
    AfaLoggerFunc.tradeDebug('类型:' + str(PL_SEAL_ENC) )
    AfaLoggerFunc.tradeDebug('业务类型:' + str(PL_TYPE_DZHD) )
    AfaLoggerFunc.tradeDebug('日期' + TradeContext.TRCDAT )
    AfaLoggerFunc.tradeDebug('流水' + TradeContext.SerialNo )
    AfaLoggerFunc.tradeDebug('密押o[' + SEAL + ']')
    
    ret = miya.DraftEncrypt(PL_SEAL_ENC,PL_TYPE_DZHD,TradeContext.TRCDAT,TradeContext.SerialNo,AMOUNT,SNDBANKCO,RCVBANKCO,'',SEAL)
    AfaLoggerFunc.tradeDebug("ret[" + str(ret) + "]")
    AfaLoggerFunc.tradeDebug('密押[' + SEAL + ']')
    if ret != 0:
        return AfaFlowControl.ExitThisFlow('M9999','调用密押服务器失败')
    else:
        TradeContext.SEAL = SEAL
        AfaLoggerFunc.tradeDebug('密押new[' + TradeContext.SEAL + ']')   

    #=====开始向字典赋值====
    TradeContext.DCFLG = PL_DCFLG_CRE
    dict = {}
    if not rccpsMap8506CTradeContext2Ddict.map(dict):
        return AfaFlowControl.ExitThisFlow('M999', '字典赋值出错')

    #=====开始插入数据库====
    if not rccpsDBFunc.insTransTrc(dict):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('D002', '插入数据库出错,RollBack成功')

    #=====commit操作====
    if not AfaDBFunc.CommitSql():
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('D011', '数据库Commit失败')
    else:
        AfaLoggerFunc.tradeDebug('COMMIT成功')

    #====送往主机字段增加收款人名称字段  ===
    if (TradeContext.existVariable( "PYRNAM" ) and len(TradeContext.PYRNAM) != 0):       #付款人名称
         TradeContext.ACNM     = TradeContext.PYRNAM
    else:
         TradeContext.ACNM     = ''
    if (TradeContext.existVariable( "PYENAM" ) and len(TradeContext.PYENAM) != 0):       #收款人名称
        TradeContext.OTNM      = TradeContext.PYENAM
    else:
        TradeContext.OTNM      = ''
        
    #汇兑往帐记帐字典赋值
    input_dict = {}
    input_dict['CHRGTYP']     = TradeContext.CHRGTYP                        #手续费收取方式
    input_dict['LOCCUSCHRG']  = TradeContext.LOCCUSCHRG                     #手续费金额
    input_dict['PYRACC']      = TradeContext.PYRACC                         #付款人账号
    input_dict['BBSSRC']      = TradeContext.BBSSRC                         #资金来源
    input_dict['OCCAMT']      = TradeContext.OCCAMT                         #交易金额
    input_dict['ACNM']        = TradeContext.ACNM                           #付款人名称
    input_dict['OTNM']        = TradeContext.OTNM                           #收款人名称
    input_dict['BESBNO']      = TradeContext.BESBNO
    #调用汇兑记账接口
    rccpsEntries.HDWZJZ(input_dict)

    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(1.本地操作).往账发送[TRCC002_8506]退出***' )
    return True
Exemple #17
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(2.主机记账).往账发送[TRCC002_8506]进入***' )
    AfaLoggerFunc.tradeInfo( '>>>开始更新主机返回结果信息' )
    
    #=====从主机返回信息取借贷方账号和主机返回信息====
    sstlog = {}
    sstlog["BJEDTE"] = TradeContext.BJEDTE      #交易日期
    sstlog["BSPSQN"] = TradeContext.BSPSQN      #报单序号
    sstlog["SBAC"] = TradeContext.SBAC          #借方账号
    sstlog["ACNM"] = TradeContext.PYRNAM        #借方户名
    sstlog["RBAC"] = TradeContext.RBAC          #贷方账号
    sstlog["OTNM"] = '0651科目'                 #贷方户名

    #=====判断主机返回结果====
    if TradeContext.errorCode != '0000':
        sstlog['BCSTAT'] = PL_BCSTAT_ACC
        sstlog['BDWFLG'] = PL_BDWFLG_FAIL
        sstlog["MGID"] = TradeContext.errorCode     #主机返回码
        sstlog["STRINFO"] = TradeContext.errorMsg   #主机返回信息
    elif TradeContext.errorCode == '0000':
        sstlog['BCSTAT'] = PL_BCSTAT_ACC
        sstlog['BDWFLG'] = PL_BDWFLG_SUCC
        sstlog["TRDT"] = TradeContext.TRDT    #主机日期
        sstlog["TLSQ"] = TradeContext.TLSQ    #主机流水号
        sstlog["MGID"] = TradeContext.MGID    #主机返回信息
        sstlog["DASQ"] = TradeContext.DASQ    #销账序号
    #测试用
    AfaLoggerFunc.tradeInfo( 'TradeContext.__status__ ='+TradeContext.__status__)
    
    if TradeContext.__status__=='2':            #异常情况
        #====需要触发主机抹账交易===
        #汇兑往帐抹帐字典赋值
        input_dict = {}
        input_dict['BJEDTE']     = TradeContext.BJEDTE
        input_dict['BSPSQN']     = TradeContext.BSPSQN
        input_dict['PYRACC']     = TradeContext.PYRACC                         #付款人账号
        input_dict['OCCAMT']     = str(TradeContext.OCCAMT)
        input_dict['BBSSRC']     = TradeContext.BBSSRC
        input_dict['BESBNO']     = TradeContext.BESBNO

        #调用汇兑往帐抹帐
        rccpsEntries.HDWZMZ(input_dict) 

        #=====调用主机函数进行抹账
        rccpsHostFunc.CommHost( TradeContext.HostCode )
 
        #=====判断主机返回值====
        if TradeContext.errorCode == '0000':
            sstlog['BCSTAT'] = PL_BCSTAT_ACC
            sstlog['BDWFLG'] = PL_BDWFLG_FAIL
            TradeContext.errorCode = 'D011'         #赋值返回错误
            TradeContext.errorMsg  = '记账失败,系统自动冲正成功'
        else:
            sstlog['BCSTAT'] = PL_BCSTAT_ACC
            sstlog['BDWFLG'] = PL_BDWFLG_WAIT
            TradeContext.errorCode = 'D011'         #赋值返回错误
            TradeContext.errorMsg  = '记账失败,系统自动冲正失败'

    #=====修改sstlog表中数据====
    AfaLoggerFunc.tradeInfo( '字典:' + str(sstlog) )

    if not rccpsState.setTransState(sstlog):
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('>>>commit成功')

    #=====判断主机返回,不成功返回错误到前台====
    if TradeContext.errorCode != '0000':
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)

    #=====赋值农信银中心需要字段====
    TradeContext.TRANTYP   = '0'   #传输类型
    TradeContext.OPRTYPNO  = '20'  #业务属性
    #TradeContext.BJEDTE    = TradeContext.NCCworkDate
    #TradeContext.TRCDAT    = TradeContext.NCCworkDate

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

    if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,TradeContext.BCSTAT,TradeContext.BDWFLG):
        #=====RollBack操作====
        if not AfaDBFunc.RollbackSql():
            return AfaFlowControl.ExitThisFlow('M999', '发送农信银中心失败,设置状态失败,系统自动回滚')
    else:
        #=====commit操作====
        if not AfaDBFunc.CommitSql():
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow('M999', '发送农信银中心失败,设置状态失败,系统自动回滚')

    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(2.主机记账).往账发送[TRCC002_8506]退出***' )
    return True
Exemple #18
0
def SubModuleDoFst():
    #====开始取流水号对应信息====
    trcbka_dict = {}
    dict = rccpsDBFunc.getTransTrc(TradeContext.BOJEDT,TradeContext.BOSPSQ,trcbka_dict)
    if dict == False:
        return AfaFlowControl.ExitThisFlow('M999','取交易信息失败')

    #=====判断撤销信息====
    if TradeContext.BESBNO != trcbka_dict["BESBNO"]:
        return AfaFlowControl.ExitThisFlow('M999','不允许跨机构撤销')
    if TradeContext.BETELR != trcbka_dict["BETELR"]:
        return AfaFlowControl.ExitThisFlow('M999','不允许换柜员操作')
    if TradeContext.BJEDTE != trcbka_dict["BJEDTE"]:
        return AfaFlowControl.ExitThisFlow('M999','不允许隔日撤销')
    if trcbka_dict["BCSTAT"] != PL_BCSTAT_MFEQUE:  #41 排队状态 1 成功
         return AfaFlowControl.ExitThisFlow('M999','当前业务状态为['+trcbka_dict["BCSTAT"]+']不允许撤销' )
    if trcbka_dict["BRSFLG"] != PL_BRSFLG_SND:    #往帐
         return AfaFlowControl.ExitThisFlow('M999','当前业务状态为来账业务不允许撤销' )

    #=====开始插入数据库====
    trccan_dict = {}
    if not rccpsMap8507Dtrcbka_dict2Dtrccan_dict.map(trcbka_dict,trccan_dict):
         return AfaFlowControl.ExitThisFlow('M999','字典赋值错误')
    
    trccan_dict["CONT"]   = TradeContext.CONT
    trccan_dict["TRCCO"]  = TradeContext.TRCCO
    trccan_dict["BJEDTE"] = TradeContext.BJEDTE
    trccan_dict["BSPSQN"] = TradeContext.BSPSQN
    trccan_dict['CLRESPN'] = PL_ISDEAL_UNDO
    trccan_dict['RCVBNKCO'] = PL_RCV_CENTER
    trccan_dict['RCVBNKNM'] = PL_RCV_CENNAM 
    trccan_dict['RCVMBRCO'] = PL_RCV_CENTER
    trccan_dict['SNDMBRCO'] = TradeContext.SNDSTLBIN
    trccan_dict['TRCNO']    = TradeContext.SerialNo
    AfaLoggerFunc.tradeInfo( '字典trccan_dict:' + str(trccan_dict) )

    #=====开始插入撤销业务登记簿====
    ret = rccpsDBTrcc_trccan.insert(trccan_dict)
    if ret <= 0:
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('D011','数据库ROLLBAKC失败')

    #=====commit操作====
    AfaDBFunc.CommitSql()
    AfaLoggerFunc.tradeInfo('>>>commit succ')

    #=====从字典向TradeContext赋值====
    if not rccpsMap8507Dtrccan_dict2CTradeContext.map(trccan_dict):
         return AfaFlowControl.ExitThisFlow('M999','字典赋值错误')

    #====手工赋值一些字段====
    TradeContext.OROCCAMT = str(TradeContext.OCCAMT)    #原交易金额
    AfaLoggerFunc.tradeDebug('>>>原交易金额' + str(TradeContext.OROCCAMT))
    TradeContext.ROPRTPNO = trcbka_dict['TRCCO'][:2]           #参考业务类型
    AfaLoggerFunc.tradeDebug('>>>参考业务类型' + TradeContext.ROPRTPNO)
    TradeContext.OPRTYPNO = '99'
    AfaLoggerFunc.tradeDebug('>>>业务类型' + TradeContext.OPRTYPNO)
    TradeContext.ORMFN    = str(trcbka_dict['SNDMBRCO']) + str(trcbka_dict['TRCDAT']) + str(trcbka_dict['TRCNO'])     #参考报文标识号
    AfaLoggerFunc.tradeDebug('>>>参考类型' + TradeContext.ORMFN)
    TradeContext.ORRCVBNK = trcbka_dict['RCVBNKCO']
    TradeContext.RCVBNKCO = PL_RCV_CENTER
    TradeContext.RCVBNKNM = PL_RCV_CENNAM 
    TradeContext.RCVSTLBIN = PL_RCV_CENTER
    TradeContext.ORTRCNO   = trcbka_dict['TRCNO']
    
    TradeContext.ORSNDBNKCO=trccan_dict['SNDBNKCO']
    AfaLoggerFunc.tradeInfo("TradeContext.ORSNDBNKCO:"+TradeContext.ORSNDBNKCO)
    AfaLoggerFunc.tradeInfo("TradeContext.BOSPSQ:"+TradeContext.BOSPSQ)

    return True
Exemple #19
0
        file_path = "settlefile/HDMXCNY1340000008" + NCCWKDAT
        
        if not rccpsFtpFunc.getRccps(file_path):
            rccpsCronFunc.cronExit("S999","下载汇兑对账明细文件[" + file_path + "]异常")
        
        AfaLoggerFunc.tradeInfo(">>>结束下载汇兑对账文件")
        
        #================关闭汇兑对账文件下载系统调度,打开导入汇兑对账文件系统调度==
        AfaLoggerFunc.tradeInfo(">>>开始关闭汇兑对账文件下载系统调度,打开导入汇兑对账文件系统调度")
        if not rccpsCronFunc.closeCron("00031"):
            rccpsCronFunc.cronExit("S999","关闭汇兑对账文件下载系统调度异常")
            
        if not rccpsCronFunc.openCron("00034"):
            rccpsCronFunc.cronExit("S999","打开汇兑对账明细文件导入系统调度异常")
        
        if not AfaDBFunc.CommitSql( ):
            AfaLoggerFunc.tradeInfo( AfaDBFunc.sqlErrMsg )
            rccpsCronFunc.cronExit("S999","Commit异常")
        AfaLoggerFunc.tradeInfo(">>>Commit成功")
        
        AfaLoggerFunc.tradeInfo(">>>结束关闭汇兑对账文件下载系统调度,打开导入汇兑对账文件系统调度")
        
        AfaLoggerFunc.tradeInfo("***农信银系统: 系统调度类.汇兑对账文件下载[rccpsHDDZGetFile]退出***")
        

    except Exception, e:
        #所有异常

        if not AfaDBFunc.RollbackSql( ):
            AfaLoggerFunc.tradeInfo( AfaDBFunc.sqlErrMsg )
            AfaLoggerFunc.tradeInfo(">>>Rollback异常")
Exemple #20
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( )
Exemple #21
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( ">>>开始汇兑来账接收处理" )

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

        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)

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

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

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

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

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

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

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

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

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

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

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

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

    return True
Exemple #22
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).系统状态变更报文接收[RCC00R6_1121]进入***' )
    
    #=================查询本地相关业务状态的系统状态============================
    mbrifa_where_dict = {}
    mbrifa_where_dict['OPRTYPNO'] = TradeContext.RELOPRTYPNO
    
    mbrifa_dict = rccpsDBTrcc_mbrifa.selectu(mbrifa_where_dict)
    if mbrifa_dict == None:
        return AfaFlowControl.ExitThisFlow("S999","查询本地系统状态信息异常")
        
    if  len(mbrifa_dict) <= 0:
        return AfaFlowControl.ExitThisFlow("S999","无相关业务类型本地系统状态信息")
    
    #=================校验报文新工作日期============================================
    if int(TradeContext.NWWKDAT) < int(mbrifa_dict['NWWKDAT']):
        AfaLoggerFunc.tradeInfo("报文新工作日期[" + TradeContext.NWWKDAT + "]在本地新工作日期[" + mbrifa_dict['NWWKDAT'] + "]之前,丢弃此报文,进入下一流程,发送表示成功的通讯回执")
        #======为通讯回执报文赋值===================================================
        out_context_dict = {}
        out_context_dict['sysType']  = 'rccpst'
        out_context_dict['TRCCO']    = '9900503'
        out_context_dict['MSGTYPCO'] = 'SET008'
        out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
        out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
        out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
        out_context_dict['SNDCLKNO'] = TradeContext.BETELR
        #out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
        #out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
        #out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
        out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
        out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
        out_context_dict['OPRTYPNO'] = '99'
        out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
        out_context_dict['TRANTYP']  = '0'
        out_context_dict['ORTRCCO']  = TradeContext.TRCCO
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '过期报文'
        
        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)
        
        return True
        
    elif int(TradeContext.NWWKDAT) == int(mbrifa_dict['NWWKDAT']):
        #============报文新工作日期与本地新工作日期相同,校验报文新工作状态======
        if int(TradeContext.NWSYSST) <= int(mbrifa_dict['NWSYSST']):
            AfaLoggerFunc.tradeInfo("报文新工作状态[" + TradeContext.NWSYSST + "]不在本地新工作状态[" + mbrifa_dict['NWSYSST'] + "]之后,丢弃此报文,进入下一流程,发送表示成功的通讯回执")
            #======为通讯回执报文赋值===================================================
            out_context_dict = {}
            out_context_dict['sysType']  = 'rccpst'
            out_context_dict['TRCCO']    = '9900503'
            out_context_dict['MSGTYPCO'] = 'SET008'
            out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
            out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
            out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
            out_context_dict['SNDCLKNO'] = TradeContext.BETELR
            out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
            out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
            out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
            out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
            out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
            out_context_dict['OPRTYPNO'] = '99'
            out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
            out_context_dict['TRANTYP']  = '0'
            out_context_dict['ORTRCCO']  = TradeContext.TRCCO
            out_context_dict['PRCCO']    = 'RCCI0000'
            out_context_dict['STRINFO']  = '过期报文'
            
            rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)
            
            return True
    
    #增加日切报文后发先至情况的处理
    #通存通兑顺序10-20-30-10
    if TradeContext.RELOPRTYPNO == "30":
        if mbrifa_dict['NWSYSST'] == '10' and TradeContext.NWSYSST != '20':
            return AfaFlowControl.ExitThisFlow("S999","[" + TradeContext.RELOPRTYPNO + "]业务当前业务状态为日间开始[10],但日切报文中变更状态非业务截止准备[20],停止处理")
            
        if mbrifa_dict['NWSYSST'] == '20' and TradeContext.NWSYSST != '30':
            return AfaFlowControl.ExitThisFlow("S999","[" + TradeContext.RELOPRTYPNO + "]业务当前业务状态为业务截止准备[20],但日切报文中变更状态非业务截止[30],停止处理")
            
        if mbrifa_dict['NWSYSST'] == '30' and TradeContext.NWSYSST != '10':
            return AfaFlowControl.ExitThisFlow("S999","[" + TradeContext.RELOPRTYPNO + "]业务当前业务状态为业务截止[30],但日切报文中变更状态非日间开始[10],停止处理")
    #汇兑汇票顺序10-30-10
    else:
        if mbrifa_dict['NWSYSST'] == '10' and TradeContext.NWSYSST != '30':
            return AfaFlowControl.ExitThisFlow("S999","[" + TradeContext.RELOPRTYPNO + "]业务当前业务状态为日间开始[10],但日切报文中变更状态非业务截止[30],停止处理")
            
        if mbrifa_dict['NWSYSST'] == '30' and TradeContext.NWSYSST != '10':
            return AfaFlowControl.ExitThisFlow("S999","[" + TradeContext.RELOPRTYPNO + "]业务当前业务状态为业务截止[30],但日切报文中变更状态非日间开始[10],停止处理")
    
    mbrifa_update_dict = {}
    mbrifa_update_dict['ORWKDAT'] = mbrifa_dict['NWWKDAT']
    mbrifa_update_dict['ORSYSST'] = mbrifa_dict['NWSYSST']
    mbrifa_update_dict['NWWKDAT'] = TradeContext.NWWKDAT
    mbrifa_update_dict['NWSYSST'] = TradeContext.NWSYSST
    mbrifa_update_dict['HOLFLG']  = TradeContext.HOLFLG
    mbrifa_update_dict['NOTE1']   = mbrifa_dict['NWWKDAT']
    
    ret = rccpsDBTrcc_mbrifa.update(mbrifa_update_dict,mbrifa_where_dict)
    if ret <= 0:
        if not AfaDBFunc.RollbackSql( ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            AfaLoggerFunc.tradeError(">>>Rollback异常")
        AfaLoggerFunc.tradeInfo(">>>Rollback成功")
        return AfaFlowControl.ExitThisFlow("S999","更新系统状态异常")
    
    #======若新系统状态为业务截止,则打开对账系统调度============================
    if TradeContext.NWSYSST == '30' and TradeContext.HOLFLG == '2':
        if TradeContext.RELOPRTYPNO == '20':
            #====打开汇兑对账系统调度=======================================
            AfaLoggerFunc.tradeInfo(">>>开始打开汇兑对账系统调度")
            
            if not rccpsCronFunc.openCron("00031"):
                if not AfaDBFunc.RollbackSql( ):
                    AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
                    AfaLoggerFunc.tradeError(">>>Rollback异常")
                AfaLoggerFunc.tradeInfo(">>>Rollback成功")
                return AfaFlowControl.ExitThisFlow("S999","打开汇兑对账系统调度异常")
                
            AfaLoggerFunc.tradeInfo(">>>结束打开汇兑对账系统调度")
            
            #====打开汇票对账系统调度=======================================
            AfaLoggerFunc.tradeInfo(">>>开始打开汇票对账系统调度")
            
            if not rccpsCronFunc.openCron("00041"):
                if not AfaDBFunc.RollbackSql( ):
                    AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
                    AfaLoggerFunc.tradeError(">>>Rollback异常")
                AfaLoggerFunc.tradeInfo(">>>Rollback成功")
                return AfaFlowControl.ExitThisFlow("S999","打开汇票对账系统调度异常")
            
            AfaLoggerFunc.tradeInfo(">>>结束打开汇票对账系统调度")
            
        elif TradeContext.RELOPRTYPNO == '30':
            #====打开通存通兑对账系统调度===================================
            AfaLoggerFunc.tradeInfo(">>>开始打开通存通兑对账系统调度")
            
            if not rccpsCronFunc.openCron("00061"):
                if not AfaDBFunc.RollbackSql( ):
                    AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
                    AfaLoggerFunc.tradeError(">>>Rollback异常")
                AfaLoggerFunc.tradeInfo(">>>Rollback成功")
                return AfaFlowControl.ExitThisFlow("S999","打开通存通兑对账系统调度异常")
                
            AfaLoggerFunc.tradeInfo(">>>结束打开通存通兑对账系统调度")
            
            #====打开信息类业务量统计系统调度======================
            AfaLoggerFunc.tradeInfo(">>>开始打开信息类业务量统计系统调度")
            
#            if not rccpsCronFunc.openCron("00067"):
#                if not AfaDBFunc.RollbackSql( ):
#                    AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
#                    AfaLoggerFunc.tradeError(">>>Rollback异常")
#                AfaLoggerFunc.tradeInfo(">>>Rollback成功")
#                return AfaFlowControl.ExitThisFlow("S999","打开信息类业务量统计系统调度异常")
            
#            AfaLoggerFunc.tradeInfo(">>>结束打开信息类业务量统计系统调度")
            
            
            
    #======若通存通兑新系统状态为日间开始,则打开行名行号生效系统调度===================
    if TradeContext.NWSYSST == '10' and TradeContext.RELOPRTYPNO == '30':
        #====开始打开行名行号生效系统调度=======================================
        AfaLoggerFunc.tradeInfo(">>>开始打开行名行号生效系统调度")
        
        if not rccpsCronFunc.openCron("00050"):
            if not AfaDBFunc.RollbackSql( ):
                AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
                AfaLoggerFunc.tradeError(">>>Rollback异常")
            AfaLoggerFunc.tradeInfo(">>>Rollback成功")
            return AfaFlowControl.ExitThisFlow("S999","打开行名行号生效系统调度异常")
            
        AfaLoggerFunc.tradeInfo(">>>结束打开行名行号生效系统调度")
            
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow("S999","Commit异常")
    AfaLoggerFunc.tradeInfo(">>>Commit成功")
        
    #======为通讯回执报文赋值===================================================
    out_context_dict = {}
    out_context_dict['sysType']  = 'rccpst'
    out_context_dict['TRCCO']    = '9900503'
    out_context_dict['MSGTYPCO'] = 'SET008'
    out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
    out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
    out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
    out_context_dict['SNDCLKNO'] = TradeContext.BETELR
    out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
    out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
    out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
    out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
    out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
    out_context_dict['OPRTYPNO'] = '99'
    out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
    out_context_dict['TRANTYP']  = '0'
    out_context_dict['ORTRCCO']  = TradeContext.TRCCO
    out_context_dict['PRCCO']    = 'RCCI0000'
    out_context_dict['STRINFO']  = '成功'
    
    rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).系统状态变更报文接收[RCC00R6_1121]退出***' )
    return True
Exemple #23
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).业务状态查复报文接收[RCC00R6_1108]进入***' )
    
    #==========判断是否重复报文,如果是重复报文,直接进入下一流程=================
    AfaLoggerFunc.tradeInfo(">>>开始检查是否重复报文")
    ztcbka_where_dict = {}
    ztcbka_where_dict['SNDBNKCO'] = TradeContext.SNDBNKCO
    ztcbka_where_dict['TRCDAT']   = TradeContext.TRCDAT
    ztcbka_where_dict['TRCNO']    = TradeContext.TRCNO
    
    ztcbka_dict = rccpsDBTrcc_ztcbka.selectu(ztcbka_where_dict)
    
    if ztcbka_dict == None:
        return AfaFlowControl.ExitThisFlow("S999","校验重复报文失败")
    
    if len(ztcbka_dict) > 0:
        AfaLoggerFunc.tradeInfo("业务状态登记簿中存在相同查复交易,此报文为重复报文,进入下一流程,发送表示成功的通讯回执")
        #======为通讯回执报文赋值===============================================
        out_context_dict = {}
        out_context_dict['sysType']  = 'rccpst'
        out_context_dict['TRCCO']    = '9900503'
        out_context_dict['MSGTYPCO'] = 'SET008'
        out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
        out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
        out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
        out_context_dict['SNDCLKNO'] = TradeContext.BETELR
        out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
        out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
        out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
        out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
        out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
        out_context_dict['OPRTYPNO'] = '99'
        out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
        out_context_dict['TRANTYP']  = '0'
        out_context_dict['ORTRCCO']  = TradeContext.TRCCO
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '重复报文'
        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)
        
        return True
        
    AfaLoggerFunc.tradeInfo(">>>结束检查是否重复报文")
    
    #==========判断是否存在原查询交易===========================================
    AfaLoggerFunc.tradeInfo(">>>开始检查是否存在原查询交易")
    or_ztcbka_where_dict = {}
    or_ztcbka_where_dict['SNDBNKCO'] = TradeContext.OQTSBNK
    or_ztcbka_where_dict['TRCDAT']   = TradeContext.OQTDAT
    or_ztcbka_where_dict['TRCNO']    = TradeContext.OQTNO
    
    or_ztcbka_dict = {}
    or_ztcbka_dict = rccpsDBTrcc_ztcbka.selectu(or_ztcbka_where_dict)
    
    if or_ztcbka_dict == None:
        return AfaFlowControl.ExitThisFlow("S999","校验原查询交易失败") 
    
    if len(or_ztcbka_dict) <= 0:
        AfaLoggerFunc.tradeInfo("业务状态登记簿中不存在原查询交易,进入下一流程,发送表示成功的通讯回执")
        #======为通讯回执报文赋值===============================================
        out_context_dict = {}
        out_context_dict['sysType']  = 'rccpst'
        out_context_dict['TRCCO']    = '9900503'
        out_context_dict['MSGTYPCO'] = 'SET008'
        out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
        out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
        out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
        out_context_dict['SNDCLKNO'] = TradeContext.BETELR
        out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
        out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
        out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
        out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
        out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
        out_context_dict['OPRTYPNO'] = '99'
        out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
        out_context_dict['TRANTYP']  = '0'
        out_context_dict['ORTRCCO']  = TradeContext.TRCCO
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '业务状态登记簿中不存在原查询交易'
        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)
        
        return True
    
    AfaLoggerFunc.tradeInfo(">>>结束检查是否存在原查询交易")
        
    
    #==========为业务状态查复查复登记簿字典赋值=================================
    AfaLoggerFunc.tradeInfo(">>>开始为此业务状态登记簿字典赋值")
    
    if or_ztcbka_dict.has_key('BJEDTE'):
        TradeContext.BOJEDT = or_ztcbka_dict['BJEDTE']
    
    if or_ztcbka_dict.has_key('BSPSQN'):
        TradeContext.BOSPSQ = or_ztcbka_dict['BSPSQN']
    
    if TradeContext.existVariable('TRCCO'):
        TradeContext.ORTRCCO = TradeContext.TRCCO
        
    TradeContext.ISDEAL = PL_ISDEAL_ISDO
    
    ztcbka_insert_dict = {}
    if not rccpsMap1108CTradeContext2Dztcbka.map(ztcbka_insert_dict):
        return AfaFlowControl.ExitThisFlow("S999","为查复业务字典赋值异常")
    
    AfaLoggerFunc.tradeInfo(">>>结束为此业务状态登记簿字典赋值")
    #==========登记业务状态查复查复登记簿=======================================
    AfaLoggerFunc.tradeInfo(">>>开始登记此查复业务")
    
    ret = rccpsDBTrcc_ztcbka.insert(ztcbka_insert_dict)
    
    if ret <= 0:
        return AfaFlowControl.ExitThisFlow("S999","登记状态查复登记簿异常") 
    
    AfaLoggerFunc.tradeInfo(">>>结束登记此查复业务")
    
    #======更新原查询交易信息===================================================
    AfaLoggerFunc.tradeInfo(">>>开始更新原查询业务信息")
    
    or_ztcbka_update_dict = {}
    or_ztcbka_update_dict['NCCTRCST'] = TradeContext.NCCTRCST
    or_ztcbka_update_dict['MBRTRCST'] = TradeContext.MBRTRCST
    or_ztcbka_update_dict['ISDEAL']   = PL_ISDEAL_ISDO
    
    ret = rccpsDBTrcc_ztcbka.update(or_ztcbka_update_dict,or_ztcbka_where_dict)
    if (ret <= 0):
        return AfaFlowControl.ExitThisFlow("S999","更新原查询业务信息异常") 
        
    if not AfaDBFunc.CommitSql():
        AfaFlowControl.ExitThisFlow("S999","Commit异常")
    AfaLoggerFunc.tradeInfo(">>>Commit成功")
    
    AfaLoggerFunc.tradeInfo(">>>结束更新原查询业务信息")
    #======为通讯回执报文赋值===================================================
    out_context_dict = {}
    out_context_dict['sysType']  = 'rccpst'
    out_context_dict['TRCCO']    = '9900503'
    out_context_dict['MSGTYPCO'] = 'SET008'
    out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
    out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
    out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
    out_context_dict['SNDCLKNO'] = TradeContext.BETELR
    out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
    out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
    out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
    out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
    out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
    out_context_dict['OPRTYPNO'] = '99'
    out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
    out_context_dict['TRANTYP']  = '0'
    out_context_dict['ORTRCCO']  = TradeContext.TRCCO
    out_context_dict['PRCCO']    = 'RCCI0000'
    out_context_dict['STRINFO']  = '成功'
    
    rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).业务状态查复报文接收[RCC00R6_1108]退出***' )
    
    return True
Exemple #24
0
def SubModuleDoFst():
    #=====判断是否重复交易====
    sel_dict = {'TRCNO':TradeContext.TRCNO,'TRCDAT':TradeContext.TRCDAT,'SNDBNKCO':TradeContext.SNDBNKCO}
    record = rccpsDBTrcc_existp.selectu(sel_dict)
    if record == None:
        return AfaFlowControl.ExitThisFlow('S999','判断是否重复报文,查询汇兑业务登记簿相同报文异常')
    elif len(record) > 0:
        AfaLoggerFunc.tradeInfo('紧急止付业务登记簿中存在相同数据,重复报文,进入下一流程')
        #=====为通讯回执报文赋值====
        out_context_dict = {}
        out_context_dict['sysType']  = 'rccpst'
        out_context_dict['TRCCO']    = '9900503'
        out_context_dict['MSGTYPCO'] = 'SET008'
        out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
        out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
        out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
        out_context_dict['SNDCLKNO'] = TradeContext.BETELR
        out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
        out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
        out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
        out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
        out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
        out_context_dict['OPRTYPNO'] = '99'
        out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
        out_context_dict['TRANTYP']  = '0'
        out_context_dict['ORTRCCO']  = trc_dict['TRCCO']
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '重复报文'

        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)

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

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

    #=====根据发送行号,委托日期,交易流水号查询原交易信息===========
    AfaLoggerFunc.tradeInfo(">>>开始根据发送行号,委托日期,交易流水号查询交易信息")
    trc_dict = {}
    if not rccpsDBFunc.getTransTrcPK(TradeContext.SNDMBRCO,TradeContext.ORTRCDAT,TradeContext.ORTRCNO,trc_dict):
        return AfaFlowControl.ExitThisFlow('S999','汇兑业务登记簿中无此交易,抛弃报文') 

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

    #=====需要插入紧急止付业务登记簿existp====
    existp = {}
    if not rccpsMap1130CTradeContext2Dexistp.map(existp):
        return AfaFlowControl.ExitThisFlow('S999','字典赋值出错,抛弃报文')

    existp['BOJEDT']  =  trc_dict['BJEDTE']
    existp['BOSPSQ']  =  trc_dict['BSPSQN']
    existp['CUR']     =  '01'
    
    #=====张恒 20091203 新增 将机构落到原交易机构 ====
    existp['BESBNO']     =  trc_dict['BESBNO']
    
    ret = rccpsDBTrcc_existp.insertCmt(existp)
    if ret < 0:
        return AfaFlowControl.ExitThisflow('S999','插入止付业务登记簿出错,抛弃报文')

    #======检查原业务状态是否为自动挂账-成功====
    #if not (trc_dict['BCSTAT'] != PL_BCSTAT_HANG and trc_dict['BDWFLG'] != PL_BDWFLG_SUCC ):
    if (trc_dict['BCSTAT'] != PL_BCSTAT_HANG or trc_dict['TRCCO'][:2] != '20' or trc_dict['TRCCO'] == '2000009'):
        out_context_dict = {}
        out_context_dict['sysType']  = 'rccpst'
        out_context_dict['TRCCO']    = '9900503'
        out_context_dict['MSGTYPCO'] = 'SET008'
        out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
        out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
        out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
        out_context_dict['SNDCLKNO'] = TradeContext.BETELR
        out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
        out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
        out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
        out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
        out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
        out_context_dict['OPRTYPNO'] = '99'
        out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
        out_context_dict['TRANTYP']  = '0'
        out_context_dict['ORTRCCO']  = trc_dict['TRCCO']
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '该笔业务已入账,不允许退汇'

        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)
        TradeContext.SNDSTLBIN       = TradeContext.RCVMBRCO     #发起成员行号

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

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

    TradeContext.BOSPSQ   = trc_dict['BSPSQN']
    TradeContext.BOJEDT   = trc_dict['BJEDTE']
    TradeContext.ORPYRACC = trc_dict['PYRACC']
    TradeContext.ORPYRNAM = trc_dict['PYRNAM']
    TradeContext.ORPYEACC = trc_dict['PYEACC']
    TradeContext.ORPYENAM = trc_dict['PYENAM']
    TradeContext.ORTRCCO  = trc_dict['TRCCO']

    #=====汇兑业务登记簿trcbka赋值新增一条记录====
    trc_dict['BOJEDT']  =  trc_dict['BJEDTE']
    trc_dict['BOSPSQ']  =  trc_dict['BSPSQN']
    trc_dict['ORTRCDAT']=  trc_dict['TRCDAT']
    trc_dict['ORTRCNO'] =  trc_dict['TRCNO']
    trc_dict['ORTRCCO'] =  trc_dict['TRCCO']
    trc_dict['TRCCO']   =  '2000004'
    trc_dict['OPRNO']   =  '09'
    trc_dict['DCFLG']   =  PL_DCFLG_CRE
    trc_dict['BJEDTE']  =  TradeContext.BJEDTE
    trc_dict['BSPSQN']  =  TradeContext.BSPSQN
    trc_dict['TRCDAT']  =  TradeContext.TRCDAT
    trc_dict['TRCNO']   =  TradeContext.SerialNo
    trc_dict['BRSFLG']  =  PL_BRSFLG_SND                  #往账
    trc_dict['BBSSRC']  =  '3'                            #待销账
    #=====接收成员行号与发送成员行号互换====
    TradeContext.temp   =  trc_dict['SNDMBRCO']
    trc_dict['SNDMBRCO']=  trc_dict['RCVMBRCO']
    trc_dict['RCVMBRCO']=  TradeContext.temp 

    #=====接收行号与发送行号互换====
    TradeContext.temp   =  trc_dict['SNDBNKCO']
    trc_dict['SNDBNKCO']=  trc_dict['RCVBNKCO']
    trc_dict['RCVBNKCO']=  TradeContext.temp 

    #=====接收行名与发送行名互换====
    TradeContext.temp   =  trc_dict['SNDBNKNM']
    trc_dict['SNDBNKNM']=  trc_dict['RCVBNKNM']
    trc_dict['RCVBNKNM']=  TradeContext.temp 

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

    #=====设置状态为记账-处理中====
    sstlog   = {}
    sstlog['BSPSQN']   = TradeContext.BSPSQN
    sstlog['BJEDTE']   = TradeContext.BJEDTE
    sstlog['BCSTAT']   = PL_BCSTAT_ACC
    sstlog['BDWFLG']   = PL_BDWFLG_WAIT

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

    #=====开始拼借贷方账号====
    TradeContext.DASQ  = trc_dict['DASQ']
    TradeContext.RBAC  =  TradeContext.BESBNO + PL_ACC_NXYDQSWZ
    TradeContext.OCCAMT= TradeContext.OROCCAMT
    TradeContext.HostCode = '8813'

    #=====开始调函数拼贷方账号第25位校验位====
    TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC, 25)
    AfaLoggerFunc.tradeInfo( '贷方账号:' + TradeContext.RBAC )
 
    rccpsHostFunc.CommHost(TradeContext.HostCode)

    AfaLoggerFunc.tradeInfo( '>>>开始判断主机返回结果' )
    status_dict = {}
    status_dict['BSPSQN']  = TradeContext.BSPSQN       #报单序号
    status_dict['BJEDTE']  = TradeContext.BJEDTE       #交易日期
    status_dict['BCSTAT']  = PL_BCSTAT_ACC             #记账

    #=====判断主机返回结果====
    if TradeContext.errorCode != '0000':
        status_dict['BDWFLG']  = PL_BDWFLG_FAIL        #失败
    else:
        status_dict['BDWFLG']  = PL_BDWFLG_SUCC        #成功
        status_dict['TRDT']    = TradeContext.TRDT     #主机日期
        status_dict['TLSQ']    = TradeContext.TLSQ     #主机流水号
        status_dict['MGID']    = TradeContext.MGID     #主机返回信息
        status_dict['DASQ']    = TradeContext.DASQ     #销账序号

    #=====修改退汇记录的状态====
    if not rccpsState.setTransState(status_dict):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('>>>commit成功')

    #=====判断主机返回结果,是否继续流程====
    if TradeContext.errorCode != '0000':
        out_context_dict = {}
        out_context_dict['sysType']  = 'rccpst'
        out_context_dict['TRCCO']    = '9900503'
        out_context_dict['MSGTYPCO'] = 'SET008'
        out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
        out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
        out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
        out_context_dict['SNDCLKNO'] = TradeContext.BETELR
        out_context_dict['SNDTRDAT'] = TradeContext.TRCDAT
        out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
        out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
        out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
        out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
        out_context_dict['OPRTYPNO'] = '99'
        out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
        out_context_dict['TRANTYP']  = '0'
        out_context_dict['ORTRCCO']  = TradeContext.ORTRCCO 
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '该笔业务已入账,不允许退汇'

        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)

        TradeContext.SNDSTLBIN       = TradeContext.RCVMBRCO     #发起成员行号

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

        return AfaFlowControl.ExitThisFlow('S999','该笔业务已被主机处理,不允许退汇')

    #=====新增记录的状态为:发送-处理中====
    if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_SND,PL_BDWFLG_WAIT):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('M999', '设置状态失败,系统自动回滚')
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()

    out_context_dict = {}
    out_context_dict['sysType']  = 'rccpst'
    out_context_dict['TRCCO']    = '9900503'
    out_context_dict['MSGTYPCO'] = 'SET008'
    out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
    out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
    out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
    out_context_dict['SNDCLKNO'] = TradeContext.BETELR
    out_context_dict['SNDTRDAT'] = TradeContext.TRCDAT
    out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
    out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
    out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
    out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
    out_context_dict['OPRTYPNO'] = '99'
    out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
    out_context_dict['TRANTYP']  = '0'
    out_context_dict['ORTRCCO']  = TradeContext.ORTRCCO
    out_context_dict['PRCCO']    = 'RCCI0000'
    out_context_dict['STRINFO']  = '成功'

    rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)

    TradeContext.SNDSTLBIN       = TradeContext.RCVMBRCO     #发起成员行号

    return True
Exemple #25
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( )
Exemple #26
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.中心类操作(1.本地操作).汇票撤销[TRCC003_8503]进入***' )
    
    #====begin 蔡永贵 20110215 增加====
    #新票据号是16位,需要取后8位,版本号为02,同时要兼容老票据号8位,版本号为01
    if TradeContext.BILVER == '02':
        TradeContext.TMP_BILNO = TradeContext.BILNO[-8:]
    else:
        TradeContext.TMP_BILNO = TradeContext.BILNO
    #============end============
    
    #校验当前汇票状态是否为签发或解挂
    AfaLoggerFunc.tradeInfo(">>>开始校验当前汇票状态是否为签发或解挂")
    
    bilinf_dict = {}
    if not rccpsDBFunc.getInfoBil(TradeContext.BILVER,TradeContext.BILNO,PL_BILRS_INN,bilinf_dict):
        return AfaFlowControl.ExitThisFlow("S999","查询汇票信息异常")
        
    if bilinf_dict['REMBNKCO'] != TradeContext.SNDBNKCO:
        return AfaFlowControl.ExitThisFlow("S999","本行非此汇票出票行,禁止提交")
        
    if bilinf_dict['BILDAT'] != TradeContext.BJEDTE:
        return AfaFlowControl.ExitThisFlow("S999","非今日签发的汇票,禁止提交")
        
    if bilinf_dict['HPSTAT'] != PL_HPSTAT_SIGN and bilinf_dict['HPSTAT'] != PL_HPSTAT_DEHG and bilinf_dict['HPSTAT'] != PL_HPSTAT_HANG:
        return AfaFlowControl.ExitThisFlow("S999","此汇票当前状态非[签发,挂失,解挂],禁止提交")
    
        
    #=====通过日期+报单序号查询汇票业务登记簿rcc_bilbka,取“资金来源”====
    #=====潘广通来负责完成====
    bilbka_where_dict = {'BJEDTE':bilinf_dict['NOTE1'],'BSPSQN':bilinf_dict['NOTE2']}
    bilbka_dict = rccpsDBTrcc_bilbka.selectu(bilbka_where_dict)
    if( bilbka_dict == None ):
        return AfaFlowControl.ExitThisFlow("S999","查询汇票业务登记簿异常")
        
    if( len(bilbka_dict) <= 0 ):
        return AfaFlowControl.ExitThisFlow("S999","查询汇票业务登记簿为空")
        
    #=====潘广通 0916 判断柜员和机构是否为签发柜员和机构====
    if( bilbka_dict['BETELR'] != TradeContext.BETELR ):
        return AfaFlowControl.ExitThisFlow("S999","此柜员不是录入柜员")
        
    #if( bilbka_dict['BESBNO'] != TradeContext.BESBNO):
    #    return AfaFlowControl.ExitThisFlow("S999","此机构不是录入机构")
        
    #将签发交易的资金来源赋值到上下文
    TradeContext.BBSSRC = bilbka_dict['BBSSRC']
    
    #将汇票信息映射到TradeContext中
    if not rccpsMap8503Dbilinf2CTradeContext.map(bilinf_dict):
        return False
    
    AfaLoggerFunc.tradeInfo(">>>结束校验当前汇票状态是否为签发或解挂")
    
    #汇票类交易接收成员行为总中心
    TradeContext.RCVSTLBIN = PL_RCV_CENTER
    
    #接收行为签发时的代理付款行
    TradeContext.RCVBNKCO  = TradeContext.PAYBNKCO
    TradeContext.RCVBNKNM  = TradeContext.PAYBNKNM
    
    #登记汇票业务登记簿
    AfaLoggerFunc.tradeInfo(">>>开始登记汇票业务登记簿")
    
    TradeContext.SNDMBRCO = TradeContext.SNDSTLBIN
    TradeContext.RCVMBRCO = TradeContext.RCVSTLBIN
    TradeContext.TRCNO    = TradeContext.SerialNo
    TradeContext.NCCWKDAT = TradeContext.NCCworkDate
    TradeContext.OPRNO    = PL_HPOPRNO_CX               #业务种类:撤销
    TradeContext.DCFLG    = PL_DCFLG_DEB                #借贷标识:借记
    TradeContext.BRSFLG   = PL_BRSFLG_SND               #往来标识:往账
    TradeContext.TRCCO    = '2100101'                   #交易代码:2100101汇票撤销
    
    bilbka_dict = {}
    if not rccpsMap8503CTradeContext2Dbilbka.map(bilbka_dict):
        return False
    
    if not rccpsDBFunc.insTransBil(bilbka_dict):
        return AfaFlowControl.ExitThisFlow('S999','登记汇票业务登记簿异常')
    
    AfaLoggerFunc.tradeInfo(">>>结束登记汇票业务登记簿")
    
    #设置业务状态为发送处理中
    AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送处理中")
    
    stat_dict = {}
    stat_dict['BJEDTE'] = TradeContext.BJEDTE
    stat_dict['BSPSQN'] = TradeContext.BSPSQN
    stat_dict['BCSTAT'] = PL_BCSTAT_SND
    stat_dict['BDWFLG'] = PL_BDWFLG_WAIT
    
    if not rccpsState.setTransState(stat_dict):
        return AfaFlowControl.ExitThisFlow('S999','设置状态为发送处理中异常')
    
    AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为发送处理中")
    
    #COMMIT
    if not AfaDBFunc.CommitSql( ):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return AfaFlowControl.ExitThisFlow("S999","Commit异常")
    AfaLoggerFunc.tradeInfo(">>>Commit成功")
    
    #为发送农信银中心做准备
    AfaLoggerFunc.tradeInfo(">>>开始为发送农信银中心做准备")
    
    TradeContext.MSGTYPCO = 'SET001'
    TradeContext.TRCCO    = '2100101'
    TradeContext.SNDBRHCO = TradeContext.BESBNO
    TradeContext.SNDCLKNO = TradeContext.BETELR
    TradeContext.SNDTRDAT = TradeContext.BJEDTE
    TradeContext.SNDTRTIM = TradeContext.BJETIM
    TradeContext.MSGFLGNO = TradeContext.SNDMBRCO + TradeContext.BJEDTE + TradeContext.TRCNO
    TradeContext.ORMFN    = ""
    TradeContext.OPRTYPNO = '21'
    TradeContext.ROPRTPNO = ''
    TradeContext.TRANTYP  = '0'
    TradeContext.OCCAMT   = str(TradeContext.BILAMT)
    TradeContext.BILAMT   = str(TradeContext.BILAMT)
    
    #begin 20110614 曾照泰 修改 送往农信银中心的票号为8位
    TradeContext.BILNO = TradeContext.BILNO[-8:]
    #end
    
    AfaLoggerFunc.tradeInfo(">>>结束为发送农信银中心做准备")
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.中心类操作(1.本地操作).汇票撤销[TRCC003_8503]退出***' )
    return True
Exemple #27
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      
Exemple #28
0
def SubModuleDoSnd():
    AfaLoggerFunc.tradeInfo('>>>主机记账后处理')
   
    #=====开始向字典赋值====
    sst_dict = {}
    sst_dict['BSPSQN']  = TradeContext.BSPSQN            #报单序号
    sst_dict['BJEDTE']  = TradeContext.BJEDTE            #交易日期
    sst_dict['SBAC']    = TradeContext.SBAC              #借方账号
    sst_dict['BESBNO']  = TradeContext.BESBNO            #机构号
    if (TradeContext.existVariable( "NOTE3" ) and len(TradeContext.NOTE3) != 0):  
        sst_dict['NOTE3']   = TradeContext.NOTE3         #备注3
        AfaLoggerFunc.tradeDebug('>>>test  NOTE3 =['+TradeContext.NOTE3 +']')
    sst_dict['BJETIM']  = TradeContext.BJETIM            #交易时间
    sst_dict['MGID']     = TradeContext.errorCode         #主机返回代码
    sst_dict['STRINFO']  = TradeContext.errorMsg          #主机返回信息
    sst_dict['BETELR']  = TradeContext.BETELR            #柜员号

    #=====开始判断主机返回结果====
    out_context_dict = {}

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


    AfaLoggerFunc.tradeDebug('>>>当前业务状态[' + str(sst_dict['BCSTAT']) + ']')
    AfaLoggerFunc.tradeDebug('>>>当前流转标志[' + str(sst_dict['BDWFLG']) + ']')
            
    #=====设置状态为 记账/挂账-成功 ====
    if not rccpsState.setTransState(sst_dict):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeDebug('>>>commit成功')
    
    # 关彬捷 20080730 更新原交易状态为退汇成功
    if TradeContext.BOJEDT != "" and TradeContext.BOSPSQ != "":
        AfaLoggerFunc(">>>开始修改原交易状态为退汇成功")
        
        if not rccpsState.newTransState(TradeContext.BOJEDT,TradeContext.BOSPSQ,PL_BCSTAT_QTR,PL_BDWFLG_SUCC):
            #return False
            return AfaFlowControl.ExitThisFlow('S999','设置状态出错')
        
        AfaLoggerFunc(">>>开始修改原交易状态为退汇成功")

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

    out_context_dict['sysType']  = 'rccpst'
    out_context_dict['TRCCO']    = '9900503'
    out_context_dict['MSGTYPCO'] = 'SET008'
    out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO
    out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO
    out_context_dict['SNDBRHCO'] = TradeContext.BESBNO
    out_context_dict['SNDCLKNO'] = TradeContext.BETELR
    out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE
    out_context_dict['SNDTRTIM'] = TradeContext.BJETIM
    out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo
    out_context_dict['ORMFN']    = TradeContext.MSGFLGNO
    out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate
    out_context_dict['OPRTYPNO'] = '99'
    out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO
    out_context_dict['TRANTYP']  = '0'
    out_context_dict['ORTRCCO']  = TradeContext.TRCCO

    rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)

    return True
Exemple #29
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作(1.本地操作).异转本_卡应答[TRCC004_1158]进入***' )

    #=================初始化返回信息============================================
    if AfaUtilTools.trim(TradeContext.STRINFO) == "":
        TradeContext.STRINFO = rccpsDBFunc.getErrInfo(TradeContext.PRCCO)
        
    AfaLoggerFunc.tradeDebug("TradeContext.STRINFO=" + TradeContext.STRINFO)

    #=====根据参考报文标识号查找原交易====
    TradeContext.ORSNDBNKCO = TradeContext.ORMFN[:10]                #原发送行号
    TradeContext.BOJEDT     = TradeContext.ORMFN[10:18]              #原交易日期
    TradeContext.ORTRCNO    = TradeContext.ORMFN[18:]                #原交易流水号

    wtr_dict = {}
    if not rccpsDBFunc.getTransWtrAK(TradeContext.ORSNDBNKCO,TradeContext.BOJEDT,TradeContext.ORTRCNO,wtr_dict):
        #=====查询原交易失败,等待前台超时发起冲正,抛弃此报文====       
        return AfaFlowControl.ExitThisFlow('S999','等待前台发起冲正,抛弃报文') 

    AfaLoggerFunc.tradeInfo( '>>>查询原交易结束' )

    #=================若应答报文回复拒绝,则设置状态为拒绝,停止处理=============
    if TradeContext.PRCCO != 'RCCI0000':
        AfaLoggerFunc.tradeInfo(">>>对方返回拒绝应答")
        
        #=============设置业务状态为拒绝处理中=================================
        
        if not rccpsState.newTransState(wtr_dict['BJEDTE'],wtr_dict['BSPSQN'],PL_BCSTAT_MFERFE,PL_BDWFLG_WAIT):
            return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为拒绝成功异常")
        
        if not AfaDBFunc.CommitSql( ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return AfaFlowControl.ExitThisFlow("S999","Commit异常")
            
        #=============设置业务状态为拒绝成功===================================
        stat_dict = {}
        stat_dict['BJEDTE']  = wtr_dict['BJEDTE']
        stat_dict['BSPSQN']  = wtr_dict['BSPSQN']
        stat_dict['BCSTAT']  = PL_BCSTAT_MFERFE
        stat_dict['BDWFLG']  = PL_BDWFLG_SUCC
        stat_dict['PRCCO']   = TradeContext.PRCCO
        stat_dict['STRINFO'] = TradeContext.STRINFO
        
        if not rccpsState.setTransState(stat_dict):
            return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为拒绝成功异常")
        
        if not AfaDBFunc.CommitSql( ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return AfaFlowControl.ExitThisFlow("S999","Commit异常")
            
        return AfaFlowControl.ExitThisFlow('S999',"对方拒绝,交易终止")
            
    #====查找自动冲正登记簿是否存在本交易的冲正====
    #====查找自动冲正登记簿是否存在本交易的冲正====
    wheresql = ''
    wheresql = wheresql + "BOJEDT = '" + wtr_dict['BJEDTE'] + "'"                #报单日期
    wheresql = wheresql + "AND BOSPSQ = '" + wtr_dict['BSPSQN'] + "'"                #报单序号
    
    ret = rccpsDBTrcc_atcbka.count(wheresql)
    if ret == -1:
        return AfaFlowControl.ExitThisFlow('S999','查找自动冲正登记簿异常') 
    elif ret > 0:
        #=====原交易已自动冲正,抛弃报文====
        return AfaFlowControl.ExitThisFlow('S999','原交易已冲正,抛弃报文') 

    AfaLoggerFunc.tradeInfo( '>>>查询冲正登记簿结束' )

    #=====主机记账前处理====
    TradeContext.BESBNO  =  wtr_dict['BESBNO']      #机构号
    TradeContext.BETELR  =  wtr_dict['BETELR']      #柜员号
    TradeContext.BEAUUS  =  wtr_dict['BEAUUS']      #授权柜员
    TradeContext.BEAUPS  =  wtr_dict['BEAUPS']      #授权密码
    TradeContext.TERMID  =  wtr_dict['TERMID']      #终端号
    TradeContext.BJEDTE  =  wtr_dict['BJEDTE']      #交易日期
    TradeContext.BSPSQN  =  wtr_dict['BSPSQN']      #报单序号
    TradeContext.BRSFLG  =  wtr_dict['BRSFLG']      #往来账标志
    TradeContext.HostCode=  '8813'                  #主机交易码

    AfaLoggerFunc.tradeInfo( '>>>主机前处理赋值结束' )

    #=====开始更新原交易,新增状态记账-处理中====
    if not rccpsState.newTransState(wtr_dict['BJEDTE'],wtr_dict['BSPSQN'],PL_BCSTAT_ACC,PL_BDWFLG_WAIT):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('M999', '设置状态失败,系统自动回滚')
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
    
    AfaLoggerFunc.tradeInfo( '>>>设置状态记账-处理中结束' )
    
    #=====根据原记录中的手续费收取方式,判断账务处理模式====
    if wtr_dict['CHRGTYP'] == '1':
        #=====转账====
        TradeContext.ACUR    =  '3'                                     #记账次数
        #=========交易金额+手续费===================
        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.OCCAMT  =  str(wtr_dict['OCCAMT'] + wtr_dict['CUSCHRG']) #发生额
        TradeContext.PKFG    = 'T'
        TradeContext.CTFG    = '9'
        TradeContext.WARNTNO = ''
        TradeContext.CERTTYPE = ''
        TradeContext.CERTNO = ''
        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.I2TRAM  =  str(wtr_dict['OCCAMT'])                       #发生额
        TradeContext.I2CTFG  = '7'
        TradeContext.I2PKFG  = 'T'
        #TradeContext.I2WARNTNO = ''
        #TradeContext.I2CERTTYPE = ''
        #TradeContext.I2CERTNO = ''
        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.I3TRAM  =  str(wtr_dict['CUSCHRG'])                      #发生额
        TradeContext.I3CTFG  = '8'
        TradeContext.I3PKFG  = 'T'
        AfaLoggerFunc.tradeInfo( '>>>结算手续费收入户:借方账号' + TradeContext.I3SBAC )
        AfaLoggerFunc.tradeInfo( '>>>结算手续费收入户:贷方账号' + TradeContext.I3RBAC )

    elif wtr_dict['CHRGTYP'] == '0':
        #=====本金====
        TradeContext.ACUR    =  '2'                                           #记账次数
        TradeContext.RCCSMCD =  PL_RCCSMCD_YZBWZ                              #摘要代码
        TradeContext.SBAC    =  TradeContext.BESBNO + PL_ACC_NXYDQSWZ         #借方账号
        TradeContext.SBAC    = rccpsHostFunc.CrtAcc(TradeContext.SBAC,25)
        TradeContext.ACNM    =  '农信银往账'                                  #借方户名
        TradeContext.RBAC    =  TradeContext.PYEACC                           #贷方账号
        TradeContext.OTNM    =  TradeContext.PYENAM                           #贷方户名
        TradeContext.OCCAMT  =  str(wtr_dict['OCCAMT'])                       #金额
        TradeContext.CTFG  = '7'
        TradeContext.PKFG  = 'T'
        TradeContext.WARNTNO = ''
        TradeContext.CERTTYPE = ''
        TradeContext.CERTNO = ''
        
        #=====手续费记账赋值====
        TradeContext.I2SMCD  =  PL_RCCSMCD_SXF                                #摘要代码
        TradeContext.I2SBAC  =  ''                                            #借方账号
        TradeContext.I2RBAC  =  TradeContext.BESBNO + PL_ACC_TCTDSXF          #贷方账号
        TradeContext.I2RBAC  =  rccpsHostFunc.CrtAcc(TradeContext.I2RBAC,25)
        TradeContext.I2OTNM  =  '手续费科目'                                  #贷方户名
        TradeContext.I2TRAM  =  str(wtr_dict['CUSCHRG'])                      #金额
        TradeContext.I2CTFG  =  '8'
        TradeContext.I2PKFG  =  'T'
        TradeContext.I2CATR  =  '0'                                           #现转标志
    elif wtr_dict['CHRGTYP'] == '2':
        #=====不收费====
        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.OCCAMT  =  str(wtr_dict['OCCAMT'])                       #金额
        TradeContext.CTFG    =  '7'
        TradeContext.PKFG    =  'T'
        TradeContext.WARNTNO = ''
        TradeContext.CERTTYPE = ''
        TradeContext.CERTNO = ''
    else:
        #=====出错====
        return AfaFlowControl.ExitThisFlow('S999','手续费收费方式错,抛弃报文') 
    
    AfaLoggerFunc.tradeInfo( '>>>根据手续费收取方式记账赋值处理结束' )
    
    #=====主机记账处理====
    rccpsHostFunc.CommHost(TradeContext.HostCode)
    
    #=====主机后处理====
    set_dict = {}
    set_dict['BSPSQN']  =  TradeContext.BSPSQN
    set_dict['BJEDTE']  =  TradeContext.BJEDTE
    set_dict['BCSTAT']  =  PL_BCSTAT_ACC
    set_dict["SBAC"]    =  TradeContext.SBAC          #借方账号
    set_dict["RBAC"]    =  TradeContext.RBAC          #贷方账号
    set_dict["OTNM"]    =  TradeContext.OTNM          #贷方户名
    set_dict['MGID']    =  TradeContext.errorCode     #主机返回码
    set_dict["STRINFO"]= TradeContext.errorMsg        #主机返回信息
    if TradeContext.errorCode == '0000':
        #=====主机记账成功====
        set_dict['BDWFLG'] = PL_BDWFLG_SUCC
        set_dict['TRDT']   = TradeContext.TRDT
        set_dict['TLSQ']   = TradeContext.TLSQ
    else:
        set_dict['BDWFLG'] = PL_BDWFLG_FAIL
    
    if not rccpsState.setTransState(set_dict):
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
    AfaLoggerFunc.tradeInfo('>>>设置主机返回状态成功') 
    
    if TradeContext.errorCode == '0000':
        #=====开始更新原交易,新增状态清算成功====
        if not rccpsState.newTransState(wtr_dict['BJEDTE'],wtr_dict['BSPSQN'],PL_BCSTAT_MFESTL,PL_BDWFLG_SUCC):
            #=====RollBack操作====
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow('M999', '设置状态失败,系统自动回滚')
        else:
            #=====commit操作====
            AfaDBFunc.CommitSql()
        
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作(1.本地操作).异转本_卡应答[TRCC004_1158]退出***' )
    
    return True
Exemple #30
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( "====开始汇兑退汇来账接收处理====" )

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

        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)

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

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

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

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

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

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

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

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

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

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

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

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

    return True