44323
2023-09-23 5f804115139dfdeeb2ce950a0f584b30f94b285c
cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
@@ -5,6 +5,7 @@
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.feignclient.account.AppUserClient;
@@ -17,6 +18,7 @@
import com.dsh.course.feignclient.model.*;
import com.dsh.course.feignclient.other.StoreClient;
import com.dsh.course.feignclient.other.model.Store;
import com.dsh.course.mapper.CoursePackageSchedulingMapper;
import com.dsh.course.model.*;
import com.dsh.course.model.dto.DiscountJsonDto;
import com.dsh.course.model.vo.CourseDetailRequest;
@@ -33,6 +35,7 @@
import io.swagger.annotations.ApiOperation;
import net.bytebuddy.asm.Advice;
import org.aspectj.weaver.ast.Var;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
@@ -115,6 +118,11 @@
    private StoreClient storeClient;
    @Autowired
    private TCoursePackageDiscountService discountService;
    @Resource
    private CoursePackageSchedulingMapper coursePackageSchedulingMapper;
    private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
    /**
@@ -231,6 +239,7 @@
                TCoursePackage tCoursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId());
                StuCourseResp resp = new StuCourseResp();
                resp.setCourseId(tCoursePackage.getId());
                resp.setId(tCoursePackagePayment.getId());
                resp.setCourseName(tCoursePackage.getName());
                resp.setTotalCourseNums(tCoursePackagePayment.getTotalClassHours());
                resp.setResidueNums(tCoursePackagePayment.getLaveClassHours());
@@ -263,12 +272,12 @@
                    .groupBy("coursePackageId"));
            if (list.size() >  0){
                for (TCoursePackagePayment tCoursePackagePayment : list) {
                    CoursePackageStudent packageStudent = cspsService.getOne(new LambdaQueryWrapper<CoursePackageStudent>()
                    List<CoursePackageStudent> packageStudent = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>()
                            .eq(CoursePackageStudent::getAppUserId, courseRest.getAppUserId())
                            .eq(CoursePackageStudent::getStudentId,courseRest.getStuId())
                            .eq(CoursePackageStudent::getCoursePackagePaymentId,tCoursePackagePayment.getId())
                            .eq(CoursePackageStudent::getCoursePackageId,tCoursePackagePayment.getCoursePackageId()));
                    if (ToolUtil.isEmpty(packageStudent) || (ToolUtil.isNotEmpty(packageStudent) && packageStudent.getReservationStatus() != 1)){
                    if (ToolUtil.isEmpty(packageStudent) || (ToolUtil.isNotEmpty(packageStudent) && packageStudent.get(0).getReservationStatus() == 1)){
//                        没有预约过的/已经取消了的
                        TCoursePackage tCoursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId());
                        CoursePackagePaymentConfig paymentConfig = icppcService.getOne(new QueryWrapper<CoursePackagePaymentConfig>()
@@ -755,6 +764,10 @@
            if(null == userIdFormRedis){
                return ResultUtil.tokenErr();
            }
            Integer couponId = request.getConponId();
            if(couponId==null || couponId==0){
                request.setConponId(null);
            }
            return packagePaymentService.ContinuationOrpaymentCourse(userIdFormRedis,request);
        }catch (Exception e){
            return ResultUtil.runErr();
@@ -1027,6 +1040,11 @@
                .eq("code",code));
    }
    @PostMapping("/base/coursePack/getCoursePackagePaymentById")
    public TCoursePackagePayment getCoursePackagePaymentById(@RequestBody Integer id){
        return packagePaymentService.getById(id);
    }
    @PostMapping("/base/coursePack/delPaymentCoursePackage")
    public boolean delPaymentCoursePackage(@RequestBody Integer payId){
        return packagePaymentService.removeById(payId);
@@ -1084,11 +1102,17 @@
    // 2.0 送课时
    @PostMapping("/base/coursePack/sendHours")
    public Boolean sendHours(@RequestBody  String s){
    public Integer sendHours(@RequestBody  String s){
        String[] split = s.split("_");
        TCoursePackagePayment byId = packagePaymentService.getById(Integer.valueOf(split[0]));
        TCoursePackagePayment byId = packagePaymentService.getById(Long.valueOf(split[0]));
        byId.setTotalClassHours(byId.getTotalClassHours()+Integer.valueOf(split[2]));
        return packagePaymentService.updateById(byId);
        boolean b = packagePaymentService.updateHoursById(byId,Integer.valueOf(split[2]));
        if(b){
            return 1;
        }else {
            return 0;
        }
    }
@@ -1143,6 +1167,16 @@
    }
    @ResponseBody
    @PostMapping("/coursePackagePayment/CountqueryByClassId")
   public   Integer  CountqueryByClassId(@RequestBody Integer id){
        int coursePackageId = packagePaymentService.count(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", id));
        return coursePackageId;
    }
    /**
     * 修改数据
     * @param coursePackagePayment
@@ -1173,28 +1207,27 @@
            if(null == appUserId){
                return ResultUtil.tokenErr();
            }
            TCoursePackagePayment packagePayment = packagePaymentService.getOne(new LambdaQueryWrapper<TCoursePackagePayment>()
            List<TCoursePackagePayment> packagePayment = packagePaymentService.list(new LambdaQueryWrapper<TCoursePackagePayment>()
                    .eq(TCoursePackagePayment::getCoursePackageId,courseID )
                    .eq(TCoursePackagePayment::getAppUserId,appUserId)
                    .eq(TCoursePackagePayment::getStudentId,stuId)
            );
            if (ToolUtil.isEmpty(packagePayment)){
            if (ToolUtil.isEmpty(packagePayment) || packagePayment.size()==0){
                return ResultUtil.error("该用户未购买该课包");
            }
            List<CoursePackageStudent> coursePackageStudent = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>()
                    .eq(CoursePackageStudent::getCoursePackageId,packagePayment.getCoursePackageId())
                    .eq(CoursePackageStudent::getCoursePackagePaymentId,courseID)
                    .in(CoursePackageStudent::getCoursePackagePaymentId,packagePayment.stream().map(TCoursePackagePayment::getId).collect(Collectors.toList()))
                    .eq(CoursePackageStudent::getCoursePackageId,courseID)
                    .eq(CoursePackageStudent::getStudentId,stuId)
                    .eq(CoursePackageStudent::getAppUserId,appUserId)
            );
            if (ToolUtil.isNotEmpty(coursePackageStudent)){
                for (CoursePackageStudent packageStudent : coursePackageStudent) {
                    if(packageStudent.getReservationStatus()==0){
                    if(packageStudent.getReservationStatus()==1){
                        packageStudent.setSignInOrNot(2);
                        packageStudent.setInsertTime(simpleDateFormat.parse(time));
                        cspsService.updateById(packageStudent);
                        cspsService.updateSignInOrNotById(packageStudent.getId());
                    }
                }
@@ -1227,6 +1260,8 @@
            map.put("lon",lon);
            map.put("lat",lat);
            String time1 = courseDetailReq.getTime();
            // 找出门店的所有课程 排出体验
            List<TCoursePackage> list = tcpService.list(new LambdaQueryWrapper<TCoursePackage>().eq(TCoursePackage::getStoreId, courseDetailReq.getStoreId()).ne(TCoursePackage::getType, 3).like(TCoursePackage::getClassWeeks,week));
            List<Integer> collect = list.stream().map(TCoursePackage::getId).collect(Collectors.toList());
@@ -1236,6 +1271,7 @@
            // 找出购买的课包
            List<TCoursePackagePayment> list1 = packagePaymentService.list(new LambdaQueryWrapper<TCoursePackagePayment>().eq(TCoursePackagePayment::getAppUserId, courseDetailReq.getAppUserId()).eq(TCoursePackagePayment::getStudentId, courseDetailReq.getStuId()).in(TCoursePackagePayment::getCoursePackageId, collect));
            List<Integer> collect1 = list1.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList());
            List<Long> ids = list1.stream().map(TCoursePackagePayment::getId).collect(Collectors.toList());
            for (TCoursePackage tCoursePackage : list) {
                DetailsListVo detailsListVo = new DetailsListVo();
                detailsListVo.setId(tCoursePackage.getId());
@@ -1257,7 +1293,30 @@
                }
                detailsListVo.setNum(tCoursePackage.getNeedNum());
                if (collect1.contains(tCoursePackage.getId())) {
                    detailsListVo.setType(1);
                    // 找出排课记录
                    List<CoursePackageScheduling> list3 = coursePackageSchedulingMapper.selectList(new LambdaQueryWrapper<CoursePackageScheduling>()
                            .eq(CoursePackageScheduling::getCoursePackageId, tCoursePackage.getId())
                            .like(CoursePackageScheduling::getClassDate, courseDetailReq.getTime())
                    );
                    List<Long> collect2 = list3.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList());
                    if(collect2.size()==0){
                        collect2.add(-1l);
                    }
                    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)
                    );
                        detailsListVo.setType(1);
                    if(list4.size()>0){
                        Integer signInOrNot = list4.get(0).getSignInOrNot();
                        if(signInOrNot==2){
                            detailsListVo.setType(3);
                        }
                    }
                } else {
                    detailsListVo.setType(2);
                }