Ejemplo n.º 1
0
def Insert():
    AfaLoggerFunc.tradeInfo( '********************插入数据表开始*******************' )
    try:
        if( TradeContext.existVariable( "busiNo" ) and len(TradeContext.busiNo)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[单位编码]:不能为空')
        if( TradeContext.existVariable( "hostIp" ) and len(TradeContext.hostIp)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[财政地址]:不能为空')
        if( TradeContext.existVariable( "upUser" ) and len(TradeContext.upUser)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[上传用户]:不能为空')
        if( TradeContext.existVariable( "upPwd" ) and len(TradeContext.upPwd)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[上传密码]:不能为空')
        if( TradeContext.existVariable( "downUser" ) and len(TradeContext.downUser)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[下载用户]:不能为空')
        if( TradeContext.existVariable( "downPwd" ) and len(TradeContext.downPwd)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[下载密码]:不能为空')
        if( TradeContext.existVariable( "accDate" ) and len(TradeContext.accDate)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[开户余额]:不能为空')
        if( TradeContext.existVariable( "remain" ) and len(TradeContext.remain)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[开户日期]:不能为空')
        
        sqlstr      =   "insert into fs_businoconf(BUSINO,HOSTIP,UPUSER,UPPASSWD,UPLDIR,DOWNUSER,DOWNPASSWD,DOWNLDIR,UPRDIR,DOWNRDIR) values("
        sqlstr1     =   sqlstr
        sqlstr1     =   sqlstr1 + "'" + TradeContext.busiNo             + "',"
        sqlstr1     =   sqlstr1 + "'" + TradeContext.hostIp             + "',"
        sqlstr1     =   sqlstr1 + "'" + TradeContext.upUser             + "',"
        sqlstr1     =   sqlstr1 + "'" + TradeContext.upPwd              + "',"
        sqlstr1     =   sqlstr1 + "'/home/maps/afa/data/ahfs',"
        sqlstr1     =   sqlstr1 + "'" + TradeContext.downUser           + "',"
        sqlstr1     =   sqlstr1 + "'" + TradeContext.downPwd            + "',"
        sqlstr1     =   sqlstr1 + "'/home/maps/afa/data/ahfs',' ',' ')"
        
        
        AfaLoggerFunc.tradeInfo(sqlstr1)
        records = AfaDBFunc.InsertSqlCmt(sqlstr1)
        if( records == None or records <=0  ):
            AfaLoggerFunc.tradeFatal(sqlstr1)
            return AfaFlowControl.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )            
        
        
        
        sqlstr      =   "insert into fs_remain(busino,date,this) values("
        sqlstr2     =   sqlstr
        sqlstr2     =   sqlstr2 + "'" + TradeContext.busiNo               + "',"
        sqlstr2     =   sqlstr2 + "'" + TradeContext.accDate              + "',"
        sqlstr2     =   sqlstr2 + "'" + TradeContext.remain               + "')"
        
        AfaLoggerFunc.tradeInfo(sqlstr2)
        records = AfaDBFunc.InsertSqlCmt(sqlstr2)
        if( records == None or records <=0  ):
            AfaLoggerFunc.tradeFatal(sqlstr2)
            return AfaFlowControl.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
        AfaLoggerFunc.tradeInfo( '********************插入数据表结束*******************' )
        return True
    
    except Exception, e:
        AfaLoggerFunc.tradeInfo(e)
        return AfaFlowControl.ExitThisFlow('9999', '程序处理异常'+str(e))
Ejemplo n.º 2
0
def SubModuleMainFst( ):

    AfaLoggerFunc.tradeInfo( '进入自由格式报文接收交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
    try:
        #=============初始化返回报文变量====================
        TradeContext.tradeResponse=[]
        
        sql="insert into TIPS_NOTE(WORKDATE,WORKTIME,SRCNODECODE,DESNODECODE,SENDORGCODE,RCVORGCODE,CONTENT)"
        sql=sql+" values"
        sql=sql+"('"+TradeContext.workDate      +"'"
        sql=sql+",'"+TradeContext.workTime      +"'"
        sql=sql+",'"+TradeContext.SrcNodeCode   +"'"
        sql=sql+",'"+TradeContext.DesNodeCode   +"'"
        sql=sql+",'"+TradeContext.SendOrgCode   +"'"
        sql=sql+",'"+TradeContext.RcvOrgCode    +"'"
        sql=sql+",'"+TradeContext.Content       +"'"
        sql=sql+")"
        AfaLoggerFunc.tradeInfo(sql)
        if( AfaDBFunc.InsertSqlCmt(sql) == -1 ):
            AfaLoggerFunc.tradeFatal(sql)
            TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            return False 

        #=============自动打包==================== 
        TradeContext.errorCode='0000'
        TradeContext.errorMsg='交易成功'
        TipsFunc.autoPackData()
        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '退出自由格式报文接收交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']\n' )
        return True
    except TipsFunc.flowException, e:
        return TipsFunc.exitMainFlow( )
Ejemplo n.º 3
0
def Insert():
    try:
        if( TradeContext.existVariable( "PAYEEBANKNO" ) and len(TradeContext.PAYEEBANKNO)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[清算国库支付系统行号]:不能为空')
        if( TradeContext.existVariable( "TRECODE" ) and len(TradeContext.TRECODE)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[清算国库代码]:不能为空')
        if( TradeContext.existVariable( "TRENAME" ) and len(TradeContext.TRENAME)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[清算国库名称]:不能为空')
        if( TradeContext.existVariable( "PAYEEACCT" ) and len(TradeContext.PAYEEACCT)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[清算国库收款账号]:不能为空')
        if( TradeContext.existVariable( "PAYEEACCTNAME" ) and len(TradeContext.PAYEEACCTNAME)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[清算国库收款账户名称]:不能为空')
        if( TradeContext.existVariable( "PAYBKCODE" ) and len(TradeContext.PAYBKCODE)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[国库关联行行号]:不能为空')
        if( TradeContext.existVariable( "PAYBKNAME" ) and len(TradeContext.PAYBKNAME)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[国库关联行名称]:不能为空')
        if( TradeContext.existVariable( "LIQUIDATEMODE" ) and len(TradeContext.LIQUIDATEMODE)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[清算模式]:不能为空')
        if( TradeContext.existVariable( "BRNO" ) and len(TradeContext.BRNO)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[机构代码]:不能为空')
        if( TradeContext.existVariable( "TELLERNO" ) and len(TradeContext.TELLERNO)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[交易柜员]:不能为空')

        sql="SELECT PAYEEBANKNO,TRECODE,TRENAME,PAYEEACCT,PAYEEACCTNAME,PAYBKCODE,PAYBKNAME,LIQUIDATEMODE,STATUS,BRNO,TELLERNO,NOTE1,NOTE2,NOTE3,NOTE4,NOTE5 "
        sql=sql+" FROM TIPS_LIQUIDATE_ADM WHERE 1=1 "
        sql=sql+"AND PAYEEBANKNO='"+ TradeContext.PAYEEBANKNO+"'"
        sql=sql+"AND PAYBKCODE='"+ TradeContext.PAYBKCODE+"'"
        AfaLoggerFunc.tradeInfo(sql)
        records = AfaDBFunc.SelectSql(sql)
        if( records == None ):
            AfaLoggerFunc.tradeFatal(sql)
            return AfaFlowControl.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
        elif( len(records) > 0 ):
            return AfaFlowControl.ExitThisFlow( 'A0027', '已存在此清算信息' )

            
        sql="INSERT INTO  TIPS_LIQUIDATE_ADM(PAYEEBANKNO,TRECODE,TRENAME,PAYEEACCT,PAYEEACCTNAME,PAYBKCODE,PAYBKNAME,LIQUIDATEMODE,STATUS,BRNO,TELLERNO) "
        sql=sql+" VALUES "
        sql=sql+"('"+ TradeContext.PAYEEBANKNO  +"'"
        sql=sql+",'"+ TradeContext.TRECODE      +"'"
        sql=sql+",'"+ TradeContext.TRENAME      +"'"
        sql=sql+",'"+ TradeContext.PAYEEACCT    +"'"
        sql=sql+",'"+ TradeContext.PAYEEACCTNAME+"'"
        sql=sql+",'"+ TradeContext.PAYBKCODE    +"'"
        sql=sql+",'"+ TradeContext.PAYBKNAME    +"'"
        sql=sql+",'"+ TradeContext.LIQUIDATEMODE+"'"
        sql=sql+",'"+ '1'                       +"'"
        sql=sql+",'"+ TradeContext.BRNO         +"'"
        sql=sql+",'"+ TradeContext.TELLERNO     +"'"
        sql=sql+" ) "              
        AfaLoggerFunc.tradeInfo(sql)
        records = AfaDBFunc.InsertSqlCmt(sql)
        
        if( records == None or records <=0  ):
            AfaLoggerFunc.tradeFatal(sql)
            return AfaFlowControl.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
        return True
    except Exception, e:
        AfaLoggerFunc.tradeInfo(e)
        return AfaFlowControl.ExitThisFlow('9999', '程序处理异常'+str(e))
Ejemplo n.º 4
0
def InsertOnOffDTL():
    sql="insert into afa_UnitOnOffDTL(SYSID,UNITNO,SUBUNITNO,STATUS,OPERFLAG,STOPTIME,STARTTIME,NOTE1,NOTE2)"
    sql=sql+" values"
    sql=sql+"('"+TradeContext.sysId       +"'"
    sql=sql+",'"+TradeContext.unitno      +"'"
    sql=sql+",'"+TradeContext.TaxOrgName     +"'"
    sql=sql+",'"+'1'                         +"'"
    sql=sql+",'"+TradeContext.operFlag      +"'"
    sql=sql+",'"+TradeContext.stopTime      +"'"
    sql=sql+",'"+TradeContext.startTime      +"'"
    sql=sql+",'"+TradeContext.NOTE1           +"'"
    sql=sql+",'"+TradeContext.NOTE2           +"'"
    sql=sql+")"
    if( AfaDBFunc.InsertSqlCmt(sql) == -1 ):
        AfaLoggerFunc.tradeFatal(sql)
        return AfaFlowControl.ExitThisFlow( 'A0025', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
    return True


#获取商户参数
#def GetUnitStatus():
#    AfaLoggerFunc.tradeInfo('获取商户参数' )
#    #============系统标识============
#    sqlStr = "SELECT * FROM AFA_UNITADM WHERE SYSID = '" + TradeContext.sysId + "' AND "
#    #============商户代码============
#    sqlStr = sqlStr+"UNITNO = '" + TradeContext.unitno + "' "
#    AfaLoggerFunc.tradeInfo( sqlStr )
#    records = AfaDBFunc.SelectSql( sqlStr )
#    if( records == None ):
#        AfaLoggerFunc.tradeFatal( sqlStr )
#        return AfaFlowControl.ExitThisFlow( 'A0025', '数据库错误,商户信息表操作异常:'+AfaDBFunc.sqlErrMsg )
#    elif( len( records )!=0 ):
#        AfaUtilTools.ListFilterNone( records )
#        TradeContext.__busiMode__ = records[0][6]   #=============业务模式=============
Ejemplo n.º 5
0
def SubTransDtlProc( action ):

    AfaLoggerFunc.tradeInfo( '>>>增加交易流水从表信息' )

    #新增
    if ( action == '1' ):
        sql = "INSERT INTO AFA_SUBTRANSDTL(AGENTSERIALNO,WORKDATE,RECSEQNO,DATA1,DATA2) VALUES("    
        sql = sql + "'"  +  TradeContext.agentSerialno  + "'"
        sql = sql + ",'" +  TradeContext.workDate       + "'"
        sql = sql + ",'" +  '1'                         + "'"

        if( TradeContext.existVariable( "appendData1" ) ):
            sql = sql + ",'" +  TradeContext.appendData1   + "'"
        else:
            sql = sql + ",'" + ""                          + "'"

        if( TradeContext.existVariable( "appendData2" ) ):
            sql = sql + ",'" +  TradeContext.appendData2   + "'"
        else:
            sql = sql + ",'" + ""                          + "'"

        sql = sql + ")"

        AfaLoggerFunc.tradeInfo( sql )
    
        subresult = AfaDBFunc.InsertSqlCmt( sql )

        if( subresult < 1 ):
            TradeContext.errorCode, TradeContext.errorMsg='A0044', '插入流水从表失败'+AfaDBFunc.sqlErrMsg
            return False


    #修改
    if ( action == '2' ):
        sql = "UPDATE AFA_SUBTRANSDTL SET "

        if( TradeContext.existVariable( "afe_appendData1" ) ):
            sql = sql + "DATA1='"  +  TradeContext.afe_appendData1   + "'"

        if( TradeContext.existVariable( "afe_appendData2" ) ):
            sql = sql + ",DATA2='" +  TradeContext.afe_appendData2   + "'"

        sql = sql + " WHERE "

        sql = sql + "AGENTSERIALNO='" +  TradeContext.agentSerialno + "' AND "
        sql = sql + "WORKDATE='"      +  TradeContext.workDate      + "'"

        AfaLoggerFunc.tradeInfo( sql )

        subresult = AfaDBFunc.UpdateSqlCmt( sql )

        if( subresult < 1 ):
            TradeContext.errorCode, TradeContext.errorMsg='A0044', '插入流水从表失败'+AfaDBFunc.sqlErrMsg
            return False

    return True
Ejemplo n.º 6
0
def inserXnbFile_for_4( ):
    
    sql = ""
    sql = sql + "insert into AHNX_FILE("
    sql = sql + "BATCHNO,"
    sql = sql + "FILENAME,"
    sql = sql + "SWAPFILENAME,"
    sql = sql + "WORKDATE,"
    sql = sql + "STATUS,"
    sql = sql + "PROCMSG,"
    sql = sql + "APPLYDATE,"
    sql = sql + "APPNO,"
    sql = sql + "BUSINO,"
    sql = sql + "TOTALNUM,"
    sql = sql + "TOTALAMT,"
    sql = sql + "FILETYPE,"
    sql = sql + "BRNO,"
    sql = sql + "TELLERNO,"
    sql = sql + "BEGINDATE,"
    sql = sql + "ENDDATE,"
    sql = sql + "WORKTIME,"
    sql = sql + "NOTE1,"
    sql = sql + "NOTE2,"
    sql = sql + "NOTE3,"
    sql = sql + "NOTE4)"
    sql = sql + " values("
    sql = sql + "'" + TradeContext.BATCHNO     + "',"             #登记流水号
    sql = sql + "'" + TradeContext.I1FILENAME  + "',"             #文件名
    sql = sql + "'',"                                             #转换后的文件名
    sql = sql + "'" + TradeContext.WorkDate    + "',"             #登记日期
    sql = sql + "'0',"                                            #状态(0-待处理,1-处理成功)
    sql = sql + "'上传成功,等待批量签约...',"                     #处理信息描述
    sql = sql + "'" + TradeContext.WorkDate    + "',"             #申请日期
    sql = sql + "'" + TradeContext.I1APPNO     + "',"             #业务编号
    sql = sql + "'" + TradeContext.I1BUSINO    + "',"             #单位编号
    sql = sql + "'" + TradeContext.I1TOTALNUM  + "',"             #总笔数
    sql = sql + "'" + TradeContext.I1TOTALAMT  + "',"             #总金额
    sql = sql + "'" + TradeContext.I1FTPTYPE   + "',"             #文件类型(0-批量代发,1-批量代扣,2-批量开户,3-开户后文件转换,4-批量签约)
    sql = sql + "'" + TradeContext.I1SBNO      + "',"             #机构号
    sql = sql + "'" + TradeContext.I1USID      + "',"             #柜员号
    sql = sql + "'" + TradeContext.I1STARTDATE + "',"             #生效日期
    sql = sql + "'" + TradeContext.I1ENDDATE   + "',"             #失效日期
    sql = sql + "'" + TradeContext.WorkTime    + "',"             #申请时间
    sql = sql + "'',"                                             #备用1
    sql = sql + "'',"                                             #备用2
    sql = sql + "'',"                                             #备用3
    sql = sql + "'')"                                             #备用4
    
    AfaLoggerFunc.tradeInfo( "批量文件登记:" + sql )
    
    ret = AfaDBFunc.InsertSqlCmt(sql)
    
    if ret < 0:
        return ExitSubTrade('D0001', "插入数据失败")
        
    return True
Ejemplo n.º 7
0
def upDate_ahjf_lawcode( ):
    try:
        selectSql = "select * from ahjf_lawcode "
        whereSql  = " where  OFFICECODE='" + TradeContext.OFFICECODE    + "'"
        whereSql  = whereSql + " and LAWACTIONCODE='" + TradeContext.LAWACTIONCODE + "'"
        
        selectSql = selectSql + whereSql
        AfaLoggerFunc.tradeInfo( '基础数据查询sql:' + selectSql)
        selectRecord = AfaDBFunc.SelectSql( selectSql )
        
        if selectRecord == None:
            AfaLoggerFunc.tradeInfo('>>>查询数据库异常')
            return False
        if len(selectRecord) > 0:
            AfaLoggerFunc.tradeInfo('>>>数据已存在,做更新操作')
            
            updateSql = "update ahjf_lawcode set "
            updateSql = updateSql + "DESCRIBE     ='" + TradeContext.DESCRIBE     + "',"
            updateSql = updateSql + "MR_AMOUNT    ='" + TradeContext.MR_AMOUNT    + "',"
            updateSql = updateSql + "LOWER_AMOUNT ='" + TradeContext.LOWER_AMOUNT + "',"
            updateSql = updateSql + "TOP_AMOUNT   ='" + TradeContext.TOP_AMOUNT   + "'"
            
            updateSql = updateSql + whereSql
            AfaLoggerFunc.tradeInfo( '基础数据更新sql:' + updateSql)
            updateRecord = AfaDBFunc.UpdateSqlCmt( updateSql )
            if updateRecord <  0:
                AfaLoggerFunc.tradeInfo( "更新基础数据失败" )
                return False
        else:
            AfaLoggerFunc.tradeInfo('>>>数据不存在,登记新的数据')
            
            insertSql = "insert into ahjf_lawcode(OFFICECODE,LAWACTIONCODE,DESCRIBE,MR_AMOUNT,LOWER_AMOUNT,TOP_AMOUNT,note1,note2,note3,note4) values("
            insertSql = insertSql + "'" + TradeContext.OFFICECODE    + "',"      #采集机关代码 
            insertSql = insertSql + "'" + TradeContext.LAWACTIONCODE + "',"      #违法行为代码 
            insertSql = insertSql + "'" + TradeContext.DESCRIBE      + "',"      #违法行为描述 
            insertSql = insertSql + "'" + TradeContext.MR_AMOUNT     + "',"      #默认罚款金额 
            insertSql = insertSql + "'" + TradeContext.LOWER_AMOUNT  + "',"      #罚款金额下限 
            insertSql = insertSql + "'" + TradeContext.TOP_AMOUNT    + "',"      #罚款金额上限 
            insertSql = insertSql + "'',"                                        #备用1
            insertSql = insertSql + "'',"                                        #备用2
            insertSql = insertSql + "'',"                                        #备用3
            insertSql = insertSql + "'')"                                        #备用4
            
            AfaLoggerFunc.tradeInfo( '基础数据登记sql:' + insertSql)
            insertRecord = AfaDBFunc.InsertSqlCmt( insertSql )
            
            if insertRecord < 0:
                AfaLoggerFunc.tradeInfo( '>>>登记基础更新数据失败数据失败' )
                return False
            return True
    except Exception, e:
        AfaLoggerFunc.tradeInfo( str(e) )
        return False
Ejemplo n.º 8
0
def Insert():
    try:
        if( TradeContext.existVariable( "BRNO" ) and len(TradeContext.BRNO)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[分行行号]:不能为空')
        if( TradeContext.existVariable( "PAYBKCODE" ) and len(TradeContext.PAYBKCODE)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[清算行行号]:不能为空')
        if( TradeContext.existVariable( "STATUS" ) and len(TradeContext.STATUS)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[是否为清算行]:不能为空')
        if( TradeContext.existVariable( "ACCNO" ) and len(TradeContext.ACCNO)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[财税库款帐号]:不能为空')
        if( TradeContext.existVariable( "PAYEEBANKNO" ) and len(TradeContext.PAYEEBANKNO)<=0):
            return AfaFlowControl.ExitThisFlow( 'A0027', '[清算国库支付系统行号]:不能为空')

        sql="SELECT BRNO,PAYBKCODE,BANKNO,BANKACCT,BANKNAME,PAYEEBANKNO,STATUS,ACCNO,NOTE1,NOTE2,NOTE3,NOTE4,NOTE5 "
        sql=sql+" FROM TIPS_BRANCH_ADM WHERE 1=1 "
        #sql=sql+"AND BRNO='"+ TradeContext.BRNO+"'"
        #guanbinjie 20090901 设置清算行号为唯一值
        sql=sql+"AND PAYBKCODE='"+ TradeContext.PAYBKCODE +"'"
        #修改完成
        AfaLoggerFunc.tradeInfo(sql)
        records = AfaDBFunc.SelectSql(sql)
        if( records == None ):
            AfaLoggerFunc.tradeFatal(sql)
            return AfaFlowControl.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
        elif( len( records ) > 0 ):
            return AfaFlowControl.ExitThisFlow( 'A0027', '已存在此上线行信息' )

        sql="INSERT INTO  TIPS_BRANCH_ADM(BRNO,PAYBKCODE,BANKNO,BANKACCT,BANKNAME,PAYEEBANKNO,STATUS,ACCNO,NOTE3) "
        sql=sql+" VALUES "
        sql=sql+"('"+ TradeContext.BRNO          +"'"
        sql=sql+",'"+ TradeContext.PAYBKCODE     +"'"
        sql=sql+",'"+ TradeContext.BANKNO        +"'"
        sql=sql+",'"+ TradeContext.BANKACCT      +"'"
        sql=sql+",'"+ TradeContext.BANKNAME      +"'"
        sql=sql+",'"+ TradeContext.PAYEEBANKNO   +"'"
        sql=sql+",'"+ TradeContext.STATUS        +"'"
        sql=sql+",'"+ TradeContext.ACCNO         +"'"
        sql=sql+",'"+ TradeContext.ACCNAME         +"'"
        sql=sql+" ) "              
        AfaLoggerFunc.tradeInfo(sql)
        records = AfaDBFunc.InsertSqlCmt(sql)
        if( records == None or records <=0  ):
            AfaLoggerFunc.tradeFatal(sql)
            return AfaFlowControl.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
        return True
    except Exception, e:
        AfaLoggerFunc.tradeInfo(e)
        return AfaFlowControl.ExitThisFlow('9999', '程序处理异常'+str(e))
Ejemplo n.º 9
0
def DeleteCustInfo( ):
    AfaLoggerFunc.tradeInfo(">>>注销客户信息(本地)")

    try:
        AfaLoggerFunc.tradeInfo(">>>把需要企业信息记录移到企业信息历史表中")

        sql = ""
        sql = "INSERT INTO ABDT_HIS_CUSTINFO SELECT * FROM ABDT_CUSTINFO WHERE "
        sql = sql + "APPNO="       + "'" + TradeContext.Appno      + "'" + " AND "        #业务编码
        sql = sql + "BUSINO="      + "'" + TradeContext.PayeeUnitno+ "'" + " AND "        #单位编码
        sql = sql + "PROTOCOLNO="  + "'" + TradeContext.Protocolno + "'"                  #协议编码

        AfaLoggerFunc.tradeInfo( sql )

        result = AfaDBFunc.InsertSqlCmt( sql )
        if( result <= 0 ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return ExitSubTrade( '9000', '注销企业协议信息失败(移动)')

        AfaLoggerFunc.tradeInfo(">>>总共移动[" + str(result) + "]条记录")

        AfaLoggerFunc.tradeInfo(">>>删除在企业信息表中被注销企业信息记录")
        
        sql = ""
        sql = "DELETE FROM ABDT_CUSTINFO WHERE "
        sql = sql + "APPNO="       + "'" + TradeContext.Appno      + "'" + " AND "        #业务编码
        sql = sql + "BUSINO="      + "'" + TradeContext.PayeeUnitno+ "'" + " AND "        #单位编码
        sql = sql + "PROTOCOLNO="  + "'" + TradeContext.Protocolno + "'"                  #协议编码

        AfaLoggerFunc.tradeInfo( sql )

        result = AfaDBFunc.DeleteSqlCmt( sql )
        if( result <= 0 ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return ExitSubTrade( '9000', '注销企业协议信息失败(删除)')

        AfaLoggerFunc.tradeInfo(">>>总共删除[" + str(result) + "]条记录")

        #TradeContext.tradeResponse.append(['O1USERNAME',     TradeContext.USERNAME])       #用户名称
        #TradeContext.tradeResponse.append(['O1IDTYPE',       TradeContext.IDTYPE])         #证件类型
        #TradeContext.tradeResponse.append(['O1IDCODE',       TradeContext.IDCODE])         #证件号码

        return True

    except Exception, e:
        AfaLoggerFunc.tradeFatal( str(e) )
        return ExitSubTrade( '9999', '注销企业协议信息异常')
Ejemplo n.º 10
0
def upDate_ahjf_officecode( ):
    try:
        selectSql = "select * from ahjf_officecode "
        whereSql  = " where  OFFICECODE='" + TradeContext.OFFICECODE    + "'"
        
        selectSql = selectSql + whereSql
        AfaLoggerFunc.tradeInfo( '基础数据查询sql:' + selectSql)
        selectRecord = AfaDBFunc.SelectSql( selectSql )
        
        if selectRecord == None:
            AfaLoggerFunc.tradeInfo('>>>查询数据库异常')
            return False
        if len(selectRecord) > 0:
            AfaLoggerFunc.tradeInfo('>>>数据已存在,做更新操作')
            
            updateSql = "update ahjf_officecode set "
            updateSql = updateSql + "OFFICENAME     ='" + TradeContext.OFFICENAME     + "'"
        
            updateSql = updateSql + whereSql
            AfaLoggerFunc.tradeInfo( '基础数据更新sql:' + updateSql)
            updateRecord = AfaDBFunc.UpdateSqlCmt( updateSql )
            if updateRecord <  0:
                AfaLoggerFunc.tradeInfo( "更新基础数据失败" )
                return False
        else:
            AfaLoggerFunc.tradeInfo('>>>数据不存在,登记新的数据')
            
            insertSql = "insert into ahjf_officecode(OFFICECODE,OFFICENAME,NOTE1,NOTE2) values("
            insertSql = insertSql + "'" + TradeContext.OFFICECODE    + "',"      #采集机关代码
            insertSql = insertSql + "'" + TradeContext.OFFICENAME + "',"         #采集机关名称
            insertSql = insertSql + "'',"                                        #备用1
            insertSql = insertSql + "'')"                                        #备用2
            
            AfaLoggerFunc.tradeInfo( '基础数据登记sql:' + insertSql)
            insertRecord = AfaDBFunc.InsertSqlCmt( insertSql )
            
            if insertRecord < 0:
                AfaLoggerFunc.tradeInfo( '>>>登记基础更新数据失败数据失败' )
                return False
            return True
    except Exception, e:
        AfaLoggerFunc.tradeInfo( str(e) )
        return False
Ejemplo n.º 11
0
def insertCmt( insert_dict ):
    if not chk(insert_dict):
        return -1 

    sql = "INSERT INTO rcc_ztcbka (" + ','.join(table_tuple) + ") VALUES ( "
    for table_item in table_tuple:
        if table_dict[table_item] == 'S':
            if insert_dict.has_key(table_item):
                sql = sql + "'" + insert_dict[table_item] + "',"
            else:
                sql = sql + "'',"
        else:
            if insert_dict.has_key(table_item) and str(insert_dict[table_item]) != '':
                sql = sql + str(insert_dict[table_item]) + ","
            else:
                sql = sql + "0,"
    sql = sql[0:-1] + ")"

    AfaLoggerFunc.tradeInfo(sql)
    return AfaDBFunc.InsertSqlCmt( sql )
Ejemplo n.º 12
0
                #如果没有查找到退付编号
                if len( records )==0:

                    #将记录集写到数据库中
                    fields  =   "AFC306,AAA010,AFC041,AFA050,AFC061,AFC062,AFC063,AFC064,AAZ016,AFC060,AAZ015,DATE,TIME"
                    sqlstr  =   "INSERT INTO FS_FC06(" + fields + ") VALUES("
                    for item in rec[i].split( sep ):
                        sqlstr  =  sqlstr   +  "'" + item + "',"

                    sqlstr      =  sqlstr +  "'" + TradeContext.workDate  + "',"
                    sqlstr      =  sqlstr +  "'" + TradeContext.workTime  + "')"

                    AfaLoggerFunc.tradeInfo( sqlstr )

                    if( AfaDBFunc.InsertSqlCmt( sqlstr ) < 1 ):
                        AfaLoggerFunc.tradeInfo ( "插入数据库失败"  + AfaDBFunc.sqlErrMsg )

                #如果查找到了退付编号,则更新状态位
                else:

                    AfaLoggerFunc.tradeInfo( '更新操作' )

                    sqlstr  =   "update fs_fc06 set aaz015='" + (rec[i].split( sep ))[10] + "' where afc060='" + (rec[i].split( sep ))[9] + "'"
                    sqlstr  =   sqlstr + " AND AFC306='" + (rec[i].split( sep ))[0] + "'"
                    sqlstr  =   sqlstr + " AND AAA010='" + (rec[i].split( sep ))[1] + "'"

                    AfaLoggerFunc.tradeInfo( sqlstr )

                    if( AfaDBFunc.UpdateSqlCmt( sqlstr ) < 1 ):
                        TradeContext.errorCode, TradeContext.errorMsg='0001', '更新退付状态失败'
Ejemplo n.º 13
0
def AddUserInfo():
    
    sql = "SELECT * FROM ABDT_USERINFO WHERE STATUS='1'"
    sql = sql + " AND ZONENO = '" + TradeContext.ZONENO + "'"
    sql = sql + " AND BRNO = '"   + TradeContext.BRNO   + "'"
    sql = sql + " AND USERNO = '" + TradeContext.USERNO + "'"
    
    records =  AfaDBFunc.SelectSql( sql )
        
    if( records == None ) :
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return ExitSubTrade( '9999', '查询用户信息异常' )

    if( len(records) > 0 ) :
        return ExitSubTrade( '9000', '该用户已经被注册,不能再次注册' )

    sql = "INSERT INTO ABDT_USERINFO("
    sql = sql + "ZONENO,"
    sql = sql + "BRNO,"
    sql = sql + "USERNO,"
    sql = sql + "USERNAME,"
    sql = sql + "ADDRESS,"
    sql = sql + "TEL,"
    sql = sql + "REGDATE,"
    sql = sql + "REGTIME,"
    sql = sql + "PASSWORD,"
    sql = sql + "DUTYNO,"
    sql = sql + "STATUS,"
    sql = sql + "NOTE1,"
    sql = sql + "NOTE2,"
    sql = sql + "NOTE3,"
    sql = sql + "NOTE4,"
    sql = sql + "NOTE5)"

    sql = sql + " VALUES ("

    sql = sql + "'" + TradeContext.ZONENO   + "',"            #地区代码
    sql = sql + "'" + TradeContext.BRNO     + "',"            #机构代码
    sql = sql + "'" + TradeContext.USERNO   + "',"            #用户号
    sql = sql + "'" + TradeContext.USERNAME + "',"            #用户名
    sql = sql + "'" + TradeContext.ADDRESS  + "',"            #地址
    sql = sql + "'" + TradeContext.TEL      + "',"            #电话
    sql = sql + "'" + TradeContext.TranDate + "',"            #日期
    sql = sql + "'" + TradeContext.TranTime + "',"            #时间
    sql = sql + "'" + TradeContext.PASSWD   + "',"            #密码
    sql = sql + "'" + TradeContext.DUTYNO   + "',"            #岗位编码
    sql = sql + "'" + '1'                   + "',"            #状态
    sql = sql + "'" + ''                    + "',"            #备用
    sql = sql + "'" + ''                    + "',"            #备用
    sql = sql + "'" + ''                    + "',"            #备用
    sql = sql + "'" + ''                    + "',"            #备用
    sql = sql + "'" + ''                    + "')"            #备用

    AfaLoggerFunc.tradeInfo(sql)

    ret = AfaDBFunc.InsertSqlCmt( sql )
    if (ret <= 0):
        AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
        return ExitSubTrade( '9000', '用户注册失败' )

    return True
Ejemplo n.º 14
0
def SubModuleMainFst( ):
    AfaLoggerFunc.tradeInfo( '进入三方协议验证/撤消[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )

    try:
        #=============获取当前系统时间====================
        #TradeContext.workDate=UtilTools.GetSysDate( )
        TradeContext.workTime=UtilTools.GetSysTime( )
        
        ##====获取工作日期=======
        #if not TipsFunc.GetUnitWorkdate( ):
        #    return False
        
        #============校验公共节点的有效性==================
        # 完整性检查
        if( not TradeContext.existVariable( "VCSign" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '标识[VCSign]值不存在!' )
        if( not TradeContext.existVariable( "zoneno" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '分行号[zoneno]值不存在!' )
        if( not TradeContext.existVariable( "channelCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '渠道代码[channelCode]值不存在!' )
        if( not TradeContext.existVariable( "brno" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '行所号[brno]值不存在!' )
        if( not TradeContext.existVariable( "teller" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '柜员号[teller]值不存在!' )
        if( not TradeContext.existVariable( "accno" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '帐号[accno]值不存在!' )
        if( not TradeContext.existVariable( "taxPayCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '纳税人编码[taxPayCode]值不存在!' )
        if( not TradeContext.existVariable( "taxPayName" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '纳税人名称[taxPayName]值不存在!' )
        if( not TradeContext.existVariable( "passWDFlag" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '密码验证标志[passWDFlag]值不存在!' )
        if( not TradeContext.existVariable( "payBkCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '清算行行号[payBkCode]值不存在!' )
            
        TradeContext.note2 = TradeContext.payBkCode    #付款行行号
        
        AfaLoggerFunc.tradeInfo((TradeContext.accno)[0])
        if((TradeContext.accno)[0] == '1'):
            if(TradeContext.passWDFlag == '0'):
                #验证密码
                TradeContext.sBrNo = TradeContext.brno          #交易机构
                TradeContext.sTeller = TradeContext.teller      #交易柜员
                TradeContext.sTermId = TradeContext.termId      #终端号 
                HostContext.I1ACNO = TradeContext.accno         #付款帐户
                HostContext.I1CYNO = '01'
                accnoLen = len(TradeContext.accno)
                if(accnoLen == 23):
                    HostContext.I1CFFG = 'A'
                elif(accnoLen == 19):
                    HostContext.I1CFFG = '0'
                    HostContext.I1CETY = (TradeContext.accno)[6:8]
                    HostContext.I1CCSQ = (TradeContext.accno)[8:19]
                else:
                    return TipsFunc.ExitThisFlow( 'A0001', '帐号错误!' )
                HostContext.I1PSWD = TradeContext.passWD    
                
                if(not TipsHostFunc.CommHost('8810')):    
                    return TipsFunc.ExitThisFlow( TradeContext.errorCode, TradeContext.errorMsg )
                if(TradeContext.errorCode == '0000'):
                    if(HostContext.O1CFFG == '1'):
                        return TipsFunc.ExitThisFlow( 'A0001', '密码错误!' )
        
        #=============判断应用状态====================
        if not TipsFunc.ChkAppStatus( ) :
            raise TipsFunc.flowException( )
        #=============判断机构是否开通此应用===============
        #if not TipsFunc.ChkBranchStatus( ) :
        #    raise TipsFunc.flowException( )
        #=============获取平台流水号==================== 
        if TipsFunc.GetSerialno( ) == -1 :
            raise TipsFunc.flowException( )
        
        #签约
        if TradeContext.VCSign=='0':
            #=============判断状态====================
            sql="SELECT STATUS FROM TIPS_CUSTINFO WHERE "
            sql=sql+" TAXORGCODE ='"+TradeContext.taxOrgCode     +"'"
            sql=sql+" AND TAXPAYCODE='"+TradeContext.taxPayCode+"'"
            sql=sql+" AND PROTOCOLNO='"+TradeContext.protocolNo+"'"
            sql=sql+" AND PAYACCT='"+TradeContext.accno+"'"
            records = AfaDBFunc.SelectSql(sql)
            AfaLoggerFunc.tradeFatal(sql)
            if( records == None or  records <0):
                #AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            elif( len( records )==0 ):
                AfaLoggerFunc.tradeInfo( "该客户尚未签约,可正常处理" )
            else:
                AfaLoggerFunc.tradeFatal(sql)
                AfaLoggerFunc.tradeInfo(records[0][0])
                UtilTools.ListFilterNone( records )
                #0-注销 1-正常(双方都已验证) 2-临时状态(银行方柜面已验证)3-临时状态(银行方柜面已撤销)
                if (records[0][0]=="1" or records[0][0]=="2" ): #已有该客户记录,状态为"已启用",不允许签约
                    return TipsFunc.ExitThisFlow( 'A0002', '客户编号或帐号已经签约,不能重复签约')
            TradeContext.status = '2'
            #TradeContext.revTranF       ='0' #正交易
            #TradeContext.tradeType      ='S' #签约类交易
            #TradeContext.amount         ='0' #
            #TradeContext.__agentAccno__ =''  #借方帐号置空
            ##记录签约流水
            #if not TipsFunc.InsertDtl( ) :
            #    return False
            #=============与第三方通讯====================
            #AfaAfeFunc.CommAfe()
            TradeContext.__status__='0'
            TradeContext.errorCode='0000'
            TradeContext.errorMsg='交易成功'
            
            ##=============更新流水表====================
            #if( not TipsFunc.UpdateDtl( 'TRADE' ) ):
            #    return False

            if TradeContext.errorCode!='0000':
                return TipsFunc.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
            if ( len( records )!=0 ):
                sql="update TIPS_CUSTINFO set "
                sql=sql+" PAYACCT         ='"+TradeContext.accno      +"'"
                sql=sql+",STATUS     ='"+'2'                     +"'"
                sql=sql+",TAXPAYNAME      ='"+TradeContext.taxPayName  +"'"
                sql=sql+",HANDORGNAME      ='"+TradeContext.handOrgName  +"'"
                sql=sql+",STARTDATE     ='"+TradeContext.workDate   +"'"
                sql=sql+",ZONENO     ='"+TradeContext.zoneno     +"'"
                sql=sql+",BRNO       ='"+TradeContext.brno       +"'"
                sql=sql+",TELLERNO   ='"+TradeContext.teller   +"'"
                if( TradeContext.existVariable( "NOTE1" ) ):
                    sql=sql+",NOTE1         ='"+TradeContext.note1   +"'"
                if( TradeContext.existVariable( "NOTE2" ) ):
                    sql=sql+",NOTE2         ='"+TradeContext.note2   +"'"
                if( TradeContext.existVariable( "NOTE3" ) ):
                    sql=sql+",NOTE3         ='"+TradeContext.note3   +"'"
                if( TradeContext.existVariable( "NOTE4" ) ):
                    sql=sql+",NOTE4         ='"+TradeContext.note4   +"'"
                if( TradeContext.existVariable( "NOTE5" ) ):
                    sql=sql+",NOTE5         ='"+TradeContext.note5   +"'"
                sql=sql+" WHERE TAXORGCODE ='"+TradeContext.taxOrgCode     +"'"
                sql=sql+" AND TAXPAYCODE ='"+TradeContext.taxPayCode     +"'"
                AfaLoggerFunc.tradeInfo(sql)
                if( AfaDBFunc.UpdateSqlCmt(sql) == -1 ):
                    AfaLoggerFunc.tradeFatal(sql)
                    return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            else:                 
                sql="insert into TIPS_CUSTINFO(TAXPAYCODE,TAXORGCODE,PROTOCOLNO,PAYACCT,IDTYPE,IDCODE,TAXPAYNAME,STATUS,"
                sql=sql+"HANDORGNAME,STARTDATE,ENDDATE,ZONENO,BRNO,TELLERNO,WORKDATE,PAYOPBKCODE,"
                sql=sql+"NOTE1,NOTE2,NOTE3,NOTE4,NOTE5)"
                sql=sql+" values"
                sql=sql+"('"+TradeContext.taxPayCode    +"'"
                sql=sql+",'"+TradeContext.taxOrgCode    +"'"
                sql=sql+",'"+TradeContext.protocolNo+"'"
                sql=sql+",'"+TradeContext.accno     +"'"
                sql=sql+",'',''"
                sql=sql+",'"+TradeContext.taxPayName +"'"
                sql=sql+",'2'" #临时状态,待第三方验证后改为1
                if( TradeContext.existVariable( "handOrgName" ) ):
                    sql=sql+",'"+TradeContext.handOrgName    +"'"
                else:
                    sql=sql+",''"
                #if( TradeContext.existVariable( "custAdd" ) ):
                #    sql=sql+",'"+TradeContext.custAdd    +"'"
                #else:
                #    sql=sql+",''"
                #if( TradeContext.existVariable( "zipCode" ) ):
                #    sql=sql+",'"+TradeContext.zipCode    +"'"
                #else:
                #    sql=sql+",''"
                #if( TradeContext.existVariable( "email" ) ):
                #    sql=sql+",'"+TradeContext.email    +"'"
                #else:
                #    sql=sql+",''"
                sql=sql+",'"+TradeContext.workDate    +"'"
                sql=sql+",''"
                sql=sql+",'"+TradeContext.zoneno      +"'"
                sql=sql+",'"+TradeContext.brno    +"'"
                sql=sql+",'"+TradeContext.teller    +"'"
                sql=sql+",'"+TradeContext.workDate    +"'"
                sql=sql+",'"+TradeContext.payOpBkCode    +"'"
                if( TradeContext.existVariable( "note1" ) ):
                    sql=sql+",'"+TradeContext.note1    +"'"
                else:
                    sql=sql+",''"
                if( TradeContext.existVariable( "note2" ) ):
                    sql=sql+",'"+TradeContext.note2    +"'"
                else:
                    sql=sql+",''"          
                if( TradeContext.existVariable( "note3" ) ):
                    sql=sql+",'"+TradeContext.note3    +"'"
                else:
                    sql=sql+",''"
                if( TradeContext.existVariable( "note4" ) ):
                    sql=sql+",'"+TradeContext.note4    +"'"
                else:
                    sql=sql+",''"
                if( TradeContext.existVariable( "note5" ) ):
                    sql=sql+",'"+TradeContext.note5    +"'"
                else:
                    sql=sql+",''"
                sql=sql+")"
                AfaLoggerFunc.tradeInfo(sql)
                records=AfaDBFunc.InsertSqlCmt(sql)
                if( records == 0 ):
                    return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
                
                if( records == -1 ):
                    return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
                AfaLoggerFunc.tradeInfo('***************')
        elif TradeContext.VCSign=='1':
            #=============判断状态====================
            sql="SELECT STATUS"
            sql=sql+" FROM TIPS_CUSTINFO WHERE TAXPAYCODE ='"+TradeContext.taxPayCode +"'"
            sql=sql+" and PAYACCT     ='"+TradeContext.accno  +"'"
            sql=sql+" and PROTOCOLNO  ='"+TradeContext.protocolNo  +"'"
            sql=sql+" and TAXORGCODE  ='"+TradeContext.taxOrgCode  +"'"
            AfaLoggerFunc.tradeInfo(sql)
            records = AfaDBFunc.SelectSql(sql)
            if( records == None or  records <0):
                AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            elif( len( records )==0 ):
                #begin 20101102 蔡永贵修改
                #return TipsFunc.ExitThisFlow( 'A0027', '该客户三方协议尚未验证,无法撤消' )
                return TipsFunc.ExitThisFlow( 'A0027', '该客户不存在三方协议,请检查录入项是否正确' )
                #end
            elif( len( records )>1 ):
                return TipsFunc.ExitThisFlow( 'A0027', '存在多条验证记录' )
            else:
                AfaLoggerFunc.tradeFatal(sql)
                AfaLoggerFunc.tradeInfo(records[0][0])
                UtilTools.ListFilterNone( records )
                if (records[0][0]=='0' or records[0][0]=='3'):
                    return TipsFunc.ExitThisFlow( 'A0027', '三方协议状态为已撤消,不能重复撤消' )
                if (records[0][0]=='2'):
                    #begin 20101102 蔡永贵修改
                    #return TipsFunc.ExitThisFlow( 'A0027', '第三方未验证,只能做删除交易,不能解约' )
                    return TipsFunc.ExitThisFlow( 'A0027', '第三方未验证,不能解约,请做删除交易' )
                    #end
            TradeContext.status = '3'

            #TradeContext.revTranF       ='0' #正交易
            #TradeContext.tradeType      ='U' #解约类交易
            #TradeContext.amount         ='0' #
            #TradeContext.__agentAccno__ =''  #借方帐号置空
            ##记录签约流水
            #if not TipsFunc.InsertDtl( ) :
            #    return False
            #=============与第三方通讯通讯====================
            #AfaAfeFunc.CommAfe()

            TradeContext.__status__='0'
            TradeContext.errorCode='0000'
            TradeContext.errorMsg='交易成功'

            ##=============更新流水表====================
            #if( not TipsFunc.UpdateDtl( 'TRADE' ) ):
            #    return False

            #if TradeContext.errorCode!='0000':
            #    return TipsFunc.ExitThisFlow(TradeContext.errorCode, TradeContext.errorMsg)
            #if TradeContext.errorCode=='0000':
            
            sql="update TIPS_CUSTINFO set "
            sql=sql+" STATUS     ='"+'3'                     +"'"
            sql=sql+",ENDDATE      ='"+TradeContext.workDate   +"'"
            sql=sql+",ZONENO     ='"+TradeContext.zoneno     +"'"
            sql=sql+",BRNO       ='"+TradeContext.brno       +"'"
            sql=sql+",TELLERNO   ='"+TradeContext.teller   +"'"
            sql=sql+" WHERE TAXPAYCODE ='"  +TradeContext.taxPayCode   +"'"
            sql=sql+" AND PAYACCT ='"       +TradeContext.accno        +"'"
            sql=sql+" AND PROTOCOLNO  ='"   +TradeContext.protocolNo   +"'"
            sql=sql+" AND TAXORGCODE  ='"   +TradeContext.taxOrgCode   +"'"
            AfaLoggerFunc.tradeInfo(sql)
            if( AfaDBFunc.UpdateSqlCmt(sql) == -1 ):
                AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
        #=============自动打包==================== 
        TradeContext.errorCode='0000'
        TradeContext.errorMsg='交易成功'
        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '退出三方协议验证/撤消['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
        return True
    except TipsFunc.flowException, e:
        return False
Ejemplo n.º 15
0
def InsertDtl( ):

    AfaLoggerFunc.tradeInfo( '>>>插入流水表' )

    #流水表的列数-1
    count=52
    TransDtl=[[]]*( count+1 )
    TransDtl[0] = TradeContext.agentSerialno                    # AGENTSERIALNO 代理业务流水号
    TransDtl[1] = TradeContext.workDate                         # WORKDATE      交易日期
    TransDtl[2] = TradeContext.workTime                         # WORKTIME      交易时间
    TransDtl[3] = TradeContext.sysId                            # SYSID         系统标识
    TransDtl[4] = TradeContext.unitno                           # UNITNO        商户单位代码
    TransDtl[5] = TradeContext.subUnitno                        # SUBUNITNO     商户分支单位代码
    TransDtl[6] = TradeContext.agentFlag                        # AGENTFLAG     业务方式
    TransDtl[7] = TradeContext.TransCode                        # TRXCODE       交易码
    TransDtl[8] = TradeContext.zoneno                           # ZONENO        分行号
    TransDtl[9] = TradeContext.brno                             # BRNO          行所号
    TransDtl[10]= TradeContext.tellerno                         # TELLERNO      柜员号
    TransDtl[11]= TradeContext.cashTelno                        # CASHTELNO     出纳员号

    if( TradeContext.existVariable( "authTeller" ) ) :
        TransDtl[12] = TradeContext.authTeller                  # AUTHTELLERNO  授权柜员号  
    else:
        TransDtl[12] = ''

    TransDtl[13] = TradeContext.channelCode                     # CHANNELCODE   渠道代码

    if( TradeContext.existVariable( "channelSerno" ) ):
        TransDtl[14] = TradeContext.channelSerno                # CHANNELSERNO  渠道交易流水号
    else:
        TransDtl[14]=''

    if( TradeContext.existVariable( "termId" ) ):
        TransDtl[15] = TradeContext.termId                      # TERMID        终端号
    else:
        TransDtl[15]=''

    if( TradeContext.existVariable( "customerId" ) ):
        TransDtl[16] = TradeContext.customerId                  # CUSTOMERID    客户注册号
    else:
        TransDtl[16]=''

    TransDtl[17] = TradeContext.userno                          # USERNO        用户号  

    if( TradeContext.existVariable( "subUserno" ) ):
        TransDtl[18] = TradeContext.subUserno                   # SUBUSERNO     附加用户号  
    else:
        TransDtl[18] = ''

    if( TradeContext.existVariable( "userName" ) ):
        TransDtl[19] = TradeContext.userName                    # USERNAME      用户名称  
    else:
        TransDtl[19] = '' 

    if( TradeContext.existVariable( "accType" ) ):
        TransDtl[20] = TradeContext.accType                     # ACCTYPE       帐户类型
    else:
        TransDtl[20] = '000'


    #单位帐号
    if( TradeContext.existVariable( "__agentAccno__" ) ):
        agentAccno = TradeContext.__agentAccno__
    else:
        agentAccno = ''


    #客户帐号
    if( TradeContext.existVariable( "accno" ) ):
        accno = TradeContext.accno
    else:
        accno = ''

 
    if( int( TradeContext.revTranF ) == 0 ):
        #业务方式(01-代收 02-代付 03-批扣 04-批付)
        if( int( TradeContext.agentFlag ) == 1 or int( TradeContext.agentFlag ) == 3 ):
            TransDtl[21] = accno                                # DRACCNO       借方帐号
            TransDtl[22] = agentAccno                           # CRACCNO       贷方帐号 
            TradeContext.__drAccno__ = accno
            TradeContext.__crAccno__ = agentAccno
        else:
            TransDtl[21] = agentAccno
            TransDtl[22] = accno
            TradeContext.__drAccno__ = agentAccno
            TradeContext.__crAccno__ = accno
    else:
        TransDtl[21] = TradeContext.__drAccno__                 # DRACCNO       借方帐号
        TransDtl[22] = TradeContext.__crAccno__                 # DRACCNO       贷方帐号


    if( TradeContext.existVariable( "vouhType" ) ):
        TransDtl[23] = TradeContext.vouhType                    # VOUHTYPE      凭证种类  
    else:
        TransDtl[23] = ''


    if( TradeContext.existVariable( "vouhno" ) ):
        TransDtl[24] = TradeContext.vouhno                      # VOUHNO        凭证号  
    else:
        TransDtl[24] = ''


    if( TradeContext.existVariable( "vouhDate" ) ):
        TransDtl[25] = TradeContext.vouhDate                    # VOUHDATE      凭证日期  
    else:
        TransDtl[25] = ''


    if( TradeContext.existVariable( "currType" ) ):
        TransDtl[26] = TradeContext.currType                    # CURRTYPE      币种
    else:
        TransDtl[26] = '1'

    
    if( TradeContext.existVariable( "currFlag" ) ):
        TransDtl[27] = TradeContext.currFlag                    # CURRFLAG      钞汇标志
    else:
        TransDtl[27] = '0'


    TransDtl[28] = TradeContext.amount                          # AMOUNT        交易金额


    if( TradeContext.existVariable( "subAmount" ) ):
        TransDtl[29] = TradeContext.subAmount                   # SUBAMOUNT     附加金额  
    else:
        TransDtl[29] = ''


    TransDtl[30] = TradeContext.revTranF                        # REVTRANF      反交易标志(0-正交易 1-反交易 2-自动冲正)
                                               
    if( int( TradeContext.revTranF ) != 0 ):
        TransDtl[31] = TradeContext.preAgentSerno               # PREAGENTSERNO 原平台流水号  
    else:
        TransDtl[31] = ''

    TransDtl[32] = '2'                                          # BANKSTATUS    银行.交易状态(0-正常 1-失败 2-异常 3-已冲正)
    TransDtl[33] = ''                                           # BANKCODE      银行.交易返回码
    TransDtl[34] = ''                                           # BANKSERNO     银行.交易流水号

    TransDtl[35] = '2'                                          # CORPSTATUS    企业.交易状态(0-正常 1-失败 2-异常 3-已冲正)
    TransDtl[36] = ''                                           # CORPCODE      企业.交易返回码
    TransDtl[37] = ''                                           # CORPSERNO     企业.交易流水号
    TransDtl[38] = ''                                           # CORPTIME      企业.时间戳

    TransDtl[39] = ''                                           # ERRORMSG      交易返回信息
                                                                
    TransDtl[40] = '9'                                          # CHKFLAG       主机对帐标志(0-已对帐,交易成功 1-已对帐,交易失败, 9-未对帐) 
                                                                
    TransDtl[41] = '9'                                          # CORPCHKFLAG   企业对帐标志(0-已对帐,交易成功 1-已对帐,交易失败, 9-未对帐)

    TransDtl[42] = TradeContext.__agentEigen__[4]               # APPENDFLAG    从表使用标志(0-不使用 1-使用)

    if( TradeContext.existVariable( "note1" ) ):                # NOTE1         备注1
        TransDtl[43] = TradeContext.note1
    else:
        TransDtl[43] = ''

    if( TradeContext.existVariable( "note2" ) ):
        TransDtl[44] = TradeContext.note2                       # NOTE2         备注2
    else:                                                       
        TransDtl[44] = ''                                       
                                                                
    if( TradeContext.existVariable( "note3" ) ):                
        TransDtl[45] = TradeContext.note3                       # NOTE3         备注3
    else:                                                       
        TransDtl[45] = ''                                       
                                                                
    if( TradeContext.existVariable( "note4" ) ):                
        TransDtl[46] = TradeContext.note4                       # NOTE4         备注4
    else:                                                       
        TransDtl[46] = ''                                       
                                                                
    if( TradeContext.existVariable( "note5" ) ):                
        TransDtl[47] = TradeContext.note5                       # NOTE5         备注5
    else:                                                       
        TransDtl[47] = ''                                       
                                                                
    if( TradeContext.existVariable( "note6" ) ):                
        TransDtl[48] = TradeContext.note6                       # NOTE6         备注6
    else:                                                       
        TransDtl[48] = ''                                       
                                                                
    if( TradeContext.existVariable( "note7" ) ):                
        TransDtl[49] = TradeContext.note7                       # NOTE7         备注7
    else:                                                       
        TransDtl[49] = ''                                       
                                                                
    if( TradeContext.existVariable( "note8" ) ):                
        TransDtl[50] = TradeContext.note8                       # NOTE8         备注8
    else:                                                       
        TransDtl[50] = ''                                       
                                                                
    if( TradeContext.existVariable( "note9" ) ):                
        TransDtl[51] = TradeContext.note9                       # NOTE9         备注9
    else:                                                       
        TransDtl[51] = ''                                       
                                                                
    if( TradeContext.existVariable( "note10" ) ):               
        TransDtl[52] = TradeContext.note10                      # NOTE10        备注10
    else:
        TransDtl[52] = ''

    sql = "INSERT INTO AFA_MAINTRANSDTL(AGENTSERIALNO,WORKDATE,"
    sql = sql + "WORKTIME,SYSID,UNITNO,SUBUNITNO,AGENTFLAG,TRXCODE,ZONENO,BRNO,TELLERNO,CASHTELNO,"
    sql = sql + "AUTHTELLERNO,CHANNELCODE,CHANNELSERNO,TERMID,CUSTOMERID,USERNO,SUBUSERNO,USERNAME,"
    sql = sql + "ACCTYPE,DRACCNO,CRACCNO,VOUHTYPE,VOUHNO,VOUHDATE,"
    sql = sql + "CURRTYPE,CURRFLAG,AMOUNT,SUBAMOUNT,REVTRANF,PREAGENTSERNO,BANKSTATUS,BANKCODE,"
    sql = sql + "BANKSERNO,CORPSTATUS,CORPCODE,CORPSERNO,CORPTIME,ERRORMSG,CHKFLAG,CORPCHKFLAG,"
    sql = sql + "APPENDFLAG,NOTE1,NOTE2,NOTE3,NOTE4,NOTE5,NOTE6,NOTE7,NOTE8,NOTE9,"
    sql = sql + "NOTE10) VALUES("
    
    i=0
    for i in range( 0, count ):
        if( type( TransDtl[i] ) is int ):
            sql=sql+str( TransDtl[i] )+","
        else:
            sql=sql+"'"+ TransDtl[i]+"',"
            
    sql=sql+"'"+TransDtl[count]+"')"

    AfaLoggerFunc.tradeInfo( sql )
    
    result=AfaDBFunc.InsertSqlCmt( sql )
        
    if( result < 1 ):
        TradeContext.errorCode, TradeContext.errorMsg='A0044', '插入流水主表失败'+AfaDBFunc.sqlErrMsg
        return False

    else:
        #特征码:子表使用标志(反交易忽略)
        if ( TradeContext.__agentEigen__[4]=='1' and TradeContext.revTranF=='0' ):
            if( not SubTransDtlProc( '1' ) ):
                TradeContext.errorCode, TradeContext.errorMsg='A0040', '子表操作失败'
                return False

        return True
Ejemplo n.º 16
0
def SubModuleMainFst( ):
    AfaLoggerFunc.tradeInfo('财税库行_TIPS发起明细对账_前处理[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
    try:
        #============变量值的有效性校验============
        if( not TradeContext.existVariable( "chkAcctOrd" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '[chkAcctOrd]值不存在!' )
        if( not TradeContext.existVariable( "chkDate" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '[chkDate]值不存在!' )
        
        #====判断应用状态=======
        if not TipsFunc.ChkAppStatus():
            return False
                   
        #查询是否重复批次
        AfaLoggerFunc.tradeInfo( '>>>查询是否重复批次' )
        sqlStr = "SELECT DEALSTATUS,WORKDATE,BATCHNO,PAYBKCODE,PAYEEBANKNO,ERRORCODE,ERRORMSG,NOTE2 FROM TIPS_CHECKADM WHERE "
        sqlStr =sqlStr +"  WORKDATE  = '"       + TradeContext.chkDate.strip()         + "'"
        sqlStr =sqlStr +"and BATCHNO   = '"     + TradeContext.chkAcctOrd.strip()      + "'"
        sqlStr =sqlStr +"and PAYEEBANKNO   = '" + TradeContext.payeeBankNo.strip()      + "'"
        sqlStr =sqlStr +"and PAYBKCODE   = '"   + TradeContext.payBkCode.strip()      + "'"
        sqlStr =sqlStr +"and NOTE3   = '"   + TradeContext.CurPackNo.strip()      + "'"
        
        Records = AfaDBFunc.SelectSql( sqlStr )
        AfaLoggerFunc.tradeInfo(sqlStr)
        if( Records == None ):
            AfaLoggerFunc.tradeFatal('批量管理表操作异常:'+AfaDBFunc.sqlErrMsg)
            return TipsFunc.ExitThisFlow( 'A0027', '数据库错,批量管理表操作异常' )
        elif(len(Records)>0):
            if Records[0][0]=='2': #重复包,且正在处理
                AfaLoggerFunc.tradeInfo( '>>>重复包,且正在处理,直接返回94052' )
                TradeContext.tradeResponse.append(['errorCode','94052'])
                TradeContext.tradeResponse.append(['errorMsg','包重复'])
                return True
            elif Records[0][0]=='0' : #已处理完成,成功或者失败,直接回执
                #发起扣税回执交易
                AfaLoggerFunc.tradeInfo( '>>>已处理完成,成功或者失败,直接回执2111' )
                TradeContext.OriChkDate    =Records[0][1]
                TradeContext.OriChkAcctOrd =Records[0][2]
                TradeContext.OriPayBankNo  =Records[0][3]
                TradeContext.OriPayeeBankNo=Records[0][4]
                TradeContext.Result        =Records[0][5]
                TradeContext.AddWord       =Records[0][6]
                subModuleName = 'TTPS001_032111'       
                subModuleHandle=__import__( subModuleName )
                AfaLoggerFunc.tradeInfo( '执行['+subModuleName+']模块' )
                if not subModuleHandle.SubModuleMainFst( ) :
                    return TipsFunc.flowException( )
                TradeContext.tradeResponse.append(['errorCode','94052'])
                TradeContext.tradeResponse.append(['errorMsg','批次已处理完成'])
                return True
            else: #重复包,重新对账
                AfaLoggerFunc.tradeInfo( '>>>重复包,重新对账' )
                if int(TradeContext.pageSerno.strip())==1:
                    #尚未处理的重复批次,按新批次处理,删掉旧数据
                    sqlStr_d_t = "DELETE FROM  TIPS_CHECKDATA WHERE "
                    sqlStr_d_t = sqlStr_d_t +"  workDate  = '"      + TradeContext.chkDate              + "'"
                    sqlStr_d_t = sqlStr_d_t +" and Batchno   = '"   + TradeContext.chkAcctOrd           + "'"
                    sqlStr_d_t = sqlStr_d_t +" AND PAYEEBANKNO ='"  + TradeContext.payeeBankNo.strip()    + "'"   
                    sqlStr_d_t = sqlStr_d_t +" AND PAYBKCODE   ='"  + TradeContext.payBkCode.strip()  + "'"
                    sqlStr_d_t = sqlStr_d_t +" AND NOTE3   = '"     + TradeContext.CurPackNo.strip()  + "'"
                    AfaLoggerFunc.tradeInfo(sqlStr_d_t )
                    if( AfaDBFunc.DeleteSqlCmt( sqlStr_d_t ) <0 ):
                        return TipsFunc.ExitThisFlow( 'A0027', '数据库错,批量管理表操作异常' )
                    sqlStr_d_b = "DELETE FROM  TIPS_CHECKADM WHERE "
                    sqlStr_d_b =sqlStr_d_b +" WORKDATE  = '"        + TradeContext.chkDate.strip()     + "'"
                    sqlStr_d_b =sqlStr_d_b +"and BATCHNO   = '"     + TradeContext.chkAcctOrd.strip()  + "'"
                    sqlStr_d_b =sqlStr_d_b +"and PAYEEBANKNO   = '" + TradeContext.payeeBankNo.strip() + "'"
                    sqlStr_d_b =sqlStr_d_b +"and PAYBKCODE     = '" + TradeContext.payBkCode.strip()   + "'"
                    sqlStr_d_b =sqlStr_d_b +"and NOTE3     = '"     + TradeContext.CurPackNo.strip()   + "'"
                    AfaLoggerFunc.tradeInfo(sqlStr_d_b )
                    if( AfaDBFunc.DeleteSqlCmt( sqlStr_d_b ) <0 ):
                        return TipsFunc.ExitThisFlow( 'A0027', '数据库错,批量管理表操作异常' )
                else:
                    if int(TradeContext.pageSerno.strip())!=int(Records[0][7].strip())+1:
                        #页序号错误
                        TradeContext.tradeResponse.append(['errorCode','A0002'])
                        TradeContext.tradeResponse.append(['errorMsg','页序号错误'])
                        return True
            
        #新的批次,对账明细入库
        AfaLoggerFunc.tradeInfo( '>>>新的批次,对账明细入库' )
        recNum=int(TradeContext.pageNum)
        AfaLoggerFunc.tradeInfo(str(recNum))
        for i in range( 0, recNum ):
            sql="insert into TIPS_CHECKDATA(WORKDATE,BATCHNO,CORPSERIALNO,PAYEEBANKNO,PAYBKCODE,TAXVOUNO,ACCNO,AMOUNT,"
            sql=sql+"STATUS,NOTE3)"
            sql=sql+" values"
            if recNum==1:
                sql=sql+"('"+TradeContext.chkDate           +"'"
                sql=sql+",'"+TradeContext.chkAcctOrd            +"'"
                sql=sql+",'"+TradeContext.cNo            +"'"
                sql=sql+",'"+TradeContext.payeeBankNo       +"'"
                sql=sql+",'"+TradeContext.payBkCode         +"'"
                sql=sql+",'"+TradeContext.vNo          +"'"
                sql=sql+",'"+TradeContext.acc           +"'"
                sql=sql+",'"+TradeContext.amt            +"'"
                sql=sql+",'"+'9'                            +"'"
                sql=sql+",'"+TradeContext.CurPackNo         +"'"
            else:
                sql=sql+"('"+TradeContext.chkDate       +"'"
                sql=sql+",'"+TradeContext.chkAcctOrd            +"'"
                sql=sql+",'"+TradeContext.cNo[i]            +"'"
                sql=sql+",'"+TradeContext.payeeBankNo       +"'"
                sql=sql+",'"+TradeContext.payBkCode         +"'"
                sql=sql+",'"+TradeContext.vNo[i]          +"'"
                sql=sql+",'"+TradeContext.acc[i]           +"'"
                sql=sql+",'"+TradeContext.amt[i]            +"'"
                sql=sql+",'"+'9'                            +"'"
                sql=sql+",'"+TradeContext.CurPackNo         +"'"
            sql=sql+")"
            AfaLoggerFunc.tradeInfo(sql)
            if( AfaDBFunc.InsertSqlCmt(sql) == -1 ):
                AfaLoggerFunc.tradeFatal(sql)
                TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
                raise TipsFunc.flowException( ) 
        #批量管理表写入    
        if (len(Records)>0 and Records[0][0]>0  and int(TradeContext.pageSerno.strip())!=1):
            #批量管理表更新
            sqlStr1 = "UPDATE TIPS_CHECKADM SET NOTE2=char(bigint(NOTE2)+1) WHERE "
            sqlStr1 =sqlStr1 +" WORKDATE  = '"      + TradeContext.chkDate.strip()         + "'"
            sqlStr1 =sqlStr1 +"and BATCHNO   = '"   + TradeContext.chkAcctOrd.strip()      + "'"
            sqlStr1 =sqlStr1 +"and PAYEEBANKNO = '" + TradeContext.payeeBankNo.strip()     + "'"
            sqlStr1 =sqlStr1 +"and PAYBKCODE   = '" + TradeContext.payBkCode.strip()       + "'"
            sqlStr1 =sqlStr1 +"and NOTE3   = '" + TradeContext.CurPackNo.strip()       + "'"
            AfaLoggerFunc.tradeInfo(sqlStr1 )
            records1=AfaDBFunc.UpdateSqlCmt( sqlStr1 )
            if( records1 <0 ):
                return TipsFunc.ExitThisFlow( 'A0027', '数据库错,批量管理表操作异常' )
        else:    
            sqlStr1="insert into TIPS_CHECKADM(WORKDATE,WORKTIME,BATCHNO,PAYEEBANKNO,PAYBKCODE,CHKACCTTYPE,DEALSTATUS,TOTALNUM,TOTALAMT,SUCCNUM,SUCCAMT,"
            sqlStr1=sqlStr1+"NOTE1,NOTE2,NOTE3)"
            sqlStr1=sqlStr1+" values"
            sqlStr1=sqlStr1+"('"+TradeContext.chkDate           +"'"
            sqlStr1=sqlStr1+",'"+TradeContext.workTime          +"'"
            sqlStr1=sqlStr1+",'"+TradeContext.chkAcctOrd        +"'"
            sqlStr1=sqlStr1+",'"+TradeContext.payeeBankNo       +"'"
            sqlStr1=sqlStr1+",'"+TradeContext.payBkCode         +"'"
            sqlStr1=sqlStr1+",'"+TradeContext.chkAcctType       +"'"
            sqlStr1=sqlStr1+",'"+'9'                            +"'"
            sqlStr1=sqlStr1+",'"+TradeContext.allNum            +"'"
            sqlStr1=sqlStr1+",'"+TradeContext.allAmt            +"'"
            sqlStr1=sqlStr1+",'0'"
            sqlStr1=sqlStr1+",'0'"
            sqlStr1=sqlStr1+",'"+TradeContext.priorChkAcctOrd   +"'"
            sqlStr1=sqlStr1+",'"+TradeContext.pageSerno         +"'"  #页序号(AFE与AFA传递数据包大小有限制,将包拆分,多次传递)
            sqlStr1=sqlStr1+",'"+TradeContext.CurPackNo         +"'"  #包序号(TIPS传递数据包大小有限制,将包拆分,多次传递)
            sqlStr1=sqlStr1+")"
            AfaLoggerFunc.tradeInfo(sqlStr1)
            if( AfaDBFunc.InsertSqlCmt(sqlStr1) == -1 ):
                AfaLoggerFunc.tradeFatal(sqlStr1)
                return TipsFunc.ExitThisFlow( 'A0027', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            
        TradeContext.tradeResponse.append(['errorCode','0000'])
        TradeContext.tradeResponse.append(['errorMsg','交易成功'])
        
        #20100113  关彬捷  增加  判断CHECKDATA登记簿中记录条数与报文中交易数是否相等,若相等则允许进行下一步对账操作
        sqlstr = "select count(*) from TIPS_CHECKDATA where "
        sqlstr = sqlstr + ""
        sqlstr = sqlstr +" WORKDATE  = '"        + TradeContext.chkDate.strip()     + "'"
        sqlstr = sqlstr +"and BATCHNO   = '"     + TradeContext.chkAcctOrd.strip()  + "'"
        sqlstr = sqlstr +"and PAYEEBANKNO   = '" + TradeContext.payeeBankNo.strip() + "'"
        sqlstr = sqlstr +"and PAYBKCODE     = '" + TradeContext.payBkCode.strip()   + "'"
        AfaLoggerFunc.tradeInfo(sqlstr)
        records = AfaDBFunc.SelectSql(sqlstr)
        if records == None:
            AfaLoggerFunc.tradeFatal(sqlstr)
            return TipsFunc.ExitThisFlow( 'A0027','数据库操作异常:' + AfaDBFunc.sqlErrMsg)
        else:
            AfaLoggerFunc.tradeInfo(">>>allNum=[" + TradeContext.allNum + "],COUNT=[" + str(records[0][0]) + "]")
            #如果TIPS_CHECKDATA记录条数与allNum相符,则允许进入下一对账流程
            if (int(TradeContext.allNum) == records[0][0]):
                TradeContext.tradeResponse.append(['nextStep','1'])  #对账流程标识:1-允许进入下一流程;2-禁止进入下一流程
                AfaLoggerFunc.tradeDebug(">>>所有包数据登记结束,进入下一对账流程")
            else:
                TradeContext.tradeResponse.append(['nextStep','2'])  #对账流程标识:1-允许进入下一流程;2-禁止进入下一流程
                AfaLoggerFunc.tradeDebug(">>>包数据未登记结束,不进入下一对账流程")
        #20100113  关彬捷  修改结束

        AfaLoggerFunc.tradeInfo('财税库行_TIPS发起明细对账_前处理结束[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
        return True
    except Exception, e:
        TipsFunc.exitMainFlow(str(e))
Ejemplo n.º 17
0
def AdbInsertQueDtl( ):
    AfaLoggerFunc.tradeInfo( '>>>>>>>开始插入银保通信息表: [ybt_info ]<<<<<<<')
    
    #流水表的列数-1
    count=42
    TransDtl=[[]]*( count+1 )
   
    #中间业务信息
    TransDtl[0] = TradeContext.agentSerialno                              # AGENTSERIALNO 代理业务流水号
    TransDtl[1] = TradeContext.sysId                                      # SYSID         系统标识
    TransDtl[2] = TradeContext.workDate                                   # WORKDATE      交易日期
    TransDtl[3] = TradeContext.workTime                                   # WORKTIME      交易时间
    TransDtl[4] = TradeContext.brno                                       # BRNO          交易机构
    TransDtl[5] = TradeContext.tellerno                                   # TELLERNO      柜员号
    
    #投保信息
    TransDtl[6] = TradeContext.unitno                                     # unitno        保险公司编码
    TransDtl[7] = TradeContext.tb_date                                    # tb_date       投保日期
    TransDtl[8] = TradeContext.applno                                     # applno        投保单号
    TransDtl[9] =TradeContext.I1CETY                                      #pz_type        凭证类型
    TransDtl[10] = TradeContext.userno                                    # bd_print_no   保单印刷号(凭证号) 
    TransDtl[11] =TradeContext.amount                                     #amount       应缴保费
    
    #初始化TransDtl[12]和TransDtl[14]
    TransDtl[12] = ''
    TransDtl[14] = ''
    
    #AfaLoggerFunc.tradeInfo('------------test1-----------------')
    
    #险种信息(主险|附加险)                             
    if( TradeContext.existVariable( "productid" ) ):                      #productid      主险险种
        TransDtl[12] = TransDtl[12] + TradeContext.productid.strip()
    TransDtl[12] = TransDtl[12] + "|"
    
    if ( TradeContext.existVariable( "productid1" ) ):                    #productid1    附加险种
        TransDtl[12] = TransDtl[12] + TradeContext.productid1.strip()
   
    #保险期间类型  
    if( TradeContext.existVariable( "pre_tormtype" ) ):                   #tormtype     保险期间类型   
        TransDtl[13] = TradeContext.pre_tormtype  
    
    #保险期间
    if( TradeContext.existVariable( "coverage_year" ) ):                  #保险期间 (年份或起始日期)            
        TransDtl[14] = TransDtl[14] + TradeContext.coverage_year.strip()
    TransDtl[14] = TransDtl[14] + "|"
    
    if ( TradeContext.existVariable( "TermDate" ) ):                      #终止日期 
        TransDtl[14] = TransDtl[14] + TradeContext.TermDate.strip()    
                              
    if( TradeContext.existVariable( "paydatelimit" ) ):                   #缴费年限
        TransDtl[15] = TradeContext.paydatelimit
          
    if( TradeContext.existVariable( "pre_paymethod" ) ):                  #缴费方式
        TransDtl[16] = TradeContext.pre_paymethod
    
    #投保人信息
    if( TradeContext.existVariable( "tbr_name" ) ):                       #投保人姓名
        TransDtl[17] = TradeContext.tbr_name
    
    if( TradeContext.existVariable( "pre_tbr_sex" ) ):                    #投保人性别
        TransDtl[18] = TradeContext.pre_tbr_sex
    
    if( TradeContext.existVariable( "tbr_birth" ) ):                      #投保人生日
        TransDtl[19] = TradeContext.tbr_birth
    
    if( TradeContext.existVariable( "pre_tbr_idtype" ) ):                     #投保人证件类型
        TransDtl[20] = TradeContext.pre_tbr_idtype
    
    if( TradeContext.existVariable( "tbr_idno" ) ):                       #投保人证件号码
        TransDtl[21] = TradeContext.tbr_idno
    
    if( TradeContext.existVariable( "tbr_addr" ) ):                       #投保人地址
        TransDtl[22] = TradeContext.tbr_addr
   
    if( TradeContext.existVariable( "tbr_postcode" ) ):                   #投保人邮编
        TransDtl[23] = TradeContext.tbr_postcode
    
    if( TradeContext.existVariable( "tbr_tel" ) ):                        #投保人电话
        TransDtl[24] = TradeContext.tbr_tel
    else:
        TransDtl[24] = ''
        
    if( TradeContext.existVariable( "tbr_mobile" ) ):                     #投保人移动电话
        TransDtl[25] = TradeContext.tbr_mobile
    else:
        TransDtl[25] = ''
        
    if( TradeContext.existVariable( "tbr_email" ) ):                      #投保人邮箱
        TransDtl[26] = TradeContext.tbr_email
    else:
        TransDtl[26] = ''
        
    if( TradeContext.existVariable( "pre_tbr_bbr_rela" ) ):                   #投保人与被保人关系
        TransDtl[27] = TradeContext.pre_tbr_bbr_rela  
    
    #被保人信息
    if( TradeContext.existVariable( "bbr_name" ) ):                       #被保人名字
        TransDtl[28] = TradeContext.bbr_name
    
    if( TradeContext.existVariable( "bbr_sex" ) ):                        #被保人性别
        TransDtl[29] = TradeContext.bbr_sex
   
    if( TradeContext.existVariable( "bbr_birth" ) ):                      #被保人生日
        TransDtl[30] = TradeContext.bbr_birth
    
    if( TradeContext.existVariable( "pre_bbr_idtype" ) ):                     #被保人证件类型
        TransDtl[31] = TradeContext.pre_bbr_idtype
    
    if( TradeContext.existVariable( "bbr_idno" ) ):                       #被保人证件号
        TransDtl[32] = TradeContext.bbr_idno
        
    if( TradeContext.existVariable( "bbr_addr" ) ):                       #被保人地址
        TransDtl[33] = TradeContext.bbr_addr
    else:
        TransDtl[33]= ''
        
    if( TradeContext.existVariable( "bbr_postcode" ) ):                   #被保人邮编
        TransDtl[34] = TradeContext.bbr_postcode
    else:
        TransDtl[34] =''
        
    if( TradeContext.existVariable( "bbr_tel" ) ):                        #被保人电话
        TransDtl[35] = TradeContext.bbr_tel
    else:
        TransDtl[35]=''
        
    if( TradeContext.existVariable( "bbr_mobile" ) ):                     #被保人移动电话
        TransDtl[36] = TradeContext.bbr_mobile
    else:
        TransDtl[36]=''
        
    if( TradeContext.existVariable( "bbr_email" ) ):                      #被保人邮箱
        TransDtl[37] = TradeContext.bbr_email
    else:
        TransDtl[37]=''

    #初始化信息
    TransDtl[38] = ''
    TransDtl[39] = ''
    TransDtl[40] = ''
    TransDtl[41] = ''
    TransDtl[42] = ''
    
    #受益人信息
    #受益人1信息(姓名|证件类型|证件号码|性别|生日|与被保人关系|收益顺序|收益份额(分子)|收益份额(分母))
    if( TradeContext.existVariable( "syr_1" ) and len(TradeContext.syr_1)!=0 ): 
        TransDtl[38] = TransDtl[38] + TradeContext.syr_1
    else:
        TransDtl[38]='' 
    
    if ( TradeContext.existVariable( "syr_2" ) and len(TradeContext.syr_2)!=0):                        
        TransDtl[39] = TransDtl[39] + TradeContext.syr_2
    else:
        TransDtl[39]=''
            
    if( TradeContext.existVariable( "syr_3" )and len(TradeContext.syr_3)!=0 ):                   
        TransDtl[40] = TransDtl[40] + TradeContext.syr_3
    else:
         TransDtl[40]=''
    
    if ( TradeContext.existVariable( "syr_4" ) and len(TradeContext.syr_4)!=0 ):                   
        TransDtl[41] = TransDtl[41] + TradeContext.syr_4
    else:
        TransDtl[41]=''  
    
    if ( TradeContext.existVariable( "syr_5" )and len(TradeContext.syr_5)!=0  ):                 
        TransDtl[42] = TransDtl[42] + TradeContext.syr_5
    else:
        TransDtl[42]=''    
  
    sql = "INSERT INTO YBT_INFO ("
    sql = sql + "AGENTSERIALNO,SYSID,WORKDATE,WORKTIME,BRNO,TELLERNO,CPICNO,SUBMISDATE,SUBMINO,PROCODE,PRINTNO,AMOUNT,XZINFO,"
    sql = sql + "TORMTYPE,EFFTORM,PAYOUTDUR,PAYOUTTYPE,TBR_NAME,TBR_SEX,TBR_BIRTH,TBR_IDTYPE,TBR_IDNO,TBR_ADDR,TBR_POSTCODE,"
    sql = sql + "TBR_TEL,TBR_MOBILE,TBR_EMAIL,TBR_BBR_RELA,BBR_NAME,BBR_SEX,BBR_BIRTH,BBR_IDTYPE,BBR_IDNO,BBR_ADDR,BBR_POSTCODE,"
    sql = sql + "BBR_TEL,BBR_MOBILE,BBR_EMAIL,SYR_INFO1,SYR_INFO2,SYR_INFO3,SYR_INFO4,SYR_INFO5) VALUES("

    i=0
    for i in range( 0, count ):
        if( type( TransDtl[i] ) is int ):
            sql=sql+str( TransDtl[i] )+","
        else:
            sql=sql+"'"+ TransDtl[i]+"',"
    
    sql=sql+"'"+TransDtl[count]+"')"
    
    AfaLoggerFunc.tradeInfo( '>>>>>>>新保投保交易登记流水<<<<<<< ' + str(sql))
    
    #插入并提交数据
    result=AfaDBFunc.InsertSqlCmt( sql )
        
    if( result < 1 ):
        TradeContext.errorCode, TradeContext.errorMsg='A0044', '插入流水表失败'+AfaDBFunc.sqlErrMsg
        return False
    
    else:
        return True
Ejemplo n.º 18
0
def InsertCustInfo( ):

    #AfaLoggerFunc.tradeInfo('>>>增加个人协议信息')

    try:

        sql = ""

        sql = "INSERT INTO ABDT_CUSTINFO("
        sql = sql + "APPNO,"
        sql = sql + "BUSINO,"
        sql = sql + "BUSIUSERNO,"
        sql = sql + "BUSIUSERAPPNO,"
        sql = sql + "BANKUSERNO,"
        sql = sql + "VOUHTYPE,"
        sql = sql + "VOUHNO,"
        sql = sql + "ACCNO,"
        sql = sql + "SUBACCNO,"
        sql = sql + "CURRTYPE,"
        sql = sql + "LIMITAMT,"
        sql = sql + "PARTFLAG,"
        sql = sql + "PROTOCOLNO,"
        sql = sql + "CONTRACTDATE,"
        sql = sql + "STARTDATE,"
        sql = sql + "ENDDATE,"
        sql = sql + "PASSCHKFLAG,"
        sql = sql + "PASSWD,"
        sql = sql + "IDCHKFLAG,"
        sql = sql + "IDTYPE,"
        sql = sql + "IDCODE,"
        sql = sql + "NAMECHKFLAG,"
        sql = sql + "USERNAME,"
        sql = sql + "TEL,"
        sql = sql + "ADDRESS,"
        sql = sql + "ZIPCODE,"
        sql = sql + "EMAIL,"
        sql = sql + "STATUS,"
        sql = sql + "ZONENO,"
        sql = sql + "BRNO,"
        sql = sql + "TELLERNO,"
        sql = sql + "INDATE,"
        sql = sql + "INTIME,"
        sql = sql + "NOTE1,"
        sql = sql + "NOTE2,"
        sql = sql + "NOTE3,"
        sql = sql + "NOTE4,"
        sql = sql + "NOTE5)"

        sql = sql + " VALUES ("

        sql = sql + "'AG1014',"                                      #业务编号
        sql = sql + "'" + TradeContext.I1BUSINO        + "',"        #单位编号
        sql = sql + "'" + TradeContext.SBNO            + "',"        #商户客户编号
        sql = sql + "'" + TradeContext.SBNO            + "',"        #商户客户应用编号
        sql = sql + "'" + TradeContext.SBNO            + "',"        #银行客户编号(201208 中间业务优化改为使用社保编号)
        sql = sql + "'49',"                                          #凭证类型
        sql = sql + "'" + TradeContext.VOUHNO          + "',"        #凭证号
        sql = sql + "'" + TradeContext.ACCNO           + "',"        #活期存款帐号
        sql = sql + "'',"                                            #子帐号
        sql = sql + "'01',"                                          #币种
        sql = sql + "'0',"                                           #交易限额
        
        #begin 20111010--胡友--修改 部分扣款标志为改为B 表示全额扣款 扣到0余额
        sql = sql + "'B',"                                           #部分扣款标志
        #end
        
        sql = sql + "'" + TradeContext.PROTOCOLNO      + "',"        #协议编号
        sql = sql + "'" + TradeContext.WorkDate        + "',"        #签约日期(合同日期)
        sql = sql + "'" + TradeContext.WorkDate        + "',"        #生效日期
        sql = sql + "'20990101',"                                    #失效日期
        sql = sql + "'0',"                                           #密码验证标志
        sql = sql + "'" + "****************"           + "',"        #密码
        sql = sql + "'0',"                                           #证件验证标志
        sql = sql + "'01',"                                          #证件类型
        sql = sql + "'" + TradeContext.IDENTITYNO      + "',"        #证件号码
        sql = sql + "'0',"                                           #姓名验证标志
        sql = sql + "'" + TradeContext.NAME            + "',"        #客户姓名
        sql = sql + "'',"                                            #联系电话
        sql = sql + "'',"                                            #联系地址
        sql = sql + "'',"                                            #邮编
        sql = sql + "'',"                                            #电子邮箱
        sql = sql + "'1',"                                           #状态
        sql = sql + "'" + TradeContext.I1BUSINO[0:4]   + "',"        #地区号
        sql = sql + "'" + TradeContext.I1BUSINO[0:10]  + "',"        #网点号(机构代码)
        sql = sql + "'" + TradeContext.I1USID          + "',"        #柜员号
        sql = sql + "'" + TradeContext.WorkDate        + "',"        #录入日期
        sql = sql + "'" + TradeContext.WorkTime        + "',"        #录入时间
        sql = sql + "'',"                                            #备注1
        sql = sql + "'',"                                            #备注2
        sql = sql + "'',"                                            #备注3
        sql = sql + "'AHXNB',"                                       #备注4(AHXNB表示该协议是通过新农保开户时批量导入)
        sql = sql + "'')"                                            #备注5

        #AfaLoggerFunc.tradeInfo(sql)

        result = AfaDBFunc.InsertSqlCmt( sql )
        if( result <= 0 ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return ExitSubTrade( '9000', '增加个人协议信息失败')
            
        return True

    except Exception, e:
        AfaLoggerFunc.tradeFatal( str(e) )
        return ExitSubTrade( '9999', '增加个人协议信息异常')
Ejemplo n.º 19
0
def InsertCustInfo( ):
    AfaLoggerFunc.tradeInfo('>>>增加企业协议信息')

    try:

        sql = ""
        sql = "INSERT INTO ABDT_CUSTINFO("
        sql = sql + "APPNO,"
        sql = sql + "BUSINO,"
        sql = sql + "BUSIUSERNO,"
        sql = sql + "BUSIUSERAPPNO,"
        sql = sql + "BANKUSERNO,"
        sql = sql + "VOUHTYPE,"
        sql = sql + "VOUHNO,"
        sql = sql + "ACCNO,"
        sql = sql + "SUBACCNO,"
        sql = sql + "CURRTYPE,"
        sql = sql + "LIMITAMT,"
        sql = sql + "PARTFLAG,"
        sql = sql + "PROTOCOLNO,"
        sql = sql + "CONTRACTDATE,"
        sql = sql + "STARTDATE,"
        sql = sql + "ENDDATE,"
        sql = sql + "PASSCHKFLAG,"
        sql = sql + "PASSWD,"
        sql = sql + "IDCHKFLAG,"
        sql = sql + "IDTYPE,"
        sql = sql + "IDCODE,"
        sql = sql + "NAMECHKFLAG,"
        sql = sql + "USERNAME,"
        sql = sql + "TEL,"
        sql = sql + "ADDRESS,"
        sql = sql + "ZIPCODE,"
        sql = sql + "EMAIL,"
        sql = sql + "STATUS,"
        sql = sql + "ZONENO,"
        sql = sql + "BRNO,"
        sql = sql + "TELLERNO,"
        sql = sql + "INDATE,"
        sql = sql + "INTIME,"
        sql = sql + "NOTE1,"
        sql = sql + "NOTE2,"
        sql = sql + "NOTE3,"
        sql = sql + "NOTE4,"
        sql = sql + "NOTE5)"

        sql = sql + " VALUES ("

        sql = sql + "'" + TradeContext.Appno           + "',"        #业务编号
        sql = sql + "'" + TradeContext.PayeeUnitno     + "',"        #单位编号
        sql = sql + "'" + TradeContext.PayerUnitno     + "',"        #商户客户编号
        sql = sql + "'" + TradeContext.PayerUnitno     + "',"        #商户客户应用编号
        sql = sql + "'" + TradeContext.PayerAccno[0:12]    + "',"    #银行客户编号
        sql = sql + "'" + '49'                         + "',"        #凭证类型
        sql = sql + "'" + TradeContext.PayerAccno[0:12]+ "',"        #凭证号
        sql = sql + "'" + TradeContext.PayerAccno      + "',"        #活期存款帐号
        sql = sql + "'" + ' '                          + "',"        #子帐号
        sql = sql + "'" + '01'                         + "',"        #币种
        sql = sql + "'" + '0'                          + "',"        #交易限额
        sql = sql + "'" + TradeContext.PartFlag        + "',"        #部分扣款标志
        sql = sql + "'" + TradeContext.Protocolno      + "',"        #协议编号
        sql = sql + "'" + TradeContext.ContractDate    + "',"        #签约日期(合同日期)
        sql = sql + "'" + TradeContext.StartDate       + "',"        #生效日期
        sql = sql + "'" + TradeContext.EndDate         + "',"        #失效日期
        sql = sql + "'" + '0'                          + "',"        #密码验证标志
        sql = sql + "'" + "****************"           + "',"        #密码
        sql = sql + "'" + '0'                          + "',"        #证件验证标志
        sql = sql + "'" + '01'                         + "',"        #证件类型
        sql = sql + "'" + ' '                          + "',"        #证件号码
        sql = sql + "'" + '0'                          + "',"        #姓名验证标志
        sql = sql + "'" + TradeContext.PayerName       + "',"        #客户姓名
        sql = sql + "'" + TradeContext.Tel             + "',"        #联系电话
        sql = sql + "'" + TradeContext.Address         + "',"        #联系地址
        sql = sql + "'" + ' '                          + "',"        #邮编
        sql = sql + "'" + ' '                          + "',"        #电子邮箱
        sql = sql + "'" + '1'                          + "',"        #状态
        sql = sql + "'" + TradeContext.zoneno          + "',"        #地区号
        sql = sql + "'" + TradeContext.brno            + "',"        #网点号(机构代码)
        sql = sql + "'" + TradeContext.tellerno        + "',"        #柜员号
        sql = sql + "'" + TradeContext.TranDate        + "',"        #录入日期
        sql = sql + "'" + TradeContext.TranTime        + "',"        #录入时间
        sql = sql + "'" + ' '                          + "',"        #备注1
        sql = sql + "'" + TradeContext.UserName        + "',"        #付款单位名称
        sql = sql + "'" + TradeContext.PayeeAccno      + "',"        #收款单位账号
        sql = sql + "'" + ' '                          + "',"        #备注4
        sql = sql + "'" + TradeContext.PayeeName       + "')"        #收款单位名称
        

        AfaLoggerFunc.tradeInfo(sql)

        result = AfaDBFunc.InsertSqlCmt( sql )
        if( result <= 0 ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return ExitSubTrade( '9000', '增加企业协议信息失败')

        #TradeContext.tradeResponse.append(['O1USERNAME',     TradeContext.USERNAME])        #用户名称
        #TradeContext.tradeResponse.append(['O1IDTYPE',       TradeContext.IDTYPE])          #证件类型
        #TradeContext.tradeResponse.append(['O1IDCODE',       TradeContext.IDCODE])          #证件号码
        #TradeContext.tradeResponse.append(['O1PROTOCOLNO',   TradeContext.PROTOCOLNO])      #协议号
        #TradeContext.tradeResponse.append(['O1WORKDATE',     TradeContext.TranDate])        #注册日期
        #TradeContext.tradeResponse.append(['O1WORKTIME',     TradeContext.TranTime])        #注册日期

        return True

    except Exception, e:
        AfaLoggerFunc.tradeFatal( str(e) )
        return ExitSubTrade( '9999', '增加企业协议信息异常')
Ejemplo n.º 20
0
def SubModuleMainFst( ):
    AfaLoggerFunc.tradeInfo('财税库行_批量请求交易_前处理[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
    try:
    
        #begin 20101130 蔡永贵增加 缓存收款国库名称,用于后面登记流水
        TradeContext.note10 = TradeContext.payeeName
        #end
        
        #begin  蔡永贵增加 缓存下列各值,避免后续操作把原值覆盖而取不到所需数据
        TradeContext.tmp_projectId     = TradeContext.projectId
        TradeContext.tmp_taxTypeName   = TradeContext.taxTypeName
        TradeContext.tmp_taxStartDate  = TradeContext.taxStartDate
        TradeContext.tmp_taxEndDate    = TradeContext.taxEndDate
        TradeContext.tmp_taxTypeAmt    = TradeContext.taxTypeAmt
        #end
        
        AfaLoggerFunc.tradeInfo('>>>日期:' + TradeContext.corpTime + "  " + TradeContext.workDate)
        #=============判断应用状态====================
        if not TipsFunc.ChkAppStatus( ) :
            return False
        #====获取清算信息=======
        if not TipsFunc.ChkLiquidStatus():
            return False

        #============变量值的有效性校验============
        AfaLoggerFunc.tradeInfo('>>>变量值的有效性校验')
        if( not TradeContext.existVariable( "taxOrgCode" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '[taxOrgCode]值不存在!' )
        if( not TradeContext.existVariable( "packNo" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '[packNo]值不存在!' )
        if( not TradeContext.existVariable( "entrustDate" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '[entrustDate]值不存在!' )
        if( not TradeContext.existVariable( "corpTime" ) ):
            return TipsFunc.ExitThisFlow( 'A0001', '[corpTime]值不存在!' )

        #检查批次是否过期
        AfaLoggerFunc.tradeInfo('>>>检查批次是否过期')
        AfaLoggerFunc.tradeInfo('>>>日期:' + TradeContext.corpTime + "  " + TradeContext.workDate)
        if (TradeContext.corpTime!=TradeContext.workDate ):
            TradeContext.tradeResponse.append(['errorCode','24020'])
            TradeContext.tradeResponse.append(['errorMsg','已过期,作废'])
            AfaLoggerFunc.tradeInfo('已过期,批次作废。报文工作日期:'+TradeContext.corpTime+'系统工作日期:'+TradeContext.workDate)
            return True
        #查询是否重复批次
        AfaLoggerFunc.tradeInfo('>>>查询是否重复批次')
        sqlStr = "SELECT Dealstatus,errorcode,errormsg FROM TIPS_BATCHADM WHERE "
        sqlStr =sqlStr +" WorkDate  = '" + TradeContext.corpTime + "'"
        sqlStr =sqlStr +"and Batchno   = '" + TradeContext.packNo      + "'"
        sqlStr =sqlStr +"and TAXORGCODE= '" + TradeContext.taxOrgCode  + "'"

        Records = AfaDBFunc.SelectSql( sqlStr )
        AfaLoggerFunc.tradeInfo(sqlStr)
        if( Records == None ):
            AfaLoggerFunc.tradeFatal('批量管理表操作异常:'+AfaDBFunc.sqlErrMsg)
            return TipsFunc.ExitThisFlow( 'A0027', '数据库错,批量管理表操作异常' )
        elif(len(Records)>0):
            AfaLoggerFunc.tradeInfo('批次已存在。批次状态:'+Records[0][0]+'处理状态:'+Records[0][1])
            if (Records[0][0]=='0'): #重复包,且批次已成功
                AfaLoggerFunc.tradeInfo('>>>重复包,且批次已完成记账处理')
                TradeContext.tradeResponse.append(['dealFlag','0'])
                TradeContext.tradeResponse.append(['errorCode','0000'])
                TradeContext.tradeResponse.append(['errorMsg','交易成功'])
                return True
            elif (Records[0][0]=='1'): #重复包,且批次已失败
                AfaLoggerFunc.tradeInfo('>>>重复包,且批次已完成记账处理')
                TradeContext.tradeResponse.append(['errorCode',Records[0][1]])
                TradeContext.tradeResponse.append(['errorMsg',Records[0][2]])
                return True
            #elif  ( Records[0][0]=='9'): #尚未处理
            #    None
            #    #认为是新的批次,重新接收
            #    #else:
            #    #    if int(TradeContext.pageSerno.strip())!=int(Records[0][2].strip())+1:
            #    #        #页序号错误
            #    #        TradeContext.tradeResponse.append(['errorCode','A0002'])
            #    #        TradeContext.tradeResponse.append(['errorMsg','页序号错误'])
            #    #        return True
            else:
                AfaLoggerFunc.tradeInfo('>>>重复包,且批次已提交处理,拒绝本次请求')
                TradeContext.tradeResponse.append(['errorCode','94052'])
                TradeContext.tradeResponse.append(['errorMsg','包重复'])
                return True
        if int(TradeContext.pageSerno.strip())==1:
            AfaLoggerFunc.tradeInfo('>>>尚未处理的重复批次,按新批次处理,删掉旧数据')
            #尚未处理的重复批次,按新批次处理,删掉旧数据
            sqlStr_d_t = "DELETE FROM  TIPS_BATCHDATA WHERE "
            sqlStr_d_t =sqlStr_d_t +" WORKDATE = '"         + TradeContext.corpTime + "'"
            sqlStr_d_t =sqlStr_d_t +"and BATCHNO = '"       + TradeContext.packNo      + "'"
            sqlStr_d_t =sqlStr_d_t +"and TAXORGCODE = '"    + TradeContext.taxOrgCode  + "'"
            AfaLoggerFunc.tradeInfo(sqlStr_d_t )
            if( AfaDBFunc.DeleteSqlCmt( sqlStr_d_t ) <0 ):
                return TipsFunc.ExitThisFlow( 'A0027', '数据库错,批量明细表操作异常' )
            sqlStr_d_b = "DELETE FROM TIPS_BATCHADM WHERE "
            sqlStr_d_b =sqlStr_d_b +" workDate  = '" + TradeContext.corpTime + "'"
            sqlStr_d_b =sqlStr_d_b +"and Batchno   = '" + TradeContext.packNo      + "'"
            sqlStr_d_b =sqlStr_d_b +"and TAXORGCODE = '"    + TradeContext.taxOrgCode  + "'"
            AfaLoggerFunc.tradeInfo(sqlStr_d_b )
            if( AfaDBFunc.DeleteSqlCmt( sqlStr_d_b ) <0 ):
                return TipsFunc.ExitThisFlow( 'A0027', '数据库错,批量管理表操作异常' )

        #新的批次或页,批量明细入库
        AfaLoggerFunc.tradeInfo('>>>新的批次或页,批量明细入库')
        recNum=int(TradeContext.pageNum)
        AfaLoggerFunc.tradeInfo(str(recNum))
        
        #beging  蔡永贵增加
        localtion = 0                   #偏移量
        #end
        
        for i in range( 0, recNum ):
            TradeContext.agentSerialno = ''
            #=============获取平台流水号====================
            if TipsFunc.GetSerialno( ) == -1 :
                AfaLoggerFunc.tradeInfo('>>>处理结果:获取平台流水号异常' )
                return TipsFunc.ExitThisFlow( 'A0027', '获取流水号失败' )

            AfaLoggerFunc.tradeInfo('>>>获取平台流水号结束')
            sql="insert into TIPS_BATCHDATA(WORKDATE,BATCHNO,TAXORGCODE,CORPSERIALNO,SERIALNO,ACCNO,TAXPAYCODE,AMOUNT,"
            sql=sql+"STATUS,ERRORCODE,ERRORMSG,NOTE1,NOTE2,NOTE3,NOTE4,NOTE5,NOTE6,NOTE7,NOTE8,NOTE9,NOTE10)"
            sql=sql+" values"

            #初始化变量
            sStatus    = '9'                              #处理状态
            sErrorCode = '99090'                          #错误码
            sErrorMsg  = '尚未处理'                       #错误信息
            TradeContext.teller         = TIPS_TELLERNO_AUTO #自动柜员
            TradeContext.catrFlag       = '1'             #现金转账标志
            TradeContext.__agentEigen__ = '0'             #从表标志
            TradeContext.revTranF       = '0'
            TradeContext.tradeType      = '8'             #交易类型
            TradeContext.errorCode      = '0000'

            if recNum==1:
                TradeContext.corpSerno  = TradeContext.tNo        #第三方流水号
                TradeContext.accno      = TradeContext.acc        #付款帐号
                TradeContext.protocolNo = TradeContext.ptlN       #协议书号
                TradeContext.taxVouNo   = TradeContext.vNo
                TradeContext.taxPayName = TradeContext.tPN
                TradeContext.amount     = TradeContext.amt
                TradeContext.brno       = TradeContext.opBk       #付款开户行

                #====检查是否签约户=======
                TipsFunc.ChkCustSign()
                AfaLoggerFunc.tradeInfo(TradeContext.errorCode)
                if(TradeContext.errorCode == '24009'):
                    sStatus    = '1'             #处理状态
                    sErrorCode = '24009'         #错误码
                    sErrorMsg  = '账户未签约'      #错误信息
                else:

                    AfaLoggerFunc.tradeInfo(TradeContext.BDt)
                    billData = (TradeContext.BDt).split('|')
                    
                    #begin 20100902 蔡永贵注释掉改部分,变量的拼接直接交给afe完成
                    #TradeContext.taxTypeNum = billData[9]
                    TradeContext.taxTypeNum = TradeContext.TaxTypeNum
                    #
                    #TradeContext.projectId     = []
                    #TradeContext.taxTypeName   = []
                    #TradeContext.taxStartDate  = []
                    #TradeContext.taxEndDate    = []
                    #TradeContext.taxTypeAmt    = []
                    #j = 1
                    #AfaLoggerFunc.tradeInfo('数据长度:' + str(len(billData[9:])))
                    #while(j < len(billData[9:])):
                    #    TradeContext.projectId.append(billData[j+9])
                    #    TradeContext.taxTypeName.append(billData[j+10])
                    #    TradeContext.taxStartDate.append(billData[j+11])
                    #    TradeContext.taxEndDate.append(billData[j+12])
                    #    TradeContext.taxTypeAmt.append(billData[j+13])
                    #    j = j + 5
                    #    i = i + 1
                    #end
                    
                sql=sql+"('"+TradeContext.corpTime          +"'"
                sql=sql+",'"+TradeContext.packNo            +"'"
                sql=sql+",'"+TradeContext.taxOrgCode        +"'"
                sql=sql+",'"+TradeContext.tNo               +"'"
                sql=sql+",'"+TradeContext.agentSerialno     +"'"
                sql=sql+",'"+TradeContext.acc               +"'"
                sql=sql+",'"+TradeContext.vNo               +"'"
                sql=sql+",'"+TradeContext.amt               +"'"
                sql=sql+",'"+sStatus                        +"'"
                sql=sql+",'"+sErrorCode                     +"'"
                sql=sql+",'"+sErrorMsg                      +"'"
                sql=sql+",'"+TradeContext.taxOrgCode        +"'"
                sql=sql+",'"+TradeContext.payeeBankNo       +"'"
                sql=sql+",'"+TradeContext.payeeOrgCode      +"'"
                sql=sql+",'"+TradeContext.payeeAcct         +"'"
                sql=sql+",'"+TradeContext.payeeName         +"'"
                sql=sql+",'"+TradeContext.payBkCode         +"'"
                sql=sql+",'"+TradeContext.opBk              +"'"
                sql=sql+",'"+TradeContext.ptlN              +"'"
                sql=sql+",'"+TradeContext.hON               +"'"
                sql=sql+",'"+TradeContext.tPN               +"'"
                #sql=sql+",'"+TradeContext.bDt               +"'"




            else:
                TradeContext.corpSerno  = TradeContext.tNo[i]        #第三方流水号
                TradeContext.accno      = TradeContext.acc[i]        #付款帐号
                TradeContext.protocolNo = TradeContext.ptlN[i]       #协议书号
                TradeContext.taxVouNo   = TradeContext.vNo[i]
                TradeContext.taxPayName = TradeContext.tPN[i]
                TradeContext.amount     = TradeContext.amt[i]
                TradeContext.brno       = TradeContext.opBk[i]       #付款开户行

                #====检查是否签约户=======
                TipsFunc.ChkCustSign()
                AfaLoggerFunc.tradeInfo(TradeContext.errorCode)
                if(TradeContext.errorCode == '24009'):
                    sStatus    = '1'             #处理状态
                    sErrorCode = '24009'         #错误码
                    sErrorMsg  = '账户未签约'    #错误信息
                    
                    #begin 蔡永贵增加
                    localtion = localtion + int(TradeContext.TaxTypeNum[i])
                    #end
                else:
                    billData = (TradeContext.BDt[i]).split('|')
                    
                    #begin 20100902 蔡永贵注释掉改部分,变量的拼接直接交给afe完成
                    #TradeContext.taxTypeNum = billData[9]
                    TradeContext.taxTypeNum = TradeContext.TaxTypeNum[i]
                    #
                    #TradeContext.projectId     = []
                    #TradeContext.taxTypeName   = []
                    #TradeContext.taxStartDate  = []
                    #TradeContext.taxEndDate    = []
                    #TradeContext.taxTypeAmt    = []
                    #
                    #j = 1
                    #while(j < len(billData[9:])):
                    #    TradeContext.projectId.append(billData[j+9])
                    #    TradeContext.taxTypeName.append(billData[j+10])
                    #    TradeContext.taxStartDate.append(billData[j+11])
                    #    TradeContext.taxEndDate.append(billData[j+12])
                    #    TradeContext.taxTypeAmt.append(billData[j+13])
                    #    j=j+ 5
                    #end
                    
                    #begin  蔡永贵增加
                    TradeContext.projectId     = TradeContext.tmp_projectId[localtion:localtion+int(TradeContext.taxTypeNum)]
                    TradeContext.taxTypeName   = TradeContext.tmp_taxTypeName[localtion:localtion+int(TradeContext.taxTypeNum)]
                    TradeContext.taxStartDate  = TradeContext.tmp_taxStartDate[localtion:localtion+int(TradeContext.taxTypeNum)]
                    TradeContext.taxEndDate    = TradeContext.tmp_taxEndDate[localtion:localtion+int(TradeContext.taxTypeNum)]
                    TradeContext.taxTypeAmt    = TradeContext.tmp_taxTypeAmt[localtion:localtion+int(TradeContext.taxTypeNum)]
                    #AfaLoggerFunc.tradeInfo( "当前偏移:" + str(localtion) )
                    #AfaLoggerFunc.tradeInfo( "当前税种条数:" + TradeContext.taxTypeNum )
                    #AfaLoggerFunc.tradeInfo( TradeContext.projectId)
                    #AfaLoggerFunc.tradeInfo( TradeContext.tmp_projectId )
                    
                    localtion = localtion + int(TradeContext.taxTypeNum)
                    #end


                sql=sql+"('"+TradeContext.corpTime       +"'"
                sql=sql+",'"+TradeContext.packNo            +"'"
                sql=sql+",'"+TradeContext.taxOrgCode        +"'"
                #AfaLoggerFunc.tradeInfo( TradeContext.tNo )
                sql=sql+",'"+TradeContext.tNo[i]            +"'"
                sql=sql+",'"+TradeContext.agentSerialno     +"'"
                sql=sql+",'"+TradeContext.acc[i]            +"'"
                sql=sql+",'"+TradeContext.vNo[i]            +"'"
                sql=sql+",'"+TradeContext.amt[i]            +"'"
                sql=sql+",'"+sStatus                        +"'"
                sql=sql+",'"+sErrorCode                     +"'"
                sql=sql+",'"+sErrorMsg                      +"'"
                sql=sql+",'"+TradeContext.taxOrgCode        +"'"
                sql=sql+",'"+TradeContext.payeeBankNo       +"'"
                sql=sql+",'"+TradeContext.payeeOrgCode      +"'"
                sql=sql+",'"+TradeContext.payeeAcct         +"'"
                sql=sql+",'"+TradeContext.payeeName         +"'"
                sql=sql+",'"+TradeContext.payBkCode         +"'"
                sql=sql+",'"+TradeContext.opBk[i]           +"'"
                sql=sql+",'"+TradeContext.ptlN[i]           +"'"
                sql=sql+",'"+TradeContext.hON[i]            +"'"
                sql=sql+",'"+TradeContext.tPN[i]            +"'"
                #sql=sql+",'"+TradeContext.bDt[i]            +"'"
            sql=sql+")"
            AfaLoggerFunc.tradeInfo(sql)
            if( AfaDBFunc.InsertSqlCmt(sql) == -1 ):
                AfaLoggerFunc.tradeFatal(sql)
                return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            AfaLoggerFunc.tradeInfo('写入一条批量明细')

            AfaLoggerFunc.tradeInfo('errorCode = ' + TradeContext.errorCode)

            #guanbj 20091110 账户未签约则不登记主流水表
            if TradeContext.errorCode == '0000':
                #====查询收款帐号=======  20090917 wqs
                if not TipsFunc.SelectAcc():
                    return TipsFunc.ExitThisFlow( 'A0027', '查询收款账号失败' )

                #=============插入流水表====================
                if not TipsFunc.InsertDtl( ):
                    return TipsFunc.ExitThisFlow( 'A0027', '插入流水表失败' )

        if TradeContext.nextFlag=='0':

            #批量管理表写入
            sqlStr1 = "insert into TIPS_BATCHADM(WORKDATE,WORKTIME,BATCHNO,TAXORGCODE,DEALSTATUS,ERRORCODE,ERRORMSG,PAYEEBANKNO,PAYEEACCT,PAYEENAME"
            sqlStr1 = sqlStr1 + ",PAYBKCODE,RETURNTERM,TOTALNUM,TOTALAMT,SUCCNUM,SUCCAMT,"

            #===张恒 增加NOTE4字段 存放批量请求报文中的委托日期字段 START 20100412===
            sqlStr1 = sqlStr1 + "NOTE1,NOTE3,"
            sqlStr1 = sqlStr1 + "NOTE4)"
            #===张恒 增加NOTE4字段 存放批量请求报文中的委托日期字段 END  ===

            sqlStr1 = sqlStr1 + " values"
            sqlStr1 = sqlStr1 + "('"+TradeContext.corpTime          +"'"
            sqlStr1 = sqlStr1 + ",'"+TradeContext.workTime          +"'"
            sqlStr1 = sqlStr1 + ",'"+TradeContext.packNo            +"'"
            sqlStr1 = sqlStr1 + ",'"+TradeContext.taxOrgCode        +"'"
            sqlStr1 = sqlStr1 + ",'"+'9'                            +"'"
            sqlStr1 = sqlStr1 + ",'"+'99090'                        +"'"
            sqlStr1 = sqlStr1 + ",'"+'尚未处理'                     +"'"
            sqlStr1 = sqlStr1 + ",'"+TradeContext.payeeBankNo       +"'"
            sqlStr1 = sqlStr1 + ",'"+TradeContext.payeeAcct         +"'"
            sqlStr1 = sqlStr1 + ",'"+TradeContext.payeeName         +"'"
            sqlStr1 = sqlStr1 + ",'"+TradeContext.payBkCode         +"'"
            sqlStr1 = sqlStr1 + ",'"+TradeContext.returnTerm        +"'"
            sqlStr1 = sqlStr1 + ",'"+TradeContext.allNum            +"'"
            sqlStr1 = sqlStr1 + ",'"+TradeContext.allAmt            +"'"
            sqlStr1 = sqlStr1 + ",'"+'0'                            +"'"
            sqlStr1 = sqlStr1 + ",'"+'0.00'                            +"'"
            sqlStr1 = sqlStr1 + ",'"+TradeContext.pageSerno       +"'"  #页序号(AFE与AFA传递数据包大小有限制,将包拆分,多次传递)
            sqlStr1 = sqlStr1 + ",'"+TradeContext.MsgRef          +"'"  #报文参考号

            #===张恒 增加NOTE4字段 存放批量请求报文中的委托日期字段  START ===
            sqlStr1 = sqlStr1 + ",'"+TradeContext.entrustDate     +"'"  #委托日期
            #===张恒 增加NOTE4字段 存放批量请求报文中的委托日期字段 END  ===

            sqlStr1 = sqlStr1 + ")"
            AfaLoggerFunc.tradeInfo(sqlStr1)
            if( AfaDBFunc.InsertSqlCmt(sqlStr1) == -1 ):
                AfaLoggerFunc.tradeFatal(sqlStr1)
                return TipsFunc.ExitThisFlow( 'A0027', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            #批次数据检查
            AfaLoggerFunc.tradeInfo('>>>批次数据检查')
            sqlStr_dt = "select count(*),sum(cast(amount as decimal(17,2))) FROM  TIPS_BATCHDATA WHERE "
            sqlStr_dt =sqlStr_dt +" workDate = '" + TradeContext.corpTime + "'"
            sqlStr_dt =sqlStr_dt +"and Batchno = '" + TradeContext.packNo      + "'"
            sqlStr_dt =sqlStr_dt +"and TAXORGCODE = '" + TradeContext.taxOrgCode  + "'"
            AfaLoggerFunc.tradeInfo(sqlStr_dt )
            records_dt = AfaDBFunc.SelectSql( sqlStr_dt )
            if records_dt == None :
                return TipsFunc.ExitThisFlow( 'A0027', '数据库错,批量管理表操作异常')
            if long(TradeContext.allNum)!=long(records_dt[0][0]):
                AfaLoggerFunc.tradeInfo('明细和汇总校验不符;实际明细汇总笔数:'+str(records_dt[0][0])+'  总比数:'+TradeContext.allNum)
                return TipsFunc.ExitThisFlow( '24020', '明细和汇总校验不符' )
            if float(TradeContext.allAmt)!=float(records_dt[0][1]):
                AfaLoggerFunc.tradeInfo('明细和汇总校验不符;实际明细汇总金额:'+str(records_dt[0][1])+'  总金额:'+TradeContext.allAmt)
                return TipsFunc.ExitThisFlow( '24020', '明细和汇总校验不符' )
        TradeContext.tradeResponse.append(['dealFlag','1'])
        TradeContext.tradeResponse.append(['errorCode','0000'])
        TradeContext.tradeResponse.append(['errorMsg','交易成功'])

        AfaLoggerFunc.tradeInfo('财税库行_批量请求交易_前处理结束[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
        return True
    except Exception, e:
        TipsFunc.exitMainFlow(str(e))
Ejemplo n.º 21
0
def DataToDB(file,ibegin):
    AfaLoggerFunc.tradeInfo( 'table:'+file )
    try :

        #首先建立表名和字段的映射,然后在下载的数据中都加入日期和时间字段
        #map =   {"AA11":"AAA010,AAA011,AAA012, AAA014,AAZ001,BUSINO,DATE,TIME",\
        #         "FA15":"AAA010,AFA050,AAZ006,AFA051,AFA052,AAZ007,AFA062,AAZ002,BUSINO,DATE,TIME",\
        #         "FA16":"AFA050,AFA030,AAZ006,AAZ007,BUSINO,DATE,TIME",\
        #         "FA13":"AFA030,AAZ006,AAZ007,AFA031,AFA032,AAZ002,AFA038,AFA039,AFA040,AFA041,AFA042,AFA020,BUSINO,DATE,TIME",\
        #         "FA20":"AAA010,AFA090,AFA091,AFA092,AFA096,BUSINO,DATE,TIME",\
        #         "FA21":"AFA090,AFA050,AFA030,AAZ006,AAZ007,BUSINO,DATE,TIME",\
        #         "DPZ_GL":"FPZDM,FQSHM,FQZHM,FDWDM,FCZQHNM,BUSINO,DATE,TIME",\
        #         "FA22":"AAA010,AFA106,AAZ006,AFA100,AFA101,AFA102,AFA103,BUSINO,DATE,TIME" }

        #begin 20100604 蔡永贵修改 除了FA22外,所有映射中在BUSINO前加上BANKNO字段
        
        map =   {"AA11":"AAA010,AAA011,AAA012, AAA014,AAZ001,BANKNO,BUSINO,DATE,TIME",\
                 "FA15":"AAA010,AFA050,AAZ006,AFA051,AFA052,AAZ007,AFA062,AAZ002,BANKNO,BUSINO,DATE,TIME",\
                 "FA16":"AFA050,AFA030,AAZ006,AAZ007,BANKNO,BUSINO,DATE,TIME",\
                 "FA13":"AFA030,AAZ006,AAZ007,AFA031,AFA032,AAZ002,AFA038,AFA039,AFA040,AFA041,AFA042,AFA020,BANKNO,BUSINO,DATE,TIME",\
                 "FA20":"AAA010,AFA090,AFA091,AFA092,AFA096,BANKNO,BUSINO,DATE,TIME",\
                 "FA21":"AFA090,AFA050,AFA030,AAZ006,AAZ007,BANKNO,BUSINO,DATE,TIME",\
                 "DPZ_GL":"FPZDM,FQSHM,FQZHM,FDWDM,FCZQHNM,BANKNO,BUSINO,DATE,TIME",\
                 "FA22":"AAA010,AFA106,AAZ006,AFA100,AFA101,AFA102,AFA103,BUSINO,DATE,TIME" }
        
        #将文件中的记录加入到数据库中
        #fileName    =   TradeContext.CROP_LDIR + "/" + file + '_' + TradeContext.busiNo + ".txt"


        if file == 'FA22':
            fileName = TradeContext.CROP_LDIR + "/" + TradeContext.bankbm+file+".txt"
        else:
            fileName = TradeContext.CROP_LDIR + "/" + file + ".txt"
        #end



        print '====' + fileName

        if ( os.path.exists(fileName) and os.path.isfile(fileName) ):
            fp      =   open(fileName,"rb")

            #将所有的数据读取到sALl中
            sAll    =   fp.read()
            fp.close()
            #rec是每一条记录
            AfaLoggerFunc.tradeInfo(ibegin)
            AfaLoggerFunc.tradeInfo(len(sAll.split(chr(12))))
            for i in range(ibegin,len(sAll.split(chr(12)))):
                AfaLoggerFunc.tradeInfo(i)
                AfaLoggerFunc.tradeInfo(sAll.split(chr(12))[i])
                rec = sAll.split(chr(12))[i]
                #print   rec + "\n"
                AfaLoggerFunc.tradeInfo(len(rec))
                if len(rec)>0:
                    if file=='AA11':
                        AfaLoggerFunc.tradeInfo('AA11')
                        AfaLoggerFunc.tradeInfo(rec.split(chr(31))[0])
                        sqlstr=''
                        sqlstr = "select count(*) from FS_AA11 where AAA010='" + rec.split(chr(31))[0] + "' and BUSINO='" + TradeContext.busiNo + "'"
                        sqlstr = sqlstr + " and bankno ='" + TradeContext.bankbm + "'"

                        AfaLoggerFunc.tradeInfo( sqlstr )

                        records = AfaDBFunc.SelectSql( sqlstr )
                        if (records==None or len(records) <= 0):
                            print '>>>查询数据库异常'
                            AfaLoggerFunc.tradeInfo('>>>查询数据库异常AA11')
                            return -1

                        if records[0][0]==1:

                            AfaLoggerFunc.tradeInfo( '重复记录,更新处理' )

                            #如果记录存在,必须先删除,再新增
                            strStr_del = "DELETE FROM FS_AA11 where AAA010='" + rec.split(chr(31))[0] + "' and BUSINO='" + TradeContext.busiNo + "'"
                            strStr_del = strStr_del + " and bankno ='" + TradeContext.bankbm + "'"

                            AfaLoggerFunc.tradeInfo( strStr_del )

                            result = AfaDBFunc.DeleteSqlCmt( strStr_del )
                            if result < 1 :
                                AfaLoggerFunc.tradeInfo('>>>删除数据失败:' + AfaDBFunc.sqlErrMsg)
                                return -1


                    elif file=='FA15':
                        sqlstr=''
                        sqlstr = "select count(*) from FS_FA15 where AFA050='" + rec.split(chr(31))[1] + "' and AAZ006='" + rec.split(chr(31))[2] + "' and BUSINO='" + TradeContext.busiNo + "'"
                        sqlstr = sqlstr + " and bankno ='" + TradeContext.bankbm + "'"

                        AfaLoggerFunc.tradeInfo( sqlstr )

                        records = AfaDBFunc.SelectSql( sqlstr )
                        if (records==None or len(records) <= 0):
                            print '>>>查询数据库异常'
                            AfaLoggerFunc.tradeInfo('>>>查询数据库异常')
                            return -1

                        if records[0][0]==1:

                            AfaLoggerFunc.tradeInfo( '重复记录,更新处理' )

                            #如果记录存在,必须先删除,再新增
                            strStr_del = "DELETE FROM FS_FA15 where AFA050='" + rec.split(chr(31))[1] + "' and AAZ006='" + rec.split(chr(31))[2] + "' and BUSINO='" + TradeContext.busiNo + "'"
                            strStr_del = strStr_del + " and bankno ='" + TradeContext.bankbm + "'"

                            AfaLoggerFunc.tradeInfo( strStr_del )

                            result = AfaDBFunc.DeleteSqlCmt( strStr_del )
                            if result < 1 :
                                AfaLoggerFunc.tradeInfo('>>>删除数据失败:' + AfaDBFunc.sqlErrMsg)
                                return -1

                    elif file=='FA16':
                        sqlstr=''
                        sqlstr = "select count(*) from FS_FA16 where AFA050='" + rec.split(chr(31))[0] + "' and AFA030='" + rec.split(chr(31))[1] + "'and AAZ006='" + rec.split(chr(31))[2] + "' and BUSINO='" + TradeContext.busiNo + "'"
                        sqlstr = sqlstr + " and bankno ='" + TradeContext.bankbm + "'"

                        AfaLoggerFunc.tradeInfo( sqlstr )

                        records = AfaDBFunc.SelectSql( sqlstr )
                        if (records==None or len(records) <= 0):
                            AfaLoggerFunc.tradeInfo('>>>查询数据库异常')
                            return -1

                        if records[0][0]==1:

                            AfaLoggerFunc.tradeInfo( '重复记录,更新处理' )

                            #如果记录存在,必须先删除,再新增
                            strStr_del = "DELETE FROM FS_FA16 where AFA050='" + rec.split(chr(31))[0] + "' and AFA030='" + rec.split(chr(31))[1] + "'and AAZ006='" + rec.split(chr(31))[2] + "' and BUSINO='" + TradeContext.busiNo + "'"
                            strStr_del = strStr_del + " and bankno ='" + TradeContext.bankbm + "'"

                            AfaLoggerFunc.tradeInfo( strStr_del )

                            result = AfaDBFunc.DeleteSqlCmt( strStr_del )
                            if result < 1 :
                                AfaLoggerFunc.tradeInfo('>>>删除数据失败:' + AfaDBFunc.sqlErrMsg)
                                return -1


                    elif file=='FA13':
                        sqlstr=''
                        sqlstr = "select count(*) from FS_FA13 where AFA030='" + rec.split(chr(31))[0] + "' and AAZ006='" + rec.split(chr(31))[1] + "' and BUSINO='" + TradeContext.busiNo + "'"
                        sqlstr = sqlstr + " and bankno ='" + TradeContext.bankbm + "'"

                        AfaLoggerFunc.tradeInfo( sqlstr )

                        records = AfaDBFunc.SelectSql( sqlstr )
                        if (records==None or len(records) <= 0):
                            AfaLoggerFunc.tradeInfo('>>>查询数据库异常')
                            return -1

                        if records[0][0]==1:
                            AfaLoggerFunc.tradeInfo( '重复记录,更新处理' )

                            #如果记录存在,必须先删除,再新增
                            strStr_del = "DELETE FROM FS_FA13 where AFA030='" + rec.split(chr(31))[0] + "' and AAZ006='" + rec.split(chr(31))[1] + "' and BUSINO='" + TradeContext.busiNo + "'"
                            strStr_del = strStr_del + " and bankno ='" + TradeContext.bankbm + "'"

                            AfaLoggerFunc.tradeInfo( strStr_del )

                            result = AfaDBFunc.DeleteSqlCmt( strStr_del )
                            if result < 1 :
                                AfaLoggerFunc.tradeInfo('>>>删除数据失败:' + AfaDBFunc.sqlErrMsg)
                                return -1

                    elif file=='FA20':
                        sqlstr=''
                        sqlstr = "select count(*) from FS_FA20 where AAA010='" + rec.split(chr(31))[0] + "' and AFA090='" + rec.split(chr(31))[1] + "' and BUSINO='" + TradeContext.busiNo + "'"
                        sqlstr = sqlstr + " and bankno ='" + TradeContext.bankbm + "'"

                        AfaLoggerFunc.tradeInfo( sqlstr )

                        records = AfaDBFunc.SelectSql( sqlstr )
                        if (records==None or len(records) <= 0):
                            AfaLoggerFunc.tradeInfo('>>>查询数据库异常')
                            return -1

                        if records[0][0]==1:

                            AfaLoggerFunc.tradeInfo( '重复记录,更新处理' )

                            #如果记录存在,必须先删除,再新增
                            strStr_del = "DELETE FROM FS_FA20 where AAA010='" + rec.split(chr(31))[0] + "' and AFA090='" + rec.split(chr(31))[1] + "' and BUSINO='" + TradeContext.busiNo + "'"
                            strStr_del = strStr_del + " and bankno ='" + TradeContext.bankbm + "'"

                            AfaLoggerFunc.tradeInfo( strStr_del )

                            result = AfaDBFunc.DeleteSqlCmt( strStr_del )
                            if result < 1 :
                                AfaLoggerFunc.tradeInfo('>>>删除数据失败:' + AfaDBFunc.sqlErrMsg)
                                return -1

                    elif file=='FA21':
                        sqlstr=''
                        #sqlstr = "select count(*) from FS_FA21 where AFA090='" + rec.split(chr(31))[0] + "' and AFA050='" + rec.split(chr(31))[1] + "'and AFA030='" + rec.split(chr(31))[2] + "'and AAZ006='" + rec.split(chr(31))[3] + "' and BUSINO='" + TradeContext.busiNo + "'"

                        sqlstr = "select count(*) from FS_FA21 where AFA090='" + rec.split(chr(31))[0] + "' and AFA050='" + rec.split(chr(31))[1] + "'and AFA030='" + rec.split(chr(31))[2] + "'and BUSINO='" + TradeContext.busiNo + "'"
                        sqlstr = sqlstr + " and bankno ='" + TradeContext.bankbm + "'"
                        
                        AfaLoggerFunc.tradeInfo( sqlstr )

                        records = AfaDBFunc.SelectSql( sqlstr )
                        if (records==None or len(records) <= 0):
                            AfaLoggerFunc.tradeInfo('>>>查询数据库异常')
                            return -1

                        if records[0][0]==1:

                            AfaLoggerFunc.tradeInfo( '重复记录,更新处理' )

                            #如果记录存在,必须先删除,再新增
                            strStr_del = "DELETE FROM FS_FA21 where AFA090='" + rec.split(chr(31))[0] + "' and AFA050='" + rec.split(chr(31))[1] + "'and AFA030='" + rec.split(chr(31))[2] + "'and BUSINO='" + TradeContext.busiNo + "'"
                            strStr_del = strStr_del + " and bankno ='" + TradeContext.bankbm + "'"

                            AfaLoggerFunc.tradeInfo( strStr_del )

                            result = AfaDBFunc.DeleteSqlCmt( strStr_del )
                            if result < 1 :
                                AfaLoggerFunc.tradeInfo('>>>删除数据失败:' + AfaDBFunc.sqlErrMsg)
                                return -1

                    elif file=='DPZ_GL':
                        sqlstr=''
                        sqlstr = "select count(*) from FS_DPZ_GL where FPZDM='" + rec.split(chr(31))[0] + "' and FQSHM='" + rec.split(chr(31))[1] + "'and FQZHM='" + rec.split(chr(31))[2] + "'and FDWDM='" + rec.split(chr(31))[3] + "'and FCZQHNM='" + rec.split(chr(31))[4].strip() + "' and BUSINO='" + TradeContext.busiNo + "'"
                        sqlstr = sqlstr + " and bankno ='" + TradeContext.bankbm + "'"

                        AfaLoggerFunc.tradeInfo( sqlstr )

                        records = AfaDBFunc.SelectSql( sqlstr )
                        if (records==None or len(records) <= 0):
                            AfaLoggerFunc.tradeInfo('>>>查询数据库异常')
                            return -1

                        if records[0][0]==1:

                            AfaLoggerFunc.tradeInfo( '重复记录,更新处理' )

                            #如果记录存在,必须先删除,再新增
                            strStr_del = "DELETE FROM FS_DPZ_GL where FPZDM='" + rec.split(chr(31))[0] + "' and FQSHM='" + rec.split(chr(31))[1] + "'and FQZHM='" + rec.split(chr(31))[2] + "'and FDWDM='" + rec.split(chr(31))[3] + "'and FCZQHNM='" + rec.split(chr(31))[4].strip() + "' and BUSINO='" + TradeContext.busiNo + "'"
                            strStr_del = strStr_del + " and bankno ='" + TradeContext.bankbm + "'"

                            AfaLoggerFunc.tradeInfo( strStr_del )

                            result = AfaDBFunc.DeleteSqlCmt( strStr_del )
                            if result < 1 :
                                AfaLoggerFunc.tradeInfo('>>>删除数据失败:' + AfaDBFunc.sqlErrMsg)
                                return -1

                    elif file=='FA22':
                        sqlstr = ''
                        sqlstr = "select count(*) from FS_FA22 where AAA010='" + rec.split(chr(31))[0] + "' and AAZ006='" + rec.split(chr(31))[2] + "'and AFA100='" + rec.split(chr(31))[3] + "' and BUSINO='" + TradeContext.busiNo + "'" + " and AFA101='" + rec.split(chr(31))[4] + "'"

                        AfaLoggerFunc.tradeInfo( sqlstr )

                        records = AfaDBFunc.SelectSql( sqlstr )
                        if (records==None or len(records) <= 0):
                            AfaLoggerFunc.tradeInfo('>>>查询数据库异常')
                            return -1

                        if records[0][0]==1:

                            AfaLoggerFunc.tradeInfo( '重复记录,更新处理' )

                            #如果记录存在,必须先删除,再新增

                            #begin 20100527 蔡永贵修改 增加AFA101(单位编码)作为sql的查询条件
                            #strStr_del = "DELETE FROM FS_FA22 where AAA010='" + rec.split(chr(31))[0] + "' and AAZ006='" + rec.split(chr(31))[2] + "'and AFA100='" + rec.split(chr(31))[3] + "' and BUSINO='" + TradeContext.busiNo + "'"
                            strStr_del = "DELETE FROM FS_FA22 where AAA010='" + rec.split(chr(31))[0] + "' and AAZ006='" + rec.split(chr(31))[2] + "'and AFA100='" + rec.split(chr(31))[3] + "' and BUSINO='" + TradeContext.busiNo + "'" + " and AFA101='" + rec.split(chr(31))[4] + "'"
                            #end

                            AfaLoggerFunc.tradeInfo( strStr_del )

                            result = AfaDBFunc.DeleteSqlCmt( strStr_del )
                            if result < 1 :
                                AfaLoggerFunc.tradeInfo('>>>删除数据失败:' + AfaDBFunc.sqlErrMsg)
                                return -1

                    sqlstr  =   ""
                    sqlstr  =   "insert into " + "FS_" + file + " (" + map[file] + " ) " + "  values ("

                    for item in rec.split(chr(31)):
                        sqlstr  =  sqlstr   +   "'"
                        sqlstr  =  sqlstr   +   item.strip() + "',"
                        
                    #begin 20100629 蔡永贵增加银行编码
                    if file != 'FA22':
                        sqlstr      =   sqlstr  + "'" + TradeContext.bankbm   + "',"
                    #end

                    sqlstr      =   sqlstr  + "'" + TradeContext.busiNo   + "',"
                    sqlstr      =   sqlstr  + "'" + TradeContext.WORKDATE + "',"
                    sqlstr      =   sqlstr  + "'" + TradeContext.WORKTIME + "')"

                    AfaLoggerFunc.tradeInfo( sqlstr )

                    ret = AfaDBFunc.InsertSqlCmt( sqlstr )
                    if(  ret< 1 ):
                        AfaLoggerFunc.tradeInfo( "插入记录异常:" + AfaDBFunc.sqlErrMsg )
                        continue

        else:
            AfaLoggerFunc.tradeInfo( "文件" + fileName + "不存在" )

        return 0



    except Exception, e:
        fp.close()
        AfaLoggerFunc.tradeInfo( e )
        return -1
Ejemplo n.º 22
0
def SubModuleMainFst( ):
    AfaLoggerFunc.tradeInfo( '进入自由格式报文查询和发送[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
    TradeContext.appNo      ='AG2010'
    TradeContext.busiNo      ='00000000000001'
    try:
        #=============获取当前系统时间====================
        TradeContext.workDate=UtilTools.GetSysDate( )
        TradeContext.workTime=UtilTools.GetSysTime( )
        
        ##====获取工作日期=======
        #if not TipsFunc.GetUnitWorkdate( ):
        #    return False
        
        #============校验公共节点的有效性==================
        # 完整性检查
        if( not TradeContext.existVariable( "operFlag" ) ):
            return AfaFlowControl.ExitThisFlow( 'A0001', '标识[operFlag]值不存在!' )
        
        ##=============获取平台流水号==================== 
        #if AfaFlowControl.GetSerialno( ) == -1 :
        #    raise AfaFlowControl.flowException( )
        #
        if TradeContext.operFlag=='0': #查询
            if( not TradeContext.existVariable( "beginDate" ) ):
                return AfaFlowControl.ExitThisFlow( 'A0001', '起始日[beginDate]值不存在!' )
            if( not TradeContext.existVariable( "endDate" ) ):
                return AfaFlowControl.ExitThisFlow( 'A0001', '截至日[endDate]值不存在!' )
            
            #=================================
            sql="SELECT * FROM TIPS_NOTE WHERE WORKDATE BETWEEN '"+ TradeContext.beginDate +"' AND '"+TradeContext.endDate+"'" 
            if( TradeContext.existVariable( "srcNodeCode" ) and len(TradeContext.srcNodeCode)>0):
                sql=sql+" AND SRCNODECODE ='"+TradeContext.srcNodeCode     +"'"
            if( TradeContext.existVariable( "desNodeCode" ) and len(TradeContext.desNodeCode)>0):
                sql=sql+" AND DESNODECODE ='"+TradeContext.desNodeCode     +"'"
            sql=sql+" ORDER BY WORKDATE,WORKTIME"
            AfaLoggerFunc.tradeInfo(sql)
            records = AfaDBFunc.SelectSql(sql)
            if( records == None ):
                AfaLoggerFunc.tradeFatal(sql)
                return AfaFlowControl.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
            elif( len( records )==0 ):
                return AfaFlowControl.ExitThisFlow( 'A0002', '无满足条件的记录')
            else:
                records=UtilTools.ListFilterNone( records ,'')
                
                mx_file_name = os.environ['AFAP_HOME'] + '/tmp/' + 'AH_' + TradeContext.teller + '.txt'
                TradeContext.tradeResponse.append(['fileName',  'AH_' + TradeContext.teller + '.txt'])
            
                if (os.path.exists(mx_file_name) and os.path.isfile(mx_file_name)):
                    #文件存在,先删除-再创建
                    os.system("rm " + mx_file_name)
            
                sfp = open(mx_file_name, "w")
                AfaLoggerFunc.tradeInfo('明细文件=['+mx_file_name+']')
                i = 0
                while ( i  < len(records) ):
                    A0 = str(records[i][0]).strip()         #WORKDATE
                    A1 = str(records[i][1]).strip()         #WORKTIME
                    A2 = str(records[i][2]).strip()         #SrcNodeCode
                    A3 = str(records[i][3]).strip()         #DesNodeCode
                    A4 = str(records[i][4]).strip()         #SendOrgCode
                    A5 = str(records[i][5]).strip()         #RcvOrgCode 
                    A6 = str(records[i][6]).strip()         #Content    
            
                    sfp.write(A0 +  '|'  +  A1[0:2]+':' +A1[2:4]+':' + A1[4:6] +  '|'  +  A2 +  '|'  +  A3 +  '|'  +  A4 +  '|'  +  A5 +  '|'  +  A6 +  '|'  + '\n')
                    i=i+1
                sfp.close()

        elif TradeContext.operFlag=='1':
            #=============获取平台流水号====================
            if AfaFlowControl.GetSerialno( ) == -1 :
                WrtLog('>>>处理结果:获取平台流水号异常' )
                sys.exit()
            
            #=============与第三方通讯====================
            AfaAfeFunc.CommAfe()
            if( TradeContext.errorCode != '0000' ):
                return False
            else:
                sql="insert into TIPS_NOTE"
                sql=sql+" values"
                sql=sql+"('"+TradeContext.workDate     +"'"
                sql=sql+",'"+TradeContext.workTime    +"'"
                sql=sql+",'"+TradeContext.srcNodeCode    +"'"
                sql=sql+",'"+TradeContext.desNodeCode    +"'"
                if( TradeContext.existVariable( "sendOrgCode" ) ):
                    sql=sql+",'"+TradeContext.sendOrgCode    +"'"
                else:
                    sql=sql+",''"
                if( TradeContext.existVariable( "rcvOrgCode" ) ):
                    sql=sql+",'"+TradeContext.rcvOrgCode    +"'"
                else:
                    sql=sql+",''"
                sql=sql+",'"+TradeContext.content +"'"
                sql=sql+")"
                AfaLoggerFunc.tradeInfo(sql)
                if( AfaDBFunc.InsertSqlCmt(sql) == -1 ):
                    AfaLoggerFunc.tradeFatal(sql)
                    return AfaFlowControl.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
        else :
            return AfaFlowControl.ExitThisFlow( 'A0002', '操作类型错误')
            
        #=============自动打包==================== 
        TradeContext.tradeResponse.append(['errorCode',  '0000'])
        TradeContext.tradeResponse.append(['errorMsg',  '交易成功'])
        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '退出三方协议验证/撤消['+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
        return True
    except AfaFlowControl.flowException, e:
        return False
Ejemplo n.º 23
0
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', '登记批次作业申请信息异常')
Ejemplo n.º 24
0
def SubModuleDoFst( ):
    try:
        #财政帐号
        if not( TradeContext.existVariable( "CzAccNo" ) and len(TradeContext.CzAccNo.strip()) > 0):     
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "财政帐号不存在"                  
            raise AfaFlowControl.flowException( ) 
            
        #帐号开户机构
        if not( TradeContext.existVariable( "OpBkCode" ) and len(TradeContext.OpBkCode.strip()) > 0):     
            TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "帐号开户机构不存在"                  
            raise AfaFlowControl.flowException( )    
            
            
        #判断此帐户信息是否存在
        sqlstr = ""
        sqlstr = sqlstr + " select accno,sbno,status from FT_CZZH where "
        sqlstr = sqlstr + " accno = '" + TradeContext.CzAccNo.strip()  + "' and"
        sqlstr = sqlstr + " sbno  = '" + TradeContext.OpBkCode.strip() + "' "
        
        #sqlstr = sqlstr + " sbno  = '" + TradeContext.OpBkCode.strip() + "' and"
        #sqlstr = sqlstr + " status= '1' "
        
        AfaLoggerFunc.tradeInfo("===查询结果:"+sqlstr)                                                                                                                         
                                                                                                                                                         
        result = AfaDBFunc.SelectSql(sqlstr)                                                                                                              
                                                                                                                                                         
        if (result == None):                                                                                                                                 
            AfaLoggerFunc.tradeInfo('>>>处理结果查询失败,数据库异常')
            TradeContext.errorCode,TradeContext.errorMsg = 'E8888', "处理结果查询失败,数据库异常"                  
            raise AfaFlowControl.flowException( )                                      
                                                             
        #判断操作类型 0--新增,1--删除
        if TradeContext.OptType == '0':
            AfaLoggerFunc.tradeInfo("===帐户操作类型:新增")
            
            if (len(result) > 0): 
                if result[0][2] == '0':
                    AfaLoggerFunc.tradeInfo( "===存在帐户状态为0(已删除)的帐户信息,可更改状态为新增" )
                    sqld = ""
                    sqld = sqld + " update  FT_CZZH set status = '1', "
                    sqld = sqld + " note1 = '"+ TradeContext.workDate.strip() +"' where "      #操作日期
                    sqld = sqld + " accno = '"+ TradeContext.CzAccNo.strip()  +"' and "
                    sqld = sqld + " sbno  = '"+ TradeContext.OpBkCode.strip() +"' and "
                    sqld = sqld + " status= '0' "
                
                    AfaLoggerFunc.tradeInfo("==(新增)更新表信息:"+sqld)

                    results = AfaDBFunc.UpdateSqlCmt( sqld )
                    if( results <= 0 ):
                        AfaLoggerFunc.tradeFatal( "===(新增)更新表失败:"+AfaDBFunc.sqlErrMsg )
                        TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "(新增)更新表失败:"                 
                        raise AfaFlowControl.flowException( ) 
             
                    AfaLoggerFunc.tradeInfo("===帐户新增(更新)操作流程结束")
                    
                else:
                    AfaLoggerFunc.tradeFatal( "===已存在相应帐号信息不能重复新增,请核对信息" )
                    TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "已存在相应帐号信息不能重复新增,请核对信息"                 
                    raise AfaFlowControl.flowException( )
            
            if (len(result) == 0):                                                                                                                                                                          
                AfaLoggerFunc.tradeInfo( "===无帐户相应数据,可新增信息" )
                sql = ""
                sql = sql + " insert into FT_CZZH values( "
                sql = sql + " '"+ TradeContext.CzAccNo.strip()  +"', "
                sql = sql + " '"+ TradeContext.OpBkCode.strip() +"', "
                sql = sql + " '1', "
                sql = sql + " '"+ TradeContext.workDate.strip() +"', "      #note1 存在操作日期
                sql = sql + " '', "
                sql = sql + " '', "
                sql = sql + " '', "
                sql = sql + " '') "
                
                AfaLoggerFunc.tradeInfo("==插入表信息:"+sql)

                results = AfaDBFunc.InsertSqlCmt( sql )
                if( results <= 0 ):
                    AfaLoggerFunc.tradeFatal( "===插入表失败:"+AfaDBFunc.sqlErrMsg )
                    TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "插入表失败:"                 
                    raise AfaFlowControl.flowException( ) 
        
                AfaLoggerFunc.tradeInfo("===帐户新增操作流程结束")
        
        if TradeContext.OptType == '1':
            AfaLoggerFunc.tradeInfo("===帐户操作类型:删除")
            
            if (len(result) == 0): 
                AfaLoggerFunc.tradeFatal( "===不存在相应帐号信息不能删除,请核对信息" )
                TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "不存在相应帐号信息不能删除,请核对信息"                 
                raise AfaFlowControl.flowException( )
            
            if (len(result) > 0):
                if result[0][2] == '1':                                                                                                                                                                      
                    AfaLoggerFunc.tradeInfo( "===存在帐户相应数据,可删除信息" )
                    sqld = ""
                    sqld = sqld + " update  FT_CZZH set status = '0', "
                    sqld = sqld + " note1 = '"+ TradeContext.workDate.strip() +"' where "      #操作日期
                    sqld = sqld + " accno = '"+ TradeContext.CzAccNo.strip()  +"' and "
                    sqld = sqld + " sbno  = '"+ TradeContext.OpBkCode.strip() +"' and "
                    sqld = sqld + " status= '1' "
                    
                    AfaLoggerFunc.tradeInfo("==(删除)更新表信息:"+sqld)
                    
                    results = AfaDBFunc.UpdateSqlCmt( sqld )
                    if( results <= 0 ):
                        AfaLoggerFunc.tradeFatal( "===(删除)更新表失败:"+AfaDBFunc.sqlErrMsg )
                        TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "(删除)更新表失败:"                 
                        raise AfaFlowControl.flowException( ) 
                    
                    AfaLoggerFunc.tradeInfo("===帐户删除操作流程结束")
                    
                else:
                    AfaLoggerFunc.tradeFatal( "===相应帐号信息已被删除,不能重复删除,请核对信息" )
                    TradeContext.errorCode,TradeContext.errorMsg = 'E9999', "相应帐号信息已被删除,不能重复删除,请核对信息"                 
                    raise AfaFlowControl.flowException( )
                
        TradeContext.errorCode  =   "0000"
        TradeContext.errorMsg   =   "交易成功"
        return True
        
    except  Exception, e:                	   
        AfaLoggerFunc.tradeInfo( str(e) )
        AfaFlowControl.flowException( )  
                        
Ejemplo n.º 25
0
def MatchData(sysId,unitNo,trxDate):

    WrtLog('>>>逐笔勾兑流水')

    try:
        #下载主机文件
        if not DownLoadFile(sysId, trxDate):
            return False

        #初始化流水标志
        if not InitData(sysId,unitNo,trxDate):
            return False

        totalnum = 0
        totalamt = 0

        #打开主机下载文件
        sFileName = TradeContext.HOST_LDIR + '/' + sysId + '_' + trxDate + '_2'


        hFp = open(sFileName, "r")


        #读取一行
        linebuf = hFp.readline()


        while ( len(linebuf) > 0 ):


            #判断对帐流水的合法性
            if ( len(linebuf) < 996 ):
                WrtLog('该批次下载文件格式错误(长度),请检查')
                hFp.close()
                return False


            #拆分对帐流水
            swapbuf = linebuf[0:996].split('<fld>')


            #读取一行
            linebuf = hFp.readline()


            #过滤非本应用对帐流水
            if ( swapbuf[0].strip()!=sysId or swapbuf[3].strip()!=trxDate or swapbuf[5].strip()!=trxDate ):
                WrtLog("===被忽略===")
                PrtRecInfo( swapbuf )
                continue


            #先查询数据库中记录是否存在
            sqlstr = "SELECT BRNO,TELLERNO,REVTRANF,AMOUNT,BANKSTATUS,CORPSTATUS,AGENTSERIALNO,WORKDATE,ERRORMSG FROM AFA_MAINTRANSDTL WHERE"
            sqlstr = sqlstr + "     SYSID         = '"  + sysId              + "'"
            sqlstr = sqlstr + " AND WORKDATE      = '"  + trxDate            + "'"
            sqlstr = sqlstr + " AND AGENTSERIALNO = '"  + swapbuf[4].strip() + "'"
            sqlstr = sqlstr + " AND UNITNO        = '"  + unitNo             + "'"

            WrtLog(sqlstr)

            ChkFlag = '*'
            statusFlag = '0'            #用来标识记录中的BANKSTATUS的状态,如果BANKSTATUS的状态不为0,则该标志的值为1
            
            records = AfaDBFunc.SelectSql( sqlstr )

            if ( records==None ):
                WrtLog( AfaDBFunc.sqlErrMsg )
                WrtLog('查询流水信息异常,请检查')
                hFp.close()
                return False


            if ( len(records) == 0 ):
                WrtLog('数据库中记录匹配失败(表中无记录)')
                continue

            else:
                h_tradeamt = long(float(swapbuf[32].strip())  *100 + 0.1)
                m_tradeamt = long(float(records[0][3].strip())*100 + 0.1)

                if ( swapbuf[9].strip() != records[0][0].strip() ):
                    WrtLog('数据库中记录匹配失败(机构号不符):' + swapbuf[9].strip()  + '|' + records[0][0] + '|')
                    PrtRecInfo( swapbuf )
                    ChkFlag = '2'

                elif ( swapbuf[10].strip() != records[0][1] ):
                    WrtLog('数据库中记录匹配失败(柜员号不符):' + swapbuf[10].strip() + '|' + records[0][1] + '|')
                    PrtRecInfo( swapbuf )
                    ChkFlag = '3'

                elif ( h_tradeamt != m_tradeamt ):
                    WrtLog('数据库中记录匹配失败(发生额不符):' + str(h_tradeamt) + '|' + str(m_tradeamt) + '|')
                    PrtRecInfo( swapbuf )
                    ChkFlag = '4'

                elif ( swapbuf[50].strip() == '1' ):
                    ChkFlag = '1'

                else:
                    if records[0][4] != '0':
                        WrtLog( '数据库中记录状态与主机不符,更新中台数据以保持和主机一致' )
                        statusFlag = 1
                        
                        #把存在该类错误的信息记录到表AFA_DZERROR中
                        WrtLog( '记录中台和主机不一致的流水信息' )
                        occurTime = time.strftime('%Y%m%d%H%M%S',time.localtime())
                        insertSql = "insert into afa_dzerror(OCCURTIME,SERIALNO,WORKDATE,AMOUNT,BANKSTATUS,ERROEMSG) values("
                        insertSql = insertSql + "'" + occurTime     +"',"
                        insertSql = insertSql + "'" + records[0][6] + "',"
                        insertSql = insertSql + "'" + records[0][7] + "',"
                        insertSql = insertSql + "'" + records[0][3] + "',"
                        insertSql = insertSql + "'" + records[0][4] + "',"
                        insertSql = insertSql + "'" + records[0][8] + "')"
                        WrtLog( '记录错误记录sql:' + insertSql )
                        
                        result = AfaDBFunc.InsertSqlCmt( insertSql )
                        if ( result < 0 ):
                            WrtLog( AfaDBFunc.sqlErrMsg )
                            WrtLog( '记录主机对账主机和中台数据不一致失败' )
                            return False
                            
                    ChkFlag = '0'

            #修改与数据库进行匹配
            updSql = "UPDATE AFA_MAINTRANSDTL SET CHKFLAG='" + ChkFlag + "'"
            if statusFlag == 1 :
                updSql = updSql + " ,BANKSTATUS = '0'"
            updSql = updSql + " WHERE SYSID         = '" + sysId              + "'"
            updSql = updSql + " AND   WORKDATE      = '" + trxDate            + "'"
            updSql = updSql + " AND   AGENTSERIALNO = '" + swapbuf[4].strip() + "'"
            updSql = updSql + " AND   UNITNO        = '" + unitNo             + "'"

            WrtLog(updSql)

            result = AfaDBFunc.UpdateSqlCmt( updSql )
            if ( result <= 0 ):
                WrtLog( AfaDBFunc.sqlErrMsg )
                WrtLog('>>>处理结果:修改与匹配流水状态,数据库异常')
                return False

            totalnum = totalnum + 1
            totalamt = totalamt + m_tradeamt

        hFp.close()

        WrtLog( '匹配记录数=' + str(totalnum) + ",匹配总金额=" + str(totalamt) )

        WrtLog( '>>>逐笔勾兑流水 ---> 成功' )

        return True

    except Exception, e:
        hFp.close()
        WrtLog(str(e))
        WrtLog('>>>逐笔勾兑流水 ---> 异常')
        return False
Ejemplo n.º 26
0
def insertXnbMac( ):

    sql = ""
    sql = sql + " select SBNO,NAME,IDENTITYNO,XZQHNAME,XZQHNO,ACCNO"
    sql = sql + " from AHXNB_MAC "
    sql = sql + " where SBNO = '" + TradeContext.SBNO  + "'" #社保编号
    
    #AfaLoggerFunc.tradeInfo( '批量开户校验sql:' + sql )
    result = AfaDBFunc.SelectSql( sql )
    
    if result == None:
        return ExitSubTrade('D0001', "校验批量开户失败,数据库异常")
    elif len(result) > 0:
        
        #胡友 20111116 start   先判断查询结果再处理
        #20110620 曾照泰 修改  如果该客户已经在ahxnb_mac表中登记直接返回True
        #return True
        #return ExitSubTrade('D0001', "该客户已经登记过,跳过此条记录")
        
        flag = ( len(result[0][5].strip()) == 0 )
        
        #账号为空,删除原记录,插入新纪录
        if( flag ):
            sql2 = ""
            sql2 = sql2 + "delete"
            sql2 = sql2 + " from ahxnb_mac"
            sql2 = sql2 + " where sbno = '" + TradeContext.SBNO + "'"
            
            #AfaLoggerFunc.tradeInfo( '删除系统占用社保编号sql2:' + sql2 )
            result2 = AfaDBFunc.DeleteSqlCmt( sql2 )
            
            if( result2 <= 0 ):
                #AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
                return ExitSubTrade( '9000', '删除系统占用社保编号失败')
            
        #账号不为空跳出
        else:
            return True
        #end
        
        
    sql = ""
    sql = sql + "insert into AHXNB_MAC("
    sql = sql + "SBNO,"
    sql = sql + "NAME,"
    sql = sql + "IDENTITYNO,"
    sql = sql + "XZQHNO,"
    sql = sql + "XZQHNAME,"
    sql = sql + "ACCNO,"
    sql = sql + "STATUS,"
    sql = sql + "WORKDATE,"
    sql = sql + "BRNO,"
    sql = sql + "NOTE1,"
    sql = sql + "NOTE2,"
    sql = sql + "NOTE3,"
    sql = sql + "NOTE4)"
    sql = sql + " values("
    sql = sql + "'" + TradeContext.SBNO       + "',"             #社保编号
    sql = sql + "'" + TradeContext.NAME       + "',"             #姓名
    sql = sql + "'" + TradeContext.IDENTITYNO + "',"             #身份证
    sql = sql + "'" + TradeContext.XZQHNO     + "',"             #行政区划代码
    sql = sql + "'" + TradeContext.XZQHNAME   + "',"             #行政区划名称
    sql = sql + "'',"                                            #银行账号
    sql = sql + "'1',"                                           #状态(0-已开户,1-未开户,2-已注销)
    sql = sql + "'',"                                            #开户日期
    sql = sql + "'',"                                            #开户机构
    sql = sql + "'',"                                            #备用1
    sql = sql + "'',"                                            #备用2
    sql = sql + "'',"                                            #备用3
    sql = sql + "'')"                                            #备用4
    
    #AfaLoggerFunc.tradeInfo( "批量开户登记:" + sql )
    
    ret = AfaDBFunc.InsertSqlCmt(sql)
    
    if ret < 0:
        
        return ExitSubTrade('D0001', "插入数据失败")
        
    return True
Ejemplo n.º 27
0
def AdbInsertQueDtl( ):
    AfaLoggerFunc.tradeInfo( '>>>>>>>开始插入安贷宝信息表: [ afa_adbinfo ]<<<<<<<')
    
    #流水表的列数-1
    count=39
    TransDtl=[[]]*( count+1 )
    TransDtl[0] = TradeContext.agentSerialno                    # AGENTSERIALNO 代理业务流水号
    TransDtl[1] = TradeContext.sysId                            # SYSID         系统标识
    TransDtl[2] = TradeContext.workDate                         # WORKDATE      交易日期
    TransDtl[3] = TradeContext.workTime                         # WORKTIME      交易时间
    TransDtl[4] = TradeContext.brno                             # BRNO          网点号
    TransDtl[5] = TradeContext.tellerno                         # TELLERNO      柜员号
    
    if( TradeContext.existVariable( "IdType" ) ) :
        TransDtl[6] = TradeContext.IdType                       # IdType        证件类型
    else:
        TransDtl[6] = ''
    
    TransDtl[7]= TradeContext.IdCode                            # IdCode        证件号码
    TransDtl[8]= TradeContext.UserNo                            # UserNo        保单号/用户编号
    TransDtl[9]= TradeContext.UserName                          # UserName      用户名称
    
    if( TradeContext.existVariable( "TelePhone" ) ) :
        TransDtl[10] = TradeContext.TelePhone                   # TelePhone     电话号码
    else:
        TransDtl[10] = ''
    
    if( TradeContext.existVariable( "Address" ) ) :
        TransDtl[11] = TradeContext.Address                     # Address        地址
    else:
        TransDtl[11] = ''
    
    if( TradeContext.existVariable( "ZipCode" ) ) :
        TransDtl[12] = TradeContext.ZipCode                     # ZipCode        邮编
    else:
        TransDtl[12] = ''
    
    if( TradeContext.existVariable( "Email" ) ) :
        TransDtl[13] = TradeContext.Email                        # Email        邮件地址
    else:
        TransDtl[13] = ''
    
    if( TradeContext.existVariable( "ProCode" ) ) :
        # ProCode =1 --------ProCodeStr = EL5602
        # ProCode =0 --------ProCodeStr = EL5601
        TransDtl[14] = TradeContext.ProCode                     # ProCode        险种代码
    else:
        TransDtl[14] = ''
    
    if( TradeContext.existVariable( "SubmisDate" ) ) :
        TransDtl[15] = TradeContext.SubmisDate                  # SubmisDate        投保日期
    else:
        TransDtl[15] = ''
    
    if( TradeContext.existVariable( "IntialNum" ) ) :
        TransDtl[16] = TradeContext.IntialNum                   # IntialNum        投保份数
    else:
        TransDtl[16] = ''
    
    TransDtl[17] = TradeContext.EffDate                         # EffDate      责任起始日期
    TransDtl[18] = TradeContext.TermDate                        # TermDate     责任结束日期
    TransDtl[19] = TradeContext.LoanDate                        # LoanDate     借款日期
    TransDtl[20] = TradeContext.LoanEndDate                     # LoanEndDate  借款到期日

    if( TradeContext.existVariable( "LoanContractNo" ) ) :
        TransDtl[21] = TradeContext.LoanContractNo                  # CreBarNo     贷款合同编号
    else:
        TransDtl[21] = ''

    if( TradeContext.existVariable( "LoanInvoiceNo" ) ) :
        TransDtl[22] = TradeContext.LoanInvoiceNo                   # CreVouNo     贷款凭证编号
    else:
        TransDtl[22] = ''
    
    if( TradeContext.existVariable( "PayoutDur" ) ) :
        TransDtl[23] = TradeContext.PayoutDur                   # PayoutDur        缴费年限
    else:
        TransDtl[23] = ''
    
    if( TradeContext.existVariable( "BenficName1" ) ) :
        TransDtl[24] = TradeContext.BenficName1                 # BenficName1      第一受益人名称
    else:
        TransDtl[24] = ''
    
    if( TradeContext.existVariable( "BenficType" ) ) :
        TransDtl[25] = TradeContext.BenficType                  # BenficType        第二受益人类型
    else:
        TransDtl[25] = ''
    
    if( TradeContext.existVariable( "BenficName2" ) ) :
        TransDtl[26] = TradeContext.BenficName2                 # BenficName2        指定受益人姓名
    else:
        TransDtl[26] = ''
    
    TransDtl[27] =  TradeContext.CpicTeller.strip()             # CPICTELLER        太保业务员号码(交易成功后返回 更新)
    
    if( TradeContext.errorCode.strip() == "0000"):
        TradeContext.DTLSTATUS = "0"
    else:
        TradeContext.DTLSTATUS = "1"
    TransDtl[28] = TradeContext.DTLSTATUS                       # DTLSTATUS        交易状态(交易成功后更新为"0")
    
    if( TradeContext.existVariable( "PaymentAmt" ) ) :
        TradeContext.AMOUNT = TradeContext.PaymentAmt
    else:
        TradeContext.AMOUNT = ''
    TransDtl[29] = TradeContext.AMOUNT                          # AMOUNT        保费金额(交易成功后返回 更新)
    
    if( TradeContext.existVariable( "GovtIDB" ) ) :
        TransDtl[30] = TradeContext.GovtIDB                     # IdCodeB        被保人证件号码(交易成功后返回 更新)
    else:
        TransDtl[30] = ''
    
    if( TradeContext.existVariable( "FullNameB" ) ) :
        TransDtl[31] = TradeContext.FullNameB                   # UserNameB        被保人姓名 (交易成功后返回 更新)
    else:
        TransDtl[31] = ''
    
    if( TradeContext.existVariable( "PolNumber" ) ):            # NOTE1         备注1(保险公司返回的保单号)
        TransDtl[32] = TradeContext.PolNumber
    else:
        TransDtl[32] = ''
    if( TradeContext.existVariable( "ProCode" ) ):              # NOTE2         备注2(保险种类)
        TransDtl[33] = TradeContext.ProCode
    else:
        TransDtl[33] = ''
    if( TradeContext.existVariable( "unitno" ) ):                # NOTE3         备注3(单位编码)
        TransDtl[34] = TradeContext.unitno
    else:
        TransDtl[34] = ''
    if( TradeContext.existVariable( "note4" ) ):                # NOTE4         备注4
        TransDtl[35] = TradeContext.note4
    else:
        TransDtl[35] = ''
    if( TradeContext.existVariable( "note5" ) ):                # NOTE5         备注5
        TransDtl[36] = TradeContext.note5
    else:
        TransDtl[36] = ''
    if( TradeContext.existVariable( "note6" ) ):                # NOT6         备注6
        TransDtl[37] = TradeContext.note6
    else:
        TransDtl[37] = ''
    if( TradeContext.existVariable( "note7" ) ):                # NOTE7         备注7
        TransDtl[38] = TradeContext.note7
    else:
        TransDtl[38] = ''
    if( TradeContext.existVariable( "errorMsg" ) ):                # NOTE8         备注8
        TransDtl[39] = TradeContext.errorMsg
    else:
        TransDtl[39] = ''
    sql = "INSERT INTO AFA_ADBINFO ("
    sql = sql + "AGENTSERIALNO,SYSID,WORKDATE,WORKTIME,BRNO,TELLERNO,IDTYPE,IDCODE,USERNO,USERNAME,TELEPHONE,"
    sql = sql + "ADDRESS,ZIPCODE,EMAIL,PROCODE,SUBMISDATE,INTIALNUM,EFFDATE,TERMDATE,LOANDATE,LOANENDDATE,CREBARNO,"
    sql = sql + "CREVOUNO,PAYOUTDUR,BENFICNAME1,BENFICTYPE,BENFICNAME2,CPICTELLER,DTLSTATUS,AMOUNT,IDCODEB,USERNAMEB,"
    sql = sql + "NOTE1,NOTE2,NOTE3,NOTE4,NOTE5,NOTE6,NOTE7,NOTE8) VALUES("
    
    i=0
    for i in range( 0, count ):
        if( type( TransDtl[i] ) is int ):
            sql=sql+str( TransDtl[i] )+","
        else:
            sql=sql+"'"+ TransDtl[i]+"',"
    
    sql=sql+"'"+TransDtl[count]+"')"
    
    AfaLoggerFunc.tradeInfo( '>>>>>>>新保试算交易登记流水<<<<<<< ' + str(sql))
    
    result=AfaDBFunc.InsertSqlCmt( sql )
        
    if( result < 1 ):
        TradeContext.errorCode, TradeContext.errorMsg='A0044', '插入流水主表失败'+AfaDBFunc.sqlErrMsg
        return False
    else:
        return True
Ejemplo n.º 28
0
def DeleteCustInfo( ):

    AfaLoggerFunc.tradeInfo(">>>注销客户信息(本地)")

    try:

        AfaLoggerFunc.tradeInfo(">>>修改注销日期和时间")

        sql = "UPDATE ABDT_CUSTINFO SET NOTE3='" + TradeContext.TranDate+TradeContext.TranTime + "'"

        sql = sql + " WHERE "

        sql = sql + "APPNO="      + "'" + TradeContext.I1APPNO      + "'" + " AND "        #业务编码
        sql = sql + "BUSINO="     + "'" + TradeContext.I1BUSINO     + "'" + " AND "        #单位编码
        sql = sql + "PROTOCOLNO=" + "'" + TradeContext.I1PROTOCOLNO + "'"                  #协议编码

        AfaLoggerFunc.tradeInfo( sql )

        result = AfaDBFunc.UpdateSqlCmt( sql )
        if( result <= 0 ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return ExitSubTrade( '9000', '修改注销日期和时间失败')
        
        AfaLoggerFunc.tradeInfo(">>>把需要个人信息记录移到个人信息历史表中")

        sql = ""
        sql = "INSERT INTO ABDT_HIS_CUSTINFO SELECT * FROM ABDT_CUSTINFO WHERE "
        sql = sql + "APPNO="       + "'" + TradeContext.I1APPNO      + "'" + " AND "        #业务编码
        sql = sql + "BUSINO="      + "'" + TradeContext.I1BUSINO     + "'" + " AND "        #单位编码
        sql = sql + "PROTOCOLNO="  + "'" + TradeContext.I1PROTOCOLNO + "'"                  #协议编码

        AfaLoggerFunc.tradeInfo( sql )

        result = AfaDBFunc.InsertSqlCmt( sql )
        if( result <= 0 ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return ExitSubTrade( '9000', '注销个人协议信息失败(移动)')

        AfaLoggerFunc.tradeInfo(">>>总共移动[" + str(result) + "]条记录")


        AfaLoggerFunc.tradeInfo(">>>删除在个人信息表中被注销个人信息记录")
        sql = ""
        sql = "DELETE FROM ABDT_CUSTINFO WHERE "
        sql = sql + "APPNO="      + "'" + TradeContext.I1APPNO      + "'" + " AND "        #业务编码
        sql = sql + "BUSINO="     + "'" + TradeContext.I1BUSINO     + "'" + " AND "        #单位编码
        sql = sql + "PROTOCOLNO=" + "'" + TradeContext.I1PROTOCOLNO + "'"                  #协议编码

        AfaLoggerFunc.tradeInfo( sql )

        result = AfaDBFunc.DeleteSqlCmt( sql )
        if( result <= 0 ):
            AfaLoggerFunc.tradeFatal( AfaDBFunc.sqlErrMsg )
            return ExitSubTrade( '9000', '注销个人协议信息失败(删除)')


        AfaLoggerFunc.tradeInfo(">>>总共删除[" + str(result) + "]条记录")


        TradeContext.tradeResponse.append(['O1USERNAME',     TradeContext.USERNAME])       #用户名称
        TradeContext.tradeResponse.append(['O1IDTYPE',       TradeContext.IDTYPE])         #证件类型
        TradeContext.tradeResponse.append(['O1IDCODE',       TradeContext.IDCODE])         #证件号码

        return True


    except Exception, e:
        AfaLoggerFunc.tradeFatal( str(e) )
        return ExitSubTrade( '9999', '注销个人协议信息异常')
Ejemplo n.º 29
0
def SubModuleMainFst( ):

    AfaLoggerFunc.tradeInfo( '进入运行参数通知交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']' )
    try:
        #=============初始化返回报文变量====================
        TradeContext.tradeResponse=[]
        #=============获取当前系统时间====================
        TradeContext.workDate=TipsFunc.GetTipsDate( )
        TradeContext.workTime=UtilTools.GetSysTime( )

        if( TradeContext.existVariable( "ListNum" ) ):
            ListNum=int(TradeContext.ListNum)
            AfaLoggerFunc.tradeInfo('listNum:'+TradeContext.ListNum)
            recNum_curr=0
            for j in range( 0, ListNum ): 
                if ListNum == 1 :
                    recNum=int(TradeContext.recNum)
                else:
                    recNum=int(TradeContext.recNum[j])
                
                AfaLoggerFunc.tradeInfo('recNum['+str(j)+']:'+str(recNum))
                for i in range( 0, recNum ): 
                    if len(TradeContext.DetailNo[recNum_curr+i])==0:
                        break
                    sql="select PARAMTYPENO,PARAMTYPEDESC,DETAILNO,DETAILDESC,PARAMVALUE from TIPS_RUNPARAM "
                    sql=sql+" where "
                    if ListNum == 1 :
                        sql=sql+"PARAMTYPENO='"+TradeContext.ParamTypeNo      +"'"
                    else:
                        sql=sql+"PARAMTYPENO='"+TradeContext.ParamTypeNo[j]      +"'"
                    sql=sql+"and DetailNo='"+TradeContext.DetailNo[recNum_curr+i]      +"'"
                    AfaLoggerFunc.tradeInfo(sql)
                    records = AfaDBFunc.SelectSql(sql)
                    if( records == None ):
                        AfaLoggerFunc.tradeFatal(sql)
                        return TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
                    #插入
                    if( len( records )==0 ):
                        sql="insert into TIPS_RUNPARAM(WORKDATE,ParamTypeNo,ParamTypeDesc,DetailNo,DetailDesc,ParamValue)"
                        sql=sql+" values"
                        sql=sql+"('"+TradeContext.workDate      +"'"
                        if ListNum == 1 :
                            sql=sql+",'"+TradeContext.ParamTypeNo      +"'"
                        else:
                            sql=sql+",'"+TradeContext.ParamTypeNo[j]      +"'"
                        if ListNum == 1 :
                            sql=sql+",'"+TradeContext.ParamTypeDesc      +"'"
                        else:
                            sql=sql+",'"+TradeContext.ParamTypeDesc[j]      +"'"
                        sql=sql+",'"+TradeContext.DetailNo[recNum_curr+i]      +"'"
                        sql=sql+",'"+TradeContext.DetailDesc[recNum_curr+i]        +"'"
                        sql=sql+",'"+TradeContext.ParamValue[recNum_curr+i]       +"'"
                        sql=sql+")"
                        AfaLoggerFunc.tradeInfo(sql)
                        if( AfaDBFunc.InsertSqlCmt(sql) == -1 ):
                            AfaLoggerFunc.tradeFatal(sql)
                            TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
                            return False 
                    else:#更新
                        sql="update TIPS_RUNPARAM set "
                        sql=sql+" WORKDATE ='"+TradeContext.workDate      +"'"
                        if ListNum == 1 :
                            sql=sql+",ParamTypeDesc ='"+TradeContext.ParamTypeDesc      +"'"
                        else:
                            sql=sql+",ParamTypeDesc ='"+TradeContext.ParamTypeDesc[j]      +"'"
                        sql=sql+",DetailDesc    ='"+TradeContext.DetailDesc[recNum_curr+i]     +"'"
                        sql=sql+",ParamValue    ='"+TradeContext.ParamValue[recNum_curr+i]     +"'"
                        if ListNum == 1 :
                            sql=sql+" WHERE ParamTypeNo ='"+TradeContext.ParamTypeNo      +"'"
                        else:
                            sql=sql+" WHERE ParamTypeNo ='"+TradeContext.ParamTypeNo[j]      +"'"
                        sql=sql+" and DetailNo      ='"+TradeContext.DetailNo[recNum_curr+i]      +"'"
                        AfaLoggerFunc.tradeInfo(sql)
                        if( AfaDBFunc.UpdateSqlCmt(sql) == -1 ):
                            AfaLoggerFunc.tradeFatal(sql)
                            TipsFunc.ExitThisFlow( 'A0002', '数据库操作异常:'+AfaDBFunc.sqlErrMsg )
                            return False 
                recNum_curr = recNum_curr + recNum
                
        #=============自动打包==================== 
        TradeContext.errorCode='0000'
        TradeContext.errorMsg='交易成功'
        TipsFunc.autoPackData()
        #=============程序退出====================
        AfaLoggerFunc.tradeInfo( '退出运行参数通知交易[T'+TradeContext.TemplateCode+'_'+TradeContext.TransCode+']\n' )
        return True
    except TipsFunc.flowException, e:
        return TipsFunc.exitMainFlow( )
Ejemplo n.º 30
0
def main():
    AfaLoggerFunc.tradeInfo( '凭证中心参数维护['+TradeContext.TemplateCode+']进入' )
    #AfaLoggerFunc.afa_InitComp('Tvouh008','凭证中心参数维护')

    try:
        #===========检查操作类型是否存在===========
        # 1 新增,2 查询, 3 修改, 4 删除
        if( not TradeContext.existVariable( "opeType" ) ):
            tradeExit( 'A005060', '操作类型[opeType]值不存在!' )
            raise AfaFlowControl.flowException( )

        if TradeContext.opeType == '1': #新增
            #==========检查该凭证种类信息是否已经存在============
            sqlStr = "select VOUHTYPE from VOUH_PARAMETER \
                 where VOUHTYPE = '" + TradeContext.sVouhType+ "'\
                 and ZONENO = '" + TradeContext.sZoneNo+ "'"
            records = AfaDBFunc.SelectSql( sqlStr )
            if( records == None ):
                tradeExit( 'A005052', '查询[凭证参数维护表]操作异常!' )
                raise AfaFlowControl.flowException( )
            elif( len( records )!=0 ):
                tradeExit( 'A005053', '凭证种类已存在!' )
                raise AfaFlowControl.flowException( )

            #=============初始化返回报文变量====================
            TradeContext.tradeResponse=[]
            sqlStr = "INSERT INTO VOUH_PARAMETER (ZONENO,VOUHTYPE,VOUHNAME,CTRLFLG,COUNTFLG,COUNTUNIT,PAYFLG,\
            MOVFLG,SALEFLG,PRICE,HEADLEN,VOUHLEN,ACTIVEDATE) VALUES ('"+TradeContext.sZoneNo+"','"+\
            TradeContext.sVouhType+"','"+TradeContext.sVouhName+"','2','0','0','0','0','0','0','"+\
            TradeContext.sHeadLen+"','"+TradeContext.sVouhLen+"','0')"

            records = AfaDBFunc.InsertSqlCmt( sqlStr )
            if records==-1 :
                tradeExit( 'A005054', '新增[凭证号码表]基本信息失败!' )
                raise AfaFlowControl.flowException( )
            tradeExit('0000', '新建成功')

        if TradeContext.opeType == '4':  #删除
            sqlStr = "select * from VOUH_REGISTER \
                 where VOUHTYPE = '" + TradeContext.sVouhType+ "'\
                 and VOUHSTATUS != '8'"
            records = AfaDBFunc.SelectSql( sqlStr )
            AfaLoggerFunc.tradeDebug(sqlStr)
            if( records == None ):
                tradeExit( 'A005060', '查询[凭证登记表]操作异常!'  )
                raise AfaFlowControl.flowException( )
            elif( len( records ) > 0 ):
                tradeExit( 'A005061', '不能删除存在有效凭证的凭证参数!' )
                raise AfaFlowControl.flowException( )
            sqlStr = "DELETE  FROM  VOUH_PARAMETER WHERE VOUHTYPE = '" + TradeContext.sVouhType+ "'\
                 and ZONENO = '" + TradeContext.sZoneNo+ "'"

            AfaLoggerFunc.tradeDebug(sqlStr)
            records = AfaDBFunc.DeleteSqlCmt( sqlStr )
            if records == -1:
                tradeExit( 'A005055', '删除[凭证参数维护表]操作异常!' )
                raise AfaFlowControl.flowException( )
            if records == 0:
                tradeExit( 'A005056', '[凭证参数维护表]内无对应记录可被删除!' )
                raise AfaFlowControl.flowException( )
            tradeExit('0000', '删除成功')

        if TradeContext.opeType == '3':#修改
            #==============修改凭证参数维护表=====================

            sqlStr = "select * from VOUH_REGISTER \
                 where VOUHTYPE = '" + TradeContext.sVouhType+ "'\
                 and VOUHSTATUS != '8' and length(headstr) = " + TradeContext.sOldHeadLen
            records = AfaDBFunc.SelectSql( sqlStr )
            AfaLoggerFunc.tradeDebug(sqlStr)
            if( records == None ):
                tradeExit( 'A005060', '查询[凭证登记表]操作异常!'  )
                raise AfaFlowControl.flowException( )
            elif( len( records ) > 0 ):
                tradeExit( 'A005061', '不能修改存在有效凭证的凭证参数!' )
                raise AfaFlowControl.flowException( )


            sqlStr = "UPDATE VOUH_PARAMETER set \
              VOUHNAME = '"+ TradeContext.sVouhName + "',VOUHLEN = '"+ TradeContext.sVouhLen+ "',\
              HEADLEN = '"+ TradeContext.sHeadLen+ "'"
            sqlStr = sqlStr +" WHERE VOUHTYPE = '" + TradeContext.oldVOUHTYPE + "'\
            and ZONENO = '" + TradeContext.sZoneNo+ "'"

            records = AfaDBFunc.UpdateSqlCmt( sqlStr )
            if records==-1 :
                tradeExit( 'A005057', '更新[凭证参数维护表]信息异常!' )
                raise AfaFlowControl.flowException( )
            elif records==0 :
                tradeExit( 'A005058', '修改[凭证参数维护表]基本信息失败!' )
                raise AfaFlowControl.flowException( )
            tradeExit('0000', '修改成功')

        if TradeContext.opeType == '2':#查询
            #=============初始化返回报文变量====================
            TradeContext.tradeResponse=[]
            sqlStr = "SELECT VOUHTYPE,VOUHNAME,VOUHLEN,HEADLEN,ZONENO FROM VOUH_PARAMETER WHERE ZONENO = '"+ TradeContext.sZoneNo +"'"
            if (len(TradeContext.sVouhType)!=0):
                sqlStr = sqlStr + " AND VOUHTYPE = '" + TradeContext.sVouhType + "'"
            if (len(TradeContext.sVouhName)!=0):
                sqlStr = sqlStr + " AND VOUHNAME = '" + TradeContext.sVouhName + "'"
            if (len(TradeContext.sVouhType)==0 and len(TradeContext.sVouhName)==0 ):
                sqlStr = sqlStr
                
            #sqlStr="SELECT VOUHTYPE,VOUHNAME,VOUHLEN,HEADLEN,ZONENO FROM VOUH_PARAMETER WHERE ZONENO ='000000' AND VOUHTYPE = '0000002343' AND VOUHNAME = 'adfsadf'"
            AfaLoggerFunc.tradeInfo( 'sqlStr = ' + sqlStr )
            records = AfaDBFunc.SelectSql( sqlStr )
            if( records == None ):
                TradeContext.tradeResponse.append( ['retCount','0'] )
                tradeExit( 'A005052', '查询[凭证参数维护表]操作异常!'  )
                raise AfaFlowControl.flowException( )
            elif( len( records )==0 ):
                TradeContext.tradeResponse.append( ['retCount','0'] )
                tradeExit( 'A005059', '查询[凭证参数维护表]基本信息不存在!' )
                raise AfaFlowControl.flowException( )
            else:
                records=AfaUtilTools.ListFilterNone( records )
                baseInfoNames=['sVouhType','sVouhName','sVouhLen','sHeadLen','sZoneNo']
                total=len( records )
                for i in range( 0, len( records ) ):
                    j=0
                    for name in baseInfoNames:
                       TradeContext.tradeResponse.append( [name, records[i][j]] )
                       j=j+1
                TradeContext.tradeResponse.append( ['retCount', str( total )] )
                TradeContext.tradeResponse.append( ['errorCode', '0000'] )
                TradeContext.tradeResponse.append( ['errorMsg', '查询成功'] )
                tradeExit('0000', '查询成功')

        #自动打包
        AfaFunc.autoPackData()

        #=============程序退出=========================================
       # AfaLoggerFunc.afa_SuccQuit(__name__,'凭证中心参数维护交易')
    except AfaFlowControl.flowException, e:
        AfaFlowControl.exitMainFlow( )