---------------------------------------[EAS6.0][资金管理]------------- -------------------1出纳管理 --收款单 --付款单 --调拨单 --现金日记帐 --银行日记帐 --现金盘点单 --银行对帐单 --银行(现金)日记帐余额表 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from t_cas_receivingbill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from t_cas_receivingbill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from t_cas_receivingbill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from t_cas_paymentbill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from t_cas_paymentbill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from t_cas_paymentbill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CAS_FundsMoveBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CAS_FundsMoveBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); --源单id update t_cas_receivingbillentry set fsourcebillid=null where fsourcebillid in (select FID from T_FS_SettlementBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); update t_cas_receivingbill set fsourcebillid=null where fsourcebillid in (select FID from T_FS_SettlementBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); update t_cas_paymentbillentry set fsourcebillid=null where fsourcebillid in (select FID from T_FS_SettlementBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); update t_cas_paymentbill set fsourcebillid=null where fsourcebillid in (select FID from T_FS_SettlementBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_CAS_FundsMoveBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CAS_Journal where FCOMPANYID in ($ORGID) and FPeriodId in ($FPERIOD_ID)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CAS_Journal where FCOMPANYID in ($ORGID) and FPeriodId in ($FPERIOD_ID)); delete from T_CAS_Journal where FCompanyID in ($ORGID) and FPeriodId in ($FPERIOD_ID); delete from T_CAS_CashCount where FCompanyID in ($ORGID) and (FCountedDate>=$endtime or FCountedDate<$starttime); delete from T_CAS_BankStatement where FCompanyID in ($ORGID) and FPeriodId in ($FPERIOD_ID); delete from T_CAS_JournalBalance where FCompanyID in ($ORGID) and FPeriodId in ($FPERIOD_ID); ---------------------2资金结算 --对外付款单 --对外收款单 --对内收款单 --对内付款单 --跨行对外付款单 --跨行对外收款单 --跨行对内付款单 --跨行对内收款单 --内部手续费 --外部手续费 --内部账户余额(明细)表 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FS_SettlementBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FS_SettlementBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_FS_SettlementBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FE_FeeBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FE_FeeBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_FE_FeeBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); delete from T_FS_SubsidiaryLedger where FCompanyID in ($ORGID) and (FDate>=$endtime or FDate<$starttime); delete from T_FS_SummaryLedger where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); ----------------------3资金划拨 --上划单 --下拨单 --子账户余额(明细)表 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FS_TransUpBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FS_TransUpBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_FS_TransUpBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FS_TransDownBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FS_TransDownBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_FS_TransDownBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); delete from T_CAS_SubAcctJournal where FCompanyID in ($ORGID) and FPeriodId in ($FPERIOD_ID); delete from T_CAS_SubAccountBalance where FCompanyID in ($ORGID) and FPeriodId in ($FPERIOD_ID); --------------------4票据管理 --付款支票 --领用公司领用记录 delete from T_BOT_RELATION where FSRCOBJECTID in (select fid from T_NT_Cheque where FApplyRecID in (select fid from T_NT_ChequeAppRec where FApplyCompanyID in ($ORGID) and (FApplyDate>=$endtime or FApplyDate<$starttime))); delete from T_BOT_RELATION where FDestObjectID in (select fid from T_NT_Cheque where FApplyRecID in (select fid from T_NT_ChequeAppRec where FApplyCompanyID in ($ORGID) and (FApplyDate>=$endtime or FApplyDate<$starttime))); delete from T_NT_Cheque where FApplyRecID in (select fid from T_NT_ChequeAppRec where FApplyCompanyID in ($ORGID) and (FApplyDate>=$endtime or FApplyDate<$starttime)); delete from T_NT_ChequeAppRec where FApplyCompanyID in ($ORGID) and (FApplyDate>=$endtime or FApplyDate<$starttime); --保管公司 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_NT_Cheque where FKeepCompanyID in ($ORGID) and (FPurDate>=$endtime or FPurDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_NT_Cheque where FKeepCompanyID in ($ORGID) and (FPurDate>=$endtime or FPurDate<$starttime)); delete from T_NT_Cheque where FKeepCompanyID in ($ORGID) and (FPurDate>=$endtime or FPurDate<$starttime); --登记公司 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_NT_Cheque where FCOMPANYID in ($ORGID) and (FPurDate>=$endtime or FPurDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_NT_Cheque where FCOMPANYID in ($ORGID) and (FPurDate>=$endtime or FPurDate<$starttime)); delete from T_NT_Cheque where FCompanyID in ($ORGID) and (FPurDate>=$endtime or FPurDate<$starttime); --收款支票 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_NT_RecCheque') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_NT_RecCheque where FCOMPANYID in ($ORGID) and (FFReceiveDate0>=$endtime or FFReceiveDate0<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_NT_RecCheque') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_NT_RecCheque where FCOMPANYID in ($ORGID) and (FFReceiveDate0>=$endtime or FFReceiveDate0<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_NT_RecCheque') delete from T_NT_RecCheque where FCompanyID in ($ORGID) and (FFReceiveDate0>=$endtime or FFReceiveDate0<$starttime); ----电汇单 --收款票据 --付款票据 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_NT_ReceiptBill where FCOMPANYID in ($ORGID) and (FReceiptDate>=$endtime or FReceiptDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_NT_ReceiptBill where FCOMPANYID in ($ORGID) and (FReceiptDate>=$endtime or FReceiptDate<$starttime)); delete from T_NT_ReceiptBill where FCompanyID in ($ORGID) and (FReceiptDate>=$endtime or FReceiptDate<$starttime); --应收票据 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_NT_ReceivableBill where FCOMPANYID in ($ORGID) and (FTakeDate>=$endtime or FTakeDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_NT_ReceivableBill where FCOMPANYID in ($ORGID) and (FTakeDate>=$endtime or FTakeDate<$starttime)); delete from T_NT_ReceivableBill where FCompanyID in ($ORGID) and (FTakeDate>=$endtime or FTakeDate<$starttime); --源单id update t_nt_ReceivableBill set fsourcebillid=null where fsourcebillid in (select FID from T_NT_EndorsementBill where FCOMPANYID in ($ORGID) and (FEndorseDate>=$endtime or FEndorseDate<$starttime)); --应付票据 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_NT_PayableBill where FCOMPANYID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_NT_PayableBill where FCOMPANYID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); delete from T_NT_PayableBill where FCompanyID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime); --背书单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_NT_EndorsementBill where FCOMPANYID in ($ORGID) and (FEndorseDate>=$endtime or FEndorseDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_NT_EndorsementBill where FCOMPANYID in ($ORGID) and (FEndorseDate>=$endtime or FEndorseDate<$starttime)); delete from T_NT_EndorsementBill where FCompanyID in ($ORGID) and (FEndorseDate>=$endtime or FEndorseDate<$starttime); --贴现单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_NT_DiscountBill where FCOMPANYID in ($ORGID) and (FDiscountDate>=$endtime or FDiscountDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_NT_DiscountBill where FCOMPANYID in ($ORGID) and (FDiscountDate>=$endtime or FDiscountDate<$starttime)); delete from T_NT_DiscountBill where FCompanyID in ($ORGID) and (FDiscountDate>=$endtime or FDiscountDate<$starttime); --收款单 出纳收款单 --质押单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_Wage where FCOMPANYID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_Wage where FCOMPANYID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); delete from T_FIN_Wage where FCompanyID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime); --退票单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_NT_ReturnBill where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_NT_ReturnBill where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); delete from T_NT_ReturnBill where FCompanyID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime); --转付单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_NT_PayableTransferBill where FCOMPANYID in ($ORGID) and (FTransferDate>=$endtime or FTransferDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_NT_PayableTransferBill where FCOMPANYID in ($ORGID) and (FTransferDate>=$endtime or FTransferDate<$starttime)); delete from T_NT_PayableTransferBill where FCompanyID in ($ORGID) and (FTransferDate>=$endtime or FTransferDate<$starttime); --兑付单 (借款、信用证)还款单 -------------5投资管理 --委托贷款单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CL_ConsignmentLoanBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CL_ConsignmentLoanBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_CL_ConsignmentLoanBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --委托展期单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CL_ConsignLoanExtBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CL_ConsignLoanExtBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_CL_ConsignLoanExtBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --委托还款单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CL_ConsingnRepaymentBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CL_ConsingnRepaymentBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_CL_ConsingnRepaymentBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --资金往来单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FT_FundTransferBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FT_FundTransferBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_FT_FundTransferBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --资金往来展期单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_FT_FundTransferExtBill') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FT_FundTransferExtBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_FT_FundTransferExtBill') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FT_FundTransferExtBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_FT_FundTransferExtBill') delete from T_FT_FundTransferExtBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --资金往来委托展期单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CL_ConsignLoanExtBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CL_ConsignLoanExtBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_CL_ConsignLoanExtBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --资金往来还款单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FT_FundTransferRepayBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FT_FundTransferRepayBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_FT_FundTransferRepayBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --银行定期(通知)存款申请单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_TD_TimeDepositApply where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_TD_TimeDepositApply where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_TD_TimeDepositApply where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --银行定期(通知)存款 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_TD_TimeDepositBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_TD_TimeDepositBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_TD_TimeDepositBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --银行定期(通知)存款解活单 If exists (select * from KSQL_USERCOLUMNS where KSQL_COL_NAME ='FMyBizDate' and KSQL_COL_TABNAME='T_TD_UnTimeDepositBill') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_TD_UnTimeDepositBill where FCOMPANYID in ($ORGID) and (FMyBizDate>=$endtime or FMyBizDate<$starttime)); If exists (select * from KSQL_USERCOLUMNS where KSQL_COL_NAME ='FMyBizDate' and KSQL_COL_TABNAME='T_TD_UnTimeDepositBill') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_TD_UnTimeDepositBill where FCOMPANYID in ($ORGID) and (FMyBizDate>=$endtime or FMyBizDate<$starttime)); If exists (select * from KSQL_USERCOLUMNS where KSQL_COL_NAME ='FMyBizDate' and KSQL_COL_TABNAME='T_TD_UnTimeDepositBill') delete from T_TD_UnTimeDepositBill where FCompanyID in ($ORGID) and (FMyBizDate>=$endtime or FMyBizDate<$starttime); --企业贷款单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_ChLoan') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IVT_ChLoan where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_ChLoan') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IVT_ChLoan where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_ChLoan') delete from T_IVT_ChLoan where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --企业贷款展期单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_CHLoanExtendBill') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IVT_CHLoanExtendBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_CHLoanExtendBill') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IVT_CHLoanExtendBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_CHLoanExtendBill') delete from T_IVT_CHLoanExtendBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --企业贷款还款单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_EntRepaymentBill') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IVT_EntRepaymentBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_EntRepaymentBill') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IVT_EntRepaymentBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_EntRepaymentBill') delete from T_IVT_EntRepaymentBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --(股票投资单) IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_SK_StockInvestBill') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_SK_StockInvestBill where FCOMPANYID in ($ORGID) and (FExchangeDate>=$endtime or FExchangeDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_SK_StockInvestBill') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_SK_StockInvestBill where FCOMPANYID in ($ORGID) and (FExchangeDate>=$endtime or FExchangeDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_SK_StockInvestBill') delete from T_SK_StockInvestBill where FCompanyID in ($ORGID) and (FExchangeDate>=$endtime or FExchangeDate<$starttime); --(股东代码) IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_SK_Stockholder') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_SK_Stockholder where FCurCompanyID in ($ORGID) and (FCreateTime>=$endtime or FCreateTime<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_SK_Stockholder') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_SK_Stockholder where FCurCompanyID in ($ORGID) and (FCreateTime>=$endtime or FCreateTime<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_SK_Stockholder') delete from T_SK_Stockholder where FCurCompanyID in ($ORGID) and (FCreateTime>=$endtime or FCreateTime<$starttime); --股票库存初始化 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_SK_FundSettleBill') delete from T_SK_FundSettleBill where FCompanyID in ($ORGID) and (FCreateTime>=$endtime or FCreateTime<$starttime); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_SK_StockSettleBill') delete from T_SK_StockSettleBill where FCompanyID in ($ORGID) and (FCreateTime>=$endtime or FCreateTime<$starttime); -----------6融资管理 --授信额度 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_CreditLimit where FCOMPANYID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_CreditLimit where FCOMPANYID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); delete from T_FIN_CreditLimit where FCompanyID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime); --抵质押物 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_Wage where FCOMPANYID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_Wage where FCOMPANYID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); delete from T_FIN_Wage where FCompanyID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime); delete from T_FIN_WageEntry where FParentID in (select FID from T_FIN_Wage where FCOMPANYID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); --借款申请单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_LoanApplyBill where FCOMPANYID in ($ORGID) and (FApplyDate>=$endtime or FApplyDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_LoanApplyBill where FCOMPANYID in ($ORGID) and (FApplyDate>=$endtime or FApplyDate<$starttime)); delete from T_FIN_LoanApplyBill where FCompanyID in ($ORGID) and (FApplyDate>=$endtime or FApplyDate<$starttime); --信用证 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_LetterOfCredit where FCOMPANYID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_LetterOfCredit where FCOMPANYID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); delete from T_FIN_LetterOfCredit where FCompanyID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime); --信用证手续费 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_FIN_FeeManage') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_FeeManage where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_FIN_FeeManage') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_FeeManage where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_FIN_FeeManage') delete from T_FIN_FeeManage where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --信用证改证 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_FIN_ModifyLetter') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_ModifyLetter where FCOMPANYID in ($ORGID) and (FModifyDate>=$endtime or FModifyDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_FIN_ModifyLetter') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_ModifyLetter where FCOMPANYID in ($ORGID) and (FModifyDate>=$endtime or FModifyDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_FIN_ModifyLetter') delete from T_FIN_ModifyLetter where FCompanyID in ($ORGID) and (FModifyDate>=$endtime or FModifyDate<$starttime); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_FIN_ModifyLetter') delete from T_FIN_ModifyLetterEntry where FParentID in (select FID from T_FIN_ModifyLetter where FCOMPANYID in ($ORGID) and (FModifyDate>=$endtime or FModifyDate<$starttime)); --借款单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_Loan where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_Loan where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_FIN_Loan where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --借款展期单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_LoanDefer where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_LoanDefer where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_FIN_LoanDefer where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --(借款、信用证)还款单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_Repayment where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_Repayment where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_FIN_Repayment where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --企业定期(通知)存款单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_CompDepositAccountBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_CompDepositAccountBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_FIN_CompDepositAccountBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --企业定期(通知)解活单 If exists (select * from KSQL_USERCOLUMNS where KSQL_COL_NAME ='FBizDate' and KSQL_COL_TABNAME='T_FIN_UnTimeDepositBill') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_UnTimeDepositBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); If exists (select * from KSQL_USERCOLUMNS where KSQL_COL_NAME ='FBizDate' and KSQL_COL_TABNAME='T_FIN_UnTimeDepositBill') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_UnTimeDepositBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); If exists (select * from KSQL_USERCOLUMNS where KSQL_COL_NAME ='FBizDate' and KSQL_COL_TABNAME='T_FIN_UnTimeDepositBill') delete from T_FIN_UnTimeDepositBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); ---------------7或有负债 --银行保函 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_CTL_LetterOfGuarantee') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CTL_LetterOfGuarantee where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_CTL_LetterOfGuarantee') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CTL_LetterOfGuarantee where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_CTL_LetterOfGuarantee') delete from T_CTL_LetterOfGuarantee where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --银行保函改函 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CTL_LetOfGuarantee where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CTL_LetOfGuarantee where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_CTL_LetOfGuarantee where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); delete from T_CTL_LetOfGuaranteeEntry where FParentID in (select FID from T_CTL_LetOfGuarantee where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); --银行保函手续费 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CTL_FeeForGuarantee where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CTL_FeeForGuarantee where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_CTL_FeeForGuarantee where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --银行保理 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_CTL_BankFactor') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CTL_BankFactor where FFICompanyID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_CTL_BankFactor') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CTL_BankFactor where FFICompanyID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_CTL_BankFactor') delete from T_CTL_BankFactor where FFICompanyID in ($ORGID) and (FIssueDate>=$endtime or FIssueDate<$starttime); --担保单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_CTL_AssureBill') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CTL_AssureBill where FCOMPANYID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_CTL_AssureBill') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CTL_AssureBill where FCOMPANYID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_CTL_AssureBill') delete from T_CTL_AssureBill where FCompanyID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime); -----------------8资金监控 --受限存款单 delete from T_MNT_DepositInControl where FCompanyID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime); --资金存量单 delete from T_MNT_CashInventory where FCompanyID in ($ORGID) and (FCreateTime>=$endtime or FCreateTime<$starttime); -----------------9银企互联 --银行付款单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_BE_BankPayingBill where FCOMPANYID in ($ORGID) and (FSubmitTime>=$endtime or FSubmitTime<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_BE_BankPayingBill where FCOMPANYID in ($ORGID) and (FSubmitTime>=$endtime or FSubmitTime<$starttime)); delete from T_BE_BankPayingBill where FCompanyID in ($ORGID) and (FSubmitTime>=$endtime or FSubmitTime<$starttime); --银行上划单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_BE_BankTransUpBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_BE_BankTransUpBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BE_BankTransUpBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); delete from T_BE_BankTransUpBillEntry where FParentID in (select FID from T_BE_BankTransUpBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); --银行下拨单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_BE_BankTransDownBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_BE_BankTransDownBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); delete from T_BE_BankTransDownBill where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); delete from T_BE_BankTransDownBillEntry where FParentID in (select FID from T_BE_BankTransDownBill where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); --银行账户交易余额(明细)表 delete from T_BE_TransDetail where FCompanyID in ($ORGID) and (FBizTime>=$endtime or FBizTime<$starttime); delete from T_BE_AccountBankBalance where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --------------------10利息管理 --内部利息单 --外部利息单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_INT_AccrualBill where FCOMPANYID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_INT_AccrualBill where FCOMPANYID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime)); delete from T_INT_AccrualBill where FCompanyID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime); delete from T_INT_AccrualBillEntry where FParentID in (select FID from T_INT_AccrualBill where FCOMPANYID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime)); --借款利息 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_LoanInterest where FCOMPANYID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_LoanInterest where FCOMPANYID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime)); delete from T_FIN_LoanInterest where FCompanyID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime); delete from T_FIN_LoanInterestEntry where FParentID in (select FID from T_FIN_LoanInterest where FCOMPANYID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime)); --企业贷款利息 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_LoanInterestBill') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IVT_LoanInterestBill where FCOMPANYID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_LoanInterestBill') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IVT_LoanInterestBill where FCOMPANYID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_LoanInterestBill') delete from T_IVT_LoanInterestBill where FCompanyID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IVT_LoanInterestBillEntry') delete from T_IVT_LoanInterestBillEntry where FParentID in (select FID from T_IVT_LoanInterestBill where FCOMPANYID in ($ORGID) and (FBeginDate>=$endtime or FBeginDate<$starttime)); --委托贷款利息 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CL_ConsignLoanIntBill where FCOMPANYID in ($ORGID) and (FStartDate>=$endtime or FStartDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CL_ConsignLoanIntBill where FCOMPANYID in ($ORGID) and (FStartDate>=$endtime or FStartDate<$starttime)); delete from T_CL_ConsignLoanIntBill where FCompanyID in ($ORGID) and (FStartDate>=$endtime or FStartDate<$starttime); --银行定期利息 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_TD_IntReceivedBill where FCOMPANYID in ($ORGID) and (FEffectiveDate>=$endtime or FEffectiveDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_TD_IntReceivedBill where FCOMPANYID in ($ORGID) and (FEffectiveDate>=$endtime or FEffectiveDate<$starttime)); delete from T_TD_IntReceivedBill where FCompanyID in ($ORGID) and (FEffectiveDate>=$endtime or FEffectiveDate<$starttime); --企业定期利息 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_CompIntReceivedBill where FCOMPANYID in ($ORGID) and (FEffectiveDate>=$endtime or FEffectiveDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_CompIntReceivedBill where FCOMPANYID in ($ORGID) and (FEffectiveDate>=$endtime or FEffectiveDate<$starttime)); delete from T_FIN_CompIntReceivedBill where FCompanyID in ($ORGID) and (FEffectiveDate>=$endtime or FEffectiveDate<$starttime); --资金往来利息 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FT_FundTransferInterestBill where FCOMPANYID in ($ORGID) and (FStartDate>=$endtime or FStartDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FT_FundTransferInterestBill where FCOMPANYID in ($ORGID) and (FStartDate>=$endtime or FStartDate<$starttime)); delete from T_FT_FundTransferInterestBill where FCompanyID in ($ORGID) and (FStartDate>=$endtime or FStartDate<$starttime); --委托贷款利息调整单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_CL_CLRateAdjustmentBill where FCOMPANYID in ($ORGID) and (FAdjustDate>=$endtime or FAdjustDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_CL_CLRateAdjustmentBill where FCOMPANYID in ($ORGID) and (FAdjustDate>=$endtime or FAdjustDate<$starttime)); delete from T_CL_CLRateAdjustmentBill where FCompanyID in ($ORGID) and (FAdjustDate>=$endtime or FAdjustDate<$starttime); --借款利息调整单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FIN_LoanAdjustInterest where FCOMPANYID in ($ORGID) and (FAdjustDate>=$endtime or FAdjustDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FIN_LoanAdjustInterest where FCOMPANYID in ($ORGID) and (FAdjustDate>=$endtime or FAdjustDate<$starttime)); delete from T_FIN_LoanAdjustInterest where FCompanyID in ($ORGID) and (FAdjustDate>=$endtime or FAdjustDate<$starttime); --资金往来利率调整单 delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_FT_FundTransRateAdjustBill where FCOMPANYID in ($ORGID) and (FAdjustDate>=$endtime or FAdjustDate<$starttime)); delete from T_BOT_RELATION where FDestObjectID in (select FID from T_FT_FundTransRateAdjustBill where FCOMPANYID in ($ORGID) and (FAdjustDate>=$endtime or FAdjustDate<$starttime)); delete from T_FT_FundTransRateAdjustBill where FCompanyID in ($ORGID) and (FAdjustDate>=$endtime or FAdjustDate<$starttime); ---------------11资金预测 --预计资金流动单 delete from T_MNT_ForecastedBlockingFlow where FCompanyID in ($ORGID) and (FExpectedDate>=$endtime or FExpectedDate<$starttime); ---------------12同业往来 --同业拆入单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_InnerFinBorIn') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IBT_InnerFinBorIn where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_InnerFinBorIn') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IBT_InnerFinBorIn where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_InnerFinBorIn') delete from T_IBT_InnerFinBorIn where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --同业拆出单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_InnerFinBorOut') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IBT_InnerFinBorOut where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_InnerFinBorOut') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IBT_InnerFinBorOut where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_InnerFinBorOut') delete from T_IBT_InnerFinBorOut where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --同业拆入还款单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_InnerBorrowingReturnIn') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IBT_InnerBorrowingReturnIn where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_InnerBorrowingReturnIn') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IBT_InnerBorrowingReturnIn where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_InnerBorrowingReturnIn') delete from T_IBT_InnerBorrowingReturnIn where FCompanyID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime); --同业拆出还款单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_InnerBorrowingReturnOut') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IBT_InnerBorrowingReturnOut where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_InnerBorrowingReturnOut') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IBT_InnerBorrowingReturnOut where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_InnerBorrowingReturnOut') delete from T_IBT_InnerBorrowingReturnOut where FCompanyID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime); --信贷资产出让单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_CredAsstTransOut') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IBT_CredAsstTransOut where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_CredAsstTransOut') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IBT_CredAsstTransOut where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_CredAsstTransOut') delete from T_IBT_CredAsstTransOut where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --信贷资产受让单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_CredAsstTransIn') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IBT_CredAsstTransIn where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_CredAsstTransIn') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IBT_CredAsstTransIn where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_CredAsstTransIn') delete from T_IBT_CredAsstTransIn where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --信贷资产出让回购单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_CreditAssRetOut') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IBT_CreditAssRetOut where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_CreditAssRetOut') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IBT_CreditAssRetOut where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_CreditAssRetOut') delete from T_IBT_CreditAssRetOut where FCompanyID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime); --信贷资产受让回购单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_CreditAssRetIn') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IBT_CreditAssRetIn where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_CreditAssRetIn') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IBT_CreditAssRetIn where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_CreditAssRetIn') delete from T_IBT_CreditAssRetIn where FCompanyID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime); --票据转贴出单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRediscountOut') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IBT_BillRediscountOut where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRediscountOut') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IBT_BillRediscountOut where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRediscountOut') delete from T_IBT_BillRediscountOut where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRediscountOut') delete from T_IBT_BillRediscountOutEntry where FParentID in (select FID from T_IBT_BillRediscountOut where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); --票据转贴入单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRediscountIn') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IBT_BillRediscountIn where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRediscountIn') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IBT_BillRediscountIn where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRediscountIn') delete from T_IBT_BillRediscountIn where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRediscountIn') delete from T_IBT_BillRediscountInEntry where FParentID in (select FID from T_IBT_BillRediscountIn where FCOMPANYID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime)); --票据转贴出回购单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRedRetOut') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IBT_BillRedRetOut where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRedRetOut') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IBT_BillRedRetOut where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRedRetOut') delete from T_IBT_BillRedRetOut where FCompanyID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRedRetOut') delete from T_IBT_BillRedRetOutEntry where FParentID in (select FID from T_IBT_BillRedRetOut where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); --票据转贴入回购单 IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRedRetIn') delete from T_BOT_RELATION where FSRCOBJECTID in (select FID from T_IBT_BillRedRetIn where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRedRetIn') delete from T_BOT_RELATION where FDestObjectID in (select FID from T_IBT_BillRedRetIn where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRedRetIn') delete from T_IBT_BillRedRetIn where FCompanyID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime); IF EXISTS (SELECT * FROM KSQL_USERTABLES WHERE KSQL_TABNAME='T_IBT_BillRedRetIn') delete from T_IBT_BillRedRetInEntry where FParentID in (select FID from T_IBT_BillRedRetIn where FCOMPANYID in ($ORGID) and (FReturnDate>=$endtime or FReturnDate<$starttime)); ----------------13基础资料 --1、 选择清理公司后,需将清理公司对应的银行账户全部删除; --delete from T_BD_AccountBanks where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --子账户 --delete from T_CAS_SubAccount where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); --内部账户 --delete from T_FS_InnerAccount where FCompanyID in ($ORGID) and (FBizDate>=$endtime or FBizDate<$starttime); update T_FIN_FeeManage set FFiVouchered=0 where FFiVouchered is null; IF NOT EXISTS (SELECT * FROM KSQL_USERCOLUMNS WHERE KSQL_COL_NAME ='FFiVouchered' AND KSQL_COL_TABNAME='T_FIN_FeeManage' and ksql_col_default is not null) ALTER TABLE T_FIN_FeeManage ADD DEFAULT 0 for FFiVouchered;