def UpdateUserPass(): sql = "SELECT PASSWORD FROM ABDT_USERINFO WHERE STATUS='1' AND USERNO = '" + TradeContext.USERNO + "'" AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql ) if (records == None or len(records)==0) : return ExitSubTrade( '9000', '不存在用户信息' ) if (records[0][0] != TradeContext.OLDPASSWD): return ExitSubTrade( '9000', '旧密码不符' ) sql = "UPDATE ABDT_USERINFO SET PASSWORD='******'" sql = sql + " WHERE " sql = sql + "USERNO=" + "'" + TradeContext.USERNO + "'" #用户号 AfaLoggerFunc.tradeInfo(sql) ret = AfaDBFunc.UpdateSqlCmt( sql ) if (ret < 0): return ExitSubTrade('9000', '修改用户密码失败') return True
def update( update_dict,where_dict ): if not chk(update_dict): return -1 if not chk(where_dict): return -1 updatesql = "" for update_item in update_dict.keys(): if table_dict[update_item] == 'S': updatesql = updatesql + update_item + " = '" + update_dict[update_item] + "'," else: updatesql = updatesql + update_item + " = " + str(update_dict[update_item]) + "," wheresql = "" for where_item in where_dict.keys(): if table_dict[where_item] == 'S': #begin 20110215 蔡永贵修改 #wheresql = wheresql + where_item + " LIKE '" + where_dict[where_item] + "' and " wheresql = wheresql + where_item + " LIKE '%" + where_dict[where_item] + "' and " #end else: wheresql = wheresql + where_item + " = " + str(where_dict[where_item]) + " and " sql = "UPDATE rcc_bilinf SET " + updatesql[0:-1] + " WHERE " + wheresql[0:-5] AfaLoggerFunc.tradeInfo(sql) return AfaDBFunc.UpdateSql( sql )
def selectu( where_dict ): if not chk(where_dict): return None wheresql = "" for where_item in where_dict.keys(): if table_dict[where_item] == 'S': wheresql = wheresql + where_item + " LIKE '" + where_dict[where_item] + "' and " else: wheresql = wheresql + where_item + " = " + str(where_dict[where_item]) + " and " sql = "SELECT BPATPE,BPARAD,BPACMT,BPADAT,BPAINF,BEFTDT,BINVDT,NOTE1,NOTE2,NOTE3,NOTE4 FROM rcc_pamtbl WHERE " + wheresql[0:-5] AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql ) if (records == None): return None elif (len(records) > 1): AfaLoggerFunc.tradeError("查询结果非唯一,请检查查询条件[" + wheresql[0:-5] + "]") return None elif (len(records) == 0): AfaLoggerFunc.tradeError("查询结果为空,查询条件[" + wheresql[0:-5] + "]") tmp_dict = {} return tmp_dict else: tmp_dict = {} for i in xrange(0,len(table_tuple)): if len(str(records[0][i])) == 0: tmp_dict[table_tuple[i]] = "" else: tmp_dict[table_tuple[i]] = records[0][i] #AfaLoggerFunc.tradeInfo("return return_dict:" + str(tmp_dict)) return tmp_dict
def main( ): AfaLoggerFunc.tradeInfo('======进入缴费交易模板['+TradeContext.TemplateCode+']=======') flag = 0 try: #=============初始化返回报文变量==================== TradeContext.tradeResponse=[] #=============获取当前系统时间==================== TradeContext.workDate = AfaUtilTools.GetSysDate( ) TradeContext.workTime = AfaUtilTools.GetSysTime( ) #begin 20100625 蔡永贵修改 #TradeContext.sysId = "AG2008" TradeContext.sysId = TradeContext.appNo #end TradeContext.agentFlag = "01" TradeContext.__respFlag__='0' #=============外调接口1==================== subModuleExistFlag=0 subModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode try: subModuleHandle=__import__( subModuleName ) except Exception, e: AfaLoggerFunc.tradeInfo( e) else:
def getTransStateSetm(BJEDTE,BSPSQN,BCSTAT,BDWFLG,stat_list): AfaLoggerFunc.tradeInfo(">>>进入getTransStateSetm") #==========获取sstlog对应状态及信息========================================= sstlog_where_sql = "BJEDTE LIKE '" + BJEDTE + "' and BSPSQN LIKE '" + BSPSQN + "' and BCSTAT LIKE '" + BCSTAT + "' and BDWFLG LIKE '" + BDWFLG + "'" sstlog_order_sql = 'order by BCURSQ desc' sstlog_list = rccpsDBTrcc_sstlog.selectm(1,0,sstlog_where_sql,sstlog_order_sql) if sstlog_list == None: AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) AfaLoggerFunc.tradeFatal("获取交易[" + BJEDTE + "][" + BSPSQN + "]指定状态详细信息异常") return AfaFlowControl.ExitThisFlow( 'S999', '获取交易指定状态详细信息异常' ) if len(sstlog_list) <= 0: AfaLoggerFunc.tradeFatal("流水状态登记簿中无此交易" + BJEDTE + "][" + BSPSQN + "]指定状态[" + BCSTAT + "][" + BDWFLG + "]详细信息") return AfaFlowControl.ExitThisFlow( 'S999', '流水状态登记簿中无此交易指定状态详细信息' ) for i in xrange(0,len(sstlog_list)): stat_dict = {} if not rccpsMap0000Dsstlog2Dstat_dict.map(sstlog_list[i],stat_dict): AfaLoggerFunc.tradeFatal("将查询出的业务状态详细信息赋值到输出字典异常") return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的业务状态详细信息赋值到输出字典异常' ) stat_list.append(stat_dict) AfaLoggerFunc.tradeInfo(">>>结束getTransStateSetm") return True
def selectu( where_dict ): if not chk(where_dict): return None wheresql = "" for where_item in where_dict.keys(): if table_dict[where_item] == 'S': wheresql = wheresql + where_item + " LIKE '" + where_dict[where_item] + "' and " else: wheresql = wheresql + where_item + " = " + str(where_dict[where_item]) + " and " sql = "SELECT BJEDTE,BSPSQN,BRSFLG,TRCCO,NCCWKDAT,TRCDAT,TRCNO,SNDMBRCO,RCVMBRCO,SNDBNKCO,SNDBNKNM,RCVBNKCO,RCVBNKNM,CUR,LBDCFLG,LSTDTBAL,NTTDCFLG,NTTBAL,BALDCFLG,TODAYBAL,AVLBAL,NTODAYBAL,CHKRST,BOJEDT,BOSPSQ,PRCCO,STRINFO,NOTE1,NOTE2,NOTE3,NOTE4 FROM rcc_rekbal WHERE " + wheresql[0:-5] AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql ) if (records == None): return None elif (len(records) > 1): AfaLoggerFunc.tradeError("查询结果非唯一,请检查查询条件[" + wheresql[0:-5] + "]") return None elif (len(records) == 0): AfaLoggerFunc.tradeError("查询结果为空,查询条件[" + wheresql[0:-5] + "]") tmp_dict = {} return tmp_dict else: tmp_dict = {} for i in xrange(0,len(table_tuple)): if len(str(records[0][i])) == 0: tmp_dict[table_tuple[i]] = "" else: tmp_dict[table_tuple[i]] = records[0][i] #AfaLoggerFunc.tradeInfo("return return_dict:" + str(tmp_dict)) return tmp_dict
def getTransStateSet(BJEDTE,BSPSQN,BCSTAT,BDWFLG,stat_dict): AfaLoggerFunc.tradeInfo(">>>进入getTransStateSet") #==========获取sstlog对应状态及信息========================================= sstlog_where_dict = {} sstlog_where_dict["BJEDTE"] = BJEDTE sstlog_where_dict["BSPSQN"] = BSPSQN sstlog_where_dict["BCSTAT"] = BCSTAT sstlog_where_dict["BDWFLG"] = BDWFLG sstlog_dict = rccpsDBTrcc_sstlog.selectu(sstlog_where_dict) if sstlog_dict == None: AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) AfaLoggerFunc.tradeFatal("获取交易[" + BJEDTE + "][" + BSPSQN + "]指定状态详细信息异常") return AfaFlowControl.ExitThisFlow( 'S999', '获取交易指定状态详细信息异常' ) if len(sstlog_dict) <= 0: AfaLoggerFunc.tradeFatal("流水状态登记簿中无此交易" + BJEDTE + "][" + BSPSQN + "]指定状态[" + BCSTAT + "][" + BDWFLG + "]详细信息") return AfaFlowControl.ExitThisFlow( 'S999', '流水状态登记簿中无此交易指定状态详细信息' ) if not rccpsMap0000Dsstlog2Dstat_dict.map(sstlog_dict,stat_dict): AfaLoggerFunc.tradeFatal("将查询出的业务状态详细信息赋值到输出字典异常") return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的业务状态详细信息赋值到输出字典异常' ) AfaLoggerFunc.tradeInfo(">>>结束getTransStateSet") return True
def getTransStateAll(BJEDTE,BSPSQN,stat_list): AfaLoggerFunc.tradeInfo(">>>进入getTransStateAll") #===========获取sstlog所有状态及相关信息==================================== sstlog_where_sql = "BJEDTE = '" + BJEDTE + "' and BSPSQN = '" + BSPSQN + "'" sstlog_order_sql = " order by BCURSQ desc " sstlog_list = rccpsDBTrcc_sstlog.selectm(1,0,sstlog_where_sql,sstlog_order_sql) if sstlog_list == None: AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) AfaLoggerFunc.tradeFatal("获取交易[" + BJEDTE + "][" + BSPSQN + "]所有状态详细信息异常") return AfaFlowControl.ExitThisFlow( 'S999', '获取交易所有状态详细信息异常' ) if len(sstlog_list) <= 0: AfaLoggerFunc.tradeFatal("流水状态登记簿中无此交易[" + BJEDTE + "][" + BSPSQN + "]状态详细信息") return AfaFlowControl.ExitThisFlow( 'S999', '流水状态登记簿中无此交易状态详细信息' ) for i in xrange(0,len(sstlog_list)): stat_dict = {} if not rccpsMap0000Dsstlog2Dstat_dict.map(sstlog_list[i],stat_dict): AfaLoggerFunc.tradeFatal("将查询出的业务状态详细信息赋值到输出字典异常") return AfaFlowControl.ExitThisFlow( 'S999', '将查询出的业务状态详细信息赋值到输出字典异常' ) stat_list.append(stat_dict) AfaLoggerFunc.tradeInfo(">>>结束getTransStateAll") return True
def ChkCustInfo( ): #AfaLoggerFunc.tradeInfo('>>>判断个人协议是否存在') try: sql = "" sql = "SELECT PROTOCOLNO,BUSIUSERNO,ACCNO FROM ABDT_CUSTINFO WHERE " sql = sql + "APPNO='AG1014' AND " #业务编号 sql = sql + "BUSINO=" + "'" + TradeContext.I1BUSINO + "'" + " AND (" #单位编号 sql = sql + "BUSIUSERNO=" + "'" + TradeContext.SBNO + "'" + " OR " #商户客户编号 sql = sql + "ACCNO=" + "'" + TradeContext.ACCNO + "'" + " )AND " #银行账号 sql = sql + "STATUS=" + "'" + "1" + "'" #状态 AfaLoggerFunc.tradeInfo( sql ) records = AfaDBFunc.SelectSql( sql ) if ( records == None ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return ExitSubTrade( '9000', '查询个人协议信息异常' ) if ( len(records) > 0 ): if records[0][1]== TradeContext.SBNO: return ExitSubTrade( '9000', '该个人协议的社保编号已经被注册,不能再次进行注册') if records[0][2]== TradeContext.ACCNO: return ExitSubTrade( '9000', '该个人协议的账号已经被注册,不能再次进行注册') else: return ExitSubTrade( '9000', '该个人协议已经被注册,不能再次进行注册') return True except Exception, e: AfaLoggerFunc.tradeFatal( str(e) ) return ExitSubTrade( '9999', '判断个人协议信息是否存在异常')
def selectu( where_dict ): if not chk(where_dict): return None wheresql = "" for where_item in where_dict.keys(): if table_dict[where_item] == 'S': wheresql = wheresql + where_item + " LIKE '" + where_dict[where_item] + "' and " else: wheresql = wheresql + where_item + " = " + str(where_dict[where_item]) + " and " sql = "SELECT SNDBNKCO,TRCDAT,TRCNO,NCCWKDAT,TRCCO,MSGTYPCO,RCVMBRCO,SNDMBRCO,SNDBRHCO,SNDCLKNO,SNDTRDAT,SNDTRTIM,MSGFLGNO,ORMFN,OPRTYPNO,ROPRTPNO,SNDBNKNM,RCVBNKCO,RCVBNKNM,CUR,OCCAMT,CUSCHRG,PYRMBRCO,PYRACC,PYEMBRCO,PYEACC,ORTRCCO,ORTRCNO,DCFLG,CBFLG,CONFFLG,CANCFLG,STRINFO,BJEDTE,BSPSQN,NOTE1,NOTE2,NOTE3,NOTE4 FROM rcc_tddzmx WHERE " + wheresql[0:-5] AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql ) if (records == None): return None elif (len(records) > 1): AfaLoggerFunc.tradeError("查询结果非唯一,请检查查询条件[" + wheresql[0:-5] + "]") return None elif (len(records) == 0): AfaLoggerFunc.tradeError("查询结果为空,查询条件[" + wheresql[0:-5] + "]") tmp_dict = {} return tmp_dict else: tmp_dict = {} for i in xrange(0,len(table_tuple)): if len(str(records[0][i])) == 0: tmp_dict[table_tuple[i]] = "" else: tmp_dict[table_tuple[i]] = records[0][i] #AfaLoggerFunc.tradeInfo("return return_dict:" + str(tmp_dict)) return tmp_dict
def ADBUpdateTransdtlRev( ): sqlupdate = "" AfaLoggerFunc.tradeInfo( '>>>>>>>开始更新原冲正交易结果信息<<<<<<<') sqlupdate = sqlupdate + "update afa_maintransdtl set " sqlupdate = sqlupdate + " corpcode = '"+TradeContext.errorCode.strip()+"' " sqlupdate = sqlupdate + ", errorMsg = '"+TradeContext.errorMsg.strip()+"' " sqlupdate = sqlupdate + " where sysid = '"+TradeContext.sysId+"' and agentserialno = '"+TradeContext.agentSerialno+"'" AfaLoggerFunc.tradeInfo( 'sqlupdate = ' + str(sqlupdate)) record=AfaDBFunc.UpdateSqlCmt( sqlupdate ) if( record > 0 ): AfaLoggerFunc.tradeInfo( '>>>>>>>更新原冲正交易结果信息成功<<<<<<<') return True if( record == 0 ): AfaLoggerFunc.tradeInfo( '>>>>>>>更新原冲正交易结果信息失败<<<<<<<') TradeContext.errorCode,TradeContext.errorMsg='A0100','未发现原始交易' return False else : AfaLoggerFunc.tradeInfo( '>>>>>>>更新原冲正交易结果信息失败<<<<<<<') TradeContext.errorCode, TradeContext.errorMsg='A0100', '更新原交易状态失败' + AfaDBFunc.sqlErrMsg return False
def GetDetailFile(rfilename, lfilename): try: #创建文件 ftpShell = os.environ['AFAP_HOME'] + '/data/ahfs/shell/ahfs_ahfs.sh' ftpFp = open(ftpShell, "w") ftpFp.write('open ' + TradeContext.HOST_HOSTIP + '\n') ftpFp.write('user ' + TradeContext.HOST_USERNO + ' ' + TradeContext.HOST_PASSWD + '\n') #下载文件 ftpFp.write('cd ' + TradeContext.HOST_RDIR + '\n') ftpFp.write('lcd ' + TradeContext.HOST_LDIR + '\n') ftpFp.write('quote type c 1381 ' + '\n') ftpFp.write('get ' + rfilename + ' ' + lfilename + '\n') ftpFp.close() ftpcmd = 'ftp -n < ' + ftpShell + ' 1>/dev/null 2>/dev/null ' ret = os.system(ftpcmd) if ( ret != 0 ): return -1 else: return 0 except Exception, e: AfaLoggerFunc.tradeInfo(e) AfaLoggerFunc.tradeInfo('FTP处理异常') return -1
def SubModuleDoFst( ): AfaLoggerFunc.tradeInfo( '反交易变量值的有效性校验' ) #交易代码 TradeContext.tradeCode = TradeContext.TransCode if( not TradeContext.existVariable( "PreSerialno" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '原交易流水号[PreSerialno]值不存在!' ) if( not TradeContext.existVariable( "channelCode" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '渠道代码[channelCode]值不存在!' ) if( TradeContext.channelCode == '005' ): if( not TradeContext.existVariable( "tellerno" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '柜员号[tellerno]值不存在!' ) if( not TradeContext.existVariable( "brno" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '网点号[brno]值不存在!' ) if( not TradeContext.existVariable( "termid" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '柜员号[termid]值不存在!' ) return True
def ftpfile( sfilename, rfilename): try: #创建文件 ftpShell = os.environ['AFAP_HOME'] + '/data/ahfs/shell/AhfsFtpTf' + '.sh' ftpFp = open(ftpShell, "w") ftpFp.write('open ' + TradeContext.BATCH_HOSTIP + '\n') ftpFp.write('user ' + TradeContext.BATCH_USERNO + ' ' + TradeContext.BATCH_PASSWD + '\n') #下载文件 ftpFp.write('cd ' + TradeContext.BATCH_RDIR + '\n') ftpFp.write('lcd ' + TradeContext.BATCH_LDIR + '\n') ftpFp.write('bin ' + '\n') ftpFp.write('get ' + rfilename + ' ' + sfilename + '\n') ftpFp.close() ftpcmd = 'ftp -n < ' + ftpShell + ' 1>/dev/null 2>/dev/null ' os.system(ftpcmd) return 0 except Exception, e: AfaLoggerFunc.tradeInfo(e) AfaLoggerFunc.tradeInfo('FTP处理异常') return -1
def ChkLiquidStatus(): AfaLoggerFunc.tradeInfo( '>>>获取清算信息' ) sql ="SELECT PAYBKCODE,PAYEEBANKNO,TRECODE,TRENAME,PAYEEACCT,PAYBKNAME,STATUS FROM TIPS_LIQUIDATE_ADM WHERE " sql =sql + "BRNO = '" + TradeContext.brno + "'" AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql(sql) if( records == None ): AfaLoggerFunc.tradeFatal(sql) return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg ) elif( len( records )==0 ): return TipsFunc.ExitThisFlow( 'A0027', '本机构不是清算行,不可以进行对账差错查询' ) else: if records[0][6]=='0': return TipsFunc.ExitThisFlow( 'A0027', '业务已停止,不可进行查询' ) if records[0][6]=='2': return TipsFunc.ExitThisFlow( 'A0027', '业务已暂停,不可进行查询' ) AfaLoggerFunc.tradeInfo('本机构的清算行号为'+ records[0][0]) AfaLoggerFunc.tradeInfo('柜面送的清算行号为'+ TradeContext.payBkCode) if(records[0][0]!=TradeContext.payBkCode): return TipsFunc.ExitThisFlow( 'A0002', '清算行行号不正确,不允许做此交易') AfaLoggerFunc.tradeInfo( '>>>获取清算信息完成' ) return True
def TrxMain( ): AfaLoggerFunc.tradeInfo('**********批量处理多笔查询(8490)开始**********') TradeContext.O1AFAPDATE = TradeContext.TranDate #工作日期 TradeContext.O1AFAPTIME = TradeContext.TranTime #工作日期 #查询单位信息,获得单位编号 try: sql = "" sql = "SELECT BUSINO FROM ABDT_UNITINFO WHERE " sql = sql + "APPNO=" + "'" + TradeContext.I1APPNO + "'" + " AND " #业务编号 sql = sql + "ACCNO=" + "'" + TradeContext.I1ACCNO + "'" #对公账户 AfaLoggerFunc.tradeInfo( sql ) results = AfaDBFunc.SelectSql( sql ) if ( results == None ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return ExitSubTrade( '9000', '查询单位信息异常' ) if ( len(results) <= 0 ): return ExitSubTrade( '9000', '没有单位信息,不能进行此类操作') except Exception, e: AfaLoggerFunc.tradeFatal( str(e) ) return ExitSubTrade( '9999', '查询单位信息失败')
def selectu( where_dict ): if not chk(where_dict): return None wheresql = "" for where_item in where_dict.keys(): if table_dict[where_item] == 'S': wheresql = wheresql + where_item + " LIKE '" + where_dict[where_item] + "' and " else: wheresql = wheresql + where_item + " = " + str(where_dict[where_item]) + " and " sql = "SELECT BANKBIN,BANKSTATUS,BANKATTR,STLBANKBIN,BANKNAM,BANKADDR,BANKPC,BANKTEL,EFCTDAT,INVDAT,ALTTYPE,PRIVILEGE,NEWOFLG,STRINFO,NOTE1,NOTE2,NOTE3,NOTE4 FROM rcc_paybnk WHERE " + wheresql[0:-5] AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql ) if (records == None): return None elif (len(records) > 1): AfaLoggerFunc.tradeError("查询结果非唯一,请检查查询条件[" + wheresql[0:-5] + "]") return None elif (len(records) == 0): AfaLoggerFunc.tradeError("查询结果为空,查询条件[" + wheresql[0:-5] + "]") tmp_dict = {} return tmp_dict else: tmp_dict = {} for i in xrange(0,len(table_tuple)): if len(str(records[0][i])) == 0: tmp_dict[table_tuple[i]] = "" else: tmp_dict[table_tuple[i]] = records[0][i] #AfaLoggerFunc.tradeInfo("return return_dict:" + str(tmp_dict)) return tmp_dict
def selectu( where_dict ): if not chk(where_dict): return None wheresql = "" for where_item in where_dict.keys(): if table_dict[where_item] == 'S': wheresql = wheresql + where_item + " LIKE '" + where_dict[where_item] + "' and " else: wheresql = wheresql + where_item + " = " + str(where_dict[where_item]) + " and " sql = "SELECT SNDBNKCO,TRCDAT,TRCNO,ROPRTPNO,TRCCO,RCVBNKCO,CUR,RDTCNT,RDTAMT,RCTCNT,RCTAMT,SDTCNT,SDTAMT,SCTCNT,SCTAMT,NOTE1,NOTE2,NOTE3,NOTE4 FROM rcc_atrchk WHERE " + wheresql[0:-5] AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql ) if (records == None): return None elif (len(records) > 1): AfaLoggerFunc.tradeError("查询结果非唯一,请检查查询条件[" + wheresql[0:-5] + "]") return None elif (len(records) == 0): AfaLoggerFunc.tradeError("查询结果为空,查询条件[" + wheresql[0:-5] + "]") tmp_dict = {} return tmp_dict else: tmp_dict = {} for i in xrange(0,len(table_tuple)): if len(str(records[0][i])) == 0: tmp_dict[table_tuple[i]] = "" else: tmp_dict[table_tuple[i]] = records[0][i] #AfaLoggerFunc.tradeInfo("return return_dict:" + str(tmp_dict)) return tmp_dict
def selectu( where_dict ): if not chk(where_dict): return None wheresql = "" for where_item in where_dict.keys(): if table_dict[where_item] == 'S': wheresql = wheresql + where_item + " LIKE '" + where_dict[where_item] + "' and " else: wheresql = wheresql + where_item + " = " + str(where_dict[where_item]) + " and " sql = "SELECT BJEDTE,BSPSQN,BRSFLG,BESBNO,BETELR,BEAUUS,NCCWKDAT,TRCCO,TRCDAT,TRCNO,SNDMBRCO,RCVMBRCO,SNDBNKCO,SNDBNKNM,RCVBNKCO,RCVBNKNM,BOJEDT,BOSPSQ,ORTRCCO,BILDAT,BILNO,BILPNAM,BILENDDT,BILAMT,PYENAM,HONBNKNM,CONT,ISDEAL,PRCCO,STRINFO,NOTE1,NOTE2,NOTE3,NOTE4 FROM rcc_pjcbka WHERE " + wheresql[0:-5] AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql ) if (records == None): return None elif (len(records) > 1): AfaLoggerFunc.tradeError("查询结果非唯一,请检查查询条件[" + wheresql[0:-5] + "]") return None elif (len(records) == 0): AfaLoggerFunc.tradeError("查询结果为空,查询条件[" + wheresql[0:-5] + "]") tmp_dict = {} return tmp_dict else: tmp_dict = {} for i in xrange(0,len(table_tuple)): if len(str(records[0][i])) == 0: tmp_dict[table_tuple[i]] = "" else: tmp_dict[table_tuple[i]] = records[0][i] #AfaLoggerFunc.tradeInfo("return return_dict:" + str(tmp_dict)) return tmp_dict
def SubModuleDoFst( ): AfaLoggerFunc.tradeInfo( '初始化汇总查询交易变量' ) if( not (TradeContext.existVariable( "insuid" ) ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '机构号[insuid]值不存在!' ) if( not (TradeContext.existVariable( "productid" ) ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '险种[productid]值不存在!' ) if( not (TradeContext.existVariable( "instno" ) ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '机构号[instno]值不存在!' ) if( not (TradeContext.existVariable( "salerno" ) ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '销售员工工号[salerno]值不存在!' ) if( not (TradeContext.existVariable( "startdate" ) and TradeContext.startdate != '00000000') ): return AfaFlowControl.ExitThisFlow( 'A0001', '起始日期[startdate]值不存在!' ) if( not (TradeContext.existVariable( "enddate" ) and TradeContext.enddate != '00000000' ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '截止日期[enddate]值不存在!' ) if( not TradeContext.existVariable( "channelCode" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '渠道代码[channelCode]值不存在!' ) if( TradeContext.channelCode == '005' ): if( not TradeContext.existVariable( "tellerno" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '柜员号[tellerno]值不存在!' ) if( not TradeContext.existVariable( "brno" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '网点号[brno]值不存在!' ) if( not TradeContext.existVariable( "termid" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '柜员号[termid]值不存在!' ) return True
def selectu( where_dict ): if not chk(where_dict): return None wheresql = "" for where_item in where_dict.keys(): if table_dict[where_item] == 'S': wheresql = wheresql + where_item + " LIKE '" + where_dict[where_item] + "' and " else: wheresql = wheresql + where_item + " = " + str(where_dict[where_item]) + " and " sql = "SELECT BJEDTE,BSPSQN,BRSFLG,BESBNO,BEACSB,BETELR,BEAUUS,BEAUPS,TERMID,BBSSRC,DASQ,DCFLG,OPRNO,OPRATTNO,NCCWKDAT,TRCCO,TRCDAT,TRCNO,MSGFLGNO,COTRCDAT,COTRCNO,COMSGFLGNO,SNDMBRCO,RCVMBRCO,SNDBNKCO,SNDBNKNM,RCVBNKCO,RCVBNKNM,CUR,OCCAMT,CHRGTYP,LOCCUSCHRG,CUSCHRG,PYRTYP,PYRACC,PYRNAM,PYRADDR,PYETYP,PYEACC,PYENAM,PYEADDR,STRINFO,CERTTYPE,CERTNO,BNKBKNO,BNKBKBAL,NOTE1,NOTE2,NOTE3,NOTE4 FROM rcc_wtrbka WHERE " + wheresql[0:-5] AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql ) if (records == None): return None elif (len(records) > 1): AfaLoggerFunc.tradeError("查询结果非唯一,请检查查询条件[" + wheresql[0:-5] + "]") return None elif (len(records) == 0): AfaLoggerFunc.tradeError("查询结果为空,查询条件[" + wheresql[0:-5] + "]") tmp_dict = {} return tmp_dict else: tmp_dict = {} for i in xrange(0,len(table_tuple)): if len(str(records[0][i])) == 0: tmp_dict[table_tuple[i]] = "" else: tmp_dict[table_tuple[i]] = records[0][i] #AfaLoggerFunc.tradeInfo("return return_dict:" + str(tmp_dict)) return tmp_dict
def main( ): AfaLoggerFunc.tradeInfo('******代收代付.模板1.缴费模板['+TradeContext.TemplateCode+']进入******') try: #=====================初始化返回报文变量================================ TradeContext.tradeResponse=[] #=====================获取当前系统时间================================== TradeContext.workDate=AfaUtilTools.GetSysDate( ) TradeContext.workTime=AfaUtilTools.GetSysTime( ) #=====================判断应用系统状态================================== if not AfaFunc.ChkSysStatus( ) : raise AfaFlowControl.flowException( ) #=====================外调接口(前处理)================================== subModuleExistFlag=0 subModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode try: subModuleHandle=__import__( subModuleName ) except Exception, e: AfaLoggerFunc.tradeInfo( e) else:
def selectu( where_dict ): if not chk(where_dict): return None wheresql = "" for where_item in where_dict.keys(): if table_dict[where_item] == 'S': wheresql = wheresql + where_item + " LIKE '" + where_dict[where_item] + "' and " else: wheresql = wheresql + where_item + " = " + str(where_dict[where_item]) + " and " sql = "SELECT TRCDAT,BSPSQN,MSGFLGNO,ORMFN,TRCCO,BRSFLG,BESBNO,BEACSB,BETELR,BEAUUS,BEAUPS,TERMID,OPTYPE,NCCWKDAT,TRCNO,SNDMBRCO,RCVMBRCO,SNDBNKCO,SNDBNKNM,RCVBNKCO,RCVBNKNM,ORTRCDAT,ORTRCCO,ORTRCNO,ORSNDSUBBNK,ORSNDBNK,ORRCVSUBBNK,ORRCVBNK,ORPYRACC,ORPYRNAM,ORPYEACC,ORPYENAM,CUR,OCCAMT,CHRG,ERRCONBAL,BALANCE,UNCONRST,CONSTS,PRCCO,STRINFO,NOTE1,NOTE2,NOTE3,NOTE4,NOTE5 FROM rcc_acckj WHERE " + wheresql[0:-5] AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql ) if (records == None): return None elif (len(records) > 1): AfaLoggerFunc.tradeError("查询结果非唯一,请检查查询条件[" + wheresql[0:-5] + "]") return None elif (len(records) == 0): AfaLoggerFunc.tradeError("查询结果为空,查询条件[" + wheresql[0:-5] + "]") tmp_dict = {} return tmp_dict else: tmp_dict = {} for i in xrange(0,len(table_tuple)): if len(str(records[0][i])) == 0: tmp_dict[table_tuple[i]] = "" else: tmp_dict[table_tuple[i]] = records[0][i] #AfaLoggerFunc.tradeInfo("return return_dict:" + str(tmp_dict)) return tmp_dict
def Query_ChkVariableExist( ): AfaLoggerFunc.tradeInfo( '查询类变量值的有效性校验[begin]' ) if( not TradeContext.existVariable( "appNo" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '业务编号[appNo]值不存在!' ) if( not TradeContext.existVariable( "busiNo" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', 'busiNo[busiNo]值不存在!' ) if( not TradeContext.existVariable( "trxCode" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '交易代码[trxCode]值不存在!' ) if( not TradeContext.existVariable( "channelCode" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '渠道代码[channelCode]值不存在!' ) else: TradeContext.channelCode=AfaUtilTools.Lfill( TradeContext.channelCode, 3, '0' ) if( TradeContext.channelCode == '001' ): if( not TradeContext.existVariable( "brno" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '机构代码[brno]值不存在!' ) if( not TradeContext.existVariable( "teller" ) ): return AfaFlowControl.ExitThisFlow( 'A0001', '柜员号[teller]值不存在!' ) AfaLoggerFunc.tradeInfo( '查询类变量值的有效性校验[end]' ) return True
def TrxMain( ): AfaLoggerFunc.tradeInfo('**********批量作业清单打印(8412)开始**********') TradeContext.tradeResponse.append(['O1AFAPDATE', TradeContext.TranDate]) #工作日期 TradeContext.tradeResponse.append(['O1AFAPTIME', TradeContext.TranTime]) #工作时间 #判断单位协议是否有效 if ( not AbdtFunc.ChkUnitInfo( ) ): return False #查询批量作业报表信息 if ( not QueryBatchInfo( ) ): return False AfaLoggerFunc.tradeInfo('**********批量作业清单打印(8412)结束**********') #返回 TradeContext.tradeResponse.append(['errorCode', '0000']) TradeContext.tradeResponse.append(['errorMsg', '交易成功']) return True
def getErrInfo(ERRKEY): AfaLoggerFunc.tradeInfo(">>>开始获取中心返回代码[" + ERRKEY + "]对应信息") errinf_where_dict = {} if ERRKEY[:2] != 'NN': errinf_where_dict['MBRTYP'] = '1' errinf_where_dict['ERRKEY'] = ERRKEY[:8] else: errinf_where_dict['MBRTYP'] = '2' errinf_where_dict['ERRKEY'] = ERRKEY[4:8] ERRSTR = "" errinf_dict = rccpsDBTrcc_errinf.selectu(errinf_where_dict) if errinf_dict == None: AfaLoggerFunc.tradeInfo("查询中心返回信息数据库异常") if len(errinf_dict) <= 0: ERRSTR = "未知错误" AfaLoggerFunc.tradeInfo("无此返回代码对应信息,返回中心返回信息[未知错误]") else: ERRSTR = errinf_dict['ERRSTR'] AfaLoggerFunc.tradeInfo("找到此返回代码对应信息,返回中心返回信息[" + ERRSTR + "]") AfaLoggerFunc.tradeInfo(">>>结束获取中心返回代码[" + ERRKEY + "]对应信息") return ERRSTR
def insTransBil(bil_dict): AfaLoggerFunc.tradeInfo( ">>>开始登记汇票业务登记簿[" + bil_dict["BJEDTE"] + "][" + bil_dict["BSPSQN"] + "]交易信息及相关状态" ) if not bil_dict.has_key("BJEDTE"): return AfaFlowControl.ExitThisFlow( 'S999',"登记汇票业务登记簿,BJEDTE不能为空") if not bil_dict.has_key("BSPSQN"): return AfaFlowControl.ExitThisFlow( 'S999',"登记汇票业务登记簿,BSPSQN不能为空") #==========将输入字典赋值到汇票业务登记簿字典=============================== bilbka_dict = {} if not rccpsMap0000Dbil_dict2Dbilbka.map(bil_dict,bilbka_dict): return AfaFlowControl.ExitThisFlow( 'S999', '将输入字典赋值到汇票业务登记簿字典异常' ) #==========登记信息到汇票业务登记簿========================================= ret = rccpsDBTrcc_bilbka.insert(bilbka_dict) if ret <= 0: AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow( 'S999', '登记汇票业务登记簿汇票业务详细信息异常' ) #==========登记初始状态===================================================== if not rccpsState.newTransState(bil_dict["BJEDTE"],bil_dict["BSPSQN"],PL_BCSTAT_INIT,PL_BDWFLG_SUCC): return False AfaLoggerFunc.tradeInfo( ">>>结束登记汇票业务登记簿[" + bil_dict["BJEDTE"] + "][" + bil_dict["BSPSQN"] + "]交易信息及相关状态" ) return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo("农信银.通存通兑来账.补正来账[T" + TradeContext.TemplateCode + '_' + TradeContext.TransCode+"]进入") AfaLoggerFunc.tradeInfo("交易前处理(登记流水,中心前处理) 进入") #==============================组织应答报文=========================================== AfaLoggerFunc.tradeInfo("组织应答报文开始") Ormfn = TradeContext.MSGFLGNO Rcvmbrco = TradeContext.SNDMBRCO Sndmbrco = TradeContext.RCVMBRCO #=====报文头==== TradeContext.MSGTYPCO = 'SET010' #报文类代码 TradeContext.RCVSTLBIN = Rcvmbrco #接受方成员行号 TradeContext.SNDSTLBIN = Sndmbrco #发送方成员行号 TradeContext.SNDBRHCO = TradeContext.BESBNO #发起行网点号 TradeContext.SNDCLKNO = TradeContext.BETELR #发起行柜员号 TradeContext.SNDTRDAT = TradeContext.BJEDTE #发起行交易日期 TradeContext.SNDTRTIM = TradeContext.BJETIM #发起行交易时间 TradeContext.MSGFLGNO = Rcvmbrco+TradeContext.BJEDTE + TradeContext.SerialNo #报文标示号 TradeContext.ORMFN = Ormfn #参考报文标示号 TradeContext.NCCWKDAT = TradeContext.NCCworkDate #中心工作日期 TradeContext.OPRTYPNO = '30' #业务类型 TradeContext.ROPRTPNO = '30' #参考业务类型 TradeContext.TRANTYP = '0' #传输类型 TradeContext.CURPIN = "" #异地客户密码 TradeContext.PRCCO = "NN1IA999" TradeContext.STRINFO = "本交易无法补正" AfaLoggerFunc.tradeInfo("组织应答报文结束") AfaLoggerFunc.tradeInfo("交易前处理(登记流水,中心前处理) 退出") return True
def SubModuleMainFst( ): AfaLoggerFunc.tradeInfo('状态变更通知交易前处理[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' ) try: if( not TradeContext.existVariable( "nextWorkDate" ) ): return TipsFunc.ExitThisFlow( '93002', 'TIPS工作日期[nextWorkDate]值不存在!' ) if( len(TradeContext.nextWorkDate)!=8 ): return TipsFunc.ExitThisFlow( '93001', 'TIPS工作日期[nextWorkDate]值不合法!' ) if( not TradeContext.existVariable( "SysStat" ) ): return TipsFunc.ExitThisFlow( '93002', 'TIPS[SysStat]值不存在!' ) if TradeContext.SysStat=='0':#日间 #应用运行状态为:运行 if(not TipsFunc.UpdAppStatus('1')): return TipsFunc.ExitThisFlow( 'A0001', '修改应用运行状态失败!' ) #修改应用工作日期 if(not TipsFunc.UpdAppWorkDate(TradeContext.nextWorkDate)): return TipsFunc.ExitThisFlow( 'A0001', '修改应用工作日期失败!' ) if TradeContext.SysStat=='1':#日切窗口 #修改应用工作日期 if(not TipsFunc.UpdAppWorkDate(TradeContext.nextWorkDate)): return TipsFunc.ExitThisFlow( 'A0001', '修改应用工作日期失败!' ) if TradeContext.SysStat=='2':#系统维护状态 #应用运行状态为:暂停 if(not TipsFunc.UpdAppStatus('2')): return TipsFunc.ExitThisFlow( 'A0001', '修改应用运行状态失败!' ) TradeContext.errorCode = '0000' TradeContext.errorMsg = '交易成功' #=============自动打包==================== AfaLoggerFunc.tradeInfo('状态变更通知前处理结束[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' ) return True except Exception, e: return TipsFunc.exitMainFlow(str(e))
def selectu( where_dict ): if not chk(where_dict): return None wheresql = "" for where_item in where_dict.keys(): if table_dict[where_item] == 'S': wheresql = wheresql + where_item + " LIKE '" + where_dict[where_item] + "' and " else: wheresql = wheresql + where_item + " = " + str(where_dict[where_item]) + " and " sql = "SELECT NCCWKDAT,SCNBBH,SCFEDT,SCRBSQ,SCEYDT,SCTLSQ,SCRVSB,SCCATR,SCWLBZ,SCTRAM,SCFLAG,SCSTCD,SCBYZ1,SCBYZ2,SCBYZ3,NOTE1,NOTE2,NOTE3,NOTE4 FROM rcc_tdzjmx WHERE " + wheresql[0:-5] AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql ) if (records == None): return None elif (len(records) > 1): AfaLoggerFunc.tradeError("查询结果非唯一,请检查查询条件[" + wheresql[0:-5] + "]") return None elif (len(records) == 0): AfaLoggerFunc.tradeError("查询结果为空,查询条件[" + wheresql[0:-5] + "]") tmp_dict = {} return tmp_dict else: tmp_dict = {} for i in xrange(0,len(table_tuple)): if len(str(records[0][i])) == 0: tmp_dict[table_tuple[i]] = "" else: tmp_dict[table_tuple[i]] = records[0][i] #AfaLoggerFunc.tradeInfo("return return_dict:" + str(tmp_dict)) return tmp_dict
return ExitSubTrade('9999', '批量处理数据文件操作异常') ############################################################################### #20090927 蔡永贵 读取配置文件的信息,判断业务处理类型(0-即时处理,1-日终处理) #----------------------------------------------------------------------------- batchCfg = AbdtFunc.getBatchConfig( ) #拆分出各种业务类型 APPTRFG = TradeContext.BATCH_APPTRFG.split( '|' ) #判断是日终处理还是即时处理 if ( TradeContext.I1APPNO[0:6] in APPTRFG and int( TradeContext.I1TOTALNUM ) <= int( TradeContext.BATCH_MAXCOUNT ) ): TradeContext.I1TRFG = '0' #即时处理 AfaLoggerFunc.tradeInfo( '>>>做即时处理' ) else: TradeContext.I1TRFG = '1' #日终处理 AfaLoggerFunc.tradeInfo( '>>>做日终处理' ) ################################################################################ #生成委托号 if ( not CrtBatchNo( ) ): return False try: #把文件移到批量内部操作目录中(in)
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=AfaUtilTools.GetHostDate( ) #TradeContext.TRCDAT = PL_BJEDTE #=====================系统公共校验====================================== if not rccpsFunc.ChkPubInfo(PL_BRSFLG_RCV) : raise AfaFlowControl.flowException( ) #=====================系统状态校验====================================== if not rccpsFunc.ChkSysInfo( 'AFA' ) : raise AfaFlowControl.flowException( ) #=====================机构合法性校验==================================== if not rccpsFunc.ChkUnitInfo( PL_BRSFLG_RCV ) : raise AfaFlowControl.flowException( ) #=====================获取中心日期==================================== if not rccpsFunc.GetNCCDate( ) : raise AfaFlowControl.flowException( ) #=====================获取平台流水号==================================== if rccpsGetFunc.GetSerialno(PL_BRSFLG_RCV) == -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( ) #=====================与中心通讯(回执)================================== AfaAfeFunc.CommAfe() #=====================交易后处理======================================== if not trxModuleHandle.SubModuleDoSnd( ) : raise AfaFlowControl.flowException( ) #=====================自动打包========================================== AfaFunc.autoPackData() #=====================退出模板========================================== AfaLoggerFunc.tradeInfo('***农信银系统: 来账.中心类操作模板['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']退出***')
#=====================自动打包========================================== AfaFunc.autoPackData() #=====================退出模板========================================== AfaLoggerFunc.tradeInfo('***农信银系统: 来账.中心类操作模板['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']退出***') except AfaFlowControl.flowException, e: #流程异常 if not AfaDBFunc.RollbackSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) AfaLoggerFunc.tradeError(">>>Rollback异常") AfaLoggerFunc.tradeInfo(">>>Rollback成功") AfaFlowControl.exitMainFlow( str(e) ) except AfaFlowControl.accException: #账务异常 if not AfaDBFunc.RollbackSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) AfaLoggerFunc.tradeError(">>>Rollback异常") AfaLoggerFunc.tradeInfo(">>>Rollback成功") AfaFlowControl.exitMainFlow( ) except Exception, e: #默认异常 if not AfaDBFunc.RollbackSql( ):
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易(1.本地操作).通存通兑业务登记簿查询[TRCC001_8567]进入***' ) #=====必要性检查==== AfaLoggerFunc.tradeInfo(">>>开始必要性检查") if( not TradeContext.existVariable( "STRDAT" ) ): return AfaFlowControl.ExitThisFlow('A099', '起始日期[STRDAT]不存在') if( not TradeContext.existVariable( "ENDDAT" ) ): return AfaFlowControl.ExitThisFlow('A099', '终止日期[ENDDAT]不存在') if( not TradeContext.existVariable( "BRSFLG" ) ): return AfaFlowControl.ExitThisFlow('A099', '往来标志[BRSFLG]不存在') if( not TradeContext.existVariable( "PYITYP" ) ): return AfaFlowControl.ExitThisFlow('A099', '卡折标志[PYITYP]不存在') if( not TradeContext.existVariable( "RECSTRNO" ) ): return AfaFlowControl.ExitThisFlow('A099', '起始笔数[RECSTRNO]不存在') #=====组织sql语句==== AfaLoggerFunc.tradeInfo(">>>开始组织查询sql语句") wheresql = "" wheresql = wheresql + "BJEDTE>='" + TradeContext.STRDAT + "' AND BJEDTE<='" + TradeContext.ENDDAT + "' " ordersql = " order by BJEDTE DESC,BSPSQN DESC,NCCWKDAT DESC " start_no = TradeContext.RECSTRNO #起始笔数 sel_size = 10 #查询笔数 #====add by pgt 0106 增加新的机构号的判断==== if(TradeContext.BESBNO1 != ""): wheresql = wheresql + " and BESBNO='" + TradeContext.BESBNO1 + "' " else: if(TradeContext.BESBNO != PL_BESBNO_BCLRSB): wheresql = wheresql + " and BESBNO='" + TradeContext.BESBNO + "' " #=====判断往来标志是否为空==== if(TradeContext.BRSFLG != ""): wheresql = wheresql + " AND BRSFLG='" + TradeContext.BRSFLG + "' " # #=====判断交易种类是否为空==== # if(TradeContext.OPRTPNO != ""): # wheresql = wheresql + " AND OPRTPNO='" + TradeContext.OPRTPNO + "' " #=====判断报单序号是否为空==== if(TradeContext.BSPSQN != ""): wheresql = wheresql + " AND BSPSQN='" + TradeContext.BSPSQN + "' " #=====判断业务状态是否为空==== if(TradeContext.BCSTAT != ""): wheresql = wheresql + " AND OPRATTNO='" + TradeContext.BCSTAT + "' " #=====判断卡折标志是否为空==== if(TradeContext.PYITYP != ""): #wheresql = wheresql + " AND BBSSRC='" + TradeContext.PYITYP + "' " wheresql = wheresql + " AND ((PYETYP = '" + TradeContext.PYITYP + "' AND TRCCO in ('3000002','3000003','3000004','3000005')) OR (PYRTYP = '" + TradeContext.PYITYP + "' AND TRCCO in ('3000102','3000103','3000104','3000105')))" #=====判断发起行行号是否为空==== if(TradeContext.SNDBNKCO != ""): wheresql = wheresql + " AND SNDBNKCO='" + TradeContext.SNDBNKCO + "' " #=====判断接收行行号是否为空==== if(TradeContext.RCVBNKCO != ""): wheresql = wheresql + " AND RCVBNKCO='" + TradeContext.RCVBNKCO + "' " AfaLoggerFunc.tradeDebug(">>>结束组织查询sql语句") #=====查询总记录数==== allcount=rccpsDBTrcc_wtrbka.count(wheresql) if(allcount<0): return AfaFlowControl.ExitThisFlow('A099','查询总笔数失败' ) #=====查询数据库==== AfaLoggerFunc.tradeInfo("wheresql=" + wheresql) records = rccpsDBTrcc_wtrbka.selectm(start_no,sel_size,wheresql,ordersql) if(records == None): return AfaFlowControl.ExitThisFlow('A099','查询失败' ) if len(records) <= 0: return AfaFlowControl.ExitThisFlow('A099','未查找到数据' ) else: #=====生成文件==== try: filename = "rccps_" + TradeContext.BETELR+"_" + AfaUtilTools.GetHostDate() + "_" + TradeContext.TransCode fpath = os.environ["AFAP_HOME"] + "/tmp/" f = open(fpath + filename,"w") except IOError: return AfaFlowControl.ExitThisFlow('S099','打开文件失败') #=====写文件操作==== try: filecontext="" AfaLoggerFunc.tradeInfo ("生成文件内容 ") for i in range(0,len(records)): #=====得到业务状态BCSTAT==== stat_dict = {} if not rccpsState.getTransStateCur(records[i]['BJEDTE'],records[i]['BSPSQN'],stat_dict): return AfaFlowControl.ExitThisFlow( 'S999', '当前业务登记簿没有满足条件的记录' ) filecontext= records[i]['BJEDTE'] + "|" \ + records[i]['BSPSQN'] + "|" \ + records[i]['BRSFLG'] + "|" \ + stat_dict['BCSTAT'] + "|" \ + stat_dict['BDWFLG'] + "|" \ + records[i]['BESBNO'] + "|" \ + records[i]['BETELR'] + "|" \ + records[i]['BEAUUS'] + "|" \ + records[i]['DCFLG'] + "|" \ + records[i]['OPRNO'] + "|" \ + records[i]['NCCWKDAT'] + "|" \ + records[i]['TRCCO'] + "|" \ + records[i]['TRCDAT'] + "|" \ + records[i]['TRCNO'] + "|" \ + records[i]['COTRCNO'] + "|" \ + records[i]['SNDMBRCO'] + "|" \ + records[i]['RCVMBRCO'] + "|" \ + records[i]['SNDBNKCO'] + "|" \ + records[i]['SNDBNKNM'] + "|" \ + records[i]['RCVBNKCO'] + "|" \ + records[i]['RCVBNKNM'] + "|" \ + records[i]['CUR'] + "|" \ + str(records[i]['OCCAMT']) + "|" \ + records[i]['CHRGTYP'] + "|" \ + str(records[i]['CUSCHRG']) + "|" \ + records[i]['PYRACC'] + "|" \ + records[i]['PYRNAM'] + "|" \ + records[i]['PYEACC'] + "|" \ + records[i]['PYENAM'] + "|" \ + records[i]['STRINFO'] + "|" \ + records[i]['CERTTYPE'] + "|" \ + records[i]['CERTNO'] + "|" \ + records[i]['BNKBKNO'] + "|" \ + str(records[i]['BNKBKBAL']) + "|" f.write(filecontext+"\n") except Exception,e: f.close() return AfaFlowControl.ExitThisFlow('S099','写文件失败')
+ records[i]['CUR'] + "|" \ + str(records[i]['OCCAMT']) + "|" \ + records[i]['CHRGTYP'] + "|" \ + str(records[i]['CUSCHRG']) + "|" \ + records[i]['PYRACC'] + "|" \ + records[i]['PYRNAM'] + "|" \ + records[i]['PYEACC'] + "|" \ + records[i]['PYENAM'] + "|" \ + records[i]['STRINFO'] + "|" \ + records[i]['CERTTYPE'] + "|" \ + records[i]['CERTNO'] + "|" \ + records[i]['BNKBKNO'] + "|" \ + str(records[i]['BNKBKBAL']) + "|" f.write(filecontext+"\n") except Exception,e: f.close() return AfaFlowControl.ExitThisFlow('S099','写文件失败') #=====输出接口赋值==== TradeContext.RECSTRNO=start_no #起始笔数 TradeContext.RECCOUNT=str(len(records)) #本次查询笔数 TradeContext.RECALLCOUNT=str(allcount) #总笔数 TradeContext.errorCode="0000" TradeContext.errorMsg="查询成功" # TradeContext.PRTDAT= TradeContext.BJEDTE #打印日期 TradeContext.PBDAFILE=filename #文件名 AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易(1.本地操作).通存通兑业务登记簿查询[TRCC001_8567]退出***' ) return True
def main( ): AfaLoggerFunc.tradeInfo( '凭证上缴入库['+TradeContext.TemplateCode+']进入' ) #=============前台上送数据=================================== #TradeContext.sBesbNo 机构号 #TradeContext.sBesbSty 机构类型 #TradeContext.sCur 货币代码 #TradeContext.sTellerNo 柜员号 #TradeContext.sVouhType 凭证种类 #TradeContext.sStartNo 起始号码 #TradeContext.sEndNo 终止号码 #TradeContext.sRivTeller 对方柜员 #TradeContext.sVouhStatus 凭证状态 #TradeContext.sVouhNum 凭证数量 #TradeContext.sLstTrxDay 最后交易日期 #TradeContext.sLstTrxTime 最后交易时间 #TradeContext.sDepository 库箱标志 #TradeContext.sVouhName 凭证名称 try: #=====================获取机构类型=============================== #TradeContext.sBesbSty = VouhFunc.SelectBesbSty(TradeContext.sBesbNo) #=============获取机构类型========================== HostContext.I1OTSB = TradeContext.sBesbNo #机构号 HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 if(not VouhHostFunc.CommHost('2001')): tradeExit(TradeContext.errorCode, TradeContext.errorMsg) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): SBNO = HostContext.O1SBCH AfaLoggerFunc.tradeInfo( SBNO ) #================拆包======================== TradeContext.sVouhType = VouhFunc.DelSpace(TradeContext.sVouhType.split("|")) TradeContext.sVouhName = VouhFunc.DelSpace(TradeContext.sVouhName.split("|")) TradeContext.sStartNo = VouhFunc.DelSpace(TradeContext.sStartNo.split("|")) TradeContext.sEndNo = VouhFunc.DelSpace(TradeContext.sEndNo.split("|")) TradeContext.sVouhNum = VouhFunc.DelSpace(TradeContext.sVouhNum.split("|")) TradeContext.sNum = len(TradeContext.sVouhType) #==================暂存================================== TradeContext.rVouhType = VouhFunc.AddSplit(TradeContext.sVouhType) TradeContext.rVouhName = VouhFunc.AddSplit(TradeContext.sVouhName) TradeContext.rStartNo = VouhFunc.AddSplit(TradeContext.sStartNo) TradeContext.rEndNo = VouhFunc.AddSplit(TradeContext.sEndNo) TradeContext.rVouhNum = VouhFunc.AddSplit(TradeContext.sVouhNum) #=============生成流水号======================== TradeContext.sVouhSerial = VouhFunc.GetVouhSerial( ) #=============获取当前系统时间========================== TradeContext.sLstTrxDay = AfaUtilTools.GetSysDate( ) TradeContext.sLstTrxTime = AfaUtilTools.GetSysTime( ) #begin凭证优化更改201109 #=============获取柜员尾箱号=============================== HostContext.I1SBNO = TradeContext.sBesbNo #机构号 HostContext.I1USID = TradeContext.sTellerNo #柜员号 HostContext.I1WSNO = TradeContext.sWSNO #终端号 HostContext.I1EDDT = TradeContext.sLstTrxDay #终止日期 HostContext.I1TELR = TradeContext.sTellerNo #柜员代号 if(not VouhHostFunc.CommHost('0104')): VouhFunc.tradeExit( TradeContext.errorCode, TradeContext.errorMsg ) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): TradeContext.sTellerTailNobak = HostContext.O2CABO TradeContext.sTellerTailNo = TradeContext.sTellerTailNobak[0] AfaLoggerFunc.tradeInfo( '交易柜员尾箱号:' + TradeContext.sTellerTailNo ) #=============获取领用柜员尾箱号=============================== HostContext.I1SBNO = TradeContext.sBesbNo #机构号 机构号送交易机构号 #HostContext.I1USID = TradeContext.sInTellerNo #柜员号 HostContext.I1USID = '999996' #柜员号 柜员号送自动柜员 HostContext.I1WSNO = TradeContext.sWSNO #终端号 HostContext.I1EDDT = TradeContext.sLstTrxDay #终止日期 HostContext.I1TELR = TradeContext.sInTellerNo #柜员代号 if(not VouhHostFunc.CommHost('0104')): VouhFunc.tradeExit( TradeContext.errorCode, TradeContext.errorMsg ) raise AfaFlowControl.flowException( ) if(TradeContext.errorCode == '0000'): TradeContext.sInTellerTailNobak = HostContext.O2CABO TradeContext.sInTellerTailNo = TradeContext.sInTellerTailNobak[0] AfaLoggerFunc.tradeInfo( '领用柜员尾箱号:' + TradeContext.sInTellerTailNo ) #end #=============初始化返回报文变量======================== TradeContext.tradeResponse = [] TradeContext.sRivTeller = TradeContext.sInTellerTailNo #=============置凭证操作状态及库箱标志==================== TradeContext.sExDepos = '4' #原库箱标志 1.分行管理库 2.支行管理库 3.网点管理库 4.柜员凭证箱 if(SBNO=='31' or SBNO=='40' or SBNO=='32'): TradeContext.sDepository = '2' #库箱标志 elif(SBNO=='50'): TradeContext.sDepository = '3' #库箱标志 else: VouhFunc.tradeExit('A005061', '该机构柜员不能进行此操作!') raise AfaFlowControl.flowException( ) TradeContext.sVouhStatus = '2' #状态 2.已发未领3.已领未用 TradeContext.sExStatus = '3' #原状态 3.已领未用时,可以凭证上缴,上缴后为2.已发未领 TradeContext.sTransType = '凭证上缴' TradeContext.sInBesbNo = TradeContext.sBesbNo tellerNo = TradeContext.sTellerTailNo TradeContext.sTellerTailNo = TradeContext.sInTellerTailNo TradeContext.sInTellerTailNo = tellerNo if(SBNO <> '31' and SBNO <> '32' and SBNO <> '40' and SBNO <> '50' ): tradeExit( 'A0001', '该机构柜员不能进行此操作!' ) raise AfaFlowControl.flowException( ) #交易公共部分 VouhFunc.VouhTrans() #更新凭证变更登记表 VouhFunc.VouhModify() #数据库提交 AfaDBFunc.CommitSql( ) TradeContext.sInTellerTailNo = TradeContext.sTellerTailNo TradeContext.sTellerTailNo = tellerNo #主机记账 AfaLoggerFunc.tradeInfo( '------------主机记账' ) TradeContext.sOperSty = '3' VouhHostFunc.VouhCommHost() TradeContext.sTranStatus = '0' AfaLoggerFunc.tradeInfo( '=======================12'+TradeContext.errorCode ) #TradeContext.errorCode = '0000' if(TradeContext.errorCode <> '0000'): tmpErrorCode= TradeContext.errorCode tmpErrorMsg = TradeContext.errorMsg #冲正 #=============置凭证操作状态及库箱标志==================== tmpDepos = TradeContext.sDepository TradeContext.sDepository = TradeContext.sExDepos TradeContext.sExDepos = tmpDepos tmpStatus = TradeContext.sVouhStatus TradeContext.sVouhStatus = TradeContext.sExStatus TradeContext.sExStatus = tmpStatus TradeContext.sRivTeller = ' ' #对方柜员 TradeContext.sTransType = '冲正' tmpBesbNo = TradeContext.sInBesbNo TradeContext.sInBesbNo = TradeContext.sBesbNo TradeContext.sBesbNo = tmpBesbNo #交易公共部分 VouhFunc.VouhTrans() AfaDBFunc.CommitSql( ) TradeContext.sTranStatus = '1' if(not TradeContext.existVariable( "HostSerno" )): TradeContext.HostSerno = '' #更新流水表 VouhFunc.ModifyVouhModify() AfaLoggerFunc.tradeInfo( '============================自动冲正!' ) VouhFunc.tradeExit(tmpErrorCode, tmpErrorMsg) raise AfaFlowControl.flowException( ) #更新流水表 VouhFunc.ModifyVouhModify() TradeContext.tradeResponse.append( ['sVouhSerial',TradeContext.sVouhSerial] ) TradeContext.tradeResponse.append( ['sVouhType',TradeContext.rVouhType] ) TradeContext.tradeResponse.append( ['sVouhName',TradeContext.rVouhName] ) TradeContext.tradeResponse.append( ['sStartNo',TradeContext.rStartNo] ) TradeContext.tradeResponse.append( ['sEndNo',TradeContext.rEndNo] ) TradeContext.tradeResponse.append( ['sVouhNum',TradeContext.rVouhNum] ) TradeContext.tradeResponse.append( ['sLstTrxDay',TradeContext.sLstTrxDay] ) TradeContext.tradeResponse.append( ['sLstTrxTime',TradeContext.sLstTrxTime] ) TradeContext.tradeResponse.append( ['sNum',str(TradeContext.sNum)] ) TradeContext.tradeResponse.append( ['errorCode','0000'] ) TradeContext.tradeResponse.append( ['errorMsg','交易成功'] ) #自动打包 AfaFunc.autoPackData() #=============程序退出==================== AfaLoggerFunc.tradeInfo( '凭证上缴['+TradeContext.TemplateCode+']退出' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( )
def SubModuleDoSnd(): #=================判断afe是否发送成功======================================= if TradeContext.errorCode != '0000': AfaLoggerFunc.tradeInfo('>>>AFE发送失败') return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg) AfaLoggerFunc.tradeInfo('>>>发送成功') update_wdict = {'BJEDTE':TradeContext.BOJEDT,'BSPSQN':TradeContext.BOSPSQ} update_dict = {'ISDEAL':PL_ISDEAL_ISDO} #已查复 ret = rccpsDBTrcc_hdcbka.update(update_dict,update_wdict) if (ret <= 0): AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow("S999","更新原查询业务信息异常") AfaDBFunc.CommitSql() AfaLoggerFunc.tradeInfo(">>>Commit成功") #=====查询机构名==== subbra_dict={'BESBNO':TradeContext.BESBNO} sub=rccpsDBTrcc_subbra.selectu(subbra_dict) if(sub==None): return AfaFlowControl.ExitThisFlow('A099','查询机构名失败' ) if(len(sub)==0): return AfaFlowControl.ExitThisFlow('A099','没有相应的机构名' ) #=====生成打印文本==== AfaLoggerFunc.tradeInfo("开始生成打印文本") txt = """\ %(BESBNM)s通存通兑查复书 |-----------------------------------------------------------------------------| | 查复日期: | %(BJEDTE)s | |-----------------------------------------------------------------------------| | 查复书号: | %(BSPSQN)s | |-----------------------------------------------------------------------------| | 接收行行号: | %(RCVBNKCO)s | |-----------------------------------------------------------------------------| | 原查询日期: | %(BOJEDT)s | |-----------------------------------------------------------------------------| | 原查询书号: | %(BOSPSQ)s | |-----------------------------------------------------------------------------| | 原金额: | %(OROCCAMT)-15.2f | |-----------------------------------------------------------------------------| | 原币种: | 人民币 | |-----------------------------------------------------------------------------| | 查复内容: | | |-----------------------------------------------------------------------------| | | | %(CONT1)s | | | | %(CONT2)s | | | | %(CONT3)s | | | | %(CONT4)s | | | |-----------------------------------------------------------------------------| 打印日期: %(BJEDTE)s 授权: 记账: """ file_name = 'rccps_' + TradeContext.BJEDTE + '_' + TradeContext.BSPSQN + '_' + '_8512' out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb") if out_file == None: return AfaFlowControl.ExitThisFlow("S999", "生成打印文件异常") print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\ 'BJEDTE':(TradeContext.BJEDTE).ljust(8,' '),\ 'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\ 'RCVBNKCO':(TradeContext.RCVBNKCO).ljust(10,' '),\ 'BOJEDT':(TradeContext.BOJEDT).ljust(8,' '),\ 'BOSPSQ':(TradeContext.BOSPSQ).ljust(12,' '),\ 'OROCCAMT':(TradeContext.PRT_OROCCAMT),\ 'CONT1':(TradeContext.CONT[:68]).ljust(68,' '),\ 'CONT2':(TradeContext.CONT[68:138]).ljust(70,' '),\ 'CONT3':(TradeContext.CONT[138:208]).ljust(70,' '),\ 'CONT4':(TradeContext.CONT[208:]).ljust(70,' ')} out_file.close() TradeContext.PBDAFILE = file_name AfaLoggerFunc.tradeInfo("结束生成打印文本") return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).卡通存请求报文接收[TRCC006_1135]进入***' ) #判断是否重复交易 AfaLoggerFunc.tradeInfo(">>>开始判断是否重复报文") sel_dict = {'TRCNO':TradeContext.TRCNO,'TRCDAT':TradeContext.TRCDAT,'SNDBNKCO':TradeContext.SNDBNKCO} record = rccpsDBTrcc_wtrbka.selectu(sel_dict) if record == None: return AfaFlowControl.ExitThisFlow('S999','判断是否重复报文,查询通存通兑业务登记簿相同报文异常') elif len(record) > 0: AfaLoggerFunc.tradeInfo('通存通兑业务登记簿中存在相同数据,重复报文,返回拒绝应答报文') #=====为应答报文赋值==== TradeContext.sysType = 'rccpst' TradeContext.MSGTYPCO = 'SET006' TradeContext.RCVSTLBIN = TradeContext.SNDMBRCO TradeContext.SNDSTLBIN = TradeContext.RCVMBRCO TradeContext.SNDBRHCO = TradeContext.BESBNO TradeContext.SNDCLKNO = TradeContext.BETELR #TradeContext.SNDTRDAT = TradeContext.BJEDTE #TradeContext.BJEDTE = TradeContext.SNDTRDAT #TradeContext.SNDTRTIM = TradeContext.BJETIM TradeContext.ORMFN = TradeContext.MSGFLGNO #TradeContext.MSGFLGNO = TradeContext.SNDMBRCO + TradeContext.SNDTRDAT + TradeContext.SerialNo TradeContext.NCCWKDAT = TradeContext.NCCworkDate TradeContext.OPRTYPNO = '30' TradeContext.ROPRTPNO = TradeContext.OPRTYPNO TradeContext.TRANTYP = '0' TradeContext.CUR = 'CNY' TradeContext.PRCCO = 'NN1IM101' TradeContext.STRINFO = "重复报文" #=====发送afe==== AfaAfeFunc.CommAfe() return AfaFlowControl.ExitThisFlow('S999','重复报文,退出处理流程') AfaLoggerFunc.tradeInfo(">>>结束判断是否重复报文") #登记通存通兑登记簿 AfaLoggerFunc.tradeInfo(">>>开始登记通存通兑业务登记簿") #=====币种转换==== if TradeContext.CUR == 'CNY': TradeContext.CUR = '01' #=====手续费收取方式===== if float(TradeContext.CUSCHRG) > 0.001: TradeContext.CHRGTYP = '1' else: TradeContext.CHRGTYP = '0' #====开始向字典赋值==== wtrbka_dict = {} if not rccpsMap1135CTradeContext2Dwtrbka_dict.map(wtrbka_dict): return AfaFlowControl.ExitThisFlow('M999', '字典赋值出错') wtrbka_dict['DCFLG'] = PL_DCFLG_CRE #借贷标识 wtrbka_dict['OPRNO'] = PL_TDOPRNO_TC #业务种类 #=====开始插入数据库==== if not rccpsDBFunc.insTransWtr(wtrbka_dict): return False if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo(">>>结束登记通存通兑业务登记簿") #设置业务状态为行内收妥成功 AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为收妥成功") stat_dict = {} stat_dict['BSPSQN'] = TradeContext.BSPSQN stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BCSTAT'] = PL_BCSTAT_BNKRCV stat_dict['BDWFLG'] = PL_BDWFLG_SUCC if not rccpsState.setTransState(stat_dict): return AfaFlowControl.ExitThisFlow('S999','设置业务状态收妥成功异常') if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为收妥成功") #设置业务状态为确认入账处理中 AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为确认入账处理中") if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_CONFACC,PL_BDWFLG_WAIT): return AfaFlowControl.ExitThisFlow('S999','设置业务状态为确认入账处理中异常') if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为确认入账处理中") #初始化返回码 TradeContext.PRCCO = 'RCCI0000' TradeContext.STRINFO = "成功" TradeContext.BCSTAT = PL_BCSTAT_CONFACC #状态:确认付款 TradeContext.BCSTATNM = "确认付款" #进行必要性检查,若校验通过,则返回成功应答报文,若校验未通过,则返回拒绝应答报文 AfaLoggerFunc.tradeInfo(">>>开始必要性检查") #检查冲正登记簿中是否有此笔业务的冲正业务,存在则返回拒绝应答报文,并设置业务状态为冲正处理中 if TradeContext.PRCCO == 'RCCI0000': atcbka_where_dict = {} atcbka_where_dict['ORMFN'] = TradeContext.MSGFLGNO atcbka_dict = rccpsDBTrcc_atcbka.selectu(atcbka_where_dict) if atcbka_dict == None: #return AfaFlowControl.ExitThisFlow('S999', "查询冲正登记簿异常") AfaLoggerFunc.tradeInfo(">>>查询冲正登记簿异常") TradeContext.PRCCO = 'NN1ID003' TradeContext.STRINFO = "系统错误,查询冲正登记簿异常" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" else: if len(atcbka_dict) <= 0: AfaLoggerFunc.tradeInfo(">>>此交易未被冲正,继续校验") else: AfaLoggerFunc.tradeInfo(">>>此交易已被冲正,返回拒绝应答报文") TradeContext.PRCCO = 'NN1IO307' TradeContext.STRINFO = "此交易已被冲正" TradeContext.BCSTAT = PL_BCSTAT_CANC TradeContext.BCSTATNM = "冲正" #唐斌新增# sql = "SELECT ischkactname,ischklate FROM rcc_chlabt where transcode='"+TradeContext.TransCode+"' and channelno= '"+(TradeContext.SNDCLKNO)[6:8]+"'" AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql) if (records == None): return False elif (len(records) == 0): AfaLoggerFunc.tradeDebug("查询结果为空,查询条件[" + sql + "]") return False AfaLoggerFunc.tradeDebug(str(records)) #校验账户状态是否正常和账号户名是否相符 if TradeContext.PRCCO == 'RCCI0000': #调用主机接口查询账户信息 TradeContext.HostCode = '8810' TradeContext.ACCNO = TradeContext.PYEACC AfaLoggerFunc.tradeDebug("ACCNO :" + TradeContext.ACCNO) rccpsHostFunc.CommHost( TradeContext.HostCode ) if TradeContext.errorCode != '0000': #return AfaFlowControl.ExitThisFlow(TradeContext.errorCode,TradeContext.errorMsg) AfaLoggerFunc.tradeInfo("查询账户信息异常,主机返回码[" + TradeContext.errorCode + "],主机返回信息[" + TradeContext.errorMsg +"]") TradeContext.PRCCO = rccpsDBFunc.HostErr2RccErr(TradeContext.errorCode) TradeContext.STRINFO = "查询主机账户信息失败 " + TradeContext.errorMsg TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" else: #TradeContext.PYENAM = AfaUtilTools.trim(TradeContext.PYENAM) AfaLoggerFunc.tradeInfo(">>>查询主机账户成功") #if TradeContext.BESBNO != PL_BESBNO_BCLRSB: # AfaLoggerFunc.tradeInfo(">>>" + TradeContext.BESBNO + ">>>" + TradeContext.ACCSO) # if( TradeContext.BESBNO[:6] != TradeContext.ACCSO[:6] ): # AfaLoggerFunc.tradeInfo(">>>不许跨法人做此交易") # TradeContext.PRCCO = 'NN1IO999' # TradeContext.STRINFO = "接收行与账户开户行不属于同一法人" # TradeContext.BCSTAT = PL_BCSTAT_MFERFE # TradeContext.BCSTATNM = "拒绝" #检查本机构是否有通存通兑业务权限 if not rccpsDBFunc.chkTDBESAuth(TradeContext.ACCSO): TradeContext.PRCCO = 'NN1IO999' TradeContext.STRINFO = "本账户开户机构无通存通兑业务权限" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" if TradeContext.PRCCO == 'RCCI0000': #查询成功,更新通存通兑登记簿账务机构号 AfaLoggerFunc.tradeInfo(">>>开始更新机构号为开户机构") TradeContext.BESBNO = TradeContext.ACCSO wtrbka_update_dict = {'BESBNO':TradeContext.ACCSO} wtrbka_where_dict = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':TradeContext.BSPSQN} ret = rccpsDBTrcc_wtrbka.updateCmt(wtrbka_update_dict,wtrbka_where_dict) if ret <= 0: AfaLoggerFunc.tradeInfo(">>>更新机构号为开户机构异常") TradeContext.PRCCO = 'NN1ID006' TradeContext.STRINFO = "系统错误,更新账务机构号异常" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" else: AfaLoggerFunc.tradeInfo(">>>更新机构号为开户机构成功") AfaLoggerFunc.tradeDebug("主机返回户名ACCNM :[" + TradeContext.ACCNM + "]") AfaLoggerFunc.tradeDebug("报文接收户名PYENAM:[" + TradeContext.PYENAM + "]") AfaLoggerFunc.tradeDebug("主机返回账户状态ACCST:[" + TradeContext.ACCST + "]") if TradeContext.ACCNM != TradeContext.PYENAM: #唐斌新增# if(records[0][0]=='1'): AfaLoggerFunc.tradeInfo(">>>账号户名不符") TradeContext.PRCCO = 'NN1IA102' TradeContext.STRINFO = '账号户名不符' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" elif TradeContext.ACCST != '0' and TradeContext.ACCST != '2': AfaLoggerFunc.tradeInfo(">>>账户状态不正常") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = '账户状态不正常' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" elif not (TradeContext.ACCCD == '0428' and TradeContext.ACCEM == '21111'): AfaLoggerFunc.tradeInfo(">>>此账户非个人结算户") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = '此账户非个人结算户' TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" #校验磁道信息 关彬捷 20081215 #唐斌新增# if TradeContext.PRCCO == 'RCCI0000': if(records[0][1]=='1'): if (TradeContext.SCTRKINF == ''.rjust(37,'0') or TradeContext.SCTRKINF == ''): AfaLoggerFunc.tradeInfo("校验磁道信息异常,该业务必须产生磁道信息") TradeContext.PRCCO = 'NN1IA141' TradeContext.STRINFO = "校验磁道信息失败 :无磁道信息" TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" if TradeContext.SCTRKINF != ''.rjust(37,'0') and TradeContext.SCTRKINF != '': #磁道信息非空或37个零,则调用主机接口校验磁道信息 TradeContext.HostCode = '0652' TradeContext.WARNTNO = TradeContext.PYEACC[6:18] AfaLoggerFunc.tradeDebug("WARNTNO :" + TradeContext.WARNTNO) AfaLoggerFunc.tradeDebug("SCTRKINF :" + TradeContext.SCTRKINF) AfaLoggerFunc.tradeDebug("THTRKINF :" + TradeContext.THTRKINF) if TradeContext.THTRKINF == ''.rjust(37,'0'): TradeContext.THTRKINF = '' AfaLoggerFunc.tradeDebug("THTRKINF :" + TradeContext.THTRKINF) rccpsHostFunc.CommHost( TradeContext.HostCode ) if TradeContext.errorCode != '0000': #return AfaFlowControl.ExitThisFlow(TradeContext.errorCode,TradeContext.errorMsg) AfaLoggerFunc.tradeInfo("校验磁道信息异常,主机返回码[" + TradeContext.errorCode + "],主机返回信息[" + TradeContext.errorMsg +"]") TradeContext.PRCCO = 'NN1IA141' TradeContext.STRINFO = "校验磁道信息失败 " + TradeContext.errorMsg TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" #校验凭证状态是否正常 if TradeContext.PRCCO == 'RCCI0000': #调用主机接口查询凭证信息 TradeContext.HostCode = '8811' TradeContext.ACCNO = TradeContext.PYEACC TradeContext.WARNTNO = TradeContext.PYEACC[6:18] AfaLoggerFunc.tradeDebug("ACCNO :" + TradeContext.ACCNO) AfaLoggerFunc.tradeDebug("WARNTNO :" + TradeContext.WARNTNO) rccpsHostFunc.CommHost( TradeContext.HostCode ) if TradeContext.errorCode != '0000': #return AfaFlowControl.ExitThisFlow(TradeContext.errorCode,TradeContext.errorMsg) AfaLoggerFunc.tradeInfo("查询凭证信息异常,主机返回码[" + TradeContext.errorCode + "],主机返回信息[" + TradeContext.errorMsg +"]") TradeContext.PRCCO = 'NN1IA999' TradeContext.STRINFO = "查询主机凭证信息失败 " + TradeContext.errorMsg TradeContext.BCSTAT = PL_BCSTAT_MFERFE TradeContext.BCSTATNM = "拒绝" # else: # #查询成功 # AfaLoggerFunc.tradeInfo(">>>查询主机凭证信息成功") # AfaLoggerFunc.tradeInfo(">>>凭证信息ACCSTCD:[" + TradeContext.ACCSTCD + "]") # # if TradeContext.ACCSTCD != '0': # TradeContext.PRCCO = 'RCCI1000' # TradeContext.STRINFO = '账户凭证状态不正常' # TradeContext.BCSTAT = PL_BCSTAT_MFERFE # TradeContext.BCSTATNM = "拒绝" AfaLoggerFunc.tradeInfo(">>>结束必要性检查") #AfaLoggerFunc.tradeInfo("gbj_test:SNDTRDAT=[" + TradeContext.SNDTRDAT + "]") #为应答报文赋值 TradeContext.sysType = 'rccpst' TradeContext.MSGTYPCO = 'SET006' TradeContext.RCVSTLBIN = TradeContext.SNDMBRCO TradeContext.SNDSTLBIN = TradeContext.RCVMBRCO TradeContext.SNDBRHCO = TradeContext.BESBNO TradeContext.SNDCLKNO = TradeContext.BETELR #TradeContext.SNDTRDAT = TradeContext.BJEDTE #TradeContext.SNDTRTIM = TradeContext.BJETIM TradeContext.ORMFN = TradeContext.MSGFLGNO #TradeContext.MSGFLGNO = TradeContext.SNDMBRCO + TradeContext.SNDTRDAT + TradeContext.SerialNo TradeContext.NCCWKDAT = TradeContext.NCCworkDate TradeContext.ROPRTPNO = TradeContext.OPRTYPNO TradeContext.OPRTYPNO = '30' TradeContext.TRANTYP = '0' TradeContext.CUR = 'CNY' AfaLoggerFunc.tradeInfo( '***农信银系统:来账.中心类操作(1.本地操作).卡通存请求报文接收[TRCC006_1135]退出***' ) return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo("'***农信银系统:通存通兑往账交易.特殊差错账补记[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 SubModuleMainFst( ): TradeContext.__agentEigen__ = '0' #从表标志 AfaLoggerFunc.tradeInfo( "********************中台清分开始***************" ) fileName = os.environ['AFAP_HOME'] + "/data/ahfs/" + TradeContext.FileName cnt = 0 amount = 0.0 #-----------------------根据单位编码配置获取财政信息---------------------------- sqlstr = "select aaa010,bankno from fs_businoinfo where busino='" + TradeContext.busiNo + "'" records = AfaDBFunc.SelectSql( sqlstr ) if records == None or len(records)==0 : TradeContext.errorCode,TradeContext.errorMsg = "0001","查找单位信息表异常" AfaLoggerFunc.tradeInfo( TradeContext.errorMsg ) AfaLoggerFunc.tradeInfo( sqlstr ) sys.exit(1) elif len(records) > 1: TradeContext.errorCode,TradeContext.errorMsg = "0001","单位信息表异常:一个单位编号对应了多个财政信息" AfaLoggerFunc.tradeInfo( TradeContext.errorMsg ) AfaLoggerFunc.tradeInfo( sqlstr ) sys.exit(1) TradeContext.AAA010 = records[0][0].strip() TradeContext.AFA101 = records[0][1].strip() #TradeContext.AAA010 = "0000000000" #TradeContext.AFA101 = "011" try: cnt = 0 amount = 0.0 if ( os.path.exists(fileName) and os.path.isfile(fileName) ): fp = open(fileName,"r") sLine = fp.readline() while ( sLine ): LineItem = sLine.split("|") #查找到了流水号码,则更新状态位置 dateTmp = TradeContext.serDate[0:4] + '-' + TradeContext.serDate[4:6] + '-' + TradeContext.serDate[6:8] if LineItem[0].strip() == '0': TradeContext.errorCode = "0002" TradeContext.errorMsg = "待查数据自动生成,不需写入待查" #sqlstr = "update fs_fc74 set flag ='1',busino='" + TradeContext.busiNo + "',afc016='" + TradeContext.brno + "',teller='" + TradeContext.teller + "',date='" + TradeContext.workDate + "' where afc401='" + LineItem[1].strip() + "' and afc015='" + dateTmp + "' and BUSINO='" + TradeContext.busiNo + "'" else: sqlstr = "select date from fs_fc74 where afc401='" + LineItem[1].strip() + "' and afc015='" + dateTmp + "' and BUSINO='" + TradeContext.busiNo + "'" #===条件增加银行编码字段,张恒修改=== sqlstr = sqlstr + " and afa101 = '" + TradeContext.bankbm + "'" AfaLoggerFunc.tradeInfo( sqlstr ) records = AfaDBFunc.SelectSql( sqlstr ) if( records == None ): TradeContext.errorCode = "0001" TradeContext.errorMsg = "查找日期信息失败" AfaLoggerFunc.tradeInfo( TradeContext.errorMsg ) AfaLoggerFunc.tradeInfo( sqlstr + AfaDBFunc.sqlErrMsg ) return False date = records[0][0] AfaLoggerFunc.tradeInfo( date ) if TradeContext.workDate != date: TradeContext.errorCode = "0002" TradeContext.errorMsg = "待查数据已上传,不得删除待查" AfaLoggerFunc.tradeInfo( TradeContext.errorMsg ) return False TradeContext.errorCode = "0002" TradeContext.errorMsg = "待查数据自动生成,不得删除待查" #sqlstr = "update fs_fc74 set flag ='*',busino='" + TradeContext.busiNo + "',afc016='" + TradeContext.brno + "',teller='" + TradeContext.teller + "',date='" + '00000000' + "' where afc401='" + LineItem[1].strip() + "' and afc015='" + dateTmp + "' and BUSINO='" + TradeContext.busiNo + "'" AfaLoggerFunc.tradeInfo( sqlstr ) if( AfaDBFunc.UpdateSqlCmt( sqlstr ) < 1 ): AfaLoggerFunc.tradeInfo( '---test----->[' +sqlstr + ']<------------') TradeContext.errorCode, TradeContext.errorMsg='0002', '待查数据自动生成,更新流水号%s失败' %( LineItem[1].strip() ) #TradeContext.errorCode, TradeContext.errorMsg='0002', '待查数据自动生成,不可修改') AfaLoggerFunc.tradeInfo( TradeContext.errorMsg + AfaDBFunc.sqlErrMsg ) AfaLoggerFunc.tradeInfo( sqlstr ) return False cnt = cnt + 1 amount = amount + float(LineItem[4].strip()) sLine = fp.readline() else: AfaLoggerFunc.tradeInfo( "文件" + fileName + "不存在" ) TradeContext.errorCode = "0002" TradeContext.errorMsg = "待查文件不存在" return False AfaLoggerFunc.tradeInfo( "********************中台清分结束***************" ) TradeContext.errorCode = "0000" TradeContext.errorMsg = "插入或更新待查表成功" TradeContext.Total = str(amount) TradeContext.Count = str(cnt) AfaLoggerFunc.tradeInfo( TradeContext.Count ) return True except Exception, e: AfaLoggerFunc.tradeInfo( str(e) ) TradeContext.errorCode = "0003" TradeContext.errorMsg = "插入待查表异常" return False
def main( ): sernoFlag = 0 AfaLoggerFunc.tradeInfo( '******代收代付.查询明细模板['+TradeContext.TemplateCode+']进入******' ) try: #=====================初始化返回报文变量================================ TradeContext.tradeResponse=[] #=====================获取当前系统时间================================== TradeContext.workDate=AfaUtilTools.GetSysDate( ) TradeContext.workTime=AfaUtilTools.GetSysTime( ) #=====================判断应用系统状态================================== if not AfaFunc.ChkSysStatus( ) : raise AfaFlowControl.flowException( ) #=====================校验公共节点的有效性============================== if( not TradeContext.existVariable( "zoneno" ) ): TradeFunc.exitOnError( 'A0001', '地区号[zoneno]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "brno" ) ): TradeFunc.exitOnError( 'A0001', '网点号[brno]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "tellerno" ) ): TradeFunc.exitOnError( 'A0001', '网点号[tellerno]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "transStatus" ) ): TradeFunc.exitOnError( 'A0001', '交易状态[transStatus]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "queryMode" ) ): TradeFunc.exitOnError( 'A0001', '查询方式[queryMode]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "orderMode" ) ): TradeFunc.exitOnError( 'A0001', '排序方式[orderMode]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "queryCount" ) ): TradeFunc.exitOnError( 'A0001', '查询条数[queryCount]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "TransType" ) ): TradeFunc.exitOnError( 'A0001', '传输类型[TransType]值不存在,不能进行查询操作' ) AfaLoggerFunc.tradeInfo('>>>transStatus = ' + TradeContext.transStatus) AfaLoggerFunc.tradeInfo('>>>queryMode = ' + TradeContext.queryMode) AfaLoggerFunc.tradeInfo('>>>orderMode = ' + TradeContext.orderMode) AfaLoggerFunc.tradeInfo('>>>queryCount = ' + TradeContext.queryCount) AfaLoggerFunc.tradeInfo('>>>TransType = ' + TradeContext.TransType) AfaLoggerFunc.tradeInfo('>>>tradeDate = ' + TradeContext.tradeDate) #=====================定义每次返回的数据的记录数======================== queryCount = int( TradeContext.queryCount ) #=====================数据打包时使用list================================ names=['agentSerialno', 'sysId', 'unitno', 'subUnitno', 'workDate', 'workTime','agentFlag', 'transCode', 'zoneno', 'brno', 'tellerno', \ 'channelCode', 'accType', 'drAccno', 'crAccno', 'userno', 'subuserno', 'username', 'vouhType', 'vouhno', \ 'vouhDate', 'amount', 'subAmount', 'bankStatus', 'bankSerno', 'corpStatus', 'errormsg', 'note1', \ 'note2', 'note3', 'note4', 'note5', 'note6', 'note7', 'note8', 'note9', 'note10'] # =====================查询字段与数据打包的list一一对应================= SqlStr = "SELECT AGENTSERIALNO,SYSID,UNITNO,SUBUNITNO,WORKDATE,WORKTIME,AGENTFLAG,TRXCODE,ZONENO,BRNO,TELLERNO," SqlStr = SqlStr + "CHANNELCODE,ACCTYPE,DRACCNO,CRACCNO,USERNO,SUBUSERNO,USERNAME,VOUHTYPE,VOUHNO," SqlStr = SqlStr + "VOUHDATE,AMOUNT,SUBAMOUNT,BANKSTATUS,BANKSERNO,CORPSTATUS,ERRORMSG,NOTE1," SqlStr = SqlStr + "NOTE2,NOTE3,NOTE4,NOTE5,NOTE6,NOTE7,NOTE8,NOTE9,NOTE10 FROM AFA_MAINTRANSDTL " #=====================统计总笔数和总金额================================ sql_count = "SELECT COUNT(*),SUM(CAST(AMOUNT AS DECIMAL(17,2))) FROM AFA_MAINTRANSDTL" sql = '' if ( int( TradeContext.queryMode ) == 4 ): #自由查询方式 if( not TradeContext.existVariable( "whereClause" ) ): TradeFunc.exitOnError( 'A0001', '查询条件[whereClause]值不存在,不能进行查询操作' ) sql= sql + TradeContext.whereClause + " AND REVTRANF='0' " AfaLoggerFunc.tradeInfo('>>>whereClause = ' + TradeContext.whereClause) else: if( not TradeContext.existVariable( "tradeDate" ) ): TradeFunc.exitOnError( 'A0001', '交易日期[tradeDate]值不存在,不能进行查询操作' ) if( not TradeContext.existVariable( "channelCode" ) ): TradeFunc.exitOnError( 'A0001', '渠道代码[channelCode]值不存在,不能进行查询操作' ) #日期 sql = sql + " WHERE WORKDATE='" + TradeContext.tradeDate + "'" #地区号 sql = sql + " AND CHANNELCODE='" + TradeContext.channelCode + "'" #地区号 sql = sql + " AND ZONENO='" + TradeContext.zoneno + "'" #网点号 sql = sql + " AND BRNO='" + TradeContext.brno + "'" #柜员 sql = sql + " AND TELLERNO='" + TradeContext.tellerno + "'" #柜员 sql = sql + " AND REVTRANF='" + "0" + "'" #用户 if( TradeContext.existVariable( "userno" ) and len(TradeContext.userno)>0 ): sql = sql + " AND USERNO='" + TradeContext.userno + "'" #金额 if( TradeContext.existVariable( "amount" ) and int(float(TradeContext.amount)*100)!=0 ): sAmount="0.00"; for i in range(0, len(TradeContext.amount)): if TradeContext.amount[i] == '0': continue sAmount = TradeContext.amount[i:] break sql = sql + " AND AMOUNT='" + sAmount + "'" #用户名 if( TradeContext.existVariable( "username" ) and len(TradeContext.username)>0 ): sql = sql + " AND USERNAME='******'" #帐号 if( TradeContext.existVariable( "accno" ) and len(TradeContext.accno)>0 ): sql = sql + " AND (DRACCNO='" + TradeContext.accno + "' OR CRACCNO='" + TradeContext.accno + "')" #transStatus:交易状态(1-正常, 2-未知, 3-全部) if( int( TradeContext.transStatus ) == 1 ): #查询正常交易 sql = sql + " AND BANKSTATUS='0' AND CORPSTATUS='0'" elif( int( TradeContext.transStatus ) == 2 ): #查询未知交易 sql = sql + " AND (AGENTFLAG IN ('01','03') AND (BANKSTATUS='2' OR (BANKSTATUS='0' AND CORPSTATUS IN ('1', '2','3')))) OR" sql = sql + " (AGENTFLAG IN ('02','04') AND (CORPSTATUS='2' OR (CORPSTATUS='0' AND BANKSTATUS IN ('1', '2','3')))) " elif( int( TradeContext.transStatus ) != 3 ): TradeContext.errorCode, TradeContext.errorMsg='A0041', "入口参数条件不符[交易状态]:"+str( TradeContext.transStatus ) raise AfaFlowControl.flowException( ) #queryMode:查询方式(1-按流水号查询, 2-按系统代码查询, 3-查询全部正交易, 4-自由查询方式) if( int( TradeContext.queryMode ) == 1 ): #按流水号查询 if( not TradeContext.existVariable( "agentSerialno" ) ): TradeFunc.exitOnError( 'A0001', '流水号[agentSerialno]值不存在!' ) sql = sql + " AND AGENTSERIALNO='"+TradeContext.agentSerialno + "'" sernoFlag = 1 elif( int( TradeContext.queryMode ) == 2 ): #按系统代码查询 if( not TradeContext.existVariable( "sysId" ) ): TradeFunc.exitOnError( 'A0001', '系统代码[sysId]值不存在!' ) #系统代码 sql = sql + " AND SYSID='" + TradeContext.sysId + "'" #按流水号查询 if( TradeContext.existVariable( "agentSerialno" ) and len(TradeContext.agentSerialno)>0 ): sql = sql + " AND AGENTSERIALNO='"+TradeContext.agentSerialno + "'" sernoFlag = 1 #业务方式 if( TradeContext.existVariable( "agentFlag" ) and len(TradeContext.agentFlag)>0 ): sql=sql + " AND AGENTFLAG='" + TradeContext.agentFlag + "'" #单位代码 if( TradeContext.existVariable( "unitno" ) and len(TradeContext.unitno)>0 ): sql=sql + " AND UNITNO='" + TradeContext.unitno + "'" #子单位代码 if( TradeContext.existVariable( "subUnitno" ) and len(TradeContext.subUnitno)>0 ): sql=sql + " AND SUBUNITNO='" + TradeContext.subUnitno + "'" elif( int( TradeContext.queryMode ) != 3 and int( TradeContext.queryMode ) != 4 ): TradeContext.errorCode, TradeContext.errorMsg='A0041', "入口参数条件不符[查询方式]:"+str( TradeContext.queryMode ) raise AfaFlowControl.flowException( ) sql_count = sql_count + sql #按流水查询应该是单结果集的,没有排序的必要 if( int( TradeContext.queryMode ) != 1 and sernoFlag==0): #orderMode:排序方式:1-正序 2-逆序 if( int( TradeContext.orderMode ) == 1 ): #正序 if( (not TradeContext.existVariable( "agentSerialno" )) or TradeContext.agentSerialno=='' ): TradeContext.agentSerialno='0' sql = sql + " AND AGENTSERIALNO>'" + TradeContext.agentSerialno + "' ORDER BY AGENTSERIALNO ASC" else: #逆序 if( (not TradeContext.existVariable( "agentSerialno" )) or TradeContext.agentSerialno=='' ): TradeContext.agentSerialno='99999999' sql = sql + " AND AGENTSERIALNO<'"+TradeContext.agentSerialno + "' ORDER BY AGENTSERIALNO DESC" #查询数据库 SqlStr = SqlStr + sql AfaLoggerFunc.tradeInfo( '>>>查询明细' ) AfaLoggerFunc.tradeInfo( SqlStr ) records=AfaDBFunc.SelectSql( SqlStr, queryCount ) if( records == None ): #None 查询失败 TradeContext.errorCode, TradeContext.errorMsg='A0025', "数据库操作错误" raise AfaFlowControl.flowException( ) elif( len( records ) == 0 ): #无记录 TradeContext.errorCode, TradeContext.errorMsg='A0025', "没有满足条件的记录" raise AfaFlowControl.flowException( ) AfaLoggerFunc.tradeInfo( '>>>统计总数' ) #统计总数 AfaLoggerFunc.tradeInfo( sql_count ) records_count=AfaDBFunc.SelectSql( sql_count ) if( records_count == None ): TradeContext.errorCode, TradeContext.errorMsg='A0025', "数据库操作错误" raise AfaFlowControl.flowException( ) # 过滤records中的所有None数据 records=AfaUtilTools.ListFilterNone( records ) #总共的返回记录数 total=len( records ) AfaLoggerFunc.tradeInfo( '返回记录数:[' + str(total) + ']' ) #公共部分拼包 TradeContext.tradeResponse=[] TradeContext.tradeResponse.append( ['errorCode', '0000'] ) TradeContext.tradeResponse.append( ['errorMsg', '交易成功'] ) TradeContext.tradeResponse.append( ['retCount', str( total )] ) TradeContext.tradeResponse.append( ['retTotalCount', str( records_count[0][0] )]) TradeContext.tradeResponse.append( ['retTotalAmount',str( records_count[0][1] )]) if ( TradeContext.TransType == '0' ): #按照变量名打包 for i in range( 0, total ): k=0 for name in names: if( int( TradeContext.orderMode ) == 1 ): TradeContext.tradeResponse.append( [name, records[i][k]] ) else: TradeContext.tradeResponse.append( [name, records[total-i-1][k]] ) k=k+1 else: MxFileName = os.environ['AFAP_HOME'] + '/tmp/MX' + TradeContext.zoneno + TradeContext.brno + TradeContext.tellerno + '.TXT' AfaLoggerFunc.tradeInfo('明细文件:['+MxFileName+']') if (os.path.exists(MxFileName) and os.path.isfile(MxFileName)): #文件存在,先删除-再创建 os.system("rm " + MxFileName) #创建明细文件 sfp = open(MxFileName, "w") #将每条记录打包成以竖线分隔的格式 TradeContext.tradeResponse.append(['filename', 'MX' + TradeContext.zoneno + TradeContext.brno + TradeContext.tellerno + '.TXT']) for i in range( 0, total ): tmpBuffer = "" tmpBuffer = tmpBuffer + str(records[i][0]).strip() + "|" #AGENTSERIALNO tmpBuffer = tmpBuffer + str(records[i][1]).strip() + "|" #SYSID tmpBuffer = tmpBuffer + str(records[i][2]).strip() + "|" #UNITNO tmpBuffer = tmpBuffer + str(records[i][3]).strip() + "|" #SUBUNITNO tmpBuffer = tmpBuffer + str(records[i][4]).strip() + "|" #WORKDATE tmpBuffer = tmpBuffer + str(records[i][5]).strip() + "|" #WORKTIME tmpBuffer = tmpBuffer + str(records[i][6]).strip() + "|" #AGENTFLAG tmpBuffer = tmpBuffer + str(records[i][7]).strip() + "|" #TRXCODE tmpBuffer = tmpBuffer + str(records[i][8]).strip() + "|" #ZONENO tmpBuffer = tmpBuffer + str(records[i][9]).strip() + "|" #BRNO tmpBuffer = tmpBuffer + str(records[i][10]).strip() + "|" #TELLERNO tmpBuffer = tmpBuffer + str(records[i][11]).strip() + "|" #CHANNELCODE tmpBuffer = tmpBuffer + str(records[i][12]).strip() + "|" #ACCTYPE tmpBuffer = tmpBuffer + str(records[i][13]).strip() + "|" #DRACCNO tmpBuffer = tmpBuffer + str(records[i][14]).strip() + "|" #CRACCNO tmpBuffer = tmpBuffer + str(records[i][15]).strip() + "|" #USERNO tmpBuffer = tmpBuffer + str(records[i][16]).strip() + "|" #SUBUSERNO tmpBuffer = tmpBuffer + str(records[i][17]).strip() + "|" #USERNAME tmpBuffer = tmpBuffer + str(records[i][18]).strip() + "|" #VOUHTYPE tmpBuffer = tmpBuffer + str(records[i][19]).strip() + "|" #VOUHNO tmpBuffer = tmpBuffer + str(records[i][20]).strip() + "|" #VOUHDATE tmpBuffer = tmpBuffer + str(records[i][21]).strip() + "|" #AMOUNT tmpBuffer = tmpBuffer + str(records[i][22]).strip() + "|" #SUBAMOUNT tmpBuffer = tmpBuffer + str(records[i][23]).strip() + "|" #BANKSTATUS tmpBuffer = tmpBuffer + str(records[i][24]).strip() + "|" #BANKSERNO tmpBuffer = tmpBuffer + str(records[i][25]).strip() + "|" #CORPSTATUS tmpBuffer = tmpBuffer + str(records[i][26]).strip() + "|" #ERRORMSG tmpBuffer = tmpBuffer + str(records[i][27]).strip() + "|" #NOTE1 tmpBuffer = tmpBuffer + str(records[i][28]).strip() + "|" #NOTE2 tmpBuffer = tmpBuffer + str(records[i][29]).strip() + "|" #NOTE3 tmpBuffer = tmpBuffer + str(records[i][30]).strip() + "|" #NOTE4 tmpBuffer = tmpBuffer + str(records[i][31]).strip() + "|" #NOTE5 tmpBuffer = tmpBuffer + str(records[i][32]).strip() + "|" #NOTE6 tmpBuffer = tmpBuffer + str(records[i][33]).strip() + "|" #NOTE7 tmpBuffer = tmpBuffer + str(records[i][34]).strip() + "|" #NOTE8 tmpBuffer = tmpBuffer + str(records[i][35]).strip() + "|" #NOTE9 tmpBuffer = tmpBuffer + str(records[i][36]).strip() + "|" #NOTE10 sfp.write(tmpBuffer + '\n') sfp.close() #=====================自动打包========================================== AfaFunc.autoPackData() #=====================退出模板========================================== AfaLoggerFunc.tradeInfo( '******代收代付.查询明细模板['+TradeContext.TemplateCode+']退出******' ) except AfaFlowControl.flowException, e: AfaFlowControl.exitMainFlow( str(e) )
def SubModuleDoFst(): #==========判断是否重复报文,如果是重复报文,直接进入下一流程================ AfaLoggerFunc.tradeInfo(">>>开始检查是否重复报文") hdcbka_where_dict = {} hdcbka_where_dict['SNDBNKCO'] = TradeContext.SNDBNKCO hdcbka_where_dict['TRCDAT'] = TradeContext.TRCDAT hdcbka_where_dict['TRCNO'] = TradeContext.TRCNO hdcbka_dict = rccpsDBTrcc_hdcbka.selectu(hdcbka_where_dict) if hdcbka_dict == None: return AfaFlowControl.ExitThisFlow("S999","校验重复报文异常") return True if len(hdcbka_dict) > 0: AfaLoggerFunc.tradeInfo("汇兑查询查复自由格式登记簿中存在相同查复交易,此报文为重复报文,进入下一流程,发送表示成功的通讯回执") #======为通讯回执报文赋值=============================================== out_context_dict = {} out_context_dict['sysType'] = 'rccpst' out_context_dict['TRCCO'] = '9900503' out_context_dict['MSGTYPCO'] = 'SET008' out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO out_context_dict['SNDBRHCO'] = TradeContext.BESBNO out_context_dict['SNDCLKNO'] = TradeContext.BETELR out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE out_context_dict['SNDTRTIM'] = TradeContext.BJETIM out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo out_context_dict['ORMFN'] = TradeContext.MSGFLGNO out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate out_context_dict['OPRTYPNO'] = '99' out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO out_context_dict['TRANTYP'] = '0' out_context_dict['ORTRCCO'] = TradeContext.TRCCO out_context_dict['PRCCO'] = 'RCCI0000' out_context_dict['STRINFO'] = '重复报文' rccpsMap0000Dout_context2CTradeContext.map(out_context_dict) return True AfaLoggerFunc.tradeInfo(">>>结束检查是否重复报文") #==========判断是否存在原查询交易=========================================== AfaLoggerFunc.tradeInfo(">>>开始检查是否存在原查询交易") or_hdcbka_where_dict = {} or_hdcbka_where_dict['SNDBNKCO'] = TradeContext.OQTSBNK or_hdcbka_where_dict['TRCDAT'] = TradeContext.ORQYDAT or_hdcbka_where_dict['TRCNO'] = TradeContext.OQTNO AfaLoggerFunc.tradeInfo(">>>" + str(or_hdcbka_where_dict)) or_hdcbka_dict = {} or_hdcbka_dict = rccpsDBTrcc_hdcbka.selectu(or_hdcbka_where_dict) if or_hdcbka_dict == None: return AfaFlowControl.ExitThisFlow("S999","校验原查询交易失败") if len(or_hdcbka_dict) <= 0: AfaLoggerFunc.tradeInfo("汇兑查询查复自由格式登记簿中不存在原查询交易,进入下一流程,发送表示成功的通讯回执") #======为通讯回执报文赋值=============================================== out_context_dict = {} out_context_dict['sysType'] = 'rccpst' out_context_dict['TRCCO'] = '9900503' out_context_dict['MSGTYPCO'] = 'SET008' out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO out_context_dict['SNDBRHCO'] = TradeContext.BESBNO out_context_dict['SNDCLKNO'] = TradeContext.BETELR out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE out_context_dict['SNDTRTIM'] = TradeContext.BJETIM out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo out_context_dict['ORMFN'] = TradeContext.MSGFLGNO out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate out_context_dict['OPRTYPNO'] = '99' out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO out_context_dict['TRANTYP'] = '0' out_context_dict['ORTRCCO'] = TradeContext.TRCCO out_context_dict['PRCCO'] = 'RCCI0000' out_context_dict['STRINFO'] = '汇兑查询查复自由格式登记簿中不存在原查询交易' rccpsMap0000Dout_context2CTradeContext.map(out_context_dict) return True AfaLoggerFunc.tradeInfo(">>>结束检查是否存在原查询交易") #==========为汇兑查询查复自由格式登记簿字典赋值================================ AfaLoggerFunc.tradeInfo(">>>开始为汇兑查询查复自由格式登记簿字典赋值") TradeContext.BRSFLG = '1' if or_hdcbka_dict.has_key('BJEDTE'): TradeContext.BOJEDT = or_hdcbka_dict['BJEDTE'] if or_hdcbka_dict.has_key('BSPSQN'): TradeContext.BOSPSQ = or_hdcbka_dict['BSPSQN'] if TradeContext.existVariable('TRCCO'): TradeContext.ORTRCCO = TradeContext.TRCCO TradeContext.ISDEAL = PL_ISDEAL_ISDO #=====张恒 20091010 新增 将机构落到原交易机构 ==== if or_hdcbka_dict.has_key('BSPSQN'): TradeContext.BESBNO = or_hdcbka_dict['BESBNO'] #接收机构号 hdcbka_insert_dict = {} if not rccpsMap1119CTradeContext2Dhdcbka_dict.map(hdcbka_insert_dict): return AfaFlowControl.ExitThisFlow("S999","为汇兑查询查复自由格式登记簿字典赋值异常") #=====刘雨龙 20080710 ==== #=====币种转换==== if TradeContext.ORCUR == 'CNY': hdcbka_insert_dict['CUR'] = '01' else: hdcbka_insert_dict['CUR'] = TradeContext.ORCUR hdcbka_insert_dict['OCCAMT'] = TradeContext.OROCCAMT AfaLoggerFunc.tradeInfo(">>>结束为汇兑查询查复自由格式登记簿字典赋值") #==========登记会对查询查复自由格式登记簿======================================= AfaLoggerFunc.tradeInfo(">>>开始登记此查复业务") ret = rccpsDBTrcc_hdcbka.insert(hdcbka_insert_dict) if ret <= 0: if not AfaDBFunc.RollbackSql(): AfaFlowControl.ExitThisFlow("S999","Rollback异常") AfaLoggerFunc.tradeInfo(">>>Rollback成功") return AfaFlowControl.ExitThisFlow("S999","登记汇兑查询查复自由格式登记簿异常") AfaLoggerFunc.tradeInfo(">>>结束登记此查复业务") #======更新原查询交易信息=================================================== AfaLoggerFunc.tradeInfo(">>>开始更新原查询业务信息") or_hdcbka_update_dict = {} or_hdcbka_update_dict['ISDEAL'] = PL_ISDEAL_ISDO ret = rccpsDBTrcc_hdcbka.update(or_hdcbka_update_dict,or_hdcbka_where_dict) if (ret <= 0): if not AfaDBFunc.RollbackSql(): AfaFlowControl.ExitThisFlow("S999","Rollback异常") AfaLoggerFunc.tradeInfo(">>>Rollback成功") return AfaFlowControl.ExitThisFlow("S999","更新原查询业务信息异常") if not AfaDBFunc.CommitSql(): AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo(">>>Commit成功") AfaLoggerFunc.tradeInfo(">>>结束更新原查询业务信息") #======为通讯回执报文赋值=================================================== out_context_dict = {} out_context_dict['sysType'] = 'rccpst' out_context_dict['TRCCO'] = '9900503' out_context_dict['MSGTYPCO'] = 'SET008' out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO out_context_dict['SNDBRHCO'] = TradeContext.BESBNO out_context_dict['SNDCLKNO'] = TradeContext.BETELR out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE out_context_dict['SNDTRTIM'] = TradeContext.BJETIM out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo out_context_dict['ORMFN'] = TradeContext.MSGFLGNO out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate out_context_dict['OPRTYPNO'] = '99' out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO out_context_dict['TRANTYP'] = '0' out_context_dict['ORTRCCO'] = TradeContext.TRCCO out_context_dict['PRCCO'] = 'RCCI0000' out_context_dict['STRINFO'] = '成功' rccpsMap0000Dout_context2CTradeContext.map(out_context_dict) return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易[TRC001_8531]进入***' ) #=====判断输入接口值是否存在==== if( not TradeContext.existVariable( "STRDAT" ) ): return AfaFlowControl.ExitThisFlow('A099','起始日期[STRDAT]不存在' ) if( not TradeContext.existVariable( "ENDDAT" ) ): return AfaFlowControl.ExitThisFlow('A099','终止日期[ENDDAT]不存在' ) if( not TradeContext.existVariable( "RECSTRNO" ) ): return AfaFlowControl.ExitThisFlow('A099','起始笔数[RECSTRNO]不存在' ) #=====生成查询语句==== wheresql="" wheresql = wheresql + "BESBNO='" + TradeContext.BESBNO + "' " wheresql=wheresql + " AND BJEDTE>='" + TradeContext.STRDAT + "'" wheresql=wheresql + " AND BJEDTE<='" + TradeContext.ENDDAT + "'" #=====判断交易代码是否为空==== if(TradeContext.TRCCO != ""): wheresql = wheresql + " AND TRCCO='" + TradeContext.TRCCO + "'" #=====判断往来标识是否为空==== if(TradeContext.BRSFLG != ""): wheresql = wheresql + " AND BRSFLG='" + TradeContext.BRSFLG + "'" #=====判断查复标识是否为空或者9-全部==== if(TradeContext.ISDEAL != "9" and TradeContext.ISDEAL!=""): wheresql = wheresql + " AND ISDEAL='" + TradeContext.ISDEAL + "'" AfaLoggerFunc.tradeDebug(">>>生成查询语句sql="+wheresql) #=====查询机构名==== subbra_dict={'BESBNO':TradeContext.BESBNO} sub=rccpsDBTrcc_subbra.selectu(subbra_dict) if(sub==None): return AfaFlowControl.ExitThisFlow('A099','查询机构名失败' ) if(len(sub)==0): return AfaFlowControl.ExitThisFlow('A099','没有相应的机构名' ) #=====判断打印类型==== #=====0 不打印==== if TradeContext.PRTTYPE=='0': AfaLoggerFunc.tradeInfo(">>>进入不打印处理") #=====判断报单序号是否为空==== if(TradeContext.BSPSQN!=""): wheresql = wheresql + " AND BSPSQN='" + TradeContext.BSPSQN + "'" #=====得到总记录数==== allcount=rccpsDBTrcc_hdcbka.count(wheresql) if(allcount==-1): return AfaFlowControl.ExitThisFlow('A099','超找总记录数失败' ) #=====查询数据库==== ordersql=" order by BJEDTE DESC,BSPSQN DESC" records=rccpsDBTrcc_hdcbka.selectm(TradeContext.RECSTRNO,10,wheresql,ordersql) if(records==None): return AfaFlowControl.ExitThisFlow('A099','查询失败' ) elif( len(records)<=0 ): return AfaFlowControl.ExitThisFlow('A099','未查找到数据' ) else: #=====生成文件==== filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetHostDate()+"_"+TradeContext.TransCode fpath=os.environ["AFAP_HOME"]+"/tmp/" f=open(fpath+filename,"w") if(f==None): return AfaFlowControl.ExitThisFlow('A099','打开文件失败' ) filecontext="" #=====写文件操作==== for i in range(0,len(records)): filecontext=records[i]['BJEDTE'] + "|" \ +records[i]['BSPSQN'] + "|" \ +records[i]['BRSFLG'] + "|" \ +records[i]['BESBNO'] + "|" \ +records[i]['BETELR'] + "|" \ +records[i]['BEAUUS'] + "|" \ +records[i]['NCCWKDAT']+ "|" \ +records[i]['TRCCO'] + "|" \ +records[i]['TRCDAT'] + "|" \ +records[i]['TRCNO'] + "|" \ +records[i]['SNDBNKCO']+ "|" \ +records[i]['SNDBNKNM']+ "|" \ +records[i]['RCVBNKCO']+ "|" \ +records[i]['RCVBNKNM']+ "|" \ +records[i]['BOJEDT'] + "|" \ +records[i]['BOSPSQ'] + "|" \ +records[i]['ORTRCCO'] + "|" \ +records[i]['CONT'] + "|" \ +records[i]['ISDEAL'] + "|" \ +records[i]['CUR'] + "|" \ +str(records[i]['OCCAMT'])+ "|" \ +records[i]['PYRACC'] + "|" \ +records[i]['PYEACC'] + "|" \ +records[i]['PRCCO'] + "|" \ +records[i]['STRINFO'] + "|" \ +records[i]['PYRNAM'] + "|" \ +records[i]['PYENAM'] + "|" f.write(filecontext+"\n") AfaLoggerFunc.tradeInfo("生成文件结束") f.close() #=====输出接口赋值==== TradeContext.RECCOUNT=str(len(records)) #查询笔数 TradeContext.RECALLCOUNT=str(allcount) #总笔数 TradeContext.PBDAFILE=filename #文件名 TradeContext.errorCode="0000" TradeContext.errorMsg="查询成功" #=====1 打印==== elif TradeContext.PRTTYPE=='1': #=====判断报单序号是否为空==== if(TradeContext.BSPSQN!=""): wheresql = wheresql + " AND BSPSQN='" + TradeContext.BSPSQN + "'" else: return AfaFlowControl.ExitThisFlow('S999','报单序号[BSPSQN]不允许为空' ) #=====查询数据库==== records=rccpsDBTrcc_hdcbka.selectm(TradeContext.RECSTRNO,10,wheresql,"") if(records==None): return AfaFlowControl.ExitThisFlow('A099','查询失败' ) elif( len(records)<=0 ): return AfaFlowControl.ExitThisFlow('A099','未查找到数据' ) else: #=====查询书==== if(TradeContext.TRCCO=='9900511'): AfaLoggerFunc.tradeInfo(">>>业务类型为查询书") #=====查询原交易信息==== where_dict={'BJEDTE':records[0]['BOJEDT'],'BSPSQN':records[0]['BOSPSQ']} ret=rccpsDBTrcc_trcbka.selectu(where_dict) if(ret==None): return AfaFlowControl.ExitThisFlow('A099','查询原信息失败' ) if(len(ret)==0): return AfaFlowControl.ExitThisFlow('A099','未查找原信息' ) AfaLoggerFunc.tradeDebug(">>>开始生成查询书打印文本") #=====查询书打印格式==== txt="""\ %(BESBNM)s电子汇兑查询书 |-----------------------------------------------------------------------------| | 查询日期: | %(BJEDTE)s | |-----------------------------------------------------------------------------| | 查询书号: | %(BSPSQN)s | |-----------------------------------------------------------------------------| | 发起行行号: | %(SNDBNKCO)s | |-----------------------------------------------------------------------------| | 接收行行号: | %(RCVBNKCO)s | |-----------------------------------------------------------------------------| | 原交易金额: | %(OROCCAMT)-15.2f | |-----------------------------------------------------------------------------| | 原发起行行号: | %(ORSNDBNKCO)s | |-----------------------------------------------------------------------------| | 原接收行行号: | %(ORRCVBNKCO)s | |-----------------------------------------------------------------------------| | 查询内容: | | |-----------------------------------------------------------------------------| | | | %(CONT1)s | | | | %(CONT2)s | | | | %(CONT3)s | | | | %(CONT4)s | | | |-----------------------------------------------------------------------------| 打印日期: %(BJEDTE)s 授权: 记账: """ #=====写文件操作==== file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8531' out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb") if out_file == None: return AfaFlowControl.ExitThisFlow("S999", "生成文件异常") print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\ 'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\ 'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\ 'SNDBNKCO':(records[0]['SNDBNKCO']).ljust(10,' '),\ 'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\ 'OROCCAMT':(records[0]['OCCAMT']),\ 'ORSNDBNKCO':(ret['SNDBNKCO']).ljust(10,' '),\ 'ORRCVBNKCO':(ret['RCVBNKCO']).ljust(10,' '),\ 'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\ 'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\ 'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\ 'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')} out_file.close() TradeContext.PBDAFILE = file_name #文件名 AfaLoggerFunc.tradeDebug(">>>结束生成打印文本") #=====查复书==== elif(TradeContext.TRCCO=='9900512'): AfaLoggerFunc.tradeInfo(">>>业务类型为查复书") #=====查询原交易信息==== where_dict={'BJEDTE':records[0]['BOJEDT'],'BSPSQN':records[0]['BOSPSQ']} ret=rccpsDBTrcc_hdcbka.selectu(where_dict) if(ret==None): return AfaFlowControl.ExitThisFlow('A099','查询原信息失败' ) if(len(ret)==0): return AfaFlowControl.ExitThisFlow('A099','未查找原信息' ) #=====查复书打印格式==== txt="""\ %(BESBNM)s电子汇兑查复书 |-----------------------------------------------------------------------------| | 查复日期: | %(BJEDTE)s | |-----------------------------------------------------------------------------| | 查复书号: | %(BSPSQN)s | |-----------------------------------------------------------------------------| | 接收行行号: | %(RCVBNKCO)s | |-----------------------------------------------------------------------------| | 原查询日期: | %(BOJEDT)s | |-----------------------------------------------------------------------------| | 原查询书号: | %(BOSPSQ)s | |-----------------------------------------------------------------------------| | 原金额: | %(OROCCAMT)-15.2f | |-----------------------------------------------------------------------------| | 原币种: | 人民币 | |-----------------------------------------------------------------------------| | 查复内容: | | |-----------------------------------------------------------------------------| | | | %(CONT1)s | | | | %(CONT2)s | | | | %(CONT3)s | | | | %(CONT4)s | | | |-----------------------------------------------------------------------------| 打印日期: %(BJEDTE)s 授权: 记账: """ #====写文件操作==== file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8531' out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb") if out_file == None: return AfaFlowControl.ExitThisFlow("S999", "生成文件异常") print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\ 'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\ 'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\ 'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\ 'BOJEDT':(records[0]['BOJEDT']).ljust(8,' '),\ 'BOSPSQ':(records[0]['BOSPSQ']).ljust(12,' '),\ 'OROCCAMT':(ret['OCCAMT']),\ 'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\ 'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\ 'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\ 'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')} out_file.close() TradeContext.PBDAFILE = file_name #文件名 AfaLoggerFunc.tradeDebug("结束生成打印文本") #=====自由格式书==== elif(TradeContext.TRCCO=='9900513'): AfaLoggerFunc.tradeInfo(">>>业务类型为自由格式书") #=====自由格式书打印格式==== txt="""\ %(BESBNM)s自由格式书 |-----------------------------------------------------------------------------| | 日期: | %(BJEDTE)s | |-----------------------------------------------------------------------------| | 自由格式书号: | %(BSPSQN)s | |-----------------------------------------------------------------------------| | 发起行行号: | %(SNDBNKCO)s | |-----------------------------------------------------------------------------| | 接收行行号: | %(RCVBNKCO)s | |-----------------------------------------------------------------------------| | 内容: | | |-----------------------------------------------------------------------------| | | | %(CONT1)s | | | | %(CONT2)s | | | | %(CONT3)s | | | | %(CONT4)s | | | |-----------------------------------------------------------------------------| 打印日期: %(BJEDTE)s 授权: 记账: """ #=====写文件操作==== file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8531' out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb") if out_file == None: return AfaFlowControl.ExitThisFlow("S999", "生成文件异常") print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\ 'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\ 'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\ 'SNDBNKCO':(records[0]['SNDBNKCO']).ljust(10,' '),\ 'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\ 'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\ 'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\ 'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\ 'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')} out_file.close() TradeContext.PBDAFILE = file_name #文件名 AfaLoggerFunc.tradeDebug("结束生成打印文本") #=====特约汇兑查询书==== elif(TradeContext.TRCCO=='9900522'): AfaLoggerFunc.tradeInfo(">>>业务类型为特约汇兑查询书") #=====查询原交易信息==== where_dict={'BJEDTE':records[0]['BOJEDT'],'BSPSQN':records[0]['BOSPSQ']} ret=rccpsDBTrcc_trcbka.selectu(where_dict) if(ret==None): return AfaFlowControl.ExitThisFlow('A099','查询原信息失败' ) if(len(ret)==0): return AfaFlowControl.ExitThisFlow('A099','未查找原信息' ) #=====特约电子汇兑查询书打印格式==== txt="""\ %(BESBNM)s全国特约电子汇兑查询书 |-----------------------------------------------------------------------------| | 查询日期: | %(BJEDTE)s | |-----------------------------------------------------------------------------| | 特约汇兑查询书号: | %(BSPSQN)s | |-----------------------------------------------------------------------------| | 发起行行号: | %(SNDBNKCO)s | |-----------------------------------------------------------------------------| | 接收行行号: | %(RCVBNKCO)s | |-----------------------------------------------------------------------------| | 原报单号: | %(BOSPSQ)s | |-----------------------------------------------------------------------------| | 原金额: | %(OROCCAMT)-15.2f | |-----------------------------------------------------------------------------| | 原委托日期: | %(ORTRCDAT)s | |-----------------------------------------------------------------------------| | 原发起行行号: | %(ORSNDBNKCO)s | |-----------------------------------------------------------------------------| | 查询内容: | | |-----------------------------------------------------------------------------| | | | %(CONT1)s | | | | %(CONT2)s | | | | %(CONT3)s | | | | %(CONT4)s | | | |-----------------------------------------------------------------------------| 打印日期: %(BJEDTE)s 授权: 记账: """ #====写文件操作==== file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8531' out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb") if out_file == None: return AfaFlowControl.ExitThisFlow("S999", "生成打印文件异常") print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\ 'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\ 'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\ 'SNDBNKCO':(records[0]['SNDBNKCO']).ljust(10,' '),\ 'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\ 'BOSPSQ':(records[0]['BOSPSQ']).ljust(10,' '),\ 'OROCCAMT':(ret['OCCAMT']),\ 'ORTRCDAT':(ret['TRCDAT']).ljust(8,' '),\ 'ORSNDBNKCO':(ret['SNDBNKCO']).ljust(10,' '),\ 'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\ 'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\ 'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\ 'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')} out_file.close() TradeContext.PBDAFILE = file_name #文件名 AfaLoggerFunc.tradeDebug("结束生成打印文本") #=====特约汇兑查复书==== elif(TradeContext.TRCCO=='9900523'): AfaLoggerFunc.tradeInfo(">>>业务类型为特约汇兑查复书") #=====查询原交易信息==== where_dict={'BJEDTE':records[0]['BOJEDT'],'BSPSQN':records[0]['BOSPSQ']} ret=rccpsDBTrcc_hdcbka.selectu(where_dict) if(ret==None): return AfaFlowControl.ExitThisFlow('A099','查询原信息失败' ) if(len(ret)==0): return AfaFlowControl.ExitThisFlow('A099','未查找原信息' ) #=====特约电子汇兑查复书打印格式==== txt="""\ %(BESBNM)s全国特约电子汇兑查复书 |-----------------------------------------------------------------------------| | 查复日期: | %(BJEDTE)s | |-----------------------------------------------------------------------------| | 特约汇兑查复书号: | %(BSPSQN)s | |-----------------------------------------------------------------------------| | 发起行行号: | %(SNDBNKCO)s | |-----------------------------------------------------------------------------| | 接收行行号: | %(RCVBNKCO)s | |-----------------------------------------------------------------------------| | 原特约查询发起行行号: | %(ORSNDBNKCO)s | |-----------------------------------------------------------------------------| | 原特约查询日期: | %(BOJEDT)s | |-----------------------------------------------------------------------------| | 原金额: | %(OROCCAMT)-15.2f | |-----------------------------------------------------------------------------| | 原委托日期: | %(ORTRCDAT)s | |-----------------------------------------------------------------------------| | 原特约查询交易流水号: | %(ORTRCNO)s | |-----------------------------------------------------------------------------| | 查询内容: | | |-----------------------------------------------------------------------------| | | | %(CONT1)s | | | | %(CONT2)s | | | | %(CONT3)s | | | | %(CONT4)s | | | |-----------------------------------------------------------------------------| 打印日期: %(BJEDTE)s 授权: 记账: """ #====写文件操作==== file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8531' out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb") if out_file == None: return AfaFlowControl.ExitThisFlow("S999", "生成打印文件异常") print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\ 'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\ 'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\ 'SNDBNKCO':(records[0]['SNDBNKCO']).ljust(10,' '),\ 'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\ 'ORSNDBNKCO':(ret['SNDBNKCO']).ljust(10,' '),\ 'BOJEDT':(records[0]['BJEDTE']).ljust(8,' '),\ 'OROCCAMT':(ret['OCCAMT']),\ 'ORTRCDAT':(ret['TRCDAT']).ljust(8,' '),\ 'ORTRCNO':(ret['TRCNO']).ljust(12,' '),\ 'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\ 'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\ 'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\ 'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')} out_file.close() TradeContext.PBDAFILE = file_name #文件名 AfaLoggerFunc.tradeDebug("结束生成打印文本") #=====特约汇兑自由格式书==== elif(TradeContext.TRCCO=='9900524'): AfaLoggerFunc.tradeInfo(">>>业务类型为特约汇兑自由格式书") #=====特约电子汇兑自由格式书打印格式==== txt="""\ %(BESBNM)s全国特约电子汇兑自由格式书 |-----------------------------------------------------------------------------| | 日期: | %(BJEDTE)s | |-----------------------------------------------------------------------------| | 特约汇兑自由格式书号: | %(BSPSQN)s | |-----------------------------------------------------------------------------| | 发起行行号: | %(SNDBNKCO)s | |-----------------------------------------------------------------------------| | 接收行行号: | %(RCVBNKCO)s | |-----------------------------------------------------------------------------| | 内容: | | |-----------------------------------------------------------------------------| | | | %(CONT1)s | | | | %(CONT2)s | | | | %(CONT3)s | | | | %(CONT4)s | | | |-----------------------------------------------------------------------------| 打印日期: %(BJEDTE)s 授权: 记账: """ #=====写文件操作==== file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8531' out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb") if out_file == None: return AfaFlowControl.ExitThisFlow("S999", "生成文件异常") print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\ 'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\ 'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\ 'SNDBNKCO':(records[0]['SNDBNKCO']).ljust(10,' '),\ 'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\ 'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\ 'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\ 'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\ 'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')} out_file.close() TradeContext.PBDAFILE = file_name #文件名 AfaLoggerFunc.tradeInfo("结束生成打印文本") else: return AfaFlowControl.ExitThisFlow('A099','没有相关的业务类型' ) TradeContext.RECCOUNT="1" #查询笔数 TradeContext.RECALLCOUNT="1" #总笔数 TradeContext.errorCode="0000" TradeContext.errorMsg="查询成功" elif( len(TradeContext.PRTTYPE) == 0 ): return AfaFlowControl.ExitThisFlow('A099','打印标志为必输项' ) else: return AfaFlowControl.ExitThisFlow('A099','打印标志非法' ) AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易[TRC001_8531]退出***' ) return True
def TrxMain(): AfaLoggerFunc.tradeInfo('**********批量作业申请(8409)开始**********') TradeContext.tradeResponse.append(['O1AFAPDATE', TradeContext.TranDate]) #工作日期 TradeContext.tradeResponse.append(['O1AFAPTIME', TradeContext.TranTime]) #工作时间 #判断单位协议是否有效 if ( not AbdtFunc.ChkUnitInfo( ) ): return False ####################################################################### #20090927 蔡永贵 增加对公账户校验 #---------------------------------------------------------------------- AfaLoggerFunc.tradeInfo( '>>>校验对公账户' ) if ( TradeContext.I1ACCNO != TradeContext.ACCNO ): return ExitSubTrade( "9000", "单位对公账户不一致,不能做此业务") ####################################################################### #判断批量申请是否已存在 if ( not ChkBatchInfo( ) ): return False #判断处理数据文件是否存在(0-柜面录入,1-外围上传) try: if ( TradeContext.I1FTPTYPE == '0' ): #柜面系统上传 sFileName = os.environ['AFAP_HOME'] + '/data/batch/up_vmenu/' + TradeContext.I1APPNO + TradeContext.I1BUSINO + TradeContext.I1BTHNO dFileName = os.environ['AFAP_HOME'] + '/data/batch/in/' + TradeContext.I1APPNO + TradeContext.I1BUSINO + TradeContext.I1BTHNO + "_" + TradeContext.TranDate elif ( TradeContext.I1FTPTYPE == '1' ): #外围系统上传 #20120409 陈浩修改添加--AG07 #if ( TradeContext.I1APPNO[0:4] == 'AG08' ): AfaLoggerFunc.tradeInfo('>>>TradeContext.I1APPNO[0:4] =='+TradeContext.I1APPNO[0:4]) if ( TradeContext.I1APPNO[0:4] == 'AG08' or TradeContext.I1APPNO[0:4] == 'AG07'): #财政特殊处理(修改人:徐忠和,修改日期:20080402) sCZZJDM = '' sCZZJDMMC= '' sCZNOTE1 = '' sCZNOTE2 = '' #查询资金代码信息 sql = "SELECT CZZJDM,ZJDMMC,NOTE1,NOTE2 FROM ABDT_CZDZB WHERE " sql = sql + "APPNO=" + "'" + TradeContext.I1APPNO + "'" #业务编号 AfaLoggerFunc.tradeInfo( '>>>财政特殊处理结果:' +sql) records = AfaDBFunc.SelectSql( sql ) if ( records == None ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return ExitSubTrade( '9000', '查询资金代码信息异常' ) if ( len(records) == 0 ): return ExitSubTrade( '9000', '没有资金代码对照信息' ) else: sCZZJDM = str(records[0][0]).strip() #资金代码 sCZZJDMMC= str(records[0][1]).strip() #单位名称 sCZNOTE1 = str(records[0][2]).strip() #备注1 sCZNOTE2 = str(records[0][3]).strip() #备注2 #生成以资金帐号(6位)+结构代码(14位)的批量文件名 sFileName = os.environ['AFAP_HOME'] + '/data/batch/up_other/' + sCZZJDM + TradeContext.I1BUSINO + TradeContext.I1BTHNO else: sFileName = os.environ['AFAP_HOME'] + '/data/batch/up_other/' + TradeContext.I1APPNO + TradeContext.I1BUSINO + TradeContext.I1BTHNO dFileName = os.environ['AFAP_HOME'] + '/data/batch/swap/' + TradeContext.I1APPNO + TradeContext.I1BUSINO + TradeContext.I1BTHNO + "_" + TradeContext.TranDate else: return ExitSubTrade( '9000', '上传方式错误' ) AfaLoggerFunc.tradeInfo("上传文件是:" + sFileName) #源文件名 TradeContext.S_FILENAME = sFileName #目标文件名 TradeContext.D_FILENAME = dFileName if ( os.path.exists(sFileName) and os.path.isfile(sFileName) ): AfaLoggerFunc.tradeInfo("批量处理数据文件存在") if ( TradeContext.I1FTPTYPE == '1' ): AfaLoggerFunc.tradeInfo("外围系统上传-->只需要登记") else: AfaLoggerFunc.tradeInfo("柜面系统上传-->需校验文件") #打开文件 bfp = open(sFileName, "r") #读取一行 linebuf = bfp.readline() while ( len(linebuf) > 0 ): if ( (len(linebuf) != 100) and (len(linebuf) != 101) ): bfp.close() return ExitSubTrade( '9000', '批量处理数据文件格式错误' ) if ( linebuf[0] == "1" ): AfaLoggerFunc.tradeInfo("**********汇总信息**********") s_rectype = linebuf[0:1].lstrip().rstrip() #记录类型 s_appno = linebuf[1:7].lstrip().rstrip() #业务编号 s_busino = linebuf[7:21].lstrip().rstrip() #单位编号 s_agenttype = linebuf[21:22].lstrip().rstrip() #委托方式 s_accno = linebuf[22:45].lstrip().rstrip() #对公帐号 s_remark = linebuf[45:65].lstrip().rstrip() #备用 s_status = linebuf[65:66].lstrip().rstrip() #状态 s_totalnum = linebuf[66:76].lstrip().rstrip() #总笔数 s_totalamt = linebuf[76:93].lstrip().rstrip() #总金额 s_retcode = linebuf[93:100].lstrip().rstrip() #返回码 AfaLoggerFunc.tradeInfo("记录类型 =" + s_rectype) AfaLoggerFunc.tradeInfo("业务编号 =" + s_appno) AfaLoggerFunc.tradeInfo("单位编号 =" + s_busino) AfaLoggerFunc.tradeInfo("委托方式 =" + s_agenttype) AfaLoggerFunc.tradeInfo("对公帐号 =" + s_accno) AfaLoggerFunc.tradeInfo("备 用 =" + s_remark) AfaLoggerFunc.tradeInfo("状 态 =" + s_status) AfaLoggerFunc.tradeInfo("总 笔 数 =" + s_totalnum) AfaLoggerFunc.tradeInfo("总 金 额 =" + s_totalamt) AfaLoggerFunc.tradeInfo("返 回 码 =" + s_retcode) AfaLoggerFunc.tradeInfo("**********汇总信息**********") break linebuf = bfp.readline() #关闭文件 bfp.close() #状态(0:忽略 1:正常) if ( s_status == "0" ): return ExitSubTrade('9000', '您申请数据文件中汇总记录状态错误,不能申请') #校验业务编码 if ( TradeContext.I1APPNO != s_appno ): return ExitSubTrade('9000', '您申请的业务编码与数据文件的业务编码不符,不能申请') #校验单位编码 if ( TradeContext.I1BUSINO != s_busino ): return ExitSubTrade('9000', '您申请的单位编码与数据文件的单位编码不符,不能申请') #校验对公帐号 if ( TradeContext.ACCNO != s_accno ): return ExitSubTrade('9000', '批量处理数据文件中的对公帐号和单位信息表中登记不符') #校验委托方式是否一致 if ( TradeContext.AGENTTYPE != s_agenttype ): return ExitSubTrade('9000', '批量处理数据文件中的委托方式和单位信息表中登记不符') #校验委托方式合法性 if ( (s_agenttype!='3') and (s_agenttype!='4') ): return ExitSubTrade('9000', '批量处理数据文件中的委托方式非法') #校验总笔数 if ( TradeContext.I1TOTALNUM != s_totalnum ): return ExitSubTrade('9000', '您申请的批量总笔数与数据文件的总笔数不符,不能申请') #校验总金额 if ( TradeContext.I1TOTALAMT != s_totalamt ): return ExitSubTrade('9000', '您申请的批量总金额与数据文件的总金额不符,不能申请') else: AfaLoggerFunc.tradeInfo("上传文件名 =" + sFileName) return ExitSubTrade('9000', '批量处理数据文件没有上传,请重试') except Exception, e: AfaLoggerFunc.tradeInfo( str(e) ) return ExitSubTrade('9999', '批量处理数据文件操作异常')
def InsertBatchInfo( ): AfaLoggerFunc.tradeInfo('>>>登记批次作业申请信息') try: sql = "" sql = "INSERT INTO ABDT_BATCHINFO(" sql = sql + "BATCHNO," #委托号(批次号: 唯一(日期+流水号) sql = sql + "APPNO," #业务编号 sql = sql + "BUSINO," #单位编号 sql = sql + "ZONENO," #地区号 sql = sql + "BRNO," #网点号 sql = sql + "USERNO," #操作员 sql = sql + "ADMINNO," #管理员 sql = sql + "TERMTYPE," #终端类型 sql = sql + "FILENAME," #上传文件名 sql = sql + "INDATE," #委托日期 sql = sql + "INTIME," #委托时间 sql = sql + "BATCHDATE," #提交日期 sql = sql + "BATCHTIME," #提交时间 sql = sql + "TOTALNUM," #总笔数 sql = sql + "TOTALAMT," #总金额 sql = sql + "SUCCNUM," #成功笔数 sql = sql + "SUCCAMT," #成功金额 sql = sql + "FAILNUM," #失败笔数 sql = sql + "FAILAMT," #失败金额 sql = sql + "STATUS," #状态 sql = sql + "BEGINDATE," #生效日期 sql = sql + "ENDDATE," #失效日期 sql = sql + "PROCMSG," #处理信息 sql = sql + "NOTE1," #备注1 sql = sql + "NOTE2," #备注2 sql = sql + "NOTE3," #备注3 sql = sql + "NOTE4," #备注4 sql = sql + "NOTE5)" #备注5 sql = sql + " VALUES (" sql = sql + "'" + TradeContext.BATCHNO + "'," #委托号(批次号:唯一(日期+流水号) sql = sql + "'" + TradeContext.I1APPNO + "'," #业务编号 sql = sql + "'" + TradeContext.I1BUSINO + "'," #单位编号 sql = sql + "'" + TradeContext.I1ZONENO + "'," #地区号 sql = sql + "'" + TradeContext.I1SBNO + "'," #网点号 sql = sql + "'" + TradeContext.I1USID + "'," #操作员 sql = sql + "'" + TradeContext.I1ADMINNO + "'," #管理员 sql = sql + "'" + TradeContext.I1FTPTYPE + "'," #终端类型 sql = sql + "'" + TradeContext.I1FILENAME + "'," #批量文件 sql = sql + "'" + TradeContext.TranDate + "'," #申请时间 sql = sql + "'" + TradeContext.TranTime + "'," #申请时间 sql = sql + "'" + "00000000" + "'," #提交日期 sql = sql + "'" + "000000" + "'," #提交时间 sql = sql + "'" + TradeContext.I1TOTALNUM + "'," #总笔数 sql = sql + "'" + TradeContext.I1TOTALAMT + "'," #总金额 sql = sql + "'" + "0" + "'," #成功笔数 sql = sql + "'" + "0" + "'," #成功金额 sql = sql + "'" + "0" + "'," #失败笔数 sql = sql + "'" + "0" + "'," #失败金额 sql = sql + "'" + "10" + "'," #状态(申请) sql = sql + "'" + TradeContext.I1NOTE1 + "'," #生效日期 sql = sql + "'" + TradeContext.I1NOTE2 + "'," #失效日期 sql = sql + "'" + TradeContext.I1NOTE5 + "'," #处理信息 sql = sql + "'" + "" + "'," #备注1 #begin 20091028 蔡永贵修改 增加批次序号,存放到备注2中 sql = sql + "'" + TradeContext.I1BTHNO + "'," #备注2 #end #begin 20090927 蔡永贵修改 增加处理标志,存放到备注3中 #sql = sql + "'" + TradeContext.I1NOTE3 + "'," #备注3 sql = sql + "'" + TradeContext.I1TRFG + "'," #备注3 #end sql = sql + "'" + TradeContext.I1NOTE4 + "'," #备注4 sql = sql + "'" + "" + "')" #备注5 AfaLoggerFunc.tradeInfo(sql) result = AfaDBFunc.InsertSqlCmt( sql ) if( result <= 0 ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) #删除文件 rm_cmd_str="rm " + TradeContext.D_FILENAME os.system(rm_cmd_str) return ExitSubTrade( '9000', '登记批次作业申请信息失败') return True except Exception, e: #删除文件 rm_cmd_str="rm " + TradeContext.D_FILENAME os.system(rm_cmd_str) AfaLoggerFunc.tradeFatal( str(e) ) return ExitSubTrade( '9999', '登记批次作业申请信息异常')
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作(1.本地操作)交易[TRC001_8539]进入***' ) #=====判断输入接口值是否存在==== if( not TradeContext.existVariable( "STRDAT" ) ): return AfaFlowControl.ExitThisFlow('A099', '起始日期[STRDAT]不存在') if( not TradeContext.existVariable( "ENDDAT" ) ): return AfaFlowControl.ExitThisFlow('A099', '结束日期[ENDDAT]不存在') if( not TradeContext.existVariable( "RECSTRNO" ) ): return AfaFlowControl.ExitThisFlow('A099', '起始笔数[RECSTRNO]不存在') #=====组织sql语句==== wheresql = "" wheresql = wheresql+"BJEDTE>='"+TradeContext.STRDAT+"'" wheresql = wheresql+" AND BJEDTE<='"+TradeContext.ENDDAT+"'" start_no=TradeContext.RECSTRNO #起始笔数 sel_size=10 #查询笔数 #=====查询总记录笔数==== allcount=rccpsDBTrcc_cshalm.count(wheresql) if(allcount == -1): return AfaFlowControl.ExitThisFlow('S999', '查询总记录数异常') #=====查询数据库==== ordersql = " order by BJEDTE DESC" records=rccpsDBTrcc_cshalm.selectm(start_no,sel_size,wheresql,ordersql) if(records == None): return AfaFlowControl.ExitThisFlow('S999', '查询头寸预警登记簿异常') if(len(records) <= 0): return AfaFlowControl.ExitThisFlow('S999', '头寸预警登记簿中无对应信息') else: #=====生成文件==== AfaLoggerFunc.tradeInfo( "生成文件") filename="rccps_"+TradeContext.BESBNO+"_"+AfaUtilTools.GetSysDate()+"_"+TradeContext.TransCode try: pub_path = os.environ["AFAP_HOME"] pub_path = pub_path + "/tmp/" f=open(pub_path + filename,"w") except IOError: return AfaFlowControl.ExitThisFlow('S999','打开文件失败') filecontext="" #=====写文件操作==== for i in range(0,len(records)): #=====生成文件内容==== filecontext=records[i]['BJEDTE']+"|"+records[i]['BSPSQN']+"|"\ +records[i]['NCCWKDAT']+"|"+records[i]['TRCDAT']+"|"\ +records[i]['TRCNO']+"|"+records[i]['CUR']+"|"\ +str(records[i]['POSITION'])+"|"+str(records[i]['POSALAMT'])+"|" AfaLoggerFunc.tradeInfo( filecontext) f.write(filecontext+"\n") f.close() #=====输出接口赋值==== TradeContext.PBDAFILE=filename #文件名 TradeContext.RECCOUNT=str(len(records)) #查询笔数 TradeContext.RECALLCOUNT=str(allcount) #总笔数 TradeContext.errorCode="0000" TradeContext.errorMsg="查询成功" AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作(1.本地操作)交易[TRC001_8539]退出***' ) return True
#=============获取当前系统时间==================== if not (TradeContext.existVariable( "workDate" ) and len(TradeContext.workDate)>0): TradeContext.workDate = UtilTools.GetSysDate( ) TradeContext.workTime = UtilTools.GetSysTime( ) TradeContext.appNo ='AG2010' TradeContext.busiNo ='00000000000001' #=============外调接口1==================== subModuleExistFlag=0 subModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode try: subModuleHandle=__import__( subModuleName ) except Exception, e: AfaLoggerFunc.tradeInfo( e) else: AfaLoggerFunc.tradeInfo( '执行['+subModuleName+']模块' ) subModuleExistFlag=1 if( not subModuleHandle.SubModuleDealFst( ) ): raise TipsFunc.flowException( ) #============校验公共节点的有效性================== if ( not TipsFunc.Cancel_ChkVariableExist( ) ): raise TipsFunc.flowException( ) #=============判断应用状态==================== if( not TipsFunc.ChkAppStatus( ) ): raise TipsFunc.flowException( ) #=============判断反交易数据是否匹配原交易==================== if( not TipsFunc.ChkRevInfo( TradeContext.preAgentSerno ) ): raise TipsFunc.flowException( )
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易[TRC001_8532]进入***' ) #=====判断输入接口值是否存在==== if( not TradeContext.existVariable( "STRDAT" ) ): return AfaFlowControl.ExitThisFlow('A099', '起始日期[STRDAT]不存在') if( not TradeContext.existVariable( "ENDDAT" ) ): return AfaFlowControl.ExitThisFlow('A099', '结束日期[ENDDAT]不存在') if( not TradeContext.existVariable( "RECSTRNO" ) ): return AfaFlowControl.ExitThisFlow('A099', '起始笔数[RECSTRNO]不存在') if(len(TradeContext.PRTTYPE)==0): return AfaFlowControl.ExitThisFlow("S999", "打印标志[PRTTYPE]不允许为空") #=====组织sql语句==== wheresql="" wheresql = wheresql + "BESBNO='" + TradeContext.BESBNO + "' " wheresql=wheresql+" and BJEDTE>='"+TradeContext.STRDAT+"'" wheresql=wheresql+" AND BJEDTE<='"+TradeContext.ENDDAT+"'" #=====判断查复标识是否为空或为9-全部==== if(TradeContext.ISDEAL != "" and TradeContext.ISDEAL != "9"): wheresql=wheresql+" AND ISDEAL='"+TradeContext.ISDEAL+"'" #=====判断往来标识是否为空==== if(TradeContext.BRSFLG!=""): wheresql=wheresql+" AND BRSFLG='"+TradeContext.BRSFLG+"'" #=====判断交易代码是否为空==== if(TradeContext.TRCCO !="" ): wheresql=wheresql+" AND TRCCO='"+TradeContext.TRCCO+"'" #业务类型(交易代码) start_no=TradeContext.RECSTRNO #起始笔数 sel_size=10 #=====查询机构名==== subbra_dict={'BESBNO':TradeContext.BESBNO} sub=rccpsDBTrcc_subbra.selectu(subbra_dict) if(sub==None): return AfaFlowControl.ExitThisFlow('A099','查询机构名失败' ) if(len(sub)==0): return AfaFlowControl.ExitThisFlow('A099','机构名称无满足条件记录' ) #=====判断打印类型 0 不打印==== if(TradeContext.PRTTYPE=='0'): AfaLoggerFunc.tradeInfo(">>>进入不打印处理") #=====判断查询查复书号是否为空==== if(TradeContext.BSPSQN!="" ): wheresql=wheresql+" AND BSPSQN='"+TradeContext.BSPSQN+"'" #=====查询总记录数==== allcount=rccpsDBTrcc_pjcbka.count(wheresql) if(allcount==-1): return AfaFlowControl.ExitThisFlow('A099','查找总记录数失败' ) #=====查询数据库==== ordersql=" order by BJEDTE DESC,BSPSQN DESC" records=rccpsDBTrcc_pjcbka.selectm(start_no,sel_size,wheresql,ordersql) if records==None: return AfaFlowControl.ExitThisFlow('A099','查询失败' ) if len(records)<=0: return AfaFlowControl.ExitThisFlow('A099','没有查找到数据' ) else: #=====生成文件==== filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetHostDate()+"_"+TradeContext.TransCode fpath=os.environ["AFAP_HOME"]+"/tmp/" try: f=open(fpath+filename,"w") except : AfaLoggerFunc.tradeInfo(">>>打开文件失败") return AfaFlowControl.ExitThisFlow('A099','打开文件失败' ) filecontext="" #=====写文件操作==== for i in range(0,len(records)): #=====生成文件内容==== AfaLoggerFunc.tradeDebug( "生成文件内容 ") filecontext=records[i]['BJEDTE'] + "|" \ +records[i]['BSPSQN'] + "|" \ +records[i]['BRSFLG'] + "|" \ +records[i]['BESBNO'] + "|" \ +records[i]['BETELR'] + "|" \ +records[i]['BEAUUS'] + "|" \ +records[i]['NCCWKDAT'] + "|" \ +records[i]['TRCCO'] + "|" \ +records[i]['TRCDAT'] + "|" \ +records[i]['TRCNO'] + "|" \ +records[i]['SNDBNKCO'] + "|" \ +records[i]['SNDBNKNM'] + "|" \ +records[i]['RCVBNKCO'] + "|" \ +records[i]['RCVBNKNM'] + "|" \ +records[i]['BOJEDT'] + "|" \ +records[i]['BOSPSQ'] + "|" \ +records[i]['ORTRCCO'] + "|" \ +records[i]['CONT'] + "|" \ +records[i]['ISDEAL'] + "|" \ +records[i]['BILDAT'] + "|" \ +records[i]['BILNO'] + "|" \ +records[i]['BILPNAM'] + "|" \ +records[i]['BILENDDT'] + "|" \ +str(records[i]['BILAMT'])+ "|" \ +records[i]['PYENAM'] + "|" \ +records[i]['HONBNKNM'] + "|" \ +records[i]['PRCCO'] + "|" \ +records[i]['STRINFO'] + "|" f.write(filecontext+"\n") f.close() #=====输出接口赋值==== TradeContext.PBDAFILE=filename #文件名 TradeContext.RECCOUNT=str(len(records)) #查询笔数 TradeContext.RECALLCOUNT=str(allcount) #总笔数 #=====打印处理 1 打印==== elif(TradeContext.PRTTYPE=='1'): AfaLoggerFunc.tradeInfo(">>>进入打印处理") #=====判断查询查复书号是否为空==== if(TradeContext.BSPSQN!="" ): wheresql=wheresql+" AND BSPSQN='"+TradeContext.BSPSQN+"'" else: return AfaFlowControl.ExitThisFlow('A099','查询查复书号[BSPSQN]不允许为空' ) #=====查询数据库==== records = rccpsDBTrcc_pjcbka.selectm(TradeContext.RECSTRNO,10,wheresql,"") if(records==None): return AfaFlowControl.ExitThisFlow('A099','查询失败' ) elif( len(records)<=0 ): return AfaFlowControl.ExitThisFlow('A099','未查找到数据' ) else: #=====票据查询书==== if(TradeContext.TRCCO=='9900520'): AfaLoggerFunc.tradeInfo(">>>业务类型为票据查询书") #=====票据查询书打印格式==== txt = """\ %(BESBNM)s票据查询书 |-----------------------------------------------------------------------------| | 查询日期: | %(BJEDTE)s | |-----------------------------------------------------------------------------| | 票据查询书号: | %(BSPSQN)s | |-----------------------------------------------------------------------------| | 发起行行号: | %(SNDBNKCO)s | |-----------------------------------------------------------------------------| | 接收行行号: | %(RCVBNKCO)s | |-----------------------------------------------------------------------------| | 票据日期: | %(BILDAT)s | |-----------------------------------------------------------------------------| | 票据到期日: | %(BILENDDT)s | |-----------------------------------------------------------------------------| | 票据号码: | %(BILNO)s | |-----------------------------------------------------------------------------| | 出票人名称: | %(BILPNAM)s| |-----------------------------------------------------------------------------| | 付款行名称: | %(HONBNKNM)s| |-----------------------------------------------------------------------------| | 查询内容: | | |-----------------------------------------------------------------------------| | | | %(CONT1)s | | | | %(CONT2)s | | | | %(CONT3)s | | | | %(CONT4)s | | | |-----------------------------------------------------------------------------| 打印日期: %(BJEDTE)s 授权: 记账: """ #====写文件操作==== file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8532' out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb") if out_file == None: return AfaFlowControl.ExitThisFlow("S999", "生成打印文件异常") print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\ 'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\ 'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\ 'SNDBNKCO':(records[0]['SNDBNKCO']).ljust(10,' '),\ 'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\ 'BILDAT':(records[0]['BILDAT']).ljust(8,' '),\ 'BILENDDT':(records[0]['BILENDDT']).ljust(8,' '),\ 'BILNO':(records[0]['BILNO']).ljust(16,' '),\ 'BILPNAM':(records[0]['BILPNAM']).ljust(60,' '),\ 'HONBNKNM':(records[0]['HONBNKNM']).ljust(60,' '),\ 'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\ 'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\ 'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\ 'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')} out_file.close() TradeContext.PBDAFILE = file_name #文件名 AfaLoggerFunc.tradeDebug("结束生成打印文本") #=====票据查复书==== elif(TradeContext.TRCCO=='9900521'): AfaLoggerFunc.tradeInfo(">>>业务类型为票据查复书") #=====查询原交易信息==== where_dict={'BJEDTE':records[0]['BOJEDT'],'BSPSQN':records[0]['BOSPSQ']} ret=rccpsDBTrcc_pjcbka.selectu(where_dict) if(ret==None): return AfaFlowControl.ExitThisFlow('A099','查询原信息失败' ) if(len(ret)==0): return AfaFlowControl.ExitThisFlow('A099','未查找原信息' ) #=====票据查复书打印格式==== txt = """\ %(BESBNM)s票据查复书 |---------------------------------------------------------------------------------------| | 查复日期: | %(BJEDTE)s | |---------------------------------------------------------------------------------------| | 票据查复书号: | %(BSPSQN)s | |---------------------------------------------------------------------------------------| | 发起行行号: | %(SNDBNKCO)s | |---------------------------------------------------------------------------------------| | 接收行行号: | %(RCVBNKCO)s | |---------------------------------------------------------------------------------------| | 票据日期: | %(BILDAT)s | |---------------------------------------------------------------------------------------| | 票据到期日: | %(BILENDDT)s | |---------------------------------------------------------------------------------------| | 票据号码: | %(BILNO)s | |---------------------------------------------------------------------------------------| | 出票人名称: | %(BILPNAM)s| |---------------------------------------------------------------------------------------| | 收款人名称: | %(PYENAM)s| |---------------------------------------------------------------------------------------| | 付款行名称: | %(HONBNKNM)s| |---------------------------------------------------------------------------------------| | 原票据查询日期: | %(BOJEDT)s | |---------------------------------------------------------------------------------------| | 原票据查询发起行行号: | %(ORSNDBNKCO)s | |---------------------------------------------------------------------------------------| | 原票据查询书号: | %(BOSPSQ)s | |---------------------------------------------------------------------------------------| | 查复内容: | | |---------------------------------------------------------------------------------------| | | | %(CONT1)s | | | | %(CONT2)s | | | | %(CONT3)s | | | | %(CONT4)s | | | |---------------------------------------------------------------------------------------| 打印日期: %(BJEDTE)s 授权: 记账: """ #====写文件操作==== file_name = 'rccps_' + records[0]['BJEDTE'] + '_' + TradeContext.BSPSQN + '_8532' out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb") if out_file == None: return AfaFlowControl.ExitThisFlow("S999", "生成打印文件异常") print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\ 'BJEDTE':(records[0]['BJEDTE']).ljust(8,' '),\ 'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\ 'SNDBNKCO':(records[0]['SNDBNKCO']).ljust(10,' '),\ 'RCVBNKCO':(records[0]['RCVBNKCO']).ljust(10,' '),\ 'BILDAT':(records[0]['BILDAT']).ljust(8,' '),\ 'BILENDDT':(records[0]['BILENDDT']).ljust(8,' '),\ 'BILNO':(records[0]['BILNO']).ljust(16,' '),\ 'BILPNAM':(records[0]['BILPNAM']).ljust(60,' '),\ 'PYENAM':(records[0]['PYENAM']).ljust(60,' '),\ 'HONBNKNM':(records[0]['HONBNKNM']).ljust(60,' '),\ 'BOJEDT':(records[0]['BOJEDT']).ljust(8,' '),\ 'ORSNDBNKCO':(ret['SNDBNKCO']).ljust(10,' '),\ 'BOSPSQ':(records[0]['BOSPSQ']).ljust(12,' '),\ 'CONT1':(records[0]['CONT'][:68]).ljust(68,' '),\ 'CONT2':(records[0]['CONT'][68:138]).ljust(70,' '),\ 'CONT3':(records[0]['CONT'][138:208]).ljust(70,' '),\ 'CONT4':(records[0]['CONT'][208:]).ljust(70,' ')} out_file.close() TradeContext.PBDAFILE = file_name #文件名 AfaLoggerFunc.tradeDebug("结束生成打印文本") else: return AfaFlowControl.ExitThisFlow("S999", "业务类型非法") TradeContext.RECCOUNT='1' #查询笔数 TradeContext.RECALLCOUNT='1' #总笔数 TradeContext.errorCode="0000" TradeContext.errorMsg="查询成功" else: return AfaFlowControl.ExitThisFlow("S999", "打印标志非法") TradeContext.errorCode="0000" TradeContext.errorMsg="查询成功" AfaLoggerFunc.tradeInfo( '***农信银系统:往账.本地类操作交易[TRC001_8532]退出***' ) return True
#=====================判断应用系统状态================================== if not AfaFunc.ChkSysStatus( ) : raise AfaFlowControl.flowException( ) #=====================外调接口(前处理)================================== subModuleExistFlag = 0 subModuleName = 'T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode try: subModuleHandle=__import__( subModuleName ) except Exception, e: AfaLoggerFunc.tradeInfo( e) else: AfaLoggerFunc.tradeInfo( '执行['+subModuleName+']模块' ) subModuleExistFlag=1 if not subModuleHandle.SubModuleDoFst( ) : raise AfaFlowControl.flowException( ) #=====================校验公共节点的有效性============================== if( not AfaFunc.Pay_ChkVariableExist( ) ): raise AfaFlowControl.flowException( ) #=====================判断单位状态====================================== if not AfaFunc.ChkUnitStatus( ) : raise AfaFlowControl.flowException( )
def SubModuleDoSnd(): AfaLoggerFunc.tradeInfo('单证重打子查询交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']进入' ) try: sql = "select unitno,amount,userno,note4,note5,note8,note9,note10,craccno,note7 from afa_maintransdtl" sql = sql + " where agentserialno = '" + TradeContext.transrno.strip() + "'" sql = sql + " and workdate = '" + TradeContext.workDate.strip() + "'" sql = sql + " and bankstatus = '0' and corpstatus = '0' and revtranf = '0'" AfaLoggerFunc.tradeInfo('单证重打信息查询语句'+ sql) records = AfaDBFunc.SelectSql( sql ) if records == None: TradeContext.errorCode,TradeContext.errorMsg = "0001" ,"查询银保通数据库失败" raise AfaFlowControl.flowException( ) if(len(records) < 1): TradeContext.errorCode,TradeContext.errorMsg = "0001","无此缴费信息" return False else: if(records[0][0]!=TradeContext.unitno): TradeContext.errorCode,TradeContext.errorMsg='E9999',"单位编号不符" return False if(records[0][1].split()!=TradeContext.amount.split()): TradeContext.errorCode,TradeContext.errorMsg='E9999',"与原交易金额不符" return False if(records[0][2]!=TradeContext.userno): TradeContext.errorCode,TradeContext.errorMsg='E9999',"与原保单印刷号不符" return False note9=records[0][6].split('|') AfaLoggerFunc.tradeInfo(note9[2] + "||"+TradeContext.policy) if(note9[2]!=TradeContext.policy): TradeContext.errorCode,TradeContext.errorMsg='E9999',"与原保险单号不符" return False #note9保险单号 TradeContext.policy=note9[2] #note8主险险种和附加险种 note8= records[0][5].split('|') TradeContext.productid=note8[0] TradeContext.productid1=note8[2] #note4:投保人姓名|投保人证件号码|与投保人关系 note4= records[0][3].split('|') TradeContext.tbr_name=note4[0] TradeContext.tbr_idno=note4[1] TradeContext.tbr_bbr_rela=note4[2] #note5:被保人姓名|被保人证件号码|与被保险人关系 note5= records[0][4].split('|') TradeContext.bbr_name=note5[0] TradeContext.bbr_idno=note5[1] TradeContext.syr_bbr_rela=note5[2] TradeContext.payacc=records[0][8] #note7:交费方式|缴费期次|交费期间 TradeContext.paymethod = records[0][9].split('|')[0] #查询受益人信息 sql = "select syr_info1,syr_info2,syr_info3,syr_info4,syr_info5 from ybt_info" sql = sql + " where submino = '" + note9[1] + "'" #投保单号 sql = sql + " and cpicno = '" + TradeContext.unitno + "'" #保险公司代码 sql = sql + " and workdate = '" + TradeContext.workDate + "'" #交易日期 sql = sql + " and tellerno = '" + TradeContext.tellerno + "'" #交易柜员 AfaLoggerFunc.tradeInfo('查询受益人信息:'+ sql) results = AfaDBFunc.SelectSql( sql ) if results == None: TradeContext.errorCode,TradeContext.errorMsg = "0001" ,"查询受益人信息异常" return False if(len(results) < 1): TradeContext.errorCode,TradeContext.errorMsg = "0001","没有找到相关的受益人信息" return False else: TradeContext.syr_1 = results[0][0] #受益人1信息 TradeContext.syr_2 = results[0][1] #受益人2信息 TradeContext.syr_3 = results[0][2] #受益人3信息 TradeContext.syr_4 = results[0][3] #受益人4信息 TradeContext.syr_5 = results[0][4] #受益人5信息 TradeContext.errorCode = '0000' AfaLoggerFunc.tradeInfo('单证重打子查询交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']退出' ) return True except Exception, e: AfaFlowControl.exitMainFlow(str(e))
def SubModuleDoSnd(): AfaLoggerFunc.tradeInfo("进入交易后处理") #=================判断afe是否发送成功======================================= if TradeContext.errorCode != '0000': return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg) #=====查询机构名==== subbra_dict={'BESBNO':TradeContext.BESBNO} sub=rccpsDBTrcc_subbra.selectu(subbra_dict) if(sub==None): return AfaFlowControl.ExitThisFlow('A099','查询机构名失败' ) if(len(sub)==0): return AfaFlowControl.ExitThisFlow('A099','没有相应的机构名' ) #=================生成打印文本============================================= AfaLoggerFunc.tradeInfo("开始生成打印文本") txt = """\ %(BESBNM)s汇票查询书 |-----------------------------------------------------------------------------| | 查询日期: | %(BJEDTE)s | |-----------------------------------------------------------------------------| | 查询书号: | %(BSPSQN)s | |-----------------------------------------------------------------------------| | 发起行行号: | %(SNDBNKCO)s | |-----------------------------------------------------------------------------| | 接收行行号: | %(RCVBNKCO)s | |-----------------------------------------------------------------------------| | 出票日期: | %(BILDAT)s | |-----------------------------------------------------------------------------| | 汇票金额: | %(BILAMT)s | |-----------------------------------------------------------------------------| | 汇票号码: | %(BILNO)s | |-----------------------------------------------------------------------------| | 付款人账号: | %(PYRACC)s | |-----------------------------------------------------------------------------| | 付款人名称: | %(PYRNAM)s| |-----------------------------------------------------------------------------| | 收款人账号: | %(PYEACC)s | |-----------------------------------------------------------------------------| | 收款人名称: | %(PYENAM)s| |-----------------------------------------------------------------------------| | 查询内容: | | |-----------------------------------------------------------------------------| | | | %(CONT1)s | | | | %(CONT2)s | | | | %(CONT3)s | | | | %(CONT4)s | | | |-----------------------------------------------------------------------------| 打印日期: %(BJEDTE)s 授权: 记账: """ file_name = 'rccps_' + TradeContext.BJEDTE + '_' + TradeContext.BSPSQN + '_8516' out_file = open(os.environ['AFAP_HOME'] + '/tmp/' + file_name,"wb") if out_file == None: return AfaFlowControl.ExitThisFlow("S999", "生成打印文件异常") AfaLoggerFunc.tradeInfo(">>>>>>开始赋值") print >> out_file,txt % {'BESBNM':(sub['BESBNM']).ljust(10,' '),\ 'BJEDTE':(TradeContext.BJEDTE).ljust(8,' '),\ 'BSPSQN':(TradeContext.BSPSQN).ljust(12,' '),\ 'SNDBNKCO':(TradeContext.SNDBNKCO).ljust(10,' '),\ 'RCVBNKCO':(TradeContext.RCVBNKCO).ljust(10,' '),\ 'BILDAT':(TradeContext.BILDAT).ljust(8,' '),\ 'BILAMT':(TradeContext.BILAMT).ljust(15,' '),\ 'BILNO':(TradeContext.BILNO).ljust(16,' '),\ 'PYRACC':(TradeContext.PYRACC).ljust(32,' '),\ 'PYRNAM':(TradeContext.PYRNAM).ljust(60,' '),\ 'PYEACC':(TradeContext.PYEACC).ljust(32,' '),\ 'PYENAM':(TradeContext.PYENAM).ljust(60,' '),\ 'CONT1':(TradeContext.CONT[:68]).ljust(68,' '),\ 'CONT2':(TradeContext.CONT[68:138]).ljust(70,' '),\ 'CONT3':(TradeContext.CONT[138:208]).ljust(70,' '),\ 'CONT4':(TradeContext.CONT[208:]).ljust(70,' ')} AfaLoggerFunc.tradeInfo(">>>>>>结束赋值") out_file.close TradeContext.PBDAFILE = file_name AfaLoggerFunc.tradeInfo("结束生成打印文本") AfaLoggerFunc.tradeInfo("结束交易后处理") return True
+ records[i]['ORTRCDAT'] + "|" \ + records[i]['ORTRCNO'] + "|" \ + records[i]['ORSNDBNK'] + "|" \ + records[i]['ORRCVBNK'] + "|" \ + "" + "|" + "" + "|" + "" + "|" + "" + "|" \ + records[i]['STRINFO'] + "|" \ + state_dict['BCSTAT'] + "|" \ + state_dict['BDWFLG'] + "|" \ + records[i]['BOJEDT'] + "|" \ + records[i]['BOSPSQ'] + "|" \ + records[i]['CHRGTYP'] + "|" \ + str(records[i]['LOCCUSCHRG']) + "|" f.write(filecontext+"\n") f.close() AfaLoggerFunc.tradeInfo(">>>生成文件结束") except Exception, e: #=====关闭文件==== f.close() return AfaFlowControl.ExitThisFlow('A099','写入返回文件失败' ) #=====输出接口赋值==== TradeContext.RECCOUNT=str(len(records)) #查询笔数 TradeContext.errorCode="0000" #返回码 TradeContext.errorMsg="成功" #返回信息 TradeContext.PBDAFILE=filename #文件名 AfaLoggerFunc.tradeInfo( '***农信银系统: 往账.本地类操作交易[RCC001_8524]退出***' ) return True
############################################################################### # -*- coding: gbk -*- import TradeContext TradeContext.sysType = 'cron' import os, AfaLoggerFunc, ConfigParser, AfaUtilTools, sys, AfaDBFunc, AfaAdminFunc from types import * if __name__ == '__main__': for i in range(100000): AfaLoggerFunc.tradeInfo( '*****asfdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf') AfaLoggerFunc.tradeInfo( '*****asfdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf') AfaLoggerFunc.tradeInfo( '*****asfdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf') AfaLoggerFunc.tradeInfo( '*****asfdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf') AfaLoggerFunc.tradeInfo( '*****asfdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf') AfaLoggerFunc.tradeInfo( '*****asfdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf') AfaLoggerFunc.tradeInfo( '*****asfdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf') AfaLoggerFunc.tradeInfo( '*****asfdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf') AfaLoggerFunc.tradeInfo( '*****asfdasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf')
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo("进入汇票查询书录入 1.本地操作 ") #====begin 蔡永贵 20110215 增加==== #新票据号是16位,需要取后8位,版本号为02,同时要兼容老票据号8位,版本号为01 if TradeContext.BILVER == '02': TradeContext.TMP_BILNO = TradeContext.BILNO[-8:] else: TradeContext.TMP_BILNO = TradeContext.BILNO #============end============ #=====查询汇票信息===== # where_dict_bilinf = {'BILVER':TradeContext.BILVER,'BILNO':TradeContext.BILNO,'BILRS':PL_BILRS_OUT} # res_bilinf = rccpsDBTrcc_bilinf.selectu(where_dict_bilinf) # if( res_bilinf == None ): # return AfaFlowControl.ExitThisFlow("S999", "查询汇票信息失败") # # if( len(res_bilinf) == 0 ): # return AfaFlowControl.ExitThisFlow("S999", "查询汇票信息为空") # #=====查询行名行号==== # where_dict_paybnk = {'BANKBIN':TradeContext.BESBNO} # res_paybnk = rccpsDBTrcc_paybnk.selectu(where_dict_paybnk) # if( res_paybnk == None ): # return AfaFlowControl.ExitThisFlow("S999", "查询行名行号失败") # # if( len(res_paybnk) == 0 ): # return AfaFlowControl.ExitThisFlow("S999", "查询行名行号为空") # #=====登记查询书信息==== AfaLoggerFunc.tradeInfo("开始登记查询书信息") TradeContext.BRSFLG = PL_BRSFLG_SND TradeContext.NCCWKDAT = TradeContext.NCCworkDate TradeContext.TRCNO = TradeContext.SerialNo # TradeContext.SNDBNKCO = TradeContext.BESBNO # TradeContext.SNDBNKNM = res_paybnk['BANKNAM'] # TradeContext.RCVBNKCO = res_bilinf['PAYBNKCO'] # TradeContext.RCVBNKNM = res_bilinf['PAYBNKNM'] TradeContext.BOJEDT = "" TradeContext.BOSPSQ = "" TradeContext.ORTRCCO = "" #TradeContext.TRCDAT = TradeContext.BJEDTE # TradeContext.BILDAT = res_bilinf['BILDAT'] # TradeContext.PAYWAY = res_bilinf['PAYWAY'] # TradeContext.CUR = res_bilinf['CUR'] # TradeContext.BILAMT = str(res_bilinf['BILAMT']) # TradeContext.PYRACC = res_bilinf['PYRACC'] # TradeContext.PYRNAM = res_bilinf['PYRNAM'] # TradeContext.PYEACC = res_bilinf['PYEACC'] # TradeContext.PYENAM = res_bilinf['PYENAM'] TradeContext.ISDEAL = PL_ISDEAL_UNDO TradeContext.PRCCO = "" TradeContext.SNDMBRCO = TradeContext.SNDSTLBIN TradeContext.RCVMBRCO = TradeContext.RCVSTLBIN hpcbka_insert_dict = {} if not rccpsMap8516CTradeContext2Dhpcbka_dict.map(hpcbka_insert_dict): return AfaFlowControl.ExitThisFlow("S999", "为汇票查询查复登记薄赋值失败") ret = rccpsDBTrcc_hpcbka.insertCmt(hpcbka_insert_dict) if( ret <= 0 ): return AfaFlowControl.ExitThisFlow("S999", "为汇票查询查复登记薄赋值异常") AfaLoggerFunc.tradeInfo("结束登记查询书信息") #=====为汇票查询书报文赋值==== AfaLoggerFunc.tradeInfo("开始为汇票查询书报文赋值") #=====报文头==== TradeContext.MSGTYPCO = 'SET008' TradeContext.SNDBRHCO = TradeContext.BESBNO TradeContext.SNDCLKNO = TradeContext.BETELR TradeContext.SNDTRDAT = TradeContext.BJEDTE TradeContext.SNDTRTIM = TradeContext.BJETIM TradeContext.MSGFLGNO = TradeContext.SNDSTLBIN + TradeContext.TRCDAT + TradeContext.SerialNo TradeContext.NCCWKDAT = TradeContext.NCCworkDate TradeContext.OPRTYPNO = '99' TradeContext.ROPRTPNO = '21' TradeContext.TRANTYP = '0' #=====扩展数据==== TradeContext.TRCCO = '9900526' # TradeContext.BILDAT = res_bilinf['BILDAT'] # TradeContext.BILAMT = str(res_bilinf['BILAMT']) #=====给前台接口赋值==== TradeContext.BILENDDT = "" #先这么放着 AfaLoggerFunc.tradeInfo("结束为汇票查询书报文赋值") return True
# 公司名称: 北京赞同科技有限公司 # 作 者: 关彬捷 # 修改时间: 2008-06-27 ################################################################################ import TradeContext TradeContext.sysType = 'cron' import AfaLoggerFunc,AfaUtilTools,AfaDBFunc,TradeFunc,AfaFlowControl,os,AfaFunc,sys from types import * from rccpsConst import * import rccpsCronFunc import rccpsDBTrcc_mbrifa if __name__ == '__main__': try: AfaLoggerFunc.tradeInfo("***农信银系统: 系统调度类.汇票对账明细账勾兑[rccpshpdzMXCompare]进入***") #==========获取中心日期================================================ AfaLoggerFunc.tradeInfo(">>>开始获取前中心工作日期") mbrifa_where_dict = {} mbrifa_where_dict['OPRTYPNO'] = "20" mbrifa_dict = rccpsDBTrcc_mbrifa.selectu(mbrifa_where_dict) if mbrifa_dict == None: AfaLoggerFunc.tradeInfo( AfaDBFunc.sqlErrMsg ) rccpsCronFunc.cronExit("S999","查询当前中心日期异常") NCCWKDAT = mbrifa_dict['NOTE1'][:8] #对账日期 LNCCWKDAT = "('" + mbrifa_dict['NOTE4'].replace(",","','") + "')" #需要对账的中心日期(包括本清算工作日和之前的非清算工作日)
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统: 往账.本地类操作交易[RCC001_8524]进入***' ) #=====判断输入接口值是否存在==== if( not TradeContext.existVariable( "STRDAT" ) ): return AfaFlowControl.ExitThisFlow('A099','起始日期[STRDAT]不存在' ) if( not TradeContext.existVariable( "ENDDAT" ) ): return AfaFlowControl.ExitThisFlow('A099','终止日期[ENDDAT]不存在' ) if( not TradeContext.existVariable( "BRSFLG" ) ): return AfaFlowControl.ExitThisFlow('A099','往来标志[BRSFLG]不存在' ) #=====组织查询sql语句==== AfaLoggerFunc.tradeInfo( "组织查询语句") if(TradeContext.BESBNO == "3400008889" and TradeContext.RCVBNKCO != ""): sql= "BJEDTE >='"+TradeContext.STRDAT+"' and BJEDTE <='" sql= sql + TradeContext.ENDDAT + "'" else: sql= "BESBNO='" + TradeContext.BESBNO + "' " sql= sql + "and BJEDTE >='"+TradeContext.STRDAT+"' and BJEDTE <='" sql= sql + TradeContext.ENDDAT + "'" if(TradeContext.BRSFLG != ""): sql= sql + " and BRSFLG='"+TradeContext.BRSFLG+"'" AfaLoggerFunc.tradeDebug( "1.sql=" + sql ) #=====判断其它查询条件是否存在==== if(TradeContext.OPRNO != ""): #业务属性 sql = sql + " and OPRNO='" + TradeContext.OPRNO + "'" if(TradeContext.OPRATTNO != ""): #业务属性 sql = sql + " and OPRATTNO='" + TradeContext.OPRATTNO + "'" if(TradeContext.BSPSQN != ""): #报单序号 sql = sql + " and BSPSQN='" + TradeContext.BSPSQN + "'" if(float(TradeContext.OCCAMT) != 0.0): #交易金额 sql = sql + " and OCCAMT=" + TradeContext.OCCAMT if(TradeContext.RCVBNKCO != ""): #接收行号 sql = sql + " and RCVBNKCO='" + TradeContext.RCVBNKCO + "'" if(TradeContext.BCSTAT != ""): #交易状态 if(TradeContext.BDWFLG!= ""): #流转标志 sql = sql + " and exists (select * from RCC_SPBSTA where " sql = sql + " BJEDTE = RCC_TRCBKA.BJEDTE" sql = sql + " and BSPSQN = RCC_TRCBKA.BSPSQN" sql = sql + " and BCSTAT = '" + TradeContext.BCSTAT + "'" sql = sql + " and BDWFLG='" + TradeContext.BDWFLG + "')" else: sql = sql + " and exists (select * from RCC_SPBSTA tab2 where " sql = sql + " BJEDTE = RCC_TRCBKA.BJEDTE" sql = sql + " and BSPSQN = RCC_TRCBKA.BSPSQN" sql = sql + " and BCSTAT = '" + TradeContext.BCSTAT + "')" AfaLoggerFunc.tradeDebug( "sql=" + sql ) #=====开始查询总笔数==== TradeContext.RECALLCOUNT=str(rccpsDBTrcc_trcbka.count(sql)) #总记录笔数 AfaLoggerFunc.tradeDebug( '>>>总笔数=' + TradeContext.RECALLCOUNT ) #=====查询数据库==== ordersql=" order by BJEDTE DESC,BSPSQN DESC" #组织按降序排列排序 AfaLoggerFunc.tradeInfo("查询条件为:"+sql) records=rccpsDBTrcc_trcbka.selectm(TradeContext.RECSTRNO,10,sql,ordersql) if(records==None): return AfaFlowControl.ExitThisFlow('A099','查询失败' ) elif(len(records)==0): return AfaFlowControl.ExitThisFlow('A099','没有查找到记录' ) else: try: #=====打开文件==== AfaLoggerFunc.tradeInfo(">>>生成文件") filename="rccps_"+TradeContext.BETELR+"_"+AfaUtilTools.GetHostDate()+"_"+TradeContext.TransCode fpath=os.environ["AFAP_HOME"]+"/tmp/" f=open(fpath+filename,"w") #=====PL_HDOPRNO_TH 09 退汇==== if(TradeContext.OPRNO==PL_HDOPRNO_TH): AfaLoggerFunc.tradeInfo(">>>进入退汇处理") #=====得到文件内容,生成文件==== for i in range(0,len(records)): #=====得到业务状态BCSTAT==== state_dict={} ret=rccpsState.getTransStateCur(records[i]['BJEDTE'],records[i]['BSPSQN'],state_dict) if(ret==False): return AfaFlowControl.ExitThisFlow( 'S999', '当前状态登记簿中无此交易状态' ) #=====写文件操作==== filecontext = records[i]['BJEDTE'] + "|" \ + records[i]['BSPSQN'] + "|" \ + records[i]['BRSFLG'] + "|" \ + records[i]['BESBNO'] + "|" \ + records[i]['BEACSB'] + "|" \ + records[i]['BETELR'] + "|" \ + records[i]['BEAUUS'] + "|" \ + records[i]['TRCCO'] + "|" \ + records[i]['OPRNO'] + "|" \ + records[i]['OPRATTNO'] + "|" \ + records[i]['TRCDAT'] + "|" \ + records[i]['TRCNO'] + "|" \ + records[i]['SNDBNKCO'] + "|" \ + records[i]['SNDBNKNM'] + "|" \ + records[i]['RCVBNKCO'] + "|" \ + records[i]['RCVBNKNM'] + "|" \ + records[i]['CUR'] + "|" \ + str(records[i]['OCCAMT']) + "|" \ + records[i]['PYRACC'] + "|" \ + records[i]['PYRNAM'] + "|" \ + records[i]['PYRADDR'] + "|" \ + records[i]['PYEACC'] + "|" \ + records[i]['PYENAM'] + "|" \ + records[i]['PYEADDR'] + "|" \ + records[i]['USE'] + "|" \ + records[i]['REMARK'] + "|" \ + records[i]['BILTYP'] + "|" \ + records[i]['BILDAT'] + "|" \ + records[i]['BILNO'] + "|" \ + str(records[i]['COMAMT']) + "|" \ + str(records[i]['OVPAYAMT']) + "|" \ + str(records[i]['CPSAMT']) + "|" \ + str(records[i]['RFUAMT']) + "|" \ + records[i]['CERTTYPE'] + "|" \ + records[i]['CERTNO'] + "|" \ + records[i]['ORTRCCO'] + "|" \ + records[i]['ORTRCDAT'] + "|" \ + records[i]['ORTRCNO'] + "|" \ + records[i]['ORSNDBNK'] + "|" \ + records[i]['ORRCVBNK'] + "|" \ + records[i]['PYRACC'] + "|" \ + records[i]['PYRNAM'] + "|" \ + records[i]['PYEACC'] + "|" \ + records[i]['PYENAM'] + "|" \ + records[i]['STRINFO'] + "|" \ + state_dict['BCSTAT'] + "|" \ + state_dict['BDWFLG'] + "|" \ + records[i]['BOJEDT'] + "|" \ + records[i]['BOSPSQ'] + "|" \ + records[i]['CHRGTYP'] + "|" \ + str(records[i]['LOCCUSCHRG']) + "|" f.write(filecontext+"\n") #=====非退汇==== else: AfaLoggerFunc.tradeInfo(">>>进入非退汇处理") for i in range(len(records)): #=====得到业务状态BCSTAT==== state_dict={} ret=rccpsState.getTransStateCur(records[i]['BJEDTE'],records[i]['BSPSQN'],state_dict) if(state_dict==False): return AfaFlowControl.ExitThisFlow( 'S999', '当前状态登记簿中无此交易状态' ) #=====写文件操作==== filecontext = records[i]['BJEDTE'] + "|" \ + records[i]['BSPSQN'] + "|" \ + records[i]['BRSFLG'] + "|" \ + records[i]['BESBNO'] + "|" \ + records[i]['BEACSB'] + "|" \ + records[i]['BETELR'] + "|" \ + records[i]['BEAUUS'] + "|" \ + records[i]['TRCCO'] + "|" \ + records[i]['OPRNO'] + "|" \ + records[i]['OPRATTNO'] + "|" \ + records[i]['TRCDAT'] + "|" \ + records[i]['TRCNO'] + "|" \ + records[i]['SNDBNKCO'] + "|" \ + records[i]['SNDBNKNM'] + "|" \ + records[i]['RCVBNKCO'] + "|" \ + records[i]['RCVBNKNM'] + "|" \ + records[i]['CUR'] + "|" \ + str(records[i]['OCCAMT'])+ "|" \ + records[i]['PYRACC'] + "|" \ + records[i]['PYRNAM'] + "|" \ + records[i]['PYRADDR'] + "|" \ + records[i]['PYEACC'] + "|" \ + records[i]['PYENAM'] + "|" \ + records[i]['PYEADDR'] + "|" \ + records[i]['USE'] + "|" \ + records[i]['REMARK'] + "|" \ + records[i]['BILTYP'] + "|" \ + records[i]['BILDAT'] + "|" \ + records[i]['BILNO'] + "|" \ + str(records[i]['COMAMT'])+ "|" \ + str(records[i]['OVPAYAMT'])+"|" \ + str(records[i]['CPSAMT'])+ "|" \ + str(records[i]['RFUAMT'])+ "|" \ + records[i]['CERTTYPE'] + "|" \ + records[i]['CERTNO'] + "|" \ + records[i]['ORTRCCO'] + "|" \ + records[i]['ORTRCDAT'] + "|" \ + records[i]['ORTRCNO'] + "|" \ + records[i]['ORSNDBNK'] + "|" \ + records[i]['ORRCVBNK'] + "|" \ + "" + "|" + "" + "|" + "" + "|" + "" + "|" \ + records[i]['STRINFO'] + "|" \ + state_dict['BCSTAT'] + "|" \ + state_dict['BDWFLG'] + "|" \ + records[i]['BOJEDT'] + "|" \ + records[i]['BOSPSQ'] + "|" \ + records[i]['CHRGTYP'] + "|" \ + str(records[i]['LOCCUSCHRG']) + "|" f.write(filecontext+"\n") f.close() AfaLoggerFunc.tradeInfo(">>>生成文件结束") except Exception, e: #=====关闭文件==== f.close() return AfaFlowControl.ExitThisFlow('A099','写入返回文件失败' ) #=====输出接口赋值==== TradeContext.RECCOUNT=str(len(records)) #查询笔数 TradeContext.errorCode="0000" #返回码 TradeContext.errorMsg="成功" #返回信息 TradeContext.PBDAFILE=filename #文件名
def QueryBatchInfo(): sqlwhere = "WHERE BATCHNO > '" + TradeContext.batchNo + "'" if TradeContext.ZONENO == "0000": #总行 if (len(TradeContext.brno)==6): #查询联社批次 sqlwhere = sqlwhere + " AND SUBSTR(BRNO,1,6) = '" + TradeContext.brno + "'" elif (len(TradeContext.brno)==0): #查询全部批次 pass else: #查询机构批次 sqlwhere = sqlwhere + " AND BRNO = '" + TradeContext.brno + "'" else: #分行 if(len(TradeContext.brno)==6): #查询联社批次 sqlwhere = sqlwhere + " AND SUBSTR(BRNO,1,6) = '" + TradeContext.brno + "'" else: #查询机构批次 sqlwhere = sqlwhere + " AND BRNO = '" + TradeContext.brno + "'" if(len(TradeContext.trxDate)!=0): sqlwhere = sqlwhere + " AND INDATE = '" + TradeContext.trxDate + "'" if(len(TradeContext.trxState)==0 or TradeContext.trxState=='00' ): sqlwhere = sqlwhere + " AND STATUS IN ('10','11','20','21','22','30','31','32','40','88')" else: sqlwhere = sqlwhere + " AND STATUS = '" + TradeContext.trxState + "'" sqlwhere = sqlwhere + " ORDER BY BATCHNO" sql = "SELECT BATCHNO,APPNO,BUSINO,BRNO,USERNO,TERMTYPE,FILENAME,INDATE,INTIME,BATCHDATE,BATCHTIME,TOTALNUM" sql = sql + ",TOTALAMT,SUCCNUM,SUCCAMT,FAILNUM,FAILAMT,STATUS,BEGINDATE,ENDDATE,PROCMSG FROM ABDT_BATCHINFO " + sqlwhere AfaLoggerFunc.tradeInfo(sql) records = AfaDBFunc.SelectSql( sql ) if (records == None): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return ExitSubTrade( '9999', '查询批次信息异常' ) if (len(records)==0) : return ExitSubTrade( '9000', '没有任何批次信息' ) ############################################################################################################# TradeContext.retData = "" TradeContext.retTotalNum = len(records) if(len(records)>3): TradeContext.retQueryNum = 3 else: TradeContext.retQueryNum = len(records) for i in range(0,TradeContext.retQueryNum): TradeContext.retData = TradeContext.retData + records[i][0] #批次号 TradeContext.retData = TradeContext.retData +"|" sql = "SELECT APPNAME,BUSINAME FROM ABDT_UNITINFO WHERE " sql = sql + "APPNO=" + "'" + records[i][1] + "'" + " AND " #业务编号 sql = sql + "BUSINO=" + "'" + records[i][2] + "'" + " AND " #单位编号 sql = sql + "STATUS=" + "'" + "1" + "'" #状态(0:注销,1:正常) name_records = AfaDBFunc.SelectSql( sql ) if ( len(name_records) != 0 ): TradeContext.retData = TradeContext.retData + records[i][1] + ' - ' + name_records[0][0] #业务编号 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][2] + ' - ' + name_records[0][1] #单位编号 TradeContext.retData = TradeContext.retData +"|" else: TradeContext.retData = TradeContext.retData + records[i][1] #业务编号 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][2] #单位编号 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][3] #机构号 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][4] #操作员 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][5] #上传方式 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][6] #上传文件名 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][7] #委托日期 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][8] #委托时间 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][9] #提交日期 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][10] #提交时间 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][11] #总笔数 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][12] #总金额 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][13] #成功笔数 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][14] #成功金额 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][15] #失败笔数 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][16] #失败金额 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][17] #状态 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][18] #生效日期 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][19] #失效日期 TradeContext.retData = TradeContext.retData +"|" TradeContext.retData = TradeContext.retData + records[i][20] #处理信息 TradeContext.retData = TradeContext.retData +"|" AfaLoggerFunc.tradeInfo(records[i][0] + '|' + records[i][1] + "|" + records[i][2] + "|" + records[i][3] + "|") TradeContext.RETDATA = TradeContext.retData TradeContext.RETTOTALNUM = str(TradeContext.retTotalNum) TradeContext.RETQUERYNUM = str(TradeContext.retQueryNum) return True
def SubModuleDoFst(): #==========判断是否重复报文,如果是重复报文,直接进入下一流程================ AfaLoggerFunc.tradeInfo(">>>开始检查是否重复报文") hdcbka_where_dict = {} hdcbka_where_dict['SNDBNKCO'] = TradeContext.SNDBNKCO hdcbka_where_dict['TRCDAT'] = TradeContext.ORTRCDAT hdcbka_where_dict['TRCNO'] = TradeContext.TRCNO hdcbka_dict = rccpsDBTrcc_hdcbka.selectu(hdcbka_where_dict) if hdcbka_dict == None: return AfaFlowControl.ExitThisFlow("S999","校验重复报文异常") if len(hdcbka_dict) > 0: AfaLoggerFunc.tradeInfo("汇兑查询查复自由格式登记簿中存在相同查复交易,此报文为重复报文,进入下一流程,发送表示成功的通讯回执") #======为通讯回执报文赋值=============================================== out_context_dict = {} out_context_dict['sysType'] = 'rccpst' out_context_dict['TRCCO'] = '9900503' out_context_dict['MSGTYPCO'] = 'SET008' out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO out_context_dict['SNDBRHCO'] = TradeContext.BESBNO out_context_dict['SNDCLKNO'] = TradeContext.BETELR out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE out_context_dict['SNDTRTIM'] = TradeContext.BJETIM out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo out_context_dict['ORMFN'] = TradeContext.MSGFLGNO out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate out_context_dict['OPRTYPNO'] = '99' out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO out_context_dict['TRANTYP'] = '0' out_context_dict['ORTRCCO'] = TradeContext.TRCCO out_context_dict['PRCCO'] = 'RCCI0000' out_context_dict['STRINFO'] = '重复报文' rccpsMap0000Dout_context2CTradeContext.map(out_context_dict) TradeContext.SNDSTLBIN = TradeContext.RCVMBRCO #发起成员行号 return True AfaLoggerFunc.tradeInfo(">>>结束检查是否重复报文") #==========为汇兑查询查复自由格式登记簿字典赋值================================ AfaLoggerFunc.tradeInfo(">>>开始为汇兑查询查复自由格式登记簿字典赋值") TradeContext.ISDEAL = PL_ISDEAL_ISDO hdcbka_insert_dict = {} if not rccpsMap1129CTradeContext2Dhdcbka_dict.map(hdcbka_insert_dict): return AfaFlowControl.ExitThisFlow("S999","为汇兑查询查复自由格式登记簿字典赋值异常") AfaLoggerFunc.tradeInfo(">>>结束为汇兑查询查复自由格式登记簿字典赋值") #==========登记汇兑查询查复自由格式登记簿======================================= AfaLoggerFunc.tradeInfo(">>>开始登记此自由格式书") ret = rccpsDBTrcc_hdcbka.insert(hdcbka_insert_dict) if ret <= 0: AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow("S999","登记汇兑查询查复自由格式登记簿异常") AfaDBFunc.CommitSql() AfaLoggerFunc.tradeInfo(">>>结束登记此自由格式书业务") #======为通讯回执报文赋值=================================================== out_context_dict = {} out_context_dict['sysType'] = 'rccpst' out_context_dict['TRCCO'] = '9900503' out_context_dict['MSGTYPCO'] = 'SET008' out_context_dict['RCVMBRCO'] = TradeContext.SNDMBRCO out_context_dict['SNDMBRCO'] = TradeContext.RCVMBRCO out_context_dict['SNDBRHCO'] = TradeContext.BESBNO out_context_dict['SNDCLKNO'] = TradeContext.BETELR out_context_dict['SNDTRDAT'] = TradeContext.BJEDTE out_context_dict['SNDTRTIM'] = TradeContext.BJETIM out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo out_context_dict['ORMFN'] = TradeContext.MSGFLGNO out_context_dict['NCCWKDAT'] = TradeContext.NCCworkDate out_context_dict['OPRTYPNO'] = '99' out_context_dict['ROPRTPNO'] = TradeContext.OPRTYPNO out_context_dict['TRANTYP'] = '0' out_context_dict['ORTRCCO'] = TradeContext.TRCCO out_context_dict['PRCCO'] = 'RCCI0000' out_context_dict['STRINFO'] = '成功' rccpsMap0000Dout_context2CTradeContext.map(out_context_dict) TradeContext.SNDSTLBIN = TradeContext.RCVMBRCO #发起成员行号 return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.中心类操作(1.本地操作).通存通兑查复书发送[TRC003_8584]进入***' ) #=================查询原查复信息============================================ if not TradeContext.existVariable('ORQYDAT'): return AfaFlowControl.ExitThisFlow("S999", "原查询日期不能为空") if not TradeContext.existVariable('OQTNO'): return AfaFlowControl.ExitThisFlow("S999", "原查询号不能为空") AfaLoggerFunc.tradeInfo(">>>开始查询原查询书信息") hdcbka_dict = {} hdcbka_where_dict = {'BJEDTE':TradeContext.ORQYDAT,'BSPSQN':TradeContext.OQTNO} hdcbka_dict = rccpsDBTrcc_hdcbka.selectu(hdcbka_where_dict) if hdcbka_dict == None: return AfaFlowControl.ExitThisFlow("S999","数据库操作失败") if len(hdcbka_dict) > 0: if hdcbka_dict['ISDEAL'] == PL_ISDEAL_ISDO: #PL_ISDEAL_ISDO 已查复或已处理 return AfaFlowControl.ExitThisFlow("S999","该查询已被查复") AfaLoggerFunc.tradeInfo(">>>开始查询通存通兑原交易信息") wtrbka_dict = {} ret = rccpsDBFunc.getTransWtr(hdcbka_dict['BOJEDT'],hdcbka_dict['BOSPSQ'],wtrbka_dict) if not ret: return False AfaLoggerFunc.tradeInfo(">>>结束查询数据库信息") #=================登记查复书信息============================================ AfaLoggerFunc.tradeInfo(">>>开始登记通存通兑业务查复书信息") # RCVBNKCO=TradeContext.RCVBNKCO # TradeContext.RCVBNKCO = hdcbka_dict['SNDBNKCO'] # TradeContext.RCVBNKNM = hdcbka_dict['SNDBNKNM'] 注释于0724 by pgt TradeContext.NCCWKDAT = TradeContext.NCCworkDate TradeContext.ISDEAL = PL_ISDEAL_ISDO #查复标识为已处理 TradeContext.BOJEDT = TradeContext.ORQYDAT #原交易日期 TradeContext.BOSPSQ = TradeContext.OQTNO #原报单序号 TradeContext.ORTRCCO = hdcbka_dict['TRCCO'] #原交易码 TradeContext.CUR = hdcbka_dict['CUR'] #币种 TradeContext.OCCAMT = str(wtrbka_dict['OCCAMT']) #交易金额 TradeContext.PYRACC = wtrbka_dict['PYRACC'] #付款人账号 TradeContext.PYEACC = wtrbka_dict['PYEACC'] #收款人账号 TradeContext.NOTE1 = hdcbka_dict['NOTE1'] TradeContext.NOTE2 = hdcbka_dict['NOTE2'] TradeContext.NOTE3 = hdcbka_dict['NOTE3'] TradeContext.NOTE4 = hdcbka_dict['NOTE4'] TradeContext.PRT_OROCCAMT = wtrbka_dict['OCCAMT'] hdcbka_insert_dict = {} if not rccpsMap8512CTradeContext2Dhdcbka.map(hdcbka_insert_dict): return AfaFlowControl.ExitThisFlow("S999", "为汇兑业务查询查复登记簿赋值异常") ret = rccpsDBTrcc_hdcbka.insertCmt(hdcbka_insert_dict) if ret <= 0: return AfaFlowControl.ExitThisFlow("S999", "登记汇兑业务查复书信息异常") AfaLoggerFunc.tradeInfo(">>>结束登记汇兑业务查复书信息") #=================为汇兑查询书报文赋值====================================== AfaLoggerFunc.tradeInfo(">>>开始为汇兑查复书报文赋值") TradeContext.TRCCO = '9900512' TradeContext.MSGTYPCO = 'SET008' TradeContext.SNDBRHCO = TradeContext.BESBNO TradeContext.SNDCLKNO = TradeContext.BETELR TradeContext.SNDTRDAT = TradeContext.BJEDTE TradeContext.SNDTRTIM = TradeContext.BJETIM TradeContext.MSGFLGNO = TradeContext.SNDSTLBIN + TradeContext.TRCDAT + TradeContext.SerialNo TradeContext.ORMFN = TradeContext.RCVSTLBIN + hdcbka_dict['TRCDAT'] + hdcbka_dict['TRCNO'] TradeContext.NCCWKDAT = TradeContext.NCCworkDate TradeContext.OPRTYPNO = '99' TradeContext.ROPRTPNO = '99' TradeContext.TRANTYP = '0' TradeContext.TRCDAT = TradeContext.TRCDAT TradeContext.TRCNO = TradeContext.SerialNo TradeContext.ORTRCDAT = wtrbka_dict['TRCDAT'] TradeContext.ORTRCNO = wtrbka_dict['TRCNO'] TradeContext.ORSNDBNK = wtrbka_dict['SNDBNKCO'] TradeContext.ORRCVBNK = wtrbka_dict['RCVBNKCO'] TradeContext.ORTRCCO = hdcbka_dict['TRCCO'] TradeContext.ORCUR = TradeContext.CUR TradeContext.OROCCAMT = str(hdcbka_dict['OCCAMT']) TradeContext.ORQYDAT = hdcbka_dict['TRCDAT'] TradeContext.OQTSBNK = hdcbka_dict['SNDBNKCO'] TradeContext.OQTNO = hdcbka_dict['TRCNO'] AfaLoggerFunc.tradeInfo(">>>结束为汇兑查复书报文赋值") return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统: 通存通兑.本地类操作交易[RCC003_8562]进入***' ) #检查本机构是否有通存通兑业务权限 if not rccpsDBFunc.chkTDBESAuth(TradeContext.BESBNO): return AfaFlowControl.ExitThisFlow("S999","本机构无通存通兑业务权限") #=====接收行判断==== if TradeContext.SNDSTLBIN == TradeContext.RCVSTLBIN: return AfaFlowControl.ExitThisFlow('S999','同一清算行不允许做此业务') #=====账户类型判断==== if not TradeContext.existVariable('PYRTYP'): return AfaFlowControl.ExitThisFlow('S999','账户类型不存在[PYRTYP]') if TradeContext.PYRTYP == '0': #=====银行卡==== if len(TradeContext.PYRNAM) == 0: return AfaFlowControl.ExitThisFlow('S999','付款人名称[PYRNAM]不允许为空') if len(TradeContext.SCTRKINF) == 0: return AfaFlowControl.ExitThisFlow('S999','二磁道[SCTRKINF]信息不允许为空') #if len(TradeContext.THTRKINF) == 0: # return AfaFlowControl.ExitThisFlow('S999','三磁道[THTRKINF]信息不允许为空') if len(TradeContext.SCTRKINF) > 37: return AfaFlowControl.ExitThisFlow('S999','磁道信息非法') #if len(TradeContext.THTRKINF) > 104: # return AfaFlowControl.ExitThisFlow('S999','磁道信息非法') elif TradeContext.PYRTYP == '1': #=====存折==== if len(TradeContext.BNKBKNO) == 0: return AfaFlowControl.ExitThisFlow('S999','存折号码[BNKBKNO]不允许为空') if float(TradeContext.BNKBKBAL) == 0.0: return AfaFlowControl.ExitThisFlow('S999','存折余额[BNKBKBAL]不允许为空') TradeContext.SCTRKINF = ''.rjust(37,'0') TradeContext.THTRKINF = ''.rjust(37,'0') else: return AfaFlowControl.ExitThisFlow('S999','账户类型错误') #=====交易金额判断==== sel_dict = {} sel_dict['BPARAD'] = 'TD001' #通存通兑凭证金额校验 dict = rccpsDBTrcc_pamtbl.selectu(sel_dict) AfaLoggerFunc.tradeInfo('dict='+str(dict)) if dict == None: return AfaFlowControl.ExitThisFlow('S999','校验交易金额失败') if len(dict) == 0: return AfaFlowControl.ExitThisFlow('S999','查询PAMTBL校验交易金额表记录错误') #=====判断农信银中心规定校验凭证上线==== if float(TradeContext.OCCAMT) >= float(dict['BPADAT']): #=====交易金额大于农信银中心规定金额,需要输入证件==== if TradeContext.existVariable('CERTTYPE') and len(TradeContext.CERTTYPE) == 0: return AfaFlowControl.ExitThisFlow('S999','请选择证件类型!') if TradeContext.existVariable('CERTNO') and len(TradeContext.CERTNO) == 0: return AfaFlowControl.ExitThisFlow('S999','请输入证件号码!') #加密客户密码 MIMA = ' ' #PIN = '888888' #ACC = '12311111111111111111111111111111' PIN = TradeContext.CURPIN ACC = TradeContext.PYRACC AfaLoggerFunc.tradeDebug('密码[' + PIN + ']') AfaLoggerFunc.tradeDebug('账号[' + ACC + ']') ret = jiami.secEncryptPin(PIN,ACC,MIMA) if ret != 0: AfaLoggerFunc.tradeDebug("ret=[" + str(ret) + "]") return AfaFlowControl.ExitThisFlow('M9999','调用加密服务器失败') else: TradeContext.CURPIN = MIMA AfaLoggerFunc.tradeDebug('密码new[' + TradeContext.CURPIN + ']') #=====字段赋值==== TradeContext.OPRNO = PL_TDOPRNO_TD #业务种类 TradeContext.DCFLG = PL_DCFLG_DEB #借贷标识 #=====字典赋值,插入数据库==== wtrbka_dict = {} if not rccpsMap8562CTradeContext2Dwtrbka_dict.map(wtrbka_dict): return AfaFlowControl.ExitThisFlow('S999','字典赋值错误!') wtrbka_dict['MSGFLGNO'] = TradeContext.SNDSTLBIN + TradeContext.TRCDAT + TradeContext.SerialNo #报文标识号 #=====插入数据库表==== if not rccpsDBFunc.insTransWtr(wtrbka_dict): return AfaFlowControl.ExitThisFlow('S999','登记通存通兑业务登记簿异常') AfaDBFunc.CommitSql( ) #=====设置业务状态为发送处理中==== AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送处理中") stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE #交易日期 stat_dict['BSPSQN'] = TradeContext.BSPSQN #报单序号 stat_dict['BCSTAT'] = PL_BCSTAT_SND #PL_BCSTAT_SND 发送 stat_dict['BDWFLG'] = PL_BDWFLG_WAIT #PL_BDWFLG_WAIT 处理中 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(">>>结束设置业务状态为发送处理中") #=====发送农信银中心==== AfaLoggerFunc.tradeInfo(">>>开始发送农信银中心处理") TradeContext.MSGTYPCO = 'SET004' #报文类代码 TradeContext.OPRTYPNO = '30' #通存通兑 #=====根据手续费收取方式判断是否发送农信银中心==== TradeContext.sCuschrg = TradeContext.CUSCHRG if TradeContext.CHRGTYP != PL_CHRG_TYPE: #PL_CHRG_TYPE 1 转账 #=====转账收取手续费==== TradeContext.CUSCHRG = '0.0' AfaLoggerFunc.tradeDebug(">>>结束发送农信银中心处理") AfaLoggerFunc.tradeInfo( '***农信银系统: 通存通兑.本地类操作交易[RCC003_8562]退出***' ) return True