|
|
@@ -23,10 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.LinkedList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author chan
|
|
|
@@ -98,10 +95,12 @@ public class GoodsDonController {
|
|
|
.build());
|
|
|
|
|
|
Optional.ofNullable(data.getSkuList()).ifPresent(skuList -> {
|
|
|
- GoodsDonSku goodsDonSku = skuList.get(0);
|
|
|
- if (goodsDonSku != null) {
|
|
|
- data.setPrice(goodsDonSku.getPrice());
|
|
|
- data.setMonths(goodsDonSku.getMonths());
|
|
|
+ if (skuList.size() > 0) {
|
|
|
+ GoodsDonSku goodsDonSku = skuList.get(0);
|
|
|
+ if (goodsDonSku != null) {
|
|
|
+ data.setPrice(goodsDonSku.getPrice());
|
|
|
+ data.setMonths(goodsDonSku.getMonths());
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
if (data.getPrice() != null && data.getPrice().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
@@ -157,11 +156,6 @@ public class GoodsDonController {
|
|
|
@GetMapping("/get/list")
|
|
|
public Result<SearchResult<GoodsFrontListView>> getGoodsList() {
|
|
|
SearchResult<GoodsFrontListView> search = beanSearcher.search(GoodsFrontListView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
- .field(GoodsFrontListView::getStatus, true)
|
|
|
- .field(GoodsFrontListView::getDeleted, true)
|
|
|
- .field(GoodsFrontListView::getType, 1)
|
|
|
- .orderBy(GoodsFrontListView::getSortBy).desc()
|
|
|
- .orderBy(GoodsFrontListView::getId).asc()
|
|
|
.build());
|
|
|
DateTime now = DateTime.now();
|
|
|
LinkedList<GoodsFrontListView> collect = new LinkedList<>();
|
|
|
@@ -173,10 +167,12 @@ public class GoodsDonController {
|
|
|
data.setSold(sold + data.getVirtualSold());
|
|
|
|
|
|
Optional.ofNullable(data.getSkuList()).ifPresent(skuList -> {
|
|
|
- GoodsDonFrontSkuView donFrontSkuView = skuList.get(0);
|
|
|
- if (donFrontSkuView != null) {
|
|
|
- data.setPrice(donFrontSkuView.getPrice());
|
|
|
- data.setMonths(donFrontSkuView.getMonths());
|
|
|
+ if (skuList.size() > 0) {
|
|
|
+ GoodsDonFrontSkuView donFrontSkuView = skuList.get(0);
|
|
|
+ if (donFrontSkuView != null) {
|
|
|
+ data.setPrice(donFrontSkuView.getPrice());
|
|
|
+ data.setMonths(donFrontSkuView.getMonths());
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
if (data.getPrice() != null && data.getPrice().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
@@ -222,6 +218,30 @@ public class GoodsDonController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * h5 银河首页平台展示
|
|
|
+ */
|
|
|
+ @GetMapping("/get/homePage")
|
|
|
+ public Result<List<GoodsHomePageView>> getGoodsHomePage() {
|
|
|
+ List<GoodsHomePageView> dataList = beanSearcher.searchAll(GoodsHomePageView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .build());
|
|
|
+ List<GoodsHomePageView> collect = new ArrayList<>();
|
|
|
+ dataList.forEach(data -> {
|
|
|
+ Integer sold = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ .eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
|
|
|
+ data.setSold(sold + data.getVirtualSold());
|
|
|
+ GoodsDonFrontSkuView skuView = beanSearcher.searchFirst(GoodsDonFrontSkuView.class, MapUtils.builder().field(GoodsDonFrontSkuView::getGoodsId, data.getId()).field(GoodsDonFrontSkuView::getStatus, true).orderBy(GoodsDonFrontSkuView::getPrice).asc().build());
|
|
|
+ if (skuView != null) {
|
|
|
+ data.setPrice(skuView.getPrice());
|
|
|
+ data.setMonths(skuView.getMonths());
|
|
|
+ }
|
|
|
+ if (data.getPrice() != null && data.getPrice().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ collect.add(data);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(collect);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取商品详情
|