From 51de7e6b1a7b68c76b8dcb385013a0c06466b81c Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期二, 22 十月 2024 11:49:26 +0800
Subject: [PATCH] 合并代码
---
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 46 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 c584e2f..b9f434d 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,5 +1,7 @@
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;
@@ -11,6 +13,7 @@
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -39,11 +42,51 @@
// 去除最后一个字符
stringBuilder.deleteCharAt(stringBuilder.length()-1);
}
+ if (list.isEmpty()) {
+ pageInfo.setRecords(list);
+ return pageInfo;
+ }
String string = stringBuilder.toString();
- List<Integer> data = orderClient.getSalesCountByGoodsId(string).getData();
+ // 订单号加上商品类型
+ String res = string+"-"+dto.getType();
-// goodsClient
- // 远程调用cha'xun
+ 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.setType(2);
+ 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;
+ }
+ String string = stringBuilder.toString();
+ // 订单号加上商品类型
+ 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;
}
--
Gitblit v1.7.1