Browse Source

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

zouxuan 3 năm trước cách đây
mục cha
commit
9f46af95ea

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

@@ -17,6 +17,8 @@ public interface DegreeRegistrationDao extends BaseDAO<Integer, DegreeRegistrati
 
     DegreeRegistration getTotalAmount(Map<String, Object> params);
 
+    int countApplyNum(Map<String, Object> params);
+
     DegreeRegistration getWithUserIdAndActivityTag(@Param("degree") DegreeRegistration degree);
 
     List<DegreeRegistration> getUserLevelDegrees(@Param("userId") Integer userId,

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/PracticeGroupService.java

@@ -212,7 +212,7 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
 	 * @param operatorInfo:
 	 * @return com.ym.mec.common.entity.HttpResponseResult
 	 */
-	HttpResponseResult createPackagePracticeGroup(PracticeGroupBuyDto practiceGroupBuyParams);
+	HttpResponseResult createPackagePracticeGroup(PracticeGroupBuyDto practiceGroupBuyParams, String operatorInfo);
 
     /**
      * @describe 支付订单回调

+ 5 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/DegreeRegistrationServiceImpl.java

@@ -183,8 +183,8 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
         }
 
         BigDecimal additionCoursePrice = new BigDecimal("0");
-        if(Objects.nonNull(degreeRegistration.getAdditionCourseInfo())){
-            Map<CourseSchedule.CourseScheduleType, Integer> additionCourseInfo = degreeRegistration.getAdditionCourseInfo();
+        Map<CourseSchedule.CourseScheduleType, Integer> additionCourseInfo = degreeRegistration.getAdditionCourseInfo();
+        if(additionCourseInfo != null && additionCourseInfo.size() > 0){
             PracticeGroupSellPrice practiceGroupSellPrice = practiceGroupSellPriceDao.get(degreeRegistration.getOrganId());
             if(Objects.isNull(practiceGroupSellPrice)){
                 throw new BizException("该分部暂未参与此活动");
@@ -305,8 +305,8 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
         if(BigDecimal.ZERO.compareTo(additionCoursePrice)<0){
             StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
             studentPaymentOrderDetail.setType(OrderDetailTypeEnum.DEGREE_REGISTRATION);
-            if(Objects.nonNull(degreeRegistration.getAdditionCourseInfo())){
-                studentPaymentOrderDetail.setGoodsIdList(JSON.toJSONString(degreeRegistration.getAdditionCourseInfo()));
+            if(additionCourseInfo != null && additionCourseInfo.size() > 0){
+            	studentPaymentOrderDetail.setGoodsIdList(JSON.toJSONString(degreeRegistration.getAdditionCourseInfo()));
             }
             studentPaymentOrderDetail.setPrice(additionCoursePrice);
             studentPaymentOrderDetail.setRemitFee(BigDecimal.ZERO);
@@ -610,9 +610,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
             BigDecimal subjectLevelAmount = degree.getMoney() == null ? BigDecimal.ZERO : degree.getMoney();
             BigDecimal theoryLevelAmount = degree.getTheoryMoney() == null ? BigDecimal.ZERO : degree.getTheoryMoney();
             BigDecimal totalAmount = subjectLevelAmount.add(theoryLevelAmount);
-            Set<Integer> collect = dataList.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
-
-            pageInfo.setApplyNum(collect.size());
+            pageInfo.setApplyNum(degreeRegistrationDao.countApplyNum(params));
             pageInfo.setSubjectLevelAmount(subjectLevelAmount);
             pageInfo.setTheoryLevelAmount(theoryLevelAmount);
             pageInfo.setTotalAmount(totalAmount);

+ 22 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/EduPracticeGroupServiceImpl.java

@@ -1,5 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
+import static java.math.BigDecimal.ROUND_DOWN;
+
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -725,9 +727,18 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
         if(teacherDefaultSalary == null){
             throw new BizException("请设置老师课酬");
         }
-        BigDecimal studentSingleCourseCost=price.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-        BigDecimal studentSingleCourseOriginalCost=price.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-        for (CourseSchedule courseSchedule : practiceCourses) {
+        
+        BigDecimal studentSingleCourseOriginalCost = price.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+
+        //使用优惠券
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(practiceGroupBuyParams.getCouponIdList(), price, true);
+        //实际支付金额,去除优惠券
+        BigDecimal actualPrice = studentPaymentOrder.getExpectAmount();
+        BigDecimal divide = actualPrice.divide(new BigDecimal(practiceCourses.size()), ROUND_DOWN);
+        BigDecimal firstAmount = actualPrice.subtract(divide.multiply(new BigDecimal(practiceCourses.size()))).add(divide);
+        
+        for (int i = 0; i < practiceCourses.size(); i++) {
+            CourseSchedule courseSchedule = practiceCourses.get(i);
             //课程与老师薪水表
             CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
             courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
@@ -747,8 +758,13 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
             courseScheduleStudentPayment.setMusicGroupId(practiceGroupBuyParams.getId().toString());
             courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
             courseScheduleStudentPayment.setUserId(practiceGroupBuyParams.getStudentId());
-            courseScheduleStudentPayment.setExpectPrice(studentSingleCourseCost);
-            courseScheduleStudentPayment.setActualPrice(studentSingleCourseCost);
+            if(i == 0){
+                courseScheduleStudentPayment.setExpectPrice(firstAmount);
+                courseScheduleStudentPayment.setActualPrice(firstAmount);
+            }else {
+                courseScheduleStudentPayment.setExpectPrice(divide);
+                courseScheduleStudentPayment.setActualPrice(divide);
+            }
             courseScheduleStudentPayment.setOriginalPrice(studentSingleCourseOriginalCost);
             courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
             courseScheduleStudentPayment.setCreateTime(now);
@@ -787,7 +803,6 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
             return BaseController.failed(HttpStatus.FOUND, errMessage);
         }
 
-        StudentPaymentOrder studentPaymentOrder=new StudentPaymentOrder();
         studentPaymentOrder.setUserId(practiceGroupBuyParams.getStudentId());
         studentPaymentOrder.setGroupType(GroupType.PRACTICE);
         String orderNo=idGeneratorService.generatorId("payment") + "";
@@ -795,7 +810,7 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
         studentPaymentOrder.setType(OrderTypeEnum.PRACTICE_GROUP_BUY);
 
-        studentPaymentOrder.setExpectAmount(price);
+        studentPaymentOrder.setExpectAmount(actualPrice);
         studentPaymentOrder.setMusicGroupId(practiceGroupBuyParams.getId().toString());
         studentPaymentOrder.setActualAmount(studentPaymentOrder.getExpectAmount());
         studentPaymentOrder.setClassGroupId(classGroup.getId());

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

@@ -3279,7 +3279,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 
     @Override
     @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-    public HttpResponseResult createPackagePracticeGroup(PracticeGroupBuyDto practiceGroupBuyParams) {
+    public HttpResponseResult createPackagePracticeGroup(PracticeGroupBuyDto practiceGroupBuyParams, String operatorInfo) {
         studentDao.lockUser(practiceGroupBuyParams.getStudentId());
         if (Objects.isNull(practiceGroupBuyParams.getUserId())) {
             return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "请选择教师");
@@ -3461,6 +3461,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         practiceGroupBuyParams.setSingleClassMinutes(practiceCourseMinutes);
         practiceGroupBuyParams.setGroupStatus(GroupStatusEnum.LOCK);
         practiceGroupBuyParams.setType(PracticeGroupType.COME_ON_PACKAGE);
+        if(StringUtils.isNotBlank(operatorInfo)){
+        	practiceGroupBuyParams.setMemo(operatorInfo+",教务代买");
+        }
         practiceGroupDao.insert(practiceGroupBuyParams);
 
         //创建班级信息
@@ -3570,7 +3573,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             courseScheduleStudentPayment.setGroupType(GroupType.PRACTICE);
             courseScheduleStudentPayment.setMusicGroupId(practiceGroupBuyParams.getId().toString());
             courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
-            courseScheduleStudentPayment.setUserId(practiceGroupBuyParams.getStudentId());if(i == 0){
+            courseScheduleStudentPayment.setUserId(practiceGroupBuyParams.getStudentId());
+            if(i == 0){
                 courseScheduleStudentPayment.setExpectPrice(firstAmount);
                 courseScheduleStudentPayment.setActualPrice(firstAmount);
             }else {
@@ -3629,6 +3633,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         studentPaymentOrder.setActualAmount(studentPaymentOrder.getExpectAmount());
         studentPaymentOrder.setClassGroupId(classGroup.getId());
         studentPaymentOrder.setVersion(0);
+        if(StringUtils.isNotBlank(operatorInfo)){
+        	studentPaymentOrder.setMemo(operatorInfo+",教务代买");
+        }
         studentPaymentOrderService.insert(studentPaymentOrder);
 
         BigDecimal balance = BigDecimal.ZERO;

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

@@ -119,6 +119,12 @@
         <include refid="queryPageSql"/>
     </select>
 
+    <select id="countApplyNum" parameterType="map" resultType="int">
+        SELECT COUNT(DISTINCT user_id_)
+        FROM degree_registration
+        <include refid="queryPageSql"/>
+    </select>
+
     <delete id="delete" parameterType="java.lang.Integer">
         delete
         from degree_registration

+ 1 - 1
mec-student/src/main/java/com/ym/mec/student/controller/PracticeGroupController.java

@@ -266,7 +266,7 @@ public class PracticeGroupController extends BaseController {
         if(Objects.isNull(practiceGroupBuyParams.getType())||PracticeGroupType.CHARGE.equals(practiceGroupBuyParams.getType())){
             return practiceGroupService.buyPracticeGroup(practiceGroupBuyParams, null);
         }else{
-            return practiceGroupService.createPackagePracticeGroup(practiceGroupBuyParams);
+            return practiceGroupService.createPackagePracticeGroup(practiceGroupBuyParams, null);
         }
     }