Explorar el Código

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

yonge hace 4 años
padre
commit
c7ccb259af

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentExtracurricularExercisesSituationDao.java

@@ -29,7 +29,8 @@ public interface StudentExtracurricularExercisesSituationDao extends BaseDAO<Lon
      * @param monday:
      * @return int
      */
-    int deleteByMonday(@Param("monday") String monday);
+    int deleteByMonday(@Param("monday") String monday,
+                       @Param("studentIds") List<Integer> studentIds);
 
     /**
      * @describe 删除指定学员的服务指标

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

@@ -289,7 +289,7 @@ public class ExtracurricularExercisesReplyServiceImpl extends BaseServiceImpl<Lo
 			studentExtracurricularExercisesSituation.setExercisesMessageTimelyNum(exercisesMessageTimelyNum>0?1:0);
 			results.add(studentExtracurricularExercisesSituation);
 		}
-		studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString());
+		studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(),null);
 		studentExtracurricularExercisesSituationDao.batchInsert(results);
 	}
 
@@ -359,7 +359,7 @@ public class ExtracurricularExercisesReplyServiceImpl extends BaseServiceImpl<Lo
 			results.add(studentExtracurricularExercisesSituation);
 		}
 
-		studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString());
+		studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(),null);
 
 		BigDecimal currentPage=BigDecimal.ONE,
                 pageSize=new BigDecimal(10000),

+ 8 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -351,6 +351,12 @@ public class PayServiceImpl implements PayService {
             if (i == routeScaleDtos.size() && !feeFlag) {
                 routeScaleDto.setFeeFlag("Y");
             }
+            //ADAPAY 采用延迟分账模式,手续费各自承担(2021-01-01号正式执行)
+            String delayRouteStartDate = sysConfigDao.findConfigValue("delay_route_start_date");
+            if (routeScaleDto.getPayType().equals(PaymentChannelEnum.ADAPAY) &&
+                    new Date().after(Objects.requireNonNull(DateUtil.stringToDate(delayRouteStartDate, "yyyy-MM-dd HH:mm:ss")))) {
+                routeScaleDto.setFeeFlag("Y");
+            }
 
             StudentPaymentRouteOrder studentPaymentRouteOrder = new StudentPaymentRouteOrder();
             studentPaymentRouteOrder.setOrderNo(orderNo);
@@ -474,9 +480,9 @@ public class PayServiceImpl implements PayService {
         for (Map.Entry<String, List<RouteScaleDto>> groupRouteScaleDtos : routeScaleDtosMap.entrySet()) {
             RouteScaleDto routeScaleDto = null;
             for (RouteScaleDto scaleDto : groupRouteScaleDtos.getValue()) {
-                if(routeScaleDto == null){
+                if (routeScaleDto == null) {
                     routeScaleDto = scaleDto;
-                }else {
+                } else {
                     routeScaleDto.setAmount(routeScaleDto.getAmount().add(scaleDto.getAmount()));
                     routeScaleDto.setBalance(routeScaleDto.getBalance().add(scaleDto.getBalance()));
                 }

+ 50 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -2,12 +2,15 @@ package com.ym.mec.biz.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentRouteOrderDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
 import com.ym.mec.biz.dal.dto.PageInfoOrder;
 import com.ym.mec.biz.dal.dto.SporadicChargeInfoDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.SporadicOrderQueryInfo;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
@@ -15,7 +18,9 @@ import com.ym.mec.biz.service.*;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.thirdparty.adapay.ConfigInit;
 import com.ym.mec.thirdparty.adapay.Payment;
 import com.ym.mec.thirdparty.yqpay.Msg;
 import com.ym.mec.thirdparty.yqpay.RsqMsg;
@@ -25,6 +30,7 @@ import com.ym.mec.util.collection.MapUtil;
 
 import com.ym.mec.util.date.DateUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.snaker.engine.entity.Order;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
@@ -62,6 +68,12 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     private SubjectChangeService subjectChangeService;
     @Autowired
     private DegreeRegistrationService degreeRegistrationService;
+    @Autowired
+    private StudentPaymentRouteOrderDao studentPaymentRouteOrderDao;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
+    @Autowired
+    private SysConfigDao sysConfigDao;
 
     @Override
     public BaseDAO<Long, StudentPaymentOrder> getDAO() {
@@ -162,7 +174,6 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         if (payingOrders.size() == 0) {
             return;
         }
-
         List<String> orderNoList = new ArrayList<String>();
 
         for (StudentPaymentOrder payingOrder : payingOrders) {
@@ -220,6 +231,11 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             //增加用户余额
             sysUserCashAccountService.updateBalance(order.getUserId(), order.getActualAmount(),
                     PlatformCashAccountDetailTypeEnum.REFUNDS, memo + ",订单号:" + order.getOrderNo());
+
+            if (order.getPaymentChannel().equals("ADAPAY")
+                    && !rpMap.containsKey("simulation")) {
+                confirmOrder(order);
+            }
             return;
         }
 
@@ -238,9 +254,41 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         }
         order.setPaymentBusinessChannel(rpMap.get("channelType"));
 
+        if (status.equals(DealStatusEnum.SUCCESS) && order.getPaymentChannel().equals("ADAPAY")
+                && !rpMap.containsKey("simulation")) {
+            confirmOrder(order);
+        }
+
         callOrderCallBack(order);
     }
 
+    private Boolean confirmOrder(StudentPaymentOrder order) throws Exception {
+        String delayRouteStartDate = sysConfigDao.findConfigValue("delay_route_start_date");
+        if (order.getCreateTime().before(Objects.requireNonNull(DateUtil.stringToDate(delayRouteStartDate, "yyyy-MM-dd HH:mm:ss")))) {
+            return true;
+        }
+        List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderDao.getRouteOrders(order.getOrderNo());
+        for (StudentPaymentRouteOrder routeOrder : routeOrders) {
+            Map<String, Object> divMember = new HashMap<>();
+            divMember.put("member_id", routeOrder.getMerNo());//分佣账户
+            divMember.put("amount", routeOrder.getRouteAmount().setScale(2, BigDecimal.ROUND_HALF_UP));//分佣金额
+            divMember.put("fee_flag", "Y");
+            if (routeOrder.getMerNo().equals(ConfigInit.merNo)) {
+                divMember.put("member_id", 0);
+            }
+            List<Map<String, Object>> divMembers = new ArrayList<>();
+            divMembers.add(divMember);
+
+            Map<String, Object> confirm = new HashMap<>();
+            confirm.put("payment_id", order.getTransNo());
+            confirm.put("order_no", idGeneratorService.generatorId("payment"));
+            confirm.put("confirm_amt", routeOrder.getRouteAmount());
+            confirm.put("div_members", divMembers);
+            Payment.createConfirm(confirm);
+        }
+        return true;
+    }
+
     //Date date = new Date();
     //        BigDecimal balance = BigDecimal.ZERO;
     //        MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
@@ -418,6 +466,6 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 
     @Override
     public List<StudentPaymentOrder> getUserOrderByType(Integer userId, OrderTypeEnum type, DealStatusEnum status) {
-       return studentPaymentOrderDao.getUserOrderByType(userId,type,status);
+        return studentPaymentOrderDao.getUserOrderByType(userId, type, status);
     }
 }

+ 168 - 47
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java

@@ -275,7 +275,7 @@ public class StudentServeServiceImpl implements StudentServeService {
             currentPage=currentPage.add(BigDecimal.ONE);
         }
 
-        studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString());
+        studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(), null);
 
         BigDecimal currentPage1=BigDecimal.ONE,
                 pageSize1=new BigDecimal(10000),
@@ -427,59 +427,174 @@ public class StudentServeServiceImpl implements StudentServeService {
         }
 
         if(!CollectionUtils.isEmpty(results)){
-//            studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString());
-            BigDecimal currentPage1=BigDecimal.ONE,
-                    pageSize1=new BigDecimal(10000),
-                    total1=new BigDecimal(results.size()),
-                    totalPage1=total1.divide(pageSize1, BigDecimal.ROUND_UP);
 
-            while (currentPage1.compareTo(totalPage1)<=0){
-                List<StudentExtracurricularExercisesSituation> rows=results.stream().skip(pageSize1.multiply(currentPage1.subtract(BigDecimal.ONE)).longValue()).limit(pageSize1.longValue()).collect(Collectors.toList());
-                List<Integer> updateStudentIds = rows.stream().map(StudentExtracurricularExercisesSituation::getStudentId).collect(Collectors.toList());
+            if(CollectionUtils.isEmpty(studentIds)){
+                studentIds = results.stream().map(StudentExtracurricularExercisesSituation::getStudentId).collect(Collectors.toList());
+            }
 
-                List<StudentExtracurricularExercisesSituation> weekServiceWithStudents = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(monDayDate.toString(), null, updateStudentIds);
-                Map<String, StudentExtracurricularExercisesSituation> codeServeMap = weekServiceWithStudents.stream().collect(Collectors.toMap(StudentExtracurricularExercisesSituation::getStuAndTeaCode, s -> s, (s1, s2) -> s1));
+            Map<Integer, List<StudentServeCourseHomeworkDto>> studentHomeworkMap=new HashMap<>();
+            Map<Integer, List<ExtracurricularExercisesReply>> studentExercisesMap=new HashMap<>();
 
-                Set<String> newCodes = rows.stream().map(StudentExtracurricularExercisesSituation::getStuAndTeaCode).collect(Collectors.toSet());
-                for (StudentExtracurricularExercisesSituation weekServiceWithStudent : weekServiceWithStudents) {
-                    if(weekServiceWithStudent.getActualExercisesNum()>0||newCodes.contains(weekServiceWithStudent.getStuAndTeaCode())){
-                        continue;
+            List<StudentServeCourseHomeworkDto> allStudentHomeworks = studentCourseHomeworkDao.findStudentHomeworkWithCourseDateRange(monDayDate.toString(), sunDayDate.toString(), new ArrayList<>(studentIds));
+            List<StudentServeCourseHomeworkDto> studentHomeworksTmp =new ArrayList<>();
+            for (StudentServeCourseHomeworkDto studentHomework : allStudentHomeworks) {
+                LocalDate courseStartLocalDate = LocalDateTime.ofInstant(studentHomework.getCourseStartTime().toInstant(), DateUtil.zoneId).toLocalDate();
+                switch (courseStartLocalDate.getDayOfWeek()){
+                    case SATURDAY:
+                        if(DateUtil.daysBetween(studentHomework.getCourseStartTime(), studentHomework.getHomeworkCreateTime())<4){
+                            studentHomeworksTmp.add(studentHomework);
+                        }
+                        break;
+                    case SUNDAY:
+                        if(DateUtil.daysBetween(studentHomework.getCourseStartTime(), studentHomework.getHomeworkCreateTime())<3){
+                            studentHomeworksTmp.add(studentHomework);
+                        }
+                        break;
+                    default:
+                        LocalDate homeworkCreateTime = LocalDateTime.ofInstant(studentHomework.getHomeworkCreateTime().toInstant(), DateUtil.zoneId).toLocalDate();
+                        if(courseStartLocalDate.get(DateUtil.weekFields.weekOfYear())==homeworkCreateTime.get(DateUtil.weekFields.weekOfYear())){
+                            studentHomeworksTmp.add(studentHomework);
+                        }
+                        break;
+                }
+            }
+            if(!CollectionUtils.isEmpty(studentHomeworksTmp)){
+                studentHomeworkMap = studentHomeworksTmp.stream()
+                        .collect(Collectors.groupingBy(StudentServeCourseHomeworkDto::getUserId));
+            }
+
+
+            List<ExtracurricularExercisesReply> allStudentExercises = extracurricularExercisesReplyDao.getStudentExercisesWithTimeZone(monDayDate.toString(), sunDayDate.toString(), new ArrayList<>(studentIds));
+            if(!CollectionUtils.isEmpty(allStudentExercises)){
+                studentExercisesMap = allStudentExercises.stream().collect(Collectors.groupingBy(ExtracurricularExercisesReply::getUserId));
+            }
+
+            for (StudentExtracurricularExercisesSituation weekServiceWithStudent : results) {
+                List<StudentServeCourseHomeworkDto> studentAllHomeworks = studentHomeworkMap.get(weekServiceWithStudent.getStudentId());
+                weekServiceWithStudent.setActualExercisesNum(0);
+                if(!CollectionUtils.isEmpty(studentAllHomeworks)&&weekServiceWithStudent.getServeType().equals("HOMEWORK")){
+                    Set<String> courseIds = Arrays.stream(weekServiceWithStudent.getCourseIds().split(",")).collect(Collectors.toSet());
+                    List<StudentServeCourseHomeworkDto> studentHomeworks = studentAllHomeworks.stream().filter(s -> courseIds.contains(s.getCourseScheduleId())).collect(Collectors.toList());
+                    weekServiceWithStudent.setActualExercisesNum(1);
+                    long replyNum = studentHomeworks.stream().filter(e -> YesOrNoEnum.YES.equals(e.getStatus())).count();
+                    weekServiceWithStudent.setExercisesReplyNum(replyNum>0?1:0);
+                    long haveSubmitTimes = studentHomeworks.stream().filter(e -> Objects.nonNull(e.getSubmitTime())).count();
+                    if(replyNum>0&&haveSubmitTimes>0){
+                        Date lastSubmitTime = studentHomeworks.stream().filter(e->Objects.nonNull(e.getSubmitTime())).max(Comparator.comparing(StudentServeCourseHomeworkDto::getSubmitTime)).get().getSubmitTime();
+                        weekServiceWithStudent.setLastSubmitTime(lastSubmitTime);
                     }
-                    studentExtracurricularExercisesSituationDao.delete(weekServiceWithStudent.getId());
+                    int exercisesMessageNum=0;
+                    int exercisesMessageTimelyNum=0;
+                    for (StudentServeCourseHomeworkDto studentHomework : studentHomeworks) {
+                        if(!YesOrNoEnum.YES.equals(studentHomework.getStatus())){
+                            continue;
+                        }
+                        if(!YesOrNoEnum.YES.equals(studentHomework.getIsReplied())){
+                            continue;
+                        }
+                        exercisesMessageNum+=1;
+                        if(new Integer(1).equals(studentHomework.getIsRepliedTimely())){
+                            exercisesMessageTimelyNum+=1;
+                        }
+                    }
+                    weekServiceWithStudent.setExercisesMessageNum(exercisesMessageNum>0?1:0);
+                    weekServiceWithStudent.setExercisesMessageTimelyNum(exercisesMessageTimelyNum>0?1:0);
                 }
 
-                List<StudentExtracurricularExercisesSituation> newService = new ArrayList<>();
-                List<StudentExtracurricularExercisesSituation> updateService = new ArrayList<>();
-                for (StudentExtracurricularExercisesSituation result : rows) {
-                    if(codeServeMap.containsKey(result.getStuAndTeaCode())){
-                        StudentExtracurricularExercisesSituation s = codeServeMap.get(result.getStuAndTeaCode());
-                        Set<Long> courseIds = new HashSet<>();
-//                        if(StringUtils.isNotBlank(s.getCourseIds())&&s.getActualExercisesNum()>0){
-//                            courseIds = Arrays.stream(s.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet());
-//                        }
-                        if(StringUtils.isNotBlank(result.getCourseIds())){
-                            courseIds.addAll(Arrays.stream(result.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet()));
+                List<ExtracurricularExercisesReply> studentAllExercises = studentExercisesMap.get(weekServiceWithStudent.getStudentId());
+                if(!CollectionUtils.isEmpty(studentAllExercises)&&weekServiceWithStudent.getServeType().equals("EXERCISE")){
+                    List<ExtracurricularExercisesReply> studentExercises = studentAllExercises.stream().filter(s -> weekServiceWithStudent.getTeacherId().equals(s.getExtracurricularExercises().getTeacherId())).collect(Collectors.toList());
+                    weekServiceWithStudent.setActualExercisesNum(1);
+                    long replyNum = studentExercises.stream().filter(e -> e.getStatus()==1).count();
+                    if(weekServiceWithStudent.getExercisesReplyNum()<=0){
+                        weekServiceWithStudent.setExercisesReplyNum(replyNum>0?1:0);
+                    }
+                    long haveSubmitTimes = studentExercises.stream().filter(e->Objects.nonNull(e.getSubmitTime())).count();
+                    if(replyNum>0&&haveSubmitTimes>0){
+                        Date lastSubmitTime = studentExercises.stream().filter(e->Objects.nonNull(e.getSubmitTime())).max(Comparator.comparing(ExtracurricularExercisesReply::getSubmitTime)).get().getSubmitTime();
+                        if(Objects.isNull(weekServiceWithStudent.getLastSubmitTime())||lastSubmitTime.after(weekServiceWithStudent.getLastSubmitTime())){
+                            weekServiceWithStudent.setLastSubmitTime(lastSubmitTime);
                         }
-                        s.setServeType(result.getServeType());
-                        if(s.getServeType().equals("HOMEWORK")){
-                            s.setCourseIds(StringUtils.join(courseIds, ","));
-                        }else{
-                            s.setCourseIds("");
+                    }
+                    int exercisesMessageNum=0;
+                    int exercisesMessageTimelyNum=0;
+                    for (ExtracurricularExercisesReply studentHomework : studentExercises) {
+                        if(!new Integer(1).equals(studentHomework.getStatus())){
+                            continue;
                         }
-                        if(StringUtils.isBlank(s.getCourseIds())){
-                            s.setExpectExercisesNum(1);
-                        }else{
-                            s.setExpectExercisesNum(courseIds.size());
+                        if(!new Integer(1).equals(studentHomework.getIsReplied())){
+                            continue;
                         }
-                        updateService.add(s);
-                    }else{
-                        newService.add(result);
+                        exercisesMessageNum+=1;
+                        if(new Integer(1).equals(studentHomework.getIsRepliedTimely())){
+                            exercisesMessageTimelyNum+=1;
+                        }
+                    }
+                    if(weekServiceWithStudent.getExercisesMessageNum()<=0){
+                        weekServiceWithStudent.setExercisesMessageNum(exercisesMessageNum>0?1:0);
+                    }
+                    if(weekServiceWithStudent.getExercisesMessageTimelyNum()<=0){
+                        weekServiceWithStudent.setExercisesMessageTimelyNum(exercisesMessageTimelyNum>0?1:0);
                     }
                 }
-                if(!CollectionUtils.isEmpty(updateService))
-                    studentExtracurricularExercisesSituationDao.batchUpdate(updateService);
-                if(!CollectionUtils.isEmpty(newService))
-                    studentExtracurricularExercisesSituationDao.batchInsert(newService);
+            }
+
+            studentExtracurricularExercisesSituationDao.deleteByMonday(monDayDate.toString(), studentIds);
+
+            BigDecimal currentPage1=BigDecimal.ONE,
+                    pageSize1=new BigDecimal(10000),
+                    total1=new BigDecimal(results.size()),
+                    totalPage1=total1.divide(pageSize1, BigDecimal.ROUND_UP);
+
+            while (currentPage1.compareTo(totalPage1)<=0){
+                List<StudentExtracurricularExercisesSituation> rows=results.stream().skip(pageSize1.multiply(currentPage1.subtract(BigDecimal.ONE)).longValue()).limit(pageSize1.longValue()).collect(Collectors.toList());
+//                List<Integer> updateStudentIds = rows.stream().map(StudentExtracurricularExercisesSituation::getStudentId).collect(Collectors.toList());
+//
+//                List<StudentExtracurricularExercisesSituation> weekServiceWithStudents = studentExtracurricularExercisesSituationDao.findWeekServiceWithStudents(monDayDate.toString(), null, updateStudentIds);
+//                Map<String, StudentExtracurricularExercisesSituation> codeServeMap = weekServiceWithStudents.stream().collect(Collectors.toMap(StudentExtracurricularExercisesSituation::getStuAndTeaCode, s -> s, (s1, s2) -> s1));
+//
+//                Set<String> newCodes = rows.stream().map(StudentExtracurricularExercisesSituation::getStuAndTeaCode).collect(Collectors.toSet());
+//                for (StudentExtracurricularExercisesSituation weekServiceWithStudent : weekServiceWithStudents) {
+//                    if(weekServiceWithStudent.getActualExercisesNum()>0||newCodes.contains(weekServiceWithStudent.getStuAndTeaCode())){
+//                        continue;
+//                    }
+//                    studentExtracurricularExercisesSituationDao.delete(weekServiceWithStudent.getId());
+//                }
+//
+//                List<StudentExtracurricularExercisesSituation> newService = new ArrayList<>();
+//                List<StudentExtracurricularExercisesSituation> updateService = new ArrayList<>();
+//                for (StudentExtracurricularExercisesSituation result : rows) {
+//                    if(codeServeMap.containsKey(result.getStuAndTeaCode())){
+//                        StudentExtracurricularExercisesSituation s = codeServeMap.get(result.getStuAndTeaCode());
+//                        Set<Long> courseIds = new HashSet<>();
+//                        if(StringUtils.isNotBlank(s.getCourseIds())&&s.getActualExercisesNum()>0){
+//                            courseIds = Arrays.stream(s.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet());
+//                        }
+//                        if(StringUtils.isNotBlank(result.getCourseIds())){
+//                            courseIds.addAll(Arrays.stream(result.getCourseIds().split(",")).map(id->Long.valueOf(id)).collect(Collectors.toSet()));
+//                        }
+//                        s.setServeType(result.getServeType());
+//                        if(s.getServeType().equals("HOMEWORK")){
+//                            s.setCourseIds(StringUtils.join(courseIds, ","));
+//                        }else{
+//                            s.setCourseIds("");
+//                        }
+//                        if(StringUtils.isBlank(s.getCourseIds())){
+//                            s.setExpectExercisesNum(1);
+//                        }else{
+//                            s.setExpectExercisesNum(courseIds.size());
+//                        }
+//                        updateService.add(s);
+//                    }else{
+//                        newService.add(result);
+//                    }
+//                }
+//                if(!CollectionUtils.isEmpty(updateService))
+//                    studentExtracurricularExercisesSituationDao.batchUpdate(updateService);
+//                if(!CollectionUtils.isEmpty(newService))
+//                    studentExtracurricularExercisesSituationDao.batchInsert(newService);
+
+                studentExtracurricularExercisesSituationDao.batchInsert(rows);
 
                 currentPage1=currentPage1.add(BigDecimal.ONE);
             }
@@ -489,6 +604,9 @@ public class StudentServeServiceImpl implements StudentServeService {
 
     @Override
     public void updateExercisesSituation(Date date,List<Integer> studentIds, Integer teacherId) {
+        if(true){
+            return;
+        }
         LocalDate nowDate = LocalDateTime.ofInstant(date.toInstant(), DateUtil.zoneId).toLocalDate();
         if(Objects.isNull(date)){
             nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
@@ -540,9 +658,11 @@ public class StudentServeServiceImpl implements StudentServeService {
         }
 
         for (StudentExtracurricularExercisesSituation weekServiceWithStudent : weekServiceWithStudents) {
-            List<StudentServeCourseHomeworkDto> studentHomeworks = studentHomeworkMap.get(weekServiceWithStudent.getStudentId());
+            List<StudentServeCourseHomeworkDto> studentAllHomeworks = studentHomeworkMap.get(weekServiceWithStudent.getStudentId());
             weekServiceWithStudent.setActualExercisesNum(0);
-            if(!CollectionUtils.isEmpty(studentHomeworks)&&weekServiceWithStudent.getServeType().equals("HOMEWORK")){
+            if(!CollectionUtils.isEmpty(studentAllHomeworks)&&weekServiceWithStudent.getServeType().equals("HOMEWORK")){
+                Set<String> courseIds = Arrays.stream(weekServiceWithStudent.getCourseIds().split(",")).collect(Collectors.toSet());
+                List<StudentServeCourseHomeworkDto> studentHomeworks = studentAllHomeworks.stream().filter(s -> courseIds.contains(s.getCourseScheduleId())).collect(Collectors.toList());
                 weekServiceWithStudent.setActualExercisesNum(1);
                 long replyNum = studentHomeworks.stream().filter(e -> YesOrNoEnum.YES.equals(e.getStatus())).count();
                 weekServiceWithStudent.setExercisesReplyNum(replyNum>0?1:0);
@@ -569,8 +689,9 @@ public class StudentServeServiceImpl implements StudentServeService {
                 weekServiceWithStudent.setExercisesMessageTimelyNum(exercisesMessageTimelyNum>0?1:0);
             }
 
-            List<ExtracurricularExercisesReply> studentExercises = studentExercisesMap.get(weekServiceWithStudent.getStudentId());
-            if(!CollectionUtils.isEmpty(studentExercises)&&weekServiceWithStudent.getServeType().equals("EXERCISE")){
+            List<ExtracurricularExercisesReply> studentAllExercises = studentExercisesMap.get(weekServiceWithStudent.getStudentId());
+            if(!CollectionUtils.isEmpty(studentAllExercises)&&weekServiceWithStudent.getServeType().equals("EXERCISE")){
+                List<ExtracurricularExercisesReply> studentExercises = studentAllExercises.stream().filter(s -> weekServiceWithStudent.getTeacherId().equals(s.getExtracurricularExercises().getTeacherId())).collect(Collectors.toList());
                 weekServiceWithStudent.setActualExercisesNum(1);
                 long replyNum = studentExercises.stream().filter(e -> e.getStatus()==1).count();
                 if(weekServiceWithStudent.getExercisesReplyNum()<=0){

+ 4 - 1
mec-biz/src/main/resources/config/mybatis/ExtracurricularExercisesReplyMapper.xml

@@ -22,6 +22,7 @@
 		<result column="is_view_" property="isView" />
 		<result column="organ_name_" property="organName" />
 		<result column="submit_time_" property="submitTime" />
+		<association property="extracurricularExercises" columnPrefix="ee_" resultMap="com.ym.mec.biz.dal.dao.ExtracurricularExercisesDao.ExtracurricularExercises"/>
 	</resultMap>
 
 	<resultMap id="ExtraExerciseStudentsDto" type="com.ym.mec.biz.dal.dto.ExtraExerciseStudentsDto" extends="ExtracurricularExercisesReply">
@@ -485,9 +486,11 @@
 			eer.status_,
 			eer.submit_time_,
 			eer.is_replied_,
-			eer.is_replied_timely_
+			eer.is_replied_timely_,
+			ee.teacher_id_ ee_teacher_id_
 		FROM
 			extracurricular_exercises_reply eer
+			LEFT JOIN extracurricular_exercises ee ON eer.extracurricular_exercises_id_=ee.id_
 		WHERE
 			DATE_FORMAT( eer.create_time_, '%Y-%m-%d' ) BETWEEN #{startDate} AND #{endDate}
 	</select>

+ 6 - 0
mec-biz/src/main/resources/config/mybatis/StudentExtracurricularExercisesSituationMapper.xml

@@ -177,6 +177,12 @@
 	</delete>
 	<delete id="deleteByMonday">
 		DELETE FROM student_extracurricular_exercises_situation_ WHERE monday_ = #{monday}
+		<if test="studentIds!=null and studentIds.size()>0">
+			AND student_id_ IN
+			<foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
+				#{studentId}
+			</foreach>
+		</if>
 	</delete>
 	<delete id="deleteByStudent">
 		DELETE FROM student_extracurricular_exercises_situation_ WHERE student_id_ = #{studentId}

+ 23 - 20
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -142,18 +142,18 @@ public class StudentOrderController extends BaseController {
             VipBuyResultDto vipBuyResultInfo = vipGroupService.findVipBuyResultInfo(Integer.valueOf(orderByOrderNo.getMusicGroupId()));
             orderDetail.put("detail", vipBuyResultInfo);
         } else if (orderByOrderNo.getGroupType().equals(GroupType.SPORADIC)) {
-            if(Objects.nonNull(orderByOrderNo.getMusicGroupId())){
+            if (Objects.nonNull(orderByOrderNo.getMusicGroupId())) {
                 SporadicChargeInfo info = sporadicChargeInfoService.get(Integer.valueOf(orderByOrderNo.getMusicGroupId()));
                 orderDetail.put("detail", info);
             }
             if (orderByOrderNo.getType().equals(OrderTypeEnum.DOUBLE_ELEVEN2020)) {
                 LuckDrawCount luckDrawCount = luckDrawCountService.get(orderByOrderNo.getUserId().longValue());
-                orderDetail.put("drawTimes", luckDrawCount==null? 0: luckDrawCount.getAvailableCount());
-            }else if(OrderTypeEnum.DEGREE_REGISTRATION.equals(orderByOrderNo.getType())){
+                orderDetail.put("drawTimes", luckDrawCount == null ? 0 : luckDrawCount.getAvailableCount());
+            } else if (OrderTypeEnum.DEGREE_REGISTRATION.equals(orderByOrderNo.getType())) {
                 DegreeRegistration degreeRegistration = degreeRegistrationDao.get(orderByOrderNo.getClassGroupId());
                 orderDetail.put("degree", degreeRegistration);
                 List<StudentPaymentOrderDetail> studentPaymentOrderDetails = studentPaymentOrderDetailService.getOrderDetail(orderByOrderNo.getId());
-                if(!CollectionUtils.isEmpty(studentPaymentOrderDetails)){
+                if (!CollectionUtils.isEmpty(studentPaymentOrderDetails)) {
                     orderDetail.put("additionCourseInfo", studentPaymentOrderDetails.get(0).getGoodsIdList());
                 }
             }
@@ -245,22 +245,24 @@ public class StudentOrderController extends BaseController {
         paymentParams.put("goods_title", orderSubject);
         paymentParams.put("goods_desc", orderBody);
         paymentParams.put("time_expire", timeExpire);
-
-        List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderDao.getRouteOrders(orderNo);
-        List<Map<String, Object>> divMembers = new ArrayList<>();
-        for (StudentPaymentRouteOrder routeOrder : routeOrders) {
-            Map<String, Object> divMember = new HashMap<>();
-            divMember.put("member_id", routeOrder.getMerNo());//分佣账户
-            divMember.put("amount", routeOrder.getRouteAmount().setScale(2, BigDecimal.ROUND_HALF_UP));//分佣金额
-            divMember.put("fee_flag", routeOrder.getFeeFlag());
-            if (routeOrder.getMerNo().equals(ConfigInit.merNo)) {
-                divMember.put("member_id", 0);
-            }
-            divMembers.add(divMember);
-        }
-        if (divMembers.size() > 0) {
-            paymentParams.put("div_members", JSON.toJSONString(divMembers));
-        }
+        paymentParams.put("pay_mode", "delay");
+
+        //延时分账时不需要
+//        List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderDao.getRouteOrders(orderNo);
+//        List<Map<String, Object>> divMembers = new ArrayList<>();
+//        for (StudentPaymentRouteOrder routeOrder : routeOrders) {
+//            Map<String, Object> divMember = new HashMap<>();
+//            divMember.put("member_id", routeOrder.getMerNo());//分佣账户
+//            divMember.put("amount", routeOrder.getRouteAmount().setScale(2, BigDecimal.ROUND_HALF_UP));//分佣金额
+//            divMember.put("fee_flag", routeOrder.getFeeFlag());
+//            if (routeOrder.getMerNo().equals(ConfigInit.merNo)) {
+//                divMember.put("member_id", 0);
+//            }
+//            divMembers.add(divMember);
+//        }
+//        if (divMembers.size() > 0) {
+//            paymentParams.put("div_members", JSON.toJSONString(divMembers));
+//        }
 
         Map<String, Object> expendParams = new HashMap<>(5);
 
@@ -331,6 +333,7 @@ public class StudentOrderController extends BaseController {
             rpMap.put("merOrderNo", payingOrder.getOrderNo());
             rpMap.put("orderNo", payingOrder.getOrderNo());
             rpMap.put("channelType", "1");
+            rpMap.put("simulation", "1");
 
             String channelType = rpMap.get("channelType").equals("1") ? "WXPay" : (rpMap.get("channelType").equals("2") ? "Alipay" : "quickPay");
             rpMap.put("channelType", channelType);

+ 24 - 19
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/Payment.java

@@ -32,6 +32,24 @@ public class Payment {
         return payment;
     }
 
+
+    /**
+     * 创建确认对象
+     *
+     * @return 查询的支付对象
+     * @throws Exception 异常
+     */
+    public static Map<String, Object> createConfirm(Map<String, Object> confirm) throws Exception {
+        confirm = com.huifu.adapay.model.Payment.createConfirm(confirm);
+
+        String error_code = (String) confirm.get("error_code");
+        if (null != error_code) {
+            String errorMsg = (String) confirm.get("error_msg");
+            throw new ThirdpartyException(errorMsg);
+        }
+        return confirm;
+    }
+
     /**
      * 关闭一个支付交易
      *
@@ -40,32 +58,19 @@ public class Payment {
      * @throws Exception 异常
      */
     public static Map<String, Object> closePayment(String paymentId) throws Exception {
-        System.out.println("=======close payment begin=======");
-        //关闭支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/04-trade.html#id11
-        //调用sdk方法,关闭支付,得到支付对象
         Map<String, Object> payment = new HashMap<>();
         Map<String, Object> paymentParams = new HashMap<>(10);
         paymentParams.put("payment_id", paymentId);
-        try {
-            paymentParams.put("payment_id", paymentId);
-            paymentParams.put("reason", "reason");
-            paymentParams.put("expend", "expend");
-            paymentParams.put("notify_url", "notify_url");
-            System.out.println("关单请求参数:" + JSON.toJSONString(paymentId));
-            payment = com.huifu.adapay.model.Payment.close(paymentParams);
-        } catch (ThirdpartyException e) {
-            e.printStackTrace();
-        }
-
+        paymentParams.put("reason", "reason");
+        paymentParams.put("expend", "expend");
+        paymentParams.put("notify_url", "notify_url");
+        payment = com.huifu.adapay.model.Payment.close(paymentParams);
 
         String error_code = (String) payment.get("error_code");
         if (null != error_code) {
-            System.out.println("关单返回参数:" + JSON.toJSONString(payment));
-            String error_msg = (String) payment.get("error_msg");
-            System.out.println("error_code:" + error_code + "............." + error_msg);
+            String errorMsg = (String) payment.get("error_msg");
+            throw new ThirdpartyException(errorMsg);
         }
-
-
         return payment;
     }
 

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/AdapayController.java

@@ -138,7 +138,7 @@ public class AdapayController extends BaseController {
         long createdLte = DateUtil.getLastSecondWithDay(endTime).getTime();
         int pageIndex = 1;
         List<Map<String, Object>> data = new ArrayList<>();
-        while (profiles.equals("dev")) {
+        while (profiles.equals("prod")) {
             Map<String, Object> paymentList = Payment.queryList(pageIndex, createdGte, createdLte);
             JSONArray payments = (JSONArray) paymentList.get("payments");
             if (!paymentList.get("status").equals("succeeded")) {

+ 8 - 13
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -1,5 +1,6 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.biz.dal.dao.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
@@ -31,18 +32,6 @@ import org.springframework.web.bind.annotation.RestController;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.CourseScheduleDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
-import com.ym.mec.biz.dal.dao.EmployeeDao;
-import com.ym.mec.biz.dal.dao.MusicGroupBuildLogDao;
-import com.ym.mec.biz.dal.dao.MusicGroupDao;
-import com.ym.mec.biz.dal.dao.PracticeGroupDao;
-import com.ym.mec.biz.dal.dao.SellOrderDao;
-import com.ym.mec.biz.dal.dao.StudentDao;
-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
-import com.ym.mec.biz.dal.dao.StudentPaymentRouteOrderDao;
-import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
-import com.ym.mec.biz.dal.dao.VipGroupDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.CourseGroupExportDto;
 import com.ym.mec.biz.dal.dto.CourseReviewDto;
@@ -229,6 +218,8 @@ public class ExportController extends BaseController {
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
     @Autowired
     private SellOrderDao sellOrderDao;
+    @Autowired
+    private SysConfigDao sysConfigDao;
 
     @ApiOperation(value = "学员考勤记录导出")
     @PostMapping("export/exportStudentAttendances")
@@ -2169,7 +2160,11 @@ public class ExportController extends BaseController {
             if (row.getBalancePaymentAmount() == null) {
                 row.setBalancePaymentAmount(BigDecimal.ZERO);
             }
-            BigDecimal transferFee = (row.getActualAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_UP);
+            BigDecimal transferFee = row.getActualAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100),2,BigDecimal.ROUND_HALF_UP);
+            String delayRouteStartDate = sysConfigDao.findConfigValue("delay_route_start_date");
+            if (row.getCreateTime().after(Objects.requireNonNull(DateUtil.stringToDate(delayRouteStartDate, "yyyy-MM-dd HH:mm:ss")))) {
+                transferFee = row.getRouteAmount().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100),2,BigDecimal.ROUND_HALF_UP);
+            }
             row.setTransferFee(transferFee);
             BigDecimal musicalFee = BigDecimal.ZERO;
             BigDecimal teachingFee = BigDecimal.ZERO;