zoujiajian 1 yıl önce
ebeveyn
işleme
05bc5486e9

+ 1 - 1
netflix-dao/src/main/resources/mapper/CouponUserMapper.xml

@@ -319,7 +319,7 @@
     <select id="selectNoLoginRecommendCouponReduce" resultType="com.cyksj.model.entity.Coupon">
         select c.id,
                c.discount,
-               c.reduce_money
+               c.reduce_money,
                if(type = 'discount', sku.price * (1 - c.discount), c.reduce_money) as couponMoney
         from coupon c
                  inner join coupon_recommend cr on cr.coupon_id = c.id

+ 20 - 28
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -653,13 +653,6 @@ public class GoodsDonController {
 							}
 						}
 						List<HomeManagementFrontView> homeManagementFrontViews = beanSearcher.searchAll(HomeManagementFrontView.class, builder.build());
-						if (type == HomeManagementConfig.Type.vg) {
-							//未登录
-							if (fUid == null) {
-								//推荐优惠券商品最低折扣
-								setHomeConfigGoodsCouponMoney(homeManagementFrontViews);
-							}
-						}
 						//实物推荐多语言
 						if (language.get() && type == HomeManagementConfig.Type.rg) {
 							backInfoTranslationsFrontService.getHomeConfigRealGoodsLanguage(homeManagementFrontViews, lang);
@@ -987,6 +980,11 @@ public class GoodsDonController {
 					data.setMonths(minPriceUserOwnsSku.getMonths());
 					data.setDays(minPriceUserOwnsSku.getDays());
 				}
+				//未登录
+				if (fUid == null) {
+					//推荐优惠券商品最低折扣
+					setHomeConfigGoodsCouponMoney(data);
+				}
 				return true;
 			}).collect(Collectors.toList());
 			setHomeManageSpecific(list, fUid, dsUserId.get(), discount);
@@ -1079,10 +1077,6 @@ public class GoodsDonController {
 		if (cgy != null) {
 			categoryGoodsKey += ":" + cgy;
 		}
-		//未登录状态 缓存一个未登录的key
-		if (fUid == null) {
-			categoryGoodsKey += ":noLgoin";
-		}
 		//List<Long> filter_goodsIds = getFilterGoodsIds();
 		List<Long> filter_goodsIds = null;
 		if (CollUtil.isNotEmpty(filter_goodsIds)) {
@@ -1117,11 +1111,6 @@ public class GoodsDonController {
 					//多语言
 					backInfoTranslationsFrontService.setCategoryGoodsLanguage(data, lang);
 				}
-				//未登录
-				if (fUid == null) {
-					//推荐优惠券商品最低折扣
-					setGoodsCouponMoney(data);
-				}
 			});
 			redisService.setNx(categoryGoodsKey, goodsFrontListViews, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 10 * 60);
 			o = redisService.get(categoryGoodsKey);
@@ -1173,6 +1162,11 @@ public class GoodsDonController {
 			data.setChannelDiscount(discount);
 			//商品优惠折扣
 			setUserCouponGoodsMoney(fUid, data);
+			//未登录
+			if (fUid == null) {
+				//推荐优惠券商品最低折扣
+				setGoodsCouponMoney(data);
+			}
 			return true;
 		}).collect(Collectors.toList());
 		return GatewayResponse.SUCCESS.newBuilder().toResult(goodsFrontListViews);
@@ -1670,19 +1664,17 @@ public class GoodsDonController {
 	/**
 	 * 未登录 首页推荐推荐优惠券
 	 */
-	private void setHomeConfigGoodsCouponMoney(List<HomeManagementFrontView> homeManagementFrontViews) {
+	private void setHomeConfigGoodsCouponMoney(HomeManagementFrontView data) {
 		//寻找对应最低规格的推荐优惠券
-		homeManagementFrontViews.forEach(data->{
-			Coupon coupon = couponUserMapper.selectNoLoginRecommendCouponReduce(data.getGoodsId(), data.getPrice());
-			if (coupon != null) {
-				data.setDiscount(coupon.getDiscount());
-				data.setReduceMoney(coupon.getReduceMoney());
-				data.setDiscountPrice(data.getPrice().subtract(coupon.getCouponMoney()));
-				data.setValidEndTime(coupon.getValidEndTime());
-				data.setCouponId(coupon.getId());
-				data.setSource(1);
-			}
-		});
+		Coupon coupon = couponUserMapper.selectNoLoginRecommendCouponReduce(data.getGoodsId(), data.getPrice());
+		if (coupon != null) {
+			data.setDiscount(coupon.getDiscount());
+			data.setReduceMoney(coupon.getReduceMoney());
+			data.setDiscountPrice(data.getPrice().subtract(coupon.getCouponMoney()));
+			data.setValidEndTime(coupon.getValidEndTime());
+			data.setCouponId(coupon.getId());
+			data.setSource(1);
+		}
 	}
 
 }