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
if not rccpsFunc.ChkPubInfo(PL_BRSFLG_RCV) : raise Exception #=====================机构合法性校验=========================== if not rccpsFunc.ChkUnitInfo( PL_BRSFLG_RCV ) : raise Exception #=====================获取中心日期============================= TradeContext.NCCworkDate = TradeContext.NCCWKDAT #=====================获取平台流水号=========================== if rccpsGetFunc.GetSerialno(PL_BRSFLG_RCV) == -1 : raise Exception #=====================获取中心流水号=========================== if rccpsGetFunc.GetRccSerialno( ) == -1 : raise Exception AfaLoggerFunc.tradeInfo(">>>结束初始化上下文") #=====================登记来账信息============================= AfaLoggerFunc.tradeInfo(">>>开始登记来账信息") #=====================币种转换================================= if TradeContext.CUR == 'CNY': TradeContext.CUR = '01' #=====================开始向字典赋值=========================== trcbka_dict = {} if not rccpsMap1101CTradeContext2Dtrcbka_dict.map(trcbka_dict): rccpsCronFunc.cronExit('M999', '字典赋值出错')
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.中心类操作(1.本地操作).柜台补正[TRCC003_8587]进入***' ) #=====检验变量合法性==== if not TradeContext.existVariable("BOJEDT"): return AfaFlowControl.ExitThisFlow('A099','原报单日期不能为空') if not TradeContext.existVariable("BOSPSQ"): return AfaFlowControl.ExitThisFlow('A099','原报单序号不能为空') #=====查询原交易信息==== wtr_dict = {} if rccpsDBFunc.getTransWtr(TradeContext.BOJEDT,TradeContext.BOSPSQ,wtr_dict): AfaLoggerFunc.tradeInfo(">>>通存通兑登记簿中找到原交易") else: return AfaFlowControl.ExitThisFlow('S0999','查找原交易信息失败') swtr_dict = wtr_dict #=====判断原交易是否为往账==== if( wtr_dict['BRSFLG'] != PL_BRSFLG_SND): return AfaFlowControl.ExitThisFlow('A099','此交易非往账,禁止补正') #====判断账户卡折类型==== if TradeContext.DCFLG == '0': TradeContext.CBFLG = TradeContext.PYITYP else: TradeContext.CBFLG = TradeContext.PYOTYP #====判断原交易状态==== AfaLoggerFunc.tradeInfo("开始判断原交易信息是否允许补正") if (wtr_dict['BCSTAT'] != PL_BCSTAT_CANC and wtr_dict['BDWFLG'] != PL_BDWFLG_SUCC): return AfaFlowControl.ExitThisFlow("S999","交易状态["+str(wtr_dict['BCSTAT'])+"],禁止补正") AfaLoggerFunc.tradeInfo("结束判断原交易信息是否允许补正") #=================登记通存通兑业务登记簿=================================== AfaLoggerFunc.tradeInfo(">>>开始登记通存通兑业务登记簿") #=====================获取中心流水号==================================== if rccpsGetFunc.GetRccSerialno( ) == -1 : raise AfaFlowControl.flowException( ) TradeContext.SNDMBRCO = TradeContext.SNDSTLBIN #发送成员行号 TradeContext.RCVMBRCO = TradeContext.RCVSTLBIN #接收成员行号 TradeContext.TRCNO = TradeContext.SerialNo #交易流水号 TradeContext.NCCWKDAT = TradeContext.NCCworkDate #中心工作日期 TradeContext.MSGFLGNO = TradeContext.SNDMBRCO + TradeContext.TRCDAT + TradeContext.SerialNo #报文标识号 TradeContext.OPRNO = PL_TDOPRNO_BZ #业务种类:个人现金通存 TradeContext.BRSFLG = PL_BRSFLG_SND #往来标识:往账 TradeContext.PYRMBRCO = TradeContext.SNDSTLBIN TradeContext.PYEMBRCO = TradeContext.RCVSTLBIN TradeContext.NOTE1 = TradeContext.BOJEDT TradeContext.NOTE2 = TradeContext.BOSPSQ TradeContext.TRCCO = '3000505' wtrbka_dict = {} if not rccpsMap8563CTradeContext2Dwtrbka_dict.map(wtrbka_dict): return AfaFlowContorl.ExitThisFlow("S999","为通存通兑业务登记簿赋值异常") if(TradeContext.DCFLG == '0'): wtrbka_dict['DCFLG'] = '1' elif(TradeContext.DCFLG == '1'): wtrbka_dict['DCFLG'] = '2' else: return AfaFlowControl.ExitThisFlow('S999','非法借贷标示') if not rccpsDBFunc.insTransWtr(wtrbka_dict): return AfaFlowControl.ExitThisFlow('S999','登记通存通兑业务登记簿异常') AfaLoggerFunc.tradeInfo(">>>结束登记通存通兑业务登记簿") #=====判断原交易是否为异转本或通兑==== if swtr_dict['TRCCO'] in ('3000102','3000103','3000104','3000105') and swtr_dict['CHRGTYP'] == '1': TradeContext.CUSCHRG = str(swtr_dict['CUSCHRG']) else: TradeContext.CUSCHRG = "0.00" #=====发送农信银中心,为发送柜面报文做准备==== #=====报文头==== TradeContext.MSGTYPCO = 'SET009' TradeContext.MSGFLGNO = TradeContext.SNDSTLBIN + TradeContext.TRCDAT + TradeContext.SerialNo TradeContext.ORMFN = swtr_dict['MSGFLGNO'] TradeContext.TRCCO = "3000505" TradeContext.NCCWKDAT = TradeContext.NCCworkDate TradeContext.OPRTYPNO = "30" TradeContext.ROPRTPNO = "30" TradeContext.TRANTYP = "0" #=====业务要素集==== TradeContext.CUR = "CNY" TradeContext.OCCAMT = str(TradeContext.OCCAMT) #TradeContext.OCCAMT = str(wtr_dict['OCCAMT']) TradeContext.CUSCHRG = str(TradeContext.CUSCHRG) TradeContext.ORTRCCO = str(swtr_dict['TRCCO']) TradeContext.ORTRCNO = str(swtr_dict['TRCNO']) if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_SND,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow("S999","设置原交易当前状态为发送-处理中异常") AfaLoggerFunc.tradeInfo(">>>结束设置原交易状态为发送-处理中") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") return True
def main( ): AfaLoggerFunc.tradeInfo('***农信银系统: 往账.主机类操作模板['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']进入***') try: #=====================初始化返回报文变量================================ TradeContext.tradeResponse=[] #=====================获取系统日期时间================================== TradeContext.BJEDTE=AfaUtilTools.GetHostDate( ) #TradeContext.BJEDTE = PL_BJEDTE TradeContext.BJETIM=AfaUtilTools.GetSysTime( ) #TradeContext.TRCDAT = PL_BJEDTE #关彬捷 20081111 修改委托日期为中心日期 #TradeContext.TRCDAT=AfaUtilTools.GetHostDate( ) #修改结束 #=====================系统公共校验====================================== if not rccpsFunc.ChkPubInfo(PL_BRSFLG_SND) : raise AfaFlowControl.flowException( ) #=====================系统状态校验====================================== if not rccpsFunc.ChkSysInfo( 'RCCPS' ) : raise AfaFlowControl.flowException( ) #=====================机构合法性校验==================================== if not rccpsFunc.ChkUnitInfo( PL_BRSFLG_SND ) : raise AfaFlowControl.flowException( ) #=====================获取中心日期==================================== if not rccpsFunc.GetNCCDate( ) : raise AfaFlowControl.flowException( ) #关彬捷 20081111 修改委托日期为中心日期 TradeContext.TRCDAT=TradeContext.NCCworkDate #修改结束 #=====================获取平台流水号==================================== if rccpsGetFunc.GetSerialno(PL_BRSFLG_SND) == -1 : raise AfaFlowControl.flowException( ) #=====================获取中心流水号==================================== if rccpsGetFunc.GetRccSerialno( ) == -1 : raise AfaFlowControl.flowException( ) #=====================动态加载交易脚本================================== trxModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode try: trxModuleHandle=__import__( trxModuleName ) except Exception, e: AfaLoggerFunc.tradeInfo(e) raise AfaFlowControl.flowException( 'A0001', '加载交易脚本失败或交易脚本不存在,执行交易失败' ) #=====================交易前处理(登记流水,主机前处理)=================== if not trxModuleHandle.SubModuleDoFst( ) : raise AfaFlowControl.flowException( ) #=====================与主机通讯======================================== rccpsHostFunc.CommHost( TradeContext.HostCode ) #=====================交易中处理(修改流水,主机后处理,中心前处理)======== if not trxModuleHandle.SubModuleDoSnd( ) : raise AfaFlowControl.flowException( ) #=====================与中心通讯(回执)================================== AfaAfeFunc.CommAfe() #=====================交易后处理======================================== if not trxModuleHandle.SubModuleDoTrd(): raise AfaFlowControl.flowException( ) #=====================自动打包========================================== AfaFunc.autoPackData() #=====================退出模板========================================== AfaLoggerFunc.tradeInfo('***农信银系统: 往账.主机类操作模板['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']退出***')
def SubModuleDoSnd(): AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(2.中心回执).业务状态查询报文接收[RCC006_1107]进入***' ) if TradeContext.errorCode != '0000': return AfaFlowControl.ExitThisFlow("S999","发送通讯回执报文异常") if TradeContext.existVariable('ISDEAL'): AfaLoggerFunc.tradeInfo(">>>状态查询业务正常,成功接收,开始自动业务状态查复处理") AfaLoggerFunc.tradeInfo(">>>开始往账初始化") #=====================往账初始化============================================ TradeContext.sysType = "rccpst" TradeContext.BRSFLG = PL_BRSFLG_SND TradeContext.TRCCO = '9900507' TradeContext.BJEDTE=AfaUtilTools.GetSysDate( ) TradeContext.BJETIM=AfaUtilTools.GetSysTime( ) TradeContext.TRCDAT=AfaUtilTools.GetSysDate( ) #=====================机构合法性校验======================================== if not rccpsFunc.ChkUnitInfo( PL_BRSFLG_SND ) : return AfaFlowControl.ExitThisFlow("S999","机构合法性校验异常") #=====================获取平台流水号======================================== if rccpsGetFunc.GetSerialno(PL_BRSFLG_SND) == -1 : return AfaFlowControl.ExitThisFlow("S999","获取平台流水号异常") #=====================获取中心流水号======================================== if rccpsGetFunc.GetRccSerialno( ) == -1 : return AfaFlowControl.ExitThisFlow("S999","获取中心流水号异常") AfaLoggerFunc.tradeInfo(">>>结束往账初始化") #=====================为状态查复业务字典赋值================================ AfaLoggerFunc.tradeInfo(">>>开始为状态查复业务字典赋值") TradeContext.TRCNO = TradeContext.SerialNo TradeContext.NCCTRCST = "" if not TradeContext.existVariable('ORBCSTAT'): TradeContext.MBRTRCST = PL_MBRTRCST_UNRCV else: if TradeContext.ORBCSTAT == PL_BCSTAT_BNKRCV: TradeContext.MBRTRCST = PL_MBRTRCST_RCV elif (TradeContext.ORBCSTAT == PL_BCSTAT_AUTO or TradeContext.ORBCSTAT == PL_BCSTAT_HANG) and TradeContext.ORBDWFLG ==PL_BDWFLG_SUCC: TradeContext.MBRTRCST = PL_MBRTRCST_ACSUC elif (TradeContext.ORBCSTAT == PL_BCSTAT_AUTO or TradeContext.ORBCSTAT == PL_BCSTAT_HANG) and TradeContext.ORBDWFLG ==PL_BDWFLG_FAIL: TradeContext.MBRTRCST = PL_MBRTRCST_ACFAL elif(TradeContext.ORBCSTAT == PL_BCSTAT_CONFACC and TradeContext.ORBDWFLG == PL_BDWFLG_SUCC): TradeContext.MBRTRCST = PL_MBRTRCST_CNF elif (TradeContext.ORBCSTAT == PL_BCSTAT_AUTOPAY and TradeContext.ORBDWFLG == PL_BDWFLG_SUCC): TradeContext.MBRTRCST = PL_MBRTRCST_ACSUC elif (TradeContext.ORBCSTAT == PL_BCSTAT_AUTOPAY and TradeContext.ORBDWFLG == PL_BDWFLG_FAIL): TradeContext.MBRTRCST = PL_MBRTRCST_ACFAL elif (TradeContext.ORBCSTAT == PL_BCSTAT_AUTOPAY and TradeContext.ORBDWFLG == PL_BDWFLG_WAIT): TradeContext.MBRTRCTS = PL_MBRTRCST_RCV elif (TradeContext.ORBCSTAT == PL_BCSTAT_CANC and TradeContext.ORBDWFLG == PL_BDWFLG_SUCC): TradeContext.MBRTRCTS = PL_MBRTRCST_RUSH else: TradeContext.MBRTRCTS = PL_MBRTRCST_RCV TradeContext.CONT = "系统自动查复业务状态查询" TradeContext.SNDMBRCO = TradeContext.SNDSTLBIN TradeContext.RCVMBRCO = TradeContext.RCVSTLBIN ztcbka_insert_dict = {} if not rccpsMap1107CTradeContext2Dztcbka.map(ztcbka_insert_dict): return AfaFlowControl.ExitThisFlow("S999","为查复业务字典赋值异常") AfaLoggerFunc.tradeInfo(">>>结束为状态查复业务字典赋值") #=====================登记状态查复业务====================================== AfaLoggerFunc.tradeInfo(">>>开始登记状态查询查复登记簿") ret = rccpsDBTrcc_ztcbka.insert(ztcbka_insert_dict) if ret <= 0: return AfaFlowControl.ExitThisFlow("S999","登记状态查询查复登记簿异常") AfaLoggerFunc.tradeInfo(">>>结束登记状态查询查复登记簿") #=====================修改原查询业务查询查复标识============================ AfaLoggerFunc.tradeInfo(">>>开始修改原查询业务查询查复标识") orztcbka_update_dict = {'ISDEAL':PL_ISDEAL_ISDO,'NCCTRCST':TradeContext.NCCTRCST,'MBRTRCST':TradeContext.MBRTRCST} orztcbka_where_dict = {'BJEDTE':TradeContext.BOJEDT,'BSPSQN':TradeContext.BOSPSQ} ret = rccpsDBTrcc_ztcbka.update(orztcbka_update_dict,orztcbka_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(">>>Commit成功") #=====================为业务状态查复报文赋值================================ AfaLoggerFunc.tradeInfo(">>>开始为业务状态查复报文赋值") TradeContext.sysType = 'rccpst' TradeContext.TRCCO = '9900507' TradeContext.MSGTYPCO = 'SET008' TradeContext.SNDBRHCO = TradeContext.BESBNO TradeContext.SNDCLKNO = TradeContext.BETELR TradeContext.SNDTRDAT = TradeContext.BJEDTE TradeContext.SNDTRTIM = TradeContext.BJETIM TradeContext.TRCNO = TradeContext.SerialNo TradeContext.MSGFLGNO = TradeContext.SNDSTLBIN + TradeContext.TRCDAT + TradeContext.SerialNo TradeContext.OPRTYPNO = '99' TradeContext.TRANTYP = '0' AfaLoggerFunc.tradeInfo(">>>结束为业务状态查复报文赋值") #=====================发送业务状态查复报文================================== AfaLoggerFunc.tradeInfo(">>>开始发送业务状态查复报文") AfaAfeFunc.CommAfe() if TradeContext.errorCode != '0000': return AfaFlowControl.ExitThisFlow("S999","发送业务状态查复报文异常") AfaLoggerFunc.tradeInfo(">>>结束发送业务状态查复报文") AfaLoggerFunc.tradeInfo(">>>结束自动业务状态查复处理") else: AfaLoggerFunc.tradeInfo(">>>状态查询业务非正常,不进行自动业务状态查复处理") AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(2.中心回执).业务状态查询报文接收[RCC006_1107]退出***' ) return True