From cec511e4a14931ed67d09292fbbb01fe5126e5cf Mon Sep 17 00:00:00 2001
From: lisy <linlangsur163@163.com>
Date: 星期一, 07 八月 2023 18:59:28 +0800
Subject: [PATCH] app端:优惠券的规则字段处理
---
cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java | 136 ++++++++++++++++++++++++++++++++++++---------
1 files changed, 109 insertions(+), 27 deletions(-)
diff --git a/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java b/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
index 25393f0..8470385 100644
--- a/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
+++ b/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
@@ -1,6 +1,7 @@
package com.dsh.course.controller;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.course.entity.*;
import com.dsh.course.feignclient.account.AppUserClient;
@@ -85,6 +86,10 @@
@Autowired
private CancelledClassesService cancelledClassesService;
+ @Resource
+ private CoursePackageStudentService cspsService;
+
+
@Autowired
private PayMoneyUtil payMoneyUtil;
@Resource
@@ -146,28 +151,37 @@
.groupBy("coursePackageId"));
if (list.size() > 0){
for (TCoursePackagePayment tCoursePackagePayment : list) {
- TCoursePackage tCoursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId());
- CoursePackagePaymentConfig paymentConfig = icppcService.getOne(new QueryWrapper<CoursePackagePaymentConfig>()
- .eq("coursePackageId",tCoursePackage.getId() )
- .eq("classHours",tCoursePackagePayment.getClassHours()));
+ CoursePackageStudent packageStudent = cspsService.getOne(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)){
+// 没有预约过的/已经取消了的
+ TCoursePackage tCoursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId());
+ CoursePackagePaymentConfig paymentConfig = icppcService.getOne(new QueryWrapper<CoursePackagePaymentConfig>()
+ .eq("coursePackageId",tCoursePackage.getId() )
+ .eq("classHours",tCoursePackagePayment.getClassHours()));
// 获取课程有效结束时间,判断 查询的日期parse 是否在有效期范围内
- Date expirationDate = DateTimeHelper.getExpirationDate(tCoursePackagePayment.getInsertTime(),tCoursePackage.getValidDays());
- System.out.println(expirationDate.after(parse));
- String classWeeks = tCoursePackage.getClassWeeks();
- System.out.println(StrUtils.dealStrToList(classWeeks).contains(DateTimeHelper.getDayOfWeek(parse)));
- if (expirationDate.after(parse) && StrUtils.dealStrToList(classWeeks).contains(DateTimeHelper.getDayOfWeek(parse))){
- CourseOfStoreVo storeVo = new CourseOfStoreVo();
- storeVo.setCourseId(tCoursePackage.getId());
- storeVo.setCourseName(tCoursePackage.getName());
- storeVo.setClassStartTime(tCoursePackage.getClassStartTime());
- storeVo.setClassEndTime(tCoursePackage.getClassEndTime());
- storeVo.setStoreId(tCoursePackage.getStoreId());
- Store store = sreClient.queryStoreById(tCoursePackage.getStoreId());
- storeVo.setStoreAddress(store.getAddress());
- storeVo.setLat(store.getLat());
- storeVo.setLon(store.getLon());
- storeVo.setCoursePrice(ToolUtil.isEmpty(paymentConfig.getCashPayment()) ? (double) paymentConfig.getPlayPaiCoin():paymentConfig.getCashPayment());
- course.add(storeVo);
+ Date expirationDate = DateTimeHelper.getExpirationDate(tCoursePackagePayment.getInsertTime(),tCoursePackage.getValidDays());
+ System.out.println(expirationDate.after(parse));
+ String classWeeks = tCoursePackage.getClassWeeks();
+ System.out.println(StrUtils.dealStrToList(classWeeks).contains(DateTimeHelper.getDayOfWeek(parse)));
+ if (expirationDate.after(parse) && StrUtils.dealStrToList(classWeeks).contains(DateTimeHelper.getDayOfWeek(parse))){
+ CourseOfStoreVo storeVo = new CourseOfStoreVo();
+ storeVo.setCourseId(tCoursePackagePayment.getId());
+ storeVo.setCourseName(tCoursePackage.getName());
+ storeVo.setClassStartTime(tCoursePackage.getClassStartTime());
+ storeVo.setClassEndTime(tCoursePackage.getClassEndTime());
+ storeVo.setStoreId(tCoursePackage.getStoreId());
+ Store store = sreClient.queryStoreById(tCoursePackage.getStoreId());
+ storeVo.setStoreAddress(store.getAddress());
+ storeVo.setLat(store.getLat());
+ storeVo.setLon(store.getLon());
+ storeVo.setCoursePrice(ToolUtil.isEmpty(paymentConfig.getCashPayment()) ? (double) paymentConfig.getPlayPaiCoin():paymentConfig.getCashPayment());
+ storeVo.setStatus(1);
+ course.add(storeVo);
+ }
}
}
}
@@ -349,12 +363,24 @@
}
@PostMapping("/base/coursePack/allPaymentCourseList")
- public List<TCoursePackagePayment> getAppuserCourseList(@RequestBody Integer appUserId){
- return packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>()
- .eq("appUserId",appUserId)
- .eq("payType",3)
- .eq("payStatus",2)
- .eq("state",1));
+ @ResponseBody
+ public List<CouponPaymentVo> getAppuserCourseList(@RequestBody Integer appUserId){
+ List<CouponPaymentVo> paymentVos = new ArrayList<>();
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm");
+ List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>()
+ .eq("appUserId", appUserId)
+ .eq("payType", 3)
+ .eq("payStatus", 2)
+ .eq("state", 1));
+ if (list.size() > 0 ){
+ for (TCoursePackagePayment tCoursePackagePayment : list) {
+ CouponPaymentVo couponPaymentVo = new CouponPaymentVo();
+ couponPaymentVo.setTime(simpleDateFormat.format(tCoursePackagePayment.getInsertTime()));
+ couponPaymentVo.setAmount( tCoursePackagePayment.getPlayPaiCoin());
+ paymentVos.add(couponPaymentVo);
+ }
+ }
+ return paymentVos;
}
@PostMapping("/base/coursePack/allAmountPayRecordOfUser")
@@ -790,4 +816,60 @@
.eq("code",code));
}
+
+
+ /**
+ * 上课主页-预约操作
+ */
+ @ResponseBody
+ @PostMapping("/api/startCource/reverse")
+ @ApiOperation(value = "上课主页-预约操作", tags = {"APP-开始上课"})
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
+ @ApiImplicitParam(value = "课包id", name = "courseID", required = true, dataType = "String"),
+ @ApiImplicitParam(value = "时间 yyyy-MM-dd", name = "time", required = true, dataType = "String"),
+ @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"),
+ })
+ public ResultUtil reverse(String courseID,String time,Integer stuId){
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ try {
+ Integer appUserId = tokenUtil.getUserIdFormRedis();
+ if(null == appUserId){
+ return ResultUtil.tokenErr();
+ }
+ TCoursePackagePayment packagePayment = packagePaymentService.getOne(new LambdaQueryWrapper<TCoursePackagePayment>()
+ .eq(TCoursePackagePayment::getId,courseID )
+ .eq(TCoursePackagePayment::getAppUserId,appUserId)
+ .eq(TCoursePackagePayment::getStudentId,stuId)
+ );
+
+ if (ToolUtil.isEmpty(packagePayment)){
+ return ResultUtil.error("该用户未购买该课包");
+ }
+ CoursePackageStudent coursePackageStudent = cspsService.getOne(new LambdaQueryWrapper<CoursePackageStudent>()
+ .eq(CoursePackageStudent::getCoursePackageId,packagePayment.getCoursePackageId())
+ .eq(CoursePackageStudent::getCoursePackagePaymentId,courseID)
+ .eq(CoursePackageStudent::getStudentId,stuId)
+ .eq(CoursePackageStudent::getAppUserId,appUserId)
+ );
+
+ if (ToolUtil.isNotEmpty(coursePackageStudent) && coursePackageStudent.getReservationStatus() == 0){
+ coursePackageStudent.setReservationStatus(1);
+ coursePackageStudent.setInsertTime(simpleDateFormat.parse(time));
+ cspsService.updateById(coursePackageStudent);
+ }else {
+ coursePackageStudent.setAppUserId(appUserId);
+ coursePackageStudent.setStudentId(stuId);
+ coursePackageStudent.setCoursePackageId(packagePayment.getCoursePackageId());
+ coursePackageStudent.setCoursePackagePaymentId(Long.parseLong(courseID));
+ coursePackageStudent.setReservationStatus(1);
+ coursePackageStudent.setInsertTime(simpleDateFormat.parse(time));
+ cspsService.save(coursePackageStudent);
+ }
+ return ResultUtil.success();
+ }catch (Exception e){
+ return ResultUtil.runErr();
+ }
+ }
+
}
--
Gitblit v1.7.1