Exemple #1
0
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'

    #===================查询原交易信息=========================================
    AfaLoggerFunc.tradeInfo(">>>开始查询原交易信息")
    
    ortrc_dict = {}
    if not rccpsDBFunc.getTransTrcAK(TradeContext.ORSNDBNK,TradeContext.ORTRCDAT,TradeContext.ORTRCNO,ortrc_dict):
        AfaLoggerFunc.tradeInfo("未找到原交易信息")
        TradeContext.BOJEDT = ""
        TradeContext.BOSPSQ = ""
    else:
        TradeContext.BOJEDT = ortrc_dict['BJEDTE']
        TradeContext.BOSPSQ = ortrc_dict['BSPSQN']
        #=====刘雨龙 2008-09-17 增加业务类型====
        TradeContext.OPRATTNO  = ortrc_dict['OPRATTNO']
    
    AfaLoggerFunc.tradeInfo(">>>结束查询原交易信息")
    
    #====开始向字典赋值====
    trcbka_dict = {}
    if not rccpsMap1101CTradeContext2Dtrcbka_dict.map(trcbka_dict):
        return AfaFlowControl.ExitThisFlow('M999', '字典赋值出错')

    trcbka_dict['DCFLG'] = PL_DCFLG_CRE                  #借贷标识
    trcbka_dict['OPRNO'] = '09'                          #业务属性

    #=====开始插入数据库====
    if not rccpsDBFunc.insTransTrc(trcbka_dict):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('D002', '插入数据库出错,RollBack成功')
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('插入汇兑业务登记簿,COMMIT成功')
        
    ##========================= START 张恒 增加于20091011 来帐落机构及入帐挂账处理  =====================##
    #初始化记挂账标识,记账.0,挂账.1,默认记账
    accflag = 0
    #接收机构暂存
    TradeContext.BESBNOFIRST = TradeContext.BESBNO
        
    #校验账号是否非法
    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.PYEACC      = TradeContext.PYEACC
    else:
        TradeContext.PYEACC      = ''
         
    if (TradeContext.existVariable( "PYENAM" ) and len(TradeContext.PYENAM) != 0):       #收款人名称
        TradeContext.OTNM      = TradeContext.PYENAM
    else:
        TradeContext.OTNM      = ''
        
    #汇兑往帐记帐字典赋值
    input_dict = {}
    input_dict['accflag']     = str(accflag)                                #记挂标志
    input_dict['OCCAMT']      = TradeContext.OCCAMT                         #交易金额
    input_dict['PYEACC']      = TradeContext.PYEACC                         #收款人账号
    input_dict['OTNM']        = TradeContext.OTNM                           #收款人名称
    input_dict['BESBNO']      = TradeContext.BESBNO
        
    #调用汇兑记账接口
    rccpsEntries.HDLZJZ(input_dict)
    
    TradeContext.accflag    = accflag                                    #代理标志

    #=====开始调函数拼贷方账号第25位校验位====
    TradeContext.HostCode = '8813'                                   #调用8813主机接口
    TradeContext.RCCSMCD  = PL_RCCSMCD_HDLZ                          #主机摘要代码:汇兑来账
    TradeContext.ACUR = '1'
    ##========================= END 张恒 增加于20091011 来帐落机构及入帐挂账处理  =====================##
    
    #=====设置状态为收妥====
    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成功')

    return True
Exemple #2
0
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
Exemple #3
0
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
Exemple #4
0
 AfaLoggerFunc.tradeInfo(">>>开始登记来账信息")
 
 #=====================币种转换=================================
 if TradeContext.CUR == 'CNY':
     TradeContext.CUR  = '01'
 
 #=====================开始向字典赋值===========================
 trcbka_dict = {}
 if not rccpsMap1101CTradeContext2Dtrcbka_dict.map(trcbka_dict):
     rccpsCronFunc.cronExit('M999', '字典赋值出错')
 
 trcbka_dict['DCFLG'] = PL_DCFLG_CRE                  #借贷标识
 trcbka_dict['OPRNO'] = TradeContext.OPRNO            #业务属性
 
 #=====================开始插入数据库===========================
 if not rccpsDBFunc.insTransTrc(trcbka_dict):
     rccpsCronFunc.cronExit('D002', '插入数据库异常')
     
 #=====================commit操作===============================
 if not AfaDBFunc.CommitSql( ):
     AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
     rccpsCronFunc.cronExit("S999","Commit异常")
 AfaLoggerFunc.tradeInfo(">>>Commit成功")
 AfaLoggerFunc.tradeInfo('插入汇兑业务登记簿成功')
 
 #=====================设置状态为收妥===========================
 sstlog   = {}
 sstlog['BSPSQN']   = TradeContext.BSPSQN
 sstlog['BJEDTE']   = TradeContext.BJEDTE
 sstlog['BCSTAT']   = PL_BCSTAT_BNKRCV
 sstlog['BDWFLG']   = PL_BDWFLG_SUCC
Exemple #5
0
def SubModuleDoFst():
    #=====判断是否重复交易====
    sel_dict = {'TRCNO':TradeContext.TRCNO,'TRCDAT':TradeContext.TRCDAT,'SNDBNKCO':TradeContext.SNDBNKCO}
    record = rccpsDBTrcc_existp.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']  = trc_dict['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(">>>开始根据发送行号,委托日期,交易流水号查询交易信息")
    trc_dict = {}
    if not rccpsDBFunc.getTransTrcPK(TradeContext.SNDMBRCO,TradeContext.ORTRCDAT,TradeContext.ORTRCNO,trc_dict):
        return AfaFlowControl.ExitThisFlow('S999','汇兑业务登记簿中无此交易,抛弃报文') 

    AfaLoggerFunc.tradeInfo(">>>结束根据发送行号,委托日期,交易流水号查询交易信息")

    #=====需要插入紧急止付业务登记簿existp====
    existp = {}
    if not rccpsMap1130CTradeContext2Dexistp.map(existp):
        return AfaFlowControl.ExitThisFlow('S999','字典赋值出错,抛弃报文')

    existp['BOJEDT']  =  trc_dict['BJEDTE']
    existp['BOSPSQ']  =  trc_dict['BSPSQN']
    existp['CUR']     =  '01'
    
    #=====张恒 20091203 新增 将机构落到原交易机构 ====
    existp['BESBNO']     =  trc_dict['BESBNO']
    
    ret = rccpsDBTrcc_existp.insertCmt(existp)
    if ret < 0:
        return AfaFlowControl.ExitThisflow('S999','插入止付业务登记簿出错,抛弃报文')

    #======检查原业务状态是否为自动挂账-成功====
    #if not (trc_dict['BCSTAT'] != PL_BCSTAT_HANG and trc_dict['BDWFLG'] != PL_BDWFLG_SUCC ):
    if (trc_dict['BCSTAT'] != PL_BCSTAT_HANG or trc_dict['TRCCO'][:2] != '20' or trc_dict['TRCCO'] == '2000009'):
        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']  = trc_dict['TRCCO']
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '该笔业务已入账,不允许退汇'

        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)
        TradeContext.SNDSTLBIN       = TradeContext.RCVMBRCO     #发起成员行号

        #=====发送afe====
        AfaAfeFunc.CommAfe()

        return AfaFlowControl.ExitThisFlow('S999','重复报文,退出处理流程')

    TradeContext.BOSPSQ   = trc_dict['BSPSQN']
    TradeContext.BOJEDT   = trc_dict['BJEDTE']
    TradeContext.ORPYRACC = trc_dict['PYRACC']
    TradeContext.ORPYRNAM = trc_dict['PYRNAM']
    TradeContext.ORPYEACC = trc_dict['PYEACC']
    TradeContext.ORPYENAM = trc_dict['PYENAM']
    TradeContext.ORTRCCO  = trc_dict['TRCCO']

    #=====汇兑业务登记簿trcbka赋值新增一条记录====
    trc_dict['BOJEDT']  =  trc_dict['BJEDTE']
    trc_dict['BOSPSQ']  =  trc_dict['BSPSQN']
    trc_dict['ORTRCDAT']=  trc_dict['TRCDAT']
    trc_dict['ORTRCNO'] =  trc_dict['TRCNO']
    trc_dict['ORTRCCO'] =  trc_dict['TRCCO']
    trc_dict['TRCCO']   =  '2000004'
    trc_dict['OPRNO']   =  '09'
    trc_dict['DCFLG']   =  PL_DCFLG_CRE
    trc_dict['BJEDTE']  =  TradeContext.BJEDTE
    trc_dict['BSPSQN']  =  TradeContext.BSPSQN
    trc_dict['TRCDAT']  =  TradeContext.TRCDAT
    trc_dict['TRCNO']   =  TradeContext.SerialNo
    trc_dict['BRSFLG']  =  PL_BRSFLG_SND                  #往账
    trc_dict['BBSSRC']  =  '3'                            #待销账
    #=====接收成员行号与发送成员行号互换====
    TradeContext.temp   =  trc_dict['SNDMBRCO']
    trc_dict['SNDMBRCO']=  trc_dict['RCVMBRCO']
    trc_dict['RCVMBRCO']=  TradeContext.temp 

    #=====接收行号与发送行号互换====
    TradeContext.temp   =  trc_dict['SNDBNKCO']
    trc_dict['SNDBNKCO']=  trc_dict['RCVBNKCO']
    trc_dict['RCVBNKCO']=  TradeContext.temp 

    #=====接收行名与发送行名互换====
    TradeContext.temp   =  trc_dict['SNDBNKNM']
    trc_dict['SNDBNKNM']=  trc_dict['RCVBNKNM']
    trc_dict['RCVBNKNM']=  TradeContext.temp 

    #=====开始插入数据库====
    if not rccpsDBFunc.insTransTrc(trc_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_ACC
    sstlog['BDWFLG']   = PL_BDWFLG_WAIT

    if not rccpsState.setTransState(sstlog):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('>>>commit成功')

    #=====开始拼借贷方账号====
    TradeContext.DASQ  = trc_dict['DASQ']
    TradeContext.RBAC  =  TradeContext.BESBNO + PL_ACC_NXYDQSWZ
    TradeContext.OCCAMT= TradeContext.OROCCAMT
    TradeContext.HostCode = '8813'

    #=====开始调函数拼贷方账号第25位校验位====
    TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC, 25)
    AfaLoggerFunc.tradeInfo( '贷方账号:' + TradeContext.RBAC )
 
    rccpsHostFunc.CommHost(TradeContext.HostCode)

    AfaLoggerFunc.tradeInfo( '>>>开始判断主机返回结果' )
    status_dict = {}
    status_dict['BSPSQN']  = TradeContext.BSPSQN       #报单序号
    status_dict['BJEDTE']  = TradeContext.BJEDTE       #交易日期
    status_dict['BCSTAT']  = PL_BCSTAT_ACC             #记账

    #=====判断主机返回结果====
    if TradeContext.errorCode != '0000':
        status_dict['BDWFLG']  = PL_BDWFLG_FAIL        #失败
    else:
        status_dict['BDWFLG']  = PL_BDWFLG_SUCC        #成功
        status_dict['TRDT']    = TradeContext.TRDT     #主机日期
        status_dict['TLSQ']    = TradeContext.TLSQ     #主机流水号
        status_dict['MGID']    = TradeContext.MGID     #主机返回信息
        status_dict['DASQ']    = TradeContext.DASQ     #销账序号

    #=====修改退汇记录的状态====
    if not rccpsState.setTransState(status_dict):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('>>>commit成功')

    #=====判断主机返回结果,是否继续流程====
    if TradeContext.errorCode != '0000':
        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.TRCDAT
        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.ORTRCCO 
        out_context_dict['PRCCO']    = 'RCCI0000'
        out_context_dict['STRINFO']  = '该笔业务已入账,不允许退汇'

        rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)

        TradeContext.SNDSTLBIN       = TradeContext.RCVMBRCO     #发起成员行号

        #=====发送afe====
        AfaAfeFunc.CommAfe()

        return AfaFlowControl.ExitThisFlow('S999','该笔业务已被主机处理,不允许退汇')

    #=====新增记录的状态为:发送-处理中====
    if not rccpsState.newTransState(TradeContext.BJEDTE,TradeContext.BSPSQN,PL_BCSTAT_SND,PL_BDWFLG_WAIT):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow('M999', '设置状态失败,系统自动回滚')
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()

    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.TRCDAT
    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.ORTRCCO
    out_context_dict['PRCCO']    = 'RCCI0000'
    out_context_dict['STRINFO']  = '成功'

    rccpsMap0000Dout_context2CTradeContext.map(out_context_dict)

    TradeContext.SNDSTLBIN       = TradeContext.RCVMBRCO     #发起成员行号

    return True
Exemple #6
0
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'] = '01'                          #业务属性

    #=====开始插入数据库====
    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')
        
        AfaLoggerFunc.tradeDebug('AMOUNT=' + str(AMOUNT) )
        AfaLoggerFunc.tradeDebug('SNDBANKCO=' + str(SNDBANKCO) )
        AfaLoggerFunc.tradeDebug('RCVBANKCO=' + str(RCVBANKCO) )

        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.PYEACC      = TradeContext.PYEACC
    else:
        TradeContext.PYEACC      = ''
         
    if (TradeContext.existVariable( "PYENAM" ) and len(TradeContext.PYENAM) != 0):       #收款人名称
        TradeContext.OTNM      = TradeContext.PYENAM
    else:
        TradeContext.OTNM      = ''
        
    #汇兑往帐记帐字典赋值
    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.PYEACC                         #收款人账号
    input_dict['OTNM']        = TradeContext.OTNM                           #收款人名称
    input_dict['BESBNO']      = TradeContext.BESBNO
        
    #调用汇兑记账接口
    rccpsEntries.HDLZJZ(input_dict)
    
    TradeContext.accflag    = accflag                                    #代理标志

    #=====开始调函数拼贷方账号第25位校验位====
    TradeContext.HostCode = '8813'                                   #调用8813主机接口
    TradeContext.RCCSMCD  = PL_RCCSMCD_HDLZ                          #主机摘要代码:汇兑来账
    TradeContext.ACUR = '1'
    ##========================= END 张恒 增加于20091011 来帐落机构及入帐挂账处理  =====================##

    #=====新增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
Exemple #7
0
def SubModuleDoFst():
    #====开始取流水号对应信息====
    trcbka_dict = {}
    dict = rccpsDBFunc.getTransTrc(TradeContext.BOJEDT,TradeContext.BOSPSQ,trcbka_dict)
    if dict == False:
        return AfaFlowControl.ExitThisFlow('M999','取交易信息失败')

    #=====判断撤销信息====
    if trcbka_dict['BRSFLG'] != PL_BRSFLG_RCV:
        return AfaFlowControl.ExitThisFlow('M999','原交易为往帐业务,不允许退汇操作')
    if TradeContext.BESBNO != trcbka_dict["BESBNO"]:
        return AfaFlowControl.ExitThisFlow('M999','不允许跨机构退汇')
    if str(trcbka_dict['TRCCO']) == '2000009':
        return AfaFlowControl.ExitThisFlow('M999','特约汇兑业务不允许退汇')
    if str(trcbka_dict['TRCCO']) == '2000004':
        return AfaFlowControl.ExitThisFlow('M999','退汇业务不允许再次退汇')
    if str(trcbka_dict['TRCCO'])[0:2] != '20':
        return AfaFlowControl.ExitThisFlow('M999','非汇兑业务不允许退汇')
    if trcbka_dict["BCSTAT"] != PL_BCSTAT_HANG:   #自动挂账状态 1 成功
         return AfaFlowControl.ExitThisFlow('M999','当前业务状态为['+str(trcbka_dict["BCSTAT"])+']不允许退汇' )

    TradeContext.ORSNDBNK    = trcbka_dict['SNDBNKCO']
    TradeContext.ORRCVBNK    = trcbka_dict['RCVBNKCO']
    TradeContext.ORSNDBNKNM  = trcbka_dict['SNDBNKNM']
    TradeContext.ORRCVBNKNM  = trcbka_dict['RCVBNKNM']

    #=====开始插入数据库====
    trcbka_dict["BRSFLG"]    = TradeContext.BRSFLG
    trcbka_dict["BOJEDT"]    = trcbka_dict["BJEDTE"]
    trcbka_dict["BOSPSQ"]    = trcbka_dict["BSPSQN"]
    trcbka_dict["ORTRCDAT"]  = trcbka_dict["TRCDAT"]
    trcbka_dict["ORTRCCO"]   = trcbka_dict["TRCCO"] 
    trcbka_dict["ORTRCNO"]   = trcbka_dict["TRCNO"] 
    trcbka_dict["ORSNDBNK"]  = trcbka_dict["SNDBNKCO"]
    trcbka_dict["ORRCVBNK"]  = trcbka_dict["RCVBNKCO"]
    trcbka_dict["BJEDTE"]    = TradeContext.BJEDTE
    trcbka_dict["BSPSQN"]    = TradeContext.BSPSQN
    trcbka_dict["BJETIM"]    = TradeContext.BJETIM
    trcbka_dict["TRCDAT"]    = TradeContext.TRCDAT
    trcbka_dict["STRINFO"]   = TradeContext.STRINFO
    trcbka_dict["TRCCO"]     = TradeContext.TRCCO
    trcbka_dict["TRCNO"]     = TradeContext.SerialNo
    trcbka_dict["SNDBNKCO"]  = TradeContext.SNDBNKCO
    trcbka_dict["SNDBNKNM"]  = TradeContext.SNDBNKNM
    trcbka_dict["SNDMBRCO"]  = TradeContext.SNDSTLBIN
    trcbka_dict["RCVBNKCO"]  = TradeContext.RCVBNKCO
    trcbka_dict["RCVBNKNM"]  = TradeContext.RCVBNKNM
    trcbka_dict["RCVMBRCO"]  = TradeContext.RCVSTLBIN
    trcbka_dict["OPRNO"]     = "09"
    trcbka_dict["BBSSRC"]    = "3"
    trcbka_dict["BETELR"]    = TradeContext.BETELR
    trcbka_dict["TERMID"]    = TradeContext.TERMID
    
    #=====刘雨龙 2008-09-17 注释对业务类型的赋空操作====
    #trcbka_dict["OPRATTNO"]  = ""
    
    trcbka_dict["NCCWKDAT"]  = TradeContext.NCCworkDate
    trcbka_dict["SEAL"]      = ""

    #=====为发送退汇报文赋值====
    TradeContext.OPRTYPNO    =  '20'   #汇兑
    TradeContext.ORTRCCO     = trcbka_dict['ORTRCCO']
    TradeContext.ORTRCDAT    = trcbka_dict['ORTRCDAT']
    TradeContext.ORTRCNO     = trcbka_dict['ORTRCNO']
    TradeContext.ORPYRACC    = trcbka_dict['PYRACC']
    TradeContext.ORPYRNAM    = trcbka_dict['PYRNAM']
    TradeContext.ORPYEACC    = trcbka_dict['PYEACC']
    TradeContext.ORPYENAM    = trcbka_dict['PYENAM']
    TradeContext.PYRACC      = trcbka_dict['PYRACC']
    TradeContext.PYRNAM      = trcbka_dict['PYRNAM']
    TradeContext.PYRADDR     = trcbka_dict['PYRADDR']
    TradeContext.PYEACC      = trcbka_dict['PYEACC']
    TradeContext.PYENAM      = trcbka_dict['PYENAM']
    TradeContext.PYEADDR     = trcbka_dict['PYEADDR']
    
    
    
    AfaLoggerFunc.tradeInfo( '字典trccan_dict:' + str(trcbka_dict) )

    #=====开始插入数据库====
    if not rccpsDBFunc.insTransTrc(trcbka_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成功')


    #=====设置sstlog表中状态为:记账-处理中====
    status = {}
    status['BJEDTE']     = TradeContext.BJEDTE
    status['BSPSQN']     = TradeContext.BSPSQN
    status['BCSTAT']     = PL_BCSTAT_ACC
    status['BDWFLG']     = PL_BDWFLG_WAIT

    if not rccpsState.setTransState(status):
        #=====RollBack操作====
        AfaDBFunc.RollbackSql()
        return AfaFlowControl.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
    else:
        #=====commit操作====
        AfaDBFunc.CommitSql()
        AfaLoggerFunc.tradeInfo('>>>commit成功')

    #=====主机记账8813====
    TradeContext.HostCode  = '8813'
    TradeContext.OCCAMT    = str(trcbka_dict['OCCAMT'])     #金额
    TradeContext.RCCSMCD   = PL_RCCSMCD_LTH                 #主机摘要代码:来账退汇
    TradeContext.DASQ      = trcbka_dict['DASQ']
    #=====开始拼借贷方账号====
    TradeContext.RBAC =  TradeContext.BESBNO + PL_ACC_NXYDQSWZ
    #TradeContext.SBAC =  TradeContext.BESBNO + PL_ACC_NXYDXZ

    #=====开始调函数拼贷方账号第25位校验位====
    TradeContext.RBAC = rccpsHostFunc.CrtAcc(TradeContext.RBAC, 25)
    #TradeContext.SBAC = rccpsHostFunc.CrtAcc(TradeContext.SBAC, 25)
    AfaLoggerFunc.tradeInfo( '贷方账号:' + TradeContext.RBAC )
    #AfaLoggerFunc.tradeInfo( '借方账号:' + TradeContext.SBAC )

    return True