| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.admin.entity.*; |
| | | import com.ruoyi.admin.service.*; |
| | | import com.ruoyi.admin.vo.EvaluatePageVO; |
| | | import com.ruoyi.admin.vo.UserWithdrawRecordVO; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.admin.entity.User; |
| | | import com.ruoyi.admin.service.UserService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.order.api.entity.EvaluatePageVO; |
| | | import com.ruoyi.order.api.entity.Order; |
| | | import com.ruoyi.order.api.entity.UserWithdrawRecordVO; |
| | | import com.ruoyi.order.api.entity.WithdrawalSetting; |
| | | import com.ruoyi.order.api.feignClient.EvaluateClient; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | | import com.ruoyi.order.api.feignClient.WithdrawClient; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | public class UserManageController { |
| | | |
| | | @Resource |
| | | private OrderService orderService; |
| | | @Resource |
| | | private EvaluateService evaluateService; |
| | | @Resource |
| | | private WithdrawService withdrawService; |
| | | @Resource |
| | | private UserService userService; |
| | | @Resource |
| | | private WithdrawalSettingService withdrawalSettingService; |
| | | private OrderClient orderClient; |
| | | @Resource |
| | | private EvaluateClient evaluateClient; |
| | | @Resource |
| | | private WithdrawClient withdrawClient; |
| | | |
| | | /** |
| | | * 用户信息分页列表 |
| | |
| | | @ApiOperation(value = "用户详情-订单记录分页列表", tags = {"后台-用户管理-用户列表"}) |
| | | @GetMapping(value = "/orderList") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "用户id", name = "userId", dataType = "Integer"), |
| | | @ApiImplicitParam(value = "用户id", name = "userId", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "页码", name = "pageNum", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "每页条数", name = "pageSize", dataType = "Integer", required = true) |
| | | }) |
| | | public R<IPage<Order>> orderList(Integer userId, |
| | | public R<IPage<Order>> orderList(@RequestParam("userId") Integer userId, |
| | | @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | return R.ok(orderService.lambdaQuery().eq(Order::getUserId, userId) |
| | | .eq(Order::getIsDelete, 0).page(Page.of(pageNum, pageSize))); |
| | | return R.ok(orderClient.orderList(userId, pageNum, pageSize).getData()); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParam(value = "页码", name = "pageNum", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "每页条数", name = "pageSize", dataType = "Integer", required = true) |
| | | }) |
| | | public R<IPage<EvaluatePageVO>> evaluateList(Integer userId, |
| | | public R<Page<EvaluatePageVO>> evaluateList(Integer userId, |
| | | @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | return R.ok(evaluateService.evaluateList(userId, Page.of(pageNum, pageSize))); |
| | | return evaluateClient.evaluateList(userId, pageNum, pageSize); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "评价记录id", name = "id", dataType = "Integer", required = true) |
| | | }) |
| | | public R<Void> deleteEvaluateRecord(@RequestParam Integer id) { |
| | | Evaluate evaluate = evaluateService.getById(id); |
| | | evaluate.setIsDelete(1); |
| | | return evaluateService.updateById(evaluate) ? R.ok() : R.fail(); |
| | | public R<String> deleteEvaluateRecord(@RequestParam Integer id) { |
| | | return evaluateClient.batchDelete(String.valueOf(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParam(value = "审核状态(0:未开启,1:已开启)", name = "enableProcess", dataType = "Integer", required = true) |
| | | }) |
| | | public R<Boolean> enableProcess(@RequestParam("enableProcess") Integer enableProcess) { |
| | | return R.ok(withdrawService.enableProcess(enableProcess)); |
| | | return withdrawClient.enableProcess(enableProcess); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @GetMapping(value = "/withdrawProcess") |
| | | public R<WithdrawalSetting> withdrawProcess() { |
| | | return R.ok(withdrawService.withdrawProcess()); |
| | | return withdrawClient.withdrawProcess(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "全局审核状态", tags = {"后台-用户管理-用户列表"}) |
| | | @GetMapping(value = "/withdrawState") |
| | | public R<WithdrawalSetting> withdrawState() { |
| | | // 全局审核设置 |
| | | WithdrawalSetting setting = withdrawalSettingService.lambdaQuery().one(); |
| | | return R.ok(setting); |
| | | return withdrawClient.withdrawProcess(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParam(value = "页码", name = "pageNum", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "每页条数", name = "pageSize", dataType = "Integer", required = true) |
| | | }) |
| | | public R<IPage<UserWithdrawRecordVO>> withdrawList(@RequestParam Integer userId, |
| | | public R<Page<UserWithdrawRecordVO>> withdrawList(@RequestParam Integer userId, |
| | | @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | return R.ok(withdrawService.withdrawList(userId, Page.of(pageNum, pageSize))); |
| | | return withdrawClient.withdrawList(userId, pageNum, pageSize); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "提现记录id", name = "id", dataType = "Integer", required = true) |
| | | }) |
| | | public R<Void> deleteWithdrawRecord(@RequestParam Integer id) { |
| | | Withdraw withdraw = withdrawService.getById(id); |
| | | withdraw.setIsDelete(1); |
| | | return withdrawService.updateById(withdraw) ? R.ok() : R.fail(); |
| | | public R<String> deleteWithdrawRecord(@RequestParam Integer id) { |
| | | return withdrawClient.batchDelete(String.valueOf(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @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(); |
| | | com.ruoyi.order.api.entity.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()) |
| | | 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("订单信息异常!"); |
| | | if (null == user) { |
| | | throw new GlobalException("提交申请的用户信息不存在!"); |
| | | } |
| | | Boolean b = withdrawService.confirmWithdraw(user, order); |
| | | 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("审批失败!"); |
| | | } |
| | | update = update && withdrawService.updateById(withdraw); |
| | | return update ? R.ok(null, "审批成功!") : R.fail("审批失败!"); |
| | | } |
| | | |
| | | } |