|
@@ -8,6 +8,7 @@ import com.txz.mall.core.RedisUtil;
|
|
|
import com.txz.mall.core.ServiceException;
|
|
|
import com.txz.mall.dao.StorePinkMapper;
|
|
|
import com.txz.mall.dubbo.client.CifUserDubboServiceClient;
|
|
|
+import com.txz.mall.enums.PinkOrderStatusEnum;
|
|
|
import com.txz.mall.model.*;
|
|
|
import com.txz.mall.service.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -81,6 +82,58 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public List<StoreCombinationRankVO> getRank() {
|
|
|
+// List<StoreCombinationRankVO> list = new ArrayList<>();
|
|
|
+// String key = "order:rank:";
|
|
|
+// boolean exists = redisUtil.hasKey("order:rank");
|
|
|
+// if (exists) {
|
|
|
+// String orderVoString = redisUtil.get(key).toString();
|
|
|
+// list = JSONObject.parseArray(orderVoString, StoreCombinationRankVO.class);
|
|
|
+// return list;
|
|
|
+// }
|
|
|
+//
|
|
|
+// Condition orderCondition = new Condition(StoreOrder.class);
|
|
|
+// Example.Criteria orderCriteria = orderCondition.createCriteria();
|
|
|
+// Date date = new Date();
|
|
|
+// Date startDate = DateUtil.beginOfDay(DateUtils.addDays(date, -7));
|
|
|
+// Date endDate = DateUtil.endOfDay(date);
|
|
|
+// orderCriteria.andEqualTo("isDelete", 0);
|
|
|
+// orderCriteria.andBetween("createTime", startDate, endDate);
|
|
|
+// orderCriteria.andEqualTo("paid", 1);
|
|
|
+// List<StoreOrder> orderList = storeOrderService.findByCondition(orderCondition);
|
|
|
+// Map<Long, Long> combinationCountMap = orderList.stream()
|
|
|
+// .collect(Collectors.groupingBy(
|
|
|
+// StoreOrder::getCombinationId,
|
|
|
+// Collectors.counting()
|
|
|
+// ));
|
|
|
+//
|
|
|
+// // 获取前10个热门商品组合
|
|
|
+// List<Map.Entry<Long, Long>> topCombinations = combinationCountMap.entrySet()
|
|
|
+// .stream()
|
|
|
+// .sorted(Map.Entry.<Long, Long>comparingByValue().reversed())
|
|
|
+// .collect(Collectors.toList());
|
|
|
+//
|
|
|
+// List<StoreCombination> combinationList = storeCombinationService.findByIds(String.join(",", topCombinations.stream().map(Map.Entry::getKey).map(Object::toString).collect(Collectors.toList())));
|
|
|
+// for (StoreCombination storeCombination : combinationList) {
|
|
|
+// List<StoreCombination> collect = combinationList.stream().filter(c -> c.getId().equals(storeCombination.getId())).collect(Collectors.toList());
|
|
|
+// if (CollectionUtils.isNotEmpty(collect)) {
|
|
|
+// StoreCombination combination = collect.get(0);
|
|
|
+// StoreCombinationRankVO rankVO = new StoreCombinationRankVO();
|
|
|
+// rankVO.setProductId(combination.getProductId());
|
|
|
+// rankVO.setProductName(combination.getProductName());
|
|
|
+// rankVO.setSales(combination.getSales());
|
|
|
+// rankVO.setImage(combination.getImage());
|
|
|
+// rankVO.setPrice(combination.getPrice());
|
|
|
+// list.add(rankVO);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// redisUtil.set(key, list);
|
|
|
+// return list;
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<StoreCombinationRankVO> getRank() {
|
|
@@ -100,7 +153,12 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
|
|
|
Date endDate = DateUtil.endOfDay(date);
|
|
|
orderCriteria.andEqualTo("isDelete", 0);
|
|
|
orderCriteria.andBetween("createTime", startDate, endDate);
|
|
|
- orderCriteria.andEqualTo("paid", 1);
|
|
|
+ List<Integer> statusList = new ArrayList<>();
|
|
|
+ statusList.add(PinkOrderStatusEnum.GROUP_ORDER_TO_RECEVIE.getKey());
|
|
|
+ statusList.add(PinkOrderStatusEnum.GROUP_ORDER_TO_SHIP.getKey());
|
|
|
+ statusList.add(PinkOrderStatusEnum.GROUP_ORDER_COMPLETED.getKey());
|
|
|
+ statusList.add(PinkOrderStatusEnum.GROUP_ORDER_TO_CLOSED.getKey());
|
|
|
+ orderCriteria.andIn("status", statusList);
|
|
|
List<StoreOrder> orderList = storeOrderService.findByCondition(orderCondition);
|
|
|
Map<Long, Long> combinationCountMap = orderList.stream()
|
|
|
.collect(Collectors.groupingBy(
|
|
@@ -133,6 +191,4 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|