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
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).折通兑来帐请求报文接收[TRCC006_1140]进入***' ) #初始化返回码 TradeContext.PRCCO = 'RCCI0000' TradeContext.STRINFO = "成功" #判断是否重复报文 AfaLoggerFunc.tradeInfo(">>>开始判断是否重复报文") sel_dict = {'COTRCNO':TradeContext.TRCNO,'COTRCDAT':TradeContext.TRCDAT,'SNDBNKCO':TradeContext.SNDBNKCO} record = rccpsDBTrcc_wtrbka.selectu(sel_dict) if record == None: AfaLoggerFunc.tradeDebug('>>>判断是否重复扣款确认报文,查询通存通兑业务登记簿相同报文异常') TradeContext.PRCCO = "NN1ID999" TradeContext.STRINFO = "数据库其他错误" elif len(record) > 0: AfaLoggerFunc.tradeInfo('通存通兑业务登记簿中存在相同数据,重复报文,返回拒绝应答报文') TradeContext.PRCCO = 'NN1ISO999' TradeContext.STRINFO = "重复报文" AfaLoggerFunc.tradeInfo(">>>结束判断是否重复报文") #登记通存通兑登记簿 AfaLoggerFunc.tradeInfo(">>>开始登记通存通兑业务登记簿") #=====币种转换==== if TradeContext.CUR == 'CNY': TradeContext.CUR = '01' #=====手续费收取方式===== if float(TradeContext.CUSCHRG) > 0.001: TradeContext.CHRGTYP = '1' else: TradeContext.CHRGTYP = '0' #====开始向字典赋值==== if TradeContext.PRCCO == 'RCCI0000': wtrbka_dict = {} if not rccpsMap1140CTradeContext2Dwtrbka_dict.map(wtrbka_dict): AfaLoggerFunc.tradeDebug('>>>字典赋值出错') TradeContext.PRCCO = "NN1ID999" TradeContext.STRINFO = "数据库其他错误" wtrbka_dict['DCFLG'] = PL_DCFLG_DEB #借贷标识 wtrbka_dict['OPRNO'] = PL_TDOPRNO_TD #业务种类 #=====开始插入数据库==== if TradeContext.PRCCO == 'RCCI0000': if not rccpsDBFunc.insTransWtr(wtrbka_dict): AfaLoggerFunc.tradeDebug('>>>登记通存通兑业务登记簿异常') TradeContext.PRCCO = "NN1ID999" TradeContext.STRINFO = "数据库其他错误" if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) TradeContext.PRCCO = "NN1ID999" TradeContext.STRINFO = "数据库其他错误" AfaLoggerFunc.tradeInfo(">>>结束登记通存通兑业务登记簿") #设置业务状态为行内收妥成功 AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为收妥成功") stat_dict = {} stat_dict['BSPSQN'] = TradeContext.BSPSQN stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BCSTAT'] = PL_BCSTAT_BNKRCV stat_dict['BDWFLG'] = PL_BDWFLG_SUCC if TradeContext.PRCCO == 'RCCI0000': if not rccpsState.setTransState(stat_dict): AfaLoggerFunc.tradeDebug('>>>设置业务状态收妥成功异常') TradeContext.PRCCO = "NN1ID999" TradeContext.STRINFO = "数据库其他错误" if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) TradeContext.PRCCO = "NN1ID999" TradeContext.STRINFO = "数据库其他错误" AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为收妥成功") #设置业务状态为自动扣款处理中 AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为自动扣款处理中") if TradeContext.PRCCO == 'RCCI0000': if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_AUTOPAY,PL_BDWFLG_WAIT): AfaLoggerFunc.tradeDebug('>>>设置业务状态为自动扣款处理中异常') TradeContext.PRCCO = "NN1ID999" TradeContext.STRINFO = "数据库其他错误" if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) TradeContext.PRCCO = "NN1ID999" TradeContext.STRINFO = "数据库其他错误" AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为自动扣款处理中") TradeContext.BCSTAT = PL_BCSTAT_AUTOPAY #状态:自动扣款 TradeContext.BCSTATNM = "自动扣款" #进行必要性检查,若校验通过,则返回成功应答报文,若校验未通过,则返回拒绝应答报文 AfaLoggerFunc.tradeInfo(">>>开始必要性检查") #检查冲正登记簿中是否有此笔业务的冲正业务,存在则返回拒绝应答报文,并设置业务状态为冲正处理中 if TradeContext.PRCCO == 'RCCI0000': atcbka_where_dict = {} atcbka_where_dict['ORMFN'] = TradeContext.MSGFLGNO atcbka_dict = rccpsDBTrcc_atcbka.selectu(atcbka_where_dict) if atcbka_dict == None: AfaLoggerFunc.tradeInfo(">>>查询冲正登记簿异常") TradeContext.PRCCO = 'NN1ID999' TradeContext.STRINFO = "查询冲正登记簿异常" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" else: if len(atcbka_dict) <= 0: AfaLoggerFunc.tradeInfo(">>>此交易未被冲正,继续校验") else: AfaLoggerFunc.tradeInfo(">>>此交易已被冲正,返回拒绝应答报文") TradeContext.PRCCO = 'NN1IO307' TradeContext.STRINFO = "此交易已被冲正" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" #解密客户密码 if TradeContext.PRCCO == 'RCCI0000': MIMA = ' ' PIN = TradeContext.CURPIN ACC = TradeContext.PYRACC AfaLoggerFunc.tradeDebug('密码[' + PIN + ']') AfaLoggerFunc.tradeDebug('账号[' + ACC + ']') ret = jiami.secDecryptPin(PIN,ACC,MIMA) if ret != 0: AfaLoggerFunc.tradeDebug("ret=[" + str(ret) + "]") AfaLoggerFunc.tradeDebug('调用加密服务器失败') TradeContext.PRCCO = 'NN1IS999' TradeContext.STRINFO = "解密密码失败" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" else: TradeContext.CURPIN = MIMA AfaLoggerFunc.tradeDebug('密码new[' + TradeContext.CURPIN + ']') #唐斌新增# sql = "SELECT ischkactname,ischklate FROM rcc_chlabt where transcode='"+TradeContext.TransCode+"' and channelno= '"+(TradeContext.SNDCLKNO)[6:8]+"'" AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql) if (records == None): return False elif (len(records) == 0): AfaLoggerFunc.tradeDebug("查询结果为空,查询条件[" + sql + "]") return False AfaLoggerFunc.tradeDebug(str(records)) #校验账户状态是否正常和账号户名是否相符 if TradeContext.PRCCO == 'RCCI0000': #调用主机接口查询账户信息 TradeContext.HostCode = '8810' TradeContext.ACCNO = TradeContext.PYRACC AfaLoggerFunc.tradeDebug("gbj test :" + TradeContext.ACCNO) rccpsHostFunc.CommHost( TradeContext.HostCode ) if TradeContext.errorCode != '0000': #return AfaFlowControl.ExitThisFlow(TradeContext.errorCode,TradeContext.errorMsg) AfaLoggerFunc.tradeInfo("查询账户信息异常,主机返回码[" + TradeContext.errorCode + "],主机返回信息[" + TradeContext.errorMsg +"]") #TradeContext.PRCCO = 'NN1IA999' TradeContext.PRCCO = rccpsDBFunc.HostErr2RccErr(TradeContext.errorCode) TradeContext.STRINFO = TradeContext.errorMsg TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" else: #查询成功,更新通存通兑登记簿账务机构号 AfaLoggerFunc.tradeInfo(">>>查询主机账户成功") #if( TradeContext.BESBNO != PL_BESBNO_BCLRSB ): # AfaLoggerFunc.tradeInfo(">>>" + TradeContext.BESBNO + ">>>" + TradeContext.ACCSO) # if( TradeContext.BESBNO[:6] != TradeContext.ACCSO[:6] ): # AfaLoggerFunc.tradeInfo(">>>不许跨法人做此交易") # TradeContext.PRCCO = 'NN1IO999' # TradeContext.STRINFO = "接收行与账户开户行不属于同一法人" # TradeContext.BCSTAT = PL_BCSTAT_MFERFE # TradeContext.BCSTATNM = "拒绝" #检查本机构是否有通存通兑业务权限 if not rccpsDBFunc.chkTDBESAuth(TradeContext.ACCSO): TradeContext.PRCCO = 'NN1IO999' TradeContext.STRINFO = "本账户开户机构无通存通兑业务权限" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" AfaLoggerFunc.tradeInfo(">>>开始更新机构号为开户机构") TradeContext.BESBNO = TradeContext.ACCSO wtrbka_update_dict = {'BESBNO':TradeContext.ACCSO} wtrbka_where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN} ret = rccpsDBTrcc_wtrbka.updateCmt(wtrbka_update_dict,wtrbka_where_dict) if ret <= 0: AfaLoggerFunc.tradeInfo(">>>更新机构号为开户机构异常") TradeContext.PRCCO = 'NN1ID006' TradeContext.STRINFO = "更新账务机构号异常" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" else: AfaLoggerFunc.tradeInfo(">>>更新机构号为开户机构成功") AfaLoggerFunc.tradeDebug("主机返回户名ACCNM :[" + TradeContext.ACCNM + "]") AfaLoggerFunc.tradeDebug("报文接收户名PYRNAM:[" + TradeContext.PYRNAM + "]") AfaLoggerFunc.tradeDebug("主机返回账户状态ACCST:[" + TradeContext.ACCST + "]") AfaLoggerFunc.tradeDebug("证件类型ACITY:[" + TradeContext.ACITY + "]") AfaLoggerFunc.tradeDebug("证件号码ACINO:[" + TradeContext.ACINO + "]") if TradeContext.ACCNM != TradeContext.PYRNAM: #唐斌新增# if(records[0][0]=='1'): AfaLoggerFunc.tradeInfo(">>>账号户名不符") TradeContext.PRCCO = 'NN1IA102' TradeContext.STRINFO = '账号户名不符' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" elif TradeContext.ACCST != '0' and TradeContext.ACCST != '2': AfaLoggerFunc.tradeInfo(">>>账户状态不正常") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = '账户状态不正常' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" elif not (TradeContext.ACCCD == '0428' and TradeContext.ACCEM == '21111'): AfaLoggerFunc.tradeInfo(">>>此账户非个人结算户") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = '此账户非个人结算户' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" #=====交易金额判断==== chk_dict = {} chk_dict['BPARAD'] = 'TD001' #通存通兑凭证金额校验 dict = rccpsDBTrcc_pamtbl.selectu(chk_dict) AfaLoggerFunc.tradeInfo('dict='+str(dict)) if dict == None: AfaLoggerFunc.tradeInfo(">>>校验交易金额失败") TradeContext.PRCCO = 'NN1ID003' TradeContext.STRINFO = '校验交易金额失败' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" if len(dict) == 0: AfaLoggerFunc.tradeInfo(">>>查询PAMTBL校验交易金额表记录错误") TradeContext.PRCCO = 'NN1ID010' TradeContext.STRINFO = '查询PAMTBL校验交易金额表记录错误' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" #=====判断农信银中心规定校验凭证上线==== if float(TradeContext.OCCAMT) > float(dict['BPADAT']): #=====交易金额大于农信银中心规定金额,需要输入证件==== if TradeContext.existVariable('CERTTYPE') and len(TradeContext.CERTTYPE) == 0: AfaLoggerFunc.tradeInfo(">>>请选择证件类型") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = '请选择证件类型' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" elif(TradeContext.CERTTYPE == '06'): if( TradeContext.ACITY != '06' and TradeContext.ACITY != '07' and TradeContext.ACITY != '08' and TradeContext.ACITY != '09'): AfaLoggerFunc.tradeInfo(">>>证件类型错误") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = '证件类型错误' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" elif( TradeContext.CERTTYPE != TradeContext.ACITY ): AfaLoggerFunc.tradeInfo(">>>证件类型错误") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = '证件类型错误' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" if TradeContext.existVariable('CERTNO') and len(TradeContext.CERTNO) == 0: AfaLoggerFunc.tradeInfo(">>>请输入证件号码") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = '请输入证件号码' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" elif( TradeContext.CERTNO != TradeContext.ACINO ): AfaLoggerFunc.tradeInfo(">>>证件号码错误") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = '证件号码错误' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" #校验交易金额是否超当日限额 if not rccpsDBFunc.chkLimited(TradeContext.BJEDTE,TradeContext.PYRACC,TradeContext.OCCAMT): AfaLoggerFunc.tradeInfo(">>>交易金额超限") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = '交易金额超限' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" AfaLoggerFunc.tradeInfo(">>>结束必要性检查") #发起主机记账 AfaLoggerFunc.tradeInfo(">>>开始发起主机记账") TradeContext.sCertType = TradeContext.CERTTYPE TradeContext.sCertNo = TradeContext.CERTNO TradeContext.sOccamt = TradeContext.OCCAMT TradeContext.sCuschrg = TradeContext.CUSCHRG AfaLoggerFunc.tradeInfo(">>>" + TradeContext.PRCCO) if TradeContext.PRCCO == 'RCCI0000': TradeContext.HostCode = '8813' #调用8813主机接口 #TradeContext.PASSWD = TradeContext.CURPIN #来账对方现金收取手续费 if( TradeContext.CHRGTYP != '1' ): TradeContext.RCCSMCD = PL_RCCSMCD_XJTDLZ #主机摘要代码 TradeContext.SBAC = TradeContext.PYRACC #借方账户:付款人账户 TradeContext.ACNM = TradeContext.PYRNAM #借方户名 付款人户名 TradeContext.RBAC = TradeContext.BESBNO + PL_ACC_NXYDQSLZ #贷方账户:农信银待清算来账 TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC, 25) TradeContext.OTNM = '农信银待清算来账' #贷方户名: TradeContext.CTFG = '7' #本金 手续费标识 7 本金 8手续费 9 本金+手续费 TradeContext.PKFG = 'T' #通存通兑标识 TradeContext.WARNTNO = '49' + TradeContext.BNKBKNO TradeContext.CERTTYPE = '' TradeContext.CERTNO = '' TradeContext.PASSWD = TradeContext.CURPIN #密码 AfaLoggerFunc.tradeInfo( '借方账号:' + TradeContext.SBAC ) AfaLoggerFunc.tradeInfo( '贷方账号:' + TradeContext.RBAC ) AfaLoggerFunc.tradeInfo( '凭证号码:' + TradeContext.WARNTNO ) else: #对方转账收取手续费时s TradeContext.ACUR = '3' #记账次数 #=========交易金额============ TradeContext.RCCSMCD = PL_RCCSMCD_XJTDLZ #摘要代码 TradeContext.SBAC = TradeContext.PYRACC #借方账号 TradeContext.ACNM = TradeContext.PYRNAM #借方户名 TradeContext.RBAC = TradeContext.BESBNO + PL_ACC_NXYDJLS #贷方账号 TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25) TradeContext.OTNM = '待解临时款项' #贷方户名 TradeContext.OCCAMT = str(TradeContext.sOccamt) #发生额 TradeContext.CTFG = '7' #本金 手续费标识 7 本金 8手续费 9 本金+手续费 TradeContext.PKFG = 'T' #通存通兑标识 TradeContext.WARNTNO = '49' + TradeContext.BNKBKNO TradeContext.PASSWD = TradeContext.CURPIN #密码 TradeContext.sCertType = TradeContext.CERTTYPE TradeContext.sCertNo = TradeContext.CERTNO TradeContext.CERTTYPE = '' TradeContext.CERTNO = '' AfaLoggerFunc.tradeInfo( '>>>交易金额:借方账号' + TradeContext.SBAC ) AfaLoggerFunc.tradeInfo( '>>>交易金额:贷方账号' + TradeContext.RBAC ) AfaLoggerFunc.tradeInfo( '凭证号码:' + TradeContext.WARNTNO ) #=========结算手续费收入户=========== TradeContext.I2SMCD = PL_RCCSMCD_SXF #摘要代码 TradeContext.I2SBAC = TradeContext.PYRACC #借方账号 TradeContext.I2ACNM = TradeContext.PYRNAM #借方户名 TradeContext.I2RBAC = TradeContext.BESBNO + PL_ACC_NXYDJLS #贷方账号 TradeContext.I2RBAC = rccpsHostFunc.CrtAcc(TradeContext.I2RBAC,25) TradeContext.I2OTNM = '待解临时款项' #贷方户名 TradeContext.I2TRAM = str(TradeContext.sCuschrg) #发生额 TradeContext.I2CTFG = '8' #本金 手续费标识 7 本金 8手续费 9 本金+手续费 TradeContext.I2PKFG = 'T' #通存通兑标识 TradeContext.I2WARNTNO = '49' + TradeContext.BNKBKNO TradeContext.I2PASSWD = TradeContext.CURPIN #密码 AfaLoggerFunc.tradeInfo( '>>>结算手续费收入户:借方账号' + TradeContext.I2SBAC ) AfaLoggerFunc.tradeInfo( '>>>结算手续费收入户:贷方账号' + TradeContext.I2RBAC ) AfaLoggerFunc.tradeInfo( '凭证号码:' + TradeContext.I2WARNTNO ) #=========交易金额+手续费=================== TradeContext.I3SMCD = PL_RCCSMCD_XJTDLZ #摘要代码 TradeContext.I3SBAC = TradeContext.BESBNO + PL_ACC_NXYDJLS #借方账号 TradeContext.I3SBAC = rccpsHostFunc.CrtAcc(TradeContext.I3SBAC,25) TradeContext.I3ACNM = '待解临时款项' #借方户名 TradeContext.I3RBAC = TradeContext.BESBNO + PL_ACC_NXYDQSLZ #贷方账号 TradeContext.I3RBAC = rccpsHostFunc.CrtAcc(TradeContext.I3RBAC,25) TradeContext.I3OTNM = '农信银来账' #贷方户名 TradeContext.I3TRAM = rccpsUtilTools.AddDot(TradeContext.OCCAMT,TradeContext.CUSCHRG) #发生额 TradeContext.I3CTFG = '9' #本金 手续费标识 7 本金 8手续费 9 本金+手续费 TradeContext.I3PKFG = 'T' #通存通兑标识 AfaLoggerFunc.tradeInfo( '>>>交易金额+手续费:借方账号' + TradeContext.I3SBAC ) AfaLoggerFunc.tradeInfo( '>>>交易金额+手续费:贷方账号' + TradeContext.I3RBAC ) rccpsHostFunc.CommHost( TradeContext.HostCode ) AfaLoggerFunc.tradeInfo(">>>结束发起主机记账") #TradeContext.errorCode, TradeContext.errorMsg = '0000', '主机成功' #根据主机返回码,设置业务状态为自动入账成功或失败 AfaLoggerFunc.tradeInfo(">>>开始根据主机放回码,设置业务状态为自动扣款成功或失败") stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BSPSQN'] = TradeContext.BSPSQN stat_dict['BESBNO'] = TradeContext.BESBNO stat_dict['BETELR'] = TradeContext.BETELR stat_dict['SBAC'] = TradeContext.SBAC stat_dict['ACNM'] = TradeContext.ACNM stat_dict['RBAC'] = TradeContext.RBAC stat_dict['OTNM'] = TradeContext.OTNM #=====modify by pgt 1129==== stat_dict['MGID'] = TradeContext.errorCode if TradeContext.existVariable('TRDT'): stat_dict['TRDT'] = TradeContext.TRDT if TradeContext.existVariable('TLSQ'): stat_dict['TLSQ'] = TradeContext.TLSQ stat_dict['STRINFO'] = TradeContext.errorMsg AfaLoggerFunc.tradeInfo("主机返回码[" + TradeContext.errorCode + "],主机返回信息[" + TradeContext.errorMsg +"]") if TradeContext.errorCode == '0000': #=====发送农信银成功,设置状态为自动入账成功==== stat_dict['BCSTAT'] = PL_BCSTAT_AUTOPAY stat_dict['BDWFLG'] = PL_BDWFLG_SUCC TradeContext.PRCCO = 'RCCI0000' TradeContext.STRINFO = '成功' if not rccpsState.setTransState(stat_dict): return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为自动入账成功异常") AfaLoggerFunc.tradeInfo(">>>设置业务状态为自动扣款成功完成") else: #=====发送农信银失败,设置状态为拒绝成功==== stat_dict['BCSTAT'] = PL_BCSTAT_MFERFE stat_dict['BDWFLG'] = PL_BDWFLG_SUCC #TradeContext.PRCCO = 'NN1CA999' TradeContext.PRCCO = rccpsDBFunc.HostErr2RccErr(TradeContext.errorCode) AfaLoggerFunc.tradeInfo(">>>>>>>>>>>>>>>>>>>>" + TradeContext.PRCCO) TradeContext.STRINFO = TradeContext.errorMsg if not rccpsState.setTransState(stat_dict): AfaLoggerFunc.tradeFatal( '设置业务状态为拒绝成功异常' ) TradeContext.PRCCO = "NN1ID999" TradeContext.STRINFO = "数据库其他错误" AfaLoggerFunc.tradeInfo(">>>设置业务状态为拒绝成功完成") else: stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BSPSQN'] = TradeContext.BSPSQN stat_dict['BESBNO'] = TradeContext.BESBNO stat_dict['BETELR'] = TradeContext.BETELR stat_dict['PRCCO'] = TradeContext.PRCCO stat_dict['STRINFO'] = TradeContext.STRINFO stat_dict['BCSTAT'] = PL_BCSTAT_MFERFE stat_dict['BDWFLG'] = PL_BDWFLG_SUCC if not rccpsState.setTransState(stat_dict): AfaLoggerFunc.tradeFatal( '设置业务状态为拒绝成功异常' ) TradeContext.PRCCO = "NN1ID999" TradeContext.STRINFO = "数据库其他错误" AfaLoggerFunc.tradeInfo(">>>设置业务状态为拒绝成功完成") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) TradeContext.PRCCO = "NN1ID999" TradeContext.STRINFO = "数据库其他错误" AfaLoggerFunc.tradeInfo(">>>开始根据主机放回码,设置业务状态为自动入账成功或失败") #为自动扣款应答报文赋值 TradeContext.sysType = 'rccpst' TradeContext.MSGTYPCO = 'SET007' #报文类代码 #TradeContext.RCVMBRCO = TradeContext.SNDMBRCO #接收方成员行号 TradeContext.RCVSTLBIN = TradeContext.SNDMBRCO #收款方成员行号 TradeContext.SNDSTLBIN = TradeContext.RCVMBRCO #付款方成员行号 TradeContext.SNDBRHCO = TradeContext.BESBNO #发起行网点号 TradeContext.SNDCLKNO = TradeContext.BETELR #发起行柜员号 TradeContext.SNDTRDAT = TradeContext.BJEDTE #发起行交易日期 TradeContext.SNDTRTIM = TradeContext.BJETIM #发起行交易时间 TradeContext.ORMFN = TradeContext.MSGFLGNO #参考报文标识号 TradeContext.MSGFLGNO = TradeContext.SNDMBRCO + TradeContext.BJEDTE + TradeContext.SerialNo #报文标识号 TradeContext.NCCWKDAT = TradeContext.NCCworkDate #中心工作日期 TradeContext.OPRTYPNO = '30' #业务类型 TradeContext.ROPRTPNO = TradeContext.OPRTYPNO #参考业务类型 TradeContext.TRANTYP = '0' #传输类型 TradeContext.CERTTYPE = TradeContext.sCertType TradeContext.CERTNO = TradeContext.sCertNo TradeContext.OCCAMT = TradeContext.sOccamt TradeContext.CUSCHRG = TradeContext.sCuschrg TradeContext.CUR = 'CNY' #货币符号 AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).折通兑来帐请求报文接收[TRCC006_1140]退出***' ) return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).卡通存请求报文接收[TRCC006_1135]进入***' ) #判断是否重复交易 AfaLoggerFunc.tradeInfo(">>>开始判断是否重复报文") sel_dict = {'TRCNO':TradeContext.TRCNO,'TRCDAT':TradeContext.TRCDAT,'SNDBNKCO':TradeContext.SNDBNKCO} record = rccpsDBTrcc_wtrbka.selectu(sel_dict) if record == None: return AfaFlowControl.ExitThisFlow('S999','判断是否重复报文,查询通存通兑业务登记簿相同报文异常') elif len(record) > 0: AfaLoggerFunc.tradeInfo('通存通兑业务登记簿中存在相同数据,重复报文,返回拒绝应答报文') #=====为应答报文赋值==== TradeContext.sysType = 'rccpst' TradeContext.MSGTYPCO = 'SET006' TradeContext.RCVSTLBIN = TradeContext.SNDMBRCO TradeContext.SNDSTLBIN = TradeContext.RCVMBRCO TradeContext.SNDBRHCO = TradeContext.BESBNO TradeContext.SNDCLKNO = TradeContext.BETELR #TradeContext.SNDTRDAT = TradeContext.BJEDTE #TradeContext.BJEDTE = TradeContext.SNDTRDAT #TradeContext.SNDTRTIM = TradeContext.BJETIM TradeContext.ORMFN = TradeContext.MSGFLGNO #TradeContext.MSGFLGNO = TradeContext.SNDMBRCO + TradeContext.SNDTRDAT + TradeContext.SerialNo TradeContext.NCCWKDAT = TradeContext.NCCworkDate TradeContext.OPRTYPNO = '30' TradeContext.ROPRTPNO = TradeContext.OPRTYPNO TradeContext.TRANTYP = '0' TradeContext.CUR = 'CNY' TradeContext.PRCCO = 'NN1IM101' TradeContext.STRINFO = "重复报文" #=====发送afe==== AfaAfeFunc.CommAfe() return AfaFlowControl.ExitThisFlow('S999','重复报文,退出处理流程') AfaLoggerFunc.tradeInfo(">>>结束判断是否重复报文") #登记通存通兑登记簿 AfaLoggerFunc.tradeInfo(">>>开始登记通存通兑业务登记簿") #=====币种转换==== if TradeContext.CUR == 'CNY': TradeContext.CUR = '01' #=====手续费收取方式===== if float(TradeContext.CUSCHRG) > 0.001: TradeContext.CHRGTYP = '1' else: TradeContext.CHRGTYP = '0' #====开始向字典赋值==== wtrbka_dict = {} if not rccpsMap1135CTradeContext2Dwtrbka_dict.map(wtrbka_dict): return AfaFlowControl.ExitThisFlow('M999', '字典赋值出错') wtrbka_dict['DCFLG'] = PL_DCFLG_CRE #借贷标识 wtrbka_dict['OPRNO'] = PL_TDOPRNO_TC #业务种类 #=====开始插入数据库==== if not rccpsDBFunc.insTransWtr(wtrbka_dict): return False if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo(">>>结束登记通存通兑业务登记簿") #设置业务状态为行内收妥成功 AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为收妥成功") stat_dict = {} stat_dict['BSPSQN'] = TradeContext.BSPSQN stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BCSTAT'] = PL_BCSTAT_BNKRCV stat_dict['BDWFLG'] = PL_BDWFLG_SUCC if not rccpsState.setTransState(stat_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务状态收妥成功异常') if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为收妥成功") #设置业务状态为确认入账处理中 AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为确认入账处理中") if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CONFACC,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow('S999','设置业务状态为确认入账处理中异常') if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为确认入账处理中") #初始化返回码 TradeContext.PRCCO = 'RCCI0000' TradeContext.STRINFO = "成功" TradeContext.BCSTAT = PL_BCSTAT_CONFACC #状态:确认付款 TradeContext.BCSTATNM = "确认付款" #进行必要性检查,若校验通过,则返回成功应答报文,若校验未通过,则返回拒绝应答报文 AfaLoggerFunc.tradeInfo(">>>开始必要性检查") #检查冲正登记簿中是否有此笔业务的冲正业务,存在则返回拒绝应答报文,并设置业务状态为冲正处理中 if TradeContext.PRCCO == 'RCCI0000': atcbka_where_dict = {} atcbka_where_dict['ORMFN'] = TradeContext.MSGFLGNO atcbka_dict = rccpsDBTrcc_atcbka.selectu(atcbka_where_dict) if atcbka_dict == None: #return AfaFlowControl.ExitThisFlow('S999', "查询冲正登记簿异常") AfaLoggerFunc.tradeInfo(">>>查询冲正登记簿异常") TradeContext.PRCCO = 'NN1ID003' TradeContext.STRINFO = "系统错误,查询冲正登记簿异常" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" else: if len(atcbka_dict) <= 0: AfaLoggerFunc.tradeInfo(">>>此交易未被冲正,继续校验") else: AfaLoggerFunc.tradeInfo(">>>此交易已被冲正,返回拒绝应答报文") TradeContext.PRCCO = 'NN1IO307' TradeContext.STRINFO = "此交易已被冲正" TradeContext.BCSTAT = PL_BCSTAT_CANC TradeContext.BCSTATNM = "冲正" #唐斌新增# sql = "SELECT ischkactname,ischklate FROM rcc_chlabt where transcode='"+TradeContext.TransCode+"' and channelno= '"+(TradeContext.SNDCLKNO)[6:8]+"'" AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql) if (records == None): return False elif (len(records) == 0): AfaLoggerFunc.tradeDebug("查询结果为空,查询条件[" + sql + "]") return False AfaLoggerFunc.tradeDebug(str(records)) #校验账户状态是否正常和账号户名是否相符 if TradeContext.PRCCO == 'RCCI0000': #调用主机接口查询账户信息 TradeContext.HostCode = '8810' TradeContext.ACCNO = TradeContext.PYEACC AfaLoggerFunc.tradeDebug("ACCNO :" + TradeContext.ACCNO) rccpsHostFunc.CommHost( TradeContext.HostCode ) if TradeContext.errorCode != '0000': #return AfaFlowControl.ExitThisFlow(TradeContext.errorCode,TradeContext.errorMsg) AfaLoggerFunc.tradeInfo("查询账户信息异常,主机返回码[" + TradeContext.errorCode + "],主机返回信息[" + TradeContext.errorMsg +"]") TradeContext.PRCCO = rccpsDBFunc.HostErr2RccErr(TradeContext.errorCode) TradeContext.STRINFO = "查询主机账户信息失败 " + TradeContext.errorMsg TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" else: #TradeContext.PYENAM = AfaUtilTools.trim(TradeContext.PYENAM) AfaLoggerFunc.tradeInfo(">>>查询主机账户成功") #if TradeContext.BESBNO != PL_BESBNO_BCLRSB: # AfaLoggerFunc.tradeInfo(">>>" + TradeContext.BESBNO + ">>>" + TradeContext.ACCSO) # if( TradeContext.BESBNO[:6] != TradeContext.ACCSO[:6] ): # AfaLoggerFunc.tradeInfo(">>>不许跨法人做此交易") # TradeContext.PRCCO = 'NN1IO999' # TradeContext.STRINFO = "接收行与账户开户行不属于同一法人" # TradeContext.BCSTAT = PL_BCSTAT_MFERFE # TradeContext.BCSTATNM = "拒绝" #检查本机构是否有通存通兑业务权限 if not rccpsDBFunc.chkTDBESAuth(TradeContext.ACCSO): TradeContext.PRCCO = 'NN1IO999' TradeContext.STRINFO = "本账户开户机构无通存通兑业务权限" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" if TradeContext.PRCCO == 'RCCI0000': #查询成功,更新通存通兑登记簿账务机构号 AfaLoggerFunc.tradeInfo(">>>开始更新机构号为开户机构") TradeContext.BESBNO = TradeContext.ACCSO wtrbka_update_dict = {'BESBNO':TradeContext.ACCSO} wtrbka_where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN} ret = rccpsDBTrcc_wtrbka.updateCmt(wtrbka_update_dict,wtrbka_where_dict) if ret <= 0: AfaLoggerFunc.tradeInfo(">>>更新机构号为开户机构异常") TradeContext.PRCCO = 'NN1ID006' TradeContext.STRINFO = "系统错误,更新账务机构号异常" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" else: AfaLoggerFunc.tradeInfo(">>>更新机构号为开户机构成功") AfaLoggerFunc.tradeDebug("主机返回户名ACCNM :[" + TradeContext.ACCNM + "]") AfaLoggerFunc.tradeDebug("报文接收户名PYENAM:[" + TradeContext.PYENAM + "]") AfaLoggerFunc.tradeDebug("主机返回账户状态ACCST:[" + TradeContext.ACCST + "]") if TradeContext.ACCNM != TradeContext.PYENAM: #唐斌新增# if(records[0][0]=='1'): AfaLoggerFunc.tradeInfo(">>>账号户名不符") TradeContext.PRCCO = 'NN1IA102' TradeContext.STRINFO = '账号户名不符' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" elif TradeContext.ACCST != '0' and TradeContext.ACCST != '2': AfaLoggerFunc.tradeInfo(">>>账户状态不正常") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = '账户状态不正常' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" elif not (TradeContext.ACCCD == '0428' and TradeContext.ACCEM == '21111'): AfaLoggerFunc.tradeInfo(">>>此账户非个人结算户") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = '此账户非个人结算户' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" #校验磁道信息 关彬捷 20081215 #唐斌新增# if TradeContext.PRCCO == 'RCCI0000': if(records[0][1]=='1'): if (TradeContext.SCTRKINF == ''.rjust(37,'0') or TradeContext.SCTRKINF == ''): AfaLoggerFunc.tradeInfo("校验磁道信息异常,该业务必须产生磁道信息") TradeContext.PRCCO = 'NN1IA141' TradeContext.STRINFO = "校验磁道信息失败 :无磁道信息" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" if TradeContext.SCTRKINF != ''.rjust(37,'0') and TradeContext.SCTRKINF != '': #磁道信息非空或37个零,则调用主机接口校验磁道信息 TradeContext.HostCode = '0652' TradeContext.WARNTNO = TradeContext.PYEACC[6:18] AfaLoggerFunc.tradeDebug("WARNTNO :" + TradeContext.WARNTNO) AfaLoggerFunc.tradeDebug("SCTRKINF :" + TradeContext.SCTRKINF) AfaLoggerFunc.tradeDebug("THTRKINF :" + TradeContext.THTRKINF) if TradeContext.THTRKINF == ''.rjust(37,'0'): TradeContext.THTRKINF = '' AfaLoggerFunc.tradeDebug("THTRKINF :" + TradeContext.THTRKINF) rccpsHostFunc.CommHost( TradeContext.HostCode ) if TradeContext.errorCode != '0000': #return AfaFlowControl.ExitThisFlow(TradeContext.errorCode,TradeContext.errorMsg) AfaLoggerFunc.tradeInfo("校验磁道信息异常,主机返回码[" + TradeContext.errorCode + "],主机返回信息[" + TradeContext.errorMsg +"]") TradeContext.PRCCO = 'NN1IA141' TradeContext.STRINFO = "校验磁道信息失败 " + TradeContext.errorMsg TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" #校验凭证状态是否正常 if TradeContext.PRCCO == 'RCCI0000': #调用主机接口查询凭证信息 TradeContext.HostCode = '8811' TradeContext.ACCNO = TradeContext.PYEACC TradeContext.WARNTNO = TradeContext.PYEACC[6:18] AfaLoggerFunc.tradeDebug("ACCNO :" + TradeContext.ACCNO) AfaLoggerFunc.tradeDebug("WARNTNO :" + TradeContext.WARNTNO) rccpsHostFunc.CommHost( TradeContext.HostCode ) if TradeContext.errorCode != '0000': #return AfaFlowControl.ExitThisFlow(TradeContext.errorCode,TradeContext.errorMsg) AfaLoggerFunc.tradeInfo("查询凭证信息异常,主机返回码[" + TradeContext.errorCode + "],主机返回信息[" + TradeContext.errorMsg +"]") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = "查询主机凭证信息失败 " + TradeContext.errorMsg TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" # else: # #查询成功 # AfaLoggerFunc.tradeInfo(">>>查询主机凭证信息成功") # AfaLoggerFunc.tradeInfo(">>>凭证信息ACCSTCD:[" + TradeContext.ACCSTCD + "]") # # if TradeContext.ACCSTCD != '0': # TradeContext.PRCCO = 'RCCI1000' # TradeContext.STRINFO = '账户凭证状态不正常' # TradeContext.BCSTAT = PL_BCSTAT_MFERFE # TradeContext.BCSTATNM = "拒绝" AfaLoggerFunc.tradeInfo(">>>结束必要性检查") #AfaLoggerFunc.tradeInfo("gbj_test:SNDTRDAT=[" + TradeContext.SNDTRDAT + "]") #为应答报文赋值 TradeContext.sysType = 'rccpst' TradeContext.MSGTYPCO = 'SET006' TradeContext.RCVSTLBIN = TradeContext.SNDMBRCO TradeContext.SNDSTLBIN = TradeContext.RCVMBRCO TradeContext.SNDBRHCO = TradeContext.BESBNO TradeContext.SNDCLKNO = TradeContext.BETELR #TradeContext.SNDTRDAT = TradeContext.BJEDTE #TradeContext.SNDTRTIM = TradeContext.BJETIM TradeContext.ORMFN = TradeContext.MSGFLGNO #TradeContext.MSGFLGNO = TradeContext.SNDMBRCO + TradeContext.SNDTRDAT + TradeContext.SerialNo TradeContext.NCCWKDAT = TradeContext.NCCworkDate TradeContext.ROPRTPNO = TradeContext.OPRTYPNO TradeContext.OPRTYPNO = '30' TradeContext.TRANTYP = '0' TradeContext.CUR = 'CNY' AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).卡通存请求报文接收[TRCC006_1135]退出***' ) return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.回执类操作(1.回执操作).通存通兑冲正应答报文接收[TRC004_1161]进入***' ) #=================初始化返回信息============================================ if AfaUtilTools.trim(TradeContext.STRINFO) == "": TradeContext.STRINFO = rccpsDBFunc.getErrInfo(TradeContext.PRCCO) AfaLoggerFunc.tradeDebug("TradeContext.STRINFO=" + TradeContext.STRINFO) #=================初始化返回信息============================================ if AfaUtilTools.trim(TradeContext.STRINFO) == "": TradeContext.STRINFO = rccpsDBFunc.getErrInfo(TradeContext.PRCCO) AfaLoggerFunc.tradeDebug("TradeContext.STRINFO=" + TradeContext.STRINFO) #查询原冲正交易信息 atcbka_dict = {} atcbka_where_dict = {} atcbka_where_dict['MSGFLGNO'] = TradeContext.ORMFN atcbka_dict = rccpsDBTrcc_atcbka.selectu(atcbka_where_dict) if atcbka_dict == None: return AfaFlowControl.ExitThisFlow("S999","查询原冲正交易信息异常") if len(atcbka_dict) <= 0: return AfaFlowControl.ExitThisFlow("S999","未找到原冲正交易信息,丢弃报文") #查询原被冲正交易是否已开始被冲销 mpcbka_dict = {} mpcbka_where_dict = {} mpcbka_where_dict['ORMFN'] = atcbka_dict['ORMFN'] mpcbka_dict = rccpsDBTrcc_mpcbka.selectu(mpcbka_where_dict) if mpcbka_dict == None: return AfaFlowControl.ExitThisFlow("S999","查询原冲正交易信息异常") if len(mpcbka_dict) > 0: return AfaFlowControl.ExitThisFlow("S999","原交易已开始冲销,停止处理本冲正应答") #=====给机构号和柜员号赋值==== TradeContext.BETELR = atcbka_dict['BETELR'] TradeContext.BESBNO = atcbka_dict['BESBNO'] #更新冲正登记簿中心返回信息 AfaLoggerFunc.tradeInfo(">>>开始更新冲正登记簿中心返回信息") atcbka_update_dict = {} atcbka_update_dict['PRCCO'] = TradeContext.PRCCO atcbka_update_dict['STRINFO'] = TradeContext.STRINFO ret = rccpsDBTrcc_atcbka.update(atcbka_update_dict,atcbka_where_dict) if ret <= 0: return AfaFlowControl.ExitThisFlow("S999","更新冲正登记簿异常") AfaLoggerFunc.tradeInfo(">>>结束更新冲正登记簿中心返回信息") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") if atcbka_dict['ORTRCCO'] != '3000504': AfaLoggerFunc.tradeInfo(">>>原被冲正交易为通存或通兑账务类交易") #查询原被冲正交易信息 wtr_dict = {} if not rccpsDBFunc.getTransWtr(atcbka_dict['BOJEDT'],atcbka_dict['BOSPSQ'],wtr_dict): return AfaFlowControl.ExitThisFlow("S999","查询原被冲正交易信息异常") #如果原被冲正交易当前状态已为冲正,表示已收到冲正应答,停止处理 if wtr_dict['BCSTAT'] == PL_BCSTAT_CANCEL: return AfaFlowControl.ExitThisFlow("S999","已收到冲正应答,丢弃报文") TradeContext.TERMID = wtr_dict['TERMID'] TradeContext.BRSFLG = wtr_dict['BRSFLG'] #若原被冲正交易为通存类交易,应抹账 if wtr_dict['TRCCO'] in ('3000002','3000003','3000004','3000005'): AfaLoggerFunc.tradeInfo(">>>开始发起主机抹账") #为抹账赋值会计分录 entries_dict = {} entries_dict['FEDT'] = wtr_dict['BJEDTE'] entries_dict['RBSQ'] = wtr_dict['BSPSQN'] entries_dict['PYRACC'] = wtr_dict['PYRACC'] entries_dict['PYRNAM'] = wtr_dict['PYRNAM'] entries_dict['PYEACC'] = wtr_dict['PYEACC'] entries_dict['PYENAM'] = wtr_dict['PYENAM'] entries_dict['OCCAMT'] = wtr_dict['OCCAMT'] entries_dict['CHRGTYP'] = wtr_dict['CHRGTYP'] entries_dict['CUSCHRG'] = wtr_dict['CUSCHRG'] entries_dict['RCCSMCD'] = PL_RCCSMCD_CX TradeContext.BRSFLG = wtr_dict['BRSFLG'] if TradeContext.ORTRCCO == '3000002' or TradeContext.ORTRCCO == '3000004': rccpsEntries.KZTCWZMZ(entries_dict) if TradeContext.ORTRCCO == '3000003' or TradeContext.ORTRCCO == '3000005': rccpsEntries.KZBZYWZMZ(entries_dict) #=====生成新的前置日期和前置流水号==== if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 : return AfaFlowControl.ExisThisFlow('S999',"产生新的前置流水号异常") #设置原交易状态为冲正处理中 AfaLoggerFunc.tradeInfo('>>>开始设置原交易状态为冲正处理中') if not rccpsState.newTransState(wtr_dict['BJEDTE'],wtr_dict['BSPSQN'],PL_BCSTAT_CANCEL,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为冲正处理中异常") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo('>>>结束设置原交易状态为冲正处理中') #=====调起主机接口===== rccpsHostFunc.CommHost( TradeContext.HostCode ) AfaLoggerFunc.tradeInfo(">>>结束发起主机记账") else: AfaLoggerFunc.tradeInfo(">>>原交易未记账,冲正不抹账") #设置原交易状态为冲正处理中 AfaLoggerFunc.tradeInfo('>>>开始设置原交易状态为冲正处理中') if not rccpsState.newTransState(wtr_dict['BJEDTE'],wtr_dict['BSPSQN'],PL_BCSTAT_CANCEL,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为冲正处理中异常") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo('>>>结束设置原交易状态为冲正处理中') TradeContext.errorCode = "0000" TradeContext.errorMsg = "冲正前未记账,冲正不抹账" #根据主机返回信息,设置交易状态 stat_dict = {} stat_dict['BJEDTE'] = wtr_dict['BJEDTE'] stat_dict['BSPSQN'] = wtr_dict['BSPSQN'] stat_dict['MGID'] = TradeContext.errorCode stat_dict['STRINFO'] = TradeContext.errorMsg AfaLoggerFunc.tradeInfo("TradeContext.errorCode = [" + TradeContext.errorCode + "]") if TradeContext.errorCode == '0000': #设置原交易状态为冲正成功 AfaLoggerFunc.tradeInfo("<<<<<<<开始更改原交易状态为冲正成功") stat_dict['BCSTAT'] = PL_BCSTAT_CANCEL stat_dict['BDWFLG'] = PL_BDWFLG_SUCC if TradeContext.existVariable('TRDT'): stat_dict['TRDT'] = TradeContext.TRDT if TradeContext.existVariable('TLSQ'): stat_dict['TLSQ'] = TradeContext.TLSQ if not rccpsState.setTransState(stat_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务状态为冲正成功异常') AfaLoggerFunc.tradeInfo("<<<<<<<结束更改原交易状态为冲正成功") else: #设置原交易状态为冲正失败 AfaLoggerFunc.tradeInfo("<<<<<<<开始更改原交易状态为冲正失败") stat_dict['BCSTAT'] = PL_BCSTAT_CANCEL stat_dict['BDWFLG'] = PL_BDWFLG_FAIL if not rccpsState.setTransState(stat_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务状态为冲正失败异常') AfaLoggerFunc.tradeInfo("<<<<<<<结束更改原交易状态为冲正成功") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") else: AfaLoggerFunc.tradeInfo(">>>原被冲正交易为冲销交易") #查询原冲销交易详细信息 AfaLoggerFunc.tradeInfo(">>>冲销交易报单日期[" + atcbka_dict['BOJEDT'] + "]报单序号[" + atcbka_dict['BOSPSQ'] + "]") AfaLoggerFunc.tradeInfo(">>>开始查询原冲销交易详细信息") mpc_dict = {} if not rccpsDBFunc.getTransMpc(atcbka_dict['BOJEDT'],atcbka_dict['BOSPSQ'],mpc_dict): return AfaFlowControl.ExitThisFlow("S999","查询原冲销交易详细信息异常") AfaLoggerFunc.tradeInfo(">>>结束查询原冲销交易详细信息") #查询原被冲销交易详细信息 AfaLoggerFunc.tradeInfo(">>>被冲销交易报单日期[" + mpc_dict['BOJEDT'] + "]报单序号[" + mpc_dict['BOSPSQ'] + "]") AfaLoggerFunc.tradeInfo(">>>开始查询原被冲销交易详细信息") wtr_dict = {} if not rccpsDBFunc.getTransWtr(mpc_dict['BOJEDT'],mpc_dict['BOSPSQ'],wtr_dict): return AfaFlowControl.ExitThisFlow("S999","查询原被冲销交易详细信息异常") AfaLoggerFunc.tradeInfo(">>>结束查询原被冲销交易详细信息") #更新冲销登记簿 AfaLoggerFunc.tradeInfo(">>>开始更新冲销登记簿") mpcbka_update_dict = {} mpcbka_update_dict['PRCCO'] = "RCCI1000" mpcbka_update_dict['STRINFO'] = "冲销交易被成功冲正" mpcbka_where_dict = {} mpcbka_where_dict['BJEDTE'] = mpc_dict['BJEDTE'] mpcbka_where_dict['BSPSQN'] = mpc_dict['BSPSQN'] ret = rccpsDBTrcc_mpcbka.update(mpcbka_update_dict,mpcbka_where_dict) if ret <= 0: return AfaFlowControl.ExitThisFlow("更新冲销登记簿返回码和返回信息异常") AfaLoggerFunc.tradeInfo(">>>结束更新冲销登记簿") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo( '***农信银系统:往账.回执类操作(1.回执操作).通存通兑冲正应答报文接收[TRC004_1161]退出***' ) return True
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
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.回执类操作(1.回执操作).通存通兑业务回执报文接收[TRC004_1147]进入***' ) #=================初始化返回信息============================================ if AfaUtilTools.trim(TradeContext.STRINFO) == "": TradeContext.STRINFO = rccpsDBFunc.getErrInfo(TradeContext.PRCCO) AfaLoggerFunc.tradeDebug("TradeContext.STRINFO=" + TradeContext.STRINFO) #=================匹配原交易信息=========================================== wtrbka_where_dict = {} wtrbka_where_dict['MSGFLGNO'] = TradeContext.ORMFN wtrbka_dict = {} wtrbka_dict = rccpsDBTrcc_wtrbka.selectu(wtrbka_where_dict) if wtrbka_dict == None: return AfaFlowControl.ExitThisFlow('S999', "查询通存通兑业务信息登记簿异常") if len(wtrbka_dict) > 0: TradeContext.BJEDTE = wtrbka_dict['BJEDTE'] TradeContext.BSPSQN = wtrbka_dict['BSPSQN'] TradeContext.TRCCO = wtrbka_dict['TRCCO'] TradeContext.BESBNO = wtrbka_dict['BESBNO'] TradeContext.BETELR = wtrbka_dict['BETELR'] TradeContext.OCCAMT = str(wtrbka_dict['OCCAMT']) TradeContext.CHRGTYP = wtrbka_dict['CHRGTYP'] TradeContext.LOCCUSCHRG = str(wtrbka_dict['CUSCHRG']) TradeContext.PYETYP = wtrbka_dict['PYETYP'] TradeContext.PYEACC = wtrbka_dict['PYEACC'] TradeContext.PYENAM = wtrbka_dict['PYENAM'] TradeContext.PYRTYP = wtrbka_dict['PYRTYP'] TradeContext.PYRACC = wtrbka_dict['PYRACC'] TradeContext.PYRNAM = wtrbka_dict['PYRNAM'] TradeContext.CERTTYPE = wtrbka_dict['CERTTYPE'] TradeContext.CERTNO = wtrbka_dict['CERTNO'] TradeContext.TERMID = wtrbka_dict['TERMID'] TradeContext.WARNTNO = wtrbka_dict['BNKBKNO'] #============设置原交易状态为拒绝====================================== AfaLoggerFunc.tradeInfo(">>>开始设置原交易业务状态为拒绝处理中") if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_MFERFE,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为拒绝处理中异常") AfaLoggerFunc.tradeInfo(">>>结束设置原交易业务状态为拒绝处理中") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo(">>>Commit成功") AfaLoggerFunc.tradeInfo(">>>开始设置原交易业务状态为拒绝成功") stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BSPSQN'] = TradeContext.BSPSQN stat_dict['BCSTAT'] = PL_BCSTAT_MFERFE stat_dict['BDWFLG'] = PL_BDWFLG_SUCC stat_dict['PRCCO'] = TradeContext.PRCCO stat_dict['STRINFO'] = TradeContext.STRINFO if not rccpsState.setTransState(stat_dict): return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为拒绝成功异常") AfaLoggerFunc.tradeInfo(">>>结束设置原交易业务状态为拒绝成功") else: AfaLoggerFunc.tradeInfo(">>>通存通兑业务登记簿中未找到原请求交易信息,开始查询原存款确认信息") wtrbka_where_dict = {} wtrbka_where_dict['COMSGFLGNO'] = TradeContext.ORMFN wtrbka_dict = {} wtrbka_dict = rccpsDBTrcc_wtrbka.selectu(wtrbka_where_dict) if wtrbka_dict == None: return AfaFlowControl.ExitThisFlow('S999', "查询通存通兑业务信息登记簿异常") if len(wtrbka_dict) > 0: TradeContext.BJEDTE = wtrbka_dict['BJEDTE'] TradeContext.BSPSQN = wtrbka_dict['BSPSQN'] TradeContext.TRCCO = wtrbka_dict['TRCCO'] TradeContext.BESBNO = wtrbka_dict['BESBNO'] TradeContext.BETELR = wtrbka_dict['BETELR'] TradeContext.OCCAMT = str(wtrbka_dict['OCCAMT']) TradeContext.CHRGTYP = wtrbka_dict['CHRGTYP'] TradeContext.LOCCUSCHRG = str(wtrbka_dict['CUSCHRG']) TradeContext.PYETYP = wtrbka_dict['PYETYP'] TradeContext.PYEACC = wtrbka_dict['PYEACC'] TradeContext.PYENAM = wtrbka_dict['PYENAM'] TradeContext.PYRTYP = wtrbka_dict['PYRTYP'] TradeContext.PYRACC = wtrbka_dict['PYRACC'] TradeContext.PYRNAM = wtrbka_dict['PYRNAM'] TradeContext.CERTTYPE = wtrbka_dict['CERTTYPE'] TradeContext.CERTNO = wtrbka_dict['CERTNO'] TradeContext.TERMID = wtrbka_dict['TERMID'] TradeContext.WARNTNO = wtrbka_dict['BNKBKNO'] #============设置原交易状态为拒绝====================================== AfaLoggerFunc.tradeInfo(">>>开始设置原交易业务状态为拒绝处理中") if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_MFERFE,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为拒绝处理中异常") AfaLoggerFunc.tradeInfo(">>>结束设置原交易业务状态为拒绝处理中") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo(">>>Commit成功") AfaLoggerFunc.tradeInfo(">>>开始设置原交易业务状态为拒绝成功") stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BSPSQN'] = TradeContext.BSPSQN stat_dict['BESBNO'] = TradeContext.BESBNO stat_dict['BETELR'] = TradeContext.BETELR stat_dict['BCSTAT'] = PL_BCSTAT_MFERFE stat_dict['BDWFLG'] = PL_BDWFLG_SUCC stat_dict['PRCCO'] = TradeContext.PRCCO stat_dict['STRINFO'] = TradeContext.STRINFO if not rccpsState.setTransState(stat_dict): return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为拒绝成功异常") AfaLoggerFunc.tradeInfo(">>>结束设置原交易业务状态为拒绝成功") else: AfaLoggerFunc.tradeInfo(">>>通存通兑业务登记簿中未找到原存款确认信息,开始查询余额查询登记簿") balbka_where_dict = {} balbka_where_dict['MSGFLGNO'] = TradeContext.ORMFN balbka_dict = {} balbka_dict = rccpsDBTrcc_balbka.selectu(balbka_where_dict) if balbka_dict == None: return AfaFlowControl.ExitThisFlow('S999', "查询余额查询登记簿异常") if len(balbka_dict) > 0: TradeContext.TRCCO = balbka_dict['TRCCO'] #=====更新原余额查询交易返回码================================= AfaLoggerFunc.tradeInfo(">>>开始更新原余额查询交易返回码") balbka_update_dict = {} balbka_update_dict['PRCCO'] = TradeContext.PRCCO balbka_update_dict['STRINFO'] = TradeContext.STRINFO ret = rccpsDBTrcc_balbka.update(balbka_update_dict,balbka_where_dict) if ret <= 0: return AfaFlowControl.ExitThisFlow('S999', "更新原余额查询交易返回码异常") AfaLoggerFunc.tradeInfo(">>>结束更新原余额查询交易返回码") else: AfaLoggerFunc.tradeInfo(">>>余额查询登记簿中未找到原交易信息,开始查询自动冲正登记簿") atcbka_where_dict = {} atcbka_where_dict['MSGFLGNO'] = TradeContext.ORMFN atcbka_dict = {} atcbka_dict = rccpsDBTrcc_atcbka.selectu(atcbka_where_dict) if atcbka_dict == None: return AfaFlowControl.ExitThisFlow('S999', "查询自动冲正登记簿异常") if len(atcbka_dict) > 0: TradeContext.BOJEDT = atcbka_dict['BOJEDT'] TradeContext.BOSPSQ = atcbka_dict['BOSPSQ'] TradeContext.TRCCO = atcbka_dict['TRCCO'] #====更新自动冲正交易返回码================================ AfaLoggerFunc.tradeInfo(">>>开始更新原自动冲正交易返回码") atcbka_update_dict = {} atcbka_update_dict['PRCCO'] = TradeContext.PRCCO atcbka_update_dict['STRINFO'] = TradeContext.STRINFO ret = rccpsDBTrcc_atcbka.update(atcbka_update_dict,atcbka_where_dict) if ret<= 0: return AfaFlowControl.ExitThisFlow('S999', "更新原冲正交易返回码异常") AfaLoggerFunc.tradeInfo(">>>结束更新原自动冲正交易返回码") #====设置原被冲正交易业务状态为冲正失败================ #AfaLoggerFunc.tradeInfo(">>>开始设置原被冲正交易业务状态为冲正失败") # #stat_dict = {} #stat_dict['BJEDTE'] = TradeContext.BOJEDT #stat_dict['BSPSQN'] = TradeContext.BOSPSQ #stat_dict['BCSTAT'] = PL_BCSTAT_CANC #stat_dict['BDWFLG'] = PL_BDWFLG_FAIL #stat_dict['PRCCO'] = TradeContext.PRCCO #stat_dict['STRINFO'] = TradeContext.STRINFO # #if not rccpsState.setTransState(stat_dict): # return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为冲正失败异常") # #AfaLoggerFunc.tradeInfo(">>>结束设置原被冲正交易业务状态为冲正失败") else: AfaLoggerFunc.tradeInfo(">>>自动冲正登记簿中未找到原交易信息,开始查询柜面冲销登记簿") mpcbka_where_dict = {} mpcbka_where_dict['MSGFLGNO'] = TradeContext.ORMFN mpcbka_dict = {} mpcbka_dict = rccpsDBTrcc_mpcbka.selectu(mpcbka_where_dict) if mpcbka_dict == None: return AfaFlowControl.ExitThisFlow('S999', "查询柜面冲销登记簿异常") if len(mpcbka_dict) > 0: TradeContext.BOJEDT = mpcbka_dict['BOJEDT'] TradeContext.BOSPSQ = mpcbka_dict['BOSPSQ'] TradeContext.TRCCO = mpcbka_dict['TRCCO'] TradeContext.ORTRCCO = mpcbka_dict['ORTRCCO'] TradeContext.BESBNO = mpcbka_dict['BESBNO'] TradeContext.BETELR = mpcbka_dict['BETELR'] TradeContext.TERMID = mpcbka_dict['TERMID'] #====更新柜台冲销交易返回码================================ AfaLoggerFunc.tradeInfo(">>>开始更新原柜台冲销交易返回码") mpcbka_update_dict = {} mpcbka_update_dict['PRCCO'] = TradeContext.PRCCO mpcbka_update_dict['STRINFO'] = TradeContext.STRINFO ret = rccpsDBTrcc_mpcbka.update(mpcbka_update_dict,mpcbka_where_dict) if ret <=0: return AfaFlowControl.ExitThisFlow('S999', "更新原柜面冲销交易返回码异常") AfaLoggerFunc.tradeInfo(">>>结束更新原柜面冲销交易返回码") #====设置原被冲销交易业务状态为冲销失败================ #AfaLoggerFunc.tradeInfo(">>>开始设置原被冲销交易业务状态为冲销处理中") # #if not rccpsState.newTransState(TradeContext.BOJEDT,TradeContext.BOSPSQ,PL_BCSTAT_CANC,PL_BDWFLG_WAIT): # return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为冲销失败异常") # #AfaLoggerFunc.tradeInfo(">>>结束设置原被冲销交易业务状态为冲销处理中") # #if not AfaDBFunc.CommitSql( ): # AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) # return AfaFlowControl.ExitThisFlow("S999","Commit异常") #AfaLoggerFunc.tradeInfo(">>>Commit成功") # #AfaLoggerFunc.tradeInfo(">>>开始设置原被冲销交易业务状态为冲销失败") # #stat_dict = {} # #stat_dict['BJEDTE'] = TradeContext.BJEDTE #stat_dict['BSPSQN'] = TradeContext.BSPSQN #stat_dict['PRCCO'] = TradeContext.PRCCO #stat_dict['STRINFO'] = TradeContext.STRINFO #stat_dict['BCSTAT'] = PL_BCSTAT_CANC #stat_dict['BDWFLG'] = PL_BDWFLG_FAIL # #AfaLoggerFunc.tradeInfo(">>>结束设置原被冲销交易业务状态为冲销失败") else: return AfaFlowControl.ExitThisFlow('S999', "未找到原交易信息,丢弃报文") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo(">>>Commit成功") #=================若原交易为通存交易,开始自动抹账========================== if TradeContext.TRCCO == '3000002' or TradeContext.TRCCO == '3000003' or TradeContext.TRCCO == '3000004' or TradeContext.TRCCO == '3000005': #=====特殊处理 关彬捷 20081127 调8813抹账,需产生新的前置流水号进行记账==== if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 : return AfaFlowControl.ExisThisFlow('S999',"产生新的前置流水号异常") else: AfaLoggerFunc.tradeInfo(">>>成功产生新的前置流水号") #为抹账赋值会计分录 entries_dict = {} entries_dict['FEDT'] = TradeContext.BJEDTE entries_dict['RBSQ'] = TradeContext.BSPSQN entries_dict['PYRACC'] = TradeContext.PYRACC entries_dict['PYRNAM'] = TradeContext.PYRNAM entries_dict['PYEACC'] = TradeContext.PYEACC entries_dict['PYENAM'] = TradeContext.PYENAM entries_dict['OCCAMT'] = TradeContext.OCCAMT entries_dict['CHRGTYP'] = TradeContext.CHRGTYP entries_dict['CUSCHRG'] = TradeContext.LOCCUSCHRG entries_dict['RCCSMCD'] = PL_RCCSMCD_CX TradeContext.BRSFLG = PL_BRSFLG_SND if TradeContext.TRCCO == '3000002' or TradeContext.TRCCO == '3000004': rccpsEntries.KZTCWZMZ(entries_dict) if TradeContext.TRCCO == '3000003' or TradeContext.TRCCO == '3000005': rccpsEntries.KZBZYWZMZ(entries_dict) #=============设置原交易业务状态为抹账处理中=========================== AfaLoggerFunc.tradeInfo(">>>开始设置原交易业务状态为抹账处理中") #====设置业务状态为抹账处理中==== if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_HCAC,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow('S999','设置业务状态为抹账处理中异常') AfaLoggerFunc.tradeInfo(">>>结束设置原交易业务状态为抹账处理中") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") #=============开始发起主机抹账========================================= AfaLoggerFunc.tradeInfo(">>>开始主机抹账") #=====调起抹账主机接口==== rccpsHostFunc.CommHost( TradeContext.HostCode ) AfaLoggerFunc.tradeInfo(">>>结束主机抹账") AfaLoggerFunc.tradeInfo("TradeContext.errorCode = [" + TradeContext.errorCode + "]") stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BSPSQN'] = TradeContext.BSPSQN stat_dict['MGID'] = TradeContext.errorCode stat_dict['STRINFO'] = TradeContext.errorMsg if TradeContext.errorCode == '0000': #=========设置原交易业务状态为抹账成功============================= AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为抹账成功") stat_dict['BCSTAT'] = PL_BCSTAT_HCAC stat_dict['BDWFLG'] = PL_BDWFLG_SUCC stat_dict['TRDT'] = TradeContext.TRDT stat_dict['TLSQ'] = TradeContext.TLSQ stat_dict['PRTCNT'] = 1 if not rccpsState.setTransState(stat_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务状态抹账成功异常') AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为抹账成功") else: #=========设置原交易业务状态为抹账失败============================= AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为抹账失败") stat_dict['BCSTAT'] = PL_BCSTAT_HCAC stat_dict['BDWFLG'] = PL_BDWFLG_FAIL if not rccpsState.setTransState(stat_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务状态抹账成功异常') AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为抹账失败") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo( '***农信银系统:往账.回执类操作(1.回执操作).通存通兑业务回执报文接收[TRC004_1147]退出***' ) return True
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