def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(1.本地操作).往账发送[TRCC002_8506]进入***' ) #====begin 蔡永贵 20110215 增加==== #新票据号是16位,需要取后8位,版本号为02,同时要兼容老票据号8位,版本号为01 if len(TradeContext.BILNO) == 16: TradeContext.TMP_BILNO = TradeContext.BILNO[-8:] else: TradeContext.TMP_BILNO = TradeContext.BILNO #============end============ AfaLoggerFunc.tradeInfo('>>>RCVSTLBIN: '+TradeContext.RCVSTLBIN) AfaLoggerFunc.tradeInfo('>>>SNDSTLBIN: '+TradeContext.SNDSTLBIN) #=====判断是否为同一成员行内==== if TradeContext.RCVSTLBIN == TradeContext.SNDSTLBIN: return AfaFlowControl.ExitThisFlow('M999','同一成员行内禁止做此业务') ##===== 张恒 增加条件,如网银支付则不校验重复次数. 将手续费标志及金额字段赋值 20091109 ========## if (TradeContext.existVariable( "CHSHTP" ) and len(TradeContext.CHSHTP) != 0): #手续费收取方式 TradeContext.CHRGTYP = TradeContext.CHSHTP else: TradeContext.CHRGTYP = '2' #默认为不收 if (TradeContext.existVariable( "CUSCHRG" ) and len(TradeContext.CUSCHRG) != 0): #手续费金额 TradeContext.LOCCUSCHRG = TradeContext.CUSCHRG else : TradeContext.LOCCUSCHRG = '0.00' #默认为0.00 TradeContext.CUSCHRG = '0.00' #异地手续费清0 if str(TradeContext.OPRATTNO) != '12': #网银支付 ##=====END=====================================================================================## #=====检查数据库是否有相同交易==== sql = "BJEDTE = '" + TradeContext.BJEDTE + "'" #日期 sql = sql + " and BESBNO ='" + TradeContext.BESBNO + "'" #机构号 if (TradeContext.existVariable( "PYRACC" ) and len(TradeContext.PYRACC) != 0): #付款人账号 sql = sql + " and PYRACC ='" + TradeContext.PYRACC + "'" if (TradeContext.existVariable( "RCVBNKCO" ) and len(TradeContext.RCVBNKCO) != 0): #收款行行号 sql = sql + " and RCVBNKCO = '" + TradeContext.RCVBNKCO + "'" if (TradeContext.existVariable( "PYEACC" ) and len(TradeContext.PYEACC) != 0): #收款人账号 sql = sql + " and PYEACC ='" + TradeContext.PYEACC + "'" if (TradeContext.existVariable( "OCCAMT" ) and len(TradeContext.OCCAMT) != 0): #金额 sql = sql + " and OCCAMT =" + TradeContext.OCCAMT + "" if (TradeContext.existVariable( "OPRNO" ) and len(TradeContext.OPRNO) != 0): #业务种类 sql = sql + " and OPRNO ='" + TradeContext.OPRNO + "'" if (TradeContext.existVariable( "OPRATTNO" ) and len(TradeContext.OPRATTNO) != 0): #业务属性 sql = sql + " and OPRATTNO ='" + TradeContext.OPRATTNO + "'" if (TradeContext.existVariable( "BBSSRC" ) and len(TradeContext.BBSSRC) != 0): #资金来源 sql = sql + " and BBSSRC ='" + TradeContext.BBSSRC + "'" if (TradeContext.existVariable( "DASQ" ) and len(TradeContext.DASQ) != 0): #销账序号 sql = sql + " and DASQ ='" + TradeContext.DASQ + "'" if (TradeContext.existVariable( "BILTYP" ) and len(TradeContext.BILTYP) != 0): #票据种类 sql = sql + " and BILTYP = '" + TradeContext.BILTYP + "'" if (TradeContext.existVariable( "BILDAT" ) and len(TradeContext.BILDAT) != 0): #票据日期 sql = sql + " and BILDAT = '" + TradeContext.BILDAT + "'" if (TradeContext.existVariable( "BILNO" ) and len(TradeContext.BILNO) != 0): #票据号码 sql = sql + " and BILNO = '" + TradeContext.BILNO + "'" if (TradeContext.existVariable( "NOTE1" ) and len(TradeContext.NOTE1) != 0): #备注1 sql = sql + " and NOTE1 = '" + TradeContext.NOTE1 + "'" #=====调用函数进行多笔查询==== AfaLoggerFunc.tradeInfo( '>>>判断必要的字段是否重复,重复返回错误') record = rccpsDBTrcc_trcbka.selectm(1,10,sql,"") if record == None: return AfaFlowControl.ExitThisFlow('D000','数据库操作失败') if len(record) > 0: #====判断必要的字段是否重复,重复返回错误==== for next in range(0, len(record)): spbsta = {'BJEDTE':TradeContext.BJEDTE,'BSPSQN':record[next]['BSPSQN']} rep = rccpsDBTrcc_spbsta.selectu(spbsta) if rep == None: return AfaFlowControl.ExitThisFlow('D000', '数据库操作错误') elif len(rep) <= 0: return AfaFlowControl.ExitThisFlow('D001', '数据库查询相同业务错误') else: if rep['BDWFLG'] != PL_BDWFLG_FAIL: return AfaFlowControl.ExitThisFlow('S000', '相同业务已录入,不允许重复提交') AfaLoggerFunc.tradeInfo( '>>>开始处理此笔业务' ) #=====资金来源为1-个人结算户时,需要调用8811校验支付条件==== if TradeContext.BBSSRC == '1': TradeContext.HostCode = '8811' TradeContext.ACCNO = TradeContext.PYRACC #付款人账户 rccpsHostFunc.CommHost( '8811' ) if TradeContext.errorCode != '0000': return AfaFlowControl.ExitThisFlow('S999','查询凭证信息出错') else: if TradeContext.PAYTYP != TradeContext.HPAYTYP: return AfaFlowControl.ExitThisFlow('S999','支付条件错误') #=====开始调用密押服务器==== SEAL = ' ' SNDBANKCO = TradeContext.SNDBNKCO RCVBANKCO = TradeContext.RCVBNKCO SNDBANKCO = SNDBANKCO.rjust(12,'0') RCVBANKCO = RCVBANKCO.rjust(12,'0') AMOUNT = TradeContext.OCCAMT.split('.')[0] + TradeContext.OCCAMT.split('.')[1] AMOUNT = AMOUNT.rjust(15,'0') AfaLoggerFunc.tradeDebug('AMOUNT=' + str(AMOUNT) ) AfaLoggerFunc.tradeDebug('SNDBANKCO=' + str(SNDBANKCO) ) AfaLoggerFunc.tradeDebug('RCVBANKCO=' + str(RCVBANKCO) ) AfaLoggerFunc.tradeDebug('类型:' + str(PL_SEAL_ENC) ) AfaLoggerFunc.tradeDebug('业务类型:' + str(PL_TYPE_DZHD) ) AfaLoggerFunc.tradeDebug('日期' + TradeContext.TRCDAT ) AfaLoggerFunc.tradeDebug('流水' + TradeContext.SerialNo ) AfaLoggerFunc.tradeDebug('密押o[' + SEAL + ']') ret = miya.DraftEncrypt(PL_SEAL_ENC,PL_TYPE_DZHD,TradeContext.TRCDAT,TradeContext.SerialNo,AMOUNT,SNDBANKCO,RCVBANKCO,'',SEAL) AfaLoggerFunc.tradeDebug("ret[" + str(ret) + "]") AfaLoggerFunc.tradeDebug('密押[' + SEAL + ']') if ret != 0: return AfaFlowControl.ExitThisFlow('M9999','调用密押服务器失败') else: TradeContext.SEAL = SEAL AfaLoggerFunc.tradeDebug('密押new[' + TradeContext.SEAL + ']') #=====开始向字典赋值==== TradeContext.DCFLG = PL_DCFLG_CRE dict = {} if not rccpsMap8506CTradeContext2Ddict.map(dict): return AfaFlowControl.ExitThisFlow('M999', '字典赋值出错') #=====开始插入数据库==== if not rccpsDBFunc.insTransTrc(dict): #=====RollBack操作==== AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow('D002', '插入数据库出错,RollBack成功') #=====commit操作==== if not AfaDBFunc.CommitSql(): #=====RollBack操作==== AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow('D011', '数据库Commit失败') else: AfaLoggerFunc.tradeDebug('COMMIT成功') #====送往主机字段增加收款人名称字段 === if (TradeContext.existVariable( "PYRNAM" ) and len(TradeContext.PYRNAM) != 0): #付款人名称 TradeContext.ACNM = TradeContext.PYRNAM else: TradeContext.ACNM = '' if (TradeContext.existVariable( "PYENAM" ) and len(TradeContext.PYENAM) != 0): #收款人名称 TradeContext.OTNM = TradeContext.PYENAM else: TradeContext.OTNM = '' #汇兑往帐记帐字典赋值 input_dict = {} input_dict['CHRGTYP'] = TradeContext.CHRGTYP #手续费收取方式 input_dict['LOCCUSCHRG'] = TradeContext.LOCCUSCHRG #手续费金额 input_dict['PYRACC'] = TradeContext.PYRACC #付款人账号 input_dict['BBSSRC'] = TradeContext.BBSSRC #资金来源 input_dict['OCCAMT'] = TradeContext.OCCAMT #交易金额 input_dict['ACNM'] = TradeContext.ACNM #付款人名称 input_dict['OTNM'] = TradeContext.OTNM #收款人名称 input_dict['BESBNO'] = TradeContext.BESBNO #调用汇兑记账接口 rccpsEntries.HDWZJZ(input_dict) AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(1.本地操作).往账发送[TRCC002_8506]退出***' ) return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( ">>>开始汇兑来账接收处理" ) #=====判断是否重复交易==== sel_dict = {'TRCNO':TradeContext.TRCNO,'TRCDAT':TradeContext.TRCDAT,'SNDBNKCO':TradeContext.SNDBNKCO} record = rccpsDBTrcc_trcbka.selectu(sel_dict) if record == None: return AfaFlowControl.ExitThisFlow('S999','判断是否重复报文,查询汇兑业务登记簿相同报文异常') elif len(record) > 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['ORMFN'] = TradeContext.MSGFLGNO out_context_dict['MSGFLGNO'] = out_context_dict['SNDMBRCO'] + TradeContext.BJEDTE + TradeContext.SerialNo 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) #=====发送afe==== AfaAfeFunc.CommAfe() return AfaFlowControl.ExitThisFlow('S999','重复报文,退出处理流程') AfaLoggerFunc.tradeInfo(">>>结束判断是否重复报文") #=====币种转换==== if TradeContext.CUR == 'CNY': TradeContext.CUR = '01' #====开始向字典赋值==== trcbka_dict = {} if not rccpsMap1101CTradeContext2Dtrcbka_dict.map(trcbka_dict): return AfaFlowControl.ExitThisFlow('M999', '字典赋值出错') trcbka_dict['DCFLG'] = PL_DCFLG_CRE #借贷标识.贷 trcbka_dict['OPRNO'] = '00' #业务属性 #=====开始插入数据库==== if not rccpsDBFunc.insTransTrc(trcbka_dict): #=====RollBack操作==== AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow('D002', '插入数据库出错,RollBack成功') else: #=====commit操作==== AfaDBFunc.CommitSql() AfaLoggerFunc.tradeInfo('插入汇兑业务登记簿,COMMIT成功') #=====设置状态为收妥==== sstlog = {} sstlog['BSPSQN'] = TradeContext.BSPSQN sstlog['BJEDTE'] = TradeContext.BJEDTE sstlog['BCSTAT'] = PL_BCSTAT_BNKRCV sstlog['BDWFLG'] = PL_BDWFLG_SUCC #=====设置状态为 收妥-成功 ==== if not rccpsState.setTransState(sstlog): #=====RollBack操作==== AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg) else: #=====commit操作==== AfaDBFunc.CommitSql() AfaLoggerFunc.tradeInfo('>>>commit成功') ##========================= START 张恒 增加于20091011 来帐落机构及入帐挂账处理 =====================## #初始化记挂账标识,记账.0,挂账.1,默认记账 accflag = 0 #接收机构暂存 TradeContext.BESBNOFIRST = TradeContext.BESBNO if accflag == 0: AfaLoggerFunc.tradeInfo(">>>开始校验密押") #=====开始调用密押服务器进行核押==== SNDBANKCO = TradeContext.SNDBNKCO RCVBANKCO = TradeContext.RCVBNKCO SNDBANKCO = SNDBANKCO.rjust(12,'0') RCVBANKCO = RCVBANKCO.rjust(12,'0') AMOUNT = TradeContext.OCCAMT.split('.')[0] + TradeContext.OCCAMT.split('.')[1] AMOUNT = AMOUNT.rjust(15,'0') INFO = ' ' INFO = INFO.rjust(60,' ') AfaLoggerFunc.tradeDebug('处理类型(0-编押 1-核押):' + str(PL_SEAL_DEC) ) AfaLoggerFunc.tradeDebug('业务种类(1-现金汇票 2-转账汇票 3-电子汇兑业务):' +str(PL_TYPE_DZHD) ) AfaLoggerFunc.tradeDebug('委托日期:' + TradeContext.TRCDAT ) AfaLoggerFunc.tradeDebug('交易流水号:' + TradeContext.TRCNO ) AfaLoggerFunc.tradeDebug('AMOUNT=' + str(AMOUNT) ) AfaLoggerFunc.tradeDebug('SNDBANKCO=' + str(SNDBANKCO) ) AfaLoggerFunc.tradeDebug('RCVBANKCO=' + str(RCVBANKCO) ) AfaLoggerFunc.tradeDebug('密押:' + TradeContext.SEAL ) AfaLoggerFunc.tradeDebug('OTHERINFO[' + str(INFO) + ']') ret = miya.DraftEncrypt(PL_SEAL_DEC,PL_TYPE_DZHD,TradeContext.TRCDAT,TradeContext.TRCNO,AMOUNT,SNDBANKCO,RCVBANKCO,'',TradeContext.SEAL) if ret != 0: #密押错,挂账 AfaLoggerFunc.tradeInfo("密押校验未通过,ret=[" + str(ret) + "]") accflag = 1 TradeContext.NOTE3 = "密押错,挂账!" else: #密押校验通过 AfaLoggerFunc.tradeInfo("密押校验通过") AfaLoggerFunc.tradeInfo(">>>结束校验密押") #校验账号是否非法 if accflag == 0: AfaLoggerFunc.tradeInfo("开始校验账号是否非法") if (len(TradeContext.PYEACC) != 23) and (len(TradeContext.PYEACC) != 19) : accflag = 1 TradeContext.NOTE3 = '此账号不是对公或对私账号,挂账!' AfaLoggerFunc.tradeInfo("结束校验账号是否非法") #调用主机接口查询账户信息 if accflag == 0: #调用8810查询账户信息 AfaLoggerFunc.tradeInfo("开始查询账户信息") TradeContext.ACCNO = TradeContext.PYEACC TradeContext.HostCode = '8810' rccpsHostFunc.CommHost( '8810' ) if TradeContext.errorCode != '0000': accflag = 1 TradeContext.NOTE3 = '查询收款人信息失败,挂账!' elif TradeContext.errorCode == '0000' and len(TradeContext.ACCSO) == 0 : accflag = 1 TradeContext.NOTE3 = '查询收款人开户机构失败,挂账!' AfaLoggerFunc.tradeInfo("结束查询账户信息") #校验账户状态是否正常 if accflag == 0: AfaLoggerFunc.tradeInfo("开始校验是否跨法人") if TradeContext.ACCSO[0:6] != TradeContext.BESBNO[0:6] : accflag = 1 TradeContext.NOTE3 = '接收行与账户开户行跨法人,挂账!' AfaLoggerFunc.tradeInfo("结束校验是否跨法人") #校验开户机构是否建立代理关系 if accflag == 0: AfaLoggerFunc.tradeInfo("开始校验接收行与开户机构是否为同一机构") if TradeContext.ACCSO != TradeContext.BESBNOFIRST: khjg = {} khjg['BESBNO'] = TradeContext.ACCSO khjg['BTOPSB'] = TradeContext.BESBNOFIRST khjg['SUBFLG'] = PL_SUBFLG_SUB rec = rccpsDBTrcc_subbra.selectu(khjg) if rec == None: accflag = 1 TradeContext.NOTE3 = '查询账户代理关系失败,挂账!' elif len(rec) <= 0: accflag = 1 TradeContext.NOTE3 = '账户未建立代理关系,挂账!' else: #接收机构与开户机构存在代理关系,设置机构号为开户机构号 TradeContext.BESBNO = TradeContext.ACCSO AfaLoggerFunc.tradeInfo("结束校验接收行与开户机构是否为同一机构") #校验账号状态是否正常 if accflag == 0: AfaLoggerFunc.tradeInfo("开始校验账号状态是否正常") if TradeContext.ACCST != '0' and TradeContext.ACCST != '2': accflag = 1 TradeContext.NOTE3 = '账户状态不正常,挂账!' #在建立代理关系的情况下,账户状态不正常,同样挂账 TradeContext.BESBNO = TradeContext.BESBNOFIRST AfaLoggerFunc.tradeInfo("结束校验账号状态是否正常") #校验收款人户名是否一致 if accflag == 0: AfaLoggerFunc.tradeInfo("开始校验收款人户名是否一致") if TradeContext.ACCNM != TradeContext.PYENAM : accflag = 1 TradeContext.NOTE3 = '收款人户名不符,挂账!' #在建立代理关系的情况下,账户状态不正常,同样挂账 TradeContext.BESBNO = TradeContext.BESBNOFIRST AfaLoggerFunc.tradeInfo("结束校验收款人户名是否一致") if (TradeContext.existVariable( "PYEACC" ) and len(TradeContext.PYEACC) != 0): #收款人名称 TradeContext.PYEACCNO = TradeContext.PYEACC else: TradeContext.PYEACCNO = '' if (TradeContext.existVariable( "PYENAM" ) and len(TradeContext.PYENAM) != 0): #收款人名称 TradeContext.OTNM = TradeContext.PYENAM else: TradeContext.OTNM = '' #汇兑往帐记帐字典赋值 TradeContext.SBACACNM = '' #借方户名 input_dict = {} if (TradeContext.existVariable( "PYRNAM" ) and len(TradeContext.PYRNAM) != 0): #付款人户名 TradeContext.SBACACNM = TradeContext.PYRNAM input_dict['accflag'] = str(accflag) #记挂标志 input_dict['OCCAMT'] = TradeContext.OCCAMT #交易金额 input_dict['PYEACC'] = TradeContext.PYEACCNO #收款人账号 input_dict['OTNM'] = TradeContext.OTNM #收款人名称 input_dict['BESBNO'] = TradeContext.BESBNO #调用汇兑记账接口 rccpsEntries.HDLZJZ(input_dict) TradeContext.accflag = accflag #代理标志 #=====新增sstlog表状态记录==== if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,TradeContext.BCSTAT,TradeContext.BDWFLG): #=====RollBack操作==== AfaDBFunc.RollbackSql() return AfaFlowControl.ExitThisFlow('M999', '设置状态['+TradeContext.BCSTAT+']['+TradeContext.BDWFLG+']失败,系统自动回滚') else: #=====commit操作==== AfaDBFunc.CommitSql() return True
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(1.本地操作).汇票签发[TRCC002_8501]进入***' ) #====begin 蔡永贵 20110215 增加==== #新票据号是16位,需要取后8位,版本号为02,同时要兼容老票据号8位,版本号为01 if TradeContext.BILVER == '02': TradeContext.TMP_BILNO = TradeContext.BILNO[-8:] else: TradeContext.TMP_BILNO = TradeContext.BILNO #============end============ #=====汇票类交易接收成员行为总中心==== TradeContext.RCVSTLBIN = PL_RCV_CENTER #=====出票日期为当前交易日期==== TradeContext.BILDAT = TradeContext.BJEDTE #=====出票行为发起行号==== TradeContext.REMBNKCO = TradeContext.SNDBNKCO TradeContext.REMBNKNM = TradeContext.SNDBNKNM #=====生成汇票密押===== AfaLoggerFunc.tradeInfo(">>>开始生成汇票密押") #=====根据汇票类型赋值编押业务种类和兑付方式==== #=====PL_BILTYP_CASH 现金 PL_TYPE_XJHP 现金汇票==== #=====PL_BILTYP_TRAN 转账 PL_TYPE_ZZHP 转账汇票==== if TradeContext.BILTYP == PL_BILTYP_CASH: TYPE = PL_TYPE_XJHP TradeContext.PAYWAY = PL_PAYWAY_CASH elif TradeContext.BILTYP == PL_BILTYP_TRAN: TYPE = PL_TYPE_ZZHP TradeContext.PAYWAY = PL_PAYWAY_TRAN else: return AfaFlowControl.ExitThisFlow("S999","汇票类型非法") #=====资金来源为1-个人结算户时,需要调用8811校验支付条件==== if TradeContext.BBSSRC == '1': TradeContext.HostCode = '8811' TradeContext.ACCNO = TradeContext.PYRACC #付款人账户 rccpsHostFunc.CommHost( '8811' ) if TradeContext.errorCode != '0000': return AfaFlowControl.ExitThisFlow('S999','查询凭证信息出错') else: if TradeContext.PAYTYP != TradeContext.HPAYTYP: return AfaFlowControl.ExitThisFlow('S999','支付条件错误') MIYA = "".rjust(10,' ') TRCDAT = TradeContext.BILDAT #委托日期 TRCNO = TradeContext.BILNO #汇票号码 REMBNKCO = TradeContext.REMBNKCO #签发行 PAYBNKCO = TradeContext.PAYBNKCO #代理付款行 REMBNKCO = REMBNKCO.rjust(12,'0') PAYBNKCO = PAYBNKCO.rjust(12,'0') AMOUNT = str(TradeContext.BILAMT).split('.')[0] + str(TradeContext.BILAMT).split('.')[1] AMOUNT = AMOUNT.rjust(15,'0') INFO = "" AfaLoggerFunc.tradeDebug('处理类型(0-编押 1-核押):' + str(PL_SEAL_ENC) ) AfaLoggerFunc.tradeDebug('业务种类(1-现金汇票 2-转账汇票 3-电子汇兑业务):' + TYPE ) AfaLoggerFunc.tradeDebug('出票日期:' + TRCDAT ) AfaLoggerFunc.tradeDebug('汇票号码:' + TRCNO ) AfaLoggerFunc.tradeDebug('出票金额:' + str(AMOUNT) ) AfaLoggerFunc.tradeDebug('出票行号:' + str(REMBNKCO) ) AfaLoggerFunc.tradeDebug('代理付款行号:' + str(PAYBNKCO) ) AfaLoggerFunc.tradeDebug('汇票密押:' + MIYA ) AfaLoggerFunc.tradeDebug('OTHERINFO[' + str(INFO) + ']') #====begin 蔡永贵 20110215 修改==== #ret = miya.DraftEncrypt(PL_SEAL_ENC,TYPE,TRCDAT,TRCNO,AMOUNT,REMBNKCO,PAYBNKCO,INFO,MIYA) ret = miya.DraftEncrypt(PL_SEAL_ENC,TYPE,TRCDAT,TradeContext.TMP_BILNO,AMOUNT,REMBNKCO,PAYBNKCO,INFO,MIYA) #============end============ AfaLoggerFunc.tradeDebug( 'ret=' + str(ret) ) if ret > 0: return AfaFlowControl.ExitThisFlow('S999','调用密押服务器生成密押失败') TradeContext.SEAL = MIYA AfaLoggerFunc.tradeDebug('TradeContext密押:' + TradeContext.SEAL ) AfaLoggerFunc.tradeInfo(">>>结束生成汇票密押") #=====登记汇票业务登记簿==== AfaLoggerFunc.tradeInfo(">>>开始登记汇票业务登记簿") TradeContext.SNDMBRCO = TradeContext.SNDSTLBIN #发送成员行号 TradeContext.RCVMBRCO = TradeContext.RCVSTLBIN #接收成员行号 TradeContext.TRCNO = TradeContext.SerialNo #交易流水号 TradeContext.NCCWKDAT = TradeContext.NCCworkDate #中心工作日期 TradeContext.OPRNO = PL_HPOPRNO_QF #业务种类:汇票签发 TradeContext.DCFLG = PL_DCFLG_CRE #借贷标识:贷记 TradeContext.BRSFLG = PL_BRSFLG_SND #往来标识:往账 TradeContext.TRCCO = '2100001' #交易代码:2100001汇票签发 bilbka_dict = {} if not rccpsMap8501CTradeContext2Dbilbka.map(bilbka_dict): return AfaFlowContorl.ExitThisFlow("S999","为汇票业务登记簿赋值异常") if not rccpsDBFunc.insTransBil(bilbka_dict): return AfaFlowControl.ExitThisFlow('S999','登记汇票业务登记簿异常') AfaLoggerFunc.tradeInfo(">>>结束登记汇票业务登记簿") #=====登记汇票信息登记簿==== AfaLoggerFunc.tradeInfo(">>>开始登记汇票信息登记簿") TradeContext.NOTE1 = TradeContext.BJEDTE TradeContext.NOTE2 = TradeContext.BSPSQN TradeContext.NOTE3 = TradeContext.BESBNO bilinf_dict = {} if not rccpsMap8501CTradeContext2Dbilinf.map(bilinf_dict): return AfaFlowContorl.ExitThisFlow("S999","为汇票信息登记簿赋值异常") if not rccpsDBFunc.insInfoBil(bilinf_dict): return AfaFlowControl.ExitThisFlow('S999','登记汇票信息登记簿异常') AfaLoggerFunc.tradeInfo(">>>结束登记汇票信息登记簿") #=====设置业务状态为记账处理中==== AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为记账处理中") stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE #交易日期 stat_dict['BSPSQN'] = TradeContext.BSPSQN #报单序号 stat_dict['BCSTAT'] = PL_BCSTAT_ACC #PL_BCSTAT_ACC 记账 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(">>>开始为主机记账做准备") #=====非待销账,借付款人账号,待销账,借方账号赋空==== if TradeContext.BBSSRC != '3': TradeContext.SBAC = TradeContext.PYRACC #借方账号 TradeContext.ACNM = TradeContext.PYRNAM else: TradeContext.SBAC = '' TradeContext.ACNM = '' TradeContext.RBAC = TradeContext.BESBNO + PL_ACC_HCHK #贷方账号 TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC,25) TradeContext.OTNM = "汇出汇款" AfaLoggerFunc.tradeInfo("借方账号:[" + TradeContext.SBAC + "]") AfaLoggerFunc.tradeInfo("贷方账号:[" + TradeContext.RBAC + "]") #=====银行卡,凭证号码取账号的7到18位==== if TradeContext.BBSSRC == '0': TradeContext.WARNTNO = TradeContext.SBAC[6:18] AfaLoggerFunc.tradeDebug("凭证号码:[" + TradeContext.WARNTNO + "]") TradeContext.HostCode = '8813' TradeContext.OCCAMT = TradeContext.BILAMT #出票金额 TradeContext.RCCSMCD = PL_RCCSMCD_HPQF #主机摘要码:汇票签发 TradeContext.ACUR = '2' #重复次数 TradeContext.TRFG = '4' #凭证处理标识 AfaLoggerFunc.tradeDebug("TradeContext.TRFG=[" + TradeContext.TRFG + "]") AfaLoggerFunc.tradeDebug("TradeContext.PASSWD=[" + TradeContext.PASSWD + "]") AfaLoggerFunc.tradeDebug("TradeContext.WARNTNO=[" + TradeContext.WARNTNO + "]") AfaLoggerFunc.tradeInfo(">>>结束为主机记账做准备") AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(1.本地操作).汇票签发[TRCC002_8501]退出***' ) return True
RCVBANKCO = RCVBANKCO.rjust(12,'0') AMOUNT = TradeContext.OCCAMT.split('.')[0] + TradeContext.OCCAMT.split('.')[1] AMOUNT = AMOUNT.rjust(15,'0') INFO = "".rjust(60,' ') AfaLoggerFunc.tradeDebug('处理类型(0-编押 1-核押):' + str(PL_SEAL_DEC) ) AfaLoggerFunc.tradeDebug('业务种类(1-现金汇票 2-转账汇票 3-电子汇兑业务):' +str(PL_TYPE_DZHD) ) AfaLoggerFunc.tradeDebug('委托日期:' + TradeContext.TRCDAT ) AfaLoggerFunc.tradeDebug('交易流水号:' + TradeContext.TRCNO ) AfaLoggerFunc.tradeDebug('AMOUNT=' + str(AMOUNT) ) AfaLoggerFunc.tradeDebug('SNDBANKCO=' + str(SNDBANKCO) ) AfaLoggerFunc.tradeDebug('RCVBANKCO=' + str(RCVBANKCO) ) AfaLoggerFunc.tradeDebug('密押:' + TradeContext.SEAL ) AfaLoggerFunc.tradeDebug('OTHERINFO[' + str(INFO) + ']') ret = miya.DraftEncrypt(PL_SEAL_DEC,PL_TYPE_DZHD,TRCDAT,TRCNO,AMOUNT,SNDBANKCO,RCVBANKCO,INFO,SEAL) AfaLoggerFunc.tradeInfo('>>>校验密押,返回值ret=['+ str(ret) + ']') if ret != 0: if ret == 9005: #====密押错,自动挂账============================== AfaLoggerFunc.tradeInfo("密押错,自动挂账") NOTE3 = "密押错,自动挂账" else: #====校验密押异常,自动挂账========================= AfaLoggerFunc.tradeInfo("校验密押异常,自动挂账") NOTE3 = "校验密押异常,自动挂账" TradeContext.HostCode = '8813' #调用8813主机接口 TradeContext.NOTE3 = NOTE3 #挂账原因
def SubModuleDoFst(): AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(1.本地操作).汇票解付[TRCC003_8502]进入***' ) #====begin 蔡永贵 20110215 增加==== #新票据号是16位,需要取后8位,版本号为02,同时要兼容老票据号8位,版本号为01 if TradeContext.BILVER == '02': TradeContext.TMP_BILNO = TradeContext.BILNO[-8:] else: TradeContext.TMP_BILNO = TradeContext.BILNO #============end============ #置代理付款行为本机构行号 TradeContext.PAYBNKCO = TradeContext.SNDBNKCO TradeContext.PAYBNKNM = TradeContext.SNDBNKNM if TradeContext.BILTYP == PL_BILTYP_CASH: #=================现金汇票置持票人账号为2431账号科目======================== TradeContext.PYHACC = TradeContext.BESBNO + PL_ACC_NXYDXZ TradeContext.PYHACC = rccpsHostFunc.CrtAcc(TradeContext.PYHACC,25) AfaLoggerFunc.tradeInfo("TradeContext.PYHACC=" + TradeContext.PYHACC) AfaLoggerFunc.tradeInfo("TradeContext.PYHNAM=" + TradeContext.PYHNAM) #=================交易必要性检查============================================ AfaLoggerFunc.tradeInfo(">>>开始交易必要性检查") if abs(float(TradeContext.BILAMT) - float(TradeContext.OCCAMT) - float(TradeContext.RMNAMT)) >= 0.001: return AfaFlowControl.ExitThisFlow("S999","多余金额非出票金额与实际结算金额之差") AfaLoggerFunc.tradeInfo(">>>结束交易必要性检查") #=================检验是否重复交易========================================== AfaLoggerFunc.tradeInfo(">>>开始校验重复交易") bilbka_where_dict = {} bilbka_where_dict['BILRS'] = PL_BILRS_OUT bilbka_where_dict['BILVER'] = TradeContext.BILVER bilbka_where_dict['BILNO'] = TradeContext.BILNO bilbka_where_dict['HPSTAT'] = PL_HPSTAT_PAYC bilbka_dict = rccpsDBTrcc_bilbka.selectu(bilbka_where_dict) if bilbka_dict == None: return AfaFlowControl.ExitThisFlow("S999","查询原汇票信息异常,校验重复交易失败") if len(bilbka_dict) > 0: return AfaFlowControl.ExitThisFlow("S999","此汇票已被解付,重复交易,禁止提交") AfaLoggerFunc.tradeInfo(">>>结束校验重复交易") if TradeContext.BILTYP != PL_BILTYP_CASH: #=================校验入账账号户名====================================== AfaLoggerFunc.tradeInfo(">>>开始校验入账账号户名") TradeContext.HostCode = '8810' TradeContext.ACCNO = TradeContext.PYHACC AfaLoggerFunc.tradeDebug("gbj test :" + TradeContext.ACCNO) rccpsHostFunc.CommHost( TradeContext.HostCode ) if TradeContext.errorCode != '0000': return AfaFlowControl.ExitThisFlow(TradeContext.errorCode,TradeContext.errorMsg) AfaLoggerFunc.tradeDebug("gbj test :" + TradeContext.ACCNM) if TradeContext.ACCNM != TradeContext.PYHNAM: return AfaFlowControl.ExitThisFlow('S999',"账号户名不符") if TradeContext.ACCST != '0' and TradeContext.ACCST != '2': return AfaFlowControl.ExitThisFlow('S999','入账账号状态不正常') AfaLoggerFunc.tradeInfo(">>>结束校验入账账号户名") #=================校验汇票密押============================================== AfaLoggerFunc.tradeInfo(">>>开始校验汇票密押") if TradeContext.BILTYP == PL_BILTYP_CASH: TYPE = PL_TYPE_XJHP elif TradeContext.BILTYP == PL_BILTYP_TRAN: TYPE = PL_TYPE_ZZHP else: return AfaFlowControl.ExitThisFlow("S999","汇票类型非法") AfaLoggerFunc.tradeDebug('TradeContext密押:' + TradeContext.SEAL ) MIYA = TradeContext.SEAL TRCDAT = TradeContext.BILDAT TRCNO = TradeContext.BILNO REMBNKCO = TradeContext.REMBNKCO #签发行 PAYBNKCO = TradeContext.PAYBNKCO #代理付款行 REMBNKCO = REMBNKCO.rjust(12,'0') PAYBNKCO = PAYBNKCO.rjust(12,'0') AMOUNT = str(TradeContext.BILAMT).split('.')[0] + str(TradeContext.BILAMT).split('.')[1] AMOUNT = AMOUNT.rjust(15,'0') INFO = "" AfaLoggerFunc.tradeDebug('处理类型(0-编押 1-核押):' + str(PL_SEAL_DEC) ) AfaLoggerFunc.tradeDebug('业务种类(1-现金汇票 2-转账汇票 3-电子汇兑业务):' + TYPE ) AfaLoggerFunc.tradeDebug('出票日期:' + TRCDAT ) AfaLoggerFunc.tradeDebug('汇票号码:' + TRCNO ) AfaLoggerFunc.tradeDebug('出票金额:' + str(AMOUNT) ) AfaLoggerFunc.tradeDebug('出票行号:' + str(REMBNKCO) ) AfaLoggerFunc.tradeDebug('代理付款行号:' + str(PAYBNKCO) ) AfaLoggerFunc.tradeDebug('汇票密押:' + MIYA ) AfaLoggerFunc.tradeDebug('OTHERINFO[' + str(INFO) + ']') AfaLoggerFunc.tradeDebug('TradeContext密押:' + TradeContext.SEAL ) #====begin 蔡永贵 20110215 修改==== #ret = miya.DraftEncrypt(PL_SEAL_DEC,TYPE,TRCDAT,TRCNO,AMOUNT,REMBNKCO,PAYBNKCO,INFO,MIYA) ret = miya.DraftEncrypt(PL_SEAL_DEC,TYPE,TRCDAT,TradeContext.TMP_BILNO,AMOUNT,REMBNKCO,PAYBNKCO,INFO,MIYA) #============end============ AfaLoggerFunc.tradeDebug('TradeContext密押:' + TradeContext.SEAL ) AfaLoggerFunc.tradeDebug( 'ret=' + str(ret) ) if ret == 9005: return AfaFlowControl.ExitThisFlow('S999','密押错,请检查业务要素和密押') elif ret > 0: return AfaFlowControl.ExitThisFlow('S999','调用密押服务器失败') AfaLoggerFunc.tradeInfo(">>>结束校验汇票密押") #=================登记汇票登记簿======================================== AfaLoggerFunc.tradeInfo(">>>开始登记汇票登记簿") #=================为汇票业务登记簿赋值================================== TradeContext.OPRNO = PL_HPOPRNO_JF #业务类型解付 TradeContext.DCFLG = PL_DCFLG_CRE TradeContext.BILRS = PL_BILRS_OUT TradeContext.NCCWKDAT = TradeContext.NCCworkDate TradeContext.TRCNO = TradeContext.SerialNo TradeContext.SNDMBRCO = TradeContext.SNDSTLBIN TradeContext.RCVMBRCO = '1000000000' bilbka_dict = {} if not rccpsMap8502CTradeContext2Dbilbka.map(bilbka_dict): return AfaFlowControl.ExitThisFlow('S999','为汇票业务登记簿赋值异常') #=================登记汇票业务登记簿==================================== if not rccpsDBFunc.insTransBil(bilbka_dict): if not AfaDBFunc.RollbackSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) AfaLoggerFunc.tradeError(">>>Rollback异常") AfaLoggerFunc.tradeInfo(">>>Rollback成功") return AfaFlowControl.ExitThisFlow('S999','登记汇票业务登记簿异常') #=================为汇票信息登记簿赋值================================== bilinf_dict = {} if not rccpsMap8502CTradeContext2Dbilinf.map(bilinf_dict): if not AfaDBFunc.RollbackSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) AfaLoggerFunc.tradeError(">>>Rollback异常") AfaLoggerFunc.tradeInfo(">>>Rollback成功") return AfaFlowControl.ExitThisFlow('S999','为汇票信息登记簿赋值异常') bilinf_dict['NOTE3'] = TradeContext.BESBNO #将交易机构赋值到汇票信息登记簿中note3字段 #=================登记汇票信息登记簿==================================== if not rccpsDBFunc.insInfoBil(bilinf_dict): if not AfaDBFunc.RollbackSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) AfaLoggerFunc.tradeError(">>>Rollback异常") AfaLoggerFunc.tradeInfo(">>>Rollback成功") return AfaFlowControl.ExitThisFlow('S999','登记汇票信息登记簿异常') AfaLoggerFunc.tradeInfo(">>>结束登记汇票登记簿") #=================设置状态为发送处理中====================================== AfaLoggerFunc.tradeInfo(">>>开始设置业务状态为发送处理中") stat_dict = {} stat_dict['BJEDTE'] = TradeContext.BJEDTE stat_dict['BSPSQN'] = TradeContext.BSPSQN stat_dict['BCSTAT'] = PL_BCSTAT_SND stat_dict['BDWFLG'] = PL_BDWFLG_WAIT if not rccpsState.setTransState(stat_dict): if not AfaDBFunc.RollbackSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) AfaLoggerFunc.tradeError(">>>Rollback异常") AfaLoggerFunc.tradeInfo(">>>Rollback成功") return AfaFlowControl.ExitThisFlow('S999','设置状态为发送处理中异常') AfaLoggerFunc.tradeInfo(">>>结束设置业务状态为发送处理中") if not AfaDBFunc.CommitSql( ): AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg ) return AfaFlowControl.ExitThisFlow("S999","Commit异常") AfaLoggerFunc.tradeInfo(">>>Commit成功") AfaLoggerFunc.tradeInfo( '***农信银系统:往账.主机类操作(1.本地操作).汇票解付[TRCC003_8502]结束***' ) #=================为汇票解付报文赋值======================================== 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 = "21" TradeContext.ROPRTPNO = "" TradeContext.TRANTYP = "0" TradeContext.ORTRCCO = "" TradeContext.TRCCO = '2100100' TradeContext.TRCNO = TradeContext.SerialNo TradeContext.RCVSTLBIN = TradeContext.RCVMBRCO TradeContext.OPRATTNO = "" AfaLoggerFunc.tradeInfo(">>>结束为解付报文赋值") return True