nickchange
2023-11-27 4d17e9219dfeb41db32e82340ec9af9faedb4ca5
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;
@@ -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) {
@@ -2160,10 +2187,10 @@
            if (null == appUserId) {
                return ResultUtil.tokenErr();
            }
            List<TCoursePackagePayment> packagePayment = packagePaymentService.list(new LambdaQueryWrapper<TCoursePackagePayment>()
                    .eq(TCoursePackagePayment::getCoursePackageId, courseID)
                    .eq(TCoursePackagePayment::getAppUserId, appUserId)
                    .eq(TCoursePackagePayment::getStudentId, stuId)
            List<CoursePackageOrderStudent> packagePayment = coursePackageOrderStudentService.list(new QueryWrapper<CoursePackageOrderStudent>()
                    .eq("coursePackageId", courseID)
                    .eq("appUserId", appUserId)
                    .eq("studentId", stuId)
            );
            if (ToolUtil.isEmpty(packagePayment) || packagePayment.size() == 0) {
@@ -2175,7 +2202,7 @@
            );
            List<CoursePackageStudent> coursePackageStudent = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>()
                    .in(CoursePackageStudent::getCoursePackagePaymentId, packagePayment.stream().map(TCoursePackagePayment::getId).collect(Collectors.toList()))
                    .in(CoursePackageStudent::getCoursePackagePaymentId, packagePayment.stream().map(CoursePackageOrderStudent::getId).collect(Collectors.toList()))
                    .in(CoursePackageStudent::getCoursePackageSchedulingId, coursePackageSchedulings.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList()))
                    .eq(CoursePackageStudent::getCoursePackageId, courseID)
                    .eq(CoursePackageStudent::getStudentId, stuId)
@@ -2238,25 +2265,32 @@
        map.put("name", store.getName());
        map.put("lon", lon);
        map.put("lat", lat);
        // 找出门店的所有课程 排出体验
        List<TCoursePackage> list = tcpService.list(new LambdaQueryWrapper<TCoursePackage>().eq(TCoursePackage::getStoreId, courseDetailReq.getStoreId()).ne(TCoursePackage::getType, 3).eq(TCoursePackage::getState, 1).like(TCoursePackage::getClassWeeks, week));
        List<Integer> collect = list.stream().map(TCoursePackage::getId).collect(Collectors.toList());
        if (collect.size() == 0) {
            collect.add(-1);
        }
        List<CoursePackageScheduling> list8 = coursePackageSchedulingMapper.selectList(new LambdaQueryWrapper<CoursePackageScheduling>()
                .eq(CoursePackageScheduling::getAppUserId, courseDetailReq.getAppUserId())
                .eq(CoursePackageScheduling::getStudentId, courseDetailReq.getStuId())
                .in(CoursePackageScheduling::getCoursePackageId, collect)
        );
        List<Integer> collect1 = list8.stream().map(CoursePackageScheduling::getCoursePackageId).collect(Collectors.toList());
        // 找出购买的课包
        List<CoursePackageOrderStudent> list1 = coursePackageOrderStudentService.list(new QueryWrapper<CoursePackageOrderStudent>()
                .eq("appUserId", courseDetailReq.getAppUserId())
                .eq("studentId", courseDetailReq.getStuId())
                .in("coursePackageId", collect)
                .in("coursePackageId", collect1)
                .eq("status", 1)
                .eq("state", 1)
        );
        List<Integer> collect1 = list1.stream().map(CoursePackageOrderStudent::getCoursePackageId).collect(Collectors.toList());
        List<Long> ids = list1.stream().map(CoursePackageOrderStudent::getId).collect(Collectors.toList());
//        List<Integer> collect1 = list1.stream().map(CoursePackageOrderStudent::getCoursePackageId).collect(Collectors.toList());
//        List<Long> ids = list1.stream().map(CoursePackageOrderStudent::getId).collect(Collectors.toList());
        for (TCoursePackage tCoursePackage : list) {
@@ -2297,6 +2331,9 @@
                detailsListVo.setMoney(cashPayment);
            }
            detailsListVo.setNum(tCoursePackage.getNeedNum());
            if (collect1.contains(tCoursePackage.getId())) {
                // 找出排课记录
                List<CoursePackageScheduling> list3 = coursePackageSchedulingMapper.selectList(new LambdaQueryWrapper<CoursePackageScheduling>()
@@ -2318,8 +2355,7 @@
                List<CoursePackageStudent> list4 = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>()
                        .eq(CoursePackageStudent::getAppUserId, courseDetailReq.getAppUserId())
                        .eq(CoursePackageStudent::getCoursePackageId, tCoursePackage.getId())
                        .in(CoursePackageStudent::getCoursePackageSchedulingId, collect2).
                                in(CoursePackageStudent::getCoursePackagePaymentId, ids)
                        .in(CoursePackageStudent::getCoursePackageSchedulingId, collect2)
                );
                List<CoursePackageStudent> list5 = cspsService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", courseDetailReq.getStuId()).eq("coursePackageId", tCoursePackage.getId()));