nickchange
2023-11-27 b0da58b53f3828a5ce7f0f1344a4c01c87181808
cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
@@ -1,11 +1,8 @@
package com.dsh.course.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsh.course.entity.*;
import com.dsh.course.entity.TAppUser;
@@ -15,8 +12,6 @@
import com.dsh.course.feignclient.account.model.Student;
import com.dsh.course.feignclient.account.model.TCourseInfoRecord;
import com.dsh.course.feignclient.account.model.TStudent;
import com.dsh.course.feignclient.activity.CouponClient;
import com.dsh.course.feignclient.activity.model.Coupon;
import com.dsh.course.feignclient.model.*;
import com.dsh.course.feignclient.other.StoreClient;
import com.dsh.course.feignclient.other.model.Store;
@@ -29,7 +24,6 @@
import com.dsh.course.model.vo.request.*;
import com.dsh.course.model.vo.response.*;
import com.dsh.course.service.*;
import com.dsh.course.service.impl.CoursePackageOrderStudentServiceImpl;
import com.dsh.course.util.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -37,16 +31,10 @@
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import net.bytebuddy.asm.Advice;
import org.aspectj.weaver.ast.Var;
import io.swagger.models.auth.In;
import org.checkerframework.checker.units.qual.C;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
@@ -727,11 +715,11 @@
        Integer totalNu = 0;
        Integer dedutNu = 0;
        Integer remainNu = 0;
        List<TCoursePackagePayment> byUserId = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>()
        List<CoursePackageOrderStudent> byUserId = coursePackageOrderStudentService.list(new QueryWrapper<CoursePackageOrderStudent>()
                .eq("appUserId", getStuOfCoursesDetails.getAppUserId())
                .eq("studentId", getStuOfCoursesDetails.getStuId()));
        if (byUserId.size() > 0) {
            for (TCoursePackagePayment tCoursePackagePayment : byUserId) {
            for (CoursePackageOrderStudent tCoursePackagePayment : byUserId) {
                totalNu = totalNu + tCoursePackagePayment.getTotalClassHours();
                dedutNu = dedutNu + tCoursePackagePayment.getLaveClassHours();
                remainNu = remainNu + (tCoursePackagePayment.getTotalClassHours() - tCoursePackagePayment.getLaveClassHours());
@@ -2116,6 +2104,33 @@
    }
//    @Autowired
//    private ICoursePackageOrderStudentService orderStudentService;
    @ResponseBody
    @PostMapping("/coursePackagePayment/consumeCourse")
    public ResultUtil consumeCourse(@RequestBody Integer coursePackagePaymentId) {
        CoursePackageOrderStudent coursePackageOrderStudent = orderStudentService.getById(coursePackagePaymentId);
        TCoursePackage coursePackage = coursePackageService.getById(coursePackageOrderStudent.getCoursePackageId());
        if (coursePackageOrderStudent.getLaveClassHours()<coursePackage.getNeedNum()){
            return ResultUtil.error("当前学员课时数不足");
        }
        coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours()-coursePackage.getNeedNum());
        orderStudentService.updateById(coursePackageOrderStudent);
        CourseCounsum courseCounsum = new CourseCounsum();
        courseCounsum.setPaymentId(coursePackageOrderStudent.getId());
        courseCounsum.setChangeType(0);
        courseCounsum.setNum(coursePackage.getNeedNum());
        courseCounsum.setInsertTime(new Date());
        courseCounsum.setReason("补课");
        courseCounsumService.save(courseCounsum);
        return ResultUtil.success("补课成功");
    }
    @ResponseBody
    @PostMapping("/coursePackagePayment/CountqueryByClassId")
    public Integer CountqueryByClassId(@RequestBody Integer id) {
@@ -2332,13 +2347,14 @@
                }
                //排课的ids
                List<Long> collect2 = list3.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList());
                if (collect2.isEmpty()) {
                if (collect2.isEmpty()){
                    collect2.add(-1l);
                }
                List<CoursePackageStudent> list4 = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>()
                        .eq(CoursePackageStudent::getAppUserId, courseDetailReq.getAppUserId())
                        .eq(CoursePackageStudent::getStudentId, courseDetailReq.getStuId())
                        .eq(CoursePackageStudent::getCoursePackageId, tCoursePackage.getId())
                        .in(CoursePackageStudent::getCoursePackageSchedulingId, collect2)
                );