|
|
@@ -73,19 +73,30 @@ public class GoodsDonController {
|
|
|
* 获取平台商品分类
|
|
|
*/
|
|
|
@GetMapping("/get/category")
|
|
|
- public Result<List<GoodsDonCategoryFrontView>> getCategory() {
|
|
|
- String key = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "category";
|
|
|
- Object o = redisService.get(key);
|
|
|
- List<GoodsDonCategoryFrontView> list;
|
|
|
- if (o == null) {
|
|
|
- list = beanSearcher.searchAll(GoodsDonCategoryFrontView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
- .field(GoodsDonCategoryFrontView::getNum, 0).op(Operator.GreaterThan)
|
|
|
- .build());
|
|
|
- redisService.setNx(key, list, 30 * 60l);
|
|
|
- o = redisService.get(key);
|
|
|
- }
|
|
|
- list = Jsons.parseList(o, GoodsDonCategoryFrontView.class);
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
+ public Result<List<GoodsDonCategoryFrontView>> getCategory(String customId) {
|
|
|
+ Long yhsId = null;
|
|
|
+ if (StrUtil.isNotBlank(customId)) {
|
|
|
+ yhsId = yhShopFrontService.getYhsIdByCustomId(customId);
|
|
|
+ }
|
|
|
+ String key = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "category";
|
|
|
+ Object o = redisService.get(key);
|
|
|
+ List<GoodsDonCategoryFrontView> list;
|
|
|
+ MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
+ String condition = " and (select count(*) from goods_don_category_relate gcr inner join goods_don g on g.id = gcr.goods_id %s where gcr.category = gc.id) > 0";
|
|
|
+ if (yhsId != null) {
|
|
|
+ condition = String.format(condition, String.format(" inner join yh_shop_goods_sku ys on ys.goods_id = g.id and ys.status is true and ys.deleted is true and g.is_distribute is true and yhs_id = %s", yhsId));
|
|
|
+ } else {
|
|
|
+ condition = String.format(condition, StrUtil.EMPTY);
|
|
|
+ }
|
|
|
+ mapBuilder.put("condition", condition);
|
|
|
+ if (o == null) {
|
|
|
+ list = beanSearcher.searchAll(GoodsDonCategoryFrontView.class, mapBuilder
|
|
|
+ .build());
|
|
|
+ redisService.setNx(key, list, 30 * 60l);
|
|
|
+ o = redisService.get(key);
|
|
|
+ }
|
|
|
+ list = Jsons.parseList(o, GoodsDonCategoryFrontView.class);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -386,20 +397,29 @@ public class GoodsDonController {
|
|
|
* 获取商品推荐平台
|
|
|
*/
|
|
|
@GetMapping("/get/recommend/{id}")
|
|
|
- public Result<List<GoodsFrontListView>> getRecommendGoodsByGid(@PathVariable Long id) throws Exception {
|
|
|
+ public Result<List<GoodsFrontListView>> getRecommendGoodsByGid(@PathVariable Long id, String customId) throws Exception {
|
|
|
String key = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "recommend:" + id;
|
|
|
+ Long yhsId = null;
|
|
|
+ if (StrUtil.isNotBlank(customId)) {
|
|
|
+ yhsId = yhShopFrontService.getYhsIdByCustomId(customId);
|
|
|
+ key = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhsId + ":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::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);
|
|
|
- goodsRecommendViews = beanSearcher.searchAll(GoodsFrontListView.class, MapUtils.builder().field(GoodsRecommendViews::getGoodsId, recommend_gidList).op(Operator.InList).build());
|
|
|
+ MapBuilder mapBuilder = MapUtils.builder();
|
|
|
+ if (yhsId != null) {
|
|
|
+ mapBuilder.put("condition", String.format(" and g.id in (select distinct goods_id from yh_shop_goods_sku where yhs_id = %s and status is true and deleted is true) and g.is_distribute is true", yhsId));
|
|
|
+ }
|
|
|
+ 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 {
|
|
|
@@ -410,9 +430,9 @@ public class GoodsDonController {
|
|
|
goodsRecommendViews = Jsons.parseList(o.toString(), GoodsFrontListView.class);
|
|
|
}
|
|
|
goodsRecommendViews.forEach(data -> {
|
|
|
- Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
|
|
|
- .eq(RegisterOrderDon::getGoodsId, data.getId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
|
|
|
- data.setSold(data.getSold() + sold);
|
|
|
+ Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
+ data.setSold(data.getSold() + sold);
|
|
|
//设置特定价格
|
|
|
setSpecificPrice(data, fUid);
|
|
|
});
|
|
|
@@ -464,14 +484,14 @@ public class GoodsDonController {
|
|
|
Long yhsId = null;
|
|
|
if (StrUtil.isNotBlank(customId)) {
|
|
|
yhsId = yhShopFrontService.getYhsIdByCustomId(customId);
|
|
|
- key += ":yhShop:" + yhsId;
|
|
|
+ key = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhsId + ":homeManage";
|
|
|
}
|
|
|
Long fUid = StpUserUtil.getUserIdAfterLogin();
|
|
|
Object o = redisService.get(key);
|
|
|
if (o == null) {
|
|
|
String condition = "g.deleted is true and g.status is true";
|
|
|
if (yhsId != null) {
|
|
|
- condition += String.format(" and g.id in (select distinct goods_id from yh_shop_goods_sku where yhs_id = %s and status is true and deleted is true)", yhsId);
|
|
|
+ condition += String.format(" and g.id in (select distinct goods_id from yh_shop_goods_sku where yhs_id = %s and status is true and deleted is true) and g.is_distribute is true", yhsId);
|
|
|
}
|
|
|
Map<String, List<HomeManagementFrontView>> map = new ConcurrentHashMap<>();
|
|
|
final String conditionSql = condition;
|
|
|
@@ -719,7 +739,7 @@ public class GoodsDonController {
|
|
|
*/
|
|
|
@GetMapping("/get/shop/goods/{yhsId}")
|
|
|
public Result<List<YhShopGoodsFrontView>> getShopGoods(@PathVariable Long yhsId) {
|
|
|
- String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "yhShop:" + yhsId;
|
|
|
+ String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhsId;
|
|
|
Object value = redisService.get(yhShopCacheKey);
|
|
|
List<YhShopGoodsFrontView> list = null;
|
|
|
if (value != null) {
|
|
|
@@ -737,9 +757,8 @@ public class GoodsDonController {
|
|
|
DateTime now = DateTime.now();
|
|
|
list.forEach(data->{
|
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
- .eq(OrderDon::getYhsId, yhsId)
|
|
|
.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
- data.setSold(sold + data.getVs());
|
|
|
+ data.setSold(sold + data.getSold());
|
|
|
data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, yhsId));
|
|
|
});
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
@@ -793,43 +812,40 @@ public class GoodsDonController {
|
|
|
o = redisService.get(categoryGoodsKey);
|
|
|
}
|
|
|
List<GoodsFrontListView> goodsFrontListViews = Jsons.parseList(o, GoodsFrontListView.class);
|
|
|
+ DateTime now = DateTime.now();
|
|
|
goodsFrontListViews.forEach(data -> {
|
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
- .eq(OrderDon::getYhsId, 0)
|
|
|
.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
data.setSold(sold + data.getSold());
|
|
|
- data.setNotifyMsg(getPayMsgTime(data.getId(), DateTime.now(), 1, null));
|
|
|
+ data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
|
|
|
});
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(goodsFrontListViews);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/get/shop/categoryGoods/{yhsId}")
|
|
|
public Result<List<YhShopGoodsFrontView>> getShopCategoryGoods(@PathVariable Long yhsId, Long category) {
|
|
|
- String categoryGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "category:goods:yhShop";
|
|
|
- Object value = redisService.get(categoryGoodsKey);
|
|
|
- List<YhShopGoodsFrontView> list = null;
|
|
|
- if (value != null) {
|
|
|
- try {
|
|
|
- list = Jsons.parseList(value, YhShopGoodsFrontView.class);
|
|
|
- } catch (Exception e) {
|
|
|
- }
|
|
|
+ String categoryGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE_SHOP.getEnvName() + yhsId + ":category";
|
|
|
+ if (category != null) {
|
|
|
+ categoryGoodsKey += ":" + category;
|
|
|
}
|
|
|
- if (CollUtil.isEmpty(list)) {
|
|
|
+ Object value = redisService.get(categoryGoodsKey);
|
|
|
+ if (value == null) {
|
|
|
MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
String condition = String.format("and yhs_id = %s", yhsId);
|
|
|
if (category != null) {
|
|
|
- condition += String.format(" and goods_id in (select goods_id from goods_don_category_relate where category = %s)", category);
|
|
|
+ condition += String.format(" and ys.goods_id in (select goods_id from goods_don_category_relate where category = %s)", category);
|
|
|
}
|
|
|
builder.put("condition", condition);
|
|
|
- list = beanSearcher.searchAll(YhShopGoodsFrontView.class, builder.build());
|
|
|
+ List<YhShopGoodsFrontView> list = beanSearcher.searchAll(YhShopGoodsFrontView.class, builder.build());
|
|
|
redisService.setNx(categoryGoodsKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout() + 5 * 60);
|
|
|
+ value = redisService.get(categoryGoodsKey);
|
|
|
}
|
|
|
+ List<YhShopGoodsFrontView> list = Jsons.parseList(value, YhShopGoodsFrontView.class);
|
|
|
DateTime now = DateTime.now();
|
|
|
list.forEach(data -> {
|
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
- .eq(OrderDon::getYhsId, yhsId)
|
|
|
.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
- data.setSold(sold + data.getVs());
|
|
|
+ data.setSold(sold + data.getSold());
|
|
|
data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, yhsId));
|
|
|
});
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|