瀏覽代碼

Merge remote-tracking branch 'origin/system_fee' into system_fee

zouxuan 4 年之前
父節點
當前提交
68cbaae577

+ 34 - 33
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudTeacherOrderServiceImpl.java

@@ -1,9 +1,24 @@
 package com.ym.mec.biz.service.impl;
 
-import com.ym.mec.biz.dal.dao.*;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.ym.mec.biz.dal.dao.CloudTeacherDao;
+import com.ym.mec.biz.dal.dao.CloudTeacherOrderDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
 import com.ym.mec.biz.dal.dto.CloudTeacherOrderDto;
-import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.entity.CloudTeacher;
+import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.enums.PeriodEnum;
 import com.ym.mec.biz.service.CloudTeacherOrderService;
 import com.ym.mec.biz.service.StudentService;
@@ -12,14 +27,6 @@ import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.date.DateUtil;
 
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.stream.Collectors;
-
 @Service
 public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTeacherOrder> implements CloudTeacherOrderService {
 
@@ -42,28 +49,22 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
     }
 
     @Override
-    public Boolean addOrderDetail2CloudTeacher(StudentPaymentOrder order) {
-        List<OrderDetailTypeEnum> orderDetailTypes = new ArrayList<>();
-        orderDetailTypes.add(OrderDetailTypeEnum.CLOUD_TEACHER);
-        orderDetailTypes.add(OrderDetailTypeEnum.CLOUD_TEACHER_PLUS);
-        List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailDao.getOrderDetailByType(order.getId(), orderDetailTypes);
-        if (orderDetails.size() <= 0) {
-            return true;
-        }
-        StudentPaymentOrderDetail orderDetail = orderDetails.get(0);
-        CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
-        cloudTeacherOrder.setOrganId(order.getOrganId());
-        cloudTeacherOrder.setStudentId(order.getUserId());
-        cloudTeacherOrder.setType(2);
-        int level = orderDetail.getType().equals(OrderDetailTypeEnum.CLOUD_TEACHER) ? 3 : 4;
-        cloudTeacherOrder.setLevel(level);
-        cloudTeacherOrder.setTime(6);
-        cloudTeacherOrder.setAmount(orderDetail.getPrice());
-        cloudTeacherOrder.setStatus(1);
-        cloudTeacherOrder.setOrderId(order.getId());
-        cloudTeacherOrderDao.insert(cloudTeacherOrder);
-        return true;
-    }
+    @Transactional(rollbackFor = Exception.class)
+	public Boolean addOrderDetail2CloudTeacher(StudentPaymentOrder order) {
+		CloudTeacherOrder cloudTeacherOrder = cloudTeacherOrderDao.queryByOrderId(order.getId());
+
+		if (cloudTeacherOrder == null) {
+			throw new BizException("云教练订单找不到");
+		}
+		Date date = new Date();
+
+		cloudTeacherOrder.setStatus(1);
+		cloudTeacherOrder.setUpdateTime(date);
+
+		cloudTeacherOrderDao.update(cloudTeacherOrder);
+
+		return true;
+	}
 
     @Override
     public Boolean checkCloudOrderStart() {

+ 49 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -695,6 +695,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentRegistration.setOrganId(musicGroup.getOrganId());
         studentRegistration.setPayingStatus(1);
 
+        Date date = new Date();
+
+        CloudTeacherOrder cloudTeacherOrder = null;
         //云教练/云教练+
         if (registerPayDto.getBuyCloudTeacher() || registerPayDto.getBuyCloudTeacherPlus()) {
             MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderDao.getMusicGroupRegCalender(studentRegistration.getMusicGroupId());
@@ -707,6 +710,19 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             
             orderAmount = orderAmount.add(cloudTeacherPrice);
             studentRegistration.setHasCloudTeacher(1);
+            
+
+            //创建订单
+            cloudTeacherOrder = new CloudTeacherOrder();
+
+    		cloudTeacherOrder.setType(2);//月
+			cloudTeacherOrder.setTime(musicGroupRegCalender.getMemberValidDate());
+    		
+    		cloudTeacherOrder.setOrganId(musicGroup.getOrganId());
+    		cloudTeacherOrder.setStudentId(studentRegistration.getUserId());
+    		cloudTeacherOrder.setLevel(musicGroupRegCalender.getMemberRankSettingId());
+    		cloudTeacherOrder.setAmount(musicGroupRegCalender.getMemberPaymentAmount());
+    		cloudTeacherOrder.setStatus(0);
         }
 
         if (amount.compareTo(orderAmount) != 0) {
@@ -723,8 +739,14 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, remitFee, courseRemitFee, newCourses, registerPayDto.getBuyMaintenance(), registerPayDto.getBuyCloudTeacher(), registerPayDto.getBuyCloudTeacherPlus());
         studentPaymentOrder = studentPaymentOrderService.get(studentPaymentOrder.getId());
         boolean canPay = studentPaymentOrder.getClassGroupId() != null && studentPaymentOrder.getClassGroupId().equals(206);
+        
+        if(cloudTeacherOrder != null){
+    		cloudTeacherOrder.setOrderId(studentPaymentOrder.getId());
+    		cloudTeacherOrder.setCreateTime(date);
+    		cloudTeacherOrder.setUpdateTime(date);
+    		cloudTeacherOrderService.insert(cloudTeacherOrder);
+        }
 
-        Date date = new Date();
         BigDecimal balance = BigDecimal.ZERO;
         if (registerPayDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
             SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
@@ -758,7 +780,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         //更新注册信息
         studentRegistrationService.update(studentRegistration);
-
+        
         if ("205".equals(studentPaymentOrder.getPaymentAccountNo())) {
             Integer teacherId = musicGroup.getEducationalTeacherId();
             SysUser endTeacher = sysUserFeignService.queryUserById(teacherId);
@@ -894,6 +916,10 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentRegistration.setOrganId(musicGroup.getOrganId());
         studentRegistration.setPayingStatus(1);
 
+        Date date = new Date();
+
+        CloudTeacherOrder cloudTeacherOrder = null;
+
         //云教练/云教练+
         if (registerPayDto.getBuyCloudTeacher() || registerPayDto.getBuyCloudTeacherPlus()) {
         	
@@ -907,6 +933,19 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             
             orderAmount = orderAmount.add(cloudTeacherPrice);
             studentRegistration.setHasCloudTeacher(1);
+            
+
+            //创建订单
+            cloudTeacherOrder = new CloudTeacherOrder();
+
+    		cloudTeacherOrder.setType(2);//月
+			cloudTeacherOrder.setTime(musicGroupRegCalender.getMemberValidDate());
+    		
+    		cloudTeacherOrder.setOrganId(musicGroup.getOrganId());
+    		cloudTeacherOrder.setStudentId(studentRegistration.getUserId());
+    		cloudTeacherOrder.setLevel(musicGroupRegCalender.getMemberRankSettingId());
+    		cloudTeacherOrder.setAmount(musicGroupRegCalender.getMemberPaymentAmount());
+    		cloudTeacherOrder.setStatus(0);
         }
 
         if (amount.compareTo(orderAmount) != 0) {
@@ -924,8 +963,14 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, remitFee, courseRemitFee, newCourses, registerPayDto.getBuyMaintenance(), registerPayDto.getBuyCloudTeacher(), registerPayDto.getBuyCloudTeacherPlus());
         studentPaymentOrder = studentPaymentOrderService.get(studentPaymentOrder.getId());
         boolean canPay = studentPaymentOrder.getClassGroupId() != null && studentPaymentOrder.getClassGroupId().equals(206);
-        Date date = new Date();
-
+        
+        if(cloudTeacherOrder != null){
+    		cloudTeacherOrder.setOrderId(studentPaymentOrder.getId());
+    		cloudTeacherOrder.setCreateTime(date);
+    		cloudTeacherOrder.setUpdateTime(date);
+    		cloudTeacherOrderService.insert(cloudTeacherOrder);
+        }
+        
         BigDecimal balance = BigDecimal.ZERO;
         if (registerPayDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
             SysUserCashAccount userCashAccount = sysUserCashAccountService.get(userId);

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

@@ -492,7 +492,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             }
             BigDecimal cloudTeacherPrice = musicGroupRegCalender.getMemberPaymentAmount();
             
-            OrderDetailTypeEnum orderDetailTypeEnum = buyCloudTeacher ? OrderDetailTypeEnum.CLOUD_TEACHER : OrderDetailTypeEnum.CLOUD_TEACHER_PLUS;
+            OrderDetailTypeEnum orderDetailTypeEnum = OrderDetailTypeEnum.CLOUD_TEACHER;
             StudentPaymentOrderDetail cloudTeacherOrderDetail = new StudentPaymentOrderDetail();
             cloudTeacherOrderDetail.setType(orderDetailTypeEnum);
             cloudTeacherOrderDetail.setPrice(cloudTeacherPrice);