|
@@ -15,11 +15,14 @@ import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.GoodsDonSkuMapper;
|
|
import com.cyksj.mapper.GoodsDonSkuMapper;
|
|
|
import com.cyksj.mapper.OrderDonMapper;
|
|
import com.cyksj.mapper.OrderDonMapper;
|
|
|
-import com.cyksj.mapper.SysConfigMapper;
|
|
|
|
|
import com.cyksj.mapper.RegisterOrderDonMapper;
|
|
import com.cyksj.mapper.RegisterOrderDonMapper;
|
|
|
|
|
+import com.cyksj.mapper.SysConfigMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
|
|
|
+import com.cyksj.model.request.ClickRecordReq;
|
|
|
import com.cyksj.model.views.*;
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
|
|
|
+import com.cyksj.service.home.ClickRecordFrontService;
|
|
|
|
|
+import com.cyksj.web.util.StpUserUtil;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
import com.ejlchina.searcher.param.Operator;
|
|
import com.ejlchina.searcher.param.Operator;
|
|
@@ -30,9 +33,10 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.Date;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Optional;
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author chan
|
|
* @author chan
|
|
@@ -58,6 +62,35 @@ public class GoodsDonController {
|
|
|
|
|
|
|
|
private final SysConfigMapper sysConfigMapper;
|
|
private final SysConfigMapper sysConfigMapper;
|
|
|
|
|
|
|
|
|
|
+ private final ClickRecordFrontService clickRecordFrontService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取平台商品分类
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/category")
|
|
|
|
|
+ public Result<List<GoodsDonCategoryFrontView>> getCategory() {
|
|
|
|
|
+ String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "category";
|
|
|
|
|
+ Object o = redisService.get(key);
|
|
|
|
|
+ List<GoodsDonCategoryFrontView> list;
|
|
|
|
|
+ if (o == null) {
|
|
|
|
|
+ list = beanSearcher.searchAll(GoodsDonCategoryFrontView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
|
|
+ .build());
|
|
|
|
|
+ redisService.setNx(key, list, 30 * 60l);
|
|
|
|
|
+ o = redisService.get(key);
|
|
|
|
|
+ }
|
|
|
|
|
+ list = Jsons.parseList(o, GoodsDonCategoryFrontView.class);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 商品搜索
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/search")
|
|
|
|
|
+ public Result<SearchResult<GoodsDonSearchView>> search() {
|
|
|
|
|
+ SearchResult<GoodsDonSearchView> search = beanSearcher.search(GoodsDonSearchView.class, MapUtils.flatBuilder(request.getParameterMap()).build());
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取商品列表
|
|
* 获取商品列表
|
|
|
*/
|
|
*/
|
|
@@ -66,7 +99,7 @@ public class GoodsDonController {
|
|
|
SearchResult<GoodsDon> search = beanSearcher.search(GoodsDon.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
SearchResult<GoodsDon> search = beanSearcher.search(GoodsDon.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
.field(GoodsDon::getStatus, true)
|
|
.field(GoodsDon::getStatus, true)
|
|
|
.field(GoodsDon::getDeleted, true)
|
|
.field(GoodsDon::getDeleted, true)
|
|
|
- .orderBy(GoodsDon::getSortBy).desc()
|
|
|
|
|
|
|
+ .orderBy(GoodsDon::getSortBy).asc()
|
|
|
.orderBy(GoodsDon::getId).asc()
|
|
.orderBy(GoodsDon::getId).asc()
|
|
|
.build()
|
|
.build()
|
|
|
);
|
|
);
|
|
@@ -95,7 +128,7 @@ public class GoodsDonController {
|
|
|
.field(GoodsDonPopularizeView::getStatus, true)
|
|
.field(GoodsDonPopularizeView::getStatus, true)
|
|
|
.field(GoodsDonPopularizeView::getDeleted, true)
|
|
.field(GoodsDonPopularizeView::getDeleted, true)
|
|
|
.field(GoodsDonPopularizeView::getType, 1)
|
|
.field(GoodsDonPopularizeView::getType, 1)
|
|
|
- .orderBy(GoodsDonPopularizeView::getSortBy).desc()
|
|
|
|
|
|
|
+ .orderBy(GoodsDonPopularizeView::getSortBy).asc()
|
|
|
.orderBy(GoodsDonPopularizeView::getId).asc()
|
|
.orderBy(GoodsDonPopularizeView::getId).asc()
|
|
|
.build());
|
|
.build());
|
|
|
DateTime now = DateTime.now();
|
|
DateTime now = DateTime.now();
|
|
@@ -161,11 +194,14 @@ public class GoodsDonController {
|
|
|
if (CollUtil.isNotEmpty(filter_goodsIds)) {
|
|
if (CollUtil.isNotEmpty(filter_goodsIds)) {
|
|
|
pcCacheKey += ":hz-ip";
|
|
pcCacheKey += ":hz-ip";
|
|
|
}
|
|
}
|
|
|
|
|
+ Long fUid = StpUserUtil.getUserIdAfterLogin();
|
|
|
Object value = redisService.get(pcCacheKey);
|
|
Object value = redisService.get(pcCacheKey);
|
|
|
if (value != null) {
|
|
if (value != null) {
|
|
|
try {
|
|
try {
|
|
|
- List<GoodsFrontListView> list = Jsons.parseObject(value, List.class);
|
|
|
|
|
|
|
+ List<GoodsFrontListView> list = Jsons.parseList(value, GoodsFrontListView.class);
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
|
+ //设置特定价格
|
|
|
|
|
+ setSpecificPrice(list, fUid);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -175,17 +211,18 @@ public class GoodsDonController {
|
|
|
if (CollUtil.isNotEmpty(filter_goodsIds)) {
|
|
if (CollUtil.isNotEmpty(filter_goodsIds)) {
|
|
|
builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
|
|
builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
|
|
|
}
|
|
}
|
|
|
|
|
+ builder.field(GoodsFrontListView::getType, 1);
|
|
|
List<GoodsFrontListView> list = beanSearcher.searchAll(GoodsFrontListView.class, builder.build());
|
|
List<GoodsFrontListView> list = beanSearcher.searchAll(GoodsFrontListView.class, builder.build());
|
|
|
DateTime now = DateTime.now();
|
|
DateTime now = DateTime.now();
|
|
|
list.forEach(data -> {
|
|
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);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+// data.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::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)
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
data.setSold(sold + data.getVirtualSold());
|
|
data.setSold(sold + data.getVirtualSold());
|
|
@@ -195,9 +232,11 @@ public class GoodsDonController {
|
|
|
.orderBy(OrderCommentFrontView::getId).desc()
|
|
.orderBy(OrderCommentFrontView::getId).desc()
|
|
|
.build());
|
|
.build());
|
|
|
data.setComments(comments);
|
|
data.setComments(comments);
|
|
|
- data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
|
|
|
|
|
|
|
+ data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
|
|
|
});
|
|
});
|
|
|
redisService.setNx(pcCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
|
|
redisService.setNx(pcCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
|
|
|
|
|
+ //设置特定价格
|
|
|
|
|
+ setSpecificPrice(list, fUid);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -205,17 +244,21 @@ public class GoodsDonController {
|
|
|
* h5 银河首页平台展示
|
|
* h5 银河首页平台展示
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/get/homePage")
|
|
@GetMapping("/get/homePage")
|
|
|
- public Result<List<GoodsHomePageView>> getGoodsHomePage() {
|
|
|
|
|
|
|
+ @Deprecated
|
|
|
|
|
+ public Result<List<GoodsFrontListView>> getGoodsHomePage() {
|
|
|
List<Long> filter_goodsIds = getFilterGoodsIds();
|
|
List<Long> filter_goodsIds = getFilterGoodsIds();
|
|
|
String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "H5";
|
|
String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "H5";
|
|
|
if (CollUtil.isNotEmpty(filter_goodsIds)) {
|
|
if (CollUtil.isNotEmpty(filter_goodsIds)) {
|
|
|
h5CacheKey += ":hz-ip";
|
|
h5CacheKey += ":hz-ip";
|
|
|
}
|
|
}
|
|
|
|
|
+ Long fUid = StpUserUtil.getUserIdAfterLogin();
|
|
|
Object value = redisService.get(h5CacheKey);
|
|
Object value = redisService.get(h5CacheKey);
|
|
|
if (value != null) {
|
|
if (value != null) {
|
|
|
try {
|
|
try {
|
|
|
- List<GoodsHomePageView> list = Jsons.parseObject(value, List.class);
|
|
|
|
|
|
|
+ List<GoodsFrontListView> list = Jsons.parseList(value, GoodsFrontListView.class);
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
|
+ //设置特定价格
|
|
|
|
|
+ setSpecificPrice(list, fUid);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -225,7 +268,8 @@ public class GoodsDonController {
|
|
|
if (CollUtil.isNotEmpty(filter_goodsIds)) {
|
|
if (CollUtil.isNotEmpty(filter_goodsIds)) {
|
|
|
builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
|
|
builder.field(GoodsFrontListView::getId, filter_goodsIds).op(Operator.NotIn);
|
|
|
}
|
|
}
|
|
|
- List<GoodsHomePageView> dataList = beanSearcher.searchAll(GoodsHomePageView.class, builder.build());
|
|
|
|
|
|
|
+ builder.field(GoodsFrontListView::getType, 1);
|
|
|
|
|
+ List<GoodsFrontListView> dataList = beanSearcher.searchAll(GoodsFrontListView.class, builder.build());
|
|
|
DateTime now = DateTime.now();
|
|
DateTime now = DateTime.now();
|
|
|
dataList.forEach(data -> {
|
|
dataList.forEach(data -> {
|
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
@@ -234,6 +278,8 @@ public class GoodsDonController {
|
|
|
data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
|
|
data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
|
|
|
});
|
|
});
|
|
|
redisService.setNx(h5CacheKey, dataList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
|
|
redisService.setNx(h5CacheKey, dataList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
|
|
|
|
|
+ //设置特定价格
|
|
|
|
|
+ setSpecificPrice(dataList, fUid);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -255,12 +301,12 @@ public class GoodsDonController {
|
|
|
}
|
|
}
|
|
|
MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
List<RegisterGoodsDonView> dataList = beanSearcher.searchAll(RegisterGoodsDonView.class, builder.build());
|
|
List<RegisterGoodsDonView> dataList = beanSearcher.searchAll(RegisterGoodsDonView.class, builder.build());
|
|
|
- DateTime now = DateTime.now();
|
|
|
|
|
- dataList.forEach(data->{
|
|
|
|
|
|
|
+ DateTime now = DateTime.now();
|
|
|
|
|
+ dataList.forEach(data -> {
|
|
|
Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
|
|
Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
|
|
|
.eq(RegisterOrderDon::getGoodsId, data.getId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
|
|
.eq(RegisterOrderDon::getGoodsId, data.getId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
|
|
|
data.setSold(sold + data.getVirtualSold());
|
|
data.setSold(sold + data.getVirtualSold());
|
|
|
- data.setNotifyMsg(getPayMsgTime(data.getId(), now, 2));
|
|
|
|
|
|
|
+ data.setNotifyMsg(getPayMsgTime(data.getId(), now, 2));
|
|
|
});
|
|
});
|
|
|
redisService.setNx(registerCacheKey, dataList, RedisService.key.REGISTER_HOME_PAGE_CACHE.getTimeout());
|
|
redisService.setNx(registerCacheKey, dataList, RedisService.key.REGISTER_HOME_PAGE_CACHE.getTimeout());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
|
|
@@ -271,8 +317,14 @@ public class GoodsDonController {
|
|
|
* 获取商品详情
|
|
* 获取商品详情
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/get/{id}")
|
|
@GetMapping("/get/{id}")
|
|
|
- public Result<GoodsDonViews> getDetail(@PathVariable Long id) {
|
|
|
|
|
- GoodsDonViews views = beanSearcher.searchFirst(GoodsDonViews.class, MapUtils.builder().field(GoodsDonViews::getId, id).build());
|
|
|
|
|
|
|
+ public Result<GoodsFrontListView> getDetail(@PathVariable Long id) {
|
|
|
|
|
+ Long fUid = StpUserUtil.getUserIdAfterLogin();
|
|
|
|
|
+ GoodsFrontListView views = beanSearcher.searchFirst(GoodsFrontListView.class, MapUtils.builder().field(GoodsDonViews::getId, id)
|
|
|
|
|
+ .build());
|
|
|
|
|
+
|
|
|
|
|
+ Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
|
|
+ .eq(OrderDon::getGoodsId, views.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
|
|
+ views.setSold(sold + views.getVirtualSold());
|
|
|
|
|
|
|
|
views.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::getGoodsId, views.getId()).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);
|
|
MapBuilder builder = MapUtils.builder().field(GoodsDonSku::getGoodsId, views.getId()).field(GoodsDonSku::getStatus, true);
|
|
@@ -287,6 +339,30 @@ public class GoodsDonController {
|
|
|
.field(GoodsDiscountPlusPurchaseRelationFrontView::getSkuId, sku.getId())
|
|
.field(GoodsDiscountPlusPurchaseRelationFrontView::getSkuId, sku.getId())
|
|
|
.build()));
|
|
.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);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ BigDecimal specificPrice = views.getSpecificPrice();
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal skuSpecificPrice = sku.getSpecificPrice();
|
|
|
|
|
+ Long specificSkuId = sku.getId();
|
|
|
|
|
+ if (specificPrice == null) {
|
|
|
|
|
+ views.setSpecificPrice(skuSpecificPrice);
|
|
|
|
|
+ views.setSpecificSkuId(specificSkuId);
|
|
|
|
|
+ } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
|
|
|
|
|
+ views.setSpecificPrice(skuSpecificPrice);
|
|
|
|
|
+ views.setSpecificSkuId(specificSkuId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(views);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(views);
|
|
|
}
|
|
}
|
|
@@ -295,11 +371,13 @@ public class GoodsDonController {
|
|
|
* 获取商品推荐平台
|
|
* 获取商品推荐平台
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/get/recommend/{id}")
|
|
@GetMapping("/get/recommend/{id}")
|
|
|
- public Result<List<GoodsRecommendViews>> getRecommendGoodsByGid(@PathVariable Long id) throws Exception {
|
|
|
|
|
|
|
+ public Result<List<GoodsFrontListView>> getRecommendGoodsByGid(@PathVariable Long id) throws Exception {
|
|
|
String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "recommend:" + id;
|
|
String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "recommend:" + id;
|
|
|
Object value = redisService.get(key);
|
|
Object value = redisService.get(key);
|
|
|
|
|
+ Long fUid = StpUserUtil.getUserIdAfterLogin();
|
|
|
if (value != null) {
|
|
if (value != null) {
|
|
|
- List<GoodsRecommendViews> goodsRecommendViews = Jsons.parseList(value.toString(), GoodsRecommendViews.class);
|
|
|
|
|
|
|
+ List<GoodsFrontListView> goodsRecommendViews = Jsons.parseList(value.toString(), GoodsFrontListView.class);
|
|
|
|
|
+ setSpecificPrice(goodsRecommendViews, fUid);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
|
|
|
}
|
|
}
|
|
|
if (value == null) {
|
|
if (value == null) {
|
|
@@ -310,13 +388,15 @@ public class GoodsDonController {
|
|
|
.build());
|
|
.build());
|
|
|
if (goodsDon != null && StrUtil.isNotEmpty(goodsDon.getRecommendGoods())) {
|
|
if (goodsDon != null && StrUtil.isNotEmpty(goodsDon.getRecommendGoods())) {
|
|
|
List<Long> recommend_gidList = Jsons.parseList(goodsDon.getRecommendGoods(), Long.class);
|
|
List<Long> recommend_gidList = Jsons.parseList(goodsDon.getRecommendGoods(), Long.class);
|
|
|
- List<GoodsRecommendViews> goodsRecommendViews = beanSearcher.searchAll(GoodsRecommendViews.class, MapUtils.builder().field(GoodsRecommendViews::getGoodsId, recommend_gidList).op(Operator.InList).build());
|
|
|
|
|
- goodsRecommendViews.forEach(data->{
|
|
|
|
|
|
|
+ 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)
|
|
Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
|
|
|
- .eq(RegisterOrderDon::getGoodsId, data.getGoodsId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
|
|
|
|
|
|
|
+ .eq(RegisterOrderDon::getGoodsId, data.getId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
|
|
|
data.setSold(sold + data.getVirtualSold());
|
|
data.setSold(sold + data.getVirtualSold());
|
|
|
});
|
|
});
|
|
|
redisService.setNx(key, Jsons.toJson(goodsRecommendViews), 60 * 15l);
|
|
redisService.setNx(key, Jsons.toJson(goodsRecommendViews), 60 * 15l);
|
|
|
|
|
+ //设置特定价格
|
|
|
|
|
+ setSpecificPrice(goodsRecommendViews, fUid);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -349,6 +429,70 @@ public class GoodsDonController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取首页配置列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/homeManage")
|
|
|
|
|
+ public Result<Map<String, List<HomeManagementFrontView>>> getHomeManagementFrontPage() {
|
|
|
|
|
+ String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "homeManage";
|
|
|
|
|
+ Long fUid = StpUserUtil.getUserIdAfterLogin();
|
|
|
|
|
+ Object o = redisService.get(key);
|
|
|
|
|
+ if (o == null) {
|
|
|
|
|
+ String condition = "g.deleted is true and g.status is true";
|
|
|
|
|
+ Map<String, List<HomeManagementFrontView>> map = new ConcurrentHashMap<>();
|
|
|
|
|
+ Stream.of(HomeManagementConfig.Type.values())
|
|
|
|
|
+ .forEach(type -> {
|
|
|
|
|
+ MapBuilder builder = MapUtils.builder()
|
|
|
|
|
+ .field(HomeManagementConfig::getType, type.name());
|
|
|
|
|
+ if (type == HomeManagementConfig.Type.ex || type == HomeManagementConfig.Type.vg) {
|
|
|
|
|
+ builder.put("condition", condition);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
|
|
|
|
|
+ if (type == HomeManagementConfig.Type.ex || type == HomeManagementConfig.Type.vg) {
|
|
|
|
|
+ DateTime now = DateTime.now();
|
|
|
|
|
+ homeManagementFrontViews.forEach(data -> {
|
|
|
|
|
+ Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
|
|
+ .eq(OrderDon::getGoodsId, data.getGoodsId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
|
|
+ data.setSold(sold + data.getVirtualSold());
|
|
|
|
|
+ data.setNotifyMsg(getPayMsgTime(data.getGoodsId(), now, 1));
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 首页点击 记录
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/homePage/click")
|
|
|
|
|
+ public Result<String> homeManageClick(@RequestBody ClickRecordReq request) {
|
|
|
|
|
+ Long userId = StpUserUtil.getUserIdAfterLogin();
|
|
|
|
|
+ clickRecordFrontService.click(userId, request);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public List<Long> getFilterGoodsIds() {
|
|
public List<Long> getFilterGoodsIds() {
|
|
|
//过滤杭州Ai ChatGPT平台
|
|
//过滤杭州Ai ChatGPT平台
|
|
|
//获取当前ip地址
|
|
//获取当前ip地址
|
|
@@ -373,49 +517,161 @@ public class GoodsDonController {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
public String getPayMsgTime(Long goodsId, DateTime now, Integer type) {
|
|
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();
|
|
|
|
|
|
|
+ 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 void setSpecificPrice(List<GoodsFrontListView> list, Long fUid) {
|
|
|
|
|
+ if (fUid != null && CollUtil.isNotEmpty(list)) {
|
|
|
|
|
+ list.forEach(data -> {
|
|
|
|
|
+ if (data.getIsSp()) {
|
|
|
|
|
+ //查找所有特定规格最小价格 满足条件
|
|
|
|
|
+ List<GoodsDonSku> specificSkus = getSpecificSku(data.getId());
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 是否购买过特定平台
|
|
|
|
|
+ */
|
|
|
|
|
+ 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 List<GoodsDonSku> getSpecificSku(Long goodsId) {
|
|
|
|
|
+ //查找所有特定规格最小价格 满足条件
|
|
|
|
|
+ String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "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) {
|
|
|
|
|
+ if (fUid != null && CollUtil.isNotEmpty(list)) {
|
|
|
|
|
+ list.forEach(data -> {
|
|
|
|
|
+ if (data.getIsSp() != null && data.getIsSp()) {
|
|
|
|
|
+ //查找所有特定规格最小价格 满足条件
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|