|
|
@@ -15,8 +15,8 @@ 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.mapper.RegisterOrderDonMapper;
|
|
|
+import com.cyksj.mapper.SysConfigMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
@@ -157,17 +157,31 @@ public class GoodsDonController {
|
|
|
* 官网首页 平台列表
|
|
|
*/
|
|
|
@GetMapping("/get/list")
|
|
|
- public Result<List<GoodsFrontListView>> getGoodsList() {
|
|
|
+ public Result<List<GoodsFrontListView>> getGoodsList(Boolean isLogin) {
|
|
|
List<Long> filter_goodsIds = getFilterGoodsIds();
|
|
|
String pcCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "PC";
|
|
|
if (CollUtil.isNotEmpty(filter_goodsIds)) {
|
|
|
pcCacheKey += ":hz-ip";
|
|
|
}
|
|
|
+ Long userId = null;
|
|
|
+ if (isLogin != null && isLogin) {
|
|
|
+ userId = StpUserUtil.getLoginIdAsLong();
|
|
|
+ }
|
|
|
+ final Long fUid = userId;
|
|
|
Object value = redisService.get(pcCacheKey);
|
|
|
if (value != null) {
|
|
|
try {
|
|
|
List<GoodsFrontListView> list = Jsons.parseObject(value, List.class);
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
+ if (fUid != null) {
|
|
|
+ list.forEach(data -> {
|
|
|
+ String specificGoodsIdsStr = data.getSpecificGoodsIds();
|
|
|
+ if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
|
|
|
+ data.setSpecificGoodsIds(null);
|
|
|
+ data.setSpecificPrice(null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -198,6 +212,13 @@ public class GoodsDonController {
|
|
|
.build());
|
|
|
data.setComments(comments);
|
|
|
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(pcCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
@@ -207,17 +228,31 @@ public class GoodsDonController {
|
|
|
* h5 银河首页平台展示
|
|
|
*/
|
|
|
@GetMapping("/get/homePage")
|
|
|
- public Result<List<GoodsHomePageView>> getGoodsHomePage() {
|
|
|
+ public Result<List<GoodsHomePageView>> getGoodsHomePage(Boolean isLogin) {
|
|
|
List<Long> filter_goodsIds = getFilterGoodsIds();
|
|
|
String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "H5";
|
|
|
if (CollUtil.isNotEmpty(filter_goodsIds)) {
|
|
|
h5CacheKey += ":hz-ip";
|
|
|
}
|
|
|
+ Long userId = null;
|
|
|
+ if (isLogin != null && isLogin) {
|
|
|
+ userId = StpUserUtil.getLoginIdAsLong();
|
|
|
+ }
|
|
|
+ final Long fUid = userId;
|
|
|
Object value = redisService.get(h5CacheKey);
|
|
|
if (value != null) {
|
|
|
try {
|
|
|
List<GoodsHomePageView> list = Jsons.parseObject(value, List.class);
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
+ if (fUid != null) {
|
|
|
+ list.forEach(data -> {
|
|
|
+ String specificGoodsIdsStr = data.getSpecificGoodsIds();
|
|
|
+ if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
|
|
|
+ data.setSpecificGoodsIds(null);
|
|
|
+ data.setSpecificPrice(null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -234,6 +269,14 @@ 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());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
|
|
|
@@ -304,26 +347,17 @@ public class GoodsDonController {
|
|
|
if (isLogin) {
|
|
|
userId = StpUserUtil.getLoginIdAsLong();
|
|
|
}
|
|
|
+ final Long fUid = userId;
|
|
|
if (value != null) {
|
|
|
List<GoodsRecommendViews> goodsRecommendViews = Jsons.parseList(value.toString(), GoodsRecommendViews.class);
|
|
|
- if (userId != null) {
|
|
|
- for (GoodsRecommendViews goodsRecommendView : goodsRecommendViews) {
|
|
|
- String specificGoodsIdsStr = goodsRecommendView.getSpecificGoodsIds();
|
|
|
- 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) {
|
|
|
- goodsRecommendView.setSpecificPrice(null);
|
|
|
- goodsRecommendView.setSpecificGoodsIds(null);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- }
|
|
|
+ if (fUid != null) {
|
|
|
+ goodsRecommendViews.forEach(data -> {
|
|
|
+ String specificGoodsIdsStr = data.getSpecificGoodsIds();
|
|
|
+ if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
|
|
|
+ data.setSpecificGoodsIds(null);
|
|
|
+ data.setSpecificPrice(null);
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
|
|
|
}
|
|
|
@@ -340,6 +374,13 @@ public class GoodsDonController {
|
|
|
Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
|
|
|
.eq(RegisterOrderDon::getGoodsId, data.getGoodsId()).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);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
|
|
|
@@ -443,4 +484,25 @@ public class GoodsDonController {
|
|
|
notifyMsg.append("前有人购买");
|
|
|
return notifyMsg.toString();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 是否购买过特定平台
|
|
|
+ */
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|