/* * 保证金退款查询:包括招标方和投标方。通过status状态来区分,具体如下 * 招标使用表中的status(2、4、10、11) ,投标使用自定义的status(-1、-3、-5) */ String sql = "select t.id,t.projectId ,t.manageCompanyId ,t.tenderCautionMoney, t.tenderName,t.status " + "from tender_document t where (t.isRemove =1 or t.isRemove is null) and (t.isReturn is null or t.isReturn = 0) and t.tenderCautionMoney > 0 and t.`status` in (2,4,11) " + " union all select t.id,t.projectId ,t.manageCompanyId ,t.tenderCautionMoney ,t.tenderName,t.status from " + "tender_document t where (t.isRemove =1 or t.isRemove is null) and (t.isReturn is null or t.isReturn = 0) " + "and t.tenderCautionMoney > 0 and t.`status` = 10 and NOT EXISTS (select d.id from tender_bid_document d where d.tenderId = t.id and d.signState !=1) " + "union all select t.id,d.id as projectId ,d.companyId manageCompanyId ,t.bidCautionMoney tenderCautionMoney,t.tenderName,-1 as status " + "from tender_document t ,tender_bid_document d where t.id = d.tenderId and (t.isRemove =1 or t.isRemove is null) and (d.isReturn is null or d.isReturn = 0) " + "and t.bidCautionMoney > 0 and t.status = 11 and (select count(*) from tender_bid_document d where d.tenderId = t.id and d.status = 2) = 0 " + "union all select t.id,d.id as projectId ,d.companyId manageCompanyId ,t.bidCautionMoney tenderCautionMoney,t.tenderName, " + " -3 as status from tender_document t,tender_bid_document d where t.id = d.tenderId and (t.isRemove =1 or t.isRemove is null)" + " and (d.isReturn is null or d.isReturn = 0) and t.bidCautionMoney > 0 and t.endDate < NOW() and d.`status` =1 and " + "(select count(*) from tender_bid_document d where d.tenderId = t.id and d.status = 2) = 0 union all " + "select t.id,d.id as projectId ,d.companyId manageCompanyId ,t.bidCautionMoney tenderCautionMoney,t.tenderName, " + "-5 as status from tender_document t,tender_bid_document d where t.id = d.tenderId and (t.isRemove =1 or t.isRemove is null) " + "and (d.isReturn is null or d.isReturn = 0) and t.bidCautionMoney > 0 and d.signState = 1 and " + "(select count(*) from tender_bid_document d where d.tenderId = t.id and d.status = 2) = 0 "; return find(sql); }