nickchange
2023-11-27 c8d5a7d5efc4c4a2efe0a482fb7884b5dfaa34ad
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;
@@ -138,8 +126,7 @@
    private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
    @Autowired
    private TOrderService orderService;
    @Autowired
    private ICoursePackageOrderStudentService coursePackageOrderStudentService;
@@ -728,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());
@@ -841,18 +828,28 @@
        return videoVos;
    }
    @PostMapping("/base/coursePack/allPaymentCourseList")
    @ResponseBody
    public List<CouponPaymentVo> getAppuserCourseList(@RequestBody Integer appUserId) {
        List<CouponPaymentVo> paymentVos = new ArrayList<>();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>()
                .eq("appUserId", appUserId)
                .eq("payType", 3)
//        List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>()
//                .eq("appUserId", appUserId)
//                .eq("payType", 3)
//                .eq("payStatus", 2)
//                .eq("state", 1));
        List<CoursePackageOrder> list = coursePackageOrderService.list(new QueryWrapper<CoursePackageOrder>().eq("appUserId", appUserId).eq("payType", 3)
                .eq("payStatus", 2)
                .eq("state", 1));
        if (list.size() > 0) {
            for (TCoursePackagePayment tCoursePackagePayment : list) {
            for (CoursePackageOrder tCoursePackagePayment : list) {
                CouponPaymentVo couponPaymentVo = new CouponPaymentVo();
                couponPaymentVo.setTime(simpleDateFormat.format(tCoursePackagePayment.getInsertTime()));
                couponPaymentVo.setAmount(tCoursePackagePayment.getPlayPaiCoin());
@@ -1115,6 +1112,7 @@
    }
    /**
     * 已报名课程详情
     */
@@ -1138,10 +1136,12 @@
            CourseDetailsResponse courseDetailsResponse = packagePaymentService.queryRegisteredCourseDetails(coursePayId, appUserId, lon, lat);
            if (orderId != null) {
                TOrder byId = orderService.getById(orderId);
                courseDetailsResponse.setAmount(byId.getPrice());
            }
//            if (orderId != null) {
//                TOrder byId = orderService.getById(orderId);
//                courseDetailsResponse.setAmount(byId.getPrice());
//            }
            return ResultUtil.success(courseDetailsResponse);
        } catch (Exception e) {
            e.printStackTrace();
@@ -2104,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) {
@@ -2320,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)
                );