GoodsDonController.java 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285
  1. package com.cyksj.web.controller.goods;
  2. import cn.hutool.core.collection.CollUtil;
  3. import cn.hutool.core.date.DateTime;
  4. import cn.hutool.core.date.DateUnit;
  5. import cn.hutool.core.date.DateUtil;
  6. import cn.hutool.core.util.RandomUtil;
  7. import cn.hutool.core.util.StrUtil;
  8. import cn.hutool.extra.servlet.ServletUtil;
  9. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  10. import com.cyksj.common.constant.Constant;
  11. import com.cyksj.common.exception.BusinessRuntimeException;
  12. import com.cyksj.common.util.Jsons;
  13. import com.cyksj.common.util.StringUtil;
  14. import com.cyksj.dto.Result;
  15. import com.cyksj.dto.UserSharedDto;
  16. import com.cyksj.enums.GatewayResponse;
  17. import com.cyksj.mapper.GoodsDonSkuMapper;
  18. import com.cyksj.mapper.OrderDonMapper;
  19. import com.cyksj.mapper.RegisterOrderDonMapper;
  20. import com.cyksj.mapper.shop.YhShopGoodsSkuMapper;
  21. import com.cyksj.mapper.sys.SysConfigMapper;
  22. import com.cyksj.model.entity.*;
  23. import com.cyksj.model.request.ClickRecordReq;
  24. import com.cyksj.model.views.*;
  25. import com.cyksj.redis.RedisService;
  26. import com.cyksj.service.goods.GoodsDonFrontService;
  27. import com.cyksj.service.home.ClickRecordFrontService;
  28. import com.cyksj.service.shop.YhShopFrontService;
  29. import com.cyksj.service.user.UserBindRelationService;
  30. import com.cyksj.service.user.UserService;
  31. import com.cyksj.web.util.StpUserUtil;
  32. import com.ejlchina.searcher.BeanSearcher;
  33. import com.ejlchina.searcher.SearchResult;
  34. import com.ejlchina.searcher.param.Operator;
  35. import com.ejlchina.searcher.util.MapBuilder;
  36. import com.ejlchina.searcher.util.MapUtils;
  37. import lombok.RequiredArgsConstructor;
  38. import lombok.extern.slf4j.Slf4j;
  39. import org.springframework.web.bind.annotation.*;
  40. import javax.servlet.http.HttpServletRequest;
  41. import java.math.BigDecimal;
  42. import java.util.*;
  43. import java.util.concurrent.ConcurrentHashMap;
  44. import java.util.concurrent.atomic.AtomicBoolean;
  45. import java.util.concurrent.atomic.AtomicLong;
  46. import java.util.stream.Collectors;
  47. import java.util.stream.Stream;
  48. /**
  49. * @author chan
  50. * @date 2022/9/26 5:33 PM
  51. */
  52. @Slf4j
  53. @RestController
  54. @RequestMapping("/applets/goods")
  55. @RequiredArgsConstructor
  56. public class GoodsDonController {
  57. private final HttpServletRequest request;
  58. private final BeanSearcher beanSearcher;
  59. private final OrderDonMapper orderDonMapper;
  60. private final RegisterOrderDonMapper registerOrderDonMapper;
  61. private final GoodsDonSkuMapper goodsDonSkuMapper;
  62. private final YhShopGoodsSkuMapper yhShopGoodsSkuMapper;
  63. private final RedisService redisService;
  64. private final SysConfigMapper sysConfigMapper;
  65. private final ClickRecordFrontService clickRecordFrontService;
  66. private final YhShopFrontService yhShopFrontService;
  67. private final UserService userService;
  68. private final GoodsDonFrontService goodsDonFrontService;
  69. private final UserBindRelationService userBindRelationService;
  70. /**
  71. * 获取平台商品分类
  72. */
  73. @GetMapping("/get/category")
  74. public Result<List<GoodsDonCategoryFrontView>> getCategory(String customId) {
  75. Long yhsId = null;
  76. if (StrUtil.isNotBlank(customId)) {
  77. yhsId = yhShopFrontService.getYhsIdByCustomId(customId);
  78. }
  79. String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "category";
  80. if (yhsId != null) {
  81. key += ":yhShop:" + yhsId;
  82. }
  83. Object o = redisService.get(key);
  84. List<GoodsDonCategoryFrontView> list;
  85. MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
  86. String condition = " and (select count(*) from goods_don_category_relate gcr inner join goods_don g on g.id = gcr.goods_id %s where gcr.category = gc.id) > 0";
  87. if (yhsId != null) {
  88. condition = String.format(condition, String.format(" and (select count(*) from yh_shop_goods_sku ys where ys.goods_id = g.id and ys.status is true and ys.deleted is true and g.is_distribute is true and ys.yhs_id = %s) > 0", yhsId));
  89. } else {
  90. condition = String.format(condition, StrUtil.EMPTY);
  91. }
  92. mapBuilder.put("condition", condition);
  93. if (o == null) {
  94. list = beanSearcher.searchAll(GoodsDonCategoryFrontView.class, mapBuilder
  95. .build());
  96. redisService.setNx(key, list, 30 * 60l);
  97. o = redisService.get(key);
  98. }
  99. list = Jsons.parseList(o, GoodsDonCategoryFrontView.class);
  100. return GatewayResponse.SUCCESS.newBuilder().toResult(list);
  101. }
  102. /**
  103. * 商品搜索
  104. */
  105. @GetMapping("/search")
  106. public Result<SearchResult<GoodsDonSearchView>> search() {
  107. SearchResult<GoodsDonSearchView> search = beanSearcher.search(GoodsDonSearchView.class, MapUtils.flatBuilder(request.getParameterMap()).build());
  108. return GatewayResponse.SUCCESS.newBuilder().toResult(search);
  109. }
  110. /**
  111. * 获取商品列表
  112. */
  113. @GetMapping("/get")
  114. public Result<SearchResult<GoodsDon>> get() {
  115. SearchResult<GoodsDon> search = beanSearcher.search(GoodsDon.class, MapUtils.flatBuilder(request.getParameterMap())
  116. .field(GoodsDon::getStatus, true)
  117. .field(GoodsDon::getDeleted, true)
  118. .orderBy(GoodsDon::getSortBy).asc()
  119. .orderBy(GoodsDon::getId).asc()
  120. .build()
  121. );
  122. search.getDataList().forEach(goods -> {
  123. GoodsDonSku goodsDonSku = goodsDonSkuMapper.selectOne(Wrappers.lambdaQuery(GoodsDonSku.class).eq(GoodsDonSku::getGoodsId, goods.getId())
  124. .eq(GoodsDonSku::getStatus, true)
  125. .orderByAsc(GoodsDonSku::getPrice)
  126. .last("limit 1")
  127. .select(GoodsDonSku::getPrice));
  128. Optional.ofNullable(goodsDonSku).ifPresent(sku -> {
  129. goods.setPrice(goodsDonSku.getPrice());
  130. goods.setSoldNum(goods.getVirtualSold() + orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  131. .eq(OrderDon::getGoodsId, goods.getId())
  132. .notIn(OrderDon::getStatus, Constant.noOrderStatus)));
  133. });
  134. });
  135. return GatewayResponse.SUCCESS.newBuilder().toResult(search);
  136. }
  137. /**
  138. * 推广未登录,虚拟商品列表
  139. */
  140. @GetMapping("/get/popularize")
  141. @Deprecated
  142. public Result<SearchResult<GoodsDonPopularizeView>> getPopularizeVipGoods() {
  143. SearchResult<GoodsDonPopularizeView> search = beanSearcher.search(GoodsDonPopularizeView.class, MapUtils.flatBuilder(request.getParameterMap())
  144. .field(GoodsDonPopularizeView::getStatus, true)
  145. .field(GoodsDonPopularizeView::getDeleted, true)
  146. .field(GoodsDonPopularizeView::getType, 1)
  147. .orderBy(GoodsDonPopularizeView::getSortBy).asc()
  148. .orderBy(GoodsDonPopularizeView::getId).asc()
  149. .build());
  150. DateTime now = DateTime.now();
  151. search.getDataList().forEach(data -> {
  152. data.setSpecs(beanSearcher.searchFirst(GoodsDonSpec.class, MapUtils.builder().field(GoodsDonSpec::getGoodsId, data.getId()).build()));
  153. data.setSkuList(beanSearcher.searchAll(GoodsDonSku.class, MapUtils.builder().field(GoodsDonSku::getGoodsId, data.getId()).field(GoodsDonSku::getStatus, true).orderBy(GoodsDonSku::getPrice).asc().build()));
  154. Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  155. .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
  156. data.setSold(sold + data.getVirtualSold());
  157. Optional.ofNullable(data.getSkuList()).ifPresent(skuList -> {
  158. if (skuList.size() > 0) {
  159. GoodsDonSku goodsDonSku = skuList.get(0);
  160. data.setPrice(goodsDonSku.getPrice());
  161. data.setMonths(goodsDonSku.getMonths());
  162. }
  163. });
  164. OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
  165. .eq(OrderDon::getGoodsId, data.getId())
  166. .notIn(OrderDon::getStatus, Constant.noOrderStatus).select(OrderDon::getCreatedTime, OrderDon::getPayTime, OrderDon::getId)
  167. .orderByDesc(OrderDon::getId)
  168. .last("limit 1"));
  169. StringBuilder notifyMsg = new StringBuilder();
  170. if (orderDon == null) {
  171. notifyMsg.append("点击购买立即上车");
  172. data.setNotifyMsg(notifyMsg.toString());
  173. return;
  174. } else {
  175. Date payTime = orderDon.getPayTime();
  176. Date startTime = payTime != null ? payTime : orderDon.getCreatedTime();
  177. long hour = DateUtil.between(startTime, now, DateUnit.HOUR);
  178. if (hour == 0) {
  179. long minute = DateUtil.between(startTime, now, DateUnit.MINUTE);
  180. if (minute == 0) {
  181. notifyMsg.append("1分钟");
  182. } else {
  183. notifyMsg.append(minute);
  184. notifyMsg.append("分钟");
  185. }
  186. } else {
  187. if (hour > 3) {
  188. int hours = RandomUtil.randomInt(3) + 1;
  189. notifyMsg.append(hours);
  190. } else {
  191. notifyMsg.append(hour);
  192. }
  193. notifyMsg.append("小时");
  194. }
  195. }
  196. notifyMsg.append("前有人购买");
  197. data.setNotifyMsg(notifyMsg.toString());
  198. });
  199. return GatewayResponse.SUCCESS.newBuilder().toResult(search);
  200. }
  201. /**
  202. * 官网首页 平台列表
  203. */
  204. @GetMapping("/get/list")
  205. @Deprecated
  206. public Result<? extends Object> getGoodsList(String customId) {
  207. if (StrUtil.isNotBlank(customId)) {
  208. Result<List<YhShopGoodsFrontView>> shopGoods = getShopGoods(yhShopFrontService.getYhsIdByCustomId(customId));
  209. return shopGoods;
  210. }
  211. //List<Long> filter_goodsIds = getFilterGoodsIds();
  212. List<Long> filter_goodsIds = null;
  213. String pcCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "PC";
  214. if (CollUtil.isNotEmpty(filter_goodsIds)) {
  215. pcCacheKey += ":hz-ip";
  216. }
  217. Long fUid = StpUserUtil.getUserIdAfterLogin();
  218. Object o = redisService.get(pcCacheKey);
  219. List<GoodsFrontListView> list = null;
  220. if (o == null) {
  221. MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
  222. if (CollUtil.isNotEmpty(filter_goodsIds)) {
  223. builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
  224. }
  225. builder.field(GoodsFrontListView::getType, 1);
  226. list = beanSearcher.searchAll(GoodsFrontListView.class, builder.build());
  227. redisService.setNx(pcCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
  228. o = redisService.get(pcCacheKey);
  229. }
  230. if (list == null) {
  231. list = Jsons.parseList(o, GoodsFrontListView.class);
  232. }
  233. DateTime now = DateTime.now();
  234. list.forEach(data -> {
  235. Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  236. .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
  237. data.setSold(sold + data.getSold());
  238. data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
  239. //设置特定价格
  240. setSpecificPrice(data, fUid, null);
  241. });
  242. return GatewayResponse.SUCCESS.newBuilder().toResult(Optional.of(list));
  243. }
  244. /**
  245. * h5 银河首页平台展示
  246. */
  247. @GetMapping("/get/homePage")
  248. @Deprecated
  249. public Result<? extends Object> getGoodsHomePage(String customId) {
  250. if (StrUtil.isNotBlank(customId)) {
  251. Result<List<YhShopGoodsFrontView>> shopGoods = getShopGoods(yhShopFrontService.getYhsIdByCustomId(customId));
  252. return shopGoods;
  253. }
  254. //List<Long> filter_goodsIds = getFilterGoodsIds();
  255. List<Long> filter_goodsIds = null;
  256. String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "H5";
  257. if (CollUtil.isNotEmpty(filter_goodsIds)) {
  258. h5CacheKey += ":hz-ip";
  259. }
  260. Long fUid = StpUserUtil.getUserIdAfterLogin();
  261. Object o = redisService.get(h5CacheKey);
  262. List<GoodsFrontListView> list = null;
  263. if (o == null) {
  264. MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
  265. if (CollUtil.isNotEmpty(filter_goodsIds)) {
  266. builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
  267. }
  268. list = beanSearcher.searchAll(GoodsFrontListView.class, builder.build());
  269. redisService.setNx(h5CacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
  270. o = redisService.get(h5CacheKey);
  271. }
  272. if (list == null) {
  273. list = Jsons.parseList(o, GoodsFrontListView.class);
  274. }
  275. DateTime now = DateTime.now();
  276. list.forEach(data -> {
  277. Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  278. .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
  279. data.setSold(sold + data.getSold());
  280. data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
  281. //设置特定价格
  282. setSpecificPrice(data, fUid, null);
  283. });
  284. return GatewayResponse.SUCCESS.newBuilder().toResult(Optional.of(list));
  285. }
  286. /**
  287. * 注册首页平台展示
  288. */
  289. @GetMapping("/get/register")
  290. public Result<List<RegisterGoodsDonView>> getRegisterGoodsDon() {
  291. String registerCacheKey = RedisService.key.REGISTER_HOME_PAGE_CACHE.getName();
  292. Object value = redisService.get(registerCacheKey);
  293. if (value != null) {
  294. try {
  295. List<RegisterGoodsDonView> list = Jsons.parseList(value, RegisterGoodsDonView.class);
  296. if (CollUtil.isNotEmpty(list)) {
  297. return GatewayResponse.SUCCESS.newBuilder().toResult(list);
  298. }
  299. } catch (Exception e) {
  300. }
  301. }
  302. MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
  303. List<RegisterGoodsDonView> dataList = beanSearcher.searchAll(RegisterGoodsDonView.class, builder.build());
  304. DateTime now = DateTime.now();
  305. dataList.forEach(data -> {
  306. Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
  307. .eq(RegisterOrderDon::getGoodsId, data.getId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
  308. data.setSold(sold + data.getVirtualSold());
  309. data.setNotifyMsg(getPayMsgTime(data.getId(), now, 2, null));
  310. });
  311. redisService.setNx(registerCacheKey, dataList, RedisService.key.REGISTER_HOME_PAGE_CACHE.getTimeout());
  312. return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
  313. }
  314. /**
  315. * 获取商品详情
  316. */
  317. @GetMapping("/get/{id}")
  318. public Result<? extends Object> getDetail(@PathVariable Long id, String customId, String dsCode) {
  319. if (StrUtil.isNotBlank(customId) && id != 15) {
  320. Result<YhShopGoodsFrontView> yhShopGoodsDetail = getGoodsDetailByYhsId(yhShopFrontService.getYhsIdByCustomId(customId), id);
  321. return yhShopGoodsDetail;
  322. }
  323. String goodsDetailKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "goods_detail:" + id;
  324. //List<Long> filter_goodsIds = getFilterGoodsIds();
  325. List<Long> filter_goodsIds = null;
  326. //存在过滤平台 商品详情不返回
  327. if (CollUtil.isNotEmpty(filter_goodsIds) && filter_goodsIds.contains(id)) {
  328. return GatewayResponse.SUCCESS.newBuilder().toResult();
  329. }
  330. Object o = redisService.get(goodsDetailKey);
  331. if (o == null) {
  332. GoodsFrontListView views = beanSearcher.searchFirst(GoodsFrontListView.class, MapUtils.builder().field(GoodsFrontListView::getId, id)
  333. .build());
  334. if (views == null) {
  335. throw BusinessRuntimeException.getInstance("商品已下架..");
  336. }
  337. views.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::getGoodsId, views.getId()).build()));
  338. MapBuilder builder = MapUtils.builder().field(GoodsDonSkuFrontView::getGoodsId, views.getId()).field(GoodsDonSkuFrontView::getStatus, true);
  339. if (views.getType() == 1) {
  340. builder.orderBy(GoodsDonSkuFrontView::getSorted).asc();
  341. }
  342. views.setSkuList(beanSearcher.searchAll(GoodsDonSkuFrontView.class, builder.build()));
  343. Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  344. .eq(OrderDon::getGoodsId, views.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
  345. views.setSold(sold + views.getSold());
  346. List<GoodsDonQaFrontView> donQaFrontViews = beanSearcher.searchAll(GoodsDonQaFrontView.class, MapUtils.builder().field(GoodsDonQaFrontView::getGoodsId, id).field(GoodsDonQaFrontView::getType, 1).build());
  347. views.setQuestions(donQaFrontViews);
  348. redisService.setNx(goodsDetailKey, views, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 60 * RandomUtil.randomInt(10));
  349. o = redisService.get(goodsDetailKey);
  350. }
  351. Long fUid = StpUserUtil.getUserIdAfterLogin();
  352. GoodsFrontListView views = Jsons.parseObject(o, GoodsFrontListView.class);
  353. AtomicLong dsUserId = new AtomicLong();
  354. AtomicBoolean existsChannel = new AtomicBoolean(true);
  355. if (StrUtil.isNotBlank(dsCode)) {
  356. UserSharedDto userSharedDto = userService.getUserShredDtoByDsCode(dsCode);
  357. dsUserId.set(userSharedDto.getSharedId());
  358. }
  359. views.setSkuList(views.getSkuList().stream().filter(sku -> {
  360. if (StrUtil.isNotBlank(sku.getUserOwns())) {
  361. if (dsUserId.get() == 0 && fUid != null && existsChannel.get()) {
  362. Long sharedId = userService.getSharedIdByUserId(fUid);
  363. if (sharedId == 0) {
  364. existsChannel.set(false);
  365. }
  366. dsUserId.set(sharedId);
  367. }
  368. if (dsUserId.get() == 0 || !sku.getUserOwns().contains(String.valueOf(dsUserId.get()))) {
  369. return false;
  370. }
  371. }
  372. if (sku.getIsDp()) {
  373. sku.setDpSkuViews(beanSearcher.searchAll(GoodsDiscountPlusPurchaseRelationFrontView.class, MapUtils.builder()
  374. .field(GoodsDiscountPlusPurchaseRelationFrontView::getSkuId, sku.getId())
  375. .build()));
  376. }
  377. if (views.getIsSp()) {
  378. if (fUid == null) {
  379. sku.setSpecificPrice(null);
  380. sku.setSpecificGoodsIds(null);
  381. }else {
  382. //设置特定价格
  383. if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
  384. sku.setSpecificGoodsIds(null);
  385. sku.setSpecificPrice(null);
  386. } else {
  387. BigDecimal specificPrice = views.getSpecificPrice();
  388. BigDecimal skuSpecificPrice = sku.getSpecificPrice();
  389. Long specificSkuId = sku.getId();
  390. if (specificPrice == null) {
  391. views.setSpecificPrice(skuSpecificPrice);
  392. views.setSpecificSkuId(specificSkuId);
  393. } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
  394. views.setSpecificPrice(skuSpecificPrice);
  395. views.setSpecificSkuId(specificSkuId);
  396. }
  397. }
  398. }
  399. }
  400. return true;
  401. }).collect(Collectors.toList()));
  402. return GatewayResponse.SUCCESS.newBuilder().toResult(views);
  403. }
  404. /**
  405. * 获取商品推荐平台
  406. */
  407. @GetMapping("/get/recommend/{id}")
  408. public Result<List<GoodsFrontListView>> getRecommendGoodsByGid(@PathVariable Long id, String customId, String dsCode) throws Exception {
  409. String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "recommend:" + id;
  410. Long yhsId = null;
  411. if (StrUtil.isNotBlank(customId)) {
  412. yhsId = yhShopFrontService.getYhsIdByCustomId(customId);
  413. key = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getName() + yhsId + ":recommend:" + id;
  414. }
  415. Object o = redisService.get(key);
  416. Long fUid = StpUserUtil.getUserIdAfterLogin();
  417. List<GoodsFrontListView> goodsRecommendViews = null;
  418. if (o == null) {
  419. GoodsDon goodsDon = beanSearcher.searchFirst(GoodsDon.class, MapUtils.builder()
  420. .field(GoodsDon::getId, id).field(GoodsDon::getStatus, true)
  421. .field(GoodsDon::getDeleted, true)
  422. .build());
  423. if (goodsDon != null && StrUtil.isNotEmpty(goodsDon.getRecommendGoods())) {
  424. List<Long> recommend_gidList = Jsons.parseList(goodsDon.getRecommendGoods(), Long.class);
  425. MapBuilder mapBuilder = MapUtils.builder();
  426. if (yhsId != null) {
  427. mapBuilder.put("condition", String.format(" and g.id in (select distinct goods_id from yh_shop_goods_sku where yhs_id = %s and status is true and deleted is true) and g.is_distribute is true", yhsId));
  428. }
  429. mapBuilder.field(GoodsFrontListView::getId, recommend_gidList).op(Operator.InList);
  430. goodsRecommendViews = beanSearcher.searchAll(GoodsFrontListView.class, mapBuilder.build());
  431. redisService.setNx(key, Jsons.toJson(goodsRecommendViews), 60 * 15l);
  432. o = redisService.get(key);
  433. } else {
  434. return GatewayResponse.SUCCESS.newBuilder().toResult();
  435. }
  436. }
  437. if (goodsRecommendViews == null) {
  438. goodsRecommendViews = Jsons.parseList(o.toString(), GoodsFrontListView.class);
  439. }
  440. AtomicLong dsUserId = new AtomicLong();
  441. AtomicBoolean existsChannel = new AtomicBoolean(true);
  442. if (StrUtil.isNotBlank(dsCode)) {
  443. UserSharedDto userSharedDto = userService.getUserShredDtoByDsCode(dsCode);
  444. dsUserId.set(userSharedDto.getSharedId());
  445. }
  446. goodsRecommendViews = goodsRecommendViews.stream().filter(data -> {
  447. if (data.getIsOwns()) {
  448. if (dsUserId.get() == 0 && fUid != null && existsChannel.get()) {
  449. Long sharedId = userService.getSharedIdByUserId(fUid);
  450. if (sharedId == 0) {
  451. existsChannel.set(false);
  452. }
  453. dsUserId.set(sharedId);
  454. }
  455. GoodsDonSku minPriceUserOwnsSku = goodsDonSkuMapper.checkAndReturnMinPriceUserOwnsSku(data.getId(), dsUserId.get());
  456. if (minPriceUserOwnsSku == null) {
  457. return false;
  458. }
  459. data.setPrice(minPriceUserOwnsSku.getPrice());
  460. data.setMonths(minPriceUserOwnsSku.getMonths());
  461. data.setDays(minPriceUserOwnsSku.getDays());
  462. }
  463. Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  464. .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
  465. data.setSold(data.getSold() + sold);
  466. //设置特定价格
  467. setSpecificPrice(data, fUid, dsUserId.get());
  468. return true;
  469. }).collect(Collectors.toList());
  470. return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
  471. }
  472. /**
  473. * 获取商品多规格列表
  474. */
  475. @GetMapping("/get/sku")
  476. public Result<List<GoodsDonSkuView>> getGoodsDonSkuView(@RequestParam(value = "skuIds") List<Long> skuIds) {
  477. if (skuIds.isEmpty()) {
  478. return GatewayResponse.SUCCESS.newBuilder().toResult();
  479. }
  480. List<GoodsDonSkuView> views = beanSearcher.searchAll(GoodsDonSkuView.class, MapUtils.builder()
  481. .field(GoodsDonSkuView::getSkuId, skuIds).op(Operator.InList)
  482. .build());
  483. return GatewayResponse.SUCCESS.newBuilder().toResult(views);
  484. }
  485. /**
  486. * 获取评价列表
  487. */
  488. @GetMapping("/get/comments")
  489. public Result<SearchResult<OrderCommentFrontView>> getComments() {
  490. SearchResult<OrderCommentFrontView> search = beanSearcher.search(OrderCommentFrontView.class, MapUtils.flatBuilder(request.getParameterMap())
  491. .orderBy(OrderCommentFrontView::getCommentTime).desc()
  492. .orderBy(OrderCommentFrontView::getId).desc()
  493. .build());
  494. return GatewayResponse.SUCCESS.newBuilder().toResult(search);
  495. }
  496. /**
  497. * 获取礼品卡平台性情
  498. */
  499. @GetMapping("/get/card/{id}")
  500. public Result<Map<Integer, List<GiftCardGoodsSkuFrontView>>> getGiftCardDetail(@PathVariable Long id) {
  501. List<GiftCardGoodsSkuFrontView> giftCardGoodsSkuFrontViews = beanSearcher.searchAll(GiftCardGoodsSkuFrontView.class, MapUtils.builder().field(GiftCardGoodsSkuFrontView::getGoodsId, id).build());
  502. Map<Integer, List<GiftCardGoodsSkuFrontView>> map = giftCardGoodsSkuFrontViews.stream().collect(Collectors.groupingBy(GiftCardGoodsSkuFrontView::getGcType));
  503. return GatewayResponse.SUCCESS.newBuilder().toResult(map);
  504. }
  505. /**
  506. * 获取首页配置列表
  507. */
  508. @GetMapping("/get/homeManage")
  509. public Result<Map<String, List<HomeManagementFrontView>>> getHomeManagementFrontPage(String customId, String dsCode) {
  510. String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "homeManage";
  511. Long yhsId = null;
  512. if (StrUtil.isNotBlank(customId)) {
  513. yhsId = yhShopFrontService.getYhsIdByCustomId(customId);
  514. key = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getName() + yhsId + ":homeManage";
  515. }
  516. // List<Long> filter_goodsIds = getFilterGoodsIds();
  517. List<Long> filter_goodsIds = null;
  518. AtomicBoolean isRemoveRg = new AtomicBoolean(false);
  519. // if (isHzIp()) {
  520. // key += ":hz-ip";
  521. // isRemoveRg.set(true);
  522. // }
  523. Long fUid = StpUserUtil.getUserIdAfterLogin();
  524. Object o = redisService.get(key);
  525. if (o == null) {
  526. String condition = "g.deleted is true and g.status is true";
  527. if (yhsId != null) {
  528. condition += String.format(" and g.id in (select distinct goods_id from yh_shop_goods_sku where yhs_id = %s and status is true and deleted is true) and g.is_distribute is true", yhsId);
  529. }
  530. Map<String, List<HomeManagementFrontView>> map = new ConcurrentHashMap<>();
  531. final String conditionSql = condition;
  532. Stream.of(HomeManagementConfig.Type.values())
  533. .forEach(type -> {
  534. if (isRemoveRg.get() && type == HomeManagementConfig.Type.rg) {
  535. return;
  536. }
  537. MapBuilder builder = MapUtils.builder()
  538. .field(HomeManagementFrontView::getType, type.name());
  539. if (type == HomeManagementConfig.Type.ex || type == HomeManagementConfig.Type.vg) {
  540. builder.put("condition", conditionSql);
  541. if (CollUtil.isNotEmpty(filter_goodsIds)) {
  542. builder.field(HomeManagementFrontView::getGoodsId, filter_goodsIds).op(Operator.NotIn);
  543. }
  544. }
  545. List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
  546. map.putIfAbsent(type.name(), homeManagementFrontViews);
  547. });
  548. redisService.setNx(key, map, 50 * 60l);
  549. o = redisService.get(key);
  550. }
  551. AtomicLong dsUserId = new AtomicLong();
  552. AtomicBoolean existsChannel = new AtomicBoolean(true);
  553. if (StrUtil.isNotBlank(dsCode)) {
  554. UserSharedDto userSharedDto = userService.getUserShredDtoByDsCode(dsCode);
  555. dsUserId.set(userSharedDto.getSharedId());
  556. }
  557. Map<String, List<HomeManagementFrontView>> map = Jsons.parseObject(o, Map.class);
  558. if (map.containsKey(HomeManagementConfig.Type.ex.name()) || map.containsKey(HomeManagementConfig.Type.vg.name())) {
  559. try {
  560. //精彩推荐
  561. List<HomeManagementFrontView> exList = Jsons.parseList(Jsons.toJson(map.get(HomeManagementConfig.Type.ex.name())), HomeManagementFrontView.class);
  562. setHomeConfigGoods(map, HomeManagementConfig.Type.ex, exList, dsUserId, existsChannel, fUid);
  563. //虚拟平台
  564. List<HomeManagementFrontView> vgList = Jsons.parseList(Jsons.toJson(map.get(HomeManagementConfig.Type.vg.name())), HomeManagementFrontView.class);
  565. setHomeConfigGoods(map, HomeManagementConfig.Type.vg, vgList, dsUserId, existsChannel, fUid);
  566. } catch (Exception e) {
  567. }
  568. }
  569. return GatewayResponse.SUCCESS.newBuilder().toResult(map);
  570. }
  571. /**
  572. * 首页点击 记录
  573. */
  574. @PostMapping("/homePage/click")
  575. public Result<String> homeManageClick(@RequestBody ClickRecordReq request) {
  576. Long userId = StpUserUtil.getUserIdAfterLogin();
  577. clickRecordFrontService.click(userId, request);
  578. return GatewayResponse.SUCCESS.newBuilder().toResult();
  579. }
  580. public List<Long> getFilterGoodsIds() {
  581. List<Long> filter_goodsIds = null;
  582. //获取当前ip地址
  583. if (StringUtil.getRealAddressByIP(ServletUtil.getClientIP(request)).contains("杭州")) {
  584. //过滤杭州Ai ChatGPT平台
  585. SysConfig sysConfig = sysConfigMapper.selectOne(Wrappers.lambdaQuery(SysConfig.class)
  586. .eq(SysConfig::getSysKey, Constant.LOCATION_FOR_GOODS_IDS).last("limit 1"));
  587. if (sysConfig != null && StrUtil.isNotBlank(sysConfig.getSysValue())) {
  588. try {
  589. filter_goodsIds = Jsons.parseList(sysConfig.getSysValue(), Long.class);
  590. } catch (Exception e) {
  591. }
  592. }
  593. }
  594. return filter_goodsIds;
  595. }
  596. public Boolean isHzIp() {
  597. if (StringUtil.getRealAddressByIP(ServletUtil.getClientIP(request)).contains("无锡")) {
  598. return true;
  599. }
  600. return false;
  601. }
  602. /**
  603. * @param goodsId
  604. * @param type 1、普通,2、注册平台
  605. * @param yhsId 店铺id
  606. * @return
  607. */
  608. public String getPayMsgTime(Long goodsId, DateTime now, Integer type, Long yhsId) {
  609. Date startTime = null;
  610. StringBuilder notifyMsg = new StringBuilder();
  611. if (type == 1) {
  612. OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
  613. .eq(OrderDon::getGoodsId, goodsId)
  614. .notIn(OrderDon::getStatus, Constant.noOrderStatus).select(OrderDon::getCreatedTime, OrderDon::getPayTime, OrderDon::getId)
  615. .eq(yhsId != null, OrderDon::getYhsId, yhsId)
  616. .orderByDesc(OrderDon::getId)
  617. .last("limit 1"));
  618. if (orderDon == null) {
  619. notifyMsg.append("点击购买立即上车");
  620. return notifyMsg.toString();
  621. }
  622. startTime = orderDon.getPayTime() != null ? orderDon.getPayTime() : orderDon.getCreatedTime();
  623. } else if (type == 2) {
  624. RegisterOrderDon orderDon = registerOrderDonMapper.selectOne(Wrappers.lambdaQuery(RegisterOrderDon.class)
  625. .eq(RegisterOrderDon::getGoodsId, goodsId)
  626. .notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus).select(RegisterOrderDon::getCreatedTime, RegisterOrderDon::getPayTime, RegisterOrderDon::getId)
  627. .orderByDesc(RegisterOrderDon::getId)
  628. .last("limit 1"));
  629. if (orderDon == null) {
  630. return null;
  631. }
  632. startTime = orderDon.getPayTime() != null ? orderDon.getPayTime() : orderDon.getCreatedTime();
  633. }
  634. long hour = DateUtil.between(startTime, now, DateUnit.HOUR);
  635. if (hour == 0) {
  636. long minute = DateUtil.between(startTime, now, DateUnit.MINUTE);
  637. if (minute == 0) {
  638. notifyMsg.append("1分钟");
  639. } else {
  640. notifyMsg.append(minute);
  641. notifyMsg.append("分钟");
  642. }
  643. } else {
  644. if (hour > 3) {
  645. int hours = RandomUtil.randomInt(3) + 1;
  646. notifyMsg.append(hours);
  647. } else {
  648. notifyMsg.append(hour);
  649. }
  650. notifyMsg.append("小时");
  651. }
  652. notifyMsg.append("前有人购买");
  653. return notifyMsg.toString();
  654. }
  655. /**
  656. * 是否购买过特定平台
  657. */
  658. public Boolean isPaySpecificGoodsIds(String specificGoodsIdsStr, Long userId) {
  659. if (StrUtil.isNotBlank(specificGoodsIdsStr)) {
  660. try {
  661. Set<Long> specificGoodsIds = Jsons.parseSet(specificGoodsIdsStr, Long.class);
  662. Number number = beanSearcher.searchCount(OrderDon.class, MapUtils.builder().field(OrderDon::getGoodsId, specificGoodsIds).op(Operator.InList)
  663. .field(OrderDon::getUserId, userId)
  664. .field(OrderDon::getStatus, Constant.noOrderAllStatus).op(Operator.NotIn)
  665. .build());
  666. if (number.intValue() == 0) {
  667. return false;
  668. }
  669. return true;
  670. } catch (Exception e) {
  671. }
  672. }
  673. return false;
  674. }
  675. /**
  676. * 设置平台 特定价格
  677. */
  678. public void setSpecificPrice(GoodsFrontListView data, Long fUid, Long dsUserId) {
  679. if (fUid != null) {
  680. if (data.getIsSp()) {
  681. //查找所有特定规格最小价格 满足条件
  682. String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "specific:" + data.getId();
  683. Object speciObj = redisService.get(specificGoodsKey);
  684. List<GoodsDonSku> specificSkus = null;
  685. if (speciObj != null) {
  686. specificSkus = Jsons.parseList(speciObj, GoodsDonSku.class);
  687. } else {
  688. specificSkus = goodsDonSkuMapper.selectList(
  689. Wrappers.lambdaQuery(GoodsDonSku.class)
  690. .eq(GoodsDonSku::getGoodsId, data.getId())
  691. .eq(GoodsDonSku::getStatus, true)
  692. .gt(GoodsDonSku::getSpecificPrice, 0));
  693. redisService.setNx(specificGoodsKey, specificSkus, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
  694. }
  695. specificSkus.forEach(specificSku -> {
  696. if (StrUtil.isNotEmpty(specificSku.getUserOwns()) && (dsUserId == null || !specificSku.getUserOwns().contains(dsUserId.toString()))) {
  697. return;
  698. }
  699. String specificGoodsIdsStr = specificSku.getSpecificGoodsIds();
  700. if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
  701. BigDecimal specificPrice = data.getSpecificPrice();
  702. BigDecimal skuSpecificPrice = specificSku.getSpecificPrice();
  703. Long specificSkuId = specificSku.getId();
  704. if (specificPrice == null) {
  705. data.setSpecificPrice(skuSpecificPrice);
  706. data.setSpecificSkuId(specificSkuId);
  707. } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
  708. data.setSpecificPrice(skuSpecificPrice);
  709. data.setSpecificSkuId(specificSkuId);
  710. }
  711. }
  712. });
  713. List<GoodsDonSkuFrontView> skuList = data.getSkuList();
  714. if (CollUtil.isNotEmpty(skuList)) {
  715. skuList.forEach(sku -> {
  716. //设置特定价格
  717. if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
  718. sku.setSpecificGoodsIds(null);
  719. sku.setSpecificPrice(null);
  720. }
  721. });
  722. }
  723. }
  724. }
  725. }
  726. /**
  727. * 设置平台 特定价格
  728. */
  729. public void setGcSpecificPrice(GoodsFrontListCategoryView data, Long fUid, Long dsUserId) {
  730. if (fUid != null) {
  731. if (data.getIsSp()) {
  732. //查找所有特定规格最小价格 满足条件
  733. String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "specific:" + data.getId();
  734. Object speciObj = redisService.get(specificGoodsKey);
  735. List<GoodsDonSku> specificSkus = null;
  736. if (speciObj != null) {
  737. specificSkus = Jsons.parseList(speciObj, GoodsDonSku.class);
  738. } else {
  739. specificSkus = goodsDonSkuMapper.selectList(
  740. Wrappers.lambdaQuery(GoodsDonSku.class)
  741. .eq(GoodsDonSku::getGoodsId, data.getId())
  742. .eq(GoodsDonSku::getStatus, true)
  743. .gt(GoodsDonSku::getSpecificPrice, 0));
  744. redisService.setNx(specificGoodsKey, specificSkus, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
  745. }
  746. specificSkus.forEach(specificSku -> {
  747. if (StrUtil.isNotEmpty(specificSku.getUserOwns()) && (dsUserId == null || !specificSku.getUserOwns().contains(dsUserId.toString()))) {
  748. return;
  749. }
  750. String specificGoodsIdsStr = specificSku.getSpecificGoodsIds();
  751. if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
  752. BigDecimal specificPrice = data.getSpecificPrice();
  753. BigDecimal skuSpecificPrice = specificSku.getSpecificPrice();
  754. Long specificSkuId = specificSku.getId();
  755. if (specificPrice == null) {
  756. data.setSpecificPrice(skuSpecificPrice);
  757. data.setSpecificSkuId(specificSkuId);
  758. } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
  759. data.setSpecificPrice(skuSpecificPrice);
  760. data.setSpecificSkuId(specificSkuId);
  761. }
  762. }
  763. });
  764. List<GoodsDonSkuFrontView> skuList = data.getSkuList();
  765. if (CollUtil.isNotEmpty(skuList)) {
  766. skuList.forEach(sku -> {
  767. //设置特定价格
  768. if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
  769. sku.setSpecificGoodsIds(null);
  770. sku.setSpecificPrice(null);
  771. }
  772. });
  773. }
  774. }
  775. }
  776. }
  777. /**
  778. * 获取特定规格
  779. */
  780. public List<GoodsDonSku> getSpecificSku(Long goodsId) {
  781. //查找所有特定规格最小价格 满足条件
  782. String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "specific:" + goodsId;
  783. Object speciObj = redisService.get(specificGoodsKey);
  784. List<GoodsDonSku> specificSkus = null;
  785. if (speciObj != null) {
  786. specificSkus = Jsons.parseList(speciObj, GoodsDonSku.class);
  787. } else {
  788. specificSkus = goodsDonSkuMapper.selectList(
  789. Wrappers.lambdaQuery(GoodsDonSku.class)
  790. .eq(GoodsDonSku::getGoodsId, goodsId)
  791. .eq(GoodsDonSku::getStatus, true)
  792. .gt(GoodsDonSku::getSpecificPrice, 0));
  793. redisService.setNx(specificGoodsKey, specificSkus, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
  794. }
  795. specificSkus = Optional.ofNullable(specificSkus).orElse(new ArrayList<>());
  796. return specificSkus;
  797. }
  798. /**
  799. * 设置首页配置 涉及平台特定价格
  800. */
  801. public void setHomeManageSpecific(List<HomeManagementFrontView> list, Long fUid, Long dsUserId) {
  802. DateTime now = DateTime.now();
  803. list.forEach(data -> {
  804. if (data.getIsSp() != null && data.getIsSp() && fUid != null) {
  805. //查找所有特定规格最小价格 满足条件
  806. List<GoodsDonSku> specificSkus = getSpecificSku(data.getGoodsId());
  807. specificSkus.forEach(specificSku -> {
  808. if (StrUtil.isNotEmpty(specificSku.getUserOwns()) && (dsUserId == null || !specificSku.getUserOwns().contains(dsUserId.toString()))) {
  809. return;
  810. }
  811. String specificGoodsIdsStr = specificSku.getSpecificGoodsIds();
  812. if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
  813. BigDecimal specificPrice = data.getSpecificPrice();
  814. BigDecimal skuSpecificPrice = specificSku.getSpecificPrice();
  815. Long specificSkuId = specificSku.getId();
  816. if (specificPrice == null) {
  817. data.setSpecificPrice(skuSpecificPrice);
  818. data.setSpecificSkuId(specificSkuId);
  819. } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
  820. data.setSpecificPrice(skuSpecificPrice);
  821. data.setSpecificSkuId(specificSkuId);
  822. }
  823. }
  824. });
  825. }
  826. Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  827. .eq(OrderDon::getGoodsId, data.getGoodsId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
  828. data.setSold(sold + data.getSold());
  829. data.setNotifyMsg(getPayMsgTime(data.getGoodsId(), now, 1, null));
  830. });
  831. }
  832. public void setHomeConfigGoods(Map<String, List<HomeManagementFrontView>> map, HomeManagementConfig.Type type, List<HomeManagementFrontView> list, AtomicLong dsUserId, AtomicBoolean existsChannel, Long fUid) throws Exception {
  833. //设置特定价格
  834. if (CollUtil.isNotEmpty(list)) {
  835. list = list.stream().filter(data -> {
  836. if (data.getIsOwns()) {
  837. if (dsUserId.get() == 0 && fUid != null && existsChannel.get()) {
  838. Long sharedId = userService.getSharedIdByUserId(fUid);
  839. if (sharedId == 0) {
  840. existsChannel.set(false);
  841. }
  842. dsUserId.set(sharedId);
  843. }
  844. GoodsDonSku minPriceUserOwnsSku = goodsDonSkuMapper.checkAndReturnMinPriceUserOwnsSku(data.getGoodsId(), dsUserId.get());
  845. if (minPriceUserOwnsSku == null) {
  846. return false;
  847. }
  848. data.setPrice(minPriceUserOwnsSku.getPrice());
  849. data.setMonths(minPriceUserOwnsSku.getMonths());
  850. data.setDays(minPriceUserOwnsSku.getDays());
  851. }
  852. return true;
  853. }).collect(Collectors.toList());
  854. setHomeManageSpecific(list, fUid, dsUserId.get());
  855. map.put(type.name(), list);
  856. }
  857. }
  858. /**
  859. * 店铺平台列表
  860. */
  861. @GetMapping("/get/shop/goods/{yhsId}")
  862. public Result<List<YhShopGoodsFrontView>> getShopGoods(@PathVariable Long yhsId) {
  863. String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getName() + yhsId;
  864. Object value = redisService.get(yhShopCacheKey);
  865. List<YhShopGoodsFrontView> list = null;
  866. if (value != null) {
  867. try {
  868. list = Jsons.parseList(value, YhShopGoodsFrontView.class);
  869. } catch (Exception e) {
  870. }
  871. }
  872. if (CollUtil.isEmpty(list)) {
  873. MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
  874. builder.put("condition", String.format("and yhs_id = %s", yhsId));
  875. list = beanSearcher.searchAll(YhShopGoodsFrontView.class, builder.build());
  876. redisService.setNx(yhShopCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
  877. }
  878. DateTime now = DateTime.now();
  879. list.forEach(data->{
  880. Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  881. .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
  882. data.setSold(sold + data.getSold());
  883. data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, yhsId));
  884. });
  885. return GatewayResponse.SUCCESS.newBuilder().toResult(list);
  886. }
  887. /**
  888. * 店铺平台详情
  889. */
  890. @GetMapping("/get/shop/goods/detail/{yhsId}/{goodsId}")
  891. public Result<YhShopGoodsFrontView> getGoodsDetailByYhsId(@PathVariable Long yhsId, @PathVariable Long goodsId) {
  892. MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
  893. String condition = String.format("and yhs_id = %s and ys.goods_id = %s", yhsId, goodsId);
  894. builder.put("condition", condition);
  895. YhShopGoodsFrontView goodsDetailView = beanSearcher.searchFirst(YhShopGoodsFrontView.class, builder.build());
  896. if (goodsDetailView == null) {
  897. throw BusinessRuntimeException.getInstance("该平台不存在或已下架,请刷新页面");
  898. }
  899. goodsDetailView.setSkuList(beanSearcher.searchAll(YhShopGoodsSkuFrontView.class, MapUtils.builder().put("condition", condition).orderBy(YhShopGoodsSkuFrontView::getSorted).asc().build()));
  900. goodsDetailView.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::getGoodsId, goodsDetailView.getId()).build()));
  901. OrderCommentFrontView comments = beanSearcher.searchFirst(OrderCommentFrontView.class, MapUtils.builder()
  902. .field(OrderCommentFrontView::getGoodsId, goodsDetailView.getId())
  903. .orderBy(OrderCommentFrontView::getCommentTime).desc()
  904. .orderBy(OrderCommentFrontView::getId).desc()
  905. .build());
  906. goodsDetailView.setComments(comments);
  907. return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDetailView);
  908. }
  909. /**
  910. * 根据分类获取对应平台
  911. */
  912. @GetMapping("/get/categoryGoods")
  913. public Result<? extends Object> getGoodsByCategory(Long cgy, String customId, String dsCode) {
  914. if (StrUtil.isNotBlank(customId)) {
  915. Result<List<YhShopGoodsFrontCategoryView>> shopGoods = getShopCategoryGoods(yhShopFrontService.getYhsIdByCustomId(customId), cgy);
  916. return shopGoods;
  917. }
  918. Long fUid = StpUserUtil.getUserIdAfterLogin();
  919. String categoryGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "category:goods";
  920. if (cgy != null) {
  921. categoryGoodsKey += ":" + cgy;
  922. }
  923. //List<Long> filter_goodsIds = getFilterGoodsIds();
  924. List<Long> filter_goodsIds = null;
  925. if (CollUtil.isNotEmpty(filter_goodsIds)) {
  926. categoryGoodsKey += ":hz-ip";
  927. }
  928. Object o = redisService.get(categoryGoodsKey);
  929. if (o == null) {
  930. DateTime now = DateTime.now();
  931. MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
  932. if (cgy != null) {
  933. String condition = String.format(" and gcr.category = %s", cgy);
  934. mapBuilder.put("condition", condition);
  935. }
  936. if (CollUtil.isNotEmpty(filter_goodsIds)) {
  937. mapBuilder.field(GoodsFrontListCategoryView::getId, filter_goodsIds).op(Operator.NotIn);
  938. }
  939. List<GoodsFrontListCategoryView> goodsFrontListViews = beanSearcher.searchAll(GoodsFrontListCategoryView.class, mapBuilder.build());
  940. goodsFrontListViews.forEach(data -> {
  941. Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  942. .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
  943. data.setSold(sold + data.getSold());
  944. data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
  945. });
  946. redisService.setNx(categoryGoodsKey, goodsFrontListViews, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 10 * 60);
  947. o = redisService.get(categoryGoodsKey);
  948. }
  949. List<GoodsFrontListCategoryView> goodsFrontListViews = Jsons.parseList(o, GoodsFrontListCategoryView.class);
  950. AtomicLong dsUserId = new AtomicLong();
  951. AtomicBoolean existsChannel = new AtomicBoolean(true);
  952. if (StrUtil.isNotBlank(dsCode)) {
  953. UserSharedDto userSharedDto = userService.getUserShredDtoByDsCode(dsCode);
  954. dsUserId.set(userSharedDto.getSharedId());
  955. }
  956. AtomicBoolean filterCourseGoods = new AtomicBoolean(false);
  957. //增值服务分类
  958. if (fUid != null && cgy != null && (cgy == 3 || cgy == 4)) {
  959. //GPT Plus基础2月 课程不展示
  960. List<Long> userIdList = userBindRelationService.getRelationUserIdList(fUid, null);
  961. Integer orders = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  962. .in(OrderDon::getUserId, userIdList)
  963. .eq(OrderDon::getSkuId, 444)
  964. .notIn(OrderDon::getStatus, Constant.noOrderStatus));
  965. if (orders > 0) {
  966. filterCourseGoods.set(true);
  967. }
  968. }
  969. goodsFrontListViews = goodsFrontListViews.stream().filter(data -> {
  970. if (data.getIsOwns()) {
  971. if (dsUserId.get() == 0 && fUid != null && existsChannel.get()) {
  972. Long sharedId = userService.getSharedIdByUserId(fUid);
  973. if (sharedId == 0) {
  974. existsChannel.set(false);
  975. }
  976. dsUserId.set(sharedId);
  977. }
  978. GoodsDonSku minPriceUserOwnsSku = goodsDonSkuMapper.checkAndReturnMinPriceUserOwnsSku(data.getId(), dsUserId.get());
  979. if (minPriceUserOwnsSku == null) {
  980. return false;
  981. }
  982. data.setPrice(minPriceUserOwnsSku.getPrice());
  983. data.setMonths(minPriceUserOwnsSku.getMonths());
  984. data.setDays(minPriceUserOwnsSku.getDays());
  985. }
  986. //课件类型 且过滤
  987. if (filterCourseGoods.get() && data.getSpecialType() != null && data.getSpecialType() == GoodsDon.SpecialType.courseware) {
  988. return false;
  989. }
  990. //设置特定价格
  991. setGcSpecificPrice(data, fUid, dsUserId.get());
  992. return true;
  993. }).collect(Collectors.toList());
  994. return GatewayResponse.SUCCESS.newBuilder().toResult(goodsFrontListViews);
  995. }
  996. @GetMapping("/get/shop/categoryGoods/{yhsId}")
  997. public Result<List<YhShopGoodsFrontCategoryView>> getShopCategoryGoods(@PathVariable Long yhsId, Long category) {
  998. String categoryGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getName() + yhsId + ":category";
  999. if (category != null) {
  1000. categoryGoodsKey += ":" + category;
  1001. }
  1002. Object value = redisService.get(categoryGoodsKey);
  1003. if (value == null) {
  1004. DateTime now = DateTime.now();
  1005. MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
  1006. builder.put("yhsId", String.format(" and yhs_id = %s", yhsId));
  1007. String condition = StrUtil.EMPTY;
  1008. if (category != null) {
  1009. condition += String.format(" and gcr.category = %s", category);
  1010. }
  1011. builder.put("condition", condition);
  1012. List<YhShopGoodsFrontCategoryView> list = beanSearcher.searchAll(YhShopGoodsFrontCategoryView.class, builder.build());
  1013. list.forEach(data->{
  1014. Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  1015. .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
  1016. data.setSold(sold + data.getSold());
  1017. data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, yhsId));
  1018. //重新设置最低价格规格
  1019. YhShopGoodsSku sku = yhShopGoodsSkuMapper.selectMinPriceSkuByYhsId(yhsId, data.getId());
  1020. data.setPrice(sku.getPrice());
  1021. data.setSkuId(sku.getSkuId());
  1022. });
  1023. redisService.setNx(categoryGoodsKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 5 * 60);
  1024. value = redisService.get(categoryGoodsKey);
  1025. }
  1026. List<YhShopGoodsFrontCategoryView> list = Jsons.parseList(value, YhShopGoodsFrontCategoryView.class);
  1027. return GatewayResponse.SUCCESS.newBuilder().toResult(list);
  1028. }
  1029. /**
  1030. * 获取设备活动详情
  1031. */
  1032. @GetMapping("/get/equipment/activity")
  1033. public Result<EquipmentActivityReduce> getEpActivity() {
  1034. DateTime now = DateTime.now();
  1035. EquipmentActivityReduce equipmentActivityReduce = beanSearcher.searchFirst(EquipmentActivityReduce.class, MapUtils.builder()
  1036. .field(EquipmentActivityReduce::getSt, now).op(Operator.LessEqual)
  1037. .field(EquipmentActivityReduce::getEt, now).op(Operator.GreaterThan)
  1038. .field(EquipmentActivityReduce::getDeleted, 1)
  1039. .onlySelect(EquipmentActivityReduce::getF, EquipmentActivityReduce::getQ, EquipmentActivityReduce::getTq, EquipmentActivityReduce::getSt, EquipmentActivityReduce::getEt)
  1040. .build());
  1041. return GatewayResponse.SUCCESS.newBuilder().toResult(equipmentActivityReduce);
  1042. }
  1043. /**
  1044. * 获取租赁商品列表
  1045. */
  1046. @GetMapping("/get/deposit")
  1047. public Result<? extends Object> getDepositGoods() {
  1048. String depositGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "deposit";
  1049. Object o = redisService.get(depositGoodsKey);
  1050. if (o == null) {
  1051. List<GoodsDon> depositList = beanSearcher.searchAll(GoodsDon.class, MapUtils.builder()
  1052. .field(GoodsDon::getType, 4)
  1053. .field(GoodsDon::getStatus, true)
  1054. .field(GoodsDon::getDeleted, true)
  1055. .onlySelect(GoodsDon::getId, GoodsDon::getTitle, GoodsDon::getLogo)
  1056. .build());
  1057. if (CollUtil.isEmpty(depositList)) {
  1058. return GatewayResponse.SUCCESS.newBuilder().toResult();
  1059. }
  1060. redisService.setNx(depositGoodsKey, depositList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 60 * RandomUtil.randomInt(10));
  1061. o = redisService.get(depositGoodsKey);
  1062. }
  1063. List<GoodsDon> depositList = Jsons.parseList(o, GoodsDon.class);
  1064. return GatewayResponse.SUCCESS.newBuilder().toResult(depositList);
  1065. }
  1066. /**
  1067. * 获取pc广告配置
  1068. */
  1069. @GetMapping("/get/pc/homeManage")
  1070. public Result<Map<String, List<HomeManagementFrontView>>> getPcHomeManagementFrontPage() {
  1071. String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "pc:homeManage";
  1072. //移除奈飞客厅 临时
  1073. Long filterConfigId = null;
  1074. // if (isHzIp()) {
  1075. // key += ":hz_ip";
  1076. // filterConfigId = 55l;
  1077. // }
  1078. Object o = redisService.get(key);
  1079. if (o == null) {
  1080. MapBuilder builder = MapUtils.builder()
  1081. .field(HomeManagementFrontView::getAdType, List.of(HomeManagementConfig.AdType.pc.name(), HomeManagementConfig.AdType.pcSec.name(), HomeManagementConfig.AdType.pcDis.name())).op(Operator.InList);
  1082. if (filterConfigId != null) {
  1083. builder.field(HomeManagementFrontView::getHomeManageConfigId, filterConfigId).op(Operator.NotEqual);
  1084. }
  1085. List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
  1086. Map<HomeManagementConfig.AdType, List<HomeManagementFrontView>> map = homeManagementFrontViews.stream().collect(Collectors.groupingBy(HomeManagementFrontView::getAdType));
  1087. redisService.setNx(key, map, 50 * 60l);
  1088. o = redisService.get(key);
  1089. }
  1090. Map<String, List<HomeManagementFrontView>> map = Jsons.parseObject(o, Map.class);
  1091. return GatewayResponse.SUCCESS.newBuilder().toResult(map);
  1092. }
  1093. /**
  1094. * 获取pc实物配置
  1095. */
  1096. @GetMapping("/get/pc/realGoodsConfig")
  1097. public Result<? extends Object> getPcRealGoodsConfig() throws Exception {
  1098. String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "pc:realHomePage";
  1099. Object o = redisService.get(key);
  1100. List<HomeManagementFrontView> list = null;
  1101. if (o == null) {
  1102. list = goodsDonFrontService.getRealGoodsConfig();
  1103. redisService.setNx(key, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 300);
  1104. }
  1105. if (list == null && o != null) {
  1106. list = Jsons.parseList(o, HomeManagementFrontView.class);
  1107. }
  1108. return GatewayResponse.SUCCESS.newBuilder().toResult(list);
  1109. }
  1110. /**
  1111. * 百亿补贴
  1112. * 补贴规格列表
  1113. */
  1114. @GetMapping("/get/subsidy")
  1115. public Result<List<GoodsDonSkuSubsidyFrontView>> getSubsidyGoods() {
  1116. String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "subsidy";
  1117. Object o = redisService.get(key);
  1118. if (o == null) {
  1119. List<GoodsDonSkuSubsidyFrontView> subsidyList = beanSearcher.searchAll(GoodsDonSkuSubsidyFrontView.class, MapUtils.builder().build());
  1120. subsidyList.forEach(e -> {
  1121. Optional.ofNullable(beanSearcher.searchFirst(GoodsDonSkuSubsidyDetailView.class, MapUtils.builder().field(GoodsDonSkuSubsidyDetailView::getGoodsId, e.getId()).field(GoodsDonSkuSubsidyDetailView::getPrice, e.getPrice()).build())).ifPresent(sku -> {
  1122. e.setOriPrice(sku.getOriPrice());
  1123. e.setMonths(sku.getMonths());
  1124. e.setDays(sku.getDays());
  1125. e.setSkuId(sku.getId());
  1126. e.setPicture(sku.getSubsidyPicture());
  1127. });
  1128. });
  1129. redisService.setNx(key, subsidyList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 60 * RandomUtil.randomInt(10));
  1130. o = redisService.get(key);
  1131. }
  1132. List<GoodsDonSkuSubsidyFrontView> subsidyList = Jsons.parseList(o, GoodsDonSkuSubsidyFrontView.class);
  1133. if (CollUtil.isEmpty(subsidyList)) {
  1134. return GatewayResponse.SUCCESS.newBuilder().toResult(subsidyList);
  1135. }
  1136. Long userId = StpUserUtil.getUserIdAfterLogin();
  1137. if (userId != null) {
  1138. List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
  1139. //过滤用户已经购买过平台
  1140. List<Long> goodsIds = orderDonMapper.getPayGoodsIds(relationUserIdList);
  1141. if (CollUtil.isNotEmpty(goodsIds)) {
  1142. subsidyList = subsidyList.stream().filter(data -> !goodsIds.contains(data.getId())).collect(Collectors.toList());
  1143. }
  1144. }
  1145. return GatewayResponse.SUCCESS.newBuilder().toResult(subsidyList);
  1146. }
  1147. /**
  1148. * 百亿补贴规格详情
  1149. */
  1150. @GetMapping("/get/subsidy/detail/{id}")
  1151. public Result<GoodsDonSubsidyDetailView> getSubsidyDetailById(@PathVariable Long id) throws Exception {
  1152. String goodsDetailKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "subsidy:detail:" + id;
  1153. Object o = redisService.get(goodsDetailKey);
  1154. GoodsDonSubsidyDetailView subsidyDetail = null;
  1155. if (o == null) {
  1156. subsidyDetail = beanSearcher.searchFirst(GoodsDonSubsidyDetailView.class, MapUtils.builder().field(GoodsDonSubsidyDetailView::getId, id).build());
  1157. if (subsidyDetail == null) {
  1158. return GatewayResponse.SUCCESS.newBuilder().toResult();
  1159. }
  1160. subsidyDetail.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::getGoodsId, subsidyDetail.getId()).build()));
  1161. MapBuilder builder = MapUtils.builder().field(GoodsDonSkuSubsidyDetailView::getGoodsId, subsidyDetail.getId());
  1162. subsidyDetail.setSkuList(beanSearcher.searchAll(GoodsDonSkuSubsidyDetailView.class, builder.build()));
  1163. Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  1164. .eq(OrderDon::getGoodsId, subsidyDetail.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
  1165. subsidyDetail.setSold(sold + subsidyDetail.getSold());
  1166. redisService.setNx(goodsDetailKey, Jsons.toJson(subsidyDetail), RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 60 * RandomUtil.randomInt(10));
  1167. }
  1168. if (subsidyDetail == null) {
  1169. o = redisService.get(goodsDetailKey);
  1170. subsidyDetail = Jsons.parseObject(o.toString(), GoodsDonSubsidyDetailView.class);
  1171. }
  1172. return GatewayResponse.SUCCESS.newBuilder().toResult(subsidyDetail);
  1173. }
  1174. /**
  1175. * 可选百亿补贴规格列表
  1176. */
  1177. @GetMapping("/get/available/subsidy/sku/{goodsId}")
  1178. public Result<List<GoodsDonSkuSubsidyAvailableView>> getAvailableSubsidySku(@PathVariable Long goodsId) {
  1179. List<GoodsDonSkuSubsidyAvailableView> goodsDonSkuSubsidyAvailableViews = beanSearcher.searchAll(GoodsDonSkuSubsidyAvailableView.class, MapUtils.builder().put("gid", String.format(" and goods_id = %s", goodsId)).build());
  1180. return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDonSkuSubsidyAvailableViews);
  1181. }
  1182. /**
  1183. * 获取用户店铺首页配置列表
  1184. */
  1185. @GetMapping("/get/shop/homeManage")
  1186. public Result<Map<String, List<HomeManagementFrontView>>> getShopHomeManageConfig(String customId) {
  1187. //是否同意展示对应首页广告位
  1188. String key = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + customId + ":homeManage";
  1189. Object o = redisService.get(key);
  1190. if (o == null) {
  1191. MapBuilder builder = MapUtils.builder()
  1192. .field(HomeManagementFrontView::getType, HomeManagementConfig.Type.ad.name())
  1193. .field(HomeManagementFrontView::getIsShop, 1);
  1194. List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
  1195. if (homeManagementFrontViews == null) {
  1196. return GatewayResponse.SUCCESS.newBuilder().toResult();
  1197. }
  1198. Map<String, List<HomeManagementFrontView>> map = new ConcurrentHashMap<>();
  1199. map.putIfAbsent(HomeManagementConfig.Type.ad.name(), homeManagementFrontViews);
  1200. redisService.setNx(key, map, 50 * 60l);
  1201. o = redisService.get(key);
  1202. }
  1203. Map map = Jsons.parseObject(o, Map.class);
  1204. return GatewayResponse.SUCCESS.newBuilder().toResult(map);
  1205. }
  1206. /**
  1207. * 获取套餐列表
  1208. */
  1209. @GetMapping("/get/upgradePackage")
  1210. public Result<SearchResult<UpgradePackageView>> list(Long skuId) {
  1211. log.info("获取套餐列表");
  1212. Map<String, Object> build = MapUtils.flatBuilder(request.getParameterMap()).build();
  1213. if (skuId != null) {
  1214. build.put("sku", String.format(" and JSON_CONTAINS(up.sku_ids,'\"%s\"')", skuId));
  1215. }
  1216. SearchResult<UpgradePackageView> search = beanSearcher.search(UpgradePackageView.class, build);
  1217. return GatewayResponse.SUCCESS.newBuilder().toResult(search);
  1218. }
  1219. }