zjk
2026-09-29 54dcf0a82e7490fa58b1c056d5c0b9cb739c2931
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
67
68
69
package com.tcm.training.admin.app.member.controller;
 
import com.tcm.training.admin.app.member.dto.AppMemberPurchaseRequest;
import com.tcm.training.admin.app.member.service.AppMemberPurchaseService;
import com.tcm.training.admin.app.member.service.AppMemberOpenPageService;
import com.tcm.training.admin.app.member.vo.AppMemberPurchaseOrderItemVO;
import com.tcm.training.admin.app.member.vo.AppMemberOpenPageVO;
import com.tcm.training.admin.app.member.vo.AppMemberPurchaseResultVO;
import com.tcm.training.admin.common.ApiResponse;
import com.tcm.training.admin.common.PageResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import javax.validation.Valid;
 
/**
 * APP 会员开通页接口。
 */
@Validated
@RestController
@RequestMapping({"/api/app/member", "/api/v1/app/member"})
public class AppMemberOpenPageController {
 
    private final AppMemberOpenPageService appMemberOpenPageService;
    private final AppMemberPurchaseService appMemberPurchaseService;
    private final com.tcm.training.admin.member.service.MemberPurchaseOrderAppService memberPurchaseOrderAppService;
 
    /**
     * 注入 APP 会员开通页服务。
     */
    public AppMemberOpenPageController(AppMemberOpenPageService appMemberOpenPageService,
                                       AppMemberPurchaseService appMemberPurchaseService,
                                       com.tcm.training.admin.member.service.MemberPurchaseOrderAppService memberPurchaseOrderAppService) {
        this.appMemberOpenPageService = appMemberOpenPageService;
        this.appMemberPurchaseService = appMemberPurchaseService;
        this.memberPurchaseOrderAppService = memberPurchaseOrderAppService;
    }
 
    /**
     * 获取 APP 会员开通页聚合数据。
     */
    @GetMapping("/open-page")
    public ApiResponse<AppMemberOpenPageVO> getOpenPage() {
        return ApiResponse.ok(appMemberOpenPageService.getOpenPage());
    }
 
    /**
     * 提交 APP 会员购买。
     */
    @PostMapping("/purchase")
    public ApiResponse<AppMemberPurchaseResultVO> purchase(@Valid @RequestBody AppMemberPurchaseRequest request) {
        return ApiResponse.ok(appMemberPurchaseService.purchase(request));
    }
 
    /**
     * 获取当前登录用户的会员购买记录。
     */
    @GetMapping("/purchase-orders")
    public ApiResponse<PageResponse<AppMemberPurchaseOrderItemVO>> purchaseOrders(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "20") int pageSize) {
        return ApiResponse.ok(memberPurchaseOrderAppService.appUserPage(page, pageSize));
    }
}