Browse Source

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

zouxuan 5 năm trước cách đây
mục cha
commit
549d393c80

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

@@ -93,8 +93,8 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
 	 * @param goodsList
 	 * @return
 	 */
-	StudentPaymentOrder addOrder(Integer userId, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee,
-			List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList, String musicGroupId);
+	StudentPaymentOrder addOrder(StudentRegistration studentRegistration, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee,
+			List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList);
 
 	/**
 	 * 学生注册缴费重新下订单

+ 10 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -118,20 +118,23 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     @Override
     @Transactional(rollbackFor = Exception.class)
     public ClassGroup addClassGroup(ClassGroup classGroup) throws Exception {
+        String userIds = classGroup.getUserIds();
+        if(userIds == null || userIds.isEmpty()) throw new Exception("班级学生不能为空");
+
+        HashSet<String> userIdStrSet = new HashSet<>(Arrays.asList(userIds.split(",")));
+
         Date date = new Date();
         classGroup.setCreateTime(date);
         classGroup.setUpdateTime(date);
         classGroup.setType(ClassGroupTypeEnum.NORMAL);
-        String userIds = classGroup.getUserIds();
-        String[] userIdArr = userIds.split(",");
 
-        classGroup.setExpectStudentNum(userIdArr.length);
-        classGroup.setStudentNum(userIdArr.length);
+        classGroup.setExpectStudentNum(userIdStrSet.size());
+        classGroup.setStudentNum(userIdStrSet.size());
         insert(classGroup);
 
         //2、插入班级学生关联关系
         List<ClassGroupStudentMapper> classGroupStudentList = new ArrayList<>();
-        for (String userId : userIdArr) {
+        for (String userId : userIdStrSet) {
             ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
             classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
             classGroupStudentMapper.setClassGroupId(classGroup.getId());
@@ -139,9 +142,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             classGroupStudentMapper.setCreateTime(date);
             classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
             classGroupStudentList.add(classGroupStudentMapper);
+
             StudentRegistration studentRegistration = new StudentRegistration();
             studentRegistration.setClassGroupId(classGroup.getId());
-            studentRegistration.setUserId(Integer.getInteger(userId));
+            studentRegistration.setUserId(Integer.parseInt(userId));
             studentRegistration.setMusicGroupId(classGroup.getMusicGroupId());
             studentRegistrationDao.updateByUserIdAndMusicGroupId(studentRegistration);
         }

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

@@ -180,18 +180,18 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public StudentPaymentOrder addOrder(Integer userId, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList, String musicGroupId) {
+    public StudentPaymentOrder addOrder(StudentRegistration studentRegistration, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList) {
 
         Date date = new Date();
         StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
-        studentPaymentOrder.setUserId(userId);
+        studentPaymentOrder.setUserId(studentRegistration.getUserId());
         studentPaymentOrder.setOrderNo(orderNo);
         studentPaymentOrder.setType(OrderTypeEnum.APPLY);
         studentPaymentOrder.setExpectAmount(amount);
         studentPaymentOrder.setActualAmount(amount);
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
         studentPaymentOrder.setPaymentChannel(paymentChannel);
-        studentPaymentOrder.setMusicGroupId(musicGroupId);
+        studentPaymentOrder.setMusicGroupId(studentRegistration.getMusicGroupId());
         studentPaymentOrderService.insert(studentPaymentOrder);
 
         ArrayList<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
@@ -254,9 +254,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
         studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
 
-        //增加报名学生数
-//        MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(musicGroupId, studentPaymentOrder.get);
-//        musicOneSubjectClassPlan.setApplyStudentNum(musicOneSubjectClassPlan.getApplyStudentNum()+1);
+        //增加缴费学生数
+        MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
+        musicOneSubjectClassPlan.setApplyStudentNum(musicOneSubjectClassPlan.getApplyStudentNum()+1);
 
         return studentPaymentOrder;
     }

+ 5 - 4
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -11,6 +11,7 @@ import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.util.string.IdWorker;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -47,9 +48,10 @@ public class MusicGroupController extends BaseController {
     private StudentPaymentOrderService studentPaymentOrderService;
     @Autowired
     private PayService payService;
-    
     @Autowired
     private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
 
     @ApiOperation("获取学生所在乐团列表")
     @GetMapping(value = "/queryUserMusicGroups")
@@ -233,12 +235,11 @@ public class MusicGroupController extends BaseController {
         }
 
 
-        IdWorker idWorker = new IdWorker(0, 0);
-        String orderNo = "1017"+idWorker.nextId();
+        String orderNo = idGeneratorService.generatorId("payment")+"";
 
         Map payMap = payService.getPayMap(orderAmount, orderNo, "https://pay.dayaedu.com/api/yqpay/notify", "http://dev.dayaedu.com", "测试订单", "测试订单");
 
-        studentRegistrationService.addOrder(userId, amount, orderNo, (String) payMap.get("type"), courseFee, goodsGroups, goodsList, otherGoodsList, studentRegistration.getMusicGroupId());
+        studentRegistrationService.addOrder(studentRegistration, amount, orderNo, (String) payMap.get("type"), courseFee, goodsGroups, goodsList, otherGoodsList);
 
         return succeed(payMap);
     }