insert into source(id, scenic_id, device_id, url, video_url, `type`, face_sample_id, pos_json, create_time)
values (#{id}, #{scenicId}, #{deviceId}, #{url}, #{videoUrl}, #{type}, #{faceSampleId}, #{posJson}, #{createTime})
replace member_source(scenic_id, face_id, member_id, source_id, is_buy, type, order_id)
values (#{scenicId}, #{faceId}, #{memberId}, #{sourceId}, #{isBuy}, #{type}, #{orderId})
replace member_source(scenic_id, face_id, member_id, source_id, is_buy, type, order_id)
values
(#{item.scenicId}, #{item.faceId}, #{item.memberId}, #{item.sourceId}, #{item.isBuy}, #{item.type}, #{item.orderId})
update source
scenic_id = #{scenicId},
device_id = #{deviceId},
url = #{url},
video_url = #{videoUrl},
is_buy = #{isBuy},
`type` = #{type},
face_sample_id = #{faceSampleId},
pos_json = #{posJson},
where id = #{id}
update member_source
is_buy = #{isBuy},
order_id = #{orderId},
where member_id = #{memberId} and face_id = #{faceId} and `type` = #{type}
delete from source where id = #{id}
delete from `source`
where id not in (select source_id from member_source)
and type = #{type}
and create_time <= #{endDate}
delete from member_source
where scenic_id = #{scenicId} and is_buy = 0 and create_time <= #{endDate}