From 1442f149019ee0590389abd7a88a79c4d9b59034 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 27 五月 2025 18:23:34 +0800 Subject: [PATCH] bug修改 --- ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/AppFranchiseeController.java | 149 +++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 137 insertions(+), 12 deletions(-) diff --git a/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/AppFranchiseeController.java b/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/AppFranchiseeController.java index 025fa45..030e58b 100644 --- a/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/AppFranchiseeController.java +++ b/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/AppFranchiseeController.java @@ -1,22 +1,37 @@ package com.ruoyi.admin.controller; -import com.ruoyi.admin.entity.Franchisee; -import com.ruoyi.admin.entity.FranchiseeWithdraw; -import com.ruoyi.admin.entity.TFranchiseeBalanceChange; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.admin.entity.*; +import com.ruoyi.admin.request.AuditFranchiseeWithdrawDTO; +import com.ruoyi.admin.request.FranchiseeWithdrawDTO; import com.ruoyi.admin.service.FranchiseeService; +import com.ruoyi.admin.service.SysUserService; import com.ruoyi.admin.service.TFranchiseeBalanceChangeService; +import com.ruoyi.admin.service.TFranchiseeWithdrawService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.admin.request.WithdrawDTO; +import com.ruoyi.order.api.entity.Order; import com.ruoyi.system.api.model.LoginUser; +import com.ruoyi.system.api.model.LoginUserInfo; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; /** * <p> @@ -27,8 +42,8 @@ * @since 2024-06-03 */ @RestController -@RequestMapping("/franchisee") -@Api(value = "加盟商迭代新增", tags = "加盟商迭代新增") +@RequestMapping("/franchiseeWithdraw") +@Api(value = "加盟商提现迭代新增", tags = "加盟商提现迭代新增") public class AppFranchiseeController { @@ -38,20 +53,26 @@ private FranchiseeService franchiseeService; @Resource private TFranchiseeBalanceChangeService franchiseeBalanceChangeService; + @Resource + private TFranchiseeWithdrawService franchiseeWithdrawService; - + @Resource + private SysUserService sysUserService; @PostMapping("/applyWithdraw") - @ApiOperation(value = "加盟商申请提现", tags = {"提现"}) + @ApiOperation(value = "APP-加盟商申请提现", tags = {"提现"}) public R check(@RequestBody WithdrawDTO dto) { LoginUser loginUser = tokenService.getLoginUser(); if (loginUser==null){ return R.fail("登录失效"); } - Franchisee franchisee = franchiseeService.getById(loginUser.getUserid()); + SysUser user = sysUserService.getById(loginUser.getUserid()); + + Franchisee franchisee = franchiseeService.getById(user.getFranchiseeId()); if (franchisee.getBalance().subtract(dto.getMoney()).compareTo(BigDecimal.ZERO)>=0){ BigDecimal subtract = franchisee.getBalance().subtract(dto.getMoney()); franchisee.setBalance(subtract); + franchiseeService.updateById(franchisee); }else{ return R.fail("余额不足"); } @@ -72,12 +93,116 @@ franchiseeWithdraw.setStatus(1); franchiseeWithdraw.setContent(dto.getContent()); franchiseeWithdraw.setMoney(dto.getMoney()); - franchiseeWithdraw.setCreateTime(LocalDateTime.now()); - franchiseeWithdraw.setUpdateTime(LocalDateTime.now()); + franchiseeWithdraw.setCreateTime(new Date()); + franchiseeWithdraw.setUpdateTime(new Date()); franchiseeWithdraw.setIsDelete(0); - - + franchiseeWithdrawService.save(franchiseeWithdraw); return R.ok(); } + @ApiOperation(value = "APP-加盟商提现记录", tags = {"提现"}) + @GetMapping(value = "/franchiseeWithdrawListApp") + + public R<IPage<FranchiseeWithdraw>> franchiseeWithdrawListApp( + @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { + LoginUser loginWorker = tokenService.getLoginUser(); + if (null == loginWorker) { + return R.loginExpire("登录失效!"); + } + SysUser user = sysUserService.getById(loginWorker.getUserid()); + IPage<FranchiseeWithdraw> franchiseeWithdrawList = franchiseeWithdrawService + .lambdaQuery().eq(FranchiseeWithdraw::getFranchiseeId, user.getFranchiseeId()) + .orderByDesc(FranchiseeWithdraw::getCreateTime) + .page(Page.of(pageNum, pageSize)); + return R.ok(franchiseeWithdrawList); + } + @ApiOperation(value = "管理后台-加盟商提现记录", tags = {"提现"}) + @PostMapping(value = "/franchiseeWithdrawList") + public R<IPage<FranchiseeWithdraw>> franchiseeWithdrawList(@RequestBody FranchiseeWithdrawDTO franchiseeWithdrawDTO) { + LoginUser loginWorker = tokenService.getLoginUser(); + if (null == loginWorker) { + return R.loginExpire("登录失效!"); + } + SysUser byId = sysUserService.getById(loginWorker.getUserid()); + + LambdaQueryWrapper<FranchiseeWithdraw> franchiseeWithdrawLambdaQueryWrapper = new LambdaQueryWrapper<>(); + franchiseeWithdrawLambdaQueryWrapper + .orderByDesc(FranchiseeWithdraw::getCreateTime); + if (StringUtils.hasLength(franchiseeWithdrawDTO.getFranchiseeName())){ + List<Integer> ids = franchiseeService.lambdaQuery().like(Franchisee::getName, franchiseeWithdrawDTO.getFranchiseeName()).list() + .stream().map(Franchisee::getId).collect(Collectors.toList()); + if (!ids.isEmpty()){ + franchiseeWithdrawLambdaQueryWrapper.in(FranchiseeWithdraw::getFranchiseeId, ids); + }else{ + franchiseeWithdrawLambdaQueryWrapper.eq(FranchiseeWithdraw::getFranchiseeId, -1); + } + } + if (StringUtils.hasLength(franchiseeWithdrawDTO.getStartTime())){ + franchiseeWithdrawLambdaQueryWrapper + .between(FranchiseeWithdraw::getCreateTime + ,franchiseeWithdrawDTO.getStartTime() + , franchiseeWithdrawDTO.getEndTime()); + } + IPage<FranchiseeWithdraw> franchiseeWithdrawList = franchiseeWithdrawService + .page(Page.of(franchiseeWithdrawDTO.getPageNum(), franchiseeWithdrawDTO.getPageSize()), franchiseeWithdrawLambdaQueryWrapper); + List<Franchisee> list = franchiseeService.list(); + for (FranchiseeWithdraw record : franchiseeWithdrawList.getRecords()) { + Franchisee franchisee = list.stream().filter(e -> e.getId().equals(record.getFranchiseeId())).findFirst().orElse(null); + if (franchisee!=null){ + record.setFranchiseeName(franchisee.getName()); + record.setFranchiseePhone(franchisee.getHeadPhone()); + } + } + return R.ok(franchiseeWithdrawList); + } + @ApiOperation(value = "管理后台-加盟商提现详情", tags = {"提现"}) + @GetMapping(value = "/franchiseeWithdrawInfo") + public R<FranchiseeWithdraw> franchiseeWithdrawInfo(@RequestParam(name = "id")Integer id) { + LoginUser loginWorker = tokenService.getLoginUser(); + if (null == loginWorker) { + return R.loginExpire("登录失效!"); + } + FranchiseeWithdraw franchiseeWithdraw = franchiseeWithdrawService.getById(id); + Franchisee franchisee = franchiseeService.getById(franchiseeWithdraw.getFranchiseeId()); + if (franchisee!=null){ + franchiseeWithdraw.setFranchiseePhone(franchisee.getHeadPhone()); + franchiseeWithdraw.setFranchiseeName(franchisee.getName()); + } + return R.ok(franchiseeWithdraw); + } + @ApiOperation(value = "管理后台-审核", tags = {"提现"}) + @PostMapping(value = "/auditFranchiseeWithdraw") + public R auditFranchiseeWithdraw(@RequestBody AuditFranchiseeWithdrawDTO auditFranchiseeWithdrawDTO) { + LoginUser loginWorker = tokenService.getLoginUser(); + if (null == loginWorker) { + return R.loginExpire("登录失效!"); + } + SysUser byId = sysUserService.getById(loginWorker.getUserid()); + FranchiseeWithdraw franchiseeWithdraw = franchiseeWithdrawService.getById(auditFranchiseeWithdrawDTO.getId()); + franchiseeWithdraw.setStatus(auditFranchiseeWithdrawDTO.getStatus()); + franchiseeWithdraw.setResult(auditFranchiseeWithdrawDTO.getResult()); + franchiseeWithdraw.setImg(auditFranchiseeWithdrawDTO.getImg()); + franchiseeWithdraw.setUpdateBy(byId.getNickName()); + franchiseeWithdraw.setHandle(byId.getNickName()); + franchiseeWithdraw.setUpdateTime(new Date()); + franchiseeWithdrawService.updateById(franchiseeWithdraw); + Franchisee franchisee = franchiseeService.getById(franchiseeWithdraw.getFranchiseeId()); + if (auditFranchiseeWithdrawDTO.getStatus()==3){ + // 回退运营商余额 + TFranchiseeBalanceChange balanceChange = new TFranchiseeBalanceChange(); + balanceChange.setAmount(franchiseeWithdraw.getMoney()); + balanceChange.setIs_pay(1); + balanceChange.setFranchiseeName(franchisee.getName()); + balanceChange.setFranchiseeId(franchisee.getId()+""); + balanceChange.setRemark("余额提现回退"); + balanceChange.setType(4); + balanceChange.setIsDelete(0); + franchiseeBalanceChangeService.save(balanceChange); + BigDecimal add = franchisee.getBalance().add(franchiseeWithdraw.getMoney()); + franchisee.setBalance(add); + franchiseeService.updateById(franchisee); + } + return R.ok(); + } } -- Gitblit v1.7.1