GoodsDonFrontServiceImpl.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package com.cyksj.service.goods.impl;
  2. import cn.hutool.core.collection.CollUtil;
  3. import cn.hutool.core.util.StrUtil;
  4. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  5. import com.cyksj.common.util.Jsons;
  6. import com.cyksj.mapper.GoodsDonSpecMapper;
  7. import com.cyksj.model.dto.RealGoodsConfigDto;
  8. import com.cyksj.model.entity.GoodsDonSpec;
  9. import com.cyksj.model.entity.HomeManagementConfig;
  10. import com.cyksj.model.manage.request.ReqGoodsSkuSpec;
  11. import com.cyksj.model.views.GoodsDonDetailFrontView;
  12. import com.cyksj.model.views.HomeManagementFrontView;
  13. import com.cyksj.service.goods.GoodsDonFrontService;
  14. import com.ejlchina.searcher.BeanSearcher;
  15. import com.ejlchina.searcher.param.Operator;
  16. import com.ejlchina.searcher.util.MapUtils;
  17. import lombok.RequiredArgsConstructor;
  18. import org.springframework.stereotype.Service;
  19. import java.util.ArrayList;
  20. import java.util.HashMap;
  21. import java.util.List;
  22. import java.util.Map;
  23. /**
  24. * 项目名: yhlxj
  25. * 文件名: GoodsDonFrontServiceImpl
  26. * 创建者: JavaZou
  27. * 创建时间:2023/10/19 17:53
  28. */
  29. @Service
  30. @RequiredArgsConstructor
  31. public class GoodsDonFrontServiceImpl implements GoodsDonFrontService {
  32. private final BeanSearcher beanSearcher;
  33. private final GoodsDonSpecMapper goodsDonSpecMapper;
  34. @Override
  35. public List<HomeManagementFrontView> getRealGoodsConfig() throws Exception {
  36. List<HomeManagementFrontView> realGoodsConfigList = beanSearcher.searchAll(HomeManagementFrontView.class, MapUtils.builder().field(HomeManagementFrontView::getType, HomeManagementConfig.Type.rg.name()).build());
  37. Map<String, List<RealGoodsConfigDto>> map = new HashMap<>();
  38. List<ReqGoodsSkuSpec> reqGoodsSkuSpecList = null;
  39. for (HomeManagementFrontView realGoodsConfig : realGoodsConfigList) {
  40. if (StrUtil.isEmpty(realGoodsConfig.getTitle())) {
  41. continue;
  42. }
  43. boolean isCtRoute = realGoodsConfig.getTitle().contains("路由器");
  44. boolean isCtApple = realGoodsConfig.getTitle().contains("Apple");
  45. if (isCtRoute || isCtApple) {
  46. List<RealGoodsConfigDto> subInfoList = new ArrayList<>();
  47. String type = null;
  48. if (CollUtil.isEmpty(reqGoodsSkuSpecList)) {
  49. GoodsDonSpec goodsDonSpec = goodsDonSpecMapper.selectOne(Wrappers.lambdaQuery(GoodsDonSpec.class)
  50. .eq(GoodsDonSpec::getGoodsId, 15).last("limit 1")
  51. .select(GoodsDonSpec::getSpecsJson));
  52. reqGoodsSkuSpecList = Jsons.parseList(goodsDonSpec.getSpecsJson(), ReqGoodsSkuSpec.class);
  53. }
  54. if (CollUtil.isEmpty(realGoodsConfigList)) {
  55. continue;
  56. }
  57. for (ReqGoodsSkuSpec reqGoodsSkuSpec : reqGoodsSkuSpecList) {
  58. if (StrUtil.isEmpty(reqGoodsSkuSpec.getKey())) {
  59. continue;
  60. }
  61. boolean subIsCtRoute = reqGoodsSkuSpec.getKey().contains("路由器");
  62. boolean subIsCtApple = reqGoodsSkuSpec.getKey().contains("机顶盒");
  63. if ((isCtRoute && subIsCtRoute) || (isCtApple && subIsCtApple)) {
  64. List<ReqGoodsSkuSpec.Node> values = reqGoodsSkuSpec.getValues();
  65. for (ReqGoodsSkuSpec.Node value : values) {
  66. RealGoodsConfigDto subInfo = new RealGoodsConfigDto();
  67. subInfo.setTitle(value.getValue());
  68. subInfo.setLogo(value.getLogo());
  69. subInfo.setPrice(value.getPrice());
  70. subInfoList.add(subInfo);
  71. }
  72. }
  73. }
  74. realGoodsConfig.setSubInfoList(subInfoList);
  75. }
  76. if (realGoodsConfig.getTitle().contains("潮玩")) {
  77. List<GoodsDonDetailFrontView> fashionGoodsList = beanSearcher.searchAll(GoodsDonDetailFrontView.class, MapUtils.builder().field(GoodsDonDetailFrontView::getType, 3)
  78. .field(GoodsDonDetailFrontView::getId, 27).op(Operator.NotEqual)
  79. .onlySelect(GoodsDonDetailFrontView::getTitle, GoodsDonDetailFrontView::getLogo, GoodsDonDetailFrontView::getMinPrice, GoodsDonDetailFrontView::getId, GoodsDonDetailFrontView::getTags)
  80. .build());
  81. if (CollUtil.isEmpty(fashionGoodsList)) {
  82. continue;
  83. }
  84. List<RealGoodsConfigDto> subInfoList = new ArrayList<>();
  85. for (GoodsDonDetailFrontView fashionGoods : fashionGoodsList) {
  86. RealGoodsConfigDto subInfo = new RealGoodsConfigDto();
  87. subInfo.setLogo(fashionGoods.getLogo());
  88. subInfo.setTitle(fashionGoods.getTitle());
  89. subInfo.setPrice(fashionGoods.getMinPrice());
  90. subInfo.setTags(fashionGoods.getTags());
  91. subInfoList.add(subInfo);
  92. }
  93. realGoodsConfig.setSubInfoList(subInfoList);
  94. }
  95. }
  96. return realGoodsConfigList;
  97. }
  98. }