|
|
@@ -19,8 +19,10 @@ import com.cyksj.mapper.OrderDonMapper;
|
|
|
import com.cyksj.model.entity.GoodsDon;
|
|
|
import com.cyksj.model.entity.GoodsDonSku;
|
|
|
import com.cyksj.model.entity.OrderDon;
|
|
|
+import com.cyksj.model.entity.UserPageLanguage;
|
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
+import com.cyksj.service.translations.BackInfoTranslationsFrontService;
|
|
|
import com.cyksj.service.user.UserBindRelationService;
|
|
|
import com.cyksj.service.user.UserService;
|
|
|
import com.cyksj.web.util.StpUserUtil;
|
|
|
@@ -67,6 +69,8 @@ public class GoodsDonController {
|
|
|
|
|
|
private final UserBindRelationService userBindRelationService;
|
|
|
|
|
|
+ private final BackInfoTranslationsFrontService backInfoTranslationsFrontService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取平台商品分类
|
|
|
*/
|
|
|
@@ -88,15 +92,6 @@ public class GoodsDonController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 商品搜索
|
|
|
- */
|
|
|
- @GetMapping("/search")
|
|
|
- public Result<SearchResult<GoodsDonSearchView>> search() {
|
|
|
- SearchResult<GoodsDonSearchView> search = beanSearcher.search(GoodsDonSearchView.class, MapUtils.flatBuilder(request.getParameterMap()).build());
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 获取商品列表
|
|
|
*/
|
|
|
@@ -128,8 +123,14 @@ public class GoodsDonController {
|
|
|
*/
|
|
|
@GetMapping("/get/{id}")
|
|
|
public Result<? extends Object> getDetail(@PathVariable Long id, String dsCode) {
|
|
|
- String goodsDetailKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "goods_detail:" + id;
|
|
|
- //List<Long> filter_goodsIds = getFilterGoodsIds();
|
|
|
+ String lang = request.getHeader("lang");
|
|
|
+ AtomicBoolean language = new AtomicBoolean(false);
|
|
|
+ String goodsDetailKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "goods_detail:" + id;
|
|
|
+ if (!UserPageLanguage.Language.zh_HK.name().equals(lang)) {
|
|
|
+ goodsDetailKey += ":" + lang;
|
|
|
+ language.set(true);
|
|
|
+ }
|
|
|
+ //List<Long> filter_goodsIds = getFilterGoodsIds();
|
|
|
List<Long> filter_goodsIds = null;
|
|
|
//存在过滤平台 商品详情不返回
|
|
|
if (CollUtil.isNotEmpty(filter_goodsIds) && filter_goodsIds.contains(id)) {
|
|
|
@@ -151,6 +152,9 @@ public class GoodsDonController {
|
|
|
}
|
|
|
views.setSkuList(beanSearcher.searchAll(GoodsDonSkuFrontView.class, builder.build()));
|
|
|
views.setSold(getGoodsSold(views.getId(), views.getSold()));
|
|
|
+ if (language.get()) {
|
|
|
+ backInfoTranslationsFrontService.setGoodsDetailLanguage(views, lang);
|
|
|
+ }
|
|
|
redisService.setNx(goodsDetailKey, views, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 60 * RandomUtil.randomInt(10));
|
|
|
o = redisService.get(goodsDetailKey);
|
|
|
}
|
|
|
@@ -209,92 +213,6 @@ public class GoodsDonController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(views);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取商品推荐平台
|
|
|
- */
|
|
|
- @GetMapping("/get/recommend/{id}")
|
|
|
- public Result<List<GoodsFrontListView>> getRecommendGoodsByGid(@PathVariable Long id, String dsCode) throws Exception {
|
|
|
- String key = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "recommend:" + id;
|
|
|
- Object o = redisService.get(key);
|
|
|
- Long fUid = StpUserUtil.getUserIdAfterLogin();
|
|
|
- List<GoodsFrontListView> goodsRecommendViews = null;
|
|
|
- if (o == 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);
|
|
|
- MapBuilder mapBuilder = MapUtils.builder();
|
|
|
- mapBuilder.field(GoodsFrontListView::getId, recommend_gidList).op(Operator.InList);
|
|
|
- goodsRecommendViews = beanSearcher.searchAll(GoodsFrontListView.class, mapBuilder.build());
|
|
|
- redisService.setNx(key, Jsons.toJson(goodsRecommendViews), 60 * 15l);
|
|
|
- o = redisService.get(key);
|
|
|
- } else {
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
- }
|
|
|
- }
|
|
|
- if (goodsRecommendViews == null) {
|
|
|
- goodsRecommendViews = Jsons.parseList(o.toString(), GoodsFrontListView.class);
|
|
|
- }
|
|
|
- AtomicLong dsUserId = new AtomicLong();
|
|
|
- AtomicBoolean existsChannel = new AtomicBoolean(true);
|
|
|
- if (StrUtil.isNotBlank(dsCode)) {
|
|
|
- UserSharedDto userSharedDto = userService.getUserShredDtoByDsCode(dsCode);
|
|
|
- dsUserId.set(userSharedDto.getSharedId());
|
|
|
- }
|
|
|
- goodsRecommendViews = goodsRecommendViews.stream().filter(data -> {
|
|
|
- if (data.getIsOwns()) {
|
|
|
- if (dsUserId.get() == 0 && fUid != null && existsChannel.get()) {
|
|
|
- Long sharedId = userService.getSharedIdByUserId(fUid);
|
|
|
- if (sharedId == 0) {
|
|
|
- existsChannel.set(false);
|
|
|
- }
|
|
|
- dsUserId.set(sharedId);
|
|
|
- }
|
|
|
- GoodsDonSku minPriceUserOwnsSku = goodsDonSkuMapper.checkAndReturnMinPriceUserOwnsSku(data.getId(), dsUserId.get());
|
|
|
- if (minPriceUserOwnsSku == null) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- data.setPrice(minPriceUserOwnsSku.getPrice());
|
|
|
- data.setMonths(minPriceUserOwnsSku.getMonths());
|
|
|
- data.setDays(minPriceUserOwnsSku.getDays());
|
|
|
- }
|
|
|
- //销量
|
|
|
- data.setSold(getGoodsSold(data.getId(), data.getSold()));
|
|
|
- //设置特定价格
|
|
|
- setSpecificPrice(data, fUid, dsUserId.get());
|
|
|
- return true;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(goodsRecommendViews);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取商品多规格列表
|
|
|
- */
|
|
|
- @GetMapping("/get/sku")
|
|
|
- public Result<List<GoodsDonSkuView>> getGoodsDonSkuView(@RequestParam(value = "skuIds") List<Long> skuIds) {
|
|
|
- if (skuIds.isEmpty()) {
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
- }
|
|
|
- List<GoodsDonSkuView> views = beanSearcher.searchAll(GoodsDonSkuView.class, MapUtils.builder()
|
|
|
- .field(GoodsDonSkuView::getSkuId, skuIds).op(Operator.InList)
|
|
|
- .build());
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(views);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取评价列表
|
|
|
- */
|
|
|
- @GetMapping("/get/comments")
|
|
|
- public Result<SearchResult<OrderCommentFrontView>> getComments() {
|
|
|
- SearchResult<OrderCommentFrontView> search = beanSearcher.search(OrderCommentFrontView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
- .orderBy(OrderCommentFrontView::getCommentTime).desc()
|
|
|
- .orderBy(OrderCommentFrontView::getId).desc()
|
|
|
- .build());
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* @param goodsId
|
|
|
@@ -477,15 +395,17 @@ public class GoodsDonController {
|
|
|
*/
|
|
|
@GetMapping("/get/categoryGoods")
|
|
|
public Result<? extends Object> getGoodsByCategory(Long cgy, String dsCode) {
|
|
|
+ String lang = request.getHeader("lang");
|
|
|
+ AtomicBoolean language = new AtomicBoolean(false);
|
|
|
Long fUid = StpUserUtil.getUserIdAfterLogin();
|
|
|
String categoryGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "category:goods";
|
|
|
if (cgy != null) {
|
|
|
categoryGoodsKey += ":" + cgy;
|
|
|
}
|
|
|
- //List<Long> filter_goodsIds = getFilterGoodsIds();
|
|
|
List<Long> filter_goodsIds = null;
|
|
|
- if (CollUtil.isNotEmpty(filter_goodsIds)) {
|
|
|
- categoryGoodsKey += ":hz-ip";
|
|
|
+ if (!UserPageLanguage.Language.zh_HK.name().equals(lang)) {
|
|
|
+ categoryGoodsKey += ":" + lang;
|
|
|
+ language.set(true);
|
|
|
}
|
|
|
Object o = redisService.get(categoryGoodsKey);
|
|
|
if (o == null) {
|
|
|
@@ -500,8 +420,12 @@ public class GoodsDonController {
|
|
|
}
|
|
|
List<GoodsFrontListCategoryView> goodsFrontListViews = beanSearcher.searchAll(GoodsFrontListCategoryView.class, mapBuilder.build());
|
|
|
goodsFrontListViews.forEach(data -> {
|
|
|
- data.setSold(getGoodsSold(data.getId(), data.getSold()));;
|
|
|
+ data.setSold(getGoodsSold(data.getId(), data.getSold()));
|
|
|
data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
|
|
|
+ if (language.get()) {
|
|
|
+ //多语言
|
|
|
+ backInfoTranslationsFrontService.setCategoryGoodsLanguage(data, lang);
|
|
|
+ }
|
|
|
});
|
|
|
redisService.setNx(categoryGoodsKey, goodsFrontListViews, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 10 * 60);
|
|
|
o = redisService.get(categoryGoodsKey);
|