|
|
@@ -179,19 +179,10 @@ public class GoodsDonController {
|
|
|
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(GoodsDonFrontSkuView.class, MapUtils.builder().field(GoodsDonFrontSkuView::getGoodsId, data.getId()).field(GoodsDonFrontSkuView::getStatus, true).orderBy(GoodsDonFrontSkuView::getPrice).asc().build()));
|
|
|
+ data.setSkuList(beanSearcher.searchAll(GoodsDonSkuFrontView.class, MapUtils.builder().field(GoodsDonSkuFrontView::getGoodsId, data.getId()).field(GoodsDonSkuFrontView::getStatus, true).orderBy(GoodsDonSkuFrontView::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) {
|
|
|
- GoodsDonFrontSkuView donFrontSkuView = skuList.get(0);
|
|
|
- data.setPrice(donFrontSkuView.getPrice());
|
|
|
- data.setMonths(donFrontSkuView.getMonths());
|
|
|
- data.setDays(donFrontSkuView.getDays());
|
|
|
- }
|
|
|
- });
|
|
|
OrderCommentFrontView comments = beanSearcher.searchFirst(OrderCommentFrontView.class, MapUtils.builder()
|
|
|
.field(OrderCommentFrontView::getGoodsId, data.getId())
|
|
|
.orderBy(OrderCommentFrontView::getCommentTime).desc()
|
|
|
@@ -234,12 +225,6 @@ public class GoodsDonController {
|
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
data.setSold(sold + data.getVirtualSold());
|
|
|
- GoodsDonFrontSkuView skuView = beanSearcher.searchFirst(GoodsDonFrontSkuView.class, MapUtils.builder().field(GoodsDonFrontSkuView::getGoodsId, data.getId()).field(GoodsDonFrontSkuView::getStatus, true).orderBy(GoodsDonFrontSkuView::getPrice).asc().build());
|
|
|
- if (skuView != null) {
|
|
|
- data.setPrice(skuView.getPrice());
|
|
|
- data.setMonths(skuView.getMonths());
|
|
|
- data.setDays(skuView.getDays());
|
|
|
- }
|
|
|
data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
|
|
|
});
|
|
|
redisService.setNx(h5CacheKey, dataList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
|
|
|
@@ -283,17 +268,48 @@ public class GoodsDonController {
|
|
|
public Result<GoodsDonViews> getDetail(@PathVariable Long id) {
|
|
|
GoodsDonViews views = beanSearcher.searchFirst(GoodsDonViews.class, MapUtils.builder().field(GoodsDonViews::getId, id).build());
|
|
|
|
|
|
- views.setSpecs(beanSearcher.searchFirst(GoodsDonSpec.class, MapUtils.builder().field(GoodsDonSpec::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);
|
|
|
|
|
|
- GoodsDonSkuView goodsDonSkuView = beanSearcher.searchFirst(GoodsDonSkuView.class, MapUtils.builder().field(GoodsDonSkuView::getGoodsId, id).build());
|
|
|
- if (goodsDonSkuView != null && goodsDonSkuView.getType() == 1) {
|
|
|
+ if (views.getType() == 1) {
|
|
|
builder.orderBy(GoodsDonSku::getOrderBy).asc();
|
|
|
}
|
|
|
- views.setSkuList(beanSearcher.searchAll(GoodsDonSku.class, builder.build()));
|
|
|
+ views.setSkuList(beanSearcher.searchAll(GoodsDonSkuFrontView.class, builder.build()));
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(views);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取商品推荐平台
|
|
|
+ */
|
|
|
+ @GetMapping("/get/recommend/{id}")
|
|
|
+ public Result<List<GoodsRecommendViews>> getRecommendGoodsByGid(@PathVariable Long id) throws Exception {
|
|
|
+ String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "recommend:" + id;
|
|
|
+ Object value = redisService.get(key);
|
|
|
+ if (value != null) {
|
|
|
+ List<GoodsRecommendViews> goodsRecommendViews = Jsons.parseList(value.toString(), GoodsRecommendViews.class);
|
|
|
+ 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<GoodsRecommendViews> goodsRecommendViews = beanSearcher.searchAll(GoodsRecommendViews.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.getGoodsId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
|
|
|
+ data.setSold(sold + data.getVirtualSold());
|
|
|
+ });
|
|
|
+ redisService.setNx(key, Jsons.toJson(goodsRecommendViews), 60 * 15l);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取商品多规格列表
|
|
|
*/
|