|
@@ -17,6 +17,7 @@ import com.txz.mall.model.*;
|
|
|
import com.txz.mall.service.*;
|
|
|
import com.txz.mall.util.I18nUtil;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -38,6 +39,7 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
@Transactional
|
|
|
@AllArgsConstructor
|
|
|
+@Slf4j
|
|
|
public class OrderServiceBusinessImpl implements OrderServiceBusiness {
|
|
|
|
|
|
private final StoreOrderService storeOrderService;
|
|
@@ -50,7 +52,7 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
|
|
|
private final RedisUtil redisUtil;
|
|
|
private final CifRedEnvelopeDubboServiceClient cifRedEnvelopeDubboServiceClient;
|
|
|
private final StoreOrderMapper storeOrderMapper;
|
|
|
-
|
|
|
+ private final StoreProductService storeProductService;
|
|
|
@Override
|
|
|
public StoreOrderVO orderDetail(Long id, String orderNo) {
|
|
|
StoreOrderVO vo = new StoreOrderVO();
|
|
@@ -179,48 +181,80 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
|
|
|
// return list;
|
|
|
// }
|
|
|
|
|
|
- Date date = new Date();
|
|
|
- Date date1 = DateUtils.addDays(date, -7);
|
|
|
- // List<Map<String, Object>> rank = storeOrderMapper.getRank(date1);
|
|
|
- List<Map<String, Object>> rank = storePinkMapper.getRank(date1);
|
|
|
-
|
|
|
-
|
|
|
- if (!CollectionUtils.isEmpty(rank)) {
|
|
|
- Map<Long, Map<String, Object>> saleMap = rank.stream().collect(Collectors.toMap(a -> Long.valueOf(a.get("pid")+"") , a -> a, (b, c) -> c));
|
|
|
- List<Long> pidList = rank.stream().map(a -> Long.valueOf(a.get("pid")+"")).collect(Collectors.toList());
|
|
|
-
|
|
|
- Condition storeCombinationCondition = new Condition(StoreCombination.class);
|
|
|
- Example.Criteria storeCombinationCriteria = storeCombinationCondition.createCriteria();
|
|
|
- storeCombinationCriteria.andIn("productId", pidList);
|
|
|
- List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
|
|
|
- Map<Long, StoreCombination> storeCombinationMap = new HashMap<>();
|
|
|
- if(!CollectionUtils.isEmpty(combinationList)){
|
|
|
- storeCombinationMap = combinationList.stream().collect(Collectors.toMap(StoreCombination::getProductId, a -> a, (b, c) -> c));
|
|
|
- }
|
|
|
- for (Map<String, Object> stringObjectMap : rank) {
|
|
|
-
|
|
|
-
|
|
|
- Object pid = stringObjectMap.get("pid");
|
|
|
- Object num = stringObjectMap.get("num");
|
|
|
-
|
|
|
- StoreCombination storeCombination = storeCombinationMap.get(Long.parseLong(pid + ""));
|
|
|
- StoreCombinationRankVO rankVO = new StoreCombinationRankVO();
|
|
|
- rankVO.setProductId(storeCombination.getProductId());
|
|
|
- rankVO.setProductName(storeCombination.getProductName());
|
|
|
- rankVO.setSales(Integer.valueOf(num+""));
|
|
|
- rankVO.setFicti(Integer.valueOf(num+""));
|
|
|
- rankVO.setImage(storeCombination.getImage());
|
|
|
- rankVO.setPrice(storeCombination.getPrice());
|
|
|
- list.add(rankVO);
|
|
|
- }
|
|
|
-
|
|
|
- if(!CollectionUtils.isEmpty(list)){
|
|
|
- list =list.stream().sorted(Comparator.comparing(StoreCombinationRankVO::getSales).reversed()).collect(Collectors.toList());
|
|
|
- }
|
|
|
-
|
|
|
+ Set<Long> isvalidProductIdList = new HashSet<>();
|
|
|
+ //提取有效的参与活动的商品id
|
|
|
+ Condition storeCombinationCondition = new Condition(StoreCombination.class);
|
|
|
+ Example.Criteria StoreCombinationCriteria = storeCombinationCondition.createCriteria();
|
|
|
+ StoreCombinationCriteria.andEqualTo("isDelete", 0);
|
|
|
+ StoreCombinationCriteria.andEqualTo("isShow", 1);
|
|
|
+ List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
|
|
|
+
|
|
|
+ if(!CollectionUtils.isEmpty(combinationList)){
|
|
|
+ log.info("getRank.storeCombinationService.findByCondition"+JSONObject.toJSONString(combinationList));
|
|
|
+ List<Long> productIdList1 = combinationList.stream().map(StoreCombination::getProductId).collect(Collectors.toList());
|
|
|
+ isvalidProductIdList.addAll(productIdList1);
|
|
|
}
|
|
|
|
|
|
|
|
|
+// Condition storeProductondition = new Condition(StoreProduct.class);
|
|
|
+// Example.Criteria storeProductCriteria = storeProductondition.createCriteria();
|
|
|
+// storeProductCriteria.andEqualTo("isDelete", 0);
|
|
|
+// storeProductCriteria.andEqualTo("isShow", 1);
|
|
|
+// List<StoreProduct> storeProductList = storeProductService.findByCondition(storeProductondition);
|
|
|
+// if(!CollectionUtils.isEmpty(storeProductList)){
|
|
|
+// List<Long> productIdList2 = storeProductList.stream().map(StoreProduct::getId).collect(Collectors.toList());
|
|
|
+// isvalidProductIdList.addAll(productIdList2);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ if(!CollectionUtils.isEmpty(isvalidProductIdList)) {
|
|
|
+ log.info("getRank.isvalidProductIdList"+JSONObject.toJSONString(isvalidProductIdList));
|
|
|
+ Date date = new Date();
|
|
|
+ Date date1 = DateUtils.addDays(date, -7);
|
|
|
+ // List<Map<String, Object>> rank = storeOrderMapper.getRank(date1);
|
|
|
+ List<Map<String, Object>> rank = storePinkMapper.getRank(date1,isvalidProductIdList);
|
|
|
+
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(rank)) {
|
|
|
+ log.info("rank"+JSONObject.toJSONString(rank));
|
|
|
+ Map<Long, Map<String, Object>> saleMap = rank.stream().collect(Collectors.toMap(a -> Long.valueOf(a.get("pid") + ""), a -> a, (b, c) -> c));
|
|
|
+ List<Long> pidList = rank.stream().map(a -> Long.valueOf(a.get("pid") + "")).collect(Collectors.toList());
|
|
|
+
|
|
|
+// Condition storeCombinationCondition = new Condition(StoreCombination.class);
|
|
|
+// Example.Criteria storeCombinationCriteria = storeCombinationCondition.createCriteria();
|
|
|
+// storeCombinationCriteria.andIn("productId", pidList);
|
|
|
+// List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
|
|
|
+ Map<Long, StoreCombination> storeCombinationMap = new HashMap<>();
|
|
|
+ if (!CollectionUtils.isEmpty(combinationList)) {
|
|
|
+ log.info("getRank.combinationList"+JSONObject.toJSONString(combinationList));
|
|
|
+ storeCombinationMap = combinationList.stream().collect(Collectors.toMap(StoreCombination::getProductId, a -> a, (b, c) -> c));
|
|
|
+ }
|
|
|
+ for (Map<String, Object> stringObjectMap : rank) {
|
|
|
+
|
|
|
+
|
|
|
+ Object pid = stringObjectMap.get("pid");
|
|
|
+ Object num = stringObjectMap.get("num");
|
|
|
+ log.info("getRank.pid"+JSONObject.toJSONString(pid));
|
|
|
+ StoreCombination storeCombination = storeCombinationMap.get(Long.parseLong(pid + ""));
|
|
|
+ log.info("getRank.storeCombination"+JSONObject.toJSONString(storeCombination));
|
|
|
+ StoreCombinationRankVO rankVO = new StoreCombinationRankVO();
|
|
|
+ rankVO.setProductId(storeCombination.getProductId());
|
|
|
+ rankVO.setProductName(storeCombination.getProductName());
|
|
|
+ rankVO.setSales(Integer.valueOf(num + ""));
|
|
|
+ rankVO.setFicti(Integer.valueOf(num + ""));
|
|
|
+ rankVO.setImage(storeCombination.getImage());
|
|
|
+ rankVO.setPrice(storeCombination.getPrice());
|
|
|
+ list.add(rankVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(list)) {
|
|
|
+ log.info("getRank.list"+JSONObject.toJSONString(list));
|
|
|
+ list = list.stream().sorted(Comparator.comparing(StoreCombinationRankVO::getSales).reversed()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
// redisUtil.set(key, list);
|
|
|
return list;
|