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( '***农信银系统: 往账.本地类操作交易[RCC001_8591]通存通兑错帐处理标识维护进入***' ) AfaLoggerFunc.tradeInfo('个性化处理(本地操作)') #=====判断接口变量是否存在==== if not TradeContext.existVariable("SNDBNKCO"): return AfaFlowControl.ExitThisFlow('A099','发送行号不能为空' ) if not TradeContext.existVariable("TRCDAT"): return AfaFlowControl.ExitThisFlow('A009','委托日期不能为空') if not TradeContext.existVariable("TRCNO"): return AfaFlowControl.ExitThisFlow('A009','交易流水号不能为空') if not TradeContext.existVariable("BJEDTE"): return AfaFlowControl.ExitThisFlow('A009','报单日期不能为空') if not TradeContext.existVariable("BSPSQN"): return AfaFlowControl.ExitThisFlow('A009','报单序号不能为空') AfaLoggerFunc.tradeInfo('个性化处理结束(本地操作)') #=====得到nccwkdat==== if not rccpsFunc.GetNCCDate( ) : #NCCworkDate raise AfaFlowControl.flowException( ) #=====查询错账登记簿==== where_dict = {} where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO} tddzcz_record = rccpsDBTrcc_tddzcz.selectu(where_dict) if(tddzcz_record == None): return AfaFlowControl.ExitThisFlow('A009','查询错账登记簿失败') elif(len(tddzcz_record) == 0): return AfaFlowControl.ExitThisFlow('A009','查询错账登记簿为空') else: AfaLoggerFunc.tradeInfo("查询错账登记簿成功") #=====查询原业务的信息==== AfaLoggerFunc.tradeInfo('查询原业务信息') where_dict = {} where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN} wtrbka_record = rccpsDBTrcc_wtrbka.selectu(where_dict) if(wtrbka_record == None): return AfaFlowControl.ExitThisFlow('A009','查询业务登记簿失败') elif(len(wtrbka_record) == 0): return AfaFlowControl.ExitThisFlow('A009','查询业务登记簿为空') else: AfaLoggerFunc.tradeInfo('查询业务登记簿成功') #=====查询业务的当前信息==== wtr_dict = {} if not rccpsDBFunc.getTransWtr(TradeContext.BJEDTE,TradeContext.BSPSQN,wtr_dict): return AfaFlowControl.ExitThisFlow('A009','查询业务的当前信息失败') if(wtr_dict['BRSFLG'] == PL_BRSFLG_SND): sstlog_dict = {} if not rccpsState.getTransStateSet(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_ACC,PL_BDWFLG_SUCC,sstlog_dict): return AfaFlowControl.ExitThisFlow('A009','查询业务状态信息失败') wtr_dict['FEDT'] = sstlog_dict['FEDT'] wtr_dict['RBSQ'] = sstlog_dict['RBSQ'] TradeContext.CLDT = wtr_dict['FEDT'] TradeContext.UNSQ = wtr_dict['RBSQ'] if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 : #RBSQ return AfaFlowControl.ExitThisFlow('A099','产生前置流水号失败') TradeContext.FEDT=AfaUtilTools.GetHostDate( ) #FEDT #=====判断当前业务是否已经结转==== if(wtr_dict['BCSTAT'] == PL_BCSTAT_TRAS and wtr_dict['BDWFLG'] == PL_BDWFLG_SUCC): return AfaFlowControl.ExitThisFlow('A009','该账务已经结转') #=====判断业务的往来标示==== AfaLoggerFunc.tradeInfo('<<<<<<判断业务的往来标示') if(wtrbka_record['BRSFLG'] == PL_BRSFLG_SND): AfaLoggerFunc.tradeInfo('<<<<<<业务为往账') acc = 0 hcac = 0 canc = 0 cancel = 0 #=====查询是否有记账成功的状态==== sstlog_list = [] if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_ACC,PL_BDWFLG_SUCC,sstlog_list): acc = len(sstlog_list) #=====查询是否有抹账的状态==== sstlog_list = [] if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_HCAC,PL_BDWFLG_SUCC,sstlog_list): hcac = len(sstlog_list) #=====查询是否有冲销的状态==== sstlog_list = [] if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CANC,PL_BDWFLG_SUCC,sstlog_list): canc = len(sstlog_list) #=====查询是否有冲正的状态==== ssltog_list = [] if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CANCEL,PL_BDWFLG_SUCC,sstlog_list): cancel = len(sstlog_list) #=====判断是否需要清算状态调整==== AfaLoggerFunc.tradeInfo('<<<<<<判断是否需要清算状态调整') if(acc - (hcac + canc + cancel) >= 0): AfaLoggerFunc.tradeInfo('<<<<<<需要进行清算状态调整') TradeContext.BETELR = PL_BETELR_AUTO TradeContext.BRSFLG = wtrbka_record['BRSFLG'] TradeContext.CHRGTYP = wtrbka_record['CHRGTYP'] TradeContext.BESBNO = wtrbka_record['BESBNO'] #=====卡折存现/本转异地==== if(wtrbka_record['TRCCO'] in ('3000002','3000003','3000004','3000005')): AfaLoggerFunc.tradeInfo('卡折存现/本转异地') TradeContext.HostCode = '8813' TradeContext.ACUR = '1' TradeContext.RCCSMCD = PL_RCCSMCD_DZBJ TradeContext.SBAC = wtrbka_record['BESBNO'] + PL_ACC_NXYDQSWZ #借方账号 TradeContext.SBAC = rccpsHostFunc.CrtAcc(TradeContext.SBAC,25) TradeContext.ACNM = '农信银待清算往账' #借方户名 TradeContext.RBAC = wtrbka_record['BESBNO'] + PL_ACC_NXYWZ #贷方账号 TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25) TradeContext.OTNM = '农信银往账' #贷方户名 TradeContext.OCCAMT = str(wtrbka_record['OCCAMT']) #发生额 TradeContext.PKFG = 'W' TradeContext.CTFG = '7' #=====卡折取现/异地转本地==== elif(wtrbka_record['TRCCO'] in ('3000102','3000103','3000104','3000105')): AfaLoggerFunc.tradeInfo('卡折取现/异地转本地') if(wtrbka_record['CHRGTYP'] == '1'): #转收 AfaLoggerFunc.tradeInfo("<<<<<转收手续费") TradeContext.HostCode = '8813' TradeContext.ACUR = '1' TradeContext.RCCSMCD = PL_RCCSMCD_DZBJ TradeContext.SBAC = wtrbka_record['BESBNO'] + PL_ACC_NXYWZ #借方账号 TradeContext.SBAC = rccpsHostFunc.CrtAcc(TradeContext.SBAC,25) TradeContext.ACNM = '农信银往账' TradeContext.RBAC = wtrbka_record['BESBNO'] + PL_ACC_NXYDQSWZ #贷方账号 TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25) TradeContext.OTNM = '农信银待清算往账' TradeContext.OCCAMT = str(wtrbka_record['OCCAMT'] + wtrbka_record['CUSCHRG']) TradeContext.PKFG = 'W' TradeContext.CTFG = '9' else: #现收 AfaLoggerFunc.tradeInfo("<<<<<现收手续费,或不收") TradeContext.HostCode = '8813' TradeContext.ACUR = '1' TradeContext.RCCSMCD = PL_RCCSMCD_DZBJ TradeContext.SBAC = wtrbka_record['BESBNO'] + PL_ACC_NXYWZ #借方账号 TradeContext.SBAC = rccpsHostFunc.CrtAcc(TradeContext.SBAC,25) TradeContext.ACNM = '农信银往账' TradeContext.RBAC = wtrbka_record['BESBNO'] + PL_ACC_NXYDQSWZ #贷方账号 TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25) TradeContext.OTNM = '农信银待清算往账' TradeContext.OCCAMT = str(wtrbka_record['OCCAMT']) TradeContext.PKFG = 'W' TradeContext.CTFG = '9' else: return AfaFlowControl.ExitThisFlow('A099','原交易交易代码非法') #=====增加原交易的状态--结转==== if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_TRAS,PL_BDWFLG_WAIT): AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow('A099','增加原交易的状态--结转,失败') else: AfaDBFunc.CommitSql() #=====调用主机交易==== rccpsHostFunc.CommHost( TradeContext.HostCode ) #=====判断主机交易是否成功==== if(TradeContext.errorCode != '0000'): AfaLoggerFunc.tradeInfo("主机交易失败") #=====更改原交易状态==== state_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'BCSTAT':PL_BCSTAT_TRAS,'BDWFLG':PL_BDWFLG_FAIL} state_dict['STRINFO'] = TradeContext.errorMsg if not rccpsState.setTransState(state_dict): AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow('A099','更改原交易状态失败') else: AfaDBFunc.CommitSql() return AfaFlowControl.ExitThisFlow('A099','主机记账失败') else: AfaLoggerFunc.tradeInfo('主机记账成功') #=====更改原交易状态==== state_dict = {} state_dict['BJEDTE'] = TradeContext.BJEDTE state_dict['BSPSQN'] = TradeContext.BSPSQN state_dict['BCSTAT'] = PL_BCSTAT_TRAS state_dict['BDWFLG'] = PL_BDWFLG_SUCC if(TradeContext.existVariable("SBAC")): state_dict['SBAC'] = TradeContext.SBAC if(TradeContext.existVariable("RBAC")): state_dict['RBAC'] = TradeContext.RBAC state_dict['STRINFO'] = '主机成功' if(TradeContext.existVariable('TRDT')): state_dict['TRDT'] = TradeContext.TRDT if(TradeContext.existVariable('TLSQ')): state_dict['TLSQ'] = TradeContext.TLSQ if not rccpsState.setTransState(state_dict): AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow('A099','更改原交易状态失败') else: AfaDBFunc.CommitSql() else: return AfaFlowControl.ExitThisFlow('A009','原交易不能进行清算调整') else: AfaLoggerFunc.tradeInfo('<<<<<<业务为来账') autopay = 0 auto = 0 hcac = 0 canc = 0 cancel = 0 #=====查询是否有记账成功的状态==== sstlog_list = [] if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_AUTO,PL_BDWFLG_SUCC,sstlog_list): auto = len(sstlog_list) sstlog_list = [] if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_AUTOPAY,PL_BDWFLG_SUCC,sstlog_list): autopay = len(sstlog_list) #=====查询是否有抹账的状态==== sstlog_list = [] if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_HCAC,PL_BDWFLG_SUCC,sstlog_list): hcac = len(sstlog_list) #=====查询是否有冲销的状态==== sstlog_list = [] if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CANC,PL_BDWFLG_SUCC,sstlog_list): canc = len(sstlog_list) #=====查询是否有冲正的状态==== ssltog_list = [] if rccpsState.getTransStateSetm(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CANCEL,PL_BDWFLG_SUCC,sstlog_list): cancel = len(sstlog_list) #=====判断原业务是否需要进行清算状态调整==== AfaLoggerFunc.tradeInfo("判断原业务是否需要进行清算状态调整") if((auto + autopay) - (hcac + canc + cancel) >= 0): AfaLoggerFunc.tradeInfo("原业务需要进行清算状态调整") TradeContext.BETELR = PL_BETELR_AUTO TradeContext.BRSFLG = wtrbka_record['BRSFLG'] TradeContext.CHRGTYP = wtrbka_record['CHRGTYP'] TradeContext.BESBNO = wtrbka_record['BESBNO'] #=====卡折存现/本转异地==== if(wtrbka_record['TRCCO'] in ('3000002','3000003','3000004','3000005')): AfaLoggerFunc.tradeInfo('卡折存现/本转异地') TradeContext.HostCode = '8813' TradeContext.ACUR = '1' TradeContext.RCCSMCD = PL_RCCSMCD_DZBJ TradeContext.SBAC = wtrbka_record['BESBNO'] + PL_ACC_NXYLZ TradeContext.SBAC = rccpsHostFunc.CrtAcc(TradeContext.SBAC,25) TradeContext.ACNM = '农信银来账' TradeContext.RBAC = wtrbka_record['BESBNO'] + PL_ACC_NXYDQSLZ TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25) TradeContext.OTNM = '农信银待清算来账' TradeContext.OCCAMT = str(wtrbka_record['OCCAMT']) TradeContext.PKFG = 'W' TradeContext.CTFG = '7' #=====卡折取现/异地转本地==== elif(wtrbka_record['TRCCO'] in ('3000102','3000103','3000104','3000105')): AfaLoggerFunc.tradeInfo('卡折存现/本转异地') TradeContext.HostCode = '8813' TradeContext.ACUR = '1' TradeContext.RCCSMCD = PL_RCCSMCD_DZBJ TradeContext.SBAC = wtrbka_record['BESBNO'] + PL_ACC_NXYDQSLZ TradeContext.SBAC = rccpsHostFunc.CrtAcc(TradeContext.SBAC,25) TradeContext.ACNM = '农信银待清算来账' TradeContext.RBAC = wtrbka_record['BESBNO'] + PL_ACC_NXYLZ TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25) TradeContext.OTNM = '农信银来账' TradeContext.OCCAMT = str(wtrbka_record['OCCAMT'] + wtrbka_record['CUSCHRG']) TradeContext.PKFG = 'W' TradeContext.CTFG = '9' else: return AfaFlowControl.ExitThisFlow('A099','原交易交易代码非法') #=====增加原交易的状态--结转==== if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_TRAS,PL_BDWFLG_WAIT): AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow('A099','增加原交易的状态--结转,失败') else: AfaDBFunc.CommitSql() #=====调用主机交易==== rccpsHostFunc.CommHost( TradeContext.HostCode ) #=====判断主机交易是否成功==== if(TradeContext.errorCode != '0000'): AfaLoggerFunc.tradeInfo("主机交易失败") #=====更改原交易状态==== state_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN,'BCSTAT':PL_BCSTAT_TRAS,'BDWFLG':PL_BDWFLG_FAIL} state_dict['STRINFO'] = TradeContext.errorMsg if not rccpsState.setTransState(state_dict): AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow('A099','更改原交易状态失败') else: AfaDBFunc.CommitSql() return AfaFlowControl.ExitThisFlow('A099','主机记账失败') else: AfaLoggerFunc.tradeInfo('主机记账成功') #=====更改原交易状态==== state_dict = {} state_dict['BJEDTE'] = TradeContext.BJEDTE state_dict['BSPSQN'] = TradeContext.BSPSQN state_dict['BCSTAT'] = PL_BCSTAT_TRAS state_dict['BDWFLG'] = PL_BDWFLG_SUCC state_dict['STRINFO'] = '主机成功' if(TradeContext.existVariable("SBAC")): state_dict['SBAC'] = TradeContext.SBAC if(TradeContext.existVariable("RBAC")): state_dict['RBAC'] = TradeContext.RBAC if(TradeContext.existVariable('TRDT')): state_dict['TRDT'] = TradeContext.TRDT if(TradeContext.existVariable('TLSQ')): state_dict['TLSQ'] = TradeContext.TLSQ if not rccpsState.setTransState(state_dict): AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow('A099','更改原交易状态失败') else: AfaDBFunc.CommitSql() else: return AfaFlowControl.ExitThisFlow('A009','原交易不能进行清算调整') #=====给修改字典赋值==== update_dict = {} update_dict = {'ISDEAL':'1','NOTE3':'此笔错账已结转'} where_dict = {} where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO,\ 'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN} #=====修改数据库中的数据==== AfaLoggerFunc.tradeInfo("通存通兑错帐处理标识修改") res = rccpsDBTrcc_tddzcz.updateCmt(update_dict,where_dict) if( res == -1 ): return AfaFlowControl.ExitThisFlow('A099','修改通存通兑错帐处理标识失败') elif( res == 0 ): return AfaFlowControl.ExitThisFlow('A099','交易记录不存在') #=====向下发的通知表中插入数据==== AfaLoggerFunc.tradeInfo("<<<<<<向通知表中插入数据") insert_dict = {} insert_dict['NOTDAT'] = AfaUtilTools.GetHostDate( ) insert_dict['BESBNO'] = wtrbka_record['BESBNO'] if(wtrbka_record['BRSFLG'] == PL_BRSFLG_RCV): insert_dict['STRINFO'] = "此笔错账["+wtrbka_record['BSPSQN']+"]["+wtrbka_record['BJEDTE']+"]已做手工结转处理" else: insert_dict['STRINFO'] = "此笔错账["+wtrbka_record['BSPSQN']+"]["+wtrbka_record['BJEDTE']+"]已做手工结转处理 请用8522补打往账凭证" if not rccpsDBTrcc_notbka.insertCmt(insert_dict): return AfaFlowControl.ExitThisFlow('S999','向下发的通知表中插入数据失败') AfaLoggerFunc.tradeInfo("<<<<<<向通知表中插入数据成功") #=====给输出接口赋值==== TradeContext.errorCode = "0000" TradeContext.errorMsg = "修改通存通兑错帐处理标识成功" TradeContext.ISDEAL = '1' # TradeContext.TLSQ = TradeContext.TLSQ # TradeContext.RBSQ = TradeContext.RBSQ # TradeContext.TRDT = TradeContext.TRDT AfaLoggerFunc.tradeInfo( '***农信银系统: 往账.本地类操作交易[RCC001_8591]通存通兑错帐处理标识维护退出***' ) return True
def SubModuleDoTrd(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(3.中心记账).个人现金通存[TRCC002_8561]进入***' ) #=================设置业务状态为发送成功或失败,若发送失败则自动抹账======== stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BSPSQN'] = TradeContext.BSPSQN stat_dict['BESBNO'] = TradeContext.BESBNO stat_dict['BETELR'] = TradeContext.BETELR stat_dict['BCSTAT'] = PL_BCSTAT_SND stat_dict['BDWFLG'] = PL_BDWFLG_SUCC stat_dict['PRCCO'] = TradeContext.errorCode stat_dict['STRINFO'] = TradeContext.errorMsg AfaLoggerFunc.tradeInfo("TradeContext.errorCode = [" + TradeContext.errorCode + "]") if TradeContext.errorCode == '0000': AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送成功") stat_dict['BCSTAT'] = PL_BCSTAT_SND stat_dict['BDWFLG'] = PL_BDWFLG_SUCC if not rccpsState.setTransState(stat_dict): return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为发送成功异常") AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为发送成功") else: AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送失败") stat_dict['BCSTAT'] = PL_BCSTAT_SND 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(">>>开始设置业务状态为抹账处理中") #=====特殊处理 关彬捷 20081127 调8813抹账,需产生新的前置流水号进行记账==== if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 : return AfaFlowControl.ExisThisFlow('S999',"产生新的前置流水号异常") #为抹账会计分录赋值 TradeContext.HostCode='8813' TradeContext.PKFG = 'T' #通存通兑标识 TradeContext.RVFG = '2' #红蓝字标志 2 TradeContext.CATR = '0' #现转标识:0-现金 TradeContext.RCCSMCD = PL_RCCSMCD_XJTCWZ #主机摘要码:现金通存往账 TradeContext.SBAC = '' TradeContext.ACNM = '' TradeContext.RBAC = TradeContext.BESBNO + PL_ACC_NXYDQSWZ #贷方账号 TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25) TradeContext.OTNM = "农信银待清算往账" TradeContext.CTFG = '7' #结转标识:结转-0 AfaLoggerFunc.tradeInfo("借方账号1:[" + TradeContext.SBAC + "]") AfaLoggerFunc.tradeInfo("贷方账号1:[" + TradeContext.RBAC + "]") if TradeContext.CHRGTYP == '0': #现金收取手续费 TradeContext.ACUR = '2' #重复次数 TradeContext.I2PKFG = 'T' #通存通兑标识 TradeContext.I2RVFG = '2' #红蓝字标志 2 TradeContext.I2CATR = '0' #现转标识:0-现金 TradeContext.I2TRAM = TradeContext.LOCCUSCHRG #手续费金额 TradeContext.I2SMCD = PL_RCCSMCD_SXF #主机摘要码:手续费 TradeContext.I2SBAC = '' TradeContext.I2ACNM = '' TradeContext.I2RBAC = TradeContext.BESBNO + PL_ACC_TCTDSXF #贷方账号:通存通兑手续费 TradeContext.I2RBAC = rccpsHostFunc.CrtAcc(TradeContext.I2RBAC,25) TradeContext.I2OTNM = "农信银手续费" TradeContext.I2CTFG = '8' #结转标识:不结转-1 #====设置业务状态为抹账处理中==== 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(">>>结束发起主机抹账") stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BSPSQN'] = TradeContext.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_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异常") TradeContext.errorCode = '0000' AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(3.中心记账).个人现金通存[TRCC002_8561]退出***' ) return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.特殊差错账补记[8593] 进入") #=====判断必输变量是否存在==== if not TradeContext.existVariable("BESBNO"): return AfaFlowControl.ExitThisFlow('A099','没有机构号') if not TradeContext.existVariable("TRCCO"): return AfaFlowControl.ExitThisFlow('A099','没有交易代码') if not TradeContext.existVariable("CUSCHRG"): return AfaFlowControl.ExitThisFlow('A099','没有手续费金额') if not TradeContext.existVariable("OCCAMT"): return AfaFlowControl.ExitThisFlow('A099','没有交易金额') #=====得到账户的开户机构==== AfaLoggerFunc.tradeInfo("<<<<<<查询账户开户机构") TradeContext.HostCode = '8810' TradeContext.BETELR = PL_BETELR_AUTO if(TradeContext.TRCCO in ('3000102','3000103','3000104','3000105')): TradeContext.ACCNO = TradeContext.PYRACC AfaLoggerFunc.tradeDebug("ACCNO<<<<<<" + TradeContext.ACCNO) else: TradeContext.ACCNO = TradeContext.PYEACC AfaLoggerFunc.tradeDebug("ACCNO<<<<<<" + TradeContext.ACCNO) rccpsHostFunc.CommHost( TradeContext.HostCode ) AfaLoggerFunc.tradeDebug("errorCode<<<<<<" + TradeContext.errorCode) AfaLoggerFunc.tradeDebug("errorMsg<<<<<<" + TradeContext.errorMsg) AfaLoggerFunc.tradeInfo("<<<<<<判断主机8810交易是否成功") if(TradeContext.errorCode != '0000'): return AfaFlowControl.ExitThisFlow('S999',TradeContext.errorMsg) else: AfaLoggerFunc.tradeInfo("<<<<<<8810交易成功") TradeContext.BESBNO = TradeContext.ACCSO AfaLoggerFunc.tradeInfo("<<<<<<结束查询账户开户机构") #=====生成保单序号,成员行号,接收行号,接收行名,前置日期,前置流水号==== # if not rccpsFunc.GetNCCDate( ) : #NCCWKDAT # raise AfaFlowControl.flowException( ) # TradeContext.NCCWKDAT = TradeContext.NCCworkDate TradeContext.NCCworkDate = TradeContext.NCCWKDAT where_dict = {} #发送成员行号 where_dict['BANKBIN'] = TradeContext.SNDBNKCO record = rccpsDBTrcc_paybnk.selectu(where_dict) if(record == None): return AfaFlowControl.ExitThisFlow('A099','查询行名行号表失败') elif(len(record) == 0): return AfaFlowControl.ExitThisFlow('A099','查询行名行号表结果为空') else: TradeContext.STLBANKBIN = record['STLBANKBIN'] # where_dict = {} #接收行号,接收行名 # where_dict['BESBNO'] = TradeContext.BESBNO # record_tmp = rccpsDBTrcc_subbra.selectu(where_dict) # if(record_tmp == None): # return AfaFlowControl.ExitThisFlow('A099','查询机构表失败') # elif(len(record_tmp) == 0): # return AfaFlowControl.ExitThisFlow('A099','查询机构表结果为空') # else: # TradeContext.BANKBIN = record_tmp['BANKBIN'] # where_dict = {} # where_dict['BANKBIN'] = TradeContext.BANKBIN # record = None # record = rccpsDBTrcc_paybnk.selectu(where_dict) # if(record == None): # return AfaFlowControl.ExitThisFlow('A099','查询行名行号表失败') # elif(len(record) == 0): # AfaLoggerFunc.tradeInfo("此机构无行号") # TradeContext.RCVBNKNM = "" # TradeContext.RCVBNKCO = "" # else: # TradeContext.RCVBNKNM = record['BANKNAM'] # TradeContext.RCVBNKCO = record['BANKBIN'] TradeContext.BJEDTE = AfaUtilTools.GetHostDate( ) #BJEDTE TradeContext.FEDT = AfaUtilTools.GetHostDate( ) #FEDT if rccpsGetFunc.GetRBSQ(PL_BRSFLG_RCV) == -1 : #RBSQ return AfaFlowControl.ExitThisFlow('S999','重新生成前置流水号失败,抛弃报文') TradeContext.BSPSQN = TradeContext.RBSQ #=====向通存通兑业务登记簿插入数据==== AfaLoggerFunc.tradeInfo("<<<<<<登记通存通兑业务登记簿") insert_dict = {} insert_dict['BJEDTE'] = TradeContext.BJEDTE insert_dict['BSPSQN'] = TradeContext.BSPSQN insert_dict['BRSFLG'] = "1" insert_dict['BEACSB'] = "" insert_dict['BETELR'] = TradeContext.BETELR insert_dict['BEAUUS'] = TradeContext.BEAUUS insert_dict['BEAUPS'] = TradeContext.BEAUPS insert_dict['TERMID'] = TradeContext.TERMID insert_dict['BESBNO'] = TradeContext.BESBNO insert_dict['BBSSRC'] = "" insert_dict['DASQ'] = "" if(TradeContext.TRCCO in ('3000002','3000003','3000004','3000005')): insert_dict['DCFLG'] = PL_DCFLG_DEB else: insert_dict['DCFLG'] = PL_DCFLG_CRE if(TradeContext.TRCCO in ('3000002','3000004')): insert_dict['OPRNO'] = PL_TDOPRNO_TC elif(TradeContext.TRCCO in ('3000003','3000005')): insert_dict['OPRNO'] = PL_TDOPRNO_BZY elif(TradeContext.TRCCO in ('3000102','3000104')): insert_dict['OPRNO'] = PL_TDOPRNO_TD else: insert_dict['OPRNO'] = PL_TDOPRNO_YZB insert_dict['OPRATTNO'] = "" insert_dict['NCCWKDAT'] = TradeContext.NCCWKDAT insert_dict['TRCCO'] = TradeContext.TRCCO insert_dict['TRCDAT'] = TradeContext.TRCDAT insert_dict['TRCNO'] = TradeContext.TRCNO insert_dict['MSGFLGNO'] = "" insert_dict['COTRCDAT'] = "" insert_dict['COTRCNO'] = "" insert_dict['COMSGFLGNO'] = "" insert_dict['SNDMBRCO'] = TradeContext.STLBANKBIN insert_dict['RCVMBRCO'] = "1340000008" insert_dict['SNDBNKCO'] = TradeContext.SNDBNKCO insert_dict['SNDBNKNM'] = TradeContext.SNDBNKNM insert_dict['RCVBNKCO'] = TradeContext.RCVBNKCO insert_dict['RCVBNKNM'] = TradeContext.RCVBNKNM insert_dict['CUR'] = "01" insert_dict['OCCAMT'] = TradeContext.OCCAMT if(float(TradeContext.CUSCHRG) != 0.00 and TradeContext.CUSCHRG != ""): insert_dict['CHRGTYP']= PL_CHRG_TYPE chrgtyp = 1 else: insert_dict['CHRGTYP']= PL_CHRG_CASH chrgtyp = 0 insert_dict['LOCCUSCHRG'] = "" insert_dict['CUSCHRG'] = TradeContext.CUSCHRG insert_dict['PYRTYP'] = "" insert_dict['PYRACC'] = TradeContext.PYRACC insert_dict['PYRNAM'] = TradeContext.PYRNAM insert_dict['PYRADDR'] = "" insert_dict['PYETYP'] = "" insert_dict['PYEACC'] = TradeContext.PYEACC insert_dict['PYENAM'] = TradeContext.PYENAM insert_dict['PYEADDR'] = "" insert_dict['STRINFO'] = TradeContext.STRINFO insert_dict['CERTTYPE'] = "" insert_dict['CERTNO'] = "" insert_dict['BNKBKNO'] = "" insert_dict['BNKBKBAL'] = "" insert_dict['NOTE1'] = "" insert_dict['NOTE2'] = "" insert_dict['NOTE3'] = "" insert_dict['NOTE4'] = "" if not rccpsDBTrcc_wtrbka.insertCmt(insert_dict): return AfaFlowControl.ExitThisFlow('A099','登记通存通兑登记簿失败') AfaLoggerFunc.tradeInfo("<<<<<<结束登记通存通兑业务登记簿") #=====查询刚刚插入到业务登记簿中的数据==== where_dict = {} where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN} wtrbka_record = rccpsDBTrcc_wtrbka.selectu(where_dict) if(wtrbka_record == None): return AfaFlowControl.ExitThisFlow('A099','查询通存通兑业务登记簿失败') elif(len(wtrbka_record) == 0): return AfaFlowControl.ExitThisFlow('A099','登记通存通兑业务登记簿结果为空') else: AfaLoggerFunc.tradeInfo("查询通存通兑业务登记簿成功") #=====向错账登记簿插入数据==== AfaLoggerFunc.tradeInfo("<<<<<<登记错账登记簿") insert_dict = {} insert_dict['NCCWKDAT'] = TradeContext.NCCWKDAT insert_dict['SNDBNKCO'] = TradeContext.SNDBNKCO insert_dict['TRCDAT'] = TradeContext.TRCDAT insert_dict['TRCNO'] = TradeContext.TRCNO insert_dict['RCVBNKCO'] = TradeContext.RCVBNKCO insert_dict['SNDMBRCO'] = TradeContext.STLBANKBIN insert_dict['RCVMBRCO'] = "1340000008" insert_dict['TRCCO'] = TradeContext.TRCCO if(TradeContext.TRCCO in ('3000002','3000003','3000004','3000005')): insert_dict['DCFLG'] = PL_DCFLG_DEB else: insert_dict['DCFLG'] = PL_DCFLG_CRE insert_dict['PYRACC'] = TradeContext.PYRACC insert_dict['PYEACC'] = TradeContext.PYEACC insert_dict['CUR'] = "01" insert_dict['OCCAMT'] = TradeContext.OCCAMT insert_dict['LOCOCCAMT'] = TradeContext.OCCAMT if(TradeContext.TRCCO in ('3000102','3000103','3000104','3000105') and wtrbka_record['CHRGTYP'] == PL_CHRG_TYPE ): insert_dict['CUSCHRG'] = TradeContext.CUSCHRG insert_dict['LOCCUSCHRG'] = TradeContext.CUSCHRG else: insert_dict['CUSCHRG'] = 0.00 insert_dict['LOCCUSCHRG'] = 0.00 insert_dict['ORTRCNO'] = "" insert_dict['BJEDTE'] = AfaUtilTools.GetHostDate( ) insert_dict['BSPSQN'] = TradeContext.BSPSQN insert_dict['EACTYP'] = "11" insert_dict['EACINF'] = "中心无,行内无" insert_dict['LOCEACTYP'] = "11" insert_dict['LOCEACINF'] = "中心无,行内无" insert_dict['ISDEAL'] = PL_ISDEAL_UNDO insert_dict['NOTE1'] = "" insert_dict['NOTE2'] = "" insert_dict['NOTE3'] = "" insert_dict['NOTE4'] = "" if not rccpsDBTrcc_tddzcz.insertCmt(insert_dict): return AfaFlowControl.ExitThisFlow('A099','登记通存通兑登记簿失败') AfaLoggerFunc.tradeInfo("<<<<<<结束登记错账登记簿") #=====查询刚刚插入到业务登记簿中的数据==== where_dict = {} where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN} tddzcz_record = rccpsDBTrcc_tddzcz.selectu(where_dict) if(tddzcz_record == None): return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿失败') elif(len(tddzcz_record) == 0): return AfaFlowControl.ExitThisFlow('A099','登记错账登记簿结果为空') else: AfaLoggerFunc.tradeInfo("查询错账登记簿成功") #=====开始给会计分录赋值==== AfaLoggerFunc.tradeInfo("<<<<<<开始给会计分录赋值") TradeContext.BRSFLG = PL_BRSFLG_RCV TradeContext.BETELR = PL_BETELR_AUTO AfaLoggerFunc.tradeInfo("<<<<<<BETELR==" + TradeContext.BETELR) input_dict = {} input_dict['FEDT'] = TradeContext.FEDT input_dict['RBSQ'] = TradeContext.RBSQ input_dict['PYRACC'] = wtrbka_record['PYRACC'] input_dict['PYRNAM'] = wtrbka_record['PYRNAM'] input_dict['PYEACC'] = wtrbka_record['PYEACC'] input_dict['PYENAM'] = wtrbka_record['PYENAM'] input_dict['CHRGTYP'] = wtrbka_record['CHRGTYP'] input_dict['OCCAMT'] = wtrbka_record['OCCAMT'] input_dict['CUSCHRG'] = wtrbka_record['CUSCHRG'] if(wtrbka_record['TRCCO'] in ('3000002','3000004')): AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通存来账记账") input_dict['RCCSMCD'] = PL_RCCSMCD_XJTCLZ rccpsEntriesErr.KZTCLZJZ(input_dict) elif(wtrbka_record['TRCCO'] in ('3000003','3000005')): AfaLoggerFunc.tradeDebug("<<<<<<卡折本转异来账记账") input_dict['RCCSMCD'] = PL_RCCSMCD_BZYLZ rccpsEntriesErr.KZBZYLZJZ(input_dict) elif(wtrbka_record['TRCCO'] in ('3000102','3000104')): AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通兑来账记账") input_dict['RCCSMCD'] = PL_RCCSMCD_XJTDLZ rccpsEntriesErr.KZTDLZJZ(input_dict) elif(wtrbka_record['TRCCO'] in ('3000103','3000105')): AfaLoggerFunc.tradeDebug("<<<<<<卡折异转本来账记账") input_dict['RCCSMCD'] = PL_RCCSMCD_YZBLZ rccpsEntriesErr.KZYZBLZJZ(input_dict) else: return AfaFlowControl.ExitThisFlow('A099','交易代码非法') AfaLoggerFunc.tradeInfo("<<<<<<给会计分录赋值结束") #=====主机前设置原交易状态==== AfaLoggerFunc.tradeInfo("<<<<<<主机前设置原交易状态") if not rccpsState.newTransState(wtrbka_record['BJEDTE'],wtrbka_record['BSPSQN'],PL_BCSTAT_ACC,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow('S999','设置业务状态为记账处理中异常') else: AfaDBFunc.CommitSql() #=====调用主机交易==== AfaLoggerFunc.tradeInfo("<<<<<<开始调用主机交易") rccpsHostFunc.CommHost( TradeContext.HostCode ) AfaLoggerFunc.tradeInfo("<<<<<<结束调用主机交易") AfaLoggerFunc.tradeDebug("errorCode<<<<<<" + TradeContext.errorCode) AfaLoggerFunc.tradeDebug("errorMsg<<<<<<" + TradeContext.errorMsg) #=====给状态字典赋值==== state_dict = {} state_dict['BJEDTE'] = wtrbka_record['BJEDTE'] state_dict['BSPSQN'] = wtrbka_record['BSPSQN'] state_dict['MGID'] = TradeContext.errorCode if TradeContext.existVariable('TRDT'): state_dict['TRDT'] = TradeContext.TRDT if TradeContext.existVariable('TLSQ'): state_dict['TLSQ'] = TradeContext.TLSQ if TradeContext.existVariable('RBSQ'): state_dict['RBSQ'] = TradeContext.RBSQ if TradeContext.existVariable('FEDT'): state_dict['FEDT'] = TradeContext.FEDT #=====判断主机交易是否成功==== AfaLoggerFunc.tradeInfo("<<<<<<判断主机交易是否成功") AfaLoggerFunc.tradeDebug("<<<<<<errorCode=" + TradeContext.errorCode) if(TradeContext.errorCode != '0000'): AfaLoggerFunc.tradeInfo("调用主机交易失败") #=====主机后更改原交易状态为失败==== state_dict['BDWFLG'] = PL_BDWFLG_FAIL state_dict['STRINFO'] = TradeContext.errorMsg state_dict['NOTE3'] = "特殊差错账补记失败" state_dict['BCSTAT'] = PL_BCSTAT_ACC if not rccpsState.setTransState(state_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务状态为失败异常') else: AfaDBFunc.CommitSql() return AfaFlowControl.ExitThisFlow('S999',TradeContext.errorMsg) else: #=====主机后更改原交易状态为成功==== state_dict['BDWFLG'] = PL_BDWFLG_SUCC state_dict['STRINFO'] = '主机成功' state_dict['NOTE3'] = "特殊差错账补记成功" if(TradeContext.TRCCO in('3000002','3000004','3000005','3000003')): #通存 state_dict['BCSTAT'] = PL_BCSTAT_AUTO else: state_dict['BCSTAT'] = PL_BCSTAT_AUTOPAY if(TradeContext.existVariable("SBAC")): state_dict['SBAC'] = TradeContext.SBAC if(TradeContext.existVariable("RBAC")): state_dict['RBAC'] = TradeContext.RBAC if not rccpsState.setTransState(state_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务状态失败') else: AfaDBFunc.CommitSql() # bcsata = "" #状态标识 # if(TradeContext.TRCCO in('3000002','3000004','3000005','3000003')): #通存 # bcstat = PL_BCSTAT_AUTO # else: # bcstat = PL_BCSTAT_AUTOPAY # if not rccpsState.newTransState(wtrbka_record['BJEDTE'],wtrbka_record['BSPSQN'],bcstat,PL_BDWFLG_SUCC): # return AfaFlowControl.ExitThisFlow('S999','设置业务状态异常') # else: # AfaDBFunc.CommitSql() #=====更改错账登记簿中的处理标示==== AfaLoggerFunc.tradeInfo("<<<<<<更改错账登记簿中的处理标示") where_dict = {} where_dict = {'BJEDTE':tddzcz_record['BJEDTE'],'BSPSQN':tddzcz_record['BSPSQN']} update_dict = {} update_dict['ISDEAL'] = PL_ISDEAL_ISDO update_dict['NOTE3'] = '此笔错账已补记' res = rccpsDBTrcc_tddzcz.updateCmt(update_dict,where_dict) if(res == -1): return AfaFlowControl.ExitThisFlow('S999','主机记账已成功,但更新处理标示失败,请手动更改处理标示') else: AfaLoggerFunc.tradeInfo("<<<<<<更改错账登记簿中的处理标示成功") #=====向下发的通知表中插入数据==== AfaLoggerFunc.tradeInfo("<<<<<<向通知表中插入数据") insert_dict = {} insert_dict['NOTDAT'] = AfaUtilTools.GetHostDate( ) insert_dict['BESBNO'] = wtrbka_record['BESBNO'] if(wtrbka_record['BRSFLG'] == PL_BRSFLG_RCV): insert_dict['STRINFO'] = "此笔错账["+wtrbka_record['BSPSQN']+"]["+wtrbka_record['BJEDTE']+"]已处理" else: insert_dict['STRINFO'] = "此笔错账["+wtrbka_record['BSPSQN']+"]["+wtrbka_record['BJEDTE']+"]已处理 请用8522补打往账凭证" if not rccpsDBTrcc_notbka.insertCmt(insert_dict): return AfaFlowControl.ExitThisFlow('S999','向下发的通知表中插入数据失败') AfaLoggerFunc.tradeInfo("<<<<<<向通知表中插入数据成功") #=====给输出接口赋值==== AfaLoggerFunc.tradeInfo("<<<<<<开始给输出接口赋值") TradeContext.TRCCO = wtrbka_record['TRCCO'] TradeContext.BRSFLG = wtrbka_record['BRSFLG'] TradeContext.BEACSB = wtrbka_record['BESBNO'] TradeContext.OCCAMT = str(wtrbka_record['OCCAMT']) TradeContext.BSPSQN = state_dict['TLSQ'] TradeContext.BJEDTE = wtrbka_record['BJEDTE'] AfaLoggerFunc.tradeInfo("<<<<<<结束给输出接口赋值") AfaLoggerFunc.tradeInfo("<<<<<<<个性化处理(本地操作) 退出") AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.特殊差错账补记[8593] 退出") return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.回执类操作(1.回执操作).通存通兑冲销应答报文接收[TRC004_1162]进入***' ) #=================初始化返回信息============================================ 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) #查询冲正登记簿中是否有对此冲销交易的冲正 AfaLoggerFunc.tradeInfo(">>>开始检查此冲销交易是否已被冲正") where_sql = "ORMFN = '" + TradeContext.ORMFN + "'" ret = rccpsDBTrcc_atcbka.count(where_sql) if ret < 0: return AfaFlowControl.ExitThisFlow("S999","查询冲正登记簿异常,退出主流程") if ret > 0: return AfaFlowControl.ExitThisFlow("S999","冲正登记簿中存在对此冲销交易的冲正,退出主流程") AfaLoggerFunc.tradeInfo(">>>结束检查此冲销交易是否已被冲正") #=====更改柜员号和机构号为发起柜员号、发起机构号==== AfaLoggerFunc.tradeInfo("<<<<<<开始更改柜员号,机构号") #=====查找冲销交易的信息===== mpcbka_where_dict = {} mpcbka_where_dict['MSGFLGNO'] = TradeContext.ORMFN mpcbka_record = rccpsDBTrcc_mpcbka.selectu(mpcbka_where_dict) if(mpcbka_record == None): return AfaFlowControl.ExitThisFlow("S999","查询原冲销交易信息异常") if(len(mpcbka_record) <= 0): return AfaFlowControl.ExitThisFlow("S999","未找到原冲销交易信息,丢弃报文") #=====给机构号和柜员号赋值==== TradeContext.BETELR = mpcbka_record['BETELR'] TradeContext.BESBNO = mpcbka_record['BESBNO'] AfaLoggerFunc.tradeInfo("<<<<<<更改柜员号,机构号结束") #更新冲销登记簿中心返回信息 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(">>>结束更新冲销登记簿中心返回信息") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") #=====查询被冲销交易信息==== AfaLoggerFunc.tradeInfo("<<<<<<开始查询被冲销的交易的信息") wtrbka_record = {} if not rccpsDBFunc.getTransWtr(mpcbka_record['BOJEDT'],mpcbka_record['BOSPSQ'],wtrbka_record): return AfaFlowControl.ExitThisFlow("S999","查询被冲销原交易详细信息异常") AfaLoggerFunc.tradeInfo("<<<<<<结束查询被冲销的交易的信息") #====为终端号和往来标识赋值==== TradeContext.TERMID = wtrbka_record['TERMID'] TradeContext.BRSFLG = wtrbka_record['BRSFLG'] #=====判断对方行冲销是否成功===== AfaLoggerFunc.tradeInfo("<<<<<<判断对方行冲销是否成功PRCCO=[" + TradeContext.PRCCO + "]") if(TradeContext.PRCCO == 'RCCI0000' or TradeContext.PRCCO == 'RCCO1106'): AfaLoggerFunc.tradeInfo("<<<<<<对方行冲销成功") #=====发起主机记账==== AfaLoggerFunc.tradeInfo("<<<<<<开始发起主机记账") #=====取最后一个记账成功状态的前置日期和前置流水号==== stat_list = [] if rccpsState.getTransStateSetm(wtrbka_record['BJEDTE'],wtrbka_record['BSPSQN'],PL_BCSTAT_ACC,PL_BDWFLG_SUCC,stat_list): entries_dict = {} entries_dict['FEDT'] = stat_list[0]['FEDT'] entries_dict['RBSQ'] = stat_list[0]['RBSQ'] entries_dict['PYRACC'] = wtrbka_record['PYRACC'] entries_dict['PYRNAM'] = wtrbka_record['PYRNAM'] entries_dict['PYEACC'] = wtrbka_record['PYEACC'] entries_dict['PYENAM'] = wtrbka_record['PYENAM'] entries_dict['OCCAMT'] = wtrbka_record['OCCAMT'] entries_dict['CHRGTYP'] = wtrbka_record['CHRGTYP'] entries_dict['CUSCHRG'] = wtrbka_record['CUSCHRG'] entries_dict['RCCSMCD'] = PL_RCCSMCD_CX TradeContext.BRSFLG = wtrbka_record['BRSFLG'] #卡折通存往账抹账会计分录赋值 if wtrbka_record['TRCCO'] == '3000002' or wtrbka_record['TRCCO'] == '3000004': rccpsEntries.KZTCWZMZ(entries_dict) #卡折本转异往账抹账会计分录赋值 if wtrbka_record['TRCCO'] == '3000003' or wtrbka_record['TRCCO'] == '3000005': rccpsEntries.KZBZYWZMZ(entries_dict) #卡折通兑往账抹账会计分录赋值 if wtrbka_record['TRCCO'] == '3000102' or wtrbka_record['TRCCO'] == '3000104': rccpsEntries.KZTDWZMZ(entries_dict) #卡折异转本往账抹账会计分录赋值 if wtrbka_record['TRCCO'] == '3000103' or wtrbka_record['TRCCO'] == '3000105': rccpsEntries.KZYZBWZMZ(entries_dict) #=====生成新的前置日期和前置流水号,并且更新到数据库中==== if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 : return AfaFlowControl.ExisThisFlow('S999',"产生新的前置流水号异常") #设置原交易状态为冲销处理中 AfaLoggerFunc.tradeInfo('>>>开始设置原交易状态为冲销处理中') if not rccpsState.newTransState(mpcbka_record['BOJEDT'],mpcbka_record['BOSPSQ'],PL_BCSTAT_CANC,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(mpcbka_record['BOJEDT'],mpcbka_record['BOSPSQ'],PL_BCSTAT_CANC,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'] = wtrbka_record['BJEDTE'] stat_dict['BSPSQN'] = wtrbka_record['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_CANC 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_CANC stat_dict['BDWFLG'] = PL_BDWFLG_FAIL if not rccpsState.setTransState(stat_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务状态冲销失败异常') AfaLoggerFunc.tradeInfo("<<<<<<<结束更改原交易状态为冲销失败") else: AfaLoggerFunc.tradeInfo("<<<<<<对方行冲销拒绝应答,不设置原交易状态") ##设置原交易状态为冲销处理中 #AfaLoggerFunc.tradeInfo('>>>开始设置原交易状态为冲销处理中') # #if not rccpsState.newTransState(wtrbka_record['BJEDTE'],wtrbka_record['BSPSQN'],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("<<<<<<<开始更改原交易状态为冲销失败") # #stat_dict = {} #stat_dict['BJEDTE'] = wtrbka_record['BJEDTE'] #stat_dict['BSPSQN'] = wtrbka_record['BSPSQN'] #stat_dict['PRCCO'] = TradeContext.PRCCO #stat_dict['STRINFO']= TradeContext.STRINFO #stat_dict['BCSTAT'] = PL_BCSTAT_CANC #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_1162]退出***' ) return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.差错抹账[8571] 进入") AfaLoggerFunc.tradeInfo("<<<<<<<个性化处理(本地操作) 进入") #=====校验变量的合法性==== AfaLoggerFunc.tradeInfo("<<<<<<校验变量的合法性") if not TradeContext.existVariable("TRCDAT"): return AfaFlowControl.ExitThisFlow('A099','没有委托日期') if not TradeContext.existVariable("SNDBNKCO"): return AfaFlowControl.ExitThisFlow('A099','没有发送行号') if not TradeContext.existVariable("TRCNO"): return AfaFlowControl.ExitThisFlow('A099','没有交易流水号') AfaLoggerFunc.tradeInfo("<<<<<<校验变量的合法性结束") #=====产生FEDT,RBSQ,NCCworkDate,BJEDTE==== TradeContext.BJEDTE = AfaUtilTools.GetHostDate( ) #BJEDTE TradeContext.FEDT=AfaUtilTools.GetHostDate( ) #FEDT if not rccpsFunc.GetNCCDate( ) : #NCCworkDate raise AfaFlowControl.flowException( ) if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 : #RBSQ return AfaFlowControl.ExitThisFlow('A099','产生前置流水号失败') #=====查询交易信息==== AfaLoggerFunc.tradeInfo("<<<<<<开始查询通存通兑业务登记簿") where_dict = {} where_dict = {'TRCNO':TradeContext.TRCNO,'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT} wtrbka_record_dict = rccpsDBTrcc_wtrbka.selectu(where_dict) if(wtrbka_record_dict == None): return AfaFlowControl.ExitThisFlow('A099','查询通存通兑业务登记簿失败') elif(len(wtrbka_record_dict) == 0): return AfaFlowControl.ExitThisFlow('A099','查询通存通兑业务登记簿结果为空') else: AfaLoggerFunc.tradeInfo("<<<<<<查询通存通兑业务登记簿成功") #=====查询错账登记簿====== AfaLoggerFunc.tradeInfo("<<<<<<开始查询错账登记簿") where_dict = {} where_dict = {'TRCNO':TradeContext.TRCNO,'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT} tddzcz_record_dict = rccpsDBTrcc_tddzcz.selectu(where_dict) if(tddzcz_record_dict == None): return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿失败') elif(len(tddzcz_record_dict) == 0): AfaLoggerFunc.tradeInfo("<<<<<<查询错账登记簿为空,应向其中补记一笔") insert_dict = {} insert_dict['NCCWKDAT'] = wtrbka_record_dict['NCCWKDAT'] insert_dict['SNDBNKCO'] = wtrbka_record_dict['SNDBNKCO'] insert_dict['TRCDAT'] = wtrbka_record_dict['TRCDAT'] insert_dict['TRCNO'] = wtrbka_record_dict['TRCNO'] insert_dict['RCVBNKCO'] = wtrbka_record_dict['RCVBNKCO'] insert_dict['SNDMBRCO'] = wtrbka_record_dict['SNDMBRCO'] insert_dict['RCVMBRCO'] = wtrbka_record_dict['RCVMBRCO'] insert_dict['TRCCO'] = wtrbka_record_dict['TRCCO'] insert_dict['DCFLG'] = wtrbka_record_dict['DCFLG'] insert_dict['PYRACC'] = wtrbka_record_dict['PYRACC'] insert_dict['PYEACC'] = wtrbka_record_dict['PYEACC'] insert_dict['CUR'] = 'CNY' insert_dict['OCCAMT'] = wtrbka_record_dict['OCCAMT'] insert_dict['LOCOCCAMT'] = wtrbka_record_dict['OCCAMT'] if(wtrbka_record_dict['TRCCO'] in ('3000102','3000103','3000104','3000105') and wtrbka_record_dict['CHRGTYP'] == '1'): insert_dict['CUSCHRG'] = wtrbka_record_dict['CUSCHRG'] insert_dict['LOCCUSCHRG'] = wtrbka_record_dict['CUSCHRG'] else: insert_dict['CUSCHRG'] = 0.00 insert_dict['LOCCUSCHRG'] = 0.00 insert_dict['ORTRCNO'] = "" insert_dict['BJEDTE'] = wtrbka_record_dict['BJEDTE'] insert_dict['BSPSQN'] = wtrbka_record_dict['BSPSQN'] insert_dict['EACTYP'] = "" insert_dict['EACINF'] = "" insert_dict['LOCEACTYP'] = "" insert_dict['LOCEACINF'] = "" insert_dict['ISDEAL'] = "0" insert_dict['NOTE1'] = "" insert_dict['NOTE2'] = "" insert_dict['NOTE3'] = "" insert_dict['NOTE4'] = "" #=====向错账登记簿中补记此笔交易==== if not rccpsDBTrcc_tddzcz.insertCmt(insert_dict): return AfaFlowControl.ExitThisFlow('A099','向错账登记簿中补记交易失败') #=====补查错账登记簿,将刚插入的数据查出来==== AfaLoggerFunc.tradeInfo("<<<<<<补查错账登记簿") where_dict = {} where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO} tddzcz_record_dict = rccpsDBTrcc_tddzcz.selectu(where_dict) if(tddzcz_record_dict == None): return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿失败') elif(len(tddzcz_record_dict) == 0): return AfaFlowControl.ExitThisFlow('A099','查询通错账登记簿结果为空') else: AfaLoggerFunc.tradeInfo("<<<<<<补查错账登记簿成功") else: AfaLoggerFunc.tradeInfo("<<<<<<查询错账登记簿成功") #=====判断此笔业务是否已经处理==== if(tddzcz_record_dict['ISDEAL'] == PL_ISDEAL_ISDO): return AfaFlowControl.ExitThisFlow('A099','此笔账务已经处理过') #=====开始行内抹账==== AfaLoggerFunc.tradeInfo("<<<<<<开始行内抹账") input_dict = {} input_dict['PYRACC'] = wtrbka_record_dict['PYRACC'] input_dict['PYRNAM'] = wtrbka_record_dict['PYRNAM'] input_dict['PYEACC'] = wtrbka_record_dict['PYEACC'] input_dict['PYENAM'] = wtrbka_record_dict['PYENAM'] input_dict['CHRGTYP'] = wtrbka_record_dict['CHRGTYP'] input_dict['OCCAMT'] = wtrbka_record_dict['OCCAMT'] input_dict['CUSCHRG'] = wtrbka_record_dict['CUSCHRG'] input_dict['RCCSMCD'] = PL_RCCSMCD_CX TradeContext.NCCworkDate = wtrbka_record_dict['NCCWKDAT'] TradeContext.BESBNO = wtrbka_record_dict['BESBNO'] TradeContext.BETELR = PL_BETELR_AUTO TradeContext.TERMID = wtrbka_record_dict['TERMID'] #=====判断原交易的往来标示==== AfaLoggerFunc.tradeInfo("<<<<<<判断原交易是来账还是往账") if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_SND): AfaLoggerFunc.tradeInfo("<<<<<原业务为往账") TradeContext.BRSFLG = PL_BRSFLG_SND if(wtrbka_record_dict['TRCCO'] in ('3000002','3000004')): AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通存往账抹账") rccpsEntriesErr.KZTCWZMZ(input_dict) elif(wtrbka_record_dict['TRCCO'] in ('3000003','3000005')): AfaLoggerFunc.tradeDebug("<<<<<<卡折本转异往账抹账") rccpsEntriesErr.KZBZYWZMZ(input_dict) elif(wtrbka_record_dict['TRCCO'] in ('3000102','3000104')): AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通兑往账抹账") rccpsEntriesErr.KZTDWZMZ(input_dict) elif(wtrbka_record_dict['TRCCO'] in ('3000103','3000105')): AfaLoggerFunc.tradeDebug("<<<<<<卡折异转本往账抹账") rccpsEntriesErr.KZYZBWZMZ(input_dict) else: return AfaFlowControl.ExitThisFlow('S999','非法交易代码') else: AfaLoggerFunc.tradeInfo("<<<<<原业务为来账") TradeContext.BRSFLG = PL_BRSFLG_RCV if(wtrbka_record_dict['TRCCO'] in ('3000002','3000004')): AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通存来账抹账") rccpsEntriesErr.KZTCLZMZ(input_dict) elif(wtrbka_record_dict['TRCCO'] in ('3000003','3000005')): AfaLoggerFunc.tradeDebug("<<<<<<卡折本转异来账抹账") rccpsEntriesErr.KZBZYLZMZ(input_dict) elif(wtrbka_record_dict['TRCCO'] in ('3000102','3000104')): AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通兑来账抹账") rccpsEntriesErr.KZTDLZMZ(input_dict) elif(wtrbka_record_dict['TRCCO'] in ('3000103','3000105')): AfaLoggerFunc.tradeDebug("<<<<<<卡折异转本来账抹账") rccpsEntriesErr.KZYZBLZMZ(input_dict) else: return AfaFlowControl.ExitThisFlow('S999','非法交易代码') #=====判断当前状态是否允许抹账==== # AfaLoggerFunc.tradeInfo("<<<<<<判断交易当前状态是否允许抹账") # stat_dict = {} # res = rccpsState.getTransStateCur(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],stat_dict) # if(res == False): # return AfaFlowControl.ExitThisFlow('A099','查询业务的当前状态失败') # else: # AfaLoggerFunc.tradeInfo("查询业务当前状态成功") # # if(stat_dict['BCSTAT'] in (PL_BCSTAT_HCAC,PL_BCSTAT_CANC,PL_BCSTAT_CANCEL) and stat_dict['BDWFLG'] == PL_BDWFLG_SUCC): # return AfaFlowControl.ExitThisFlow('S999','原业务当前状态不需要抹账,请手工更改处理标识') acc = 0 autopay = 0 auto = 0 hcac = 0 canc = 0 cancel = 0 #=====查询是否有记账成功的状态==== sstlog_list = [] if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_ACC,PL_BDWFLG_SUCC,sstlog_list): acc = len(sstlog_list) sstlog_list = [] if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_AUTOPAY,PL_BDWFLG_SUCC,sstlog_list): autopay = len(sstlog_list) sstlog_list = [] if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_AUTO,PL_BDWFLG_SUCC,sstlog_list): auto = len(sstlog_list) #=====查询是否有抹账的状态==== sstlog_list = [] if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_HCAC,PL_BDWFLG_SUCC,sstlog_list): hcac = len(sstlog_list) #=====查询是否有冲销的状态==== sstlog_list = [] if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_CANC,PL_BDWFLG_SUCC,sstlog_list): canc = len(sstlog_list) #=====查询是否有冲正的状态==== ssltog_list = [] if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_CANCEL,PL_BDWFLG_SUCC,sstlog_list): cancel = len(sstlog_list) if((acc + autopay + auto) - (hcac + canc + cancel) <= 0): return AfaFlowControl.ExitThisFlow('S999','此交易未记账或已抹账,禁止提交') AfaLoggerFunc.tradeInfo("<<<<<<结束判断交易当前状态是否允许抹账") #=====在上主机前设置原交易的状态==== AfaLoggerFunc.tradeInfo("<<<<<<在上主机前设置原交易的状态") if not rccpsState.newTransState(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_HCAC,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow('S999','设置业务状态为抹账处理中异常') else: AfaDBFunc.CommitSql() #=====开始调用主机交易==== AfaLoggerFunc.tradeInfo("<<<<<<开始调用主机交易") rccpsHostFunc.CommHost( TradeContext.HostCode ) AfaLoggerFunc.tradeInfo("<<<<<<结束调用主机交易") AfaLoggerFunc.tradeInfo("<<<<<<行内抹账结束") #=====给状态字典赋值==== state_dict = {} state_dict['BJEDTE'] = wtrbka_record_dict['BJEDTE'] state_dict['BSPSQN'] = wtrbka_record_dict['BSPSQN'] state_dict['BCSTAT'] = PL_BCSTAT_HCAC state_dict['MGID'] = TradeContext.errorCode state_dict['STRINFO']= TradeContext.errorMsg if TradeContext.existVariable('TRDT'): state_dict['TRDT'] = TradeContext.TRDT if TradeContext.existVariable('TLSQ'): state_dict['TLSQ'] = TradeContext.TLSQ if TradeContext.existVariable('RBSQ'): state_dict['RBSQ'] = TradeContext.RBSQ if TradeContext.existVariable('FEDT'): state_dict['FEDT'] = TradeContext.FEDT #=====判断主机抹账是否成功==== AfaLoggerFunc.tradeInfo("<<<<<<判断主机抹账是否成功") AfaLoggerFunc.tradeDebug("<<<<<<errorCode=" + TradeContext.errorCode) if(TradeContext.errorCode != '0000'): AfaLoggerFunc.tradeDebug("主机抹账失败") #=====主机后更改原交易为失败==== AfaLoggerFunc.tradeInfo("<<<<<<主机后更改原交易为抹失败") state_dict['BDWFLG'] = PL_BDWFLG_FAIL state_dict['STRINFO'] = TradeContext.errorMsg if not rccpsState.setTransState(state_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务为失败异常') else: AfaDBFunc.CommitSql() return AfaFlowControl.ExitThisFlow('S999','主机抹账失败') else: AfaLoggerFunc.tradeInfo("<<<<<<主机抹账成功") #=====主机后更改原交易状态===== AfaLoggerFunc.tradeInfo("<<<<<<主机后更改原交易为成功") state_dict['BDWFLG'] = PL_BDWFLG_SUCC state_dict['STRINFO'] = '主机成功' if not rccpsState.setTransState(state_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务为成功异常') else: AfaDBFunc.CommitSql() #=====更改错账登记簿中的处理标示==== AfaLoggerFunc.tradeInfo("<<<<<<更改错账登记簿中的处理标示") where_dict = {} where_dict = {'BJEDTE':tddzcz_record_dict['BJEDTE'],'BSPSQN':tddzcz_record_dict['BSPSQN']} update_dict = {} update_dict['ISDEAL'] = PL_ISDEAL_ISDO update_dict['NOTE3'] = '此笔错账已抹账' res = rccpsDBTrcc_tddzcz.updateCmt(update_dict,where_dict) if(res == -1): return AfaFlowControl.ExitThisFlow('S999','主机抹账成功,但更新错账处理标示失败,请手工更新错账处理标示') else: AfaLoggerFunc.tradeInfo("<<<<<<更改错账登记簿中的处理标示成功") #=====向下发的通知表中插入数据==== AfaLoggerFunc.tradeInfo("<<<<<<向通知表中插入数据") insert_dict = {} insert_dict['NOTDAT'] = TradeContext.BJEDTE insert_dict['BESBNO'] = wtrbka_record_dict['BESBNO'] if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_RCV): insert_dict['STRINFO'] = "此笔错账["+wtrbka_record_dict['BSPSQN']+"]["+wtrbka_record_dict['BJEDTE']+"]已做抹账处理" else: insert_dict['STRINFO'] = "此笔错账["+wtrbka_record_dict['BSPSQN']+"]["+wtrbka_record_dict['BJEDTE']+"]已做抹账处理 请用8522补打往账凭证" if not rccpsDBTrcc_notbka.insertCmt(insert_dict): return AfaFlowControl.ExitThisFlow('S999','向下发的通知表中插入数据失败') AfaLoggerFunc.tradeInfo("<<<<<<向通知表中插入数据成功") #=====给输出接口赋值===== AfaLoggerFunc.tradeInfo("<<<<<<开始给输出接口赋值") TradeContext.BOSPSQ = wtrbka_record_dict['BSPSQN'] TradeContext.BOJEDT = wtrbka_record_dict['BJEDTE'] TradeContext.TLSQ = TradeContext.TLSQ TradeContext.BRSFLG = wtrbka_record_dict['BRSFLG'] TradeContext.TRCCO = wtrbka_record_dict['TRCCO'] TradeContext.BEACSB = wtrbka_record_dict['BESBNO'] TradeContext.OROCCAMT = str(wtrbka_record_dict['OCCAMT']) TradeContext.ORCUR = wtrbka_record_dict['CUR'] TradeContext.ORSNDBNK = wtrbka_record_dict['SNDBNKCO'] TradeContext.ORSNDBNKNM = wtrbka_record_dict['SNDBNKNM'] TradeContext.ORRCVBNK = wtrbka_record_dict['RCVBNKCO'] TradeContext.ORRCVBNKNM = wtrbka_record_dict['RCVBNKNM'] TradeContext.ORPYRACC = wtrbka_record_dict['PYRACC'] TradeContext.ORPYRNAM = wtrbka_record_dict['PYRNAM'] TradeContext.ORPYEACC = wtrbka_record_dict['PYEACC'] TradeContext.ORPYENAM = wtrbka_record_dict['PYENAM'] # TradeContext.SBAC = # TradeContext.RBAC = AfaLoggerFunc.tradeDebug("<<<<<<OROCCAMT="+str(TradeContext.OROCCAMT)) AfaLoggerFunc.tradeInfo("<<<<<<结束给输出接口赋值") AfaLoggerFunc.tradeInfo("<<<<<<<个性化处理(本地操作) 退出") AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.差错抹账[8571] 退出") return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo(" 农信银系统:来账.中心类操作(1.本地操作).折本转异应答报文接收[TRCC006_1155]进入 ") #=================初始化返回信息============================================ if AfaUtilTools.trim(TradeContext.STRINFO) == "": TradeContext.STRINFO = rccpsDBFunc.getErrInfo(TradeContext.PRCCO) AfaLoggerFunc.tradeDebug("TradeContext.STRINFO=" + TradeContext.STRINFO) #=================必要性检查=============================================== AfaLoggerFunc.tradeInfo(">>>开始必要性检查") #=================若交易已被冲正或冲销,则停止处理================================ AfaLoggerFunc.tradeInfo(">>>开始检查此交易是否已被冲正") where_sql = "ORMFN = '" + TradeContext.ORMFN + "'" ret = rccpsDBTrcc_atcbka.count(where_sql) if ret < 0: return AfaFlowControl.ExitThisFlow("S999","查询冲正登记簿异常,退出主流程") if ret > 0: return AfaFlowControl.ExitThisFlow("S999","冲正登记簿中存在对此交易的冲正,退出主流程") AfaLoggerFunc.tradeInfo(">>>结束检查此交易是否已被冲正") AfaLoggerFunc.tradeInfo(">>>开始检查此交易是否已被冲销") ret = rccpsDBTrcc_mpcbka.count(where_sql) if ret < 0: return AfaFlowControl.ExitThisFlow("S999","查询冲销登记簿异常,退出主流程") if ret > 0: return AfaFlowControl.ExitThisFlow("S999","冲销登记簿中存在对此交易的冲销,退出主流程") AfaLoggerFunc.tradeInfo(">>>结束检查此交易是否已被冲销") AfaLoggerFunc.tradeInfo(">>>结束必要性检查") #=================匹配原交易信息=========================================== AfaLoggerFunc.tradeInfo(">>>开始匹配原交易") wtr_dict = {} if not rccpsDBFunc.getTransWtrAK(TradeContext.SNDBNKCO,TradeContext.TRCDAT,TradeContext.TRCNO,wtr_dict): return AfaFlowControl.ExitThisFlow('S999', "未找到原存款请求交易,停止处理") TradeContext.BJEDTE = wtr_dict['BJEDTE'] TradeContext.BSPSQN = wtr_dict['BSPSQN'] TradeContext.TRCCO = wtr_dict['TRCCO'] TradeContext.BESBNO = wtr_dict['BESBNO'] TradeContext.BETELR = wtr_dict['BETELR'] TradeContext.OCCAMT = str(wtr_dict['OCCAMT']) TradeContext.CHRGTYP = wtr_dict['CHRGTYP'] TradeContext.LOCCUSCHRG = str(wtr_dict['CUSCHRG']) TradeContext.PYRTYP = wtr_dict['PYRTYP'] TradeContext.PYRACC = wtr_dict['PYRACC'] TradeContext.PYRNAM = wtr_dict['PYRNAM'] TradeContext.CERTTYPE = wtr_dict['CERTTYPE'] TradeContext.CERTNO = wtr_dict['CERTNO'] TradeContext.TERMID = wtr_dict['TERMID'] TradeContext.WARNTNO = wtr_dict['BNKBKNO'] AfaLoggerFunc.tradeInfo(">>>结束匹配原交易") #=================若应答报文回复拒绝,则设置状态为拒绝,停止处理============= if TradeContext.PRCCO != 'RCCI0000': AfaLoggerFunc.tradeInfo(">>>对方返回拒绝应答") #=============设置业务状态为拒绝处理中================================= if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_MFERFE,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为拒绝处理中异常") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") stat_dict = {} stat_dict['BJEDTE'] = 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', "设置业务状态为拒绝成功异常") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") #=============发起主机抹账============================================= AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为抹账处理中") #=====特殊处理 关彬捷 20081127 调8813抹账,需产生新的前置流水号进行记账==== if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 : return AfaFlowControl.ExisThisFlow('S999',"产生新的前置流水号异常") #为抹账赋值会计分录 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_CZ TradeContext.BRSFLG = PL_BRSFLG_SND rccpsEntries.KZBZYWZMZ(entries_dict) #====设置业务状态为抹账处理中==== 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(">>>结束发起主机抹账") stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BSPSQN'] = TradeContext.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_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异常") return AfaFlowControl.ExitThisFlow("S999","对方拒绝,停止处理") else: AfaLoggerFunc.tradeInfo(">>>对方返回成功应答") #=================设置业务状态为确认付款处理中============================= AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为确认付款处理中") if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CONFPAY,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow('S999',"设置业务状态为确认付款处理中异常") AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为确认付款处理中") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") #=================更新存款确认委托日期和交易流水号========================= AfaLoggerFunc.tradeInfo(">>>开始更新存款确认委托日期和交易流水号") wtrbka_update_dict = {} wtrbka_update_dict['COTRCDAT'] = TradeContext.TRCDAT wtrbka_update_dict['COTRCNO'] = TradeContext.SerialNo wtrbka_update_dict['COMSGFLGNO'] = TradeContext.RCVMBRCO + TradeContext.TRCDAT + TradeContext.SerialNo wtrbka_where_dict = {} wtrbka_where_dict['BJEDTE'] = TradeContext.BJEDTE wtrbka_where_dict['BSPSQN'] = TradeContext.BSPSQN ret = rccpsDBTrcc_wtrbka.update(wtrbka_update_dict,wtrbka_where_dict) if ret <= 0: return AfaFlowControl.ExitThisFlow('S999', "更新存款确认委托日期和交易流水号异常") AfaLoggerFunc.tradeInfo(">>>结束更新存款确认委托日期和交易流水号") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") #=================为存款确认请求报文做准备================================= AfaLoggerFunc.tradeInfo(">>>开始为存款确认请求报文做准备") TradeContext.MSGTYPCO = 'SET009' TradeContext.SNDSTLBIN = TradeContext.RCVMBRCO TradeContext.RCVSTLBIN = TradeContext.SNDMBRCO TradeContext.SNDBRHCO = TradeContext.BESBNO TradeContext.SNDCLKNO = TradeContext.BETELR #TradeContext.SNDTRDAT = TradeContext.BJEDTE #TradeContext.SNDTRTIM = TradeContext.BJETIM #TradeContext.MSGFLGNO = TradeContext.SNDMBRCO + TradeContext.BJEDTE + TradeContext.TRCNO TradeContext.ORMFN = TradeContext.ORMFN TradeContext.OPRTYPNO = '30' TradeContext.ROPRTPNO = '30' TradeContext.TRANTYP = '0' TradeContext.ORTRCCO = TradeContext.TRCCO TradeContext.ORTRCNO = TradeContext.TRCNO TradeContext.TRCCO = '3000503' TradeContext.TRCNO = TradeContext.SerialNo TradeContext.CURPIN = "" TradeContext.STRINFO = '收到存款应答,自动发送存款确认' AfaLoggerFunc.tradeInfo(">>>结束为存款确认请求报文做准备") AfaLoggerFunc.tradeInfo(" 农信银系统:来账.中心类操作(1.本地操作).卡本转异应答报文接收[TRCC006_1155]退出 ") 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 SubModuleDoTrd(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(3.中心记账).行内账户转异地[TRCC002_8563]进入***' ) #=================设置业务状态为发送成功或失败,若发送失败则自动抹账======== stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BSPSQN'] = TradeContext.BSPSQN stat_dict['BESBNO'] = TradeContext.BESBNO stat_dict['BETELR'] = TradeContext.BETELR stat_dict['BCSTAT'] = PL_BCSTAT_SND stat_dict['BDWFLG'] = PL_BDWFLG_SUCC stat_dict['PRCCO'] = TradeContext.errorCode stat_dict['STRINFO'] = TradeContext.errorMsg AfaLoggerFunc.tradeInfo("TradeContext.errorCode = [" + TradeContext.errorCode + "]") if TradeContext.errorCode == '0000': AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送成功") stat_dict['BCSTAT'] = PL_BCSTAT_SND stat_dict['BDWFLG'] = PL_BDWFLG_SUCC if not rccpsState.setTransState(stat_dict): return AfaFlowControl.ExitThisFlow('S999', "设置业务状态为发送成功异常") AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为发送成功") else: AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送失败") stat_dict['BCSTAT'] = PL_BCSTAT_SND 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(">>>开始设置业务状态为抹账处理中") #=====特殊处理 关彬捷 20081127 调8813抹账,需产生新的前置流水号进行记账==== if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 : return AfaFlowControl.ExisThisFlow('S999',"产生新的前置流水号异常") #为抹账会计分录赋值 if TradeContext.CHRGTYP == '0': #现金收取 AfaLoggerFunc.tradeInfo(">>>现金收取手续费") TradeContext.HostComm = '8813' TradeContext.ACUR = '2' #重复次数 TradeContext.PKFG = 'T' #通存通兑标识 TradeContext.OCCAMT = "-" + str(TradeContext.OCCAMT) #出票金额 TradeContext.RCCSMCD = PL_RCCSMCD_BZYWZ #主机摘要码:本转异往账 TradeContext.SBAC = TradeContext.PYRACC #借方账号:客户账 TradeContext.ACNM = TradeContext.PYRNAM #借方户名 TradeContext.RBAC = TradeContext.BESBNO + PL_ACC_NXYDQSWZ #贷方账号:汇出汇款 TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25) TradeContext.OTNM = "农信银待清算往账" TradeContext.PASSWD = TradeContext.PASSWD #付款人密码 if TradeContext.PYRTYP == '0': TradeContext.WARNTNO = TradeContext.SBAC[6:18] TradeContext.CERTTYPE = TradeContext.CERTTYPE #证件类型 TradeContext.CERTNO = TradeContext.CERTNO #证件号码 TradeContext.CTFG = '7' #本金标识:本金-1 AfaLoggerFunc.tradeInfo("借方账号1:[" + TradeContext.SBAC + "]") AfaLoggerFunc.tradeInfo("贷方账号1:[" + TradeContext.RBAC + "]") AfaLoggerFunc.tradeInfo("凭证号码1:[" + TradeContext.WARNTNO + "]") TradeContext.I2PKFG = 'T' #通存通兑标识 TradeContext.I2RVFG = '2' #红蓝字标志 2 TradeContext.I2CATR = '0' #现转标识:0-现金 TradeContext.I2TRAM = str(TradeContext.LOCCUSCHRG) #手续费金额 TradeContext.I2SMCD = PL_RCCSMCD_SXF #主机摘要码:手续费 TradeContext.I2SBAC = "" #借方账号:柜员尾箱 TradeContext.I2ACNM = "" TradeContext.I2RBAC = TradeContext.BESBNO + PL_ACC_TCTDSXF #贷方账号:通存通兑手续费 TradeContext.I2RBAC = rccpsHostFunc.CrtAcc(TradeContext.I2RBAC,25) TradeContext.I2OTNM = "手续费" TradeContext.I2CTFG = '8' #本金标识:手续费-0 AfaLoggerFunc.tradeInfo("借方账号2:[" + TradeContext.I2SBAC + "]") AfaLoggerFunc.tradeInfo("贷方账号2:[" + TradeContext.I2RBAC + "]") else: TradeContext.HostCode='8820' TradeContext.BOJEDT = TradeContext.BJEDTE TradeContext.BOSPSQ = TradeContext.BSPSQN #====设置业务状态为抹账处理中==== 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(">>>结束发起主机抹账") stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BSPSQN'] = TradeContext.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_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( '***农信银系统:往账.主机类操作(3.中心记账).行内账户转异地[TRCC002_8563]退出***' ) 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
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.差错账补记[8572] 进入") AfaLoggerFunc.tradeInfo("<<<<<<<个性化处理(本地操作) 进入") #=====校验变量的合法性==== AfaLoggerFunc.tradeInfo("<<<<<<校验变量的合法性") if not TradeContext.existVariable("SNDBNKCO"): return AfaFlowControl.ExitThisFlow('A099','没有发起行号') if not TradeContext.existVariable("TRCNO"): return AfaFlowControl.ExitThisFlow('A099','没有交易流水号') if not TradeContext.existVariable("TRCDAT"): return AfaFlowControl.ExitThisFlow('A099','没有委托日期') AfaLoggerFunc.tradeInfo("<<<<<<校验变量的合法性结束") #=====生成RBSQ,FEDT,BJEDTE,NCCworkDate,BSPSQN==== TradeContext.FEDT=AfaUtilTools.GetHostDate( ) #FEDT TradeContext.BJEDTE=AfaUtilTools.GetHostDate( ) #BJEDTE if not rccpsFunc.GetNCCDate( ) : #NCCworkDate raise AfaFlowControl.flowException( ) if rccpsGetFunc.GetRBSQ(PL_BRSFLG_RCV) == -1 : #RBSQ return AfaFlowControl.ExitThisFlow('S999','重新生成前置流水号失败,抛弃报文') if rccpsGetFunc.GetSerialno(PL_BRSFLG_RCV) == -1 : #BSPSQN raise AfaFlowControl.flowException( ) #=====判断原业务是来账还是往账==== AfaLoggerFunc.tradeInfo("<<<<<<判断原业务的往来标示") if(TradeContext.SNDBNKCO == '1340000008'): AfaLoggerFunc.tradeInfo("<<<<<<原业务为往账") #=====查询原业务信息==== where_dict = {} where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO} wtrbka_record_dict = rccpsDBTrcc_wtrbka.selectu(where_dict) if(wtrbka_record_dict == None): return AfaFlowControl.ExitThisFlow('A099','查询通存通兑登记簿失败') elif(len(wtrbka_record_dict) == 0): return AfaFlowControl.ExitThisFlow('A099','查询通存通兑登记簿为空') else: AfaLoggerFunc.tradeInfo("<<<<<<查询原业务信息成功") #=====查询错账登记簿==== where_dict = {} where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO} tddzcz_record_dict = rccpsDBTrcc_tddzcz.selectu(where_dict) if(tddzcz_record_dict == None): return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿失败') elif(len(tddzcz_record_dict) == 0): AfaLoggerFunc.tradeInfo("查询错账登记簿结果为空,应向其中插入相应的记录") #=====给插入错账登记簿的字典赋值==== insert_dict = {} insert_dict['NCCWKDAT'] = wtrbka_record_dict['NCCWKDAT'] insert_dict['SNDBNKCO'] = wtrbka_record_dict['SNDBNKCO'] insert_dict['TRCDAT'] = wtrbka_record_dict['TRCDAT'] insert_dict['TRCNO'] = wtrbka_record_dict['TRCNO'] insert_dict['RCVBNKCO'] = wtrbka_record_dict['RCVBNKCO'] insert_dict['SNDMBRCO'] = wtrbka_record_dict['SNDMBRCO'] insert_dict['RCVMBRCO'] = wtrbka_record_dict['RCVMBRCO'] insert_dict['TRCCO'] = wtrbka_record_dict['TRCCO'] if(wtrbka_record_dict['DCFLG'] == '0'): insert_dict['DCFLG'] = '1' else: insert_dict['DCFLG'] = '2' insert_dict['PYRACC'] = wtrbka_record_dict['PYRACC'] insert_dict['PYEACC'] = wtrbka_record_dict['PYEACC'] insert_dict['CUR'] = 'CNY' insert_dict['OCCAMT'] = wtrbka_record_dict['OCCAMT'] insert_dict['LOCOCCAMT'] = wtrbka_record_dict['OCCAMT'] if(wtrbka_record_dict['TRCCO'] in ('3000102','3000103','3000104','3000105') and wtrbka_record_dict['CHRGTYP'] == '1'): insert_dict['CUSCHRG'] = wtrbka_record_dict['CUSCHRG'] insert_dict['LOCCUSCHRG'] = wtrbka_record_dict['CUSCHRG'] else: insert_dict['CUSCHRG'] = 0.00 insert_dict['LOCCUSCHRG'] = 0.00 insert_dict['ORTRCNO'] = "" insert_dict['BJEDTE'] = wtrbka_record_dict['BJEDTE'] insert_dict['BSPSQN'] = wtrbka_record_dict['BSPSQN'] insert_dict['EACTYP'] = '02' insert_dict['EACINF'] = '中心有成员行无' insert_dict['LOCEACTYP'] = '03' insert_dict['LOCEACINF'] = '往账中心清算,行内未清算' insert_dict['ISDEAL'] = '0' insert_dict['NOTE1'] = "" insert_dict['NOTE2'] = "" insert_dict['NOTE3'] = "" insert_dict['NOTE4'] = "" #=====向错账登记簿中补记此笔交易==== if not rccpsDBTrcc_tddzcz.insertCmt(insert_dict): return AfaFlowControl.ExitThisFlow('A099','向错账登记簿中补记交易失败') #=====补查错账登记簿,将刚插入的数据查出来==== where_dict = {} where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO} tddzcz_record_dict = rccpsDBTrcc_tddzcz.selectu(where_dict) if(tddzcz_record_dict == None): return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿失败') elif(len(tddzcz_record_dict) == 0): return AfaFlowControl.ExitThisFlow('A099','查询通错账登记簿结果为空') else: AfaLoggerFunc.tradeInfo("<<<<<<补查错账登记簿成功") else: AfaLoggerFunc.tradeInfo("<<<<<<查询错账登记簿成功") else: AfaLoggerFunc.tradeInfo("<<<<<<原业务为来账") #=====查询对账明细登记簿==== AfaLoggerFunc.tradeInfo("<<<<<<开始查询对账明细登记簿") where_dict = {} where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO} tddzmx_record_dict = rccpsDBTrcc_tddzmx.selectu(where_dict) if(tddzmx_record_dict == None): return AfaFlowControl.ExitThisFlow('A099','查询对账明细登记簿失败') elif(len(tddzmx_record_dict) == 0): return AfaFlowControl.ExitThisFlow('A099','查询对账明细登记簿为空') else: AfaLoggerFunc.tradeInfo("<<<<<<查询对账明细登记簿成功") #=====查询错账登记簿==== AfaLoggerFunc.tradeInfo("<<<<<<开始查询错账登记簿") where_dict = {} where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO} tddzcz_record_dict = rccpsDBTrcc_tddzcz.selectu(where_dict) if(tddzcz_record_dict == None): return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿失败') elif(len(tddzcz_record_dict) == 0): AfaLoggerFunc.tradeInfo("查询错账登记簿结果为空,应向其中插入相应的记录") #=====给插入错账登记簿的字典赋值==== insert_dict = {} insert_dict['NCCWKDAT'] = tddzmx_record_dict['NCCWKDAT'] insert_dict['SNDBNKCO'] = tddzmx_record_dict['SNDBNKCO'] insert_dict['TRCDAT'] = tddzmx_record_dict['TRCDAT'] insert_dict['TRCNO'] = tddzmx_record_dict['TRCNO'] insert_dict['RCVBNKCO'] = tddzmx_record_dict['RCVBNKCO'] insert_dict['SNDMBRCO'] = tddzmx_record_dict['SNDMBRCO'] insert_dict['RCVMBRCO'] = tddzmx_record_dict['RCVMBRCO'] insert_dict['TRCCO'] = tddzmx_record_dict['TRCCO'] insert_dict['DCFLG'] = tddzmx_record_dict['DCFLG'] insert_dict['PYRACC'] = tddzmx_record_dict['PYRACC'] insert_dict['PYEACC'] = tddzmx_record_dict['PYEACC'] insert_dict['CUR'] = tddzmx_record_dict['CUR'] insert_dict['OCCAMT'] = tddzmx_record_dict['OCCAMT'] insert_dict['LOCOCCAMT'] = tddzmx_record_dict['OCCAMT'] insert_dict['CUSCHRG'] = tddzmx_record_dict['CUSCHRG'] insert_dict['LOCCUSCHRG'] = tddzmx_record_dict['CUSCHRG'] insert_dict['ORTRCNO'] = "" insert_dict['BJEDTE'] = tddzmx_record_dict['BJEDTE'] insert_dict['BSPSQN'] = tddzmx_record_dict['BSPSQN'] insert_dict['EACTYP'] = "02" insert_dict['EACINF'] = "中心有成员行无" insert_dict['LOCEACTYP'] = "08" insert_dict['LOCEACINF'] = "来账中心清算,行内未清算" insert_dict['ISDEAL'] = "0" insert_dict['NOTE1'] = "" insert_dict['NOTE2'] = "" insert_dict['NOTE3'] = "" insert_dict['NOTE4'] = "" #=====向错账登记簿中补记此笔交易==== if not rccpsDBTrcc_tddzcz.insertCmt(insert_dict): return AfaFlowControl.ExitThisFlow('A099','向错账登记簿中补记交易失败') #=====补查错账登记簿,将刚插入的数据查出来==== where_dict = {} where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO} tddzcz_record_dict = rccpsDBTrcc_tddzcz.selectu(where_dict) if(tddzcz_record_dict == None): return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿失败') elif(len(tddzcz_record_dict) == 0): return AfaFlowControl.ExitThisFlow('A099','查询通错账登记簿结果为空') else: AfaLoggerFunc.tradeInfo("<<<<<<补查错账登记簿成功") else: AfaLoggerFunc.tradeInfo("<<<<<<查询错账登记簿成功") AfaLoggerFunc.tradeInfo("<<<<<<结束查询错账明细登记簿") #=====查询原交易信息==== AfaLoggerFunc.tradeInfo("<<<<<<开始查询原交易信息") where_dict = {} where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO} wtrbka_record_dict = rccpsDBTrcc_wtrbka.selectu(where_dict) if(wtrbka_record_dict == None): return AfaFlowControl.ExitThisFlow('A099','查询通存通兑业务登记簿失败') elif(len(wtrbka_record_dict) == 0): #通存通兑登记簿结果为空,应向其中插入相应记录 AfaLoggerFunc.tradeInfo("<<<<<<通存通兑业务登记簿结果为空") #=====开始登记通存通兑业务登记簿==== AfaLoggerFunc.tradeInfo("<<<<<<开始登记通存通兑业务登记簿") #=====调用主机交易得到机构号==== AfaLoggerFunc.tradeInfo("<<<<<<查询账户开户机构") TradeContext.HostCode = '8810' if(tddzmx_record_dict['TRCCO'] in ('3000002','3000003','3000004','3000005')): TradeContext.ACCNO = tddzmx_record_dict['PYEACC'] else: TradeContext.ACCNO = tddzmx_record_dict['PYRACC'] rccpsHostFunc.CommHost( TradeContext.HostCode ) if(TradeContext.errorCode != '0000'): return AfaFlowControl.ExitThisFlow('A099','查询账户开户行信息失败') AfaLoggerFunc.tradeInfo("<<<<<<查询账户开户信息成功") #=====给插入通存通兑业务登记簿的字典赋值==== insert_dict = {} insert_dict['BJEDTE'] = tddzmx_record_dict['BJEDTE'] insert_dict['BSPSQN'] = tddzmx_record_dict['BSPSQN'] if(tddzmx_record_dict['SNDMBRCO'] == '1340000008'): insert_dict['BRSFLG'] = PL_BRSFLG_SND else: insert_dict['BRSFLG'] = PL_BRSFLG_RCV insert_dict['BESBNO'] = TradeContext.ACCSO insert_dict['BEACSB'] = "" insert_dict['BETELR'] = PL_BETELR_AUTO insert_dict['BEAUUS'] = "" insert_dict['BEAUPS'] = "" insert_dict['TERMID'] = "" insert_dict['BBSSRC'] = "" insert_dict['DASQ'] = "" insert_dict['DCFLG'] = tddzmx_record_dict['DCFLG'] if(tddzmx_record_dict['TRCCO'] in ('3000002','3000004')): insert_dict['OPRNO'] = PL_TDOPRNO_TC elif(tddzmx_record_dict['TRCCO'] in ('3000102','3000104')): insert_dict['OPRNO'] = PL_TDOPRNO_TD elif(tddzmx_record_dict['TRCCO'] in ('3000003','3000005')): insert_dict['OPRNO'] = PL_TDOPRNO_BZY else: insert_dict['OPRNO'] = PL_TDOPRNO_YZB insert_dict['OPRATTNO'] = "" insert_dict['NCCWKDAT'] = TradeContext.NCCworkDate insert_dict['TRCCO'] = tddzmx_record_dict['TRCCO'] insert_dict['TRCDAT'] = tddzmx_record_dict['TRCDAT'] insert_dict['TRCNO'] = tddzmx_record_dict['TRCNO'] insert_dict['MSGFLGNO'] = tddzmx_record_dict['MSGFLGNO'] insert_dict['COTRCDAT'] = "" insert_dict['COTRCNO'] = "" insert_dict['COMSGFLGNO'] = "" insert_dict['SNDMBRCO'] = tddzmx_record_dict['SNDMBRCO'] insert_dict['RCVMBRCO'] = tddzmx_record_dict['RCVMBRCO'] insert_dict['SNDBNKCO'] = tddzmx_record_dict['SNDBNKCO'] insert_dict['SNDBNKNM'] = tddzmx_record_dict['SNDBNKNM'] insert_dict['RCVBNKCO'] = tddzmx_record_dict['RCVBNKCO'] insert_dict['RCVBNKNM'] = tddzmx_record_dict['RCVBNKNM'] insert_dict['CUR'] = tddzmx_record_dict['CUR'] insert_dict['OCCAMT'] = tddzmx_record_dict['OCCAMT'] if(tddzmx_record_dict['CUSCHRG'] == 0.00): insert_dict['CHRGTYP']= PL_CHRG_CASH else: insert_dict['CHRGTYP']= PL_CHRG_TYPE insert_dict['LOCCUSCHRG'] = "" insert_dict['CUSCHRG'] = tddzmx_record_dict['CUSCHRG'] insert_dict['PYRTYP'] = "" insert_dict['PYRACC'] = tddzmx_record_dict['PYRACC'] insert_dict['PYRNAM'] = "" insert_dict['PYRADDR'] = "" insert_dict['PYETYP'] = "" insert_dict['PYEACC'] = tddzmx_record_dict['PYEACC'] insert_dict['PYENAM'] = "" insert_dict['PYEADDR'] = "" insert_dict['STRINFO'] = tddzmx_record_dict['STRINFO'] insert_dict['CERTTYPE'] = "" insert_dict['CERTNO'] = "" insert_dict['BNKBKNO'] = "" insert_dict['BNKBKBAL'] = "" if not rccpsDBTrcc_wtrbka.insertCmt(insert_dict): return AfaFlowControl.ExitThisFlow('A099','登记通存通兑业务登记簿失败') AfaLoggerFunc.tradeInfo("<<<<<<结束登记通存通兑业务登记簿") #=====补查通存通兑业务登记簿,将刚才插入的数据查出来==== where_dict = {} where_dict = {'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT,'TRCNO':TradeContext.TRCNO} wtrbka_record_dict = rccpsDBTrcc_wtrbka.selectu(where_dict) if(wtrbka_record_dict == None): return AfaFlowControl.ExitThisFlow('A099','查询通存通兑业务登记簿失败') elif(len(wtrbka_record_dict) == 0): return AfaFlowControl.ExitThisFlow('A099','查询通存通兑业务登记簿结果为空') else: AfaLoggerFunc.tradeInfo("<<<<<<补查通存通兑业务登记簿成功") else: AfaLoggerFunc.tradeInfo("<<<<<<查询通存通兑业务登记簿成功") #=====判断此笔业务是否已经处理==== if(tddzcz_record_dict['ISDEAL'] == PL_ISDEAL_ISDO): return AfaFlowControl.ExitThisFlow('A099','此笔账务已经处理过') #=====开始行内补记==== AfaLoggerFunc.tradeInfo("<<<<<<开始行内补记") #=====判断原交易的往来标示==== AfaLoggerFunc.tradeInfo("<<<<<<判断原交易的往来标示") if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_RCV): AfaLoggerFunc.tradeInfo("<<<<<<原交易为来账") # if(TradeContext.existVariable("BSPSQN")): # TradeContext.BSPSQN = wtrbka_record_dict['BSPSQN'] TradeContext.BESBNO = wtrbka_record_dict['BESBNO'] TradeContext.BRSFLG = wtrbka_record_dict['BRSFLG'] TradeContext.CHRGTYP = wtrbka_record_dict['CHRGTYP'] TradeContext.BETELR = PL_BETELR_AUTO input_dict = {} input_dict['FEDT'] = TradeContext.FEDT input_dict['RBSQ'] = TradeContext.RBSQ input_dict['PYRACC'] = wtrbka_record_dict['PYRACC'] input_dict['PYRNAM'] = wtrbka_record_dict['PYRNAM'] input_dict['PYEACC'] = wtrbka_record_dict['PYEACC'] input_dict['PYENAM'] = wtrbka_record_dict['PYENAM'] input_dict['CHRGTYP'] = wtrbka_record_dict['CHRGTYP'] input_dict['OCCAMT'] = wtrbka_record_dict['OCCAMT'] input_dict['CUSCHRG'] = wtrbka_record_dict['CUSCHRG'] if(wtrbka_record_dict['TRCCO'] in ('3000002','3000004')): AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通存来账记账") input_dict['RCCSMCD'] = PL_RCCSMCD_XJTCLZ rccpsEntriesErr.KZTCLZJZ(input_dict) elif(wtrbka_record_dict['TRCCO'] in ('3000003','3000005')): AfaLoggerFunc.tradeDebug("<<<<<<卡折本转异来账记账") input_dict['RCCSMCD'] = PL_RCCSMCD_BZYLZ rccpsEntriesErr.KZBZYLZJZ(input_dict) elif(wtrbka_record_dict['TRCCO'] in ('3000102','3000104')): AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通兑来账记账") input_dict['RCCSMCD'] = PL_RCCSMCD_XJTDLZ rccpsEntriesErr.KZTDLZJZ(input_dict) elif(wtrbka_record_dict['TRCCO'] in ('3000103','3000105')): AfaLoggerFunc.tradeDebug("<<<<<<卡折异转本来账记账") input_dict['RCCSMCD'] = PL_RCCSMCD_YZBLZ rccpsEntriesErr.KZYZBLZJZ(input_dict) else: return AfaFlowControl.ExitThisFlow('A099','交易代码非法') elif(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_SND): AfaLoggerFunc.tradeInfo("<<<<<<原交易为往账") # if(TradeContext.existVariable("BSPSQN")): # TradeContext.BSPSQN = wtrbka_record_dict['BSPSQN'] TradeContext.BESBNO = wtrbka_record_dict['BESBNO'] TradeContext.CHRGTYP = wtrbka_record_dict['CHRGTYP'] TradeContext.BRSFLG = wtrbka_record_dict['BRSFLG'] TradeContext.BETELR = PL_BETELR_AUTO input_dict = {} input_dict['FEDT'] = TradeContext.FEDT input_dict['RBSQ'] = TradeContext.RBSQ input_dict['PYRACC'] = wtrbka_record_dict['PYRACC'] input_dict['PYRNAM'] = wtrbka_record_dict['PYRNAM'] input_dict['PYEACC'] = wtrbka_record_dict['PYEACC'] input_dict['PYENAM'] = wtrbka_record_dict['PYENAM'] input_dict['CHRGTYP'] = wtrbka_record_dict['CHRGTYP'] input_dict['OCCAMT'] = wtrbka_record_dict['OCCAMT'] input_dict['CUSCHRG'] = wtrbka_record_dict['CUSCHRG'] if(wtrbka_record_dict['TRCCO'] in ('3000002','3000004')): AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通存往账记账") input_dict['RCCSMCD'] = PL_RCCSMCD_XJTCWZ rccpsEntriesErr.KZTCWZJZ(input_dict) elif(wtrbka_record_dict['TRCCO'] in ('3000003','3000005')): AfaLoggerFunc.tradeDebug("<<<<<<卡折本转异往账记账") input_dict['RCCSMCD'] = PL_RCCSMCD_BZYWZ rccpsEntriesErr.KZBZYWZJZ(input_dict) elif(wtrbka_record_dict['TRCCO'] in ('3000102','3000104')): AfaLoggerFunc.tradeDebug("<<<<<<卡折现金通兑往账记账") input_dict['RCCSMCD'] = PL_RCCSMCD_XJTDWZ rccpsEntriesErr.KZTDWZJZ(input_dict) elif(wtrbka_record_dict['TRCCO'] in ('3000103','3000105')): AfaLoggerFunc.tradeDebug("<<<<<<卡折异转本往账记账") input_dict['RCCSMCD'] = PL_RCCSMCD_YZBWZ rccpsEntriesErr.KZYZBWZJZ(input_dict) else: return AfaFlowControl.ExitThisFlow('A099','交易代码非法') else: return AfaFlowControl.ExitThisFlow('A099','往来标示非法') #=====主机前设置原交易的状态==== bcstat = '' #状态变量 if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_SND): #往账 bcstat = PL_BCSTAT_ACC elif(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_RCV and wtrbka_record_dict['TRCCO'] in ('3000002','3000003','3000004','3000005')): #来账通存 bcstat = PL_BCSTAT_AUTO else: #来账通兑 bcstat = PL_BCSTAT_AUTOPAY #=====判断原交易是否有成功的账务状态==== AfaLoggerFunc.tradeInfo("<<<<<<判断原交易是是否有成功的交易状态") isaccount = 0 #调用主机交易标示,0不调用,1调用 acc = 0 hcac = 0 canc = 0 cancel = 0 if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_SND): #=====原业务为往账==== #=====查询是否有记账成功的状态==== sstlog_list = [] if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_ACC,PL_BDWFLG_SUCC,sstlog_list): acc = len(sstlog_list) #=====查询是否有抹账的状态==== sstlog_list = [] if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_HCAC,PL_BDWFLG_SUCC,sstlog_list): hcac = len(sstlog_list) #=====查询是否有冲销的状态==== sstlog_list = [] if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_CANC,PL_BDWFLG_SUCC,sstlog_list): canc = len(sstlog_list) #=====查询是否有冲正的状态==== ssltog_list = [] if rccpsState.getTransStateSetm(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_CANCEL,PL_BDWFLG_SUCC,sstlog_list): cancel = len(sstlog_list) if(acc - (hcac + canc + cancel) <= 0): isaccount = 1 else: #======原业务为来账==== stat_dict = {} res = rccpsState.getTransStateCur(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],stat_dict) if(res == False): return AfaFlowControl.ExitThisFlow('A099','查询业务的当前状态失败') else: AfaLoggerFunc.tradeInfo("查询业务当前状态成功") if(stat_dict['BCSTAT'] in (PL_BCSTAT_AUTO,PL_BCSTAT_AUTOPAY) and stat_dict['BDWFLG'] == PL_BDWFLG_SUCC): isaccount = 0 else: isaccount = 1 AfaLoggerFunc.tradeInfo("<<<<<<结束判断原交易是是否有成功的交易状态") #=====判断业务是否需要进行主机记账==== if(isaccount == 0): return AfaFlowControl.ExitThisFlow('S999','原业务已记账,禁止提交') #=====主机前设置原交易状态==== AfaLoggerFunc.tradeInfo("<<<<<<主机前设置原交易状态") if not rccpsState.newTransState(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],bcstat,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow('S999','设置业务状态为记账处理中异常') else: AfaDBFunc.CommitSql() #=====开始调用主机交易==== AfaLoggerFunc.tradeInfo("<<<<<<开始调用主机交易") rccpsHostFunc.CommHost( TradeContext.HostCode ) AfaLoggerFunc.tradeInfo("<<<<<<结束调用主机交易") AfaLoggerFunc.tradeInfo("<<<<<<结束行内补记") #=====给状态字典赋值==== state_dict = {} state_dict['BJEDTE'] = wtrbka_record_dict['BJEDTE'] state_dict['BSPSQN'] = wtrbka_record_dict['BSPSQN'] state_dict['BCSTAT'] = bcstat state_dict['MGID'] = TradeContext.errorCode if TradeContext.existVariable('TRDT'): state_dict['TRDT'] = TradeContext.TRDT if TradeContext.existVariable('TLSQ'): state_dict['TLSQ'] = TradeContext.TLSQ if TradeContext.existVariable('RBSQ'): state_dict['RBSQ'] = TradeContext.RBSQ if TradeContext.existVariable('FEDT'): state_dict['FEDT'] = TradeContext.FEDT #=====判断主机交易是否成功==== AfaLoggerFunc.tradeInfo("<<<<<<判断主机交易是否成功") AfaLoggerFunc.tradeDebug("<<<<<<errorCode=" + TradeContext.errorCode) if(TradeContext.errorCode != '0000'): AfaLoggerFunc.tradeInfo("调用主机交易失败") #=====主机后更改原交易状态为失败==== state_dict['BDWFLG'] = PL_BDWFLG_FAIL state_dict['STRINFO'] = TradeContext.errorMsg if not rccpsState.setTransState(state_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务状态为失败异常') else: AfaDBFunc.CommitSql() return AfaFlowControl.ExitThisFlow('S999','主机交易失败') else: AfaLoggerFunc.tradeInfo("调用主机交易成功") #=====主机后更改原交易状态为成功==== state_dict['BDWFLG'] = PL_BDWFLG_SUCC state_dict['STRINFO'] = '主机成功' if(TradeContext.existVariable("SBAC")): state_dict['SBAC'] = TradeContext.SBAC if(TradeContext.existVariable("RBAC")): state_dict['RBAC'] = TradeContext.RBAC if not rccpsState.setTransState(state_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务状态为失败成功') else: AfaDBFunc.CommitSql() #=====如果是往账要将状态设置为清算成功==== if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_SND): #往账 if not rccpsState.newTransState(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_MFESTL,PL_BDWFLG_SUCC): return AfaFlowControl.ExitThisFlow('S999','设置业务状态为清算成功异常') else: AfaDBFunc.CommitSql() #=====更改错账登记簿中的处理标示==== AfaLoggerFunc.tradeInfo("<<<<<<更改错账登记簿中的处理标示") where_dict = {} where_dict = {'BJEDTE':tddzcz_record_dict['BJEDTE'],'BSPSQN':tddzcz_record_dict['BSPSQN']} update_dict = {} update_dict['ISDEAL'] = PL_ISDEAL_ISDO update_dict['NOTE3'] = '此笔错账已补记' res = rccpsDBTrcc_tddzcz.updateCmt(update_dict,where_dict) if(res == -1): return AfaFlowControl.ExitThisFlow('S999','主机记账已成功,但更新处理标示失败,请手动更改处理标示') else: AfaLoggerFunc.tradeInfo("<<<<<<更改错账登记簿中的处理标示成功") #=====向下发的通知表中插入数据==== AfaLoggerFunc.tradeInfo("<<<<<<向通知表中插入数据") insert_dict = {} insert_dict['NOTDAT'] = TradeContext.BJEDTE insert_dict['BESBNO'] = wtrbka_record_dict['BESBNO'] if(wtrbka_record_dict['BRSFLG'] == PL_BRSFLG_RCV): insert_dict['STRINFO'] = "此笔错账["+wtrbka_record_dict['BSPSQN']+"]["+wtrbka_record_dict['BJEDTE']+"]已做补记处理" else: insert_dict['STRINFO'] = "此笔错账["+wtrbka_record_dict['BSPSQN']+"]["+wtrbka_record_dict['BJEDTE']+"]已做补记处理 请用8522补打往账凭证" if not rccpsDBTrcc_notbka.insertCmt(insert_dict): return AfaFlowControl.ExitThisFlow('S999','向下发的通知表中插入数据失败') AfaLoggerFunc.tradeInfo("<<<<<<向通知表中插入数据成功") #=====给输出接口赋值==== AfaLoggerFunc.tradeInfo("<<<<<<开始给输出接口赋值") TradeContext.BOSPSQ = wtrbka_record_dict['BSPSQN'] TradeContext.BOJEDT = wtrbka_record_dict['BJEDTE'] TradeContext.TLSQ = TradeContext.TLSQ TradeContext.TRCCO = wtrbka_record_dict['TRCCO'] TradeContext.BRSFLG = wtrbka_record_dict['BRSFLG'] TradeContext.BEACSB = wtrbka_record_dict['BESBNO'] TradeContext.OROCCAMT = str(wtrbka_record_dict['OCCAMT']) TradeContext.ORCUR = wtrbka_record_dict['CUR'] TradeContext.ORSNDBNK = wtrbka_record_dict['SNDBNKCO'] TradeContext.ORSNDBNKNM = wtrbka_record_dict['SNDBNKNM'] TradeContext.ORRCVBNK = wtrbka_record_dict['RCVBNKCO'] TradeContext.ORRCVBNKNM = wtrbka_record_dict['RCVBNKNM'] TradeContext.ORPYRACC = wtrbka_record_dict['PYRACC'] TradeContext.ORPYRNAM = wtrbka_record_dict['PYRNAM'] TradeContext.ORPYEACC = wtrbka_record_dict['PYEACC'] TradeContext.ORPYENAM = wtrbka_record_dict['PYENAM'] # TradeContext.SBAC = # TradeContext.RBAC = AfaLoggerFunc.tradeInfo("<<<<<<结束给输出接口赋值") AfaLoggerFunc.tradeInfo("<<<<<<<个性化处理(本地操作) 退出") AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.差错账补记[8572] 退出") return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.差错补记抹账[8573] 进入") AfaLoggerFunc.tradeInfo("<<<<<<<个性化处理(本地操作) 进入") #=====校验变量的合法性==== AfaLoggerFunc.tradeInfo("<<<<<<<开始校验变量的合法性") if not TradeContext.existVariable("SNDBNKCO"): return AfaFlowControl.ExitThisFlow('A099','没有原发送行号') if not TradeContext.existVariable("TRCNO"): return AfaFlowControl.ExitThisFlow('A099','没有交易流水号') if not TradeContext.existVariable("TRCDAT"): return AfaFlowControl.ExitThisFlow('A099','没有委托日期') AfaLoggerFunc.tradeInfo("<<<<<<<结束校验变量的合法性") #=====产生RBSQ,NCCWKDAT,FEDT==== if rccpsGetFunc.GetRBSQ(PL_BRSFLG_SND) == -1 : return AfaFlowControl.ExitThisFlow('A099','产生前置流水号失败') if not rccpsFunc.GetNCCDate( ) : #NCCworkDate raise AfaFlowControl.flowException( ) TradeContext.FEDT = AfaUtilTools.GetHostDate( ) #=====查询错账登记簿==== where_dict = {} where_dict={'TRCNO':TradeContext.TRCNO,'SNDBNKCO':TradeContext.SNDBNKCO,'TRCDAT':TradeContext.TRCDAT} tddzcz_record_dict = rccpsDBTrcc_tddzcz.selectu(where_dict) if(tddzcz_record_dict == None): return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿异常') elif(len(tddzcz_record_dict) == 0): return AfaFlowControl.ExitThisFlow('A099','查询错账登记簿结果为空') else: AfaLoggerFunc.tradeInfo("查询错账登记簿成功") #=======判断原交易是否已被补记== AfaLoggerFunc.tradeInfo("<<<<<<判断原交易是否已被补记") if(tddzcz_record_dict['ISDEAL'] == PL_ISDEAL_UNDO): return AfaFlowControl.ExitThisFlow('A099','原交易尚未被补记') else: AfaLoggerFunc.tradeInfo("<<<<<<原交易已被补记") #=====查询原交易信息==== AfaLoggerFunc.tradeInfo("<<<<<<查询通存通兑业务登记簿") wtrbka_record_dict = {} if not rccpsDBFunc.getTransWtr(tddzcz_record_dict['BJEDTE'],tddzcz_record_dict['BSPSQN'],wtrbka_record_dict): return AfaFlowControl.ExitThisFlow('A099','查询原交易信息失败') #=====判断被抹账务的日期是否是当日==== if(wtrbka_record_dict['FEDT'] != AfaUtilTools.GetHostDate( )): return AfaFlowControl.ExitThisFlow('A099','要抹掉的交易非当日记账') #=====开始行内抹账==== AfaLoggerFunc.tradeInfo("<<<<<<开始行内抹账") #=====给主机函数参数赋值==== TradeContext.BOSPSQ = wtrbka_record_dict['RBSQ'] TradeContext.BOJEDT = wtrbka_record_dict['FEDT'] TradeContext.HostCode = '8820' #=====设置原交易状态为抹账处理中==== AfaLoggerFunc.tradeInfo("<<<<<<设置原交易状态为抹账处理中") if not rccpsState.newTransState(wtrbka_record_dict['BJEDTE'],wtrbka_record_dict['BSPSQN'],PL_BCSTAT_HCAC,PL_BDWFLG_WAIT): AfaDBFunc.RollBackSql() return AfaFlowControl.ExitThisFlow('S999','设置业务状态为抹账处理中异常') else: AfaDBFunc.CommitSql() #=====开始调用主机交易==== AfaLoggerFunc.tradeInfo("<<<<<<开始调用主机交易") rccpsHostFunc.CommHost( TradeContext.HostCode ) AfaLoggerFunc.tradeInfo("<<<<<<结束调用主机交易") AfaLoggerFunc.tradeInfo("<<<<<<结束行内抹账") #=====给状态字典赋值==== state_dict = {} state_dict['BJEDTE'] = wtrbka_record_dict['BJEDTE'] state_dict['BSPSQN'] = wtrbka_record_dict['BSPSQN'] state_dict['BCSTAT'] = PL_BCSTAT_HCAC state_dict['MGID'] = TradeContext.errorCode if TradeContext.existVariable('TRDT'): state_dict['TRDT'] = TradeContext.TRDT if TradeContext.existVariable('TLSQ'): state_dict['TLSQ'] = TradeContext.TLSQ if TradeContext.existVariable('RBSQ'): state_dict['RBSQ'] = TradeContext.RBSQ if TradeContext.existVariable('FEDT'): state_dict['FEDT'] = TradeContext.FEDT #=====判断主机抹账是否成功==== AfaLoggerFunc.tradeInfo("<<<<<<判断主机抹账是否成功") AfaLoggerFunc.tradeDebug("<<<<<<errorCode=" + TradeContext.errorCode) if(TradeContext.errorCode != '0000'): AfaLoggerFunc.tradeDebug("主机抹账失败") #=====更改原交易状态为抹账失败==== AfaLoggerFunc.tradeInfo("<<<<<<更改原交易状态为抹账失败") state_dict['BDWFLG'] = PL_BDWFLG_FAIL state_dict['STRINFO'] = TradeContext.errorMsg if not rccpsState.setTransState(state_dict): AfaDBFunc.RollBackSql() return AfaFlowControl.ExitThisFlow('S999','设置业务状态为抹账成功异常') else: AfaDBFunc.CommitSql() return AfaFlowControl.ExitThisFlow('S999','主机抹账失败') else: AfaLoggerFunc.tradeInfo("<<<<<<主机抹账成功") #=====更改原交易状态===== AfaLoggerFunc.tradeInfo("<<<<<<更改原交易状态为抹账成功") state_dict['BDWFLG'] = PL_BDWFLG_SUCC state_dict['STRINFO'] = '主机成功' if not rccpsState.setTransState(state_dict): AfaDBFunc.RollBackSql() return AfaFlowControl.ExitThisFlow('S999','设置业务状态为抹账成功异常') else: AfaDBFunc.CommitSql() #=====更改错账登记簿中的处理标示==== AfaLoggerFunc.tradeInfo("<<<<<<更改错账登记簿中的处理标示") where_dict = {} where_dict = {'BJEDTE':tddzcz_record_dict['BJEDTE'],'BSPSQN':tddzcz_record_dict['BSPSQN']} update_dict = {} update_dict['ISDEAL'] = PL_ISDEAL_UNDO update_dict['NOTE3'] = '此笔补记已经被抹账' res = rccpsDBTrcc_tddzcz.updateCmt(update_dict,where_dict) if(res == -1): return AfaFlowControl.ExitThisFlow('S999','更新处理标示失败') else: AfaLoggerFunc.tradeInfo("<<<<<<更改错账登记簿中的处理标示成功") #=====给输出接口赋值===== AfaLoggerFunc.tradeInfo("<<<<<<开始给输出接口赋值") TradeContext.BOSPSQ = wtrbka_record_dict['BSPSQN'] TradeContext.BOJEDT = wtrbka_record_dict['BJEDTE'] TradeContext.BRSFLG = wtrbka_record_dict['BRSFLG'] TradeContext.TRCCO = wtrbka_record_dict['TRCCO'] TradeContext.BEACSB = wtrbka_record_dict['BESBNO'] TradeContext.OROCCAMT = str(wtrbka_record_dict['OCCAMT']) TradeContext.ORCUR = wtrbka_record_dict['CUR'] TradeContext.ORSNDBNK = wtrbka_record_dict['SNDBNKCO'] TradeContext.ORSNDBNKNM = wtrbka_record_dict['SNDBNKNM'] TradeContext.ORRCVBNK = wtrbka_record_dict['RCVBNKCO'] TradeContext.ORRCVBNKNM = wtrbka_record_dict['RCVBNKNM'] TradeContext.ORPYRACC = wtrbka_record_dict['PYRACC'] TradeContext.ORPYRNAM = wtrbka_record_dict['PYRNAM'] TradeContext.ORPYEACC = wtrbka_record_dict['PYEACC'] TradeContext.ORPYENAM = wtrbka_record_dict['PYENAM'] # TradeContext.SBAC = # TradeContext.RBAC = AfaLoggerFunc.tradeDebug("<<<<<<OROCCAMT="+str(TradeContext.OROCCAMT)) AfaLoggerFunc.tradeInfo("<<<<<<结束给输出接口赋值") AfaLoggerFunc.tradeInfo("<<<<<<<个性化处理(本地操作) 退出") AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.差错补记抹账[8573] 退出") return True