| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.model.BalanceChangeRecord; |
| | | import com.ruoyi.account.dto.BalanceQuery; |
| | | import com.ruoyi.account.service.BalanceChangeRecordService; |
| | | import com.ruoyi.account.vo.CommissionStatistics; |
| | | import com.ruoyi.account.vo.WalletStatistics; |
| | | import com.ruoyi.account.vo.WalletStatisticsDetail; |
| | | import com.ruoyi.common.core.domain.R; |
| | | 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.ruoyi.common.core.utils.poi.ExcelUtil; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | @RestController |
| | | @RequestMapping("/balanceChangeRecord") |
| | | public class BalanceChangeRecordController { |
| | | |
| | | @Resource |
| | | private BalanceChangeRecordService balanceChangeRecordService; |
| | | |
| | | |
| | | /** |
| | | * 保存账户流水记录 |
| | | * @param balanceChangeRecord |
| | | * @return |
| | | */ |
| | | @PostMapping("/saveBalanceChangeRecord") |
| | | public R saveBalanceChangeRecord(@RequestBody BalanceChangeRecord balanceChangeRecord){ |
| | | balanceChangeRecordService.save(balanceChangeRecord); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private BalanceChangeRecordService balanceChangeRecordService; |
| | | |
| | | |
| | | /** |
| | | * 保存账户流水记录 |
| | | * |
| | | * @param balanceChangeRecord |
| | | * @return |
| | | */ |
| | | @PostMapping("/saveBalanceChangeRecord") |
| | | public R saveBalanceChangeRecord(@RequestBody BalanceChangeRecord balanceChangeRecord) { |
| | | balanceChangeRecordService.save(balanceChangeRecord); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/page") |
| | | @ApiOperation(value = "余额变更明细", tags = {"后台"}) |
| | | public R<IPage<BalanceChangeRecord>> page(@RequestBody BalanceQuery agentQuery) { |
| | | |
| | | IPage<BalanceChangeRecord> page = balanceChangeRecordService.pageList(agentQuery); |
| | | for (BalanceChangeRecord record : page.getRecords()) { |
| | | if (record.getChangeDirection() == -1){ |
| | | record.setFlag(2); |
| | | }else { |
| | | record.setFlag(1); |
| | | } |
| | | } |
| | | return R.ok(page); |
| | | } |
| | | |
| | | /** |
| | | * 用户分佣统计 |
| | | */ |
| | | @GetMapping("/commissionStatistics") |
| | | @ApiOperation(value = "用户分佣统计", tags = "管理后台-财务统计-用户分佣统计") |
| | | public R<CommissionStatistics> commissionStatistics(@ApiParam("页码") @RequestParam Integer pageNum, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | BalanceChangeRecord balanceChangeRecord) { |
| | | CommissionStatistics commissionStatistics1 = balanceChangeRecordService.commissionStatistics(Page.of(pageNum, pageSize), balanceChangeRecord); |
| | | return R.ok(commissionStatistics1); |
| | | } |
| | | |
| | | // |
| | | // /** |
| | | // * 导出用户分佣统计 |
| | | // */ |
| | | @GetMapping("/commissionExport") |
| | | @ApiOperation(value = "用户分佣统计导出", tags = "管理后台-财务统计-用户分佣统计") |
| | | public void commissionExport(HttpServletResponse response, BalanceChangeRecord balanceChangeRecord) { |
| | | CommissionStatistics commissionStatistics1 = balanceChangeRecordService.commissionStatistics(Page.of(1, Integer.MAX_VALUE), balanceChangeRecord); |
| | | IPage<BalanceChangeRecord> userPointPage = commissionStatistics1.getUserPointPage(); |
| | | List<BalanceChangeRecord> userPointList = userPointPage.getRecords(); |
| | | ExcelUtil<BalanceChangeRecord> util = new ExcelUtil<>(BalanceChangeRecord.class); |
| | | util.exportExcel(response, userPointList, "用户分佣统计"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 钱包统计 |
| | | */ |
| | | @GetMapping("/walletStatistics") |
| | | @ApiOperation(value = "钱包统计", tags = "管理后台-财务统计-钱包统计") |
| | | public R<WalletStatistics> walletStatistics(@ApiParam("页码") @RequestParam Integer pageNum, |
| | | @ApiParam("每一页数据大小") Integer pageSize, |
| | | BalanceChangeRecord balanceChangeRecord) { |
| | | WalletStatistics walletStatistics = balanceChangeRecordService.walletStatistics(Page.of(pageNum, pageSize), balanceChangeRecord); |
| | | return R.ok(walletStatistics); |
| | | } |
| | | |
| | | /** |
| | | * 钱包统计导出 |
| | | */ |
| | | @GetMapping("/walletExport") |
| | | @ApiOperation(value = "钱包统计导出", tags = "管理后台-财务统计-钱包统计") |
| | | public void walletExport(HttpServletResponse response, BalanceChangeRecord balanceChangeRecord) { |
| | | WalletStatistics walletStatistics = balanceChangeRecordService.walletStatistics(Page.of(1, Integer.MAX_VALUE), balanceChangeRecord); |
| | | IPage<WalletStatisticsDetail> userPointPage = walletStatistics.getPage(); |
| | | List<WalletStatisticsDetail> userPointList = userPointPage.getRecords(); |
| | | ExcelUtil<WalletStatisticsDetail> util = new ExcelUtil<>(WalletStatisticsDetail.class); |
| | | util.exportExcel(response, userPointList, "钱包统计"); |
| | | } |
| | | |
| | | } |