فهرست منبع

Merge branch '20221010' of http://git.dayaedu.com/yonge/mec into 20221010

yonge 2 سال پیش
والد
کامیت
b2af7922db

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/page/CooperationRefundQueryInfo.java

@@ -12,7 +12,7 @@ public class CooperationRefundQueryInfo extends QueryInfo {
     private String organId;
 
     @ApiModelProperty(value = "回访状态",required = false)
-    private Integer refundStatus;
+    private String refundStatus;
 
     @ApiModelProperty(value = "缴费开始时间",required = false)
     private String refundStartDate;
@@ -39,11 +39,11 @@ public class CooperationRefundQueryInfo extends QueryInfo {
         this.cooperationId = cooperationId;
     }
 
-    public Integer getRefundStatus() {
+    public String getRefundStatus() {
         return refundStatus;
     }
 
-    public void setRefundStatus(Integer refundStatus) {
+    public void setRefundStatus(String refundStatus) {
         this.refundStatus = refundStatus;
     }
 

+ 5 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CooperationShareProfitServiceImpl.java

@@ -51,9 +51,11 @@ public class CooperationShareProfitServiceImpl extends BaseServiceImpl<Integer,
 			params.put("offset", pageInfo.getOffset());
 			dataList = cooperationShareProfitDao.queryDtoPage(params);
 			List<Integer> eduUserIds = dataList.stream().map(e -> e.getEducationUserId()).distinct().collect(Collectors.toList());
+			List<String> groupIds = dataList.stream().map(e -> e.getMusicGroupId()).distinct().collect(Collectors.toList());
+			List<Integer> organIds = dataList.stream().map(e -> e.getOrganId()).distinct().collect(Collectors.toList());
 			Map<Integer, String> eduNameMap = MapUtil.convertMybatisMap(teacherDao.queryNameByIdList(eduUserIds));
-			Map<Integer, String> organNameMap = getMap("organization", "id_", "name_", true,queryInfo.getTenantId(), Integer.class, String.class);
-			Map<Integer, String> groupNameMap = getMap("music_group", "id_", "name_", true,queryInfo.getTenantId(), Integer.class, String.class);
+			Map<Integer, String> organNameMap = getMap("organization", "id_", "name_", organIds,queryInfo.getTenantId(), Integer.class, String.class);
+			Map<String, String> groupNameMap = getMap("music_group", "id_", "name_", groupIds,queryInfo.getTenantId(), String.class, String.class);
 			for (CooperationShareProfitDto dto : dataList) {
 				dto.setEducationUserName(eduNameMap.get(dto.getEducationUserId()));
 				dto.setOrganName(organNameMap.get(dto.getOrganId()));
@@ -76,6 +78,7 @@ public class CooperationShareProfitServiceImpl extends BaseServiceImpl<Integer,
 		List<CourseSchedule> courseSchedules = courseScheduleDao.findByCourseScheduleIds(courseIds);
 		List<String> musicGroupIds = courseSchedules.stream().map(e -> e.getMusicGroupId()).distinct().collect(Collectors.toList());
 		musicGroupIds.removeAll(cooperationShareProfitDao.queryNotShare(musicGroupIds));
+		musicGroupIds.removeAll(Collections.singleton(null));
 		if(CollectionUtils.isEmpty(musicGroupIds)){
 			return;
 		}

+ 0 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupCalenderRefundPeriodServiceImpl.java

@@ -119,7 +119,6 @@ public class MusicGroupCalenderRefundPeriodServiceImpl extends BaseServiceImpl<I
             params.put("offset", pageInfo.getOffset());
             dataList = musicGroupCalenderRefundPeriodDao.queryCoopCalender(params);
             dataList.forEach(e->{
-                e.setIncome(e.getReceivable().subtract(e.getPrepaidFee()));
                 int compareTo = e.getPrepaidFee().compareTo(BigDecimal.ZERO);
                 e.setRefundStatus(compareTo > 0 ? "ING":"END");
             });

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java

@@ -331,6 +331,10 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
                     musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSettings.getCourseCurrentPrice());
                     musicGroupPaymentStudentCourseDetail.setSubCourseOriginalPrice(courseSettings.getCourseOriginalPrice());
                     musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(courseSettings.getCourseCurrentPrice());
+                    if(musicGroupPaymentCalender.getPayUserType() == SCHOOL){
+                        musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(BigDecimal.ZERO);
+                        musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(BigDecimal.ZERO);
+                    }
                     musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
                     musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
                     musicGroupPaymentStudentCourseDetail.setUserId(studentId);

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java

@@ -304,16 +304,16 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
             }
 
             //根据学校缴费项id,确定缴费状态
-            BigDecimal amount = studentPaymentRouteOrderDao.sumAmountByCalenderId(studentPaymentRouteOrder.getCalenderId());
+//            BigDecimal amount = studentPaymentRouteOrderDao.sumAmountByCalenderId(studentPaymentRouteOrder.getCalenderId());
             //修改学员缴费回款周期
-            Boolean aBoolean = musicGroupCalenderRefundPeriodService.calcRefundAmount(studentPaymentRouteOrder.getCalenderId(),studentPaymentRouteOrder.getOrderNo(), amount);
+            Boolean aBoolean = musicGroupCalenderRefundPeriodService.calcRefundAmount(studentPaymentRouteOrder.getCalenderId(),studentPaymentRouteOrder.getOrderNo(), studentPaymentRouteOrder.getRouteAmount());
 
             //是否已完成回款
             if(aBoolean){
                 List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.getCalenderDetailWithCalender(studentPaymentRouteOrder.getCalenderId());
                 MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(studentPaymentRouteOrder.getCalenderId());
 
-                if (amount.compareTo(musicGroupPaymentCalender.getCurrentTotalAmount()) >= 0) {
+                if (studentPaymentRouteOrder.getRouteAmount().compareTo(musicGroupPaymentCalender.getCurrentTotalAmount()) >= 0) {
                     musicGroupPaymentCalender.setActualNum(musicGroupPaymentCalender.getExpectNum());
                     musicGroupPaymentCalender.setStatus(MusicGroupPaymentCalender.PaymentCalenderStatusEnum.PAID);
                     musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);

+ 18 - 12
mec-biz/src/main/resources/config/mybatis/CooperationShareProfitMapper.xml

@@ -14,6 +14,7 @@
 		<result column="musical_num_" property="musicalNum" />
 		<result column="total_amount_" property="totalAmount" />
 		<result column="payment_status_" property="paymentStatus" />
+		<result column="credentials_" property="credentials" />
 		<result column="payment_no_" property="paymentNo" />
 		<result column="memo_" property="memo" />
 		<result column="credentials_" property="credentials" />
@@ -38,7 +39,7 @@
 	</insert>
 	<insert id="batchInsert">
 		INSERT INTO cooperation_share_profit (organ_id_,cooperation_id_,music_group_id_,musical_num_,total_amount_,
-		                                      payment_status_,payment_no_,memo_,create_time_,update_time_)
+		                                      payment_status_,create_time_,update_time_)
 		VALUES
 		<foreach collection="profits" item="bean" separator=",">
 			(#{bean.organId},#{bean.cooperationId},#{bean.musicGroupId},#{bean.musicalNum},#{bean.totalAmount},
@@ -49,16 +50,19 @@
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.CooperationShareProfit">
 		UPDATE cooperation_share_profit <set>
+		<if test="credentials != null and credentials != ''">
+			credentials_ = #{credentials},
+		</if>
 		<if test="paymentNo != null">
-		payment_no_ = #{paymentNo},
+			payment_no_ = #{paymentNo},
 		</if>
 		<if test="paymentStatus != null">
-		payment_status_ = #{paymentStatus},
+			payment_status_ = #{paymentStatus},
 		</if>
 		<if test="memo != null">
-		memo_ = #{memo},
+			memo_ = #{memo},
 		</if>
-		update_time_ = NOW()
+			update_time_ = NOW()
 	</set> WHERE id_ = #{id}
 	</update>
 	
@@ -83,17 +87,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_,
+		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 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
+		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_ and sr.user_id_ = spo.user_id_
+		left join student_payment_order_detail spod ON spod.payment_order_id_ = spo.id_
+		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'
+		AND mgpc.payment_type_ = 'MUSIC_APPLY' AND spo.type_ = 'APPLY' AND spo.status_ = 'SUCCESS' AND spod.type_ = 'ORGAN_SHARE_PROFIT'
+		group by sr.music_group_id_
 	</select>
 	<resultMap id="CooperationShareProfitDto" type="com.ym.mec.biz.dal.entity.CooperationShareProfitDto" extends="CooperationShareProfit">
 		<result property="educationUserId" column="education_user_id_"/>

+ 11 - 5
mec-biz/src/main/resources/config/mybatis/MusicGroupCalenderRefundPeriodMapper.xml

@@ -105,6 +105,7 @@
 	</resultMap>
 	<sql id="queryCoopRefundSql">
 		<where>
+			mgpc.status_ IN ('OPEN','OVER','PAID')
 			<if test="errorType != null and errorType != ''">
 				<if test="errorType == 'COOPERATION_PAYMENT_ERROR'">
 					AND TIMESTAMPDIFF(DAY,crp.refund_date_,DATE_FORMAT(NOW(),'%Y-%m-%d')) >= 1
@@ -125,6 +126,7 @@
 		select COUNT(DISTINCT crp.cooperation_organ_id_)
 		from music_group_calender_refund_period crp
 		left join cooperation_organ co ON co.id_ = crp.cooperation_organ_id_
+		left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
 		<include refid="queryCoopRefundSql"/>
 	</select>
 	<select id="queryCoopRefund" resultMap="CooperationRefundDto">
@@ -132,6 +134,7 @@
 		SUM(refund_amount_) receivable_,SUM(sub_refund_amount_) prepaidFee,co.education_user_id_
 		from music_group_calender_refund_period crp
 		left join cooperation_organ co ON co.id_ = crp.cooperation_organ_id_
+		left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
 		<include refid="queryCoopRefundSql"/>
 		group by crp.cooperation_organ_id_
 		order by crp.id_ DESC
@@ -145,12 +148,14 @@
 		<result property="calenderFeeType" column="calender_fee_type_"/>
 		<result property="receivable" column="receivable_"/>
 		<result property="prepaidFee" column="prepaidFee"/>
+		<result property="income" column="income_"/>
 		<result property="nextRefundDate" column="nextRefundDate"/>
 		<result property="refundStatus" column="refundStatus"/>
 		<result property="contractUrl" column="contract_url_"/>
 	</resultMap>
 	<sql id="queryCoopCalenderSql">
 		<where>
+			mgpc.status_ IN ('OPEN','OVER','PAID')
 			<if test="cooperationId != null">
 				AND crp.cooperation_organ_id_ = #{cooperationId}
 			</if>
@@ -167,21 +172,21 @@
 	</sql>
 	<sql id="queryCoopCalenderHavingSql">
 		<if test="refundStatus != null and refundStatus != ''">
-			<if test="refundStatus = 'ING'">
+			<if test="refundStatus == 'ING'">
 				HAVING SUM(crp.sub_refund_amount_) > 0
 			</if>
-			<if test="refundStatus = 'END'">
+			<if test="refundStatus == 'END'">
 				HAVING SUM(crp.sub_refund_amount_) = 0
 			</if>
 		</if>
 	</sql>
 	<select id="queryCoopCalender" resultMap="CooperationCalenderRefundDto">
 		select crp.calender_id_,mgpc.music_group_id_,mg.name_ music_group_name_,mgpc.batch_no_,mgpc.payment_type_,mgpc.calender_fee_type_,
-			   SUM(crp.refund_amount_) receivable_,SUM(crp.sub_refund_amount_) prepaidFee,
+			   SUM(crp.refund_amount_) receivable_,SUM(crp.sub_refund_amount_) prepaidFee,SUM(crp.income_) income_,
 			   MIN(CASE WHEN crp.refund_flag_ = 0 THEN crp.refund_date_ ELSE NULL END) nextRefundDate,crp.organ_id_,mgpc.contract_url_
 		from music_group_calender_refund_period crp
-				 left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
-				 left join music_group mg ON mg.id_ = mgpc.music_group_id_
+		left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
+		left join music_group mg ON mg.id_ = mgpc.music_group_id_
 		<include refid="queryCoopCalenderSql"/>
 		group by crp.calender_id_
 		<include refid="queryCoopCalenderHavingSql"/>
@@ -198,6 +203,7 @@
 	<select id="sumCoopRefund" resultType="java.math.BigDecimal">
 		select CASE WHEN crp.id_ IS NULL THEN 0 ELSE SUM(sub_refund_amount_) END from music_group_calender_refund_period crp
 		left join cooperation_organ co ON co.id_ = crp.cooperation_organ_id_
+		left join music_group_payment_calender mgpc ON mgpc.id_ = crp.calender_id_
 		<include refid="queryCoopRefundSql"/>
 	</select>
 </mapper>

+ 5 - 0
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupCalenderRefundPeriodController.java

@@ -3,6 +3,7 @@ package com.ym.mec.web.controller;
 import com.ym.mec.biz.dal.dto.CooperationCalenderRefundDto;
 import com.ym.mec.biz.dal.page.CooperationRefundQueryInfo;
 import com.ym.mec.biz.service.MusicGroupCalenderRefundPeriodService;
+import com.ym.mec.biz.service.OrganizationService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.PageInfo;
@@ -25,12 +26,15 @@ public class MusicGroupCalenderRefundPeriodController extends BaseController {
 
     @Autowired
     private MusicGroupCalenderRefundPeriodService musicGroupCalenderRefundPeriodService;
+    @Autowired
+    private OrganizationService organizationService;
 
     @ApiOperation(value = "获取合作单位费用汇总列表")
     @PostMapping("/queryCoopRefund")
     @PreAuthorize("@pcs.hasPermissions('musicGroupCalenderRefundPeriod/queryCoopRefund')")
     @AuditLogAnnotation(operateName = "获取合作单位费用汇总列表")
     public HttpResponseResult<HashMap<String, Object>> queryCoopRefund(@RequestBody CooperationRefundQueryInfo queryInfo) {
+        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
         HashMap<String, Object> resultMap = new HashMap<>(2);
         resultMap.put("pageInfo",musicGroupCalenderRefundPeriodService.queryCoopRefund(queryInfo));
         resultMap.put("amount",musicGroupCalenderRefundPeriodService.sumCoopRefund(queryInfo));
@@ -42,6 +46,7 @@ public class MusicGroupCalenderRefundPeriodController extends BaseController {
     @PreAuthorize("@pcs.hasPermissions('musicGroupCalenderRefundPeriod/queryCoopCalender')")
     @AuditLogAnnotation(operateName = "获取合作单位学校缴费列表")
     public HttpResponseResult<PageInfo<CooperationCalenderRefundDto>> queryCoopCalender(@RequestBody CooperationRefundQueryInfo queryInfo) {
+        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
         return succeed(musicGroupCalenderRefundPeriodService.queryCoopCalender(queryInfo));
     }
 }

+ 3 - 2
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -242,11 +242,12 @@ public class TaskController extends BaseController {
 	// 更新课程状态至已结束
 	public void updateCourseScheduleToOverStatus() throws Exception {
 		List<Long> courseIds = courseScheduleService.updateCourseScheduleToOverStatus();
+		//更新合作单位分润
+		cooperationShareProfitService.init(courseIds);
 		courseEventSource.courseStatusChange(courseIds);
+
 		courseIds = courseScheduleService.updateCourseScheduleToUnderway();
 		courseEventSource.courseStatusChange(courseIds);
-		//更新合作单位分润
-		cooperationShareProfitService.init(courseIds);
 		//发送定时群消息
 		imSendGroupMessageService.sendTimedMessages();
 		//更新乐团课统计信息