Преглед изворни кода

Merge remote-tracking branch 'origin/master'

周箭河 пре 4 година
родитељ
комит
a4c03e0ab3

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

@@ -1241,7 +1241,17 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @param courseSchedule
      * @return
      */
-    CourseSchedule queryContinueCourse(@Param("courseSchedule") CourseSchedule courseSchedule,
+    CourseSchedule queryStudentContinueCourse(@Param("courseSchedule") CourseSchedule courseSchedule,
+                                       @Param("continueCourseTime") String continueCourseTime, @Param("endDateTime") String endDateTime);
+
+    /**
+     * 获取当前课程,下一次连堂课
+     *
+     * @param continueCourseTime
+     * @param courseSchedule
+     * @return
+     */
+    CourseSchedule queryTeacherContinueCourse(@Param("courseSchedule") CourseSchedule courseSchedule,
                                        @Param("continueCourseTime") String continueCourseTime, @Param("endDateTime") String endDateTime);
 
     /**

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRepairService.java

@@ -79,6 +79,17 @@ public interface StudentRepairService extends BaseService<Integer, StudentRepair
     Map addGoodsSellOrder(StudentGoodsSell studentGoodsSell) throws Exception;
 
     /**
+     * @describe 学员扫码支付
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/9/16
+     * @time 13:47
+     * @param goodsSellId:
+     * @return java.util.Map
+     */
+    Map studentPaymentGoodsOrder(Integer goodsSellId) throws Exception;
+
+    /**
      * @describe 商品销售订单回调
      * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
      * @author zouxuan

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

@@ -871,10 +871,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             throw new BizException("用户信息获取失败");
         }
         MusicGroup musicGroup = saveLog(musicGroupId, MusicGroupStatusEnum.PREPARE);
-        int finishCourseNum = courseScheduleDao.countGroupFinishCourse(musicGroupId, GroupType.MUSIC.getCode());
-        if(finishCourseNum>0){
-            throw new BizException("此乐团存在已结束课程");
-        }
 
         //乐器采购清单是否确认
         Map<String, Object> param = new HashMap<>();

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

@@ -521,7 +521,7 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
             //获取当前课程的所有连堂课列表
             String courseClassDate = DateUtil.format(cs.getClassDate(), DateUtil.DEFAULT_PATTERN);
             String courseEndDateTime = DateUtil.format(cs.getEndClassTime(), DateUtil.EXPANDED_TIME_FORMAT);
-            cs = courseScheduleDao.queryContinueCourse(cs, continueCourseTime, courseClassDate + " " + courseEndDateTime);
+            cs = courseScheduleDao.queryStudentContinueCourse(cs, continueCourseTime, courseClassDate + " " + courseEndDateTime);
             //存在连堂课
             if (cs != null) {
                 courseSchedules.add(cs);
@@ -629,7 +629,7 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
                 //获取当前课程的所有连堂课列表
                 String courseClassDate = DateUtil.format(cs.getClassDate(), DateUtil.DEFAULT_PATTERN);
                 String courseEndDateTime = DateUtil.format(cs.getEndClassTime(), DateUtil.EXPANDED_TIME_FORMAT);
-                cs = courseScheduleDao.queryContinueCourse(cs, continueCourseTime, courseClassDate + " " + courseEndDateTime);
+                cs = courseScheduleDao.queryStudentContinueCourse(cs, continueCourseTime, courseClassDate + " " + courseEndDateTime);
                 //存在连堂课
                 if (cs != null) {
                     courseSchedules.add(cs);

+ 86 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -251,6 +251,92 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class,isolation = Isolation.SERIALIZABLE)
+    public Map studentPaymentGoodsOrder(Integer goodsSellId) throws Exception {
+        StudentGoodsSell studentGoodsSell = studentGoodsSellDao.get(goodsSellId);
+        Integer studentId = studentGoodsSell.getUserId();
+        studentDao.lockUser(studentId);
+        SysUser student = sysUserFeignService.queryUserById(studentId);
+        List<GoodsSellDto> goodsSellDtos = studentGoodsSell.getGoodsSellDtos();
+        List<Integer> goodsIds = goodsSellDtos.stream().map(e -> e.getGoodsId()).collect(Collectors.toList());
+
+        Map<Integer, BigDecimal> map = getMap("goods", "id_", "market_price_", goodsIds, Integer.class, BigDecimal.class);
+        for (GoodsSellDto goodsSellDto : goodsSellDtos) {
+            goodsSellDto.setGoodsPrice(map.get(goodsSellDto.getGoodsId()));
+            goodsSellDto.setTotalGoodsPrice(map.get(goodsSellDto.getGoodsId()).multiply(new BigDecimal(goodsSellDto.getGoodsNum())));
+        }
+        Map<Integer, List<GoodsSellDto>> goodsMap = goodsSellDtos.stream().collect(Collectors.groupingBy(GoodsSellDto::getGoodsId));
+        BigDecimal amount = BigDecimal.ZERO;
+        for (Integer id : goodsIds) {
+            GoodsSellDto goodsSellDto = goodsMap.get(id).get(0);
+            amount = amount.add(goodsSellDto.getTotalGoodsPrice());
+        }
+        amount = amount.subtract(studentGoodsSell.getMarketAmount());
+        if(amount.signum() < 0){
+            throw new BizException("操作失败:订单金额异常");
+        }
+
+        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+        studentPaymentOrder.setUserId(studentId);
+        studentPaymentOrder.setGroupType(GroupType.GOODS_SELL);
+        studentPaymentOrder.setOrderNo(studentGoodsSell.getOrderNo());
+        studentPaymentOrder.setType(OrderTypeEnum.GOODS_SELL);
+        studentPaymentOrder.setExpectAmount(amount);
+        studentPaymentOrder.setActualAmount(amount);
+        studentPaymentOrder.setStatus(DealStatusEnum.ING);
+        studentPaymentOrder.setOrganId(student.getOrganId());
+        studentPaymentOrder.setRoutingOrganId(student.getOrganId());
+        studentPaymentOrderService.insert(studentPaymentOrder);
+
+        studentPaymentOrder.setVersion(0);
+        BigDecimal balance = BigDecimal.ZERO;
+        if (studentGoodsSell.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
+            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(studentId);
+            if (userCashAccount == null) {
+                throw new BizException("用户账户不存在");
+            }
+            if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
+                balance = amount.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : amount;
+                amount = amount.subtract(balance);
+                studentPaymentOrder.setActualAmount(amount);
+                studentPaymentOrder.setBalancePaymentAmount(balance);
+                sysUserCashAccountService.updateBalance(studentId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "商品销售");
+            }
+        }
+        studentPaymentOrderService.update(studentPaymentOrder);
+        studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);
+
+        if (amount.compareTo(BigDecimal.ZERO) == 0) {
+            studentPaymentRouteOrderService.addRouteOrder(studentGoodsSell.getOrderNo(), student.getOrganId(), balance);
+            Map<String, String> notifyMap = new HashMap<>();
+            notifyMap.put("tradeState", "1");
+            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
+            studentPaymentOrderService.updateOrder(notifyMap);
+            notifyMap.put("orderNo", studentGoodsSell.getOrderNo());
+            return notifyMap;
+        }
+
+        String baseApiUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
+
+        Map payMap = payService.getPayMap(
+                amount,
+                balance,
+                studentGoodsSell.getOrderNo(),
+                baseApiUrl + "/api-student/studentOrder/notify",
+                baseApiUrl + "/api-student/studentOrder/paymentResult?type=edu&orderNo=" + studentGoodsSell.getOrderNo(),
+                "商品销售",
+                "商品销售",
+                student.getOrganId(),
+                "goodsSell"
+        );
+
+        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
+        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
+        studentPaymentOrderService.update(studentPaymentOrder);
+        return payMap;
+    }
+
+    @Override
     @Transactional(rollbackFor = Exception.class)
     public Map addRepair(StudentRepair repairInfo) throws Exception {
         studentDao.lockUser(repairInfo.getEmployeeId());

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

@@ -261,7 +261,7 @@ public class TeacherAttendanceServiceImpl extends BaseServiceImpl<Long, TeacherA
 			//获取当前课程的所有连堂课列表
 			String courseClassDate = DateUtil.format(cs.getClassDate(), DateUtil.DEFAULT_PATTERN);
 			String courseEndDateTime = DateUtil.format(cs.getEndClassTime(), DateUtil.EXPANDED_TIME_FORMAT);
-			cs = courseScheduleDao.queryContinueCourse(cs,continueCourseTime,courseClassDate + " " + courseEndDateTime);
+			cs = courseScheduleDao.queryTeacherContinueCourse(cs,continueCourseTime,courseClassDate + " " + courseEndDateTime);
 			//存在连堂课
 			if(cs != null){
 				courseSchedules.add(cs);

+ 15 - 2
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -2619,13 +2619,26 @@
           AND #{startTime} &lt; CONCAT(cs.class_date_, ' ', cs.end_class_time_)
           AND #{endTime} &gt; CONCAT(cs.class_date_, ' ', cs.start_class_time_);
     </select>
-    <select id="queryContinueCourse" resultMap="CourseSchedule">
+    <select id="queryStudentContinueCourse" resultMap="CourseSchedule">
         SELECT cs.*
         FROM course_schedule cs
+        LEFT JOIN student_attendance sa ON cs.id_ = sa.course_schedule_id_
         WHERE TIMESTAMPDIFF(MINUTE, #{endDateTime}, CONCAT(cs.class_date_, ' ', cs.start_class_time_)) >= 0
           AND TIMESTAMPDIFF(MINUTE, #{endDateTime}, CONCAT(cs.class_date_, ' ', cs.start_class_time_)) &lt;= #{continueCourseTime}
           AND cs.teacher_id_ = #{courseSchedule.teacherId}
-          AND cs.class_group_id_ = #{courseSchedule.classGroupId} AND NOW() > CONCAT(cs.class_date_,' ', cs.start_class_time_)
+          AND cs.class_group_id_ = #{courseSchedule.classGroupId}
+          AND (NOW() > CONCAT(cs.class_date_,' ', cs.start_class_time_) OR sa.sign_in_time_ IS NOT NULL)
+        LIMIT 1
+    </select>
+    <select id="queryTeacherContinueCourse" resultMap="CourseSchedule">
+        SELECT cs.*
+        FROM course_schedule cs
+        LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_
+        WHERE TIMESTAMPDIFF(MINUTE, #{endDateTime}, CONCAT(cs.class_date_, ' ', cs.start_class_time_)) >= 0
+          AND TIMESTAMPDIFF(MINUTE, #{endDateTime}, CONCAT(cs.class_date_, ' ', cs.start_class_time_)) &lt;= #{continueCourseTime}
+          AND cs.teacher_id_ = #{courseSchedule.teacherId}
+          AND cs.class_group_id_ = #{courseSchedule.classGroupId}
+          AND (NOW() > CONCAT(cs.class_date_,' ', cs.start_class_time_) OR ta.sign_in_time_ IS NOT NULL)
         LIMIT 1
     </select>
     <select id="getSingleClassMinutes" resultType="java.lang.Integer">

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

@@ -94,7 +94,7 @@
 		<result column="goods_json_" property="goodsJson" />
 		<result column="total_amount_" property="totalAmount" />
 		<result column="market_amount_" property="marketAmount" />
-		<result column="user_name_" property="userName" />
+		<result column="username_" property="userName" />
 	</resultMap>
 	<sql id="queryStudentGoodsOrdersSql">
 		<where>

+ 12 - 0
mec-student/src/main/java/com/ym/mec/student/controller/RepairController.java

@@ -69,6 +69,18 @@ public class RepairController extends BaseController {
         return succeed(map);
     }
 
+    @ApiOperation("学员扫码支付")
+    @PostMapping(value = "/studentPaymentGoodsOrder")
+    public HttpResponseResult studentPaymentGoodsOrder(Integer goodsSellId) throws Exception {
+        Map map = studentRepairService.studentPaymentGoodsOrder(goodsSellId);
+        if(map.containsKey("tradeState")){
+            return failed(HttpStatus.CREATED, "恭喜您,购买成功!");
+        }
+        return succeed(map);
+    }
+
+
+
     @ApiOperation("获取维修记录")
     @GetMapping(value = "/getStudentRepairList")
     public HttpResponseResult getStudentRepairList(RepairStudentQueryInfo queryInfo) {