|
|
@@ -32,7 +32,10 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.*;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* @author chan
|
|
|
@@ -193,13 +196,7 @@ public class GoodsDonController {
|
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
data.setSold(sold + data.getVirtualSold());
|
|
|
- OrderCommentFrontView comments = beanSearcher.searchFirst(OrderCommentFrontView.class, MapUtils.builder()
|
|
|
- .field(OrderCommentFrontView::getGoodsId, data.getId())
|
|
|
- .orderBy(OrderCommentFrontView::getCommentTime).desc()
|
|
|
- .orderBy(OrderCommentFrontView::getId).desc()
|
|
|
- .build());
|
|
|
- data.setComments(comments);
|
|
|
- data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
|
|
|
+ data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
|
|
|
});
|
|
|
redisService.setNx(pcCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
|
|
|
//设置特定价格
|
|
|
@@ -211,6 +208,7 @@ public class GoodsDonController {
|
|
|
* h5 银河首页平台展示
|
|
|
*/
|
|
|
@GetMapping("/get/homePage")
|
|
|
+ @Deprecated
|
|
|
public Result<List<GoodsFrontListView>> getGoodsHomePage() {
|
|
|
List<Long> filter_goodsIds = getFilterGoodsIds();
|
|
|
String h5CacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "H5";
|
|
|
@@ -240,7 +238,7 @@ public class GoodsDonController {
|
|
|
Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
data.setSold(sold + data.getVirtualSold());
|
|
|
- data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1));
|
|
|
+ data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
|
|
|
});
|
|
|
redisService.setNx(h5CacheKey, dataList, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
|
|
|
//设置特定价格
|
|
|
@@ -271,7 +269,7 @@ public class GoodsDonController {
|
|
|
Integer sold = registerOrderDonMapper.selectCount(Wrappers.lambdaQuery(RegisterOrderDon.class)
|
|
|
.eq(RegisterOrderDon::getGoodsId, data.getId()).notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus));
|
|
|
data.setSold(sold + data.getVirtualSold());
|
|
|
- data.setNotifyMsg(getPayMsgTime(data.getId(), now, 2));
|
|
|
+ data.setNotifyMsg(getPayMsgTime(data.getId(), now, 2, null));
|
|
|
});
|
|
|
redisService.setNx(registerCacheKey, dataList, RedisService.key.REGISTER_HOME_PAGE_CACHE.getTimeout());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(dataList);
|
|
|
@@ -312,6 +310,13 @@ public class GoodsDonController {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ //评论
|
|
|
+// OrderCommentFrontView comments = beanSearcher.searchFirst(OrderCommentFrontView.class, MapUtils.builder()
|
|
|
+// .field(OrderCommentFrontView::getGoodsId, views.getId())
|
|
|
+// .orderBy(OrderCommentFrontView::getCommentTime).desc()
|
|
|
+// .orderBy(OrderCommentFrontView::getId).desc()
|
|
|
+// .build());
|
|
|
+// views.setComments(comments);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(views);
|
|
|
}
|
|
|
|
|
|
@@ -395,56 +400,57 @@ public class GoodsDonController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @param goodsId
|
|
|
- * @param type 1、普通,2、注册平台
|
|
|
+ * @param type 1、普通,2、注册平台
|
|
|
+ * @param yhsId 店铺id
|
|
|
* @return
|
|
|
*/
|
|
|
- public String getPayMsgTime(Long goodsId, DateTime now, Integer type) {
|
|
|
- Date startTime = null;
|
|
|
- StringBuilder notifyMsg = new StringBuilder();
|
|
|
- if (type == 1) {
|
|
|
- OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
- .eq(OrderDon::getGoodsId, goodsId)
|
|
|
- .notIn(OrderDon::getStatus, Constant.noOrderStatus).select(OrderDon::getCreatedTime, OrderDon::getPayTime, OrderDon::getId)
|
|
|
- .orderByDesc(OrderDon::getId)
|
|
|
- .last("limit 1"));
|
|
|
- if (orderDon == null) {
|
|
|
- notifyMsg.append("点击购买立即上车");
|
|
|
- return notifyMsg.toString();
|
|
|
- }
|
|
|
- startTime = orderDon.getPayTime() != null ? orderDon.getPayTime() : orderDon.getCreatedTime();
|
|
|
- } else if (type == 2) {
|
|
|
- RegisterOrderDon orderDon = registerOrderDonMapper.selectOne(Wrappers.lambdaQuery(RegisterOrderDon.class)
|
|
|
- .eq(RegisterOrderDon::getGoodsId, goodsId)
|
|
|
- .notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus).select(RegisterOrderDon::getCreatedTime, RegisterOrderDon::getPayTime, RegisterOrderDon::getId)
|
|
|
- .orderByDesc(RegisterOrderDon::getId)
|
|
|
- .last("limit 1"));
|
|
|
- if (orderDon == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- startTime = orderDon.getPayTime() != null ? orderDon.getPayTime() : orderDon.getCreatedTime();
|
|
|
- }
|
|
|
- long hour = DateUtil.between(startTime, now, DateUnit.HOUR);
|
|
|
- if (hour == 0) {
|
|
|
- long minute = DateUtil.between(startTime, now, DateUnit.MINUTE);
|
|
|
- if (minute == 0) {
|
|
|
- notifyMsg.append("1分钟");
|
|
|
- } else {
|
|
|
- notifyMsg.append(minute);
|
|
|
- notifyMsg.append("分钟");
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (hour > 3) {
|
|
|
- int hours = RandomUtil.randomInt(3) + 1;
|
|
|
- notifyMsg.append(hours);
|
|
|
- } else {
|
|
|
- notifyMsg.append(hour);
|
|
|
- }
|
|
|
- notifyMsg.append("小时");
|
|
|
- }
|
|
|
- notifyMsg.append("前有人购买");
|
|
|
- return notifyMsg.toString();
|
|
|
+ public String getPayMsgTime(Long goodsId, DateTime now, Integer type, Long yhsId) {
|
|
|
+ Date startTime = null;
|
|
|
+ StringBuilder notifyMsg = new StringBuilder();
|
|
|
+ if (type == 1) {
|
|
|
+ OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ .eq(OrderDon::getGoodsId, goodsId)
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderStatus).select(OrderDon::getCreatedTime, OrderDon::getPayTime, OrderDon::getId)
|
|
|
+ .eq(yhsId != null, OrderDon::getYhsId, yhsId)
|
|
|
+ .orderByDesc(OrderDon::getId)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (orderDon == null) {
|
|
|
+ notifyMsg.append("点击购买立即上车");
|
|
|
+ return notifyMsg.toString();
|
|
|
+ }
|
|
|
+ startTime = orderDon.getPayTime() != null ? orderDon.getPayTime() : orderDon.getCreatedTime();
|
|
|
+ } else if (type == 2) {
|
|
|
+ RegisterOrderDon orderDon = registerOrderDonMapper.selectOne(Wrappers.lambdaQuery(RegisterOrderDon.class)
|
|
|
+ .eq(RegisterOrderDon::getGoodsId, goodsId)
|
|
|
+ .notIn(RegisterOrderDon::getStatus, Constant.noOrderStatus).select(RegisterOrderDon::getCreatedTime, RegisterOrderDon::getPayTime, RegisterOrderDon::getId)
|
|
|
+ .orderByDesc(RegisterOrderDon::getId)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (orderDon == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ startTime = orderDon.getPayTime() != null ? orderDon.getPayTime() : orderDon.getCreatedTime();
|
|
|
+ }
|
|
|
+ long hour = DateUtil.between(startTime, now, DateUnit.HOUR);
|
|
|
+ if (hour == 0) {
|
|
|
+ long minute = DateUtil.between(startTime, now, DateUnit.MINUTE);
|
|
|
+ if (minute == 0) {
|
|
|
+ notifyMsg.append("1分钟");
|
|
|
+ } else {
|
|
|
+ notifyMsg.append(minute);
|
|
|
+ notifyMsg.append("分钟");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (hour > 3) {
|
|
|
+ int hours = RandomUtil.randomInt(3) + 1;
|
|
|
+ notifyMsg.append(hours);
|
|
|
+ } else {
|
|
|
+ notifyMsg.append(hour);
|
|
|
+ }
|
|
|
+ notifyMsg.append("小时");
|
|
|
+ }
|
|
|
+ notifyMsg.append("前有人购买");
|
|
|
+ return notifyMsg.toString();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -518,4 +524,55 @@ public class GoodsDonController {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 店铺平台列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get/shop/goods/{yhsId}")
|
|
|
+ public Result<List<YhShopGoodsFrontView>> getShopGoods(@PathVariable Long yhsId) {
|
|
|
+ String yhShopCacheKey = RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "yhShop:" + yhsId;
|
|
|
+ Object value = redisService.get(yhShopCacheKey);
|
|
|
+ List<YhShopGoodsFrontView> list = null;
|
|
|
+ if (value != null) {
|
|
|
+ try {
|
|
|
+ list = Jsons.parseList(value, YhShopGoodsFrontView.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
+ builder.put("condition", String.format("and yhs_id = %s", yhsId));
|
|
|
+ list = beanSearcher.searchAll(YhShopGoodsFrontView.class, builder.build());
|
|
|
+ redisService.setNx(yhShopCacheKey, list, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
|
|
|
+ }
|
|
|
+ DateTime now = DateTime.now();
|
|
|
+ list.forEach(data->{
|
|
|
+ Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
+ data.setSold(sold + data.getVs());
|
|
|
+ data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, yhsId));
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 店铺平台详情
|
|
|
+ */
|
|
|
+ @GetMapping("/get/shop/goods/detail/{yhsId}/{goodsId}")
|
|
|
+ public Result<YhShopGoodsFrontView> getGoodsDetailByYhsId(@PathVariable Long yhsId, @PathVariable Long goodsId) {
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
+ String condition = String.format("and yhs_id = %s and goods_id = %s", yhsId, goodsId);
|
|
|
+ builder.put("condition", condition);
|
|
|
+ YhShopGoodsFrontView goodsDetailView = beanSearcher.searchFirst(YhShopGoodsFrontView.class, builder.build());
|
|
|
+
|
|
|
+ goodsDetailView.setSkuList(beanSearcher.searchAll(YhShopGoodsSkuFrontView.class, MapUtils.builder().put("condition", condition).orderBy(YhShopGoodsSkuFrontView::getOrderBy).asc().build()));
|
|
|
+ goodsDetailView.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::getGoodsId, goodsDetailView.getId()).build()));
|
|
|
+ OrderCommentFrontView comments = beanSearcher.searchFirst(OrderCommentFrontView.class, MapUtils.builder()
|
|
|
+ .field(OrderCommentFrontView::getGoodsId, goodsDetailView.getId())
|
|
|
+ .orderBy(OrderCommentFrontView::getCommentTime).desc()
|
|
|
+ .orderBy(OrderCommentFrontView::getId).desc()
|
|
|
+ .build());
|
|
|
+ goodsDetailView.setComments(comments);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDetailView);
|
|
|
+ }
|
|
|
}
|