|
@@ -3,6 +3,7 @@ package com.txz.mall.service.impl;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
import com.txz.cif.param.AccomplishParam;
|
|
import com.txz.cif.param.AccomplishParam;
|
|
import com.txz.mall.core.AbstractService;
|
|
import com.txz.mall.core.AbstractService;
|
|
import com.txz.mall.core.ServiceException;
|
|
import com.txz.mall.core.ServiceException;
|
|
@@ -11,6 +12,7 @@ import com.txz.mall.dubbo.client.CifAccountDubboServiceClient;
|
|
import com.txz.mall.enums.PinkOrderStatusEnum;
|
|
import com.txz.mall.enums.PinkOrderStatusEnum;
|
|
import com.txz.mall.model.StoreOrder;
|
|
import com.txz.mall.model.StoreOrder;
|
|
import com.txz.mall.model.StorePink;
|
|
import com.txz.mall.model.StorePink;
|
|
|
|
+import com.txz.mall.model.StorePinkSummary;
|
|
import com.txz.mall.service.StorePinkService;
|
|
import com.txz.mall.service.StorePinkService;
|
|
import com.txz.mall.service.StorePinkSummaryService;
|
|
import com.txz.mall.service.StorePinkSummaryService;
|
|
import com.txz.mall.util.RandomUtil;
|
|
import com.txz.mall.util.RandomUtil;
|
|
@@ -179,35 +181,55 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<StorePinkOngoingVO> ongoingList(StorePink storePink) {
|
|
public List<StorePinkOngoingVO> ongoingList(StorePink storePink) {
|
|
- Condition condition = new Condition(StorePink.class);
|
|
|
|
- Example.Criteria criteria = condition.createCriteria();
|
|
|
|
- criteria.andEqualTo("isDelete", 0);
|
|
|
|
- criteria.andEqualTo("cid", storePink.getCid());
|
|
|
|
-// criteria.andEqualTo("kid", 0);
|
|
|
|
- criteria.andEqualTo("status", 1);
|
|
|
|
- List<StorePink> pinkList = findByCondition(condition);
|
|
|
|
|
|
+
|
|
|
|
+ // PageHelper.startPage(1, 3);
|
|
List<StorePinkOngoingVO> list = new ArrayList<>();
|
|
List<StorePinkOngoingVO> list = new ArrayList<>();
|
|
|
|
+ Condition storePinkSummarycondition = new Condition(StorePinkSummary.class);
|
|
|
|
+ Example.Criteria storePinkSummarycriteria = storePinkSummarycondition.createCriteria();
|
|
|
|
+ storePinkSummarycriteria.andEqualTo("isDelete", 0);
|
|
|
|
+ storePinkSummarycriteria.andEqualTo("cid", storePink.getCid());
|
|
|
|
+ storePinkSummarycriteria.andEqualTo("isVirtual", 0);
|
|
|
|
+ storePinkSummarycondition.setOrderByClause("people_count DESC");
|
|
|
|
+ List<StorePinkSummary> byCondition = storePinkSummaryService.findByCondition(storePinkSummarycondition);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(!CollectionUtils.isEmpty(byCondition)){
|
|
|
|
+
|
|
|
|
+ Map<Long, StorePinkSummary> storePinkSummaryMap = byCondition.stream().collect(Collectors.toMap(StorePinkSummary::getId, a -> a, (b, c) -> c));
|
|
|
|
+
|
|
|
|
+ List<Long> spsIdList = byCondition.stream().map(StorePinkSummary::getId).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ Condition condition = new Condition(StorePink.class);
|
|
|
|
+ Example.Criteria criteria = condition.createCriteria();
|
|
|
|
+ criteria.andEqualTo("isDelete", 0);
|
|
|
|
+ criteria.andEqualTo("cid", storePink.getCid());
|
|
|
|
+ // criteria.andEqualTo("kid", 0);
|
|
|
|
+ criteria.andIn("spsId", spsIdList);
|
|
|
|
+ List<StorePink> pinkList = findByCondition(condition);
|
|
|
|
+
|
|
|
|
+ Map<Long, List<StorePink>> collect = pinkList.stream().collect(Collectors.groupingBy(StorePink::getSpsId));
|
|
|
|
+ list = pinkList.stream().filter(a->a.getKId().equals(0)).map(a -> {
|
|
|
|
+ List<StorePink> storePinks = collect.get(a.getSpsId());
|
|
|
|
+
|
|
|
|
+ StorePinkOngoingVO pinkOngoingVO = new StorePinkOngoingVO();
|
|
|
|
+ pinkOngoingVO.setId(a.getId());
|
|
|
|
+ pinkOngoingVO.setOrderId(a.getOrderId());
|
|
|
|
+ pinkOngoingVO.setSpsId(a.getSpsId());
|
|
|
|
+ pinkOngoingVO.setCid(a.getCid());
|
|
|
|
+ pinkOngoingVO.setTotalNum(a.getPeople());
|
|
|
|
+ pinkOngoingVO.setRemainNum(storePinkSummaryMap.get(a.getSpsId()).getPeopleCount());
|
|
|
|
+ pinkOngoingVO.setSuccessAvatar(storePinks.stream().map(StorePink::getAvatar).collect(Collectors.toList()));
|
|
|
|
+ return pinkOngoingVO;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ list = list.stream().sorted(Comparator.comparing(StorePinkOngoingVO::getRemainNum).reversed()).collect(Collectors.toList());
|
|
|
|
|
|
- Map<String, List<StorePink>> collect = pinkList.stream().collect(Collectors.groupingBy(StorePink::getOrderId));
|
|
|
|
- for (Map.Entry<String, List<StorePink>> entry : collect.entrySet()) {
|
|
|
|
- StorePinkOngoingVO pinkOngoingVO = new StorePinkOngoingVO();
|
|
|
|
- List<StorePink> groupList = entry.getValue();
|
|
|
|
- List<StorePink> kidCollect = groupList.stream().filter(i -> i.getKId().equals(0L)).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- if (CollectionUtils.isNotEmpty(kidCollect)) {
|
|
|
|
- pinkOngoingVO.setId(kidCollect.get(0).getId());
|
|
|
|
- pinkOngoingVO.setOrderId(entry.getKey());
|
|
|
|
- StorePink pink = groupList.get(0);
|
|
|
|
- pinkOngoingVO.setCid(pink.getCid());
|
|
|
|
- pinkOngoingVO.setTotalNum(pink.getPeople());
|
|
|
|
- pinkOngoingVO.setRemainNum(pink.getPeople() - groupList.size());
|
|
|
|
- pinkOngoingVO.setSuccessAvatar(groupList.stream().map(StorePink::getAvatar).collect(Collectors.toList()));
|
|
|
|
- list.add(pinkOngoingVO);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
- list = list.stream().sorted(Comparator.comparing(StorePinkOngoingVO::getRemainNum)).collect(Collectors.toList());
|
|
|
|
|
|
+
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|