Simon Zhou преди 5 години
родител
ревизия
67c0620329
променени са 1 файла, в които са добавени 5 реда и са изтрити 1 реда
  1. 5 1
      controllers/erms2/erms2.go

+ 5 - 1
controllers/erms2/erms2.go

@@ -387,7 +387,11 @@ func QuerySpotContract(c *gin.Context) {
 							t.RelatedStatus
 						from ERMS2_SpotContract t
 						left join ERMS2_ASSpotDetail a on t.spotcontractid = a.spotcontractid
-						where t.ContractStatus = 0 and a.asapplyid = %d`, req.AsApplyID)
+						where t.ContractStatus = 0 
+							and not exists (
+								select 1 from ERMS2_ASTradeDetails e where e.spotcontractid=t.spotcontractid
+							)
+							and a.asapplyid = %d`, req.AsApplyID)
 	if req.SpotContractID > 0 {
 		sql += fmt.Sprintf(" and a.spotcontractid = %d", req.SpotContractID)
 	}