INSERT INTO student_payment_order
        (id_,group_type_,user_id_,type_,expect_amount_,actual_amount_,com_amount_,per_amount_,balance_payment_amount_,trans_no_,
        status_,memo_,create_time_,update_time_,payment_channel_,payment_business_channel_,
        payment_account_no_,order_no_,music_group_id_,class_group_id_)
        VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
        #{userId},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
        #{expectAmount},#{actualAmount},#{comAmount},#{perAmount},#{balancePaymentAmount},#{transNo},
        #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{memo},now(),now(),
        #{paymentChannel},#{paymentBusinessChannel},#{paymentAccountNo},#{orderNo},#{musicGroupId},#{classGroupId})
    
    
    
        UPDATE student_payment_order
        
            
                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},
            
            
                update_time_ = NOW(),
            
            
                payment_business_channel_ = #{paymentBusinessChannel},
            
            
                trans_no_ = #{transNo},
            
            
                actual_amount_ = #{actualAmount},
            
            
                com_amount_ = #{comAmount},
            
            
                per_amount_ = #{perAmount},
            
            
                balance_payment_amount_ = #{balancePaymentAmount},
            
            
                type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
            
            
                music_group_id_ = #{musicGroupId},
            
            
                pay_time_ = #{payTime},
            
            
                version_ = version_+1,
            
        
        WHERE id_ = #{id} AND version_ = #{version}
    
    
    
        DELETE FROM student_payment_order WHERE id_ = #{id}
    
    
    
    
    
    
        
            
                AND FIND_IN_SET(u.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.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