|
|
@@ -35,7 +35,9 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* @author chan
|
|
|
@@ -406,6 +408,84 @@ public class GoodsDonController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(map);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取h5首页配置列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get/homeManage")
|
|
|
+ public Result<Map<String, List<HomeManagementFrontView>>> getHomeManagementFrontPage(String customId) {
|
|
|
+ String key = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "homeManage";
|
|
|
+ Long yhsId = null;
|
|
|
+ if (StrUtil.isNotBlank(customId)) {
|
|
|
+ yhsId = yhShopFrontService.getYhsIdByCustomId(customId);
|
|
|
+ key = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhsId + ":homeManage";
|
|
|
+ }
|
|
|
+ Long fUid = StpUserUtil.getUserIdAfterLogin();
|
|
|
+ Object o = redisService.get(key);
|
|
|
+ if (o == null) {
|
|
|
+ String condition = "g.deleted is true and g.status is true";
|
|
|
+ if (yhsId != null) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ Map<String, List<HomeManagementFrontView>> map = new ConcurrentHashMap<>();
|
|
|
+ final String conditionSql = condition;
|
|
|
+ Stream.of(HomeManagementConfig.Type.values())
|
|
|
+ .forEach(type -> {
|
|
|
+ MapBuilder builder = MapUtils.builder()
|
|
|
+ .field(HomeManagementFrontView::getType, type.name());
|
|
|
+ if (type == HomeManagementConfig.Type.ex || type == HomeManagementConfig.Type.vg) {
|
|
|
+ builder.put("condition", conditionSql);
|
|
|
+ }
|
|
|
+ if (type == HomeManagementConfig.Type.ad) {
|
|
|
+ builder.field(HomeManagementFrontView::getAdType, HomeManagementConfig.AdType.h5.name());
|
|
|
+ }
|
|
|
+ List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
|
|
|
+ map.putIfAbsent(type.name(), homeManagementFrontViews);
|
|
|
+ });
|
|
|
+ redisService.setNx(key, map, 50 * 60l);
|
|
|
+ o = redisService.get(key);
|
|
|
+ }
|
|
|
+ Map<String, List<HomeManagementFrontView>> map = Jsons.parseObject(o, Map.class);
|
|
|
+ if (map.containsKey(HomeManagementConfig.Type.ex.name()) || map.containsKey(HomeManagementConfig.Type.vg.name())) {
|
|
|
+ try {
|
|
|
+ //设置特定价格
|
|
|
+ List<HomeManagementFrontView> exList = Jsons.parseList(Jsons.toJson(map.get(HomeManagementConfig.Type.ex.name())), HomeManagementFrontView.class);
|
|
|
+ if (CollUtil.isNotEmpty(exList)) {
|
|
|
+ setHomeManageSpecific(exList, fUid);
|
|
|
+ map.put(HomeManagementConfig.Type.ex.name(), exList);
|
|
|
+ }
|
|
|
+ //设置特定价格
|
|
|
+ List<HomeManagementFrontView> vgList = Jsons.parseList(Jsons.toJson(map.get(HomeManagementConfig.Type.vg.name())), HomeManagementFrontView.class);
|
|
|
+ if (CollUtil.isNotEmpty(vgList)) {
|
|
|
+ setHomeManageSpecific(vgList, fUid);
|
|
|
+ map.put(HomeManagementConfig.Type.vg.name(), vgList);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取pc广告配置
|
|
|
+ */
|
|
|
+ @GetMapping("/get/pc/homeManage")
|
|
|
+ public Result<Map<String, List<HomeManagementFrontView>>> getPcHomeManagementFrontPage() {
|
|
|
+ String key = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "pc:homeManage";
|
|
|
+ Object o = redisService.get(key);
|
|
|
+ if (o == null) {
|
|
|
+ MapBuilder builder = MapUtils.builder()
|
|
|
+ .field(HomeManagementFrontView::getAdType, List.of(HomeManagementConfig.AdType.pc.name(), HomeManagementConfig.AdType.pcSec.name(), HomeManagementConfig.AdType.pcDis.name())).op(Operator.InList);
|
|
|
+ List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
|
|
|
+ Map<HomeManagementConfig.AdType, List<HomeManagementFrontView>> map = homeManagementFrontViews.stream().collect(Collectors.groupingBy(HomeManagementFrontView::getAdType));
|
|
|
+ redisService.setNx(key, map, 50 * 60l);
|
|
|
+ o = redisService.get(key);
|
|
|
+ }
|
|
|
+ Map<String, List<HomeManagementFrontView>> map = Jsons.parseObject(o, Map.class);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(map);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public List<Long> getFilterGoodsIds() {
|
|
|
//过滤杭州Ai ChatGPT平台
|
|
|
//获取当前ip地址
|
|
|
@@ -549,6 +629,61 @@ public class GoodsDonController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取特定规格
|
|
|
+ */
|
|
|
+ public List<GoodsDonSku> getSpecificSku(Long goodsId) {
|
|
|
+ //查找所有特定规格最小价格 满足条件
|
|
|
+ String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "specific:" + goodsId;
|
|
|
+ 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, goodsId)
|
|
|
+ .eq(GoodsDonSku::getStatus, true)
|
|
|
+ .gt(GoodsDonSku::getSpecificPrice, 0));
|
|
|
+ redisService.setNx(specificGoodsKey, specificSkus, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
|
|
|
+ }
|
|
|
+ specificSkus = Optional.ofNullable(specificSkus).orElse(new ArrayList<>());
|
|
|
+ return specificSkus;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置首页配置 涉及平台特定价格
|
|
|
+ */
|
|
|
+ public void setHomeManageSpecific(List<HomeManagementFrontView> list, Long fUid) {
|
|
|
+ DateTime now = DateTime.now();
|
|
|
+ list.forEach(data -> {
|
|
|
+ if (data.getIsSp() != null && data.getIsSp() && fUid != null) {
|
|
|
+ //查找所有特定规格最小价格 满足条件
|
|
|
+ List<GoodsDonSku> specificSkus = getSpecificSku(data.getGoodsId());
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ .eq(OrderDon::getGoodsId, data.getGoodsId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
+ data.setSold(sold + data.getSold());
|
|
|
+ data.setNotifyMsg(getPayMsgTime(data.getGoodsId(), now, 1, null));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 店铺平台列表
|
|
|
*/
|