From 67f416634f95c81e618123b826e18a57ae08220d Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 22 四月 2025 17:55:30 +0800 Subject: [PATCH] 11.6 --- ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/WithdrawController.java | 121 +++++++++++++++++++++++++--------------- 1 files changed, 76 insertions(+), 45 deletions(-) diff --git a/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/WithdrawController.java b/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/WithdrawController.java index ee5a35a..264301d 100644 --- a/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/WithdrawController.java +++ b/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/WithdrawController.java @@ -1,19 +1,20 @@ package com.ruoyi.admin.controller; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.ruoyi.admin.entity.Order; +import com.ruoyi.admin.entity.Franchisee; import com.ruoyi.admin.entity.User; -import com.ruoyi.admin.entity.Withdraw; -import com.ruoyi.admin.request.WithdrawExportRequest; -import com.ruoyi.admin.service.OrderService; +import com.ruoyi.admin.service.FranchiseeService; import com.ruoyi.admin.service.UserService; import com.ruoyi.admin.service.WithdrawService; -import com.ruoyi.admin.vo.UserWithdrawRecordVO; -import com.ruoyi.common.core.constant.Constants; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.GlobalException; +import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.order.api.entity.UserWithdrawRecordVO; +import com.ruoyi.order.api.entity.Withdraw; +import com.ruoyi.order.api.entity.WithdrawExportRequest; +import com.ruoyi.order.api.feignClient.WithdrawClient; +import com.ruoyi.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -22,6 +23,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import java.lang.reflect.Array; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -42,10 +44,14 @@ @Resource private WithdrawService withdrawService; @Resource - private OrderService orderService; + private WithdrawClient withdrawClient; @Resource private UserService userService; + @Resource + private TokenService tokenService; + @Resource + private FranchiseeService franchiseeService; /** * 用户所关联提现记录分页列表 * @@ -63,11 +69,48 @@ @ApiImplicitParam(value = "页码", name = "pageNum", dataType = "Integer", required = true), @ApiImplicitParam(value = "每页条数", name = "pageSize", dataType = "Integer", required = true) }) - public R<IPage<UserWithdrawRecordVO>> withdrawPage(String nickname, String userPhone, - String applyForTime, Integer state, - @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, - @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { - return R.ok(withdrawService.withdrawPage(nickname, userPhone, applyForTime, state, Page.of(pageNum, pageSize))); + public R<Page<UserWithdrawRecordVO>> withdrawPage(String nickname, String userPhone, + String applyForTime, Integer state, + @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { + + List<Integer> userIds = userService.lambdaQuery().like(User::getNickname, nickname).list().stream().map(User::getId).collect(Collectors.toList()); + if (nickname!=null&&nickname!="") { + if (userIds.isEmpty()) { + return R.ok(new Page<UserWithdrawRecordVO>()); + } + } + LoginUser loginUser = tokenService.getLoginUser(); + List<String> cityList = loginUser.getCityList(); + + + Integer franchiseeId = loginUser.getSysUser().getFranchiseeId(); + String[] siteIds = new String[0]; + if (franchiseeId!=null){ + Franchisee byId = franchiseeService.getById(franchiseeId); + siteIds = byId.getSiteIds().split(","); + if (loginUser.getIsFranchisee()&&siteIds.length==0){ + return R.ok(); + } + } + + + Page<UserWithdrawRecordVO> page = withdrawClient.withdrawPage1(cityList,nickname, userPhone, applyForTime, + state, pageNum, pageSize,userIds, Arrays.asList(siteIds)).getData(); + if (null != page) { + for (UserWithdrawRecordVO record : page.getRecords()) { + Integer userId = record.getUserId(); + User user = userService.lambdaQuery() + .eq(User::getId, userId) + .eq(User::getIsDelete, 0).one(); + if (null != user) { + record.setUserNo(user.getUserNo()); + record.setNickname(user.getNickname()); + record.setProfilePicture(user.getProfilePicture()); + } + } + } + return R.ok(page); } /** @@ -80,10 +123,8 @@ @ApiImplicitParams({ @ApiImplicitParam(value = "提现记录id", name = "id", dataType = "Integer", required = true) }) - public R<Withdraw> withdrawRecordDetail(@RequestParam Integer id) { - Withdraw withdraw = withdrawService.lambdaQuery().eq(Withdraw::getId, id) - .eq(Withdraw::getIsDelete, 0).one(); - return R.ok(withdraw); + public R<Withdraw> withdrawRecordDetail(@RequestParam Long id) { + return withdrawClient.withdrawRecordDetail(id); } /** @@ -100,32 +141,23 @@ @ApiImplicitParam(value = "审批意见", name = "opinion", dataType = "String"), @ApiImplicitParam(value = "审批同意/不同意(1同意;2驳回)", name = "state", dataType = "Integer", required = true) }) - public R<String> withdrawExamine(@RequestParam Integer id, @RequestParam Integer state, String opinion) { - Withdraw withdraw = withdrawService.lambdaQuery().eq(Withdraw::getId, id).eq(Withdraw::getIsDelete, 0) - .eq(Withdraw::getState, 0).one(); + public R<String> withdrawExamine(@RequestParam Long id, @RequestParam Integer state, String opinion) { + Withdraw withdraw = withdrawClient.withdrawRecordDetail(id).getData(); if (null == withdraw) { - return R.fail(503, "当前提现记录审批状态异常!"); + throw new GlobalException("提现记录不存在或已删除!"); } - // 修改审批状态及审批意见 - withdraw.setState(state); - withdraw.setOpinion(opinion); - // 同意提现申请,更改订单提现状态 - boolean update = true; - if (Constants.ONE.equals(state)) { - update = orderService.lambdaUpdate().set(Order::getIsWithdrawal, Constants.ONE) - .eq(Order::getId, withdraw.getOrderId()).eq(Order::getIsDelete, 0).update(); - // 商家打款至用户微信零钱 - User user = userService.lambdaQuery().eq(User::getId, withdraw.getUserId()) - .eq(User::getIsDelete, 0).one(); - Order order = orderService.lambdaQuery().eq(Order::getId, withdraw.getOrderId()) - .eq(Order::getIsDelete, 0).one(); - if (null == order) { - throw new GlobalException("订单信息异常!"); - } - Boolean b = withdrawService.confirmWithdraw(user, order); + User user = userService.lambdaQuery() + .eq(User::getId, withdraw.getUserId()) + .eq(User::getIsDelete, 0).one(); + if (null == user) { + throw new GlobalException("提交申请的用户信息不存在!"); } - update = update && withdrawService.updateById(withdraw); - return update ? R.ok(null, "审批成功!") : R.fail("审批失败!"); + Boolean data = withdrawClient.withdrawExamine(id, state, opinion, user.getOpenId(), user.getId()).getData(); + if (null != data) { + return data ? R.ok(null, "审批成功!") : R.fail("审批失败!"); + } else { + return R.fail("审批失败!"); + } } /** @@ -136,7 +168,9 @@ @ApiOperation(value = "用户提现管理-excel导出用户提现记录", tags = {"后台-用户管理-提现列表"}) @PostMapping(value = "/excelExport") public R<String> excelExport(@RequestBody WithdrawExportRequest exportRequest, HttpServletResponse response) { - return withdrawService.excelExport(exportRequest, response); + List<UserWithdrawRecordVO> data = withdrawClient.excelExport(exportRequest).getData(); + // 独立service + return withdrawService.excelExport(data, response); } /** @@ -151,10 +185,7 @@ @ApiImplicitParam(value = "多个id ',' 拼接", name = "ids", dataType = "String", required = true) }) public R<String> batchDelete(@RequestParam String ids) { - List<String> idList = Arrays.stream(ids.split(",")).collect(Collectors.toList()); - List<Withdraw> list = withdrawService.lambdaQuery().in(Withdraw::getId, idList).list(); - list.forEach(data -> data.setIsDelete(1)); - return withdrawService.updateBatchById(list) ? R.ok() : R.fail(); + return withdrawClient.batchDelete(ids); } } -- Gitblit v1.7.1