GoodsDonController.java 56 KB

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