|
|
@@ -5,13 +5,17 @@ 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.SysConfigMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
@@ -49,6 +53,8 @@ public class GoodsDonController {
|
|
|
|
|
|
private final RedisService redisService;
|
|
|
|
|
|
+ private final SysConfigMapper sysConfigMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 获取商品列表
|
|
|
*/
|
|
|
@@ -157,8 +163,12 @@ public class GoodsDonController {
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
}
|
|
|
- List<GoodsFrontListView> list = beanSearcher.searchAll(GoodsFrontListView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
- .build());
|
|
|
+ List<Long> filter_goodsIds = getFilterGoodsIds();
|
|
|
+ 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()));
|
|
|
@@ -234,8 +244,12 @@ public class GoodsDonController {
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
}
|
|
|
- List<GoodsHomePageView> dataList = beanSearcher.searchAll(GoodsHomePageView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
- .build());
|
|
|
+ List<Long> filter_goodsIds = getFilterGoodsIds();
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
+ if (CollUtil.isNotEmpty(filter_goodsIds)) {
|
|
|
+ builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
|
|
|
+ }
|
|
|
+ List<GoodsHomePageView> dataList = beanSearcher.searchAll(GoodsHomePageView.class, builder.build());
|
|
|
dataList.forEach(data -> {
|
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
@@ -294,4 +308,21 @@ public class GoodsDonController {
|
|
|
.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;
|
|
|
+ }
|
|
|
}
|