From cb7edabb2232bc9901725d562a2b4ec56d174a07 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期五, 05 七月 2024 11:32:57 +0800
Subject: [PATCH] bug修改

---
 ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
index 247be0d..796b60c 100644
--- a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
+++ b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
@@ -223,7 +223,7 @@
     @ApiOperation(value = "修改", tags = {"后台-商品管理"})
     public R updateGoods(@RequestBody TGoods dto) {
         TGoods byId = goodsService.getById(dto.getId());
-        if (!Objects.equals(byId.getTotal(), dto.getTotal())){
+        if (byId.getTotal()!=null && dto.getTotal()!=null &&!Objects.equals(byId.getTotal(), dto.getTotal())){
             // 如果修改了商品总数 那么需要再判断当前商品已被购买了多少
             List<TOrder> list = orderService.list(new QueryWrapper<TOrder>()
                     .eq("goodsId", dto.getId()));
@@ -232,7 +232,7 @@
                 temp += tOrder.getCount();
             }
             if (dto.getTotal()<temp){
-                return R.fail("商品总数不能小于当前商品已兑换数量,"+"当前商品已兑换数量为:"+temp);
+                return R.fail("商品总数不能小于当前商品已兑换数量,"+"当前商品已兑换数量为:"+temp);
             }
         }
         goodsService.updateById(dto);
@@ -265,12 +265,13 @@
      */
     @GetMapping("/exchangeRecord")
     @ApiOperation(value = "学习端-兑换记录", tags = {"学习端-商城"})
-    public R<List<ExchangeRecordVO>> exchangeRecord() {
+    public R<PageInfo<ExchangeRecordVO>> exchangeRecord(Integer pageNumber,Integer pageSize) {
+        PageInfo<ExchangeRecordVO> res = new PageInfo<>(pageNumber, pageSize);
         LoginUserParent loginUserStudy = tokenService.getLoginUserStudy();
         if (null == loginUserStudy) {
             return R.tokenError("登录失效!");
         }
-        List<ExchangeRecordVO> exchangeRecord = orderService.exchangeRecord(tokenService.getLoginUserStudy().getUserid());
+        List<ExchangeRecordVO> exchangeRecord = orderService.exchangeRecord(res,tokenService.getLoginUserStudy().getUserid());
         for (ExchangeRecordVO record : exchangeRecord) {
             TGoods goods = goodsService.getById(record.getGoodsId());
             List<String> typeList;
@@ -283,16 +284,19 @@
             }
             record.setGoodsType(typeList);
         }
-        return R.ok(exchangeRecord);
+        res.setRecords(exchangeRecord);
+        res.setTotal(exchangeRecord.size());
+        return R.ok(res);
     }
 
     @GetMapping("/exchangeRecordParent")
     @ApiOperation(value = "家长端-兑换记录", tags = {"家长端-兑换记录"})
-    public R<List<ExchangeRecordVO>> exchangeRecordParent() {
+    public R<PageInfo<ExchangeRecordVO>> exchangeRecordParent(Integer pageNumber,Integer pageSize) {
+        PageInfo<ExchangeRecordVO> res = new PageInfo<>(pageNumber, pageSize);
         if (tokenService.getLoginUser1() == null) {
             return R.tokenError("登录失效");
         }
-        List<ExchangeRecordVO> exchangeRecord = orderService.exchangeRecord(tokenService.getLoginUser1().getUserid());
+        List<ExchangeRecordVO> exchangeRecord = orderService.exchangeRecord(res,tokenService.getLoginUser1().getUserid());
         for (ExchangeRecordVO record : exchangeRecord) {
             TGoods goods = goodsService.getById(record.getGoodsId());
             List<String> typeList;
@@ -305,7 +309,9 @@
             }
             record.setGoodsType(typeList);
         }
-        return R.ok(exchangeRecord);
+        res.setRecords(exchangeRecord);
+        res.setTotal(exchangeRecord.size());
+        return R.ok(res);
     }
 
     /**

--
Gitblit v1.7.1