From b5ead35c1d955f2a0e2e10da79254860d0ba95e9 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期五, 23 五月 2025 14:50:27 +0800 Subject: [PATCH] 大屏接口bug修改 --- ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/UserController.java | 120 +++++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 90 insertions(+), 30 deletions(-) diff --git a/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/UserController.java b/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/UserController.java index 0bfcc23..5373775 100644 --- a/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/UserController.java +++ b/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/UserController.java @@ -1,33 +1,36 @@ package com.ruoyi.user.controller; +import cn.hutool.core.util.RandomUtil; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.ruoyi.admin.api.entity.*; import com.ruoyi.admin.api.feignClient.AdminClient; import com.ruoyi.common.core.constant.Constants; import com.ruoyi.common.core.constant.RedisConstants; +import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.GlobalException; import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.core.vo.AddressDto; +import com.ruoyi.common.core.vo.UserDto; import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.system.api.model.LoginUserInfo; -import com.ruoyi.user.entity.RecoveryClassify; -import com.ruoyi.user.entity.RecoveryServe; -import com.ruoyi.user.entity.User; +import com.ruoyi.user.entity.*; import com.ruoyi.user.request.LoginPhoneRequest; -import com.ruoyi.user.service.RecoveryClassifyService; -import com.ruoyi.user.service.RecoveryServeService; -import com.ruoyi.user.service.UserService; +import com.ruoyi.user.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -57,6 +60,14 @@ private RecoveryClassifyService recoveryClassifyService; @Resource private RecoveryServeService recoveryServeService; + @Resource + private UserRecipientService userRecipientService; + + /** + * 用户端默认头像 + */ + @Value("${default.profilePicture}") + private String profilePicture; /** * 解密用户敏感数据 @@ -105,13 +116,13 @@ // 手机验证码校验获取缓存验证码 Object phoneCodeRedis = redisService.getCacheObject(RedisConstants.USER_LOGIN_PHONE_CODE + phone); if (null == phoneCodeRedis) { - return R.errorCode("登录失败,验证码已过期!"); + return R.errorCode("验证码错误!"); } else { // redis 验证码的value 为 code:时间戳 String rCodeAndTime = String.valueOf(phoneCodeRedis); String rCode = rCodeAndTime.split(":")[0]; if (!rCode.equalsIgnoreCase(phoneCode)) { - return R.errorCode("登录失败,验证码无效!"); + return R.errorCode("验证码错误!"); } } } @@ -120,14 +131,15 @@ .eq(User::getIsDelete, 0).one(); if (null != user) { if (!Constants.ONE.equals(user.getState())) { - return R.notEnabled("登录失败,当前账号未启用!"); + return R.notEnabled("账号已被禁用,请联系平台管理员。"); } } else { user = new User(); // 随机编号 - user.setUserNo(String.format(Constants.USER_NO_PRE, StringUtils.getCharAndNum(Constants.SIX))); + user.setUserNo(String.format(Constants.USER_NO_PRE, RandomUtil.randomNumbers(Constants.EIGHT))); user.setState(Constants.ONE); - user.setNickname(phone); + user.setProfilePicture(profilePicture); + user.setNickname(String.format(Constants.USER_NO_PRE, StringUtils.getCharAndNum(Constants.SIX))); user.setPhone(phone); user.setCity(loginPhoneRequest.getCity()); user.setOpenId(loginPhoneRequest.getOpenId()); @@ -151,13 +163,17 @@ @ApiOperation(value = "用户注册协议/用户隐私协议", tags = {"用户端-登录"}) @GetMapping(value = "/registerOrAgreement") @ApiImplicitParams({ - @ApiImplicitParam(value = "0:用户注册协议、1:用户隐私协议", name = "type", dataType = "Integer", required = true) + @ApiImplicitParam(value = "0:用户注册协议、1:用户隐私协议;3:服务规则管理", name = "type", dataType = "Integer", required = true) }) public R<Agreement> registerOrAgreement(@RequestParam Integer type) { - if (!Constants.ZERO.equals(type) && !Constants.ONE.equals(type)) { + if (!Constants.ZERO.equals(type) && !Constants.ONE.equals(type) && !Constants.THREE.equals(type)) { throw new GlobalException("获取类型异常!"); } - return R.ok(adminClient.dataInfo(type).getData()); + R<Agreement> r = adminClient.agreementPolicy(type); + if (500 == r.getCode()) { + return R.fail(r.getMsg()); + } + return R.ok(r.getData()); } /** @@ -166,21 +182,25 @@ @ApiOperation(value = "轮播图列表", tags = {"用户端-首页"}) @GetMapping(value = "/banner") public R<List<Rotate>> banner() { - List<Rotate> data = adminClient.bannerList().getData(); + R<List<Rotate>> r = adminClient.bannerList(); + List<Rotate> data = r.getData(); + if (null == data) { + return R.fail(r.getMsg()); + } for (Rotate datum : data) { RecoveryServe recoveryServe = recoveryServeService.lambdaQuery() - .eq(RecoveryServe::getId, datum.getId()) - .eq(RecoveryServe::getIsDelete, 0).one(); - Integer classifyId = recoveryServe.getClassifyId(); - RecoveryClassify classify = recoveryClassifyService.lambdaQuery() - .eq(RecoveryClassify::getId, classifyId) - .eq(RecoveryClassify::getIsDelete, 0).one(); - if (null != classify) { - String supClassify = classify.getSupClassify(); - if (Constants.RECOVERY.equals(supClassify)) { - datum.setType(Constants.ONE); - } else { - datum.setType(Constants.ZERO); + .eq(RecoveryServe::getId, datum.getRotateServeId()).one(); + if (null != recoveryServe) { + Integer classifyId = recoveryServe.getClassifyId(); + RecoveryClassify classify = recoveryClassifyService.lambdaQuery() + .eq(RecoveryClassify::getId, classifyId).one(); + if (null != classify) { + String supClassify = classify.getSupClassify(); + if (Constants.RECOVERY.equals(supClassify)) { + datum.setType(Constants.ONE); + } else { + datum.setType(Constants.ZERO); + } } } } @@ -230,7 +250,8 @@ @ApiOperation(value = "首页回收分类推荐", tags = {"用户端-首页"}) public R<List<RecoveryClassify>> recommend() { return R.ok(recoveryClassifyService.lambdaQuery().eq(RecoveryClassify::getIsRecommend, Constants.ONE) - .eq(RecoveryClassify::getIsDelete, 0).orderByAsc(RecoveryClassify::getSort).list()); + .eq(RecoveryClassify::getIsDelete, 0).orderByDesc(RecoveryClassify::getSort) + .orderByDesc(RecoveryClassify::getCreateTime).list()); } /** @@ -244,10 +265,10 @@ public R<List<RecoveryServe>> recoverySearch(@RequestParam String keyword) { LambdaQueryChainWrapper<RecoveryServe> wrapper = recoveryServeService.lambdaQuery() .eq(RecoveryServe::getIsDelete, 0) - .orderByAsc(RecoveryServe::getSort); + .orderByDesc(RecoveryServe::getSort); wrapper = null != keyword && !"".equals(keyword.trim()) ? wrapper.like(RecoveryServe::getServeName, keyword) : wrapper; - List<RecoveryServe> serveList = wrapper.list(); + List<RecoveryServe> serveList = wrapper.orderByDesc(RecoveryServe::getCreateTime).list(); for (RecoveryServe recoveryServe : serveList) { RecoveryClassify classify = recoveryClassifyService.lambdaQuery() .eq(RecoveryClassify::getId, recoveryServe.getClassifyId()).one(); @@ -262,6 +283,45 @@ return R.ok(serveList); } + + @PostMapping(value = "/getUser") + public R<UserDto> updateWithdrawalState(@RequestParam("userId") Integer userId) { + + User byId = userService.getById(userId); + UserDto userDto = new UserDto(); + BeanUtils.copyProperties(byId,userDto); + return R.ok(userDto); + + } + +// @ApiOperation(value = "订单列表-更改订单提现状态", tags = {"后台-订单管理"}) + @PostMapping(value = "/getCityCode") + public R<AddressDto> getCityCode(@RequestParam("addressId") Integer addressId) { + UserRecipient byId = userRecipientService.getById(addressId); + AddressDto userDto = new AddressDto(); + userDto.setCityCode(byId.getCityCode()); + userDto.setCity(byId.getCity()); + userDto.setName(byId.getName()); + userDto.setDetail(byId.getAddressDetail()); + return R.ok(userDto); + + } + + + @Resource + private RecoveryServePriceService recoveryServePriceService; + + @PostMapping(value = "/getServePrice") + public R<BigDecimal> getServePrice(@RequestParam("serveId") Integer serveId, @RequestParam("cityCode") String cityCode) { + RecoveryServePrice one = recoveryServePriceService.lambdaQuery().eq(RecoveryServePrice::getRecoveryServeId, serveId).eq(RecoveryServePrice::getCity, cityCode).eq(RecoveryServePrice::getIsDelete, 0).one(); + if (one==null){ + return R.ok(null); + } + return R.ok(one.getRecoveryPrice()); + + } + + /** * 用户端-个人中心用户信息 */ -- Gitblit v1.7.1