INSERT INTO exam_organization_relation (examination_basic_id_,organ_id_,settlement_type_,share_profit_amount_,
self_registration_student_num_,self_payment_amount_,total_registration_student_num_,total_payment_amount_,
url_,send_url_flag_,is_allow_arrange_exam_,total_trans_amount_,
create_time_,update_time_,tenant_id_)
VALUES(#{examinationBasicId},#{organId},#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{shareProfitAmount},
#{selfRegistrationStudentNum},#{selfPaymentAmount},#{totalRegistrationStudentNum},#{totalPaymentAmount},
#{url},#{sendUrlFlag},#{isAllowArrangeExam},#{totalTransAmount},
NOW(),NOW(),#{tenantId})
INSERT INTO exam_organization_relation (examination_basic_id_,organ_id_,settlement_type_,share_profit_amount_,
self_registration_student_num_,self_payment_amount_,total_registration_student_num_,total_payment_amount_,
url_,send_url_flag_,is_allow_arrange_exam_,total_trans_amount_,
create_time_,update_time_,tenant_id_)
VALUES
(#{examOrganizationRelation.examinationBasicId},#{examOrganizationRelation.organId},
#{examOrganizationRelation.settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
#{examOrganizationRelation.shareProfitAmount},
#{examOrganizationRelation.selfRegistrationStudentNum},
#{examOrganizationRelation.selfPaymentAmount},
#{examOrganizationRelation.totalRegistrationStudentNum},
#{examOrganizationRelation.totalPaymentAmount},#{examOrganizationRelation.url},
#{examOrganizationRelation.sendUrlFlag},
#{examOrganizationRelation.isAllowArrangeExam},
#{examOrganizationRelation.totalTransAmount},
NOW(),NOW(),#{examOrganizationRelation.tenantId})
UPDATE exam_organization_relation
examination_basic_id_ = #{examinationBasicId},
send_url_flag_ = #{sendUrlFlag},
is_allow_arrange_exam_ = #{isAllowArrangeExam},
url_ = #{url},
tenant_id_ = #{tenantId},
share_profit_amount_ = #{shareProfitAmount},
self_registration_student_num_ = #{selfRegistrationStudentNum},
self_payment_amount_ = #{selfPaymentAmount},
total_registration_student_num_ = #{totalRegistrationStudentNum},
total_payment_amount_ = #{totalPaymentAmount},
total_trans_amount_ = #{totalTransAmount},
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},
is_allow_arrange_exam_ = #{eo.isAllowArrangeExam},
url_ = #{eo.url},
tenant_id_ = #{eo.tenantId},
share_profit_amount_ = #{eo.shareProfitAmount},
self_registration_student_num_ = #{eo.selfRegistrationStudentNum},
self_payment_amount_ = #{eo.selfPaymentAmount},
total_registration_student_num_ = #{eo.totalRegistrationStudentNum},
total_payment_amount_ = #{eo.totalPaymentAmount},
total_trans_amount_ = #{eo.totalTransAmount},
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}
DELETE FROM exam_organization_relation
WHERE examination_basic_id_=#{examId} AND organ_id_ IN
#{organId}
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}, '%'))
AND o.tenant_id_ = #{tenantId}
AND o.id_ IN
#{organId}
AND NOT EXISTS ( SELECT organ_id_ FROM exam_organization_relation WHERE examination_basic_id_ = #{examId} AND organ_id_ = o.id_ )