mitao
2025-05-20 179c4d64313c9b7572778da4aaaf6c6584fe457d
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/WalletApi.java
New file
@@ -0,0 +1,74 @@
package com.panzhihua.applets.api;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.dtos.community.wallet.ComActWalletDetailDTO;
import com.panzhihua.common.model.dtos.community.wallet.PageComActWalletTradeDTO;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.wallet.ComActWalletRankingVO;
import com.panzhihua.common.model.vos.community.wallet.ComActWalletTradeVO;
import com.panzhihua.common.model.vos.community.wallet.ComActWalletVO;
import com.panzhihua.common.service.community.CommunityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/wallet/")
@Api(tags = {"钱包模块"})
public class WalletApi extends BaseController {
    @Resource
    private CommunityService communityService;
    @ApiOperation(value = "查询我的钱包", response = ComActWalletVO.class)
    @PostMapping("/get/my")
    public R getWallet() {
        ComActWalletDetailDTO walletDetailDTO = new ComActWalletDetailDTO();
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        if (loginUserInfo == null) {
            return R.fail("请先登录");
        }
        walletDetailDTO.setUserId(loginUserInfo.getUserId());
        Long communityId = loginUserInfo.getCommunityId();
        if (null == communityId || 0 == communityId) {
            return R.fail("用户未绑定社区");
        }
        walletDetailDTO.setCommunityId(communityId);
        return communityService.getUserWalletDetail(walletDetailDTO);
    }
    @ApiOperation(value = "查询我的收支记录", response = ComActWalletTradeVO.class)
    @PostMapping("/get/trade")
    public R getWalletTrade(@RequestBody PageComActWalletTradeDTO walletTradeDTO) {
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        if (loginUserInfo == null) {
            return R.fail("请先登录");
        }
        walletTradeDTO.setUserId(loginUserInfo.getUserId());
        Long communityId = loginUserInfo.getCommunityId();
        if (null == communityId || 0 == communityId) {
            return R.fail("用户未绑定社区");
        }
        walletTradeDTO.setCommunityId(communityId);
        return communityService.getUserWalletTrade(walletTradeDTO);
    }
    @ApiOperation(value = "查询收益排行榜", response = ComActWalletRankingVO.class)
    @PostMapping("/get/ranking")
    public R getWalletRanking(@RequestBody PageComActWalletTradeDTO walletTradeDTO) {
        Long communityId = this.getCommunityId();
        if (null == communityId || 0 == communityId) {
            return R.fail("用户未绑定社区");
        }
        walletTradeDTO.setCommunityId(communityId);
        return communityService.getWalletRanking(walletTradeDTO);
    }
}