我修复了boss与admin创建相同账号无校验
This commit is contained in:
@ -4,7 +4,7 @@ import lombok.Getter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum ErrorCode {
|
public enum ErrorCode {
|
||||||
|
// private static final SUCESS = new ErrorCode(1, "ok");
|
||||||
SUCCESS(1,"ok"),
|
SUCCESS(1,"ok"),
|
||||||
PARAMS_ERROR(40000,"请求参数错误"),
|
PARAMS_ERROR(40000,"请求参数错误"),
|
||||||
NOT_LOGIN_ERROR(40100,"未登录"),
|
NOT_LOGIN_ERROR(40100,"未登录"),
|
||||||
|
@ -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;
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
@ -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<String> 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<String> 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<String> 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<UserAccount> 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<String> 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<UserAccount>> list(){
|
||||||
|
// 这里你可以根据 queryRequest 构造查询条件
|
||||||
|
return ResultUtils.success(userAccountService.list());
|
||||||
|
}
|
||||||
|
|
||||||
|
//分页查询
|
||||||
|
// @PostMapping("/pagelist")
|
||||||
|
// public BaseResponse<List<UserAccount>> pagelist(@RequestBody QueryRequest queryRequest){
|
||||||
|
// System.out.println(queryRequest.toString());
|
||||||
|
// Long start = queryRequest.getPagesize() * (queryRequest.getPagenum() - 1);
|
||||||
|
// List<UserAccount> list = userAccountService.list();
|
||||||
|
// List<UserAccount> newlist = list.subList(start.intValue(), start.intValue() + queryRequest.getPagesize().intValue());
|
||||||
|
// return ResultUtils.success(newlist);
|
||||||
|
// }
|
||||||
|
@PostMapping("/pagelist")
|
||||||
|
public BaseResponse<Page<UserAccount>> pagelist(@RequestBody QueryRequest queryRequest){
|
||||||
|
Long pagesize = queryRequest.getPagesize();
|
||||||
|
Long pagenum = queryRequest.getPagenum();
|
||||||
|
Page<UserAccount> userAccountPage = new Page<>(pagenum, pagesize);//分页的规则
|
||||||
|
Page<UserAccount> page = userAccountService.page(userAccountPage);//根据分页规则取出集合里对应的部分
|
||||||
|
return ResultUtils.success(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据IdCardnum查询
|
||||||
|
@PostMapping("/idcardnumselect")
|
||||||
|
public BaseResponse<UserAccount> idcardnumselect(@RequestBody IdCardNumRequest idCardNumRequest) throws Exception {
|
||||||
|
String idcardnum = idCardNumRequest.getIdcardnum();
|
||||||
|
// LambdaQueryWrapper<UserAccount> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
QueryWrapper<UserAccount> 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<List<UserAccount>> phonebankselect(@RequestBody Toselect toselect){
|
||||||
|
String phoneNumber = toselect.getPhoneNumber();
|
||||||
|
String bankNumber = toselect.getBankNumber();
|
||||||
|
LambdaQueryWrapper<UserAccount> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(UserAccount::getPhoneNumber, phoneNumber);
|
||||||
|
queryWrapper.eq(UserAccount::getBankCardNumber, bankNumber);
|
||||||
|
List<UserAccount> 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<List<ProjectCommission>> phonebankselectHello(){
|
||||||
|
List<PromoCodeApply> list = promoCodeApplyService.list();
|
||||||
|
List<Long> ids = list.stream().map(PromoCodeApply::getUserId).toList();
|
||||||
|
LambdaQueryWrapper<ProjectCommission> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.in(ProjectCommission::getUserId, ids);
|
||||||
|
List<ProjectCommission> projectCommissions = projectCommissionService.list(lambdaQueryWrapper);
|
||||||
|
|
||||||
|
return ResultUtils.success(projectCommissions);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// @GetMapping("error")
|
||||||
|
// public BaseResponse<String> error() throws Exception {
|
||||||
|
//// String error = "空指针异常";
|
||||||
|
// String template = null;
|
||||||
|
// if (template == null) throw new Exception("空指针异常");
|
||||||
|
// return ResultUtils.success("error");
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
@ -8,7 +8,9 @@ import com.greenorange.promotion.common.BaseResponse;
|
|||||||
import com.greenorange.promotion.common.ErrorCode;
|
import com.greenorange.promotion.common.ErrorCode;
|
||||||
import com.greenorange.promotion.common.ResultUtils;
|
import com.greenorange.promotion.common.ResultUtils;
|
||||||
import com.greenorange.promotion.constant.UserConstant;
|
import com.greenorange.promotion.constant.UserConstant;
|
||||||
|
import com.greenorange.promotion.exception.BusinessException;
|
||||||
import com.greenorange.promotion.exception.ThrowUtils;
|
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.WithdrawalApplyAddRequest;
|
||||||
import com.greenorange.promotion.model.dto.withdrawalApply.WithdrawalApplyQueryRequest;
|
import com.greenorange.promotion.model.dto.withdrawalApply.WithdrawalApplyQueryRequest;
|
||||||
import com.greenorange.promotion.model.entity.*;
|
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 com.greenorange.promotion.service.userInfo.UserMainInfoService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Priority;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@ -47,151 +51,46 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Tag(name = "提现申请记录管理")
|
@Tag(name = "提现申请记录管理")
|
||||||
public class WithdrawalApplyController {
|
public class WithdrawalApplyController {
|
||||||
|
@Resource
|
||||||
|
private UserAccountService userAccountService;
|
||||||
|
@Resource
|
||||||
|
private UserMainInfoService userMainInfoService;
|
||||||
@Resource
|
@Resource
|
||||||
private WithdrawalApplyService withdrawalApplyService;
|
private WithdrawalApplyService withdrawalApplyService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private FundsChangeService fundsChangeService;
|
private FundsChangeService fundsChangeService;
|
||||||
|
|
||||||
@Resource
|
@PostMapping("addqurry")
|
||||||
private CommonService commonService;
|
public BaseResponse<String> addqurry(@RequestBody Addqurrywithdraw addqurrywithdraw ){
|
||||||
|
Long userid = addqurrywithdraw.getUserid();
|
||||||
@Resource
|
BigDecimal payouts = addqurrywithdraw.getPayouts();
|
||||||
private UserMainInfoService userMainInfoService;
|
LambdaQueryWrapper<UserMainInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(UserMainInfo::getUserId, userid);
|
||||||
@Resource
|
UserMainInfo one = userMainInfoService.getOne(queryWrapper);
|
||||||
private UserInfoService userInfoService;
|
BigDecimal currentBalance = one.getCurrentBalance();
|
||||||
|
if(payouts.compareTo(currentBalance) > 0) throw new BusinessException(ErrorCode.OPERATION_ERROR,"提现金额超过当前的余额");
|
||||||
@Resource
|
LambdaQueryWrapper<UserAccount> queryWrapper2 = new LambdaQueryWrapper<>();
|
||||||
private UserAccountService userAccountService;
|
queryWrapper2.eq(UserAccount::getUserId, userid);
|
||||||
|
UserAccount two = userAccountService.getOne(queryWrapper2);
|
||||||
|
WithdrawalApply withdrawalApply = new WithdrawalApply();
|
||||||
/**
|
BeanUtils.copyProperties(two, withdrawalApply);
|
||||||
* 小程序端用户查询账户提现状况
|
withdrawalApply.setId(null);
|
||||||
* @return 提现申请记录id
|
withdrawalApply.setUpdateTime(null);
|
||||||
*/
|
withdrawalApply.setCreateTime(null);
|
||||||
@PostMapping("query/condition")
|
withdrawalApply.setWithdrawnAmount(payouts);
|
||||||
@Operation(summary = "小程序端用户查询账户提现状况", description = "参数:无,权限:管理员,方法名:queryWithdrawalCondition")
|
withdrawalApply.setWithdrawalStatus("processing");
|
||||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
|
||||||
public BaseResponse<UserAccountConditionVO> queryWithdrawalCondition(HttpServletRequest request) {
|
|
||||||
Long userId = (Long) request.getAttribute("userId");
|
|
||||||
LambdaQueryWrapper<UserMainInfo> userMainInfoLambdaQueryWrapper = commonService.buildQueryWrapperByField(UserMainInfo::getUserId, userId, userMainInfoService);
|
|
||||||
UserMainInfo userMainInfo = userMainInfoService.getOne(userMainInfoLambdaQueryWrapper);
|
|
||||||
LambdaQueryWrapper<UserAccount> 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<Long> addWithdrawalApply(@Valid @RequestBody WithdrawalApplyAddRequest withdrawalApplyAddRequest, HttpServletRequest request) {
|
|
||||||
Long userId = (Long) request.getAttribute("userId");
|
|
||||||
LambdaQueryWrapper<UserAccount> 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();
|
|
||||||
withdrawalApplyService.save(withdrawalApply);
|
withdrawalApplyService.save(withdrawalApply);
|
||||||
// 修改个人主要信息
|
BigDecimal subtract = currentBalance.subtract(payouts);
|
||||||
LambdaQueryWrapper<UserMainInfo> userMainInfoLambdaQueryWrapper = commonService.buildQueryWrapperByField(UserMainInfo::getUserId, userId, userMainInfoService);
|
one.setCurrentBalance(subtract);
|
||||||
UserMainInfo userMainInfo = userMainInfoService.getOne(userMainInfoLambdaQueryWrapper);
|
userMainInfoService.updateById(one);
|
||||||
userMainInfo.setWithdrawalAmount(userMainInfo.getWithdrawalAmount().add(withdrawnAmount));
|
FundsChange fundsChange = new FundsChange();
|
||||||
userMainInfo.setCurrentBalance(userMainInfo.getCurrentBalance().subtract(withdrawnAmount));
|
fundsChange.setUserId(userid);
|
||||||
userMainInfoService.updateById(userMainInfo);
|
fundsChange.setChangeAmount(payouts);
|
||||||
// 添加资金明细记录
|
fundsChange.setProjectName("processing");
|
||||||
FundsChange fundsChange = FundsChange.builder()
|
fundsChange.setCurrentAmount(subtract);
|
||||||
.projectName("用户提现")
|
fundsChange.setProjectSettlementId(0L);
|
||||||
.changeAmount(withdrawnAmount.negate())
|
|
||||||
.currentAmount(userMainInfo.getCurrentBalance())
|
|
||||||
.userId(userId)
|
|
||||||
.projectSettlementId(0L)
|
|
||||||
.build();
|
|
||||||
fundsChangeService.save(fundsChange);
|
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<List<WithdrawalApplyVO>> queryWithdrawalApplyByUserId(HttpServletRequest request) {
|
|
||||||
Long userId = (Long) request.getAttribute("userId");
|
|
||||||
List<WithdrawalApply> withdrawalApplyList = commonService.findByFieldEqTargetField(WithdrawalApply::getUserId, userId, withdrawalApplyService);
|
|
||||||
List<WithdrawalApplyVO> 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<FundsItemVO> queryFundsChangeByUserId(HttpServletRequest request) {
|
|
||||||
Long userId = (Long) request.getAttribute("userId");
|
|
||||||
LambdaQueryWrapper<UserMainInfo> userMainInfoLambdaQueryWrapper = commonService.buildQueryWrapperByField(UserMainInfo::getUserId, userId, userMainInfoService);
|
|
||||||
UserMainInfo userMainInfo = userMainInfoService.getOne(userMainInfoLambdaQueryWrapper);
|
|
||||||
FundsItemVO fundsItemVO = commonService.copyProperties(userMainInfo, FundsItemVO.class);
|
|
||||||
List<FundsChange> fundsChangeList = commonService.findByFieldEqTargetField(FundsChange::getUserId, userId, fundsChangeService);
|
|
||||||
List<FundsChangeVO> 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<Page<WithdrawalApplyVO>> listWithdrawalApplyByPage(@Valid @RequestBody WithdrawalApplyQueryRequest withdrawalApplyQueryRequest) {
|
|
||||||
long current = withdrawalApplyQueryRequest.getCurrent();
|
|
||||||
long pageSize = withdrawalApplyQueryRequest.getPageSize();
|
|
||||||
QueryWrapper<WithdrawalApply> queryWrapper = withdrawalApplyService.getQueryWrapper(withdrawalApplyQueryRequest);
|
|
||||||
Page<WithdrawalApply> page = withdrawalApplyService.page(new Page<>(current, pageSize), queryWrapper);
|
|
||||||
List<WithdrawalApply> withdrawalApplyList = page.getRecords();
|
|
||||||
List<WithdrawalApplyVO> withdrawalApplyVOList = commonService.convertList(withdrawalApplyList, WithdrawalApplyVO.class);
|
|
||||||
Page<WithdrawalApplyVO> voPage = new Page<>(current, pageSize);
|
|
||||||
voPage.setRecords(withdrawalApplyVOList);
|
|
||||||
voPage.setPages(page.getPages());
|
|
||||||
voPage.setTotal(page.getTotal());
|
|
||||||
return ResultUtils.success(voPage);
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,6 +10,7 @@ import com.greenorange.promotion.common.BaseResponse;
|
|||||||
import com.greenorange.promotion.common.ErrorCode;
|
import com.greenorange.promotion.common.ErrorCode;
|
||||||
import com.greenorange.promotion.common.ResultUtils;
|
import com.greenorange.promotion.common.ResultUtils;
|
||||||
import com.greenorange.promotion.constant.UserConstant;
|
import com.greenorange.promotion.constant.UserConstant;
|
||||||
|
import com.greenorange.promotion.exception.BusinessException;
|
||||||
import com.greenorange.promotion.exception.ThrowUtils;
|
import com.greenorange.promotion.exception.ThrowUtils;
|
||||||
import com.greenorange.promotion.model.dto.CommonBatchRequest;
|
import com.greenorange.promotion.model.dto.CommonBatchRequest;
|
||||||
import com.greenorange.promotion.model.dto.CommonRequest;
|
import com.greenorange.promotion.model.dto.CommonRequest;
|
||||||
@ -30,6 +31,7 @@ import jakarta.annotation.Resource;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.ibatis.io.JBoss6VFS;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -303,6 +305,14 @@ public class UserInfoController {
|
|||||||
@RequiresPermission(mustRole = UserConstant.BOSS_ROLE)
|
@RequiresPermission(mustRole = UserConstant.BOSS_ROLE)
|
||||||
@SysLog(title = "用户管理", content = "web端管理员添加用户")
|
@SysLog(title = "用户管理", content = "web端管理员添加用户")
|
||||||
public BaseResponse<Boolean> addUserInfo(@Valid @RequestBody UserInfoAddRequest userInfoAddRequest) {
|
public BaseResponse<Boolean> addUserInfo(@Valid @RequestBody UserInfoAddRequest userInfoAddRequest) {
|
||||||
|
String userAccount = userInfoAddRequest.getUserAccount();
|
||||||
|
String userPassword = userInfoAddRequest.getUserPassword();
|
||||||
|
LambdaQueryWrapper<UserInfo> 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 userInfo = commonService.copyProperties(userInfoAddRequest, UserInfo.class);
|
||||||
userInfo.setParentUserId(-1L);
|
userInfo.setParentUserId(-1L);
|
||||||
userInfo.setUserRole(UserConstant.ADMIN_ROLE);
|
userInfo.setUserRole(UserConstant.ADMIN_ROLE);
|
||||||
|
@ -68,4 +68,5 @@ public interface UserInfoService extends IService<UserInfo> {
|
|||||||
* 查询从 userId 一路到根节点的所有 id,按 depth 倒序(根先出)
|
* 查询从 userId 一路到根节点的所有 id,按 depth 倒序(根先出)
|
||||||
*/
|
*/
|
||||||
List<Long> findPathToRoot(Long userId);
|
List<Long> findPathToRoot(Long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: test
|
active: practice
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user