From 4f0503f056dc75a6ff61995465d3b86532b2640e Mon Sep 17 00:00:00 2001
From: nickchange <126672920+nickchange@users.noreply.github.com>
Date: 星期二, 28 十一月 2023 20:21:20 +0800
Subject: [PATCH] 11.27,9

---
 cloud-server-course/src/main/java/com/dsh/course/feignclient/account/StudentClient.java               |    3 ++-
 cloud-server-course/src/main/java/com/dsh/course/service/impl/CoursePackageSchedulingServiceImpl.java |   12 ++++++++++++
 cloud-server-course/src/main/java/com/dsh/course/feignclient/account/model/Student.java               |    6 ++++++
 cloud-server-course/src/main/java/com/dsh/course/controller/CourseStudentController.java              |   11 ++++++++++-
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/cloud-server-course/src/main/java/com/dsh/course/controller/CourseStudentController.java b/cloud-server-course/src/main/java/com/dsh/course/controller/CourseStudentController.java
index 189628e..e775a71 100644
--- a/cloud-server-course/src/main/java/com/dsh/course/controller/CourseStudentController.java
+++ b/cloud-server-course/src/main/java/com/dsh/course/controller/CourseStudentController.java
@@ -513,6 +513,13 @@
             calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + validDays);
             to.setUseTime(calendar.getTime());
             orderStudentService.save(to);
+            if(null == student.getValidity()){
+                student.setValidity(calendar.getTime());
+            }else if(student.getValidity().getTime() < calendar.getTime().getTime()){
+                student.setValidity(calendar.getTime());
+            }
+            studentClient.frozen(student);
+
 
             Integer appUserId = orinPay.getAppUserId();
             orinPay.setLaveClassHours(0);
@@ -591,7 +598,9 @@
                 int day_week = calendar.get(Calendar.DAY_OF_WEEK);
                 day_week = day_week - 1 == 0 ? 7 : day_week - 1;
                 int num = 8 - day_week + 7;
-                Date useTime = coursePackageOrderStudent.getUseTime();
+
+                Student student = studentClient.queryStudentById(coursePackageOrderStudent.getStudentId());
+                Date useTime = student.getValidity();
 
                 for (int i = 0; i < num; i++) {
                     Date time = calendar.getTime();
diff --git a/cloud-server-course/src/main/java/com/dsh/course/feignclient/account/StudentClient.java b/cloud-server-course/src/main/java/com/dsh/course/feignclient/account/StudentClient.java
index e7ef08b..7f991b0 100644
--- a/cloud-server-course/src/main/java/com/dsh/course/feignclient/account/StudentClient.java
+++ b/cloud-server-course/src/main/java/com/dsh/course/feignclient/account/StudentClient.java
@@ -56,5 +56,6 @@
     @PostMapping("/student/queryTStudentListByName")
     List<TStudent> queryTStudentListByName(@RequestBody String name);
 
-
+    @PostMapping("/student/frozen")
+    void frozen(@RequestBody Student student);
 }
diff --git a/cloud-server-course/src/main/java/com/dsh/course/feignclient/account/model/Student.java b/cloud-server-course/src/main/java/com/dsh/course/feignclient/account/model/Student.java
index 2f41ab3..a123916 100644
--- a/cloud-server-course/src/main/java/com/dsh/course/feignclient/account/model/Student.java
+++ b/cloud-server-course/src/main/java/com/dsh/course/feignclient/account/model/Student.java
@@ -70,4 +70,10 @@
      * 是否默认 1默认 2不是默认
      */
     private Integer isDefault;
+    /**
+     * 课时有效期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date validity;
+
 }
diff --git a/cloud-server-course/src/main/java/com/dsh/course/service/impl/CoursePackageSchedulingServiceImpl.java b/cloud-server-course/src/main/java/com/dsh/course/service/impl/CoursePackageSchedulingServiceImpl.java
index 41847eb..17df637 100644
--- a/cloud-server-course/src/main/java/com/dsh/course/service/impl/CoursePackageSchedulingServiceImpl.java
+++ b/cloud-server-course/src/main/java/com/dsh/course/service/impl/CoursePackageSchedulingServiceImpl.java
@@ -5,6 +5,8 @@
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dsh.course.controller.CoursePackagePaymentController;
 import com.dsh.course.entity.*;
+import com.dsh.course.feignclient.account.StudentClient;
+import com.dsh.course.feignclient.account.model.Student;
 import com.dsh.course.mapper.CoursePackageSchedulingMapper;
 import com.dsh.course.mapper.CoursePackageStudentMapper;
 import com.dsh.course.model.QueryCoursePackageSchedulingList;
@@ -44,6 +46,9 @@
 
     @Resource
     private CoursePackageStudentMapper coursePackageStudentMapper;
+
+    @Resource
+    private StudentClient studentClient;
 
 
     /**
@@ -524,6 +529,13 @@
             coursePackageOrderStudent.setUseTime(useTime);
             coursePackageOrderStudent.setStatus(1);
             coursePackageOrderStudentService.updateById(coursePackageOrderStudent);
+            Student student = studentClient.queryStudentById(coursePackageOrderStudent.getStudentId());
+            if(null == student.getValidity()){
+                student.setValidity(useTime);
+            }else if(student.getValidity().getTime() < useTime.getTime()){
+                student.setValidity(useTime);
+            }
+            studentClient.frozen(student);
         }catch (Exception e){
             e.printStackTrace();
         }

--
Gitblit v1.7.1