diff --git a/src/main/java/com/greenorange/promotion/common/ErrorCode.java b/src/main/java/com/greenorange/promotion/common/ErrorCode.java index 51f5d86..dd88e39 100644 --- a/src/main/java/com/greenorange/promotion/common/ErrorCode.java +++ b/src/main/java/com/greenorange/promotion/common/ErrorCode.java @@ -4,7 +4,7 @@ import lombok.Getter; @Getter public enum ErrorCode { - +// private static final SUCESS = new ErrorCode(1, "ok"); SUCCESS(1,"ok"), PARAMS_ERROR(40000,"请求参数错误"), NOT_LOGIN_ERROR(40100,"未登录"), diff --git a/src/main/java/com/greenorange/promotion/controller/practice/IdCardNumRequest.java b/src/main/java/com/greenorange/promotion/controller/practice/IdCardNumRequest.java new file mode 100644 index 0000000..c5428a4 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/controller/practice/IdCardNumRequest.java @@ -0,0 +1,15 @@ +package com.greenorange.promotion.controller.practice; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data + +@NoArgsConstructor + +@AllArgsConstructor + +public class IdCardNumRequest { + private String idcardnum; +} diff --git a/src/main/java/com/greenorange/promotion/controller/practice/Project_commission.java b/src/main/java/com/greenorange/promotion/controller/practice/Project_commission.java new file mode 100644 index 0000000..6f12d21 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/controller/practice/Project_commission.java @@ -0,0 +1,16 @@ +package com.greenorange.promotion.controller.practice; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.checkerframework.checker.units.qual.A; + +@Data + +@NoArgsConstructor + +@AllArgsConstructor + +public class Project_commission { + private Long userid; +} diff --git a/src/main/java/com/greenorange/promotion/controller/practice/Promo_code_apply.java b/src/main/java/com/greenorange/promotion/controller/practice/Promo_code_apply.java new file mode 100644 index 0000000..26b86ef --- /dev/null +++ b/src/main/java/com/greenorange/promotion/controller/practice/Promo_code_apply.java @@ -0,0 +1,15 @@ +package com.greenorange.promotion.controller.practice; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data + +@NoArgsConstructor + +@AllArgsConstructor + +public class Promo_code_apply { + private Long userid; +} diff --git a/src/main/java/com/greenorange/promotion/controller/practice/QueryRequest.java b/src/main/java/com/greenorange/promotion/controller/practice/QueryRequest.java new file mode 100644 index 0000000..080d0fc --- /dev/null +++ b/src/main/java/com/greenorange/promotion/controller/practice/QueryRequest.java @@ -0,0 +1,19 @@ +package com.greenorange.promotion.controller.practice; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +//有get,set方法,to-string方法 +@Data +//无参构造函数 +@NoArgsConstructor +//全参构造函数 +@AllArgsConstructor +public class QueryRequest { + private Long pagesize; + + + private Long pagenum; + +} diff --git a/src/main/java/com/greenorange/promotion/controller/practice/Toselect.java b/src/main/java/com/greenorange/promotion/controller/practice/Toselect.java new file mode 100644 index 0000000..56024d3 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/controller/practice/Toselect.java @@ -0,0 +1,16 @@ +package com.greenorange.promotion.controller.practice; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data + +@NoArgsConstructor + +@AllArgsConstructor + +public class Toselect { + private String phoneNumber; + private String bankNumber; +} diff --git a/src/main/java/com/greenorange/promotion/controller/practice/UserAccountTestController.java b/src/main/java/com/greenorange/promotion/controller/practice/UserAccountTestController.java new file mode 100644 index 0000000..ad6d8b5 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/controller/practice/UserAccountTestController.java @@ -0,0 +1,223 @@ +package com.greenorange.promotion.controller.practice; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.greenorange.promotion.common.BaseResponse; +import com.greenorange.promotion.common.ErrorCode; +import com.greenorange.promotion.common.ResultUtils; +import com.greenorange.promotion.exception.BusinessException; +import com.greenorange.promotion.model.dto.CommonRequest; +import com.greenorange.promotion.model.dto.userAccount.UserAccountAddRequest; +import com.greenorange.promotion.model.dto.userAccount.UserAccountUpdateRequest; +import com.greenorange.promotion.model.entity.ProjectCommission; +import com.greenorange.promotion.model.entity.PromoCodeApply; +import com.greenorange.promotion.model.entity.UserAccount; +import com.greenorange.promotion.service.project.ProjectCommissionService; +import com.greenorange.promotion.service.project.PromoCodeApplyService; +import com.greenorange.promotion.service.project.impl.PromoCodeApplyServiceImpl; +import com.greenorange.promotion.service.settle.UserAccountService; +import jakarta.annotation.Resource; +import org.checkerframework.common.util.report.qual.ReportWrite; +import org.jacoco.agent.rt.internal_f3994fa.IExceptionLogger; +import org.springframework.beans.BeanUtils; +import org.springframework.web.bind.annotation.*; +import java.util.*; + +//@ResponseBody 把返回值传到浏览器上 +//@Controller 把当前类的对象创建出来,存放到SpringIOC容器, +//@RestController = @Controller + @ResponseBody +@RestController +// ip + 端口号用于运行这个服务 +// ip + 端口号 + /test/hello +// @Controller @Service @Mapper 把当前类的对象创建出来,存放到SpringIOC容器, +@RequestMapping("test") +public class UserAccountTestController { + + // 对userAccount表实现功能 + // 1.插入,删除,修改,全部查询,根据id查询 + @Resource + // 从容器中取出名字为userAccountService的对象 + private UserAccountService userAccountService; + + @PostMapping("/add") + public BaseResponse add(@RequestBody UserAccountAddRequest userAccountAddRequest){ + if (userAccountAddRequest == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数不能为空"); + } + if (userAccountAddRequest.getBankCardNumber() == null || + userAccountAddRequest.getPhoneNumber() == null || + userAccountAddRequest.getIdCardNumber() == null || + userAccountAddRequest.getCardHolder() == null || + userAccountAddRequest.getOpenBank() == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "必填字段不能为空"); + } + UserAccount userAccount = new UserAccount(); +// userAccount.setId(null); +// userAccount.setBankCardNumber(userAccountAddRequest.getBankCardNumber()); +// userAccount.setOpenBank(userAccountAddRequest.getOpenBank()); +// userAccount.setPhoneNumber(userAccountAddRequest.getPhoneNumber()); +// userAccount.setIdCardNumber(userAccountAddRequest.getIdCardNumber()); +// userAccount.setCardHolder(userAccountAddRequest.getCardHolder()); +// userAccount.setUserId(1L); + BeanUtils.copyProperties(userAccountAddRequest, userAccount); + boolean result = userAccountService.save(userAccount); + if (!result) { + throw new BusinessException(ErrorCode.SYSTEM_ERROR, "新增用户账户失败"); + } + return ResultUtils.success("插入成功"); + } + +// @GetMapping("/delete") +// public String delete(@RequestParam Long id) { +// boolean removed = userAccountService.removeById(id); +// return removed ? "删除成功" : "删除失败"; + + +// @GetMapping("/delete/{id}") +// public String delete(@PathVariable Long id) { +// boolean removed = userAccountService.removeById(id); +// return removed ? "删除成功" : "删除失败"; +// } + + + @PostMapping("/delete") + public BaseResponse delete(@RequestBody CommonRequest commonRequest){ + Long id = commonRequest.getId(); + if(id == null) throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数 id 不能为空"); + boolean removed = userAccountService.removeById(id); + return ResultUtils.success(removed ? "删除成功" : "删除失败"); + } + + @PostMapping("/update") + public BaseResponse update(@RequestBody UserAccountUpdateRequest userAccountUpdateRequest){ + if (userAccountUpdateRequest == null || userAccountUpdateRequest.getId() == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "更新操作必须提供 ID"); + } + UserAccount existing = userAccountService.getById(userAccountUpdateRequest.getId()); + if (existing == null) { + throw new BusinessException(ErrorCode.NOT_FOUND_ERROR, "要更新的用户账户不存在"); + } + UserAccount userAccount = new UserAccount(); +// userAccount.setId(userAccountUpdateRequest.getId()); +// userAccount.setOpenBank(userAccountUpdateRequest.getOpenBank()); +// userAccount.setPhoneNumber(userAccountUpdateRequest.getPhoneNumber()); +// userAccount.setCardHolder(userAccountUpdateRequest.getCardHolder()); +// userAccount.setIdCardNumber(userAccountUpdateRequest.getIdCardNumber()); +// userAccount.setUserId(1L); + BeanUtils.copyProperties(userAccountUpdateRequest, userAccount); + userAccountService.updateById(userAccount); + boolean result = userAccountService.updateById(userAccount); + if (!result) { + throw new BusinessException(ErrorCode.SYSTEM_ERROR, "更新失败,请稍后再试"); + } + return ResultUtils.success("更新成功"); + } + + //根据id查询 + @PostMapping("/select") + public BaseResponse select(@RequestBody CommonRequest commonRequest){ + Long id = commonRequest.getId(); + if (id == null) { + throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数 id 不能为空"); + } + UserAccount selected = userAccountService.getById(id); + if (selected == null) { + throw new BusinessException(ErrorCode.NOT_FOUND_ERROR, "未找到对应的用户记录"); + } + return ResultUtils.success(selected); + } + + @GetMapping("success") + public BaseResponse test() { + for (int i = 0; i < 10; i ++ ) + System.out.println("运行了这个程序"); + String template = "运行程序"; + return ResultUtils.success(template); +// return new BaseResponse<>(1, template, "ok"); + } + + +//查询所有数据 + @PostMapping("/list") + public BaseResponse> list(){ + // 这里你可以根据 queryRequest 构造查询条件 + return ResultUtils.success(userAccountService.list()); +} + +//分页查询 +// @PostMapping("/pagelist") +// public BaseResponse> pagelist(@RequestBody QueryRequest queryRequest){ +// System.out.println(queryRequest.toString()); +// Long start = queryRequest.getPagesize() * (queryRequest.getPagenum() - 1); +// List list = userAccountService.list(); +// List newlist = list.subList(start.intValue(), start.intValue() + queryRequest.getPagesize().intValue()); +// return ResultUtils.success(newlist); +// } + @PostMapping("/pagelist") + public BaseResponse> pagelist(@RequestBody QueryRequest queryRequest){ + Long pagesize = queryRequest.getPagesize(); + Long pagenum = queryRequest.getPagenum(); + Page userAccountPage = new Page<>(pagenum, pagesize);//分页的规则 + Page page = userAccountService.page(userAccountPage);//根据分页规则取出集合里对应的部分 + return ResultUtils.success(page); + } + + //根据IdCardnum查询 + @PostMapping("/idcardnumselect") + public BaseResponse idcardnumselect(@RequestBody IdCardNumRequest idCardNumRequest) throws Exception { + String idcardnum = idCardNumRequest.getIdcardnum(); +// LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.eq(UserAccount::getIdCardNumber, idcardnum); + queryWrapper.eq("idCardNumber", idcardnum); + UserAccount userAccount = userAccountService.getOne(queryWrapper); + if(userAccount == null) throw new BusinessException(ErrorCode.NOT_FOUND_ERROR, "这条记录不存在"); +// if(userAccount == null) ResultUtils.error(ErrorCode.NOT_FOUND_ERROR); + return ResultUtils.success(userAccount); + } + + //根据phoneNumber,bankCardNumber + @PostMapping("phonebankNumberselect") + public BaseResponse> phonebankselect(@RequestBody Toselect toselect){ + String phoneNumber = toselect.getPhoneNumber(); + String bankNumber = toselect.getBankNumber(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(UserAccount::getPhoneNumber, phoneNumber); + queryWrapper.eq(UserAccount::getBankCardNumber, bankNumber); + List list = userAccountService.list(queryWrapper); + if (list == null || list.isEmpty()) { + throw new BusinessException(ErrorCode.NOT_FOUND_ERROR, "没有符合条件的用户账户信息"); + } + return ResultUtils.success(list); + } + + @Resource + private PromoCodeApplyService promoCodeApplyService; + + @Resource + private ProjectCommissionService projectCommissionService; + + + @PostMapping("/queryByIds") + public BaseResponse> phonebankselectHello(){ + List list = promoCodeApplyService.list(); + List ids = list.stream().map(PromoCodeApply::getUserId).toList(); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.in(ProjectCommission::getUserId, ids); + List projectCommissions = projectCommissionService.list(lambdaQueryWrapper); + + return ResultUtils.success(projectCommissions); + } + + + +// @GetMapping("error") +// public BaseResponse error() throws Exception { +//// String error = "空指针异常"; +// String template = null; +// if (template == null) throw new Exception("空指针异常"); +// return ResultUtils.success("error"); +// } + +} diff --git a/src/main/java/com/greenorange/promotion/controller/projectSettlement/Addqurrywithdraw.java b/src/main/java/com/greenorange/promotion/controller/projectSettlement/Addqurrywithdraw.java new file mode 100644 index 0000000..c947487 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/controller/projectSettlement/Addqurrywithdraw.java @@ -0,0 +1,17 @@ +package com.greenorange.promotion.controller.projectSettlement; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Data + +@NoArgsConstructor + +@AllArgsConstructor +public class Addqurrywithdraw { + private Long userid; + private BigDecimal payouts; +} diff --git a/src/main/java/com/greenorange/promotion/controller/projectSettlement/WithdrawalApplyController.java b/src/main/java/com/greenorange/promotion/controller/projectSettlement/WithdrawalApplyController.java index b01e62c..8969adb 100644 --- a/src/main/java/com/greenorange/promotion/controller/projectSettlement/WithdrawalApplyController.java +++ b/src/main/java/com/greenorange/promotion/controller/projectSettlement/WithdrawalApplyController.java @@ -8,7 +8,9 @@ import com.greenorange.promotion.common.BaseResponse; import com.greenorange.promotion.common.ErrorCode; import com.greenorange.promotion.common.ResultUtils; import com.greenorange.promotion.constant.UserConstant; +import com.greenorange.promotion.exception.BusinessException; import com.greenorange.promotion.exception.ThrowUtils; +import com.greenorange.promotion.model.dto.userAccount.UserAccountQueryRequest; import com.greenorange.promotion.model.dto.withdrawalApply.WithdrawalApplyAddRequest; import com.greenorange.promotion.model.dto.withdrawalApply.WithdrawalApplyQueryRequest; import com.greenorange.promotion.model.entity.*; @@ -24,9 +26,11 @@ import com.greenorange.promotion.service.userInfo.UserInfoService; import com.greenorange.promotion.service.userInfo.UserMainInfoService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Priority; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -47,151 +51,46 @@ import java.util.List; @Slf4j @Tag(name = "提现申请记录管理") public class WithdrawalApplyController { - + @Resource + private UserAccountService userAccountService; + @Resource + private UserMainInfoService userMainInfoService; @Resource private WithdrawalApplyService withdrawalApplyService; - @Resource private FundsChangeService fundsChangeService; - @Resource - private CommonService commonService; - - @Resource - private UserMainInfoService userMainInfoService; - - @Resource - private UserInfoService userInfoService; - - @Resource - private UserAccountService userAccountService; - - - /** - * 小程序端用户查询账户提现状况 - * @return 提现申请记录id - */ - @PostMapping("query/condition") - @Operation(summary = "小程序端用户查询账户提现状况", description = "参数:无,权限:管理员,方法名:queryWithdrawalCondition") - @RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE) - public BaseResponse queryWithdrawalCondition(HttpServletRequest request) { - Long userId = (Long) request.getAttribute("userId"); - LambdaQueryWrapper userMainInfoLambdaQueryWrapper = commonService.buildQueryWrapperByField(UserMainInfo::getUserId, userId, userMainInfoService); - UserMainInfo userMainInfo = userMainInfoService.getOne(userMainInfoLambdaQueryWrapper); - LambdaQueryWrapper userAccountLambdaQueryWrapper = commonService.buildQueryWrapperByField(UserAccount::getUserId, userId, userAccountService); - UserAccount userAccount = userAccountService.getOne(userAccountLambdaQueryWrapper); - String bankCardNumber = userAccount == null ? "" : userAccount.getBankCardNumber(); - UserAccountConditionVO userAccountConditionVO = UserAccountConditionVO.builder() - .currentBalance(userMainInfo.getCurrentBalance()) - .bankCardNumber(bankCardNumber) - .build(); - return ResultUtils.success(userAccountConditionVO); - } - - - /** - * 小程序端用户申请提现 - * @param withdrawalApplyAddRequest 提现申请记录查添加请求体 - * @return 提现申请记录id - */ - @PostMapping("add") - @Operation(summary = "小程序端用户申请提现", description = "参数:提现申请记录查添加请求体,权限:管理员,方法名:addWithdrawalApply") - @RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE) -// @SysLog(title = "提现申请记录管理", content = "小程序端用户申请提现") - public BaseResponse addWithdrawalApply(@Valid @RequestBody WithdrawalApplyAddRequest withdrawalApplyAddRequest, HttpServletRequest request) { - Long userId = (Long) request.getAttribute("userId"); - LambdaQueryWrapper userAccountLambdaQueryWrapper = commonService.buildQueryWrapperByField(UserAccount::getUserId, userId, userAccountService); - UserAccount userAccount = userAccountService.getOne(userAccountLambdaQueryWrapper); - ThrowUtils.throwIf(userAccount == null, ErrorCode.OPERATION_ERROR, "请先绑定银行卡"); - BigDecimal withdrawnAmount = withdrawalApplyAddRequest.getWithdrawnAmount(); - WithdrawalApply withdrawalApply = WithdrawalApply.builder() - .withdrawnAmount(withdrawnAmount) - .cardHolder(userAccount.getCardHolder()) - .idCardNumber(userAccount.getIdCardNumber()) - .phoneNumber(userAccount.getPhoneNumber()) - .bankCardNumber(userAccount.getBankCardNumber()) - .openBank(userAccount.getOpenBank()) - .userId(userId) - .build(); + @PostMapping("addqurry") + public BaseResponse addqurry(@RequestBody Addqurrywithdraw addqurrywithdraw ){ + Long userid = addqurrywithdraw.getUserid(); + BigDecimal payouts = addqurrywithdraw.getPayouts(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(UserMainInfo::getUserId, userid); + UserMainInfo one = userMainInfoService.getOne(queryWrapper); + BigDecimal currentBalance = one.getCurrentBalance(); + if(payouts.compareTo(currentBalance) > 0) throw new BusinessException(ErrorCode.OPERATION_ERROR,"提现金额超过当前的余额"); + LambdaQueryWrapper queryWrapper2 = new LambdaQueryWrapper<>(); + queryWrapper2.eq(UserAccount::getUserId, userid); + UserAccount two = userAccountService.getOne(queryWrapper2); + WithdrawalApply withdrawalApply = new WithdrawalApply(); + BeanUtils.copyProperties(two, withdrawalApply); + withdrawalApply.setId(null); + withdrawalApply.setUpdateTime(null); + withdrawalApply.setCreateTime(null); + withdrawalApply.setWithdrawnAmount(payouts); + withdrawalApply.setWithdrawalStatus("processing"); withdrawalApplyService.save(withdrawalApply); - // 修改个人主要信息 - LambdaQueryWrapper userMainInfoLambdaQueryWrapper = commonService.buildQueryWrapperByField(UserMainInfo::getUserId, userId, userMainInfoService); - UserMainInfo userMainInfo = userMainInfoService.getOne(userMainInfoLambdaQueryWrapper); - userMainInfo.setWithdrawalAmount(userMainInfo.getWithdrawalAmount().add(withdrawnAmount)); - userMainInfo.setCurrentBalance(userMainInfo.getCurrentBalance().subtract(withdrawnAmount)); - userMainInfoService.updateById(userMainInfo); - // 添加资金明细记录 - FundsChange fundsChange = FundsChange.builder() - .projectName("用户提现") - .changeAmount(withdrawnAmount.negate()) - .currentAmount(userMainInfo.getCurrentBalance()) - .userId(userId) - .projectSettlementId(0L) - .build(); + BigDecimal subtract = currentBalance.subtract(payouts); + one.setCurrentBalance(subtract); + userMainInfoService.updateById(one); + FundsChange fundsChange = new FundsChange(); + fundsChange.setUserId(userid); + fundsChange.setChangeAmount(payouts); + fundsChange.setProjectName("processing"); + fundsChange.setCurrentAmount(subtract); + fundsChange.setProjectSettlementId(0L); fundsChangeService.save(fundsChange); - return ResultUtils.success(withdrawalApply.getId()); + return ResultUtils.success("提现成功"); } +} - - /** - * 小程序端用户查询提现申请记录 - * @return 提现申请记录列表 - */ - @PostMapping("query") - @Operation(summary = "小程序端用户查询提现申请记录", description = "参数:无,权限:管理员,方法名:queryWithdrawalApplyByUserId") - @RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE) -// @SysLog(title = "提现申请记录管理", content = "小程序端用户查询提现申请记录") - public BaseResponse> queryWithdrawalApplyByUserId(HttpServletRequest request) { - Long userId = (Long) request.getAttribute("userId"); - List withdrawalApplyList = commonService.findByFieldEqTargetField(WithdrawalApply::getUserId, userId, withdrawalApplyService); - List withdrawalApplyVOS = commonService.convertList(withdrawalApplyList, WithdrawalApplyVO.class); - Collections.reverse(withdrawalApplyVOS); - return ResultUtils.success(withdrawalApplyVOS); - } - - - /** - * 小程序端用户查询资金变动记录 - * @return 提现申请记录id - */ - @PostMapping("query/change") - @Operation(summary = "小程序端用户查询资金变动记录", description = "参数:无,权限:管理员,方法名:queryFundsChangeByUserId") - @RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE) -// @SysLog(title = "提现申请记录管理", content = "小程序端用户查询资金变动记录") - public BaseResponse queryFundsChangeByUserId(HttpServletRequest request) { - Long userId = (Long) request.getAttribute("userId"); - LambdaQueryWrapper userMainInfoLambdaQueryWrapper = commonService.buildQueryWrapperByField(UserMainInfo::getUserId, userId, userMainInfoService); - UserMainInfo userMainInfo = userMainInfoService.getOne(userMainInfoLambdaQueryWrapper); - FundsItemVO fundsItemVO = commonService.copyProperties(userMainInfo, FundsItemVO.class); - List fundsChangeList = commonService.findByFieldEqTargetField(FundsChange::getUserId, userId, fundsChangeService); - List fundsChangeVOS = commonService.convertList(fundsChangeList, FundsChangeVO.class); - Collections.reverse(fundsChangeVOS); - fundsItemVO.setFundsChangeVOList(fundsChangeVOS); - return ResultUtils.success(fundsItemVO); - } - - - - /** - * Web端管理员分页查询提现申请记录 - * @param withdrawalApplyQueryRequest 提现申请记录查询请求体 - * @return 提现申请记录列表 - */ - @PostMapping("page") - @Operation(summary = "Web端管理员分页查询提现申请记录", description = "参数:提现申请记录查询请求体,权限:管理员,方法名:listWithdrawalApplyByPage") - @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) - @SysLog(title = "提现申请记录管理", content = "Web端管理员分页查询提现申请记录") - public BaseResponse> listWithdrawalApplyByPage(@Valid @RequestBody WithdrawalApplyQueryRequest withdrawalApplyQueryRequest) { - long current = withdrawalApplyQueryRequest.getCurrent(); - long pageSize = withdrawalApplyQueryRequest.getPageSize(); - QueryWrapper queryWrapper = withdrawalApplyService.getQueryWrapper(withdrawalApplyQueryRequest); - Page page = withdrawalApplyService.page(new Page<>(current, pageSize), queryWrapper); - List withdrawalApplyList = page.getRecords(); - List withdrawalApplyVOList = commonService.convertList(withdrawalApplyList, WithdrawalApplyVO.class); - Page voPage = new Page<>(current, pageSize); - voPage.setRecords(withdrawalApplyVOList); - voPage.setPages(page.getPages()); - voPage.setTotal(page.getTotal()); - return ResultUtils.success(voPage); - } -} \ No newline at end of file diff --git a/src/main/java/com/greenorange/promotion/controller/userInfo/UserInfoController.java b/src/main/java/com/greenorange/promotion/controller/userInfo/UserInfoController.java index 0a6b0d4..9f5b5b1 100644 --- a/src/main/java/com/greenorange/promotion/controller/userInfo/UserInfoController.java +++ b/src/main/java/com/greenorange/promotion/controller/userInfo/UserInfoController.java @@ -10,6 +10,7 @@ import com.greenorange.promotion.common.BaseResponse; import com.greenorange.promotion.common.ErrorCode; import com.greenorange.promotion.common.ResultUtils; import com.greenorange.promotion.constant.UserConstant; +import com.greenorange.promotion.exception.BusinessException; import com.greenorange.promotion.exception.ThrowUtils; import com.greenorange.promotion.model.dto.CommonBatchRequest; import com.greenorange.promotion.model.dto.CommonRequest; @@ -30,6 +31,7 @@ import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.io.JBoss6VFS; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.bind.annotation.*; @@ -303,6 +305,14 @@ public class UserInfoController { @RequiresPermission(mustRole = UserConstant.BOSS_ROLE) @SysLog(title = "用户管理", content = "web端管理员添加用户") public BaseResponse addUserInfo(@Valid @RequestBody UserInfoAddRequest userInfoAddRequest) { + String userAccount = userInfoAddRequest.getUserAccount(); + String userPassword = userInfoAddRequest.getUserPassword(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(UserInfo::getUserRole,"boss"); + UserInfo one = userInfoService.getOne(queryWrapper); + String userAccount2 = one.getUserAccount(); + String userPassword2 = one.getUserPassword(); + if(userAccount2.equals(userAccount) && userPassword2.equals(userPassword)) throw new BusinessException(ErrorCode.OPERATION_ERROR,"不能添加跟boss重名的账号和密码"); UserInfo userInfo = commonService.copyProperties(userInfoAddRequest, UserInfo.class); userInfo.setParentUserId(-1L); userInfo.setUserRole(UserConstant.ADMIN_ROLE); diff --git a/src/main/java/com/greenorange/promotion/service/userInfo/UserInfoService.java b/src/main/java/com/greenorange/promotion/service/userInfo/UserInfoService.java index 79b637d..e1cec63 100644 --- a/src/main/java/com/greenorange/promotion/service/userInfo/UserInfoService.java +++ b/src/main/java/com/greenorange/promotion/service/userInfo/UserInfoService.java @@ -68,4 +68,5 @@ public interface UserInfoService extends IService { * 查询从 userId 一路到根节点的所有 id,按 depth 倒序(根先出) */ List findPathToRoot(Long userId); + } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a17ec4c..99bfa52 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: test + active: practice