| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521 |
- package com.cyksj.web.controller.goods;
- import cn.hutool.core.collection.CollUtil;
- import cn.hutool.core.date.DateTime;
- import cn.hutool.core.date.DateUnit;
- import cn.hutool.core.date.DateUtil;
- import cn.hutool.core.util.RandomUtil;
- import cn.hutool.core.util.StrUtil;
- import cn.hutool.extra.servlet.ServletUtil;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.cyksj.common.constant.Constant;
- import com.cyksj.common.util.Jsons;
- import com.cyksj.common.util.StringUtil;
- import com.cyksj.dto.Result;
- import com.cyksj.enums.GatewayResponse;
- import com.cyksj.mapper.GoodsDonSkuMapper;
- import com.cyksj.mapper.OrderDonMapper;
- import com.cyksj.mapper.RegisterOrderDonMapper;
- import com.cyksj.mapper.SysConfigMapper;
- import com.cyksj.model.entity.*;
- import com.cyksj.model.views.*;
- import com.cyksj.redis.RedisService;
- import com.cyksj.web.util.StpUserUtil;
- import com.ejlchina.searcher.BeanSearcher;
- import com.ejlchina.searcher.SearchResult;
- import com.ejlchina.searcher.param.Operator;
- import com.ejlchina.searcher.util.MapBuilder;
- import com.ejlchina.searcher.util.MapUtils;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.*;
- import javax.servlet.http.HttpServletRequest;
- import java.math.BigDecimal;
- import java.util.*;
- /**
- * @author chan
- * @date 2022/9/26 5:33 PM
- */
- @Slf4j
- @RestController
- @RequestMapping("/applets/goods")
- @RequiredArgsConstructor
- public class GoodsDonController {
- private final HttpServletRequest request;
- private final BeanSearcher beanSearcher;
- private final OrderDonMapper orderDonMapper;
- private final RegisterOrderDonMapper registerOrderDonMapper;
- private final GoodsDonSkuMapper goodsDonSkuMapper;
- private final RedisService redisService;
- private final SysConfigMapper sysConfigMapper;
- /**
- * 获取商品列表
- */
- @GetMapping("/get")
- public Result<SearchResult<GoodsDon>> get() {
- SearchResult<GoodsDon> search = beanSearcher.search(GoodsDon.class, MapUtils.flatBuilder(request.getParameterMap())
- .field(GoodsDon::getStatus, true)
- .field(GoodsDon::getDeleted, true)
- .orderBy(GoodsDon::getSortBy).desc()
- .orderBy(GoodsDon::getId).asc()
- .build()
- );
- search.getDataList().forEach(goods -> {
- GoodsDonSku goodsDonSku = goodsDonSkuMapper.selectOne(Wrappers.lambdaQuery(GoodsDonSku.class).eq(GoodsDonSku::getGoodsId, goods.getId())
- .eq(GoodsDonSku::getStatus, true)
- .orderByAsc(GoodsDonSku::getPrice)
- .last("limit 1")
- .select(GoodsDonSku::getPrice));
- Optional.ofNullable(goodsDonSku).ifPresent(sku->{
- goods.setPrice(goodsDonSku.getPrice());
- goods.setSoldNum(goods.getVirtualSold() + orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
- .eq(OrderDon::getGoodsId, goods.getId())
- .notIn(OrderDon::getStatus, Constant.noOrderStatus)));
- });
- });
- return GatewayResponse.SUCCESS.newBuilder().toResult(search);
- }
- /**
- * 推广未登录,虚拟商品列表
- */
- @GetMapping("/get/popularize")
- @Deprecated
- public Result<SearchResult<GoodsDonPopularizeView>> getPopularizeVipGoods() {
- SearchResult<GoodsDonPopularizeView> search = beanSearcher.search(GoodsDonPopularizeView.class, MapUtils.flatBuilder(request.getParameterMap())
- .field(GoodsDonPopularizeView::getStatus, true)
- .field(GoodsDonPopularizeView::getDeleted, true)
- .field(GoodsDonPopularizeView::getType, 1)
- .orderBy(GoodsDonPopularizeView::getSortBy).desc()
- .orderBy(GoodsDonPopularizeView::getId).asc()
- .build());
- DateTime now = DateTime.now();
- search.getDataList().forEach(data -> {
- data.setSpecs(beanSearcher.searchFirst(GoodsDonSpec.class, MapUtils.builder().field(GoodsDonSpec::getGoodsId, data.getId()).build()));
- data.setSkuList(beanSearcher.searchAll(GoodsDonSku.class, MapUtils.builder().field(GoodsDonSku::getGoodsId, data.getId()).field(GoodsDonSku::getStatus, true).orderBy(GoodsDonSku::getPrice).asc().build()));
- Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
- .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
- data.setSold(sold + data.getVirtualSold());
- Optional.ofNullable(data.getSkuList()).ifPresent(skuList -> {
- if (skuList.size() > 0) {
- GoodsDonSku goodsDonSku = skuList.get(0);
- data.setPrice(goodsDonSku.getPrice());
- data.setMonths(goodsDonSku.getMonths());
- }
- });
- OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
- .eq(OrderDon::getGoodsId, data.getId())
- .notIn(OrderDon::getStatus, Constant.noOrderStatus).select(OrderDon::getCreatedTime, OrderDon::getPayTime, OrderDon::getId)
- .orderByDesc(OrderDon::getId)
- .last("limit 1"));
- StringBuilder notifyMsg = new StringBuilder();
- if (orderDon == null) {
- notifyMsg.append("点击购买立即上车");
- data.setNotifyMsg(notifyMsg.toString());
- return;
- } else {
- Date payTime = orderDon.getPayTime();
- Date startTime = payTime != null ? payTime : orderDon.getCreatedTime();
- long hour = DateUtil.between(startTime, now, DateUnit.HOUR);
- if (hour == 0) {
- long minute = DateUtil.between(startTime, now, DateUnit.MINUTE);
- if (minute == 0) {
- notifyMsg.append("1分钟");
- } else {
- notifyMsg.append(minute);
- notifyMsg.append("分钟");
- }
- } else {
- if (hour > 3) {
- int hours = RandomUtil.randomInt(3) + 1;
- notifyMsg.append(hours);
- } else {
- notifyMsg.append(hour);
- }
- notifyMsg.append("小时");
- }
- }
- notifyMsg.append("前有人购买");
- data.setNotifyMsg(notifyMsg.toString());
- });
- return GatewayResponse.SUCCESS.newBuilder().toResult(search);
- }
- /**
- * 官网首页 平台列表
- */
- @GetMapping("/get/list")
- public Result<List<GoodsFrontListView>> getGoodsList() {
- List<Long> filter_goodsIds = getFilterGoodsIds();
- String pcCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "PC";
- if (CollUtil.isNotEmpty(filter_goodsIds)) {
- pcCacheKey += ":hz-ip";
- }
- Long fUid = StpUserUtil.getUserIdAfterLogin();
- Object value = redisService.get(pcCacheKey);
- if (value != null) {
- try {
- List<GoodsFrontListView> list = Jsons.parseList(value, GoodsFrontListView.class);
- if (CollUtil.isNotEmpty(list)) {
- //设置特定价格
- setSpecificPrice(list, fUid);
- return GatewayResponse.SUCCESS.newBuilder().toResult(list);
- }
- } catch (Exception e) {
- }
- }
- MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
- if (CollUtil.isNotEmpty(filter_goodsIds)) {
- builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
- }
- List<GoodsFrontListView> list = beanSearcher.searchAll(GoodsFrontListView.class, builder.build());
- DateTime now = DateTime.now();
- list.forEach(data -> {
- data.setSpecs(beanSearcher.searchFirst(GoodsDonSpec.class, MapUtils.builder().field(GoodsDonSpec::getGoodsId, data.getId()).build()));
- data.setSkuList(beanSearcher.searchAll(GoodsDonSkuFrontView.class, MapUtils.builder().field(GoodsDonSkuFrontView::getGoodsId, data.getId()).field(GoodsDonSkuFrontView::getStatus, true).orderBy(GoodsDonSkuFrontView::getPrice).asc().build()));
- data.getSkuList().forEach(sku -> {
- if (sku.getIsDp()) {
- List<GoodsDiscountPlusPurchaseRelationFrontView> dpSkuViews = beanSearcher.searchAll(GoodsDiscountPlusPurchaseRelationFrontView.class, MapUtils.builder().field(GoodsDiscountPlusPurchaseRelationFrontView::getSkuId, sku.getId()).build());
- sku.setDpSkuViews(dpSkuViews);
- }
- });
- Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
- .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
- data.setSold(sold + data.getVirtualSold());
- OrderCommentFrontView comments = beanSearcher.searchFirst(OrderCommentFrontView.class, MapUtils.builder()
- .field(OrderCommentFrontView::getGoodsId, data.getId())
- .orderBy(OrderCommentFrontView::getCommentTime).desc()
- .orderBy(OrderCommentFrontView::getId).desc()
- .build());
- data.setComments(comments);
- data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
- });
- redisService.setNx(pcCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
- //设置特定价格
- setSpecificPrice(list, fUid);
- return GatewayResponse.SUCCESS.newBuilder().toResult(list);
- }
- /**
- * h5 银河首页平台展示
- */
- @GetMapping("/get/homePage")
- public Result<List<GoodsFrontListView>> getGoodsHomePage() {
- List<Long> filter_goodsIds = getFilterGoodsIds();
- String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "H5";
- if (CollUtil.isNotEmpty(filter_goodsIds)) {
- h5CacheKey += ":hz-ip";
- }
- Long fUid = StpUserUtil.getUserIdAfterLogin();
- Object value = redisService.get(h5CacheKey);
- if (value != null) {
- try {
- List<GoodsFrontListView> list = Jsons.parseList(value, GoodsFrontListView.class);
- if (CollUtil.isNotEmpty(list)) {
- //设置特定价格
- setSpecificPrice(list, fUid);
- return GatewayResponse.SUCCESS.newBuilder().toResult(list);
- }
- } catch (Exception e) {
- }
- }
- MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
- if (CollUtil.isNotEmpty(filter_goodsIds)) {
- builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
- }
- List<GoodsFrontListView> dataList = beanSearcher.searchAll(GoodsFrontListView.class, builder.build());
- DateTime now = DateTime.now();
- dataList.forEach(data -> {
- Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
- .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
- data.setSold(sold + data.getVirtualSold());
- data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
- });
- redisService.setNx(h5CacheKey, dataList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
- //设置特定价格
- setSpecificPrice(dataList, fUid);
- return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
- }
- /**
- * 注册首页平台展示
- */
- @GetMapping("/get/register")
- public Result<List<RegisterGoodsDonView>> getRegisterGoodsDon() {
- String registerCacheKey = RedisService.key.REGISTER_HOME_PAGE_CACHE.getName();
- Object value = redisService.get(registerCacheKey);
- if (value != null) {
- try {
- List<RegisterGoodsDonView> list = Jsons.parseList(value, RegisterGoodsDonView.class);
- if (CollUtil.isNotEmpty(list)) {
- return GatewayResponse.SUCCESS.newBuilder().toResult(list);
- }
- } catch (Exception e) {
- }
- }
- MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
- List<RegisterGoodsDonView> dataList = beanSearcher.searchAll(RegisterGoodsDonView.class, builder.build());
- DateTime now = DateTime.now();
- dataList.forEach(data->{
- Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
- .eq(RegisterOrderDon::getGoodsId, data.getId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
- data.setSold(sold + data.getVirtualSold());
- data.setNotifyMsg(getPayMsgTime(data.getId(), now, 2));
- });
- redisService.setNx(registerCacheKey, dataList, RedisService.key.REGISTER_HOME_PAGE_CACHE.getTimeout());
- return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
- }
- /**
- * 获取商品详情
- */
- @GetMapping("/get/{id}")
- public Result<GoodsDonViews> getDetail(@PathVariable Long id) {
- Long fUid = StpUserUtil.getUserIdAfterLogin();
- GoodsDonViews views = beanSearcher.searchFirst(GoodsDonViews.class, MapUtils.builder().field(GoodsDonViews::getId, id).build());
- views.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::getGoodsId, views.getId()).build()));
- MapBuilder builder = MapUtils.builder().field(GoodsDonSku::getGoodsId, views.getId()).field(GoodsDonSku::getStatus, true);
- if (views.getType() == 1) {
- builder.orderBy(GoodsDonSku::getOrderBy).asc();
- }
- views.setSkuList(beanSearcher.searchAll(GoodsDonSkuFrontView.class, builder.build()));
- views.getSkuList().forEach(sku -> {
- if (sku.getIsDp()) {
- sku.setDpSkuViews(beanSearcher.searchAll(GoodsDiscountPlusPurchaseRelationFrontView.class, MapUtils.builder()
- .field(GoodsDiscountPlusPurchaseRelationFrontView::getSkuId, sku.getId())
- .build()));
- }
- if (views.getIsSp()) {
- if (fUid == null) {
- sku.setSpecificPrice(null);
- sku.setSpecificGoodsIds(null);
- return;
- }
- //设置特定价格
- if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
- sku.setSpecificGoodsIds(null);
- sku.setSpecificPrice(null);
- }
- }
- });
- return GatewayResponse.SUCCESS.newBuilder().toResult(views);
- }
- /**
- * 获取商品推荐平台
- */
- @GetMapping("/get/recommend/{id}")
- public Result<List<GoodsFrontListView>> getRecommendGoodsByGid(@PathVariable Long id) throws Exception {
- String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "recommend:" + id;
- Object value = redisService.get(key);
- Long fUid = StpUserUtil.getUserIdAfterLogin();
- if (value != null) {
- List<GoodsFrontListView> goodsRecommendViews = Jsons.parseList(value.toString(), GoodsFrontListView.class);
- setSpecificPrice(goodsRecommendViews, fUid);
- return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
- }
- if (value == null) {
- GoodsDon goodsDon = beanSearcher.searchFirst(GoodsDon.class, MapUtils.builder()
- .field(GoodsDon::getId, id)
- .field(GoodsDon::getStatus, true)
- .field(GoodsDon::getDeleted, true)
- .build());
- if (goodsDon != null && StrUtil.isNotEmpty(goodsDon.getRecommendGoods())) {
- List<Long> recommend_gidList = Jsons.parseList(goodsDon.getRecommendGoods(), Long.class);
- List<GoodsFrontListView> goodsRecommendViews = beanSearcher.searchAll(GoodsFrontListView.class, MapUtils.builder().field(GoodsRecommendViews::getGoodsId, recommend_gidList).op(Operator.InList).build());
- goodsRecommendViews.forEach(data -> {
- Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
- .eq(RegisterOrderDon::getGoodsId, data.getId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
- data.setSold(sold + data.getVirtualSold());
- });
- redisService.setNx(key, Jsons.toJson(goodsRecommendViews), 60 * 15l);
- //设置特定价格
- setSpecificPrice(goodsRecommendViews, fUid);
- return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
- }
- }
- return GatewayResponse.SUCCESS.newBuilder().toResult();
- }
- /**
- * 获取商品多规格列表
- */
- @GetMapping("/get/sku")
- public Result<List<GoodsDonSkuView>> getGoodsDonSkuView(@RequestParam(value = "skuIds") List<Long> skuIds) {
- if (skuIds.isEmpty()) {
- return GatewayResponse.SUCCESS.newBuilder().toResult();
- }
- List<GoodsDonSkuView> views = beanSearcher.searchAll(GoodsDonSkuView.class, MapUtils.builder()
- .field(GoodsDonSkuView::getSkuId, skuIds).op(Operator.InList)
- .build());
- return GatewayResponse.SUCCESS.newBuilder().toResult(views);
- }
- /**
- * 获取评价列表
- */
- @GetMapping("/get/comments")
- public Result<SearchResult<OrderCommentFrontView>> getComments() {
- SearchResult<OrderCommentFrontView> search = beanSearcher.search(OrderCommentFrontView.class, MapUtils.flatBuilder(request.getParameterMap())
- .orderBy(OrderCommentFrontView::getCommentTime).desc()
- .orderBy(OrderCommentFrontView::getId).desc()
- .build());
- return GatewayResponse.SUCCESS.newBuilder().toResult(search);
- }
- public List<Long> getFilterGoodsIds() {
- //过滤杭州Ai ChatGPT平台
- //获取当前ip地址
- SysConfig sysConfig = sysConfigMapper.selectOne(Wrappers.lambdaQuery(SysConfig.class)
- .eq(SysConfig::getSysKey, Constant.LOCATION_FOR_GOODS_IDS).last("limit 1"));
- List<Long> filter_goodsIds = null;
- if (sysConfig != null && StrUtil.isNotBlank(sysConfig.getSysValue())) {
- if (StringUtil.getRealAddressByIP(ServletUtil.getClientIP(request)).contains("杭州")) {
- try {
- filter_goodsIds = Jsons.parseList(sysConfig.getSysValue(), Long.class);
- } catch (Exception e) {
- }
- }
- }
- return filter_goodsIds;
- }
- /**
- *
- * @param goodsId
- * @param type 1、普通,2、注册平台
- * @return
- */
- public String getPayMsgTime(Long goodsId, DateTime now, Integer type) {
- Date startTime = null;
- StringBuilder notifyMsg = new StringBuilder();
- if (type == 1) {
- OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
- .eq(OrderDon::getGoodsId, goodsId)
- .notIn(OrderDon::getStatus, Constant.noOrderStatus).select(OrderDon::getCreatedTime, OrderDon::getPayTime, OrderDon::getId)
- .orderByDesc(OrderDon::getId)
- .last("limit 1"));
- if (orderDon == null) {
- notifyMsg.append("点击购买立即上车");
- return notifyMsg.toString();
- }
- startTime = orderDon.getPayTime() != null ? orderDon.getPayTime() : orderDon.getCreatedTime();
- } else if (type == 2) {
- RegisterOrderDon orderDon = registerOrderDonMapper.selectOne(Wrappers.lambdaQuery(RegisterOrderDon.class)
- .eq(RegisterOrderDon::getGoodsId, goodsId)
- .notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus).select(RegisterOrderDon::getCreatedTime, RegisterOrderDon::getPayTime, RegisterOrderDon::getId)
- .orderByDesc(RegisterOrderDon::getId)
- .last("limit 1"));
- if (orderDon == null) {
- return null;
- }
- startTime = orderDon.getPayTime() != null ? orderDon.getPayTime() : orderDon.getCreatedTime();
- }
- long hour = DateUtil.between(startTime, now, DateUnit.HOUR);
- if (hour == 0) {
- long minute = DateUtil.between(startTime, now, DateUnit.MINUTE);
- if (minute == 0) {
- notifyMsg.append("1分钟");
- } else {
- notifyMsg.append(minute);
- notifyMsg.append("分钟");
- }
- } else {
- if (hour > 3) {
- int hours = RandomUtil.randomInt(3) + 1;
- notifyMsg.append(hours);
- } else {
- notifyMsg.append(hour);
- }
- notifyMsg.append("小时");
- }
- notifyMsg.append("前有人购买");
- return notifyMsg.toString();
- }
- /**
- * 是否购买过特定平台
- */
- public Boolean isPaySpecificGoodsIds(String specificGoodsIdsStr, Long userId) {
- if (StrUtil.isNotBlank(specificGoodsIdsStr)) {
- try {
- Set<Long> specificGoodsIds = Jsons.parseSet(specificGoodsIdsStr, Long.class);
- Number number = beanSearcher.searchCount(OrderDon.class, MapUtils.builder().field(OrderDon::getGoodsId, specificGoodsIds).op(Operator.InList)
- .field(OrderDon::getUserId, userId)
- .field(OrderDon::getStatus, Constant.noOrderAllStatus).op(Operator.NotIn)
- .build());
- if (number.intValue() == 0) {
- return false;
- }
- return true;
- } catch (Exception e) {
- }
- }
- return false;
- }
- /**
- * 设置平台 特定价格
- */
- public void setSpecificPrice(List<GoodsFrontListView> list, Long fUid) {
- if (fUid != null) {
- list.forEach(data -> {
- if (data.getIsSp()) {
- //查找所有特定规格最小价格 满足条件
- String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "specific:" + data.getId();
- Object speciObj = redisService.get(specificGoodsKey);
- List<GoodsDonSku> specificSkus = null;
- if (speciObj != null) {
- specificSkus = Jsons.parseList(speciObj, GoodsDonSku.class);
- } else {
- specificSkus = goodsDonSkuMapper.selectList(
- Wrappers.lambdaQuery(GoodsDonSku.class)
- .eq(GoodsDonSku::getGoodsId, data.getId())
- .eq(GoodsDonSku::getStatus, true)
- .gt(GoodsDonSku::getSpecificPrice, 0));
- redisService.setNx(specificGoodsKey, specificSkus, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
- }
- specificSkus.forEach(specificSku -> {
- String specificGoodsIdsStr = specificSku.getSpecificGoodsIds();
- if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
- BigDecimal specificPrice = data.getSpecificPrice();
- BigDecimal skuSpecificPrice = specificSku.getSpecificPrice();
- Long specificSkuId = specificSku.getId();
- if (specificPrice == null) {
- data.setSpecificPrice(skuSpecificPrice);
- data.setSpecificSkuId(specificSkuId);
- } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
- data.setSpecificPrice(skuSpecificPrice);
- data.setSpecificSkuId(specificSkuId);
- }
- }
- });
- List<GoodsDonSkuFrontView> skuList = data.getSkuList();
- if (CollUtil.isNotEmpty(skuList)) {
- skuList.forEach(sku->{
- //设置特定价格
- if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
- sku.setSpecificGoodsIds(null);
- sku.setSpecificPrice(null);
- }
- });
- }
- }
- });
- }
- }
- }
|