From 1882d607549762a84b1a5326f7262eba01363b85 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期一, 14 八月 2023 10:00:16 +0800
Subject: [PATCH] 更新课包功能

---
 cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java |  110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 108 insertions(+), 2 deletions(-)

diff --git a/cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java b/cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java
index 6e19834..7502215 100644
--- a/cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java
+++ b/cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java
@@ -5,12 +5,15 @@
 import com.alipay.api.domain.Person;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dsh.course.entity.*;
 import com.dsh.course.feignclient.account.AppUserClient;
 import com.dsh.course.feignclient.account.CoachClient;
+import com.dsh.course.feignclient.account.StudentClient;
 import com.dsh.course.feignclient.account.model.AppUser;
 import com.dsh.course.feignclient.account.model.Coach;
+import com.dsh.course.feignclient.account.model.Student;
 import com.dsh.course.feignclient.activity.BenefitVideoClient;
 import com.dsh.course.feignclient.activity.CouponClient;
 import com.dsh.course.feignclient.activity.model.BenefitsVideos;
@@ -19,6 +22,8 @@
 import com.dsh.course.feignclient.other.StoreClient;
 import com.dsh.course.feignclient.other.model.Store;
 import com.dsh.course.mapper.*;
+import com.dsh.course.model.QueryRegistrationRecord;
+import com.dsh.course.model.QueryWalkInStudentList;
 import com.dsh.course.model.dto.DiscountJsonDto;
 import com.dsh.course.model.vo.RegisterCourseVo;
 import com.dsh.course.model.vo.request.ClasspaymentRequest;
@@ -28,10 +33,12 @@
 import com.dsh.course.model.vo.response.AppUserVideoResponse;
 import com.dsh.course.model.vo.response.CourseDetailsResponse;
 import com.dsh.course.model.vo.response.CourseOfVideoResponse;
+import com.dsh.course.service.ICoursePackageSchedulingService;
 import com.dsh.course.service.TCoursePackagePaymentService;
 import com.dsh.course.util.*;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -58,7 +65,6 @@
     @Resource
     private BenefitVideoClient bfvoClient;
 
-
     @Resource
     private UserVideoDetailsMapper uvdmapper;
 
@@ -83,7 +89,6 @@
     @Resource
     private TCoursePackageDiscountMapper tcpdMapper;
 
-
     @Resource
     private CoursePackagePaymentConfigMapper cpConfigMapper;
 
@@ -95,6 +100,16 @@
 
     @Resource
     private AppUserClient appuClient;
+
+    @Resource
+    private StudentClient studentClient;
+
+    @Autowired
+    private ICoursePackageSchedulingService coursePackageSchedulingService;
+
+
+
+
 
 
     /**
@@ -633,4 +648,95 @@
     }
 
 
+    /**
+     * 获取课包报名信息
+     * @param page
+     * @param queryRegistrationRecord
+     * @return
+     */
+    @Override
+    public List<Map<String, Object>> queryRegistrationRecord(Page<Map<String, Object>> page, QueryRegistrationRecord queryRegistrationRecord) {
+        Integer coursePackageId = queryRegistrationRecord.getCoursePackageId();
+        String userName = queryRegistrationRecord.getUserName();
+        List<Integer> userIds = null;
+        List<Integer> studentIds = null;
+        if(ToolUtil.isNotEmpty(userName)){
+            List<AppUser> appUsers = appuClient.queryAppUserListByName(userName);
+            if(appUsers.size() > 0){
+                userIds = appUsers.stream().map(AppUser::getId).collect(Collectors.toList());
+            }
+        }
+        String studentName = queryRegistrationRecord.getStudentName();
+        if(ToolUtil.isNotEmpty(studentName)){
+            List<Student> students = studentClient.queryStudentListByName(studentName);
+            if(students.size() > 0){
+                studentIds = students.stream().map(Student::getId).collect(Collectors.toList());
+            }
+        }
+        List<Map<String, Object>> list = this.baseMapper.queryRegistrationRecord(page, coursePackageId, userIds, studentIds);
+        for (Map<String, Object> map : list) {
+            Long id = Long.valueOf(map.get("id").toString());
+            Integer appUserId = Integer.valueOf(map.get("appUserId").toString());
+            Integer studentId = Integer.valueOf(map.get("studentId").toString());
+            AppUser appUser = appuClient.queryAppUser(appUserId);
+            map.put("userName", null != appUser ? appUser.getName() : "");
+            map.put("phone", null != appUser ? appUser.getPhone() : "");
+            Student student = studentClient.queryStudentById(studentId);
+            map.put("studentName", null != student ? student.getName() : "");
+            Integer integer = cpsMapper.selectCount(new QueryWrapper<CoursePackageStudent>().eq("appUserId", appUserId)
+                    .eq("studentId", studentId).eq("coursePackagePaymentId", id).eq("signInOrNot", 1));
+            map.put("already", integer);
+        }
+        return list;
+    }
+
+
+    /**
+     * 获取未预约排课学员列表
+     * @param page
+     * @param queryWalkInStudentList
+     * @return
+     */
+    @Override
+    public List<Map<String, Object>> queryWalkInStudentList(Page<Map<String, Object>> page, QueryWalkInStudentList queryWalkInStudentList) {
+        Long coursePackageSchedulingId = queryWalkInStudentList.getCoursePackageSchedulingId();
+        CoursePackageScheduling coursePackageScheduling = coursePackageSchedulingService.getById(coursePackageSchedulingId);
+        String userName = queryWalkInStudentList.getUserName();
+        List<Integer> userIds = null;
+        List<Integer> studentIds = null;
+        if(ToolUtil.isNotEmpty(userName)){
+            List<AppUser> appUsers = appuClient.queryAppUserListByName(userName);
+            if(appUsers.size() > 0){
+                userIds = appUsers.stream().map(AppUser::getId).collect(Collectors.toList());
+            }
+        }
+        String studentName = queryWalkInStudentList.getStudentName();
+        if(ToolUtil.isNotEmpty(studentName)){
+            List<Student> students = studentClient.queryStudentListByName(studentName);
+            if(students.size() > 0){
+                studentIds = students.stream().map(Student::getId).collect(Collectors.toList());
+            }
+        }
+        List<Long> coursePackagePaymentId = null;
+        List<CoursePackageStudent> coursePackageStudents = cpsMapper.selectList(new QueryWrapper<CoursePackageStudent>().eq("coursePackageSchedulingId", coursePackageSchedulingId).eq("reservationStatus", 1));
+        if(coursePackageStudents.size() > 0){
+            coursePackagePaymentId = coursePackageStudents.stream().map(CoursePackageStudent::getCoursePackagePaymentId).collect(Collectors.toList());
+        }
+
+        List<Map<String, Object>> list = this.baseMapper.queryWalkInStudentList(page, coursePackageScheduling.getCoursePackageId(), coursePackagePaymentId, userIds, studentIds);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
+        Integer now = Integer.valueOf(sdf.format(new Date()));
+        for (Map<String, Object> map : list) {
+            Integer appUserId = Integer.valueOf(map.get("appUserId").toString());
+            Integer student_Id = Integer.valueOf(map.get("studentId").toString());
+            AppUser appUser = appuClient.queryAppUser(appUserId);
+            Student student = studentClient.queryStudentById(student_Id);
+            map.put("userName", appUser.getName());
+            map.put("phone", student.getPhone());
+            map.put("studentName", student.getName());
+            map.put("age", null != student.getBirthday() ? now - Integer.valueOf(sdf.format(student.getBirthday())) : "-");
+            map.put("sex", student.getSex());
+        }
+        return list;
+    }
 }

--
Gitblit v1.7.1