|
|
@@ -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)
|
|
|
}
|