瀏覽代碼

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

yonge 4 年之前
父節點
當前提交
c07f93fa6f

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

@@ -17,5 +17,5 @@ public interface DegreeRegistrationDao extends BaseDAO<Integer, DegreeRegistrati
 
     DegreeRegistration getWithUserIdAndActivityTag(@Param("degree") DegreeRegistration degree);
 
-    DegreeRegistration getWithSubjectAndLevel(@Param("degree") DegreeRegistration degree);
+    DegreeRegistration getWithLevel(@Param("degree") DegreeRegistration degree);
 }

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDetailDao.java

@@ -4,6 +4,7 @@ import com.ym.mec.biz.dal.dto.MusicalListDetailDto;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
@@ -120,6 +121,17 @@ public interface StudentPaymentOrderDetailDao extends BaseDAO<Long, StudentPayme
      */
     List<StudentPaymentOrderDetail> getOrderGoodies(@Param("orderIds") List<Long> orderIds);
 
+    /**
+     * @describe 获取用户指定类型的订单
+     * @author qnc99
+     * @date 2020/12/7 0007
+     * @param userId:
+     * @param orderType:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail>
+     */
+    List<StudentPaymentOrderDetail> getWithUserAndOrderType(@Param("userId") Integer userId,
+                                                            @Param("orderType")OrderTypeEnum orderType);
+
     List<StudentPaymentOrderDetail> getWithIds(@Param("paymentOrderIds") List<Long> paymentOrderIds);
 
 

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

@@ -459,6 +459,8 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
             return;
         }
 
+        courseScheduleService.mergeCourseReplace(classGroupNotStartCourse);
+
         if(ClassGroupTypeEnum.MUSIC_NETWORK.equals(classGroup.getType())){
             for (CourseSchedule courseSchedule : classGroupNotStartCourse) {
                 courseSchedule.setName(classGroup.getName());

+ 18 - 15
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -14,20 +14,7 @@ import java.math.BigInteger;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -5261,7 +5248,23 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			return;
 		}
 		List<CourseSchedule> mainCourses = courseScheduleDao.findByCourseScheduleIds(new ArrayList<>(newCourseIds));
-//		mainCourses.stream().collect()
+		Map<Long, CourseSchedule> idCourseMap = mainCourses.stream().collect(Collectors.toMap(CourseSchedule::getId, c -> c, (c1, c2) -> c1));
+		Iterator<CourseSchedule> iterator = courseSchedules.iterator();
+		while (iterator.hasNext()){
+			CourseSchedule next = iterator.next();
+			if(Objects.isNull(next.getNewCourseId())){
+				continue;
+			}
+			if(next.getClassGroupId().equals(idCourseMap.get(next.getNewCourseId()).getClassGroupId())){
+				iterator.remove();
+			}
+		}
+		for (CourseSchedule courseSchedule : courseSchedules) {
+			if(Objects.isNull(courseSchedule.getNewCourseId())){
+				continue;
+			}
+			courseSchedule = idCourseMap.get(courseSchedule.getId());
+		}
 	}
 
 	@Override

+ 42 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/DegreeRegistrationServiceImpl.java

@@ -77,7 +77,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
         Student student = studentDao.getLocked(degreeRegistration.getUserId());
 
         degreeRegistration.setActivityTag(ACTIVITY_TAG);
-        DegreeRegistration degree = degreeRegistrationDao.getWithSubjectAndLevel(degreeRegistration);
+        DegreeRegistration degree = degreeRegistrationDao.getWithLevel(degreeRegistration);
 
         Date nowDate = new Date();
 
@@ -85,7 +85,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
 
         //获取收费项价格
         SporadicChargeInfo chargeInfo = null;
-        if(Objects.nonNull(degreeRegistration.getSporadicId())&&Objects.nonNull(degreeRegistration.getTheoryLevel())){
+        if(Objects.nonNull(degreeRegistration.getSporadicId())){
             chargeInfo = sporadicChargeInfoDao.get(degreeRegistration.getSporadicId());
             if (chargeInfo == null || chargeInfo.getDelFlag().equals(1) || chargeInfo.getOpenFlag().equals(1)) {
                 throw new BizException("你选的考试级别不存在");
@@ -95,9 +95,13 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
                     && StringUtils.isBlank(degreeRegistration.getTheoryCert())) {
                 throw new BizException("报考级别为“" + chargeInfo.getTitle() + "”且乐理级别是“免考”时,必须上传证书");
             }
-
-            degreeRegistration.setActivityTag(ACTIVITY_TAG);
             degreeRegistration.setLevel(chargeInfo.getTitle());
+            degreeRegistration.setMoney(chargeInfo.getAmount());
+        }else{
+            degreeRegistration.setMoney(BigDecimal.ZERO);
+        }
+
+        if(Objects.nonNull(degreeRegistration.getTheoryLevel())){
             degreeRegistration.setOrderNo(orderNo);
             BigDecimal theoryMoney = BigDecimal.ZERO;
             switch (degreeRegistration.getTheoryLevel()) {
@@ -119,8 +123,12 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
                     throw new BizException("您选择的乐理级别不存在,请核对");
             }
             degreeRegistration.setTheoryMoney(theoryMoney);
+        }else{
+            degreeRegistration.setTheoryMoney(BigDecimal.ZERO);
+        }
+
+        if(Objects.nonNull(degreeRegistration.getSporadicId())||Objects.nonNull(degreeRegistration.getTheoryLevel())){
             if (degree == null) {
-                degreeRegistration.setMoney(chargeInfo.getAmount());
                 degreeRegistration.setStatus(1);
                 degreeRegistration.setCreateTime(nowDate);
                 degreeRegistration.setUpdateTime(nowDate);
@@ -148,9 +156,6 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
                 degreeRegistration.setUpdateTime(nowDate);
                 degreeRegistrationDao.update(degreeRegistration);
             }
-        }else{
-            degreeRegistration.setMoney(BigDecimal.ZERO);
-            degreeRegistration.setTheoryMoney(BigDecimal.ZERO);
         }
 
         BigDecimal additionCoursePrice = new BigDecimal("0");
@@ -160,6 +165,29 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
             if(Objects.isNull(practiceGroupSellPrice)){
                 throw new BizException("该分部暂未参与此活动");
             }
+
+            List<StudentPaymentOrderDetail> historyOrderDetails = studentPaymentOrderDetailDao.getWithUserAndOrderType(degreeRegistration.getUserId(), OrderTypeEnum.DEGREE_REGISTRATION);
+            int historyVipNum = 0, historyPracticeNum = 0, historyHighNum = 0;
+            for (StudentPaymentOrderDetail historyOrderDetail : historyOrderDetails) {
+                if(StringUtils.isBlank(historyOrderDetail.getGoodsIdList())){
+                    continue;
+                }
+                Map<String, Integer> courseNumMap = JSON.parseObject(historyOrderDetail.getGoodsIdList(), Map.class);
+                for (Map.Entry<String, Integer> stringIntegerEntry : courseNumMap.entrySet()) {
+                    switch (stringIntegerEntry.getKey()){
+                        case "VIP":
+                            historyVipNum = historyVipNum + stringIntegerEntry.getValue();
+                            break;
+                        case "PRACTICE":
+                            historyPracticeNum = historyPracticeNum + stringIntegerEntry.getValue();
+                            break;
+                        case "HIGH":
+                            historyHighNum = historyHighNum + stringIntegerEntry.getValue();
+                            break;
+                    }
+                }
+            }
+
             BigDecimal practiceUnitPrice = practiceGroupSellPrice.getOnceOriginalPrice(),
                     vipUnitPrice = new BigDecimal("0"), highUnitPrice;
             if(student.getIsNewUser()){
@@ -168,7 +196,10 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
                 if(!additionCourseInfo.containsKey(CourseSchedule.CourseScheduleType.VIP)){
                     additionCourseInfo.remove(CourseSchedule.CourseScheduleType.PRACTICE);
                 }
-                boolean vipMoreThan2 = additionCourseInfo.containsKey(CourseSchedule.CourseScheduleType.VIP)&&additionCourseInfo.get(CourseSchedule.CourseScheduleType.VIP)>=2;
+                if(additionCourseInfo.containsKey(CourseSchedule.CourseScheduleType.VIP)){
+                    historyVipNum = historyVipNum + additionCourseInfo.get(CourseSchedule.CourseScheduleType.VIP);
+                }
+                boolean vipMoreThan2 = historyVipNum>=2;
                 if(vipMoreThan2){
                     if(FREE_PRICE_LEVEL.contains(degreeRegistration.getLevel())){
                         degreeRegistration.setMoney(BigDecimal.ZERO);
@@ -176,7 +207,6 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
                         degreeRegistration.setMoney(degreeRegistration.getMoney().divide(new BigDecimal(2), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN));
                     }
                     highUnitPrice = practiceGroupSellPrice.getHighOnlineTenCourseActivityPriceWithNewUser();
-
                 }
                 if(vipMoreThan2&&additionCourseInfo.containsKey(CourseSchedule.CourseScheduleType.HIGH)){
                     degreeRegistration.setTheoryMoney(BigDecimal.ZERO);
@@ -223,6 +253,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
         studentPaymentOrder.setExpectAmount(amount);
         studentPaymentOrder.setActualAmount(amount);
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
+        studentPaymentOrder.setClassGroupId(degreeRegistration.getId());
         if(Objects.nonNull(degreeRegistration.getSporadicId())){
             studentPaymentOrder.setMusicGroupId(degreeRegistration.getSporadicId().toString());
         }
@@ -283,7 +314,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
 
     @Override
     public Boolean updateStatus(StudentPaymentOrder studentPaymentOrder) {
-        DegreeRegistration degree = degreeRegistrationDao.getLock(studentPaymentOrder.getUserId());
+        DegreeRegistration degree = degreeRegistrationDao.getLock(studentPaymentOrder.getClassGroupId());
 
         int updateCount = studentPaymentOrderService.update(studentPaymentOrder);
         if (updateCount <= 0) {

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

@@ -1294,6 +1294,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         Map<CourseSchedule.CourseScheduleType, List<CourseSchedule>> typeCourseMap = new HashMap<>();
         if(Objects.nonNull(classGroupId)){
             List<CourseSchedule> classGroupNotStartCourse = courseScheduleDao.getClassGroupNotStartCourse(classGroupId);
+            courseScheduleService.mergeCourseReplace(classGroupNotStartCourse);
             typeCourseMap = classGroupNotStartCourse.stream().collect(Collectors.groupingBy(CourseSchedule::getType));
             for (Map.Entry<CourseSchedule.CourseScheduleType, List<CourseSchedule>> typeCoursesEntry : typeCourseMap.entrySet()) {
                 int totalCourseDuration = 0;

+ 6 - 7
mec-biz/src/main/resources/config/mybatis/DegreeRegistrationMapper.xml

@@ -225,7 +225,7 @@
 
     <select id="getWithUserIdAndActivityTag" resultMap="DegreeRegistration">
         select *
-        from degree_registration
+            from degree_registration
         where
             user_id_ = #{degree.userId}
             AND activity_tag_=#{degree.activityTag}
@@ -240,13 +240,12 @@
             </if>
     </select>
 
-    <select id="getWithSubjectAndLevel" resultMap="DegreeRegistration">
+    <select id="getWithLevel" resultMap="DegreeRegistration">
         select *
-        from degree_registration
+            from degree_registration
         where
-        user_id_ = #{degree.userId}
-        AND activity_tag_=#{degree.activityTag}
-        AND subject_ = #{degree.subject}
-        AND (sporadic_id_ = #{degree.sporadicId} OR theory_level_ = #{degree.theoryLevel})
+            user_id_ = #{degree.userId}
+            AND activity_tag_=#{degree.activityTag}
+            AND (sporadic_id_ = #{degree.sporadicId} OR theory_level_ = #{degree.theoryLevel})
     </select>
 </mapper>

+ 8 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml

@@ -273,4 +273,12 @@
             #{orderDetailType}
         </foreach>
     </select>
+
+    <select id="getWithUserAndOrderType" resultType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
+        SELECT spod.* FROM student_payment_order_detail spod
+        LEFT JOIN student_payment_order spo ON spo.id_=spod.payment_order_id_
+        WHERE spo.user_id_= #{userId}
+        AND spod.type_ = #{orderType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        AND spo.status_='SUCCESS'
+    </select>
 </mapper>

+ 37 - 22
mec-student/src/main/java/com/ym/mec/student/controller/DegreeController.java

@@ -1,19 +1,15 @@
 package com.ym.mec.student.controller;
 
 
+import com.alibaba.fastjson.JSON;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.DegreeRegistrationDao;
-import com.ym.mec.biz.dal.dao.OrganizationDao;
-import com.ym.mec.biz.dal.dao.SporadicChargeInfoDao;
-import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.DegreeRegistrationActivityDto;
 import com.ym.mec.biz.dal.dto.SporadicPayDto;
-import com.ym.mec.biz.dal.entity.DegreeRegistration;
-import com.ym.mec.biz.dal.entity.Employee;
-import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
-import com.ym.mec.biz.dal.entity.Student;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
 import com.ym.mec.biz.dal.page.SporadicChargeInfoQueryInfo;
 import com.ym.mec.biz.service.DegreeRegistrationService;
@@ -42,9 +38,6 @@ import java.util.*;
 public class DegreeController extends BaseController {
 
     @Autowired
-    private StudentPaymentOrderService studentPaymentOrderService;
-
-    @Autowired
     private DegreeRegistrationDao degreeRegistrationDao;
 
     @Autowired
@@ -65,6 +58,9 @@ public class DegreeController extends BaseController {
     @Autowired
     private OrganizationDao organizationDao;
 
+    @Autowired
+    private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
+
     @ApiOperation(value = "考级报名支付")
     @PostMapping("/pay")
     public HttpResponseResult pay(@RequestBody DegreeRegistrationActivityDto degreeRegistration) throws Exception {
@@ -107,7 +103,7 @@ public class DegreeController extends BaseController {
         }
         degreeRegistration.setUserId(user.getId());
         studentDao.getLocked(degreeRegistration.getUserId());
-        DegreeRegistration degree = degreeRegistrationDao.getWithSubjectAndLevel(degreeRegistration);
+        DegreeRegistration degree = degreeRegistrationDao.getWithLevel(degreeRegistration);
         if(Objects.nonNull(degree) && degree.getStatus().equals(2)){
             return failed(HttpStatus.CREATED, "您已报考过选择的考级项目");
         }
@@ -130,7 +126,7 @@ public class DegreeController extends BaseController {
     @GetMapping("/getParams")
     public HttpResponseResult getParams(){
         SysUser user = sysUserFeignService.queryUserInfo();
-        if(Objects.isNull(user)){
+        if(Objects.isNull(user)||Objects.isNull(user.getId())){
             return failed(HttpStatus.FORBIDDEN,"请登录");
         }
 
@@ -144,20 +140,39 @@ public class DegreeController extends BaseController {
 
         Map<String, Object> result = new HashMap<>();
 
-//        DegreeRegistration degreeRegistration = degreeRegistrationDao.getWithUserIdAndActivityTag(user.getId(), DegreeRegistrationService.ACTIVITY_TAG);
-
         Student student = studentDao.get(user.getId());
         result.put("userInfo", user);
         result.put("isNewUser", student.getIsNewUser());
         result.put("organs", organizationDao.getActivityOrgans());
         result.put("sporadicChargeInfo", sporadicChargeInfoService.queryDetailPage(queryInfo));
-//        if(Objects.isNull(degreeRegistration)||degreeRegistration.getStatus()==0){
-//            result.put("isApplied", 0);
-//        }else if(degreeRegistration.getStatus()==1){
-//            result.put("isApplied", 1);
-//        }else if(degreeRegistration.getStatus()==2){
-//            result.put("isApplied", 2);
-//        }
+
+        List<StudentPaymentOrderDetail> historyOrderDetails = studentPaymentOrderDetailDao.getWithUserAndOrderType(user.getId(), OrderTypeEnum.DEGREE_REGISTRATION);
+        int historyVipNum = 0, historyPracticeNum = 0, historyHighNum = 0;
+        for (StudentPaymentOrderDetail historyOrderDetail : historyOrderDetails) {
+            if(StringUtils.isBlank(historyOrderDetail.getGoodsIdList())){
+                continue;
+            }
+            Map<String, Integer> courseNumMap = JSON.parseObject(historyOrderDetail.getGoodsIdList(), Map.class);
+            for (Map.Entry<String, Integer> stringIntegerEntry : courseNumMap.entrySet()) {
+                switch (stringIntegerEntry.getKey()){
+                    case "VIP":
+                        historyVipNum = historyVipNum + stringIntegerEntry.getValue();
+                        break;
+                    case "PRACTICE":
+                        historyPracticeNum = historyPracticeNum + stringIntegerEntry.getValue();
+                        break;
+                    case "HIGH":
+                        historyHighNum = historyHighNum + stringIntegerEntry.getValue();
+                        break;
+                }
+            }
+        }
+        Map<String, Integer> historyCourseInfo = new HashMap<>();
+        historyCourseInfo.put(CourseSchedule.CourseScheduleType.VIP.getCode(), historyVipNum);
+        historyCourseInfo.put(CourseSchedule.CourseScheduleType.PRACTICE.getCode(), historyPracticeNum);
+        historyCourseInfo.put(CourseSchedule.CourseScheduleType.HIGH.getCode(), historyHighNum);
+        result.put("historyCourseInfo", historyCourseInfo);
+
         return succeed(result);
     }
 }

+ 4 - 0
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -75,6 +75,8 @@ public class StudentOrderController extends BaseController {
     private StudentGoodsSellDao studentGoodsSellDao;
     @Autowired
     private LuckDrawCountService luckDrawCountService;
+    @Autowired
+    private DegreeRegistrationDao degreeRegistrationDao;
 
 
     @Value("${spring.profiles.active:dev}")
@@ -144,6 +146,8 @@ public class StudentOrderController extends BaseController {
                 LuckDrawCount luckDrawCount = luckDrawCountService.get(orderByOrderNo.getUserId().longValue());
                 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)){
                     orderDetail.put("additionCourseInfo", studentPaymentOrderDetails.get(0).getGoodsIdList());