|
|
@@ -172,24 +172,8 @@ public class GoodsDonController {
|
|
|
try {
|
|
|
List<GoodsFrontListView> list = Jsons.parseObject(value, List.class);
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
- if (fUid != null) {
|
|
|
- list.forEach(data -> {
|
|
|
- data.getSkuList().forEach(sku -> {
|
|
|
- String specificGoodsIdsStr = sku.getSpecificGoodsIds();
|
|
|
- if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
|
|
|
- BigDecimal specificPrice = data.getSpecificPrice();
|
|
|
- BigDecimal skuSpecificPrice = sku.getSpecificPrice();
|
|
|
- if (specificPrice == null) {
|
|
|
- data.setSpecificPrice(skuSpecificPrice);
|
|
|
- data.setMonths(sku.getMonths());
|
|
|
- } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
|
|
|
- data.setSpecificPrice(skuSpecificPrice);
|
|
|
- data.setMonths(sku.getMonths());
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
+ //设置特定价格
|
|
|
+ setSpecificPrice(list, fUid);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -209,20 +193,6 @@ public class GoodsDonController {
|
|
|
List<GoodsDiscountPlusPurchaseRelationFrontView> dpSkuViews = beanSearcher.searchAll(GoodsDiscountPlusPurchaseRelationFrontView.class, MapUtils.builder().field(GoodsDiscountPlusPurchaseRelationFrontView::getSkuId, sku.getId()).build());
|
|
|
sku.setDpSkuViews(dpSkuViews);
|
|
|
}
|
|
|
- if (fUid != null) {
|
|
|
- String specificGoodsIdsStr = sku.getSpecificGoodsIds();
|
|
|
- if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
|
|
|
- BigDecimal specificPrice = data.getSpecificPrice();
|
|
|
- BigDecimal skuSpecificPrice = sku.getSpecificPrice();
|
|
|
- if (specificPrice == null) {
|
|
|
- data.setSpecificPrice(skuSpecificPrice);
|
|
|
- data.setMonths(sku.getMonths());
|
|
|
- } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
|
|
|
- data.setSpecificPrice(skuSpecificPrice);
|
|
|
- data.setMonths(sku.getMonths());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
});
|
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
@@ -236,6 +206,8 @@ public class GoodsDonController {
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
@@ -259,45 +231,8 @@ public class GoodsDonController {
|
|
|
try {
|
|
|
List<GoodsFrontListView> list = Jsons.parseObject(value, List.class);
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
- 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();
|
|
|
- if (specificPrice == null) {
|
|
|
- data.setSpecificPrice(skuSpecificPrice);
|
|
|
- data.setMonths(specificSku.getMonths());
|
|
|
- } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
|
|
|
- data.setSpecificPrice(skuSpecificPrice);
|
|
|
- data.setMonths(specificSku.getMonths());
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- String specificGoodsIdsStr = data.getSpecificGoodsIds();
|
|
|
- if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
|
|
|
- data.setSpecificGoodsIds(null);
|
|
|
- data.setSpecificPrice(null);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ //设置特定价格
|
|
|
+ setSpecificPrice(list, fUid);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -314,16 +249,10 @@ public class GoodsDonController {
|
|
|
.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
data.setSold(sold + data.getVirtualSold());
|
|
|
data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
|
|
|
-
|
|
|
- if (fUid != null) {
|
|
|
- String specificGoodsIdsStr = data.getSpecificGoodsIds();
|
|
|
- if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
|
|
|
- data.setSpecificGoodsIds(null);
|
|
|
- data.setSpecificPrice(null);
|
|
|
- }
|
|
|
- }
|
|
|
});
|
|
|
redisService.setNx(h5CacheKey, dataList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
|
|
|
+ //设置特定价格
|
|
|
+ setSpecificPrice(dataList, fUid);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
|
|
|
}
|
|
|
|
|
|
@@ -385,7 +314,7 @@ public class GoodsDonController {
|
|
|
* 获取商品推荐平台
|
|
|
*/
|
|
|
@GetMapping("/get/recommend/{id}")
|
|
|
- public Result<List<GoodsRecommendViews>> getRecommendGoodsByGid(@PathVariable Long id, Boolean isLogin) throws Exception {
|
|
|
+ public Result<List<GoodsFrontListView>> getRecommendGoodsByGid(@PathVariable Long id, Boolean isLogin) throws Exception {
|
|
|
String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "recommend:" + id;
|
|
|
Object value = redisService.get(key);
|
|
|
Long userId = null;
|
|
|
@@ -394,16 +323,8 @@ public class GoodsDonController {
|
|
|
}
|
|
|
final Long fUid = userId;
|
|
|
if (value != null) {
|
|
|
- List<GoodsRecommendViews> goodsRecommendViews = Jsons.parseList(value.toString(), GoodsRecommendViews.class);
|
|
|
- if (fUid != null) {
|
|
|
- goodsRecommendViews.forEach(data -> {
|
|
|
- String specificGoodsIdsStr = data.getSpecificGoodsIds();
|
|
|
- if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
|
|
|
- data.setSpecificGoodsIds(null);
|
|
|
- data.setSpecificPrice(null);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ List<GoodsFrontListView> goodsRecommendViews = Jsons.parseList(value.toString(), GoodsFrontListView.class);
|
|
|
+ setSpecificPrice(goodsRecommendViews, fUid);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
|
|
|
}
|
|
|
if (value == null) {
|
|
|
@@ -414,20 +335,15 @@ public class GoodsDonController {
|
|
|
.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());
|
|
|
+ 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.getGoodsId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
|
|
|
+ .eq(RegisterOrderDon::getGoodsId, data.getId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
|
|
|
data.setSold(sold + data.getVirtualSold());
|
|
|
- if (fUid != null) {
|
|
|
- String specificGoodsIdsStr = data.getSpecificGoodsIds();
|
|
|
- if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
|
|
|
- data.setSpecificGoodsIds(null);
|
|
|
- data.setSpecificPrice(null);
|
|
|
- }
|
|
|
- }
|
|
|
});
|
|
|
redisService.setNx(key, Jsons.toJson(goodsRecommendViews), 60 * 15l);
|
|
|
+ //设置特定价格
|
|
|
+ setSpecificPrice(goodsRecommendViews, fUid);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
|
|
|
}
|
|
|
}
|
|
|
@@ -550,4 +466,44 @@ public class GoodsDonController {
|
|
|
}
|
|
|
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();
|
|
|
+ if (specificPrice == null) {
|
|
|
+ data.setSpecificPrice(skuSpecificPrice);
|
|
|
+ data.setMonths(specificSku.getMonths());
|
|
|
+ } else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
|
|
|
+ data.setSpecificPrice(skuSpecificPrice);
|
|
|
+ data.setMonths(specificSku.getMonths());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|