Esempio n. 1
0
def getTransStateCur(BJEDTE,BSPSQN,stat_dict):
    AfaLoggerFunc.tradeDebug(">>>进入getTransStateCur")
    
    #==========获取spbsta当前状态信息及编号=====================================
    spbsta_where_dict = {}
    spbsta_where_dict["BJEDTE"] = BJEDTE
    spbsta_where_dict["BSPSQN"] = BSPSQN
    
    spbsta_dict = rccpsDBTrcc_spbsta.selectu(spbsta_where_dict)
    
    if spbsta_dict == None:
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        AfaLoggerFunc.tradeFatal("获取交易[" + BJEDTE + "][" + BSPSQN + "]当前状态异常")
        return AfaFlowControl.ExitThisFlow( 'S999', '获取交易当前状态异常' )
        
    elif len(spbsta_dict) <= 0:
        AfaLoggerFunc.tradeFatal("当前状态登记簿中无此交易[" + BJEDTE + "][" + BSPSQN + "]状态")
        return AfaFlowControl.ExitThisFlow( 'S999', '当前状态登记簿中无此交易状态' )
        return False
        
    #===========获取sstlog对应状态及信息========================================
    sstlog_where_dict = {}
    sstlog_where_dict["BJEDTE"] = spbsta_dict["BJEDTE"]
    sstlog_where_dict["BSPSQN"] = spbsta_dict["BSPSQN"]
    sstlog_where_dict["BCURSQ"] = str(spbsta_dict["BCURSQ"])
    
    sstlog_dict = rccpsDBTrcc_sstlog.selectu(sstlog_where_dict)
    
    if sstlog_dict == None:
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        AfaLoggerFunc.tradeFatal("获取交易[" + BJEDTE + "][" + BSPSQN + "]当前状态详细信息异常")
        return AfaFlowControl.ExitThisFlow( 'S999', '获取交易当前状态详细信息异常' )
        
    if len(sstlog_dict) <= 0:
        AfaLoggerFunc.tradeFatal("流水状态登记簿中无此交易[" + BJEDTE + "][" + BSPSQN + "]当前状态详细信息")
        return AfaFlowControl.ExitThisFlow( 'S999', '流水状态登记簿中无此交易当前状态详细信息' )
        
    if not rccpsMap0000Dsstlog2Dstat_dict.map(sstlog_dict,stat_dict):
        AfaLoggerFunc.tradeFatal("将查询出的交易[" + BJEDTE + "][" + BSPSQN + "]业务状态详细信息赋值到输出字典异常")
        return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的业务状态详细信息赋值到输出字典异常' )
        
    AfaLoggerFunc.tradeDebug(">>>结束getTransStateCur")
    return True
Esempio n. 2
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
Esempio n. 3
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
Esempio n. 4
0
def setTransState(stat_dict):
    AfaLoggerFunc.tradeInfo(">>>进入setTransState")
    
    AfaLoggerFunc.tradeDebug("stat_dict = " + str(stat_dict))
    #==========检查表spbsta中是否存在此业务状态=================================
    spbsta_where_dict = {}
    if stat_dict.has_key("BJEDTE"):
        spbsta_where_dict["BJEDTE"] = stat_dict["BJEDTE"]
        
    if stat_dict.has_key("BSPSQN"):
        spbsta_where_dict["BSPSQN"] = stat_dict["BSPSQN"]
        
    spbsta_dict = rccpsDBTrcc_spbsta.selectu(spbsta_where_dict)
    if spbsta_dict == None:
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        AfaLoggerFunc.tradeFatal("获取交易[" + stat_dict['BJEDTE'] + "][" + stat_dict['BSPSQN'] + "]当前状态异常")
        return AfaFlowControl.ExitThisFlow( 'S999', '获取交易当前状态异常' )
        
    elif len(spbsta_dict) <= 0:
        AfaLoggerFunc.tradeFatal("当前状态登记簿中无交易[" + stat_dict['BJEDTE'] + "][" + stat_dict['BSPSQN'] + "]状态信息")
        return AfaFlowControl.ExitThisFlow( 'S999', '当前状态登记簿中无此交易状态' )
    
    #===========检查表sstlog中是否存在此业务状态================================
    sstlog_where_dict = {}
    if spbsta_dict.has_key("BJEDTE"):
        sstlog_where_dict["BJEDTE"] = spbsta_dict["BJEDTE"]
        
    if spbsta_dict.has_key("BSPSQN"):
        sstlog_where_dict["BSPSQN"] = spbsta_dict["BSPSQN"]
        
    if spbsta_dict.has_key("BCURSQ"):
        sstlog_where_dict["BCURSQ"] = str(spbsta_dict["BCURSQ"])
    
    sstlog_dict = rccpsDBTrcc_sstlog.selectu(sstlog_where_dict)
    
    if sstlog_dict == None:
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        AfaLoggerFunc.tradeFatal("获取交易[" + stat_dict['BJEDTE'] + "][" + stat_dict['BSPSQN'] + "]当前状态详细信息异常")
        return AfaFlowControl.ExitThisFlow( 'S999', '获取交易当前状态详细信息异常' )
        
    elif len(sstlog_dict) == 0:
        AfaLoggerFunc.tradeFatal("流水状态登记簿中无交易[" + stat_dict['BJEDTE'] + "][" + stat_dict['BSPSQN'] + "]当前状态详细信息")
        return AfaFlowControl.ExitThisFlow( 'S999', '流水状态登记簿中无此交易当前状态详细信息' )
    
    #============设置默认值=====================================================
    stat_dict["PRTCNT"] = 0
    stat_dict["NOTE2"] = AfaUtilTools.GetSysDate() + AfaUtilTools.GetSysTime()
    #AfaLoggerFunc.tradeInfo(stat_dict["NOTE2"])
    #============更新表sstlog===================================================
    sstlog_update_dict = {}
    
    if not rccpsMap0000Dstat_dict2Dsstlog.map(stat_dict,sstlog_update_dict):
        return AfaFlowControl.ExitThisFlow( 'S999', '为交易当前状态详细信息赋值异常' )
        
    sstlog_where_dict = {}
    if spbsta_dict.has_key("BJEDTE"):
        sstlog_where_dict["BJEDTE"] = spbsta_dict["BJEDTE"]
        
    if spbsta_dict.has_key("BSPSQN"):
        sstlog_where_dict["BSPSQN"] = spbsta_dict["BSPSQN"]
        
    if spbsta_dict.has_key("BCURSQ"):
        sstlog_where_dict["BCURSQ"] = str(spbsta_dict["BCURSQ"])
        
    #AfaLoggerFunc.tradeInfo("update_dict = " + str(sstlog_update_dict))
    #AfaLoggerFunc.tradeInfo("where_dict = " + str(sstlog_where_dict))
    
    ret = rccpsDBTrcc_sstlog.update(sstlog_update_dict,sstlog_where_dict)
    
    if ret <= 0:
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        AfaLoggerFunc.tradeFatal("登记交易[" + stat_dict['BJEDTE'] + "][" + stat_dict['BSPSQN'] + "]")
        return AfaFlowControl.ExitThisFlow( 'S999', '登记交易当前状态详细信息异常' )
    
    #============更新表spbsta===================================================
    spbsta_update_dict = {}
    
    if not rccpsMap0000Dstat_dict2Dspbsta.map(stat_dict,spbsta_update_dict):
        return AfaFlowControl.ExitThisFlow( 'S999', '为交易当前状态赋值异常' )
    
    spbsta_where_dict = {}
    if stat_dict.has_key("BJEDTE"):
        spbsta_where_dict["BJEDTE"] = stat_dict["BJEDTE"]
    if stat_dict.has_key("BSPSQN"):
        spbsta_where_dict["BSPSQN"] = stat_dict["BSPSQN"]
    
    ret = rccpsDBTrcc_spbsta.update(spbsta_update_dict,spbsta_where_dict)
    if (ret <= 0):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        AfaLoggerFunc.tradeFatal("登记交易[" + stat_dict['BJEDTE'] + "][" + stat_dict['BSPSQN'] + "]当前状态异常")
        return AfaFlowControl.ExitThisFlow( 'S999', '登记交易当前状态异常' )
        
    AfaLoggerFunc.tradeInfo(">>>结束setTransState")
    
    return True
Esempio n. 5
0
def newTransState(BJEDTE,BSPSQN,BCSTAT,BDWFLG):
    AfaLoggerFunc.tradeInfo(">>>进入newTransState")
    
    stat_dict = {}
    stat_dict["BJEDTE"] = BJEDTE;
    stat_dict["BSPSQN"] = BSPSQN;
    stat_dict["BCSTAT"] = BCSTAT;
    stat_dict["BDWFLG"] = BDWFLG;
    
    #==========检查表spbsta中是否存在此业务状态=================================
    spbsta_where_dict = {}
    if stat_dict.has_key("BJEDTE"):
        spbsta_where_dict["BJEDTE"] = stat_dict["BJEDTE"]
    if stat_dict.has_key("BSPSQN"):
        spbsta_where_dict["BSPSQN"] = stat_dict["BSPSQN"]
        
    spbsta_dict = rccpsDBTrcc_spbsta.selectu(spbsta_where_dict)
    
    if spbsta_dict == None:
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        AfaLoggerFunc.tradeFatal("查询交易[" + BJEDTE + "][" + BSPSQN + "]当前状态异常")
        return AfaFlowControl.ExitThisFlow( 'S999', '查询交易当前状态异常' )
        
    elif len(spbsta_dict) <= 0:
        AfaLoggerFunc.tradeInfo("当前状态登记簿中无此业务状态,需新增一条业务状态")
        MaxBCURSQ = 1
        
    else:
        MaxBCURSQ = int(spbsta_dict["BCURSQ"]) + 1
            
    #===========设置默认值======================================================
    if TradeContext.existVariable('BESBNO'):            #机构号
        stat_dict["BESBNO"] = TradeContext.BESBNO
        
    if TradeContext.existVariable('BEACSB'):            #账务机构号
        stat_dict["BEACSB"] = TradeContext.BEACSB
        
    if TradeContext.existVariable('BETELR'):            #柜员号
        stat_dict["BETELR"] = TradeContext.BETELR
        
    if TradeContext.existVariable('BEAUUS'):            #授权柜员号
        stat_dict["BEAUUS"] = TradeContext.BEAUUS
        
    if TradeContext.existVariable('TERMID'):            #终端号
        stat_dict['TERMID'] = TradeContext.TERMID
        
    if TradeContext.existVariable('NOTE3'):             #挂账原因
        stat_dict['NOTE3']  = TradeContext.NOTE3
        
    if TradeContext.existVariable('FEDT') and TradeContext.FEDT != '' and TradeContext.existVariable('HostCode') and TradeContext.HostCode != '8820':              #前置日期
        stat_dict['FEDT'] = TradeContext.FEDT
    else:
        stat_dict['FEDT'] = BJEDTE

    if TradeContext.existVariable('RBSQ') and TradeContext.RBSQ != '' and TradeContext.existVariable('HostCode') and TradeContext.HostCode != '8820':              #前置流水号
        stat_dict['RBSQ']  = TradeContext.RBSQ
    else:
        stat_dict['RBSQ'] = BSPSQN
    
    stat_dict["PRTCNT"] = 0
    stat_dict["BJETIM"] = AfaUtilTools.GetSysDate() + AfaUtilTools.GetSysTime()
    #AfaLoggerFunc.tradeInfo(">>>>time:" + stat_dict["BJETIM"])
    
    #===========在表sstlog中新增一条业务状态====================================
    sstlog_insert_dict = {}
    stat_dict["BCURSQ"] = MaxBCURSQ
    
    if not rccpsMap0000Dstat_dict2Dsstlog.map(stat_dict,sstlog_insert_dict):
        AfaLoggerFunc.tradeFatal("为交易[" + BJEDTE + "][" + BSPSQN + "]当前状态详细信息赋值异常")
        return AfaFlowControl.ExitThisFlow( 'S999', '为交易当前状态详细信息赋值异常' )
    
    ret = rccpsDBTrcc_sstlog.insert(sstlog_insert_dict)
    
    if ret <= 0:
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        AfaLoggerFunc.tradeFatal("登记交易[" + BJEDTE + "][" + BSPSQN + "]当前状态详细信息异常")
        return AfaFlowControl.ExitThisFlow( 'S999', '登记交易当前状态详细信息异常' )
        
    if MaxBCURSQ == 1:    
        #========表spbsta中新增一条业务状态=====================================
        spbsta_insert_dict = {}
        stat_dict["BCURSQ"] = MaxBCURSQ
        
        if not rccpsMap0000Dstat_dict2Dspbsta.map(stat_dict,spbsta_insert_dict):
            AfaLoggerFunc.tradeFatal("为交易[" + BJEDTE + "][" + BSPSQN + "]当前状态赋值异常")
            return AfaFlowControl.ExitThisFlow( 'S999', '为交易当前状态赋值异常' )
            
        ret = rccpsDBTrcc_spbsta.insert(spbsta_insert_dict)
        if ret <= 0:
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            AfaLoggerFunc.tradeFatal("登记交易[" + BJEDTE + "][" + BSPSQN + "]当前状态异常")
            return AfaFlowControl.ExitThisFlow( 'S999', '登记交易当前状态异常' )
    else:
        #========修改spbsta中对应业务状态=======================================
        spbsta_update_dict = {}
        stat_dict["BCURSQ"] = MaxBCURSQ
        
        if not rccpsMap0000Dstat_dict2Dspbsta.map(stat_dict,spbsta_update_dict):
            AfaLoggerFunc.tradeFatal("为交易[" + BJEDTE + "][" + BSPSQN + "]当前状态赋值异常")
            return AfaFlowControl.ExitThisFlow( 'S999', '为交易当前状态赋值异常' )
        
        spbsta_where_dict = {}
        spbsta_where_dict["BJEDTE"] = stat_dict["BJEDTE"]
        spbsta_where_dict["BSPSQN"] = stat_dict["BSPSQN"]
        
        ret = rccpsDBTrcc_spbsta.update(spbsta_update_dict,spbsta_where_dict)
        if (ret <= 0):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            AfaLoggerFunc.tradeFatal("登记交易[" + BJEDTE + "][" + BSPSQN + "]当前状态异常")
            return AfaFlowControl.ExitThisFlow( 'S999', '登记交易当前状态异常' )
    AfaLoggerFunc.tradeInfo(">>>结束newTransState")
    return True
Esempio n. 6
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易[TRC001_8535]进入***' )
    
    #=====判断业务类型是否存在====
    if not (TradeContext.existVariable( "TRCCO" ) and len(TradeContext.TRCCO) != 0):
        return AfaFlowControl.ExitThisFlow('S999','业务类型[TRCCO]不存在或为空')

    #=====取交易时间====
    TradeContext.BJEDTE = AfaUtilTools.GetSysDate( )

    #=====通过机构号查询机构名称====
    ret    = {}
    subbra = {'BESBNO':TradeContext.BESBNO}
    
    ret = rccpsDBTrcc_subbra.selectu(subbra)
    if ret == None:
        return AfaFlowControl.ExitThisFlow('S999','数据库操作失败')
    if len(ret) <= 0:
        if TradeContext.TRCCO not in ('14','15'):
            return AfaFlowControl.ExitThisFlow('S999','数据库中无机构号['+TradeContext.BESBNO+']')
        else:
            TradeContext.BESBNM = TradeContext.BESBNO
    else:
        TradeContext.BESBNM  = ret['BESBNM'] 

    #=====判断业务类型  01  汇兑往账====
    if TradeContext.TRCCO == '01':
        AfaLoggerFunc.tradeInfo('>>>汇兑往账清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND BRSFLG = '"  + PL_BRSFLG_SND + "'"
        sql = sql + " AND TRCCO IN ('2000001','2000002','2000003','2000009') "

        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_trcbka.selectm(1,0,sql,ordersql)
        
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "电子汇兑往帐清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号 业务种类 报单序号   报单日期 发起行行号 接收行行号 金额      付款人账号          "
        filecontext = filecontext + "收款人账号          业务状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====通过报单序号和日期取状态====
            bcstat      = {}
            bcstat_dict = {'BJEDTE':records[i]['BJEDTE'],'BSPSQN':records[i]['BSPSQN']}
            bcstat     = rccpsDBTrcc_spbsta.selectu(bcstat_dict)
            if bcstat == None:
                return AfaFlowControl.ExitThisFlow('S999','数据库操作失败')
            if len(bcstat) <= 0:
                return AfaFlowControl.ExitThisFlow('S999','通过报单序号取业务状态失败')
                 
            #=====写文件====
            filecontext=str(i+1).ljust(4) +  records[i]['TRCCO'].ljust(10) + records[i]['BSPSQN'].ljust(13) \
                       + records[i]['BJEDTE'].ljust(9)    + records[i]['SNDBNKCO'].ljust(11)      \
                       + records[i]['RCVBNKCO'].ljust(11) + str(records[i]['OCCAMT']).ljust(11)   \
                       + records[i]['PYRACC'].ljust(30)   + records[i]['PYEACC'].ljust(34)        \
                       + bcstat['BCSTAT']
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    #=====02 汇兑来帐====
    elif TradeContext.TRCCO == '02':
        AfaLoggerFunc.tradeInfo('>>>汇兑来账清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND BRSFLG = '"  + PL_BRSFLG_RCV + "'"
        sql = sql + " AND TRCCO IN ('2000001','2000002','2000003','2000009')"

        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_trcbka.selectm(1,0,sql,ordersql)
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "电子汇兑来帐清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号 汇票类别 报单序号   出票日期 汇票号码  金额      申请人账号          "
        filecontext = filecontext + "收款人账号          业务状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====通过报单序号和日期取状态====
            bcstat      = {}
            bcstat_dict = {'BJEDTE':records[i]['BJEDTE'],'BSPSQN':records[i]['BSPSQN']}
            bcstat     = rccpsDBTrcc_spbsta.selectu(bcstat_dict)
            if bcstat == None:
                return AfaFlowControl.ExitThisFlow('S999','数据库操作失败')
            if len(bcstat) <= 0:
                return AfaFlowControl.ExitThisFlow('S999','通过报单序号取业务状态失败')
                 
            #=====写文件====
            filecontext=str(i+1).ljust(4) +  records[i]['TRCCO'].ljust(10) + records[i]['BSPSQN'].ljust(13) \
                       + records[i]['BJEDTE'].ljust(9)    + records[i]['SNDBNKCO'].ljust(11)      \
                       + records[i]['RCVBNKCO'].ljust(11) + str(records[i]['OCCAMT']).ljust(11)   \
                       + records[i]['PYRACC'].ljust(30)   + records[i]['PYEACC'].ljust(34)        \
                       + bcstat['BCSTAT']
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    #====03 本行汇票签发====
    elif TradeContext.TRCCO == '03':
        AfaLoggerFunc.tradeInfo('>>>本行汇票签发清单打印操作')
        
        #====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND BRSFLG = '"  + PL_BRSFLG_SND + "'"
        sql = sql + " AND BILRS = '" + PL_BILRS_INN + "' AND HPSTAT = '" + PL_HPSTAT_SIGN + "'"

        #=====多笔查询====
        records = rccpsDBTrcc_bilbka.selectm(1,0,sql,"")
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "本行汇票签发清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号 汇票类别 报单序号   出票日期  汇票号码 金    额  申请人账号          "
        filecontext = filecontext + "收款人账号          业务状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====通过汇票号码、汇票版本号取汇票类别====
            bilinf      = {}
            bilinf_dict = {'BILVER':records[i]['BILVER'],'BILNO':records[i]['BILNO'],'BILRS':records[i]['BILRS']}
            bilinf     = rccpsDBTrcc_bilinf.selectu(bilinf_dict)
            if bilinf == None:
                return AfaFlowControl.ExitThisFlow('S999','数据库操作失败')
            if len(bilinf) <= 0:
                return AfaFlowControl.ExitThisFlow('S999','通过汇票号码取汇票类别失败')
                 
            #=====写文件====
            filecontext=str(i+1).ljust(4) + bilinf['BILTYP'].ljust(10) + records[i]['BSPSQN'].ljust(13) \
                       + bilinf['BILDAT'].ljust(9)        + records[i]['BILNO'].ljust(11)         \
                       + str(bilinf['BILAMT']).ljust(11)  + bilinf['PYRACC'].ljust(30)            \
                       + bilinf['PYEACC'].ljust(34)       + bilinf['BILTYP']
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    #====04 解付他行汇票====
    elif TradeContext.TRCCO == '04':
        AfaLoggerFunc.tradeInfo('>>>解付他行汇票清单打印操作')
        
        #====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND BRSFLG = '"  + PL_BRSFLG_SND + "'"
        sql = sql + " AND BILRS = '" + PL_BILRS_OUT + "'"

        #=====多笔查询====
        records = rccpsDBTrcc_bilbka.selectm(1,0,sql,"")
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "解付他行汇票清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号 汇票类别 报单序号   出票日期  汇票号码 金    额  申请人账号          "
        filecontext = filecontext + "收款人账号          业务状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====通过汇票号码、汇票版本号取汇票类别====
            bilinf      = {}
            bilinf_dict = {'BILVER':records[i]['BILVER'],'BILNO':records[i]['BILNO'],'BILRS':records[i]['BILRS']}
            bilinf     = rccpsDBTrcc_bilinf.selectu(bilinf_dict)
            
            if bilinf == None:
                return AfaFlowControl.ExitThisFlow('S999','数据库操作失败')
            if len(bilinf) <= 0:
                return AfaFlowControl.ExitThisFlow('S999','通过汇票号码取汇票类别失败')
                 
            #=====写文件====
            filecontext=str(i+1).ljust(4) + bilinf['BILTYP'].ljust(10) + records[i]['BSPSQN'].ljust(13) \
                       + bilinf['BILDAT'].ljust(9)        + records[i]['BILNO'].ljust(11)         \
                       + str(bilinf['BILAMT']).ljust(11)  + bilinf['PYRACC'].ljust(30)            \
                       + bilinf['PYEACC'].ljust(34)       + bilinf['BILTYP']
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    #=====05 退汇往帐====
    elif TradeContext.TRCCO == '05':
        AfaLoggerFunc.tradeInfo('>>>退汇往账清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND BRSFLG = '"  + PL_BRSFLG_SND + "'"
        sql = sql + " AND TRCCO  = '2000004' "

        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_trcbka.selectm(1,0,sql,ordersql)
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "退汇往帐清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号 业务种类 报单序号   报单日期 发起行行号 接收行行号 金额      付款人账号          "
        filecontext = filecontext + "收款人账号          业务状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====通过报单序号和日期取状态====
            bcstat      = {}
            bcstat_dict = {'BJEDTE':records[i]['BJEDTE'],'BSPSQN':records[i]['BSPSQN']}
            bcstat     = rccpsDBTrcc_spbsta.selectu(bcstat_dict)
            if bcstat == None:
                return AfaFlowControl.ExitThisFlow('S999','数据库操作失败')
            if len(bcstat) <= 0:
                return AfaFlowControl.ExitThisFlow('S999','通过报单序号取业务状态失败')
                 
            #=====写文件====
            filecontext=str(i+1).ljust(4) +  records[i]['TRCCO'].ljust(10) + records[i]['BSPSQN'].ljust(13) \
                       + records[i]['BJEDTE'].ljust(9)    + records[i]['SNDBNKCO'].ljust(11)      \
                       + records[i]['RCVBNKCO'].ljust(11) + str(records[i]['OCCAMT']).ljust(11)   \
                       + records[i]['PYRACC'].ljust(30)   + records[i]['PYEACC'].ljust(34)        \
                       + bcstat['BCSTAT']
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    #=====06 退汇来帐====
    elif TradeContext.TRCCO == '06':
        AfaLoggerFunc.tradeInfo('>>>退汇来账清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND BRSFLG = '"  + PL_BRSFLG_RCV + "'"
        sql = sql + " AND TRCCO  = '2000004' "

        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_trcbka.selectm(1,0,sql,ordersql)
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "退汇来帐清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号 业务种类 报单序号   报单日期 发起行行号 接收行行号 金额      付款人账号          "
        filecontext = filecontext + "收款人账号          业务状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====通过报单序号和日期取状态====
            bcstat      = {}
            bcstat_dict = {'BJEDTE':records[i]['BJEDTE'],'BSPSQN':records[i]['BSPSQN']}
            bcstat     = rccpsDBTrcc_spbsta.selectu(bcstat_dict)
            if bcstat == None:
                return AfaFlowControl.ExitThisFlow('S999','数据库操作失败')
            if len(bcstat) <= 0:
                return AfaFlowControl.ExitThisFlow('S999','通过报单序号取业务状态失败')
                 
            #=====写文件====
            filecontext=str(i+1).ljust(4) +  records[i]['TRCCO'].ljust(10) + records[i]['BSPSQN'].ljust(13) \
                       + records[i]['BJEDTE'].ljust(9)    + records[i]['SNDBNKCO'].ljust(11)      \
                       + records[i]['RCVBNKCO'].ljust(11) + str(records[i]['OCCAMT']).ljust(11)   \
                       + records[i]['PYRACC'].ljust(30)   + records[i]['PYEACC'].ljust(34)        \
                       + bcstat['BCSTAT'] 
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    #=====07 汇兑查询书====
    elif TradeContext.TRCCO == '07':
        AfaLoggerFunc.tradeInfo('>>>汇兑查询书清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND TRCCO IN ('9900511','9900522') "

        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_hdcbka.selectm(1,0,sql,ordersql)
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "汇兑查询书清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号  查询书号   查询日期  往来标志  发起行行号  接收行行号 状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====写文件====
            filecontext=str(i+1).ljust(4) + records[i]['BSPSQN'].ljust(13) \
                       + records[i]['BJEDTE'].ljust(13)    + records[i]['BRSFLG'].ljust(8)      \
                       + records[i]['SNDBNKCO'].ljust(12) + records[i]['RCVBNKCO'].ljust(13)    \
                       + records[i]['ISDEAL'] 
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    #=====08 汇兑查复书====
    elif TradeContext.TRCCO == '08':
        AfaLoggerFunc.tradeInfo('>>>汇兑查复书清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND TRCCO IN ('9900512','9900523') "

        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_hdcbka.selectm(1,0,sql,ordersql)
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "汇兑查复书清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号  查询书号   查询日期  往来标志  发起行行号  接收行行号 状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====写文件====
            filecontext=str(i+1).ljust(4) + records[i]['BSPSQN'].ljust(13) \
                       + records[i]['BJEDTE'].ljust(9)    + records[i]['BRSFLG'].ljust(10)      \
                       + records[i]['SNDBNKCO'].ljust(11) + records[i]['RCVBNKCO'].ljust(11)    \
                       + records[i]['ISDEAL'] 
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    #=====09 票据查询书====
    elif TradeContext.TRCCO == '09':
        AfaLoggerFunc.tradeInfo('>>>票据查询书清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND TRCCO  = '9900520' "

        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_pjcbka.selectm(1,0,sql,ordersql)
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "票据查询书清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号  查询书号   查询日期  往来标志  发起行行号  接收行行号 状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====写文件====
            filecontext=str(i+1).ljust(4) + records[i]['BSPSQN'].ljust(13) \
                       + records[i]['BJEDTE'].ljust(9)    + records[i]['BRSFLG'].ljust(10)      \
                       + records[i]['SNDBNKCO'].ljust(11) + records[i]['RCVBNKCO'].ljust(11)    \
                       + records[i]['ISDEAL'] 
            f.write(filecontext+"\n")
        

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    #=====10 票据查复书====
    elif TradeContext.TRCCO == '10':
        AfaLoggerFunc.tradeInfo('>>>票据查复书清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND TRCCO  = '9900521' "

        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_pjcbka.selectm(1,0,sql,ordersql)
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "票据查复书清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号  查询书号   查询日期  往来标志  发起行行号  接收行行号 状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====写文件====
            filecontext=str(i+1).ljust(4) + records[i]['BSPSQN'].ljust(13) \
                       + records[i]['BJEDTE'].ljust(9)    + records[i]['BRSFLG'].ljust(10)      \
                       + records[i]['SNDBNKCO'].ljust(11) + records[i]['RCVBNKCO'].ljust(11)    \
                       + records[i]['ISDEAL'] 
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    #=====11 汇票查询书====
    elif TradeContext.TRCCO == '11':
        AfaLoggerFunc.tradeInfo('>>>汇票查询书清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND TRCCO  = '9900526' "

        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_hpcbka.selectm(1,0,sql,ordersql)
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "汇票查询书清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号  查询书号    出票日期   汇票号码  出票金额  往来标志  发起行行号  接收行行号 状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====写文件====
            filecontext=str(i+1).ljust(4) + records[i]['BSPSQN'].ljust(15) \
                       + records[i]['BILDAT'].ljust(9)    + records[i]['BILNO'].ljust(11)  \
                       + str(records[i]['BILAMT']).ljust(15) + records[i]['BRSFLG'].ljust(6)      \
                       + records[i]['SNDBNKCO'].ljust(11) + records[i]['RCVBNKCO'].ljust(13)    \
                       + records[i]['ISDEAL'] 
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    #=====12 汇票查复书====
    elif TradeContext.TRCCO == '12':
        AfaLoggerFunc.tradeInfo('>>>汇票查复书清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND TRCCO  = '9900527' "

        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_hpcbka.selectm(1,0,sql,ordersql)
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "汇票查复书清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号  查询书号   查询日期  往来标志  发起行行号  接收行行号 状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====写文件====
            filecontext=str(i+1).ljust(4) + records[i]['BSPSQN'].ljust(13) \
                       + records[i]['BJEDTE'].ljust(9)    + records[i]['BRSFLG'].ljust(10)      \
                       + records[i]['SNDBNKCO'].ljust(11) + records[i]['RCVBNKCO'].ljust(11)    \
                       + records[i]['ISDEAL'] 
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    #=====13 自由格式书====
    elif TradeContext.TRCCO == '13':
        AfaLoggerFunc.tradeInfo('>>>自由格式书清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND TRCCO IN ('9900513','9900524') "

        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_hdcbka.selectm(1,0,sql,ordersql)
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )

        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "自由格式书清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号 业务种类 报 单 序 号 报单日期  发起行行号 接收行行号 往来标志 状态\n"
        filecontext = filecontext + "=================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====写文件====
            filecontext=str(i+1).ljust(4) +  records[i]['TRCCO'].ljust(10) + records[i]['BSPSQN'].ljust(13) \
                       + records[i]['BJEDTE'].ljust(9)    + records[i]['SNDBNKCO'].ljust(11)      \
                       + records[i]['RCVBNKCO'].ljust(11) + records[i]['BRSFLG'].ljust(10)   \
                       + records[i]['ISDEAL']
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    
    #=====15 通存通兑往账====
    elif(TradeContext.TRCCO == '15'):
        AfaLoggerFunc.tradeInfo('>>>通存通兑往账清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND BRSFLG =  '" + PL_BRSFLG_SND       + "'"
        
        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_wtrbka.selectm(1,0,sql,ordersql)
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )
            
        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "通存通兑往账清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号 报单日期  报单序号      接收行行号  交易代码 收款人账号               付款人账号              金额           手续费         状态\n"
        filecontext = filecontext + "================================================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====查询此笔交易的当前状态====
            where_dict = {}
            where_dict = {'BJEDTE':records[i]['BJEDTE'],'BSPSQN':records[i]['BSPSQN']}
            spb_dict = rccpsDBTrcc_spbsta.selectu(where_dict)
            if(spb_dict == None):
                return AfaFlowControl.ExitThisFlow('S999','查询业务的当前状态失败')
            
            elif(len(spb_dict) == 0):
                return AfaFlowControl.ExitThisFlow('S999','查询业务的当前状态结果为空')
                
            else:
                AfaLoggerFunc.tradeInfo("查询业务的当前状态成功")
            
            #=====写文件====
            filecontext=str(i+1).ljust(6) +  records[i]['BJEDTE'].ljust(10) + records[i]['BSPSQN'].ljust(14) \
                       + records[i]['RCVBNKCO'].ljust(12)    + records[i]['TRCCO'].ljust(10)      \
                       + records[i]['PYEACC'].ljust(26) + records[i]['PYRACC'].ljust(25)   \
                       + str(records[i]['OCCAMT']).ljust(15) + str(records[i]['CUSCHRG']).ljust(15) + spb_dict['BCSTAT'].ljust(2)
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
        
    #=====14 通存通兑来账====
    elif(TradeContext.TRCCO == '14'):
        AfaLoggerFunc.tradeInfo('>>>通存通兑往账清单打印操作')
        
        #=====组织查询语句====
        sql = "BJEDTE >= '" + TradeContext.STRDAT + "'"
        sql = sql + " AND BJEDTE <= '" + TradeContext.ENDDAT + "'"
        sql = sql + " AND BESBNO =  '" + TradeContext.BESBNO + "'"
        sql = sql + " AND BRSFLG =  '" + PL_BRSFLG_RCV       + "'"
        
        #=====多笔查询====
        ordersql = "ORDER BY TRCCO ASC"
        records = rccpsDBTrcc_wtrbka.selectm(1,0,sql,ordersql)
        if records == None:
            return AfaFlowControl.ExitThisFlow('A099','数据库操作失败' )
        if len(records) == 0:
            return AfaFlowControl.ExitThisFlow('A099','无满足条件记录' )
            
        #=====开始组织返回文件====
        filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode
        try:
            fpath=os.environ["AFAP_HOME"]+"/tmp/"
            f=open(fpath+filename,"w")
        except IOError:
            return AfaFlowControl.ExitThisFlow('S999','打开文件失败') 

        #=====写文件头====
        filecontext = "\n\n\n"
        filecontext = filecontext + "                                                  " + TradeContext.BESBNM + "通存通兑来账清单\n" 
        filecontext = filecontext + "起止日期:" + TradeContext.STRDAT + "~" + TradeContext.ENDDAT + "\n"
        filecontext = filecontext + "序号 报单日期  报单序号      接收行行号  交易代码 收款人账号               付款人账号              金额           手续费         状态\n"
        filecontext = filecontext + "================================================================================================================================================\n"
        f.write(filecontext+"\n")

        #=====循环组织文件数据====
        for i in range(0,len(records)):
            #=====查询此笔交易的当前状态====
            where_dict = {}
            where_dict = {'BJEDTE':records[i]['BJEDTE'],'BSPSQN':records[i]['BSPSQN']}
            spb_dict = rccpsDBTrcc_spbsta.selectu(where_dict)
            if(spb_dict == None):
                return AfaFlowControl.ExitThisFlow('S999','查询业务的当前状态失败')
            
            elif(len(spb_dict) == 0):
                return AfaFlowControl.ExitThisFlow('S999','查询业务的当前状态结果为空')
                
            else:
                AfaLoggerFunc.tradeInfo("查询业务的当前状态成功")
            
            #=====写文件====
            filecontext=str(i+1).ljust(6) +  records[i]['BJEDTE'].ljust(10) + records[i]['BSPSQN'].ljust(14) \
                       + records[i]['RCVBNKCO'].ljust(12)    + records[i]['TRCCO'].ljust(10)      \
                       + records[i]['PYEACC'].ljust(26) + records[i]['PYRACC'].ljust(25)   \
                       + str(records[i]['OCCAMT']).ljust(15) + str(records[i]['CUSCHRG']).ljust(15) + spb_dict['BCSTAT'].ljust(2)
            f.write(filecontext+"\n")

        #=====添加打印日期等====       
        filecontext = "-----------------------------------------------------------------------------------------------------------------\n"
        filecontext = filecontext +  "    打印日期:" + TradeContext.BJEDTE + "                           授权:           记账:  \n"
        f.write(filecontext)

        f.close()
        AfaLoggerFunc.tradeInfo(">>>生成文件结束")
    
    else:
        return AfaFlowControl.ExitThisFlow('S999','业务类型错')

    TradeContext.errorCode = '0000'
    TradeContext.errorMsg  = '成功'
    TradeContext.PRTDAT    = TradeContext.BJEDTE        #打印日期
    TradeContext.PBDAFILE  = filename                   #文件名
    
    AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易[TRC001_8535]退出***' )
    return True
Esempio n. 7
0
def SubModuleDoFst():
    #time.sleep(60)
        
    AfaLoggerFunc.tradeInfo("农信银系统:来账.中心类操作(1.本地操作).柜台冲销来账接收[TRCC006_1145]进入")
    
    #=====判断是否为重复交易====
    AfaLoggerFunc.tradeInfo(">>>判断是否为重复交易")

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        ret = rccpsDBTrcc_mpcbka.update(mpcbka_dict,mpcbka_where)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                rccpsHostFunc.CommHost( TradeContext.HostCode ) 

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

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

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

                res = rccpsState.setTransState(sstlog_dict)

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

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

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

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

    AfaLoggerFunc.tradeInfo("农信银系统:来账.中心类操作(1.本地操作).柜台冲销来账接收[TRCC006_1145]退出")
    
    return True
Esempio n. 8
0
def SubModuleDoFst():
    AfaLoggerFunc.tradeInfo("农信银系统:来账.中心类操作(1.本地操作).柜台冲正来账接收[TRCC006_1144]进入")
    AfaLoggerFunc.tradeDebug(">>>BJEDTE==" + TradeContext.BJEDTE)
    AfaLoggerFunc.tradeDebug(">>>BSPSQN==" + TradeContext.BSPSQN)
    #=====判断是否为重复交易====
    AfaLoggerFunc.tradeInfo(">>>判断是否为重复交易")
    
    where_dict = {}
    where_dict = {'MSGFLGNO':TradeContext.MSGFLGNO}

    record = rccpsDBTrcc_atcbka.selectu(where_dict)
    if( record == None ):
        AfaLoggerFunc.tradeDebug(">>>查找冲正登记簿异常,抛弃报文,等待中心重新发送自动冲正报文")
        return AfaFlowControl.ExitThisFlow('A099',"查找冲正登记簿异常,抛弃报文,等待中心重新发送自动冲正报文")    
    elif( len(record) > 0 ):    #重复交易
        AfaLoggerFunc.tradeDebug(">>>自动冲正交易重复") 
        #=====为返回自动冲正成功发送成功回执====
        #TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
        #TradeContext.PRCCO    = 'RCCI0000'               #中心返回码
        #TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
        #TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
        #TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
        #TradeContext.STRINFO  = '自动冲正交易重复'       #附言
        #
        #return True        
        TradeContext.BJEDTE = record['BJEDTE']
        TradeContext.BSPSQN = record['BSPSQN']
    else:       
        #TradeContext.OR_BJEDTE = TradeContext.BJEDTE #为下面更新atcbka表时的字典赋值
        #TradeContext.OR_BSPSQN = TradeContext.BSPSQN #为下面更新atcbka表时的字典赋值      
        #=====开始登记自动冲正登记簿====
        AfaLoggerFunc.tradeDebug(">>>登记自动冲正登记簿")
        
        atcbka_dict = {}
        if not rccpsMap1144CTradeContext2Datcbka_dict.map(atcbka_dict):
            AfaLoggerFunc.tradeDebug(">>>自动冲正登记簿字典赋值失败,抛弃报文,等待自动冲正报文下次来得")
            return AfaFlowControl.ExitThisFlow('A099',"自动冲正登记簿字典赋值失败")     
            
        res = rccpsDBTrcc_atcbka.insertCmt(atcbka_dict)      
        if( res == -1):
            AfaLoggerFunc.tradeDebug(">>>自动冲正登记簿插入数据失败,数据库会滚,抛弃报文")
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow('A099',"冲正登记簿插入数据失败") 
        else:
            AfaDBFunc.CommitSql()
    
    #=====判断中心日期是否相同====
    if TradeContext.NCCWKDAT != TradeContext.NCCworkDate:
        AfaLoggerFunc.tradeDebug(">>>查找原交易失败,未收到原交易,直接回复成功报文")
         
        #=====为返回自动冲正成功发送成功回执====
        TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
        TradeContext.PRCCO    = 'RCCI0006'               #中心返回码
        TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
        TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
        TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
        TradeContext.STRINFO  = '冲正日期不合法'         #附言
        
        return True        
            
    #=====判断原交易代码====
    if TradeContext.ORTRCCO == '3000504':
        #=====3000504 柜台冲销报文====
        AfaLoggerFunc.tradeDebug('>>>查找原冲销业务是否存在')

        mpcbka_where = {'MSGFLGNO':TradeContext.ORMFN}
        record = rccpsDBTrcc_mpcbka.selectu(mpcbka_where)

        if record == None:
            AfaLoggerFunc.tradeDebug('>>>查找原冲销业务异常,抛弃报文,等待中心再次发生自动冲正')
            return AfaFlowControl.ExitThisFlow('S999','抛弃报文')
            
        elif len(record) <= 0:
            AfaLoggerFunc.tradeDebug('>>>查找原冲销业务空,回复成功')
            #=====为返回冲正成功发送成功回执====
            TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
            TradeContext.PRCCO    = 'RCCI0000'               #中心返回码
            TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
            TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
            TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
            TradeContext.STRINFO  = '原冲销业务已冲正成功'       #附言
        
            return True        
            #return AfaFlowControl.ExitThisFlow('S999','抛弃报文')
        else:
            AfaLoggerFunc.tradeDebug('>>>查找冲销业务成功')
            
        #=====将原报单序号 原交易日期更新到冲正登记簿中====
        AfaLoggerFunc.tradeInfo('>>>更新原报单序号\原交易日期')
        
        atcbka_where={}
        atcbka_where['BJEDTE'] = TradeContext.BJEDTE      #交易日期
        atcbka_where['BSPSQN'] = TradeContext.BSPSQN      #报单序号
        
        atcbka_dict ={}
        atcbka_dict['BOJEDT']  = record['BJEDTE']    #原交易日期
        atcbka_dict['BOSPSQ']  = record['BSPSQN']    #原报单序号
        atcbka_dict['STRINFO'] = TradeContext.STRINFO     #附言 
        atcbka_dict['ORTRCDAT']= record['TRCDAT']    #原委托日期
        atcbka_dict['BESBNO']  = record['BESBNO']    #原机构号
        atcbka_dict['OPRNO']   = PL_TDOPRNO_CZ            #业务类型

        ret = rccpsDBTrcc_atcbka.update(atcbka_dict,atcbka_where)
        AfaLoggerFunc.tradeDebug('>>>ret=='+str(ret))
        if ret <= 0:
            AfaDBFunc.RollbackSql( )
            return AfaFlowControl.ExitThisFlow('S999', "更新自动冲正登记簿原报单序号和原交易日期异常,抛弃报文")
        else:
            AfaDBFunc.CommitSql( )
        
        AfaLoggerFunc.tradeInfo(">>>结束更新冲销登记簿原交易日期和原报单序号")

        #=====通过冲销登记簿查找原业务====
        AfaLoggerFunc.tradeDebug('>>>通过冲销登记簿中原报单序号和原交易日期查询原业务')

        wtr_where = {'BJEDTE':record['BOJEDT'],'BSPSQN':record['BOSPSQ']}
        wtr_dict = rccpsDBTrcc_wtrbka.selectu(wtr_where)

        if wtr_dict == None:
            AfaLoggerFunc.tradeDebug('>>>通过冲销登记簿中原报单序号和原交易日期查询原交易异常,抛弃报文,等待中心再次发生自动冲正')
            return AfaFlowControl.ExitThisFlow('S999','抛弃报文')
        elif len(wtr_dict) <= 0:
            AfaLoggerFunc.tradeDebug('>>>通过冲销登记簿中原报单序号和原交易日期查询原交易败,抛弃报文,等待中心再次发生自动冲正')
            return AfaFlowControl.ExitThisFlow('S999','抛弃报文')
        else:
            AfaLoggerFunc.tradeDebug('>>>查找原业务成功')

        #=====取原业务的业务状态====
        AfaLoggerFunc.tradeDebug('>>>取原业务业务状态')

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

        if spb_dict == None:
            AfaLoggerFunc.tradeDebug('>>>取原业务业务状态异常,抛弃报文,等待中心再次发生自动冲正')
            return AfaFlowControl.ExitThisFlow('S999','抛弃报文')
        elif len(spb_dict) <= 0:
            AfaLoggerFunc.tradeDebug('>>>取原业务业务状态失败,抛弃报文,等待中心再次发生自动冲正')
            return AfaFlowControl.ExitThisFlow('S999','抛弃报文')
        else:
            AfaLoggerFunc.tradeDebug('>>>取原业务业务状态成功')

        #关彬捷  20081226  新增查询交易当前状态详细信息
        #查询交易当前状态详细信息
        sstlog_where = {'BJEDTE':wtr_dict['BJEDTE'],'BSPSQN':wtr_dict['BSPSQN'],'BCURSQ':spb_dict['BCURSQ']}
        spb_dict = rccpsDBTrcc_sstlog.selectu(sstlog_where)
        
        if( spb_dict == None ):
            return AfaFlowControl.ExitThisFlow('S999','取原业务业务状态详细信息异常,抛弃报文,等待中心再次发生自动冲正')
        elif len(spb_dict) <= 0:
            return AfaFlowControl.ExitThisFlow('S999','取原业务业务状态详细信息失败,抛弃报文,等待中心再次发生自动冲正')
        else:
            AfaLoggerFunc.tradeDebug('>>>取原业务业务状态详细信息成功')
            
        
        #关彬捷  20081226  新增若交易当前状态为自动扣款,自动入账,冲销,冲正处理中状态,则直接拒绝此冲销
        if (spb_dict['BCSTAT'] == PL_BCSTAT_AUTO or spb_dict['BCSTAT'] == PL_BCSTAT_AUTOPAY or spb_dict['BCSTAT'] == PL_BCSTAT_CANC or spb_dict['BCSTAT'] == PL_BCSTAT_CANCEL) and  spb_dict['BDWFLG'] == PL_BDWFLG_WAIT:
            return AfaFlowControl.ExitThisFlow('S999','原业务账务状态未知,抛弃报文,等待中心再次发起自动冲正')
            
        #关彬捷  20081226  新增若交易当前状态为自动扣款,自动入账,冲销,冲正失败状态,则调用8816查询账务状态
        if (spb_dict['BCSTAT'] == PL_BCSTAT_AUTO or spb_dict['BCSTAT'] == PL_BCSTAT_AUTOPAY or spb_dict['BCSTAT'] == PL_BCSTAT_CANC or spb_dict['BCSTAT'] == PL_BCSTAT_CANCEL) and  spb_dict['BDWFLG'] == PL_BDWFLG_FAIL:
            AfaLoggerFunc.tradeDebug('>>>调用8816查找该业务[' + wtr_dict['BSPSQN'] + ']状态')

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

        #=====判断原业务业务状态====
        #=====PL_BCSTAT_CANC 冲销====
        if not (spb_dict['BCSTAT'] == PL_BCSTAT_CANC and spb_dict['BDWFLG'] == PL_BDWFLG_SUCC):
            #=====原业务未冲销,直接回复成功即可====
            AfaLoggerFunc.tradeDebug(">>>原交易未冲销成功,回复成功")
         
            #=====为返回冲销成功发送成功回执====
            TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
            TradeContext.PRCCO    = 'RCCI0000'               #中心返回码
            TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
            TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
            TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
            TradeContext.STRINFO  = '原冲销业务已冲正成功'   #附言
        
            return True
        elif spb_dict['TRDT'] == '' and spb_dict['TLSQ'] == '':
            #=====原业务冲销成功,但未抹账,回滚冲销前状态,回复冲正成功====
            AfaLoggerFunc.tradeDebug(">>>原业务冲销成功,但未抹账,回滚冲销前状态,回复冲正成功")
            
            #回滚原被冲销交易状态为冲销前状态
            AfaLoggerFunc.tradeInfo(">>>开始回滚原被冲销交易状态为冲销前状态")
            
            spbsta_dict = {}
            if not rccpsState.getTransStateDes(spb_dict['BJEDTE'],spb_dict['BSPSQN'],spbsta_dict,1):
                return AfaFlowControl.ExitThisFlow('S999','查询原被冲销交易冲销前状态异常')
            
            if not rccpsState.newTransState(spbsta_dict['BJEDTE'],spbsta_dict['BSPSQN'],spbsta_dict['BCSTAT'],spbsta_dict['BDWFLG']):
                return AfaFlowControl.ExitThisFlow('S999','回滚状态为冲销前状态异常')
            else:
                AfaDBFunc.CommitSql()
                
            sstlog_dict = {}
            sstlog_dict['BJEDTE']    =  spbsta_dict['BJEDTE']
            sstlog_dict['BSPSQN']    =  spbsta_dict['BSPSQN']
            sstlog_dict['BCSTAT']    =  spbsta_dict['BCSTAT']
            sstlog_dict['BDWFLG']    =  spbsta_dict['BDWFLG']
            sstlog_dict['NOTE3']     =  '冲销交易被冲正,回滚为冲销前状态'
            if spbsta_dict.has_key('FEDT'):           #前置日期
                sstlog_dict['FEDT']  =  spbsta_dict['FEDT']
            if spbsta_dict.has_key('RBSQ'):           #前置流水号
                sstlog_dict['RBSQ']  =  spbsta_dict['RBSQ']
            if spbsta_dict.has_key('TRDT'):           #主机日期
                sstlog_dict['TRDT']  =  spbsta_dict['TRDT']
            if spbsta_dict.has_key('TLSQ'):           #主机流水号
                sstlog_dict['TLSQ']  =  spbsta_dict['TLSQ']
            sstlog_dict['MGID']      =  spbsta_dict['MGID'] #主机返回码
            sstlog_dict['STRINFO']   =  spbsta_dict['STRINFO']  #主机返回信息
            
            if not rccpsState.setTransState(sstlog_dict):
                return AfaFlowControl.ExitThisFlow('S999','回滚状态为冲正前状态详细信息异常')
            else:
                AfaDBFunc.CommitSql()
                
            AfaLoggerFunc.tradeInfo(">>>结束回滚原被冲销交易状态为冲销前状态")
         
            #=====为返回冲销成功发送成功回执====
            TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
            TradeContext.PRCCO    = 'RCCI0000'               #中心返回码
            TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
            TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
            TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
            TradeContext.STRINFO  = '原冲销业务已冲正成功'   #附言
            
            return True
        else:
            AfaLoggerFunc.tradeDebug('>>>准备调用8813再次记账')

        #=====记账前赋值操作====
        AfaLoggerFunc.tradeDebug('>>>记账前赋值操作')

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

        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.HostCode  =  '8813'                       #主机交易码
        TradeContext.PYRACC    =  wtr_dict['PYRACC']           #付款人账户
        TradeContext.PYRNAM    =  wtr_dict['PYRNAM']           #付款人名称
        TradeContext.OCCAMT    =  str(wtr_dict['OCCAMT'])      #金额
        TradeContext.CUSCHRG   =  str(wtr_dict['CUSCHRG'])     #手续费金额
        TradeContext.BANKNO    =  wtr_dict['BNKBKNO']          #存折号码
        
        if wtr_dict['TRCCO'] in ('3000002','3000004'):
            #=====通存====
            AfaLoggerFunc.tradeDebug('>>>通存')

            TradeContext.RCCSMCD  =  PL_RCCSMCD_XJTCLZ                       #摘要代码  PL_RCCSMCD_XJTCLZ  通存来账
            TradeContext.SBAC     = TradeContext.BESBNO + PL_ACC_NXYDQSLZ    #借方账户:农信银待清算来账
            TradeContext.SBNM     = "农信银待清算来账"
            TradeContext.RBAC     = wtr_dict['PYEACC']                       #贷方账户:收款人账户
            TradeContext.RBNM     = wtr_dict['PYENAM']                       #贷方户名:收款人户名
            TradeContext.OCCAMT = str(wtr_dict['OCCAMT'])
            #=====add by pgt 12-4====
            TradeContext.CTFG      = '7'                                    #本金 手续费标识  7 本金 8手续费 9 本金+手续费 
            TradeContext.PKFG      = 'T'                                    #通存通兑标识                                   
            TradeContext.SBAC = rccpsHostFunc.CrtAcc(TradeContext.SBAC, 25)
        elif wtr_dict['TRCCO'] in ('3000102','3000104'):
            #=====通兑====
            AfaLoggerFunc.tradeDebug('>>>通兑')

            if float(wtr_dict['CUSCHRG']) <= 0:
                #=====对方现金收取手续费或不收费====
                AfaLoggerFunc.tradeDebug('>>>现金收取手续费')
 
                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.RBNM = '农信银待清算来账'                        #贷方户名
                #=====add by pgt 12-4====
                TradeContext.CTFG      = '7'                                  #本金 手续费标识  7 本金 8手续费 9 本金+手续费 
                TradeContext.PKFG      = 'T'                                  #通存通兑标识                                   

                if wtr_dict['TRCCO'] == '3000104':
                    TradeContext.WARNTNO = '49' + TradeContext.BANKNO
                else:
                    TradeContext.WARNTNO = TradeContext.SBAC[6:18]
            else:
                #=====对方转账收取手续费====
                AfaLoggerFunc.tradeDebug('>>>转账收取手续费')

                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.CTFG  = '7'                                            #本金 手续费标识  7 本金 8手续费 9 本金+手续费 
                TradeContext.PKFG  = 'T'                                            #通存通兑标识                                   

                AfaLoggerFunc.tradeInfo( '>>>交易金额:借方账号' + TradeContext.SBAC )
                AfaLoggerFunc.tradeInfo( '>>>交易金额:贷方账号' + TradeContext.RBAC )

                #=========结算手续费收入户===========
                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.CUSCHRG)                      #发生额
                TradeContext.I2CTFG  = '8'                                             #本金 手续费标识  7 本金 8手续费 9 本金+手续费 
                TradeContext.I2PKFG  = 'T'                                             #通存通兑标识                                   

                AfaLoggerFunc.tradeInfo( '>>>结算手续费收入户:借方账号' + TradeContext.I2SBAC )
                AfaLoggerFunc.tradeInfo( '>>>结算手续费收入户:贷方账号' + TradeContext.I2RBAC )

                #=========交易金额+手续费===================
                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'                                              #通存通兑标识                                   

                #=====凭证号码====
                if wtr_dict['TRCCO'] ==  '3000102':
                    #=====卡====
                    TradeContext.WARNTNO = TradeContext.SBAC[6:18]
                    TradeContext.I2WARNTNO = TradeContext.I2SBAC[6:18]
                else:
                    #=====折====
                    TradeContext.WARNTNO   = '49' + TradeContext.BANKNO
                    TradeContext.I2WARNTNO = '49' + TradeContext.BANKNO
        elif wtr_dict['TRCCO'] in ('3000003','3000005'):
            #=====本转异====
            AfaLoggerFunc.tradeDebug('>>>本转异')

            TradeContext.RCCSMCD  =  PL_RCCSMCD_XJTCLZ                       #摘要代码  PL_RCCSMCD_XJTCLZ  通存来账
            TradeContext.SBAC     = TradeContext.BESBNO + PL_ACC_NXYDQSLZ    #借方账户:农信银待清算来账
            TradeContext.SBNM     = "农信银待清算来账"
            TradeContext.RBAC     = wtr_dict['PYEACC']                       #贷方账户:收款人账户
            TradeContext.RBNM     = wtr_dict['PYENAM']                       #贷方户名:收款人户名
            TradeContext.OCCAMT = str(wtr_dict['OCCAMT'])
            #=====add by pgt 12-4====
            TradeContext.CTFG      = '7'                                    #本金 手续费标识  7 本金 8手续费 9 本金+手续费 
            TradeContext.PKFG      = 'T'                                    #通存通兑标识
            TradeContext.SBAC = rccpsHostFunc.CrtAcc(TradeContext.SBAC, 25)
        elif wtr_dict['TRCCO'] in ('3000103','3000105'):
            #=====异转本====
            AfaLoggerFunc.tradeDebug('>>>异转本')

            if( float(TradeContext.CUSCHRG) <= 0 ):
                #=====现金====
                AfaLoggerFunc.tradeDebug('>>>现金收取手续费')

                TradeContext.RCCSMCD  = PL_RCCSMCD_YZBWZ#主机摘要代码
                TradeContext.SBAC = TradeContext.PYRACC                       #借方账户:付款人账户
                TradeContext.ACNM = TradeContext.PYRNAM                       #借方户名 付款人户名
                TradeContext.RBAC = TradeContext.BESBNO + PL_ACC_NXYDQSLZ     #贷方账户:农信银待清算来账
                TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC, 25)
                TradeContext.RBNM = '农信银待清算来账'                        #贷方户名:
                TradeContext.CTFG =  '7'                                      #本金 手续费标识  7 本金 8手续费 9 本金+手续费 
                TradeContext.PKFG =  'T'                                      #通存通兑标识                                   

                if wtr_dict['TRCCO'] == '3000103':
                    TradeContext.WARNTNO = TradeContext.SBAC[6:18]
                else:
                    TradeContext.WARNTNO = '49' + TradeContext.BANKNO

                AfaLoggerFunc.tradeDebug( '>>>借方账号:' + TradeContext.SBAC )
                AfaLoggerFunc.tradeDebug( '>>>贷方账号:' + TradeContext.RBAC )
                AfaLoggerFunc.tradeDebug( '>>>凭证号码:' + TradeContext.WARNTNO )
            else:
                #=====转账=====
                AfaLoggerFunc.tradeDebug('>>>转账收取手续费')

                TradeContext.ACUR    =  '3'                                           #记账次数
                #=========交易金额============
                TradeContext.RCCSMCD  =  PL_RCCSMCD_YZBWZ                               #摘要代码
                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.OCCAMT)                       #发生额
                TradeContext.CTFG  = '7'                                            #本金 手续费标识  7 本金 8手续费 9 本金+手续费 
                TradeContext.PKFG  = 'T'                                            #通存通兑标识                                   

                AfaLoggerFunc.tradeDebug( '>>>交易金额:借方账号' + TradeContext.SBAC )
                AfaLoggerFunc.tradeDebug( '>>>交易金额:贷方账号' + TradeContext.RBAC )

                #=========结算手续费收入户===========
                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.CUSCHRG)                      #发生额
                TradeContext.I2CTFG  = '8'                                            #本金 手续费标识  7 本金 8手续费 9 本金+手续费 
                TradeContext.I2PKFG  = 'T'                                            #通存通兑标识                                    

                AfaLoggerFunc.tradeDebug( '>>>结算手续费收入户:借方账号' + TradeContext.I2SBAC )
                AfaLoggerFunc.tradeDebug( '>>>结算手续费收入户:贷方账号' + TradeContext.I2RBAC )

                #=========交易金额+手续费===================
                TradeContext.I3SMCD    =  PL_RCCSMCD_YZBWZ                               #摘要代码
                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.tradeDebug( '>>>交易金额+手续费:借方账号' + TradeContext.I3SBAC )
                AfaLoggerFunc.tradeDebug( '>>>交易金额+手续费:贷方账号' + TradeContext.I3RBAC )

                if wtr_dict['TRCCO'] == '3000103':
                    TradeContext.WARNTNO   = TradeContext.SBAC[6:18]
                    TradeContext.I2WARNTNO = TradeContext.I2SBAC[6:18]
                else:
                    TradeContext.WARNTNO   = '49' + TradeContext.BANKNO
                    TradeContext.I2WARNTNO = '49' + TradeContext.BANKNO
        else:
            AfaLoggerFunc.tradeInfo('>>>原交易码错误')
            return AfaFlowControl.ExitThisFlow('S999','抛弃报文')

        #=====新增状态====
        if wtr_dict['TRCCO'] in ('3000002','3000004','3000003','3000005'):
            #=====通存 本转异 状态为:自动入账====
            TradeContext.BCSTAT = PL_BCSTAT_AUTO
        else:
            #=====通兑 异转本 状态为:自动扣款====
            TradeContext.BCSTAT = PL_BCSTAT_AUTOPAY

        #=====开始设置状态====
        #if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,TradeContext.BCSTAT,PL_BDWFLG_WAIT):
        if not rccpsState.newTransState(wtr_dict['BJEDTE'],wtr_dict['BSPSQN'],TradeContext.BCSTAT,PL_BDWFLG_WAIT):
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow('S999','设置业务状态为自动入账/扣款-处理中异常')
        else:
            AfaDBFunc.CommitSql()

        #=====开始与主机进行通讯====
        AfaLoggerFunc.tradeInfo('>>>准备开始与主机通讯')

        rccpsHostFunc.CommHost( TradeContext.HostCode )

        #=====分析主机返回====
        AfaLoggerFunc.tradeInfo('>>>分析主机返回')

        sstlog = {}
        sstlog['BJEDTE']  =  wtr_dict['BJEDTE']
        sstlog['BSPSQN']  =  wtr_dict['BSPSQN']
        sstlog['BCSTAT']  =  TradeContext.BCSTAT
        sstlog['MGID']    =  TradeContext.errorCode

        if TradeContext.errorCode == '0000':
            sstlog['TRDT']  =  TradeContext.TRDT             #主机日期
            sstlog['TLSQ']  =  TradeContext.TLSQ             #主机流水
            sstlog['BDWFLG']=  PL_BDWFLG_SUCC
            sstlog['STRINFO'] = '冲销交易被冲正,补记账务成功'               #附言
        else:
            sstlog['BDWFLG']=  PL_BDWFLG_FAIL
            sstlog['STRINFO'] = TradeContext.errorMsg        #附言
            
        #=====设置状态====
        if not rccpsState.setTransState(sstlog):
            AfaDBFunc.RollbackSql()
            return AfaFlowControl.ExitThisFlow('S999', "设置业务状态异常")
        else:
            AfaDBFunc.CommitSql()

        #=====主机成功后返回正确回执报文====
        AfaLoggerFunc.tradeInfo('>>>发送成功回执')

        TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
        TradeContext.PRCCO    = 'RCCI0000'               #中心返回码
        TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
        TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
        TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
        TradeContext.STRINFO  = '成功'                   #附言

        return True
    elif TradeContext.ORTRCCO == '3000505':
        #=====3000505 补正业务====
        AfaLoggerFunc.tradeDebug('>>>查找原补正业务是否存在')
        
        #关彬捷  20081230  若原业务为补正,直接回复冲正成功应答
        
        AfaLoggerFunc.tradeInfo('>>>发送成功回执')

        TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
        TradeContext.PRCCO    = 'RCCI0000'               #中心返回码
        TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
        TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
        TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
        TradeContext.STRINFO  = '成功'                   #附言
        
        return True
    else:
        #=====冲正原来账/往账正常业务====
     
        #=====查找原交易是否存在====
        AfaLoggerFunc.tradeDebug(">>>查找原交易是否存在")
        
        where_dict = {'MSGFLGNO':TradeContext.ORMFN}
        wtrbka_dict = rccpsDBTrcc_wtrbka.selectu(where_dict)
        
        if( wtrbka_dict == -1 ):
            AfaLoggerFunc.tradeInfo(">>>查找原交易失败,原业务中心流水号["+str(TradeContext.ORTRCNO)+"]")
            return AfaFlowControl.ExitThisFlow('A099',"查找原交易失败,抛弃报文,等待中心自动冲正")
            
        if( len(wtrbka_dict) == 0 ):
            #=====未查找到原交易====
            AfaLoggerFunc.tradeDebug(">>>查找原交易失败,未收到原交易,直接回复成功报文")
         
            #=====为返回冲销成功发送成功回执====
            TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
            TradeContext.PRCCO    = 'RCCI0000'               #中心返回码
            TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
            TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
            TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
            TradeContext.STRINFO  = '成功'                   #附言
        
            return True        
        else:
            #=====查找原交易成功====
            AfaLoggerFunc.tradeInfo(">>>查找原交易成功")
            
            #=====将原报单序号 原交易日期更新到冲销登记簿中====
            AfaLoggerFunc.tradeInfo('>>>更新原报单序号\原交易日期')
            
            atcbka_where={}
            atcbka_where['BSPSQN'] = TradeContext.BSPSQN      #报单序号
            atcbka_where['BJEDTE'] = TradeContext.BJEDTE      #交易日期
            
            atcbka_dict ={}
            atcbka_dict['BOJEDT']  = wtrbka_dict['BJEDTE']    #原交易日期
            atcbka_dict['BOSPSQ']  = wtrbka_dict['BSPSQN']    #原报单序号
            #关彬捷  20081225  更新冲正登记簿中登记机构号为原交易机构号
            atcbka_dict['BESBNO']  = wtrbka_dict['BESBNO']    #原机构号
            atcbka_dict['STRINFO'] = TradeContext.STRINFO     #附言 
            atcbka_dict['ORTRCDAT']= wtrbka_dict['TRCDAT']    #原委托日期
            atcbka_dict['OPRNO']   = PL_TDOPRNO_CZ            #业务类型

            ret = rccpsDBTrcc_atcbka.update(atcbka_dict,atcbka_where)
            
            if ret <= 0:
                AfaDBFunc.RollbackSql( )
                return AfaFlowControl.ExitThisFlow('S999', "更新自动冲正登记簿原报单序号和原交易日期异常,抛弃报文")
            else:
                AfaDBFunc.CommitSql( )
            
            AfaLoggerFunc.tradeInfo(">>>结束更新冲销登记簿原交易日期和原报单序号")
            
            #=====查找原来账业务状态====
            AfaLoggerFunc.tradeInfo(">>>查找原业务状态")
            
            spbsta_where = {'BJEDTE':wtrbka_dict['BJEDTE'],'BSPSQN':wtrbka_dict['BSPSQN']}
            spbsta_dict = rccpsDBTrcc_spbsta.selectu(spbsta_where)
            
            if( spbsta_dict == None ):
                AfaLoggerFunc.tradeDebug(">>>查找原业务状态失败,发送中心失败报文")
            
                #=====为返回冲销成功发送拒绝回执====
                TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
                TradeContext.PRCCO    = 'RCCO1006'               #中心返回码
                TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
                TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
                TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
                TradeContext.STRINFO  = '开户行处理失败'         #附言
            
                return True
                
            #关彬捷  20081226  新增查询交易当前状态详细信息
            #查询交易当前状态详细信息
            sstlog_where = {'BJEDTE':wtrbka_dict['BJEDTE'],'BSPSQN':wtrbka_dict['BSPSQN'],'BCURSQ':spbsta_dict['BCURSQ']}
            spbsta_dict = rccpsDBTrcc_sstlog.selectu(sstlog_where)
            
            if( spbsta_dict == None ):
                AfaLoggerFunc.tradeDebug(">>>查找原业务状态失败,发送中心失败报文")
            
                #=====为返回冲销成功发送拒绝回执====
                TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
                TradeContext.PRCCO    = 'RCCO1006'               #中心返回码
                TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
                TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
                TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
                TradeContext.STRINFO  = '开户行处理失败'         #附言
            
                return True

            
            #关彬捷  20081226  新增若交易当前状态为自动扣款,自动入账,冲销,冲正处理中状态,退出,等待下个冲正报文
            if (spbsta_dict['BCSTAT'] == PL_BCSTAT_AUTO or spbsta_dict['BCSTAT'] == PL_BCSTAT_AUTOPAY or spbsta_dict['BCSTAT'] == PL_BCSTAT_CANC or spbsta_dict['BCSTAT'] == PL_BCSTAT_CANCEL) and  spbsta_dict['BDWFLG'] == PL_BDWFLG_WAIT:
                return AfaFlowControl.ExitThisFlow('S999','原业务账务状态未知,抛弃报文,等待中心再次发起自动冲正')

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

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

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

                    if spbsta_dict['BCSTAT'] not in (PL_BCSTAT_MFERFE,PL_BCSTAT_CANC,PL_BCSTAT_CANCEL):
                        AfaLoggerFunc.tradeDebug('>>>新增原业务状态为自动冲正-成功')
                        if not rccpsState.newTransState(spbsta_dict['BJEDTE'],spbsta_dict['BSPSQN'],PL_BCSTAT_CANCEL,PL_BDWFLG_SUCC):
                            AfaDBFunc.RollbackSql()
                            return AfaFlowControl.ExitThisFlow('S999','设置业务状态为自动冲正-成功异常')
                        else:
                            AfaDBFunc.CommitSql( )
                    else:
                        AfaLoggerFunc.tradeDebug('>>>原业务状态为[拒绝/冲销/冲正],不需要新增状态')
 
                    #=====原交易无需抹账,返回冲正成功应答====
                    TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
                    TradeContext.PRCCO    = 'RCCI0000'               #中心返回码
                    TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
                    TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
                    TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
                    TradeContext.STRINFO  = '原业务冲正成功'         #附言
            
                    return True
                else:
                    #=====新增原业务状态为冲正-处理中====
                    AfaLoggerFunc.tradeDebug('>>>新增原业务状态为自动冲正-处理中')
            
                    #=====直接调用8820冲正原业务====
                    TradeContext.BOSPSQ   = spbsta_dict['BSPSQN']    #原报单序号
                    TradeContext.BOJEDT   = spbsta_dict['BJEDTE']    #原交易日期
                    TradeContext.HostCode = '8820'                   #主机交易码
                    
                    if not rccpsState.newTransState(spbsta_dict['BJEDTE'],spbsta_dict['BSPSQN'],PL_BCSTAT_CANCEL,PL_BDWFLG_WAIT):
                        AfaDBFunc.RollbackSql()
                        return AfaFlowControl.ExitThisFlow('S999','设置业务状态为自动冲正处理中异常')
                    else:
                        AfaDBFunc.CommitSql( )
            
                    #=====向主机发起8820抹账处理==== 
                    AfaLoggerFunc.tradeDebug('>>>向主机发起8820抹账处理')
            
                    rccpsHostFunc.CommHost( TradeContext.HostCode ) 
            
                    #=====判断主机返回====
                    sstlog_dict={}
                    sstlog_dict['BJEDTE']  =  spbsta_dict['BJEDTE']
                    sstlog_dict['BSPSQN']  =  spbsta_dict['BSPSQN']
                    sstlog_dict['BCSTAT']  =  PL_BCSTAT_CANCEL       #冲正
                    sstlog_dict['MGID']    =  TradeContext.errorCode #主机返回码
                    if TradeContext.existVariable('BOJEDT'):           #前置日期
                        sstlog_dict['FEDT'] = TradeContext.BOJEDT
                    if TradeContext.existVariable('BOSPSQ'):           #前置流水号
                        sstlog_dict['RBSQ'] = TradeContext.BOSPSQ
                    if TradeContext.existVariable('TRDT'):           #主机日期
                        sstlog_dict['TRDT'] = TradeContext.TRDT
                    if TradeContext.existVariable('TLSQ'):           #主机流水号
                        sstlog_dict['TLSQ'] = TradeContext.TLSQ
                    
                    #关彬捷  20090219  增加冲销成功的主机错误码判断:SXR0010(此笔交易已被冲正)
                    if TradeContext.errorCode in ('0000','SXR0010'):
                        #=====更改状态====
                        sstlog_dict['BDWFLG']    =  PL_BDWFLG_SUCC       #流转标识 PL_BDWFLG_SUCC 成功
                        sstlog_dict['STRINFO']   =  '来账冲正成功'       #附言
                        TradeContext.PRCCO       =  'RCCI0000'
                        TradeContext.STRINFO     =  '原业务冲正成功'
                    else:
                        sstlog_dict['BDWFLG']    =  PL_BDWFLG_FAIL       #流转标识 PL_BDWFLG_FAIL 失败
                        sstlog_dict['STRINFO']   =  TradeContext.errorMsg  #附言
                        TradeContext.PRCCO       =  'NN1IA999'
                        TradeContext.STRINFO     =  '原业务冲正失败 ' + TradeContext.errorMsg
            
                    #=====修改原业务状态====
                    AfaLoggerFunc.tradeDebug('>>>修改原业务状态')
            
                    res = rccpsState.setTransState(sstlog_dict)
            
                    if( res == False ):
                        AfaDBFunc.RollbackSql()
                        return AfaFlowControl.ExitThisFlow('A099', '更改被冲正的交易状态失败')
                    else:
                        AfaDBFunc.CommitSql( )
                    
                    #关彬捷 20081226  修改如果冲正失败则回滚冲正前状态
                    if TradeContext.errorCode not in ('0000','SXR0010'):
                        #冲正失败,回滚状态为冲正前状态
                        if not rccpsState.newTransState(spbsta_dict['BJEDTE'],spbsta_dict['BSPSQN'],spbsta_dict['BCSTAT'],spbsta_dict['BDWFLG']):
                            AfaDBFunc.RollBackSql()
                            return AfaFlowControl.ExitThisFlow('S999','回滚状态为冲正前状态异常')
                        else:
                            AfaDBFunc.CommitSql()
                            
                        sstlog_dict = {}
                        sstlog_dict['BJEDTE']    =  spbsta_dict['BJEDTE']
                        sstlog_dict['BSPSQN']    =  spbsta_dict['BSPSQN']
                        sstlog_dict['BCSTAT']    =  spbsta_dict['BCSTAT']
                        sstlog_dict['BDWFLG']    =  spbsta_dict['BDWFLG']
                        sstlog_dict['NOTE3']     =  '原业务冲正失败,回滚为冲正前状态'
                        if spbsta_dict.has_key('FEDT'):           #前置日期
                            sstlog_dict['FEDT']  =  spbsta_dict['FEDT']
                        if spbsta_dict.has_key('RBSQ'):           #前置流水号
                            sstlog_dict['RBSQ']  =  spbsta_dict['RBSQ']
                        if spbsta_dict.has_key('TRDT'):           #主机日期
                            sstlog_dict['TRDT']  =  spbsta_dict['TRDT']
                        if spbsta_dict.has_key('TLSQ'):           #主机流水号
                            sstlog_dict['TLSQ']  =  spbsta_dict['TLSQ']
                        sstlog_dict['MGID']      =  spbsta_dict['MGID'] #主机返回码
                        sstlog_dict['STRINFO']   =  spbsta_dict['STRINFO']  #主机返回信息
                        
                        if not rccpsState.setTransState(sstlog_dict):
                            return AfaFlowControl.ExitThisFlow('S999','回滚状态为冲正前状态详细信息异常')
                        else:
                            AfaDBFunc.CommitSql()
                    
                    #=====发送回执====
                    AfaLoggerFunc.tradeDebug('>>>发送成功回执到对方行')
               
                    #=====为返回冲销成功发送成功回执====
                    TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
                    #TradeContext.PRCCO    = 'RCCI0000'               #中心返回码
                    #TradeContext.STRINFO  = '原业务冲正成功'         #附言
                    TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
                    TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
                    TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
                    
                    return True
            else:
                #=====往帐业务====
                AfaLoggerFunc.tradeDebug(">>>往帐业务")
                
                #=====发送回执====
                AfaLoggerFunc.tradeDebug('>>>发送拒绝回执到对方行')
                
                #=====为返回冲销成功发送成功回执====
                TradeContext.MSGTYPCO = 'SET010'                 #报文类代码
                TradeContext.PRCCO    = 'RCCO1006'               #中心返回码
                TradeContext.STRINFO  = '往帐业务只能由受理方冲正'     #附言
                TradeContext.ORMFN    = TradeContext.MSGFLGNO    #参考报文标示号
                TradeContext.SNDSTLBIN= TradeContext.RCVMBRCO    #发送成员行号
                TradeContext.RCVSTLBIN= TradeContext.SNDMBRCO    #接收成员行号
                
    AfaLoggerFunc.tradeInfo("农信银系统:来账.中心类操作(1.本地操作).柜台冲正来账接收[TRCC006_1144]进入")
    
    return True