|
@@ -20,6 +20,7 @@ import com.cyksj.mapper.RegisterOrderDonMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.views.*;
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
|
|
|
+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;
|
|
@@ -33,6 +34,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author chan
|
|
* @author chan
|
|
@@ -295,11 +297,34 @@ public class GoodsDonController {
|
|
|
* 获取商品推荐平台
|
|
* 获取商品推荐平台
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/get/recommend/{id}")
|
|
@GetMapping("/get/recommend/{id}")
|
|
|
- public Result<List<GoodsRecommendViews>> getRecommendGoodsByGid(@PathVariable Long id) throws Exception {
|
|
|
|
|
|
|
+ public Result<List<GoodsRecommendViews>> getRecommendGoodsByGid(@PathVariable Long id, Boolean isLogin) 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 userId = null;
|
|
|
|
|
+ if (isLogin) {
|
|
|
|
|
+ userId = StpUserUtil.getLoginIdAsLong();
|
|
|
|
|
+ }
|
|
|
if (value != null) {
|
|
if (value != null) {
|
|
|
List<GoodsRecommendViews> goodsRecommendViews = Jsons.parseList(value.toString(), GoodsRecommendViews.class);
|
|
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) {
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
|
|
|
}
|
|
}
|
|
|
if (value == null) {
|
|
if (value == null) {
|
|
@@ -311,7 +336,7 @@ public class GoodsDonController {
|
|
|
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());
|
|
List<GoodsRecommendViews> goodsRecommendViews = beanSearcher.searchAll(GoodsRecommendViews.class, MapUtils.builder().field(GoodsRecommendViews::getGoodsId, recommend_gidList).op(Operator.InList).build());
|
|
|
- goodsRecommendViews.forEach(data->{
|
|
|
|
|
|
|
+ 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.getGoodsId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
|
|
|
data.setSold(sold + data.getVirtualSold());
|
|
data.setSold(sold + data.getVirtualSold());
|