INSERT INTO exam_organization_relation (examination_basic_id_,organ_id_,settlement_type_,share_profit_amount_,total_registration_student_num_,total_payment_amount_,url_,send_url_flag_,is_allow_arrange_exam_,create_time_,update_time_,tenant_id_) VALUES(#{examinationBasicId},#{organId},#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{shareProfitAmount},#{totalRegistrationStudentNum},#{totalPaymentAmount},#{url},#{sendUrlFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{isAllowArrangeExam,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},NOW(),NOW(),#{tenantId}) INSERT INTO exam_organization_relation (examination_basic_id_,organ_id_,settlement_type_,share_profit_amount_,total_registration_student_num_,total_payment_amount_,url_,send_url_flag_,is_allow_arrange_exam_,create_time_,update_time_,tenant_id_) VALUES (#{examOrganizationRelation.examinationBasicId},#{examOrganizationRelation.organId},#{examOrganizationRelation.settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examOrganizationRelation.shareProfitAmount},#{examOrganizationRelation.totalRegistrationStudentNum},#{examOrganizationRelation.totalPaymentAmount},#{examOrganizationRelation.url},#{examOrganizationRelation.sendUrlFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examOrganizationRelation.isAllowArrangeExam,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},NOW(),NOW(),#{examOrganizationRelation.tenantId}) UPDATE exam_organization_relation examination_basic_id_ = #{examinationBasicId}, id_ = #{id}, send_url_flag_ = #{sendUrlFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}, is_allow_arrange_exam_ = #{isAllowArrangeExam,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}, url_ = #{url}, tenant_id_ = #{tenantId}, share_profit_amount_ = #{shareProfitAmount}, total_registration_student_num_ = #{totalRegistrationStudentNum}, total_payment_amount_ = #{totalPaymentAmount}, organ_id_ = #{organId}, settlement_type_ = #{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}, update_time_ = NOW() WHERE id_ = #{id} UPDATE exam_organization_relation examination_basic_id_ = #{eo.examinationBasicId}, send_url_flag_ = #{eo.sendUrlFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}, is_allow_arrange_exam_ = #{eo.isAllowArrangeExam,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}, url_ = #{eo.url}, tenant_id_ = #{eo.tenantId}, share_profit_amount_ = #{eo.shareProfitAmount}, total_registration_student_num_ = #{eo.totalRegistrationStudentNum}, total_payment_amount_ = #{eo.totalPaymentAmount}, organ_id_ = #{eo.organId}, settlement_type_ = #{eo.settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}, update_time_ = NOW() WHERE id_ = #{eo.id} UPDATE exam_organization_relation SET send_url_flag_=#{sendUrlFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler} WHERE examination_basic_id_=#{examId} AND organ_id_ IN #{organId} DELETE FROM exam_organization_relation WHERE id_ = #{id} ear.tenant_id_=#{tenantId} AND ear.examination_basic_id_=#{examId} AND ear.organ_id_ IN #{organId} AND ear.settlement_type_=#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler} AND ear.is_allow_arrange_exam_ = #{isAllowArrangeExam} AND (ear.organ_id_=#{search} OR a.name_ LIKE CONCAT(#{search}, '%')) o.tenant_id_ = #{tenantId} o.id_ IN #{organId} AND NOT EXISTS ( SELECT organ_id_ FROM exam_organization_relation WHERE examination_basic_id_ = #{examId} AND organ_id_ = o.id_ )