Browse Source

乐团缴费项目改造

zouxuan 2 years ago
parent
commit
5642e290f6

+ 10 - 8
mec-biz/src/main/resources/config/mybatis/CooperationShareProfitMapper.xml

@@ -83,17 +83,19 @@
 		</foreach>
 	</select>
 	<select id="initShareProfit" resultMap="CooperationShareProfit">
-		select spo.organ_id_,mg.cooperation_organ_id_ cooperation_id_,sr.music_group_id_,COUNT(distinct spod.id_) musical_num_,
-		SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_amount_ from student_registration sr
-			   left join music_group mg ON mg.id_ = sr.music_group_id_
-			   left join music_group_payment_calender mgpc ON mgpc.id_ = sr.music_group_payment_calender_id_
-			   left join student_payment_order spo ON spo.calender_id_ = sr.music_group_payment_calender_id_
-			   left join student_payment_order_detail spod ON spod.payment_order_id_ = spo.id_
-		where sr.music_group_status_ = 'NORMAL' AND mgpc.payment_type_ = 'MUSIC_APPLY' AND sr.music_group_id_ IN
+		select spo.organ_id_,mg.cooperation_organ_id_ cooperation_id_,sr.music_group_id_,spod.price_,COUNT(distinct spod.id_) musical_num_,
+		SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_amount_
+		from (select sr.music_group_id_,max(sr.music_group_payment_calender_id_) music_group_payment_calender_id_ from student_registration sr
+		where sr.music_group_id_ IN
 		<foreach collection="musicGroupIds" item="id" open="(" close=")">
 			#{id}
 		</foreach>
-		  AND spo.type_ = 'APPLY' AND spo.status_ = 'SUCCESS' AND spod.type_ = 'ORGAN_SHARE_PROFIT'
+		AND sr.music_group_status_ = 'NORMAL' group by sr.music_group_id_) sr
+		left join music_group mg ON mg.id_ = sr.music_group_id_
+		left join music_group_payment_calender mgpc ON mgpc.id_ = sr.music_group_payment_calender_id_
+		left join student_payment_order spo ON spo.calender_id_ = sr.music_group_payment_calender_id_
+		left join student_payment_order_detail spod ON spod.payment_order_id_ = spo.id_
+		where mgpc.payment_type_ = 'MUSIC_APPLY' AND spo.type_ = 'APPLY' AND spo.status_ = 'SUCCESS' AND spod.type_ = 'ORGAN_SHARE_PROFIT'
 	</select>
 	<resultMap id="CooperationShareProfitDto" type="com.ym.mec.biz.dal.entity.CooperationShareProfitDto" extends="CooperationShareProfit">
 		<result property="educationUserId" column="education_user_id_"/>