INSERT INTO student_payment_order
(group_type_, user_id_, organ_id_, routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_,
per_amount_,
balance_payment_amount_, remit_fee_, course_remit_fee_, trans_no_,
status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_, pay_time_,batch_no_,coupon_code_id_,
coupon_remit_fee_,activity_id_,activity_buy_num_,tenant_id_,calender_id_)
VALUES (#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
#{userId}, #{organId}, #{routingOrganId},
#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
#{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount},
#{remitFee}, #{courseRemitFee}, #{transNo},
#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
#{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
#{musicGroupId},
#{classGroupId}, #{payTime},#{batchNo},#{couponCodeId},#{couponRemitFee},#{activityId},#{activityBuyNum},#{tenantId},#{calenderId})
UPDATE student_payment_order
activity_buy_num_ = #{activityBuyNum},
activity_id_ = #{activityId},
receive_status_ = #{receiveStatus},
status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
order_no_ = #{orderNo},
class_group_id_ = #{classGroupId},
expect_amount_ = #{expectAmount},
memo_ = #{memo},
payment_channel_ = #{paymentChannel},
user_id_ = #{userId},
payment_account_no_ = #{paymentAccountNo},
mer_nos_ = #{merNos},
payment_business_channel_ = #{paymentBusinessChannel},
trans_no_ = #{transNo},
actual_amount_ = #{actualAmount},
com_amount_ = #{comAmount},
per_amount_ = #{perAmount},
balance_payment_amount_ = #{balancePaymentAmount},
remit_fee_ = #{remitFee},
course_remit_fee_ = #{courseRemitFee},
type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
music_group_id_ = #{musicGroupId},
organ_id_ = #{organId},
routing_organ_id_ = #{routingOrganId},
pay_time_ = #{payTime},
batch_no_ = #{batchNo},
version_ = version_+1,
update_time_ = NOW()
WHERE id_ = #{id} AND version_ = #{version} and tenant_id_ = #{tenantId}
UPDATE student_payment_order
activity_buy_num_ = #{studentPaymentOrder.activityBuyNum},
activity_id_ = #{studentPaymentOrder.activityId},
receive_status_ = #{studentPaymentOrder.receiveStatus},
status_ = #{studentPaymentOrder.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
group_type_ = #{studentPaymentOrder.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
order_no_ = #{studentPaymentOrder.orderNo},
class_group_id_ = #{studentPaymentOrder.classGroupId},
expect_amount_ = #{studentPaymentOrder.expectAmount},
memo_ = #{studentPaymentOrder.memo},
payment_channel_ = #{studentPaymentOrder.paymentChannel},
user_id_ = #{studentPaymentOrder.userId},
payment_account_no_ = #{studentPaymentOrder.paymentAccountNo},
mer_nos_ = #{studentPaymentOrder.merNos},
payment_business_channel_ = #{studentPaymentOrder.paymentBusinessChannel},
trans_no_ = #{studentPaymentOrder.transNo},
actual_amount_ = #{studentPaymentOrder.actualAmount},
com_amount_ = #{studentPaymentOrder.comAmount},
per_amount_ = #{studentPaymentOrder.perAmount},
balance_payment_amount_ = #{studentPaymentOrder.balancePaymentAmount},
remit_fee_ = #{studentPaymentOrder.remitFee},
course_remit_fee_ = #{studentPaymentOrder.courseRemitFee},
type_ = #{studentPaymentOrder.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
music_group_id_ = #{studentPaymentOrder.musicGroupId},
organ_id_ = #{studentPaymentOrder.organId},
routing_organ_id_ = #{studentPaymentOrder.routingOrganId},
pay_time_ = #{studentPaymentOrder.payTime},
batch_no_ = #{studentPaymentOrder.batchNo},
version_ = version_+1,
update_time_ = NOW()
WHERE id_ = #{studentPaymentOrder.id} AND version_ = #{studentPaymentOrder.version} and tenant_id_ = #{studentPaymentOrder.tenantId}
DELETE
FROM student_payment_order
WHERE id_ = #{id}
spo.tenant_id_ = #{tenantId}
AND spo.user_id_ IN
#{userId}
AND FIND_IN_SET(spo.organ_id_,#{organId})
AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') >= #{orderStartDate}
AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') <= #{orderEndDate}
AND spo.group_type_ != #{notGroupType}
AND spo.type_ = #{paymentType}
AND spo.memo_ LIKE CONCAT('%',#{remark},'%')
AND spo.user_id_ = #{studentId}
AND spo.status_ = #{paymentStatus}
AND spo.payment_channel_ NOT IN (#{paymentChannel})
AND spo.com_amount_ > 0
AND spo.per_amount_ > 0
AND FIND_IN_SET(spo.routing_organ_id_,#{routingOrganId})
AND spo.actual_amount_ >= #{actualAmount}
AND spo.balance_payment_amount_ >= #{balancePaymentAmount}
AND (spo.id_ = #{orderNo} OR spo.order_no_ = #{orderNo})
AND FIND_IN_SET(#{merNos},spo.mer_nos_)
AND spo.trans_no_ = #{transNo}
spo.tenant_id_ = #{tenantId}
AND spo.user_id_ IN
#{userId}
AND FIND_IN_SET(spo.organ_id_,#{organId})
AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') >= #{orderStartDate}
AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') <= #{orderEndDate}
AND DATE_FORMAT(spo.create_time_,'%Y-%m') = #{month} AND spo.status_ = 'SUCCESS'
AND spo.group_type_ != #{notGroupType}
AND spo.type_ = #{paymentType}
AND spo.memo_ LIKE CONCAT('%',#{remark},'%')
AND spo.user_id_ = #{studentId}
AND spo.status_ = #{paymentStatus}
AND spo.payment_channel_ NOT IN (#{paymentChannel})
AND spo.com_amount_ > 0
AND spo.per_amount_ > 0
AND FIND_IN_SET(spo.routing_organ_id_,#{routingOrganId})
AND spo.actual_amount_ >= #{actualAmount}
AND spo.balance_payment_amount_ >= #{balancePaymentAmount}
AND (spo.id_ = #{orderNo} OR spo.order_no_ = #{orderNo})
AND FIND_IN_SET(#{merNos},spo.mer_nos_)
AND spo.trans_no_ = #{transNo}
AND spo.group_type_='SPORADIC'
AND sci.charge_type_ = #{chargeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
AND FIND_IN_SET(spo.organ_id_,#{organId})
AND (sci.title_ LIKE CONCAT('%',#{search},'%') OR su.username_ LIKE CONCAT('%',#{search},'%'))
AND sci.charge_type_ = #{chargeType}
AND spo.status_ = #{payStatus}