puzhibing
2023-07-06 c0f6294b0be6789fddd652f89f820fcf6d5526cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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.PurchaseRecordVo;
import com.dsh.course.service.CancelledClassesService;
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.Date;
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 stuId 学员id
     * @param appUserId 用户id
     * @return
     */
    @PostMapping("/base/cancelSource/cancelList")
    public List<PurchaseRecordVo> getCancelCourseList(@RequestParam("startTime") Date startTime, @RequestParam("endTime") Date  endTime, @RequestParam("stuId") Integer stuId, @RequestParam("appUserId") Integer appUserId){
        List<PurchaseRecordVo> purchaseRecordVos = new ArrayList<>();
 
        List<TCoursePackagePayment> tCoursePackagePayments = tcppService.queryAllCoursePackage(startTime,endTime,null,stuId, appUserId);
        List<Long> coursePackageIds = tCoursePackagePayments.stream().map(TCoursePackagePayment::getId).collect(Collectors.toList());
 
        List<CancelledClasses> list = caceService.list(new QueryWrapper<CancelledClasses>()
                .in("coursePackageId", coursePackageIds)
                .between("insertTime",startTime,endTime));
        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;
    }
 
 
}