无关风月
2024-07-03 0aa266f982339c78de8c441652f07f6e5de0d158
bug修改
3个文件已修改
94 ■■■■■ 已修改文件
ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/TGoodsServiceImpl.java 67 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
@@ -596,7 +596,7 @@
        }
        order.setConsigneeName(recipient.getAddress());
        order.setConsigneePhone(recipient.getRecipientPhone());
        order.setConsigneeAddress(recipient.getAddress());
        order.setConsigneeAddress(recipient.getProvince()+recipient.getCity()+recipient.getAddress());
        orderService.updateById(order);
        return R.ok();
    }
@@ -622,7 +622,7 @@
        }
        order.setConsigneeName(recipient.getAddress());
        order.setConsigneePhone(recipient.getRecipientPhone());
        order.setConsigneeAddress(recipient.getAddress());
        order.setConsigneeAddress(recipient.getProvince()+recipient.getCity()+recipient.getAddress());
        orderService.updateById(order);
        return R.ok();
    }
ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/TGoodsServiceImpl.java
@@ -193,41 +193,13 @@
        }
        return R.ok();
    }
    private Boolean exchangeGood(GoodExchangeDTO goodExchange, Recipient recipient, Integer number,
                                 Integer goodId, int needIntegral) {
        // 兑换成功,生成订单信息、生成积分明细(积分明细需要远程调用rouyi-study服务)
        TOrder order = orderInfo(goodExchange, recipient, number, goodId, needIntegral);
        order.setProvince(recipient.getProvince());
        order.setCity(recipient.getCity());
        boolean result = orderService.save(order);
        // 远程调用,生成积分明细
        result = result && studyClient.addIntegralDetail(Constants.BURDEN + needIntegral, Constants.SHOPPING_CONSUME).getData();
        // 扣除用户积分
        result = result && studyClient.exchangeIntegral(needIntegral, Constants.BURDEN).getData();
        return result;
    }
    private Boolean exchangeGoodParent(GoodExchangeDTO goodExchange, Recipient recipient, Integer number,
                                       Integer goodId, int needIntegral) {
        // 兑换成功,生成订单信息、生成积分明细(积分明细需要远程调用rouyi-study服务)
        TOrder order = orderInfoParent(goodExchange, recipient, number, goodId, needIntegral);
        order.setProvince(recipient.getProvince());
        order.setCity(recipient.getCity());
        boolean result = orderService.save(order);
        // 远程调用,生成积分明细
        result = result && studyClient.addIntegralDetailParent(Constants.BURDEN + needIntegral, Constants.SHOPPING_CONSUME).getData();
        // 扣除用户积分
        result = result && studyClient.exchangeIntegralParent(needIntegral, Constants.BURDEN).getData();
        return result;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R goodExchange1(GoodExchangeDTO goodExchange, Recipient recipient) {
        // 用户本次兑换数量
        Integer number = goodExchange.getNumber();
        Integer goodId = goodExchange.getGoodId();
        TGoods good = this.getById(goodId);
        TGoods good = lambdaQuery().eq(TGoods::getId, goodId).one();
        if (null == good) {
            return R.exchangeError("商品不存在,请稍后重试!");
        }
@@ -262,6 +234,7 @@
            // 检查用户兑换数量是否超过单用户最大兑换数量
            List<TOrder> orderList = orderService.lambdaQuery().eq(TOrder::getUserId, user.getId())
                    .eq(TOrder::getGoodsId, goodId).list();
            // 用户已兑换数量
            int totalNumber;
            if (orderList.isEmpty()) {
                totalNumber = 0;
@@ -295,9 +268,6 @@
            }
            // 兑换成功,生成订单信息、生成积分明细(积分明细需要远程调用rouyi-study服务)
            boolean result = exchangeGoodParent(goodExchange, recipient, number, goodId, needIntegral);
            // 扣除库存
            result = result && this.lambdaUpdate().set(TGoods::getTotal, good.getTotal() - number)
                    .eq(TGoods::getId, good.getId()).update();
            if (!result) {
                semaphore.release(number);
                return R.exchangeError("商品兑换失败!");
@@ -316,7 +286,7 @@
                            .stream().mapToInt(Integer::intValue).sum();
                }
                Integer userCount = good.getUserCount();
                if (good.getUserCount() > totalNumber) {
                if (userCount > totalNumber) {
                    int i = userCount - totalNumber;
                    if (number > i) {
                        return R.exchangeError("兑换失败,当前兑换数量已超过最大兑换数量,剩余兑换数量为: " +
@@ -333,6 +303,35 @@
        }
        return R.ok();
    }
    private Boolean exchangeGood(GoodExchangeDTO goodExchange, Recipient recipient, Integer number,
                                 Integer goodId, int needIntegral) {
        // 兑换成功,生成订单信息、生成积分明细(积分明细需要远程调用rouyi-study服务)
        TOrder order = orderInfo(goodExchange, recipient, number, goodId, needIntegral);
        order.setProvince(recipient.getProvince());
        order.setCity(recipient.getCity());
        boolean result = orderService.save(order);
        // 远程调用,生成积分明细
        result = result && studyClient.addIntegralDetail(Constants.BURDEN + needIntegral, Constants.SHOPPING_CONSUME).getData();
        // 扣除用户积分
        result = result && studyClient.exchangeIntegral(needIntegral, Constants.BURDEN).getData();
        return result;
    }
    private Boolean exchangeGoodParent(GoodExchangeDTO goodExchange, Recipient recipient, Integer number,
                                       Integer goodId, int needIntegral) {
        // 兑换成功,生成订单信息、生成积分明细(积分明细需要远程调用rouyi-study服务)
        TOrder order = orderInfoParent(goodExchange, recipient, number, goodId, needIntegral);
        order.setProvince(recipient.getProvince());
        order.setCity(recipient.getCity());
        boolean result = orderService.save(order);
        // 远程调用,生成积分明细
        result = result && studyClient.addIntegralDetailParent(Constants.BURDEN + needIntegral, Constants.SHOPPING_CONSUME).getData();
        // 扣除用户积分
        result = result && studyClient.exchangeIntegralParent(needIntegral, Constants.BURDEN).getData();
        return result;
    }
    @Override
    public void updateOne(TGoods dto) {
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java
@@ -28,6 +28,7 @@
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
@@ -617,8 +618,25 @@
    @ApiOperation(value = "发送手机验证码", tags = {"家长端/学习端-发送手机验证码"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "手机号", name = "phone", dataType = "string", required = true),
            @ApiImplicitParam(value = "类型 更换手机号的时候传该参数 传1", name = "type", dataType = "int"),
    })
    public R<?> sendPhoneCode(@RequestParam String phone) throws Exception {
    public R<?> sendPhoneCode(String phone, Integer type) throws Exception {
        if (type != null && type == 1){
            List<TUser> list = userService.list(new QueryWrapper<TUser>()
                    .eq("phone", phone)
                    .ne("state", 3));
            if (!list.isEmpty()) {
                return R.fail("更换的手机号已被使用!");
            }
            LoginUserParent loginUser1 = tokenService.getLoginUser1();
            if (loginUser1==null){
                return R.tokenError("登录失效!");
            }
            TUser byId = userService.getById(loginUser1.getUserid());
            if (byId.getPhone().equals(phone)){
                return R.fail("更换的手机号不能和原手机号相同!");
            }
        }
        return userService.phoneCode(phone) ? R.ok() : R.fail();
    }
@@ -925,6 +943,7 @@
                if (!"10000".equals(code)) {
                    return R.fail(stringStringMap1.get("return_msg"));
                }
                System.err.println("修改会员订单状态"+ byId);
                byId.setPayState(3);
                byId.setBackTime(new Date());
                vipOrderService.updateById(byId);
@@ -941,11 +960,13 @@
                        .orderByDesc("createTime"));
                int size = list.size();
                if (size == 0) {
                    System.err.println("证明这是用户第一次充值会员 将首次充值会员时间和会员到期时间清空");
                    // 证明这是用户第一次充值会员 将首次充值会员时间和会员到期时间清空
                    byId1.setVipEndTime(null);
                    byId1.setVipPayTime(null);
                    userService.updateById(byId1);
                } else {
                    System.err.println("最近的一次充值会员时间  将会员到期时间回退到上一次");
                    // 最近的一次充值会员时间
                    TVipOrder tVipOrder = list.get(0);
                    // 将会员到期时间回退到上一次