要求按照以下順序排序
審核中->審核拒絕->待放款->放款失敗->待還款->已結清->已逾期
{
id:80,
label:'審核中'
},{
id:100,
label:'審核拒絕'
},{
id:90,
label:'待放款'
},{
id:170,
label:'放款失敗'
}
,{
id:175,
label:'待還款'
}
,{
id:200,
label:'已結清'
}
,{
id:180,
label:'已逾期'
}
實現sql
select id, phone, user_name AS userName, cid, product_id AS productId, product_name AS productName, status, repayment_status AS repaymentStatus, order_id AS orderId, associated_order_id AS associatedOrderId, apply_time AS applyTime, due_time AS dueTime, repayment_time AS repaymentTime, amount, product_amount AS productAmount, paid_amount AS paidAmount, actual_amount AS actualAmount, term, term_unit AS termUnit from loan_order <where> <if test="orderId != null and orderId !=''"> order_id = #{orderId} </if> <if test="associatedOrderId != null and associatedOrderId !=''"> and associated_order_id = #{associatedOrderId} </if> <if test="userName != null and userName !=''"> and user_name = #{userName} </if> <if test="status != null"> and status = #{status} </if> <if test="repaymentTime != null"> and repayment_status = #{repaymentTime} </if> <if test="phone != null and phone != ''"> and phone = #{phone} </if> <if test="cid != null and cid != ''"> and cid = #{cid} </if> <if test="productName != null and productName != ''"> and product_name = #{productName} </if> <if test="startApplyTime != null"> AND DATE_FORMAT(apply_time, '%Y-%m-%d') >= DATE_FORMAT(#{startApplyTime}, '%Y-%m-%d') </if> <if test="endApplyTime != null"> AND DATE_FORMAT(apply_time, '%Y-%m-%d') <= DATE_FORMAT(#{endApplyTime}, '%Y-%m-%d') </if> <if test="startRepaymentTime != null"> AND DATE_FORMAT(repayment_time, '%Y-%m-%d') >= DATE_FORMAT(#{startRepaymentTime}, '%Y-%m-%d') </if> <if test="endRepaymentTime != null"> AND DATE_FORMAT(repayment_time, '%Y-%m-%d') <= DATE_FORMAT(#{endRepaymentTime}, '%Y-%m-%d') </if> </where> order by (CASE WHEN `status` = 80 THEN 0 WHEN `status` = 100 THEN 1 WHEN `status` = 90 THEN 2 WHEN `status` = 170 THEN 3 WHEN `status` = 175 THEN 4 WHEN `status` = 200 THEN 5 WHEN `status` = 180 THEN 6 ELSE 7 END) asc