From 67d06a785d5fc4524639ace27651c01ff05a4b58 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期四, 29 五月 2025 22:31:33 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java |   48 +++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java
index 52dfdb0..d5e2f68 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java
@@ -1,6 +1,9 @@
 package com.ruoyi.other.service.impl;
 
+import com.ruoyi.common.core.dto.AppGoodQuery;
+import com.ruoyi.common.core.web.page.BasePage;
 import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.order.api.feignClient.OrderClient;
 import com.ruoyi.other.api.domain.TGoods;
 import com.ruoyi.other.api.dto.GoodsDTO;
 import com.ruoyi.other.mapper.TGoodsMapper;
@@ -10,6 +13,7 @@
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -24,7 +28,7 @@
 public class TGoodsServiceImpl extends ServiceImpl<TGoodsMapper, TGoods> implements TGoodsService {
 
     @Autowired
-    private OrderClient goodsClient;
+    private OrderClient orderClient;
     @Override
     public PageInfo<TGoods> pageList(GoodsDTO dto) {
         PageInfo<TGoods> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize());
@@ -38,9 +42,47 @@
             // 去除最后一个字符
             stringBuilder.deleteCharAt(stringBuilder.length()-1);
         }
+        if (list.isEmpty()) {
+            pageInfo.setRecords(list);
+            return pageInfo;
+        }
         String string = stringBuilder.toString();
-//        goodsClient
-        // 远程调用cha'xun
+        // 订单号加上商品类型
+        String res = string+"-"+dto.getType();
+
+        List<Integer> data = orderClient.getSalesCountByGoodsId(res).getData();
+        for (int i = 0; i < list.size(); i++) {
+            list.get(i).setSalesCount(data.get(i));
+        }
+        pageInfo.setRecords(list);
+        return pageInfo;
+    }
+    @Override
+    public PageInfo<TGoods> pageList1(AppGoodQuery basePage) {
+        GoodsDTO dto = new GoodsDTO();
+        dto.setStatus(1);
+        dto.setPageCurr(basePage.getPageCurr());
+        dto.setPageSize(basePage.getPageSize());
+        PageInfo<TGoods> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize());
+        List<TGoods> list = this.baseMapper.pageList1(pageInfo,basePage);
+
+        StringBuilder stringBuilder = new StringBuilder();
+        for (TGoods temp : list) {
+            stringBuilder.append(temp.getId()).append(",");
+        }
+        if (StringUtils.hasLength(stringBuilder)){
+            // 去除最后一个字符
+            stringBuilder.deleteCharAt(stringBuilder.length()-1);
+        }
+        if (list.isEmpty()) {
+            pageInfo.setRecords(list);
+            return pageInfo;
+        }
+        for (TGoods tGoods : list) {
+            Integer data = orderClient.getSalesCountByGoodsIdgetCount(tGoods.getId(), tGoods.getGoodType(), basePage.getType()).getData();
+            tGoods.setSalesCount(data);
+        }
+
         pageInfo.setRecords(list);
         return pageInfo;
     }

--
Gitblit v1.7.1