|
@@ -1,33 +1,37 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import com.sun.javafx.collections.MappingChange;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
+import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDto;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
-import com.ym.mec.biz.service.MusicGroupSchoolTermCourseDetailService;
|
|
|
-import com.ym.mec.biz.service.SysConfigService;
|
|
|
-import com.ym.mec.biz.service.SysMessageService;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
+import com.ym.mec.common.redis.service.RedisCache;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.AUDITING;
|
|
|
+
|
|
|
@Service
|
|
|
public class MusicGroupSchoolTermCourseDetailServiceImpl extends BaseServiceImpl<Integer, MusicGroupSchoolTermCourseDetail> implements MusicGroupSchoolTermCourseDetailService {
|
|
|
|
|
@@ -55,6 +59,18 @@ public class MusicGroupSchoolTermCourseDetailServiceImpl extends BaseServiceImpl
|
|
|
private StudentDao studentDao;
|
|
|
@Autowired
|
|
|
private MemberRankSettingDao memberRankSettingDao;
|
|
|
+ @Autowired
|
|
|
+ private MemberFeeSettingDao memberFeeSettingDao;
|
|
|
+ @Autowired
|
|
|
+ private OrganizationDao organizationDao;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupPaymentCalenderDetailService musicGroupPaymentCalenderDetailService;
|
|
|
+ @Autowired
|
|
|
+ private RedisCache<String, Object> redisCache;
|
|
|
+
|
|
|
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, MusicGroupSchoolTermCourseDetail> getDAO() {
|
|
@@ -152,7 +168,12 @@ public class MusicGroupSchoolTermCourseDetailServiceImpl extends BaseServiceImpl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void musicSchoolTermPush() {
|
|
|
+// Object o = redisCache.get("musicSchoolTermPush");
|
|
|
+// if(o != null){
|
|
|
+// return;
|
|
|
+// }
|
|
|
String remindCourseTime = sysConfigDao.findConfigValue(SysConfigService.REMIND_COURSE_TIME);
|
|
|
if(StringUtils.isEmpty(remindCourseTime)){
|
|
|
remindCourseTime = "14";
|
|
@@ -191,8 +212,9 @@ public class MusicGroupSchoolTermCourseDetailServiceImpl extends BaseServiceImpl
|
|
|
if(memberRankSetting != null){
|
|
|
memberName = memberRankSetting.getName();
|
|
|
}
|
|
|
+ Date date = new Date();
|
|
|
//会员结束前15天提醒学员续费
|
|
|
- String pushMemberRenew = sysConfigDao.findConfigValue(SysConfigService.PUSH_MEMBER_RENEW);
|
|
|
+ /*String pushMemberRenew = sysConfigDao.findConfigValue(SysConfigService.PUSH_MEMBER_RENEW);
|
|
|
if(StringUtils.isEmpty(pushMemberRenew)){
|
|
|
pushMemberRenew = "15";
|
|
|
}
|
|
@@ -220,8 +242,8 @@ public class MusicGroupSchoolTermCourseDetailServiceImpl extends BaseServiceImpl
|
|
|
0,
|
|
|
null,
|
|
|
"STUDENT",memberName,pushMemberRenew);
|
|
|
- }
|
|
|
- //会员结束前15天提醒学员续费
|
|
|
+ }*/
|
|
|
+ //会员结束前5天提醒学员续费
|
|
|
String pushMemberRenewAgain = sysConfigDao.findConfigValue(SysConfigService.PUSH_MEMBER_RENEW_AGAIN);
|
|
|
if(StringUtils.isEmpty(pushMemberRenewAgain)){
|
|
|
pushMemberRenewAgain = "5";
|
|
@@ -251,6 +273,86 @@ public class MusicGroupSchoolTermCourseDetailServiceImpl extends BaseServiceImpl
|
|
|
null,
|
|
|
"STUDENT",memberName,pushMemberRenewAgain);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //会员结束前15天自动创建乐团续费(默认提前15天)
|
|
|
+ String autoCreateMemberRenew = sysConfigDao.findConfigValue(SysConfigService.AUTO_CREATE_MEMBER_RENEW);
|
|
|
+ if(StringUtils.isEmpty(autoCreateMemberRenew)){
|
|
|
+ autoCreateMemberRenew = "15";
|
|
|
+ }
|
|
|
+ Map<String,String> studentMusicMap = MapUtil.convertMybatisMap(studentDao.queryAutoCreateStudentMap(autoCreateMemberRenew));
|
|
|
+ if(studentMusicMap.size() > 0){
|
|
|
+ for (String musicGroupId : studentMusicMap.keySet()) {
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
|
|
|
+ // 所有缴费项目已完成排课才能创建下一个缴费项目
|
|
|
+// String orignBatchNo = musicGroupPaymentStudentCourseDetailService.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, null, null,null);
|
|
|
+// if (StringUtils.isNoneBlank(orignBatchNo)) {
|
|
|
+// logger.error("自动创建缴费项目失败,{} 乐团存在未排课的缴费项目",musicGroup.getName());
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+ MemberFeeSetting memberFee = memberFeeSettingDao.findByRankIdAndOrganId(musicGroup.getOrganId(), memberRankSetting.getId());
|
|
|
+ if(memberFee == null){
|
|
|
+ Organization organization = organizationDao.get(musicGroup.getOrganId());
|
|
|
+ logger.error("自动创建缴费项目失败,{} 分部会员收费标准未配置",organization.getName());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //创建缴费项目
|
|
|
+ MusicGroupPaymentCalenderDto musicGroupPaymentCalenderDto = new MusicGroupPaymentCalenderDto();
|
|
|
+ musicGroupPaymentCalenderDto.setMusicGroupId(musicGroupId);
|
|
|
+ musicGroupPaymentCalenderDto.setMemberValidDate(6);
|
|
|
+ musicGroupPaymentCalenderDto.setMemo("系统自动创建缴费项目");
|
|
|
+ musicGroupPaymentCalenderDto.setMemberRankSettingId(memberRankSetting.getId());
|
|
|
+ musicGroupPaymentCalenderDto.setPayUserType(MusicGroupPaymentCalender.PayUserType.STUDENT);
|
|
|
+ musicGroupPaymentCalenderDto.setPaymentType(MusicGroupPaymentCalender.PaymentType.MUSIC_RENEW);
|
|
|
+ musicGroupPaymentCalenderDto.setPaymentPattern(1);
|
|
|
+ musicGroupPaymentCalenderDto.setMemberPaymentAmount(memberFee.getCurrentHalfYearFee().setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ musicGroupPaymentCalenderDto.setAutoCreate(true);
|
|
|
+ musicGroupPaymentCalenderDto.setIsGiveMusicNetwork(false);
|
|
|
+ List<MusicGroupPaymentCalenderDto.MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = new ArrayList<>();
|
|
|
+ MusicGroupPaymentCalenderDto.MusicGroupPaymentDateRange range = new MusicGroupPaymentCalenderDto().new MusicGroupPaymentDateRange();
|
|
|
+ range.setStartPaymentDate(date);
|
|
|
+ range.setDeadlinePaymentDate(DateUtil.addMonths(date,1));
|
|
|
+ musicGroupPaymentDateRangeList.add(range);
|
|
|
+ musicGroupPaymentCalenderDto.setMusicGroupPaymentDateRangeList(musicGroupPaymentDateRangeList);
|
|
|
+ String batchNo = "";
|
|
|
+ try {
|
|
|
+ batchNo = musicGroupPaymentCalenderService.create(musicGroupPaymentCalenderDto);
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.error("{} 乐团自动创建缴费项目失败,失败原因:{}",musicGroup.getName(),e.getMessage());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ MusicGroupPaymentCalender calender = musicGroupPaymentCalenderService.findByBatchNo(batchNo).get(0);
|
|
|
+ Set<Integer> userIdList = Arrays.stream(studentMusicMap.get(musicGroupId).split(",")).map(Integer::new).collect(Collectors.toSet());
|
|
|
+ musicGroupPaymentCalenderDetailService.batchAdd(calender.getId(),userIdList,musicGroup);
|
|
|
+ Map<Integer, String> studentPhoneMap = MapUtil.convertMybatisMap(teacherDao.queryPhoneByIds(studentMusicMap.get(musicGroupId)));
|
|
|
+ Map<Integer,String> userMap = new HashMap<>(userIdList.size());
|
|
|
+ Map<Integer,String> userMap1 = new HashMap<>(userIdList.size());
|
|
|
+ for (Integer studentId : userIdList) {
|
|
|
+ userMap.put(studentId,studentPhoneMap.get(studentId));
|
|
|
+ userMap1.put(studentId,studentId.toString());
|
|
|
+ }
|
|
|
+ String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
|
|
|
+ String pushUrl = "4?" + baseApiUrl + "/#/musicGroupRenew?calenderId=" + calender.getId() + "&id=" + musicGroupId;
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS,
|
|
|
+ MessageTypeEnum.AUTO_STUDENT_MEMBER_RENEW_MESSAGE,
|
|
|
+ userMap,
|
|
|
+ null,
|
|
|
+ 0,
|
|
|
+ pushUrl,
|
|
|
+ null,memberName,autoCreateMemberRenew);
|
|
|
+
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG,
|
|
|
+ MessageTypeEnum.AUTO_STUDENT_MEMBER_RENEW_MESSAGE,
|
|
|
+ userMap1,
|
|
|
+ null,
|
|
|
+ 0,
|
|
|
+ pushUrl,
|
|
|
+ "STUDENT",memberName,autoCreateMemberRenew);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ redisCache.getRedisTemplate().opsForValue().set("musicSchoolTermPush","musicSchoolTermPush",
|
|
|
+ 23,
|
|
|
+ TimeUnit.HOURS);
|
|
|
}
|
|
|
|
|
|
private MusicGroupSchoolTermCourseDetail getCourseDetail(MusicGroupSchoolTermCourseDetail courseDetail){
|