基于mall4j产品的二开项目后端
lee
2024-12-18 921461a3f906d74403aeb6a27051deb77eca10fc
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.yami.shop.api.controller.cdn;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yami.shop.bean.model.CdnUserWallet;
import com.yami.shop.bean.param.CdnNodeInfoParam;
import com.yami.shop.bean.param.CdnWalletInfoParam;
import com.yami.shop.bean.param.MyCdnTeamParam;
import com.yami.shop.common.enums.WalletEnum;
import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.security.api.util.SecurityUtils;
import com.yami.shop.service.CdnBindService;
import com.yami.shop.service.CdnTeamRelationService;
import com.yami.shop.service.CdnUserWalletService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
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 java.math.BigDecimal;
 
@RestController
@RequestMapping("/p/cdn/index")
@Tag(name = "Cdn个人中心相关接口")
public class CdnIndexController {
    @Autowired
    private CdnTeamRelationService cdnTeamRelationService;
 
    @Autowired
    private CdnUserWalletService cdnUserWalletService;
 
    @Autowired
    private CdnBindService cdnBindService;
 
    @GetMapping("/myTeam")
    @Operation(summary = "我的团队", description = "我的团队")
    @Parameters({
            @Parameter(name = "userId",description = "用户id"),
            @Parameter(name = "pattern", description = "模式 0托管 1自主")
    })
    public ServerResponseEntity<MyCdnTeamParam> getMyTeam(@RequestParam(name = "userId") String userId){
        // 直推人数: 统计 pid = userId 的用户
        // 团队人数:统计 pids 包含 userId 的用户
        // 个人设备:统计个人设备数
        // 团队设备:统计团队设备数
        // 姓名,账号,等级,注册时间:在 user 表查询
        // 团队设备:pids 包含 userId 的用户设备
        MyCdnTeamParam myCdnTeamParam = cdnTeamRelationService.getMyCdnTeamInfo(userId);
        return ServerResponseEntity.success(myCdnTeamParam);
    }
 
    /**
     * 团队列表展示接口
     */
 
 
    /**
     * 个人中心展示数据
     */
    @GetMapping("/getWalletInfo")
    @Operation(summary = "获取个人中心钱包展示数据", description = "获取个人中心钱包展示数据")
    @Parameters({
            @Parameter(name = "userId",description = "用户id")
    })
    public ServerResponseEntity<CdnWalletInfoParam> getWalletInfo(){
        String userId = SecurityUtils.getUser().getUserId();
        // 查询钱包币种数额
        CdnWalletInfoParam cdnWalletInfoParam = new CdnWalletInfoParam();
        // 根据币种查询钱包相关币种余额
        CdnUserWallet flow = cdnUserWalletService.getOne(Wrappers.lambdaQuery(CdnUserWallet.class)
                .eq(CdnUserWallet::getUserId, userId)
                .eq(CdnUserWallet::getWalletId, WalletEnum.FLOW.value()));
        CdnUserWallet goldCowBean = cdnUserWalletService.getOne(Wrappers.lambdaQuery(CdnUserWallet.class)
                .eq(CdnUserWallet::getUserId,userId)
                .eq(CdnUserWallet::getWalletId, WalletEnum.GOLDCOWBEAN.value()));
        CdnUserWallet luckPool = cdnUserWalletService.getOne(Wrappers.lambdaQuery(CdnUserWallet.class)
                .eq(CdnUserWallet::getUserId,userId)
                .eq(CdnUserWallet::getWalletId, WalletEnum.LUCKPOOL.value()));
        CdnUserWallet integral = cdnUserWalletService.getOne(Wrappers.lambdaQuery(CdnUserWallet.class)
                .eq(CdnUserWallet::getUserId,userId)
                .eq(CdnUserWallet::getWalletId, WalletEnum.INTEGRAL.value()));
        CdnUserWallet credit = cdnUserWalletService.getWalletByUserId(userId,WalletEnum.CREDIT.value());
        CdnUserWallet alloy = cdnUserWalletService.getWalletByUserId(userId,WalletEnum.ALLOY.value());
        BigDecimal b = new BigDecimal(0);
        cdnWalletInfoParam.setFlow(flow != null ? flow.getMoney() : b);
        cdnWalletInfoParam.setGoldCowBean(goldCowBean != null ? goldCowBean.getMoney() : b);
        cdnWalletInfoParam.setLuckPool(luckPool != null ? luckPool.getMoney() : b);
        cdnWalletInfoParam.setIntegral(integral != null ? integral.getMoney() : b);
        cdnWalletInfoParam.setCredit(credit != null ? credit.getMoney() : b);
        cdnWalletInfoParam.setAlloy(alloy != null ? alloy.getMoney() : b);
        return ServerResponseEntity.success(cdnWalletInfoParam);
    }
    @GetMapping("/getNodeInfo")
    @Operation(summary = "获取节点建设进度数据", description = "获取节点建设进度数据")
    @Parameters({
            @Parameter(name = "userId",description = "用户id"),
    })
    public ServerResponseEntity<CdnNodeInfoParam> getNodeInfo(@RequestParam(name = "userId") String userId){
        return ServerResponseEntity.success(cdnBindService.getNodeInfo(userId));
    }
 
}