hjl
2024-07-04 70af8656577dfc82b6f103eba1439a4e283f858e
fix: 学习端、家长端商城bug
4个文件已修改
84 ■■■■■ 已修改文件
ruoyi-api/ruoyi-api-goods/src/main/java/com/ruoyi/goods/api/domain/TGoods.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java 73 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-goods/src/main/java/com/ruoyi/goods/api/domain/TGoods.java
@@ -5,9 +5,7 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.web.domain.BaseModel;
import com.sun.xml.internal.ws.developer.Serialization;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
@@ -2,7 +2,6 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.GlobalException;
@@ -127,7 +126,7 @@
        wrapper.eq("isDelete", 0);
        // sort排序
        wrapper.orderByAsc("CASE WHEN sort IS NULL THEN 1 ELSE 0 END")
                .orderByAsc("sort")
                .orderByDesc("sort")
                .orderByDesc("createTime");
        return R.ok(goodsService.page(new PageInfo<>(goodQuery.getPageNumber(), goodQuery.getPageSize()), wrapper));
    }
@@ -602,7 +601,7 @@
        if (!Constants.ONE.equals(order.getState())) {
            throw new GlobalException("订单已发货,无法修改收货地址!");
        }
        order.setConsigneeName(recipient.getAddress());
        order.setConsigneeName(recipient.getRecipient());
        order.setConsigneePhone(recipient.getRecipientPhone());
        order.setConsigneeAddress(recipient.getProvince()+recipient.getCity()+recipient.getAddress());
        orderService.updateById(order);
@@ -628,7 +627,7 @@
        if (!Constants.ONE.equals(order.getState())) {
            throw new GlobalException("订单已发货,无法修改收货地址!");
        }
        order.setConsigneeName(recipient.getAddress());
        order.setConsigneeName(recipient.getRecipient());
        order.setConsigneePhone(recipient.getRecipientPhone());
        order.setConsigneeAddress(recipient.getProvince()+recipient.getCity()+recipient.getAddress());
        orderService.updateById(order);
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
@@ -874,8 +874,6 @@
        } else {
            result = null;
        }
        subjectRecordService.lambdaUpdate().set(TSubjectRecord::getDisabled, 0)
                .eq(TSubjectRecord::getUserId, loginStudy.getUserid()).update();
        return R.ok(result);
    }
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java
@@ -28,7 +28,6 @@
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.*;
@@ -70,6 +69,38 @@
    public R<TUser> getUserById(@PathVariable("id") Integer id) {
        TUser byId = userService.getById(id);
        return R.ok(byId);
    }
    @PostMapping("/vipInfoStudy")
    @ApiOperation(value = "会员中心-获取会员说明、当前登录用户是否为会员、会员购买规格", tags = {"学习端-个人中心"})
    public R<List<VipInfoVO>> vipInfoStudy() {
        if (tokenService.getLoginUserStudy() == null) {
            throw new GlobalException("登录失效!");
        }
        List<VipInfoVO> vipInfoVOS = new ArrayList<>();
        List<TVipSet> data = managementClient.getVipSet1().getData();
        for (TVipSet datum : data) {
            VipInfoVO vipInfoVO = new VipInfoVO();
            vipInfoVO.setInfo(datum.getInfo());
            vipInfoVO.setId(datum.getId());
            Integer userid = tokenService.getLoginUserStudy().getUserid();
            TUser byId = userService.getById(userid);
            // 先判断vipEndTime
            if (byId.getVipEndTime() == null) {
                vipInfoVO.setIsVip(0);
            } else {
                // 判断会员到期时间是否大于当前时间
                if (byId.getVipEndTime().getTime() > System.currentTimeMillis()) {
                    vipInfoVO.setIsVip(1);
                } else {
                    vipInfoVO.setIsVip(0);
                }
            }
            vipInfoVO.setTime(datum.getTime());
            vipInfoVO.setAmount(datum.getAmount());
            vipInfoVOS.add(vipInfoVO);
        }
        return R.ok(vipInfoVOS);
    }
    @PostMapping("/vipInfo")
@@ -176,7 +207,7 @@
        try {
            System.err.println("进入支付宝回调");
            Map<String, String> map = payMoneyUtil.alipayCallback(request);
            System.err.println("返回参数"+map);
            System.err.println("返回参数" + map);
            if (null != map) {
                String out_trade_no = map.get("out_trade_no");
                String trade_no = map.get("trade_no");
@@ -193,7 +224,7 @@
                String s1 = out_trade_no.split("_")[1];
                Integer integer1 = Integer.valueOf(s1);
                TVipOrder byId = vipOrderService.getById(integer1);
                if (byId.getBackTime()!=null){
                if (byId.getBackTime() != null) {
                    return;
                }
                byId.setPayState(2);
@@ -480,16 +511,16 @@
                    } else {
                        tUser1.setHeadImg("https://haitunyingyu.obs.cn-southwest-2.myhuaweicloud.com/admin/1c6ee218aa18434db2e86df903990de8.jpg");
                        tUser1 = getUser(phone);
                        tUser1.setAccount("用户"+UUIDUtil.getNumberRandom(6));
                        tUser1.setName("用户"+UUIDUtil.getNumberRandom(6));
                        tUser1.setAccount("用户" + UUIDUtil.getNumberRandom(6));
                        tUser1.setName("用户" + UUIDUtil.getNumberRandom(6));
                        userService.save(tUser1);
                    }
                }
            } else {
                tUser1 = getUser(phone);
                tUser1.setHeadImg("https://haitunyingyu.obs.cn-southwest-2.myhuaweicloud.com/admin/1c6ee218aa18434db2e86df903990de8.jpg");
                tUser1.setAccount("用户"+UUIDUtil.getNumberRandom(6));
                tUser1.setName("用户"+UUIDUtil.getNumberRandom(6));
                tUser1.setAccount("用户" + UUIDUtil.getNumberRandom(6));
                tUser1.setName("用户" + UUIDUtil.getNumberRandom(6));
                userService.save(tUser1);
            }
        }
@@ -561,8 +592,8 @@
        } else {
            user = getUser(phone);
            user.setHeadImg("https://haitunyingyu.obs.cn-southwest-2.myhuaweicloud.com/admin/1c6ee218aa18434db2e86df903990de8.jpg");
            user.setAccount("用户"+UUIDUtil.getNumberRandom(6));
            user.setName("用户"+UUIDUtil.getNumberRandom(6));
            user.setAccount("用户" + UUIDUtil.getNumberRandom(6));
            user.setName("用户" + UUIDUtil.getNumberRandom(6));
            userService.save(user);
        }
        // 生成登录用户信息
@@ -624,7 +655,7 @@
            @ApiImplicitParam(value = "类型 更换手机号的时候传该参数 传1", name = "type", dataType = "int"),
    })
    public R<?> sendPhoneCode(String phone, Integer type) throws Exception {
        if (type != null && type == 1){
        if (type != null && type == 1) {
            List<TUser> list = userService.list(new QueryWrapper<TUser>()
                    .eq("phone", phone)
                    .ne("state", 3));
@@ -632,11 +663,11 @@
                return R.fail("更换的手机号已被使用!");
            }
            LoginUserParent loginUser1 = tokenService.getLoginUser1();
            if (loginUser1==null){
            if (loginUser1 == null) {
                return R.tokenError("登录失效!");
            }
            TUser byId = userService.getById(loginUser1.getUserid());
            if (byId.getPhone().equals(phone)){
            if (byId.getPhone().equals(phone)) {
                return R.fail("更换的手机号不能和原手机号相同!");
            }
        }
@@ -773,7 +804,7 @@
            } else {
                byId.setIsVip(Constants.ONE);
            }
        }else{
        } else {
            byId.setIsVip(Constants.ZERO);
        }
        return R.ok(byId);
@@ -851,7 +882,7 @@
                Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone);
                if (null == redisPhoneCode) {
                    return R.errorCode("手机验证码无效");
                }else{
                } else {
                    // redis 验证码的value 为 code:时间戳
                    String rCodeAndTime = String.valueOf(redisPhoneCode);
                    String rCode = rCodeAndTime.split(":")[0];
@@ -938,7 +969,7 @@
            case 2:
                // 支付宝退款
                Map<String, String> stringStringMap1 = payMoneyUtil.aliRefund(transactionId, byId.getMoney().toString());
                System.err.println("支付宝退款数据"+ stringStringMap1);
                System.err.println("支付宝退款数据" + stringStringMap1);
                if (null == stringStringMap1) {
                    return R.fail("取消退款异常");
                }
@@ -946,7 +977,7 @@
                if (!"10000".equals(code)) {
                    return R.fail(stringStringMap1.get("return_msg"));
                }
                System.err.println("修改会员订单状态"+ byId);
                System.err.println("修改会员订单状态" + byId);
                byId.setPayState(3);
                byId.setBackTime(new Date());
                vipOrderService.updateById(byId);
@@ -968,7 +999,7 @@
                    byId1.setVipEndTime(null);
                    byId1.setVipPayTime(null);
                    userService.updateById(byId1);
                    userService.updateOne(byId1.getId(),null,null);
                    userService.updateOne(byId1.getId(), null, null);
                } else {
                    System.err.println("最近的一次充值会员时间  将会员到期时间回退到上一次");
                    // 最近的一次充值会员时间
@@ -1031,13 +1062,13 @@
                res.setIsVip(0);
            }
        }
        if (vipEndTime!=null){
        if (vipEndTime != null) {
            res.setVipPayTime(format.format(vipPayTime));
        }
        res.setState(byId.getState());
        res.setName(name);
        res.setPhone(phone);
        if (insertTime!=null){
        if (insertTime != null) {
            res.setInsertTime(format.format(insertTime));
        }
        res.setIntegral(byId.getIntegral());
@@ -1079,14 +1110,14 @@
        int sum = gameRecordList.stream().map(TGameRecord::getUseTime).mapToInt(Integer::intValue).sum();
        Integer totalStudy = studyRecord.getTotalStudy();
        studyRecord.setTotalStudy(Math.round((float) (totalStudy) / 3600));
        res.setCurrent(studyRecord.getWeek()+"");
        res.setCurrent(studyRecord.getWeek() + "");
        // 剩余周目
        List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0)
                .eq(TStudy::getType, Constants.ONE)
                .orderByAsc(TStudy::getWeek).list();
        int size = studyService.residueWeek(studyRecord, studyList);
        studyRecord.setSurplus(size);
        res.setSurplus(studyRecord.getSurplus()+"");
        res.setSurplus(studyRecord.getSurplus() + "");
        res.setTotalHours(studyRecord.getTotalStudy().doubleValue());
        res.setTodayHours(studyRecord.getTodayStudy().doubleValue());
        res.setMonthHours(studyRecord.getMonthStudy().doubleValue());