|
@@ -489,5 +489,91 @@
|
|
|
ORDER BY og.create_time DESC
|
|
|
</select>
|
|
|
|
|
|
+ <select id="listUserFreeUnionBuyGoodsList" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="GoodsUserQuestionVo">
|
|
|
+ SELECT * from (SELECT
|
|
|
+ g.*,
|
|
|
+ ps.supply_name,
|
|
|
+ cet.education_name,
|
|
|
+ cpt.project_name,
|
|
|
+ cb.business_name,
|
|
|
+ s.school_name,
|
|
|
+ m.category_name,
|
|
|
+ ot.type AS template_type,
|
|
|
+ ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
|
|
|
+ ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
|
|
|
+ o.user_id,
|
|
|
+ og.create_time as order_create_time,
|
|
|
+ og.service_start_time,
|
|
|
+ og.service_end_time,
|
|
|
+ og.order_goods_id,
|
|
|
+ (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
|
|
|
+ FROM
|
|
|
+ goods g
|
|
|
+ LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
|
|
|
+ LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
|
|
|
+ LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
|
|
|
+ LEFT JOIN course_business cb ON g.business_id = cb.id
|
|
|
+ LEFT JOIN school s ON s.id = g.school_id
|
|
|
+ LEFT JOIN major m ON g.major_id = m.id
|
|
|
+ LEFT JOIN order_input_template ot ON cb.template_status = ot.id
|
|
|
+ LEFT JOIN order_goods og on g.goods_id =og.goods_id
|
|
|
+ LEFT JOIN `order` o on o.order_sn = og.order_sn
|
|
|
+ WHERE
|
|
|
+ 1 = 1
|
|
|
+ AND g.goods_type = 2
|
|
|
+ AND o.user_id=#{userId}
|
|
|
+ AND og.`status` =1
|
|
|
+ and og.pay_status in (2,3,4)
|
|
|
+ AND og.refund_status in (0,3,1)
|
|
|
+ <if test="educationTypeId != null and educationTypeId != ''">
|
|
|
+ AND g.education_type_id = #{educationTypeId}
|
|
|
+ </if>
|
|
|
+ <if test="businessId != null and businessId != ''">
|
|
|
+ AND g.business_id = #{businessId}
|
|
|
+ </if>
|
|
|
+ UNION
|
|
|
+ SELECT
|
|
|
+ g.*,
|
|
|
+ ps.supply_name,
|
|
|
+ cet.education_name,
|
|
|
+ cpt.project_name,
|
|
|
+ cb.business_name,
|
|
|
+ s.school_name,
|
|
|
+ m.category_name,
|
|
|
+ ot.type AS template_type,
|
|
|
+ ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
|
|
|
+ ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
|
|
|
+ o.user_id,
|
|
|
+ og.create_time as order_create_time,
|
|
|
+ og.service_start_time,
|
|
|
+ og.service_end_time,
|
|
|
+ og.order_goods_id,
|
|
|
+ (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
|
|
|
+ FROM `order` o
|
|
|
+ LEFT JOIN order_goods og ON o.order_sn = og.order_sn
|
|
|
+ LEFT JOIN order_goods_free ogf ON og.order_goods_id = ogf.order_goods_id
|
|
|
+ LEFT JOIN goods g ON ogf.free_goods_id = g.goods_id
|
|
|
+ LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
|
|
|
+ LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
|
|
|
+ LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
|
|
|
+ LEFT JOIN course_business cb ON g.business_id = cb.id
|
|
|
+ LEFT JOIN school s ON s.id = g.school_id
|
|
|
+ LEFT JOIN major m ON g.major_id = m.id
|
|
|
+ LEFT JOIN order_input_template ot ON cb.template_status = ot.id
|
|
|
+ WHERE
|
|
|
+ 1 = 1
|
|
|
+ AND g.goods_type = 5
|
|
|
+ AND o.user_id = #{userId}
|
|
|
+ AND og.`status` = 1
|
|
|
+ AND og.pay_status IN ( 2, 3, 4 )
|
|
|
+ AND og.refund_status IN (0,3,1)
|
|
|
+ <if test="educationTypeId != null and educationTypeId != ''">
|
|
|
+ AND g.education_type_id = #{educationTypeId}
|
|
|
+ </if>
|
|
|
+ <if test="businessId != null and businessId != ''">
|
|
|
+ AND g.business_id = #{businessId}
|
|
|
+ </if>
|
|
|
+ )un ORDER BY un.order_create_time DESC
|
|
|
|
|
|
+ </select>
|
|
|
</mapper>
|