首页数据

This commit is contained in:
liuyingfang
2024-04-08 17:35:32 +08:00
parent 934a116cf2
commit 22bb4c6d15
10 changed files with 380 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto;
import com.chaozhanggui.system.cashierservice.entity.vo.*;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.Threads;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -36,6 +37,8 @@ public class HomePageService {
private TbProductMapper productMapper;
@Resource
private SysDictDetailMapper sysDictDetailMapper;
@Resource
private TagProductDeptsMapper tagProductDeptsMapper;
public Result homePage(HomeDto homeDto,String environmen) throws ExecutionException, InterruptedException {
@@ -50,9 +53,11 @@ public class HomePageService {
//统计shopId以及productId
List<String> shopIds = new ArrayList<>();
List<String> productIds = new ArrayList<>();
List<Integer> productIdsInt = new ArrayList<>();
for (TbMerchantCoupon coupon : tbMerchantCoupons) {
shopIds.add(coupon.getShopId());
productIds.add(coupon.getRelationIds());
productIdsInt.add(Integer.valueOf(coupon.getRelationIds()));
}
CompletableFuture<List<TbShopInfo>> shopInfo = CompletableFuture.supplyAsync(() ->
shopInfoMapper.selectByIds(shopIds));
@@ -60,26 +65,21 @@ public class HomePageService {
productMapper.selectByIds((productIds)));
CompletableFuture<List<TbProductSku>> productSku = CompletableFuture.supplyAsync(() ->
productSkuMapper.selectSkus((productIds)));
CompletableFuture<List<TbPlatformDict>> dictPro = CompletableFuture.supplyAsync(() ->
platformDictMapper.queryAllByType("proTag",environmen));
CompletableFuture<List<TbPlatformDict>> dictShop = CompletableFuture.supplyAsync(() ->
platformDictMapper.queryAllByType("shopTag",environmen));
Threads.call(shopInfo,product,productSku,dictPro,dictShop);
boolean isFirstAdded = true;
CompletableFuture<List<TagProductVO>> dictPro = CompletableFuture.supplyAsync(() ->
tagProductDeptsMapper.queryTagAndProduct(productIdsInt));
Threads.call(shopInfo,product,productSku,dictPro);
//组装
List<HomeVO> homeVOList = new ArrayList<>();
for (TbMerchantCoupon o :tbMerchantCoupons) {
HomeVO homeVO = new HomeVO();
homeVO.setDiscount(o.getRatio());
if (isFirstAdded){
homeVO.setShopTag(dictShop.get().get(0).getName());
homeVO.setProTag(dictPro.get().get(0).getName());
isFirstAdded = false;
}
for (TbShopInfo tbShopInfo : shopInfo.get()) {
if (o.getShopId().equals(tbShopInfo.getId().toString())) {
homeVO.setShopName(tbShopInfo.getShopName());
homeVO.setImage(tbShopInfo.getLogo());
TbPlatformDict tbPlatformDict = platformDictMapper.queryById(Integer.valueOf(tbShopInfo.getTag()));
homeVO.setShopTag(tbPlatformDict == null?"":tbPlatformDict.getName());
}
}
for (TbProduct tbProduct :product.get()) {
@@ -99,6 +99,12 @@ public class HomePageService {
homeVO.setSave(homeVO.getOriginPrice().subtract(homeVO.getSalePrice()));
}
}
for (TagProductVO tagProductVO :dictPro.get()) {
if (o.getRelationIds().equals(tagProductVO.getProductId().toString())){
homeVO.setProTag(tagProductVO.getTags());
}
}
homeVO.setEndTime(DateUtils.getTodayEndTimeAsString());
homeVOList.add(homeVO);
}