package com.dsh.course.controller;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.dsh.course.entity.CancelledClasses;
|
import com.dsh.course.entity.TCoursePackagePayment;
|
import com.dsh.course.feignclient.model.GetStuSessionList;
|
import com.dsh.course.feignclient.model.PurchaseRecordVo;
|
import com.dsh.course.service.CancelledClassesService;
|
import com.dsh.course.service.CourseCounsumService;
|
import com.dsh.course.service.TCoursePackagePaymentService;
|
import io.swagger.annotations.Api;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.text.SimpleDateFormat;
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
@Api
|
@CrossOrigin
|
@RestController
|
@RequestMapping("")
|
public class CancelSourceController {
|
|
@Autowired
|
private CancelledClassesService caceService;
|
|
|
@Autowired
|
private TCoursePackagePaymentService tcppService;
|
|
private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
|
|
|
/**
|
* 获取课包对应的消费记录
|
*
|
* @param sessionList
|
* @return
|
*/
|
@PostMapping("/base/cancelSource/cancelList")
|
public List<PurchaseRecordVo> getCancelCourseList(@RequestBody GetStuSessionList sessionList) {
|
List<PurchaseRecordVo> purchaseRecordVos = new ArrayList<>();
|
List<TCoursePackagePayment> tCoursePackagePayments = tcppService.list(new QueryWrapper<TCoursePackagePayment>()
|
.between("insertTime", sessionList.getStartTime(), sessionList.getEndTime())
|
.eq("appUserId", sessionList.getAppUserId())
|
.eq("studentId", sessionList.getStuId()));
|
if (tCoursePackagePayments.size() > 0) {
|
List<Long> coursePackageIds = tCoursePackagePayments.stream().map(TCoursePackagePayment::getId).collect(Collectors.toList());
|
|
List<CancelledClasses> list = caceService.list(new QueryWrapper<CancelledClasses>()
|
.in("coursePackageId", coursePackageIds)
|
.between("insertTime", sessionList.getStartTime(), sessionList.getEndTime()));
|
if (list.size() > 0) {
|
list.forEach(canse -> {
|
PurchaseRecordVo purchaseRecordVo = new PurchaseRecordVo();
|
purchaseRecordVo.setPurchaseTime(format.format(canse.getInsertTime()));
|
purchaseRecordVo.setPurchaseType("");
|
purchaseRecordVo.setPurchaseAmount("-" + canse.getCancelledClassesNumber());
|
purchaseRecordVos.add(purchaseRecordVo);
|
});
|
}
|
}
|
return purchaseRecordVos;
|
}
|
|
|
}
|